Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-02 17:05:23 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-02 17:05:23 +0300
commit43e6bb85cee0802887eae9489a2bd73836daf41d (patch)
treeeaa106429af8341bf2123d7445fdab0af71b3dda /source
parent7daeb1f9aee284d958abe87622b43c70c21af967 (diff)
parentffaf91b5fc03f91e1fc90bd2f1d5dc5aa75656ff (diff)
Merge 'master' into 'collada'
Diffstat (limited to 'source')
-rw-r--r--source/blender/alembic/intern/abc_exporter.cc3
-rw-r--r--source/blender/alembic/intern/abc_exporter.h4
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc9
-rw-r--r--source/blender/alembic/intern/abc_object.cc23
-rw-r--r--source/blender/alembic/intern/abc_util.cc8
-rw-r--r--source/blender/alembic/intern/abc_util.h5
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc15
-rw-r--r--source/blender/avi/AVI_avi.h28
-rw-r--r--source/blender/avi/intern/avi.c84
-rw-r--r--source/blender/avi/intern/avi_codecs.c12
-rw-r--r--source/blender/avi/intern/avi_mjpeg.c27
-rw-r--r--source/blender/avi/intern/avi_options.c6
-rw-r--r--source/blender/avi/intern/avi_rgb.c6
-rw-r--r--source/blender/avi/intern/avi_rgb32.c2
-rw-r--r--source/blender/blenfont/BLF_api.h7
-rw-r--r--source/blender/blenfont/CMakeLists.txt4
-rw-r--r--source/blender/blenfont/intern/blf.c57
-rw-r--r--source/blender/blenfont/intern/blf_dir.c18
-rw-r--r--source/blender/blenfont/intern/blf_font.c114
-rw-r--r--source/blender/blenfont/intern/blf_font_win32_compat.c6
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c21
-rw-r--r--source/blender/blenfont/intern/blf_thumbs.c9
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h5
-rw-r--r--source/blender/blenkernel/BKE_action.h6
-rw-r--r--source/blender/blenkernel/BKE_animsys.h3
-rw-r--r--source/blender/blenkernel/BKE_armature.h18
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/BKE_bvhutils.h5
-rw-r--r--source/blender/blenkernel/BKE_cachefile.h27
-rw-r--r--source/blender/blenkernel/BKE_collection.h3
-rw-r--r--source/blender/blenkernel/BKE_constraint.h15
-rw-r--r--source/blender/blenkernel/BKE_customdata.h65
-rw-r--r--source/blender/blenkernel/BKE_data_transfer.h2
-rw-r--r--source/blender/blenkernel/BKE_deform.h3
-rw-r--r--source/blender/blenkernel/BKE_dynamicpaint.h2
-rw-r--r--source/blender/blenkernel/BKE_effect.h10
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h85
-rw-r--r--source/blender/blenkernel/BKE_gpencil_modifier.h4
-rw-r--r--source/blender/blenkernel/BKE_image.h3
-rw-r--r--source/blender/blenkernel/BKE_image_save.h67
-rw-r--r--source/blender/blenkernel/BKE_layer.h1
-rw-r--r--source/blender/blenkernel/BKE_library.h43
-rw-r--r--source/blender/blenkernel/BKE_library_query.h7
-rw-r--r--source/blender/blenkernel/BKE_library_remap.h45
-rw-r--r--source/blender/blenkernel/BKE_main.h20
-rw-r--r--source/blender/blenkernel/BKE_mesh.h34
-rw-r--r--source/blender/blenkernel/BKE_mesh_remap.h17
-rw-r--r--source/blender/blenkernel/BKE_modifier.h21
-rw-r--r--source/blender/blenkernel/BKE_node.h46
-rw-r--r--source/blender/blenkernel/BKE_object.h2
-rw-r--r--source/blender/blenkernel/BKE_paint.h1
-rw-r--r--source/blender/blenkernel/BKE_particle.h11
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h6
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h7
-rw-r--r--source/blender/blenkernel/BKE_rigidbody.h3
-rw-r--r--source/blender/blenkernel/BKE_scene.h1
-rw-r--r--source/blender/blenkernel/BKE_screen.h6
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h68
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h6
-rw-r--r--source/blender/blenkernel/BKE_softbody.h4
-rw-r--r--source/blender/blenkernel/BKE_sound.h5
-rw-r--r--source/blender/blenkernel/BKE_undo_system.h7
-rw-r--r--source/blender/blenkernel/BKE_unit.h2
-rw-r--r--source/blender/blenkernel/CMakeLists.txt18
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c141
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_inline.h30
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_intern.h5
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_legacy.c87
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c6
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_util.c12
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c149
-rw-r--r--source/blender/blenkernel/intern/action.c260
-rw-r--r--source/blender/blenkernel/intern/anim.c104
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c448
-rw-r--r--source/blender/blenkernel/intern/appdir.c121
-rw-r--r--source/blender/blenkernel/intern/armature.c948
-rw-r--r--source/blender/blenkernel/intern/armature_update.c88
-rw-r--r--source/blender/blenkernel/intern/blender.c8
-rw-r--r--source/blender/blenkernel/intern/blender_copybuffer.c3
-rw-r--r--source/blender/blenkernel/intern/blendfile.c36
-rw-r--r--source/blender/blenkernel/intern/boids.c148
-rw-r--r--source/blender/blenkernel/intern/bpath.c15
-rw-r--r--source/blender/blenkernel/intern/brush.c63
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c33
-rw-r--r--source/blender/blenkernel/intern/cachefile.c253
-rw-r--r--source/blender/blenkernel/intern/camera.c60
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c109
-rw-r--r--source/blender/blenkernel/intern/cloth.c135
-rw-r--r--source/blender/blenkernel/intern/collection.c37
-rw-r--r--source/blender/blenkernel/intern/collision.c77
-rw-r--r--source/blender/blenkernel/intern/colorband.c77
-rw-r--r--source/blender/blenkernel/intern/colortools.c237
-rw-r--r--source/blender/blenkernel/intern/constraint.c547
-rw-r--r--source/blender/blenkernel/intern/context.c156
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c49
-rw-r--r--source/blender/blenkernel/intern/curve.c645
-rw-r--r--source/blender/blenkernel/intern/customdata.c607
-rw-r--r--source/blender/blenkernel/intern/customdata_file.c78
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c69
-rw-r--r--source/blender/blenkernel/intern/deform.c64
-rw-r--r--source/blender/blenkernel/intern/displist.c225
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c878
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c8
-rw-r--r--source/blender/blenkernel/intern/editmesh.c25
-rw-r--r--source/blender/blenkernel/intern/editmesh_bvh.c12
-rw-r--r--source/blender/blenkernel/intern/editmesh_tangent.c28
-rw-r--r--source/blender/blenkernel/intern/effect.c66
-rw-r--r--source/blender/blenkernel/intern/fcurve.c407
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c498
-rw-r--r--source/blender/blenkernel/intern/font.c80
-rw-r--r--source/blender/blenkernel/intern/freestyle.c18
-rw-r--r--source/blender/blenkernel/intern/gpencil.c139
-rw-r--r--source/blender/blenkernel/intern/gpencil_modifier.c21
-rw-r--r--source/blender/blenkernel/intern/icons.c40
-rw-r--r--source/blender/blenkernel/intern/idcode.c6
-rw-r--r--source/blender/blenkernel/intern/idprop.c72
-rw-r--r--source/blender/blenkernel/intern/image.c771
-rw-r--r--source/blender/blenkernel/intern/image_gen.c18
-rw-r--r--source/blender/blenkernel/intern/image_save.c394
-rw-r--r--source/blender/blenkernel/intern/ipo.c493
-rw-r--r--source/blender/blenkernel/intern/key.c249
-rw-r--r--source/blender/blenkernel/intern/lattice.c237
-rw-r--r--source/blender/blenkernel/intern/layer.c20
-rw-r--r--source/blender/blenkernel/intern/library.c289
-rw-r--r--source/blender/blenkernel/intern/library_idmap.c3
-rw-r--r--source/blender/blenkernel/intern/library_override.c120
-rw-r--r--source/blender/blenkernel/intern/library_query.c88
-rw-r--r--source/blender/blenkernel/intern/library_remap.c177
-rw-r--r--source/blender/blenkernel/intern/light.c9
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c6
-rw-r--r--source/blender/blenkernel/intern/linestyle.c60
-rw-r--r--source/blender/blenkernel/intern/main.c19
-rw-r--r--source/blender/blenkernel/intern/mask.c64
-rw-r--r--source/blender/blenkernel/intern/mask_evaluate.c57
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c75
-rw-r--r--source/blender/blenkernel/intern/material.c240
-rw-r--r--source/blender/blenkernel/intern/mball.c33
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c212
-rw-r--r--source/blender/blenkernel/intern/mesh.c206
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c98
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c362
-rw-r--r--source/blender/blenkernel/intern/mesh_iterators.c3
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.c96
-rw-r--r--source/blender/blenkernel/intern/mesh_merge.c47
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c141
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c31
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c49
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c80
-rw-r--r--source/blender/blenkernel/intern/modifier.c122
-rw-r--r--source/blender/blenkernel/intern/movieclip.c165
-rw-r--r--source/blender/blenkernel/intern/multires.c282
-rw-r--r--source/blender/blenkernel/intern/nla.c439
-rw-r--r--source/blender/blenkernel/intern/node.c601
-rw-r--r--source/blender/blenkernel/intern/object.c327
-rw-r--r--source/blender/blenkernel/intern/object_deform.c35
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c126
-rw-r--r--source/blender/blenkernel/intern/object_facemap.c30
-rw-r--r--source/blender/blenkernel/intern/object_update.c17
-rw-r--r--source/blender/blenkernel/intern/ocean.c150
-rw-r--r--source/blender/blenkernel/intern/packedFile.c71
-rw-r--r--source/blender/blenkernel/intern/paint.c204
-rw-r--r--source/blender/blenkernel/intern/paint_toolslots.c1
-rw-r--r--source/blender/blenkernel/intern/particle.c722
-rw-r--r--source/blender/blenkernel/intern/particle_child.c51
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c188
-rw-r--r--source/blender/blenkernel/intern/particle_system.c688
-rw-r--r--source/blender/blenkernel/intern/pbvh.c377
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c84
-rw-r--r--source/blender/blenkernel/intern/pbvh_intern.h1
-rw-r--r--source/blender/blenkernel/intern/pointcache.c612
-rw-r--r--source/blender/blenkernel/intern/report.c51
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c234
-rw-r--r--source/blender/blenkernel/intern/scene.c206
-rw-r--r--source/blender/blenkernel/intern/screen.c92
-rw-r--r--source/blender/blenkernel/intern/seqcache.c617
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c297
-rw-r--r--source/blender/blenkernel/intern/seqmodifier.c69
-rw-r--r--source/blender/blenkernel/intern/sequencer.c844
-rw-r--r--source/blender/blenkernel/intern/shader_fx.c21
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c78
-rw-r--r--source/blender/blenkernel/intern/smoke.c369
-rw-r--r--source/blender/blenkernel/intern/softbody.c422
-rw-r--r--source/blender/blenkernel/intern/sound.c259
-rw-r--r--source/blender/blenkernel/intern/speaker.c6
-rw-r--r--source/blender/blenkernel/intern/studiolight.c85
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.c12
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c200
-rw-r--r--source/blender/blenkernel/intern/suggestions.c20
-rw-r--r--source/blender/blenkernel/intern/text.c543
-rw-r--r--source/blender/blenkernel/intern/texture.c67
-rw-r--r--source/blender/blenkernel/intern/tracking.c321
-rw-r--r--source/blender/blenkernel/intern/tracking_auto.c3
-rw-r--r--source/blender/blenkernel/intern/tracking_detect.c9
-rw-r--r--source/blender/blenkernel/intern/tracking_region_tracker.c24
-rw-r--r--source/blender/blenkernel/intern/tracking_solver.c42
-rw-r--r--source/blender/blenkernel/intern/tracking_stabilize.c51
-rw-r--r--source/blender/blenkernel/intern/tracking_util.c45
-rw-r--r--source/blender/blenkernel/intern/undo_system.c12
-rw-r--r--source/blender/blenkernel/intern/unit.c119
-rw-r--r--source/blender/blenkernel/intern/workspace.c16
-rw-r--r--source/blender/blenkernel/intern/world.c9
-rw-r--r--source/blender/blenkernel/intern/writeavi.c15
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c110
-rw-r--r--source/blender/blenkernel/nla_private.h3
-rw-r--r--source/blender/blenlib/BLI_assert.h8
-rw-r--r--source/blender/blenlib/BLI_astar.h6
-rw-r--r--source/blender/blenlib/BLI_compiler_compat.h6
-rw-r--r--source/blender/blenlib/BLI_dlrbTree.h17
-rw-r--r--source/blender/blenlib/BLI_fileops.h6
-rw-r--r--source/blender/blenlib/BLI_listbase.h4
-rw-r--r--source/blender/blenlib/BLI_math_base.h5
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h10
-rw-r--r--source/blender/blenlib/BLI_mempool.h6
-rw-r--r--source/blender/blenlib/BLI_rect.h2
-rw-r--r--source/blender/blenlib/BLI_string.h39
-rw-r--r--source/blender/blenlib/BLI_utildefines.h46
-rw-r--r--source/blender/blenlib/CMakeLists.txt2
-rw-r--r--source/blender/blenlib/PIL_time.h11
-rw-r--r--source/blender/blenlib/PIL_time_utildefines.h5
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c21
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c34
-rw-r--r--source/blender/blenlib/intern/BLI_linklist_lockfree.c6
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c17
-rw-r--r--source/blender/blenlib/intern/DLRB_tree.c2
-rw-r--r--source/blender/blenlib/intern/array_store.c15
-rw-r--r--source/blender/blenlib/intern/array_utils.c3
-rw-r--r--source/blender/blenlib/intern/astar.c33
-rw-r--r--source/blender/blenlib/intern/edgehash.c33
-rw-r--r--source/blender/blenlib/intern/expr_pylike_eval.c58
-rw-r--r--source/blender/blenlib/intern/fileops.c17
-rw-r--r--source/blender/blenlib/intern/freetypefont.c39
-rw-r--r--source/blender/blenlib/intern/hash_md5.c12
-rw-r--r--source/blender/blenlib/intern/hash_mm2a.c9
-rw-r--r--source/blender/blenlib/intern/kdtree_impl.h6
-rw-r--r--source/blender/blenlib/intern/listbase.c3
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c8
-rw-r--r--source/blender/blenlib/intern/math_color.c6
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c4
-rw-r--r--source/blender/blenlib/intern/math_geom.c103
-rw-r--r--source/blender/blenlib/intern/math_interp.c18
-rw-r--r--source/blender/blenlib/intern/math_matrix.c39
-rw-r--r--source/blender/blenlib/intern/math_solvers.c3
-rw-r--r--source/blender/blenlib/intern/math_statistics.c3
-rw-r--r--source/blender/blenlib/intern/noise.c4
-rw-r--r--source/blender/blenlib/intern/path_util.c31
-rw-r--r--source/blender/blenlib/intern/polyfill_2d_beautify.c5
-rw-r--r--source/blender/blenlib/intern/rct.c22
-rw-r--r--source/blender/blenlib/intern/smallhash.c8
-rw-r--r--source/blender/blenlib/intern/storage.c13
-rw-r--r--source/blender/blenlib/intern/string.c19
-rw-r--r--source/blender/blenlib/intern/string_utils.c12
-rw-r--r--source/blender/blenlib/intern/task.c28
-rw-r--r--source/blender/blenloader/BLO_blend_validate.h3
-rw-r--r--source/blender/blenloader/CMakeLists.txt1
-rw-r--r--source/blender/blenloader/intern/blend_validate.c14
-rw-r--r--source/blender/blenloader/intern/readblenentry.c44
-rw-r--r--source/blender/blenloader/intern/readfile.c1280
-rw-r--r--source/blender/blenloader/intern/readfile.h6
-rw-r--r--source/blender/blenloader/intern/undofile.c12
-rw-r--r--source/blender/blenloader/intern/versioning_250.c441
-rw-r--r--source/blender/blenloader/intern/versioning_260.c452
-rw-r--r--source/blender/blenloader/intern/versioning_270.c75
-rw-r--r--source/blender/blenloader/intern/versioning_280.c266
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c332
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c106
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c318
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c129
-rw-r--r--source/blender/blenloader/intern/writefile.c163
-rw-r--r--source/blender/blentranslation/BLT_lang.h4
-rw-r--r--source/blender/blentranslation/BLT_translation.h11
-rw-r--r--source/blender/blentranslation/intern/blt_lang.c45
-rw-r--r--source/blender/blentranslation/intern/blt_translation.c4
-rw-r--r--source/blender/blentranslation/msgfmt/msgfmt.c20
-rw-r--r--source/blender/bmesh/CMakeLists.txt2
-rw-r--r--source/blender/bmesh/bmesh.h43
-rw-r--r--source/blender/bmesh/bmesh_class.h63
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c15
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c30
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.c7
-rw-r--r--source/blender/bmesh/intern/bmesh_iterators_inline.h3
-rw-r--r--source/blender/bmesh/intern/bmesh_log.c18
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c193
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c54
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_validate.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_mods.c28
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c8
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c21
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon_edgenet.c12
-rw-r--r--source/blender/bmesh/intern/bmesh_private.h4
-rw-r--r--source/blender/bmesh/intern/bmesh_query.c24
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c14
-rw-r--r--source/blender/bmesh/operators/bmo_bridge.c7
-rw-r--r--source/blender/bmesh/operators/bmo_connect_pair.c9
-rw-r--r--source/blender/bmesh/operators/bmo_create.c4
-rw-r--r--source/blender/bmesh/operators/bmo_dissolve.c18
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c3
-rw-r--r--source/blender/bmesh/operators/bmo_fill_grid.c8
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c8
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c157
-rw-r--r--source/blender/bmesh/operators/bmo_join_triangles.c3
-rw-r--r--source/blender/bmesh/operators/bmo_normals.c38
-rw-r--r--source/blender/bmesh/operators/bmo_planar_faces.c6
-rw-r--r--source/blender/bmesh/operators/bmo_primitive.c34
-rw-r--r--source/blender/bmesh/operators/bmo_removedoubles.c5
-rw-r--r--source/blender/bmesh/operators/bmo_rotate_edges.c21
-rw-r--r--source/blender/bmesh/operators/bmo_smooth_laplacian.c6
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c16
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide_edgering.c6
-rw-r--r--source/blender/bmesh/operators/bmo_utils.c12
-rw-r--r--source/blender/bmesh/tools/bmesh_beautify.c30
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c341
-rw-r--r--source/blender/bmesh/tools/bmesh_bisect_plane.c3
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c5
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_dissolve.c3
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_edgesplit.c11
-rw-r--r--source/blender/bmesh/tools/bmesh_path_region.c13
-rw-r--r--source/blender/bmesh/tools/bmesh_region_match.c3
-rw-r--r--source/blender/collada/AnimationExporter.cpp60
-rw-r--r--source/blender/collada/AnimationImporter.cpp325
-rw-r--r--source/blender/collada/AnimationImporter.h3
-rw-r--r--source/blender/collada/ArmatureExporter.cpp12
-rw-r--r--source/blender/collada/ArmatureExporter.h2
-rw-r--r--source/blender/collada/ArmatureImporter.cpp174
-rw-r--r--source/blender/collada/ArmatureImporter.h8
-rw-r--r--source/blender/collada/BCAnimationCurve.cpp12
-rw-r--r--source/blender/collada/BCAnimationSampler.cpp41
-rw-r--r--source/blender/collada/BCAnimationSampler.h8
-rw-r--r--source/blender/collada/BCSampleData.cpp8
-rw-r--r--source/blender/collada/CMakeLists.txt2
-rw-r--r--source/blender/collada/ControllerExporter.cpp76
-rw-r--r--source/blender/collada/ControllerExporter.h2
-rw-r--r--source/blender/collada/DocumentExporter.cpp5
-rw-r--r--source/blender/collada/DocumentImporter.cpp184
-rw-r--r--source/blender/collada/DocumentImporter.h3
-rw-r--r--source/blender/collada/EffectExporter.cpp19
-rw-r--r--source/blender/collada/ExtraHandler.cpp13
-rw-r--r--source/blender/collada/ExtraHandler.h3
-rw-r--r--source/blender/collada/GeometryExporter.cpp80
-rw-r--r--source/blender/collada/GeometryExporter.h16
-rw-r--r--source/blender/collada/ImageExporter.cpp37
-rw-r--r--source/blender/collada/MeshImporter.cpp5
-rw-r--r--source/blender/collada/MeshImporter.h28
-rw-r--r--source/blender/collada/SceneExporter.cpp41
-rw-r--r--source/blender/collada/SkinInfo.cpp74
-rw-r--r--source/blender/collada/TransformReader.h2
-rw-r--r--source/blender/collada/TransformWriter.cpp7
-rw-r--r--source/blender/collada/collada_utils.cpp65
-rw-r--r--source/blender/collada/collada_utils.h5
-rw-r--r--source/blender/compositor/CMakeLists.txt4
-rw-r--r--source/blender/compositor/COM_compositor.h121
-rw-r--r--source/blender/compositor/COM_defines.h6
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.h3
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h4
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp6
-rw-r--r--source/blender/compositor/intern/COM_Converter.h6
-rw-r--r--source/blender/compositor/intern/COM_Debug.cpp44
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp15
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h23
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h55
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h27
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp12
-rw-r--r--source/blender/compositor/intern/COM_Node.h3
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.cpp33
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp9
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h33
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.cpp110
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.cpp12
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.cpp3
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp12
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.h7
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.h5
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.cpp3
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp9
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.cpp3
-rw-r--r--source/blender/compositor/nodes/COM_SeparateColorNode.cpp24
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.cpp24
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.cpp3
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.cpp9
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.cpp48
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.h29
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp11
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp24
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp33
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp67
-rw-r--r--source/blender/compositor/operations/COM_GlareGhostOperation.cpp45
-rw-r--r--source/blender/compositor/operations/COM_GlareStreaksOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_KeyingClipOperation.cpp15
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.cpp33
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp36
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.cpp135
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_OpenCLKernels.cl16
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp31
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp30
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp40
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp3
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cpp29
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp12
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.cpp11
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp10
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp110
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h3
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.cpp2
-rw-r--r--source/blender/datatoc/datatoc.c3
-rw-r--r--source/blender/depsgraph/CMakeLists.txt2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc97
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.h17
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cache.cc186
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cache.h103
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_cycle.cc14
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc26
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc12
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc106
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc66
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc23
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.h4
-rw-r--r--source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc12
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_debug.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_filter.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.h2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc82
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h3
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_component.cc2
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.cc1
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.h3
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_operation.cc11
-rw-r--r--source/blender/draw/CMakeLists.txt4
-rw-r--r--source/blender/draw/DRW_engine.h6
-rw-r--r--source/blender/draw/engines/basic/basic_engine.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_bloom.c37
-rw-r--r--source/blender/draw/engines/eevee/eevee_depth_of_field.c11
-rw-r--r--source/blender/draw/engines/eevee/eevee_effects.c67
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c7
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c97
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c3
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c13
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c154
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c205
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c6
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h17
-rw-r--r--source/blender/draw/engines/eevee/eevee_screen_raytrace.c5
-rw-r--r--source/blender/draw/engines/eevee/eevee_temporal_sampling.c17
-rw-r--r--source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl29
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl9
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl7
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl3
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl11
-rw-r--r--source/blender/draw/engines/eevee/shaders/ltc_lib.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl3
-rw-r--r--source/blender/draw/engines/external/external_engine.c118
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_cache_utils.c8
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c88
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_utils.c156
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c3
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h4
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_render.c18
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_shader_fx.c9
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl14
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl5
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl54
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl2
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl2
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl28
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl2
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl6
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl7
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl7
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl22
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl3
-rw-r--r--source/blender/draw/engines/workbench/workbench_deferred.c54
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_dof.c49
-rw-r--r--source/blender/draw/engines/workbench/workbench_forward.c53
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c48
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h34
-rw-r--r--source/blender/draw/engines/workbench/workbench_studiolight.c12
-rw-r--r--source/blender/draw/intern/DRW_render.h2
-rw-r--r--source/blender/draw/intern/draw_anim_viz.c5
-rw-r--r--source/blender/draw/intern/draw_armature.c91
-rw-r--r--source/blender/draw/intern/draw_cache.c220
-rw-r--r--source/blender/draw/intern/draw_cache.h1
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h23
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c8
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c439
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c15
-rw-r--r--source/blender/draw/intern/draw_common.c8
-rw-r--r--source/blender/draw/intern/draw_common.h1
-rw-r--r--source/blender/draw/intern/draw_hair.c3
-rw-r--r--source/blender/draw/intern/draw_instance_data.c10
-rw-r--r--source/blender/draw/intern/draw_manager.c216
-rw-r--r--source/blender/draw/intern/draw_manager.h21
-rw-r--r--source/blender/draw/intern/draw_manager_data.c48
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c34
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c9
-rw-r--r--source/blender/draw/intern/draw_view.c29
-rw-r--r--source/blender/draw/intern/draw_view.h2
-rw-r--r--source/blender/draw/modes/edit_armature_mode.c1
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c64
-rw-r--r--source/blender/draw/modes/edit_mesh_mode_text.c13
-rw-r--r--source/blender/draw/modes/edit_metaball_mode.c2
-rw-r--r--source/blender/draw/modes/object_mode.c47
-rw-r--r--source/blender/draw/modes/overlay_mode.c3
-rw-r--r--source/blender/draw/modes/paint_texture_mode.c2
-rw-r--r--source/blender/draw/modes/pose_mode.c16
-rw-r--r--source/blender/draw/modes/sculpt_mode.c12
-rw-r--r--source/blender/draw/modes/shaders/common_fxaa_lib.glsl8
-rw-r--r--source/blender/draw/modes/shaders/common_hair_lib.glsl4
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl36
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl12
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl31
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl14
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl23
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl12
-rw-r--r--source/blender/draw/modes/shaders/object_grid_frag.glsl4
-rw-r--r--source/blender/draw/modes/shaders/particle_strand_vert.glsl4
-rw-r--r--source/blender/draw/modes/shaders/sculpt_mask_vert.glsl3
-rw-r--r--source/blender/editors/animation/CMakeLists.txt2
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c398
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c395
-rw-r--r--source/blender/editors/animation/anim_deps.c61
-rw-r--r--source/blender/editors/animation/anim_draw.c59
-rw-r--r--source/blender/editors/animation/anim_filter.c482
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c67
-rw-r--r--source/blender/editors/animation/anim_markers.c338
-rw-r--r--source/blender/editors/animation/anim_motion_paths.c18
-rw-r--r--source/blender/editors/animation/anim_ops.c48
-rw-r--r--source/blender/editors/animation/drivers.c104
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c63
-rw-r--r--source/blender/editors/animation/keyframes_draw.c90
-rw-r--r--source/blender/editors/animation/keyframes_edit.c257
-rw-r--r--source/blender/editors/animation/keyframes_general.c129
-rw-r--r--source/blender/editors/animation/keyframing.c278
-rw-r--r--source/blender/editors/animation/keyingsets.c155
-rw-r--r--source/blender/editors/armature/CMakeLists.txt2
-rw-r--r--source/blender/editors/armature/armature_add.c106
-rw-r--r--source/blender/editors/armature/armature_edit.c97
-rw-r--r--source/blender/editors/armature/armature_intern.h12
-rw-r--r--source/blender/editors/armature/armature_naming.c43
-rw-r--r--source/blender/editors/armature/armature_ops.c11
-rw-r--r--source/blender/editors/armature/armature_relations.c147
-rw-r--r--source/blender/editors/armature/armature_select.c88
-rw-r--r--source/blender/editors/armature/armature_skinning.c44
-rw-r--r--source/blender/editors/armature/armature_utils.c97
-rw-r--r--source/blender/editors/armature/meshlaplacian.c321
-rw-r--r--source/blender/editors/armature/pose_edit.c48
-rw-r--r--source/blender/editors/armature/pose_group.c60
-rw-r--r--source/blender/editors/armature/pose_lib.c219
-rw-r--r--source/blender/editors/armature/pose_select.c81
-rw-r--r--source/blender/editors/armature/pose_slide.c145
-rw-r--r--source/blender/editors/armature/pose_transform.c167
-rw-r--r--source/blender/editors/armature/pose_utils.c74
-rw-r--r--source/blender/editors/curve/CMakeLists.txt2
-rw-r--r--source/blender/editors/curve/curve_ops.c4
-rw-r--r--source/blender/editors/curve/editcurve.c23
-rw-r--r--source/blender/editors/gizmo_library/CMakeLists.txt2
-rw-r--r--source/blender/editors/gizmo_library/gizmo_geometry.h5
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_utils.c3
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c12
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c14
-rw-r--r--source/blender/editors/gpencil/CMakeLists.txt4
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c342
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c202
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c90
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c84
-rw-r--r--source/blender/editors/gpencil/gpencil_add_stroke.c3
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c73
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c86
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c142
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c194
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c17
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_merge.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c207
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c48
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c56
-rw-r--r--source/blender/editors/gpencil/gpencil_undo.c9
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c155
-rw-r--r--source/blender/editors/include/BIF_glutil.h106
-rw-r--r--source/blender/editors/include/ED_anim_api.h6
-rw-r--r--source/blender/editors/include/ED_armature.h7
-rw-r--r--source/blender/editors/include/ED_gpencil.h2
-rw-r--r--source/blender/editors/include/ED_image.h3
-rw-r--r--source/blender/editors/include/ED_keyframing.h4
-rw-r--r--source/blender/editors/include/ED_mesh.h5
-rw-r--r--source/blender/editors/include/ED_numinput.h14
-rw-r--r--source/blender/editors/include/ED_screen.h32
-rw-r--r--source/blender/editors/include/ED_screen_types.h24
-rw-r--r--source/blender/editors/include/ED_space_api.h1
-rw-r--r--source/blender/editors/include/ED_uvedit.h1
-rw-r--r--source/blender/editors/include/ED_view3d.h19
-rw-r--r--source/blender/editors/include/UI_interface.h29
-rw-r--r--source/blender/editors/include/UI_resources.h9
-rw-r--r--source/blender/editors/include/UI_view2d.h128
-rw-r--r--source/blender/editors/interface/CMakeLists.txt3
-rw-r--r--source/blender/editors/interface/interface.c69
-rw-r--r--source/blender/editors/interface/interface_align.c38
-rw-r--r--source/blender/editors/interface/interface_context_menu.c52
-rw-r--r--source/blender/editors/interface/interface_draw.c117
-rw-r--r--source/blender/editors/interface/interface_handlers.c66
-rw-r--r--source/blender/editors/interface/interface_icons.c27
-rw-r--r--source/blender/editors/interface/interface_intern.h37
-rw-r--r--source/blender/editors/interface/interface_layout.c181
-rw-r--r--source/blender/editors/interface/interface_ops.c6
-rw-r--r--source/blender/editors/interface/interface_panel.c20
-rw-r--r--source/blender/editors/interface/interface_query.c131
-rw-r--r--source/blender/editors/interface/interface_region_color_picker.c3
-rw-r--r--source/blender/editors/interface/interface_region_hud.c10
-rw-r--r--source/blender/editors/interface/interface_region_menu_pie.c8
-rw-r--r--source/blender/editors/interface/interface_region_menu_popup.c2
-rw-r--r--source/blender/editors/interface/interface_region_popover.c11
-rw-r--r--source/blender/editors/interface/interface_region_popup.c13
-rw-r--r--source/blender/editors/interface/interface_region_search.c9
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c8
-rw-r--r--source/blender/editors/interface/interface_templates.c76
-rw-r--r--source/blender/editors/interface/interface_utils.c12
-rw-r--r--source/blender/editors/interface/interface_widgets.c29
-rw-r--r--source/blender/editors/interface/resources.c4
-rw-r--r--source/blender/editors/interface/view2d.c637
-rw-r--r--source/blender/editors/interface/view2d_draw.c526
-rw-r--r--source/blender/editors/interface/view2d_ops.c14
-rw-r--r--source/blender/editors/io/CMakeLists.txt4
-rw-r--r--source/blender/editors/io/io_alembic.c6
-rw-r--r--source/blender/editors/io/io_cache.c14
-rw-r--r--source/blender/editors/io/io_collada.c16
-rw-r--r--source/blender/editors/lattice/editlattice_select.c3
-rw-r--r--source/blender/editors/lattice/editlattice_tools.c3
-rw-r--r--source/blender/editors/lattice/editlattice_undo.c3
-rw-r--r--source/blender/editors/mask/CMakeLists.txt2
-rw-r--r--source/blender/editors/mask/mask_add.c27
-rw-r--r--source/blender/editors/mask/mask_draw.c33
-rw-r--r--source/blender/editors/mask/mask_edit.c5
-rw-r--r--source/blender/editors/mask/mask_editaction.c60
-rw-r--r--source/blender/editors/mask/mask_ops.c104
-rw-r--r--source/blender/editors/mask/mask_relationships.c2
-rw-r--r--source/blender/editors/mask/mask_select.c34
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt4
-rw-r--r--source/blender/editors/mesh/editface.c35
-rw-r--r--source/blender/editors/mesh/editmesh_add.c4
-rw-r--r--source/blender/editors/mesh/editmesh_add_gizmo.c3
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c42
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c29
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_screw.c3
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c3
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c24
-rw-r--r--source/blender/editors/mesh/editmesh_intersect.c9
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c147
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c12
-rw-r--r--source/blender/editors/mesh/editmesh_path.c46
-rw-r--r--source/blender/editors/mesh/editmesh_preselect_edgering.c3
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c48
-rw-r--r--source/blender/editors/mesh/editmesh_rip_edge.c3
-rw-r--r--source/blender/editors/mesh/editmesh_select.c76
-rw-r--r--source/blender/editors/mesh/editmesh_select_similar.c12
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c221
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c10
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c66
-rw-r--r--source/blender/editors/mesh/mesh_data.c96
-rw-r--r--source/blender/editors/mesh/mesh_mirror.c18
-rw-r--r--source/blender/editors/mesh/mesh_ops.c22
-rw-r--r--source/blender/editors/mesh/meshtools.c118
-rw-r--r--source/blender/editors/metaball/mball_edit.c2
-rw-r--r--source/blender/editors/metaball/mball_ops.c2
-rw-r--r--source/blender/editors/object/CMakeLists.txt6
-rw-r--r--source/blender/editors/object/object_add.c133
-rw-r--r--source/blender/editors/object/object_bake.c42
-rw-r--r--source/blender/editors/object/object_bake_api.c95
-rw-r--r--source/blender/editors/object/object_collection.c68
-rw-r--r--source/blender/editors/object/object_constraint.c282
-rw-r--r--source/blender/editors/object/object_data_transfer.c17
-rw-r--r--source/blender/editors/object/object_edit.c48
-rw-r--r--source/blender/editors/object/object_facemap_ops.c39
-rw-r--r--source/blender/editors/object/object_gpencil_modifier.c74
-rw-r--r--source/blender/editors/object/object_hook.c80
-rw-r--r--source/blender/editors/object/object_modes.c45
-rw-r--r--source/blender/editors/object/object_modifier.c288
-rw-r--r--source/blender/editors/object/object_ops.c4
-rw-r--r--source/blender/editors/object/object_relations.c212
-rw-r--r--source/blender/editors/object/object_select.c42
-rw-r--r--source/blender/editors/object/object_shader_fx.c60
-rw-r--r--source/blender/editors/object/object_shapekey.c15
-rw-r--r--source/blender/editors/object/object_transform.c140
-rw-r--r--source/blender/editors/object/object_utils.c2
-rw-r--r--source/blender/editors/object/object_vgroup.c180
-rw-r--r--source/blender/editors/physics/CMakeLists.txt2
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c38
-rw-r--r--source/blender/editors/physics/particle_boids.c36
-rw-r--r--source/blender/editors/physics/particle_edit.c535
-rw-r--r--source/blender/editors/physics/particle_object.c164
-rw-r--r--source/blender/editors/physics/physics_fluid.c107
-rw-r--r--source/blender/editors/physics/rigidbody_constraint.c3
-rw-r--r--source/blender/editors/physics/rigidbody_object.c9
-rw-r--r--source/blender/editors/physics/rigidbody_world.c6
-rw-r--r--source/blender/editors/render/CMakeLists.txt4
-rw-r--r--source/blender/editors/render/render_internal.c157
-rw-r--r--source/blender/editors/render/render_opengl.c57
-rw-r--r--source/blender/editors/render/render_preview.c160
-rw-r--r--source/blender/editors/render/render_shading.c60
-rw-r--r--source/blender/editors/render/render_update.c24
-rw-r--r--source/blender/editors/render/render_view.c30
-rw-r--r--source/blender/editors/scene/scene_edit.c12
-rw-r--r--source/blender/editors/screen/CMakeLists.txt3
-rw-r--r--source/blender/editors/screen/area.c291
-rw-r--r--source/blender/editors/screen/area_query.c172
-rw-r--r--source/blender/editors/screen/glutil.c212
-rw-r--r--source/blender/editors/screen/screen_context.c171
-rw-r--r--source/blender/editors/screen/screen_draw.c9
-rw-r--r--source/blender/editors/screen/screen_edit.c167
-rw-r--r--source/blender/editors/screen/screen_geometry.c160
-rw-r--r--source/blender/editors/screen/screen_intern.h3
-rw-r--r--source/blender/editors/screen/screen_ops.c611
-rw-r--r--source/blender/editors/screen/screendump.c18
-rw-r--r--source/blender/editors/screen/workspace_edit.c9
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt2
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c108
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve.c60
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c42
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c106
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c229
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c380
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_undo.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h3
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c52
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c89
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c108
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c44
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c115
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.c11
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c1
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c332
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c105
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c161
-rw-r--r--source/blender/editors/sound/sound_ops.c83
-rw-r--r--source/blender/editors/space_action/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_action/action_buttons.c24
-rw-r--r--source/blender/editors/space_action/action_data.c38
-rw-r--r--source/blender/editors/space_action/action_draw.c29
-rw-r--r--source/blender/editors/space_action/action_edit.c156
-rw-r--r--source/blender/editors/space_action/action_intern.h3
-rw-r--r--source/blender/editors/space_action/action_ops.c11
-rw-r--r--source/blender/editors/space_action/action_select.c209
-rw-r--r--source/blender/editors/space_action/space_action.c107
-rw-r--r--source/blender/editors/space_api/spacetypes.c9
-rw-r--r--source/blender/editors/space_buttons/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c20
-rw-r--r--source/blender/editors/space_clip/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c57
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c9
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_ops.c12
-rw-r--r--source/blender/editors/space_clip/clip_draw.c119
-rw-r--r--source/blender/editors/space_clip/clip_editor.c66
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c14
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c51
-rw-r--r--source/blender/editors/space_clip/clip_intern.h2
-rw-r--r--source/blender/editors/space_clip/clip_ops.c93
-rw-r--r--source/blender/editors/space_clip/clip_toolbar.c98
-rw-r--r--source/blender/editors/space_clip/clip_utils.c24
-rw-r--r--source/blender/editors/space_clip/space_clip.c139
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c6
-rw-r--r--source/blender/editors/space_clip/tracking_ops_detect.c2
-rw-r--r--source/blender/editors/space_clip/tracking_ops_intern.h4
-rw-r--r--source/blender/editors/space_clip/tracking_ops_orient.c16
-rw-r--r--source/blender/editors/space_clip/tracking_ops_plane.c26
-rw-r--r--source/blender/editors/space_clip/tracking_ops_solve.c3
-rw-r--r--source/blender/editors/space_clip/tracking_ops_track.c2
-rw-r--r--source/blender/editors/space_clip/tracking_select.c88
-rw-r--r--source/blender/editors/space_console/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_console/console_ops.c2
-rw-r--r--source/blender/editors/space_console/space_console.c9
-rw-r--r--source/blender/editors/space_file/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_file/file_draw.c9
-rw-r--r--source/blender/editors/space_file/file_ops.c110
-rw-r--r--source/blender/editors/space_file/filelist.c198
-rw-r--r--source/blender/editors/space_file/filesel.c88
-rw-r--r--source/blender/editors/space_file/fsmenu.c41
-rw-r--r--source/blender/editors/space_file/space_file.c29
-rw-r--r--source/blender/editors/space_graph/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c98
-rw-r--r--source/blender/editors/space_graph/graph_draw.c98
-rw-r--r--source/blender/editors/space_graph/graph_edit.c337
-rw-r--r--source/blender/editors/space_graph/graph_intern.h7
-rw-r--r--source/blender/editors/space_graph/graph_ops.c47
-rw-r--r--source/blender/editors/space_graph/graph_select.c228
-rw-r--r--source/blender/editors/space_graph/graph_utils.c71
-rw-r--r--source/blender/editors/space_graph/space_graph.c122
-rw-r--r--source/blender/editors/space_image/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_image/image_buttons.c259
-rw-r--r--source/blender/editors/space_image/image_draw.c4
-rw-r--r--source/blender/editors/space_image/image_intern.h4
-rw-r--r--source/blender/editors/space_image/image_ops.c600
-rw-r--r--source/blender/editors/space_image/space_image.c138
-rw-r--r--source/blender/editors/space_info/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_info/info_draw.c4
-rw-r--r--source/blender/editors/space_info/info_report.c92
-rw-r--r--source/blender/editors/space_info/space_info.c7
-rw-r--r--source/blender/editors/space_info/textview.c3
-rw-r--r--source/blender/editors/space_nla/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c80
-rw-r--r--source/blender/editors/space_nla/nla_channels.c90
-rw-r--r--source/blender/editors/space_nla/nla_draw.c30
-rw-r--r--source/blender/editors/space_nla/nla_edit.c196
-rw-r--r--source/blender/editors/space_nla/nla_intern.h3
-rw-r--r--source/blender/editors/space_nla/nla_ops.c25
-rw-r--r--source/blender/editors/space_nla/nla_select.c131
-rw-r--r--source/blender/editors/space_nla/space_nla.c91
-rw-r--r--source/blender/editors/space_node/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_node/drawnode.c16
-rw-r--r--source/blender/editors/space_node/node_add.c6
-rw-r--r--source/blender/editors/space_node/node_buttons.c32
-rw-r--r--source/blender/editors/space_node/node_draw.c7
-rw-r--r--source/blender/editors/space_node/node_edit.c18
-rw-r--r--source/blender/editors/space_node/node_group.c12
-rw-r--r--source/blender/editors/space_node/node_intern.h15
-rw-r--r--source/blender/editors/space_node/node_ops.c3
-rw-r--r--source/blender/editors/space_node/node_relationships.c4
-rw-r--r--source/blender/editors/space_node/node_select.c33
-rw-r--r--source/blender/editors/space_node/node_toolbar.c34
-rw-r--r--source/blender/editors/space_node/space_node.c60
-rw-r--r--source/blender/editors/space_outliner/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c13
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c147
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c38
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h5
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c40
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c30
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c236
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c8
-rw-r--r--source/blender/editors/space_script/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_script/space_script.c9
-rw-r--r--source/blender/editors/space_sequencer/CMakeLists.txt4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c20
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c27
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c231
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c46
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c47
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c44
-rw-r--r--source/blender/editors/space_statusbar/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_text/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_text/space_text.c22
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c70
-rw-r--r--source/blender/editors/space_text/text_draw.c225
-rw-r--r--source/blender/editors/space_text/text_format.c15
-rw-r--r--source/blender/editors/space_text/text_format_lua.c137
-rw-r--r--source/blender/editors/space_text/text_format_osl.c172
-rw-r--r--source/blender/editors/space_text/text_format_pov.c1245
-rw-r--r--source/blender/editors/space_text/text_format_pov_ini.c523
-rw-r--r--source/blender/editors/space_text/text_format_py.c110
-rw-r--r--source/blender/editors/space_text/text_header.c63
-rw-r--r--source/blender/editors/space_text/text_intern.h2
-rw-r--r--source/blender/editors/space_text/text_ops.c399
-rw-r--r--source/blender/editors/space_topbar/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c4
-rw-r--r--source/blender/editors/space_view3d/CMakeLists.txt5
-rw-r--r--source/blender/editors/space_view3d/drawobject.c45
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c124
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c39
-rw-r--r--source/blender/editors/space_view3d/view3d_camera_control.c9
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c30
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c50
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c17
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_armature.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_navigate.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h6
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_project.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c20
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c67
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c21
-rw-r--r--source/blender/editors/transform/CMakeLists.txt4
-rw-r--r--source/blender/editors/transform/transform.c809
-rw-r--r--source/blender/editors/transform/transform.h5
-rw-r--r--source/blender/editors/transform/transform_constraints.c84
-rw-r--r--source/blender/editors/transform/transform_conversions.c1074
-rw-r--r--source/blender/editors/transform/transform_generics.c297
-rw-r--r--source/blender/editors/transform/transform_gizmo_2d.c6
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c41
-rw-r--r--source/blender/editors/transform/transform_input.c6
-rw-r--r--source/blender/editors/transform/transform_ops.c27
-rw-r--r--source/blender/editors/transform/transform_orientations.c33
-rw-r--r--source/blender/editors/transform/transform_snap.c116
-rw-r--r--source/blender/editors/transform/transform_snap_object.c14
-rw-r--r--source/blender/editors/undo/CMakeLists.txt2
-rw-r--r--source/blender/editors/undo/ed_undo.c14
-rw-r--r--source/blender/editors/undo/memfile_undo.c6
-rw-r--r--source/blender/editors/util/CMakeLists.txt4
-rw-r--r--source/blender/editors/util/ed_transverts.c27
-rw-r--r--source/blender/editors/util/ed_util.c32
-rw-r--r--source/blender/editors/util/numinput.c3
-rw-r--r--source/blender/editors/util/select_utils.c4
-rw-r--r--source/blender/editors/uvedit/CMakeLists.txt2
-rw-r--r--source/blender/editors/uvedit/uvedit_buttons.c11
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c20
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c471
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c466
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c89
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c229
-rw-r--r--source/blender/freestyle/intern/application/AppCanvas.cpp28
-rw-r--r--source/blender/freestyle/intern/application/AppView.h4
-rw-r--r--source/blender/freestyle/intern/application/Controller.cpp40
-rw-r--r--source/blender/freestyle/intern/application/Controller.h42
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp10
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h5
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp5
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp7
-rw-r--r--source/blender/freestyle/intern/geometry/FastGrid.h8
-rw-r--r--source/blender/freestyle/intern/geometry/FitCurve.cpp9
-rw-r--r--source/blender/freestyle/intern/geometry/GeomCleaner.h44
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.cpp34
-rw-r--r--source/blender/freestyle/intern/geometry/GeomUtils.h6
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.cpp26
-rw-r--r--source/blender/freestyle/intern/geometry/Grid.h40
-rw-r--r--source/blender/freestyle/intern/geometry/GridHelpers.cpp13
-rw-r--r--source/blender/freestyle/intern/geometry/GridHelpers.h4
-rw-r--r--source/blender/freestyle/intern/geometry/Polygon.h4
-rw-r--r--source/blender/freestyle/intern/geometry/SweepLine.h12
-rw-r--r--source/blender/freestyle/intern/geometry/VecMat.h24
-rw-r--r--source/blender/freestyle/intern/geometry/matrix_util.h26
-rw-r--r--source/blender/freestyle/intern/image/GaussianFilter.h23
-rw-r--r--source/blender/freestyle/intern/image/Image.h13
-rw-r--r--source/blender/freestyle/intern/image/ImagePyramid.cpp6
-rw-r--r--source/blender/freestyle/intern/image/ImagePyramid.h2
-rw-r--r--source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp4
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp6
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h3
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h3
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp20
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp20
-rw-r--r--source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h6
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h6
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h3
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h3
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h12
-rw-r--r--source/blender/freestyle/intern/scene_graph/Node.h3
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeCamera.cpp2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeCamera.h2
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp3
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h3
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.cpp10
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.h3
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeTransform.cpp2
-rw-r--r--source/blender/freestyle/intern/scene_graph/Rep.cpp3
-rw-r--r--source/blender/freestyle/intern/scene_graph/Rep.h7
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h8
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h50
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h12
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp20
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h50
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.cpp18
-rw-r--r--source/blender/freestyle/intern/stroke/Canvas.h10
-rw-r--r--source/blender/freestyle/intern/stroke/Chain.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.cpp5
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.h92
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.cpp56
-rw-r--r--source/blender/freestyle/intern/stroke/Curve.h42
-rw-r--r--source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h15
-rw-r--r--source/blender/freestyle/intern/stroke/CurveIterators.h6
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.cpp28
-rw-r--r--source/blender/freestyle/intern/stroke/Operators.h116
-rw-r--r--source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates0D.h4
-rw-r--r--source/blender/freestyle/intern/stroke/Predicates1D.h13
-rw-r--r--source/blender/freestyle/intern/stroke/QInformationMap.h2
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp31
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h37
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h6
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeIterators.h23
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRenderer.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.cpp44
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.h5
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeShader.h15
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeTesselator.cpp2
-rw-r--r--source/blender/freestyle/intern/system/PointerSequence.h26
-rw-r--r--source/blender/freestyle/intern/system/PythonInterpreter.h2
-rw-r--r--source/blender/freestyle/intern/system/StringUtils.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/BoxGrid.h31
-rw-r--r--source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp53
-rw-r--r--source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp42
-rw-r--r--source/blender/freestyle/intern/view_map/FEdgeXDetector.h9
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.cpp2
-rw-r--r--source/blender/freestyle/intern/view_map/Functions0D.h59
-rw-r--r--source/blender/freestyle/intern/view_map/Functions1D.h28
-rw-r--r--source/blender/freestyle/intern/view_map/GridDensityProvider.h3
-rw-r--r--source/blender/freestyle/intern/view_map/Interface0D.h21
-rw-r--r--source/blender/freestyle/intern/view_map/Interface1D.h42
-rw-r--r--source/blender/freestyle/intern/view_map/Silhouette.cpp20
-rw-r--r--source/blender/freestyle/intern/view_map/Silhouette.h96
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp10
-rw-r--r--source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h4
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/SphericalGrid.h50
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.cpp33
-rw-r--r--source/blender/freestyle/intern/view_map/SteerableViewMap.h26
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp18
-rw-r--r--source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h9
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.cpp24
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMap.h132
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h23
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp179
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapBuilder.h34
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIO.cpp6
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapIterators.h24
-rw-r--r--source/blender/freestyle/intern/view_map/ViewMapTesselator.h22
-rw-r--r--source/blender/freestyle/intern/winged_edge/Curvature.cpp79
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.cpp26
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.h77
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.cpp20
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.h74
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp6
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h4
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp16
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h4
-rw-r--r--source/blender/gpencil_modifiers/CMakeLists.txt6
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c3
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c19
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c6
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c3
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c3
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c6
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c6
-rw-r--r--source/blender/gpu/CMakeLists.txt2
-rw-r--r--source/blender/gpu/GPU_batch.h6
-rw-r--r--source/blender/gpu/GPU_buffers.h3
-rw-r--r--source/blender/gpu/GPU_immediate.h7
-rw-r--r--source/blender/gpu/GPU_legacy_stubs.h4
-rw-r--r--source/blender/gpu/GPU_matrix.h3
-rw-r--r--source/blender/gpu/GPU_shader.h9
-rw-r--r--source/blender/gpu/GPU_vertex_format.h7
-rw-r--r--source/blender/gpu/GPU_viewport.h1
-rw-r--r--source/blender/gpu/intern/gpu_attr_binding.c3
-rw-r--r--source/blender/gpu/intern/gpu_batch.c48
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c1432
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c306
-rw-r--r--source/blender/gpu/intern/gpu_context.cpp3
-rw-r--r--source/blender/gpu/intern/gpu_debug.c3
-rw-r--r--source/blender/gpu/intern/gpu_draw.c144
-rw-r--r--source/blender/gpu/intern/gpu_element.c9
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c6
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c44
-rw-r--r--source/blender/gpu/intern/gpu_immediate.c13
-rw-r--r--source/blender/gpu/intern/gpu_init_exit.c9
-rw-r--r--source/blender/gpu/intern/gpu_material.c18
-rw-r--r--source/blender/gpu/intern/gpu_matrix.c59
-rw-r--r--source/blender/gpu/intern/gpu_select.c11
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c19
-rw-r--r--source/blender/gpu/intern/gpu_select_private.h2
-rw-r--r--source/blender/gpu/intern/gpu_shader.c124
-rw-r--r--source/blender/gpu/intern/gpu_texture.c109
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.c19
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c15
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl10
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl3
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl7
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl30
-rw-r--r--source/blender/ikplugin/BIK_api.h15
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c6
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp45
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h3
-rw-r--r--source/blender/imbuf/IMB_imbuf.h39
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h2
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c151
-rw-r--r--source/blender/imbuf/intern/anim_movie.c79
-rw-r--r--source/blender/imbuf/intern/bmp.c22
-rw-r--r--source/blender/imbuf/intern/cache.c42
-rw-r--r--source/blender/imbuf/intern/cineon/cineon_dpx.c24
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c66
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c102
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.c348
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.h45
-rw-r--r--source/blender/imbuf/intern/cineon/logmemfile.c27
-rw-r--r--source/blender/imbuf/intern/colormanagement.c244
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.cpp21
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.h24
-rw-r--r--source/blender/imbuf/intern/dds/Color.h17
-rw-r--r--source/blender/imbuf/intern/dds/ColorBlock.cpp154
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp205
-rw-r--r--source/blender/imbuf/intern/dds/FlipDXT.cpp9
-rw-r--r--source/blender/imbuf/intern/dds/Image.cpp3
-rw-r--r--source/blender/imbuf/intern/dds/Image.h4
-rw-r--r--source/blender/imbuf/intern/dds/PixelFormat.h32
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp30
-rw-r--r--source/blender/imbuf/intern/divers.c104
-rw-r--r--source/blender/imbuf/intern/filetype.c12
-rw-r--r--source/blender/imbuf/intern/filter.c101
-rw-r--r--source/blender/imbuf/intern/imageprocess.c39
-rw-r--r--source/blender/imbuf/intern/indexer.c24
-rw-r--r--source/blender/imbuf/intern/iris.c54
-rw-r--r--source/blender/imbuf/intern/jp2.c72
-rw-r--r--source/blender/imbuf/intern/jpeg.c31
-rw-r--r--source/blender/imbuf/intern/moviecache.c89
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.cpp38
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp303
-rw-r--r--source/blender/imbuf/intern/png.c68
-rw-r--r--source/blender/imbuf/intern/radiance_hdr.c54
-rw-r--r--source/blender/imbuf/intern/readimage.c57
-rw-r--r--source/blender/imbuf/intern/rectop.c123
-rw-r--r--source/blender/imbuf/intern/rotate.c6
-rw-r--r--source/blender/imbuf/intern/scaling.c183
-rw-r--r--source/blender/imbuf/intern/stereoimbuf.c24
-rw-r--r--source/blender/imbuf/intern/targa.c162
-rw-r--r--source/blender/imbuf/intern/thumbs.c14
-rw-r--r--source/blender/imbuf/intern/thumbs_blend.c5
-rw-r--r--source/blender/imbuf/intern/tiff.c123
-rw-r--r--source/blender/imbuf/intern/util.c60
-rw-r--r--source/blender/imbuf/intern/writeimage.c3
-rw-r--r--source/blender/makesdna/DNA_ID.h27
-rw-r--r--source/blender/makesdna/DNA_action_types.h35
-rw-r--r--source/blender/makesdna/DNA_anim_types.h11
-rw-r--r--source/blender/makesdna/DNA_armature_types.h7
-rw-r--r--source/blender/makesdna/DNA_boid_types.h12
-rw-r--r--source/blender/makesdna/DNA_brush_types.h15
-rw-r--r--source/blender/makesdna/DNA_cachefile_types.h12
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h5
-rw-r--r--source/blender/makesdna/DNA_curve_types.h4
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h19
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h2
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h7
-rw-r--r--source/blender/makesdna/DNA_light_types.h4
-rw-r--r--source/blender/makesdna/DNA_material_types.h16
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h3
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h21
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h5
-rw-r--r--source/blender/makesdna/DNA_node_types.h56
-rw-r--r--source/blender/makesdna/DNA_object_enums.h9
-rw-r--r--source/blender/makesdna/DNA_object_force_types.h11
-rw-r--r--source/blender/makesdna/DNA_object_types.h12
-rw-r--r--source/blender/makesdna/DNA_rigidbody_types.h2
-rw-r--r--source/blender/makesdna/DNA_scene_types.h33
-rw-r--r--source/blender/makesdna/DNA_screen_types.h16
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h42
-rw-r--r--source/blender/makesdna/DNA_smoke_types.h8
-rw-r--r--source/blender/makesdna/DNA_space_types.h42
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h19
-rw-r--r--source/blender/makesdna/DNA_vec_types.h9
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h12
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h31
-rw-r--r--source/blender/makesdna/DNA_world_types.h4
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt2
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c55
-rw-r--r--source/blender/makesdna/intern/dna_rename_defs.h15
-rw-r--r--source/blender/makesdna/intern/makesdna.c8
-rw-r--r--source/blender/makesrna/RNA_access.h6
-rw-r--r--source/blender/makesrna/RNA_define.h14
-rw-r--r--source/blender/makesrna/RNA_documentation.h3
-rw-r--r--source/blender/makesrna/RNA_enum_types.h9
-rw-r--r--source/blender/makesrna/RNA_types.h55
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt8
-rw-r--r--source/blender/makesrna/intern/makesrna.c974
-rw-r--r--source/blender/makesrna/intern/rna_ID.c6
-rw-r--r--source/blender/makesrna/intern/rna_access.c1033
-rw-r--r--source/blender/makesrna/intern/rna_action.c18
-rw-r--r--source/blender/makesrna/intern/rna_animation.c50
-rw-r--r--source/blender/makesrna/intern/rna_animviz.c13
-rw-r--r--source/blender/makesrna/intern/rna_armature.c111
-rw-r--r--source/blender/makesrna/intern/rna_boid.c26
-rw-r--r--source/blender/makesrna/intern/rna_brush.c19
-rw-r--r--source/blender/makesrna/intern/rna_cachefile.c38
-rw-r--r--source/blender/makesrna/intern/rna_camera.c5
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c3
-rw-r--r--source/blender/makesrna/intern/rna_collection.c11
-rw-r--r--source/blender/makesrna/intern/rna_color.c18
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c37
-rw-r--r--source/blender/makesrna/intern/rna_context.c7
-rw-r--r--source/blender/makesrna/intern/rna_curve.c8
-rw-r--r--source/blender/makesrna/intern/rna_define.c545
-rw-r--r--source/blender/makesrna/intern/rna_depsgraph.c10
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c55
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c21
-rw-r--r--source/blender/makesrna/intern/rna_fcurve_api.c3
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c6
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c8
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c5
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c36
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h18
-rw-r--r--source/blender/makesrna/intern/rna_key.c12
-rw-r--r--source/blender/makesrna/intern/rna_main.c3
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_mask.c2
-rw-r--r--source/blender/makesrna/intern/rna_material.c21
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c23
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c97
-rw-r--r--source/blender/makesrna/intern/rna_nla.c33
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c79
-rw-r--r--source/blender/makesrna/intern/rna_object.c78
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c17
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c18
-rw-r--r--source/blender/makesrna/intern/rna_particle.c11
-rw-r--r--source/blender/makesrna/intern/rna_pose.c15
-rw-r--r--source/blender/makesrna/intern/rna_rigidbody.c24
-rw-r--r--source/blender/makesrna/intern/rna_rna.c116
-rw-r--r--source/blender/makesrna/intern/rna_scene.c365
-rw-r--r--source/blender/makesrna/intern/rna_screen.c15
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c9
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c105
-rw-r--r--source/blender/makesrna/intern/rna_shader_fx.c3
-rw-r--r--source/blender/makesrna/intern/rna_space.c291
-rw-r--r--source/blender/makesrna/intern/rna_text.c4
-rw-r--r--source/blender/makesrna/intern/rna_texture.c3
-rw-r--r--source/blender/makesrna/intern/rna_ui.c11
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c53
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c108
-rw-r--r--source/blender/makesrna/intern/rna_wm.c20
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_wm_gizmo.c4
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c18
-rw-r--r--source/blender/modifiers/CMakeLists.txt6
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c26
-rw-r--r--source/blender/modifiers/intern/MOD_array.c35
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c46
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c3
-rw-r--r--source/blender/modifiers/intern/MOD_build.c3
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c60
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c27
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c3
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c3
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c4
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c6
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c5
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c3
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c21
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c6
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c21
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c9
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c17
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c9
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c72
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c28
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c15
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c263
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c8
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c57
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c23
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c66
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c15
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c3
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c15
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c184
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c6
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c36
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c35
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c2
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c12
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c6
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c2
-rw-r--r--source/blender/modifiers/intern/MOD_util.c18
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c20
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c6
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c6
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c6
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.c210
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c14
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.h16
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c33
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c46
-rw-r--r--source/blender/nodes/CMakeLists.txt2
-rw-r--r--source/blender/nodes/NOD_common.h6
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c144
-rw-r--r--source/blender/nodes/composite/node_composite_util.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bilateralblur.c6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehimage.c1
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorbalance.c3
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_common.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_cryptomatte.c9
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c33
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c50
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_moviedistortion.c12
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_outputFile.c26
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_scale.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c12
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c12
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_switchview.c26
-rw-r--r--source/blender/nodes/intern/node_common.c166
-rw-r--r--source/blender/nodes/intern/node_exec.c66
-rw-r--r--source/blender/nodes/intern/node_exec.h7
-rw-r--r--source/blender/nodes/intern/node_socket.c24
-rw-r--r--source/blender/nodes/intern/node_util.c39
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c38
-rw-r--r--source/blender/nodes/shader/node_shader_util.c66
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c8
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_common.c23
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_invert.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mapping.c24
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c124
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c15
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_particle_info.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_script.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c11
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c9
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c95
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectTransform.c18
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c63
-rw-r--r--source/blender/nodes/texture/node_texture_util.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_common.c11
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_compose.c3
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_curves.c3
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_hueSatVal.c18
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_image.c18
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_math.c61
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_mixRgb.c3
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_output.c21
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_proc.c12
-rw-r--r--source/blender/physics/CMakeLists.txt2
-rw-r--r--source/blender/physics/intern/BPH_mass_spring.cpp75
-rw-r--r--source/blender/physics/intern/ConstrainedConjugateGradient.h163
-rw-r--r--source/blender/physics/intern/eigen_utils.h5
-rw-r--r--source/blender/physics/intern/hair_volume.cpp132
-rw-r--r--source/blender/physics/intern/implicit_blender.c78
-rw-r--r--source/blender/physics/intern/implicit_eigen.cpp24
-rw-r--r--source/blender/python/bmesh/CMakeLists.txt2
-rw-r--r--source/blender/python/bmesh/bmesh_py_ops_call.c3
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c35
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_meshdata.c2
-rw-r--r--source/blender/python/generic/CMakeLists.txt4
-rw-r--r--source/blender/python/generic/bgl.c35
-rw-r--r--source/blender/python/generic/bpy_internal_import.c375
-rw-r--r--source/blender/python/generic/bpy_internal_import.h50
-rw-r--r--source/blender/python/generic/idprop_py_api.c15
-rw-r--r--source/blender/python/generic/py_capi_utils.c12
-rw-r--r--source/blender/python/generic/python_utildefines.h3
-rw-r--r--source/blender/python/gpu/CMakeLists.txt2
-rw-r--r--source/blender/python/gpu/gpu_py_batch.c3
-rw-r--r--source/blender/python/gpu/gpu_py_matrix.c9
-rw-r--r--source/blender/python/intern/CMakeLists.txt1
-rw-r--r--source/blender/python/intern/bpy.c41
-rw-r--r--source/blender/python/intern/bpy_app_ocio.c10
-rw-r--r--source/blender/python/intern/bpy_app_translations.c22
-rw-r--r--source/blender/python/intern/bpy_capi_utils.c7
-rw-r--r--source/blender/python/intern/bpy_driver.c16
-rw-r--r--source/blender/python/intern/bpy_gizmo_wrap.c5
-rw-r--r--source/blender/python/intern/bpy_interface.c54
-rw-r--r--source/blender/python/intern/bpy_operator.c13
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c8
-rw-r--r--source/blender/python/intern/bpy_props.c14
-rw-r--r--source/blender/python/intern/bpy_rna.c147
-rw-r--r--source/blender/python/intern/bpy_rna.h11
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c8
-rw-r--r--source/blender/python/intern/bpy_rna_array.c21
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c19
-rw-r--r--source/blender/python/intern/bpy_rna_id_collection.c44
-rw-r--r--source/blender/python/intern/bpy_utils_units.c12
-rw-r--r--source/blender/python/intern/stubs.c5
-rw-r--r--source/blender/python/mathutils/CMakeLists.txt2
-rw-r--r--source/blender/python/mathutils/mathutils.c18
-rw-r--r--source/blender/python/mathutils/mathutils.h25
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c3
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.c2
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c7
-rw-r--r--source/blender/python/mathutils/mathutils_geometry.c8
-rw-r--r--source/blender/render/CMakeLists.txt6
-rw-r--r--source/blender/render/extern/include/RE_pipeline.h22
-rw-r--r--source/blender/render/intern/include/render_types.h7
-rw-r--r--source/blender/render/intern/include/texture.h6
-rw-r--r--source/blender/render/intern/source/bake_api.c66
-rw-r--r--source/blender/render/intern/source/external_engine.c87
-rw-r--r--source/blender/render/intern/source/imagetexture.c360
-rw-r--r--source/blender/render/intern/source/initrender.c60
-rw-r--r--source/blender/render/intern/source/multires_bake.c138
-rw-r--r--source/blender/render/intern/source/pipeline.c221
-rw-r--r--source/blender/render/intern/source/pointdensity.c66
-rw-r--r--source/blender/render/intern/source/render_result.c243
-rw-r--r--source/blender/render/intern/source/render_texture.c211
-rw-r--r--source/blender/render/intern/source/zbuf.c48
-rw-r--r--source/blender/shader_fx/CMakeLists.txt6
-rw-r--r--source/blender/windowmanager/CMakeLists.txt2
-rw-r--r--source/blender/windowmanager/WM_api.h14
-rw-r--r--source/blender/windowmanager/WM_keymap.h6
-rw-r--r--source/blender/windowmanager/WM_types.h10
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo.c3
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c18
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c29
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c468
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c206
-rw-r--r--source/blender/windowmanager/intern/wm_files.c86
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c30
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c27
-rw-r--r--source/blender/windowmanager/intern/wm_gesture_ops.c18
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c25
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c29
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c268
-rw-r--r--source/blender/windowmanager/intern/wm_keymap_utils.c3
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c7
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c8
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c80
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c2
-rw-r--r--source/blender/windowmanager/intern/wm_stereo.c5
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c97
-rw-r--r--source/blender/windowmanager/intern/wm_window.c17
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c5
-rw-r--r--source/blender/windowmanager/wm_cursors.h2
-rw-r--r--source/blender/windowmanager/wm_event_system.h5
-rw-r--r--source/blender/windowmanager/wm_event_types.h3
-rw-r--r--source/creator/CMakeLists.txt8
-rw-r--r--source/creator/creator.c4
-rw-r--r--source/creator/creator_args.c16
1505 files changed, 55286 insertions, 34750 deletions
diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc
index 4a7f26d2e18..e39b5686c82 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -158,7 +158,8 @@ static bool export_object(const ExportSettings *const settings,
if (settings->selected_only && !BASE_SELECTED(v3d, base)) {
return false;
}
- // FIXME Sybren: handle these cleanly (maybe just remove code), now using active scene layer instead.
+ // FIXME Sybren: handle these cleanly (maybe just remove code),
+ // now using active scene layer instead.
if (settings->visible_layers_only && !BASE_VISIBLE(v3d, base)) {
return false;
}
diff --git a/source/blender/alembic/intern/abc_exporter.h b/source/blender/alembic/intern/abc_exporter.h
index 6ed6a97f935..e6a7a3fc7f4 100644
--- a/source/blender/alembic/intern/abc_exporter.h
+++ b/source/blender/alembic/intern/abc_exporter.h
@@ -43,8 +43,8 @@ struct ExportSettings {
ExportSettings();
Scene *scene;
- ViewLayer *
- view_layer; // Scene layer to export; all its objects will be exported, unless selected_only=true
+ /** Scene layer to export; all its objects will be exported, unless selected_only=true. */
+ ViewLayer *view_layer;
Depsgraph *depsgraph;
SimpleLogger logger;
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 5ccb9be02a3..34d7e8847b1 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -373,8 +373,9 @@ void AbcGenericMeshWriter::setIsAnimated(bool is_animated)
void AbcGenericMeshWriter::do_write()
{
/* We have already stored a sample for this object. */
- if (!m_first_frame && !m_is_animated)
+ if (!m_first_frame && !m_is_animated) {
return;
+ }
bool needsfree;
struct Mesh *mesh = getFinalMesh(needsfree);
@@ -387,12 +388,14 @@ void AbcGenericMeshWriter::do_write()
writeMesh(mesh);
}
- if (needsfree)
+ if (needsfree) {
freeEvaluatedMesh(mesh);
+ }
}
catch (...) {
- if (needsfree)
+ if (needsfree) {
freeEvaluatedMesh(mesh);
+ }
throw;
}
}
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index dddd985d796..e437273c1be 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -273,7 +273,15 @@ Alembic::AbcGeom::IXform AbcObjectReader::xform()
{
/* Check that we have an empty object (locator, bone head/tail...). */
if (IXform::matches(m_iobject.getMetaData())) {
- return IXform(m_iobject, Alembic::AbcGeom::kWrapExisting);
+ try {
+ return IXform(m_iobject, Alembic::AbcGeom::kWrapExisting);
+ }
+ catch (Alembic::Util::Exception &ex) {
+ printf("Alembic: error reading object transform for '%s': %s\n",
+ m_iobject.getFullName().c_str(),
+ ex.what());
+ return IXform();
+ }
}
/* Check that we have an object with actual data, in which case the
@@ -282,7 +290,15 @@ Alembic::AbcGeom::IXform AbcObjectReader::xform()
/* The archive's top object can be recognised by not having a parent. */
if (abc_parent.getParent() && IXform::matches(abc_parent.getMetaData())) {
- return IXform(abc_parent, Alembic::AbcGeom::kWrapExisting);
+ try {
+ return IXform(abc_parent, Alembic::AbcGeom::kWrapExisting);
+ }
+ catch (Alembic::Util::Exception &ex) {
+ printf("Alembic: error reading object transform for '%s': %s\n",
+ abc_parent.getFullName().c_str(),
+ ex.what());
+ return IXform();
+ }
}
/* This can happen in certain cases. For example, MeshLab exports
@@ -348,9 +364,6 @@ void AbcObjectReader::addCacheModifier()
id_us_plus(&mcmd->cache_file->id);
BLI_strncpy(mcmd->object_path, m_iobject.getFullName().c_str(), FILE_MAX);
-
- mcmd->reader = reinterpret_cast<CacheReader *>(this);
- this->incref();
}
chrono_t AbcObjectReader::minTime() const
diff --git a/source/blender/alembic/intern/abc_util.cc b/source/blender/alembic/intern/abc_util.cc
index 380ceff80cf..2fc340f73ce 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -160,7 +160,8 @@ void create_swapped_rotation_matrix(float rot_x_mat[3][3],
rot_z_mat[1][1] = cos(rz);
}
-/* Convert matrix from Z=up to Y=up or vice versa. Use yup_mat = zup_mat for in-place conversion. */
+/* Convert matrix from Z=up to Y=up or vice versa.
+ * Use yup_mat = zup_mat for in-place conversion. */
void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode)
{
float dst_rot[3][3], src_rot[3][3], dst_scale_mat[4][4];
@@ -378,11 +379,6 @@ ScopeTimer::~ScopeTimer()
/* ********************** */
-bool SimpleLogger::empty()
-{
- return ((size_t)m_stream.tellp()) == 0ul;
-}
-
std::string SimpleLogger::str() const
{
return m_stream.str();
diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h
index 44ad4bca2f7..f7f662212fd 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -210,11 +210,6 @@ class SimpleLogger {
public:
/**
- * Check whether or not the SimpleLogger's stream is empty.
- */
- bool empty();
-
- /**
* Return a copy of the string contained in the SimpleLogger's stream.
*/
std::string str() const;
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 0bc4eb2385b..b502692d0e5 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -290,8 +290,9 @@ static void export_endjob(void *customdata)
BLI_delete(data->filename, false, false);
}
- if (!data->settings.logger.empty()) {
- std::cerr << data->settings.logger;
+ std::string log = data->settings.logger.str();
+ if (!log.empty()) {
+ std::cerr << log;
WM_report(RPT_ERROR, "Errors occurred during the export, look in the console to know more...");
}
@@ -626,6 +627,7 @@ struct ImportJobData {
char filename[1024];
ImportSettings settings;
+ ArchiveReader *archive;
std::vector<AbcObjectReader *> readers;
short *stop;
@@ -671,9 +673,9 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
cache_file->is_sequence = data->settings.is_sequence;
cache_file->scale = data->settings.scale;
- cache_file->handle = handle_from_archive(archive);
- BLI_strncpy(cache_file->filepath, data->filename, 1024);
+ STRNCPY(cache_file->filepath, data->filename);
+ data->archive = archive;
data->settings.cache_file = cache_file;
*data->do_update = true;
@@ -787,8 +789,9 @@ static void import_endjob(void *user_data)
/* It's possible that cancellation occurred between the creation of
* the reader and the creation of the Blender object. */
- if (ob == NULL)
+ if (ob == NULL) {
continue;
+ }
BKE_id_free_us(data->bmain, ob);
}
@@ -853,6 +856,7 @@ static void import_endjob(void *user_data)
static void import_freejob(void *user_data)
{
ImportJobData *data = static_cast<ImportJobData *>(user_data);
+ delete data->archive;
delete data;
}
@@ -884,6 +888,7 @@ bool ABC_import(bContext *C,
job->settings.validate_meshes = validate_meshes;
job->error_code = ABC_NO_ERROR;
job->was_cancelled = false;
+ job->archive = NULL;
G.is_break = false;
diff --git a/source/blender/avi/AVI_avi.h b/source/blender/avi/AVI_avi.h
index 86f0189343e..e14d947f5dd 100644
--- a/source/blender/avi/AVI_avi.h
+++ b/source/blender/avi/AVI_avi.h
@@ -63,12 +63,18 @@ typedef struct _AviMainHeader {
int MaxBytesPerSec; /* MaxBytesPerSec - approx bps system must handle */
int PaddingGranularity;
int Flags;
-#define AVIF_HASINDEX 0x00000010 /* had idx1 chunk */
-#define AVIF_MUSTUSEINDEX 0x00000020 /* must use idx1 chunk to determine order */
-#define AVIF_ISINTERLEAVED 0x00000100 /* AVI file is interleaved */
+
+ /** had idx1 chunk */
+#define AVIF_HASINDEX 0x00000010
+ /** must use idx1 chunk to determine order */
+#define AVIF_MUSTUSEINDEX 0x00000020
+ /** AVI file is interleaved */
+#define AVIF_ISINTERLEAVED 0x00000100
#define AVIF_TRUSTCKTYPE 0x00000800
-#define AVIF_WASCAPTUREFILE 0x00010000 /* specially allocated used for capturing real time video */
-#define AVIF_COPYRIGHTED 0x00020000 /* contains copyrighted data */
+ /** specially allocated used for capturing real time video */
+#define AVIF_WASCAPTUREFILE 0x00010000
+ /** contains copyrighted data */
+#define AVIF_COPYRIGHTED 0x00020000
int TotalFrames;
int InitialFrames; /* InitialFrames - initial frame before interleaving */
@@ -153,10 +159,14 @@ typedef struct _AviIndex {
} AviIndex;
typedef enum {
- AVI_FORMAT_RGB24, /* The most basic of forms, 3 bytes per pixel, 1 per r, g, b */
- AVI_FORMAT_RGB32, /* The second most basic of forms, 4 bytes per pixel, 1 per r, g, b, alpha */
- AVI_FORMAT_AVI_RGB, /* Same as above, but is in the weird AVI order (bottom to top, left to right) */
- AVI_FORMAT_MJPEG, /* Motion-JPEG */
+ /** The most basic of forms, 3 bytes per pixel, 1 per r, g, b. */
+ AVI_FORMAT_RGB24,
+ /** The second most basic of forms, 4 bytes per pixel, 1 per r, g, b, alpha. */
+ AVI_FORMAT_RGB32,
+ /** Same as above, but is in the weird AVI order (bottom to top, left to right). */
+ AVI_FORMAT_AVI_RGB,
+ /** Motion-JPEG. */
+ AVI_FORMAT_MJPEG,
} AviFormat;
typedef struct _AviStreamRec {
diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c
index 1f55f6ce557..22eb0be0cc0 100644
--- a/source/blender/avi/intern/avi.c
+++ b/source/blender/avi/intern/avi.c
@@ -107,15 +107,18 @@ int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num)
{
int cur_stream;
- if (movie == NULL)
+ if (movie == NULL) {
return -AVI_ERROR_OPTION;
+ }
for (cur_stream = 0; cur_stream < movie->header->Streams; cur_stream++) {
if (movie->streams[cur_stream].sh.Type == avist_type) {
- if (stream_num == 0)
+ if (stream_num == 0) {
return cur_stream;
- else
+ }
+ else {
stream_num--;
+ }
}
}
@@ -143,10 +146,12 @@ static bool fcc_is_data(int fcc)
fccs[2] = fcc >> 16;
fccs[3] = fcc >> 24;
- if (!isdigit(fccs[0]) || !isdigit(fccs[1]) || (fccs[2] != 'd' && fccs[2] != 'w'))
+ if (!isdigit(fccs[0]) || !isdigit(fccs[1]) || (fccs[2] != 'd' && fccs[2] != 'w')) {
return 0;
- if (fccs[3] != 'b' && fccs[3] != 'c')
+ }
+ if (fccs[3] != 'b' && fccs[3] != 'c') {
return 0;
+ }
return 1;
}
@@ -155,10 +160,12 @@ AviError AVI_print_error(AviError in_error)
{
int error;
- if ((int)in_error < 0)
+ if ((int)in_error < 0) {
error = -in_error;
- else
+ }
+ else {
error = in_error;
+ }
switch (error) {
case AVI_ERROR_NONE:
@@ -208,8 +215,9 @@ bool AVI_is_avi(const char *name)
movie.fp = BLI_fopen(name, "rb");
movie.offset_table = NULL;
- if (movie.fp == NULL)
+ if (movie.fp == NULL) {
return 0;
+ }
if (GET_FCC(movie.fp) != FCC("RIFF") || !(movie.size = GET_FCC(movie.fp))) {
fclose(movie.fp);
@@ -353,8 +361,9 @@ bool AVI_is_avi(const char *name)
}
}
}
- if (j > 0)
+ if (j > 0) {
fseek(movie.fp, j, SEEK_CUR);
+ }
}
else {
fseek(movie.fp, movie.streams[temp].sf_size, SEEK_CUR);
@@ -395,8 +404,9 @@ AviError AVI_open_movie(const char *name, AviMovie *movie)
movie->fp = BLI_fopen(name, "rb");
movie->offset_table = NULL;
- if (movie->fp == NULL)
+ if (movie->fp == NULL) {
return AVI_ERROR_OPEN;
+ }
if (GET_FCC(movie->fp) != FCC("RIFF") || !(movie->size = GET_FCC(movie->fp))) {
return AVI_ERROR_FORMAT;
@@ -529,8 +539,9 @@ AviError AVI_open_movie(const char *name, AviMovie *movie)
}
}
}
- if (j > 0)
+ if (j > 0) {
fseek(movie->fp, j, SEEK_CUR);
+ }
}
else {
fseek(movie->fp, movie->streams[temp].sf_size, SEEK_CUR);
@@ -553,14 +564,17 @@ AviError AVI_open_movie(const char *name, AviMovie *movie)
temp = GET_FCC(movie->fp);
size = GET_FCC(movie->fp);
- if (size == 0)
+ if (size == 0) {
break;
+ }
if (temp == FCC("LIST")) {
- if (GET_FCC(movie->fp) == FCC("movi"))
+ if (GET_FCC(movie->fp) == FCC("movi")) {
break;
- else
+ }
+ else {
fseek(movie->fp, size - 4, SEEK_CUR);
+ }
}
else {
fseek(movie->fp, size, SEEK_CUR);
@@ -615,8 +629,9 @@ AviError AVI_open_movie(const char *name, AviMovie *movie)
* Note the offset needs an extra 4 bytes for some
* undetermined reason */
- if (movie->entries[0].Offset == movie->movi_offset)
+ if (movie->entries[0].Offset == movie->movi_offset) {
movie->read_offset = 4;
+ }
}
DEBUG_PRINT("movie successfully opened\n");
@@ -650,8 +665,9 @@ void *AVI_read_frame(AviMovie *movie, AviFormat format, int frame, int stream)
}
}
- if (cur_frame != frame)
+ if (cur_frame != frame) {
return NULL;
+ }
fseek(movie->fp, movie->read_offset + movie->entries[i - 1].Offset, SEEK_SET);
@@ -684,10 +700,12 @@ AviError AVI_close(AviMovie *movie)
MEM_freeN(movie->header);
MEM_freeN(movie->streams);
- if (movie->entries != NULL)
+ if (movie->entries != NULL) {
MEM_freeN(movie->entries);
- if (movie->offset_table != NULL)
+ }
+ if (movie->offset_table != NULL) {
MEM_freeN(movie->offset_table);
+ }
return AVI_ERROR_NONE;
}
@@ -707,13 +725,15 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...)
movie->index_entries = 0;
- if (movie->fp == NULL)
+ if (movie->fp == NULL) {
return AVI_ERROR_OPEN;
+ }
movie->offset_table = (int64_t *)MEM_mallocN((1 + streams * 2) * sizeof(int64_t), "offsettable");
- for (i = 0; i < 1 + streams * 2; i++)
+ for (i = 0; i < 1 + streams * 2; i++) {
movie->offset_table[i] = -1L;
+ }
movie->entries = NULL;
@@ -852,8 +872,9 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...)
awrite(movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK);
- for (i = 0; i < chunk.size; i++)
+ for (i = 0; i < chunk.size; i++) {
putc(0, movie->fp);
+ }
}
header_pos2 = ftell(movie->fp);
@@ -885,8 +906,9 @@ AviError AVI_write_frame(AviMovie *movie, int frame_num, ...)
AviFormat format;
void *buffer;
- if (frame_num < 0)
+ if (frame_num < 0) {
return AVI_ERROR_OPTION;
+ }
/* Allocate the new memory for the index entry */
@@ -930,8 +952,9 @@ AviError AVI_write_frame(AviMovie *movie, int frame_num, ...)
chunk.fcc = avi_get_data_id(format, stream);
chunk.size = size;
- if (size % 4)
+ if (size % 4) {
chunk.size += 4 - size % 4;
+ }
awrite(movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK);
@@ -947,8 +970,9 @@ AviError AVI_write_frame(AviMovie *movie, int frame_num, ...)
awrite(movie, buffer, 1, size, movie->fp, AVI_RAW);
MEM_freeN(buffer);
- if (size % 4)
+ if (size % 4) {
awrite(movie, &tbuf, 1, 4 - size % 4, movie->fp, AVI_RAW);
+ }
/* Update the stream headers length field */
movie->streams[stream].sh.Length++;
@@ -995,8 +1019,9 @@ AviError AVI_close_compress(AviMovie *movie)
PUT_FCC("idx1", movie->fp);
PUT_FCCN((movie->index_entries * (movie->header->Streams + 1) * 16), movie->fp);
- for (temp = 0; temp < movie->index_entries * (movie->header->Streams + 1); temp++)
+ for (temp = 0; temp < movie->index_entries * (movie->header->Streams + 1); temp++) {
awrite(movie, &movie->entries[temp], 1, sizeof(AviIndexEntry), movie->fp, AVI_INDEXE);
+ }
temp = (int)ftell(movie->fp);
@@ -1018,11 +1043,14 @@ AviError AVI_close_compress(AviMovie *movie)
MEM_freeN(movie->header);
- if (movie->entries != NULL)
+ if (movie->entries != NULL) {
MEM_freeN(movie->entries);
- if (movie->streams != NULL)
+ }
+ if (movie->streams != NULL) {
MEM_freeN(movie->streams);
- if (movie->offset_table != NULL)
+ }
+ if (movie->offset_table != NULL) {
MEM_freeN(movie->offset_table);
+ }
return AVI_ERROR_NONE;
}
diff --git a/source/blender/avi/intern/avi_codecs.c b/source/blender/avi/intern/avi_codecs.c
index 705ca1e41e1..15f498ac653 100644
--- a/source/blender/avi/intern/avi_codecs.c
+++ b/source/blender/avi/intern/avi_codecs.c
@@ -33,8 +33,9 @@
void *avi_format_convert(
AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, size_t *size)
{
- if (from == to)
+ if (from == to) {
return buffer;
+ }
if (from != AVI_FORMAT_RGB24 && to != AVI_FORMAT_RGB24) {
return avi_format_convert(
@@ -82,12 +83,15 @@ int avi_get_data_id(AviFormat format, int stream)
{
char fcc[5];
- if (avi_get_format_type(format) == FCC("vids"))
+ if (avi_get_format_type(format) == FCC("vids")) {
sprintf(fcc, "%2.2ddc", stream);
- else if (avi_get_format_type(format) == FCC("auds"))
+ }
+ else if (avi_get_format_type(format) == FCC("auds")) {
sprintf(fcc, "%2.2ddc", stream);
- else
+ }
+ else {
return 0;
+ }
return FCC(fcc);
}
diff --git a/source/blender/avi/intern/avi_mjpeg.c b/source/blender/avi/intern/avi_mjpeg.c
index 28743619c04..d4c7378964e 100644
--- a/source/blender/avi/intern/avi_mjpeg.c
+++ b/source/blender/avi/intern/avi_mjpeg.c
@@ -47,8 +47,9 @@ static void add_huff_table(j_decompress_ptr dinfo,
const UINT8 *bits,
const UINT8 *val)
{
- if (*htblptr == NULL)
+ if (*htblptr == NULL) {
*htblptr = jpeg_alloc_huff_table((j_common_ptr)dinfo);
+ }
memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
memcpy((*htblptr)->huffval, val, sizeof((*htblptr)->huffval));
@@ -237,8 +238,9 @@ static int Decode_JPEG(unsigned char *inBuffer,
}
jpeg_finish_decompress(&dinfo);
- if (dinfo.output_height >= height)
+ if (dinfo.output_height >= height) {
return 0;
+ }
inBuffer += numbytes;
jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize - numbytes);
@@ -306,14 +308,16 @@ static void Compress_JPEG(int quality,
marker[i++] = 'I';
marker[i++] = '1';
marker[i++] = 0;
- while (i < 60)
+ while (i < 60) {
marker[i++] = 32;
+ }
jpeg_write_marker(&cinfo, JPEG_APP0, marker, 60);
i = 0;
- while (i < 60)
+ while (i < 60) {
marker[i++] = 0;
+ }
jpeg_write_marker(&cinfo, JPEG_COM, marker, 60);
@@ -331,10 +335,12 @@ static void interlace(unsigned char *to, unsigned char *from, int width, int hei
size_t i, rowstride = width * 3;
for (i = 0; i < height; i++) {
- if (i & 1)
+ if (i & 1) {
memcpy(&to[i * rowstride], &from[(i / 2 + height / 2) * rowstride], rowstride);
- else
+ }
+ else {
memcpy(&to[i * rowstride], &from[(i / 2) * rowstride], rowstride);
+ }
}
}
@@ -343,10 +349,12 @@ static void deinterlace(int odd, unsigned char *to, unsigned char *from, int wid
size_t i, rowstride = width * 3;
for (i = 0; i < height; i++) {
- if ((i & 1) == odd)
+ if ((i & 1) == odd) {
memcpy(&to[(i / 2 + height / 2) * rowstride], &from[i * rowstride], rowstride);
- else
+ }
+ else {
memcpy(&to[(i / 2) * rowstride], &from[i * rowstride], rowstride);
+ }
}
}
@@ -507,8 +515,9 @@ static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo)
static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt)
{
- if (dinfo->src->bytes_in_buffer < skipcnt)
+ if (dinfo->src->bytes_in_buffer < skipcnt) {
skipcnt = dinfo->src->bytes_in_buffer;
+ }
dinfo->src->next_input_byte += skipcnt;
dinfo->src->bytes_in_buffer -= skipcnt;
diff --git a/source/blender/avi/intern/avi_options.c b/source/blender/avi/intern/avi_options.c
index d491f3bb2d0..4f7e26c874c 100644
--- a/source/blender/avi/intern/avi_options.c
+++ b/source/blender/avi/intern/avi_options.c
@@ -43,8 +43,9 @@ AviError AVI_set_compress_option(
(void)stream; /* unused */
if (movie->header->TotalFrames !=
- 0) /* Can't change params after we have already started writing frames */
+ 0) { /* Can't change params after we have already started writing frames */
return AVI_ERROR_OPTION;
+ }
switch (option_type) {
case AVI_OPTION_TYPE_MAIN:
@@ -112,8 +113,9 @@ AviError AVI_set_compress_option(
case AVI_OPTION_FRAMERATE:
useconds = (int)(1000000 / (*((double *)opt_data)));
- if (useconds)
+ if (useconds) {
movie->header->MicroSecPerFrame = useconds;
+ }
for (i = 0; i < movie->header->Streams; i++) {
if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) {
diff --git a/source/blender/avi/intern/avi_rgb.c b/source/blender/avi/intern/avi_rgb.c
index 8d81b561403..d449556e79b 100644
--- a/source/blender/avi/intern/avi_rgb.c
+++ b/source/blender/avi/intern/avi_rgb.c
@@ -44,8 +44,9 @@ void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buf
(void)size; /* unused */
bi = (AviBitmapInfoHeader *)movie->streams[stream].sf;
- if (bi)
+ if (bi) {
bits = bi->BitCount;
+ }
if (bits == 16) {
unsigned short *pxl;
@@ -96,8 +97,9 @@ void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buf
if (buf) {
size_t rowstride = movie->header->Width * 3;
- if ((bits != 16) && (movie->header->Width % 2))
+ if ((bits != 16) && (movie->header->Width % 2)) {
rowstride++;
+ }
for (size_t y = 0; y < movie->header->Height; y++) {
memcpy(&buf[y * movie->header->Width * 3],
diff --git a/source/blender/avi/intern/avi_rgb32.c b/source/blender/avi/intern/avi_rgb32.c
index fae255d65ba..3efa4814c70 100644
--- a/source/blender/avi/intern/avi_rgb32.c
+++ b/source/blender/avi/intern/avi_rgb32.c
@@ -71,7 +71,7 @@ void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer,
*size = (size_t)movie->header->Height * (size_t)movie->header->Width * 4;
buf = imb_alloc_pixels(
- movie->header->Height, movie->header->Width, 3, sizeof(unsigned char), "torgb32buf");
+ movie->header->Height, movie->header->Width, 4, sizeof(unsigned char), "torgb32buf");
if (!buf) {
return NULL;
}
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index bf5ecd24269..448bb0d621a 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -53,6 +53,9 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
void BLF_unload(const char *name) ATTR_NONNULL();
void BLF_unload_id(int fontid);
+/* Check if font supports a particular glyph. */
+bool BLF_has_glyph(int fontid, unsigned int unicode);
+
/* Attach a file with metrics information from memory. */
void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size);
@@ -198,8 +201,8 @@ void BLF_buffer(int fontid,
/* Set the color to be used for text. */
void BLF_buffer_col(int fontid, const float rgba[4]) ATTR_NONNULL(2);
-/* Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_
- * it's not necessary set both buffer, NULL is valid here.
+/* Draw the string into the buffer, this function draw in both buffer,
+ * float and unsigned char _BUT_ it's not necessary set both buffer, NULL is valid here.
*/
void BLF_draw_buffer_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
ATTR_NONNULL(2);
diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt
index e16ff10c76d..ba8697a44b6 100644
--- a/source/blender/blenfont/CMakeLists.txt
+++ b/source/blender/blenfont/CMakeLists.txt
@@ -25,11 +25,11 @@ set(INC
../blentranslation
../editors/include
../gpu
+ ../imbuf
../makesdna
../makesrna
- ../imbuf
- ../../../intern/guardedalloc
../../../intern/glew-mx
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 0da96226143..793e9805899 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -86,8 +86,9 @@ int blf_mono_font_render = -1;
static FontBLF *blf_get(int fontid)
{
- if (fontid >= 0 && fontid < BLF_MAX_FONT)
+ if (fontid >= 0 && fontid < BLF_MAX_FONT) {
return global_font[fontid];
+ }
return NULL;
}
@@ -95,8 +96,9 @@ int BLF_init(void)
{
int i;
- for (i = 0; i < BLF_MAX_FONT; i++)
+ for (i = 0; i < BLF_MAX_FONT; i++) {
global_font[i] = NULL;
+ }
global_font_points = 11;
global_font_dpi = 72;
@@ -151,8 +153,9 @@ static int blf_search(const char *name)
for (i = 0; i < BLF_MAX_FONT; i++) {
font = global_font[i];
- if (font && (STREQ(font->name, name)))
+ if (font && (STREQ(font->name, name))) {
return i;
+ }
}
return -1;
@@ -162,9 +165,11 @@ static int blf_search_available(void)
{
int i;
- for (i = 0; i < BLF_MAX_FONT; i++)
- if (!global_font[i])
+ for (i = 0; i < BLF_MAX_FONT; i++) {
+ if (!global_font[i]) {
return i;
+ }
+ }
return -1;
}
@@ -183,6 +188,15 @@ int BLF_default(void)
return global_font_default;
}
+bool BLF_has_glyph(int fontid, unsigned int unicode)
+{
+ FontBLF *font = blf_get(fontid);
+ if (font) {
+ return FT_Get_Char_Index(font->face, unicode) != 0;
+ }
+ return false;
+}
+
int BLF_load(const char *name)
{
FontBLF *font;
@@ -378,26 +392,32 @@ void BLF_position(int fontid, float x, float y, float z)
remainder = x - floorf(x);
if (remainder > 0.4f && remainder < 0.6f) {
- if (remainder < 0.5f)
+ if (remainder < 0.5f) {
x -= 0.1f * xa;
- else
+ }
+ else {
x += 0.1f * xa;
+ }
}
remainder = y - floorf(y);
if (remainder > 0.4f && remainder < 0.6f) {
- if (remainder < 0.5f)
+ if (remainder < 0.5f) {
y -= 0.1f * ya;
- else
+ }
+ else {
y += 0.1f * ya;
+ }
}
remainder = z - floorf(z);
if (remainder > 0.4f && remainder < 0.6f) {
- if (remainder < 0.5f)
+ if (remainder < 0.5f) {
z -= 0.1f * za;
- else
+ }
+ else {
z += 0.1f * za;
+ }
}
font->pos[0] = x;
@@ -554,27 +574,32 @@ static void blf_draw_gl__start(FontBLF *font)
/* always bind the texture for the first glyph */
font->tex_bind_state = 0;
- if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) == 0)
+ if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) == 0) {
return; /* glyphs will be translated individually and batched. */
+ }
GPU_matrix_push();
- if (font->flags & BLF_MATRIX)
+ if (font->flags & BLF_MATRIX) {
GPU_matrix_mul(font->m);
+ }
GPU_matrix_translate_3fv(font->pos);
- if (font->flags & BLF_ASPECT)
+ if (font->flags & BLF_ASPECT) {
GPU_matrix_scale_3fv(font->aspect);
+ }
- if (font->flags & BLF_ROTATION)
+ if (font->flags & BLF_ROTATION) {
GPU_matrix_rotate_2d(RAD2DEG(font->angle));
+ }
}
static void blf_draw_gl__end(FontBLF *font)
{
- if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) != 0)
+ if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) != 0) {
GPU_matrix_pop();
+ }
}
void BLF_draw_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info)
diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c
index 89378dc6181..204be5a86b2 100644
--- a/source/blender/blenfont/intern/blf_dir.c
+++ b/source/blender/blenfont/intern/blf_dir.c
@@ -55,8 +55,9 @@ static DirBLF *blf_dir_find(const char *path)
p = global_font_dir.first;
while (p) {
- if (BLI_path_cmp(p->path, path) == 0)
+ if (BLI_path_cmp(p->path, path) == 0) {
return p;
+ }
p = p->next;
}
return NULL;
@@ -67,8 +68,9 @@ void BLF_dir_add(const char *path)
DirBLF *dir;
dir = blf_dir_find(path);
- if (dir) /* already in the list ? just return. */
+ if (dir) { /* already in the list ? just return. */
return;
+ }
dir = (DirBLF *)MEM_callocN(sizeof(DirBLF), "BLF_dir_add");
dir->path = BLI_strdup(path);
@@ -95,8 +97,9 @@ char **BLF_dir_get(int *ndir)
int i, count;
count = BLI_listbase_count(&global_font_dir);
- if (!count)
+ if (!count) {
return NULL;
+ }
dirs = (char **)MEM_callocN(sizeof(char *) * count, "BLF_dir_get");
p = global_font_dir.first;
@@ -138,8 +141,9 @@ char *blf_dir_search(const char *file)
if (!s) {
/* check the current directory, why not ? */
- if (BLI_exists(file))
+ if (BLI_exists(file)) {
s = BLI_strdup(file);
+ }
}
return s;
@@ -166,14 +170,16 @@ char *blf_dir_metrics_search(const char *filename)
s[2] = 'm';
/* first check .afm */
- if (BLI_exists(mfile))
+ if (BLI_exists(mfile)) {
return mfile;
+ }
/* and now check .pfm */
s[0] = 'p';
- if (BLI_exists(mfile))
+ if (BLI_exists(mfile)) {
return mfile;
+ }
}
MEM_freeN(mfile);
return NULL;
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index ae406b103a7..7283ade3ae5 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -173,8 +173,9 @@ void blf_batch_draw_begin(FontBLF *font)
void blf_batch_draw(void)
{
- if (g_batch.glyph_len == 0)
+ if (g_batch.glyph_len == 0) {
return;
+ }
GPU_blend(true);
GPU_blend_set_func_separate(
@@ -235,8 +236,9 @@ void blf_font_size(FontBLF *font, unsigned int size, unsigned int dpi)
if (gc) {
font->glyph_cache = gc;
/* Optimization: do not call FT_Set_Char_Size if size did not change. */
- if (font->size == size && font->dpi == dpi)
+ if (font->size == size && font->dpi == dpi) {
return;
+ }
}
err = FT_Set_Char_Size(font->face, 0, (FT_F26Dot6)(size * 64), dpi, dpi);
@@ -251,10 +253,12 @@ void blf_font_size(FontBLF *font, unsigned int size, unsigned int dpi)
if (!gc) {
gc = blf_glyph_cache_new(font);
- if (gc)
+ if (gc) {
font->glyph_cache = gc;
- else
+ }
+ else {
font->glyph_cache = NULL;
+ }
}
}
@@ -371,12 +375,15 @@ static void blf_font_draw_ex(
while ((i < len) && str[i]) {
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
- if (UNLIKELY(c == BLI_UTF8_ERR))
+ if (UNLIKELY(c == BLI_UTF8_ERR)) {
break;
- if (UNLIKELY(g == NULL))
+ }
+ if (UNLIKELY(g == NULL)) {
continue;
- if (has_kerning)
+ }
+ if (has_kerning) {
BLF_KERNING_STEP_FAST(font, kern_mode, g_prev, g, c_prev, c, pen_x);
+ }
/* do not return this loop if clipped, we want every character tested */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
@@ -416,10 +423,12 @@ static void blf_font_draw_ascii_ex(
while ((c = *(str++)) && len--) {
BLI_assert(c < 128);
- if ((g = glyph_ascii_table[c]) == NULL)
+ if ((g = glyph_ascii_table[c]) == NULL) {
continue;
- if (has_kerning)
+ }
+ if (has_kerning) {
BLF_KERNING_STEP_FAST(font, kern_mode, g_prev, g, c_prev, c, pen_x);
+ }
/* do not return this loop if clipped, we want every character tested */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
@@ -458,17 +467,20 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
while ((i < len) && str[i]) {
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
- if (UNLIKELY(c == BLI_UTF8_ERR))
+ if (UNLIKELY(c == BLI_UTF8_ERR)) {
break;
- if (UNLIKELY(g == NULL))
+ }
+ if (UNLIKELY(g == NULL)) {
continue;
+ }
/* do not return this loop if clipped, we want every character tested */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
col = BLI_wcwidth((wchar_t)c);
- if (col < 0)
+ if (col < 0) {
col = 1;
+ }
columns += col;
pen_x += cwidth * col;
@@ -507,12 +519,15 @@ static void blf_font_draw_buffer_ex(
while ((i < len) && str[i]) {
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
- if (UNLIKELY(c == BLI_UTF8_ERR))
+ if (UNLIKELY(c == BLI_UTF8_ERR)) {
break;
- if (UNLIKELY(g == NULL))
+ }
+ if (UNLIKELY(g == NULL)) {
continue;
- if (has_kerning)
+ }
+ if (has_kerning) {
BLF_KERNING_STEP_FAST(font, kern_mode, g_prev, g, c_prev, c, pen_x);
+ }
chx = pen_x + ((int)g->pos_x);
chy = pen_y_basis + g->height;
@@ -531,10 +546,12 @@ static void blf_font_draw_buffer_ex(
int height_clip = g->height;
int yb_start = g->pitch < 0 ? 0 : g->height - 1;
- if (width_clip + chx > buf_info->w)
+ if (width_clip + chx > buf_info->w) {
width_clip -= chx + width_clip - buf_info->w;
- if (height_clip + pen_y > buf_info->h)
+ }
+ if (height_clip + pen_y > buf_info->h) {
height_clip -= pen_y + height_clip - buf_info->h;
+ }
/* drawing below the image? */
if (pen_y < 0) {
@@ -570,10 +587,12 @@ static void blf_font_draw_buffer_ex(
}
}
- if (g->pitch < 0)
+ if (g->pitch < 0) {
yb++;
- else
+ }
+ else {
yb--;
+ }
}
}
@@ -606,10 +625,12 @@ static void blf_font_draw_buffer_ex(
}
}
- if (g->pitch < 0)
+ if (g->pitch < 0) {
yb++;
- else
+ }
+ else {
yb--;
+ }
}
}
}
@@ -762,27 +783,34 @@ static void blf_font_boundbox_ex(
while ((i < len) && str[i]) {
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
- if (UNLIKELY(c == BLI_UTF8_ERR))
+ if (UNLIKELY(c == BLI_UTF8_ERR)) {
break;
- if (UNLIKELY(g == NULL))
+ }
+ if (UNLIKELY(g == NULL)) {
continue;
- if (has_kerning)
+ }
+ if (has_kerning) {
BLF_KERNING_STEP_FAST(font, kern_mode, g_prev, g, c_prev, c, pen_x);
+ }
gbox.xmin = (float)pen_x;
gbox.xmax = (float)pen_x + g->advance;
gbox.ymin = g->box.ymin + (float)pen_y;
gbox.ymax = g->box.ymax + (float)pen_y;
- if (gbox.xmin < box->xmin)
+ if (gbox.xmin < box->xmin) {
box->xmin = gbox.xmin;
- if (gbox.ymin < box->ymin)
+ }
+ if (gbox.ymin < box->ymin) {
box->ymin = gbox.ymin;
+ }
- if (gbox.xmax > box->xmax)
+ if (gbox.xmax > box->xmax) {
box->xmax = gbox.xmax;
- if (gbox.ymax > box->ymax)
+ }
+ if (gbox.ymax > box->ymax) {
box->ymax = gbox.ymax;
+ }
pen_x += g->advance_i;
g_prev = g;
@@ -854,12 +882,15 @@ static void blf_font_wrap_apply(
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
- if (UNLIKELY(c == BLI_UTF8_ERR))
+ if (UNLIKELY(c == BLI_UTF8_ERR)) {
break;
- if (UNLIKELY(g == NULL))
+ }
+ if (UNLIKELY(g == NULL)) {
continue;
- if (has_kerning)
+ }
+ if (has_kerning) {
BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
+ }
/**
* Implementation Detail (utf8).
@@ -998,10 +1029,12 @@ float blf_font_width(FontBLF *font, const char *str, size_t len, struct ResultBL
float xa;
rctf box;
- if (font->flags & BLF_ASPECT)
+ if (font->flags & BLF_ASPECT) {
xa = font->aspect[0];
- else
+ }
+ else {
xa = 1.0f;
+ }
if (font->flags & BLF_WORD_WRAP) {
blf_font_boundbox__wrap(font, str, len, &box, r_info);
@@ -1017,10 +1050,12 @@ float blf_font_height(FontBLF *font, const char *str, size_t len, struct ResultB
float ya;
rctf box;
- if (font->flags & BLF_ASPECT)
+ if (font->flags & BLF_ASPECT) {
ya = font->aspect[1];
- else
+ }
+ else {
ya = 1.0f;
+ }
if (font->flags & BLF_WORD_WRAP) {
blf_font_boundbox__wrap(font, str, len, &box, r_info);
@@ -1084,10 +1119,12 @@ void blf_font_free(FontBLF *font)
blf_kerning_cache_clear(font);
FT_Done_Face(font->face);
- if (font->filename)
+ if (font->filename) {
MEM_freeN(font->filename);
- if (font->name)
+ }
+ if (font->name) {
MEM_freeN(font->name);
+ }
MEM_freeN(font);
}
@@ -1100,8 +1137,9 @@ static void blf_font_fill(FontBLF *font)
font->pos[1] = 0.0f;
font->angle = 0.0f;
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++) {
font->m[i] = 0;
+ }
/* annoying bright color so we can see where to add BLF_color calls */
font->color[0] = 255;
diff --git a/source/blender/blenfont/intern/blf_font_win32_compat.c b/source/blender/blenfont/intern/blf_font_win32_compat.c
index c609d67ece1..e73df4dbfc7 100644
--- a/source/blender/blenfont/intern/blf_font_win32_compat.c
+++ b/source/blender/blenfont/intern/blf_font_win32_compat.c
@@ -59,13 +59,15 @@ static unsigned long ft_ansi_stream_io(FT_Stream stream,
unsigned long count)
{
FILE *file;
- if (!count && offset > stream->size)
+ if (!count && offset > stream->size) {
return 1;
+ }
file = STREAM_FILE(stream);
- if (stream->pos != offset)
+ if (stream->pos != offset) {
fseek(file, offset, SEEK_SET);
+ }
return fread(buffer, 1, count, file);
}
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 8f9db604434..049af7678d5 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -63,8 +63,9 @@ KerningCacheBLF *blf_kerning_cache_find(FontBLF *font)
p = (KerningCacheBLF *)font->kerning_caches.first;
while (p) {
- if (p->mode == font->kerning_mode)
+ if (p->mode == font->kerning_mode) {
return p;
+ }
p = p->next;
}
return NULL;
@@ -120,8 +121,9 @@ GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, unsigned int size, unsigned i
p = (GlyphCacheBLF *)font->cache.first;
while (p) {
- if (p->size == size && p->dpi == dpi)
+ if (p->size == size && p->dpi == dpi) {
return p;
+ }
p = p->next;
}
return NULL;
@@ -254,8 +256,9 @@ GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c)
key = blf_hash(c);
p = gc->bucket[key].first;
while (p) {
- if (p->c == c)
+ if (p->c == c) {
return p;
+ }
p = p->next;
}
return NULL;
@@ -271,8 +274,9 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
unsigned int key;
g = blf_glyph_search(font->glyph_cache, c);
- if (g)
+ if (g) {
return g;
+ }
/* glyphs are dynamically created as needed by font rendering. this means that
* to make font rendering thread safe we have to do locking here. note that this
@@ -388,8 +392,9 @@ void blf_glyph_free(GlyphBLF *g)
/* don't need free the texture, the GlyphCache already
* have a list of all the texture and free it.
*/
- if (g->bitmap)
+ if (g->bitmap) {
MEM_freeN(g->bitmap);
+ }
MEM_freeN(g);
}
@@ -480,14 +485,16 @@ static void blf_glyph_calc_rect_shadow(rctf *rect, GlyphBLF *g, float x, float y
void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
{
- if ((!g->width) || (!g->height))
+ if ((!g->width) || (!g->height)) {
return;
+ }
if (g->build_tex == 0) {
GlyphCacheBLF *gc = font->glyph_cache;
- if (font->tex_size_max == -1)
+ if (font->tex_size_max == -1) {
font->tex_size_max = GPU_max_texture_size();
+ }
if (gc->texture_current == BLF_TEXTURE_UNSET) {
blf_glyph_cache_texture(font, gc);
diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c
index f2036d2e4e9..802f97fc5f5 100644
--- a/source/blender/blenfont/intern/blf_thumbs.c
+++ b/source/blender/blenfont/intern/blf_thumbs.c
@@ -97,8 +97,9 @@ void BLF_thumb_preview(const char *filename,
blf_font_size(font, (unsigned int)MAX2(font_size_min, font_size_curr), dpi);
/* font->glyph_cache remains NULL if blf_font_size() failed to set font size */
- if (!font->glyph_cache)
+ if (!font->glyph_cache) {
break;
+ }
/* decrease font size each time */
font_size_curr -= (font_size_curr / font_shrink);
@@ -106,9 +107,9 @@ void BLF_thumb_preview(const char *filename,
font->pos[1] -= font->glyph_cache->ascender * 1.1f;
- /* We fallback to default english strings in case not enough chars are available in current font for given
- * translated string (useful in non-latin i18n context, like chinese, since many fonts will then show
- * nothing but ugly 'missing char' in their preview).
+ /* We fallback to default english strings in case not enough chars are available in current
+ * font for given translated string (useful in non-latin i18n context, like chinese,
+ * since many fonts will then show nothing but ugly 'missing char' in their preview).
* Does not handle all cases, but much better than nothing.
*/
if (blf_font_count_missing_chars(font, draw_str_i18n, draw_str_i18n_len, &draw_str_i18n_nbr) >
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 4fc519ecd6d..f835f4332ed 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -134,8 +134,9 @@ struct DerivedMesh {
* \warning Typical access is done via #getLoopTriArray, #getNumLoopTri.
*/
struct {
- /* WARNING! swapping between array (ready-to-be-used data) and array_wip (where data is actually computed)
- * shall always be protected by same lock as one used for looptris computing. */
+ /* WARNING! swapping between array (ready-to-be-used data) and array_wip
+ * (where data is actually computed) shall always be protected by same
+ * lock as one used for looptris computing. */
struct MLoopTri *array, *array_wip;
int num;
int num_alloc;
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 08237be0a21..69f3070fcba 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -35,6 +35,7 @@ struct bActionGroup;
struct bItasc;
struct bPose;
struct bPoseChannel;
+struct bPoseChannel_Runtime;
/* Kernel prototypes */
#ifdef __cplusplus
@@ -132,7 +133,10 @@ void action_groups_clear_tempflags(struct bAction *act);
void BKE_pose_channel_free(struct bPoseChannel *pchan);
void BKE_pose_channel_free_ex(struct bPoseChannel *pchan, bool do_id_user);
-void BKE_pose_channel_free_bbone_cache(struct bPoseChannel *pchan);
+void BKE_pose_channel_runtime_reset(struct bPoseChannel_Runtime *runtime);
+void BKE_pose_channel_runtime_free(struct bPoseChannel_Runtime *runtime);
+
+void BKE_pose_channel_free_bbone_cache(struct bPoseChannel_Runtime *runtime);
void BKE_pose_channels_free(struct bPose *pose);
void BKE_pose_channels_free_ex(struct bPose *pose, bool do_id_user);
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index 0503efb1661..583a90b2dee 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -95,7 +95,8 @@ void BKE_animdata_merge_copy(struct Main *bmain,
/* ************************************* */
/* KeyingSets API */
-/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
+/* Used to create a new 'custom' KeyingSet for the user,
+ * that will be automatically added to the stack */
struct KeyingSet *BKE_keyingset_add(
struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag);
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 50457c5b3f0..b5da30e725d 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -144,8 +144,9 @@ void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph,
float outmat[4][4]);
void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat);
+void BKE_pchan_rot_to_mat3(const struct bPoseChannel *pchan, float mat[3][3]);
void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat);
-void BKE_pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]);
+void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float chan_mat[4][4]);
void BKE_pchan_calc_mat(struct bPoseChannel *pchan);
/* Simple helper, computes the offset bone matrix. */
@@ -207,8 +208,8 @@ typedef struct BBoneSplineParameters {
/* Control values. */
float ease1, ease2;
float roll1, roll2;
- float scaleIn, scaleOut;
- float curveInX, curveInY, curveOutX, curveOutY;
+ float scale_in_x, scale_in_y, scale_out_x, scale_out_y;
+ float curve_in_x, curve_in_y, curve_out_x, curve_out_y;
} BBoneSplineParameters;
void BKE_pchan_bbone_handles_get(struct bPoseChannel *pchan,
@@ -335,17 +336,6 @@ void BKE_pose_eval_proxy_copy_bone(struct Depsgraph *depsgraph,
struct Object *object,
int pchan_index);
-/* BBOne deformation cache.
- *
- * The idea here is to pre-calculate deformation queternions, matricies and such
- * used by armature_deform_verts().
- */
-struct ObjectBBoneDeform;
-struct ObjectBBoneDeform *BKE_armature_cached_bbone_deformation_get(struct Object *object);
-void BKE_armature_cached_bbone_deformation_free_data(struct Object *object);
-void BKE_armature_cached_bbone_deformation_free(struct Object *object);
-void BKE_armature_cached_bbone_deformation_update(struct Object *object);
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 0566ecf3444..e01f6a6b751 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
* \note Use #STRINGIFY() rather than defining with quotes.
*/
#define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 57
+#define BLENDER_SUBVERSION 60
/** Several breakages with 280, e.g. collections vs layers. */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h
index 1d40ba0bc78..4b64b6fa269 100644
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@ -84,11 +84,12 @@ typedef struct BVHTreeFromMesh {
/**
* Builds a bvh tree where nodes are the relevant elements of the given mesh.
- * Configures BVHTreeFromMesh.
+ * Configures #BVHTreeFromMesh.
*
* The tree is build in mesh space coordinates, this means special care must be made on queries
* so that the coordinates and rays are first translated on the mesh local coordinates.
- * Reason for this is that bvh_from_mesh_* can use a cache in some cases and so it becomes possible to reuse a BVHTree.
+ * Reason for this is that bvh_from_mesh_* can use a cache in some cases and so it
+ * becomes possible to reuse a #BVHTree.
*
* free_bvhtree_from_mesh should be called when the tree is no longer needed.
*/
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h
index b991ac24284..257975e3c17 100644
--- a/source/blender/blenkernel/BKE_cachefile.h
+++ b/source/blender/blenkernel/BKE_cachefile.h
@@ -29,8 +29,10 @@ extern "C" {
#endif
struct CacheFile;
+struct CacheReader;
struct Depsgraph;
struct Main;
+struct Object;
struct Scene;
void BKE_cachefiles_init(void);
@@ -52,24 +54,27 @@ void BKE_cachefile_make_local(struct Main *bmain,
struct CacheFile *cache_file,
const bool lib_local);
-void BKE_cachefile_reload(const struct Main *bmain, struct CacheFile *cache_file);
+void BKE_cachefile_reload(struct Depsgraph *depsgraph, struct CacheFile *cache_file);
-void BKE_cachefile_ensure_handle(const struct Main *bmain, struct CacheFile *cache_file);
-
-void BKE_cachefile_update_frame(struct Main *bmain,
- struct Depsgraph *depsgraph,
- struct Scene *scene,
- const float ctime,
- const float fps);
+void BKE_cachefile_eval(struct Main *bmain,
+ struct Depsgraph *depsgraph,
+ struct CacheFile *cache_file);
bool BKE_cachefile_filepath_get(const struct Main *bmain,
+ const struct Depsgraph *depsgrah,
const struct CacheFile *cache_file,
- float frame,
char r_filename[1024]);
-float BKE_cachefile_time_offset(struct CacheFile *cache_file, const float time, const float fps);
+float BKE_cachefile_time_offset(const struct CacheFile *cache_file,
+ const float time,
+ const float fps);
-void BKE_cachefile_clean(struct Main *bmain, struct CacheFile *cache_file);
+/* Modifiers and constraints open and free readers through these. */
+void BKE_cachefile_reader_open(struct CacheFile *cache_file,
+ struct CacheReader **reader,
+ struct Object *object,
+ const char *object_path);
+void BKE_cachefile_reader_free(struct CacheFile *cache_file, struct CacheReader **reader);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index f06d9d1e64e..47786629aed 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -180,7 +180,8 @@ typedef void (*BKE_scene_collections_Cb)(struct Collection *ob, void *data);
#define FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END \
} \
} \
- }
+ } \
+ ((void)0)
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object) \
for (Base *_base = (Base *)BKE_collection_object_cache_get(_collection).first; _base; \
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index 9ad3657284d..8fe3bd77a26 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -101,13 +101,22 @@ typedef struct bConstraintTypeInfo {
void (*id_looper)(struct bConstraint *con, ConstraintIDFunc func, void *userdata);
/** copy any special data that is allocated separately (optional) */
void (*copy_data)(struct bConstraint *con, struct bConstraint *src);
- /** set settings for data that will be used for bConstraint.data (memory already allocated using MEM_callocN) */
+ /**
+ * Set settings for data that will be used for #bConstraint.data
+ * (memory already allocated using #MEM_callocN).
+ */
void (*new_data)(void *cdata);
/* target handling function pointers */
- /** for multi-target constraints: return that list; otherwise make a temporary list (returns number of targets) */
+ /**
+ * For multi-target constraints: return that list;
+ * otherwise make a temporary list (returns number of targets).
+ */
int (*get_constraint_targets)(struct bConstraint *con, struct ListBase *list);
- /** for single-target constraints only: flush data back to source data, and the free memory used */
+ /**
+ * For single-target constraints only:
+ * flush data back to source data, and the free memory used.
+ */
void (*flush_constraint_targets)(struct bConstraint *con, struct ListBase *list, bool no_copy);
/* evaluation */
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 88035e2b3d9..f354e5e6de3 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -61,14 +61,18 @@ extern const CustomData_MeshMasks CD_MASK_EVERYTHING;
* memory space for totelem elements. mask must be an array of length
* CD_NUMTYPES elements, that indicate if a layer can be copied. */
-/* add/copy/merge allocation types */
+/** Add/copy/merge allocation types. */
typedef enum eCDAllocType {
- CD_ASSIGN = 0, /* use the data pointer */
- CD_CALLOC = 1, /* allocate blank memory */
- CD_DEFAULT = 2, /* allocate and set to default */
- CD_REFERENCE = 3, /* use data pointers, set layer flag NOFREE */
- CD_DUPLICATE = 4, /* do a full copy of all layers, only allowed if source
- * has same number of elements */
+ /** Use the data pointer. */
+ CD_ASSIGN = 0,
+ /** Allocate blank memory. */
+ CD_CALLOC = 1,
+ /** Allocate and set to default. */
+ CD_DEFAULT = 2,
+ /** Use data pointers, set layer flag NOFREE. */
+ CD_REFERENCE = 3,
+ /** Do a full copy of all layers, only allowed if source has same number of elements. */
+ CD_DUPLICATE = 4,
} eCDAllocType;
#define CD_TYPE_AS_MASK(_type) (CustomDataMask)((CustomDataMask)1 << (CustomDataMask)(_type))
@@ -109,7 +113,8 @@ bool CustomData_has_referenced(const struct CustomData *data);
* implemented for mloopuv/mloopcol, for now.*/
void CustomData_data_copy_value(int type, const void *source, void *dest);
-/* Same as above, but doing advanced mixing. Only available for a few types of data (like colors...). */
+/* Same as above, but doing advanced mixing.
+ * Only available for a few types of data (like colors...). */
void CustomData_data_mix_value(
int type, const void *source, void *dest, const int mixmode, const float mixfactor);
@@ -474,8 +479,8 @@ typedef void (*cd_datatransfer_interp)(const struct CustomDataTransferLayerMap *
const float mix_factor);
/**
- * Fake CD_LAYERS (those are actually 'real' data stored directly into elements' structs, or otherwise not (directly)
- * accessible to usual CDLayer system). */
+ * Fake CD_LAYERS (those are actually 'real' data stored directly into elements' structs,
+ * or otherwise not (directly) accessible to usual CDLayer system). */
enum {
CD_FAKE = 1 << 8,
@@ -527,23 +532,29 @@ typedef struct CustomDataTransferLayerMap {
int data_type;
int mix_mode;
float mix_factor;
- const float *
- mix_weights; /* If non-NULL, array of weights, one for each dest item, replaces mix_factor. */
-
- const void *
- data_src; /* Data source array (can be regular CD data, vertices/edges/etc., keyblocks...). */
- void *data_dst; /* Data dest array (same type as dat_src). */
- int data_src_n; /* Index to affect in data_src (used e.g. for vgroups). */
- int data_dst_n; /* Index to affect in data_dst (used e.g. for vgroups). */
- size_t elem_size; /* Size of one element of data_src/data_dst. */
-
- size_t data_size; /* Size of actual data we transfer. */
- size_t
- data_offset; /* Offset of actual data we transfer (in element contained in data_src/dst). */
- uint64_t data_flag; /* For bitflag transfer, flag(s) to affect in transferred data. */
-
- void *
- interp_data; /* Opaque pointer, to be used by specific interp callback (e.g. transformspace for normals). */
+ /** If non-NULL, array of weights, one for each dest item, replaces mix_factor. */
+ const float *mix_weights;
+
+ /** Data source array (can be regular CD data, vertices/edges/etc., keyblocks...). */
+ const void *data_src;
+ /** Data dest array (same type as dat_src). */
+ void *data_dst;
+ /** Index to affect in data_src (used e.g. for vgroups). */
+ int data_src_n;
+ /** Index to affect in data_dst (used e.g. for vgroups). */
+ int data_dst_n;
+ /** Size of one element of data_src/data_dst. */
+ size_t elem_size;
+
+ /** Size of actual data we transfer. */
+ size_t data_size;
+ /** Offset of actual data we transfer (in element contained in data_src/dst). */
+ size_t data_offset;
+ /** For bitflag transfer, flag(s) to affect in transferred data. */
+ uint64_t data_flag;
+
+ /** Opaque pointer, to be used by specific interp callback (e.g. transformspace for normals). */
+ void *interp_data;
cd_datatransfer_interp interp;
} CustomDataTransferLayerMap;
diff --git a/source/blender/blenkernel/BKE_data_transfer.h b/source/blender/blenkernel/BKE_data_transfer.h
index a909328ac9c..79ef512bc1f 100644
--- a/source/blender/blenkernel/BKE_data_transfer.h
+++ b/source/blender/blenkernel/BKE_data_transfer.h
@@ -119,7 +119,7 @@ enum {
DT_LAYERS_NAME_DST = -2,
DT_LAYERS_INDEX_DST = -3,
#if 0 /* TODO */
- DT_LAYERS_CREATE_DST = -4, /* Never replace existing data in dst, always create new layers. */
+ DT_LAYERS_CREATE_DST = -4, /* Never replace existing data in dst, always create new layers. */
#endif
};
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index 510e989a087..fd7fa632999 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -109,7 +109,8 @@ void defvert_normalize_lock_map(struct MDeformVert *dvert,
const bool *lock_flags,
const int defbase_tot);
-/* Utilities to 'extract' a given vgroup into a simple float array, for verts, but also edges/polys/loops. */
+/* Utilities to 'extract' a given vgroup into a simple float array,
+ * for verts, but also edges/polys/loops. */
void BKE_defvert_extract_vgroup_to_vertweights(struct MDeformVert *dvert,
const int defgroup,
const int num_verts,
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index 9f4f2862c95..c4f05d404ce 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -83,13 +83,11 @@ void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd);
void dynamicPaint_freeSurfaceData(struct DynamicPaintSurface *surface);
void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
-bool dynamicPaint_surfaceHasColorPreview(struct DynamicPaintSurface *surface);
bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface,
struct Object *ob,
int output);
void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
void dynamicPaintSurface_setUniqueName(struct DynamicPaintSurface *surface, const char *basename);
-void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);
struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings *canvas);
/* image sequence baking */
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index 15b59993d77..94e8f4304b8 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -154,8 +154,14 @@ int get_effector_data(struct EffectorCache *eff,
int real_velocity);
/* required for particle_system.c */
-//void do_physical_effector(struct EffectorData *eff, struct EffectorPoint *point, float *total_force);
-//float effector_falloff(struct EffectorData *eff, struct EffectorPoint *point, struct EffectorWeights *weights);
+#if 0
+void do_physical_effector(struct EffectorData *eff,
+ struct EffectorPoint *point,
+ float *total_force);
+float effector_falloff(struct EffectorData *eff,
+ struct EffectorPoint *point,
+ struct EffectorWeights *weights);
+#endif
/* EffectedPoint->flag */
#define PE_WIND_AS_SPEED 1
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 52a4d00b117..c1232addee3 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -115,8 +115,6 @@ float evaluate_driver(struct PathResolvedRNA *anim_rna,
/* ************** F-Curve Modifiers *************** */
-typedef struct GHash FModifierStackStorage;
-
/* F-Curve Modifier Type-Info (fmi):
* This struct provides function pointers for runtime, so that functions can be
* written more generally (with fewer/no special exceptions for various modifiers).
@@ -130,46 +128,40 @@ typedef struct GHash FModifierStackStorage;
*/
typedef struct FModifierTypeInfo {
/* admin/ident */
- short type; /* FMODIFIER_TYPE_### */
- short size; /* size in bytes of the struct */
- short acttype; /* eFMI_Action_Types */
- short requires; /* eFMI_Requirement_Flags */
- char name[64]; /* name of modifier in interface */
- char structName[64]; /* name of struct for SDNA */
+ /** #FMODIFIER_TYPE_* */
+ short type;
+ /** size in bytes of the struct. */
+ short size;
+ /** #eFMI_Action_Types. */
+ short acttype;
+ /** #eFMI_Requirement_Flags. */
+ short requires;
+ /** name of modifier in interface. */
+ char name[64];
+ /** name of struct for SDNA. */
+ char structName[64];
+ /** Size of buffer that can be reused between time and value evaluation. */
+ uint storage_size;
/* data management function pointers - special handling */
- /* free any data that is allocated separately (optional) */
+ /** Free any data that is allocated separately (optional). */
void (*free_data)(struct FModifier *fcm);
- /* copy any special data that is allocated separately (optional) */
+ /** Copy any special data that is allocated separately (optional). */
void (*copy_data)(struct FModifier *fcm, const struct FModifier *src);
- /* set settings for data that will be used for FCuModifier.data (memory already allocated using MEM_callocN) */
+ /**
+ * Set settings for data that will be used for FCuModifier.data
+ * (memory already allocated using #MEM_callocN). */
void (*new_data)(void *mdata);
- /* verifies that the modifier settings are valid */
+ /** Verifies that the modifier settings are valid */
void (*verify_data)(struct FModifier *fcm);
/* evaluation */
- /* evaluate time that the modifier requires the F-Curve to be evaluated at */
- float (*evaluate_modifier_time)(struct FCurve *fcu,
- struct FModifier *fcm,
- float cvalue,
- float evaltime);
- /* evaluate the modifier for the given time and 'accumulated' value */
- void (*evaluate_modifier)(struct FCurve *fcu,
- struct FModifier *fcm,
- float *cvalue,
- float evaltime);
-
- /* Same as above but for modifiers which requires storage */
- float (*evaluate_modifier_time_storage)(FModifierStackStorage *storage,
- struct FCurve *fcu,
- struct FModifier *fcm,
- float cvalue,
- float evaltime);
- void (*evaluate_modifier_storage)(FModifierStackStorage *storage,
- struct FCurve *fcu,
- struct FModifier *fcm,
- float *cvalue,
- float evaltime);
+ /** Evaluate time that the modifier requires the F-Curve to be evaluated at */
+ float (*evaluate_modifier_time)(
+ struct FCurve *fcu, struct FModifier *fcm, float cvalue, float evaltime, void *storage);
+ /** Evaluate the modifier for the given time and 'accumulated' value */
+ void (*evaluate_modifier)(
+ struct FCurve *fcu, struct FModifier *fcm, float *cvalue, float evaltime, void *storage);
} FModifierTypeInfo;
/* Values which describe the behavior of a FModifier Type */
@@ -194,9 +186,6 @@ typedef enum eFMI_Requirement_Flags {
FMI_REQUIRES_NOTHING = (1 << 1),
/* refer to modifier instance */
FMI_REQUIRES_RUNTIME_CHECK = (1 << 2),
-
- /* Requires to store data shared between time and valua evaluation */
- FMI_REQUIRES_STORAGE = (1 << 3),
} eFMI_Requirement_Flags;
/* Function Prototypes for FModifierTypeInfo's */
@@ -216,14 +205,19 @@ void set_active_fmodifier(ListBase *modifiers, struct FModifier *fcm);
bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype);
-FModifierStackStorage *evaluate_fmodifiers_storage_new(ListBase *modifiers);
-void evaluate_fmodifiers_storage_free(FModifierStackStorage *storage);
-float evaluate_time_fmodifiers(FModifierStackStorage *storage,
+typedef struct FModifiersStackStorage {
+ uint modifier_count;
+ uint size_per_modifier;
+ void *buffer;
+} FModifiersStackStorage;
+
+uint evaluate_fmodifiers_storage_size_per_modifier(ListBase *modifiers);
+float evaluate_time_fmodifiers(FModifiersStackStorage *storage,
ListBase *modifiers,
struct FCurve *fcu,
float cvalue,
float evaltime);
-void evaluate_value_fmodifiers(FModifierStackStorage *storage,
+void evaluate_value_fmodifiers(FModifiersStackStorage *storage,
ListBase *modifiers,
struct FCurve *fcu,
float *cvalue,
@@ -238,7 +232,8 @@ int BKE_fcm_envelope_find_index(struct FCM_EnvelopeData *array,
/* ************** F-Curves API ******************** */
-/* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */
+/* threshold for binary-searching keyframes - threshold here should be good enough for now,
+ * but should become userpref */
#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
/* -------- Data Management -------- */
@@ -258,7 +253,8 @@ struct FCurve *iter_step_fcurve(struct FCurve *fcu_iter, const char rna_path[]);
struct FCurve *id_data_find_fcurve(
ID *id, void *data, struct StructRNA *type, const char *prop_name, int index, bool *r_driven);
-/* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated
+/* Get list of LinkData's containing pointers to the F-Curves which control the types of data
+ * indicated
* e.g. numMatches = list_find_data_fcurves(matches, &act->curves, "pose.bones[", "MyFancyBone");
*/
int list_find_data_fcurves(ListBase *dst,
@@ -274,7 +270,8 @@ struct FCurve *rna_get_fcurve(struct PointerRNA *ptr,
struct bAction **r_action,
bool *r_driven,
bool *r_special);
-/* Same as above, but takes a context data, temp hack needed for complex paths like texture ones. */
+/* Same as above, but takes a context data,
+ * temp hack needed for complex paths like texture ones. */
struct FCurve *rna_get_fcurve_context_ui(struct bContext *C,
struct PointerRNA *ptr,
struct PropertyRNA *prop,
diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h
index 128ff39de7a..4655abf6e02 100644
--- a/source/blender/blenkernel/BKE_gpencil_modifier.h
+++ b/source/blender/blenkernel/BKE_gpencil_modifier.h
@@ -38,8 +38,8 @@ struct Object;
struct Scene;
struct ViewLayer;
struct bArmature;
-struct
- bContext; /* NOTE: bakeModifier() - called from UI - needs to create new datablocks, hence the need for this */
+/* NOTE: bakeModifier() called from UI: needs to create new datablocks, hence the need for this. */
+struct bContext;
struct bGPDframe;
struct bGPDlayer;
struct bGPDstroke;
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 4d3ad17519e..28886a5a195 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -233,6 +233,7 @@ struct Image *BKE_image_add_generated(struct Main *bmain,
struct Image *BKE_image_add_from_imbuf(struct Main *bmain, struct ImBuf *ibuf, const char *name);
/* for reload, refresh, pack */
+void BKE_imageuser_default(struct ImageUser *iuser);
void BKE_image_init_imageuser(struct Image *ima, struct ImageUser *iuser);
void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal);
@@ -293,7 +294,7 @@ void BKE_image_free_anim_ibufs(struct Image *ima, int except_frame);
/* does all images with type MOVIE or SEQUENCE */
void BKE_image_all_free_anim_ibufs(struct Main *bmain, int except_frame);
-void BKE_image_memorypack(struct Image *ima);
+bool BKE_image_memorypack(struct Image *ima);
void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath);
void BKE_image_packfiles_from_mem(struct ReportList *reports,
struct Image *ima,
diff --git a/source/blender/blenkernel/BKE_image_save.h b/source/blender/blenkernel/BKE_image_save.h
new file mode 100644
index 00000000000..26c377a2574
--- /dev/null
+++ b/source/blender/blenkernel/BKE_image_save.h
@@ -0,0 +1,67 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ */
+#ifndef __BKE_IMAGE_SAVE_H__
+#define __BKE_IMAGE_SAVE_H__
+
+#include "DNA_scene_types.h"
+
+/** \file
+ * \ingroup bke
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct Image;
+struct Main;
+struct RenderResult;
+struct ReportList;
+struct Scene;
+
+typedef struct ImageSaveOptions {
+ /* Context within which image is saved. */
+ struct Main *bmain;
+ struct Scene *scene;
+
+ /* Format and absolute file path. */
+ struct ImageFormatData im_format;
+ char filepath[1024]; /* 1024 = FILE_MAX */
+
+ /* Options. */
+ bool relative;
+ bool save_copy;
+ bool save_as_render;
+ bool do_newpath;
+} ImageSaveOptions;
+
+void BKE_image_save_options_init(struct ImageSaveOptions *opts,
+ struct Main *bmain,
+ struct Scene *scene);
+bool BKE_image_save(struct ReportList *reports,
+ struct Main *bmain,
+ struct Image *ima,
+ struct ImageUser *iuser,
+ struct ImageSaveOptions *opts);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BKE_IMAGE_SAVE_H__ */
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 98fb59814fa..cc6c43c51f6 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -68,7 +68,6 @@ struct ViewLayer *BKE_view_layer_find_from_collection(const struct Scene *scene,
struct Base *BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob);
void BKE_view_layer_base_deselect_all(struct ViewLayer *view_layer);
-void BKE_view_layer_base_select(struct Base *selbase);
void BKE_view_layer_base_select_and_set_active(struct ViewLayer *view_layer, struct Base *selbase);
void BKE_view_layer_copy_data(struct Scene *scene_dst,
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 82ae832c73e..54b9fdac5b4 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -34,13 +34,13 @@ extern "C" {
* WARNING: description below is ideal goal, current status of naming does not yet
* fully follow it (this is WIP).
*
- * BKE_id_ should be used for rather high-level operations, that involve Main database and
- * relations with other IDs, and can be considered as 'safe' (as in, in themselves, they leave
- * affected IDs/Main in a consistent status).
+ * - BKE_id_ should be used for rather high-level operations, that involve Main database and
+ * relations with other IDs, and can be considered as 'safe'
+ * (as in, in themselves, they leave affected IDs/Main in a consistent status).
*
- * BKE_libblock_ should be used for lower level operations, that perform some parts of BKE_id_ ones,
- * but will generally not ensure caller that affected data is in a consistent state
- * by their own execution alone.
+ * - BKE_libblock_ should be used for lower level operations,
+ * that perform some parts of BKE_id_ ones, but will generally not ensure caller that affected
+ * data is in a consistent state by their own execution alone.
*
* Consequently, external code should not typically use BKE_libblock_ functions,
* except in some specific cases requiring advanced (and potentially dangerous) handling.
@@ -72,44 +72,47 @@ void *BKE_id_new_nomain(const short type, const char *name);
*/
enum {
/* *** Generic options (should be handled by all ID types copying, ID creation, etc.). *** */
- /* Create datablock outside of any main database - similar to 'localize' functions of materials etc. */
+ /** Create datablock outside of any main database -
+ * similar to 'localize' functions of materials etc. */
LIB_ID_CREATE_NO_MAIN = 1 << 0,
- /* Do not affect user refcount of datablocks used by new one (which also gets zero usercount then).
+ /** Do not affect user refcount of datablocks used by new one
+ * (which also gets zero usercount then).
* Implies LIB_ID_CREATE_NO_MAIN. */
LIB_ID_CREATE_NO_USER_REFCOUNT = 1 << 1,
- /* Assume given 'newid' already points to allocated memory for whole datablock (ID + data) - USE WITH CAUTION!
+ /** Assume given 'newid' already points to allocated memory for whole datablock
+ * (ID + data) - USE WITH CAUTION!
* Implies LIB_ID_CREATE_NO_MAIN. */
LIB_ID_CREATE_NO_ALLOCATE = 1 << 2,
- /* Do not tag new ID for update in depsgraph. */
+ /** Do not tag new ID for update in depsgraph. */
LIB_ID_CREATE_NO_DEG_TAG = 1 << 8,
/* *** Specific options to some ID types or usages. *** */
/* *** May be ignored by unrelated ID copying functions. *** */
- /* Object only, needed by make_local code. */
+ /** Object only, needed by make_local code. */
LIB_ID_COPY_NO_PROXY_CLEAR = 1 << 16,
- /* Do not copy preview data, when supported. */
+ /** Do not copy preview data, when supported. */
LIB_ID_COPY_NO_PREVIEW = 1 << 17,
- /* Copy runtime data caches. */
+ /** Copy runtime data caches. */
LIB_ID_COPY_CACHES = 1 << 18,
- /* Don't copy id->adt, used by ID datablock localization routines. */
+ /** Don't copy id->adt, used by ID datablock localization routines. */
LIB_ID_COPY_NO_ANIMDATA = 1 << 19,
- /* Mesh: Reference CD data layers instead of doing real copy - USE WITH CAUTION! */
+ /** Mesh: Reference CD data layers instead of doing real copy - USE WITH CAUTION! */
LIB_ID_COPY_CD_REFERENCE = 1 << 20,
/* *** XXX Hackish/not-so-nice specific behaviors needed for some corner cases. *** */
/* *** Ideally we should not have those, but we need them for now... *** */
- /* EXCEPTION! Deep-copy actions used by animdata of copied ID. */
+ /** EXCEPTION! Deep-copy actions used by animdata of copied ID. */
LIB_ID_COPY_ACTIONS = 1 << 24,
- /* Keep the library pointer when copying datablock outside of bmain. */
+ /** Keep the library pointer when copying datablock outside of bmain. */
LIB_ID_COPY_KEEP_LIB = 1 << 25,
- /* EXCEPTION! Deep-copy shapekeys used by copied obdata ID. */
+ /** EXCEPTION! Deep-copy shapekeys used by copied obdata ID. */
LIB_ID_COPY_SHAPEKEY = 1 << 26,
/* *** Helper 'defines' gathering most common flag sets. *** */
- /* Shapekeys are not real ID's, more like local data to geometry IDs... */
+ /** Shapekeys are not real ID's, more like local data to geometry IDs... */
LIB_ID_COPY_DEFAULT = LIB_ID_COPY_SHAPEKEY,
- /* Generate a local copy, outside of bmain, to work on (used by COW e.g.). */
+ /** Generate a local copy, outside of bmain, to work on (used by COW e.g.). */
LIB_ID_COPY_LOCALIZE = LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_CACHES,
};
diff --git a/source/blender/blenkernel/BKE_library_query.h b/source/blender/blenkernel/BKE_library_query.h
index caa36742f76..94e7830aabe 100644
--- a/source/blender/blenkernel/BKE_library_query.h
+++ b/source/blender/blenkernel/BKE_library_query.h
@@ -38,9 +38,12 @@ enum {
*/
IDWALK_CB_INDIRECT_USAGE = (1 << 2),
- /** That ID is used as mere sub-data by its owner
+ /**
+ * That ID is used as mere sub-data by its owner
* (only case currently: those f***ing nodetrees in materials etc.).
- * This means callback shall not *do* anything, only use this as informative data if it needs it. */
+ * This means callback shall not *do* anything,
+ * only use this as informative data if it needs it.
+ */
IDWALK_CB_PRIVATE = (1 << 3),
/** That ID is not really used by its owner, it's just an internal hint/helper.
diff --git a/source/blender/blenkernel/BKE_library_remap.h b/source/blender/blenkernel/BKE_library_remap.h
index da104c4c205..41ac8c8c8e6 100644
--- a/source/blender/blenkernel/BKE_library_remap.h
+++ b/source/blender/blenkernel/BKE_library_remap.h
@@ -29,29 +29,44 @@ extern "C" {
/* Also IDRemap->flag. */
enum {
- /* Do not remap indirect usages of IDs (that is, when user is some linked data). */
+ /** Do not remap indirect usages of IDs (that is, when user is some linked data). */
ID_REMAP_SKIP_INDIRECT_USAGE = 1 << 0,
- /* This flag should always be set, *except for 'unlink' scenarios* (only relevant when new_id == NULL).
- * Basically, when unset, NEVER_NULL ID usages will keep pointing to old_id, but (if needed) old_id user count
- * will still be decremented. This is mandatory for 'delete ID' case, but in all other situation this would lead
- * to invalid user counts! */
+ /**
+ * This flag should always be set, *except for 'unlink' scenarios*
+ * (only relevant when new_id == NULL).
+ * Basically, when unset, NEVER_NULL ID usages will keep pointing to old_id, but (if needed)
+ * old_id user count will still be decremented.
+ * This is mandatory for 'delete ID' case,
+ * but in all other situation this would lead to invalid user counts!
+ */
ID_REMAP_SKIP_NEVER_NULL_USAGE = 1 << 1,
- /* This tells the callback func to flag with LIB_DOIT all IDs using target one with a 'never NULL' pointer
- * (like e.g. Object->data). */
+ /**
+ * This tells the callback func to flag with #LIB_DOIT all IDs
+ * using target one with a 'never NULL' pointer (like e.g. #Object.data).
+ */
ID_REMAP_FLAG_NEVER_NULL_USAGE = 1 << 2,
- /* This tells the callback func to force setting IDs using target one with a 'never NULL' pointer to NULL.
- * WARNING! Use with extreme care, this will leave database in broken state and can cause crashes very easily! */
+ /**
+ * This tells the callback func to force setting IDs
+ * using target one with a 'never NULL' pointer to NULL.
+ * \warning Use with extreme care, this will leave database in broken state
+ * and can cause crashes very easily!
+ */
ID_REMAP_FORCE_NEVER_NULL_USAGE = 1 << 3,
- /* Do not consider proxy/_group pointers of local objects as indirect usages...
- * Our oh-so-beloved proxies again... Do not consider data used by local proxy object as indirect usage.
- * This is needed e.g. in reload scenario, since we have to ensure remapping of Armature data of local proxy
- * is also performed. Usual nightmare... */
+ /**
+ * Do not consider proxy/_group pointers of local objects as indirect usages...
+ * Our oh-so-beloved proxies again...
+ * Do not consider data used by local proxy object as indirect usage.
+ * This is needed e.g. in reload scenario,
+ * since we have to ensure remapping of Armature data of local proxy
+ * is also performed. Usual nightmare...
+ */
ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE = 1 << 4,
- /* Do not remap static override pointers. */
+ /** Do not remap static override pointers. */
ID_REMAP_SKIP_STATIC_OVERRIDE = 1 << 5,
};
-/* Note: Requiring new_id to be non-null, this *may* not be the case ultimately, but makes things simpler for now. */
+/* Note: Requiring new_id to be non-null, this *may* not be the case ultimately,
+ * but makes things simpler for now. */
void BKE_libblock_remap_locked(struct Main *bmain,
void *old_idv,
void *new_idv,
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 84ff46aa5d0..1c987d5eb8e 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -57,7 +57,8 @@ typedef struct BlendThumbnail {
/* Structs caching relations between data-blocks in a given Main. */
typedef struct MainIDRelationsEntry {
struct MainIDRelationsEntry *next;
- /* WARNING! for user_to_used, that pointer is really an ID** one, but for used_to_user, it’s only an ID* one! */
+ /* WARNING! for user_to_used,
+ * that pointer is really an ID** one, but for used_to_user, it’s only an ID* one! */
struct ID **id_pointer;
int usage_flag; /* Using IDWALK_ enums, in BKE_library_query.h */
} MainIDRelationsEntry;
@@ -121,9 +122,11 @@ typedef struct Main {
ListBase cachefiles;
ListBase workspaces;
- /* Must be generated, used and freed by same code - never assume this is valid data unless you know
- * when, who and how it was created.
- * Used by code doing a lot of remapping etc. at once to speed things up. */
+ /**
+ * Must be generated, used and freed by same code - never assume this is valid data unless you
+ * know when, who and how it was created.
+ * Used by code doing a lot of remapping etc. at once to speed things up.
+ */
struct MainIDRelations *relations;
struct MainLock *lock;
@@ -165,14 +168,15 @@ struct GSet *BKE_main_gset_create(struct Main *bmain, struct GSet *gset);
} \
((void)0)
-/* DO NOT use break statement with that macro, use FOREACH_MAIN_LISTBASE and FOREACH_MAIN_LISTBASE_ID instead
+/**
+ * DO NOT use break statement with that macro,
+ * use #FOREACH_MAIN_LISTBASE and #FOREACH_MAIN_LISTBASE_ID instead
* if you need that kind of control flow. */
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id) \
{ \
ListBase *_lb; \
- FOREACH_MAIN_LISTBASE_BEGIN(_bmain, _lb) \
- { \
- FOREACH_MAIN_LISTBASE_ID_BEGIN(_lb, _id)
+ FOREACH_MAIN_LISTBASE_BEGIN (_bmain, _lb) { \
+ FOREACH_MAIN_LISTBASE_ID_BEGIN (_lb, _id)
#define FOREACH_MAIN_ID_END \
FOREACH_MAIN_LISTBASE_ID_END; \
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index e89e1b05029..ecee00b1b3f 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -123,10 +123,12 @@ struct Mesh *BKE_mesh_new_nomain_from_template(const struct Mesh *me_src,
int loops_len,
int polys_len);
-/* Performs copy for use during evaluation, optional referencing original arrays to reduce memory. */
+/* Performs copy for use during evaluation,
+ * optional referencing original arrays to reduce memory. */
struct Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference);
-/* These functions construct a new Mesh, contrary to BKE_mesh_from_nurbs which modifies ob itself. */
+/* These functions construct a new Mesh,
+ * contrary to BKE_mesh_from_nurbs which modifies ob itself. */
struct Mesh *BKE_mesh_new_nomain_from_curve(struct Object *ob);
struct Mesh *BKE_mesh_new_nomain_from_curve_displist(struct Object *ob, struct ListBase *dispbase);
@@ -214,8 +216,8 @@ struct Mesh *BKE_mesh_new_from_object(struct Depsgraph *depsgraph,
const bool calc_undeformed);
struct Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
struct Scene *scene,
- struct Object *ob,
- struct ModifierData *md,
+ struct Object *ob_eval,
+ struct ModifierData *md_eval,
int build_shapekey_layers);
/* Copies a nomain-Mesh into an existing Mesh. */
@@ -325,22 +327,25 @@ void BKE_edges_sharp_from_angle_set(const struct MVert *mverts,
* References a contiguous loop-fan with normal offset vars.
*/
typedef struct MLoopNorSpace {
- float vec_lnor[3]; /* Automatically computed loop normal. */
- float vec_ref[3]; /* Reference vector, orthogonal to vec_lnor. */
- float vec_ortho[3]; /* Third vector, orthogonal to vec_lnor and vec_ref. */
- float
- ref_alpha; /* Reference angle, around vec_ortho, in ]0, pi] range (0.0 marks that space as invalid). */
- float
- ref_beta; /* Reference angle, around vec_lnor, in ]0, 2pi] range (0.0 marks that space as invalid). */
- /* All loops using this lnor space (i.e. smooth fan of loops),
+ /** Automatically computed loop normal. */
+ float vec_lnor[3];
+ /** Reference vector, orthogonal to vec_lnor. */
+ float vec_ref[3];
+ /** Third vector, orthogonal to vec_lnor and vec_ref. */
+ float vec_ortho[3];
+ /** Reference angle, around vec_ortho, in ]0, pi] range (0.0 marks that space as invalid). */
+ float ref_alpha;
+ /** Reference angle, around vec_lnor, in ]0, 2pi] range (0.0 marks that space as invalid). */
+ float ref_beta;
+ /** All loops using this lnor space (i.e. smooth fan of loops),
* as (depending on owning MLoopNorSpaceArrary.data_type):
* - Indices (uint_in_ptr), or
* - BMLoop pointers. */
struct LinkNode *loops;
char flags;
- void *
- user_data; /* To be used for extended processing related to loop normal spaces (aka smooth fans). */
+ /** To be used for extended processing related to loop normal spaces (aka smooth fans). */
+ void *user_data;
} MLoopNorSpace;
/**
* MLoopNorSpace.flags
@@ -668,6 +673,7 @@ enum {
BKE_MESH_BATCH_DIRTY_ALL = 0,
BKE_MESH_BATCH_DIRTY_MAYBE_ALL,
BKE_MESH_BATCH_DIRTY_SELECT,
+ BKE_MESH_BATCH_DIRTY_SELECT_PAINT,
BKE_MESH_BATCH_DIRTY_SHADING,
BKE_MESH_BATCH_DIRTY_SCULPT_COORDS,
BKE_MESH_BATCH_DIRTY_UVEDIT_ALL,
diff --git a/source/blender/blenkernel/BKE_mesh_remap.h b/source/blender/blenkernel/BKE_mesh_remap.h
index 54f263a8bfb..36cc5bedb79 100644
--- a/source/blender/blenkernel/BKE_mesh_remap.h
+++ b/source/blender/blenkernel/BKE_mesh_remap.h
@@ -54,10 +54,12 @@ void BKE_mesh_remap_item_define_invalid(MeshPairRemap *map, const int index);
/* TODO:
* Add other 'from/to' mapping sources, like e.g. using an UVMap, etc.
- * http://blenderartists.org/forum/showthread.php?346458-Move-Vertices-to-the-location-of-the-Reference-Mesh-based-on-the-UV-Position
+ * https://blenderartists.org/t/619105
+ *
* We could also use similar topology mappings inside a same mesh
* (cf. Campbell's 'select face islands from similar topology' wip work).
- * Also, users will have to check, whether we can get rid of some modes here, not sure all will be useful!
+ * Also, users will have to check, whether we can get rid of some modes here,
+ * not sure all will be useful!
*/
enum {
MREMAP_USE_VERT = 1 << 4,
@@ -104,13 +106,15 @@ enum {
/* Nearest edge of nearest poly (using mid-point). */
MREMAP_MODE_EDGE_POLY_NEAREST = MREMAP_MODE_EDGE | MREMAP_USE_POLY | MREMAP_USE_NEAREST,
- /* Cast a set of rays from along dest edge, interpolating its vertices' normals, and use hit source edges. */
+ /* Cast a set of rays from along dest edge,
+ * interpolating its vertices' normals, and use hit source edges. */
MREMAP_MODE_EDGE_EDGEINTERP_VNORPROJ = MREMAP_MODE_EDGE | MREMAP_USE_VERT | MREMAP_USE_NORPROJ |
MREMAP_USE_INTERP,
/* ***** Target's loops ***** */
- /* Note: when islands are given to loop mapping func, all loops from the same destination face will always be mapped
- * to loops of source faces within a same island, regardless of mapping mode. */
+ /* Note: when islands are given to loop mapping func,
+ * all loops from the same destination face will always be mapped
+ * to loops of source faces within a same island, regardless of mapping mode. */
MREMAP_MODE_LOOP = 1 << 26,
/* Best normal-matching loop from nearest vert. */
@@ -138,7 +142,8 @@ enum {
/* Source poly from best normal-matching dest poly. */
MREMAP_MODE_POLY_NOR = MREMAP_MODE_POLY | MREMAP_USE_POLY | MREMAP_USE_NORMAL,
- /* Project dest poly onto source mesh using its normal, and use interpolation of all intersecting source polys. */
+ /* Project dest poly onto source mesh using its normal,
+ * and use interpolation of all intersecting source polys. */
MREMAP_MODE_POLY_POLYINTERP_PNORPROJ = MREMAP_MODE_POLY | MREMAP_USE_POLY | MREMAP_USE_NORPROJ |
MREMAP_USE_INTERP,
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 68ef413b198..a34f570ad1f 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -83,8 +83,8 @@ typedef enum {
*/
eModifierTypeFlag_RequiresOriginalData = (1 << 5),
- /* For modifiers that support pointcache, so we can check to see if it has files we need to deal with
- */
+ /* For modifiers that support pointcache,
+ * so we can check to see if it has files we need to deal with. */
eModifierTypeFlag_UsesPointCache = (1 << 6),
/* For physics modifiers, max one per type */
@@ -110,13 +110,16 @@ typedef void (*TexWalkFunc)(void *userData,
const char *propname);
typedef enum ModifierApplyFlag {
- MOD_APPLY_RENDER = 1 << 0, /* Render time. */
- MOD_APPLY_USECACHE = 1 << 1, /* Result of evaluation will be cached, so modifier might
- * want to cache data for quick updates (used by subsurf) */
- MOD_APPLY_ORCO = 1 << 2, /* Modifier evaluated for undeformed texture coordinates */
- MOD_APPLY_IGNORE_SIMPLIFY = 1 << 3, /* Ignore scene simplification flag and use subdivisions
- * level set in multires modifier.
- */
+ /** Render time. */
+ MOD_APPLY_RENDER = 1 << 0,
+ /** Result of evaluation will be cached, so modifier might
+ * want to cache data for quick updates (used by subsurf) */
+ MOD_APPLY_USECACHE = 1 << 1,
+ /** Modifier evaluated for undeformed texture coordinates */
+ MOD_APPLY_ORCO = 1 << 2,
+ /** Ignore scene simplification flag and use subdivisions
+ * level set in multires modifier. */
+ MOD_APPLY_IGNORE_SIMPLIFY = 1 << 3,
} ModifierApplyFlag;
typedef struct ModifierUpdateDepsgraphContext {
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 48b58562dd7..b760be29dae 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -218,7 +218,7 @@ typedef struct bNodeType {
/// Called when the node is updated in the editor.
void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node);
/// Check and update if internal ID data has changed.
- void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
+ void (*group_update_func)(struct bNodeTree *ntree, struct bNode *node);
/// Initialize a new node instance of this type after creation.
void (*initfunc)(struct bNodeTree *ntree, struct bNode *node);
@@ -395,15 +395,14 @@ struct bNode *ntreeFindType(const struct bNodeTree *ntree, int type);
bool ntreeHasType(const struct bNodeTree *ntree, int type);
bool ntreeHasTree(const struct bNodeTree *ntree, const struct bNodeTree *lookup);
void ntreeUpdateTree(struct Main *main, struct bNodeTree *ntree);
-/* XXX Currently each tree update call does call to ntreeVerifyNodes too.
- * Some day this should be replaced by a decent depsgraph automatism!
- */
-void ntreeVerifyNodes(struct Main *main, struct ID *id);
+void ntreeUpdateAllNew(struct Main *main);
+void ntreeUpdateAllUsers(struct Main *main, struct ID *id);
void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes);
-/* XXX old trees handle output flags automatically based on special output node types and last active selection.
- * new tree types have a per-output socket flag to indicate the final output to use explicitly.
+/* XXX old trees handle output flags automatically based on special output
+ * node types and last active selection.
+ * New tree types have a per-output socket flag to indicate the final output to use explicitly.
*/
void ntreeSetOutput(struct bNodeTree *ntree);
@@ -491,7 +490,8 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype);
#define NODE_SOCKET_TYPES_END \
} \
BLI_ghashIterator_free(__node_socket_type_iter__); \
- }
+ } \
+ ((void)0)
struct bNodeSocket *nodeFindSocket(struct bNode *node, int in_out, const char *identifier);
struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree,
@@ -735,10 +735,10 @@ void node_type_label(
struct bNodeType *ntype,
void (*labelfunc)(struct bNodeTree *ntree, struct bNode *, char *label, int maxlen));
void node_type_update(struct bNodeType *ntype,
- void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
- void (*verifyfunc)(struct bNodeTree *ntree,
- struct bNode *node,
- struct ID *id));
+ void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node));
+void node_type_group_update(struct bNodeType *ntype,
+ void (*group_update_func)(struct bNodeTree *ntree,
+ struct bNode *node));
void node_type_exec(struct bNodeType *ntype,
NodeInitExecFunction initexecfunc,
@@ -776,16 +776,20 @@ void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree);
/* -------------------------------------------------------------------- */
/** \name Node Tree Iterator
*
- * Utility macro for visiting every node tree in the library data, including local bNodeTree blocks in other IDs.
- * This avoids the need for callback functions and allows executing code in a single inner code block.
+ * Utility macro for visiting every node tree in the library data,
+ * including local bNodeTree blocks in other IDs.
+ * This avoids the need for callback functions and allows executing code
+ * in a single inner code block.
*
* Variables:
*
- * nodetree: The actual bNodeTree data block.
- * Check nodetree->idname or nodetree->typeinfo to use only specific types.
+ * - nodetree:
+ * The actual bNodeTree data block.
+ * Check nodetree->idname or nodetree->typeinfo to use only specific types.
*
- * id: The owner of the bNodeTree data block.
- * Same as nodetree if it's a linkable node tree from the library.
+ * - id:
+ * The owner of the bNodeTree data block.
+ * Same as nodetree if it's a linkable node tree from the library.
*
* Examples:
*
@@ -853,7 +857,8 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree,
/* note: types are needed to restore callbacks, don't change values */
/* range 1 - 100 is reserved for common nodes */
-/* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
+/* using toolbox, we add node groups by assuming the values below
+ * don't exceed NODE_GROUP_MENU for now. */
//#define SH_NODE_OUTPUT 1
@@ -1144,8 +1149,6 @@ void ntreeCompositExecTree(struct Scene *scene,
const struct ColorManagedDisplaySettings *display_settings,
const char *view_name);
void ntreeCompositTagRender(struct Scene *sce);
-int ntreeCompositTagAnimated(struct bNodeTree *ntree);
-void ntreeCompositTagGenerators(struct bNodeTree *ntree);
void ntreeCompositUpdateRLayers(struct bNodeTree *ntree);
void ntreeCompositRegisterPass(struct bNodeTree *ntree,
struct Scene *scene,
@@ -1220,7 +1223,6 @@ struct TexResult;
#define TEX_NODE_PROC_MAX 600
/* API */
-int ntreeTexTagAnimated(struct bNodeTree *ntree);
void ntreeTexCheckCyclics(struct bNodeTree *ntree);
struct bNodeTreeExec *ntreeTexBeginExecTree(struct bNodeTree *ntree);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index ab7ca44368c..49b35bfccc1 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -153,7 +153,7 @@ struct Object *BKE_object_duplicate(struct Main *bmain,
void BKE_object_obdata_size_init(struct Object *ob, const float scale);
void BKE_object_scale_to_mat3(struct Object *ob, float mat[3][3]);
-void BKE_object_rot_to_mat3(struct Object *ob, float mat[3][3], bool use_drot);
+void BKE_object_rot_to_mat3(const struct Object *ob, float mat[3][3], bool use_drot);
void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat);
void BKE_object_to_mat3(struct Object *ob, float mat[3][3]);
void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index b0fbf07d467..56c92b731b7 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -145,6 +145,7 @@ void BKE_paint_runtime_init(const struct ToolSettings *ts, struct Paint *paint);
void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode);
+bool BKE_paint_ensure_from_paintmode(struct Scene *sce, ePaintMode mode);
struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode);
const struct EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode);
const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index feb40d86151..f9bd722f8ba 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -201,21 +201,24 @@ typedef struct ParticleCollisionElement {
short inv_nor, inside;
} ParticleCollisionElement;
-/* container for moving data between deflet_particle and particle_intersect_face */
+/** Container for moving data between deflet_particle and particle_intersect_face. */
typedef struct ParticleCollision {
struct Object *current;
struct Object *hit;
struct Object *skip[PARTICLE_COLLISION_MAX_COLLISIONS + 1];
struct Object *emitter;
- struct CollisionModifierData *md; // collision modifier for current object;
+ /** Collision modifier for current object. */
+ struct CollisionModifierData *md;
- float f; // time factor of previous collision, needed for substracting face velocity
+ /** Time factor of previous collision, needed for substracting face velocity. */
+ float f;
float fac1, fac2;
float cfra, old_cfra;
- float original_ray_length; //original length of co2-co1, needed for collision time evaluation
+ /** Original length of co2-co1, needed for collision time evaluation. */
+ float original_ray_length;
int skip_count;
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 049fc585b56..f59288f54bd 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -67,6 +67,7 @@ void BKE_pbvh_build_mesh(PBVH *bvh,
struct MVert *verts,
int totvert,
struct CustomData *vdata,
+ struct CustomData *ldata,
const struct MLoopTri *looptri,
int looptri_num);
void BKE_pbvh_build_grids(PBVH *bvh,
@@ -153,6 +154,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
bool fast,
bool wires,
bool only_mask,
+ bool show_vcol,
void (*draw_fn)(void *user_data, struct GPUBatch *batch),
void *user_data);
@@ -398,8 +400,8 @@ void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node,
bool BKE_pbvh_node_vert_update_check_any(PBVH *bvh, PBVHNode *node);
-//void BKE_pbvh_node_BB_reset(PBVHNode *node);
-//void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
+// void BKE_pbvh_node_BB_reset(PBVHNode *node);
+// void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
bool pbvh_has_mask(PBVH *bvh);
void pbvh_show_diffuse_color_set(PBVH *bvh, bool show_diffuse_color);
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 8a8ae3e2566..6ce60081f5b 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -167,7 +167,8 @@ typedef struct PTCacheID {
void (*interpolate_extra_data)(
void *calldata, struct PTCacheMem *pm, float cfra, float cfra1, float cfra2);
- /* total number of simulated points (the cfra parameter is just for using same function pointer with totwrite) */
+ /* Total number of simulated points
+ * (the cfra parameter is just for using same function pointer with totwrite). */
int (*totpoint)(void *calldata, int cfra);
/* report error if number of points does not match */
void (*error)(void *calldata, const char *message);
@@ -265,8 +266,8 @@ typedef struct PTCacheEdit {
struct ParticleSystemModifierData *psmd;
struct ParticleSystemModifierData *psmd_eval;
struct KDTree_3d *emitter_field;
- float *
- emitter_cosnos; /* localspace face centers and normals (average of its verts), from the derived mesh */
+ /* Localspace face centers and normals (average of its verts), from the derived mesh. */
+ float *emitter_cosnos;
int *mirror_cache;
struct ParticleCacheKey **pathcache; /* path cache (runtime) */
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h
index 72bc95028da..c940e646d95 100644
--- a/source/blender/blenkernel/BKE_rigidbody.h
+++ b/source/blender/blenkernel/BKE_rigidbody.h
@@ -106,7 +106,8 @@ void BKE_rigidbody_remove_constraint(struct Scene *scene, struct Object *ob);
(rbo->flag & RBO_FLAG_DISABLED))) ? \
(0.0f) : \
(rbo->mass))
-/* get collision margin for Rigid Body Object, triangle mesh and cone shapes cannot embed margin, convex hull always uses custom margin */
+/* Get collision margin for Rigid Body Object, triangle mesh and cone shapes cannot embed margin,
+ * convex hull always uses custom margin. */
#define RBO_GET_MARGIN(rbo) \
((rbo->flag & RBO_FLAG_USE_MARGIN || rbo->shape == RB_SHAPE_CONVEXH || \
rbo->shape == RB_SHAPE_TRIMESH || rbo->shape == RB_SHAPE_CONE) ? \
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 6cd71604561..75ff5eace3c 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -102,7 +102,6 @@ int BKE_scene_base_iter_next(struct Depsgraph *depsgraph,
void BKE_scene_base_flag_to_objects(struct ViewLayer *view_layer);
void BKE_scene_object_base_flag_sync_from_base(struct Base *base);
-void BKE_scene_object_base_flag_sync_from_object(struct Base *base);
void BKE_scene_set_background(struct Main *bmain, struct Scene *sce);
struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name);
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 6a9711dd316..93c9c41e482 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -182,7 +182,8 @@ typedef struct ARegionType {
int prefsizex, prefsizey;
/* default keymaps to add */
int keymapflag;
- /* return without drawing. lock is set by region definition, and copied to do_lock by render. can become flag */
+ /* return without drawing.
+ * lock is set by region definition, and copied to do_lock by render. can become flag. */
short do_lock, lock;
/* call cursor function on each move event */
short event_cursor;
@@ -337,7 +338,8 @@ struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
void BKE_area_region_panels_free(struct ListBase *panels);
void BKE_screen_area_free(struct ScrArea *sa);
-/* Gizmo-maps of a region need to be freed with the region. Uses callback to avoid low-level call. */
+/* Gizmo-maps of a region need to be freed with the region.
+ * Uses callback to avoid low-level call. */
void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *));
void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *));
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 820f28fb363..017c15ebe41 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -100,7 +100,6 @@ typedef struct SeqRenderData {
/* special case for OpenGL render */
struct GPUOffScreen *gpu_offscreen;
- struct GPUFX *gpu_fx;
int gpu_samples;
bool gpu_full_samples;
} SeqRenderData;
@@ -302,46 +301,33 @@ void BKE_sequencer_proxy_set(struct Sequence *seq, bool value);
* Sequencer memory cache management functions
* ********************************************************************** */
-typedef enum {
- SEQ_STRIPELEM_IBUF,
- SEQ_STRIPELEM_IBUF_COMP,
- SEQ_STRIPELEM_IBUF_STARTSTILL,
- SEQ_STRIPELEM_IBUF_ENDSTILL,
-} eSeqStripElemIBuf;
+#define SEQ_CACHE_COST_MAX 10.0f
-void BKE_sequencer_cache_destruct(void);
-void BKE_sequencer_cache_cleanup(void);
-
-/* returned ImBuf is properly refed and has to be freed */
struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
struct Sequence *seq,
float cfra,
- eSeqStripElemIBuf type);
-
-/* passed ImBuf is properly refed, so ownership is *not*
- * transferred to the cache.
- * you can pass the same ImBuf multiple times to the cache without problems.
- */
-
+ int type);
void BKE_sequencer_cache_put(const SeqRenderData *context,
struct Sequence *seq,
float cfra,
- eSeqStripElemIBuf type,
- struct ImBuf *nval);
-
-void BKE_sequencer_cache_cleanup_sequence(struct Sequence *seq);
-
-struct ImBuf *BKE_sequencer_preprocessed_cache_get(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- eSeqStripElemIBuf type);
-void BKE_sequencer_preprocessed_cache_put(const SeqRenderData *context,
- struct Sequence *seq,
- float cfra,
- eSeqStripElemIBuf type,
- struct ImBuf *ibuf);
-void BKE_sequencer_preprocessed_cache_cleanup(void);
-void BKE_sequencer_preprocessed_cache_cleanup_sequence(struct Sequence *seq);
+ int type,
+ struct ImBuf *nval,
+ float cost);
+bool BKE_sequencer_cache_put_if_possible(const SeqRenderData *context,
+ struct Sequence *seq,
+ float cfra,
+ int type,
+ struct ImBuf *nval,
+ float cost);
+void BKE_sequencer_cache_free_temp_cache(struct Scene *scene, short id, int cfra);
+void BKE_sequencer_cache_destruct(struct Scene *scene);
+void BKE_sequencer_cache_cleanup_all(struct Main *bmain);
+void BKE_sequencer_cache_cleanup(struct Scene *scene);
+void BKE_sequencer_cache_cleanup_sequence(struct Scene *scene, struct Sequence *seq);
+void BKE_sequencer_cache_iterate(
+ struct Scene *scene,
+ void *userdata,
+ bool callback(void *userdata, struct Sequence *seq, int cfra, int cache_type, float cost));
/* **********************************************************************
* seqeffects.c
@@ -500,19 +486,9 @@ struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C,
ListBase *seqbasep,
struct SeqLoadInfo *seq_load);
-/* view3d draw callback, run when not in background view */
-/* NOTE: Keep in sync with V3D_OFSDRAW_* flags. */
-enum {
- SEQ_OFSDRAW_NONE = (0),
- SEQ_OFSDRAW_USE_BACKGROUND = (1 << 0),
- SEQ_OFSDRAW_USE_FULL_SAMPLE = (1 << 1),
- SEQ_OFSDRAW_USE_GPENCIL = (1 << 2),
- SEQ_OFSDRAW_USE_SOLID_TEX = (1 << 2),
- SEQ_OFSDRAW_USE_CAMERA_DOF = (1 << 3),
-};
-
typedef struct ImBuf *(*SequencerDrawView)(struct Depsgraph *depsgraph,
struct Scene *scene,
+ struct View3DShading *shading_override,
int drawtype,
struct Object *camera,
int width,
@@ -590,6 +566,6 @@ void BKE_sequencer_color_balance_apply(struct StripColorBalance *cb,
bool make_float,
struct ImBuf *mask_input);
-void BKE_sequencer_all_free_anim_ibufs(struct Main *bmain, int cfra);
+void BKE_sequencer_all_free_anim_ibufs(struct Scene *scene, int cfra);
#endif /* __BKE_SEQUENCER_H__ */
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index d97525d4094..8993654254e 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -112,7 +112,8 @@ void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd,
int numVerts);
/*
- * This function casts a ray in the given BVHTree.. but it takes into consideration the space_transform, that is:
+ * This function casts a ray in the given BVHTree.
+ * but it takes into consideration the space_transform, that is:
*
* if transf was configured with "SPACE_TRANSFORM_SETUP( &transf, ob1, ob2 )"
* then the input (vert, dir, BVHTreeRayHit) must be defined in ob1 coordinates space
@@ -129,7 +130,8 @@ bool BKE_shrinkwrap_project_normal(char options,
struct ShrinkwrapTreeData *tree,
BVHTreeRayHit *hit);
-/* Maps the point to the nearest surface, either by simple nearest, or by target normal projection. */
+/* Maps the point to the nearest surface, either by simple nearest,
+ * or by target normal projection. */
void BKE_shrinkwrap_find_nearest_surface(struct ShrinkwrapTreeData *tree,
struct BVHTreeNearest *nearest,
float co[3],
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index 049950f2a03..e0a8b7f9d5d 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -37,8 +37,8 @@ typedef struct BodyPoint {
int *springs;
float choke, choke2, frozen;
float colball;
- short loc_flag; //reserved by locale module specific states
- //char octantflag;
+ short loc_flag; // reserved by locale module specific states
+ // char octantflag;
float mass;
float springweight;
} BodyPoint;
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index 9d917f0e420..91e23d35f0e 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -61,7 +61,10 @@ struct bSound *BKE_sound_new_file_exists(struct Main *bmain, const char *filepat
#if 0
struct bSound *BKE_sound_new_buffer(struct Main *bmain, struct bSound *source);
-struct bSound *BKE_sound_new_limiter(struct Main *bmain, struct bSound *source, float start, float end);
+struct bSound *BKE_sound_new_limiter(struct Main *bmain,
+ struct bSound *source,
+ float start,
+ float end);
#endif
void BKE_sound_cache(struct bSound *sound);
diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h
index 6852c3ee970..d4cb9331605 100644
--- a/source/blender/blenkernel/BKE_undo_system.h
+++ b/source/blender/blenkernel/BKE_undo_system.h
@@ -92,7 +92,8 @@ typedef struct UndoType {
/**
* When NULL, we don't consider this undo type for context checks.
* Operators must explicitly set the undo type and handle adding the undo step.
- * This is needed when tools operate on data which isn't the primary mode (eg, paint-curve in sculpt mode).
+ * This is needed when tools operate on data which isn't the primary mode
+ * (eg, paint-curve in sculpt mode).
*/
bool (*poll)(struct bContext *C);
@@ -187,7 +188,9 @@ void BKE_undosys_type_free_all(void);
/* ID Accessor */
#if 0 /* functionality is only used internally for now. */
-void BKE_undosys_foreach_ID_ref(UndoStack *ustack, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data);
+void BKE_undosys_foreach_ID_ref(UndoStack *ustack,
+ UndoTypeForEachIDRefFn foreach_ID_ref_fn,
+ void *user_data);
#endif
/* Use when the undo step stores many arbitrary pointers. */
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index 17973265390..4f9ff61c9a6 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -63,7 +63,7 @@ double bUnit_BaseScalar(int system, int type);
bool bUnit_IsValid(int system, int type);
/* loop over scales, could add names later */
-//double bUnit_Iter(void **unit, char **name, int system, int type);
+// double bUnit_Iter(void **unit, char **name, int system, int type);
void bUnit_GetSystem(int system, int type, void const **r_usys_pt, int *r_len);
int bUnit_GetBaseUnit(const void *usys_pt);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 019ab929f16..e564e91749c 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -24,31 +24,32 @@ set(INC
../blenlib
../blenloader
../blentranslation
+ ../bmesh
../depsgraph
../draw
+ ../gpencil_modifiers
../gpu
../ikplugin
../imbuf
../makesdna
../makesrna
- ../bmesh
../modifiers
- ../gpencil_modifiers
- ../shader_fx
../nodes
../physics
+ ../shader_fx
../render/extern/include
../../../intern/ghost
- ../../../intern/guardedalloc
../../../intern/glew-mx
+ ../../../intern/guardedalloc
../../../intern/iksolver/extern
- ../../../intern/memutil
- ../../../intern/mikktspace
../../../intern/atomic
../../../intern/clog
../../../intern/libmv
+ ../../../intern/memutil
+ ../../../intern/mikktspace
../../../intern/opensubdiv
../../../extern/curve_fit_nd
+ ../../../intern/smoke/extern
)
set(INC_SYS
@@ -120,6 +121,7 @@ set(SRC
intern/idprop_utils.c
intern/image.c
intern/image_gen.c
+ intern/image_save.c
intern/ipo.c
intern/key.c
intern/keyconfig.c
@@ -274,6 +276,7 @@ set(SRC
BKE_idcode.h
BKE_idprop.h
BKE_image.h
+ BKE_image_save.h
BKE_ipo.h
BKE_key.h
BKE_keyconfig.h
@@ -519,9 +522,6 @@ if(WITH_MOD_FLUID)
endif()
if(WITH_MOD_SMOKE)
- list(APPEND INC
- ../../../intern/smoke/extern
- )
list(APPEND LIB
bf_intern_smoke
)
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 2ab6eb387aa..49855de0591 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -73,8 +73,9 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss)
userData = ccgSubSurf_getVertUserData(ss, v);
memset(userData, 0, ss->meshIFC.vertUserSize);
- if (ss->useAgeCounts)
+ if (ss->useAgeCounts) {
*((int *)&userData[ss->vertUserAgeOffset]) = ss->currentAge;
+ }
return v;
}
@@ -155,8 +156,9 @@ static CCGEdge *_edge_new(CCGEdgeHDL eHDL, CCGVert *v0, CCGVert *v1, float creas
userData = ccgSubSurf_getEdgeUserData(ss, e);
memset(userData, 0, ss->meshIFC.edgeUserSize);
- if (ss->useAgeCounts)
+ if (ss->useAgeCounts) {
*((int *)&userData[ss->edgeUserAgeOffset]) = ss->currentAge;
+ }
return e;
}
@@ -229,8 +231,9 @@ static CCGFace *_face_new(
userData = ccgSubSurf_getFaceUserData(ss, f);
memset(userData, 0, ss->meshIFC.faceUserSize);
- if (ss->useAgeCounts)
+ if (ss->useAgeCounts) {
*((int *)&userData[ss->faceUserAgeOffset]) = ss->currentAge;
+ }
return f;
}
@@ -354,8 +357,9 @@ void ccgSubSurf_free(CCGSubSurf *ss)
CCGSUBSURF_free(ss, ss->r);
CCGSUBSURF_free(ss, ss->q);
- if (ss->defaultEdgeUserData)
+ if (ss->defaultEdgeUserData) {
CCGSUBSURF_free(ss, ss->defaultEdgeUserData);
+ }
ccg_ehash_free(ss->fMap, (EHEntryFreeFP)_face_free, ss);
ccg_ehash_free(ss->eMap, (EHEntryFreeFP)_edge_free, ss);
@@ -395,13 +399,16 @@ void ccgSubSurf_getAllowEdgeCreation(CCGSubSurf *ss,
float *defaultCreaseValue_r,
void *defaultUserData_r)
{
- if (allowEdgeCreation_r)
+ if (allowEdgeCreation_r) {
*allowEdgeCreation_r = ss->allowEdgeCreation;
+ }
if (ss->allowEdgeCreation) {
- if (defaultCreaseValue_r)
+ if (defaultCreaseValue_r) {
*defaultCreaseValue_r = ss->defaultCreaseValue;
- if (defaultUserData_r)
+ }
+ if (defaultUserData_r) {
memcpy(defaultUserData_r, ss->defaultEdgeUserData, ss->meshIFC.edgeUserSize);
+ }
}
}
@@ -432,12 +439,15 @@ void ccgSubSurf_getUseAgeCounts(CCGSubSurf *ss,
{
*useAgeCounts_r = ss->useAgeCounts;
- if (vertUserOffset_r)
+ if (vertUserOffset_r) {
*vertUserOffset_r = ss->vertUserAgeOffset;
- if (edgeUserOffset_r)
+ }
+ if (edgeUserOffset_r) {
*edgeUserOffset_r = ss->edgeUserAgeOffset;
- if (faceUserOffset_r)
+ }
+ if (faceUserOffset_r) {
*faceUserOffset_r = ss->faceUserAgeOffset;
+ }
}
CCGError ccgSubSurf_setUseAgeCounts(
@@ -666,8 +676,9 @@ CCGError ccgSubSurf_syncVert(
#endif
}
- if (v_r)
+ if (v_r) {
*v_r = v;
+ }
return eCCGError_None;
}
@@ -731,8 +742,9 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss,
}
}
- if (e_r)
+ if (e_r) {
*e_r = e;
+ }
return eCCGError_None;
}
@@ -783,8 +795,9 @@ CCGError ccgSubSurf_syncFace(
ccg_ehash_insert(ss->fMap, (EHEntry *)fNew);
}
- for (k = 0; k < numVerts; k++)
+ for (k = 0; k < numVerts; k++) {
FACE_getVerts(fNew)[k]->flags |= Vert_eEffected;
+ }
}
}
else {
@@ -800,8 +813,9 @@ CCGError ccgSubSurf_syncFace(
for (k = 0; k < numVerts; k++) {
ss->tempVerts[k] = ccg_ehash_lookup(ss->vMap, vHDLs[k]);
- if (!ss->tempVerts[k])
+ if (!ss->tempVerts[k]) {
return eCCGError_InvalidValue;
+ }
}
for (k = 0; k < numVerts; k++) {
ss->tempEdges[k] = _vert_findEdgeTo(ss->tempVerts[k], ss->tempVerts[(k + 1) % numVerts]);
@@ -841,8 +855,9 @@ CCGError ccgSubSurf_syncFace(
ccg_ehash_insert(ss->fMap, (EHEntry *)f);
ss->numGrids += numVerts;
- for (k = 0; k < numVerts; k++)
+ for (k = 0; k < numVerts; k++) {
FACE_getVerts(f)[k]->flags |= Vert_eEffected;
+ }
}
else {
*prevp = f->next;
@@ -852,8 +867,9 @@ CCGError ccgSubSurf_syncFace(
for (j = 0; j < f->numVerts; j++) {
if (FACE_getVerts(f)[j]->flags & Vert_eChanged) {
- for (k = 0; k < f->numVerts; k++)
+ for (k = 0; k < f->numVerts; k++) {
FACE_getVerts(f)[k]->flags |= Vert_eEffected;
+ }
break;
}
}
@@ -869,8 +885,9 @@ CCGError ccgSubSurf_syncFace(
#endif
}
- if (f_r)
+ if (f_r) {
*f_r = f;
+ }
return eCCGError_None;
}
@@ -929,8 +946,9 @@ void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces, int *
for (i = 0; i < ss->fMap->curSize; i++) {
CCGFace *f = (CCGFace *)ss->fMap->buckets[i];
- for (; f; f = f->next)
+ for (; f; f = f->next) {
array[num++] = f;
+ }
}
*faces = array;
@@ -967,9 +985,11 @@ void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss,
CCGVert *v = (CCGVert *)ss->vMap->buckets[i];
for (; v; v = v->next) {
- for (j = 0; j < v->numFaces; j++)
- if (!(v->faces[j]->flags & Face_eEffected))
+ for (j = 0; j < v->numFaces; j++) {
+ if (!(v->faces[j]->flags & Face_eEffected)) {
break;
+ }
+ }
if (j == v->numFaces) {
arrayV[numV++] = v;
@@ -982,9 +1002,11 @@ void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss,
CCGEdge *e = (CCGEdge *)ss->eMap->buckets[i];
for (; e; e = e->next) {
- for (j = 0; j < e->numFaces; j++)
- if (!(e->faces[j]->flags & Face_eEffected))
+ for (j = 0; j < e->numFaces; j++) {
+ if (!(e->faces[j]->flags & Face_eEffected)) {
break;
+ }
+ }
if (j == e->numFaces) {
e->flags |= Edge_eEffected;
@@ -1023,8 +1045,9 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
VertDataCopy(
VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss);
- for (x = 0; x < gridSize; x++)
+ for (x = 0; x < gridSize; x++) {
VertDataCopy(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0), ss);
+ }
for (x = 0; x < gridSize; x++) {
int eI = gridSize - 1 - x;
@@ -1038,8 +1061,9 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
}
}
- if (freeF)
+ if (freeF) {
MEM_freeN(effectedF);
+ }
return eCCGError_None;
}
@@ -1086,8 +1110,9 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
}
}
- if (freeF)
+ if (freeF) {
MEM_freeN(effectedF);
+ }
return eCCGError_None;
}
@@ -1115,16 +1140,19 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
/* zero */
for (i = 0; i < numEffectedV; i++) {
CCGVert *v = effectedV[i];
- if (v->numFaces)
+ if (v->numFaces) {
VertDataZero(VERT_getCo(v, lvl), ss);
+ }
}
for (i = 0; i < numEffectedE; i++) {
CCGEdge *e = effectedE[i];
- if (e->numFaces)
- for (x = 0; x < edgeSize; x++)
+ if (e->numFaces) {
+ for (x = 0; x < edgeSize; x++) {
VertDataZero(EDGE_getCo(e, lvl, x), ss);
+ }
+ }
}
/* add */
@@ -1133,9 +1161,11 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
VertDataZero((float *)FACE_getCenterData(f), ss);
- for (S = 0; S < f->numVerts; S++)
- for (x = 0; x < gridSize; x++)
+ for (S = 0; S < f->numVerts; S++) {
+ for (x = 0; x < gridSize; x++) {
VertDataZero(FACE_getIECo(f, lvl, S, x), ss);
+ }
+ }
for (S = 0; S < f->numVerts; S++) {
int prevS = (S + f->numVerts - 1) % f->numVerts;
@@ -1143,10 +1173,11 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
CCGEdge *prevE = FACE_getEdges(f)[prevS];
VertDataAdd((float *)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
- if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
+ if (FACE_getVerts(f)[S]->flags & Vert_eEffected) {
VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl),
FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx),
ss);
+ }
for (x = 1; x < gridSize - 1; x++) {
VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0), ss);
@@ -1155,15 +1186,18 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
for (x = 0; x < gridSize - 1; x++) {
int eI = gridSize - 1 - x;
- if (FACE_getEdges(f)[S]->flags & Edge_eEffected)
+ if (FACE_getEdges(f)[S]->flags & Edge_eEffected) {
VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize),
FACE_getIFCo(f, lvl, S, cornerIdx, x),
ss);
- if (FACE_getEdges(f)[prevS]->flags & Edge_eEffected)
- if (x != 0)
+ }
+ if (FACE_getEdges(f)[prevS]->flags & Edge_eEffected) {
+ if (x != 0) {
VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize),
FACE_getIFCo(f, lvl, S, x, cornerIdx),
ss);
+ }
+ }
}
}
}
@@ -1171,8 +1205,9 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
/* average */
for (i = 0; i < numEffectedV; i++) {
CCGVert *v = effectedV[i];
- if (v->numFaces)
+ if (v->numFaces) {
VertDataMulN(VERT_getCo(v, lvl), 1.0f / v->numFaces, ss);
+ }
}
for (i = 0; i < numEffectedE; i++) {
@@ -1181,9 +1216,11 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
VertDataCopy(EDGE_getCo(e, lvl, 0), VERT_getCo(e->v0, lvl), ss);
VertDataCopy(EDGE_getCo(e, lvl, edgeSize - 1), VERT_getCo(e->v1, lvl), ss);
- if (e->numFaces)
- for (x = 1; x < edgeSize - 1; x++)
+ if (e->numFaces) {
+ for (x = 1; x < edgeSize - 1; x++) {
VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f / e->numFaces, ss);
+ }
+ }
}
/* copy */
@@ -1192,9 +1229,11 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
VertDataMulN((float *)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
- for (S = 0; S < f->numVerts; S++)
- for (x = 1; x < gridSize - 1; x++)
+ for (S = 0; S < f->numVerts; S++) {
+ for (x = 1; x < gridSize - 1; x++) {
VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f, ss);
+ }
+ }
for (S = 0; S < f->numVerts; S++) {
int prevS = (S + f->numVerts - 1) % f->numVerts;
@@ -1227,17 +1266,21 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
}
}
- for (i = 0; i < numEffectedV; i++)
+ for (i = 0; i < numEffectedV; i++) {
effectedV[i]->flags = 0;
- for (i = 0; i < numEffectedE; i++)
+ }
+ for (i = 0; i < numEffectedE; i++) {
effectedE[i]->flags = 0;
- for (i = 0; i < numEffectedF; i++)
+ }
+ for (i = 0; i < numEffectedF; i++) {
effectedF[i]->flags = 0;
+ }
MEM_freeN(effectedE);
MEM_freeN(effectedV);
- if (freeF)
+ if (freeF) {
MEM_freeN(effectedF);
+ }
return eCCGError_None;
}
@@ -1616,20 +1659,24 @@ void CCG_key(CCGKey *key, const CCGSubSurf *ss, int level)
/* if normals are present, always the last three floats of an
* element */
- if (key->has_normals)
+ if (key->has_normals) {
key->normal_offset = key->elem_size - sizeof(float) * 3;
- else
+ }
+ else {
key->normal_offset = -1;
+ }
key->grid_size = ccgSubSurf_getGridLevelSize(ss, level);
key->grid_area = key->grid_size * key->grid_size;
key->grid_bytes = key->elem_size * key->grid_area;
key->has_mask = ss->allocMask;
- if (key->has_mask)
+ if (key->has_mask) {
key->mask_offset = ss->maskDataOffset;
- else
+ }
+ else {
key->mask_offset = -1;
+ }
}
void CCG_key_top_level(CCGKey *key, const CCGSubSurf *ss)
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_inline.h b/source/blender/blenkernel/intern/CCGSubSurf_inline.h
index 44e27cb89da..86012bd2a43 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_inline.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf_inline.h
@@ -144,18 +144,22 @@ BLI_INLINE float *ccg_face_getIFNo(
BLI_INLINE int ccg_face_getVertIndex(CCGFace *f, CCGVert *v)
{
int i;
- for (i = 0; i < f->numVerts; i++)
- if (FACE_getVerts(f)[i] == v)
+ for (i = 0; i < f->numVerts; i++) {
+ if (FACE_getVerts(f)[i] == v) {
return i;
+ }
+ }
return -1;
}
BLI_INLINE int ccg_face_getEdgeIndex(CCGFace *f, CCGEdge *e)
{
int i;
- for (i = 0; i < f->numVerts; i++)
- if (FACE_getEdges(f)[i] == e)
+ for (i = 0; i < f->numVerts; i++) {
+ if (FACE_getEdges(f)[i] == e) {
return i;
+ }
+ }
return -1;
}
@@ -214,8 +218,9 @@ BLI_INLINE int VertDataEqual(const float a[], const float b[], const CCGSubSurf
{
int i;
for (i = 0; i < ss->meshIFC.numLayers; i++) {
- if (a[i] != b[i])
+ if (a[i] != b[i]) {
return 0;
+ }
}
return 1;
}
@@ -228,29 +233,33 @@ BLI_INLINE void VertDataZero(float v[], const CCGSubSurf *ss)
BLI_INLINE void VertDataCopy(float dst[], const float src[], const CCGSubSurf *ss)
{
int i;
- for (i = 0; i < ss->meshIFC.numLayers; i++)
+ for (i = 0; i < ss->meshIFC.numLayers; i++) {
dst[i] = src[i];
+ }
}
BLI_INLINE void VertDataAdd(float a[], const float b[], const CCGSubSurf *ss)
{
int i;
- for (i = 0; i < ss->meshIFC.numLayers; i++)
+ for (i = 0; i < ss->meshIFC.numLayers; i++) {
a[i] += b[i];
+ }
}
BLI_INLINE void VertDataSub(float a[], const float b[], const CCGSubSurf *ss)
{
int i;
- for (i = 0; i < ss->meshIFC.numLayers; i++)
+ for (i = 0; i < ss->meshIFC.numLayers; i++) {
a[i] -= b[i];
+ }
}
BLI_INLINE void VertDataMulN(float v[], float f, const CCGSubSurf *ss)
{
int i;
- for (i = 0; i < ss->meshIFC.numLayers; i++)
+ for (i = 0; i < ss->meshIFC.numLayers; i++) {
v[i] *= f;
+ }
}
BLI_INLINE void VertDataAvg4(float v[],
@@ -261,8 +270,9 @@ BLI_INLINE void VertDataAvg4(float v[],
const CCGSubSurf *ss)
{
int i;
- for (i = 0; i < ss->meshIFC.numLayers; i++)
+ for (i = 0; i < ss->meshIFC.numLayers; i++) {
v[i] = (a[i] + b[i] + c[i] + d[i]) * 0.25f;
+ }
}
#endif /* __CCGSUBSURF_INLINE_H__ */
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_intern.h b/source/blender/blenkernel/intern/CCGSubSurf_intern.h
index f89545e802e..41a34b65381 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_intern.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf_intern.h
@@ -269,7 +269,10 @@ struct CCGSubSurf {
#define EDGE_getNo(e, lvl, x) ccg_edge_getNo(e, lvl, x, vertDataSize, normalDataOffset)
#define FACE_getIFNo(f, lvl, S, x, y) \
ccg_face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset)
-//#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
+#if 0
+# define FACE_calcIFNo(f, lvl, S, x, y, no) \
+ _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize)
+#endif
#define FACE_getIENo(f, lvl, S, x) \
ccg_face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset)
#define FACE_getIECo(f, lvl, S, x) ccg_face_getIECo(f, lvl, S, x, subdivLevels, vertDataSize)
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c
index 430a8ef56f5..720c828664a 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c
@@ -52,9 +52,11 @@ static int _edge_isBoundary(const CCGEdge *e)
static int _vert_isBoundary(const CCGVert *v)
{
int i;
- for (i = 0; i < v->numEdges; i++)
- if (_edge_isBoundary(v->edges[i]))
+ for (i = 0; i < v->numEdges; i++) {
+ if (_edge_isBoundary(v->edges[i])) {
return 1;
+ }
+ }
return 0;
}
@@ -106,14 +108,18 @@ static int VERT_seam(const CCGVert *v)
static float EDGE_getSharpness(CCGEdge *e, int lvl)
{
- if (!lvl)
+ if (!lvl) {
return e->crease;
- else if (!e->crease)
+ }
+ else if (!e->crease) {
return 0.0f;
- else if (e->crease - lvl < 0.0f)
+ }
+ else if (e->crease - lvl < 0.0f) {
return 0.0f;
- else
+ }
+ else {
return e->crease - lvl;
+ }
}
typedef struct CCGSubSurfCalcSubdivData {
@@ -181,10 +187,12 @@ static void ccgSubSurf__calcVertNormals_faces_accumulate_cb(
FACE_calcIFNo(f, lvl, S, x, y, no);
NormAdd(FACE_getIFNo(f, lvl, S, x + 0, y + 0), no);
- if (xPlusOk)
+ if (xPlusOk) {
NormAdd(FACE_getIFNo(f, lvl, S, x + 1, y + 0), no);
- if (yPlusOk)
+ }
+ if (yPlusOk) {
NormAdd(FACE_getIFNo(f, lvl, S, x + 0, y + 1), no);
+ }
if (xPlusOk && yPlusOk) {
if (x < gridSize - 2 || y < gridSize - 2 ||
FACE_getVerts(f)[S]->flags & Vert_eEffected) {
@@ -195,10 +203,12 @@ static void ccgSubSurf__calcVertNormals_faces_accumulate_cb(
if (x == 0 && y == 0) {
int K;
- if (!yLimitNext || 1 < gridSize - 1)
+ if (!yLimitNext || 1 < gridSize - 1) {
NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, 1), no);
- if (!xLimitPrev || 1 < gridSize - 1)
+ }
+ if (!xLimitPrev || 1 < gridSize - 1) {
NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, 1, 0), no);
+ }
for (K = 0; K < f->numVerts; K++) {
if (K != S) {
@@ -208,13 +218,15 @@ static void ccgSubSurf__calcVertNormals_faces_accumulate_cb(
}
else if (y == 0) {
NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, x), no);
- if (!yLimitNext || x < gridSize - 2)
+ if (!yLimitNext || x < gridSize - 2) {
NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, x + 1), no);
+ }
}
else if (x == 0) {
NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, y, 0), no);
- if (!xLimitPrev || y < gridSize - 2)
+ if (!xLimitPrev || y < gridSize - 2) {
NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, y + 1, 0), no);
+ }
}
}
}
@@ -390,10 +402,11 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
int x;
const int f_ed_idx = ccg_face_getEdgeIndex(f, e);
- for (x = 0; x < edgeSize; x++)
+ for (x = 0; x < edgeSize; x++) {
NormCopy(EDGE_getNo(e, lvl, x),
_face_getIFNoEdge(
f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
+ }
}
else {
/* set to zero here otherwise the normals are uninitialized memory
@@ -763,8 +776,9 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
CCGEdge *e = v->edges[j];
float sharpness = EDGE_getSharpness(e, curLvl);
- if (seam && _edge_isBoundary(e))
+ if (seam && _edge_isBoundary(e)) {
seamEdges++;
+ }
if (sharpness != 0.0f) {
sharpCount++;
@@ -782,8 +796,9 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
}
- if (seamEdges < 2 || seamEdges != v->numEdges)
+ if (seamEdges < 2 || seamEdges != v->numEdges) {
seam = 0;
+ }
if (!v->numEdges || ss->meshIFC.simpleSubdiv) {
VertDataCopy(nCo, co, ss);
@@ -846,8 +861,9 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
float sharpness = EDGE_getSharpness(e, curLvl);
if (seam) {
- if (_edge_isBoundary(e))
+ if (_edge_isBoundary(e)) {
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss);
+ }
}
else if (sharpness != 0.0f) {
VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss);
@@ -1104,8 +1120,9 @@ void ccgSubSurf__sync_legacy(CCGSubSurf *ss)
CCGEdge *e = v->edges[i];
float sharpness = EDGE_getSharpness(e, curLvl);
- if (seam && _edge_isBoundary(e))
+ if (seam && _edge_isBoundary(e)) {
seamEdges++;
+ }
if (sharpness != 0.0f) {
sharpCount++;
@@ -1123,8 +1140,9 @@ void ccgSubSurf__sync_legacy(CCGSubSurf *ss)
}
}
- if (seamEdges < 2 || seamEdges != v->numEdges)
+ if (seamEdges < 2 || seamEdges != v->numEdges) {
seam = 0;
+ }
if (!v->numEdges || ss->meshIFC.simpleSubdiv) {
VertDataCopy(nCo, co, ss);
@@ -1267,13 +1285,15 @@ void ccgSubSurf__sync_legacy(CCGSubSurf *ss)
}
}
- for (curLvl = 1; curLvl < subdivLevels; curLvl++)
+ for (curLvl = 1; curLvl < subdivLevels; curLvl++) {
ccgSubSurf__calcSubdivLevel(
ss, effectedV, effectedE, effectedF, numEffectedV, numEffectedE, numEffectedF, curLvl);
+ }
- if (ss->calcVertNormals)
+ if (ss->calcVertNormals) {
ccgSubSurf__calcVertNormals(
ss, effectedV, effectedE, effectedF, numEffectedV, numEffectedE, numEffectedF);
+ }
for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) {
CCGVert *v = effectedV[ptrIdx];
@@ -1306,21 +1326,26 @@ CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEf
ccgSubSurf__effectedFaceNeighbours(
ss, effectedF, numEffectedF, &effectedV, &numEffectedV, &effectedE, &numEffectedE);
- if (ss->calcVertNormals)
+ if (ss->calcVertNormals) {
ccgSubSurf__calcVertNormals(
ss, effectedV, effectedE, effectedF, numEffectedV, numEffectedE, numEffectedF);
+ }
- for (i = 0; i < numEffectedV; i++)
+ for (i = 0; i < numEffectedV; i++) {
effectedV[i]->flags = 0;
- for (i = 0; i < numEffectedE; i++)
+ }
+ for (i = 0; i < numEffectedE; i++) {
effectedE[i]->flags = 0;
- for (i = 0; i < numEffectedF; i++)
+ }
+ for (i = 0; i < numEffectedF; i++) {
effectedF[i]->flags = 0;
+ }
MEM_freeN(effectedE);
MEM_freeN(effectedV);
- if (freeF)
+ if (freeF) {
MEM_freeN(effectedF);
+ }
return eCCGError_None;
}
@@ -1344,17 +1369,21 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i
ss, effectedV, effectedE, effectedF, numEffectedV, numEffectedE, numEffectedF, curLvl);
}
- for (i = 0; i < numEffectedV; i++)
+ for (i = 0; i < numEffectedV; i++) {
effectedV[i]->flags = 0;
- for (i = 0; i < numEffectedE; i++)
+ }
+ for (i = 0; i < numEffectedE; i++) {
effectedE[i]->flags = 0;
- for (i = 0; i < numEffectedF; i++)
+ }
+ for (i = 0; i < numEffectedF; i++) {
effectedF[i]->flags = 0;
+ }
MEM_freeN(effectedE);
MEM_freeN(effectedV);
- if (freeF)
+ if (freeF) {
MEM_freeN(effectedF);
+ }
return eCCGError_None;
}
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c
index 53af82f4c0c..eb04d13d4a0 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv_converter.c
@@ -69,10 +69,12 @@ typedef struct ConvDMStorage {
static OpenSubdiv_SchemeType conv_dm_get_type(const OpenSubdiv_Converter *converter)
{
ConvDMStorage *storage = converter->user_data;
- if (storage->ss->meshIFC.simpleSubdiv)
+ if (storage->ss->meshIFC.simpleSubdiv) {
return OSD_SCHEME_BILINEAR;
- else
+ }
+ else {
return OSD_SCHEME_CATMARK;
+ }
}
static OpenSubdiv_VtxBoundaryInterpolation conv_dm_get_vtx_boundary_interpolation(
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_util.c b/source/blender/blenkernel/intern/CCGSubSurf_util.c
index 9ad1b0cf1b1..ebd4531a67b 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_util.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_util.c
@@ -51,8 +51,9 @@ EHash *ccg_ehash_new(int estimatedNumEntries,
eh->allocator = allocator;
eh->numEntries = 0;
eh->curSizeIdx = 0;
- while (kHashSizes[eh->curSizeIdx] < estimatedNumEntries)
+ while (kHashSizes[eh->curSizeIdx] < estimatedNumEntries) {
eh->curSizeIdx++;
+ }
eh->curSize = kHashSizes[eh->curSizeIdx];
eh->buckets = EHASH_alloc(eh, eh->curSize * sizeof(*eh->buckets));
memset(eh->buckets, 0, eh->curSize * sizeof(*eh->buckets));
@@ -133,8 +134,9 @@ void *ccg_ehash_lookup(EHash *eh, void *key)
EHEntry *entry;
for (entry = eh->buckets[hash]; entry; entry = entry->next) {
- if (entry->key == key)
+ if (entry->key == key) {
break;
+ }
}
return entry;
@@ -151,8 +153,9 @@ void ccg_ehashIterator_init(EHash *eh, EHashIterator *ehi)
while (!ehi->curEntry) {
ehi->curBucket++;
- if (ehi->curBucket == ehi->eh->curSize)
+ if (ehi->curBucket == ehi->eh->curSize) {
break;
+ }
ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
}
}
@@ -168,8 +171,9 @@ void ccg_ehashIterator_next(EHashIterator *ehi)
ehi->curEntry = ehi->curEntry->next;
while (!ehi->curEntry) {
ehi->curBucket++;
- if (ehi->curBucket == ehi->eh->curSize)
+ if (ehi->curBucket == ehi->eh->curSize) {
break;
+ }
ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
}
}
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 2c22f744125..959435ad486 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -175,8 +175,9 @@ static MVert *dm_dupVertArray(DerivedMesh *dm)
{
MVert *tmp = MEM_malloc_arrayN(dm->getNumVerts(dm), sizeof(*tmp), "dm_dupVertArray tmp");
- if (tmp)
+ if (tmp) {
dm->copyVertArray(dm, tmp);
+ }
return tmp;
}
@@ -185,8 +186,9 @@ static MEdge *dm_dupEdgeArray(DerivedMesh *dm)
{
MEdge *tmp = MEM_malloc_arrayN(dm->getNumEdges(dm), sizeof(*tmp), "dm_dupEdgeArray tmp");
- if (tmp)
+ if (tmp) {
dm->copyEdgeArray(dm, tmp);
+ }
return tmp;
}
@@ -195,8 +197,9 @@ static MFace *dm_dupFaceArray(DerivedMesh *dm)
{
MFace *tmp = MEM_malloc_arrayN(dm->getNumTessFaces(dm), sizeof(*tmp), "dm_dupFaceArray tmp");
- if (tmp)
+ if (tmp) {
dm->copyTessFaceArray(dm, tmp);
+ }
return tmp;
}
@@ -205,8 +208,9 @@ static MLoop *dm_dupLoopArray(DerivedMesh *dm)
{
MLoop *tmp = MEM_malloc_arrayN(dm->getNumLoops(dm), sizeof(*tmp), "dm_dupLoopArray tmp");
- if (tmp)
+ if (tmp) {
dm->copyLoopArray(dm, tmp);
+ }
return tmp;
}
@@ -215,8 +219,9 @@ static MPoly *dm_dupPolyArray(DerivedMesh *dm)
{
MPoly *tmp = MEM_malloc_arrayN(dm->getNumPolys(dm), sizeof(*tmp), "dm_dupPolyArray tmp");
- if (tmp)
+ if (tmp) {
dm->copyPolyArray(dm, tmp);
+ }
return tmp;
}
@@ -241,8 +246,8 @@ static const MLoopTri *dm_getLoopTriArray(DerivedMesh *dm)
}
else {
BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_WRITE);
- /* We need to ensure array is still NULL inside mutex-protected code, some other thread might have already
- * recomputed those looptris. */
+ /* We need to ensure array is still NULL inside mutex-protected code,
+ * some other thread might have already recomputed those looptris. */
if (dm->looptris.array == NULL) {
dm->recalcLoopTri(dm);
}
@@ -480,7 +485,8 @@ void DM_ensure_normals(DerivedMesh *dm)
/**
* Ensure the array is large enough
*
- * \note This function must always be thread-protected by caller. It should only be used by internal code.
+ * \note This function must always be thread-protected by caller.
+ * It should only be used by internal code.
*/
void DM_ensure_looptri_data(DerivedMesh *dm)
{
@@ -756,24 +762,27 @@ void *DM_get_poly_data(DerivedMesh *dm, int index, int type)
void *DM_get_vert_data_layer(DerivedMesh *dm, int type)
{
- if (type == CD_MVERT)
+ if (type == CD_MVERT) {
return dm->getVertArray(dm);
+ }
return CustomData_get_layer(&dm->vertData, type);
}
void *DM_get_edge_data_layer(DerivedMesh *dm, int type)
{
- if (type == CD_MEDGE)
+ if (type == CD_MEDGE) {
return dm->getEdgeArray(dm);
+ }
return CustomData_get_layer(&dm->edgeData, type);
}
void *DM_get_tessface_data_layer(DerivedMesh *dm, int type)
{
- if (type == CD_MFACE)
+ if (type == CD_MFACE) {
return dm->getTessFaceArray(dm);
+ }
return CustomData_get_layer(&dm->faceData, type);
}
@@ -814,8 +823,9 @@ DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
{
DerivedMesh *dm = CDDM_from_mesh(me);
- if (!dm)
+ if (!dm) {
return NULL;
+ }
if (vertCos) {
CDDM_apply_vert_coords(dm, vertCos);
@@ -852,10 +862,12 @@ static float (*get_orco_coords(Object *ob, BMEditMesh *em, int layer, int *free)
/* get original coordinates */
*free = 1;
- if (em)
+ if (em) {
return get_editbmesh_orco_verts(em);
- else
+ }
+ else {
return BKE_mesh_orco_verts_get(ob);
+ }
}
else if (layer == CD_CLOTH_ORCO) {
/* apply shape key for cloth, this should really be solved
@@ -893,8 +905,9 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *me, BMEditMesh *em, int layer)
if (orco) {
BKE_mesh_apply_vert_coords(mesh, orco);
- if (free)
+ if (free) {
MEM_freeN(orco);
+ }
}
return mesh;
@@ -936,8 +949,9 @@ static void add_orco_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orc
}
memcpy(layerorco, orco, sizeof(float) * 3 * totvert);
- if (free)
+ if (free) {
MEM_freeN(orco);
+ }
}
}
@@ -954,8 +968,9 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
KeyBlock *kb;
int i, j, tot;
- if (!me->key)
+ if (!me->key) {
return;
+ }
tot = CustomData_number_of_layers(&dm->vertData, CD_SHAPEKEY);
for (i = 0; i < tot; i++) {
@@ -964,8 +979,9 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
float(*cos)[3], (*kbcos)[3];
for (kb = me->key->block.first; kb; kb = kb->next) {
- if (kb->uid == layer->uid)
+ if (kb->uid == layer->uid) {
break;
+ }
}
if (!kb) {
@@ -973,8 +989,9 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
kb->uid = layer->uid;
}
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
cos = CustomData_get_layer_n(&dm->vertData, CD_SHAPEKEY, i);
kb->totelem = dm->numVertData;
@@ -996,8 +1013,9 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
for (kb = me->key->block.first; kb; kb = kb->next) {
if (kb->totelem != dm->numVertData) {
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
kb->totelem = dm->numVertData;
kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), "kb->data derivedmesh.c");
@@ -1022,16 +1040,28 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input,
/* Compute normals. */
const bool do_loop_normals = ((mesh_input->flag & ME_AUTOSMOOTH) != 0 ||
(dataMask->lmask & CD_MASK_NORMAL) != 0);
- /* Some modifiers may need this info from their target (other) object, simpler to generate it here as well.
+ /* Some modifiers may need this info from their target (other) object,
+ * simpler to generate it here as well.
* Note that they will always be generated when no loop normals are comptuted,
* since they are needed by drawing code. */
const bool do_poly_normals = ((dataMask->pmask & CD_MASK_NORMAL) != 0);
if (do_loop_normals) {
- /* In case we also need poly normals, add the layer here, then BKE_mesh_calc_normals_split() will fill it. */
+ /* In case we also need poly normals, add the layer and compute them here
+ * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */
if (do_poly_normals) {
if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) {
- CustomData_add_layer(&mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly);
+ float(*polynors)[3] = CustomData_add_layer(
+ &mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly);
+ BKE_mesh_calc_normals_poly(mesh_final->mvert,
+ NULL,
+ mesh_final->totvert,
+ mesh_final->mloop,
+ mesh_final->mpoly,
+ mesh_final->totloop,
+ mesh_final->totpoly,
+ polynors,
+ false);
}
}
/* Compute loop normals (note: will compute poly and vert normals as well, if needed!) */
@@ -1059,8 +1089,9 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input,
}
}
- /* Some modifiers, like datatransfer, may generate those data as temp layer, we do not want to keep them,
- * as they are used by display code when available (i.e. even if autosmooth is disabled). */
+ /* Some modifiers, like data-transfer, may generate those data as temp layer,
+ * we do not want to keep them, as they are used by display code when available
+ * (i.e. even if autosmooth is disabled). */
if (!do_loop_normals && CustomData_has_layer(&mesh_final->ldata, CD_NORMAL)) {
CustomData_free_layers(&mesh_final->ldata, CD_NORMAL, mesh_final->totloop);
}
@@ -1184,8 +1215,9 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
}
/* grab modifiers until index i */
- if ((index != -1) && (BLI_findindex(&ob->modifiers, md) >= index))
+ if ((index != -1) && (BLI_findindex(&ob->modifiers, md) >= index)) {
break;
+ }
}
/* Result of all leading deforming modifiers is cached for
@@ -1227,19 +1259,23 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
}
}
- if (sculpt_dyntopo)
+ if (sculpt_dyntopo) {
unsupported = true;
+ }
- if (scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM)
+ if (scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM) {
unsupported |= (mti->type != eModifierTypeType_OnlyDeform);
+ }
unsupported |= multires_applied;
if (unsupported) {
- if (sculpt_dyntopo)
+ if (sculpt_dyntopo) {
modifier_setError(md, "Not supported in dyntopo");
- else
+ }
+ else {
modifier_setError(md, "Not supported in sculpt mode");
+ }
continue;
}
else {
@@ -1294,10 +1330,12 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
else {
/* determine which data layers are needed by following modifiers */
CustomData_MeshMasks nextmask;
- if (md_datamask->next)
+ if (md_datamask->next) {
nextmask = md_datamask->next->mask;
- else
+ }
+ else {
nextmask = *dataMask;
+ }
/* apply vertex coordinates or build a Mesh as necessary */
if (mesh_final) {
@@ -1330,7 +1368,8 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
CustomData_add_layer(
&mesh_final->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh_final->totpoly);
- /* Not worth parallelizing this, gives less than 0.1% overall speedup in best of best cases... */
+ /* Not worth parallelizing this,
+ * gives less than 0.1% overall speedup in best of best cases... */
range_vn_i(
CustomData_get_layer(&mesh_final->vdata, CD_ORIGINDEX), mesh_final->totvert, 0);
range_vn_i(
@@ -1456,8 +1495,9 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
isPrevDeform = (mti->type == eModifierTypeType_OnlyDeform);
/* grab modifiers until index i */
- if ((index != -1) && (BLI_findindex(&ob->modifiers, md) >= index))
+ if ((index != -1) && (BLI_findindex(&ob->modifiers, md) >= index)) {
break;
+ }
if (sculpt_mode && md->type == eModifierType_Multires) {
multires_applied = true;
@@ -1466,8 +1506,9 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
BLI_linklist_free((LinkNode *)datamasks, NULL);
- for (md = firstmd; md; md = md->next)
+ for (md = firstmd; md; md = md->next) {
modifier_freeTemporaryData(md);
+ }
/* Yay, we are done. If we have a Mesh and deformed vertices
* need to apply these back onto the Mesh. If we have no
@@ -1485,8 +1526,9 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
if (dataMask->vmask & CD_MASK_ORCO) {
add_orco_mesh(ob, NULL, mesh_final, mesh_orco, CD_ORCO);
- if (mesh_deform)
+ if (mesh_deform) {
add_orco_mesh(ob, NULL, mesh_deform, NULL, CD_ORCO);
+ }
}
if (mesh_orco) {
@@ -1547,11 +1589,13 @@ static void editbmesh_calc_modifier_final_normals(const Mesh *mesh_input,
{
const bool do_loop_normals = ((mesh_input->flag & ME_AUTOSMOOTH) != 0 ||
(dataMask->lmask & CD_MASK_NORMAL) != 0);
- /* Some modifiers may need this info from their target (other) object, simpler to generate it here as well. */
+ /* Some modifiers may need this info from their target (other) object,
+ * simpler to generate it here as well. */
const bool do_poly_normals = ((dataMask->pmask & CD_MASK_NORMAL) != 0);
if (do_loop_normals) {
- /* In case we also need poly normals, add the layer here, then BKE_mesh_calc_normals_split() will fill it. */
+ /* In case we also need poly normals, add the layer here,
+ * then BKE_mesh_calc_normals_split() will fill it. */
if (do_poly_normals) {
if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) {
CustomData_add_layer(&mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly);
@@ -1687,11 +1731,13 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
}
- if (mti->deformVertsEM)
+ if (mti->deformVertsEM) {
modwrap_deformVertsEM(
md, &mectx, em_input, mesh_final, deformed_verts, num_deformed_verts);
- else
+ }
+ else {
modwrap_deformVerts(md, &mectx, mesh_final, deformed_verts, num_deformed_verts);
+ }
}
else {
/* apply vertex coordinates or build a DerivedMesh as necessary */
@@ -1980,7 +2026,10 @@ static void mesh_build_data(struct Depsgraph *depsgraph,
* but this avoids waiting on first stroke) */
/* XXX Disabled for now.
* This can create horrible nasty bugs by generating re-entrant call of mesh_get_eval_final! */
- // BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
+#if 0
+ BKE_sculpt_update_mesh_elements(
+ depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
+#endif
}
mesh_runtime_check_normals_valid(ob->runtime.mesh_eval);
@@ -2052,8 +2101,9 @@ static void object_get_datamask(const Depsgraph *depsgraph,
r_mask->vmask |= CD_MASK_MDEFORMVERT;
}
- if (ob->mode & OB_MODE_EDIT)
+ if (ob->mode & OB_MODE_EDIT) {
r_mask->vmask |= CD_MASK_MVERT_SKIN;
+ }
}
}
@@ -2381,10 +2431,12 @@ static void mesh_init_origspace(Mesh *mesh)
copy_v2_v2(vcos_2d[j], co);
for (k = 0; k < 2; k++) {
- if (co[k] > max[k])
+ if (co[k] > max[k]) {
max[k] = co[k];
- else if (co[k] < min[k])
+ }
+ else if (co[k] < min[k]) {
min[k] = co[k];
+ }
}
}
@@ -2393,13 +2445,16 @@ static void mesh_init_origspace(Mesh *mesh)
/* Scale will bring max to (1, 1). */
sub_v2_v2v2(scale, max, min);
- if (scale[0] == 0.0f)
+ if (scale[0] == 0.0f) {
scale[0] = 1e-9f;
- if (scale[1] == 0.0f)
+ }
+ if (scale[1] == 0.0f) {
scale[1] = 1e-9f;
+ }
invert_v2(scale);
- /* Finally, transform all vcos_2d into ((0, 0), (1, 1)) square and assign them as origspace. */
+ /* Finally, transform all vcos_2d into ((0, 0), (1, 1))
+ * square and assign them as origspace. */
for (j = 0; j < mp->totloop; j++, lof++) {
add_v2_v2v2(lof->uv, vcos_2d[j], translate);
mul_v2_v2(lof->uv, scale);
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index a3b7df6b020..9b321ff4e44 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -115,8 +115,10 @@ void BKE_action_free(bAction *act)
/* .................................. */
/**
- * Only copy internal data of Action ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Action ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -139,8 +141,11 @@ void BKE_action_copy_data(Main *UNUSED(bmain),
for (fcu_src = act_src->curves.first; fcu_src; fcu_src = fcu_src->next) {
/* duplicate F-Curve */
- fcu_dst = copy_fcurve(
- fcu_src); /* XXX TODO pass subdata flag? But surprisingly does not seem to be doing any ID refcounting... */
+
+ /* XXX TODO pass subdata flag?
+ * But surprisingly does not seem to be doing any ID refcounting... */
+ fcu_dst = copy_fcurve(fcu_src);
+
BLI_addtail(&act_dst->curves, fcu_dst);
/* fix group links (kindof bad list-in-list search, but this is the most reliable way) */
@@ -177,8 +182,9 @@ bActionGroup *get_active_actiongroup(bAction *act)
if (act && act->groups.first) {
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
- if (agrp->flag & AGRP_ACTIVE)
+ if (agrp->flag & AGRP_ACTIVE) {
break;
+ }
}
}
@@ -191,15 +197,18 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select)
bActionGroup *grp;
/* sanity checks */
- if (act == NULL)
+ if (act == NULL) {
return;
+ }
/* Deactivate all others */
for (grp = act->groups.first; grp; grp = grp->next) {
- if ((grp == agrp) && (select))
+ if ((grp == agrp) && (select)) {
grp->flag |= AGRP_ACTIVE;
- else
+ }
+ else {
grp->flag &= ~AGRP_ACTIVE;
+ }
}
}
@@ -240,8 +249,9 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[])
bActionGroup *agrp;
/* sanity check: must have action and name */
- if (ELEM(NULL, act, name))
+ if (ELEM(NULL, act, name)) {
return NULL;
+ }
/* allocate a new one */
agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup");
@@ -266,8 +276,9 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[])
void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
{
/* sanity checks */
- if (ELEM(NULL, act, agrp, fcurve))
+ if (ELEM(NULL, act, agrp, fcurve)) {
return;
+ }
/* if no channels anywhere, just add to two lists at the same time */
if (BLI_listbase_is_empty(&act->curves)) {
@@ -285,8 +296,9 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
* then set the F-Curve as the last for the action first so that
* the lists will be in sync after linking
*/
- if (agrp->channels.last == act->curves.last)
+ if (agrp->channels.last == act->curves.last) {
act->curves.last = fcurve;
+ }
/* link in the given F-Curve after the last F-Curve in the group,
* which means that it should be able to fit in with the rest of the
@@ -302,12 +314,13 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
/* firstly, link this F-Curve to the group */
agrp->channels.first = agrp->channels.last = fcurve;
- /* step through the groups preceding this one, finding the F-Curve there to attach this one after */
+ /* Step through the groups preceding this one,
+ * finding the F-Curve there to attach this one after. */
for (grp = agrp->prev; grp; grp = grp->prev) {
- /* if this group has F-Curves, we want weave the given one in right after the last channel there,
- * but via the Action's list not this group's list
+ /* if this group has F-Curves, we want weave the given one in right after the last channel
+ * there, but via the Action's list not this group's list
* - this is so that the F-Curve is in the right place in the Action,
- * but won't be included in the previous group
+ * but won't be included in the previous group.
*/
if (grp->channels.last) {
/* once we've added, break here since we don't need to search any further... */
@@ -316,12 +329,13 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
}
}
- /* if grp is NULL, that means we fell through, and this F-Curve should be added as the new first
- * since group is (effectively) the first group. Thus, the existing first F-Curve becomes the
- * second in the chain, etc. etc.
+ /* If grp is NULL, that means we fell through, and this F-Curve should be added as the new
+ * first since group is (effectively) the first group. Thus, the existing first F-Curve becomes
+ * the second in the chain, etc. etc.
*/
- if (grp == NULL)
+ if (grp == NULL) {
BLI_insertlinkbefore(&act->curves, act->curves.first, fcurve);
+ }
}
/* set the F-Curve's new group */
@@ -332,8 +346,9 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
void action_groups_remove_channel(bAction *act, FCurve *fcu)
{
/* sanity checks */
- if (ELEM(NULL, act, fcu))
+ if (ELEM(NULL, act, fcu)) {
return;
+ }
/* check if any group used this directly */
if (fcu->grp) {
@@ -345,16 +360,20 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu)
}
}
else if (agrp->channels.first == fcu) {
- if ((fcu->next) && (fcu->next->grp == agrp))
+ if ((fcu->next) && (fcu->next->grp == agrp)) {
agrp->channels.first = fcu->next;
- else
+ }
+ else {
agrp->channels.first = NULL;
+ }
}
else if (agrp->channels.last == fcu) {
- if ((fcu->prev) && (fcu->prev->grp == agrp))
+ if ((fcu->prev) && (fcu->prev->grp == agrp)) {
agrp->channels.last = fcu->prev;
- else
+ }
+ else {
agrp->channels.last = NULL;
+ }
}
fcu->grp = NULL;
@@ -368,8 +387,9 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu)
bActionGroup *BKE_action_group_find_name(bAction *act, const char name[])
{
/* sanity checks */
- if (ELEM(NULL, act, act->groups.first, name) || (name[0] == 0))
+ if (ELEM(NULL, act, act->groups.first, name) || (name[0] == 0)) {
return NULL;
+ }
/* do string comparisons */
return BLI_findstring(&act->groups, name, offsetof(bActionGroup, name));
@@ -381,12 +401,14 @@ void action_groups_clear_tempflags(bAction *act)
bActionGroup *agrp;
/* sanity checks */
- if (ELEM(NULL, act, act->groups.first))
+ if (ELEM(NULL, act, act->groups.first)) {
return;
+ }
/* flag clearing loop */
- for (agrp = act->groups.first; agrp; agrp = agrp->next)
+ for (agrp = act->groups.first; agrp; agrp = agrp->next) {
agrp->flag &= ~AGRP_TEMP;
+ }
}
/* *************** Pose channels *************** */
@@ -397,11 +419,13 @@ void action_groups_clear_tempflags(bAction *act)
*/
bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name)
{
- if (ELEM(NULL, pose, name) || (name[0] == '\0'))
+ if (ELEM(NULL, pose, name) || (name[0] == '\0')) {
return NULL;
+ }
- if (pose->chanhash)
+ if (pose->chanhash) {
return BLI_ghash_lookup(pose->chanhash, (const void *)name);
+ }
return BLI_findstring(&((const bPose *)pose)->chanbase, name, offsetof(bPoseChannel, name));
}
@@ -418,8 +442,9 @@ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name)
{
bPoseChannel *chan;
- if (pose == NULL)
+ if (pose == NULL) {
return NULL;
+ }
/* See if this channel exists */
chan = BKE_pose_channel_find_name(pose, name);
@@ -439,7 +464,8 @@ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name)
unit_axis_angle(chan->rotAxis, &chan->rotAngle);
chan->size[0] = chan->size[1] = chan->size[2] = 1.0f;
- chan->scaleIn = chan->scaleOut = 1.0f;
+ chan->scale_in_x = chan->scale_in_y = 1.0f;
+ chan->scale_out_x = chan->scale_out_y = 1.0f;
chan->limitmin[0] = chan->limitmin[1] = chan->limitmin[2] = -M_PI;
chan->limitmax[0] = chan->limitmax[1] = chan->limitmax[2] = M_PI;
@@ -490,8 +516,9 @@ bPoseChannel *BKE_pose_channel_active(Object *ob)
/* find active */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if ((pchan->bone) && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer))
+ if ((pchan->bone) && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer)) {
return pchan;
+ }
}
return NULL;
@@ -585,7 +612,8 @@ void BKE_pose_copy_data_ex(bPose **dst,
&listb, &pchan->constraints, flag, true); // BKE_constraints_copy NULLs listb
pchan->constraints = listb;
- /* XXX: This is needed for motionpath drawing to work. Dunno why it was setting to null before... */
+ /* XXX: This is needed for motionpath drawing to work.
+ * Dunno why it was setting to null before... */
pchan->mpath = animviz_copy_motionpath(pchan->mpath);
}
@@ -657,15 +685,17 @@ static bool pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = con->data;
if ((data->rootbone == 0) || (data->rootbone > level)) {
- if ((data->flag & CONSTRAINT_IK_AUTO) == 0)
+ if ((data->flag & CONSTRAINT_IK_AUTO) == 0) {
return true;
+ }
}
}
}
for (bone = pchan->bone->childbase.first; bone; bone = bone->next) {
pchan = BKE_pose_channel_find_name(ob->pose, bone->name);
- if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1))
+ if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) {
return true;
+ }
}
return false;
}
@@ -685,8 +715,9 @@ void BKE_pose_channels_hash_make(bPose *pose)
bPoseChannel *pchan;
pose->chanhash = BLI_ghash_str_new("make_pose_chan gh");
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next)
+ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
+ }
}
}
@@ -742,23 +773,27 @@ void BKE_pose_channels_remove(Object *ob,
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
}
if (pchan->bbone_prev) {
- if (filter_fn(pchan->bbone_prev->name, user_data))
+ if (filter_fn(pchan->bbone_prev->name, user_data)) {
pchan->bbone_prev = NULL;
+ }
}
if (pchan->bbone_next) {
- if (filter_fn(pchan->bbone_next->name, user_data))
+ if (filter_fn(pchan->bbone_next->name, user_data)) {
pchan->bbone_next = NULL;
+ }
}
if (pchan->custom_tx) {
- if (filter_fn(pchan->custom_tx->name, user_data))
+ if (filter_fn(pchan->custom_tx->name, user_data)) {
pchan->custom_tx = NULL;
+ }
}
}
}
@@ -793,15 +828,25 @@ void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
/* Cached data, for new draw manager rendering code. */
MEM_SAFE_FREE(pchan->draw_data);
- /* Cached B-Bone shape data. */
- BKE_pose_channel_free_bbone_cache(pchan);
+ /* Cached B-Bone shape and other data. */
+ BKE_pose_channel_runtime_free(&pchan->runtime);
}
-/** Deallocates runtime cache of a pose channel's B-Bone shape. */
-void BKE_pose_channel_free_bbone_cache(bPoseChannel *pchan)
+/** Clears the runtime cache of a pose channel without free. */
+void BKE_pose_channel_runtime_reset(bPoseChannel_Runtime *runtime)
+{
+ memset(runtime, 0, sizeof(*runtime));
+}
+
+/** Deallocates runtime cache of a pose channel */
+void BKE_pose_channel_runtime_free(bPoseChannel_Runtime *runtime)
{
- bPoseChannel_Runtime *runtime = &pchan->runtime;
+ BKE_pose_channel_free_bbone_cache(runtime);
+}
+/** Deallocates runtime cache of a pose channel's B-Bone shape. */
+void BKE_pose_channel_free_bbone_cache(bPoseChannel_Runtime *runtime)
+{
runtime->bbone_segments = 0;
MEM_SAFE_FREE(runtime->bbone_rest_mats);
MEM_SAFE_FREE(runtime->bbone_pose_mats);
@@ -823,8 +868,9 @@ void BKE_pose_channels_free_ex(bPose *pose, bool do_id_user)
bPoseChannel *pchan;
if (pose->chanbase.first) {
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next)
+ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
BKE_pose_channel_free_ex(pchan, do_id_user);
+ }
BLI_freelistN(&pose->chanbase);
}
@@ -845,15 +891,17 @@ void BKE_pose_free_data_ex(bPose *pose, bool do_id_user)
BKE_pose_channels_free_ex(pose, do_id_user);
/* free pose-groups */
- if (pose->agroups.first)
+ if (pose->agroups.first) {
BLI_freelistN(&pose->agroups);
+ }
/* free IK solver state */
BIK_clear_data(pose);
/* free IK solver param */
- if (pose->ikparam)
+ if (pose->ikparam) {
MEM_freeN(pose->ikparam);
+ }
}
void BKE_pose_free_data(bPose *pose)
@@ -955,22 +1003,26 @@ void BKE_pose_update_constraint_flags(bPose *pose)
pchan->constflag |= PCHAN_HAS_IK;
- if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0))
+ if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) {
pchan->constflag |= PCHAN_HAS_TARGET;
+ }
/* negative rootbone = recalc rootbone index. used in do_versions */
if (data->rootbone < 0) {
data->rootbone = 0;
- if (data->flag & CONSTRAINT_IK_TIP)
+ if (data->flag & CONSTRAINT_IK_TIP) {
parchan = pchan;
- else
+ }
+ else {
parchan = pchan->parent;
+ }
while (parchan) {
data->rootbone++;
- if ((parchan->bone->flag & BONE_CONNECTED) == 0)
+ if ((parchan->bone->flag & BONE_CONNECTED) == 0) {
break;
+ }
parchan = parchan->parent;
}
}
@@ -984,13 +1036,16 @@ void BKE_pose_update_constraint_flags(bPose *pose)
/* if we have a valid target, make sure that this will get updated on frame-change
* (needed for when there is no anim-data for this pose)
*/
- if ((data->tar) && (data->tar->type == OB_CURVE))
+ if ((data->tar) && (data->tar->type == OB_CURVE)) {
pose->flag |= POSE_CONSTRAINTS_TIMEDEPEND;
+ }
}
- else if (con->type == CONSTRAINT_TYPE_SPLINEIK)
+ else if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
pchan->constflag |= PCHAN_HAS_SPLINEIK;
- else
+ }
+ else {
pchan->constflag |= PCHAN_HAS_CONST;
+ }
}
}
pose->flag &= ~POSE_CONSTRAINTS_NEED_UPDATE_FLAGS;
@@ -1017,8 +1072,9 @@ void framechange_poses_clear_unkeyed(Main *bmain)
/* we only need to do this on objects with a pose */
if ((pose = ob->pose)) {
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->bone)
+ if (pchan->bone) {
pchan->bone->flag &= ~BONE_UNKEYED;
+ }
}
}
}
@@ -1063,10 +1119,12 @@ void BKE_pose_remove_group(bPose *pose, bActionGroup *grp, const int index)
* - also, make sure that those after this item get corrected
*/
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->agrp_index == idx)
+ if (pchan->agrp_index == idx) {
pchan->agrp_index = 0;
- else if (pchan->agrp_index > idx)
+ }
+ else if (pchan->agrp_index > idx) {
pchan->agrp_index--;
+ }
}
/* now, remove it from the pose */
@@ -1105,8 +1163,9 @@ bool action_has_motion(const bAction *act)
/* return on the first F-Curve that has some keyframes/samples defined */
if (act) {
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
- if (fcu->totvert)
+ if (fcu->totvert) {
return true;
+ }
}
}
@@ -1166,10 +1225,12 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
{
FMod_Cycles *fmd = (FMod_Cycles *)fcm->data;
- if (fmd->before_mode != FCM_EXTRAPOLATE_NONE)
+ if (fmd->before_mode != FCM_EXTRAPOLATE_NONE) {
min = MINAFRAMEF;
- if (fmd->after_mode != FCM_EXTRAPOLATE_NONE)
+ }
+ if (fmd->after_mode != FCM_EXTRAPOLATE_NONE) {
max = MAXFRAMEF;
+ }
break;
}
/* TODO: function modifier may need some special limits */
@@ -1187,8 +1248,9 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
if (foundvert || foundmod) {
/* ensure that action is at least 1 frame long (for NLA strips to have a valid length) */
- if (min == max)
+ if (min == max) {
max += 1.0f;
+ }
*start = min;
*end = max;
@@ -1210,17 +1272,21 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
short flags = 0;
/* build PointerRNA from provided data to obtain the paths to use */
- if (pchan)
+ if (pchan) {
RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr);
- else if (ob)
+ }
+ else if (ob) {
RNA_id_pointer_create((ID *)ob, &ptr);
- else
+ }
+ else {
return 0;
+ }
/* get the basic path to the properties of interest */
basePath = RNA_path_from_ID_to_struct(&ptr);
- if (basePath == NULL)
+ if (basePath == NULL) {
return 0;
+ }
/* search F-Curves for the given properties
* - we cannot use the groups, since they may not be grouped in that way...
@@ -1228,13 +1294,16 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
const char *bPtr = NULL, *pPtr = NULL;
- /* if enough flags have been found, we can stop checking unless we're also getting the curves */
- if ((flags == ACT_TRANS_ALL) && (curves == NULL))
+ /* If enough flags have been found,
+ * we can stop checking unless we're also getting the curves. */
+ if ((flags == ACT_TRANS_ALL) && (curves == NULL)) {
break;
+ }
/* just in case... */
- if (fcu->rna_path == NULL)
+ if (fcu->rna_path == NULL) {
continue;
+ }
/* step 1: check for matching base path */
bPtr = strstr(fcu->rna_path, basePath);
@@ -1257,8 +1326,9 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
if (pPtr) {
flags |= ACT_TRANS_LOC;
- if (curves)
+ if (curves) {
BLI_addtail(curves, BLI_genericNodeN(fcu));
+ }
continue;
}
}
@@ -1268,8 +1338,9 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
if (pPtr) {
flags |= ACT_TRANS_SCALE;
- if (curves)
+ if (curves) {
BLI_addtail(curves, BLI_genericNodeN(fcu));
+ }
continue;
}
}
@@ -1279,8 +1350,9 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
if (pPtr) {
flags |= ACT_TRANS_ROT;
- if (curves)
+ if (curves) {
BLI_addtail(curves, BLI_genericNodeN(fcu));
+ }
continue;
}
}
@@ -1291,8 +1363,9 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
if (pPtr) {
flags |= ACT_TRANS_BBONE;
- if (curves)
+ if (curves) {
BLI_addtail(curves, BLI_genericNodeN(fcu));
+ }
continue;
}
}
@@ -1305,8 +1378,9 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan,
if (pPtr) {
flags |= ACT_TRANS_PROP;
- if (curves)
+ if (curves) {
BLI_addtail(curves, BLI_genericNodeN(fcu));
+ }
continue;
}
}
@@ -1327,8 +1401,9 @@ void BKE_pose_rest(bPose *pose)
{
bPoseChannel *pchan;
- if (!pose)
+ if (!pose) {
return;
+ }
memset(pose->stride_offset, 0, sizeof(pose->stride_offset));
memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset));
@@ -1341,10 +1416,11 @@ void BKE_pose_rest(bPose *pose)
pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f;
pchan->roll1 = pchan->roll2 = 0.0f;
- pchan->curveInX = pchan->curveInY = 0.0f;
- pchan->curveOutX = pchan->curveOutY = 0.0f;
+ pchan->curve_in_x = pchan->curve_in_y = 0.0f;
+ pchan->curve_out_x = pchan->curve_out_y = 0.0f;
pchan->ease1 = pchan->ease2 = 0.0f;
- pchan->scaleIn = pchan->scaleOut = 1.0f;
+ pchan->scale_in_x = pchan->scale_in_y = 1.0f;
+ pchan->scale_out_x = pchan->scale_out_y = 1.0f;
pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE);
}
@@ -1366,14 +1442,16 @@ void BKE_pose_copyesult_pchan_result(bPoseChannel *pchanto, const bPoseChannel *
pchanto->roll1 = pchanfrom->roll1;
pchanto->roll2 = pchanfrom->roll2;
- pchanto->curveInX = pchanfrom->curveInX;
- pchanto->curveInY = pchanfrom->curveInY;
- pchanto->curveOutX = pchanfrom->curveOutX;
- pchanto->curveOutY = pchanfrom->curveOutY;
+ pchanto->curve_in_x = pchanfrom->curve_in_x;
+ pchanto->curve_in_y = pchanfrom->curve_in_y;
+ pchanto->curve_out_x = pchanfrom->curve_out_x;
+ pchanto->curve_out_y = pchanfrom->curve_out_y;
pchanto->ease1 = pchanfrom->ease1;
pchanto->ease2 = pchanfrom->ease2;
- pchanto->scaleIn = pchanfrom->scaleIn;
- pchanto->scaleOut = pchanfrom->scaleOut;
+ pchanto->scale_in_x = pchanfrom->scale_in_x;
+ pchanto->scale_in_y = pchanfrom->scale_in_y;
+ pchanto->scale_out_x = pchanfrom->scale_out_x;
+ pchanto->scale_out_y = pchanfrom->scale_out_y;
pchanto->rotmode = pchanfrom->rotmode;
pchanto->flag = pchanfrom->flag;
@@ -1461,14 +1539,12 @@ void what_does_obaction(
}
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
- BLI_strncpy(
- workob->id.name,
- "OB<ConstrWorkOb>",
- sizeof(
- workob->id
- .name)); /* we don't use real object name, otherwise RNA screws with the real thing */
-
- /* if we're given a group to use, it's likely to be more efficient (though a bit more dangerous) */
+
+ /* we don't use real object name, otherwise RNA screws with the real thing */
+ BLI_strncpy(workob->id.name, "OB<ConstrWorkOb>", sizeof(workob->id.name));
+
+ /* If we're given a group to use, it's likely to be more efficient
+ * (though a bit more dangerous). */
if (agrp) {
/* specifically evaluate this group only */
PointerRNA id_ptr;
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 0e7caca9433..6b8f8e5303e 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -67,8 +67,9 @@ static CLG_LogRef LOG = {"bke.anim"};
void animviz_settings_init(bAnimVizSettings *avs)
{
/* sanity check */
- if (avs == NULL)
+ if (avs == NULL) {
return;
+ }
/* path settings */
avs->path_bc = avs->path_ac = 10;
@@ -89,12 +90,14 @@ void animviz_settings_init(bAnimVizSettings *avs)
void animviz_free_motionpath_cache(bMotionPath *mpath)
{
/* sanity check */
- if (mpath == NULL)
+ if (mpath == NULL) {
return;
+ }
/* free the path if necessary */
- if (mpath->points)
+ if (mpath->points) {
MEM_freeN(mpath->points);
+ }
GPU_VERTBUF_DISCARD_SAFE(mpath->points_vbo);
GPU_BATCH_DISCARD_SAFE(mpath->batch_line);
@@ -111,8 +114,9 @@ void animviz_free_motionpath_cache(bMotionPath *mpath)
void animviz_free_motionpath(bMotionPath *mpath)
{
/* sanity check */
- if (mpath == NULL)
+ if (mpath == NULL) {
return;
+ }
/* free the cache first */
animviz_free_motionpath_cache(mpath);
@@ -128,8 +132,9 @@ bMotionPath *animviz_copy_motionpath(const bMotionPath *mpath_src)
{
bMotionPath *mpath_dst;
- if (mpath_src == NULL)
+ if (mpath_src == NULL) {
return NULL;
+ }
mpath_dst = MEM_dupallocN(mpath_src);
mpath_dst->points = MEM_dupallocN(mpath_src->points);
@@ -161,8 +166,9 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports,
bMotionPath *mpath, **dst;
/* sanity checks */
- if (ELEM(NULL, scene, ob))
+ if (ELEM(NULL, scene, ob)) {
return NULL;
+ }
/* get destination data */
if (pchan) {
@@ -196,7 +202,8 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports,
mpath = *dst;
- /* path is "valid" if length is valid, but must also be of the same length as is being requested */
+ /* Path is "valid" if length is valid,
+ * but must also be of the same length as is being requested. */
if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) {
/* outer check ensures that we have some curve data for this path */
if (mpath->length == expected_length) {
@@ -221,10 +228,12 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports,
mpath->length = mpath->end_frame - mpath->start_frame;
- if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS)
+ if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS) {
mpath->flag |= MOTIONPATH_FLAG_BHEAD;
- else
+ }
+ else {
mpath->flag &= ~MOTIONPATH_FLAG_BHEAD;
+ }
/* set default custom values */
mpath->color[0] = 1.0; /* Red */
@@ -253,8 +262,9 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports,
*/
void free_path(Path *path)
{
- if (path->data)
+ if (path->data) {
MEM_freeN(path->data);
+ }
MEM_freeN(path);
}
@@ -279,8 +289,9 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
return;
}
- if (ob->runtime.curve_cache->path)
+ if (ob->runtime.curve_cache->path) {
free_path(ob->runtime.curve_cache->path);
+ }
ob->runtime.curve_cache->path = NULL;
/* weak! can only use first curve */
@@ -299,7 +310,8 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
tot = cycl ? bl->nr : bl->nr - 1;
path->len = tot + 1;
- /* exception: vector handle paths and polygon paths should be subdivided at least a factor resolu */
+ /* Exception: vector handle paths and polygon paths should be subdivided
+ * at least a factor resolution. */
if (path->len < nu->resolu * SEGMENTSU(nu)) {
path->len = nu->resolu * SEGMENTSU(nu);
}
@@ -312,10 +324,12 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
*fp = 0.0f;
for (a = 0; a < tot; a++) {
fp++;
- if (cycl && a == tot - 1)
+ if (cycl && a == tot - 1) {
sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec);
- else
+ }
+ else {
sub_v3_v3v3(xyz, (bevp + 1)->vec, bevp->vec);
+ }
*fp = *(fp - 1) + len_v3(xyz);
bevp++;
@@ -346,8 +360,9 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
if (LIKELY(tot > 0)) {
while ((fp < maxdist) && (d >= *fp)) {
fp++;
- if (bevp < bevplast)
+ if (bevp < bevplast) {
bevp++;
+ }
bevpn = bevp + 1;
if (UNLIKELY(bevpn > bevplast)) {
bevpn = cycl ? bevpfirst : bevplast;
@@ -381,10 +396,12 @@ static int interval_test(const int min, const int max, int p1, const int cycl)
p1 = mod_i(p1 - min, (max - min + 1)) + min;
}
else {
- if (p1 < min)
+ if (p1 < min) {
p1 = min;
- else if (p1 > max)
+ }
+ else if (p1 > max) {
p1 = max;
+ }
}
return p1;
}
@@ -414,8 +431,9 @@ int where_on_path(Object *ob,
int cycl = 0, s0, s1, s2, s3;
ListBase *nurbs;
- if (ob == NULL || ob->type != OB_CURVE)
+ if (ob == NULL || ob->type != OB_CURVE) {
return 0;
+ }
cu = ob->data;
if (ob->runtime.curve_cache == NULL || ob->runtime.curve_cache->path == NULL ||
ob->runtime.curve_cache->path->data == NULL) {
@@ -427,12 +445,15 @@ int where_on_path(Object *ob,
/* test for cyclic */
bl = ob->runtime.curve_cache->bev.first;
- if (!bl)
+ if (!bl) {
return 0;
- if (!bl->nr)
+ }
+ if (!bl->nr) {
return 0;
- if (bl->poly > -1)
+ }
+ if (bl->poly > -1) {
cycl = 1;
+ }
/* values below zero for non-cyclic curves give strange results */
BLI_assert(cycl || ctime >= 0.0f);
@@ -459,7 +480,7 @@ int where_on_path(Object *ob,
* which used to temporary set CU_FOLLOW flag for the curve and no
* longer does it (because of threading issues of such a thing.
*/
- //if (cu->flag & CU_FOLLOW) {
+ // if (cu->flag & CU_FOLLOW) {
key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE);
@@ -470,19 +491,24 @@ int where_on_path(Object *ob,
//}
nurbs = BKE_curve_editNurbs_get(cu);
- if (!nurbs)
+ if (!nurbs) {
nurbs = &cu->nurb;
+ }
nu = nurbs->first;
/* make sure that first and last frame are included in the vectors here */
- if (nu->type == CU_POLY)
+ if (nu->type == CU_POLY) {
key_curve_position_weights(1.0f - fac, data, KEY_LINEAR);
- else if (nu->type == CU_BEZIER)
+ }
+ else if (nu->type == CU_BEZIER) {
key_curve_position_weights(1.0f - fac, data, KEY_LINEAR);
- else if (s0 == s1 || p2 == p3)
+ }
+ else if (s0 == s1 || p2 == p3) {
key_curve_position_weights(1.0f - fac, data, KEY_CARDINAL);
- else
+ }
+ else {
key_curve_position_weights(1.0f - fac, data, KEY_BSPLINE);
+ }
vec[0] = data[0] * p0->vec[0] + data[1] * p1->vec[0] + data[2] * p2->vec[0] +
data[3] * p3->vec[0]; /* X */
@@ -497,31 +523,39 @@ int where_on_path(Object *ob,
float totfac, q1[4], q2[4];
totfac = data[0] + data[3];
- if (totfac > FLT_EPSILON)
+ if (totfac > FLT_EPSILON) {
interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac);
- else
+ }
+ else {
copy_qt_qt(q1, p1->quat);
+ }
totfac = data[1] + data[2];
- if (totfac > FLT_EPSILON)
+ if (totfac > FLT_EPSILON) {
interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac);
- else
+ }
+ else {
copy_qt_qt(q2, p3->quat);
+ }
totfac = data[0] + data[1] + data[2] + data[3];
- if (totfac > FLT_EPSILON)
+ if (totfac > FLT_EPSILON) {
interp_qt_qtqt(quat, q1, q2, (data[1] + data[2]) / totfac);
- else
+ }
+ else {
copy_qt_qt(quat, q2);
+ }
}
- if (radius)
+ if (radius) {
*radius = data[0] * p0->radius + data[1] * p1->radius + data[2] * p2->radius +
data[3] * p3->radius;
+ }
- if (weight)
+ if (weight) {
*weight = data[0] * p0->weight + data[1] * p1->weight + data[2] * p2->weight +
data[3] * p3->weight;
+ }
return 1;
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 75244a8ba8a..cc5cd3b03ae 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -120,8 +120,9 @@ bool id_type_can_have_animdata(const short id_type)
bool id_can_have_animdata(const ID *id)
{
/* sanity check */
- if (id == NULL)
+ if (id == NULL) {
return false;
+ }
return id_type_can_have_animdata(GS(id->name));
}
@@ -140,8 +141,9 @@ AnimData *BKE_animdata_from_id(ID *id)
IdAdtTemplate *iat = (IdAdtTemplate *)id;
return iat->adt;
}
- else
+ else {
return NULL;
+ }
}
/* Add AnimData to the given ID-block. In order for this to work, we assume that
@@ -170,13 +172,15 @@ AnimData *BKE_animdata_add_id(ID *id)
return iat->adt;
}
- else
+ else {
return NULL;
+ }
}
/* Action Setter --------------------------------------- */
-/* Called when user tries to change the active action of an AnimData block (via RNA, Outliner, etc.) */
+/** Called when user tries to change the active action of an AnimData block
+ * (via RNA, Outliner, etc.) */
bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
{
AnimData *adt = BKE_animdata_from_id(id);
@@ -198,8 +202,9 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
}
/* manage usercount for current action */
- if (adt->action)
+ if (adt->action) {
id_us_min((ID *)adt->action);
+ }
/* assume that AnimData's action can in fact be edited... */
if (act) {
@@ -247,11 +252,13 @@ void BKE_animdata_free(ID *id, const bool do_id_user)
if (adt) {
if (do_id_user) {
/* unlink action (don't free, as it's in its own list) */
- if (adt->action)
+ if (adt->action) {
id_us_min(&adt->action->id);
+ }
/* same goes for the temporarily displaced action */
- if (adt->tmpact)
+ if (adt->tmpact) {
id_us_min(&adt->tmpact->id);
+ }
}
/* free nla data */
@@ -277,7 +284,8 @@ void BKE_animdata_free(ID *id, const bool do_id_user)
/**
* Make a copy of the given AnimData - to be used when copying datablocks.
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management,
+ * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
* \return The copied animdata.
*/
AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
@@ -288,8 +296,9 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
const bool do_id_user = (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0;
/* sanity check before duplicating struct */
- if (adt == NULL)
+ if (adt == NULL) {
return NULL;
+ }
dadt = MEM_dupallocN(adt);
/* make a copy of action - at worst, user has to delete copies... */
@@ -318,15 +327,17 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const int flag)
}
/**
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management,
+ * see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
* \return true is succesfully copied.
*/
bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const int flag)
{
AnimData *adt;
- if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name)))
+ if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name))) {
return false;
+ }
BKE_animdata_free(id_to, (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0);
@@ -364,8 +375,9 @@ void BKE_animdata_merge_copy(
AnimData *dst = BKE_animdata_from_id(dst_id);
/* sanity checks */
- if (ELEM(NULL, dst, src))
+ if (ELEM(NULL, dst, src)) {
return;
+ }
// TODO: we must unset all "tweakmode" flags
if ((src->flag & ADT_NLA_EDIT_ON) || (dst->flag & ADT_NLA_EDIT_ON)) {
@@ -501,10 +513,12 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha
/* perform the migration now */
action_groups_remove_channel(srcAct, fcu);
- if (agrp)
+ if (agrp) {
action_groups_add_channel(dstAct, agrp, fcu);
- else
+ }
+ else {
BLI_addtail(&dstAct->curves, fcu);
+ }
}
}
@@ -520,10 +534,12 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha
/* if group is empty and tagged, then we can remove as this operation
* moved out all the channels that were formerly here
*/
- if (BLI_listbase_is_empty(&agrp->channels))
+ if (BLI_listbase_is_empty(&agrp->channels)) {
BLI_freelinkN(&srcAct->groups, agrp);
- else
+ }
+ else {
agrp->flag &= ~AGRP_TEMP;
+ }
}
}
}
@@ -540,8 +556,9 @@ void BKE_animdata_separate_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBa
/* sanity checks */
if (ELEM(NULL, srcID, dstID)) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
CLOG_ERROR(&LOG, "no source or destination ID to separate AnimData with");
+ }
return;
}
@@ -550,14 +567,16 @@ void BKE_animdata_separate_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBa
dstAdt = BKE_animdata_add_id(dstID);
if (ELEM(NULL, srcAdt, dstAdt)) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
CLOG_ERROR(&LOG, "no AnimData for this pair of ID's");
+ }
return;
}
/* active action */
if (srcAdt->action) {
- /* set up an action if necessary, and name it in a similar way so that it can be easily found again */
+ /* Set up an action if necessary,
+ * and name it in a similar way so that it can be easily found again. */
if (dstAdt->action == NULL) {
dstAdt->action = BKE_action_add(bmain, srcAdt->action->id.name + 2);
}
@@ -614,7 +633,8 @@ void BKE_animdata_separate_by_basepath(Main *bmain, ID *srcID, ID *dstID, ListBa
* they will get picked up by the dependency system.
*
* \param C: Context pointer - for getting active data
- * \param[in,out] ptr RNA pointer for property's datablock. May be modified as result of path remapping.
+ * \param[in,out] ptr: RNA pointer for property's datablock.
+ * May be modified as result of path remapping.
* \param prop: RNA definition of property to add for
* \return MEM_alloc'd string representing the path to the property from the given #PointerRNA
*/
@@ -655,7 +675,8 @@ char *BKE_animdata_driver_path_hack(bContext *C,
/* Path Validation -------------------------------------------- */
-/* Check if a given RNA Path is valid, by tracing it from the given ID, and seeing if we can resolve it */
+/* Check if a given RNA Path is valid, by tracing it from the given ID,
+ * and seeing if we can resolve it. */
static bool check_rna_path_is_valid(ID *owner_id, const char *path)
{
PointerRNA id_ptr, ptr;
@@ -751,7 +772,8 @@ static bool fcurves_path_rename_fix(ID *owner_id,
fcu->rna_path = rna_path_rename_fix(
owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths);
/* if path changed and the F-Curve is grouped, check if its group also needs renaming
- * (i.e. F-Curve is first of a bone's F-Curves; hence renaming this should also trigger rename) */
+ * (i.e. F-Curve is first of a bone's F-Curves;
+ * hence renaming this should also trigger rename) */
if (fcu->rna_path != old_path) {
bActionGroup *agrp = fcu->grp;
is_changed = true;
@@ -868,8 +890,9 @@ char *BKE_animsys_fix_rna_path_rename(ID *owner_id,
/* if no action, no need to proceed */
if (ELEM(NULL, owner_id, old_path)) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
CLOG_WARN(&LOG, "early abort");
+ }
return old_path;
}
@@ -892,11 +915,13 @@ char *BKE_animsys_fix_rna_path_rename(ID *owner_id,
}
/* fix given path */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s | %s | oldpath = %p ", oldN, newN, old_path);
+ }
result = rna_path_rename_fix(owner_id, prefix, oldN, newN, old_path, verify_paths);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("path rename result = %p\n", result);
+ }
/* free the temp names */
MEM_freeN(oldN);
@@ -926,8 +951,9 @@ void BKE_action_fix_paths_rename(ID *owner_id,
char *oldN, *newN;
/* if no action, no need to proceed */
- if (ELEM(NULL, owner_id, act))
+ if (ELEM(NULL, owner_id, act)) {
return;
+ }
/* Name sanitation logic - copied from BKE_animdata_fix_paths_rename() */
if ((oldName != NULL) && (newName != NULL)) {
@@ -1031,8 +1057,9 @@ static bool fcurves_path_remove_fix(const char *prefix, ListBase *curves)
{
FCurve *fcu, *fcn;
bool any_removed = false;
- if (!prefix)
+ if (!prefix) {
return any_removed;
+ }
/* we need to check every curve... */
for (fcu = curves->first; fcu; fcu = fcn) {
@@ -1394,8 +1421,9 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks,
KS_Path *ksp;
/* sanity checks */
- if (ELEM(NULL, ks, rna_path, id))
+ if (ELEM(NULL, ks, rna_path, id)) {
return NULL;
+ }
/* loop over paths in the current KeyingSet, finding the first one where all settings match
* (i.e. the first one where none of the checks fail and equal 0)
@@ -1404,16 +1432,19 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks,
short eq_id = 1, eq_path = 1, eq_index = 1, eq_group = 1;
/* id */
- if (id != ksp->id)
+ if (id != ksp->id) {
eq_id = 0;
+ }
/* path */
- if ((ksp->rna_path == NULL) || !STREQ(rna_path, ksp->rna_path))
+ if ((ksp->rna_path == NULL) || !STREQ(rna_path, ksp->rna_path)) {
eq_path = 0;
+ }
/* index - need to compare whole-array setting too... */
- if (ksp->array_index != array_index)
+ if (ksp->array_index != array_index) {
eq_index = 0;
+ }
/* group */
if (group_name) {
@@ -1421,8 +1452,9 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks,
}
/* if all aspects are ok, return */
- if (eq_id && eq_path && eq_index && eq_group)
+ if (eq_id && eq_path && eq_index && eq_group) {
return ksp;
+ }
}
/* none found */
@@ -1431,7 +1463,8 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks,
/* Defining Tools --------------------------- */
-/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
+/* Used to create a new 'custom' KeyingSet for the user,
+ * that will be automatically added to the stack */
KeyingSet *BKE_keyingset_add(
ListBase *list, const char idname[], const char name[], short flag, short keyingflag)
{
@@ -1446,8 +1479,8 @@ KeyingSet *BKE_keyingset_add(
ks->flag = flag;
ks->keyingflag = keyingflag;
- ks->keyingoverride =
- keyingflag; /* NOTE: assume that if one is set one way, the other should be too, so that it'll work */
+ /* NOTE: assume that if one is set one way, the other should be too, so that it'll work */
+ ks->keyingoverride = keyingflag;
/* add KeyingSet to list */
BLI_addtail(list, ks);
@@ -1490,8 +1523,9 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks,
/* don't add if there is already a matching KS_Path in the KeyingSet */
if (BKE_keyingset_find_path(ks, id, group_name, rna_path, array_index, groupmode)) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
CLOG_ERROR(&LOG, "destination already exists in Keying Set");
+ }
return NULL;
}
@@ -1500,14 +1534,17 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks,
/* just store absolute info */
ksp->id = id;
- if (group_name)
+ if (group_name) {
BLI_strncpy(ksp->group, group_name, sizeof(ksp->group));
- else
+ }
+ else {
ksp->group[0] = '\0';
+ }
/* store additional info for relative paths (just in case user makes the set relative) */
- if (id)
+ if (id) {
ksp->idtype = GS(id->name);
+ }
/* just copy path info */
/* TODO: should array index be checked too? */
@@ -1529,12 +1566,14 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks,
void BKE_keyingset_free_path(KeyingSet *ks, KS_Path *ksp)
{
/* sanity check */
- if (ELEM(NULL, ks, ksp))
+ if (ELEM(NULL, ks, ksp)) {
return;
+ }
/* free RNA-path info */
- if (ksp->rna_path)
+ if (ksp->rna_path) {
MEM_freeN(ksp->rna_path);
+ }
/* free path itself */
BLI_freelinkN(&ks->paths, ksp);
@@ -1551,8 +1590,9 @@ void BKE_keyingsets_copy(ListBase *newlist, const ListBase *list)
for (ksn = newlist->first; ksn; ksn = ksn->next) {
BLI_duplicatelist(&ksn->paths, &ksn->paths);
- for (kspn = ksn->paths.first; kspn; kspn = kspn->next)
+ for (kspn = ksn->paths.first; kspn; kspn = kspn->next) {
kspn->rna_path = MEM_dupallocN(kspn->rna_path);
+ }
}
}
@@ -1564,8 +1604,9 @@ void BKE_keyingset_free(KeyingSet *ks)
KS_Path *ksp, *kspn;
/* sanity check */
- if (ks == NULL)
+ if (ks == NULL) {
return;
+ }
/* free each path as we go to avoid looping twice */
for (ksp = ks->paths.first; ksp; ksp = kspn) {
@@ -1580,8 +1621,9 @@ void BKE_keyingsets_free(ListBase *list)
KeyingSet *ks, *ksn;
/* sanity check */
- if (list == NULL)
+ if (list == NULL) {
return;
+ }
/* loop over KeyingSets freeing them
* - BKE_keyingset_free() doesn't free the set itself, but it frees its sub-data
@@ -1790,31 +1832,50 @@ bool BKE_animsys_execute_fcurve(PointerRNA *ptr, FCurve *fcu, float curval)
return ok;
}
+static bool animsys_construct_orig_pointer_rna(const PointerRNA *ptr, PointerRNA *ptr_orig)
+{
+ *ptr_orig = *ptr;
+ /* NOTE: nlastrip_evaluate_controls() creates PointerRNA with ID of NULL. Technically, this is
+ * not a valid pointer, but there are exceptions in various places of this file which handles
+ * such pointers.
+ * We do special trickery here as well, to quickly go from evaluated to original NlaStrip. */
+ if (ptr->id.data == NULL) {
+ if (ptr->type != &RNA_NlaStrip) {
+ return false;
+ }
+ NlaStrip *strip = ((NlaStrip *)ptr_orig->data);
+ if (strip->orig_strip == NULL) {
+ return false;
+ }
+ ptr_orig->data = strip->orig_strip;
+ }
+ else {
+ ptr_orig->id.data = ((ID *)ptr_orig->id.data)->orig_id;
+ ptr_orig->data = ptr_orig->id.data;
+ }
+ return true;
+}
+
static void animsys_write_orig_anim_rna(PointerRNA *ptr,
const char *rna_path,
int array_index,
float value)
{
- /* Pointer is expected to be an ID pointer, if it's not -- we are doomed.
- *
- * NOTE: It is possible to have animation data on NLA strip, see T57360.
- * TODO(sergey): Find solution for those cases.
- */
- if (ptr->id.data == NULL) {
+ PointerRNA ptr_orig;
+ if (!animsys_construct_orig_pointer_rna(ptr, &ptr_orig)) {
return;
}
- PointerRNA orig_ptr = *ptr;
- orig_ptr.id.data = ((ID *)orig_ptr.id.data)->orig_id;
- orig_ptr.data = orig_ptr.id.data;
PathResolvedRNA orig_anim_rna;
- /* TODO(sergey): Is there a faster way to get anim_rna of original ID? */
- if (animsys_store_rna_setting(&orig_ptr, rna_path, array_index, &orig_anim_rna)) {
+ /* TODO(sergey): Should be possible to cache resolved path in dependency graph somehow. */
+ if (animsys_store_rna_setting(&ptr_orig, rna_path, array_index, &orig_anim_rna)) {
animsys_write_rna_setting(&orig_anim_rna, value);
}
}
-/* Evaluate all the F-Curves in the given list
- * This performs a set of standard checks. If extra checks are required, separate code should be used
+/**
+ * Evaluate all the F-Curves in the given list
+ * This performs a set of standard checks. If extra checks are required,
+ * separate code should be used.
*/
static void animsys_evaluate_fcurves(Depsgraph *depsgraph,
PointerRNA *ptr,
@@ -1864,9 +1925,8 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime
/* XXX driver recalc flag is not set yet by depsgraph! */
if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID)) {
/* evaluate this using values set already in other places
- * NOTE: for 'layering' option later on, we should check if we should remove old value before adding
- * new to only be done when drivers only changed */
-
+ * NOTE: for 'layering' option later on, we should check if we should remove old value
+ * before adding new to only be done when drivers only changed. */
PathResolvedRNA anim_rna;
if (animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
@@ -1874,8 +1934,9 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime
}
/* set error-flag if evaluation failed */
- if (ok == 0)
+ if (ok == 0) {
driver->flag |= DRIVER_FLAG_INVALID;
+ }
}
}
}
@@ -1893,14 +1954,17 @@ static void action_idcode_patch_check(ID *id, bAction *act)
int idcode = 0;
/* just in case */
- if (ELEM(NULL, id, act))
+ if (ELEM(NULL, id, act)) {
return;
- else
+ }
+ else {
idcode = GS(id->name);
+ }
/* the actual checks... hopefully not too much of a performance hit in the long run... */
if (act->idroot == 0) {
- /* use the current root if not set already (i.e. newly created actions and actions from 2.50-2.57 builds)
+ /* use the current root if not set already
+ * (i.e. newly created actions and actions from 2.50-2.57 builds).
* - this has problems if there are 2 users, and the first one encountered is the invalid one
* in which case, the user will need to manually fix this (?)
*/
@@ -1927,14 +1991,16 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
FCurve *fcu;
/* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
- if (ELEM(NULL, act, agrp))
+ if (ELEM(NULL, act, agrp)) {
return;
+ }
action_idcode_patch_check(ptr->id.data, act);
/* if group is muted, don't evaluated any of the F-Curve */
- if (agrp->flag & AGRP_MUTED)
+ if (agrp->flag & AGRP_MUTED) {
return;
+ }
/* calculate then execute each curve */
for (fcu = agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu = fcu->next) {
@@ -1956,8 +2022,9 @@ static void animsys_evaluate_action_ex(Depsgraph *depsgraph,
float ctime)
{
/* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
- if (act == NULL)
+ if (act == NULL) {
return;
+ }
action_idcode_patch_check(ptr->id.data, act);
@@ -2013,8 +2080,9 @@ static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, fl
* - we do this after the F-Curves have been evaluated to override the effects of those
* in case the override has been turned off.
*/
- if ((strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) == 0) {
strip->influence = nlastrip_get_influence(strip, ctime);
+ }
/* Bypass evaluation time computation if time mapping is disabled. */
if ((strip->flag & NLASTRIP_FLAG_NO_TIME_MAP) != 0) {
@@ -2022,16 +2090,18 @@ static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, fl
return;
}
- if ((strip->flag & NLASTRIP_FLAG_USR_TIME) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_USR_TIME) == 0) {
strip->strip_time = nlastrip_get_frame(strip, ctime, NLATIME_CONVERT_EVAL);
+ }
- /* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped
- * to lie within extents of the action-clip, so that a steady changing rate of progress through several cycles of the clip
- * can be achieved easily
+ /* if user can control the evaluation time (using F-Curves), consider the option which allows
+ * this time to be clamped to lie within extents of the action-clip, so that a steady changing
+ * rate of progress through several cycles of the clip can be achieved easily.
*/
/* NOTE: if we add any more of these special cases, we better group them up nicely... */
- if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC))
+ if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC)) {
strip->strip_time = fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart);
+ }
}
/* gets the strip active at the current time for a list of strips for evaluation purposes */
@@ -2057,8 +2127,9 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
if (ctime < strip->start) {
if (strip == strips->first) {
/* before first strip - only try to use it if it extends backwards in time too */
- if (strip->extendmode == NLASTRIP_EXTEND_HOLD)
+ if (strip->extendmode == NLASTRIP_EXTEND_HOLD) {
estrip = strip;
+ }
/* side is 'before' regardless of whether there's a useful strip */
side = NES_TIME_BEFORE;
@@ -2071,8 +2142,9 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
*/
strip = strip->prev;
- if (strip->extendmode != NLASTRIP_EXTEND_NOTHING)
+ if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) {
estrip = strip;
+ }
side = NES_TIME_AFTER;
}
break;
@@ -2082,8 +2154,9 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
if (ctime > strip->end) {
/* only if this is the last strip should we do anything, and only if that is being held */
if (strip == strips->last) {
- if (strip->extendmode != NLASTRIP_EXTEND_NOTHING)
+ if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) {
estrip = strip;
+ }
side = NES_TIME_AFTER;
break;
@@ -2096,8 +2169,9 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
/* check if a valid strip was found
* - must not be muted (i.e. will have contribution
*/
- if ((estrip == NULL) || (estrip->flag & NLASTRIP_FLAG_MUTED))
+ if ((estrip == NULL) || (estrip->flag & NLASTRIP_FLAG_MUTED)) {
return NULL;
+ }
/* if ctime was not within the boundaries of the strip, clamp! */
switch (side) {
@@ -2113,10 +2187,12 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
* - skip if no influence (i.e. same effect as muting the strip)
* - negative influence is not supported yet... how would that be defined?
*/
- /* TODO: this sounds a bit hacky having a few isolated F-Curves stuck on some data it operates on... */
+ /* TODO: this sounds a bit hacky having a few isolated F-Curves
+ * stuck on some data it operates on... */
nlastrip_evaluate_controls(depsgraph, estrip, ctime);
- if (estrip->influence <= 0.0f)
+ if (estrip->influence <= 0.0f) {
return NULL;
+ }
/* check if strip has valid data to evaluate,
* and/or perform any additional type-specific actions
@@ -2124,13 +2200,15 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
switch (estrip->type) {
case NLASTRIP_TYPE_CLIP:
/* clip must have some action to evaluate */
- if (estrip->act == NULL)
+ if (estrip->act == NULL) {
return NULL;
+ }
break;
case NLASTRIP_TYPE_TRANSITION:
/* there must be strips to transition from and to (i.e. prev and next required) */
- if (ELEM(NULL, estrip->prev, estrip->next))
+ if (ELEM(NULL, estrip->prev, estrip->next)) {
return NULL;
+ }
/* evaluate controls for the relevant extents of the bordering strips... */
nlastrip_evaluate_controls(depsgraph, estrip->prev, estrip->start);
@@ -2146,8 +2224,9 @@ NlaEvalStrip *nlastrips_ctime_get_strip(
nes->track_index = index;
nes->strip_time = estrip->strip_time;
- if (list)
+ if (list) {
BLI_addtail(list, nes);
+ }
return nes;
}
@@ -2280,7 +2359,8 @@ static NlaEvalChannelSnapshot *nlaeval_snapshot_find_channel(NlaEvalSnapshot *sn
return &nec->base_snapshot;
}
-/* Retrieve or create the channel value snapshot, copying from the other snapshot (or default values) */
+/* Retrieve or create the channel value snapshot, copying from the other snapshot
+ * (or default values) */
static NlaEvalChannelSnapshot *nlaeval_snapshot_ensure_channel(NlaEvalSnapshot *snapshot,
NlaEvalChannel *nec)
{
@@ -2541,6 +2621,9 @@ static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, NlaEvalData *nlaeval,
return *p_path_nec;
}
+ /* Cache NULL result for now. */
+ *p_path_nec = NULL;
+
/* Resolve the property and look it up in the key hash. */
NlaEvalChannelKey key;
@@ -2553,8 +2636,11 @@ static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, NlaEvalData *nlaeval,
path);
}
- /* Cache NULL result. */
- *p_path_nec = NULL;
+ return NULL;
+ }
+
+ /* Check that the property can be animated. */
+ if (ptr->id.data != NULL && !RNA_property_animateable(&key.ptr, key.prop)) {
return NULL;
}
@@ -2902,7 +2988,8 @@ static void nlaeval_snapshot_mix_and_free(NlaEvalData *nlaeval,
}
/* ---------------------- */
-/* F-Modifier stack joining/separation utilities - should we generalise these for BLI_listbase.h interface? */
+/* F-Modifier stack joining/separation utilities -
+ * should we generalize these for BLI_listbase.h interface? */
/* Temporarily join two lists of modifiers together, storing the result in a third list */
static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, ListBase *list2)
@@ -2922,8 +3009,9 @@ static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, Li
result->last = list1->last;
}
else {
- /* list1 should be added first, and list2 second, with the endpoints of these being the endpoints for result
- * - the original lists must be left unchanged though, as we need that fact for restoring
+ /* list1 should be added first, and list2 second,
+ * with the endpoints of these being the endpoints for result
+ * - the original lists must be left unchanged though, as we need that fact for restoring.
*/
result->first = list1->first;
result->last = list2->last;
@@ -2942,10 +3030,12 @@ static void nlaeval_fmodifiers_split_stacks(ListBase *list1, ListBase *list2)
FModifier *fcm1, *fcm2;
/* if list1/2 is invalid... just skip */
- if (ELEM(NULL, list1, list2))
+ if (ELEM(NULL, list1, list2)) {
return;
- if (ELEM(NULL, list1->first, list2->first))
+ }
+ if (ELEM(NULL, list1->first, list2->first)) {
return;
+ }
/* get endpoints */
fcm1 = list1->last;
@@ -2965,15 +3055,15 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
NlaEvalStrip *nes,
NlaEvalSnapshot *snapshot)
{
- FModifierStackStorage *storage;
ListBase tmp_modifiers = {NULL, NULL};
NlaStrip *strip = nes->strip;
FCurve *fcu;
float evaltime;
/* sanity checks for action */
- if (strip == NULL)
+ if (strip == NULL) {
return;
+ }
if (strip->act == NULL) {
CLOG_ERROR(&LOG, "NLA-Strip Eval Error: Strip '%s' has no Action", strip->name);
@@ -2986,8 +3076,12 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers);
/* evaluate strip's modifiers which modify time to evaluate the base curves at */
- storage = evaluate_fmodifiers_storage_new(&tmp_modifiers);
- evaltime = evaluate_time_fmodifiers(storage, &tmp_modifiers, NULL, 0.0f, strip->strip_time);
+ FModifiersStackStorage storage;
+ storage.modifier_count = BLI_listbase_count(&tmp_modifiers);
+ storage.size_per_modifier = evaluate_fmodifiers_storage_size_per_modifier(&tmp_modifiers);
+ storage.buffer = alloca(storage.modifier_count * storage.size_per_modifier);
+
+ evaltime = evaluate_time_fmodifiers(&storage, &tmp_modifiers, NULL, 0.0f, strip->strip_time);
NlaBlendData blend = {
.snapshot = snapshot,
@@ -2995,29 +3089,34 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
.influence = strip->influence,
};
- /* evaluate all the F-Curves in the action, saving the relevant pointers to data that will need to be used */
+ /* Evaluate all the F-Curves in the action,
+ * saving the relevant pointers to data that will need to be used. */
for (fcu = strip->act->curves.first; fcu; fcu = fcu->next) {
float value = 0.0f;
/* check if this curve should be skipped */
- if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED))
+ if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) {
continue;
- if ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED))
+ }
+ if ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) {
continue;
+ }
/* evaluate the F-Curve's value for the time given in the strip
- * NOTE: we use the modified time here, since strip's F-Curve Modifiers are applied on top of this
+ * NOTE: we use the modified time here, since strip's F-Curve Modifiers
+ * are applied on top of this.
*/
value = evaluate_fcurve(fcu, evaltime);
/* apply strip's F-Curve Modifiers on this value
- * NOTE: we apply the strip's original evaluation time not the modified one (as per standard F-Curve eval)
+ * NOTE: we apply the strip's original evaluation time not the modified one
+ * (as per standard F-Curve eval)
*/
- evaluate_value_fmodifiers(storage, &tmp_modifiers, fcu, &value, strip->strip_time);
+ evaluate_value_fmodifiers(&storage, &tmp_modifiers, fcu, &value, strip->strip_time);
- /* get an NLA evaluation channel to work with, and accumulate the evaluated value with the value(s)
- * stored in this channel if it has been used already
- */
+ /* Get an NLA evaluation channel to work with,
+ * and accumulate the evaluated value with the value(s)
+ * stored in this channel if it has been used already. */
NlaEvalChannel *nec = nlaevalchan_verify(ptr, channels, fcu->rna_path);
nlaeval_blend_value(&blend, nec, fcu->array_index, value);
@@ -3025,9 +3124,6 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
nlaeval_blend_flush(&blend);
- /* free temporary storage */
- evaluate_fmodifiers_storage_free(storage);
-
/* unlink this strip's modifiers from the parent's modifiers again */
nlaeval_fmodifiers_split_stacks(&strip->modifiers, modifiers);
}
@@ -3146,12 +3242,16 @@ void nlastrip_evaluate(Depsgraph *depsgraph,
{
NlaStrip *strip = nes->strip;
- /* to prevent potential infinite recursion problems (i.e. transition strip, beside meta strip containing a transition
- * several levels deep inside it), we tag the current strip as being evaluated, and clear this when we leave
+ /* To prevent potential infinite recursion problems
+ * (i.e. transition strip, beside meta strip containing a transition
+ * several levels deep inside it),
+ * we tag the current strip as being evaluated, and clear this when we leave.
*/
- /* TODO: be careful with this flag, since some edit tools may be running and have set this while animplayback was running */
- if (strip->flag & NLASTRIP_FLAG_EDIT_TOUCHED)
+ /* TODO: be careful with this flag, since some edit tools may be running and have
+ * set this while animplayback was running */
+ if (strip->flag & NLASTRIP_FLAG_EDIT_TOUCHED) {
return;
+ }
strip->flag |= NLASTRIP_FLAG_EDIT_TOUCHED;
/* actions to take depend on the type of strip */
@@ -3181,8 +3281,9 @@ void nladata_flush_channels(Depsgraph *depsgraph,
NlaEvalSnapshot *snapshot)
{
/* sanity checks */
- if (channels == NULL)
+ if (channels == NULL) {
return;
+ }
const bool is_active_depsgraph = DEG_is_active(depsgraph);
@@ -3220,10 +3321,12 @@ static void nla_eval_domain_action(PointerRNA *ptr,
for (FCurve *fcu = act->curves.first; fcu; fcu = fcu->next) {
/* check if this curve should be skipped */
- if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED))
+ if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) {
continue;
- if ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED))
+ }
+ if ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) {
continue;
+ }
NlaEvalChannel *nec = nlaevalchan_verify(ptr, channels, fcu->rna_path);
@@ -3276,14 +3379,16 @@ static void animsys_evaluate_nla_domain(PointerRNA *ptr, NlaEvalData *channels,
/* solo and muting are mutually exclusive... */
if (adt->flag & ADT_NLA_SOLO_TRACK) {
/* skip if there is a solo track, but this isn't it */
- if ((nlt->flag & NLATRACK_SOLO) == 0)
+ if ((nlt->flag & NLATRACK_SOLO) == 0) {
continue;
+ }
/* else - mute doesn't matter */
}
else {
/* no solo tracks - skip track if muted */
- if (nlt->flag & NLATRACK_MUTED)
+ if (nlt->flag & NLATRACK_MUTED) {
continue;
+ }
}
nla_eval_domain_strips(ptr, channels, &nlt->strips, touched_actions);
@@ -3297,9 +3402,10 @@ static void animsys_evaluate_nla_domain(PointerRNA *ptr, NlaEvalData *channels,
/**
* NLA Evaluation function - values are calculated and stored in temporary "NlaEvalChannels"
*
- * \param[out] echannels Evaluation channels with calculated values
- * \param[out] r_context If not NULL, data about the currently edited strip is stored here and excluded from value calculation.
- * \return false if NLA evaluation isn't actually applicable
+ * \param[out] echannels: Evaluation channels with calculated values
+ * \param[out] r_context: If not NULL,
+ * data about the currently edited strip is stored here and excluded from value calculation.
+ * \return false if NLA evaluation isn't actually applicable.
*/
static bool animsys_evaluate_nla(Depsgraph *depsgraph,
NlaEvalData *echannels,
@@ -3323,33 +3429,39 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
/* 1. get the stack of strips to evaluate at current time (influence calculated here) */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next, track_index++) {
- /* stop here if tweaking is on and this strip is the tweaking track (it will be the first one that's 'disabled')... */
- if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED))
+ /* stop here if tweaking is on and this strip is the tweaking track
+ * (it will be the first one that's 'disabled')... */
+ if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED)) {
break;
+ }
/* solo and muting are mutually exclusive... */
if (adt->flag & ADT_NLA_SOLO_TRACK) {
/* skip if there is a solo track, but this isn't it */
- if ((nlt->flag & NLATRACK_SOLO) == 0)
+ if ((nlt->flag & NLATRACK_SOLO) == 0) {
continue;
+ }
/* else - mute doesn't matter */
}
else {
/* no solo tracks - skip track if muted */
- if (nlt->flag & NLATRACK_MUTED)
+ if (nlt->flag & NLATRACK_MUTED) {
continue;
+ }
}
/* if this track has strips (but maybe they won't be suitable), set has_strips
* - used for mainly for still allowing normal action evaluation...
*/
- if (nlt->strips.first)
+ if (nlt->strips.first) {
has_strips = true;
+ }
/* otherwise, get strip to evaluate for this channel */
nes = nlastrips_ctime_get_strip(depsgraph, &estrips, &nlt->strips, track_index, ctime);
- if (nes)
+ if (nes) {
nes->track = nlt;
+ }
}
/* add 'active' Action (may be tweaking track) as last strip to evaluate in NLA stack
@@ -3379,7 +3491,8 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
/* set settings of dummy NLA strip from AnimData settings */
dummy_strip->act = adt->action;
- /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */
+ /* action range is calculated taking F-Modifiers into account
+ * (which making new strips doesn't do due to the troublesome nature of that) */
calc_action_range(dummy_strip->act, &dummy_strip->actstart, &dummy_strip->actend, 1);
dummy_strip->start = dummy_strip->actstart;
dummy_strip->end = (IS_EQF(dummy_strip->actstart, dummy_strip->actend)) ?
@@ -3396,14 +3509,16 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
dummy_strip->extendmode = adt->act_extendmode;
}
- /* Unless extendmode is Nothing (might be useful for flattening NLA evaluation), disable range. */
+ /* Unless extendmode is Nothing (might be useful for flattening NLA evaluation),
+ * disable range. */
if (dummy_strip->extendmode != NLASTRIP_EXTEND_NOTHING) {
dummy_strip->flag |= NLASTRIP_FLAG_NO_TIME_MAP;
}
dummy_strip->influence = adt->act_influence;
- /* NOTE: must set this, or else the default setting overrides, and this setting doesn't work */
+ /* NOTE: must set this, or else the default setting overrides,
+ * and this setting doesn't work. */
dummy_strip->flag |= NLASTRIP_FLAG_USR_INFLUENCE;
}
@@ -3413,7 +3528,8 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
}
/* If computing the context for keyframing, store data there instead of the list. */
else {
- /* The extend mode here effectively controls whether it is possible to keyframe beyond the ends. */
+ /* The extend mode here effectively controls
+ * whether it is possible to key-frame beyond the ends. */
dummy_strip->extendmode = is_inplace_tweak ? NLASTRIP_EXTEND_NOTHING :
NLASTRIP_EXTEND_HOLD;
@@ -3436,12 +3552,15 @@ static bool animsys_evaluate_nla(Depsgraph *depsgraph,
}
/* only continue if there are strips to evaluate */
- if (BLI_listbase_is_empty(&estrips))
+ if (BLI_listbase_is_empty(&estrips)) {
return true;
+ }
- /* 2. for each strip, evaluate then accumulate on top of existing channels, but don't set values yet */
- for (nes = estrips.first; nes; nes = nes->next)
+ /* 2. for each strip, evaluate then accumulate on top of existing channels,
+ * but don't set values yet. */
+ for (nes = estrips.first; nes; nes = nes->next) {
nlastrip_evaluate(depsgraph, ptr, echannels, NULL, nes, &echannels->eval_snapshot);
+ }
/* 3. free temporary evaluation data that's not used elsewhere */
BLI_freelistN(&estrips);
@@ -3472,8 +3591,9 @@ static void animsys_calculate_nla(Depsgraph *depsgraph,
else {
/* special case - evaluate as if there isn't any NLA data */
/* TODO: this is really just a stop-gap measure... */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
CLOG_WARN(&LOG, "NLA Eval: Stopgap for active action on NLA Stack - no strips case");
+ }
animsys_evaluate_action(depsgraph, ptr, adt->action, ctime);
}
@@ -3488,9 +3608,10 @@ static void animsys_calculate_nla(Depsgraph *depsgraph,
* Prepare data necessary to compute correct keyframe values for NLA strips
* with non-Replace mode or influence different from 1.
*
- * @param cache List used to cache contexts for reuse when keying multiple channels in one operation.
- * @param ptr RNA pointer to the Object with the animation.
- * @return Keyframing context, or NULL if not necessary.
+ * \param cache List used to cache contexts for reuse when keying
+ * multiple channels in one operation.
+ * \param ptr RNA pointer to the Object with the animation.
+ * \return Keyframing context, or NULL if not necessary.
*/
NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(struct ListBase *cache,
struct Depsgraph *depsgraph,
@@ -3531,13 +3652,14 @@ NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context(struct ListBase *ca
/**
* Apply correction from the NLA context to the values about to be keyframed.
*
- * @param context Context to use (may be NULL).
- * @param prop_ptr Property about to be keyframed.
- * @param[in,out] values Array of property values to adjust.
- * @param count Number of values in the array.
- * @param index Index of the element about to be updated, or -1.
- * @param[out] r_force_all Set to true if all channels must be inserted. May be NULL.
- * @return False if correction fails due to a division by zero, or null r_force_all when all channels are required.
+ * \param context Context to use (may be NULL).
+ * \param prop_ptr Property about to be keyframed.
+ * \param[in,out] values Array of property values to adjust.
+ * \param count Number of values in the array.
+ * \param index Index of the element about to be updated, or -1.
+ * \param[out] r_force_all Set to true if all channels must be inserted. May be NULL.
+ * \return False if correction fails due to a division by zero,
+ * or null r_force_all when all channels are required.
*/
bool BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context,
struct PointerRNA *prop_ptr,
@@ -3681,17 +3803,21 @@ static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt)
* 3) Drivers/expressions are evaluated on top of this, in an order where dependencies are
* resolved nicely.
* Note: it may be necessary to have some tools to handle the cases where some higher-level
- * drivers are added and cause some problematic dependencies that didn't exist in the local levels...
+ * drivers are added and cause some problematic dependencies that
+ * didn't exist in the local levels...
*
* --------------< always executed >------------------
*
* Maintenance of editability of settings (XXX):
- * In order to ensure that settings that are animated can still be manipulated in the UI without requiring
- * that keyframes are added to prevent these values from being overwritten, we use 'overrides'.
+ * - In order to ensure that settings that are animated can still be manipulated in the UI without
+ * requiring that keyframes are added to prevent these values from being overwritten,
+ * we use 'overrides'.
*
* Unresolved things:
- * - Handling of multi-user settings (i.e. time-offset, group-instancing) -> big cache grids or nodal system? but stored where?
- * - Multiple-block dependencies (i.e. drivers for settings are in both local and higher levels) -> split into separate lists?
+ * - Handling of multi-user settings (i.e. time-offset, group-instancing) -> big cache grids
+ * or nodal system? but stored where?
+ * - Multiple-block dependencies
+ * (i.e. drivers for settings are in both local and higher levels) -> split into separate lists?
*
* Current Status:
* - Currently (as of September 2009), overrides we haven't needed to (fully) implement overrides.
@@ -3710,8 +3836,9 @@ void BKE_animsys_evaluate_animdata(
PointerRNA id_ptr;
/* sanity checks */
- if (ELEM(NULL, id, adt))
+ if (ELEM(NULL, id, adt)) {
return;
+ }
/* get pointer to ID-block for RNA to use */
RNA_id_pointer_create(id, &id_ptr);
@@ -3730,8 +3857,9 @@ void BKE_animsys_evaluate_animdata(
animsys_calculate_nla(depsgraph, &id_ptr, adt, ctime);
}
/* evaluate Active Action only */
- else if (adt->action)
+ else if (adt->action) {
animsys_evaluate_action_ex(depsgraph, &id_ptr, adt->action, ctime);
+ }
}
/* recalculate drivers
@@ -3773,10 +3901,11 @@ void BKE_animsys_evaluate_all_animation(Main *main,
{
ID *id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Evaluate all animation - %f\n", ctime);
+ }
- /* macros for less typing
+ /* macros for less typing
* - only evaluate animation data for id if it has users (and not just fake ones)
* - whether animdata exists is checked for by the evaluation function, though taking
* this outside of the function may make things slightly faster?
@@ -3790,7 +3919,7 @@ void BKE_animsys_evaluate_all_animation(Main *main,
} \
(void)0
- /* another macro for the "embedded" nodetree cases
+ /* another macro for the "embedded" nodetree cases
* - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees"
* (i.e. scene/material/texture->nodetree) which we need a special exception
* for, otherwise they'd get skipped
@@ -3820,8 +3949,9 @@ void BKE_animsys_evaluate_all_animation(Main *main,
* set correctly, so this optimization must be skipped in that case...
*/
if (BLI_listbase_is_empty(&main->actions) && BLI_listbase_is_empty(&main->curves)) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tNo Actions, so no animation needs to be evaluated...\n");
+ }
return;
}
@@ -3906,9 +4036,9 @@ void BKE_animsys_eval_animdata(Depsgraph *depsgraph, ID *id)
{
float ctime = DEG_get_ctime(depsgraph);
AnimData *adt = BKE_animdata_from_id(id);
- Scene *scene = NULL; /* XXX: this is only needed for flushing RNA updates,
- * which should get handled as part of the dependency graph instead...
- */
+ /* XXX: this is only needed for flushing RNA updates,
+ * which should get handled as part of the dependency graph instead. */
+ Scene *scene = NULL;
DEG_debug_print_eval_time(depsgraph, __func__, id->name, id, ctime);
BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, ADT_RECALC_ANIM);
}
@@ -3964,9 +4094,9 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph,
/* XXX driver recalc flag is not set yet by depsgraph! */
if ((driver_orig) && !(driver_orig->flag & DRIVER_FLAG_INVALID)) {
/* evaluate this using values set already in other places
- * NOTE: for 'layering' option later on, we should check if we should remove old value before adding
- * new to only be done when drivers only changed */
- //printf("\told val = %f\n", fcu->curval);
+ * NOTE: for 'layering' option later on, we should check if we should remove old value before
+ * adding new to only be done when drivers only changed */
+ // printf("\told val = %f\n", fcu->curval);
PathResolvedRNA anim_rna;
if (animsys_store_rna_setting(&id_ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 5383138956e..2b4123c74e2 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -55,8 +55,9 @@
# ifdef WITH_BINRELOC
# include "binreloc.h"
# endif
-# include <unistd.h> /* mkdtemp on OSX (and probably all *BSD?), not worth making specific check for this OS. */
-#endif /* WIN32 */
+/* mkdtemp on OSX (and probably all *BSD?), not worth making specific check for this OS. */
+# include <unistd.h>
+#endif /* WIN32 */
/* local */
static CLG_LogRef LOG = {"bke.appdir"};
@@ -73,8 +74,9 @@ const char *BKE_appdir_folder_default(void)
#ifndef WIN32
const char *const xdg_documents_dir = BLI_getenv("XDG_DOCUMENTS_DIR");
- if (xdg_documents_dir)
+ if (xdg_documents_dir) {
return xdg_documents_dir;
+ }
return BLI_getenv("HOME");
#else /* Windows */
@@ -83,8 +85,9 @@ const char *BKE_appdir_folder_default(void)
/* Check for %HOME% env var */
if (uput_getenv("HOME", documentfolder, MAXPATHLEN)) {
- if (BLI_is_dir(documentfolder))
+ if (BLI_is_dir(documentfolder)) {
return documentfolder;
+ }
}
/* add user profile support for WIN 2K / NT.
@@ -95,8 +98,9 @@ const char *BKE_appdir_folder_default(void)
hResult = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, documentfolder);
if (hResult == S_OK) {
- if (BLI_is_dir(documentfolder))
+ if (BLI_is_dir(documentfolder)) {
return documentfolder;
+ }
}
return NULL;
@@ -153,7 +157,7 @@ static bool test_path(char *targetpath,
#ifdef PATH_DEBUG
printf("\t%s missing: %s\n", __func__, targetpath);
#endif
- //targetpath[0] = '\0';
+ // targetpath[0] = '\0';
return false;
}
}
@@ -165,8 +169,9 @@ static bool test_path(char *targetpath,
static bool test_env_path(char *path, const char *envvar)
{
const char *env = envvar ? BLI_getenv(envvar) : NULL;
- if (!env)
+ if (!env) {
return false;
+ }
if (BLI_is_dir(env)) {
BLI_strncpy(path, env, FILE_MAX);
@@ -218,9 +223,11 @@ static bool get_path_local(char *targetpath,
relfolder[0] = '\0';
}
- /* try EXECUTABLE_DIR/2.5x/folder_name - new default directory for local blender installed files */
+ /* Try EXECUTABLE_DIR/2.5x/folder_name -
+ * new default directory for local blender installed files. */
#ifdef __APPLE__
- /* due new codesign situation in OSX > 10.9.5 we must move the blender_version dir with contents to Resources */
+ /* Due new codesign situation in OSX > 10.9.5
+ * we must move the blender_version dir with contents to Resources. */
char osx_resourses[FILE_MAX];
BLI_snprintf(osx_resourses, sizeof(osx_resourses), "%s../Resources", bprogdir);
/* Remove the '/../' added above. */
@@ -324,11 +331,13 @@ static bool get_path_user(char *targetpath,
user_path[0] = '\0';
user_base_path = (const char *)GHOST_getUserDir(ver, blender_version_decimal(ver));
- if (user_base_path)
+ if (user_base_path) {
BLI_strncpy(user_path, user_base_path, FILE_MAX);
+ }
- if (!user_path[0])
+ if (!user_path[0]) {
return false;
+ }
#ifdef PATH_DEBUG
printf("%s: %s\n", __func__, user_path);
@@ -375,11 +384,13 @@ static bool get_path_system(char *targetpath,
system_path[0] = '\0';
system_base_path = (const char *)GHOST_getSystemDir(ver, blender_version_decimal(ver));
- if (system_base_path)
+ if (system_base_path) {
BLI_strncpy(system_path, system_base_path, FILE_MAX);
+ }
- if (!system_path[0])
+ if (!system_path[0]) {
return false;
+ }
#ifdef PATH_DEBUG
printf("%s: %s\n", __func__, system_path);
@@ -411,71 +422,93 @@ const char *BKE_appdir_folder_id_ex(const int folder_id,
switch (folder_id) {
case BLENDER_DATAFILES: /* general case */
- if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES"))
+ if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES")) {
break;
- if (get_path_user(path, path_len, "datafiles", subfolder, ver))
+ }
+ if (get_path_user(path, path_len, "datafiles", subfolder, ver)) {
break;
- if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES"))
+ }
+ if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES")) {
break;
- if (get_path_local(path, path_len, "datafiles", subfolder, ver))
+ }
+ if (get_path_local(path, path_len, "datafiles", subfolder, ver)) {
break;
- if (get_path_system(path, path_len, "datafiles", subfolder, ver))
+ }
+ if (get_path_system(path, path_len, "datafiles", subfolder, ver)) {
break;
+ }
return NULL;
case BLENDER_USER_DATAFILES:
- if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES"))
+ if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES")) {
break;
- if (get_path_user(path, path_len, "datafiles", subfolder, ver))
+ }
+ if (get_path_user(path, path_len, "datafiles", subfolder, ver)) {
break;
+ }
return NULL;
case BLENDER_SYSTEM_DATAFILES:
- if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES"))
+ if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_DATAFILES")) {
break;
- if (get_path_system(path, path_len, "datafiles", subfolder, ver))
+ }
+ if (get_path_system(path, path_len, "datafiles", subfolder, ver)) {
break;
- if (get_path_local(path, path_len, "datafiles", subfolder, ver))
+ }
+ if (get_path_local(path, path_len, "datafiles", subfolder, ver)) {
break;
+ }
return NULL;
case BLENDER_USER_AUTOSAVE:
- if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES"))
+ if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_DATAFILES")) {
break;
- if (get_path_user(path, path_len, "autosave", subfolder, ver))
+ }
+ if (get_path_user(path, path_len, "autosave", subfolder, ver)) {
break;
+ }
return NULL;
case BLENDER_USER_CONFIG:
- if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_CONFIG"))
+ if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_CONFIG")) {
break;
- if (get_path_user(path, path_len, "config", subfolder, ver))
+ }
+ if (get_path_user(path, path_len, "config", subfolder, ver)) {
break;
+ }
return NULL;
case BLENDER_USER_SCRIPTS:
- if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_SCRIPTS"))
+ if (get_path_environment(path, path_len, subfolder, "BLENDER_USER_SCRIPTS")) {
break;
- if (get_path_user(path, path_len, "scripts", subfolder, ver))
+ }
+ if (get_path_user(path, path_len, "scripts", subfolder, ver)) {
break;
+ }
return NULL;
case BLENDER_SYSTEM_SCRIPTS:
- if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_SCRIPTS"))
+ if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_SCRIPTS")) {
break;
- if (get_path_system(path, path_len, "scripts", subfolder, ver))
+ }
+ if (get_path_system(path, path_len, "scripts", subfolder, ver)) {
break;
- if (get_path_local(path, path_len, "scripts", subfolder, ver))
+ }
+ if (get_path_local(path, path_len, "scripts", subfolder, ver)) {
break;
+ }
return NULL;
case BLENDER_SYSTEM_PYTHON:
- if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_PYTHON"))
+ if (get_path_environment(path, path_len, subfolder, "BLENDER_SYSTEM_PYTHON")) {
break;
- if (get_path_system(path, path_len, "python", subfolder, ver))
+ }
+ if (get_path_system(path, path_len, "python", subfolder, ver)) {
break;
- if (get_path_local(path, path_len, "python", subfolder, ver))
+ }
+ if (get_path_local(path, path_len, "python", subfolder, ver)) {
break;
+ }
return NULL;
default:
@@ -502,23 +535,27 @@ const char *BKE_appdir_folder_id_user_notest(const int folder_id, const char *su
switch (folder_id) {
case BLENDER_USER_DATAFILES:
- if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_DATAFILES"))
+ if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_DATAFILES")) {
break;
+ }
get_path_user(path, sizeof(path), "datafiles", subfolder, ver);
break;
case BLENDER_USER_CONFIG:
- if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_CONFIG"))
+ if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_CONFIG")) {
break;
+ }
get_path_user(path, sizeof(path), "config", subfolder, ver);
break;
case BLENDER_USER_AUTOSAVE:
- if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_AUTOSAVE"))
+ if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_AUTOSAVE")) {
break;
+ }
get_path_user(path, sizeof(path), "autosave", subfolder, ver);
break;
case BLENDER_USER_SCRIPTS:
- if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_SCRIPTS"))
+ if (get_path_environment_notest(path, sizeof(path), subfolder, "BLENDER_USER_SCRIPTS")) {
break;
+ }
get_path_user(path, sizeof(path), "scripts", subfolder, ver);
break;
default:
@@ -544,15 +581,17 @@ const char *BKE_appdir_folder_id_create(const int folder_id, const char *subfold
BLENDER_USER_DATAFILES,
BLENDER_USER_CONFIG,
BLENDER_USER_SCRIPTS,
- BLENDER_USER_AUTOSAVE))
+ BLENDER_USER_AUTOSAVE)) {
return NULL;
+ }
path = BKE_appdir_folder_id(folder_id, subfolder);
if (!path) {
path = BKE_appdir_folder_id_user_notest(folder_id, subfolder);
- if (path)
+ if (path) {
BLI_dir_create_recursive(path);
+ }
}
return path;
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 69721651a45..60446bf60b6 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -89,8 +89,9 @@ bArmature *BKE_armature_add(Main *bmain, const char *name)
bArmature *BKE_armature_from_object(Object *ob)
{
- if (ob->type == OB_ARMATURE)
+ if (ob->type == OB_ARMATURE) {
return (bArmature *)ob->data;
+ }
return NULL;
}
@@ -168,9 +169,33 @@ static void copy_bonechildren(Bone *bone_dst,
}
}
+static void copy_bonechildren_custom_handles(Bone *bone_dst, bArmature *arm_dst, GHash **bone_hash)
+{
+ Bone *bone_dst_child;
+
+ /* Lazily create the name -> bone hashtable. */
+ if ((bone_dst->bbone_prev || bone_dst->bbone_next) && *bone_hash == NULL) {
+ *bone_hash = BKE_armature_bone_from_name_map(arm_dst);
+ }
+
+ if (bone_dst->bbone_prev) {
+ bone_dst->bbone_prev = BLI_ghash_lookup(*bone_hash, bone_dst->bbone_prev->name);
+ }
+ if (bone_dst->bbone_next) {
+ bone_dst->bbone_next = BLI_ghash_lookup(*bone_hash, bone_dst->bbone_next->name);
+ }
+
+ for (bone_dst_child = bone_dst->childbase.first; bone_dst_child;
+ bone_dst_child = bone_dst_child->next) {
+ copy_bonechildren_custom_handles(bone_dst_child, arm_dst, bone_hash);
+ }
+}
+
/**
- * Only copy internal data of Armature ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Armature ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -199,6 +224,17 @@ void BKE_armature_copy_data(Main *UNUSED(bmain),
arm_dst->act_bone = bone_dst_act;
+ /* Fix custom handle references. */
+ GHash *bone_hash = NULL; /* lazily created */
+
+ for (bone_dst = arm_dst->bonebase.first; bone_dst; bone_dst = bone_dst->next) {
+ copy_bonechildren_custom_handles(bone_dst, arm_dst, &bone_hash);
+ }
+
+ if (bone_hash) {
+ BLI_ghash_free(bone_hash, NULL, NULL);
+ }
+
arm_dst->edbo = NULL;
arm_dst->act_edbone = NULL;
}
@@ -215,12 +251,14 @@ static Bone *get_named_bone_bonechildren(ListBase *lb, const char *name)
Bone *curBone, *rbone;
for (curBone = lb->first; curBone; curBone = curBone->next) {
- if (STREQ(curBone->name, name))
+ if (STREQ(curBone->name, name)) {
return curBone;
+ }
rbone = get_named_bone_bonechildren(&curBone->childbase, name);
- if (rbone)
+ if (rbone) {
return rbone;
+ }
}
return NULL;
@@ -232,8 +270,9 @@ static Bone *get_named_bone_bonechildren(ListBase *lb, const char *name)
*/
Bone *BKE_armature_find_bone_name(bArmature *arm, const char *name)
{
- if (!arm)
+ if (!arm) {
return NULL;
+ }
return get_named_bone_bonechildren(&arm->bonebase, name);
}
@@ -285,8 +324,9 @@ int bone_autoside_name(
char extension[5] = "";
len = strlen(name);
- if (len == 0)
+ if (len == 0) {
return 0;
+ }
BLI_strncpy(basename, name, sizeof(basename));
/* Figure out extension to append:
@@ -300,47 +340,59 @@ int bone_autoside_name(
if (axis == 2) {
/* z-axis - vertical (top/bottom) */
if (IS_EQF(head, 0.0f)) {
- if (tail < 0)
+ if (tail < 0) {
strcpy(extension, "Bot");
- else if (tail > 0)
+ }
+ else if (tail > 0) {
strcpy(extension, "Top");
+ }
}
else {
- if (head < 0)
+ if (head < 0) {
strcpy(extension, "Bot");
- else
+ }
+ else {
strcpy(extension, "Top");
+ }
}
}
else if (axis == 1) {
/* y-axis - depth (front/back) */
if (IS_EQF(head, 0.0f)) {
- if (tail < 0)
+ if (tail < 0) {
strcpy(extension, "Fr");
- else if (tail > 0)
+ }
+ else if (tail > 0) {
strcpy(extension, "Bk");
+ }
}
else {
- if (head < 0)
+ if (head < 0) {
strcpy(extension, "Fr");
- else
+ }
+ else {
strcpy(extension, "Bk");
+ }
}
}
else {
/* x-axis - horizontal (left/right) */
if (IS_EQF(head, 0.0f)) {
- if (tail < 0)
+ if (tail < 0) {
strcpy(extension, "R");
- else if (tail > 0)
+ }
+ else if (tail > 0) {
strcpy(extension, "L");
+ }
}
else {
- if (head < 0)
+ if (head < 0) {
strcpy(extension, "R");
- /* XXX Shouldn't this be simple else, as for z and y axes? */
- else if (head > 0)
+ /* XXX Shouldn't this be simple else, as for z and y axes? */
+ }
+ else if (head > 0) {
strcpy(extension, "L");
+ }
}
}
@@ -391,8 +443,9 @@ int bone_autoside_name(
return 1;
}
- else
+ else {
return 0;
+ }
}
/* ************* B-Bone support ******************* */
@@ -420,8 +473,9 @@ static void equalize_cubic_bezier(const float control[4][3],
/* Calculate the length of the polyline at each point. */
pdist[0] = 0.0f;
- for (int i = 0; i < temp_segments; i++)
+ for (int i = 0; i < temp_segments; i++) {
pdist[i + 1] = pdist[i] + len_v3v3(coords[i], coords[i + 1]);
+ }
/* Go over distances and calculate new parameter values. */
float dist_step = pdist[temp_segments] / final_segments;
@@ -432,8 +486,9 @@ static void equalize_cubic_bezier(const float control[4][3],
float dist = i * dist_step;
/* We're looking for location (distance) 'dist' in the array. */
- while ((nr < temp_segments) && (dist >= pdist[nr]))
+ while ((nr < temp_segments) && (dist >= pdist[nr])) {
nr++;
+ }
float fac = (pdist[nr] - dist) / (pdist[nr] - pdist[nr - 1]);
@@ -443,7 +498,8 @@ static void equalize_cubic_bezier(const float control[4][3],
r_t_points[final_segments] = 1.0f;
}
-/* Evaluate bezier position and tangent at a specific parameter value using the De Casteljau algorithm. */
+/* Evaluate bezier position and tangent at a specific parameter value
+ * using the De Casteljau algorithm. */
static void evaluate_cubic_bezier(const float control[4][3],
float t,
float r_pos[3],
@@ -660,15 +716,17 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan,
}
}
- param->scaleIn = bone->scaleIn * (!rest ? pchan->scaleIn : 1.0f);
- param->scaleOut = bone->scaleOut * (!rest ? pchan->scaleOut : 1.0f);
+ param->scale_in_x = bone->scale_in_x * (!rest ? pchan->scale_in_x : 1.0f);
+ param->scale_in_y = bone->scale_in_y * (!rest ? pchan->scale_in_y : 1.0f);
+ param->scale_out_x = bone->scale_out_x * (!rest ? pchan->scale_out_x : 1.0f);
+ param->scale_out_y = bone->scale_out_y * (!rest ? pchan->scale_out_y : 1.0f);
/* Extra curve x / y */
- param->curveInX = bone->curveInX + (!rest ? pchan->curveInX : 0.0f);
- param->curveInY = bone->curveInY + (!rest ? pchan->curveInY : 0.0f);
+ param->curve_in_x = bone->curve_in_x + (!rest ? pchan->curve_in_x : 0.0f);
+ param->curve_in_y = bone->curve_in_y + (!rest ? pchan->curve_in_y : 0.0f);
- param->curveOutX = bone->curveOutX + (!rest ? pchan->curveOutX : 0.0f);
- param->curveOutY = bone->curveOutY + (!rest ? pchan->curveOutY : 0.0f);
+ param->curve_out_x = bone->curve_out_x + (!rest ? pchan->curve_out_x : 0.0f);
+ param->curve_out_y = bone->curve_out_y + (!rest ? pchan->curve_out_y : 0.0f);
}
}
@@ -713,8 +771,9 @@ void BKE_pchan_bbone_handles_compute(const BBoneSplineParameters *param,
h1[1] -= length;
}
- if (normalize_v3(h1) < epsilon)
+ if (normalize_v3(h1) < epsilon) {
copy_v3_fl3(h1, 0.0f, -1.0f, 0.0f);
+ }
negate_v3(h1);
@@ -741,8 +800,9 @@ void BKE_pchan_bbone_handles_compute(const BBoneSplineParameters *param,
h2[1] -= length;
}
- if (normalize_v3(h2) < epsilon)
+ if (normalize_v3(h2) < epsilon) {
copy_v3_fl3(h2, 0.0f, 1.0f, 0.0f);
+ }
/* Find the next roll to interpolate as well. */
copy_m3_m4(mat3, param->next_mat);
@@ -785,18 +845,19 @@ void BKE_pchan_bbone_handles_compute(const BBoneSplineParameters *param,
*r_roll2 += param->roll2;
/* Extra curve x / y */
- /* NOTE: Scale correction factors here are to compensate for some random floating-point glitches
- * when scaling up the bone or it's parent by a factor of approximately 8.15/6, which results
- * in the bone length getting scaled up too (from 1 to 8), causing the curve to flatten out.
+ /* NOTE:
+ * Scale correction factors here are to compensate for some random floating-point glitches
+ * when scaling up the bone or it's parent by a factor of approximately 8.15/6, which results
+ * in the bone length getting scaled up too (from 1 to 8), causing the curve to flatten out.
*/
const float xscale_correction = (param->do_scale) ? param->scale[0] : 1.0f;
const float yscale_correction = (param->do_scale) ? param->scale[2] : 1.0f;
- h1[0] += param->curveInX * xscale_correction;
- h1[2] += param->curveInY * yscale_correction;
+ h1[0] += param->curve_in_x * xscale_correction;
+ h1[2] += param->curve_in_y * yscale_correction;
- h2[0] += param->curveOutX * xscale_correction;
- h2[2] += param->curveOutY * yscale_correction;
+ h2[0] += param->curve_out_x * xscale_correction;
+ h2[2] += param->curve_out_y * yscale_correction;
}
}
@@ -805,7 +866,8 @@ static void make_bbone_spline_matrix(BBoneSplineParameters *param,
float pos[3],
float axis[3],
float roll,
- float scalefac,
+ float scalex,
+ float scaley,
float result[4][4])
{
float mat3[3][3];
@@ -821,8 +883,8 @@ static void make_bbone_spline_matrix(BBoneSplineParameters *param,
}
/* BBone scale... */
- mul_v3_fl(result[0], scalefac);
- mul_v3_fl(result[2], scalefac);
+ mul_v3_fl(result[0], scalex);
+ mul_v3_fl(result[2], scaley);
}
/* Fade from first to second derivative when the handle is very short. */
@@ -886,17 +948,25 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param,
/* End points require special handling to fix zero length handles. */
ease_handle_axis(bezt_deriv1[0], bezt_deriv2[0], axis);
- make_bbone_spline_matrix(
- param, scalemats, bezt_controls[0], axis, roll1, param->scaleIn, result_array[0].mat);
+ make_bbone_spline_matrix(param,
+ scalemats,
+ bezt_controls[0],
+ axis,
+ roll1,
+ param->scale_in_x,
+ param->scale_in_y,
+ result_array[0].mat);
for (int a = 1; a < param->segments; a++) {
evaluate_cubic_bezier(bezt_controls, bezt_points[a], cur, axis);
float fac = ((float)a) / param->segments;
float roll = interpf(roll2, roll1, fac);
- float scalefac = interpf(param->scaleOut, param->scaleIn, fac);
+ float scalex = interpf(param->scale_out_x, param->scale_in_x, fac);
+ float scaley = interpf(param->scale_out_y, param->scale_in_y, fac);
- make_bbone_spline_matrix(param, scalemats, cur, axis, roll, scalefac, result_array[a].mat);
+ make_bbone_spline_matrix(
+ param, scalemats, cur, axis, roll, scalex, scaley, result_array[a].mat);
}
negate_v3(bezt_deriv2[1]);
@@ -906,7 +976,8 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param,
bezt_controls[3],
axis,
roll2,
- param->scaleOut,
+ param->scale_out_x,
+ param->scale_out_y,
result_array[param->segments].mat);
}
/* Other code (e.g. display) uses matrices for the segments themselves. */
@@ -920,9 +991,11 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param,
float fac = (a + 0.5f) / param->segments;
float roll = interpf(roll2, roll1, fac);
- float scalefac = interpf(param->scaleOut, param->scaleIn, fac);
+ float scalex = interpf(param->scale_out_x, param->scale_in_x, fac);
+ float scaley = interpf(param->scale_out_y, param->scale_in_y, fac);
- make_bbone_spline_matrix(param, scalemats, prev, axis, roll, scalefac, result_array[a].mat);
+ make_bbone_spline_matrix(
+ param, scalemats, prev, axis, roll, scalex, scaley, result_array[a].mat);
copy_v3_v3(prev, cur);
}
}
@@ -932,25 +1005,12 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param,
/* ************ Armature Deform ******************* */
-typedef struct bPoseChanDeform {
- DualQuat *dual_quat;
-} bPoseChanDeform;
-
-/* Definition of cached object bbone deformations. */
-typedef struct ObjectBBoneDeform {
- DualQuat *dualquats;
- bPoseChanDeform *pdef_info_array;
- int num_pchan;
-} ObjectBBoneDeform;
-
static void allocate_bbone_cache(bPoseChannel *pchan, int segments)
{
bPoseChannel_Runtime *runtime = &pchan->runtime;
if (runtime->bbone_segments != segments) {
- if (runtime->bbone_segments != 0) {
- BKE_pose_channel_free_bbone_cache(pchan);
- }
+ BKE_pose_channel_free_bbone_cache(runtime);
runtime->bbone_segments = segments;
runtime->bbone_rest_mats = MEM_malloc_arrayN(
@@ -1020,7 +1080,7 @@ void BKE_pchan_bbone_segments_cache_copy(bPoseChannel *pchan, bPoseChannel *pcha
int segments = runtime_from->bbone_segments;
if (segments <= 1) {
- BKE_pose_channel_free_bbone_cache(pchan);
+ BKE_pose_channel_free_bbone_cache(&pchan->runtime);
}
else {
allocate_bbone_cache(pchan, segments);
@@ -1036,7 +1096,8 @@ void BKE_pchan_bbone_segments_cache_copy(bPoseChannel *pchan, bPoseChannel *pcha
}
}
-/** Calculate index and blend factor for the two B-Bone segment nodes affecting the point at 0 <= pos <= 1. */
+/** Calculate index and blend factor for the two B-Bone segment nodes
+ * affecting the point at 0 <= pos <= 1. */
void BKE_pchan_bbone_deform_segment_index(const bPoseChannel *pchan,
float pos,
int *r_index,
@@ -1071,8 +1132,9 @@ static void pchan_deform_accumulate(const DualQuat *deform_dq,
DualQuat *dq_accum,
float mat_accum[3][3])
{
- if (weight == 0.0f)
+ if (weight == 0.0f) {
return;
+ }
if (dq_accum) {
BLI_assert(!co_accum);
@@ -1154,18 +1216,21 @@ float distfactor_to_bone(
rad = a / l;
rad = rad * rad2 + (1.0f - rad) * rad1;
}
- else
+ else {
rad = rad1;
+ }
}
a = rad * rad;
- if (dist_sq < a)
+ if (dist_sq < a) {
return 1.0f;
+ }
else {
l = rad + rdist;
l *= l;
- if (rdist == 0.0f || dist_sq >= l)
+ if (rdist == 0.0f || dist_sq >= l) {
return 0.0f;
+ }
else {
a = sqrtf(dist_sq) - rad;
return 1.0f - (a * a) / (rdist * rdist);
@@ -1173,18 +1238,15 @@ float distfactor_to_bone(
}
}
-static float dist_bone_deform(bPoseChannel *pchan,
- const bPoseChanDeform *pdef_info,
- float vec[3],
- DualQuat *dq,
- float mat[3][3],
- const float co[3])
+static float dist_bone_deform(
+ bPoseChannel *pchan, float vec[3], DualQuat *dq, float mat[3][3], const float co[3])
{
Bone *bone = pchan->bone;
float fac, contrib = 0.0;
- if (bone == NULL)
+ if (bone == NULL) {
return 0.0f;
+ }
fac = distfactor_to_bone(
co, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, bone->dist);
@@ -1193,10 +1255,13 @@ static float dist_bone_deform(bPoseChannel *pchan,
fac *= bone->weight;
contrib = fac;
if (contrib > 0.0f) {
- if (bone->segments > 1 && pchan->runtime.bbone_segments == bone->segments)
+ if (bone->segments > 1 && pchan->runtime.bbone_segments == bone->segments) {
b_bone_deform(pchan, co, fac, vec, dq, mat);
- else
- pchan_deform_accumulate(pdef_info->dual_quat, pchan->chan_mat, co, fac, vec, dq, mat);
+ }
+ else {
+ pchan_deform_accumulate(
+ &pchan->runtime.deform_dual_quat, pchan->chan_mat, co, fac, vec, dq, mat);
+ }
}
}
@@ -1204,7 +1269,6 @@ static float dist_bone_deform(bPoseChannel *pchan,
}
static void pchan_bone_deform(bPoseChannel *pchan,
- const bPoseChanDeform *pdef_info,
float weight,
float vec[3],
DualQuat *dq,
@@ -1214,37 +1278,224 @@ static void pchan_bone_deform(bPoseChannel *pchan,
{
Bone *bone = pchan->bone;
- if (!weight)
+ if (!weight) {
return;
+ }
- if (bone->segments > 1 && pchan->runtime.bbone_segments == bone->segments)
+ if (bone->segments > 1 && pchan->runtime.bbone_segments == bone->segments) {
b_bone_deform(pchan, co, weight, vec, dq, mat);
- else
- pchan_deform_accumulate(pdef_info->dual_quat, pchan->chan_mat, co, weight, vec, dq, mat);
+ }
+ else {
+ pchan_deform_accumulate(
+ &pchan->runtime.deform_dual_quat, pchan->chan_mat, co, weight, vec, dq, mat);
+ }
(*contrib) += weight;
}
-typedef struct ArmatureBBoneDefmatsData {
- bPoseChanDeform *pdef_info_array;
- DualQuat *dualquats;
+typedef struct ArmatureUserdata {
+ Object *armOb;
+ Object *target;
+ const Mesh *mesh;
+ float (*vertexCos)[3];
+ float (*defMats)[3][3];
+ float (*prevCos)[3];
+
+ bool use_envelope;
bool use_quaternion;
-} ArmatureBBoneDefmatsData;
+ bool invert_vgroup;
+ bool use_dverts;
+
+ int armature_def_nr;
-static void armature_bbone_defmats_cb(void *userdata, Link *iter, int index)
+ int target_totvert;
+ MDeformVert *dverts;
+
+ int defbase_tot;
+ bPoseChannel **defnrToPC;
+
+ float premat[4][4];
+ float postmat[4][4];
+} ArmatureUserdata;
+
+static void armature_vert_task(void *__restrict userdata,
+ const int i,
+ const ParallelRangeTLS *__restrict UNUSED(tls))
{
- ArmatureBBoneDefmatsData *data = userdata;
- bPoseChannel *pchan = (bPoseChannel *)iter;
+ const ArmatureUserdata *data = userdata;
+ float(*const vertexCos)[3] = data->vertexCos;
+ float(*const defMats)[3][3] = data->defMats;
+ float(*const prevCos)[3] = data->prevCos;
+ const bool use_envelope = data->use_envelope;
+ const bool use_quaternion = data->use_quaternion;
+ const bool use_dverts = data->use_dverts;
+ const int armature_def_nr = data->armature_def_nr;
- if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
- bPoseChanDeform *pdef_info = &data->pdef_info_array[index];
- const bool use_quaternion = data->use_quaternion;
+ MDeformVert *dvert;
+ DualQuat sumdq, *dq = NULL;
+ bPoseChannel *pchan;
+ float *co, dco[3];
+ float sumvec[3], summat[3][3];
+ float *vec = NULL, (*smat)[3] = NULL;
+ float contrib = 0.0f;
+ float armature_weight = 1.0f; /* default to 1 if no overall def group */
+ float prevco_weight = 1.0f; /* weight for optional cached vertexcos */
+ if (use_quaternion) {
+ memset(&sumdq, 0, sizeof(DualQuat));
+ dq = &sumdq;
+ }
+ else {
+ sumvec[0] = sumvec[1] = sumvec[2] = 0.0f;
+ vec = sumvec;
+
+ if (defMats) {
+ zero_m3(summat);
+ smat = summat;
+ }
+ }
+
+ if (use_dverts || armature_def_nr != -1) {
+ if (data->mesh) {
+ BLI_assert(i < data->mesh->totvert);
+ dvert = data->mesh->dvert + i;
+ }
+ else if (data->dverts && i < data->target_totvert) {
+ dvert = data->dverts + i;
+ }
+ else {
+ dvert = NULL;
+ }
+ }
+ else {
+ dvert = NULL;
+ }
+
+ if (armature_def_nr != -1 && dvert) {
+ armature_weight = defvert_find_weight(dvert, armature_def_nr);
+
+ if (data->invert_vgroup) {
+ armature_weight = 1.0f - armature_weight;
+ }
+
+ /* hackish: the blending factor can be used for blending with prevCos too */
+ if (prevCos) {
+ prevco_weight = armature_weight;
+ armature_weight = 1.0f;
+ }
+ }
+
+ /* check if there's any point in calculating for this vert */
+ if (armature_weight == 0.0f) {
+ return;
+ }
+
+ /* get the coord we work on */
+ co = prevCos ? prevCos[i] : vertexCos[i];
+
+ /* Apply the object's matrix */
+ mul_m4_v3(data->premat, co);
+
+ if (use_dverts && dvert && dvert->totweight) { /* use weight groups ? */
+ MDeformWeight *dw = dvert->dw;
+ int deformed = 0;
+ unsigned int j;
+ float acum_weight = 0;
+ for (j = dvert->totweight; j != 0; j--, dw++) {
+ const int index = dw->def_nr;
+ if (index >= 0 && index < data->defbase_tot && (pchan = data->defnrToPC[index])) {
+ float weight = dw->weight;
+ Bone *bone = pchan->bone;
+
+ deformed = 1;
+
+ if (bone && bone->flag & BONE_MULT_VG_ENV) {
+ weight *= distfactor_to_bone(
+ co, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, bone->dist);
+ }
+
+ /* check limit of weight */
+ if (data->target->type == OB_GPENCIL) {
+ if (acum_weight + weight >= 1.0f) {
+ weight = 1.0f - acum_weight;
+ }
+ acum_weight += weight;
+ }
+
+ pchan_bone_deform(pchan, weight, vec, dq, smat, co, &contrib);
+
+ /* if acumulated weight limit exceed, exit loop */
+ if ((data->target->type == OB_GPENCIL) && (acum_weight >= 1.0f)) {
+ break;
+ }
+ }
+ }
+ /* if there are vertexgroups but not groups with bones
+ * (like for softbody groups) */
+ if (deformed == 0 && use_envelope) {
+ for (pchan = data->armOb->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
+ contrib += dist_bone_deform(pchan, vec, dq, smat, co);
+ }
+ }
+ }
+ }
+ else if (use_envelope) {
+ for (pchan = data->armOb->pose->chanbase.first; pchan; pchan = pchan->next) {
+ if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
+ contrib += dist_bone_deform(pchan, vec, dq, smat, co);
+ }
+ }
+ }
+
+ /* actually should be EPSILON? weight values and contrib can be like 10e-39 small */
+ if (contrib > 0.0001f) {
if (use_quaternion) {
- pdef_info->dual_quat = &data->dualquats[index];
- mat4_to_dquat(pdef_info->dual_quat, pchan->bone->arm_mat, pchan->chan_mat);
+ normalize_dq(dq, contrib);
+
+ if (armature_weight != 1.0f) {
+ copy_v3_v3(dco, co);
+ mul_v3m3_dq(dco, (defMats) ? summat : NULL, dq);
+ sub_v3_v3(dco, co);
+ mul_v3_fl(dco, armature_weight);
+ add_v3_v3(co, dco);
+ }
+ else {
+ mul_v3m3_dq(co, (defMats) ? summat : NULL, dq);
+ }
+
+ smat = summat;
+ }
+ else {
+ mul_v3_fl(vec, armature_weight / contrib);
+ add_v3_v3v3(co, vec, co);
+ }
+
+ if (defMats) {
+ float pre[3][3], post[3][3], tmpmat[3][3];
+
+ copy_m3_m4(pre, data->premat);
+ copy_m3_m4(post, data->postmat);
+ copy_m3_m3(tmpmat, defMats[i]);
+
+ if (!use_quaternion) { /* quaternion already is scale corrected */
+ mul_m3_fl(smat, armature_weight / contrib);
+ }
+
+ mul_m3_series(defMats[i], post, smat, pre, tmpmat);
}
}
+
+ /* always, check above code */
+ mul_m4_v3(data->postmat, co);
+
+ /* interpolate with previous modifier position using weight group */
+ if (prevCos) {
+ float mw = 1.0f - prevco_weight;
+ vertexCos[i][0] = prevco_weight * vertexCos[i][0] + mw * co[0];
+ vertexCos[i][1] = prevco_weight * vertexCos[i][1] + mw * co[1];
+ vertexCos[i][2] = prevco_weight * vertexCos[i][2] + mw * co[2];
+ }
}
void armature_deform_verts(Object *armOb,
@@ -1258,13 +1509,10 @@ void armature_deform_verts(Object *armOb,
const char *defgrp_name,
bGPDstroke *gps)
{
- const bPoseChanDeform *pdef_info = NULL;
bArmature *arm = armOb->data;
- bPoseChannel *pchan, **defnrToPC = NULL;
- int *defnrToPCIndex = NULL;
+ bPoseChannel **defnrToPC = NULL;
MDeformVert *dverts = NULL;
bDeformGroup *dg;
- float obinv[4][4], premat[4][4], postmat[4][4];
const bool use_envelope = (deformflag & ARM_DEF_ENVELOPE) != 0;
const bool use_quaternion = (deformflag & ARM_DEF_QUATERNION) != 0;
const bool invert_vgroup = (deformflag & ARM_DEF_INVERT_VGROUP) != 0;
@@ -1285,25 +1533,6 @@ void armature_deform_verts(Object *armOb,
BLI_assert(0);
}
- invert_m4_m4(obinv, target->obmat);
- copy_m4_m4(premat, target->obmat);
- mul_m4_m4m4(postmat, obinv, armOb->obmat);
- invert_m4_m4(premat, postmat);
-
- /* Use pre-calculated bbone deformation.
- *
- * TODO(sergey): Make this code robust somehow when there are dependency
- * cycles involved. */
- ObjectBBoneDeform *bbone_deform = BKE_armature_cached_bbone_deformation_get(armOb);
- if (bbone_deform == NULL || bbone_deform->pdef_info_array == NULL) {
- CLOG_ERROR(&LOG,
- "Armature does not have bbone cache %s, "
- "usually happens due to a dependency cycle.\n",
- armOb->id.name + 2);
- return;
- }
- const bPoseChanDeform *pdef_info_array = bbone_deform->pdef_info_array;
-
/* get the def_nr for the overall armature vertex group if present */
armature_def_nr = defgroup_name_index(target, defgrp_name);
@@ -1313,19 +1542,22 @@ void armature_deform_verts(Object *armOb,
if (target->type == OB_MESH) {
Mesh *me = target->data;
dverts = me->dvert;
- if (dverts)
+ if (dverts) {
target_totvert = me->totvert;
+ }
}
else if (target->type == OB_LATTICE) {
Lattice *lt = target->data;
dverts = lt->dvert;
- if (dverts)
+ if (dverts) {
target_totvert = lt->pntsu * lt->pntsv * lt->pntsw;
+ }
}
else if (target->type == OB_GPENCIL) {
dverts = gps->dvert;
- if (dverts)
+ if (dverts) {
target_totvert = gps->totpoints;
+ }
}
}
@@ -1342,19 +1574,10 @@ void armature_deform_verts(Object *armOb,
if (use_dverts) {
defnrToPC = MEM_callocN(sizeof(*defnrToPC) * defbase_tot, "defnrToBone");
- defnrToPCIndex = MEM_callocN(sizeof(*defnrToPCIndex) * defbase_tot, "defnrToIndex");
/* TODO(sergey): Some considerations here:
*
- * - Make it more generic function, maybe even keep together with chanhash.
* - Check whether keeping this consistent across frames gives speedup.
- * - Don't use hash for small armatures.
*/
- GHash *idx_hash = BLI_ghash_ptr_new("pose channel index by name");
- int pchan_index = 0;
- for (pchan = armOb->pose->chanbase.first; pchan != NULL;
- pchan = pchan->next, ++pchan_index) {
- BLI_ghash_insert(idx_hash, pchan, POINTER_FROM_INT(pchan_index));
- }
for (i = 0, dg = target->defbase.first; dg; i++, dg = dg->next) {
defnrToPC[i] = BKE_pose_channel_find_name(armOb->pose, dg->name);
/* exclude non-deforming bones */
@@ -1362,181 +1585,42 @@ void armature_deform_verts(Object *armOb,
if (defnrToPC[i]->bone->flag & BONE_NO_DEFORM) {
defnrToPC[i] = NULL;
}
- else {
- defnrToPCIndex[i] = POINTER_AS_INT(BLI_ghash_lookup(idx_hash, defnrToPC[i]));
- }
}
}
- BLI_ghash_free(idx_hash, NULL, NULL);
}
}
}
- for (i = 0; i < numVerts; i++) {
- MDeformVert *dvert;
- DualQuat sumdq, *dq = NULL;
- float *co, dco[3];
- float sumvec[3], summat[3][3];
- float *vec = NULL, (*smat)[3] = NULL;
- float contrib = 0.0f;
- float armature_weight = 1.0f; /* default to 1 if no overall def group */
- float prevco_weight = 1.0f; /* weight for optional cached vertexcos */
-
- if (use_quaternion) {
- memset(&sumdq, 0, sizeof(DualQuat));
- dq = &sumdq;
- }
- else {
- sumvec[0] = sumvec[1] = sumvec[2] = 0.0f;
- vec = sumvec;
-
- if (defMats) {
- zero_m3(summat);
- smat = summat;
- }
- }
-
- if (use_dverts || armature_def_nr != -1) {
- if (mesh) {
- BLI_assert(i < mesh->totvert);
- dvert = mesh->dvert + i;
- }
- else if (dverts && i < target_totvert)
- dvert = dverts + i;
- else
- dvert = NULL;
- }
- else
- dvert = NULL;
-
- if (armature_def_nr != -1 && dvert) {
- armature_weight = defvert_find_weight(dvert, armature_def_nr);
-
- if (invert_vgroup)
- armature_weight = 1.0f - armature_weight;
-
- /* hackish: the blending factor can be used for blending with prevCos too */
- if (prevCos) {
- prevco_weight = armature_weight;
- armature_weight = 1.0f;
- }
- }
-
- /* check if there's any point in calculating for this vert */
- if (armature_weight == 0.0f)
- continue;
-
- /* get the coord we work on */
- co = prevCos ? prevCos[i] : vertexCos[i];
-
- /* Apply the object's matrix */
- mul_m4_v3(premat, co);
-
- if (use_dverts && dvert && dvert->totweight) { /* use weight groups ? */
- MDeformWeight *dw = dvert->dw;
- int deformed = 0;
- unsigned int j;
- float acum_weight = 0;
- for (j = dvert->totweight; j != 0; j--, dw++) {
- const int index = dw->def_nr;
- if (index >= 0 && index < defbase_tot && (pchan = defnrToPC[index])) {
- float weight = dw->weight;
- Bone *bone = pchan->bone;
- pdef_info = pdef_info_array + defnrToPCIndex[index];
-
- deformed = 1;
-
- if (bone && bone->flag & BONE_MULT_VG_ENV) {
- weight *= distfactor_to_bone(
- co, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, bone->dist);
- }
-
- /* check limit of weight */
- if (target->type == OB_GPENCIL) {
- if (acum_weight + weight >= 1.0f) {
- weight = 1.0f - acum_weight;
- }
- acum_weight += weight;
- }
-
- pchan_bone_deform(pchan, pdef_info, weight, vec, dq, smat, co, &contrib);
-
- /* if acumulated weight limit exceed, exit loop */
- if ((target->type == OB_GPENCIL) && (acum_weight >= 1.0f)) {
- break;
- }
- }
- }
- /* if there are vertexgroups but not groups with bones
- * (like for softbody groups) */
- if (deformed == 0 && use_envelope) {
- pdef_info = pdef_info_array;
- for (pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next, pdef_info++) {
- if (!(pchan->bone->flag & BONE_NO_DEFORM))
- contrib += dist_bone_deform(pchan, pdef_info, vec, dq, smat, co);
- }
- }
- }
- else if (use_envelope) {
- pdef_info = pdef_info_array;
- for (pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next, pdef_info++) {
- if (!(pchan->bone->flag & BONE_NO_DEFORM))
- contrib += dist_bone_deform(pchan, pdef_info, vec, dq, smat, co);
- }
- }
-
- /* actually should be EPSILON? weight values and contrib can be like 10e-39 small */
- if (contrib > 0.0001f) {
- if (use_quaternion) {
- normalize_dq(dq, contrib);
-
- if (armature_weight != 1.0f) {
- copy_v3_v3(dco, co);
- mul_v3m3_dq(dco, (defMats) ? summat : NULL, dq);
- sub_v3_v3(dco, co);
- mul_v3_fl(dco, armature_weight);
- add_v3_v3(co, dco);
- }
- else
- mul_v3m3_dq(co, (defMats) ? summat : NULL, dq);
-
- smat = summat;
- }
- else {
- mul_v3_fl(vec, armature_weight / contrib);
- add_v3_v3v3(co, vec, co);
- }
-
- if (defMats) {
- float pre[3][3], post[3][3], tmpmat[3][3];
-
- copy_m3_m4(pre, premat);
- copy_m3_m4(post, postmat);
- copy_m3_m3(tmpmat, defMats[i]);
+ ArmatureUserdata data = {.armOb = armOb,
+ .target = target,
+ .mesh = mesh,
+ .vertexCos = vertexCos,
+ .defMats = defMats,
+ .prevCos = prevCos,
+ .use_envelope = use_envelope,
+ .use_quaternion = use_quaternion,
+ .invert_vgroup = invert_vgroup,
+ .use_dverts = use_dverts,
+ .armature_def_nr = armature_def_nr,
+ .target_totvert = target_totvert,
+ .dverts = dverts,
+ .defbase_tot = defbase_tot,
+ .defnrToPC = defnrToPC};
+
+ float obinv[4][4];
+ invert_m4_m4(obinv, target->obmat);
- if (!use_quaternion) /* quaternion already is scale corrected */
- mul_m3_fl(smat, armature_weight / contrib);
+ mul_m4_m4m4(data.postmat, obinv, armOb->obmat);
+ invert_m4_m4(data.premat, data.postmat);
- mul_m3_series(defMats[i], post, smat, pre, tmpmat);
- }
- }
+ ParallelRangeSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.min_iter_per_thread = 32;
+ BLI_task_parallel_range(0, numVerts, &data, armature_vert_task, &settings);
- /* always, check above code */
- mul_m4_v3(postmat, co);
-
- /* interpolate with previous modifier position using weight group */
- if (prevCos) {
- float mw = 1.0f - prevco_weight;
- vertexCos[i][0] = prevco_weight * vertexCos[i][0] + mw * co[0];
- vertexCos[i][1] = prevco_weight * vertexCos[i][1] + mw * co[1];
- vertexCos[i][2] = prevco_weight * vertexCos[i][2] + mw * co[2];
- }
- }
-
- if (defnrToPC)
+ if (defnrToPC) {
MEM_freeN(defnrToPC);
- if (defnrToPCIndex)
- MEM_freeN(defnrToPCIndex);
+ }
}
/* ************ END Armature Deform ******************* */
@@ -1557,8 +1641,9 @@ void BKE_armature_mat_world_to_pose(Object *ob, float inmat[4][4], float outmat[
float obmat[4][4];
/* prevent crashes */
- if (ob == NULL)
+ if (ob == NULL) {
return;
+ }
/* get inverse of (armature) object's matrix */
invert_m4_m4(obmat, ob->obmat);
@@ -1600,13 +1685,14 @@ void BKE_bone_offset_matrix_get(const Bone *bone, float offs_bone[4][4])
offs_bone[3][1] += bone->parent->length;
}
-/* Construct the matrices (rot/scale and loc) to apply the PoseChannels into the armature (object) space.
+/* Construct the matrices (rot/scale and loc)
+ * to apply the PoseChannels into the armature (object) space.
* I.e. (roughly) the "pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b)" in the
* pose_mat(b)= pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b)
* ...function.
*
- * This allows to get the transformations of a bone in its object space, *before* constraints (and IK)
- * get applied (used by pose evaluation code).
+ * This allows to get the transformations of a bone in its object space,
+ * *before* constraints (and IK) get applied (used by pose evaluation code).
* And reverse: to find pchan transformations needed to place a bone at a given loc/rot/scale
* in object space (used by interactive transform, and snapping code).
*
@@ -1679,8 +1765,9 @@ void BKE_bone_parent_transform_calc_from_matrices(int bone_flag,
normalize_m4(tmat);
mul_m4_m4m4(r_bpt->rotscale_mat, tmat, offs_bone);
}
- else
+ else {
mul_m4_m4m4(r_bpt->rotscale_mat, parent_pose_mat, offs_bone);
+ }
/* Compose the loc matrix for this bone. */
/* NOTE: That version does not modify bone's loc when HINGE/NO_SCALE options are set. */
@@ -1706,9 +1793,11 @@ void BKE_bone_parent_transform_calc_from_matrices(int bone_flag,
else if (bone_flag & (BONE_HINGE | BONE_NO_SCALE)) {
mul_m4_m4m4(r_bpt->loc_mat, parent_pose_mat, offs_bone);
}
- /* Else (i.e. default, usual case), just use the same matrix for rotation/scaling, and location. */
- else
+ /* Else (i.e. default, usual case),
+ * just use the same matrix for rotation/scaling, and location. */
+ else {
copy_m4_m4(r_bpt->loc_mat, r_bpt->rotscale_mat);
+ }
}
/* Root bones. */
else {
@@ -1720,8 +1809,9 @@ void BKE_bone_parent_transform_calc_from_matrices(int bone_flag,
unit_m4(r_bpt->loc_mat);
copy_v3_v3(r_bpt->loc_mat[3], offs_bone[3]);
}
- else
+ else {
copy_m4_m4(r_bpt->loc_mat, r_bpt->rotscale_mat);
+ }
}
}
@@ -1831,15 +1921,44 @@ void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat
mat3_normalized_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, mat);
break;
default: /* euler */
- if (use_compat)
+ if (use_compat) {
mat3_normalized_to_compatible_eulO(pchan->eul, pchan->eul, pchan->rotmode, mat);
- else
+ }
+ else {
mat3_normalized_to_eulO(pchan->eul, pchan->rotmode, mat);
+ }
break;
}
}
/**
+ * Same as #BKE_object_rot_to_mat3().
+ */
+void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3])
+{
+ /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
+ if (pchan->rotmode > 0) {
+ /* euler rotations (will cause gimble lock,
+ * but this can be alleviated a bit with rotation orders) */
+ eulO_to_mat3(mat, pchan->eul, pchan->rotmode);
+ }
+ else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+ /* axis-angle - not really that great for 3D-changing orientations */
+ axis_angle_to_mat3(mat, pchan->rotAxis, pchan->rotAngle);
+ }
+ else {
+ /* quats are normalized before use to eliminate scaling issues */
+ float quat[4];
+
+ /* NOTE: we now don't normalize the stored values anymore,
+ * since this was kindof evil in some cases but if this proves to be too problematic,
+ * switch back to the old system of operating directly on the stored copy. */
+ normalize_qt_qt(quat, pchan->quat);
+ quat_to_mat3(mat, quat);
+ }
+}
+
+/**
* Apply a 4x4 matrix to the pose bone,
* similar to #BKE_object_apply_mat4().
*/
@@ -1909,7 +2028,8 @@ void BKE_rotMode_change_values(
quat_to_axis_angle(axis, angle, quat);
}
- /* when converting to axis-angle, we need a special exception for the case when there is no axis */
+ /* When converting to axis-angle,
+ * we need a special exception for the case when there is no axis. */
if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) {
/* for now, rotate around y-axis then (so that it simply becomes the roll) */
axis[1] = 1.0f;
@@ -1964,50 +2084,72 @@ void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll)
}
/* Calculates the rest matrix of a bone based on its vector and a roll around that vector. */
-/* Given v = (v.x, v.y, v.z) our (normalized) bone vector, we want the rotation matrix M
- * from the Y axis (so that M * (0, 1, 0) = v).
- * -> The rotation axis a lays on XZ plane, and it is orthonormal to v, hence to the projection of v onto XZ plane.
- * -> a = (v.z, 0, -v.x)
+/**
+ * Given `v = (v.x, v.y, v.z)` our (normalized) bone vector, we want the rotation matrix M
+ * from the Y axis (so that `M * (0, 1, 0) = v`).
+ * - The rotation axis a lays on XZ plane, and it is orthonormal to v,
+ * hence to the projection of v onto XZ plane.
+ * - `a = (v.z, 0, -v.x)`
+ *
* We know a is eigenvector of M (so M * a = a).
- * Finally, we have w, such that M * w = (0, 1, 0) (i.e. the vector that will be aligned with Y axis once transformed).
+ * Finally, we have w, such that M * w = (0, 1, 0)
+ * (i.e. the vector that will be aligned with Y axis once transformed).
* We know w is symmetric to v by the Y axis.
- * -> w = (-v.x, v.y, -v.z)
+ * - `w = (-v.x, v.y, -v.z)`
*
* Solving this, we get (x, y and z being the components of v):
+ * <pre>
* ┌ (x^2 * y + z^2) / (x^2 + z^2), x, x * z * (y - 1) / (x^2 + z^2) ┐
* M = │ x * (y^2 - 1) / (x^2 + z^2), y, z * (y^2 - 1) / (x^2 + z^2) │
* └ x * z * (y - 1) / (x^2 + z^2), z, (x^2 + z^2 * y) / (x^2 + z^2) ┘
+ * </pre>
+ *
+ * This is stable as long as v (the bone) is not too much aligned with +/-Y
+ * (i.e. x and z components are not too close to 0).
*
- * This is stable as long as v (the bone) is not too much aligned with +/-Y (i.e. x and z components
- * are not too close to 0).
+ * Since v is normalized, we have `x^2 + y^2 + z^2 = 1`,
+ * hence `x^2 + z^2 = 1 - y^2 = (1 - y)(1 + y)`.
*
- * Since v is normalized, we have x^2 + y^2 + z^2 = 1, hence x^2 + z^2 = 1 - y^2 = (1 - y)(1 + y).
* This allows to simplifies M like this:
+ * <pre>
* ┌ 1 - x^2 / (1 + y), x, -x * z / (1 + y) ┐
* M = │ -x, y, -z │
* └ -x * z / (1 + y), z, 1 - z^2 / (1 + y) ┘
+ * </pre>
*
- * Written this way, we see the case v = +Y is no more a singularity. The only one remaining is the bone being
- * aligned with -Y.
+ * Written this way, we see the case v = +Y is no more a singularity.
+ * The only one
+ * remaining is the bone being aligned with -Y.
*
- * Let's handle the asymptotic behavior when bone vector is reaching the limit of y = -1. Each of the four corner
- * elements can vary from -1 to 1, depending on the axis a chosen for doing the rotation. And the "rotation" here
- * is in fact established by mirroring XZ plane by that given axis, then inversing the Y-axis.
- * For sufficiently small x and z, and with y approaching -1, all elements but the four corner ones of M
- * will degenerate. So let's now focus on these corner elements.
+ * Let's handle
+ * the asymptotic behavior when bone vector is reaching the limit of y = -1.
+ * Each of the four corner elements can vary from -1 to 1,
+ * depending on the axis a chosen for doing the rotation.
+ * And the "rotation" here is in fact established by mirroring XZ plane by that given axis,
+ * then inversing the Y-axis.
+ * For sufficiently small x and z, and with y approaching -1,
+ * all elements but the four corner ones of M will degenerate.
+ * So let's now focus on these corner elements.
*
- * We rewrite M so that it only contains its four corner elements, and combine the 1 / (1 + y) factor:
+ * We rewrite M so that it only contains its four corner elements,
+ * and combine the `1 / (1 + y)` factor:
+ * <pre>
* ┌ 1 + y - x^2, -x * z ┐
* M* = 1 / (1 + y) * │ │
* └ -x * z, 1 + y - z^2 ┘
+ * </pre>
+ *
+ * When y is close to -1, computing 1 / (1 + y) will cause severe numerical instability,
+ * so we ignore it and normalize M instead.
+ * We know `y^2 = 1 - (x^2 + z^2)`, and `y < 0`, hence `y = -sqrt(1 - (x^2 + z^2))`.
*
- * When y is close to -1, computing 1 / (1 + y) will cause severe numerical instability, so we ignore it and
- * normalize M instead. We know y^2 = 1 - (x^2 + z^2), and y < 0, hence y = -sqrt(1 - (x^2 + z^2)).
* Since x and z are both close to 0, we apply the binomial expansion to the first order:
- * y = -sqrt(1 - (x^2 + z^2)) = -1 + (x^2 + z^2) / 2. Which gives:
+ * `y = -sqrt(1 - (x^2 + z^2)) = -1 + (x^2 + z^2) / 2`. Which gives:
+ * <pre>
* ┌ z^2 - x^2, -2 * x * z ┐
* M* = 1 / (x^2 + z^2) * │ │
* └ -2 * x * z, x^2 - z^2 ┘
+ * </pre>
*/
void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat[3][3])
{
@@ -2138,8 +2280,9 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
bConstraint *con;
int error = 0;
- if (frompose == NULL)
+ if (frompose == NULL) {
return;
+ }
/* in some cases when rigs change, we cant synchronize
* to avoid crashing check for possible errors here */
@@ -2155,8 +2298,9 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
}
}
- if (error)
+ if (error) {
return;
+ }
/* clear all transformation values from library */
BKE_pose_rest(frompose);
@@ -2205,13 +2349,14 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
}
}
- /* constraints - proxy constraints are flushed... local ones are added after
- * 1. extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints
- * 2. copy proxy-pchan's constraints on-to new
- * 3. add extracted local constraints back on top
+ /* Constraints - proxy constraints are flushed... local ones are added after
+ * 1: extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints.
+ * 2: copy proxy-pchan's constraints on-to new.
+ * 3: add extracted local constraints back on top.
*
- * Note for BKE_constraints_copy: when copying constraints, disable 'do_extern' otherwise
- * we get the libs direct linked in this blend.
+ * Note for BKE_constraints_copy:
+ * When copying constraints, disable 'do_extern' otherwise
+ * we get the libs direct linked in this blend.
*/
BKE_constraints_proxylocal_extract(&proxylocal_constraints, &pchan->constraints);
BKE_constraints_copy(&pchanw.constraints, &pchanp->constraints, false);
@@ -2227,12 +2372,14 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) {
- if (ct->tar == from)
+ if (ct->tar == from) {
ct->tar = ob;
+ }
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
}
@@ -2251,8 +2398,9 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
if (pchan->custom) {
id_us_plus(&pchan->custom->id);
}
- if (pchanp->custom_tx)
+ if (pchanp->custom_tx) {
pchan->custom_tx = BKE_pose_channel_find_name(pose, pchanp->custom_tx->name);
+ }
/* ID-Property Syncing */
{
@@ -2288,15 +2436,17 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int
for (bone = bone->childbase.first; bone; bone = bone->next) {
counter = rebuild_pose_bone(pose, bone, pchan, counter);
/* for quick detecting of next bone in chain, only b-bone uses it now */
- if (bone->flag & BONE_CONNECTED)
+ if (bone->flag & BONE_CONNECTED) {
pchan->child = BKE_pose_channel_find_name(pose, bone->name);
+ }
}
return counter;
}
/**
- * Clear pointers of object's pose (needed in remap case, since we cannot always wait for a complete pose rebuild).
+ * Clear pointers of object's pose
+ * (needed in remap case, since we cannot always wait for a complete pose rebuild).
*/
void BKE_pose_clear_pointers(bPose *pose)
{
@@ -2382,7 +2532,8 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
/* synchronize protected layers with proxy */
/* HACK! To preserve 2.7x behavior that you always can pose even locked bones,
* do not do any restoration if this is a COW temp copy! */
- /* Switched back to just NO_MAIN tag, for some reasons (c) using COW tag was working this morning, but not anymore... */
+ /* Switched back to just NO_MAIN tag, for some reasons (c)
+ * using COW tag was working this morning, but not anymore... */
if (ob->proxy != NULL && (ob->id.tag & LIB_TAG_NO_MAIN) == 0) {
BKE_object_copy_proxy_drivers(ob, ob->proxy);
pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected);
@@ -2393,7 +2544,8 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
pose->flag &= ~POSE_RECALC;
pose->flag |= POSE_WAS_REBUILT;
- /* Rebuilding poses forces us to also rebuild the dependency graph, since there is one node per pose/bone... */
+ /* Rebuilding poses forces us to also rebuild the dependency graph,
+ * since there is one node per pose/bone. */
if (bmain != NULL) {
DEG_relations_tag_update(bmain);
}
@@ -2402,7 +2554,7 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
/* ********************** THE POSE SOLVER ******************* */
/* loc/rot/size to given mat4 */
-void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4])
+void BKE_pchan_to_mat4(const bPoseChannel *pchan, float chan_mat[4][4])
{
float smat[3][3];
float rmat[3][3];
@@ -2411,26 +2563,8 @@ void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4])
/* get scaling matrix */
size_to_mat3(smat, pchan->size);
- /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
- if (pchan->rotmode > 0) {
- /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
- eulO_to_mat3(rmat, pchan->eul, pchan->rotmode);
- }
- else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
- /* axis-angle - not really that great for 3D-changing orientations */
- axis_angle_to_mat3(rmat, pchan->rotAxis, pchan->rotAngle);
- }
- else {
- /* quats are normalized before use to eliminate scaling issues */
- float quat[4];
-
- /* NOTE: we now don't normalize the stored values anymore, since this was kindof evil in some cases
- * but if this proves to be too problematic, switch back to the old system of operating directly on
- * the stored copy
- */
- normalize_qt_qt(quat, pchan->quat);
- quat_to_mat3(rmat, quat);
- }
+ /* get rotation matrix */
+ BKE_pchan_rot_to_mat3(pchan, rmat);
/* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */
mul_m3_m3m3(tmat, rmat, smat);
@@ -2475,10 +2609,12 @@ void BKE_pose_where_is_bone(struct Depsgraph *depsgraph,
bool do_extra)
{
/* This gives a chan_mat with actions (ipos) results. */
- if (do_extra)
+ if (do_extra) {
BKE_pchan_calc_mat(pchan);
- else
+ }
+ else {
unit_m4(pchan->chan_mat);
+ }
/* Construct the posemat based on PoseChannels, that we do before applying constraints. */
/* pose_mat(b) = pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b) */
@@ -2487,8 +2623,9 @@ void BKE_pose_where_is_bone(struct Depsgraph *depsgraph,
/* Only rootbones get the cyclic offset (unless user doesn't want that). */
/* XXX That could be a problem for snapping and other "reverse transform" features... */
if (!pchan->parent) {
- if ((pchan->bone->flag & BONE_NO_CYCLICOFFSET) == 0)
+ if ((pchan->bone->flag & BONE_NO_CYCLICOFFSET) == 0) {
add_v3_v3(pchan->pose_mat[3], ob->pose->cyclic_offset);
+ }
}
if (do_extra) {
@@ -2537,14 +2674,17 @@ void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
float imat[4][4];
float ctime;
- if (ob->type != OB_ARMATURE)
+ if (ob->type != OB_ARMATURE) {
return;
+ }
arm = ob->data;
- if (ELEM(NULL, arm, scene))
+ if (ELEM(NULL, arm, scene)) {
return;
+ }
if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) {
- /* WARNING! passing NULL bmain here means we won't tag depsgraph's as dirty - hopefully this is OK. */
+ /* WARNING! passing NULL bmain here means we won't tag depsgraph's as dirty -
+ * hopefully this is OK. */
BKE_pose_rebuild(NULL, ob, arm, true);
}
@@ -2611,7 +2751,8 @@ static int minmax_armature(Object *ob, float r_min[3], float r_max[3])
{
bPoseChannel *pchan;
- /* For now, we assume BKE_pose_where_is has already been called (hence we have valid data in pachan). */
+ /* For now, we assume BKE_pose_where_is has already been called
+ * (hence we have valid data in pachan). */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
minmax_v3v3_v3(r_min, r_max, pchan->pose_head);
minmax_v3v3_v3(r_min, r_max, pchan->pose_tail);
@@ -2726,70 +2867,3 @@ bPoseChannel *BKE_armature_splineik_solver_find_root(bPoseChannel *pchan,
}
return rootchan;
}
-
-/* ****************************** BBone cache ****************************** */
-
-ObjectBBoneDeform *BKE_armature_cached_bbone_deformation_get(Object *object)
-{
- return object->runtime.cached_bbone_deformation;
-}
-
-void BKE_armature_cached_bbone_deformation_free_data(Object *object)
-{
- ObjectBBoneDeform *bbone_deform = BKE_armature_cached_bbone_deformation_get(object);
- if (bbone_deform == NULL) {
- return;
- }
- /* Free arrays. */
- MEM_SAFE_FREE(bbone_deform->pdef_info_array);
- MEM_SAFE_FREE(bbone_deform->dualquats);
- /* Tag that we've got no data, so we are safe for sequential calls to
- * data free. */
- bbone_deform->num_pchan = 0;
-}
-
-void BKE_armature_cached_bbone_deformation_free(Object *object)
-{
- ObjectBBoneDeform *bbone_deform = BKE_armature_cached_bbone_deformation_get(object);
- if (bbone_deform == NULL) {
- return;
- }
- BKE_armature_cached_bbone_deformation_free_data(object);
- MEM_freeN(bbone_deform);
- object->runtime.cached_bbone_deformation = NULL;
-}
-
-void BKE_armature_cached_bbone_deformation_update(Object *object)
-{
- BLI_assert(object->type == OB_ARMATURE);
- BLI_assert(object->pose != NULL);
- bPose *pose = object->pose;
- const int totchan = BLI_listbase_count(&pose->chanbase);
- const bool use_quaternion = true;
- /* Make sure cache exists. */
- ObjectBBoneDeform *bbone_deform = BKE_armature_cached_bbone_deformation_get(object);
- if (bbone_deform == NULL) {
- bbone_deform = MEM_callocN(sizeof(*bbone_deform), "bbone deform cache");
- object->runtime.cached_bbone_deformation = bbone_deform;
- }
- /* Make sure arrays are allocateds at the proper size. */
- BKE_armature_cached_bbone_deformation_free_data(object);
- DualQuat *dualquats = NULL;
- if (use_quaternion) {
- dualquats = MEM_calloc_arrayN(sizeof(DualQuat), totchan, "dualquats");
- }
- bPoseChanDeform *pdef_info_array = MEM_calloc_arrayN(
- sizeof(bPoseChanDeform), totchan, "bPoseChanDeform");
- /* Calculate deofrmation matricies. */
- ArmatureBBoneDefmatsData data = {
- .pdef_info_array = pdef_info_array,
- .dualquats = dualquats,
- .use_quaternion = use_quaternion,
- };
- BLI_task_parallel_listbase(&pose->chanbase, &data, armature_bbone_defmats_cb, totchan > 1024);
- /* Store pointers. */
- bbone_deform->dualquats = dualquats;
- atomic_cas_ptr(
- (void **)&bbone_deform->pdef_info_array, bbone_deform->pdef_info_array, pdef_info_array);
- bbone_deform->num_pchan = totchan;
-}
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 6d51c7f5108..c71c2dc86cf 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -88,18 +88,21 @@ static void splineik_init_tree_from_pchan(Scene *UNUSED(scene),
ikData = con->data;
/* target can only be curve */
- if ((ikData->tar == NULL) || (ikData->tar->type != OB_CURVE))
+ if ((ikData->tar == NULL) || (ikData->tar->type != OB_CURVE)) {
continue;
+ }
/* skip if disabled */
- if ((con->enforce == 0.0f) || (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)))
+ if ((con->enforce == 0.0f) || (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))) {
continue;
+ }
/* otherwise, constraint is ok... */
break;
}
}
- if (con == NULL)
+ if (con == NULL) {
return;
+ }
/* find the root bone and the chain of bones from the root to the tip
* NOTE: this assumes that the bones are connected, but that may not be true... */
@@ -113,10 +116,12 @@ static void splineik_init_tree_from_pchan(Scene *UNUSED(scene),
totLength += boneLengths[segcount];
}
- if (segcount == 0)
+ if (segcount == 0) {
return;
- else
+ }
+ else {
pchanRoot = pchanChain[segcount - 1];
+ }
/* perform binding step if required */
if ((ikData->flag & CONSTRAINT_SPLINEIK_BOUND) == 0) {
@@ -124,8 +129,9 @@ static void splineik_init_tree_from_pchan(Scene *UNUSED(scene),
int i;
/* setup new empty array for the points list */
- if (ikData->points)
+ if (ikData->points) {
MEM_freeN(ikData->points);
+ }
ikData->numpoints = ikData->chainlen + 1;
ikData->points = MEM_mallocN(sizeof(float) * ikData->numpoints, "Spline IK Binding");
@@ -159,7 +165,8 @@ static void splineik_init_tree_from_pchan(Scene *UNUSED(scene),
CLAMP_MIN(ikData->points[segcount], 0.0f);
/* make a new Spline-IK chain, and store it in the IK chains */
- /* TODO: we should check if there is already an IK chain on this, since that would take precedence... */
+ /* TODO: we should check if there is already an IK chain on this,
+ * since that would take precedence... */
{
/* make new tree */
tSplineIK_Tree *tree = MEM_callocN(sizeof(tSplineIK_Tree), "SplineIK Tree");
@@ -193,10 +200,12 @@ static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
{
bPoseChannel *pchan;
- /* find the tips of Spline IK chains, which are simply the bones which have been tagged as such */
+ /* find the tips of Spline IK chains,
+ * which are simply the bones which have been tagged as such */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->constflag & PCHAN_HAS_SPLINEIK)
+ if (pchan->constflag & PCHAN_HAS_SPLINEIK) {
splineik_init_tree_from_pchan(scene, ob, pchan);
+ }
}
}
@@ -293,8 +302,9 @@ static void splineik_evaluate_bone(
/* apply curve's object-mode transforms to the position
* unless the option to allow curve to be positioned elsewhere is activated (i.e. no root)
*/
- if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) == 0)
+ if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) == 0) {
mul_m4_v3(ikData->tar->obmat, vec);
+ }
/* convert the position to pose-space, then store it */
mul_m4_v3(ob->imat, vec);
@@ -309,8 +319,9 @@ static void splineik_evaluate_bone(
/* apply curve's object-mode transforms to the position
* unless the option to allow curve to be positioned elsewhere is activated (i.e. no root)
*/
- if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) == 0)
+ if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) == 0) {
mul_m4_v3(ikData->tar->obmat, vec);
+ }
/* store the position, and convert it to pose space */
mul_m4_v3(ob->imat, vec);
@@ -321,9 +332,9 @@ static void splineik_evaluate_bone(
}
}
- /* step 2: determine the implied transform from these endpoints
- * - splineVec: the vector direction that the spline applies on the bone
- * - scaleFac: the factor that the bone length is scaled by to get the desired amount
+ /* Step 2: determine the implied transform from these endpoints.
+ * - splineVec: the vector direction that the spline applies on the bone.
+ * - scaleFac: the factor that the bone length is scaled by to get the desired amount.
*/
sub_v3_v3v3(splineVec, poseTail, poseHead);
scaleFac = len_v3(splineVec) / pchan->bone->length;
@@ -331,8 +342,10 @@ static void splineik_evaluate_bone(
/* Adjust the scale factor towards the neutral state when rolling off the curve end. */
scaleFac = interpf(scaleFac, baseScale, tailBlendFac);
- /* step 3: compute the shortest rotation needed to map from the bone rotation to the current axis
- * - this uses the same method as is used for the Damped Track Constraint (see the code there for details)
+ /* Step 3: compute the shortest rotation needed
+ * to map from the bone rotation to the current axis.
+ * - this uses the same method as is used for the Damped Track Constraint
+ * (see the code there for details).
*/
{
float dmat[3][3], rmat[3][3];
@@ -344,7 +357,8 @@ static void splineik_evaluate_bone(
mul_m3_m4m4(basePoseMat, state->locrot_offset, pchan->pose_mat);
normalize_m3_m3(rmat, basePoseMat);
- /* also, normalize the orientation imposed by the bone, now that we've extracted the scale factor */
+ /* Also, normalize the orientation imposed by the bone,
+ * now that we've extracted the scale factor. */
normalize_v3(splineVec);
/* calculate smallest axis-angle rotation necessary for getting from the
@@ -366,12 +380,12 @@ static void splineik_evaluate_bone(
*/
axis_angle_to_mat3(dmat, raxis, rangle);
- /* combine these rotations so that the y-axis of the bone is now aligned as the spline dictates,
- * while still maintaining roll control from the existing bone animation
- */
+ /* Combine these rotations so that the y-axis of the bone is now aligned as the
+ * spline dictates, while still maintaining roll control from the existing bone animation. */
mul_m3_m3m3(poseMat, dmat, rmat);
- normalize_m3(
- poseMat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */
+
+ /* attempt to reduce shearing, though I doubt this'll really help too much now... */
+ normalize_m3(poseMat);
mul_m3_m3m3(basePoseMat, dmat, basePoseMat);
@@ -412,8 +426,9 @@ static void splineik_evaluate_bone(
/* NOTE: these should be fine for now, but should get sanitised in future */
CLAMP(scale, 0.0001f, 100000.0f);
}
- else
+ else {
scale = 1.0f;
+ }
/* apply the scaling */
mul_v3_fl(poseMat[0], scale);
@@ -529,7 +544,8 @@ static void splineik_execute_tree(
while ((tree = pchan_root->siktree.first) != NULL) {
int i;
- /* Firstly, calculate the bone matrix the standard way, since this is needed for roll control. */
+ /* Firstly, calculate the bone matrix the standard way,
+ * since this is needed for roll control. */
for (i = tree->chainlen - 1; i >= 0; i--) {
BKE_pose_where_is_bone(depsgraph, scene, ob, tree->chain[i], ctime, 1);
}
@@ -539,8 +555,8 @@ static void splineik_execute_tree(
if (splineik_evaluate_init(tree, &state)) {
/* Walk over each bone in the chain, calculating the effects of spline IK
- * - the chain is traversed in the opposite order to storage order (i.e. parent to children)
- * so that dependencies are correct
+ * - the chain is traversed in the opposite order to storage order (i.e. parent to children)
+ * so that dependencies are correct
*/
for (i = tree->chainlen - 1; i >= 0; i--) {
bPoseChannel *pchan = tree->chain[i];
@@ -549,8 +565,9 @@ static void splineik_execute_tree(
}
/* free the tree info specific to SplineIK trees now */
- if (tree->chain)
+ if (tree->chain) {
MEM_freeN(tree->chain);
+ }
/* free this tree */
BLI_freelinkN(&pchan_root->siktree, tree);
@@ -613,13 +630,11 @@ void BKE_pose_eval_init(struct Depsgraph *depsgraph, Scene *UNUSED(scene), Objec
/* Free B-Bone shape data cache if it's not a B-Bone. */
if (pchan->bone == NULL || pchan->bone->segments <= 1) {
- BKE_pose_channel_free_bbone_cache(pchan);
+ BKE_pose_channel_free_bbone_cache(&pchan->runtime);
}
}
BLI_assert(pose->chan_array != NULL || BLI_listbase_is_empty(&pose->chanbase));
-
- BKE_armature_cached_bbone_deformation_free_data(object);
}
void BKE_pose_eval_init_ik(struct Depsgraph *depsgraph, Scene *scene, Object *object)
@@ -714,6 +729,9 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph, struct Object *object, int
if (pchan->bone) {
invert_m4_m4(imat, pchan->bone->arm_mat);
mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
+ if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
+ mat4_to_dquat(&pchan->runtime.deform_dual_quat, pchan->bone->arm_mat, pchan->chan_mat);
+ }
}
if (DEG_is_active(depsgraph) && armature->edbo == NULL) {
bPoseChannel *pchan_orig = pchan->orig_pchan;
@@ -723,7 +741,7 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph, struct Object *object, int
copy_m4_m4(pchan_orig->constinv, pchan->constinv);
BKE_pose_where_is_bone_tail(pchan_orig);
if (pchan->bone == NULL || pchan->bone->segments <= 1) {
- BKE_pose_channel_free_bbone_cache(pchan_orig);
+ BKE_pose_channel_free_bbone_cache(&pchan_orig->runtime);
}
}
}
@@ -798,7 +816,6 @@ static void pose_eval_done_common(struct Depsgraph *depsgraph, Object *object)
bPose *pose = object->pose;
UNUSED_VARS_NDEBUG(pose);
BLI_assert(pose != NULL);
- BKE_armature_cached_bbone_deformation_update(object);
BKE_object_eval_boundbox(depsgraph, object);
}
static void pose_eval_cleanup_common(Object *object)
@@ -806,6 +823,7 @@ static void pose_eval_cleanup_common(Object *object)
bPose *pose = object->pose;
BLI_assert(pose != NULL);
BLI_assert(pose->chan_array != NULL || BLI_listbase_is_empty(&pose->chanbase));
+ UNUSED_VARS_NDEBUG(pose);
}
void BKE_pose_eval_done(struct Depsgraph *depsgraph, Object *object)
@@ -837,8 +855,6 @@ void BKE_pose_eval_proxy_init(struct Depsgraph *depsgraph, Object *object)
DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
BLI_assert(object->pose->chan_array != NULL || BLI_listbase_is_empty(&object->pose->chanbase));
-
- BKE_armature_cached_bbone_deformation_free_data(object);
}
void BKE_pose_eval_proxy_done(struct Depsgraph *depsgraph, Object *object)
@@ -869,13 +885,13 @@ void BKE_pose_eval_proxy_copy_bone(struct Depsgraph *depsgraph, Object *object,
* around for the time while proxies are evaluating.
*/
#if 0
- bPoseChannel *pchan_from = pose_pchan_get_indexed(
- object->proxy_from, pchan_index);
+ bPoseChannel *pchan_from = pose_pchan_get_indexed(object->proxy_from, pchan_index);
#else
bPoseChannel *pchan_from = BKE_pose_channel_find_name(object->proxy_from->pose, pchan->name);
#endif
BLI_assert(pchan != NULL);
BLI_assert(pchan_from != NULL);
BKE_pose_copyesult_pchan_result(pchan, pchan_from);
+ copy_dq_dq(&pchan->runtime.deform_dual_quat, &pchan_from->runtime.deform_dual_quat);
BKE_pchan_bbone_segments_cache_copy(pchan, pchan_from);
}
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index cf32abbb7b7..48b271cf277 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -75,7 +75,9 @@ void BKE_blender_free(void)
{
/* samples are in a global list..., also sets G_MAIN->sound->sample NULL */
- BKE_studiolight_free(); /* needs to run before main free as wm is still referenced for icons preview jobs */
+ /* Needs to run before main free as wm is still referenced for icons preview jobs. */
+ BKE_studiolight_free();
+
BKE_main_free(G_MAIN);
G_MAIN = NULL;
@@ -95,7 +97,6 @@ void BKE_blender_free(void)
BLI_callback_global_finalize();
- BKE_sequencer_cache_destruct();
IMB_moviecache_destruct();
free_nodesystem();
@@ -156,8 +157,9 @@ static void keymap_item_free(wmKeyMapItem *kmi)
IDP_FreeProperty(kmi->properties);
MEM_freeN(kmi->properties);
}
- if (kmi->ptr)
+ if (kmi->ptr) {
MEM_freeN(kmi->ptr);
+ }
}
void BKE_blender_userdef_data_swap(UserDef *userdef_a, UserDef *userdef_b)
diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c
index c801c1780c8..32c6f74dc2d 100644
--- a/source/blender/blenkernel/intern/blender_copybuffer.c
+++ b/source/blender/blenkernel/intern/blender_copybuffer.c
@@ -110,7 +110,8 @@ bool BKE_copybuffer_read(Main *bmain_dst,
}
/**
- * \return Number of IDs directly pasted from the buffer (does not includes indirectly pulled out ones).
+ * \return Number of IDs directly pasted from the buffer
+ * (does not includes indirectly pulled out ones).
*/
int BKE_copybuffer_paste(bContext *C,
const char *libname,
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 723c8bb48bf..d1a3045a829 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -152,7 +152,8 @@ static void setup_app_data(bContext *C,
/* no load screens? */
if (mode != LOAD_UI) {
/* Logic for 'track_undo_scene' is to keep using the scene which the active screen has,
- * as long as the scene associated with the undo operation is visible in one of the open windows.
+ * as long as the scene associated with the undo operation is visible
+ * in one of the open windows.
*
* - 'curscreen->scene' - scene the user is currently looking at.
* - 'bfd->curscene' - scene undo-step was created in.
@@ -278,8 +279,9 @@ static void setup_app_data(bContext *C,
wmWindow *win = CTX_wm_window(C);
/* in case we don't even have a local scene, add one */
- if (!bmain->scenes.first)
+ if (!bmain->scenes.first) {
BKE_scene_add(bmain, "Empty");
+ }
CTX_data_scene_set(C, bmain->scenes.first);
win->scene = CTX_data_scene(C);
@@ -304,8 +306,9 @@ static void setup_app_data(bContext *C,
/* FIXME: this version patching should really be part of the file-reading code,
* but we still get too many unrelated data-corruption crashes otherwise... */
- if (bmain->versionfile < 250)
+ if (bmain->versionfile < 250) {
do_versions_ipos_to_animato(bmain);
+ }
bmain->recovered = 0;
@@ -320,8 +323,9 @@ static void setup_app_data(bContext *C,
bmain->recovered = 1;
/* these are the same at times, should never copy to the same location */
- if (bmain->name != filepath)
+ if (bmain->name != filepath) {
BLI_strncpy(bmain->name, filepath, FILE_MAX);
+ }
}
/* baseflags, groups, make depsgraph, etc */
@@ -399,8 +403,9 @@ int BKE_blendfile_read(bContext *C,
setup_app_data(C, bfd, filepath, params->is_startup, reports);
}
}
- else
+ else {
BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);
+ }
return (bfd ? retval : BKE_BLENDFILE_READ_FAIL);
}
@@ -416,8 +421,9 @@ bool BKE_blendfile_read_from_memory(bContext *C,
bfd = BLO_read_from_memory(filebuf, filelength, params->skip_flags, reports);
if (bfd) {
- if (update_defaults)
+ if (update_defaults) {
BLO_update_defaults_startup_blend(bfd->main, NULL);
+ }
setup_app_data(C, bfd, "<memory2>", params->is_startup, reports);
}
else {
@@ -440,10 +446,12 @@ bool BKE_blendfile_read_from_memfile(bContext *C,
bmain, BKE_main_blendfile_path(bmain), memfile, params->skip_flags, reports);
if (bfd) {
/* remove the unused screens and wm */
- while (bfd->main->wm.first)
+ while (bfd->main->wm.first) {
BKE_id_free(bfd->main, bfd->main->wm.first);
- while (bfd->main->screens.first)
+ }
+ while (bfd->main->screens.first) {
BKE_id_free(bfd->main, bfd->main->screens.first);
+ }
setup_app_data(C, bfd, "<memory1>", params->is_startup, reports);
}
@@ -464,10 +472,8 @@ void BKE_blendfile_read_make_empty(bContext *C)
ListBase *lb;
ID *id;
- FOREACH_MAIN_LISTBASE_BEGIN(bmain, lb)
- {
- FOREACH_MAIN_LISTBASE_ID_BEGIN(lb, id)
- {
+ FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb) {
+ FOREACH_MAIN_LISTBASE_ID_BEGIN (lb, id) {
if (ELEM(GS(id->name), ID_SCE, ID_SCR, ID_WM, ID_WS)) {
break;
}
@@ -638,11 +644,13 @@ static void blendfile_write_partial_cb(void *UNUSED(handle), Main *UNUSED(bmain)
if (vid) {
ID *id = vid;
/* only tag for need-expand if not done, prevents eternal loops */
- if ((id->tag & LIB_TAG_DOIT) == 0)
+ if ((id->tag & LIB_TAG_DOIT) == 0) {
id->tag |= LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT;
+ }
- if (id->lib && (id->lib->id.tag & LIB_TAG_DOIT) == 0)
+ if (id->lib && (id->lib->id.tag & LIB_TAG_DOIT) == 0) {
id->lib->id.tag |= LIB_TAG_DOIT;
+ }
}
}
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index b31a283448c..becef327fab 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -99,7 +99,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
pd_point_from_particle(bbd->sim, pa, &pa->state, &epoint);
/* first find out goal/predator with highest priority */
- if (effectors)
+ if (effectors) {
for (cur = effectors->first; cur; cur = cur->next) {
Object *eob = cur->ob;
PartDeflect *pd = cur->pd;
@@ -108,11 +108,13 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
if (gabr->ob == eob) {
/* TODO: effectors with multiple points */
if (get_effector_data(cur, &efd, &epoint, 0)) {
- if (cur->pd && cur->pd->forcefield == PFIELD_BOID)
+ if (cur->pd && cur->pd->forcefield == PFIELD_BOID) {
priority = mul * pd->f_strength *
effector_falloff(cur, &efd, &epoint, bbd->part->effector_weights);
- else
+ }
+ else {
priority = 1.0;
+ }
eff = cur;
}
@@ -144,6 +146,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
}
}
}
+ }
/* if the object doesn't have effector data we have to fake it */
if (eff == NULL && gabr->ob) {
@@ -227,7 +230,7 @@ static int rule_avoid_collision(BoidRule *rule,
int n, neighbors = 0, nearest = 0;
int ret = 0;
- //check deflector objects first
+ // check deflector objects first
if (acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) {
ParticleCollision col;
BVHTreeRayHit hit;
@@ -246,8 +249,9 @@ static int rule_avoid_collision(BoidRule *rule,
/* find out closest deflector object */
for (coll = bbd->sim->colliders->first; coll; coll = coll->next) {
/* don't check with current ground object */
- if (coll->ob == bpa->ground)
+ if (coll->ob == bpa->ground) {
continue;
+ }
col.current = coll->ob;
col.md = coll->collmd;
@@ -288,7 +292,7 @@ static int rule_avoid_collision(BoidRule *rule,
}
}
- //check boids in own system
+ // check boids in own system
if (acbr->options & BRULE_ACOLL_WITH_BOIDS) {
neighbors = BLI_kdtree_3d_range_search_with_len_squared_cb(bbd->sim->psys->tree,
pa->prev_state.co,
@@ -297,7 +301,7 @@ static int rule_avoid_collision(BoidRule *rule,
len_v3(pa->prev_state.vel),
len_squared_v3v3_with_normal_bias,
pa->prev_state.ave);
- if (neighbors > 1)
+ if (neighbors > 1) {
for (n = 1; n < neighbors; n++) {
copy_v3_v3(co1, pa->prev_state.co);
copy_v3_v3(vel1, pa->prev_state.vel);
@@ -335,6 +339,7 @@ static int rule_avoid_collision(BoidRule *rule,
}
}
}
+ }
}
if (ptn) {
MEM_freeN(ptn);
@@ -355,7 +360,7 @@ static int rule_avoid_collision(BoidRule *rule,
len_squared_v3v3_with_normal_bias,
pa->prev_state.ave);
- if (neighbors > 0)
+ if (neighbors > 0) {
for (n = 0; n < neighbors; n++) {
copy_v3_v3(co1, pa->prev_state.co);
copy_v3_v3(vel1, pa->prev_state.vel);
@@ -393,6 +398,7 @@ static int rule_avoid_collision(BoidRule *rule,
}
}
}
+ }
if (ptn) {
MEM_freeN(ptn);
@@ -401,8 +407,9 @@ static int rule_avoid_collision(BoidRule *rule,
}
}
- if (ptn && nearest == 0)
+ if (ptn && nearest == 0) {
MEM_freeN(ptn);
+ }
return ret;
}
@@ -608,8 +615,9 @@ static int rule_follow_leader(BoidRule *rule,
}
}
- if (ret)
+ if (ret) {
return 1;
+ }
/* not blocking so try to follow leader */
if (flbr->options & BRULE_LEADER_IN_LINE) {
@@ -737,10 +745,12 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
enemy_pa = epars + ptn[n].index;
}
}
- if (pt->mode == PTARGET_MODE_ENEMY)
+ if (pt->mode == PTARGET_MODE_ENEMY) {
e_strength += epsys->part->boids->strength * health;
- else if (pt->mode == PTARGET_MODE_FRIEND)
+ }
+ else if (pt->mode == PTARGET_MODE_FRIEND) {
f_strength += epsys->part->boids->strength * health;
+ }
if (ptn) {
MEM_freeN(ptn);
@@ -810,11 +820,11 @@ static boid_rule_cb boid_rules[] = {
rule_follow_leader,
rule_average_speed,
rule_fight,
- //rule_help,
- //rule_protect,
- //rule_hide,
- //rule_follow_path,
- //rule_follow_wall,
+ // rule_help,
+ // rule_protect,
+ // rule_hide,
+ // rule_follow_path,
+ // rule_follow_wall,
};
static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *pa)
@@ -869,8 +879,9 @@ static Object *boid_find_ground(BoidBrainData *bbd,
BVHTreeRayHit hit;
float radius = 0.0f, t, ray_dir[3];
- if (!bbd->sim->colliders)
+ if (!bbd->sim->colliders) {
return NULL;
+ }
memset(&col, 0, sizeof(ParticleCollision));
@@ -951,14 +962,18 @@ static int boid_rule_applies(ParticleData *pa, BoidSettings *UNUSED(boids), Boid
{
BoidParticle *bpa = pa->boid;
- if (rule == NULL)
+ if (rule == NULL) {
return 0;
+ }
- if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND)
+ if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) &&
+ rule->flag & BOIDRULE_ON_LAND) {
return 1;
+ }
- if (bpa->data.mode == eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR)
+ if (bpa->data.mode == eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR) {
return 1;
+ }
return 0;
}
@@ -1014,21 +1029,26 @@ static float boid_goal_signed_dist(float *boid_co, float *goal_co, float *goal_n
static int apply_boid_rule(
BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness)
{
- if (rule == NULL)
+ if (rule == NULL) {
return 0;
+ }
- if (boid_rule_applies(pa, bbd->part->boids, rule) == 0)
+ if (boid_rule_applies(pa, bbd->part->boids, rule) == 0) {
return 0;
+ }
- if (boid_rules[rule->type](rule, bbd, val, pa) == 0)
+ if (boid_rules[rule->type](rule, bbd, val, pa) == 0) {
return 0;
+ }
if (fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co,
pa->prev_state.vel,
- fuzziness * len_v3(pa->prev_state.vel)) == 0)
+ fuzziness * len_v3(pa->prev_state.vel)) == 0) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa)
{
@@ -1036,18 +1056,20 @@ static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa)
BoidParticle *bpa = pa->boid;
for (; state; state = state->next) {
- if (state->id == bpa->data.state_id)
+ if (state->id == bpa->data.state_id) {
return state;
+ }
}
/* for some reason particle isn't at a valid state */
state = boids->states.first;
- if (state)
+ if (state) {
bpa->data.state_id = state->id;
+ }
return state;
}
-//static int boid_condition_is_true(BoidCondition *cond)
+// static int boid_condition_is_true(BoidCondition *cond)
//{
// /* TODO */
// return 0;
@@ -1063,7 +1085,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
BoidParticle *bpa = pa->boid;
ParticleSystem *psys = bbd->sim->psys;
int rand;
- //BoidCondition *cond;
+ // BoidCondition *cond;
if (bpa->data.health <= 0.0f) {
pa->alive = PARS_DYING;
@@ -1071,9 +1093,9 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
return;
}
- //planned for near future
- //cond = state->conditions.first;
- //for (; cond; cond=cond->next) {
+ // planned for near future
+ // cond = state->conditions.first;
+ // for (; cond; cond=cond->next) {
// if (boid_condition_is_true(cond)) {
// pa->boid->state_id = cond->state_id;
// state = get_boid_state(boids, pa);
@@ -1094,8 +1116,9 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
switch (state->ruleset_type) {
case eBoidRulesetType_Fuzzy: {
for (rule = state->rules.first; rule; rule = rule->next) {
- if (apply_boid_rule(bbd, rule, &val, pa, state->rule_fuzziness))
+ if (apply_boid_rule(bbd, rule, &val, pa, state->rule_fuzziness)) {
break; /* only first nonzero rule that comes through fuzzy rule is applied */
+ }
}
break;
}
@@ -1146,8 +1169,9 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
copy_v3_v3(cvel, bbd->wanted_co);
normalize_v2(cvel);
- if (dot_v2v2(cvel, dir) > 0.95f / mul)
+ if (dot_v2v2(cvel, dir) > 0.95f / mul) {
bpa->data.mode = eBoidMode_Liftoff;
+ }
}
else if (val.jump_speed > 0.0f) {
float jump_v[3];
@@ -1229,14 +1253,16 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* make sure there's something in new velocity, location & rotation */
copy_particle_key(&pa->state, &pa->prev_state, 0);
- if (bbd->part->flag & PART_SIZEMASS)
+ if (bbd->part->flag & PART_SIZEMASS) {
pa_mass *= pa->size;
+ }
/* if boids can't fly they fall to the ground */
if ((boids->options & BOID_ALLOW_FLIGHT) == 0 &&
ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) == 0 &&
- psys_uses_gravity(bbd->sim))
+ psys_uses_gravity(bbd->sim)) {
bpa->data.mode = eBoidMode_Falling;
+ }
if (bpa->data.mode == eBoidMode_Falling) {
/* Falling boids are only effected by gravity. */
@@ -1318,10 +1344,12 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* constrain speed with maximum acceleration */
old_speed = len_v3(pa->prev_state.vel);
- if (bbd->wanted_speed < old_speed)
+ if (bbd->wanted_speed < old_speed) {
new_speed = MAX2(bbd->wanted_speed, old_speed - val.max_acc);
- else
+ }
+ else {
new_speed = MIN2(bbd->wanted_speed, old_speed + val.max_acc);
+ }
/* combine direction and speed */
copy_v3_v3(new_vel, new_dir);
@@ -1392,7 +1420,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
madd_v3_v3fl(pa->state.vel, acc, dtime);
- //if (bpa->data.mode != eBoidMode_InAir)
+ // if (bpa->data.mode != eBoidMode_InAir)
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
/* change modes, constrain movement & keep track of down vector */
@@ -1467,29 +1495,31 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
bpa->data.mode = eBoidMode_OnLand;
}
/* if we're falling, can fly and want to go upwards lets fly */
- else if (boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f)
+ else if (boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) {
bpa->data.mode = eBoidMode_InAir;
+ }
}
- else
+ else {
bpa->data.mode = eBoidMode_InAir;
+ }
break;
}
case eBoidMode_Climbing: {
boid_climb(boids, pa, ground_co, ground_nor);
- //float nor[3];
- //copy_v3_v3(nor, ground_nor);
+ // float nor[3];
+ // copy_v3_v3(nor, ground_nor);
///* gather apparent gravity to r_ve */
- //madd_v3_v3fl(pa->r_ve, ground_nor, -1.0);
- //normalize_v3(pa->r_ve);
+ // madd_v3_v3fl(pa->r_ve, ground_nor, -1.0);
+ // normalize_v3(pa->r_ve);
///* raise boid it's size from surface */
- //mul_v3_fl(nor, pa->size * boids->height);
- //add_v3_v3v3(pa->state.co, ground_co, nor);
+ // mul_v3_fl(nor, pa->size * boids->height);
+ // add_v3_v3v3(pa->state.co, ground_co, nor);
///* remove normal component from velocity */
- //project_v3_v3v3(v, pa->state.vel, ground_nor);
- //sub_v3_v3v3(pa->state.vel, pa->state.vel, v);
+ // project_v3_v3v3(v, pa->state.vel, ground_nor);
+ // sub_v3_v3v3(pa->state.vel, pa->state.vel, v);
break;
}
case eBoidMode_OnLand: {
@@ -1502,8 +1532,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
boid_climb(boids, pa, ground_co, ground_nor);
}
/* ground is too far away so boid falls */
- else if (pa->state.co[2] - ground_co[2] > 1.1f * pa->size * boids->height)
+ else if (pa->state.co[2] - ground_co[2] > 1.1f * pa->size * boids->height) {
bpa->data.mode = eBoidMode_Falling;
+ }
else {
/* constrain to surface */
pa->state.co[2] = ground_co[2] + pa->size * boids->height;
@@ -1541,8 +1572,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
}
/* apply damping */
- if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing))
+ if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
mul_v3_fl(pa->state.vel, 1.0f - 0.2f * bbd->part->dampfac);
+ }
/* calculate rotation matrix based on forward & down vectors */
if (bpa->data.mode == eBoidMode_InAir) {
@@ -1570,8 +1602,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
BoidRule *boid_new_rule(int type)
{
BoidRule *rule = NULL;
- if (type <= 0)
+ if (type <= 0) {
return NULL;
+ }
switch (type) {
case eBoidRuleType_Goal:
@@ -1637,10 +1670,12 @@ BoidState *boid_new_state(BoidSettings *boids)
BoidState *state = MEM_callocN(sizeof(BoidState), "BoidState");
state->id = boids->last_state_id++;
- if (state->id)
+ if (state->id) {
BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id);
- else
+ }
+ else {
strcpy(state->name, "State");
+ }
state->rule_fuzziness = 0.5;
state->volume = 1.0f;
@@ -1705,8 +1740,9 @@ BoidState *boid_get_current_state(BoidSettings *boids)
BoidState *state = boids->states.first;
for (; state; state = state->next) {
- if (state->flag & BOIDSTATE_CURRENT)
+ if (state->flag & BOIDSTATE_CURRENT) {
break;
+ }
}
return state;
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index 25f886b815a..6f0c1891b05 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -233,21 +233,25 @@ static bool missing_files_find__recursive(char *filename_new,
dir = opendir(dirname);
- if (dir == NULL)
+ if (dir == NULL) {
return found;
+ }
- if (*r_filesize == -1)
+ if (*r_filesize == -1) {
*r_filesize = 0; /* dir opened fine */
+ }
while ((de = readdir(dir)) != NULL) {
- if (FILENAME_IS_CURRPAR(de->d_name))
+ if (FILENAME_IS_CURRPAR(de->d_name)) {
continue;
+ }
BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
- if (BLI_stat(path, &status) == -1)
+ if (BLI_stat(path, &status) == -1) {
continue; /* cant stat, don't bother with this file, could print debug info here */
+ }
if (S_ISREG(status.st_mode)) { /* is file */
if (BLI_path_ncmp(filename, de->d_name, FILE_MAX) == 0) { /* name matches */
@@ -321,8 +325,9 @@ static bool missing_files_find__visit_cb(void *userdata, char *path_dst, const c
BLI_strncpy(path_dst, filename_new, FILE_MAX);
/* keep path relative if the previous one was relative */
- if (was_relative)
+ if (was_relative) {
BLI_path_rel(path_dst, data->basedir);
+ }
return true;
}
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 56a6de62dab..e28f1fc566f 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -140,12 +140,16 @@ void BKE_brush_init(Brush *brush)
brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */
+ /* A kernel radius of 1 has almost no effect (T63233). */
+ brush->blur_kernel_radius = 2;
+
/* the default alpha falloff curve */
BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
}
/**
- * \note Resulting brush will have two users: one as a fake user, another is assumed to be used by the caller.
+ * \note Resulting brush will have two users: one as a fake user,
+ * another is assumed to be used by the caller.
*/
Brush *BKE_brush_add(Main *bmain, const char *name, const eObjectMode ob_mode)
{
@@ -212,8 +216,9 @@ typedef enum eGPCurveMappingPreset {
static void brush_gpencil_curvemap_reset(CurveMap *cuma, int tot, int preset)
{
- if (cuma->curve)
+ if (cuma->curve) {
MEM_freeN(cuma->curve);
+ }
cuma->totpoint = tot;
cuma->curve = MEM_callocN(cuma->totpoint * sizeof(CurveMapPoint), __func__);
@@ -572,15 +577,18 @@ struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mo
Brush *brush;
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->ob_mode & ob_mode)
+ if (brush->ob_mode & ob_mode) {
return brush;
+ }
}
return NULL;
}
/**
- * Only copy internal data of Brush ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Brush ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -869,8 +877,9 @@ void BKE_brush_curve_preset(Brush *b, eCurveMappingPreset preset)
{
CurveMap *cm = NULL;
- if (!b->curve)
+ if (!b->curve) {
b->curve = curvemapping_add(1, 0, 0, 1, 1);
+ }
cm = b->curve->cm;
cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
@@ -1156,10 +1165,12 @@ void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float c
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- if (ups->flag & UNIFIED_PAINT_COLOR)
+ if (ups->flag & UNIFIED_PAINT_COLOR) {
copy_v3_v3(ups->rgb, color);
- else
+ }
+ else {
copy_v3_v3(brush->rgb, color);
+ }
}
void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
@@ -1169,10 +1180,12 @@ void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
/* make sure range is sane */
CLAMP(size, 1, MAX_BRUSH_PIXEL_RADIUS);
- if (ups->flag & UNIFIED_PAINT_SIZE)
+ if (ups->flag & UNIFIED_PAINT_SIZE) {
ups->size = size;
- else
+ }
+ else {
brush->size = size;
+ }
}
int BKE_brush_size_get(const Scene *scene, const Brush *brush)
@@ -1228,10 +1241,12 @@ void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojec
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- if (ups->flag & UNIFIED_PAINT_SIZE)
+ if (ups->flag & UNIFIED_PAINT_SIZE) {
ups->unprojected_radius = unprojected_radius;
- else
+ }
+ else {
brush->unprojected_radius = unprojected_radius;
+ }
}
float BKE_brush_unprojected_radius_get(const Scene *scene, const Brush *brush)
@@ -1245,10 +1260,12 @@ void BKE_brush_alpha_set(Scene *scene, Brush *brush, float alpha)
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- if (ups->flag & UNIFIED_PAINT_ALPHA)
+ if (ups->flag & UNIFIED_PAINT_ALPHA) {
ups->alpha = alpha;
- else
+ }
+ else {
brush->alpha = alpha;
+ }
}
float BKE_brush_alpha_get(const Scene *scene, const Brush *brush)
@@ -1269,10 +1286,12 @@ void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value)
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- if (ups->flag & UNIFIED_PAINT_WEIGHT)
+ if (ups->flag & UNIFIED_PAINT_WEIGHT) {
ups->weight = value;
- else
+ }
+ else {
brush->weight = value;
+ }
}
/* scale unprojected radius to reflect a change in the brush's 2D size */
@@ -1282,8 +1301,9 @@ void BKE_brush_scale_unprojected_radius(float *unprojected_radius,
{
float scale = new_brush_size;
/* avoid division by zero */
- if (old_brush_size != 0)
+ if (old_brush_size != 0) {
scale /= (float)old_brush_size;
+ }
(*unprojected_radius) *= scale;
}
@@ -1294,8 +1314,9 @@ void BKE_brush_scale_size(int *r_brush_size,
{
float scale = new_unprojected_radius;
/* avoid division by zero */
- if (old_unprojected_radius != 0)
+ if (old_unprojected_radius != 0) {
scale /= new_unprojected_radius;
+ }
(*r_brush_size) = (int)((float)(*r_brush_size) * scale);
}
@@ -1342,10 +1363,12 @@ float BKE_brush_curve_strength(const Brush *br, float p, const float len)
{
float strength;
- if (p >= len)
+ if (p >= len) {
return 0;
- else
+ }
+ else {
p = p / len;
+ }
strength = curvemapping_evaluateF(br->curve, 0, p);
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 1c17408e286..8600d60c5c6 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -204,10 +204,12 @@ static void mesh_faces_spherecast(void *userdata,
do {
float dist;
- if (ray->radius == 0.0f)
+ if (ray->radius == 0.0f) {
dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
- else
+ }
+ else {
dist = bvhtree_sphereray_tri_intersection(ray, ray->radius, hit->dist, t0, t1, t2);
+ }
if (dist >= 0 && dist < hit->dist) {
hit->index = index;
@@ -239,10 +241,12 @@ static void mesh_looptri_spherecast(void *userdata,
};
float dist;
- if (ray->radius == 0.0f)
+ if (ray->radius == 0.0f) {
dist = bvhtree_ray_tri_intersection(ray, hit->dist, UNPACK3(vtri_co));
- else
+ }
+ else {
dist = bvhtree_sphereray_tri_intersection(ray, ray->radius, hit->dist, UNPACK3(vtri_co));
+ }
if (dist >= 0 && dist < hit->dist) {
hit->index = index;
@@ -269,10 +273,12 @@ static void editmesh_looptri_spherecast(void *userdata,
{
float dist;
- if (ray->radius == 0.0f)
+ if (ray->radius == 0.0f) {
dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
- else
+ }
+ else {
dist = bvhtree_sphereray_tri_intersection(ray, ray->radius, hit->dist, t0, t1, t2);
+ }
if (dist >= 0 && dist < hit->dist) {
hit->index = index;
@@ -562,7 +568,8 @@ BVHTree *bvhtree_from_editmesh_verts(BVHTreeFromEditMesh *data,
* Builds a bvh tree where nodes are the given vertices (note: does not copy given mverts!).
* \param vert_allocated: if true, vert freeing will be done when freeing data.
* \param verts_mask: if not null, true elements give which vert to add to BVH tree.
- * \param verts_num_active: if >= 0, number of active verts to add to BVH tree (else will be computed from mask).
+ * \param verts_num_active: if >= 0, number of active verts to add to BVH tree
+ * (else will be computed from mask).
*/
BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
const MVert *vert,
@@ -752,7 +759,8 @@ BVHTree *bvhtree_from_editmesh_edges(BVHTreeFromEditMesh *data,
* \param vert, vert_allocated: if true, elem freeing will be done when freeing data.
* \param edge, edge_allocated: if true, elem freeing will be done when freeing data.
* \param edges_mask: if not null, true elements give which vert to add to BVH tree.
- * \param edges_num_active: if >= 0, number of active edges to add to BVH tree (else will be computed from mask).
+ * \param edges_num_active: if >= 0, number of active edges to add to BVH tree
+ * (else will be computed from mask).
*/
BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
const MVert *vert,
@@ -816,8 +824,9 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(float epsilon,
copy_v3_v3(co[0], vert[face[i].v1].co);
copy_v3_v3(co[1], vert[face[i].v2].co);
copy_v3_v3(co[2], vert[face[i].v3].co);
- if (face[i].v4)
+ if (face[i].v4) {
copy_v3_v3(co[3], vert[face[i].v4].co);
+ }
BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
}
@@ -853,11 +862,13 @@ static void bvhtree_from_mesh_faces_setup_data(BVHTreeFromMesh *data,
}
/**
- * Builds a bvh tree where nodes are the given tessellated faces (note: does not copy given mfaces!).
+ * Builds a bvh tree where nodes are the given tessellated faces
+ * (note: does not copy given mfaces!).
* \param vert_allocated: if true, vert freeing will be done when freeing data.
* \param face_allocated: if true, face freeing will be done when freeing data.
* \param faces_mask: if not null, true elements give which faces to add to BVH tree.
- * \param faces_num_active: if >= 0, number of active faces to add to BVH tree (else will be computed from mask).
+ * \param faces_num_active: if >= 0, number of active faces to add to BVH tree
+ * (else will be computed from mask).
*/
BVHTree *bvhtree_from_mesh_faces_ex(BVHTreeFromMesh *data,
const MVert *vert,
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 4fe8cabde65..44e951a43da 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -21,18 +21,21 @@
* \ingroup bke
*/
+#include <string.h>
+
#include "DNA_anim_types.h"
#include "DNA_cachefile_types.h"
#include "DNA_constraint_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "BLI_utildefines.h"
#include "BLI_fileops.h"
+#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_threads.h"
-#include "BLI_utildefines.h"
#include "BKE_animsys.h"
#include "BKE_cachefile.h"
@@ -41,10 +44,13 @@
#include "BKE_modifier.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph_query.h"
+
#ifdef WITH_ALEMBIC
# include "ABC_alembic.h"
#endif
+/* TODO: make this per cache file to avoid global locks. */
static SpinLock spin;
void BKE_cachefiles_init(void)
@@ -57,6 +63,94 @@ void BKE_cachefiles_exit(void)
BLI_spin_end(&spin);
}
+void BKE_cachefile_reader_open(CacheFile *cache_file,
+ struct CacheReader **reader,
+ Object *object,
+ const char *object_path)
+{
+#ifdef WITH_ALEMBIC
+ BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
+
+ if (cache_file->handle == NULL) {
+ return;
+ }
+
+ /* Open Alembic cache reader. */
+ *reader = CacheReader_open_alembic_object(cache_file->handle, *reader, object, object_path);
+
+ /* Multiple modifiers and constraints can call this function concurrently. */
+ BLI_spin_lock(&spin);
+ if (*reader) {
+ /* Register in set so we can free it when the cache file changes. */
+ if (cache_file->handle_readers == NULL) {
+ cache_file->handle_readers = BLI_gset_ptr_new("CacheFile.handle_readers");
+ }
+ BLI_gset_reinsert(cache_file->handle_readers, reader, NULL);
+ }
+ else if (cache_file->handle_readers) {
+ /* Remove in case CacheReader_open_alembic_object free the existing reader. */
+ BLI_gset_remove(cache_file->handle_readers, reader, NULL);
+ }
+ BLI_spin_unlock(&spin);
+#else
+ UNUSED_VARS(cache_file, reader, object, object_path);
+#endif
+}
+
+void BKE_cachefile_reader_free(CacheFile *cache_file, struct CacheReader **reader)
+{
+#ifdef WITH_ALEMBIC
+ BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
+
+ if (*reader != NULL) {
+ CacheReader_free(*reader);
+ *reader = NULL;
+
+ /* Multiple modifiers and constraints can call this function concurrently. */
+ BLI_spin_lock(&spin);
+ if (cache_file->handle_readers) {
+ BLI_gset_remove(cache_file->handle_readers, reader, NULL);
+ }
+ BLI_spin_unlock(&spin);
+ }
+#else
+ UNUSED_VARS(cache_file, reader);
+#endif
+}
+
+static void cachefile_handle_free(CacheFile *cache_file)
+{
+#ifdef WITH_ALEMBIC
+ /* Free readers in all modifiers and constraints that use the handle, before
+ * we free the handle itself. */
+ BLI_spin_lock(&spin);
+ if (cache_file->handle_readers) {
+ GSetIterator gs_iter;
+ GSET_ITER (gs_iter, cache_file->handle_readers) {
+ struct CacheReader **reader = BLI_gsetIterator_getKey(&gs_iter);
+ if (*reader != NULL) {
+ CacheReader_free(*reader);
+ *reader = NULL;
+ }
+ }
+
+ BLI_gset_free(cache_file->handle_readers, NULL);
+ cache_file->handle_readers = NULL;
+ }
+ BLI_spin_unlock(&spin);
+
+ /* Free handle. */
+ if (cache_file->handle) {
+ ABC_free_handle(cache_file->handle);
+ cache_file->handle = NULL;
+ }
+
+ cache_file->handle_filepath[0] = '\0';
+#else
+ UNUSED_VARS(cache_file);
+#endif
+}
+
void *BKE_cachefile_add(Main *bmain, const char *name)
{
CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name, 0);
@@ -68,43 +162,31 @@ void *BKE_cachefile_add(Main *bmain, const char *name)
void BKE_cachefile_init(CacheFile *cache_file)
{
- cache_file->handle = NULL;
cache_file->filepath[0] = '\0';
cache_file->override_frame = false;
cache_file->frame = 0.0f;
cache_file->is_sequence = false;
cache_file->scale = 1.0f;
- cache_file->handle_mutex = BLI_mutex_alloc();
BLI_listbase_clear(&cache_file->object_paths);
+
+ cache_file->handle = NULL;
+ cache_file->handle_filepath[0] = '\0';
+ cache_file->handle_readers = NULL;
}
/** Free (or release) any data used by this cachefile (does not free the cachefile itself). */
void BKE_cachefile_free(CacheFile *cache_file)
{
BKE_animdata_free((ID *)cache_file, false);
-
- if (cache_file->id.tag & LIB_TAG_NO_MAIN) {
- /* CoW/no-main copies reuse the existing ArchiveReader and mutex */
- return;
- }
-
- if (cache_file->handle) {
-#ifdef WITH_ALEMBIC
- ABC_free_handle(cache_file->handle);
-#endif
- cache_file->handle = NULL;
- }
- if (cache_file->handle_mutex) {
- BLI_mutex_free(cache_file->handle_mutex);
- cache_file->handle_mutex = NULL;
- }
-
+ cachefile_handle_free(cache_file);
BLI_freelistN(&cache_file->object_paths);
}
/**
- * Only copy internal data of CacheFile ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of CacheFile ID from source to already
+ * allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -115,13 +197,8 @@ void BKE_cachefile_copy_data(Main *UNUSED(bmain),
const CacheFile *UNUSED(cache_file_src),
const int UNUSED(flag))
{
- if (cache_file_dst->id.tag & LIB_TAG_NO_MAIN) {
- /* CoW/no-main copies reuse the existing ArchiveReader and mutex */
- return;
- }
-
cache_file_dst->handle = NULL;
- cache_file_dst->handle_mutex = NULL;
+ cache_file_dst->handle_readers = NULL;
BLI_duplicatelist(&cache_file_dst->object_paths, &cache_file_dst->object_paths);
}
@@ -137,72 +214,51 @@ void BKE_cachefile_make_local(Main *bmain, CacheFile *cache_file, const bool lib
BKE_id_make_local_generic(bmain, &cache_file->id, true, lib_local);
}
-void BKE_cachefile_reload(const Main *bmain, CacheFile *cache_file)
+void BKE_cachefile_reload(Depsgraph *depsgraph, CacheFile *cache_file)
{
- char filepath[FILE_MAX];
-
- BLI_strncpy(filepath, cache_file->filepath, sizeof(filepath));
- BLI_path_abs(filepath, ID_BLEND_PATH(bmain, &cache_file->id));
-
-#ifdef WITH_ALEMBIC
- if (cache_file->handle) {
- ABC_free_handle(cache_file->handle);
+ /* To force reload, free the handle and tag depsgraph to load it again. */
+ CacheFile *cache_file_eval = (CacheFile *)DEG_get_evaluated_id(depsgraph, &cache_file->id);
+ if (cache_file_eval) {
+ cachefile_handle_free(cache_file_eval);
}
- cache_file->handle = ABC_create_handle(filepath, &cache_file->object_paths);
-#endif
+ DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE);
}
-void BKE_cachefile_ensure_handle(const Main *bmain, CacheFile *cache_file)
+void BKE_cachefile_eval(Main *bmain, Depsgraph *depsgraph, CacheFile *cache_file)
{
- BLI_spin_lock(&spin);
- if (cache_file->handle_mutex == NULL) {
- cache_file->handle_mutex = BLI_mutex_alloc();
- }
- BLI_spin_unlock(&spin);
-
- BLI_mutex_lock(cache_file->handle_mutex);
+ BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
- if (cache_file->handle == NULL) {
- /* Assigning to a CoW copy is a bad idea; assign to the original instead. */
- BLI_assert((cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0);
- BKE_cachefile_reload(bmain, cache_file);
+ /* Compute filepath. */
+ char filepath[FILE_MAX];
+ if (!BKE_cachefile_filepath_get(bmain, depsgraph, cache_file, filepath)) {
+ return;
}
- BLI_mutex_unlock(cache_file->handle_mutex);
-}
-
-void BKE_cachefile_update_frame(
- Main *bmain, struct Depsgraph *depsgraph, Scene *scene, const float ctime, const float fps)
-{
- CacheFile *cache_file;
- char filename[FILE_MAX];
-
- for (cache_file = bmain->cachefiles.first; cache_file; cache_file = cache_file->id.next) {
- /* TODO: dependency graph should be updated to do drivers on cachefile.
- * Execute drivers only, as animation has already been done. */
- BKE_animsys_evaluate_animdata(
- depsgraph, scene, &cache_file->id, cache_file->adt, ctime, ADT_RECALC_DRIVERS);
-
- if (!cache_file->is_sequence) {
- continue;
- }
+ /* Test if filepath change or if we can keep the existing handle. */
+ if (STREQ(cache_file->handle_filepath, filepath)) {
+ return;
+ }
- const float time = BKE_cachefile_time_offset(cache_file, ctime, fps);
+ cachefile_handle_free(cache_file);
+ BLI_freelistN(&cache_file->object_paths);
- if (BKE_cachefile_filepath_get(bmain, cache_file, time, filename)) {
- BKE_cachefile_clean(bmain, cache_file);
#ifdef WITH_ALEMBIC
- ABC_free_handle(cache_file->handle);
- cache_file->handle = ABC_create_handle(filename, NULL);
+ cache_file->handle = ABC_create_handle(filepath, &cache_file->object_paths);
+ BLI_strncpy(cache_file->handle_filepath, filepath, FILE_MAX);
#endif
- }
+
+ if (DEG_is_active(depsgraph)) {
+ /* Flush object paths back to original datablock for UI. */
+ CacheFile *cache_file_orig = (CacheFile *)DEG_get_original_id(&cache_file->id);
+ BLI_freelistN(&cache_file_orig->object_paths);
+ BLI_duplicatelist(&cache_file_orig->object_paths, &cache_file->object_paths);
}
}
bool BKE_cachefile_filepath_get(const Main *bmain,
+ const Depsgraph *depsgraph,
const CacheFile *cache_file,
- float frame,
char r_filepath[FILE_MAX])
{
BLI_strncpy(r_filepath, cache_file->filepath, FILE_MAX);
@@ -212,6 +268,11 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
int frame_len;
if (cache_file->is_sequence && BLI_path_frame_get(r_filepath, &fframe, &frame_len)) {
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+ const float ctime = BKE_scene_frame_get(scene);
+ const float fps = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base);
+ const float frame = BKE_cachefile_time_offset(cache_file, ctime, fps);
+
char ext[32];
BLI_path_frame_strip(r_filepath, ext);
BLI_path_frame(r_filepath, frame, frame_len);
@@ -224,47 +285,9 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
return true;
}
-float BKE_cachefile_time_offset(CacheFile *cache_file, const float time, const float fps)
+float BKE_cachefile_time_offset(const CacheFile *cache_file, const float time, const float fps)
{
const float time_offset = cache_file->frame_offset / fps;
const float frame = (cache_file->override_frame ? cache_file->frame : time);
return cache_file->is_sequence ? frame : frame / fps - time_offset;
}
-
-/* TODO(kevin): replace this with some depsgraph mechanism, or something similar. */
-void BKE_cachefile_clean(struct Main *bmain, CacheFile *cache_file)
-{
- for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache);
-
- if (md) {
- MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
-
- if (cache_file == mcmd->cache_file) {
-#ifdef WITH_ALEMBIC
- if (mcmd->reader != NULL) {
- CacheReader_free(mcmd->reader);
- }
-#endif
- mcmd->reader = NULL;
- }
- }
-
- for (bConstraint *con = ob->constraints.first; con; con = con->next) {
- if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) {
- continue;
- }
-
- bTransformCacheConstraint *data = con->data;
-
- if (cache_file == data->cache_file) {
-#ifdef WITH_ALEMBIC
- if (data->reader != NULL) {
- CacheReader_free(data->reader);
- }
-#endif
- data->reader = NULL;
- }
- }
- }
-}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index f4d09be2991..25399d342e1 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -88,8 +88,10 @@ void *BKE_camera_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Camera ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Camera ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -129,8 +131,9 @@ void BKE_camera_free(Camera *ca)
float BKE_camera_object_dof_distance(Object *ob)
{
Camera *cam = (Camera *)ob->data;
- if (ob->type != OB_CAMERA)
+ if (ob->type != OB_CAMERA) {
return 0.0f;
+ }
if (cam->dof_ob) {
float view_dir[3], dof_dir[3];
normalize_v3_v3(view_dir, ob->obmat[2]);
@@ -143,8 +146,9 @@ float BKE_camera_object_dof_distance(Object *ob)
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
{
/* sensor size used to fit to. for auto, sensor_x is both x and y. */
- if (sensor_fit == CAMERA_SENSOR_FIT_VERT)
+ if (sensor_fit == CAMERA_SENSOR_FIT_VERT) {
return sensor_y;
+ }
return sensor_x;
}
@@ -152,10 +156,12 @@ float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey)
{
if (sensor_fit == CAMERA_SENSOR_FIT_AUTO) {
- if (sizex >= sizey)
+ if (sizex >= sizey) {
return CAMERA_SENSOR_FIT_HOR;
- else
+ }
+ else {
return CAMERA_SENSOR_FIT_VERT;
+ }
}
return sensor_fit;
@@ -181,15 +187,17 @@ void BKE_camera_params_init(CameraParams *params)
void BKE_camera_params_from_object(CameraParams *params, const Object *ob)
{
- if (!ob)
+ if (!ob) {
return;
+ }
if (ob->type == OB_CAMERA) {
/* camera object */
Camera *cam = ob->data;
- if (cam->type == CAM_ORTHO)
+ if (cam->type == CAM_ORTHO) {
params->is_ortho = true;
+ }
params->lens = cam->lens;
params->ortho_scale = cam->ortho_scale;
@@ -207,8 +215,9 @@ void BKE_camera_params_from_object(CameraParams *params, const Object *ob)
/* light object */
Light *la = ob->data;
params->lens = 16.0f / tanf(la->spotsize * 0.5f);
- if (params->lens == 0.0f)
+ if (params->lens == 0.0f) {
params->lens = 35.0f;
+ }
}
else {
params->lens = 35.0f;
@@ -282,10 +291,12 @@ void BKE_camera_params_compute_viewplane(
/* determine sensor fit */
sensor_fit = BKE_camera_sensor_fit(params->sensor_fit, xasp * winx, yasp * winy);
- if (sensor_fit == CAMERA_SENSOR_FIT_HOR)
+ if (sensor_fit == CAMERA_SENSOR_FIT_HOR) {
viewfac = winx;
- else
+ }
+ else {
viewfac = params->ycor * winy;
+ }
pixsize /= viewfac;
@@ -328,7 +339,7 @@ void BKE_camera_params_compute_matrix(CameraParams *params)
rctf viewplane = params->viewplane;
/* compute projection matrix */
- if (params->is_ortho)
+ if (params->is_ortho) {
orthographic_m4(params->winmat,
viewplane.xmin,
viewplane.xmax,
@@ -336,7 +347,8 @@ void BKE_camera_params_compute_matrix(CameraParams *params)
viewplane.ymax,
params->clip_start,
params->clip_end);
- else
+ }
+ else {
perspective_m4(params->winmat,
viewplane.xmin,
viewplane.xmax,
@@ -344,6 +356,7 @@ void BKE_camera_params_compute_matrix(CameraParams *params)
viewplane.ymax,
params->clip_start,
params->clip_end);
+ }
}
/***************************** Camera View Frame *****************************/
@@ -723,8 +736,9 @@ static void camera_stereo3d_model_matrix(const Object *camera,
size_to_mat4(sizemat, size);
}
- if (pivot == CAM_S3D_PIVOT_CENTER)
+ if (pivot == CAM_S3D_PIVOT_CENTER) {
fac = 0.5f;
+ }
fac_signed = is_left ? fac : -fac;
@@ -865,13 +879,16 @@ bool BKE_camera_multiview_spherical_stereo(RenderData *rd, const Object *camera)
Camera *cam;
const bool is_multiview = (rd && rd->scemode & R_MULTIVIEW) != 0;
- if (!is_multiview)
+ if (!is_multiview) {
return false;
+ }
- if (camera->type != OB_CAMERA)
+ if (camera->type != OB_CAMERA) {
return false;
- else
+ }
+ else {
cam = camera->data;
+ }
if ((rd->views_format == SCE_VIEWS_FORMAT_STEREO_3D) && ELEM(cam->type, CAM_PANO, CAM_PERSP) &&
((cam->stereo.flag & CAM_S3D_SPHERICAL) != 0)) {
@@ -895,8 +912,9 @@ static Object *camera_multiview_advanced(Scene *scene, Object *camera, const cha
for (srv = scene->r.views.first; srv; srv = srv->next) {
const int len_suffix = strlen(srv->suffix);
- if ((len_suffix < len_suffix_max) || (len_name < len_suffix))
+ if ((len_suffix < len_suffix_max) || (len_name < len_suffix)) {
continue;
+ }
if (STREQ(camera_name + (len_name - len_suffix), srv->suffix)) {
BLI_snprintf(name, sizeof(name), "%.*s%s", (len_name - len_suffix), camera_name, suffix);
@@ -951,15 +969,17 @@ static float camera_stereo3d_shift_x(const Object *camera, const char *viewname)
convergence_mode = data->stereo.convergence_mode;
pivot = data->stereo.pivot;
- if (convergence_mode != CAM_S3D_OFFAXIS)
+ if (convergence_mode != CAM_S3D_OFFAXIS) {
return shift;
+ }
if (((pivot == CAM_S3D_PIVOT_LEFT) && is_left) || ((pivot == CAM_S3D_PIVOT_RIGHT) && !is_left)) {
return shift;
}
- if (pivot == CAM_S3D_PIVOT_CENTER)
+ if (pivot == CAM_S3D_PIVOT_CENTER) {
fac = 0.5f;
+ }
fac_signed = is_left ? fac : -fac;
shift += ((interocular_distance / data->sensor_x) * (data->lens / convergence_distance)) *
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index ada746d3fcc..667219e0eec 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -178,8 +178,9 @@ static void cdDM_getVertCos(DerivedMesh *dm, float (*r_cos)[3])
MVert *mv = CDDM_get_verts(dm);
int i;
- for (i = 0; i < dm->numVertData; i++, mv++)
+ for (i = 0; i < dm->numVertData; i++, mv++) {
copy_v3_v3(r_cos[i], mv->co);
+ }
}
static void cdDM_getVertNo(DerivedMesh *dm, int index, float r_no[3])
@@ -248,8 +249,9 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
return NULL;
}
- if (!ob->sculpt)
+ if (!ob->sculpt) {
return NULL;
+ }
if (ob->sculpt->pbvh) {
cddm->pbvh = ob->sculpt->pbvh;
@@ -294,6 +296,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
me->mvert,
me->totvert,
&me->vdata,
+ &me->ldata,
looptri,
looptris_num);
@@ -335,8 +338,9 @@ static void cdDM_foreachMappedVert(DerivedMesh *dm,
for (i = 0; i < dm->numVertData; i++, mv++) {
const short *no = (flag & DM_FOREACH_USE_NORMAL) ? mv->no : NULL;
const int orig = *index++;
- if (orig == ORIGINDEX_NONE)
+ if (orig == ORIGINDEX_NONE) {
continue;
+ }
func(userData, orig, mv->co, NULL, no);
}
}
@@ -361,12 +365,14 @@ static void cdDM_foreachMappedEdge(
for (i = 0; i < dm->numEdgeData; i++, med++) {
if (index) {
orig = *index++;
- if (orig == ORIGINDEX_NONE)
+ if (orig == ORIGINDEX_NONE) {
continue;
+ }
func(userData, orig, mv[med->v1].co, mv[med->v2].co);
}
- else
+ else {
func(userData, i, mv[med->v1].co, mv[med->v2].co);
+ }
}
}
@@ -379,7 +385,8 @@ static void cdDM_foreachMappedLoop(DerivedMesh *dm,
void *userData,
DMForeachFlag flag)
{
- /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
+ /* We can't use dm->getLoopDataLayout(dm) here,
+ * we want to always access dm->loopData, EditDerivedBMesh would
* return loop data from bmesh itself. */
const float(*lnors)[3] = (flag & DM_FOREACH_USE_NORMAL) ? DM_get_loop_data_layer(dm, CD_NORMAL) :
NULL;
@@ -423,8 +430,9 @@ static void cdDM_foreachMappedFaceCenter(
if (index) {
orig = *index++;
- if (orig == ORIGINDEX_NONE)
+ if (orig == ORIGINDEX_NONE) {
continue;
+ }
}
else {
orig = i;
@@ -489,10 +497,12 @@ void CDDM_recalc_looptri(DerivedMesh *dm)
static void cdDM_free_internal(CDDerivedMesh *cddm)
{
- if (cddm->pmap)
+ if (cddm->pmap) {
MEM_freeN(cddm->pmap);
- if (cddm->pmap_mem)
+ }
+ if (cddm->pmap_mem) {
MEM_freeN(cddm->pmap_mem);
+ }
}
static void cdDM_release(DerivedMesh *dm)
@@ -624,7 +634,8 @@ DerivedMesh *CDDM_from_mesh_ex(Mesh *mesh,
if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) {
dm->dirty |= DM_DIRTY_NORMALS;
}
- /* TODO DM_DIRTY_TESS_CDLAYERS ? Maybe not though, since we probably want to switch to looptris ? */
+ /* TODO DM_DIRTY_TESS_CDLAYERS ? Maybe not though,
+ * since we probably want to switch to looptris? */
CustomData_merge(&mesh->vdata, &dm->vertData, cddata_masks.vmask, alloctype, mesh->totvert);
CustomData_merge(&mesh->edata, &dm->edgeData, cddata_masks.emask, alloctype, mesh->totedge);
@@ -829,11 +840,13 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm,
mv->flag = BM_vert_flag_to_mflag(eve);
- if (cd_vert_bweight_offset != -1)
+ if (cd_vert_bweight_offset != -1) {
mv->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eve, cd_vert_bweight_offset);
+ }
- if (add_orig)
+ if (add_orig) {
*index++ = i;
+ }
CustomData_from_bmesh_block(&bm->vdata, &dm->vertData, eve->head.data, i);
}
@@ -858,14 +871,17 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm,
}
}
- if (cd_edge_crease_offset != -1)
+ if (cd_edge_crease_offset != -1) {
med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_crease_offset);
- if (cd_edge_bweight_offset != -1)
+ }
+ if (cd_edge_bweight_offset != -1) {
med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_bweight_offset);
+ }
CustomData_from_bmesh_block(&bm->edata, &dm->edgeData, eed->head.data, i);
- if (add_orig)
+ if (add_orig) {
*index++ = i;
+ }
}
bm->elem_index_dirty &= ~BM_EDGE;
@@ -923,8 +939,9 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm,
CustomData_from_bmesh_block(&bm->pdata, &dm->polyData, efa->head.data, i);
- if (add_orig)
+ if (add_orig) {
*index++ = i;
+ }
}
bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
@@ -1029,12 +1046,15 @@ DerivedMesh *CDDM_from_template_ex(DerivedMesh *source,
CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_CALLOC, NULL, numLoops);
CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_CALLOC, NULL, numPolys);
- if (!CustomData_get_layer(&dm->vertData, CD_ORIGINDEX))
+ if (!CustomData_get_layer(&dm->vertData, CD_ORIGINDEX)) {
CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, numVerts);
- if (!CustomData_get_layer(&dm->edgeData, CD_ORIGINDEX))
+ }
+ if (!CustomData_get_layer(&dm->edgeData, CD_ORIGINDEX)) {
CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
- if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))
+ }
+ if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) {
CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numTessFaces);
+ }
cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT);
cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE);
@@ -1061,8 +1081,9 @@ void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3])
vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
cddm->mvert = vert;
- for (i = 0; i < dm->numVertData; ++i, ++vert)
+ for (i = 0; i < dm->numVertData; ++i, ++vert) {
copy_v3_v3(vert->co, vertCoords[i]);
+ }
cddm->dm.dirty |= DM_DIRTY_NORMALS;
}
@@ -1077,8 +1098,9 @@ void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3])
vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
cddm->mvert = vert;
- for (i = 0; i < dm->numVertData; ++i, ++vert)
+ for (i = 0; i < dm->numVertData; ++i, ++vert) {
copy_v3_v3_short(vert->no, vertNormals[i]);
+ }
cddm->dm.dirty &= ~DM_DIRTY_NORMALS;
}
@@ -1149,9 +1171,10 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm)
void CDDM_calc_normals(DerivedMesh *dm)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
- float (*poly_nors)[3];
+ float(*poly_nors)[3];
- if (dm->numVertData == 0) return;
+ if (dm->numVertData == 0)
+ return;
/* we don't want to overwrite any referenced layers */
cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
@@ -1162,8 +1185,14 @@ void CDDM_calc_normals(DerivedMesh *dm)
poly_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, dm->numPolyData);
}
- BKE_mesh_calc_normals_poly(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm),
- dm->numLoopData, dm->numPolyData, poly_nors, false);
+ BKE_mesh_calc_normals_poly(cddm->mvert,
+ dm->numVertData,
+ CDDM_get_loops(dm),
+ CDDM_get_polys(dm),
+ dm->numLoopData,
+ dm->numPolyData,
+ poly_nors,
+ false);
cddm->dm.dirty &= ~DM_DIRTY_NORMALS;
}
@@ -1299,8 +1328,9 @@ void CDDM_calc_loop_normals_spacearr(DerivedMesh *dm,
void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts)
{
BLI_assert(numVerts >= 0);
- if (numVerts < dm->numVertData)
+ if (numVerts < dm->numVertData) {
CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData - numVerts);
+ }
dm->numVertData = numVerts;
}
@@ -1308,8 +1338,9 @@ void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts)
void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges)
{
BLI_assert(numEdges >= 0);
- if (numEdges < dm->numEdgeData)
+ if (numEdges < dm->numEdgeData) {
CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData - numEdges);
+ }
dm->numEdgeData = numEdges;
}
@@ -1317,8 +1348,9 @@ void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges)
void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces)
{
BLI_assert(numTessFaces >= 0);
- if (numTessFaces < dm->numTessFaceData)
+ if (numTessFaces < dm->numTessFaceData) {
CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData - numTessFaces);
+ }
dm->numTessFaceData = numTessFaces;
}
@@ -1326,8 +1358,9 @@ void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces)
void CDDM_lower_num_loops(DerivedMesh *dm, int numLoops)
{
BLI_assert(numLoops >= 0);
- if (numLoops < dm->numLoopData)
+ if (numLoops < dm->numLoopData) {
CustomData_free_elem(&dm->loopData, numLoops, dm->numLoopData - numLoops);
+ }
dm->numLoopData = numLoops;
}
@@ -1335,8 +1368,9 @@ void CDDM_lower_num_loops(DerivedMesh *dm, int numLoops)
void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys)
{
BLI_assert(numPolys >= 0);
- if (numPolys < dm->numPolyData)
+ if (numPolys < dm->numPolyData) {
CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData - numPolys);
+ }
dm->numPolyData = numPolys;
}
@@ -1399,8 +1433,9 @@ void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
- if (!CustomData_has_layer(&dm->vertData, CD_MVERT))
+ if (!CustomData_has_layer(&dm->vertData, CD_MVERT)) {
CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, mvert, dm->numVertData);
+ }
cddm->mvert = mvert;
}
@@ -1409,8 +1444,9 @@ void CDDM_set_medge(DerivedMesh *dm, MEdge *medge)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
- if (!CustomData_has_layer(&dm->edgeData, CD_MEDGE))
+ if (!CustomData_has_layer(&dm->edgeData, CD_MEDGE)) {
CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_ASSIGN, medge, dm->numEdgeData);
+ }
cddm->medge = medge;
}
@@ -1419,8 +1455,9 @@ void CDDM_set_mface(DerivedMesh *dm, MFace *mface)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
- if (!CustomData_has_layer(&dm->faceData, CD_MFACE))
+ if (!CustomData_has_layer(&dm->faceData, CD_MFACE)) {
CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, mface, dm->numTessFaceData);
+ }
cddm->mface = mface;
}
@@ -1429,8 +1466,9 @@ void CDDM_set_mloop(DerivedMesh *dm, MLoop *mloop)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
- if (!CustomData_has_layer(&dm->loopData, CD_MLOOP))
+ if (!CustomData_has_layer(&dm->loopData, CD_MLOOP)) {
CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_ASSIGN, mloop, dm->numLoopData);
+ }
cddm->mloop = mloop;
}
@@ -1439,8 +1477,9 @@ void CDDM_set_mpoly(DerivedMesh *dm, MPoly *mpoly)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
- if (!CustomData_has_layer(&dm->polyData, CD_MPOLY))
+ if (!CustomData_has_layer(&dm->polyData, CD_MPOLY)) {
CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_ASSIGN, mpoly, dm->numPolyData);
+ }
cddm->mpoly = mpoly;
}
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 9f25cd14499..fcc0e1856af 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -140,11 +140,13 @@ void cloth_init(ClothModifierData *clmd)
clmd->sim_parms->bending_model = CLOTH_BENDING_ANGULAR;
- if (!clmd->sim_parms->effector_weights)
+ if (!clmd->sim_parms->effector_weights) {
clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
+ }
- if (clmd->point_cache)
+ if (clmd->point_cache) {
clmd->point_cache->step = 1;
+ }
}
static BVHTree *bvhtree_build_from_cloth(ClothModifierData *clmd, float epsilon)
@@ -155,20 +157,23 @@ static BVHTree *bvhtree_build_from_cloth(ClothModifierData *clmd, float epsilon)
ClothVertex *verts;
const MVertTri *vt;
- if (!clmd)
+ if (!clmd) {
return NULL;
+ }
cloth = clmd->clothObject;
- if (!cloth)
+ if (!cloth) {
return NULL;
+ }
verts = cloth->verts;
vt = cloth->tri;
/* in the moment, return zero if no faces there */
- if (!cloth->tri_num)
+ if (!cloth->tri_num) {
return NULL;
+ }
/* create quadtree with k=26 */
bvhtree = BLI_bvhtree_new(cloth->tri_num, epsilon, 4, 26);
@@ -205,8 +210,9 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving, bool self)
bvhtree = cloth->bvhtree;
}
- if (!bvhtree)
+ if (!bvhtree) {
return;
+ }
vt = cloth->tri;
@@ -254,8 +260,9 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
// don't do anything as long as we're in editmode!
- if (pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT)
+ if (pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT) {
return;
+ }
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr);
}
@@ -317,8 +324,9 @@ static int do_step_cloth(
effectors = BKE_effectors_create(depsgraph, ob, NULL, clmd->sim_parms->effector_weights);
- if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH)
+ if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH) {
cloth_update_verts(ob, clmd, result);
+ }
/* Support for dynamic vertex groups, changing from frame to frame */
cloth_apply_vgroup(clmd, result);
@@ -387,8 +395,9 @@ void clothModifier_do(ClothModifierData *clmd,
}
/* initialize simulation data if it didn't exist already */
- if (!do_init_cloth(ob, clmd, mesh, framenr))
+ if (!do_init_cloth(ob, clmd, mesh, framenr)) {
return;
+ }
if (framenr == startframe) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
@@ -412,8 +421,9 @@ void clothModifier_do(ClothModifierData *clmd,
BKE_ptcache_validate(cache, framenr);
- if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
+ if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) {
BKE_ptcache_write(&pid, framenr);
+ }
clmd->clothObject->last_frame = framenr;
@@ -422,17 +432,19 @@ void clothModifier_do(ClothModifierData *clmd,
else if (cache_result == PTCACHE_READ_OLD) {
BKE_cloth_solver_set_positions(clmd);
}
- else if (/*ob->id.lib ||*/ (
- cache->flag &
- PTCACHE_BAKED)) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */
+ else if (
+ /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */
+ /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) {
/* if baked and nothing in cache, do nothing */
BKE_ptcache_invalidate(cache);
return;
}
/* if on second frame, write cache for first frame */
- if (cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0))
+ if (cache->simframe == startframe &&
+ (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
BKE_ptcache_write(&pid, startframe);
+ }
clmd->sim_parms->timescale *= framenr - cache->simframe;
@@ -442,8 +454,9 @@ void clothModifier_do(ClothModifierData *clmd,
if (!do_step_cloth(depsgraph, ob, clmd, mesh, framenr)) {
BKE_ptcache_invalidate(cache);
}
- else
+ else {
BKE_ptcache_write(&pid, framenr);
+ }
cloth_to_object(ob, clmd, vertexCos);
clmd->clothObject->last_frame = framenr;
@@ -454,8 +467,9 @@ void cloth_free_modifier(ClothModifierData *clmd)
{
Cloth *cloth = NULL;
- if (!clmd)
+ if (!clmd) {
return;
+ }
cloth = clmd->clothObject;
@@ -463,8 +477,9 @@ void cloth_free_modifier(ClothModifierData *clmd)
BPH_cloth_solver_free(clmd);
// Free the verts.
- if (cloth->verts != NULL)
+ if (cloth->verts != NULL) {
MEM_freeN(cloth->verts);
+ }
cloth->verts = NULL;
cloth->mvert_num = 0;
@@ -490,18 +505,22 @@ void cloth_free_modifier(ClothModifierData *clmd)
cloth->numsprings = 0;
// free BVH collision tree
- if (cloth->bvhtree)
+ if (cloth->bvhtree) {
BLI_bvhtree_free(cloth->bvhtree);
+ }
- if (cloth->bvhselftree)
+ if (cloth->bvhselftree) {
BLI_bvhtree_free(cloth->bvhselftree);
+ }
// we save our faces for collision objects
- if (cloth->tri)
+ if (cloth->tri) {
MEM_freeN(cloth->tri);
+ }
- if (cloth->edgeset)
+ if (cloth->edgeset) {
BLI_edgeset_free(cloth->edgeset);
+ }
#if 0
if (clmd->clothObject->facemarks) {
@@ -521,8 +540,9 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
printf("cloth_free_modifier_extern\n");
}
- if (!clmd)
+ if (!clmd) {
return;
+ }
cloth = clmd->clothObject;
@@ -534,8 +554,9 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
BPH_cloth_solver_free(clmd);
// Free the verts.
- if (cloth->verts != NULL)
+ if (cloth->verts != NULL) {
MEM_freeN(cloth->verts);
+ }
cloth->verts = NULL;
cloth->mvert_num = 0;
@@ -561,18 +582,22 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
cloth->numsprings = 0;
// free BVH collision tree
- if (cloth->bvhtree)
+ if (cloth->bvhtree) {
BLI_bvhtree_free(cloth->bvhtree);
+ }
- if (cloth->bvhselftree)
+ if (cloth->bvhselftree) {
BLI_bvhtree_free(cloth->bvhselftree);
+ }
// we save our faces for collision objects
- if (cloth->tri)
+ if (cloth->tri) {
MEM_freeN(cloth->tri);
+ }
- if (cloth->edgeset)
+ if (cloth->edgeset) {
BLI_edgeset_free(cloth->edgeset);
+ }
#if 0
if (clmd->clothObject->facemarks) {
@@ -631,8 +656,9 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, Mesh *mesh)
/* float goalfac = 0; */ /* UNUSED */
ClothVertex *verts = NULL;
- if (!clmd || !mesh)
+ if (!clmd || !mesh) {
return;
+ }
clothObj = clmd->clothObject;
@@ -644,10 +670,12 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, Mesh *mesh)
for (i = 0; i < mvert_num; i++, verts++) {
/* Reset Goal values to standard */
- if (clmd->sim_parms->vgroup_mass > 0)
+ if (clmd->sim_parms->vgroup_mass > 0) {
verts->goal = clmd->sim_parms->defgoal;
- else
+ }
+ else {
verts->goal = 0.0f;
+ }
/* Compute base cloth shrink weight */
verts->shrink_factor = 0.0f;
@@ -668,8 +696,9 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, Mesh *mesh)
// ABS ( clmd->sim_parms->maxgoal - clmd->sim_parms->mingoal );
verts->goal = pow4f(verts->goal);
- if (verts->goal >= SOFTGOALSNAP)
+ if (verts->goal >= SOFTGOALSNAP) {
verts->flags |= CLOTH_VERT_FLAG_PINNED;
+ }
}
if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct - 1)) {
@@ -693,7 +722,8 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, Mesh *mesh)
}
if (clmd->sim_parms->vgroup_shrink > 0) {
if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shrink - 1)) {
- /* Used for linear interpolation between min and max shrink factor based on weight. */
+ /* Used for linear interpolation between min and max
+ * shrink factor based on weight. */
verts->shrink_factor = dvert->dw[j].weight;
}
}
@@ -713,7 +743,7 @@ static float cloth_shrink_factor(ClothModifierData *clmd, ClothVertex *verts, in
float k2 = base + delta * verts[i2].shrink_factor;
/* Use geometrical mean to average two factors since it behaves better
- for diagonals when a rectangle transforms into a trapezoid. */
+ * for diagonals when a rectangle transforms into a trapezoid. */
return sqrtf(k1 * k2);
}
@@ -746,8 +776,9 @@ static int cloth_from_object(
}
// mesh input objects need Mesh
- if (!mesh)
+ if (!mesh) {
return 0;
+ }
cloth_from_mesh(clmd, mesh);
@@ -756,8 +787,9 @@ static int cloth_from_object(
clmd->clothObject->numsprings = -1;
if (clmd->sim_parms->shapekey_rest &&
- !(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH))
+ !(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH)) {
shapekey_rest = CustomData_get_layer(&mesh->vdata, CD_CLOTH_ORCO);
+ }
mvert = mesh->mvert;
@@ -774,18 +806,21 @@ static int cloth_from_object(
copy_v3_v3(verts->xrest, shapekey_rest[i]);
mul_m4_v3(ob->obmat, verts->xrest);
}
- else
+ else {
copy_v3_v3(verts->xrest, verts->x);
+ }
}
/* no GUI interface yet */
verts->mass = clmd->sim_parms->mass;
verts->impulse_count = 0;
- if (clmd->sim_parms->vgroup_mass > 0)
+ if (clmd->sim_parms->vgroup_mass > 0) {
verts->goal = clmd->sim_parms->defgoal;
- else
+ }
+ else {
verts->goal = 0.0f;
+ }
verts->shrink_factor = 0.0f;
@@ -813,8 +848,9 @@ static int cloth_from_object(
// init our solver
BPH_cloth_solver_init(ob, clmd);
- if (!first)
+ if (!first) {
BKE_cloth_solver_set_positions(clmd);
+ }
clmd->clothObject->bvhtree = bvhtree_build_from_cloth(clmd, clmd->coll_parms->epsilon);
clmd->clothObject->bvhselftree = bvhtree_build_from_cloth(clmd, clmd->coll_parms->selfepsilon);
@@ -854,8 +890,9 @@ static void cloth_from_mesh(ClothModifierData *clmd, Mesh *mesh)
/* Free the springs since they can't be correct if the vertices
* changed.
*/
- if (clmd->clothObject->springs != NULL)
+ if (clmd->clothObject->springs != NULL) {
MEM_freeN(clmd->clothObject->springs);
+ }
}
/***************************************************************************************
@@ -960,8 +997,9 @@ static void cloth_hair_update_bending_targets(ClothModifierData *clmd)
float hair_frame[3][3], dir_old[3], dir_new[3];
int prev_mn; /* to find hair chains */
- if (!clmd->hairdata)
+ if (!clmd->hairdata) {
return;
+ }
/* XXX Note: we need to propagate frames from the root up,
* but structural hair springs are stored in reverse order.
@@ -1017,8 +1055,9 @@ static void cloth_hair_update_bending_rest_targets(ClothModifierData *clmd)
float hair_frame[3][3], dir_old[3], dir_new[3];
int prev_mn; /* to find hair roots */
- if (!clmd->hairdata)
+ if (!clmd->hairdata) {
return;
+ }
/* XXX Note: we need to propagate frames from the root up,
* but structural hair springs are stored in reverse order.
@@ -1110,7 +1149,8 @@ static void cloth_update_springs(ClothModifierData *clmd)
spring->lin_stiffness = (v1->bend_stiff + v2->bend_stiff) / 2.0f;
}
else if (spring->type == CLOTH_SPRING_TYPE_GOAL) {
- /* Warning: Appending NEW goal springs does not work because implicit solver would need reset! */
+ /* Warning: Appending NEW goal springs does not work
+ * because implicit solver would need reset! */
/* Activate / Deactivate existing springs */
if ((!(cloth->verts[spring->ij].flags & CLOTH_VERT_FLAG_PINNED)) &&
@@ -1358,8 +1398,9 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
BendSpringRef *spring_ref = NULL;
// error handling
- if (numedges == 0)
+ if (numedges == 0) {
return 0;
+ }
/* NOTE: handling ownership of springs and edgeset is quite sloppy
* currently they are never initialized but assert just to be sure */
@@ -1434,13 +1475,15 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
}
}
- if (struct_springs_real > 0)
+ if (struct_springs_real > 0) {
clmd->sim_parms->avg_spring_len /= struct_springs_real;
+ }
for (int i = 0; i < mvert_num; i++) {
- if (cloth->verts[i].spring_count > 0)
+ if (cloth->verts[i].spring_count > 0) {
cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f /
((float)cloth->verts[i].spring_count);
+ }
}
edgeset = BLI_edgeset_new_ex(__func__, numedges);
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 38094841e4a..d33d4e344b5 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -188,8 +188,10 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
/***************************** Collection Copy *******************************/
/**
- * Only copy internal data of Collection ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Collection ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -248,7 +250,8 @@ static Collection *collection_duplicate_recursive(Main *bmain,
collection_new = (Collection *)collection_old->id.newid;
}
- /* Optionally add to parent (we always want to do that, even if collection_old had already been duplicated). */
+ /* Optionally add to parent (we always want to do that,
+ * even if collection_old had already been duplicated). */
if (parent != NULL) {
if (collection_child_add(parent, collection_new, 0, true)) {
/* Put collection right after existing one. */
@@ -263,14 +266,15 @@ static Collection *collection_duplicate_recursive(Main *bmain,
}
/* If we are not doing any kind of deep-copy, we can return immediately.
- * False do_full_process means collection_old had already been duplicated, no need to redo some deep-copy on it. */
+ * False do_full_process means collection_old had already been duplicated,
+ * no need to redo some deep-copy on it. */
if (!do_hierarchy || !do_full_process) {
return collection_new;
}
if (do_objects) {
- /* We can loop on collection_old's objects, that list is currently identical the collection_new' objects,
- * and won't be changed here. */
+ /* We can loop on collection_old's objects, that list is currently identical the collection_new
+ * objects, and won't be changed here. */
for (CollectionObject *cob = collection_old->gobject.first; cob; cob = cob->next) {
Object *ob_old = cob->ob;
Object *ob_new = (Object *)ob_old->id.newid;
@@ -285,8 +289,8 @@ static Collection *collection_duplicate_recursive(Main *bmain,
}
}
- /* We can loop on collection_old's children, that list is currently identical the collection_new' children,
- * and won't be changed here. */
+ /* We can loop on collection_old's children,
+ * that list is currently identical the collection_new' children, and won't be changed here. */
for (CollectionChild *child = collection_old->children.first; child; child = child->next) {
Collection *child_collection_old = child->collection;
@@ -314,13 +318,15 @@ Collection *BKE_collection_copy(Main *bmain, Collection *parent, Collection *col
*
* If \a do_hierarchy and \a do_deep_copy are false, this is a regular (shallow) ID copy.
*
- * \warning If any 'deep copy' behavior is enabled, this functions will clear all \a bmain id.idnew pointers.
+ * \warning If any 'deep copy' behavior is enabled,
+ * this functions will clear all \a bmain id.idnew pointers.
*
* \param do_hierarchy If true, it will recursively make shallow copies of children collections.
* \param do_objects If true, it will also make duplicates of objects.
* This one does nothing if \a do_hierarchy is not set.
- * \param do_obdata If true, it will also make deep duplicates of objects, using behavior defined in user settings
- * (U.dupflag). This one does nothing if \a do_hierarchy and \a do_objects are not set.
+ * \param do_obdata If true, it will also make deep duplicates of objects,
+ * using behavior defined in user settings (U.dupflag).
+ * This one does nothing if \a do_hierarchy and \a do_objects are not set.
*/
Collection *BKE_collection_duplicate(Main *bmain,
Collection *parent,
@@ -602,8 +608,9 @@ Collection *BKE_collection_object_find(Main *bmain,
}
while (collection) {
- if (BKE_collection_has_object(collection, ob))
+ if (BKE_collection_has_object(collection, ob)) {
return collection;
+ }
collection = collection_next_find(bmain, scene, collection);
}
return NULL;
@@ -834,7 +841,8 @@ static void collection_missing_parents_remove(Collection *collection)
*
* \note caller must ensure #BKE_main_collection_sync_remap() is called afterwards!
*
- * \param collection: may be \a NULL, in which case whole \a bmain database of collections is checked.
+ * \param collection: may be \a NULL,
+ * in which case whole \a bmain database of collections is checked.
*/
void BKE_collections_child_remove_nulls(Main *bmain, Collection *collection)
{
@@ -1217,8 +1225,9 @@ static void scene_collections_array(Scene *scene, Collection ***collections_arra
BLI_assert(collection != NULL);
scene_collection_callback(collection, scene_collections_count, tot);
- if (*tot == 0)
+ if (*tot == 0) {
return;
+ }
*collections_array = array = MEM_mallocN(sizeof(Collection *) * (*tot), "CollectionArray");
scene_collection_callback(collection, scene_collections_build_array, &array);
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 67e1f36b222..ff6258ac339 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -73,8 +73,8 @@ typedef struct SelfColDetectData {
} SelfColDetectData;
/***********************************
-Collision modifier code start
-***********************************/
+ * Collision modifier code start
+ ***********************************/
/* step is limited from 0 (frame start position) to 1 (frame end position) */
void collision_move_object(CollisionModifierData *collmd, float step, float prevstep)
@@ -178,9 +178,9 @@ void bvhtree_update_from_mvert(BVHTree *bvhtree,
BLI_bvhtree_update_tree(bvhtree);
}
-/***********************************
-Collision modifier code end
-***********************************/
+/* ***************************
+ * Collision modifier code end
+ * *************************** */
BLI_INLINE int next_ind(int i)
{
@@ -446,13 +446,15 @@ static void collision_compute_barycentric(
w1[0] = (float)((e * c - b * f) / d);
- if (w1[0] < 0)
+ if (w1[0] < 0) {
w1[0] = 0;
+ }
w2[0] = (float)((f - b * (double)w1[0]) / c);
- if (w2[0] < 0)
+ if (w2[0] < 0) {
w2[0] = 0;
+ }
w3[0] = 1.0f - w1[0] - w2[0];
@@ -537,7 +539,8 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
sub_v3_v3v3(relativeVelocity, v2, v1);
- /* Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). */
+ /* Calculate the normal component of the relative velocity
+ * (actually only the magnitude - the direction is stored in 'normal'). */
magrelVel = dot_v3v3(relativeVelocity, collpair->normal);
/* If magrelVel < 0 the edges are approaching each other. */
@@ -555,7 +558,8 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp);
/* Decrease in magnitude of relative tangential velocity due to coulomb friction
- * in original formula "magrelVel" should be the "change of relative velocity in normal direction". */
+ * in original formula "magrelVel" should be the
+ * "change of relative velocity in normal direction". */
magtangent = min_ff(collob->pd->pdef_cfrict * 0.01f * magrelVel, len_v3(vrel_t_pre));
/* Apply friction impulse. */
@@ -637,16 +641,19 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
for (int j = 0; j < 3; j++) {
if (cloth1->verts[collpair->ap1].impulse_count > 0 &&
- ABS(cloth1->verts[collpair->ap1].impulse[j]) < ABS(i1[j]))
+ ABS(cloth1->verts[collpair->ap1].impulse[j]) < ABS(i1[j])) {
cloth1->verts[collpair->ap1].impulse[j] = i1[j];
+ }
if (cloth1->verts[collpair->ap2].impulse_count > 0 &&
- ABS(cloth1->verts[collpair->ap2].impulse[j]) < ABS(i2[j]))
+ ABS(cloth1->verts[collpair->ap2].impulse[j]) < ABS(i2[j])) {
cloth1->verts[collpair->ap2].impulse[j] = i2[j];
+ }
if (cloth1->verts[collpair->ap3].impulse_count > 0 &&
- ABS(cloth1->verts[collpair->ap3].impulse[j]) < ABS(i3[j]))
+ ABS(cloth1->verts[collpair->ap3].impulse[j]) < ABS(i3[j])) {
cloth1->verts[collpair->ap3].impulse[j] = i3[j];
+ }
}
}
}
@@ -715,7 +722,8 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd,
sub_v3_v3v3(relativeVelocity, v2, v1);
- /* Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). */
+ /* Calculate the normal component of the relative velocity
+ * (actually only the magnitude - the direction is stored in 'normal'). */
magrelVel = dot_v3v3(relativeVelocity, collpair->normal);
/* TODO: Impulses should be weighed by mass as this is self col,
@@ -735,7 +743,8 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd,
sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp);
/* Decrease in magnitude of relative tangential velocity due to coulomb friction
- * in original formula "magrelVel" should be the "change of relative velocity in normal direction". */
+ * in original formula "magrelVel" should be the
+ * "change of relative velocity in normal direction". */
magtangent = min_ff(clmd->coll_parms->self_friction * 0.01f * magrelVel, len_v3(vrel_t_pre));
/* Apply friction impulse. */
@@ -816,16 +825,19 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd,
for (int j = 0; j < 3; j++) {
if (cloth1->verts[collpair->ap1].impulse_count > 0 &&
- ABS(cloth1->verts[collpair->ap1].impulse[j]) < ABS(i1[j]))
+ ABS(cloth1->verts[collpair->ap1].impulse[j]) < ABS(i1[j])) {
cloth1->verts[collpair->ap1].impulse[j] = i1[j];
+ }
if (cloth1->verts[collpair->ap2].impulse_count > 0 &&
- ABS(cloth1->verts[collpair->ap2].impulse[j]) < ABS(i2[j]))
+ ABS(cloth1->verts[collpair->ap2].impulse[j]) < ABS(i2[j])) {
cloth1->verts[collpair->ap2].impulse[j] = i2[j];
+ }
if (cloth1->verts[collpair->ap3].impulse_count > 0 &&
- ABS(cloth1->verts[collpair->ap3].impulse[j]) < ABS(i3[j]))
+ ABS(cloth1->verts[collpair->ap3].impulse[j]) < ABS(i3[j])) {
cloth1->verts[collpair->ap3].impulse[j] = i3[j];
+ }
}
}
}
@@ -974,8 +986,9 @@ static void add_collision_object(ListBase *relations,
/* only get objects with collision modifier */
if (((modifier_type == eModifierType_Collision) && ob->pd && ob->pd->deflect) ||
- (modifier_type != eModifierType_Collision))
+ (modifier_type != eModifierType_Collision)) {
cmd = (CollisionModifierData *)modifiers_findByType(ob, modifier_type);
+ }
if (cmd) {
CollisionRelation *relation = MEM_callocN(sizeof(CollisionRelation), "CollisionRelation");
@@ -1279,8 +1292,9 @@ int cloth_bvh_collision(
uint coll_count_self = 0;
BVHTreeOverlap *overlap_self = NULL;
- if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ) || cloth_bvh == NULL)
+ if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ) || cloth_bvh == NULL) {
return 0;
+ }
verts = cloth->verts;
mvert_num = cloth->mvert_num;
@@ -1500,16 +1514,18 @@ static CollPair *cloth_point_collpair(float p1[3],
float facenor[3], v1p1[3], v1p2[3];
float w[3];
- if (!cloth_point_face_collision_params(p1, p2, co1, co2, co3, facenor, &lambda, w))
+ if (!cloth_point_face_collision_params(p1, p2, co1, co2, co3, facenor, &lambda, w)) {
return collpair;
+ }
sub_v3_v3v3(v1p1, p1, co1);
// distance1 = dot_v3v3(v1p1, facenor);
sub_v3_v3v3(v1p2, p2, co1);
distance2 = dot_v3v3(v1p2, facenor);
// if (distance2 > epsilon || (distance1 < 0.0f && distance2 < 0.0f))
- if (distance2 > epsilon)
+ if (distance2 > epsilon) {
return collpair;
+ }
collpair->face1 = index_cloth; /* XXX actually not a face, but equivalent index for point */
collpair->face2 = index_coll;
@@ -1536,7 +1552,8 @@ static CollPair *cloth_point_collpair(float p1[3],
return collpair;
}
-//Determines collisions on overlap, collisions are written to collpair[i] and collision+number_collision_found is returned
+/* Determines collisions on overlap,
+ * collisions are written to collpair[i] and collision+number_collision_found is returned. */
static CollPair *cloth_point_collision(ModifierData *md1,
ModifierData *md2,
BVHTreeOverlap *overlap,
@@ -1642,8 +1659,9 @@ void cloth_find_point_contacts(Depsgraph *depsgraph,
Object *collob = collobjs[i];
CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(
collob, eModifierType_Collision);
- if (!collmd->bvhtree)
+ if (!collmd->bvhtree) {
continue;
+ }
/* move object to position (step) in time */
collision_move_object(collmd, step + dt, step);
@@ -1666,8 +1684,9 @@ void cloth_find_point_contacts(Depsgraph *depsgraph,
ct->collisions = NULL;
ct->totcollisions = 0;
- if (!collmd->bvhtree)
+ if (!collmd->bvhtree) {
continue;
+ }
/* search for overlapping collision pairs */
overlap = BLI_bvhtree_overlap(cloth_bvh, collmd->bvhtree, &result, NULL, NULL);
@@ -1682,12 +1701,16 @@ void cloth_find_point_contacts(Depsgraph *depsgraph,
clmd, collmd, &ct->collisions, &collisions_index, result, overlap, epsilon, dt);
ct->totcollisions = (int)(collisions_index - ct->collisions);
- // resolve nearby collisions
- // ret += cloth_points_objcollisions_resolve(clmd, collmd, collob->pd, collisions[i], collisions_index[i], dt);
+ /* Resolve nearby collisions. */
+#if 0
+ ret += cloth_points_objcollisions_resolve(
+ clmd, collmd, collob->pd, collisions[i], collisions_index[i], dt);
+#endif
}
- if (overlap)
+ if (overlap) {
MEM_freeN(overlap);
+ }
}
BKE_collision_objects_free(collobjs);
diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c
index ffb60195f36..8701f06d9dd 100644
--- a/source/blender/blenkernel/intern/colorband.c
+++ b/source/blender/blenkernel/intern/colorband.c
@@ -338,38 +338,49 @@ static float colorband_hue_interp(
switch (ipotype_hue) {
case COLBAND_HUE_NEAR: {
- if ((h1 < h2) && (h2 - h1) > +0.5f)
+ if ((h1 < h2) && (h2 - h1) > +0.5f) {
mode = 1;
- else if ((h1 > h2) && (h2 - h1) < -0.5f)
+ }
+ else if ((h1 > h2) && (h2 - h1) < -0.5f) {
mode = 2;
- else
+ }
+ else {
mode = 0;
+ }
break;
}
case COLBAND_HUE_FAR: {
/* Do full loop in Hue space in case both stops are the same... */
- if (h1 == h2)
+ if (h1 == h2) {
mode = 1;
- else if ((h1 < h2) && (h2 - h1) < +0.5f)
+ }
+ else if ((h1 < h2) && (h2 - h1) < +0.5f) {
mode = 1;
- else if ((h1 > h2) && (h2 - h1) > -0.5f)
+ }
+ else if ((h1 > h2) && (h2 - h1) > -0.5f) {
mode = 2;
- else
+ }
+ else {
mode = 0;
+ }
break;
}
case COLBAND_HUE_CCW: {
- if (h1 > h2)
+ if (h1 > h2) {
mode = 2;
- else
+ }
+ else {
mode = 0;
+ }
break;
}
case COLBAND_HUE_CW: {
- if (h1 < h2)
+ if (h1 < h2) {
mode = 1;
- else
+ }
+ else {
mode = 0;
+ }
break;
}
}
@@ -403,13 +414,15 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
int ipotype;
int a;
- if (coba == NULL || coba->tot == 0)
+ if (coba == NULL || coba->tot == 0) {
return false;
+ }
cbd1 = coba->data;
- /* Note: when ipotype >= COLBAND_INTERP_B_SPLINE, we cannot do early-out with a constant color before
- * first color stop and after last one, because interpolation starts before and ends after those... */
+ /* Note: when ipotype >= COLBAND_INTERP_B_SPLINE,
+ * we cannot do early-out with a constant color before first color stop and after last one,
+ * because interpolation starts before and ends after those... */
ipotype = (coba->color_mode == COLBAND_BLEND_RGB) ? coba->ipotype : COLBAND_INTERP_LINEAR;
if (coba->tot == 1) {
@@ -480,14 +493,18 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
/* ipo from right to left: 3 2 1 0 */
float t[4];
- if (a >= coba->tot - 1)
+ if (a >= coba->tot - 1) {
cbd0 = cbd1;
- else
+ }
+ else {
cbd0 = cbd1 + 1;
- if (a < 2)
+ }
+ if (a < 2) {
cbd3 = cbd2;
- else
+ }
+ else {
cbd3 = cbd2 - 1;
+ }
CLAMP(fac, 0.0f, 1.0f);
@@ -561,18 +578,21 @@ void BKE_colorband_evaluate_table_rgba(const ColorBand *coba, float **array, int
*size = CM_TABLE + 1;
*array = MEM_callocN(sizeof(float) * (*size) * 4, "ColorBand");
- for (a = 0; a < *size; a++)
+ for (a = 0; a < *size; a++) {
BKE_colorband_evaluate(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]);
+ }
}
static int vergcband(const void *a1, const void *a2)
{
const CBData *x1 = a1, *x2 = a2;
- if (x1->pos > x2->pos)
+ if (x1->pos > x2->pos) {
return 1;
- else if (x1->pos < x2->pos)
+ }
+ else if (x1->pos < x2->pos) {
return -1;
+ }
return 0;
}
@@ -580,11 +600,13 @@ void BKE_colorband_update_sort(ColorBand *coba)
{
int a;
- if (coba->tot < 2)
+ if (coba->tot < 2) {
return;
+ }
- for (a = 0; a < coba->tot; a++)
+ for (a = 0; a < coba->tot; a++) {
coba->data[a].cur = a;
+ }
qsort(coba->data, coba->tot, sizeof(CBData), vergcband);
@@ -627,17 +649,20 @@ int BKE_colorband_element_remove(struct ColorBand *coba, int index)
{
int a;
- if (coba->tot < 2)
+ if (coba->tot < 2) {
return 0;
+ }
- if (index < 0 || index >= coba->tot)
+ if (index < 0 || index >= coba->tot) {
return 0;
+ }
coba->tot--;
for (a = index; a < coba->tot; a++) {
coba->data[a] = coba->data[a + 1];
}
- if (coba->cur)
+ if (coba->cur) {
coba->cur--;
+ }
return 1;
}
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 96c098b37e9..45cb5e817d2 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -55,8 +55,9 @@ void curvemapping_set_defaults(
float clipminx, clipminy, clipmaxx, clipmaxy;
cumap->flag = CUMA_DO_CLIP;
- if (tot == 4)
+ if (tot == 4) {
cumap->cur = 3; /* rhms, hack for 'col' curve? */
+ }
clipminx = min_ff(minx, maxx);
clipminy = min_ff(miny, maxy);
@@ -129,12 +130,15 @@ void curvemapping_copy_data(CurveMapping *target, const CurveMapping *cumap)
*target = *cumap;
for (a = 0; a < CM_TOT; a++) {
- if (cumap->cm[a].curve)
+ if (cumap->cm[a].curve) {
target->cm[a].curve = MEM_dupallocN(cumap->cm[a].curve);
- if (cumap->cm[a].table)
+ }
+ if (cumap->cm[a].table) {
target->cm[a].table = MEM_dupallocN(cumap->cm[a].table);
- if (cumap->cm[a].premultable)
+ }
+ if (cumap->cm[a].premultable) {
target->cm[a].premultable = MEM_dupallocN(cumap->cm[a].premultable);
+ }
}
}
@@ -181,8 +185,9 @@ bool curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
int a, b, removed = 0;
/* must have 2 points minimum */
- if (cuma->totpoint <= 2)
+ if (cuma->totpoint <= 2) {
return false;
+ }
cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points");
@@ -263,8 +268,9 @@ CurveMapPoint *curvemap_insert(CurveMap *cuma, float x, float y)
void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
{
- if (cuma->curve)
+ if (cuma->curve) {
MEM_freeN(cuma->curve);
+ }
switch (preset) {
case CURVE_PRESET_LINE:
@@ -502,10 +508,12 @@ static void calchandle_curvemap(BezTriple *bezt, const BezTriple *prev, const Be
len_a = len_v2(dvec_a);
len_b = len_v2(dvec_b);
- if (len_a == 0.0f)
+ if (len_a == 0.0f) {
len_a = 1.0f;
- if (len_b == 0.0f)
+ }
+ if (len_b == 0.0f) {
len_b = 1.0f;
+ }
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) || ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */
float tvec[2];
@@ -590,10 +598,12 @@ static float curvemap_calc_extend(const CurveMap *cuma,
return first[1];
}
else {
- if (cuma->ext_in[0] == 0.0f)
+ if (cuma->ext_in[0] == 0.0f) {
return first[1] + cuma->ext_in[1] * 10000.0f;
- else
+ }
+ else {
return first[1] + cuma->ext_in[1] * (x - first[0]) / cuma->ext_in[0];
+ }
}
}
else if (x >= last[0]) {
@@ -602,10 +612,12 @@ static float curvemap_calc_extend(const CurveMap *cuma,
return last[1];
}
else {
- if (cuma->ext_out[0] == 0.0f)
+ if (cuma->ext_out[0] == 0.0f) {
return last[1] - cuma->ext_out[1] * 10000.0f;
- else
+ }
+ else {
return last[1] + cuma->ext_out[1] * (x - last[0]) / cuma->ext_out[0];
+ }
}
}
return 0.0f;
@@ -619,8 +631,9 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
float *fp, *allpoints, *lastpoint, curf, range;
int a, totpoint;
- if (cuma->curve == NULL)
+ if (cuma->curve == NULL) {
return;
+ }
/* default rect also is table range */
cuma->mintable = clipr->xmin;
@@ -662,8 +675,9 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
hlen = len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */
/* clip handle point */
copy_v3_v3(vec, bezt[1].vec[0]);
- if (vec[0] < bezt[0].vec[1][0])
+ if (vec[0] < bezt[0].vec[1][0]) {
vec[0] = bezt[0].vec[1][0];
+ }
sub_v3_v3(vec, bezt[0].vec[1]);
nlen = len_v3(vec);
@@ -679,8 +693,9 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
hlen = len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */
/* clip handle point */
copy_v3_v3(vec, bezt[a - 1].vec[2]);
- if (vec[0] > bezt[a].vec[1][0])
+ if (vec[0] > bezt[a].vec[1][0]) {
vec[0] = bezt[a].vec[1][0];
+ }
sub_v3_v3(vec, bezt[a].vec[1]);
nlen = len_v3(vec);
@@ -692,8 +707,9 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
}
}
/* make the bezier curve */
- if (cuma->table)
+ if (cuma->table) {
MEM_freeN(cuma->table);
+ }
totpoint = (cuma->totpoint - 1) * CM_RESOL;
fp = allpoints = MEM_callocN(totpoint * 2 * sizeof(float), "table");
@@ -748,15 +764,18 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr)
while (curf >= fp[0] && fp != lastpoint) {
fp += 2;
}
- if (fp == allpoints || (curf >= fp[0] && fp == lastpoint))
+ if (fp == allpoints || (curf >= fp[0] && fp == lastpoint)) {
cmp[a].y = curvemap_calc_extend(cuma, curf, allpoints, lastpoint);
+ }
else {
float fac1 = fp[0] - fp[-2];
float fac2 = fp[0] - curf;
- if (fac1 > FLT_EPSILON)
+ if (fac1 > FLT_EPSILON) {
fac1 = fac2 / fac1;
- else
+ }
+ else {
fac1 = 0.0f;
+ }
cmp[a].y = fac1 * fp[-1] + (1.0f - fac1) * fp[1];
}
}
@@ -791,16 +810,18 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore)
if ((cumap->flag & CUMA_PREMULLED) == 0) {
/* verify and copy */
for (a = 0; a < 3; a++) {
- if (cumap->cm[a].table == NULL)
+ if (cumap->cm[a].table == NULL) {
curvemap_make_table(cumap->cm + a, &cumap->clipr);
+ }
cumap->cm[a].premultable = cumap->cm[a].table;
cumap->cm[a].table = MEM_mallocN((CM_TABLE + 1) * sizeof(CurveMapPoint), "premul table");
memcpy(
cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE + 1) * sizeof(CurveMapPoint));
}
- if (cumap->cm[3].table == NULL)
+ if (cumap->cm[3].table == NULL) {
curvemap_make_table(cumap->cm + 3, &cumap->clipr);
+ }
/* premul */
for (a = 0; a < 3; a++) {
@@ -824,10 +845,12 @@ static int sort_curvepoints(const void *a1, const void *a2)
{
const struct CurveMapPoint *x1 = a1, *x2 = a2;
- if (x1->x > x2->x)
+ if (x1->x > x2->x) {
return 1;
- else if (x1->x < x2->x)
+ }
+ else if (x1->x < x2->x) {
return -1;
+ }
return 0;
}
@@ -849,14 +872,18 @@ void curvemapping_changed(CurveMapping *cumap, const bool rem_doubles)
if (cumap->flag & CUMA_DO_CLIP) {
for (a = 0; a < cuma->totpoint; a++) {
if (cmp[a].flag & CUMA_SELECT) {
- if (cmp[a].x < clipr->xmin)
+ if (cmp[a].x < clipr->xmin) {
dx = min_ff(dx, cmp[a].x - clipr->xmin);
- else if (cmp[a].x > clipr->xmax)
+ }
+ else if (cmp[a].x > clipr->xmax) {
dx = max_ff(dx, cmp[a].x - clipr->xmax);
- if (cmp[a].y < clipr->ymin)
+ }
+ if (cmp[a].y < clipr->ymin) {
dy = min_ff(dy, cmp[a].y - clipr->ymin);
- else if (cmp[a].y > clipr->ymax)
+ }
+ else if (cmp[a].y > clipr->ymax) {
dy = max_ff(dy, cmp[a].y - clipr->ymax);
+ }
}
}
for (a = 0; a < cuma->totpoint; a++) {
@@ -887,19 +914,22 @@ void curvemapping_changed(CurveMapping *cumap, const bool rem_doubles)
if (sqrtf(dx * dx + dy * dy) < thresh) {
if (a == 0) {
cmp[a + 1].flag |= CUMA_HANDLE_VECTOR;
- if (cmp[a + 1].flag & CUMA_SELECT)
+ if (cmp[a + 1].flag & CUMA_SELECT) {
cmp[a].flag |= CUMA_SELECT;
+ }
}
else {
cmp[a].flag |= CUMA_HANDLE_VECTOR;
- if (cmp[a].flag & CUMA_SELECT)
+ if (cmp[a].flag & CUMA_SELECT) {
cmp[a + 1].flag |= CUMA_SELECT;
+ }
}
break; /* we assume 1 deletion per edit is ok */
}
}
- if (a != cuma->totpoint - 1)
+ if (a != cuma->totpoint - 1) {
curvemap_remove(cuma, 2);
+ }
}
curvemap_make_table(cuma, clipr);
}
@@ -929,13 +959,16 @@ float curvemap_evaluateF(const CurveMap *cuma, float value)
i = (int)fi;
/* fi is table float index and should check against table range i.e. [0.0 CM_TABLE] */
- if (fi < 0.0f || fi > CM_TABLE)
+ if (fi < 0.0f || fi > CM_TABLE) {
return curvemap_calc_extend(cuma, value, &cuma->table[0].x, &cuma->table[CM_TABLE].x);
+ }
else {
- if (i < 0)
+ if (i < 0) {
return cuma->table[0].y;
- if (i >= CM_TABLE)
+ }
+ if (i >= CM_TABLE) {
return cuma->table[CM_TABLE].y;
+ }
fi = fi - (float)i;
return (1.0f - fi) * cuma->table[i].y + (fi)*cuma->table[i + 1].y;
@@ -950,10 +983,12 @@ float curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
/* account for clipping */
if (cumap->flag & CUMA_DO_CLIP) {
- if (val < cumap->curr.ymin)
+ if (val < cumap->curr.ymin) {
val = cumap->curr.ymin;
- else if (val > cumap->curr.ymax)
+ }
+ else if (val > cumap->curr.ymax) {
val = cumap->curr.ymax;
+ }
}
return val;
@@ -1096,32 +1131,43 @@ int curvemapping_RGBA_does_something(const CurveMapping *cumap)
{
int a;
- if (cumap->black[0] != 0.0f)
+ if (cumap->black[0] != 0.0f) {
return 1;
- if (cumap->black[1] != 0.0f)
+ }
+ if (cumap->black[1] != 0.0f) {
return 1;
- if (cumap->black[2] != 0.0f)
+ }
+ if (cumap->black[2] != 0.0f) {
return 1;
- if (cumap->white[0] != 1.0f)
+ }
+ if (cumap->white[0] != 1.0f) {
return 1;
- if (cumap->white[1] != 1.0f)
+ }
+ if (cumap->white[1] != 1.0f) {
return 1;
- if (cumap->white[2] != 1.0f)
+ }
+ if (cumap->white[2] != 1.0f) {
return 1;
+ }
for (a = 0; a < CM_TOT; a++) {
if (cumap->cm[a].curve) {
- if (cumap->cm[a].totpoint != 2)
+ if (cumap->cm[a].totpoint != 2) {
return 1;
+ }
- if (cumap->cm[a].curve[0].x != 0.0f)
+ if (cumap->cm[a].curve[0].x != 0.0f) {
return 1;
- if (cumap->cm[a].curve[0].y != 0.0f)
+ }
+ if (cumap->cm[a].curve[0].y != 0.0f) {
return 1;
- if (cumap->cm[a].curve[1].x != 1.0f)
+ }
+ if (cumap->cm[a].curve[1].x != 1.0f) {
return 1;
- if (cumap->cm[a].curve[1].y != 1.0f)
+ }
+ if (cumap->cm[a].curve[1].y != 1.0f) {
return 1;
+ }
}
}
return 0;
@@ -1131,12 +1177,14 @@ void curvemapping_initialize(CurveMapping *cumap)
{
int a;
- if (cumap == NULL)
+ if (cumap == NULL) {
return;
+ }
for (a = 0; a < CM_TOT; a++) {
- if (cumap->cm[a].table == NULL)
+ if (cumap->cm[a].table == NULL) {
curvemap_make_table(cumap->cm + a, &cumap->clipr);
+ }
}
}
@@ -1148,14 +1196,18 @@ void curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *size
*array = MEM_callocN(sizeof(float) * (*size) * 4, "CurveMapping");
for (a = 0; a < *size; a++) {
- if (cumap->cm[0].table)
+ if (cumap->cm[0].table) {
(*array)[a * 4 + 0] = cumap->cm[0].table[a].y;
- if (cumap->cm[1].table)
+ }
+ if (cumap->cm[1].table) {
(*array)[a * 4 + 1] = cumap->cm[1].table[a].y;
- if (cumap->cm[2].table)
+ }
+ if (cumap->cm[2].table) {
(*array)[a * 4 + 2] = cumap->cm[2].table[a].y;
- if (cumap->cm[3].table)
+ }
+ if (cumap->cm[3].table) {
(*array)[a * 4 + 3] = cumap->cm[3].table[a].y;
+ }
}
}
@@ -1232,11 +1284,13 @@ void BKE_histogram_update_sample_line(Histogram *hist,
hist->xmax = 1.0f;
/* hist->ymax = 1.0f; */ /* now do this on the operator _only_ */
- if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
return;
+ }
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+ }
for (i = 0; i < 256; i++) {
x = (int)(0.5f + x1 + (float)i * (x2 - x1) / 255.0f);
@@ -1290,8 +1344,9 @@ void BKE_histogram_update_sample_line(Histogram *hist,
}
}
- if (cm_processor)
+ if (cm_processor) {
IMB_colormanagement_processor_free(cm_processor);
+ }
}
/* if view_settings, it also applies this to byte buffers */
@@ -1343,8 +1398,9 @@ static void scopes_update_cb(void *__restrict userdata,
(y % rows_per_sample_line) == 0;
const bool is_float = (ibuf->rect_float != NULL);
- if (is_float)
+ if (is_float) {
rf = ibuf->rect_float + ((size_t)y) * ibuf->x * ibuf->channels;
+ }
else {
rc = display_buffer + ((size_t)y) * ibuf->x * ibuf->channels;
}
@@ -1376,8 +1432,9 @@ static void scopes_update_cb(void *__restrict userdata,
}
}
else {
- for (int c = 4; c--;)
+ for (int c = 4; c--;) {
rgba[c] = rc[c] * INV_255;
+ }
}
/* we still need luma for histogram */
@@ -1440,10 +1497,12 @@ static void scopes_update_finalize(void *__restrict userdata, void *__restrict u
}
for (int c = 3; c--;) {
- if (min[c] < minmax[c][0])
+ if (min[c] < minmax[c][0]) {
minmax[c][0] = min[c];
- if (max[c] > minmax[c][1])
+ }
+ if (max[c] > minmax[c][1]) {
minmax[c][1] = max[c];
+ }
}
}
@@ -1456,24 +1515,27 @@ void scopes_update(Scopes *scopes,
unsigned int nl, na, nr, ng, nb;
double divl, diva, divr, divg, divb;
const unsigned char *display_buffer = NULL;
- unsigned int bin_lum[256] = {0}, bin_r[256] = {0}, bin_g[256] = {0}, bin_b[256] = {0},
- bin_a[256] = {0};
+ uint bin_lum[256] = {0}, bin_r[256] = {0}, bin_g[256] = {0}, bin_b[256] = {0}, bin_a[256] = {0};
int ycc_mode = -1;
void *cache_handle = NULL;
struct ColormanageProcessor *cm_processor = NULL;
- if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
return;
+ }
- if (scopes->ok == 1)
+ if (scopes->ok == 1) {
return;
+ }
- if (scopes->hist.ymax == 0.f)
+ if (scopes->hist.ymax == 0.f) {
scopes->hist.ymax = 1.f;
+ }
/* hmmmm */
- if (!(ELEM(ibuf->channels, 3, 4)))
+ if (!(ELEM(ibuf->channels, 3, 4))) {
return;
+ }
scopes->hist.channels = 3;
scopes->hist.x_resolution = 256;
@@ -1500,8 +1562,9 @@ void scopes_update(Scopes *scopes,
scopes->sample_lines = (scopes->accuracy * 0.01f) * (scopes->accuracy * 0.01f) * ibuf->y;
CLAMP_MIN(scopes->sample_lines, 1);
- if (scopes->sample_full)
+ if (scopes->sample_full) {
scopes->sample_lines = ibuf->y;
+ }
/* scan the image */
for (a = 0; a < 3; a++) {
@@ -1511,14 +1574,18 @@ void scopes_update(Scopes *scopes,
scopes->waveform_tot = ibuf->x * scopes->sample_lines;
- if (scopes->waveform_1)
+ if (scopes->waveform_1) {
MEM_freeN(scopes->waveform_1);
- if (scopes->waveform_2)
+ }
+ if (scopes->waveform_2) {
MEM_freeN(scopes->waveform_2);
- if (scopes->waveform_3)
+ }
+ if (scopes->waveform_3) {
MEM_freeN(scopes->waveform_3);
- if (scopes->vecscope)
+ }
+ if (scopes->vecscope) {
MEM_freeN(scopes->vecscope);
+ }
scopes->waveform_1 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float),
"waveform point channel 1");
@@ -1564,16 +1631,21 @@ void scopes_update(Scopes *scopes,
/* convert hist data to float (proportional to max count) */
nl = na = nr = nb = ng = 0;
for (a = 0; a < 256; a++) {
- if (bin_lum[a] > nl)
+ if (bin_lum[a] > nl) {
nl = bin_lum[a];
- if (bin_r[a] > nr)
+ }
+ if (bin_r[a] > nr) {
nr = bin_r[a];
- if (bin_g[a] > ng)
+ }
+ if (bin_g[a] > ng) {
ng = bin_g[a];
- if (bin_b[a] > nb)
+ }
+ if (bin_b[a] > nb) {
nb = bin_b[a];
- if (bin_a[a] > na)
+ }
+ if (bin_a[a] > na) {
na = bin_a[a];
+ }
}
divl = nl ? 1.0 / (double)nl : 1.0;
diva = na ? 1.0 / (double)na : 1.0;
@@ -1589,10 +1661,12 @@ void scopes_update(Scopes *scopes,
scopes->hist.data_a[a] = bin_a[a] * diva;
}
- if (cm_processor)
+ if (cm_processor) {
IMB_colormanagement_processor_free(cm_processor);
- if (cache_handle)
+ }
+ if (cache_handle) {
IMB_display_buffer_release(cache_handle);
+ }
scopes->ok = 1;
}
@@ -1692,16 +1766,19 @@ void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings
new_settings->exposure = settings->exposure;
new_settings->gamma = settings->gamma;
- if (settings->curve_mapping)
+ if (settings->curve_mapping) {
new_settings->curve_mapping = curvemapping_copy(settings->curve_mapping);
- else
+ }
+ else {
new_settings->curve_mapping = NULL;
+ }
}
void BKE_color_managed_view_settings_free(ColorManagedViewSettings *settings)
{
- if (settings->curve_mapping)
+ if (settings->curve_mapping) {
curvemapping_free(settings->curve_mapping);
+ }
}
void BKE_color_managed_colorspace_settings_init(
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 114bf5ec1e6..0e29f165992 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -120,7 +120,8 @@ void BKE_constraint_unique_name(bConstraint *con, ListBase *list)
/* ----------------- Evaluation Loop Preparation --------------- */
/* package an object/bone for use in constraint evaluation */
-/* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */
+/* This function MEM_calloc's a bConstraintOb struct,
+ * that will need to be freed after evaluation */
bConstraintOb *BKE_constraints_make_evalob(
Depsgraph *depsgraph, Scene *scene, Object *ob, void *subdata, short datatype)
{
@@ -156,8 +157,9 @@ bConstraintOb *BKE_constraints_make_evalob(
}
copy_m4_m4(cob->matrix, ob->obmat);
}
- else
+ else {
unit_m4(cob->matrix);
+ }
copy_m4_m4(cob->startmat, cob->matrix);
break;
@@ -181,8 +183,9 @@ bConstraintOb *BKE_constraints_make_evalob(
/* matrix in world-space */
mul_m4_m4m4(cob->matrix, ob->obmat, cob->pchan->pose_mat);
}
- else
+ else {
unit_m4(cob->matrix);
+ }
copy_m4_m4(cob->startmat, cob->matrix);
break;
@@ -202,15 +205,16 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob)
float delta[4][4], imat[4][4];
/* prevent crashes */
- if (cob == NULL)
+ if (cob == NULL) {
return;
+ }
/* calculate delta of constraints evaluation */
invert_m4_m4(imat, cob->startmat);
- /* XXX This would seem to be in wrong order. However, it does not work in 'right' order - would be nice to
- * understand why premul is needed here instead of usual postmul?
- * In any case, we **do not get a delta** here (e.g. startmat & matrix having same location, still gives
- * a 'delta' with non-null translation component :/ ).*/
+ /* XXX This would seem to be in wrong order. However, it does not work in 'right' order -
+ * would be nice to understand why premul is needed here instead of usual postmul?
+ * In any case, we **do not get a delta** here (e.g. startmat & matrix having same location,
+ * still gives a 'delta' with non-null translation component :/ ).*/
mul_m4_m4m4(delta, cob->matrix, imat);
/* copy matrices back to source */
@@ -256,11 +260,13 @@ void BKE_constraint_mat_convertspace(
float imat[4][4];
/* prevent crashes in these unlikely events */
- if (ob == NULL || mat == NULL)
+ if (ob == NULL || mat == NULL) {
return;
+ }
/* optimize trick - check if need to do anything */
- if (from == to)
+ if (from == to) {
return;
+ }
/* are we dealing with pose-channels or objects */
if (pchan) {
@@ -347,8 +353,9 @@ void BKE_constraint_mat_convertspace(
*/
/* XXX This is actually an ugly hack, local space of a parent-less object *is* the same as
* global space!
- * Think what we want actually here is some kind of 'Final Space', i.e. once transformations
- * are applied - users are often confused about this too, this is not consistent with bones
+ * Think what we want actually here is some kind of 'Final Space', i.e
+ * . once transformations are applied - users are often confused about this too,
+ * this is not consistent with bones
* local space either... Meh :|
* --mont29
*/
@@ -513,10 +520,12 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m
copy_m4_m4(mat, ob->obmat);
/* get index of vertex group */
- if (defgroup == -1)
+ if (defgroup == -1) {
return;
- if (dv == NULL)
+ }
+ if (dv == NULL) {
return;
+ }
/* 1. Loop through control-points checking if in nominated vertex-group.
* 2. If it is, add it to vec to find the average point.
@@ -534,15 +543,18 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m
}
/* advance pointer to coordinate data */
- if (co)
+ if (co) {
co += 3;
- else
+ }
+ else {
bp++;
+ }
}
/* find average location, then multiply by ob->obmat to find world-space location */
- if (grouped)
+ if (grouped) {
mul_v3_fl(vec, 1.0f / grouped);
+ }
mul_v3_m4v3(tvec, ob->obmat, vec);
/* copy new location to matrix */
@@ -638,8 +650,9 @@ static void constraint_target_to_mat4(Object *ob,
mul_m4_m4m4(mat, ob->obmat, tempmat);
}
}
- else
+ else {
copy_m4_m4(mat, ob->obmat);
+ }
/* convert matrix space as required */
BKE_constraint_mat_convertspace(ob, pchan, mat, from, to, false);
@@ -665,18 +678,18 @@ static void constraint_target_to_mat4(Object *ob,
*/
#if 0
static bConstraintTypeInfo CTI_CONSTRNAME = {
- CONSTRAINT_TYPE_CONSTRNAME, /* type */
- sizeof(bConstrNameConstraint), /* size */
- "ConstrName", /* name */
- "bConstrNameConstraint", /* struct name */
- constrname_free, /* free data */
- constrname_id_looper, /* id looper */
- constrname_copy, /* copy data */
- constrname_new_data, /* new data */
- constrname_get_tars, /* get constraint targets */
- constrname_flush_tars, /* flush constraint targets */
- constrname_get_tarmat, /* get target matrix */
- constrname_evaluate, /* evaluate */
+ CONSTRAINT_TYPE_CONSTRNAME, /* type */
+ sizeof(bConstrNameConstraint), /* size */
+ "ConstrName", /* name */
+ "bConstrNameConstraint", /* struct name */
+ constrname_free, /* free data */
+ constrname_id_looper, /* id looper */
+ constrname_copy, /* copy data */
+ constrname_new_data, /* new data */
+ constrname_get_tars, /* get constraint targets */
+ constrname_flush_tars, /* flush constraint targets */
+ constrname_get_tarmat, /* get target matrix */
+ constrname_evaluate, /* evaluate */
};
#endif
@@ -689,7 +702,7 @@ static void default_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
bConstraintTarget *ct,
float UNUSED(ctime))
{
- if (VALID_CONS_TARGET(ct))
+ if (VALID_CONS_TARGET(ct)) {
constraint_target_to_mat4(ct->tar,
ct->subtarget,
ct->matrix,
@@ -697,8 +710,10 @@ static void default_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
ct->space,
con->flag,
con->headtail);
- else if (ct)
+ }
+ else if (ct) {
unit_m4(ct->matrix);
+ }
}
/* This is a variant that extracts full transformation from B-Bone segments.
@@ -709,7 +724,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
bConstraintTarget *ct,
float UNUSED(ctime))
{
- if (VALID_CONS_TARGET(ct))
+ if (VALID_CONS_TARGET(ct)) {
constraint_target_to_mat4(ct->tar,
ct->subtarget,
ct->matrix,
@@ -717,8 +732,10 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph),
ct->space,
con->flag | CONSTRAINT_BBONE_SHAPE_FULL,
con->headtail);
- else if (ct)
+ }
+ else if (ct) {
unit_m4(ct->matrix);
+ }
}
/* This following macro should be used for all standard single-target *_get_tars functions
@@ -905,24 +922,33 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
mat4_to_size(sizo, invmat);
/* disable channels not enabled */
- if (!(data->flag & CHILDOF_LOCX))
+ if (!(data->flag & CHILDOF_LOCX)) {
loc[0] = loco[0] = 0.0f;
- if (!(data->flag & CHILDOF_LOCY))
+ }
+ if (!(data->flag & CHILDOF_LOCY)) {
loc[1] = loco[1] = 0.0f;
- if (!(data->flag & CHILDOF_LOCZ))
+ }
+ if (!(data->flag & CHILDOF_LOCZ)) {
loc[2] = loco[2] = 0.0f;
- if (!(data->flag & CHILDOF_ROTX))
+ }
+ if (!(data->flag & CHILDOF_ROTX)) {
eul[0] = eulo[0] = 0.0f;
- if (!(data->flag & CHILDOF_ROTY))
+ }
+ if (!(data->flag & CHILDOF_ROTY)) {
eul[1] = eulo[1] = 0.0f;
- if (!(data->flag & CHILDOF_ROTZ))
+ }
+ if (!(data->flag & CHILDOF_ROTZ)) {
eul[2] = eulo[2] = 0.0f;
- if (!(data->flag & CHILDOF_SIZEX))
+ }
+ if (!(data->flag & CHILDOF_SIZEX)) {
size[0] = sizo[0] = 1.0f;
- if (!(data->flag & CHILDOF_SIZEY))
+ }
+ if (!(data->flag & CHILDOF_SIZEY)) {
size[1] = sizo[1] = 1.0f;
- if (!(data->flag & CHILDOF_SIZEZ))
+ }
+ if (!(data->flag & CHILDOF_SIZEZ)) {
size[2] = sizo[2] = 1.0f;
+ }
/* make new target mat and offset mat */
loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder);
@@ -942,12 +968,15 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
/* without this, changes to scale and rotation can change location
* of a parentless bone or a disconnected bone. Even though its set
* to zero above. */
- if (!(data->flag & CHILDOF_LOCX))
+ if (!(data->flag & CHILDOF_LOCX)) {
cob->matrix[3][0] = tempmat[3][0];
- if (!(data->flag & CHILDOF_LOCY))
+ }
+ if (!(data->flag & CHILDOF_LOCY)) {
cob->matrix[3][1] = tempmat[3][1];
- if (!(data->flag & CHILDOF_LOCZ))
+ }
+ if (!(data->flag & CHILDOF_LOCZ)) {
cob->matrix[3][2] = tempmat[3][2];
+ }
}
}
}
@@ -1047,10 +1076,12 @@ static void vectomat(const float vec[3],
n[1] = 0.0f;
n[2] = 1.0f;
}
- if (axis > 2)
+ if (axis > 2) {
axis -= 3;
- else
+ }
+ else {
negate_v3(n);
+ }
/* n specifies the transformation of the track axis */
if (flags & TARGET_Z_UP) {
@@ -1110,7 +1141,8 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
float size[3], vec[3];
float totmat[3][3];
- /* Get size property, since ob->scale is only the object's own relative size, not its global one */
+ /* Get size property, since ob->scale is only the object's own relative size,
+ * not its global one. */
mat4_to_size(size, cob->matrix);
/* Clear the object's rotation */
@@ -1210,7 +1242,7 @@ static void kinematic_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
{
bKinematicConstraint *data = con->data;
- if (VALID_CONS_TARGET(ct))
+ if (VALID_CONS_TARGET(ct)) {
constraint_target_to_mat4(ct->tar,
ct->subtarget,
ct->matrix,
@@ -1218,6 +1250,7 @@ static void kinematic_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
ct->space,
con->flag,
con->headtail);
+ }
else if (ct) {
if (data->flag & CONSTRAINT_IK_AUTO) {
Object *ob = cob->ob;
@@ -1233,8 +1266,9 @@ static void kinematic_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
copy_v3_v3(ct->matrix[3], vec);
}
}
- else
+ else {
unit_m4(ct->matrix);
+ }
}
}
@@ -1326,12 +1360,11 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
Nurb *nu = cu->nurb.first;
curvetime = cu->ctime - data->offset;
- /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
- * but this will only work if it actually is animated...
+ /* ctime is now a proper var setting of Curve which gets set by Animato like any other var
+ * that's animated, but this will only work if it actually is animated...
*
- * we divide the curvetime calculated in the previous step by the length of the path, to get a time
- * factor, which then gets clamped to lie within 0.0 - 1.0 range
- */
+ * we divide the curvetime calculated in the previous step by the length of the path,
+ * to get a time factor, which then gets clamped to lie within 0.0 - 1.0 range. */
curvetime /= cu->pathlen;
if (nu && nu->flagu & CU_NURB_CYCLIC) {
@@ -1379,8 +1412,9 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
}
}
}
- else if (ct)
+ else if (ct) {
unit_m4(ct->matrix);
+ }
}
static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
@@ -1404,17 +1438,21 @@ static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *
mul_m4_m4m4(cob->matrix, ct->matrix, obmat);
/* un-apply scaling caused by path */
- if ((data->followflag & FOLLOWPATH_RADIUS) ==
- 0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */
+ if ((data->followflag & FOLLOWPATH_RADIUS) == 0) {
+ /* XXX: Assume that scale correction means that radius
+ * will have some scale error in it - Campbell. */
float obsize[3];
mat4_to_size(obsize, cob->matrix);
- if (obsize[0])
+ if (obsize[0]) {
mul_v3_fl(cob->matrix[0], size[0] / obsize[0]);
- if (obsize[1])
+ }
+ if (obsize[1]) {
mul_v3_fl(cob->matrix[1], size[1] / obsize[1]);
- if (obsize[2])
+ }
+ if (obsize[2]) {
mul_v3_fl(cob->matrix[2], size[2] / obsize[2]);
+ }
}
}
}
@@ -1441,28 +1479,34 @@ static void loclimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UN
bLocLimitConstraint *data = con->data;
if (data->flag & LIMIT_XMIN) {
- if (cob->matrix[3][0] < data->xmin)
+ if (cob->matrix[3][0] < data->xmin) {
cob->matrix[3][0] = data->xmin;
+ }
}
if (data->flag & LIMIT_XMAX) {
- if (cob->matrix[3][0] > data->xmax)
+ if (cob->matrix[3][0] > data->xmax) {
cob->matrix[3][0] = data->xmax;
+ }
}
if (data->flag & LIMIT_YMIN) {
- if (cob->matrix[3][1] < data->ymin)
+ if (cob->matrix[3][1] < data->ymin) {
cob->matrix[3][1] = data->ymin;
+ }
}
if (data->flag & LIMIT_YMAX) {
- if (cob->matrix[3][1] > data->ymax)
+ if (cob->matrix[3][1] > data->ymax) {
cob->matrix[3][1] = data->ymax;
+ }
}
if (data->flag & LIMIT_ZMIN) {
- if (cob->matrix[3][2] < data->zmin)
+ if (cob->matrix[3][2] < data->zmin) {
cob->matrix[3][2] = data->zmin;
+ }
}
if (data->flag & LIMIT_ZMAX) {
- if (cob->matrix[3][2] > data->zmax)
+ if (cob->matrix[3][2] > data->zmax) {
cob->matrix[3][2] = data->zmax;
+ }
}
}
@@ -1499,25 +1543,31 @@ static void rotlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UN
/* limiting of euler values... */
if (data->flag & LIMIT_XROT) {
- if (eul[0] < data->xmin)
+ if (eul[0] < data->xmin) {
eul[0] = data->xmin;
+ }
- if (eul[0] > data->xmax)
+ if (eul[0] > data->xmax) {
eul[0] = data->xmax;
+ }
}
if (data->flag & LIMIT_YROT) {
- if (eul[1] < data->ymin)
+ if (eul[1] < data->ymin) {
eul[1] = data->ymin;
+ }
- if (eul[1] > data->ymax)
+ if (eul[1] > data->ymax) {
eul[1] = data->ymax;
+ }
}
if (data->flag & LIMIT_ZROT) {
- if (eul[2] < data->zmin)
+ if (eul[2] < data->zmin) {
eul[2] = data->zmin;
+ }
- if (eul[2] > data->zmax)
+ if (eul[2] > data->zmax) {
eul[2] = data->zmax;
+ }
}
loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder);
@@ -1549,36 +1599,45 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U
mat4_to_size(obsize, cob->matrix);
if (data->flag & LIMIT_XMIN) {
- if (size[0] < data->xmin)
+ if (size[0] < data->xmin) {
size[0] = data->xmin;
+ }
}
if (data->flag & LIMIT_XMAX) {
- if (size[0] > data->xmax)
+ if (size[0] > data->xmax) {
size[0] = data->xmax;
+ }
}
if (data->flag & LIMIT_YMIN) {
- if (size[1] < data->ymin)
+ if (size[1] < data->ymin) {
size[1] = data->ymin;
+ }
}
if (data->flag & LIMIT_YMAX) {
- if (size[1] > data->ymax)
+ if (size[1] > data->ymax) {
size[1] = data->ymax;
+ }
}
if (data->flag & LIMIT_ZMIN) {
- if (size[2] < data->zmin)
+ if (size[2] < data->zmin) {
size[2] = data->zmin;
+ }
}
if (data->flag & LIMIT_ZMAX) {
- if (size[2] > data->zmax)
+ if (size[2] > data->zmax) {
size[2] = data->zmax;
+ }
}
- if (obsize[0])
+ if (obsize[0]) {
mul_v3_fl(cob->matrix[0], size[0] / obsize[0]);
- if (obsize[1])
+ }
+ if (obsize[1]) {
mul_v3_fl(cob->matrix[1], size[1] / obsize[1]);
- if (obsize[2])
+ }
+ if (obsize[2]) {
mul_v3_fl(cob->matrix[2], size[2] / obsize[2]);
+ }
}
static bConstraintTypeInfo CTI_SIZELIMIT = {
@@ -1647,28 +1706,32 @@ static void loclike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
if (VALID_CONS_TARGET(ct)) {
float offset[3] = {0.0f, 0.0f, 0.0f};
- if (data->flag & LOCLIKE_OFFSET)
+ if (data->flag & LOCLIKE_OFFSET) {
copy_v3_v3(offset, cob->matrix[3]);
+ }
if (data->flag & LOCLIKE_X) {
cob->matrix[3][0] = ct->matrix[3][0];
- if (data->flag & LOCLIKE_X_INVERT)
+ if (data->flag & LOCLIKE_X_INVERT) {
cob->matrix[3][0] *= -1;
+ }
cob->matrix[3][0] += offset[0];
}
if (data->flag & LOCLIKE_Y) {
cob->matrix[3][1] = ct->matrix[3][1];
- if (data->flag & LOCLIKE_Y_INVERT)
+ if (data->flag & LOCLIKE_Y_INVERT) {
cob->matrix[3][1] *= -1;
+ }
cob->matrix[3][1] += offset[1];
}
if (data->flag & LOCLIKE_Z) {
cob->matrix[3][2] = ct->matrix[3][2];
- if (data->flag & LOCLIKE_Z_INVERT)
+ if (data->flag & LOCLIKE_Z_INVERT) {
cob->matrix[3][2] *= -1;
+ }
cob->matrix[3][2] += offset[2];
}
}
@@ -1745,42 +1808,53 @@ static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
copy_v3_v3(loc, cob->matrix[3]);
mat4_to_size(size, cob->matrix);
- /* to allow compatible rotations, must get both rotations in the order of the owner... */
+ /* To allow compatible rotations, must get both rotations in the order of the owner... */
mat4_to_eulO(obeul, cob->rotOrder, cob->matrix);
- /* we must get compatible eulers from the beginning because some of them can be modified below (see bug #21875) */
+ /* We must get compatible eulers from the beginning because
+ * some of them can be modified below (see bug T21875). */
mat4_to_compatible_eulO(eul, obeul, cob->rotOrder, ct->matrix);
- if ((data->flag & ROTLIKE_X) == 0)
+ if ((data->flag & ROTLIKE_X) == 0) {
eul[0] = obeul[0];
+ }
else {
- if (data->flag & ROTLIKE_OFFSET)
+ if (data->flag & ROTLIKE_OFFSET) {
rotate_eulO(eul, cob->rotOrder, 'X', obeul[0]);
+ }
- if (data->flag & ROTLIKE_X_INVERT)
+ if (data->flag & ROTLIKE_X_INVERT) {
eul[0] *= -1;
+ }
}
- if ((data->flag & ROTLIKE_Y) == 0)
+ if ((data->flag & ROTLIKE_Y) == 0) {
eul[1] = obeul[1];
+ }
else {
- if (data->flag & ROTLIKE_OFFSET)
+ if (data->flag & ROTLIKE_OFFSET) {
rotate_eulO(eul, cob->rotOrder, 'Y', obeul[1]);
+ }
- if (data->flag & ROTLIKE_Y_INVERT)
+ if (data->flag & ROTLIKE_Y_INVERT) {
eul[1] *= -1;
+ }
}
- if ((data->flag & ROTLIKE_Z) == 0)
+ if ((data->flag & ROTLIKE_Z) == 0) {
eul[2] = obeul[2];
+ }
else {
- if (data->flag & ROTLIKE_OFFSET)
+ if (data->flag & ROTLIKE_OFFSET) {
rotate_eulO(eul, cob->rotOrder, 'Z', obeul[2]);
+ }
- if (data->flag & ROTLIKE_Z_INVERT)
+ if (data->flag & ROTLIKE_Z_INVERT) {
eul[2] *= -1;
+ }
}
- /* good to make eulers compatible again, since we don't know how much they were changed above */
+ /* Good to make eulers compatible again,
+ * since we don't know how much they were changed above. */
compatible_eul(eul, obeul);
loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder);
}
@@ -1979,8 +2053,9 @@ static void samevolume_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *
/* calculate normalizing scale factor for non-essential values */
total_scale = obsize[0] * obsize[1] * obsize[2];
- if (total_scale != 0)
+ if (total_scale != 0) {
fac = sqrtf(volume / total_scale);
+ }
/* apply scaling factor to the channels not being kept */
switch (data->flag) {
@@ -2066,8 +2141,9 @@ static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userd
bConstraintTarget *ct;
/* targets */
- for (ct = data->targets.first; ct; ct = ct->next)
+ for (ct = data->targets.first; ct; ct = ct->next) {
func(con, (ID **)&ct->tar, false, userdata);
+ }
/* script */
func(con, (ID **)&data->text, true, userdata);
@@ -2103,12 +2179,14 @@ static void pycon_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
/* only execute target calculation if allowed */
#ifdef WITH_PYTHON
- if (G.f & G_FLAG_SCRIPT_AUTOEXEC)
+ if (G.f & G_FLAG_SCRIPT_AUTOEXEC) {
BPY_pyconstraint_target(data, ct);
+ }
#endif
}
- else if (ct)
+ else if (ct) {
unit_m4(ct->matrix);
+ }
}
static void pycon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
@@ -2120,8 +2198,9 @@ static void pycon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targe
bPythonConstraint *data = con->data;
/* only evaluate in python if we're allowed to do so */
- if ((G.f & G_FLAG_SCRIPT_AUTOEXEC) == 0)
+ if ((G.f & G_FLAG_SCRIPT_AUTOEXEC) == 0) {
return;
+ }
/* Now, run the actual 'constraint' function, which should only access the matrices */
BPY_pyconstraint_exec(data, cob, targets);
@@ -2214,8 +2293,9 @@ static void armdef_accumulate_matrix(float obmat[4][4],
float r_sum_mat[4][4],
DualQuat *r_sum_dq)
{
- if (weight == 0.0f)
+ if (weight == 0.0f) {
return;
+ }
/* Convert the selected matrix into object space. */
float mat[4][4];
@@ -2478,11 +2558,12 @@ static void actcon_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
CLAMP(s, 0, 1);
t = (s * (data->end - data->start)) + data->start;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("do Action Constraint %s - Ob %s Pchan %s\n",
con->name,
cob->ob->id.name + 2,
(cob->pchan) ? cob->pchan->name : NULL);
+ }
/* Get the appropriate information from the action */
if (cob->type == CONSTRAINT_OBTYPE_OBJECT || (data->flag & ACTCON_BONE_USE_OBJECT_ACTION)) {
@@ -2498,9 +2579,9 @@ static void actcon_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
bPose pose = {{0}};
bPoseChannel *pchan, *tchan;
- /* make a copy of the bone of interest in the temp pose before evaluating action, so that it can get set
- * - we need to manually copy over a few settings, including rotation order, otherwise this fails
- */
+ /* make a copy of the bone of interest in the temp pose before evaluating action,
+ * so that it can get set - we need to manually copy over a few settings,
+ * including rotation order, otherwise this fails. */
pchan = cob->pchan;
tchan = BKE_pose_channel_verify(&pose, pchan->name);
@@ -2944,8 +3025,9 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* if inside, then move to surface */
if (dist <= data->dist) {
clamp_surf = 1;
- if (dist != 0.0f)
+ if (dist != 0.0f) {
sfac = data->dist / dist;
+ }
}
/* if soft-distance is enabled, start fading once owner is dist+softdist from the target */
else if (data->flag & LIMITDIST_USESOFT) {
@@ -2958,8 +3040,9 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* if outside, then move to surface */
if (dist >= data->dist) {
clamp_surf = 1;
- if (dist != 0.0f)
+ if (dist != 0.0f) {
sfac = data->dist / dist;
+ }
}
/* if soft-distance is enabled, start fading once owner is dist-soft from the target */
else if (data->flag & LIMITDIST_USESOFT) {
@@ -2967,8 +3050,9 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
if (dist >= (data->dist - data->soft)) {
sfac = (float)(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) +
data->dist);
- if (dist != 0.0f)
+ if (dist != 0.0f) {
sfac /= dist;
+ }
clamp_surf = 1;
}
@@ -2977,8 +3061,9 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
else {
if (IS_EQF(dist, data->dist) == 0) {
clamp_surf = 1;
- if (dist != 0.0f)
+ if (dist != 0.0f) {
sfac = data->dist / dist;
+ }
}
}
@@ -3409,8 +3494,9 @@ static void clampto_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
/* technically, this isn't really needed for evaluation, but we don't know what else
* might end up calling this...
*/
- if (ct)
+ if (ct) {
unit_m4(ct->matrix);
+ }
}
static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
@@ -3449,15 +3535,19 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
* extent. Otherwise, default to the x-axis, as that is quite
* frequently used.
*/
- if ((size[2] > size[0]) && (size[2] > size[1]))
+ if ((size[2] > size[0]) && (size[2] > size[1])) {
clamp_axis = CLAMPTO_Z - 1;
- else if ((size[1] > size[0]) && (size[1] > size[2]))
+ }
+ else if ((size[1] > size[0]) && (size[1] > size[2])) {
clamp_axis = CLAMPTO_Y - 1;
- else
+ }
+ else {
clamp_axis = CLAMPTO_X - 1;
+ }
}
- else
+ else {
clamp_axis = data->flag - 1;
+ }
/* 2. determine position relative to curve on a 0-1 scale based on bounding box */
if (data->flag2 & CLAMPTO_CYCLIC) {
@@ -3473,7 +3563,8 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
offset = curveMin[clamp_axis] -
ceilf((curveMin[clamp_axis] - ownLoc[clamp_axis]) / len) * len;
- /* now, we calculate as per normal, except using offset instead of curveMin[clamp_axis] */
+ /* Now, we calculate as per normal,
+ * except using offset instead of curveMin[clamp_axis]. */
curvetime = (ownLoc[clamp_axis] - offset) / (len);
}
else if (ownLoc[clamp_axis] > curveMax[clamp_axis]) {
@@ -3481,7 +3572,8 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
offset = curveMax[clamp_axis] +
(int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len;
- /* now, we calculate as per normal, except using offset instead of curveMax[clamp_axis] */
+ /* Now, we calculate as per normal,
+ * except using offset instead of curveMax[clamp_axis]. */
curvetime = (ownLoc[clamp_axis] - offset) / (len);
}
else {
@@ -3496,15 +3588,19 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
}
else {
/* no cyclic, so position is clamped to within the bounding box */
- if (ownLoc[clamp_axis] <= curveMin[clamp_axis])
+ if (ownLoc[clamp_axis] <= curveMin[clamp_axis]) {
curvetime = 0.0f;
- else if (ownLoc[clamp_axis] >= curveMax[clamp_axis])
+ }
+ else if (ownLoc[clamp_axis] >= curveMax[clamp_axis]) {
curvetime = 1.0f;
- else if (IS_EQF((curveMax[clamp_axis] - curveMin[clamp_axis]), 0.0f) == false)
+ }
+ else if (IS_EQF((curveMax[clamp_axis] - curveMin[clamp_axis]), 0.0f) == false) {
curvetime = (ownLoc[clamp_axis] - curveMin[clamp_axis]) /
(curveMax[clamp_axis] - curveMin[clamp_axis]);
- else
+ }
+ else {
curvetime = 0.0f;
+ }
}
/* 3. position on curve */
@@ -3599,11 +3695,10 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
mat4_to_size(dvec, ct->matrix);
if (is_negative_m4(ct->matrix)) {
- /* Bugfix [#27886]
- * We can't be sure which axis/axes are negative, though we know that something is negative.
- * Assume we don't care about negativity of separate axes. <--- This is a limitation that
- * riggers will have to live with for now.
- */
+ /* Bugfix T27886: (this is a limitation that riggers will have to live with for now).
+ * We can't be sure which axis/axes are negative,
+ * though we know that something is negative.
+ * Assume we don't care about negativity of separate axes. */
negate_v3(dvec);
}
from_min = data->from_min_scale;
@@ -3630,20 +3725,24 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* determine where in range current transforms lie */
if (data->expo) {
for (i = 0; i < 3; i++) {
- if (from_max[i] - from_min[i])
+ if (from_max[i] - from_min[i]) {
sval[i] = (dvec[i] - from_min[i]) / (from_max[i] - from_min[i]);
- else
+ }
+ else {
sval[i] = 0.0f;
+ }
}
}
else {
/* clamp transforms out of range */
for (i = 0; i < 3; i++) {
CLAMP(dvec[i], from_min[i], from_max[i]);
- if (from_max[i] - from_min[i])
+ if (from_max[i] - from_min[i]) {
sval[i] = (dvec[i] - from_min[i]) / (from_max[i] - from_min[i]);
- else
+ }
+ else {
sval[i] = 0.0f;
+ }
}
}
@@ -3838,9 +3937,10 @@ static void shrinkwrap_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
break;
}
- /* transform normal into requested space */
- /* Note that in this specific case, we need to keep scaling in non-parented 'local2world' object
- * case, because SpaceTransform also takes it into account when handling normals. See T42447. */
+ /* Transform normal into requested space */
+ /* Note that in this specific case, we need to keep scaling in non-parented 'local2world'
+ * object case, because SpaceTransform also takes it into account when handling normals.
+ * See T42447. */
unit_m4(mat);
BKE_constraint_mat_convertspace(
cob->ob, cob->pchan, mat, CONSTRAINT_SPACE_LOCAL, scon->projAxisSpace, true);
@@ -4100,8 +4200,9 @@ static void splineik_free(bConstraint *con)
bSplineIKConstraint *data = con->data;
/* binding array */
- if (data->points)
+ if (data->points) {
MEM_freeN(data->points);
+ }
}
static void splineik_copy(bConstraint *con, bConstraint *srccon)
@@ -4168,8 +4269,9 @@ static void splineik_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
/* technically, this isn't really needed for evaluation, but we don't know what else
* might end up calling this...
*/
- if (ct)
+ if (ct) {
unit_m4(ct->matrix);
+ }
}
static bConstraintTypeInfo CTI_SPLINEIK = {
@@ -4244,13 +4346,15 @@ static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *ta
/* check which range might be violated */
if (data->rotAxis < PIVOTCON_AXIS_X) {
/* negative rotations (data->rotAxis = 0 -> 2) */
- if (rot[data->rotAxis] > 0.0f)
+ if (rot[data->rotAxis] > 0.0f) {
return;
+ }
}
else {
/* positive rotations (data->rotAxis = 3 -> 5 */
- if (rot[data->rotAxis - PIVOTCON_AXIS_X] < 0.0f)
+ if (rot[data->rotAxis - PIVOTCON_AXIS_X] < 0.0f) {
return;
+ }
}
}
@@ -4345,26 +4449,32 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
float ctime = DEG_get_ctime(depsgraph);
float framenr;
- if (data->flag & FOLLOWTRACK_ACTIVECLIP)
+ if (data->flag & FOLLOWTRACK_ACTIVECLIP) {
clip = scene->clip;
+ }
- if (!clip || !data->track[0] || !camob_eval)
+ if (!clip || !data->track[0] || !camob_eval) {
return;
+ }
tracking = &clip->tracking;
- if (data->object[0])
+ if (data->object[0]) {
tracking_object = BKE_tracking_object_get_named(tracking, data->object);
- else
+ }
+ else {
tracking_object = BKE_tracking_object_get_camera(tracking);
+ }
- if (!tracking_object)
+ if (!tracking_object) {
return;
+ }
track = BKE_tracking_track_get_named(tracking, tracking_object, data->track);
- if (!track)
+ if (!track) {
return;
+ }
framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, ctime);
@@ -4476,10 +4586,12 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
vec[1] = params.ortho_scale * (pos[1] - 0.5f + params.shifty);
vec[2] = -len;
- if (aspect > 1.0f)
+ if (aspect > 1.0f) {
vec[1] /= aspect;
- else
+ }
+ else {
vec[0] *= aspect;
+ }
mul_v3_m4v3(disp, camob_eval->obmat, vec);
@@ -4496,10 +4608,12 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
vec[1] = d * (2.0f * (pos[1] + params.shifty) - 1.0f);
vec[2] = -len;
- if (aspect > 1.0f)
+ if (aspect > 1.0f) {
vec[1] /= aspect;
- else
+ }
+ else {
vec[0] *= aspect;
+ }
mul_v3_m4v3(disp, camob_eval->obmat, vec);
@@ -4586,8 +4700,9 @@ static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
bCameraSolverConstraint *data = con->data;
MovieClip *clip = data->clip;
- if (data->flag & CAMERASOLVER_ACTIVECLIP)
+ if (data->flag & CAMERASOLVER_ACTIVECLIP) {
clip = scene->clip;
+ }
if (clip) {
float mat[4][4], obmat[4][4];
@@ -4646,11 +4761,13 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
MovieClip *clip = data->clip;
Object *camob = data->camera ? data->camera : scene->camera;
- if (data->flag & OBJECTSOLVER_ACTIVECLIP)
+ if (data->flag & OBJECTSOLVER_ACTIVECLIP) {
clip = scene->clip;
+ }
- if (!camob || !clip)
+ if (!camob || !clip) {
return;
+ }
if (clip) {
MovieTracking *tracking = &clip->tracking;
@@ -4718,13 +4835,9 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
const float frame = DEG_get_ctime(cob->depsgraph);
const float time = BKE_cachefile_time_offset(cache_file, frame, FPS);
- /* Must always load ABC handle on original. */
- CacheFile *cache_file_orig = (CacheFile *)DEG_get_original_id(&cache_file->id);
- BKE_cachefile_ensure_handle(G.main, cache_file_orig);
-
- if (!data->reader) {
- data->reader = CacheReader_open_alembic_object(
- cache_file_orig->handle, data->reader, cob->ob, data->object_path);
+ if (!data->reader || !STREQ(data->reader_object_path, data->object_path)) {
+ STRNCPY(data->reader_object_path, data->object_path);
+ BKE_cachefile_reader_open(cache_file, &data->reader, cob->ob, data->object_path);
}
ABC_get_transform(data->reader, cob->matrix, time, cache_file->scale);
@@ -4742,12 +4855,8 @@ static void transformcache_copy(bConstraint *con, bConstraint *srccon)
BLI_strncpy(dst->object_path, src->object_path, sizeof(dst->object_path));
dst->cache_file = src->cache_file;
-
-#ifdef WITH_ALEMBIC
- if (dst->reader) {
- CacheReader_incref(dst->reader);
- }
-#endif
+ dst->reader = NULL;
+ dst->reader_object_path[0] = '\0';
}
static void transformcache_free(bConstraint *con)
@@ -4755,10 +4864,8 @@ static void transformcache_free(bConstraint *con)
bTransformCacheConstraint *data = con->data;
if (data->reader) {
-#ifdef WITH_ALEMBIC
- CacheReader_free(data->reader);
-#endif
- data->reader = NULL;
+ BKE_cachefile_reader_free(data->cache_file, &data->reader);
+ data->reader_object_path[0] = '\0';
}
}
@@ -4858,10 +4965,12 @@ const bConstraintTypeInfo *BKE_constraint_typeinfo_from_type(int type)
const bConstraintTypeInfo *BKE_constraint_typeinfo_get(bConstraint *con)
{
/* only return typeinfo for valid constraints */
- if (con)
+ if (con) {
return BKE_constraint_typeinfo_from_type(con->type);
- else
+ }
+ else {
return NULL;
+ }
}
/* ************************* General Constraints API ************************** */
@@ -4879,8 +4988,9 @@ static void con_unlink_refs_cb(bConstraint *UNUSED(con),
bool is_reference,
void *UNUSED(userData))
{
- if (*idpoin && is_reference)
+ if (*idpoin && is_reference) {
id_us_min(*idpoin);
+ }
}
/**
@@ -4895,12 +5005,14 @@ void BKE_constraint_free_data_ex(bConstraint *con, bool do_id_user)
if (cti) {
/* perform any special freeing constraint may have */
- if (cti->free_data)
+ if (cti->free_data) {
cti->free_data(con);
+ }
/* unlink the referenced resources it uses */
- if (do_id_user && cti->id_looper)
+ if (do_id_user && cti->id_looper) {
cti->id_looper(con, con_unlink_refs_cb, NULL);
+ }
}
/* free constraint data now */
@@ -4919,8 +5031,9 @@ void BKE_constraints_free_ex(ListBase *list, bool do_id_user)
bConstraint *con;
/* Free constraint data and also any extra data */
- for (con = list->first; con; con = con->next)
+ for (con = list->first; con; con = con->next) {
BKE_constraint_free_data_ex(con, do_id_user);
+ }
/* Free the whole list */
BLI_freelistN(list);
@@ -4979,8 +5092,9 @@ static bConstraint *add_new_constraint_internal(const char *name, short type)
con->data = MEM_callocN(cti->size, cti->structName);
/* only constraints that change any settings need this */
- if (cti->new_data)
+ if (cti->new_data) {
cti->new_data(con->data);
+ }
/* if no name is provided, use the type of the constraint as the name */
newName = (name && name[0]) ? name : DATA_(cti->name);
@@ -5024,8 +5138,9 @@ static bConstraint *add_new_constraint(Object *ob,
* Armature layer, we must tag newly added constraints with a flag which allows them
* to persist after proxy syncing has been done
*/
- if (BKE_constraints_proxylocked_owner(ob, pchan))
+ if (BKE_constraints_proxylocked_owner(ob, pchan)) {
con->flag |= CONSTRAINT_PROXY_LOCAL;
+ }
/* make this constraint the active one */
BKE_constraints_active_set(list, con);
@@ -5062,8 +5177,9 @@ bConstraint *BKE_constraint_add_for_pose(Object *ob,
const char *name,
short type)
{
- if (pchan == NULL)
+ if (pchan == NULL) {
return NULL;
+ }
return add_new_constraint(ob, pchan, name, type);
}
@@ -5085,8 +5201,9 @@ void BKE_constraints_id_loop(ListBase *conlist, ConstraintIDFunc func, void *use
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
if (cti) {
- if (cti->id_looper)
+ if (cti->id_looper) {
cti->id_looper(con, func, userdata);
+ }
}
}
}
@@ -5099,19 +5216,22 @@ static void con_extern_cb(bConstraint *UNUSED(con),
bool UNUSED(is_reference),
void *UNUSED(userData))
{
- if (*idpoin && ID_IS_LINKED(*idpoin))
+ if (*idpoin && ID_IS_LINKED(*idpoin)) {
id_lib_extern(*idpoin);
+ }
}
-/* helper for BKE_constraints_copy(), to be used for making sure that usercounts of copied ID's are fixed up */
+/* helper for BKE_constraints_copy(),
+ * to be used for making sure that usercounts of copied ID's are fixed up */
static void con_fix_copied_refs_cb(bConstraint *UNUSED(con),
ID **idpoin,
bool is_reference,
void *UNUSED(userData))
{
/* increment usercount if this is a reference type */
- if ((*idpoin) && (is_reference))
+ if ((*idpoin) && (is_reference)) {
id_us_plus(*idpoin);
+ }
}
/** Copies a single constraint's data (\a dst must already be a shallow copy of \a src). */
@@ -5128,8 +5248,9 @@ static void constraint_copy_data_ex(bConstraint *dst,
/* only do specific constraints if required */
if (cti) {
/* perform custom copying operations if needed */
- if (cti->copy_data)
+ if (cti->copy_data) {
cti->copy_data(dst, src);
+ }
/* Fix usercounts for all referenced data that need it. */
if (cti->id_looper && (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
@@ -5139,8 +5260,9 @@ static void constraint_copy_data_ex(bConstraint *dst,
/* for proxies we don't want to make extern */
if (do_extern) {
/* go over used ID-links for this constraint to ensure that they are valid for proxies */
- if (cti->id_looper)
+ if (cti->id_looper) {
cti->id_looper(dst, con_extern_cb, NULL);
+ }
}
}
}
@@ -5188,8 +5310,9 @@ bConstraint *BKE_constraints_active_get(ListBase *list)
/* search for the first constraint with the 'active' flag set */
if (list) {
for (con = list->first; con; con = con->next) {
- if (con->flag & CONSTRAINT_ACTIVE)
+ if (con->flag & CONSTRAINT_ACTIVE) {
return con;
+ }
}
}
@@ -5204,10 +5327,12 @@ void BKE_constraints_active_set(ListBase *list, bConstraint *con)
if (list) {
for (c = list->first; c; c = c->next) {
- if (c == con)
+ if (c == con) {
c->flag |= CONSTRAINT_ACTIVE;
- else
+ }
+ else {
c->flag &= ~CONSTRAINT_ACTIVE;
+ }
}
}
}
@@ -5332,7 +5457,8 @@ static bConstraint *constraint_find_original_for_update(bConstraintOb *cob, bCon
/* -------- Constraints and Proxies ------- */
-/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */
+/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL
+ * (i.e. added to bone that's proxy-synced in this file) */
void BKE_constraints_proxylocal_extract(ListBase *dst, ListBase *src)
{
bConstraint *con, *next;
@@ -5358,8 +5484,9 @@ bool BKE_constraints_proxylocked_owner(Object *ob, bPoseChannel *pchan)
bArmature *arm = ob->data;
/* On bone-level, check if bone is on proxy-protected layer */
- if ((pchan->bone) && (pchan->bone->layer & arm->layer_protected))
+ if ((pchan->bone) && (pchan->bone->layer & arm->layer_protected)) {
return true;
+ }
}
else {
/* FIXME: constraints on object-level are not handled well yet */
@@ -5373,8 +5500,8 @@ bool BKE_constraints_proxylocked_owner(Object *ob, bPoseChannel *pchan)
/* -------- Target-Matrix Stuff ------- */
/* This function is a relic from the prior implementations of the constraints system, when all
- * constraints either had one or no targets. It used to be called during the main constraint solving
- * loop, but is now only used for the remaining cases for a few constraints.
+ * constraints either had one or no targets. It used to be called during the main constraint
+ * solving loop, but is now only used for the remaining cases for a few constraints.
*
* None of the actual calculations of the matrices should be done here! Also, this function is
* not to be used by any new constraints, particularly any that have multiple targets.
@@ -5437,14 +5564,16 @@ void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph,
ct = BLI_findlink(&targets, index);
if (ct) {
- if (cti->get_target_matrix)
+ if (cti->get_target_matrix) {
cti->get_target_matrix(depsgraph, con, cob, ct, ctime);
+ }
copy_m4_m4(mat, ct->matrix);
}
/* free targets + 'constraint-ob' */
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 1);
+ }
MEM_freeN(cob);
}
else {
@@ -5475,12 +5604,14 @@ void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph,
* - calculate if possible, otherwise just initialize as identity matrix
*/
if (cti->get_target_matrix) {
- for (ct = targets->first; ct; ct = ct->next)
+ for (ct = targets->first; ct; ct = ct->next) {
cti->get_target_matrix(depsgraph, con, cob, ct, ctime);
+ }
}
else {
- for (ct = targets->first; ct; ct = ct->next)
+ for (ct = targets->first; ct; ct = ct->next) {
unit_m4(ct->matrix);
+ }
}
}
}
@@ -5503,8 +5634,9 @@ void BKE_constraints_solve(struct Depsgraph *depsgraph,
float enf;
/* check that there is a valid constraint object to evaluate */
- if (cob == NULL)
+ if (cob == NULL) {
return;
+ }
/* loop over available constraints, solving and blending them */
for (con = conlist->first; con; con = con->next) {
@@ -5512,16 +5644,20 @@ void BKE_constraints_solve(struct Depsgraph *depsgraph,
ListBase targets = {NULL, NULL};
/* these we can skip completely (invalid constraints...) */
- if (cti == NULL)
+ if (cti == NULL) {
continue;
- if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))
+ }
+ if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) {
continue;
+ }
/* these constraints can't be evaluated anyway */
- if (cti->evaluate_constraint == NULL)
+ if (cti->evaluate_constraint == NULL) {
continue;
+ }
/* influence == 0 should be ignored */
- if (con->enforce == 0.0f)
+ if (con->enforce == 0.0f) {
continue;
+ }
/* influence of constraint
* - value should have been set from animation data already
@@ -5550,14 +5686,15 @@ void BKE_constraints_solve(struct Depsgraph *depsgraph,
}
/* move owner back into worldspace for next constraint/other business */
- if ((con->flag & CONSTRAINT_SPACEONCE) == 0)
+ if ((con->flag & CONSTRAINT_SPACEONCE) == 0) {
BKE_constraint_mat_convertspace(
cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD, false);
+ }
/* Interpolate the enforcement, to blend result of constraint into final owner transform
- * - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]),
- * since some constraints may not convert the solution back to the input space before blending
- * but all are guaranteed to end up in good "worldspace" result
+ * - all this happens in worldspace to prevent any weirdness creeping in
+ * (T26014 and T25725), since some constraints may not convert the solution back to the input
+ * space before blending but all are guaranteed to end up in good "worldspace" result.
*/
/* Note: all kind of stuff here before (caused trouble), much easier to just interpolate,
* or did I miss something? -jahka (r.32105) */
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index d9ee3ab6d15..4383b6a1f9b 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -134,8 +134,9 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p
ctx = MEM_dupallocN(lastctx);
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
}
- else
+ else {
ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
+ }
BLI_addtail(contexts, ctx);
}
@@ -164,8 +165,9 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
ctx = MEM_dupallocN(lastctx);
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
}
- else
+ else {
ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
+ }
BLI_addtail(contexts, ctx);
}
@@ -266,8 +268,9 @@ static void *ctx_wm_python_context_get(const bContext *C,
#endif
/* don't allow UI context access from non-main threads */
- if (!BLI_thread_is_main())
+ if (!BLI_thread_is_main()) {
return NULL;
+ }
return fall_through;
}
@@ -290,8 +293,9 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
#endif
/* don't allow UI context access from non-main threads */
- if (!BLI_thread_is_main())
+ if (!BLI_thread_is_main()) {
return done;
+ }
/* we check recursion to ensure that we do not get infinite
* loops requesting data from ourselves in a context callback */
@@ -317,16 +321,18 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
C->data.recursion = 2;
if (ar->type && ar->type->context) {
ret = ar->type->context(C, member, result);
- if (ret)
+ if (ret) {
done = -(-ret | -done);
+ }
}
}
if (done != 1 && recursion < 3 && (sa = CTX_wm_area(C))) {
C->data.recursion = 3;
if (sa->type && sa->type->context) {
ret = sa->type->context(C, member, result);
- if (ret)
+ if (ret) {
done = -(-ret | -done);
+ }
}
}
if (done != 1 && recursion < 4 && (sc = CTX_wm_screen(C))) {
@@ -334,8 +340,9 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
C->data.recursion = 4;
if (cb) {
ret = cb(C, member, result);
- if (ret)
+ if (ret) {
done = -(-ret | -done);
+ }
}
}
@@ -464,11 +471,13 @@ static void data_dir_add(ListBase *lb, const char *member, const bool use_all)
{
LinkData *link;
- if ((use_all == false) && STREQ(member, "scene")) /* exception */
+ if ((use_all == false) && STREQ(member, "scene")) { /* exception */
return;
+ }
- if (BLI_findstring(lb, member, offsetof(LinkData, data)))
+ if (BLI_findstring(lb, member, offsetof(LinkData, data))) {
return;
+ }
link = MEM_callocN(sizeof(LinkData), "LinkData");
link->data = (void *)member;
@@ -519,33 +528,40 @@ ListBase CTX_data_dir_get_ex(const bContext *C,
if (use_store && C->wm.store) {
bContextStoreEntry *entry;
- for (entry = C->wm.store->entries.first; entry; entry = entry->next)
+ for (entry = C->wm.store->entries.first; entry; entry = entry->next) {
data_dir_add(&lb, entry->name, use_all);
+ }
}
if ((ar = CTX_wm_region(C)) && ar->type && ar->type->context) {
memset(&result, 0, sizeof(result));
ar->type->context(C, "", &result);
- if (result.dir)
- for (a = 0; result.dir[a]; a++)
+ if (result.dir) {
+ for (a = 0; result.dir[a]; a++) {
data_dir_add(&lb, result.dir[a], use_all);
+ }
+ }
}
if ((sa = CTX_wm_area(C)) && sa->type && sa->type->context) {
memset(&result, 0, sizeof(result));
sa->type->context(C, "", &result);
- if (result.dir)
- for (a = 0; result.dir[a]; a++)
+ if (result.dir) {
+ for (a = 0; result.dir[a]; a++) {
data_dir_add(&lb, result.dir[a], use_all);
+ }
+ }
}
if ((sc = CTX_wm_screen(C)) && sc->context) {
bContextDataCallback cb = sc->context;
memset(&result, 0, sizeof(result));
cb(C, "", &result);
- if (result.dir)
- for (a = 0; result.dir[a]; a++)
+ if (result.dir) {
+ for (a = 0; result.dir[a]; a++) {
data_dir_add(&lb, result.dir[a], use_all);
+ }
+ }
}
return lb;
@@ -605,8 +621,9 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBas
BLI_freelistN(&list);
return tot;
}
- else
+ else {
return 0;
+ }
}
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
@@ -685,8 +702,9 @@ struct wmMsgBus *CTX_wm_message_bus(const bContext *C)
struct ReportList *CTX_wm_reports(const bContext *C)
{
- if (C->wm.manager)
+ if (C->wm.manager) {
return &(C->wm.manager->reports);
+ }
return NULL;
}
@@ -694,8 +712,9 @@ struct ReportList *CTX_wm_reports(const bContext *C)
View3D *CTX_wm_view3d(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_VIEW3D)
+ if (sa && sa->spacetype == SPACE_VIEW3D) {
return sa->spacedata.first;
+ }
return NULL;
}
@@ -704,129 +723,146 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C)
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- if (sa && sa->spacetype == SPACE_VIEW3D)
- if (ar)
+ if (sa && sa->spacetype == SPACE_VIEW3D) {
+ if (ar) {
return ar->regiondata;
+ }
+ }
return NULL;
}
struct SpaceText *CTX_wm_space_text(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_TEXT)
+ if (sa && sa->spacetype == SPACE_TEXT) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceConsole *CTX_wm_space_console(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_CONSOLE)
+ if (sa && sa->spacetype == SPACE_CONSOLE) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceImage *CTX_wm_space_image(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_IMAGE)
+ if (sa && sa->spacetype == SPACE_IMAGE) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceProperties *CTX_wm_space_properties(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_PROPERTIES)
+ if (sa && sa->spacetype == SPACE_PROPERTIES) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceFile *CTX_wm_space_file(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_FILE)
+ if (sa && sa->spacetype == SPACE_FILE) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_SEQ)
+ if (sa && sa->spacetype == SPACE_SEQ) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceOutliner *CTX_wm_space_outliner(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_OUTLINER)
+ if (sa && sa->spacetype == SPACE_OUTLINER) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceNla *CTX_wm_space_nla(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_NLA)
+ if (sa && sa->spacetype == SPACE_NLA) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceNode *CTX_wm_space_node(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_NODE)
+ if (sa && sa->spacetype == SPACE_NODE) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceGraph *CTX_wm_space_graph(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_GRAPH)
+ if (sa && sa->spacetype == SPACE_GRAPH) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceAction *CTX_wm_space_action(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_ACTION)
+ if (sa && sa->spacetype == SPACE_ACTION) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceInfo *CTX_wm_space_info(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_INFO)
+ if (sa && sa->spacetype == SPACE_INFO) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_USERPREF)
+ if (sa && sa->spacetype == SPACE_USERPREF) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceClip *CTX_wm_space_clip(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_CLIP)
+ if (sa && sa->spacetype == SPACE_CLIP) {
return sa->spacedata.first;
+ }
return NULL;
}
struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype == SPACE_TOPBAR)
+ if (sa && sa->spacetype == SPACE_TOPBAR) {
return sa->spacedata.first;
+ }
return NULL;
}
@@ -895,10 +931,12 @@ Main *CTX_data_main(const bContext *C)
{
Main *bmain;
- if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain))
+ if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain)) {
return bmain;
- else
+ }
+ else {
return C->data.main;
+ }
}
void CTX_data_main_set(bContext *C, Main *bmain)
@@ -911,10 +949,12 @@ Scene *CTX_data_scene(const bContext *C)
{
Scene *scene;
- if (ctx_data_pointer_verify(C, "scene", (void *)&scene))
+ if (ctx_data_pointer_verify(C, "scene", (void *)&scene)) {
return scene;
- else
+ }
+ else {
return C->data.scene;
+ }
}
ViewLayer *CTX_data_view_layer(const bContext *C)
@@ -1008,26 +1048,36 @@ enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit,
else {
// Object *ob = CTX_data_active_object(C);
if (ob) {
- if (object_mode & OB_MODE_POSE)
+ if (object_mode & OB_MODE_POSE) {
return CTX_MODE_POSE;
- else if (object_mode & OB_MODE_SCULPT)
+ }
+ else if (object_mode & OB_MODE_SCULPT) {
return CTX_MODE_SCULPT;
- else if (object_mode & OB_MODE_WEIGHT_PAINT)
+ }
+ else if (object_mode & OB_MODE_WEIGHT_PAINT) {
return CTX_MODE_PAINT_WEIGHT;
- else if (object_mode & OB_MODE_VERTEX_PAINT)
+ }
+ else if (object_mode & OB_MODE_VERTEX_PAINT) {
return CTX_MODE_PAINT_VERTEX;
- else if (object_mode & OB_MODE_TEXTURE_PAINT)
+ }
+ else if (object_mode & OB_MODE_TEXTURE_PAINT) {
return CTX_MODE_PAINT_TEXTURE;
- else if (object_mode & OB_MODE_PARTICLE_EDIT)
+ }
+ else if (object_mode & OB_MODE_PARTICLE_EDIT) {
return CTX_MODE_PARTICLE;
- else if (object_mode & OB_MODE_PAINT_GPENCIL)
+ }
+ else if (object_mode & OB_MODE_PAINT_GPENCIL) {
return CTX_MODE_PAINT_GPENCIL;
- else if (object_mode & OB_MODE_EDIT_GPENCIL)
+ }
+ else if (object_mode & OB_MODE_EDIT_GPENCIL) {
return CTX_MODE_EDIT_GPENCIL;
- else if (object_mode & OB_MODE_SCULPT_GPENCIL)
+ }
+ else if (object_mode & OB_MODE_SCULPT_GPENCIL) {
return CTX_MODE_SCULPT_GPENCIL;
- else if (object_mode & OB_MODE_WEIGHT_GPENCIL)
+ }
+ else if (object_mode & OB_MODE_WEIGHT_GPENCIL) {
return CTX_MODE_WEIGHT_GPENCIL;
+ }
}
}
@@ -1080,10 +1130,12 @@ ToolSettings *CTX_data_tool_settings(const bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (scene)
+ if (scene) {
return scene->toolsettings;
- else
+ }
+ else {
return NULL;
+ }
}
int CTX_data_selected_nodes(const bContext *C, ListBase *list)
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 465a9980579..3b46f491f11 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -86,12 +86,14 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
ModifierData *md;
int disabled = 0;
- for (md = ob->modifiers.first; md; md = md->next)
- if (md->type == eModifierType_Subsurf)
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Subsurf) {
if (md->mode & eModifierMode_OnCage) {
md->mode ^= eModifierMode_DisableTemporary;
disabled = 1;
}
+ }
+ }
return disabled;
}
@@ -199,8 +201,9 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me,
MPoly *mp;
mvert = me->mvert;
- for (i = 0; i < me->totvert; i++, mvert++)
+ for (i = 0; i < me->totvert; i++, mvert++) {
mvert->flag &= ~ME_VERT_TMP_TAG;
+ }
/* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
mvert = me->mvert;
@@ -277,8 +280,9 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra
for (i = 0; md && i <= cageIndex; i++, md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!editbmesh_modifier_is_enabled(scene, md, me != NULL))
+ if (!editbmesh_modifier_is_enabled(scene, md, me != NULL)) {
continue;
+ }
if (mti->type == eModifierTypeType_OnlyDeform && mti->deformMatricesEM) {
if (!defmats) {
@@ -293,18 +297,23 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra
deformedVerts = editbmesh_get_vertex_cos(em, &numVerts);
defmats = MEM_mallocN(sizeof(*defmats) * numVerts, "defmats");
- for (a = 0; a < numVerts; a++)
+ for (a = 0; a < numVerts; a++) {
unit_m3(defmats[a]);
+ }
}
mti->deformMatricesEM(md, &mectx, em, me, deformedVerts, defmats, numVerts);
}
- else
+ else {
break;
+ }
}
- for (; md && i <= cageIndex; md = md->next, i++)
- if (editbmesh_modifier_is_enabled(scene, md, me != NULL) && modifier_isCorrectableDeformed(md))
+ for (; md && i <= cageIndex; md = md->next, i++) {
+ if (editbmesh_modifier_is_enabled(scene, md, me != NULL) &&
+ modifier_isCorrectableDeformed(md)) {
numleft++;
+ }
+ }
if (me) {
BKE_id_free(NULL, me);
@@ -365,8 +374,9 @@ int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph,
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
continue;
+ }
if (mti->type == eModifierTypeType_OnlyDeform) {
if (!defmats) {
@@ -377,26 +387,30 @@ int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph,
deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats");
- for (a = 0; a < numVerts; a++)
+ for (a = 0; a < numVerts; a++) {
unit_m3(defmats[a]);
+ }
}
if (mti->deformMatrices) {
mti->deformMatrices(md, &mectx, me_eval, deformedVerts, defmats, numVerts);
}
- else
+ else {
break;
+ }
}
}
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
continue;
+ }
- if (mti->type == eModifierTypeType_OnlyDeform)
+ if (mti->type == eModifierTypeType_OnlyDeform) {
numleft++;
+ }
}
if (me_eval) {
@@ -436,14 +450,16 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph,
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
continue;
+ }
if (mti->type == eModifierTypeType_OnlyDeform) {
/* skip leading modifiers which have been already
* handled in sculpt_get_first_deform_matrices */
- if (mti->deformMatrices && !deformed)
+ if (mti->deformMatrices && !deformed) {
continue;
+ }
mti->deformVerts(md, &mectx, NULL, deformedVerts, mesh->totvert);
deformed = 1;
@@ -473,7 +489,8 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph,
*deformcos = BKE_mesh_vertexCos_get(mesh, &numVerts);
*deformmats = MEM_callocN(sizeof(*(*deformmats)) * numVerts, "defmats");
- for (a = 0; a < numVerts; a++)
+ for (a = 0; a < numVerts; a++) {
unit_m3((*deformmats)[a]);
+ }
}
}
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index f28e14be512..dc677449a4c 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -78,12 +78,15 @@ void BKE_curve_editfont_free(Curve *cu)
if (cu->editfont) {
EditFont *ef = cu->editfont;
- if (ef->textbuf)
+ if (ef->textbuf) {
MEM_freeN(ef->textbuf);
- if (ef->textbufinfo)
+ }
+ if (ef->textbufinfo) {
MEM_freeN(ef->textbufinfo);
- if (ef->selboxes)
+ }
+ if (ef->selboxes) {
MEM_freeN(ef->selboxes);
+ }
MEM_freeN(ef);
cu->editfont = NULL;
@@ -193,8 +196,10 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
}
/**
- * Only copy internal data of Curve ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Curve ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -281,8 +286,9 @@ void BKE_curve_curve_dimension_update(Curve *cu)
BKE_nurb_test_2d(nu);
/* since the handles are moved they need to be auto-located again */
- if (nu->type == CU_BEZIER)
+ if (nu->type == CU_BEZIER) {
BKE_nurb_handles_calc(nu);
+ }
}
}
}
@@ -291,8 +297,9 @@ void BKE_curve_type_test(Object *ob)
{
ob->type = BKE_curve_type_get(ob->data);
- if (ob->type == OB_CURVE)
+ if (ob->type == OB_CURVE) {
BKE_curve_curve_dimension_update((Curve *)ob->data);
+ }
}
void BKE_curve_boundbox_calc(Curve *cu, float r_loc[3], float r_size[3])
@@ -301,14 +308,17 @@ void BKE_curve_boundbox_calc(Curve *cu, float r_loc[3], float r_size[3])
float min[3], max[3];
float mloc[3], msize[3];
- if (cu->bb == NULL)
+ if (cu->bb == NULL) {
cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
+ }
bb = cu->bb;
- if (!r_loc)
+ if (!r_loc) {
r_loc = mloc;
- if (!r_size)
+ }
+ if (!r_size) {
r_size = msize;
+ }
INIT_MINMAX(min, max);
if (!BKE_curve_minmax(cu, true, min, max)) {
@@ -329,7 +339,8 @@ void BKE_curve_boundbox_calc(Curve *cu, float r_loc[3], float r_size[3])
BoundBox *BKE_curve_boundbox_get(Object *ob)
{
- /* This is Object-level data access, DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
+ /* This is Object-level data access,
+ * DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
if (ob->runtime.bb == NULL || ob->runtime.bb->flag & BOUNDBOX_DIRTY) {
Curve *cu = ob->data;
float min[3], max[3];
@@ -356,12 +367,15 @@ void BKE_curve_texspace_calc(Curve *cu)
if (cu->texflag & CU_AUTOSPACE) {
for (a = 0; a < 3; a++) {
- if (size[a] == 0.0f)
+ if (size[a] == 0.0f) {
size[a] = 1.0f;
- else if (size[a] > 0.0f && size[a] < 0.00001f)
+ }
+ else if (size[a] > 0.0f && size[a] < 0.00001f) {
size[a] = 0.00001f;
- else if (size[a] < 0.0f && size[a] > -0.00001f)
+ }
+ else if (size[a] < 0.0f && size[a] > -0.00001f) {
size[a] = -0.00001f;
+ }
}
copy_v3_v3(cu->loc, loc);
@@ -376,12 +390,15 @@ BoundBox *BKE_curve_texspace_get(Curve *cu, float r_loc[3], float r_rot[3], floa
BKE_curve_texspace_calc(cu);
}
- if (r_loc)
+ if (r_loc) {
copy_v3_v3(r_loc, cu->loc);
- if (r_rot)
+ }
+ if (r_rot) {
copy_v3_v3(r_rot, cu->rot);
- if (r_size)
+ }
+ if (r_size) {
copy_v3_v3(r_size, cu->size);
+ }
return cu->bb;
}
@@ -420,10 +437,12 @@ int BKE_nurbList_verts_count(ListBase *nurb)
nu = nurb->first;
while (nu) {
- if (nu->bezt)
+ if (nu->bezt) {
tot += 3 * nu->pntsu;
- else if (nu->bp)
+ }
+ else if (nu->bp) {
tot += nu->pntsu * nu->pntsv;
+ }
nu = nu->next;
}
@@ -437,10 +456,12 @@ int BKE_nurbList_verts_count_without_handles(ListBase *nurb)
nu = nurb->first;
while (nu) {
- if (nu->bezt)
+ if (nu->bezt) {
tot += nu->pntsu;
- else if (nu->bp)
+ }
+ else if (nu->bp) {
tot += nu->pntsu * nu->pntsv;
+ }
nu = nu->next;
}
@@ -452,20 +473,25 @@ int BKE_nurbList_verts_count_without_handles(ListBase *nurb)
void BKE_nurb_free(Nurb *nu)
{
- if (nu == NULL)
+ if (nu == NULL) {
return;
+ }
- if (nu->bezt)
+ if (nu->bezt) {
MEM_freeN(nu->bezt);
+ }
nu->bezt = NULL;
- if (nu->bp)
+ if (nu->bp) {
MEM_freeN(nu->bp);
+ }
nu->bp = NULL;
- if (nu->knotsu)
+ if (nu->knotsu) {
MEM_freeN(nu->knotsu);
+ }
nu->knotsu = NULL;
- if (nu->knotsv)
+ if (nu->knotsv) {
MEM_freeN(nu->knotsv);
+ }
nu->knotsv = NULL;
/* if (nu->trim.first) freeNurblist(&(nu->trim)); */
@@ -476,8 +502,9 @@ void BKE_nurbList_free(ListBase *lb)
{
Nurb *nu, *next;
- if (lb == NULL)
+ if (lb == NULL) {
return;
+ }
nu = lb->first;
while (nu) {
@@ -494,8 +521,9 @@ Nurb *BKE_nurb_duplicate(const Nurb *nu)
int len;
newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "duplicateNurb");
- if (newnu == NULL)
+ if (newnu == NULL) {
return NULL;
+ }
memcpy(newnu, nu, sizeof(Nurb));
if (nu->bezt) {
@@ -533,8 +561,9 @@ Nurb *BKE_nurb_copy(Nurb *src, int pntsu, int pntsv)
Nurb *newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "copyNurb");
memcpy(newnu, src, sizeof(Nurb));
- if (pntsu == 1)
+ if (pntsu == 1) {
SWAP(int, pntsu, pntsv);
+ }
newnu->pntsu = pntsu;
newnu->pntsv = pntsv;
@@ -573,8 +602,9 @@ void BKE_nurb_test_2d(Nurb *nu)
BPoint *bp;
int a;
- if ((nu->flag & CU_2D) == 0)
+ if ((nu->flag & CU_2D) == 0) {
return;
+ }
if (nu->type == CU_BEZIER) {
a = nu->pntsu;
@@ -1016,8 +1046,9 @@ static void calcknots(float *knots, const int pnts, const short order, const sho
k = 0.0;
for (a = 1; a <= pnts_order; a++) {
knots[a - 1] = k;
- if (a >= order && a <= pnts)
+ if (a >= order && a <= pnts) {
k += 1.0f;
+ }
}
break;
case CU_NURB_BEZIER:
@@ -1033,8 +1064,9 @@ static void calcknots(float *knots, const int pnts, const short order, const sho
else if (order == 3) {
k = 0.6f;
for (a = 0; a < pnts_order; a++) {
- if (a >= order && a <= pnts)
+ if (a >= order && a <= pnts) {
k += 0.5f;
+ }
knots[a] = floorf(k);
}
}
@@ -1055,8 +1087,9 @@ static void makecyclicknots(float *knots, int pnts, short order)
{
int a, b, order2, c;
- if (knots == NULL)
+ if (knots == NULL) {
return;
+ }
order2 = order - 1;
@@ -1064,11 +1097,13 @@ static void makecyclicknots(float *knots, int pnts, short order)
if (order > 2) {
b = pnts + order2;
for (a = 1; a < order2; a++) {
- if (knots[b] != knots[b - a])
+ if (knots[b] != knots[b - a]) {
break;
+ }
}
- if (a == order2)
+ if (a == order2) {
knots[pnts + order - 2] += 1.0f;
+ }
}
b = order;
@@ -1083,8 +1118,9 @@ static void makeknots(Nurb *nu, short uv)
{
if (nu->type == CU_NURBS) {
if (uv == 1) {
- if (nu->knotsu)
+ if (nu->knotsu) {
MEM_freeN(nu->knotsu);
+ }
if (BKE_nurb_check_valid_u(nu)) {
nu->knotsu = MEM_calloc_arrayN(KNOTSU(nu) + 1, sizeof(float), "makeknots");
if (nu->flagu & CU_NURB_CYCLIC) {
@@ -1095,12 +1131,14 @@ static void makeknots(Nurb *nu, short uv)
calcknots(nu->knotsu, nu->pntsu, nu->orderu, nu->flagu);
}
}
- else
+ else {
nu->knotsu = NULL;
+ }
}
else if (uv == 2) {
- if (nu->knotsv)
+ if (nu->knotsv) {
MEM_freeN(nu->knotsv);
+ }
if (BKE_nurb_check_valid_v(nu)) {
nu->knotsv = MEM_calloc_arrayN(KNOTSV(nu) + 1, sizeof(float), "makeknots");
if (nu->flagv & CU_NURB_CYCLIC) {
@@ -1138,10 +1176,12 @@ static void basisNurb(
opp2 = orderpluspnts - 1;
/* this is for float inaccuracy */
- if (t < knots[0])
+ if (t < knots[0]) {
t = knots[0];
- else if (t > knots[opp2])
+ }
+ else if (t > knots[opp2]) {
t = knots[opp2];
+ }
/* this part is order '1' */
o2 = order + 1;
@@ -1149,8 +1189,9 @@ static void basisNurb(
if (knots[i] != knots[i + 1] && t >= knots[i] && t <= knots[i + 1]) {
basis[i] = 1.0;
i1 = i - o2;
- if (i1 < 0)
+ if (i1 < 0) {
i1 = 0;
+ }
i2 = i;
i++;
while (i < opp2) {
@@ -1159,27 +1200,33 @@ static void basisNurb(
}
break;
}
- else
+ else {
basis[i] = 0.0;
+ }
}
basis[i] = 0.0;
/* this is order 2, 3, ... */
for (j = 2; j <= order; j++) {
- if (i2 + j >= orderpluspnts)
+ if (i2 + j >= orderpluspnts) {
i2 = opp2 - j;
+ }
for (i = i1; i <= i2; i++) {
- if (basis[i] != 0.0f)
+ if (basis[i] != 0.0f) {
d = ((t - knots[i]) * basis[i]) / (knots[i + j - 1] - knots[i]);
- else
+ }
+ else {
d = 0.0f;
+ }
- if (basis[i + 1] != 0.0f)
+ if (basis[i + 1] != 0.0f) {
e = ((knots[i + j] - t) * basis[i + 1]) / (knots[i + j] - knots[i + 1]);
- else
+ }
+ else {
e = 0.0;
+ }
basis[i] = d + e;
}
@@ -1191,8 +1238,9 @@ static void basisNurb(
for (i = i1; i <= i2; i++) {
if (basis[i] > 0.0f) {
*end = i;
- if (*start == 1000)
+ if (*start == 1000) {
*start = i;
+ }
}
}
}
@@ -1210,19 +1258,24 @@ void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int r
int totu = nu->pntsu * resolu, totv = nu->pntsv * resolv;
- if (nu->knotsu == NULL || nu->knotsv == NULL)
+ if (nu->knotsu == NULL || nu->knotsv == NULL) {
return;
- if (nu->orderu > nu->pntsu)
+ }
+ if (nu->orderu > nu->pntsu) {
return;
- if (nu->orderv > nu->pntsv)
+ }
+ if (nu->orderv > nu->pntsv) {
return;
- if (coord_array == NULL)
+ }
+ if (coord_array == NULL) {
return;
+ }
/* allocate and initialize */
len = totu * totv;
- if (len == 0)
+ if (len == 0) {
return;
+ }
sum = (float *)MEM_calloc_arrayN(len, sizeof(float), "makeNurbfaces1");
@@ -1239,10 +1292,12 @@ void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int r
fp = nu->knotsu;
ustart = fp[nu->orderu - 1];
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
uend = fp[nu->pntsu + nu->orderu - 1];
- else
+ }
+ else {
uend = fp[nu->pntsu];
+ }
ustep = (uend - ustart) / ((nu->flagu & CU_NURB_CYCLIC) ? totu : totu - 1);
basisu = (float *)MEM_malloc_arrayN(KNOTSU(nu), sizeof(float), "makeNurbfaces3");
@@ -1250,10 +1305,12 @@ void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int r
fp = nu->knotsv;
vstart = fp[nu->orderv - 1];
- if (nu->flagv & CU_NURB_CYCLIC)
+ if (nu->flagv & CU_NURB_CYCLIC) {
vend = fp[nu->pntsv + nu->orderv - 1];
- else
+ }
+ else {
vend = fp[nu->pntsv];
+ }
vstep = (vend - vstart) / ((nu->flagv & CU_NURB_CYCLIC) ? totv : totv - 1);
len = KNOTSV(nu);
@@ -1262,10 +1319,12 @@ void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int r
jend = (int *)MEM_malloc_arrayN(totv, sizeof(float), "makeNurbfaces5");
/* precalculation of basisv and jstart, jend */
- if (nu->flagv & CU_NURB_CYCLIC)
+ if (nu->flagv & CU_NURB_CYCLIC) {
cycl = nu->orderv - 1;
- else
+ }
+ else {
cycl = 0;
+ }
v = vstart;
basis = basisv;
curv = totv;
@@ -1275,10 +1334,12 @@ void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int r
v += vstep;
}
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
cycl = nu->orderu - 1;
- else
+ }
+ else {
cycl = 0;
+ }
in = coord_array;
u = ustart;
curu = totu;
@@ -1297,10 +1358,12 @@ void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int r
for (j = jsta; j <= jen; j++) {
- if (j >= nu->pntsv)
+ if (j >= nu->pntsv) {
jofs = (j - nu->pntsv);
- else
+ }
+ else {
jofs = j;
+ }
bp = nu->bp + nu->pntsu * jofs + istart - 1;
for (i = istart; i <= iend; i++, fp++) {
@@ -1308,15 +1371,17 @@ void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int r
iofs = i - nu->pntsu;
bp = nu->bp + nu->pntsu * jofs + iofs;
}
- else
+ else {
bp++;
+ }
if (ratcomp) {
*fp = basisu[i] * basis[j] * bp->vec[3];
sumdiv += *fp;
}
- else
+ else {
*fp = basisu[i] * basis[j];
+ }
}
}
@@ -1335,10 +1400,12 @@ void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int r
fp = sum;
for (j = jsta; j <= jen; j++) {
- if (j >= nu->pntsv)
+ if (j >= nu->pntsv) {
jofs = (j - nu->pntsv);
- else
+ }
+ else {
jofs = j;
+ }
bp = nu->bp + nu->pntsu * jofs + istart - 1;
for (i = istart; i <= iend; i++, fp++) {
@@ -1346,8 +1413,9 @@ void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int r
iofs = i - nu->pntsu;
bp = nu->bp + nu->pntsu * jofs + iofs;
}
- else
+ else {
bp++;
+ }
if (*fp != 0.0f) {
madd_v3_v3fl(in, bp->vec, *fp);
@@ -1393,17 +1461,21 @@ void BKE_nurb_makeCurve(const Nurb *nu,
*weight_fp = weight_array;
int i, len, istart, iend, cycl;
- if (nu->knotsu == NULL)
+ if (nu->knotsu == NULL) {
return;
- if (nu->orderu > nu->pntsu)
+ }
+ if (nu->orderu > nu->pntsu) {
return;
- if (coord_array == NULL)
+ }
+ if (coord_array == NULL) {
return;
+ }
/* allocate and initialize */
len = nu->pntsu;
- if (len == 0)
+ if (len == 0) {
return;
+ }
sum = (float *)MEM_calloc_arrayN(len, sizeof(float), "makeNurbcurve1");
resolu = (resolu * SEGMENTSU(nu));
@@ -1415,18 +1487,22 @@ void BKE_nurb_makeCurve(const Nurb *nu,
fp = nu->knotsu;
ustart = fp[nu->orderu - 1];
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
uend = fp[nu->pntsu + nu->orderu - 1];
- else
+ }
+ else {
uend = fp[nu->pntsu];
+ }
ustep = (uend - ustart) / (resolu - ((nu->flagu & CU_NURB_CYCLIC) ? 0 : 1));
basisu = (float *)MEM_malloc_arrayN(KNOTSU(nu), sizeof(float), "makeNurbcurve3");
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
cycl = nu->orderu - 1;
- else
+ }
+ else {
cycl = 0;
+ }
u = ustart;
while (resolu--) {
@@ -1437,10 +1513,12 @@ void BKE_nurb_makeCurve(const Nurb *nu,
fp = sum;
bp = nu->bp + istart - 1;
for (i = istart; i <= iend; i++, fp++) {
- if (i >= nu->pntsu)
+ if (i >= nu->pntsu) {
bp = nu->bp + (i - nu->pntsu);
- else
+ }
+ else {
bp++;
+ }
*fp = basisu[i] * bp->vec[3];
sumdiv += *fp;
@@ -1459,33 +1537,41 @@ void BKE_nurb_makeCurve(const Nurb *nu,
fp = sum;
bp = nu->bp + istart - 1;
for (i = istart; i <= iend; i++, fp++) {
- if (i >= nu->pntsu)
+ if (i >= nu->pntsu) {
bp = nu->bp + (i - nu->pntsu);
- else
+ }
+ else {
bp++;
+ }
if (*fp != 0.0f) {
madd_v3_v3fl(coord_fp, bp->vec, *fp);
- if (tilt_fp)
+ if (tilt_fp) {
(*tilt_fp) += (*fp) * bp->tilt;
+ }
- if (radius_fp)
+ if (radius_fp) {
(*radius_fp) += (*fp) * bp->radius;
+ }
- if (weight_fp)
+ if (weight_fp) {
(*weight_fp) += (*fp) * bp->weight;
+ }
}
}
coord_fp = POINTER_OFFSET(coord_fp, stride);
- if (tilt_fp)
+ if (tilt_fp) {
tilt_fp = POINTER_OFFSET(tilt_fp, stride);
- if (radius_fp)
+ }
+ if (radius_fp) {
radius_fp = POINTER_OFFSET(radius_fp, stride);
- if (weight_fp)
+ }
+ if (weight_fp) {
weight_fp = POINTER_OFFSET(weight_fp, stride);
+ }
u += ustep;
}
@@ -1681,12 +1767,15 @@ float *BKE_curve_surf_make_orco(Object *ob)
sizeu = nu->pntsu * resolu;
sizev = nu->pntsv * resolv;
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
sizeu++;
- if (nu->flagv & CU_NURB_CYCLIC)
+ }
+ if (nu->flagv & CU_NURB_CYCLIC) {
sizev++;
- if (nu->pntsv > 1)
+ }
+ if (nu->pntsv > 1) {
tot += sizeu * sizev;
+ }
nu = nu->next;
}
@@ -1702,24 +1791,30 @@ float *BKE_curve_surf_make_orco(Object *ob)
sizeu = nu->pntsu * resolu;
sizev = nu->pntsv * resolv;
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
sizeu++;
- if (nu->flagv & CU_NURB_CYCLIC)
+ }
+ if (nu->flagv & CU_NURB_CYCLIC) {
sizev++;
+ }
if (cu->flag & CU_UV_ORCO) {
for (b = 0; b < sizeu; b++) {
for (a = 0; a < sizev; a++) {
- if (sizev < 2)
+ if (sizev < 2) {
fp[0] = 0.0f;
- else
+ }
+ else {
fp[0] = -1.0f + 2.0f * ((float)a) / (sizev - 1);
+ }
- if (sizeu < 2)
+ if (sizeu < 2) {
fp[1] = 0.0f;
- else
+ }
+ else {
fp[1] = -1.0f + 2.0f * ((float)b) / (sizeu - 1);
+ }
fp[2] = 0.0;
@@ -1736,13 +1831,15 @@ float *BKE_curve_surf_make_orco(Object *ob)
for (b = 0; b < sizeu; b++) {
int use_b = b;
- if (b == sizeu - 1 && (nu->flagu & CU_NURB_CYCLIC))
+ if (b == sizeu - 1 && (nu->flagu & CU_NURB_CYCLIC)) {
use_b = false;
+ }
for (a = 0; a < sizev; a++) {
int use_a = a;
- if (a == sizev - 1 && (nu->flagv & CU_NURB_CYCLIC))
+ if (a == sizev - 1 && (nu->flagv & CU_NURB_CYCLIC)) {
use_a = false;
+ }
tdata = _tdata + 3 * (use_b * (nu->pntsv * resolv) + use_a);
@@ -1785,21 +1882,25 @@ float *BKE_curve_make_orco(Depsgraph *depsgraph, Scene *scene, Object *ob, int *
* (closed circle beveling)
*/
if (dl->flag & DL_CYCL_U) {
- if (dl->flag & DL_CYCL_V)
+ if (dl->flag & DL_CYCL_V) {
numVerts += (dl->parts + 1) * (dl->nr + 1);
- else
+ }
+ else {
numVerts += dl->parts * (dl->nr + 1);
+ }
}
else if (dl->flag & DL_CYCL_V) {
numVerts += (dl->parts + 1) * dl->nr;
}
- else
+ else {
numVerts += dl->parts * dl->nr;
+ }
}
}
- if (r_numVerts)
+ if (r_numVerts) {
*r_numVerts = numVerts;
+ }
fp = coord_array = MEM_malloc_arrayN(numVerts, 3 * sizeof(float), "cu_orco");
for (dl = disp.first; dl; dl = dl->next) {
@@ -1825,8 +1926,9 @@ float *BKE_curve_make_orco(Depsgraph *depsgraph, Scene *scene, Object *ob, int *
/* exception as handled in convertblender.c too */
if (dl->flag & DL_CYCL_U) {
sizeu++;
- if (dl->flag & DL_CYCL_V)
+ if (dl->flag & DL_CYCL_V) {
sizev++;
+ }
}
else if (dl->flag & DL_CYCL_V) {
sizev++;
@@ -1883,8 +1985,9 @@ void BKE_curve_bevel_make(Depsgraph *depsgraph,
// XXX if ( ob == obedit && ob->type == OB_FONT ) return;
if (cu->bevobj) {
- if (cu->bevobj->type != OB_CURVE)
+ if (cu->bevobj->type != OB_CURVE) {
return;
+ }
bevcu = cu->bevobj->data;
if (bevcu->ext1 == 0.0f && bevcu->ext2 == 0.0f) {
@@ -1927,8 +2030,9 @@ void BKE_curve_bevel_make(Depsgraph *depsgraph,
dl->parts * dl->nr, 3 * sizeof(float), "makebevelcurve1");
memcpy(dlnew->verts, dl->verts, 3 * sizeof(float) * dl->parts * dl->nr);
- if (dlnew->type == DL_SEGM)
+ if (dlnew->type == DL_SEGM) {
dlnew->flag |= (DL_FRONT_CURVE | DL_BACK_CURVE);
+ }
BLI_addtail(disp, dlnew);
fp = dlnew->verts;
@@ -2101,8 +2205,9 @@ static int cu_isectLL(const float v1[3],
float deler;
deler = (v1[cox] - v2[cox]) * (v3[coy] - v4[coy]) - (v3[cox] - v4[cox]) * (v1[coy] - v2[coy]);
- if (deler == 0.0f)
+ if (deler == 0.0f) {
return -1;
+ }
*lambda = (v1[coy] - v3[coy]) * (v3[cox] - v4[cox]) - (v1[cox] - v3[cox]) * (v3[coy] - v4[coy]);
*lambda = -(*lambda / deler);
@@ -2119,8 +2224,9 @@ static int cu_isectLL(const float v1[3],
vec[coy] = *lambda * (v2[coy] - v1[coy]) + v1[coy];
if (*lambda >= 0.0f && *lambda <= 1.0f && *mu >= 0.0f && *mu <= 1.0f) {
- if (*lambda == 0.0f || *lambda == 1.0f || *mu == 0.0f || *mu == 1.0f)
+ if (*lambda == 0.0f || *lambda == 1.0f || *mu == 0.0f || *mu == 1.0f) {
return 1;
+ }
return 2;
}
return 0;
@@ -2165,10 +2271,12 @@ static bool bevelinside(BevList *bl1, BevList *bl2)
* only allow for one situation: we choose lab= 1.0
*/
if (mode >= 0 && lab != 0.0f) {
- if (vec[0] < hvec1[0])
+ if (vec[0] < hvec1[0]) {
links++;
- else
+ }
+ else {
rechts++;
+ }
}
}
}
@@ -2189,10 +2297,12 @@ static int vergxcobev(const void *a1, const void *a2)
{
const struct BevelSort *x1 = a1, *x2 = a2;
- if (x1->left > x2->left)
+ if (x1->left > x2->left) {
return 1;
- else if (x1->left < x2->left)
+ }
+ else if (x1->left < x2->left) {
return -1;
+ }
return 0;
}
@@ -2205,10 +2315,12 @@ static void calc_bevel_sin_cos(
t01 = sqrtf(x1 * x1 + y1 * y1);
t02 = sqrtf(x2 * x2 + y2 * y2);
- if (t01 == 0.0f)
+ if (t01 == 0.0f) {
t01 = 1.0f;
- if (t02 == 0.0f)
+ }
+ if (t02 == 0.0f) {
t02 = 1.0f;
+ }
x1 /= t01;
y1 /= t01;
@@ -2216,14 +2328,17 @@ static void calc_bevel_sin_cos(
y2 /= t02;
t02 = x1 * x2 + y1 * y2;
- if (fabsf(t02) >= 1.0f)
+ if (fabsf(t02) >= 1.0f) {
t02 = M_PI_2;
- else
+ }
+ else {
t02 = (saacos(t02)) / 2.0f;
+ }
t02 = sinf(t02);
- if (t02 == 0.0f)
+ if (t02 == 0.0f) {
t02 = 1.0f;
+ }
x3 = x1 - x2;
y3 = y1 - y2;
@@ -2254,30 +2369,37 @@ static void tilt_bezpart(BezTriple *prevbezt,
float fac, dfac, t[4];
int a;
- if (tilt_array == NULL && radius_array == NULL)
+ if (tilt_array == NULL && radius_array == NULL) {
return;
+ }
last = nu->bezt + (nu->pntsu - 1);
/* returns a point */
if (prevbezt == nu->bezt) {
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
pprev = last;
- else
+ }
+ else {
pprev = prevbezt;
+ }
}
- else
+ else {
pprev = prevbezt - 1;
+ }
/* next point */
if (bezt == last) {
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
next = nu->bezt;
- else
+ }
+ else {
next = bezt;
+ }
}
- else
+ else {
next = bezt + 1;
+ }
fac = 0.0;
dfac = 1.0f / (float)resolu;
@@ -2381,8 +2503,9 @@ static void bevel_list_flip_tangents(BevList *bl)
nr = bl->nr;
while (nr--) {
- if (angle_normalized_v3v3(bevp0->tan, bevp1->tan) > DEG2RADF(90.0f))
+ if (angle_normalized_v3v3(bevp0->tan, bevp1->tan) > DEG2RADF(90.0f)) {
negate_v3(bevp1->tan);
+ }
bevp0 = bevp1;
bevp1 = bevp2;
@@ -2563,8 +2686,9 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
/* flip rotation if needs be */
cross_v3_v3v3(cross_tmp, vec_1, vec_2);
normalize_v3(cross_tmp);
- if (angle_normalized_v3v3(bevp_first->dir, cross_tmp) < DEG2RADF(90.0f))
+ if (angle_normalized_v3v3(bevp_first->dir, cross_tmp) < DEG2RADF(90.0f)) {
angle = -angle;
+ }
bevp2 = bl->bevpoints;
bevp1 = bevp2 + (bl->nr - 1);
@@ -2663,8 +2787,9 @@ static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode)
break;
}
- if (smooth_iter)
+ if (smooth_iter) {
bevel_list_smooth(bl, smooth_iter);
+ }
bevel_list_apply_tilt(bl);
}
@@ -2840,8 +2965,11 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
bev = &ob->runtime.curve_cache->bev;
+#if 0
/* do we need to calculate the radius for each point? */
- /* do_radius = (cu->bevobj || cu->taperobj || (cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ? 0 : 1; */
+ do_radius = (cu->bevobj || cu->taperobj || (cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ? 0 :
+ 1;
+#endif
/* STEP 1: MAKE POLYS */
@@ -2852,9 +2980,9 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
}
for (; nu; nu = nu->next) {
-
- if (nu->hide && is_editmode)
+ if (nu->hide && is_editmode) {
continue;
+ }
/* check if we will calculate tilt data */
do_tilt = CU_DO_TILT(cu, nu);
@@ -2874,10 +3002,12 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
else {
BevPoint *bevp;
- if (for_render && cu->resolu_ren != 0)
+ if (for_render && cu->resolu_ren != 0) {
resolu = cu->resolu_ren;
- else
+ }
+ else {
resolu = nu->resolu;
+ }
segcount = SEGMENTSU(nu);
@@ -2912,10 +3042,12 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
*seglen = len_v3v3(bevp->vec, bp->vec);
bevp++;
bevp->offset = *seglen;
- if (*seglen > treshold)
+ if (*seglen > treshold) {
*segbevcount = 1;
- else
+ }
+ else {
*segbevcount = 0;
+ }
seglen++;
segbevcount++;
}
@@ -2987,8 +3119,9 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
bevp->offset = *seglen;
seglen++;
/* match segbevcount to the cleaned up bevel lists (see STEP 2) */
- if (bevp->offset > treshold)
+ if (bevp->offset > treshold) {
*segbevcount = 1;
+ }
segbevcount++;
}
}
@@ -3029,14 +3162,17 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
/* indicate with handlecodes double points */
if (prevbezt->h1 == prevbezt->h2) {
- if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT)
+ if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) {
bevp->split_tag = true;
+ }
}
else {
- if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT)
+ if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) {
bevp->split_tag = true;
- else if (prevbezt->h2 == 0 || prevbezt->h2 == HD_VECT)
+ }
+ else if (prevbezt->h2 == 0 || prevbezt->h2 == HD_VECT) {
bevp->split_tag = true;
+ }
}
/* seglen */
@@ -3249,23 +3385,29 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
sd->left = min;
bevp = bl->bevpoints;
- if (bevp1 == bevp)
+ if (bevp1 == bevp) {
bevp0 = bevp + (bl->nr - 1);
- else
+ }
+ else {
bevp0 = bevp1 - 1;
+ }
bevp = bevp + (bl->nr - 1);
- if (bevp1 == bevp)
+ if (bevp1 == bevp) {
bevp2 = bl->bevpoints;
- else
+ }
+ else {
bevp2 = bevp1 + 1;
+ }
inp = ((bevp1->vec[0] - bevp0->vec[0]) * (bevp0->vec[1] - bevp2->vec[1]) +
(bevp0->vec[1] - bevp1->vec[1]) * (bevp0->vec[0] - bevp2->vec[0]));
- if (inp > 0.0f)
+ if (inp > 0.0f) {
sd->dir = 1;
- else
+ }
+ else {
sd->dir = 0;
+ }
sd++;
}
@@ -3404,10 +3546,12 @@ static void calchandleNurb_intern(BezTriple *bezt,
len_b = len_v3(dvec_b);
}
- if (len_a == 0.0f)
+ if (len_a == 0.0f) {
len_a = 1.0f;
- if (len_b == 0.0f)
+ }
+ if (len_b == 0.0f) {
len_b = 1.0f;
+ }
len_ratio = len_a / len_b;
@@ -3437,10 +3581,12 @@ static void calchandleNurb_intern(BezTriple *bezt,
bool leftviolate = false, rightviolate = false;
if (!is_fcurve || fcurve_smoothing == FCURVE_SMOOTH_NONE) {
- if (len_a > 5.0f * len_b)
+ if (len_a > 5.0f * len_b) {
len_a = 5.0f * len_b;
- if (len_b > 5.0f * len_a)
+ }
+ if (len_b > 5.0f * len_a) {
len_b = 5.0f * len_a;
+ }
}
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) {
@@ -3534,10 +3680,12 @@ static void calchandleNurb_intern(BezTriple *bezt,
len_a = len_v3v3(p2, p2_h1);
len_b = len_v3v3(p2, p2_h2);
- if (len_a == 0.0f)
+ if (len_a == 0.0f) {
len_a = 1.0f;
- if (len_b == 0.0f)
+ }
+ if (len_b == 0.0f) {
len_b = 1.0f;
+ }
len_ratio = len_a / len_b;
@@ -3587,30 +3735,37 @@ static void calchandlesNurb_intern(Nurb *nu, bool skip_align)
BezTriple *bezt, *prev, *next;
int a;
- if (nu->type != CU_BEZIER)
+ if (nu->type != CU_BEZIER) {
return;
- if (nu->pntsu < 2)
+ }
+ if (nu->pntsu < 2) {
return;
+ }
a = nu->pntsu;
bezt = nu->bezt;
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
prev = bezt + (a - 1);
- else
+ }
+ else {
prev = NULL;
+ }
next = bezt + 1;
while (a--) {
calchandleNurb_intern(bezt, prev, next, 0, skip_align, 0);
prev = bezt;
if (a == 1) {
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
next = nu->bezt;
- else
+ }
+ else {
next = NULL;
+ }
}
- else
+ else {
next++;
+ }
bezt++;
}
@@ -3638,8 +3793,9 @@ static void *allocate_arrays(int count, float ***floats, char ***chars, const ch
void *buffer = (float *)MEM_malloc_arrayN(count, (sizeof(float) * num_floats + num_chars), name);
- if (!buffer)
+ if (!buffer) {
return NULL;
+ }
float *fptr = buffer;
@@ -3697,8 +3853,9 @@ static bool tridiagonal_solve_with_limits(
char **flagarrays[] = {&is_locked, &num_unlocks, NULL};
void *tmps = allocate_arrays(solve_count, arrays, flagarrays, "tridiagonal_solve_with_limits");
- if (!tmps)
+ if (!tmps) {
return false;
+ }
memcpy(a0, a, sizeof(float) * solve_count);
memcpy(b0, b, sizeof(float) * solve_count);
@@ -3723,8 +3880,9 @@ static bool tridiagonal_solve_with_limits(
do {
for (int i = 0; i < solve_count; i++) {
- if (h[i] >= hmin[i] && h[i] <= hmax[i])
+ if (h[i] >= hmin[i] && h[i] <= hmax[i]) {
continue;
+ }
overshoot = true;
@@ -3743,12 +3901,14 @@ static bool tridiagonal_solve_with_limits(
all = true;
} while (overshoot && !locked);
- /* if no handles overshot and were locked, see if it may be a good idea to unlock some handles */
+ /* If no handles overshot and were locked,
+ * see if it may be a good idea to unlock some handles. */
if (!locked) {
for (int i = 0; i < solve_count; i++) {
// to definitely avoid infinite loops limit this to 2 times
- if (!is_locked[i] || num_unlocks[i] >= 2)
+ if (!is_locked[i] || num_unlocks[i] >= 2) {
continue;
+ }
/* if the handle wants to move in allowable direction, release it */
float relax = bezier_relax_direction(a0, b0, c0, d0, h, i, solve_count);
@@ -3768,6 +3928,8 @@ static bool tridiagonal_solve_with_limits(
return true;
}
+/* Keep ascii art. */
+/* clang-format off */
/*
* This function computes the handles of a series of auto bezier points
* on the basis of 'no acceleration discontinuities' at the points.
@@ -3795,30 +3957,31 @@ static bool tridiagonal_solve_with_limits(
* |-------t1---------t2--------- ~ --------tN-------------------> time (co 0)
* Mathematical basis:
*
- * 1. Handle lengths on either side of each point are connected by a factor
- * ensuring continuity of the first derivative:
+ * 1. Handle lengths on either side of each point are connected by a factor
+ * ensuring continuity of the first derivative:
*
- * l[i] = t[i+1]/t[i]
+ * l[i] = t[i+1]/t[i]
*
- * 2. The tridiagonal system is formed by the following equation, which is derived
- * by differentiating the bezier curve and specifies second derivative continuity
- * at every point:
+ * 2. The tridiagonal system is formed by the following equation, which is derived
+ * by differentiating the bezier curve and specifies second derivative continuity
+ * at every point:
*
- * l[i]^2 * h[i-1] + (2*l[i]+2) * h[i] + 1/l[i+1] * h[i+1] = (y[i]-y[i-1])*l[i]^2 + y[i+1]-y[i]
+ * l[i]^2 * h[i-1] + (2*l[i]+2) * h[i] + 1/l[i+1] * h[i+1] = (y[i]-y[i-1])*l[i]^2 + y[i+1]-y[i]
*
- * 3. If this point is adjacent to a manually set handle with X size not equal to 1/3
- * of the horizontal interval, this equation becomes slightly more complex:
+ * 3. If this point is adjacent to a manually set handle with X size not equal to 1/3
+ * of the horizontal interval, this equation becomes slightly more complex:
*
- * l[i]^2 * h[i-1] + (3*(1-R[i-1])*l[i] + 3*(1-L[i+1])) * h[i] + 1/l[i+1] * h[i+1] = (y[i]-y[i-1])*l[i]^2 + y[i+1]-y[i]
+ * l[i]^2 * h[i-1] + (3*(1-R[i-1])*l[i] + 3*(1-L[i+1])) * h[i] + 1/l[i+1] * h[i+1] = (y[i]-y[i-1])*l[i]^2 + y[i+1]-y[i]
*
- * The difference between equations amounts to this, and it's obvious that when R[i-1]
- * and L[i+1] are both 1/3, it becomes zero:
+ * The difference between equations amounts to this, and it's obvious that when R[i-1]
+ * and L[i+1] are both 1/3, it becomes zero:
*
- * ( (1-3*R[i-1])*l[i] + (1-3*L[i+1]) ) * h[i]
+ * ( (1-3*R[i-1])*l[i] + (1-3*L[i+1]) ) * h[i]
*
- * 4. The equations for zero acceleration border conditions are basically the above
- * equation with parts omitted, so the handle size correction also applies.
+ * 4. The equations for zero acceleration border conditions are basically the above
+ * equation with parts omitted, so the handle size correction also applies.
*/
+/* clang-format on */
static void bezier_eq_continuous(
float *a, float *b, float *c, float *d, float *dy, float *l, int i)
@@ -3852,16 +4015,20 @@ static void bezier_clamp(
float *hmax, float *hmin, int i, float dy, bool no_reverse, bool no_overshoot)
{
if (dy > 0) {
- if (no_overshoot)
+ if (no_overshoot) {
hmax[i] = min_ff(hmax[i], dy);
- if (no_reverse)
+ }
+ if (no_reverse) {
hmin[i] = 0.0f;
+ }
}
else if (dy < 0) {
- if (no_reverse)
+ if (no_reverse) {
hmax[i] = 0.0f;
- if (no_overshoot)
+ }
+ if (no_overshoot) {
hmin[i] = max_ff(hmin[i], dy);
+ }
}
else if (no_reverse || no_overshoot) {
hmax[i] = hmin[i] = 0.0f;
@@ -3878,8 +4045,9 @@ static void bezier_output_handle_inner(BezTriple *bezt, bool right, float newval
char hm = right ? bezt->h1 : bezt->h2;
/* only assign Auto/Vector handles */
- if (!ELEM(hr, HD_AUTO, HD_AUTO_ANIM, HD_VECT))
+ if (!ELEM(hr, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
return;
+ }
copy_v3_v3(bezt->vec[idx], newval);
@@ -3935,8 +4103,9 @@ static void bezier_handle_calc_smooth_fcurve(
/* verify index ranges */
- if (count < 2)
+ if (count < 2) {
return;
+ }
BLI_assert(start < total - 1 && count <= total);
BLI_assert(start + count <= total || cycle);
@@ -3958,8 +4127,9 @@ static void bezier_handle_calc_smooth_fcurve(
/* allocate all */
void *tmp_buffer = allocate_arrays(count, arrays, NULL, "bezier_calc_smooth_tmp");
- if (!tmp_buffer)
+ if (!tmp_buffer) {
return;
+ }
/* point locations */
@@ -3970,8 +4140,9 @@ static void bezier_handle_calc_smooth_fcurve(
dy[i] = bezt[j].vec[1][1] - bezt[j - 1].vec[1][1];
/* when cyclic, jump from last point to first */
- if (cycle && j == total - 1)
+ if (cycle && j == total - 1) {
j = 0;
+ }
}
/* ratio of x intervals */
@@ -4079,8 +4250,9 @@ static void bezier_handle_calc_smooth_fcurve(
bezier_output_handle(&bezt[j], false, -h[i] / l[i], end);
- if (end)
+ if (end) {
j = 0;
+ }
bezier_output_handle(&bezt[j], true, h[i], end);
}
@@ -4133,8 +4305,9 @@ void BKE_nurb_handle_smooth_fcurve(BezTriple *bezt, int total, bool cycle)
for (int i = 1, j = start + 1; i < total; i++, j++) {
/* in cyclic mode: jump from last to first point when necessary */
- if (j == total - 1 && cycle)
+ if (j == total - 1 && cycle) {
j = 0;
+ }
/* non auto handle closes the list (we come here at least for the last handle, see above) */
if (!is_free_auto_point(&bezt[j])) {
@@ -4228,12 +4401,15 @@ void BKE_nurb_bezt_handle_test(BezTriple *bezt, const bool use_handle)
#define SEL_F3 (1 << 2)
if (use_handle) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
flag |= SEL_F1;
- if (bezt->f2 & SELECT)
+ }
+ if (bezt->f2 & SELECT) {
flag |= SEL_F2;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
flag |= SEL_F3;
+ }
}
else {
flag = (bezt->f2 & SELECT) ? (SEL_F1 | SEL_F2 | SEL_F3) : 0;
@@ -4270,8 +4446,9 @@ void BKE_nurb_handles_test(Nurb *nu, const bool use_handle)
BezTriple *bezt;
int a;
- if (nu->type != CU_BEZIER)
+ if (nu->type != CU_BEZIER) {
return;
+ }
bezt = nu->bezt;
a = nu->pntsu;
@@ -4292,8 +4469,9 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag)
BezTriple *bezt2, *bezt1, *bezt0;
int i;
- if (nu == NULL || nu->bezt == NULL)
+ if (nu == NULL || nu->bezt == NULL) {
return;
+ }
bezt2 = nu->bezt;
bezt1 = bezt2 + (nu->pntsu - 1);
@@ -4318,8 +4496,9 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag)
bezt1->h1 = HD_ALIGN;
}
/* or vector handle? */
- if (dist_squared_to_line_v3(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < eps_sq)
+ if (dist_squared_to_line_v3(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < eps_sq) {
bezt1->h1 = HD_VECT;
+ }
}
}
/* right handle: */
@@ -4332,24 +4511,30 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag)
}
else {
/* aligned handle? */
- if (align)
+ if (align) {
bezt1->h2 = HD_ALIGN;
+ }
/* or vector handle? */
- if (dist_squared_to_line_v3(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < eps_sq)
+ if (dist_squared_to_line_v3(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < eps_sq) {
bezt1->h2 = HD_VECT;
+ }
}
}
- if (leftsmall && bezt1->h2 == HD_ALIGN)
+ if (leftsmall && bezt1->h2 == HD_ALIGN) {
bezt1->h2 = HD_FREE;
- if (rightsmall && bezt1->h1 == HD_ALIGN)
+ }
+ if (rightsmall && bezt1->h1 == HD_ALIGN) {
bezt1->h1 = HD_FREE;
+ }
/* undesired combination: */
- if (bezt1->h1 == HD_ALIGN && bezt1->h2 == HD_VECT)
+ if (bezt1->h1 == HD_ALIGN && bezt1->h2 == HD_VECT) {
bezt1->h1 = HD_FREE;
- if (bezt1->h2 == HD_ALIGN && bezt1->h1 == HD_VECT)
+ }
+ if (bezt1->h2 == HD_ALIGN && bezt1->h1 == HD_VECT) {
bezt1->h2 = HD_FREE;
+ }
bezt0 = bezt1;
bezt1 = bezt2;
@@ -4390,15 +4575,19 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
a = nu->pntsu;
while (a--) {
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = code;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = code;
+ }
if (bezt->h1 != bezt->h2) {
- if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO))
+ if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO)) {
bezt->h1 = HD_FREE;
- if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO))
+ }
+ if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO)) {
bezt->h2 = HD_FREE;
+ }
}
}
bezt++;
@@ -4443,10 +4632,12 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = h_new;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = h_new;
+ }
bezt++;
}
@@ -4554,8 +4745,9 @@ void BKE_nurb_direction_switch(Nurb *nu)
a = nu->pntsu;
bezt1 = nu->bezt;
bezt2 = bezt1 + (a - 1);
- if (a & 1)
+ if (a & 1) {
a += 1; /* if odd, also swap middle content */
+ }
a /= 2;
while (a > 0) {
if (bezt1 != bezt2) {
@@ -4790,44 +4982,54 @@ void BKE_curve_nurbs_keyVertexTilts_apply(ListBase *lb, float *key)
bool BKE_nurb_check_valid_u(struct Nurb *nu)
{
- if (nu->pntsu <= 1)
+ if (nu->pntsu <= 1) {
return false;
- if (nu->type != CU_NURBS)
+ }
+ if (nu->type != CU_NURBS) {
return true; /* not a nurb, lets assume its valid */
+ }
- if (nu->pntsu < nu->orderu)
+ if (nu->pntsu < nu->orderu) {
return false;
+ }
if (((nu->flagu & CU_NURB_CYCLIC) == 0) &&
(nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */
if (nu->orderu == 4) {
- if (nu->pntsu < 5)
+ if (nu->pntsu < 5) {
return false; /* bezier with 4 orderu needs 5 points */
+ }
}
else {
- if (nu->orderu != 3)
+ if (nu->orderu != 3) {
return false; /* order must be 3 or 4 */
+ }
}
}
return true;
}
bool BKE_nurb_check_valid_v(struct Nurb *nu)
{
- if (nu->pntsv <= 1)
+ if (nu->pntsv <= 1) {
return false;
- if (nu->type != CU_NURBS)
+ }
+ if (nu->type != CU_NURBS) {
return true; /* not a nurb, lets assume its valid */
+ }
- if (nu->pntsv < nu->orderv)
+ if (nu->pntsv < nu->orderv) {
return false;
+ }
if (((nu->flagv & CU_NURB_CYCLIC) == 0) &&
(nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */
if (nu->orderv == 4) {
- if (nu->pntsv < 5)
+ if (nu->pntsv < 5) {
return false; /* bezier with 4 orderu needs 5 points */
+ }
}
else {
- if (nu->orderv != 3)
+ if (nu->orderv != 3) {
return false; /* order must be 3 or 4 */
+ }
}
}
return true;
@@ -4835,10 +5037,12 @@ bool BKE_nurb_check_valid_v(struct Nurb *nu)
bool BKE_nurb_check_valid_uv(struct Nurb *nu)
{
- if (!BKE_nurb_check_valid_u(nu))
+ if (!BKE_nurb_check_valid_u(nu)) {
return false;
- if ((nu->pntsv > 1) && !BKE_nurb_check_valid_v(nu))
+ }
+ if ((nu->pntsv > 1) && !BKE_nurb_check_valid_v(nu)) {
return false;
+ }
return true;
}
@@ -4930,8 +5134,9 @@ bool BKE_nurb_type_convert(Nurb *nu, const short type, const bool use_handles)
copy_v3_v3(bp->vec, bezt->vec[1]);
bp->vec[3] = 1.0;
bp->f1 = bezt->f2;
- if (use_handles)
+ if (use_handles) {
nr -= 2;
+ }
bp->radius = bezt->radius;
bp->weight = bezt->weight;
bp++;
@@ -4967,11 +5172,13 @@ bool BKE_nurb_type_convert(Nurb *nu, const short type, const bool use_handles)
else if (nu->type == CU_NURBS) {
if (type == CU_POLY) {
nu->type = CU_POLY;
- if (nu->knotsu)
+ if (nu->knotsu) {
MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */
+ }
nu->knotsu = NULL;
- if (nu->knotsv)
+ if (nu->knotsv) {
MEM_freeN(nu->knotsv);
+ }
nu->knotsv = NULL;
}
else if (type == CU_BEZIER) { /* to Bezier */
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index eff85f411ca..22bc44a88d8 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -159,7 +159,8 @@ typedef struct LayerTypeInfo {
/** a function to determine file size */
size_t (*filesize)(CDataFile *cdf, const void *data, int count);
- /** a function to determine max allowed number of layers, should be NULL or return -1 if no limit */
+ /** a function to determine max allowed number of layers,
+ * should be NULL or return -1 if no limit */
int (*layers_max)(void);
} LayerTypeInfo;
@@ -179,8 +180,9 @@ static void layerCopy_mdeformvert(const void *source, void *dest, int count)
memcpy(dw, dvert->dw, dvert->totweight * sizeof(*dw));
dvert->dw = dw;
}
- else
+ else {
dvert->dw = NULL;
+ }
}
}
@@ -247,8 +249,9 @@ static void layerInterp_mdeformvert(const void **sources,
struct MDeformWeight_Link *node;
int i, j, totweight;
- if (count <= 0)
+ if (count <= 0) {
return;
+ }
/* build a list of unique def_nrs for dest */
totweight = 0;
@@ -260,8 +263,9 @@ static void layerInterp_mdeformvert(const void **sources,
MDeformWeight *dw = &source->dw[j];
float weight = dw->weight * interp_weight;
- if (weight == 0.0f)
+ if (weight == 0.0f) {
continue;
+ }
for (node = dest_dwlink; node; node = node->next) {
MDeformWeight *tmp_dw = &node->dw;
@@ -321,7 +325,8 @@ static void layerInterp_normal(const void **sources,
void *dest)
{
/* Note: This is linear interpolation, which is not optimal for vectors.
- * Unfortunately, spherical interpolation of more than two values is hairy, so for now it will do... */
+ * Unfortunately, spherical interpolation of more than two values is hairy,
+ * so for now it will do... */
float no[3] = {0.0f};
while (count--) {
@@ -399,8 +404,9 @@ static void layerCopy_tface(const void *source, void *dest, int count)
MTFace *dest_tf = (MTFace *)dest;
int i;
- for (i = 0; i < count; ++i)
+ for (i = 0; i < count; ++i) {
dest_tf[i] = source_tf[i];
+ }
}
static void layerInterp_tface(
@@ -411,8 +417,9 @@ static void layerInterp_tface(
float uv[4][2] = {{0.0f}};
const float *sub_weight;
- if (count <= 0)
+ if (count <= 0) {
return;
+ }
sub_weight = sub_weights;
for (i = 0; i < count; ++i) {
@@ -456,8 +463,9 @@ static void layerDefault_tface(void *data, int count)
MTFace *tf = (MTFace *)data;
int i;
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++) {
tf[i] = default_tf;
+ }
}
static int layerMaxNum_tface(void)
@@ -503,8 +511,9 @@ static void layerCopy_origspace_face(const void *source, void *dest, int count)
OrigSpaceFace *dest_tf = (OrigSpaceFace *)dest;
int i;
- for (i = 0; i < count; ++i)
+ for (i = 0; i < count; ++i) {
dest_tf[i] = source_tf[i];
+ }
}
static void layerInterp_origspace_face(
@@ -515,8 +524,9 @@ static void layerInterp_origspace_face(
float uv[4][2] = {{0.0f}};
const float *sub_weight;
- if (count <= 0)
+ if (count <= 0) {
return;
+ }
sub_weight = sub_weights;
for (i = 0; i < count; ++i) {
@@ -557,8 +567,9 @@ static void layerDefault_origspace_face(void *data, int count)
OrigSpaceFace *osf = (OrigSpaceFace *)data;
int i;
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++) {
osf[i] = default_osf;
+ }
}
static void layerSwap_mdisps(void *data, const int *ci)
@@ -584,8 +595,9 @@ static void layerSwap_mdisps(void *data, const int *ci)
d = MEM_calloc_arrayN(s->totdisp, 3 * sizeof(float), "mdisps swap");
- for (S = 0; S < corners; S++)
+ for (S = 0; S < corners; S++) {
memcpy(d + cornersize * S, s->disps + cornersize * ci[S], cornersize * 3 * sizeof(float));
+ }
MEM_freeN(s->disps);
s->disps = d;
@@ -620,10 +632,12 @@ static void layerFree_mdisps(void *data, int count, int UNUSED(size))
MDisps *d = data;
for (i = 0; i < count; ++i) {
- if (d[i].disps)
+ if (d[i].disps) {
MEM_freeN(d[i].disps);
- if (d[i].hidden)
+ }
+ if (d[i].hidden) {
MEM_freeN(d[i].hidden);
+ }
d[i].disps = NULL;
d[i].hidden = NULL;
d[i].totdisp = 0;
@@ -637,8 +651,9 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count)
int i;
for (i = 0; i < count; ++i) {
- if (!d[i].disps)
+ if (!d[i].disps) {
d[i].disps = MEM_calloc_arrayN(d[i].totdisp, 3 * sizeof(float), "mdisps read");
+ }
if (!cdf_read_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) {
CLOG_ERROR(&LOG, "failed to read multires displacement %d/%d %d", i, count, d[i].totdisp);
@@ -670,8 +685,9 @@ static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), const void *data, int
size_t size = 0;
int i;
- for (i = 0; i < count; ++i)
+ for (i = 0; i < count; ++i) {
size += d[i].totdisp * 3 * sizeof(float);
+ }
return size;
}
@@ -700,8 +716,9 @@ static void layerFree_grid_paint_mask(void *data, int count, int UNUSED(size))
GridPaintMask *gpm = data;
for (i = 0; i < count; ++i) {
- if (gpm[i].data)
+ if (gpm[i].data) {
MEM_freeN(gpm[i].data);
+ }
gpm[i].data = NULL;
gpm[i].level = 0;
}
@@ -803,23 +820,31 @@ static void layerDoMinMax_mloopcol(const void *data, void *vmin, void *vmax)
const MLoopCol *m = data;
MLoopCol *min = vmin, *max = vmax;
- if (m->r < min->r)
+ if (m->r < min->r) {
min->r = m->r;
- if (m->g < min->g)
+ }
+ if (m->g < min->g) {
min->g = m->g;
- if (m->b < min->b)
+ }
+ if (m->b < min->b) {
min->b = m->b;
- if (m->a < min->a)
+ }
+ if (m->a < min->a) {
min->a = m->a;
+ }
- if (m->r > max->r)
+ if (m->r > max->r) {
max->r = m->r;
- if (m->g > max->g)
+ }
+ if (m->g > max->g) {
max->g = m->g;
- if (m->b > max->b)
+ }
+ if (m->b > max->b) {
max->b = m->b;
- if (m->a > max->a)
+ }
+ if (m->a > max->a) {
max->a = m->a;
+ }
}
static void layerInitMinMax_mloopcol(void *vmin, void *vmax)
@@ -842,8 +867,9 @@ static void layerDefault_mloopcol(void *data, int count)
MLoopCol default_mloopcol = {255, 255, 255, 255};
MLoopCol *mlcol = (MLoopCol *)data;
int i;
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++) {
mlcol[i] = default_mloopcol;
+ }
}
static void layerInterp_mloopcol(
@@ -899,7 +925,8 @@ static void layerCopyValue_mloopuv(const void *source,
const MLoopUV *luv1 = source;
MLoopUV *luv2 = dest;
- /* We only support a limited subset of advanced mixing here - namely the mixfactor interpolation. */
+ /* We only support a limited subset of advanced mixing here -
+ * namely the mixfactor interpolation. */
if (mixmode == CDT_MIX_NOMIX) {
copy_v2_v2(luv2->uv, luv1->uv);
@@ -1093,8 +1120,9 @@ static void layerInterp_mcol(
const float *sub_weight;
- if (count <= 0)
+ if (count <= 0) {
return;
+ }
sub_weight = sub_weights;
for (i = 0; i < count; ++i) {
@@ -1139,8 +1167,9 @@ static void layerSwap_mcol(void *data, const int *corner_indices)
MCol col[4];
int j;
- for (j = 0; j < 4; ++j)
+ for (j = 0; j < 4; ++j) {
col[j] = mcol[corner_indices[j]];
+ }
memcpy(mcol, col, sizeof(col));
}
@@ -1171,8 +1200,9 @@ static void layerInterp_bweight(const void **sources,
float **in = (float **)sources;
int i;
- if (count <= 0)
+ if (count <= 0) {
return;
+ }
f = 0.0f;
@@ -1201,8 +1231,9 @@ static void layerInterp_shapekey(const void **sources,
float **in = (float **)sources;
int i;
- if (count <= 0)
+ if (count <= 0) {
return;
+ }
zero_v3(co);
@@ -1401,7 +1432,8 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 14: CD_ORCO */
{sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 15: CD_MTEXPOLY */ /* DEPRECATED */
- /* note, when we expose the UV Map / TexFace split to the user, change this back to face Texture */
+ /* note, when we expose the UV Map / TexFace split to the user,
+ * change this back to face Texture. */
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 16: CD_MLOOPUV */
{sizeof(MLoopUV),
@@ -1720,16 +1752,18 @@ const CustomData_MeshMasks CD_MASK_EVERYTHING = {
static const LayerTypeInfo *layerType_getInfo(int type)
{
- if (type < 0 || type >= CD_NUMTYPES)
+ if (type < 0 || type >= CD_NUMTYPES) {
return NULL;
+ }
return &LAYERTYPEINFO[type];
}
static const char *layerType_getName(int type)
{
- if (type < 0 || type >= CD_NUMTYPES)
+ if (type < 0 || type >= CD_NUMTYPES) {
return NULL;
+ }
return LAYERTYPENAMES[type];
}
@@ -1841,17 +1875,22 @@ bool CustomData_merge(const struct CustomData *source,
lastmask = layer->active_mask;
lasttype = type;
}
- else
+ else {
number++;
+ }
- if (flag & CD_FLAG_NOCOPY)
+ if (flag & CD_FLAG_NOCOPY) {
continue;
- else if (!(mask & CD_TYPE_AS_MASK(type)))
+ }
+ else if (!(mask & CD_TYPE_AS_MASK(type))) {
continue;
- else if ((maxnumber != -1) && (number >= maxnumber))
+ }
+ else if ((maxnumber != -1) && (number >= maxnumber)) {
continue;
- else if (CustomData_get_layer_named(dest, type, layer->name))
+ }
+ else if (CustomData_get_layer_named(dest, type, layer->name)) {
continue;
+ }
switch (alloctype) {
case CD_ASSIGN:
@@ -1911,8 +1950,9 @@ void CustomData_copy(const struct CustomData *source,
{
CustomData_reset(dest);
- if (source->external)
+ if (source->external) {
dest->external = MEM_dupallocN(source->external);
+ }
CustomData_merge(source, dest, mask, alloctype, totelem);
}
@@ -1924,11 +1964,13 @@ static void customData_free_layer__internal(CustomDataLayer *layer, int totelem)
if (!(layer->flag & CD_FLAG_NOFREE) && layer->data) {
typeInfo = layerType_getInfo(layer->type);
- if (typeInfo->free)
+ if (typeInfo->free) {
typeInfo->free(layer->data, totelem, typeInfo->size);
+ }
- if (layer->data)
+ if (layer->data) {
MEM_freeN(layer->data);
+ }
}
}
@@ -1950,11 +1992,13 @@ void CustomData_free(CustomData *data, int totelem)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
+ for (i = 0; i < data->totlayer; ++i) {
customData_free_layer__internal(&data->layers[i], totelem);
+ }
- if (data->layers)
+ if (data->layers) {
MEM_freeN(data->layers);
+ }
CustomData_external_free(data);
CustomData_reset(data);
@@ -1972,8 +2016,9 @@ void CustomData_free_typemask(struct CustomData *data, int totelem, CustomDataMa
customData_free_layer__internal(layer, totelem);
}
- if (data->layers)
+ if (data->layers) {
MEM_freeN(data->layers);
+ }
CustomData_external_free(data);
CustomData_reset(data);
@@ -2000,9 +2045,11 @@ static int CustomData_get_layer_index__notypemap(const CustomData *data, int typ
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
return i;
+ }
+ }
return -1;
}
@@ -2032,10 +2079,13 @@ int CustomData_get_named_layer_index(const CustomData *data, int type, const cha
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
- if (STREQ(data->layers[i].name, name))
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
+ if (STREQ(data->layers[i].name, name)) {
return i;
+ }
+ }
+ }
return -1;
}
@@ -2111,82 +2161,101 @@ void CustomData_set_layer_active(CustomData *data, int type, int n)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
data->layers[i].active = n;
+ }
+ }
}
void CustomData_set_layer_render(CustomData *data, int type, int n)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
data->layers[i].active_rnd = n;
+ }
+ }
}
void CustomData_set_layer_clone(CustomData *data, int type, int n)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
data->layers[i].active_clone = n;
+ }
+ }
}
void CustomData_set_layer_stencil(CustomData *data, int type, int n)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
data->layers[i].active_mask = n;
+ }
+ }
}
-/* for using with an index from CustomData_get_active_layer_index and CustomData_get_render_layer_index */
+/* For using with an index from CustomData_get_active_layer_index and
+ * CustomData_get_render_layer_index. */
void CustomData_set_layer_active_index(CustomData *data, int type, int n)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
data->layers[i].active = n - i;
+ }
+ }
}
void CustomData_set_layer_render_index(CustomData *data, int type, int n)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
data->layers[i].active_rnd = n - i;
+ }
+ }
}
void CustomData_set_layer_clone_index(CustomData *data, int type, int n)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
data->layers[i].active_clone = n - i;
+ }
+ }
}
void CustomData_set_layer_stencil_index(CustomData *data, int type, int n)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
data->layers[i].active_mask = n - i;
+ }
+ }
}
void CustomData_set_layer_flag(struct CustomData *data, int type, int flag)
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; ++i) {
+ if (data->layers[i].type == type) {
data->layers[i].flag |= flag;
+ }
+ }
}
void CustomData_clear_layer_flag(struct CustomData *data, int type, int flag)
@@ -2204,8 +2273,9 @@ static int customData_resize(CustomData *data, int amount)
{
CustomDataLayer *tmp = MEM_calloc_arrayN(
(data->maxlayer + amount), sizeof(*tmp), "CustomData->layers");
- if (!tmp)
+ if (!tmp) {
return 0;
+ }
data->maxlayer += amount;
if (data->layers) {
@@ -2233,8 +2303,9 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
BLI_assert(!layerdata || (alloctype == CD_ASSIGN) || (alloctype == CD_DUPLICATE) ||
(alloctype == CD_REFERENCE));
- if (!typeInfo->defaultname && CustomData_has_layer(data, type))
+ if (!typeInfo->defaultname && CustomData_has_layer(data, type)) {
return &data->layers[CustomData_get_layer_index(data, type)];
+ }
if ((alloctype == CD_ASSIGN) || (alloctype == CD_REFERENCE)) {
newlayerdata = layerdata;
@@ -2247,27 +2318,33 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
newlayerdata = MEM_calloc_arrayN((size_t)totelem, typeInfo->size, layerType_getName(type));
}
- if (!newlayerdata)
+ if (!newlayerdata) {
return NULL;
+ }
}
if (alloctype == CD_DUPLICATE && layerdata) {
- if (typeInfo->copy)
+ if (typeInfo->copy) {
typeInfo->copy(layerdata, newlayerdata, totelem);
- else
+ }
+ else {
memcpy(newlayerdata, layerdata, (size_t)totelem * typeInfo->size);
+ }
}
else if (alloctype == CD_DEFAULT) {
- if (typeInfo->set_default)
+ if (typeInfo->set_default) {
typeInfo->set_default(newlayerdata, totelem);
+ }
}
- else if (alloctype == CD_REFERENCE)
+ else if (alloctype == CD_REFERENCE) {
flag |= CD_FLAG_NOFREE;
+ }
if (index >= data->maxlayer) {
if (!customData_resize(data, CUSTOMDATA_GROW)) {
- if (newlayerdata != layerdata)
+ if (newlayerdata != layerdata) {
MEM_freeN(newlayerdata);
+ }
return NULL;
}
}
@@ -2275,8 +2352,9 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
data->totlayer++;
/* keep layers ordered by type */
- for (; index > 0 && data->layers[index - 1].type > type; --index)
+ for (; index > 0 && data->layers[index - 1].type > type; --index) {
data->layers[index] = data->layers[index - 1];
+ }
data->layers[index].type = type;
data->layers[index].flag = flag;
@@ -2293,8 +2371,9 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
BLI_strncpy(data->layers[index].name, name, sizeof(data->layers[index].name));
CustomData_set_layer_unique_name(data, index);
}
- else
+ else {
data->layers[index].name[0] = '\0';
+ }
if (index > 0 && data->layers[index - 1].type == type) {
data->layers[index].active = data->layers[index - 1].active;
@@ -2324,8 +2403,9 @@ void *CustomData_add_layer(
data, type, alloctype, layerdata, totelem, typeInfo->defaultname);
CustomData_update_typemap(data);
- if (layer)
+ if (layer) {
return layer->data;
+ }
return NULL;
}
@@ -2343,8 +2423,9 @@ void *CustomData_add_layer_named(CustomData *data,
layer = customData_add_layer__internal(data, type, alloctype, layerdata, totelem, name);
CustomData_update_typemap(data);
- if (layer)
+ if (layer) {
return layer->data;
+ }
return NULL;
}
@@ -2363,8 +2444,9 @@ bool CustomData_free_layer(CustomData *data, int type, int totelem, int index)
customData_free_layer__internal(&data->layers[index], totelem);
- for (i = index + 1; i < data->totlayer; ++i)
+ for (i = index + 1; i < data->totlayer; ++i) {
data->layers[i - 1] = data->layers[i];
+ }
data->totlayer--;
@@ -2377,19 +2459,24 @@ bool CustomData_free_layer(CustomData *data, int type, int totelem, int index)
CustomDataLayer *layer;
for (layer = &data->layers[i]; i < data->totlayer && layer->type == type; i++, layer++) {
- if (layer->active >= index_nonzero)
+ if (layer->active >= index_nonzero) {
layer->active--;
- if (layer->active_rnd >= index_nonzero)
+ }
+ if (layer->active_rnd >= index_nonzero) {
layer->active_rnd--;
- if (layer->active_clone >= index_nonzero)
+ }
+ if (layer->active_clone >= index_nonzero) {
layer->active_clone--;
- if (layer->active_mask >= index_nonzero)
+ }
+ if (layer->active_mask >= index_nonzero) {
layer->active_mask--;
+ }
}
}
- if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
+ if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW) {
customData_resize(data, -CUSTOMDATA_GROW);
+ }
customData_update_offsets(data);
@@ -2400,8 +2487,9 @@ bool CustomData_free_layer_active(CustomData *data, int type, int totelem)
{
int index = 0;
index = CustomData_get_active_layer_index(data, type);
- if (index == -1)
+ if (index == -1) {
return false;
+ }
return CustomData_free_layer(data, type, totelem, index);
}
@@ -2422,9 +2510,11 @@ int CustomData_number_of_layers(const CustomData *data, int type)
{
int i, number = 0;
- for (i = 0; i < data->totlayer; i++)
- if (data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; i++) {
+ if (data->layers[i].type == type) {
number++;
+ }
+ }
return number;
}
@@ -2433,9 +2523,11 @@ int CustomData_number_of_layers_typemask(const CustomData *data, CustomDataMask
{
int i, number = 0;
- for (i = 0; i < data->totlayer; i++)
- if (mask & CD_TYPE_AS_MASK(data->layers[i].type))
+ for (i = 0; i < data->totlayer; i++) {
+ if (mask & CD_TYPE_AS_MASK(data->layers[i].type)) {
number++;
+ }
+ }
return number;
}
@@ -2518,8 +2610,9 @@ bool CustomData_is_referenced_layer(struct CustomData *data, int type)
/* get the layer index of the first layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return false;
+ }
layer = &data->layers[layer_index];
@@ -2535,15 +2628,17 @@ void CustomData_free_temporary(CustomData *data, int totelem)
for (i = 0, j = 0; i < data->totlayer; ++i) {
layer = &data->layers[i];
- if (i != j)
+ if (i != j) {
data->layers[j] = data->layers[i];
+ }
if ((layer->flag & CD_FLAG_TEMPORARY) == CD_FLAG_TEMPORARY) {
customData_free_layer__internal(layer, totelem);
changed = true;
}
- else
+ else {
j++;
+ }
}
data->totlayer = j;
@@ -2562,19 +2657,23 @@ void CustomData_set_only_copy(const struct CustomData *data, CustomDataMask mask
{
int i;
- for (i = 0; i < data->totlayer; ++i)
- if (!(mask & CD_TYPE_AS_MASK(data->layers[i].type)))
+ for (i = 0; i < data->totlayer; ++i) {
+ if (!(mask & CD_TYPE_AS_MASK(data->layers[i].type))) {
data->layers[i].flag |= CD_FLAG_NOCOPY;
+ }
+ }
}
void CustomData_copy_elements(int type, void *src_data_ofs, void *dst_data_ofs, int count)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (typeInfo->copy)
+ if (typeInfo->copy) {
typeInfo->copy(src_data_ofs, dst_data_ofs, count);
- else
+ }
+ else {
memcpy(dst_data_ofs, src_data_ofs, (size_t)count * typeInfo->size);
+ }
}
static void CustomData_copy_data_layer(const CustomData *source,
@@ -2652,8 +2751,9 @@ void CustomData_copy_data(
}
/* if there are no more dest layers, we're done */
- if (dest_i >= dest->totlayer)
+ if (dest_i >= dest->totlayer) {
return;
+ }
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type) {
@@ -2728,15 +2828,17 @@ void CustomData_interp(const CustomData *source,
/* slow fallback in case we're interpolating a ridiculous number of
* elements
*/
- if (count > SOURCE_BUF_SIZE)
+ if (count > SOURCE_BUF_SIZE) {
sources = MEM_malloc_arrayN(count, sizeof(*sources), __func__);
+ }
/* interpolates a layer at a time */
dest_i = 0;
for (src_i = 0; src_i < source->totlayer; ++src_i) {
const LayerTypeInfo *typeInfo = layerType_getInfo(source->layers[src_i].type);
- if (!typeInfo->interp)
+ if (!typeInfo->interp) {
continue;
+ }
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
@@ -2746,8 +2848,9 @@ void CustomData_interp(const CustomData *source,
}
/* if there are no more dest layers, we're done */
- if (dest_i >= dest->totlayer)
+ if (dest_i >= dest->totlayer) {
break;
+ }
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type) {
@@ -2772,14 +2875,15 @@ void CustomData_interp(const CustomData *source,
}
}
- if (count > SOURCE_BUF_SIZE)
+ if (count > SOURCE_BUF_SIZE) {
MEM_freeN((void *)sources);
+ }
}
/**
* Swap data inside each item, for all layers.
- * This only applies to item types that may store several sub-item data (e.g. corner data [UVs, VCol, ...] of
- * tessellated faces).
+ * This only applies to item types that may store several sub-item data
+ * (e.g. corner data [UVs, VCol, ...] of tessellated faces).
*
* \param corner_indices: A mapping 'new_index -> old_index' of sub-item data.
*/
@@ -2838,8 +2942,9 @@ void *CustomData_get(const CustomData *data, int index, int type)
/* get the layer index of the active layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return NULL;
+ }
/* get the offset of the desired element */
const size_t offset = (size_t)index * layerType_getInfo(type)->size;
@@ -2855,8 +2960,9 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n)
/* get the layer index of the first layer of type */
layer_index = data->typemap[type];
- if (layer_index == -1)
+ if (layer_index == -1) {
return NULL;
+ }
const size_t offset = (size_t)index * layerType_getInfo(type)->size;
return POINTER_OFFSET(data->layers[layer_index + n].data, offset);
@@ -2866,8 +2972,9 @@ void *CustomData_get_layer(const CustomData *data, int type)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return NULL;
+ }
return data->layers[layer_index].data;
}
@@ -2876,8 +2983,9 @@ void *CustomData_get_layer_n(const CustomData *data, int type, int n)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if (layer_index == -1)
+ if (layer_index == -1) {
return NULL;
+ }
return data->layers[layer_index].data;
}
@@ -2885,8 +2993,9 @@ void *CustomData_get_layer_n(const CustomData *data, int type, int n)
void *CustomData_get_layer_named(const struct CustomData *data, int type, const char *name)
{
int layer_index = CustomData_get_named_layer_index(data, type, name);
- if (layer_index == -1)
+ if (layer_index == -1) {
return NULL;
+ }
return data->layers[layer_index].data;
}
@@ -2895,8 +3004,9 @@ int CustomData_get_offset(const CustomData *data, int type)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return -1;
+ }
return data->layers[layer_index].offset;
}
@@ -2905,8 +3015,9 @@ int CustomData_get_n_offset(const CustomData *data, int type, int n)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if (layer_index == -1)
+ if (layer_index == -1) {
return -1;
+ }
return data->layers[layer_index].offset;
}
@@ -2916,8 +3027,9 @@ bool CustomData_set_layer_name(const CustomData *data, int type, int n, const ch
/* get the layer index of the first layer of type */
const int layer_index = CustomData_get_layer_index_n(data, type, n);
- if ((layer_index == -1) || !name)
+ if ((layer_index == -1) || !name) {
return false;
+ }
BLI_strncpy(data->layers[layer_index].name, name, sizeof(data->layers[layer_index].name));
@@ -2936,8 +3048,9 @@ void *CustomData_set_layer(const CustomData *data, int type, void *ptr)
/* get the layer index of the first layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return NULL;
+ }
data->layers[layer_index].data = ptr;
@@ -2948,8 +3061,9 @@ void *CustomData_set_layer_n(const struct CustomData *data, int type, int n, voi
{
/* get the layer index of the first layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if (layer_index == -1)
+ if (layer_index == -1) {
return NULL;
+ }
data->layers[layer_index].data = ptr;
@@ -2961,13 +3075,16 @@ void CustomData_set(const CustomData *data, int index, int type, const void *sou
void *dest = CustomData_get(data, index, type);
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (!dest)
+ if (!dest) {
return;
+ }
- if (typeInfo->copy)
+ if (typeInfo->copy) {
typeInfo->copy(source, dest, 1);
- else
+ }
+ else {
memcpy(dest, source, typeInfo->size);
+ }
}
/* BMesh functions */
@@ -3042,18 +3159,24 @@ bool CustomData_from_bmeshpoly_test(CustomData *fdata, CustomData *ldata, bool f
((a_num += CustomData_number_of_layers(l_a, t_a)) == \
(b_num += CustomData_number_of_layers(l_b, t_b)))
- if (!LAYER_CMP(ldata, CD_MLOOPUV, fdata, CD_MTFACE))
+ if (!LAYER_CMP(ldata, CD_MLOOPUV, fdata, CD_MTFACE)) {
return false;
- if (!LAYER_CMP(ldata, CD_MLOOPCOL, fdata, CD_MCOL))
+ }
+ if (!LAYER_CMP(ldata, CD_MLOOPCOL, fdata, CD_MCOL)) {
return false;
- if (!LAYER_CMP(ldata, CD_PREVIEW_MLOOPCOL, fdata, CD_PREVIEW_MCOL))
+ }
+ if (!LAYER_CMP(ldata, CD_PREVIEW_MLOOPCOL, fdata, CD_PREVIEW_MCOL)) {
return false;
- if (!LAYER_CMP(ldata, CD_ORIGSPACE_MLOOP, fdata, CD_ORIGSPACE))
+ }
+ if (!LAYER_CMP(ldata, CD_ORIGSPACE_MLOOP, fdata, CD_ORIGSPACE)) {
return false;
- if (!LAYER_CMP(ldata, CD_NORMAL, fdata, CD_TESSLOOPNORMAL))
+ }
+ if (!LAYER_CMP(ldata, CD_NORMAL, fdata, CD_TESSLOOPNORMAL)) {
return false;
- if (!LAYER_CMP(ldata, CD_TANGENT, fdata, CD_TANGENT))
+ }
+ if (!LAYER_CMP(ldata, CD_TANGENT, fdata, CD_TANGENT)) {
return false;
+ }
# undef LAYER_CMP
@@ -3192,8 +3315,9 @@ bool CustomData_bmesh_merge(const CustomData *source,
}
if (CustomData_merge(source, dest, mask, alloctype, 0) == false) {
- if (destold.layers)
+ if (destold.layers) {
MEM_freeN(destold.layers);
+ }
return false;
}
@@ -3249,10 +3373,12 @@ bool CustomData_bmesh_merge(const CustomData *source,
}
}
- if (destold.pool)
+ if (destold.pool) {
BLI_mempool_destroy(destold.pool);
- if (destold.layers)
+ }
+ if (destold.layers) {
MEM_freeN(destold.layers);
+ }
return true;
}
@@ -3261,8 +3387,9 @@ void CustomData_bmesh_free_block(CustomData *data, void **block)
const LayerTypeInfo *typeInfo;
int i;
- if (*block == NULL)
+ if (*block == NULL) {
return;
+ }
for (i = 0; i < data->totlayer; ++i) {
if (!(data->layers[i].flag & CD_FLAG_NOFREE)) {
@@ -3275,8 +3402,9 @@ void CustomData_bmesh_free_block(CustomData *data, void **block)
}
}
- if (data->totsize)
+ if (data->totsize) {
BLI_mempool_free(data->pool, *block);
+ }
*block = NULL;
}
@@ -3289,8 +3417,9 @@ void CustomData_bmesh_free_block_data(CustomData *data, void *block)
const LayerTypeInfo *typeInfo;
int i;
- if (block == NULL)
+ if (block == NULL) {
return;
+ }
for (i = 0; i < data->totlayer; ++i) {
if (!(data->layers[i].flag & CD_FLAG_NOFREE)) {
@@ -3303,20 +3432,24 @@ void CustomData_bmesh_free_block_data(CustomData *data, void *block)
}
}
- if (data->totsize)
+ if (data->totsize) {
memset(block, 0, data->totsize);
+ }
}
static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
{
- if (*block)
+ if (*block) {
CustomData_bmesh_free_block(data, block);
+ }
- if (data->totsize > 0)
+ if (data->totsize > 0) {
*block = BLI_mempool_alloc(data->pool);
- else
+ }
+ else {
*block = NULL;
+ }
}
void CustomData_bmesh_copy_data(const CustomData *source,
@@ -3329,8 +3462,9 @@ void CustomData_bmesh_copy_data(const CustomData *source,
if (*dest_block == NULL) {
CustomData_bmesh_alloc_block(dest, dest_block);
- if (*dest_block)
+ if (*dest_block) {
memset(*dest_block, 0, dest->totsize);
+ }
}
/* copies a layer at a time */
@@ -3345,8 +3479,9 @@ void CustomData_bmesh_copy_data(const CustomData *source,
}
/* if there are no more dest layers, we're done */
- if (dest_i >= dest->totlayer)
+ if (dest_i >= dest->totlayer) {
return;
+ }
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type &&
@@ -3356,10 +3491,12 @@ void CustomData_bmesh_copy_data(const CustomData *source,
typeInfo = layerType_getInfo(source->layers[src_i].type);
- if (typeInfo->copy)
+ if (typeInfo->copy) {
typeInfo->copy(src_data, dest_data, 1);
- else
+ }
+ else {
memcpy(dest_data, src_data, typeInfo->size);
+ }
/* if there are multiple source & dest layers of the same type,
* we don't want to copy all source layers to the same dest, so
@@ -3370,15 +3507,18 @@ void CustomData_bmesh_copy_data(const CustomData *source,
}
}
-/*Bmesh Custom Data Functions. Should replace editmesh ones with these as well, due to more efficient memory alloc*/
+/* BMesh Custom Data Functions.
+ * Should replace edit-mesh ones with these as well, due to more efficient memory alloc.
+ */
void *CustomData_bmesh_get(const CustomData *data, void *block, int type)
{
int layer_index;
/* get the layer index of the first layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return NULL;
+ }
return POINTER_OFFSET(block, data->layers[layer_index].offset);
}
@@ -3389,8 +3529,9 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int
/* get the layer index of the first layer of type */
layer_index = CustomData_get_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return NULL;
+ }
return POINTER_OFFSET(block, data->layers[layer_index + n].offset);
}
@@ -3398,8 +3539,9 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int
/*gets from the layer at physical index n, note: doesn't check type.*/
void *CustomData_bmesh_get_layer_n(const CustomData *data, void *block, int n)
{
- if (n < 0 || n >= data->totlayer)
+ if (n < 0 || n >= data->totlayer) {
return NULL;
+ }
return POINTER_OFFSET(block, data->layers[n].offset);
}
@@ -3489,13 +3631,16 @@ void CustomData_data_copy_value(int type, const void *source, void *dest)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (!dest)
+ if (!dest) {
return;
+ }
- if (typeInfo->copyvalue)
+ if (typeInfo->copyvalue) {
typeInfo->copyvalue(source, dest, CDT_MIX_NOMIX, 0.0f);
- else
+ }
+ else {
memcpy(dest, source, typeInfo->size);
+ }
}
/* Mixes the "value" (e.g. mloopuv uv or mloopcol colors) from one block into
@@ -3505,8 +3650,9 @@ void CustomData_data_mix_value(
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (!dest)
+ if (!dest) {
return;
+ }
if (typeInfo->copyvalue) {
typeInfo->copyvalue(source, dest, mixmode, mixfactor);
@@ -3521,42 +3667,48 @@ bool CustomData_data_equals(int type, const void *data1, const void *data2)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (typeInfo->equal)
+ if (typeInfo->equal) {
return typeInfo->equal(data1, data2);
- else
+ }
+ else {
return !memcmp(data1, data2, typeInfo->size);
+ }
}
void CustomData_data_initminmax(int type, void *min, void *max)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (typeInfo->initminmax)
+ if (typeInfo->initminmax) {
typeInfo->initminmax(min, max);
+ }
}
void CustomData_data_dominmax(int type, const void *data, void *min, void *max)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (typeInfo->dominmax)
+ if (typeInfo->dominmax) {
typeInfo->dominmax(data, min, max);
+ }
}
void CustomData_data_multiply(int type, void *data, float fac)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (typeInfo->multiply)
+ if (typeInfo->multiply) {
typeInfo->multiply(data, fac);
+ }
}
void CustomData_data_add(int type, void *data1, const void *data2)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (typeInfo->add)
+ if (typeInfo->add) {
typeInfo->add(data1, data2);
+ }
}
void CustomData_bmesh_set(const CustomData *data, void *block, int type, const void *source)
@@ -3564,13 +3716,16 @@ void CustomData_bmesh_set(const CustomData *data, void *block, int type, const v
void *dest = CustomData_bmesh_get(data, block, type);
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (!dest)
+ if (!dest) {
return;
+ }
- if (typeInfo->copy)
+ if (typeInfo->copy) {
typeInfo->copy(source, dest, 1);
- else
+ }
+ else {
memcpy(dest, source, typeInfo->size);
+ }
}
void CustomData_bmesh_set_n(CustomData *data, void *block, int type, int n, const void *source)
@@ -3578,13 +3733,16 @@ void CustomData_bmesh_set_n(CustomData *data, void *block, int type, int n, cons
void *dest = CustomData_bmesh_get_n(data, block, type, n);
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if (!dest)
+ if (!dest) {
return;
+ }
- if (typeInfo->copy)
+ if (typeInfo->copy) {
typeInfo->copy(source, dest, 1);
- else
+ }
+ else {
memcpy(dest, source, typeInfo->size);
+ }
}
void CustomData_bmesh_set_layer_n(CustomData *data, void *block, int n, const void *source)
@@ -3592,13 +3750,16 @@ void CustomData_bmesh_set_layer_n(CustomData *data, void *block, int n, const vo
void *dest = CustomData_bmesh_get_layer_n(data, block, n);
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[n].type);
- if (!dest)
+ if (!dest) {
return;
+ }
- if (typeInfo->copy)
+ if (typeInfo->copy) {
typeInfo->copy(source, dest, 1);
- else
+ }
+ else {
memcpy(dest, source, typeInfo->size);
+ }
}
/**
@@ -3633,8 +3794,9 @@ void CustomData_bmesh_interp(CustomData *data,
/* slow fallback in case we're interpolating a ridiculous number of
* elements
*/
- if (count > SOURCE_BUF_SIZE)
+ if (count > SOURCE_BUF_SIZE) {
sources = MEM_malloc_arrayN(count, sizeof(*sources), __func__);
+ }
/* interpolates a layer at a time */
for (i = 0; i < data->totlayer; ++i) {
@@ -3649,8 +3811,9 @@ void CustomData_bmesh_interp(CustomData *data,
}
}
- if (count > SOURCE_BUF_SIZE)
+ if (count > SOURCE_BUF_SIZE) {
MEM_freeN((void *)sources);
+ }
}
static void CustomData_bmesh_set_default_n(CustomData *data, void **block, int n)
@@ -3672,8 +3835,9 @@ void CustomData_bmesh_set_default(CustomData *data, void **block)
{
int i;
- if (*block == NULL)
+ if (*block == NULL) {
CustomData_bmesh_alloc_block(data, block);
+ }
for (i = 0; i < data->totlayer; ++i) {
CustomData_bmesh_set_default_n(data, block, i);
@@ -3694,8 +3858,9 @@ void CustomData_to_bmesh_block(const CustomData *source,
const LayerTypeInfo *typeInfo;
int dest_i, src_i;
- if (*dest_block == NULL)
+ if (*dest_block == NULL) {
CustomData_bmesh_alloc_block(dest, dest_block);
+ }
/* copies a layer at a time */
dest_i = 0;
@@ -3712,8 +3877,9 @@ void CustomData_to_bmesh_block(const CustomData *source,
}
/* if there are no more dest layers, we're done */
- if (dest_i >= dest->totlayer)
+ if (dest_i >= dest->totlayer) {
break;
+ }
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type) {
@@ -3724,10 +3890,12 @@ void CustomData_to_bmesh_block(const CustomData *source,
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
const size_t src_offset = (size_t)src_index * typeInfo->size;
- if (typeInfo->copy)
+ if (typeInfo->copy) {
typeInfo->copy(POINTER_OFFSET(src_data, src_offset), dest_data, 1);
- else
+ }
+ else {
memcpy(dest_data, POINTER_OFFSET(src_data, src_offset), typeInfo->size);
+ }
/* if there are multiple source & dest layers of the same type,
* we don't want to copy all source layers to the same dest, so
@@ -3764,8 +3932,9 @@ void CustomData_from_bmesh_block(const CustomData *source,
}
/* if there are no more dest layers, we're done */
- if (dest_i >= dest->totlayer)
+ if (dest_i >= dest->totlayer) {
return;
+ }
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type) {
@@ -3775,10 +3944,12 @@ void CustomData_from_bmesh_block(const CustomData *source,
void *dst_data = POINTER_OFFSET(dest->layers[dest_i].data,
(size_t)dst_index * typeInfo->size);
- if (typeInfo->copy)
+ if (typeInfo->copy) {
typeInfo->copy(src_data, dst_data, 1);
- else
+ }
+ else {
memcpy(dst_data, src_data, typeInfo->size);
+ }
/* if there are multiple source & dest layers of the same type,
* we don't want to copy all source layers to the same dest, so
@@ -3801,15 +3972,20 @@ void CustomData_file_write_info(int type, const char **r_struct_name, int *r_str
* Prepare given custom data for file writing.
*
* \param data: the customdata to tweak for .blend file writing (modified in place).
- * \param r_write_layers: contains a reduced set of layers to be written to file, use it with writestruct_at_address()
- * (caller must free it if != \a write_layers_buff).
+ * \param r_write_layers: contains a reduced set of layers to be written to file,
+ * use it with writestruct_at_address()
+ * (caller must free it if != \a write_layers_buff).
+ *
* \param write_layers_buff: an optional buffer for r_write_layers (to avoid allocating it).
* \param write_layers_size: the size of pre-allocated \a write_layer_buff.
*
- * \warning After this func has ran, given custom data is no more valid from Blender PoV (its totlayer is invalid).
- * This func shall always be called with localized data (as it is in write_meshes()).
- * \note data->typemap is not updated here, since it is always rebuilt on file read anyway. This means written
- * typemap does not match written layers (as returned by \a r_write_layers). Trivial to fix is ever needed.
+ * \warning After this func has ran, given custom data is no more valid from Blender PoV
+ * (its totlayer is invalid). This func shall always be called with localized data
+ * (as it is in write_meshes()).
+ *
+ * \note data->typemap is not updated here, since it is always rebuilt on file read anyway.
+ * This means written typemap does not match written layers (as returned by \a r_write_layers).
+ * Trivial to fix is ever needed.
*/
void CustomData_file_write_prepare(CustomData *data,
CustomDataLayer **r_write_layers,
@@ -3892,8 +4068,9 @@ int CustomData_layertype_layers_max(const int type)
static bool CustomData_is_property_layer(int type)
{
- if ((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR))
+ if ((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR)) {
return true;
+ }
return false;
}
@@ -3967,8 +4144,9 @@ void CustomData_validate_layer_name(const CustomData *data,
int index = -1;
/* if a layer name was given, try to find that layer */
- if (name[0])
+ if (name[0]) {
index = CustomData_get_named_layer_index(data, type, name);
+ }
if (index == -1) {
/* either no layer was specified, or the layer we want has been
@@ -3998,9 +4176,11 @@ bool CustomData_verify_versions(struct CustomData *data, int index)
if (!typeInfo->defaultname && (index > 0) && data->layers[index - 1].type == layer->type) {
keeplayer = false; /* multiple layers of which we only support one */
}
- /* This is a pre-emptive fix for cases that should not happen (layers that should not be written
- * in .blend files), but can happen due to bugs (see e.g. T62318).
- * Also for forward compatibility, in future, we may put into .blend file some currently un-written data types,
+ /* This is a pre-emptive fix for cases that should not happen
+ * (layers that should not be written in .blend files),
+ * but can happen due to bugs (see e.g. T62318).
+ * Also for forward compatibility, in future,
+ * we may put into `.blend` file some currently un-written data types,
* this should cover that case as well.
* Better to be safe here, and fix issue on the fly rather than crash... */
/* 0 structnum is used in writing code to tag layer types that should not be written. */
@@ -4013,8 +4193,9 @@ bool CustomData_verify_versions(struct CustomData *data, int index)
}
if (!keeplayer) {
- for (i = index + 1; i < data->totlayer; ++i)
+ for (i = index + 1; i < data->totlayer; ++i) {
data->layers[i - 1] = data->layers[i];
+ }
data->totlayer--;
}
@@ -4022,7 +4203,8 @@ bool CustomData_verify_versions(struct CustomData *data, int index)
}
/**
- * Validate and fix data of \a layer, if possible (needs relevant callback in layer's type to be defined).
+ * Validate and fix data of \a layer,
+ * if possible (needs relevant callback in layer's type to be defined).
*
* \return True if some errors were found.
*/
@@ -4061,8 +4243,9 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask
/* pass */
}
else if ((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) {
- if (typeInfo->free)
+ if (typeInfo->free) {
typeInfo->free(layer->data, totelem, typeInfo->size);
+ }
layer->flag &= ~CD_FLAG_IN_MEMORY;
}
}
@@ -4078,8 +4261,9 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
const LayerTypeInfo *typeInfo;
int i, update = 0;
- if (!external)
+ if (!external) {
return;
+ }
for (i = 0; i < data->totlayer; i++) {
layer = &data->layers[i];
@@ -4096,8 +4280,9 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
}
}
- if (!update)
+ if (!update) {
return;
+ }
customdata_external_filename(filename, id, external);
@@ -4131,8 +4316,9 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
}
layer->flag |= CD_FLAG_IN_MEMORY;
}
- else
+ else {
break;
+ }
}
}
}
@@ -4152,8 +4338,9 @@ void CustomData_external_write(
int i, update = 0;
char filename[FILE_MAX];
- if (!external)
+ if (!external) {
return;
+ }
/* test if there is anything to write */
for (i = 0; i < data->totlayer; i++) {
@@ -4168,8 +4355,9 @@ void CustomData_external_write(
}
}
- if (!update)
+ if (!update) {
return;
+ }
/* make sure data is read before we try to write */
CustomData_external_read(data, id, mask, totelem);
@@ -4233,8 +4421,9 @@ void CustomData_external_write(
if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
if (free) {
- if (typeInfo->free)
+ if (typeInfo->free) {
typeInfo->free(layer->data, totelem, typeInfo->size);
+ }
layer->flag &= ~CD_FLAG_IN_MEMORY;
}
}
@@ -4252,13 +4441,15 @@ void CustomData_external_add(
int layer_index;
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return;
+ }
layer = &data->layers[layer_index];
- if (layer->flag & CD_FLAG_EXTERNAL)
+ if (layer->flag & CD_FLAG_EXTERNAL) {
return;
+ }
if (!external) {
external = MEM_callocN(sizeof(CustomDataExternal), "CustomDataExternal");
@@ -4273,21 +4464,24 @@ void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
{
CustomDataExternal *external = data->external;
CustomDataLayer *layer;
- //char filename[FILE_MAX];
+ // char filename[FILE_MAX];
int layer_index; // i, remove_file;
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return;
+ }
layer = &data->layers[layer_index];
- if (!external)
+ if (!external) {
return;
+ }
if (layer->flag & CD_FLAG_EXTERNAL) {
- if (!(layer->flag & CD_FLAG_IN_MEMORY))
+ if (!(layer->flag & CD_FLAG_IN_MEMORY)) {
CustomData_external_read(data, id, CD_TYPE_AS_MASK(layer->type), totelem);
+ }
layer->flag &= ~CD_FLAG_EXTERNAL;
}
@@ -4299,8 +4493,9 @@ bool CustomData_external_test(CustomData *data, int type)
int layer_index;
layer_index = CustomData_get_active_layer_index(data, type);
- if (layer_index == -1)
+ if (layer_index == -1) {
return false;
+ }
layer = &data->layers[layer_index];
return (layer->flag & CD_FLAG_EXTERNAL) != 0;
@@ -4331,7 +4526,7 @@ static void copy_bit_flag(void *dst, const void *src, const size_t data_size, co
COPY_BIT_FLAG(uint64_t, dst, src, flag);
break;
default:
- //CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
+ // CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
break;
}
@@ -4350,7 +4545,7 @@ static bool check_bit_flag(const void *data, const size_t data_size, const uint6
case 8:
return ((*((uint64_t *)data) & ((uint64_t)flag)) != 0);
default:
- //CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
+ // CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
return false;
}
}
@@ -4363,9 +4558,9 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye
const float mix_factor)
{
/* Fake interpolation, we actually copy highest weighted source to dest.
- * Note we also handle bitflags here, in which case we rather choose to transfer value of elements totaling
+ * Note we also handle bitflags here,
+ * in which case we rather choose to transfer value of elements totaling
* more than 0.5 of weight. */
-
int best_src_idx = 0;
const int data_type = laymap->data_type;
@@ -4401,7 +4596,8 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye
int i;
if (data_flag) {
- /* Boolean case, we can 'interpolate' in two groups, and choose value from highest weighted group. */
+ /* Boolean case, we can 'interpolate' in two groups,
+ * and choose value from highest weighted group. */
float tot_weight_true = 0.0f;
int item_true_idx = -1, item_false_idx = -1;
@@ -4446,7 +4642,8 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye
}
if (data_flag) {
- /* Bool flags, only copy if dest data is set (resp. unset) - only 'advanced' modes we can support here! */
+ /* Bool flags, only copy if dest data is set (resp. unset) -
+ * only 'advanced' modes we can support here! */
if (mix_factor >= 0.5f && ((mix_mode == CDT_MIX_TRANSFER) ||
(mix_mode == CDT_MIX_REPLACE_ABOVE_THRESHOLD &&
check_bit_flag(data_dst, data_size, data_flag)) ||
diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c
index 6e7d4d856d7..379da377b42 100644
--- a/source/blender/blenkernel/intern/customdata_file.c
+++ b/source/blender/blenkernel/intern/customdata_file.c
@@ -98,10 +98,12 @@ struct CDataFile {
static int cdf_endian(void)
{
- if (ENDIAN_ORDER == L_ENDIAN)
+ if (ENDIAN_ORDER == L_ENDIAN) {
return CDF_ENDIAN_LITTLE;
- else
+ }
+ else {
return CDF_ENDIAN_BIG;
+ }
}
CDataFile *cdf_create(int type)
@@ -118,8 +120,9 @@ void cdf_free(CDataFile *cdf)
cdf_read_close(cdf);
cdf_write_close(cdf);
- if (cdf->layer)
+ if (cdf->layer) {
MEM_freeN(cdf->layer);
+ }
MEM_freeN(cdf);
}
@@ -138,13 +141,16 @@ static int cdf_read_header(CDataFile *cdf)
header = &cdf->header;
- if (!fread(header, sizeof(CDataFileHeader), 1, cdf->readf))
+ if (!fread(header, sizeof(CDataFileHeader), 1, cdf->readf)) {
return 0;
+ }
- if (memcmp(header->ID, "BCDF", sizeof(header->ID)) != 0)
+ if (memcmp(header->ID, "BCDF", sizeof(header->ID)) != 0) {
return 0;
- if (header->version > CDF_VERSION)
+ }
+ if (header->version > CDF_VERSION) {
return 0;
+ }
cdf->switchendian = header->endian != cdf_endian();
header->endian = cdf_endian();
@@ -155,19 +161,22 @@ static int cdf_read_header(CDataFile *cdf)
BLI_endian_switch_int32(&header->structbytes);
}
- if (!ELEM(header->type, CDF_TYPE_IMAGE, CDF_TYPE_MESH))
+ if (!ELEM(header->type, CDF_TYPE_IMAGE, CDF_TYPE_MESH)) {
return 0;
+ }
offset += header->structbytes;
header->structbytes = sizeof(CDataFileHeader);
- if (fseek(f, offset, SEEK_SET) != 0)
+ if (fseek(f, offset, SEEK_SET) != 0) {
return 0;
+ }
if (header->type == CDF_TYPE_IMAGE) {
image = &cdf->btype.image;
- if (!fread(image, sizeof(CDataFileImageHeader), 1, f))
+ if (!fread(image, sizeof(CDataFileImageHeader), 1, f)) {
return 0;
+ }
if (cdf->switchendian) {
BLI_endian_switch_int32(&image->width);
@@ -181,18 +190,21 @@ static int cdf_read_header(CDataFile *cdf)
}
else if (header->type == CDF_TYPE_MESH) {
mesh = &cdf->btype.mesh;
- if (!fread(mesh, sizeof(CDataFileMeshHeader), 1, f))
+ if (!fread(mesh, sizeof(CDataFileMeshHeader), 1, f)) {
return 0;
+ }
- if (cdf->switchendian)
+ if (cdf->switchendian) {
BLI_endian_switch_int32(&mesh->structbytes);
+ }
offset += mesh->structbytes;
mesh->structbytes = sizeof(CDataFileMeshHeader);
}
- if (fseek(f, offset, SEEK_SET) != 0)
+ if (fseek(f, offset, SEEK_SET) != 0) {
return 0;
+ }
cdf->layer = MEM_calloc_arrayN(header->totlayer, sizeof(CDataFileLayer), "CDataFileLayer");
cdf->totlayer = header->totlayer;
@@ -204,8 +216,9 @@ static int cdf_read_header(CDataFile *cdf)
for (a = 0; a < header->totlayer; a++) {
layer = &cdf->layer[a];
- if (!fread(layer, sizeof(CDataFileLayer), 1, f))
+ if (!fread(layer, sizeof(CDataFileLayer), 1, f)) {
return 0;
+ }
if (cdf->switchendian) {
BLI_endian_switch_int32(&layer->type);
@@ -214,14 +227,16 @@ static int cdf_read_header(CDataFile *cdf)
BLI_endian_switch_int32(&layer->structbytes);
}
- if (layer->datatype != CDF_DATA_FLOAT)
+ if (layer->datatype != CDF_DATA_FLOAT) {
return 0;
+ }
offset += layer->structbytes;
layer->structbytes = sizeof(CDataFileLayer);
- if (fseek(f, offset, SEEK_SET) != 0)
+ if (fseek(f, offset, SEEK_SET) != 0) {
return 0;
+ }
}
cdf->dataoffset = offset;
@@ -240,25 +255,29 @@ static int cdf_write_header(CDataFile *cdf)
header = &cdf->header;
- if (!fwrite(header, sizeof(CDataFileHeader), 1, f))
+ if (!fwrite(header, sizeof(CDataFileHeader), 1, f)) {
return 0;
+ }
if (header->type == CDF_TYPE_IMAGE) {
image = &cdf->btype.image;
- if (!fwrite(image, sizeof(CDataFileImageHeader), 1, f))
+ if (!fwrite(image, sizeof(CDataFileImageHeader), 1, f)) {
return 0;
+ }
}
else if (header->type == CDF_TYPE_MESH) {
mesh = &cdf->btype.mesh;
- if (!fwrite(mesh, sizeof(CDataFileMeshHeader), 1, f))
+ if (!fwrite(mesh, sizeof(CDataFileMeshHeader), 1, f)) {
return 0;
+ }
}
for (a = 0; a < header->totlayer; a++) {
layer = &cdf->layer[a];
- if (!fwrite(layer, sizeof(CDataFileLayer), 1, f))
+ if (!fwrite(layer, sizeof(CDataFileLayer), 1, f)) {
return 0;
+ }
}
return 1;
@@ -269,8 +288,9 @@ bool cdf_read_open(CDataFile *cdf, const char *filename)
FILE *f;
f = BLI_fopen(filename, "rb");
- if (!f)
+ if (!f) {
return 0;
+ }
cdf->readf = f;
@@ -295,10 +315,12 @@ bool cdf_read_layer(CDataFile *cdf, CDataFileLayer *blay)
/* seek to right location in file */
offset = cdf->dataoffset;
for (a = 0; a < cdf->totlayer; a++) {
- if (&cdf->layer[a] == blay)
+ if (&cdf->layer[a] == blay) {
break;
- else
+ }
+ else {
offset += cdf->layer[a].datasize;
+ }
}
return (fseek(cdf->readf, offset, SEEK_SET) == 0);
@@ -307,8 +329,9 @@ bool cdf_read_layer(CDataFile *cdf, CDataFileLayer *blay)
bool cdf_read_data(CDataFile *cdf, unsigned int size, void *data)
{
/* read data */
- if (!fread(data, size, 1, cdf->readf))
+ if (!fread(data, size, 1, cdf->readf)) {
return 0;
+ }
/* switch endian if necessary */
if (cdf->switchendian) {
@@ -334,8 +357,9 @@ bool cdf_write_open(CDataFile *cdf, const char *filename)
FILE *f;
f = BLI_fopen(filename, "wb");
- if (!f)
+ if (!f) {
return 0;
+ }
cdf->writef = f;
@@ -379,8 +403,9 @@ bool cdf_write_layer(CDataFile *UNUSED(cdf), CDataFileLayer *UNUSED(blay))
bool cdf_write_data(CDataFile *cdf, unsigned int size, void *data)
{
/* write data */
- if (!fwrite(data, size, 1, cdf->writef))
+ if (!fwrite(data, size, 1, cdf->writef)) {
return 0;
+ }
return 1;
}
@@ -408,8 +433,9 @@ CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, const char *name)
for (a = 0; a < cdf->totlayer; a++) {
layer = &cdf->layer[a];
- if (layer->type == type && STREQ(layer->name, name))
+ if (layer->type == type && STREQ(layer->name, name)) {
return layer;
+ }
}
return NULL;
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 41e8cfe188d..5d9ba1bcdc7 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -90,7 +90,8 @@ void BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types,
}
}
-/* Check what can do each layer type (if it is actually handled by transferdata, if it supports advanced mixing... */
+/* Check what can do each layer type
+ * (if it is actually handled by transferdata, if it supports advanced mixing... */
bool BKE_object_data_transfer_get_dttypes_capacity(const int dtdata_types,
bool *r_advanced_mixing,
bool *r_threshold)
@@ -340,6 +341,10 @@ static void data_transfer_dtdata_type_postprocess(Object *UNUSED(ob_src),
const bool changed)
{
if (dtdata_type == DT_TYPE_LNOR) {
+ if (!changed) {
+ return;
+ }
+
/* Bake edited destination loop normals into custom normals again. */
MVert *verts_dst = me_dst->mvert;
const int num_verts_dst = me_dst->totvert;
@@ -358,10 +363,6 @@ static void data_transfer_dtdata_type_postprocess(Object *UNUSED(ob_src),
BLI_assert(poly_nors_dst);
- if (!changed) {
- return;
- }
-
if (!custom_nors_dst) {
custom_nors_dst = CustomData_add_layer(
ldata_dst, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, num_loops_dst);
@@ -458,7 +459,8 @@ static void data_transfer_interp_char(const CustomDataTransferLayerMap *laymap,
*data_dst = (char)(val_src * 255.0f);
}
-/* Helpers to match sources and destinations data layers (also handles 'conversions' in CD_FAKE cases). */
+/* Helpers to match sources and destinations data layers
+ * (also handles 'conversions' in CD_FAKE cases). */
void data_transfer_layersmapping_add_item(ListBase *r_map,
const int cddata_type,
@@ -537,12 +539,13 @@ static void data_transfer_layersmapping_add_item_cd(ListBase *r_map,
interp_data);
}
-/* Note: All those layer mapping handlers return false *only* if they were given invalid parameters.
- * This means that even if they do nothing, they will return true if all given parameters were OK.
- * Also, r_map may be NULL, in which case they will 'only' create/delete destination layers according
- * to given parameters.
+/**
+ * \note
+ * All those layer mapping handlers return false *only* if they were given invalid parameters.
+ * This means that even if they do nothing, they will return true if all given parameters were OK.
+ * Also, r_map may be NULL, in which case they will 'only' create/delete destination layers
+ * according to given parameters.
*/
-
static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map,
const int cddata_type,
const int mix_mode,
@@ -581,8 +584,9 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
idx_dst = tot_dst;
/* Find last source actually used! */
- while (idx_src-- && !use_layers_src[idx_src])
+ while (idx_src-- && !use_layers_src[idx_src]) {
;
+ }
idx_src++;
if (idx_dst < idx_src) {
@@ -608,7 +612,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
continue;
}
data_src = CustomData_get_layer_n(cd_src, cddata_type, idx_src);
- /* If dest is a evaluated mesh (fro; ;odifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_src, num_elem_dst);
@@ -653,7 +658,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
else {
- /* If we are not allowed to create missing dst data layers, just skip matching src one. */
+ /* If we are not allowed to create missing dst data layers,
+ * just skip matching src one. */
continue;
}
}
@@ -661,7 +667,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
data_dst_to_delete[idx_dst] = false;
}
if (r_map) {
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -682,9 +689,10 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
}
if (data_dst_to_delete) {
- /* Note: This won't affect newly created layers, if any, since tot_dst has not been updated!
- * Also, looping backward ensures us we do not suffer from index shifting when deleting a layer.
- */
+ /* Note:
+ * This won't affect newly created layers, if any, since tot_dst has not been updated!
+ * Also, looping backward ensures us we do not suffer
+ * from index shifting when deleting a layer. */
for (idx_dst = tot_dst; idx_dst--;) {
if (data_dst_to_delete[idx_dst]) {
CustomData_free_layer(cd_dst, cddata_type, num_elem_dst, idx_dst);
@@ -736,7 +744,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
}
else if (use_dupref_dst && r_map) {
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
data_dst = CustomData_duplicate_referenced_layer(cd_dst, cddata_type, num_elem_dst);
}
@@ -770,7 +779,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
if (tolayers >= 0) { /* Real-layer index */
idx_dst = tolayers;
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst && r_map) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -787,7 +797,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
}
else {
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst && r_map) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -809,7 +820,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
}
}
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst && r_map) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -827,7 +839,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
CustomData_add_layer_named(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst, name);
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
- /* If dest is a evaluated mesh (from modifier), we do not want to overwrite cdlayers of orig mesh! */
+ /* If dest is a evaluated mesh (from modifier),
+ * we do not want to overwrite cdlayers of orig mesh! */
if (use_dupref_dst && r_map) {
data_dst = CustomData_duplicate_referenced_layer_n(
cd_dst, cddata_type, idx_dst, num_elem_dst);
@@ -1001,7 +1014,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
return ret;
}
else if (cddata_type == CD_FAKE_SHAPEKEY) {
- /* TODO: leaving shapekeys aside for now, quite specific case, since we can't access them from MVert :/ */
+ /* TODO: leaving shapekeys aside for now, quite specific case,
+ * since we can't access them from MVert :/ */
return false;
}
}
@@ -1126,7 +1140,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
cddata_type = CD_MLOOPUV;
}
else if (cddata_type == CD_FAKE_LNOR) {
- /* Preprocess should have generated it, Postprocess will convert it back to CD_CUSTOMLOOPNORMAL. */
+ /* Pre-process should have generated it,
+ * Post-process will convert it back to CD_CUSTOMLOOPNORMAL. */
cddata_type = CD_NORMAL;
interp_data = space_transform;
interp = customdata_data_transfer_interp_normal_normals;
@@ -1223,8 +1238,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
/**
* Transfer data *layout* of selected types from source to destination object.
* By default, it only creates new data layers if needed on \a ob_dst.
- * If \a use_delete is true, it will also delete data layers on \a ob_dst that do not match those from \a ob_src,
- * to get (as much as possible) exact copy of source data layout.
+ * If \a use_delete is true, it will also delete data layers on \a ob_dst that do not match those
+ * from \a ob_src, to get (as much as possible) exact copy of source data layout.
*/
void BKE_object_data_transfer_layout(struct Depsgraph *depsgraph,
Scene *scene,
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 7769f3aff86..e83e9560b02 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -142,17 +142,21 @@ void defvert_mirror_subset(MDeformVert *dvert_dst,
void defvert_copy(MDeformVert *dvert_dst, const MDeformVert *dvert_src)
{
if (dvert_dst->totweight == dvert_src->totweight) {
- if (dvert_src->totweight)
+ if (dvert_src->totweight) {
memcpy(dvert_dst->dw, dvert_src->dw, dvert_src->totweight * sizeof(MDeformWeight));
+ }
}
else {
- if (dvert_dst->dw)
+ if (dvert_dst->dw) {
MEM_freeN(dvert_dst->dw);
+ }
- if (dvert_src->totweight)
+ if (dvert_src->totweight) {
dvert_dst->dw = MEM_dupallocN(dvert_src->dw);
- else
+ }
+ else {
dvert_dst->dw = NULL;
+ }
dvert_dst->totweight = dvert_src->totweight;
}
@@ -198,10 +202,12 @@ void defvert_sync(MDeformVert *dvert_dst, const MDeformVert *dvert_src, const bo
MDeformWeight *dw_src;
for (i = 0, dw_src = dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
MDeformWeight *dw_dst;
- if (use_verify)
+ if (use_verify) {
dw_dst = defvert_verify_index(dvert_dst, dw_src->def_nr);
- else
+ }
+ else {
dw_dst = defvert_find_index(dvert_dst, dw_src->def_nr);
+ }
if (dw_dst) {
dw_dst->weight = dw_src->weight;
@@ -225,10 +231,12 @@ void defvert_sync_mapped(MDeformVert *dvert_dst,
for (i = 0, dw_src = dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
if (dw_src->def_nr < flip_map_len) {
MDeformWeight *dw_dst;
- if (use_verify)
+ if (use_verify) {
dw_dst = defvert_verify_index(dvert_dst, flip_map[dw_src->def_nr]);
- else
+ }
+ else {
dw_dst = defvert_find_index(dvert_dst, flip_map[dw_src->def_nr]);
+ }
if (dw_dst) {
dw_dst->weight = dw_src->weight;
@@ -514,8 +522,9 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, const bool use_default)
if (map[i] == -1) { /* may be calculated previously */
/* in case no valid value is found, use this */
- if (use_default)
+ if (use_default) {
map[i] = i;
+ }
BLI_string_flip_side_name(name_flip, dg->name, false, sizeof(name_flip));
@@ -637,11 +646,11 @@ float defvert_array_find_weight_safe(const struct MDeformVert *dvert,
const int index,
const int defgroup)
{
- /* Invalid defgroup index means the vgroup selected is invalid, does not exist, in that case it is OK to return 1.0
+ /* Invalid defgroup index means the vgroup selected is invalid,
+ * does not exist, in that case it is OK to return 1.0
* (i.e. maximum weight, as if no vgroup was selected).
* But in case of valid defgroup and NULL dvert data pointer, it means that vgroup **is** valid,
- * and just totally empty, so we shall return '0.0' value then!
- */
+ * and just totally empty, so we shall return '0.0' value then! */
if (defgroup == -1) {
return 1.0f;
}
@@ -687,8 +696,9 @@ MDeformWeight *defvert_verify_index(MDeformVert *dvert, const int defgroup)
}
dw_new = defvert_find_index(dvert, defgroup);
- if (dw_new)
+ if (dw_new) {
return dw_new;
+ }
dw_new = MEM_mallocN(sizeof(MDeformWeight) * (dvert->totweight + 1), "deformWeight");
if (dvert->dw) {
@@ -864,8 +874,9 @@ void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int copyco
/* Assumes dst is already set up */
int i;
- if (!src || !dst)
+ if (!src || !dst) {
return;
+ }
memcpy(dst, src, copycount * sizeof(MDeformVert));
@@ -884,13 +895,15 @@ void BKE_defvert_array_free_elems(MDeformVert *dvert, int totvert)
* vert data */
int i;
- if (!dvert)
+ if (!dvert) {
return;
+ }
/* Free any special data from the verts */
for (i = 0; i < totvert; i++) {
- if (dvert[i].dw)
+ if (dvert[i].dw) {
MEM_freeN(dvert[i].dw);
+ }
}
}
@@ -899,8 +912,9 @@ void BKE_defvert_array_free(MDeformVert *dvert, int totvert)
/* Instead of freeing the verts directly,
* call this function to delete any special
* vert data */
- if (!dvert)
+ if (!dvert) {
return;
+ }
/* Free any special data from the verts */
BKE_defvert_array_free_elems(dvert, totvert);
@@ -1109,8 +1123,9 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
/* Find last source actually used! */
idx_src = num_layers_src;
- while (idx_src-- && !use_layers_src[idx_src])
+ while (idx_src-- && !use_layers_src[idx_src]) {
;
+ }
idx_src++;
if (idx_dst < idx_src) {
@@ -1192,7 +1207,7 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
}
if (r_map) {
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!
- * use_create is not relevant in this case */
+ * use_create is not relevant in this case */
if (!data_dst) {
data_dst = CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_CALLOC, NULL, num_elem_dst);
}
@@ -1243,12 +1258,13 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
const size_t elem_size = sizeof(*((MDeformVert *)NULL));
- /* Note: VGroups are a bit hairy, since their layout is defined on object level (ob->defbase), while their actual
- * data is a (mesh) CD layer.
- * This implies we may have to handle data layout itself while having NULL data itself,
- * and even have to support NULL data_src in transfer data code (we always create a data_dst, though).
+ /* Note:
+ * VGroups are a bit hairy, since their layout is defined on object level (ob->defbase),
+ * while their actual data is a (mesh) CD layer.
+ * This implies we may have to handle data layout itself while having NULL data itself,
+ * and even have to support NULL data_src in transfer data code
+ * (we always create a data_dst, though).
*/
-
if (BLI_listbase_is_empty(&ob_src->defbase)) {
if (use_delete) {
BKE_object_defgroup_remove_all(ob_dst);
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 2794a6e36e4..c228595b6e8 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -64,14 +64,18 @@ static void boundbox_displist_object(Object *ob);
void BKE_displist_elem_free(DispList *dl)
{
if (dl) {
- if (dl->verts)
+ if (dl->verts) {
MEM_freeN(dl->verts);
- if (dl->nors)
+ }
+ if (dl->nors) {
MEM_freeN(dl->nors);
- if (dl->index)
+ }
+ if (dl->index) {
MEM_freeN(dl->index);
- if (dl->bevel_split)
+ }
+ if (dl->bevel_split) {
MEM_freeN(dl->bevel_split);
+ }
MEM_freeN(dl);
}
}
@@ -91,8 +95,9 @@ DispList *BKE_displist_find_or_create(ListBase *lb, int type)
dl = lb->first;
while (dl) {
- if (dl->type == type)
+ if (dl->type == type) {
return dl;
+ }
dl = dl->next;
}
@@ -109,8 +114,9 @@ DispList *BKE_displist_find(ListBase *lb, int type)
dl = lb->first;
while (dl) {
- if (dl->type == type)
+ if (dl->type == type) {
return dl;
+ }
dl = dl->next;
}
@@ -184,8 +190,9 @@ void BKE_displist_normals_add(ListBase *lb)
for (a = 0; a < dl->parts; a++) {
- if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0)
+ if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0) {
break;
+ }
v1 = vdata + 3 * p1;
n1 = ndata + 3 * p1;
@@ -322,10 +329,12 @@ static void curve_to_displist(Curve *cu,
nu = nubase->first;
while (nu) {
if (nu->hide == 0 || editmode == false) {
- if (use_render_resolution && cu->resolu_ren != 0)
+ if (use_render_resolution && cu->resolu_ren != 0) {
resolu = cu->resolu_ren;
- else
+ }
+ else {
resolu = nu->resolu;
+ }
if (!BKE_nurb_check_valid_u(nu)) {
/* pass */
@@ -334,22 +343,27 @@ static void curve_to_displist(Curve *cu,
/* count */
len = 0;
a = nu->pntsu - 1;
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
a++;
+ }
prevbezt = nu->bezt;
bezt = prevbezt + 1;
while (a--) {
- if (a == 0 && (nu->flagu & CU_NURB_CYCLIC))
+ if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) {
bezt = nu->bezt;
+ }
- if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT)
+ if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
len++;
- else
+ }
+ else {
len += resolu;
+ }
- if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0)
+ if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) {
len++;
+ }
prevbezt = bezt;
bezt++;
@@ -380,8 +394,9 @@ static void curve_to_displist(Curve *cu,
bezt = prevbezt + 1;
while (a--) {
- if (a == 0 && dl->type == DL_POLY)
+ if (a == 0 && dl->type == DL_POLY) {
bezt = nu->bezt;
+ }
if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
copy_v3_v3(data, prevbezt->vec[1]);
@@ -423,10 +438,12 @@ static void curve_to_displist(Curve *cu,
dl->charidx = nu->charidx;
data = dl->verts;
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
dl->type = DL_POLY;
- else
+ }
+ else {
dl->type = DL_SEGM;
+ }
BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float));
}
else if (nu->type == CU_POLY) {
@@ -481,10 +498,12 @@ void BKE_displist_fill(ListBase *dispbase,
const int scanfill_flag = BLI_SCANFILL_CALC_REMOVE_DOUBLES | BLI_SCANFILL_CALC_POLYS |
BLI_SCANFILL_CALC_HOLES;
- if (dispbase == NULL)
+ if (dispbase == NULL) {
return;
- if (BLI_listbase_is_empty(dispbase))
+ }
+ if (BLI_listbase_is_empty(dispbase)) {
return;
+ }
sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__);
@@ -499,8 +518,9 @@ void BKE_displist_fill(ListBase *dispbase,
dl = dispbase->first;
while (dl) {
if (dl->type == DL_POLY) {
- if (charidx < dl->charidx)
+ if (charidx < dl->charidx) {
cont = 1;
+ }
else if (charidx == dl->charidx) { /* character with needed index */
if (colnr == dl->col) {
@@ -517,8 +537,9 @@ void BKE_displist_fill(ListBase *dispbase,
sf_vert = BLI_scanfill_vert_add(&sf_ctx, f1);
totvert++;
- if (sf_vert_last == NULL)
+ if (sf_vert_last == NULL) {
sf_vert_new = sf_vert;
+ }
else {
BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert);
}
@@ -574,8 +595,9 @@ void BKE_displist_fill(ListBase *dispbase,
index[1] = sf_tri->v2->tmp.i;
index[2] = sf_tri->v3->tmp.i;
- if (flipnormal)
+ if (flipnormal) {
SWAP(int, index[0], index[2]);
+ }
index += 3;
}
@@ -674,8 +696,9 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dispbase)
{
- if (!CU_DO_2DFILL(cu))
+ if (!CU_DO_2DFILL(cu)) {
return;
+ }
if (dispbase->first && ((DispList *)dispbase->first)->type == DL_SURF) {
bevels_to_filledpoly(cu, dispbase);
@@ -695,8 +718,9 @@ static float displist_calc_taper(Depsgraph *depsgraph, Scene *scene, Object *tap
{
DispList *dl;
- if (taperobj == NULL || taperobj->type != OB_CURVE)
+ if (taperobj == NULL || taperobj->type != OB_CURVE) {
return 1.0;
+ }
dl = taperobj->runtime.curve_cache ? taperobj->runtime.curve_cache->disp.first : NULL;
if (dl == NULL) {
@@ -718,8 +742,9 @@ static float displist_calc_taper(Depsgraph *depsgraph, Scene *scene, Object *tap
if (a > 0) {
float fac1 = (fp[-3] - minx) / dx;
float fac2 = (fp[0] - minx) / dx;
- if (fac1 != fac2)
+ if (fac1 != fac2) {
return fp[1] * (fac1 - fac) / (fac1 - fac2) + fp[-2] * (fac - fac2) / (fac1 - fac2);
+ }
}
return fp[1];
}
@@ -741,8 +766,9 @@ float BKE_displist_calc_taper(
void BKE_displist_make_mball(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
- if (!ob || ob->type != OB_MBALL)
+ if (!ob || ob->type != OB_MBALL) {
return;
+ }
if (ob == BKE_mball_basis_find(scene, ob)) {
if (ob->runtime.curve_cache) {
@@ -783,22 +809,27 @@ static ModifierData *curve_get_tessellate_point(Scene *scene,
ModifierData *pretessellatePoint;
int required_mode;
- if (use_render_resolution)
+ if (use_render_resolution) {
required_mode = eModifierMode_Render;
- else
+ }
+ else {
required_mode = eModifierMode_Realtime;
+ }
- if (editmode)
+ if (editmode) {
required_mode |= eModifierMode_Editmode;
+ }
pretessellatePoint = NULL;
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, required_mode))
+ if (!modifier_isEnabled(scene, md, required_mode)) {
continue;
- if (mti->type == eModifierTypeType_Constructive)
+ }
+ if (mti->type == eModifierTypeType_Constructive) {
return pretessellatePoint;
+ }
if (ELEM(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) {
pretessellatePoint = md;
@@ -837,21 +868,24 @@ static void curve_calc_modifiers_pre(Depsgraph *depsgraph,
modifiers_clearErrors(ob);
- if (editmode)
+ if (editmode) {
app_flag |= MOD_APPLY_USECACHE;
+ }
if (use_render_resolution) {
app_flag |= MOD_APPLY_RENDER;
required_mode = eModifierMode_Render;
}
- else
+ else {
required_mode = eModifierMode_Realtime;
+ }
const ModifierEvalContext mectx = {depsgraph, ob, app_flag};
pretessellatePoint = curve_get_tessellate_point(scene, ob, use_render_resolution, editmode);
- if (editmode)
+ if (editmode) {
required_mode |= eModifierMode_Editmode;
+ }
if (!editmode) {
keyVerts = BKE_key_evaluate_object(ob, &numElems);
@@ -872,10 +906,12 @@ static void curve_calc_modifiers_pre(Depsgraph *depsgraph,
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, required_mode))
+ if (!modifier_isEnabled(scene, md, required_mode)) {
continue;
- if (mti->type != eModifierTypeType_OnlyDeform)
+ }
+ if (mti->type != eModifierTypeType_OnlyDeform) {
continue;
+ }
if (!deformedVerts) {
deformedVerts = BKE_curve_nurbs_vertexCos_get(nurb, &numVerts);
@@ -883,8 +919,9 @@ static void curve_calc_modifiers_pre(Depsgraph *depsgraph,
mti->deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
- if (md == pretessellatePoint)
+ if (md == pretessellatePoint) {
break;
+ }
}
}
@@ -892,11 +929,13 @@ static void curve_calc_modifiers_pre(Depsgraph *depsgraph,
BK_curve_nurbs_vertexCos_apply(nurb, deformedVerts);
MEM_freeN(deformedVerts);
}
- if (keyVerts) /* these are not passed through modifier stack */
+ if (keyVerts) { /* these are not passed through modifier stack */
BKE_curve_nurbs_keyVertexTilts_apply(nurb, keyVerts);
+ }
- if (keyVerts)
+ if (keyVerts) {
MEM_freeN(keyVerts);
+ }
}
static float (*displist_get_allverts(ListBase *dispbase, int *totvert))[3]
@@ -906,8 +945,9 @@ static float (*displist_get_allverts(ListBase *dispbase, int *totvert))[3]
*totvert = 0;
- for (dl = dispbase->first; dl; dl = dl->next)
+ for (dl = dispbase->first; dl; dl = dl->next) {
*totvert += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr;
+ }
allverts = MEM_mallocN((*totvert) * sizeof(float) * 3, "displist_get_allverts allverts");
fp = (float *)allverts;
@@ -957,8 +997,9 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
app_flag |= MOD_APPLY_RENDER;
required_mode = eModifierMode_Render;
}
- else
+ else {
required_mode = eModifierMode_Realtime;
+ }
const ModifierEvalContext mectx_deform = {
depsgraph, ob, editmode ? app_flag | MOD_APPLY_USECACHE : app_flag};
@@ -967,8 +1008,9 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
pretessellatePoint = curve_get_tessellate_point(scene, ob, use_render_resolution, editmode);
- if (editmode)
+ if (editmode) {
required_mode |= eModifierMode_Editmode;
+ }
if (pretessellatePoint) {
md = pretessellatePoint->next;
@@ -981,11 +1023,15 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, required_mode))
+ if (!modifier_isEnabled(scene, md, required_mode)) {
continue;
+ }
/* If we need normals, no choice, have to convert to mesh now. */
- if (mti->dependsOnNormals != NULL && mti->dependsOnNormals(md) && modified == NULL) {
+ bool need_normal = mti->dependsOnNormals != NULL && mti->dependsOnNormals(md);
+ /* XXX 2.8 : now that batch cache is stored inside the ob->data
+ * we need to create a Mesh for each curve that uses modifiers. */
+ if (modified == NULL /* && need_normal */) {
if (vertCos != NULL) {
displist_apply_allverts(dispbase, vertCos);
}
@@ -1003,7 +1049,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
if (!vertCos) {
vertCos = BKE_mesh_vertexCos_get(modified, &totvert);
}
- if (mti->dependsOnNormals != NULL && mti->dependsOnNormals(md)) {
+ if (need_normal) {
BKE_mesh_ensure_normals(modified);
}
mti->deformVerts(md, &mectx_deform, modified, vertCos, totvert);
@@ -1052,7 +1098,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
vertCos = NULL;
}
- if (mti->dependsOnNormals != NULL && mti->dependsOnNormals(md)) {
+ if (need_normal) {
BKE_mesh_ensure_normals(modified);
}
mesh_applied = mti->applyModifier(md, &mectx_apply, modified);
@@ -1060,8 +1106,9 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
if (mesh_applied) {
/* Modifier returned a new derived mesh */
- if (modified && modified != mesh_applied) /* Modifier */
+ if (modified && modified != mesh_applied) { /* Modifier */
BKE_id_free(NULL, modified);
+ }
modified = mesh_applied;
}
}
@@ -1132,8 +1179,9 @@ static void displist_surf_indices(DispList *dl)
for (a = 0; a < dl->parts; a++) {
- if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0)
+ if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0) {
break;
+ }
for (; b < dl->nr; b++, index += 4) {
index[0] = p1;
@@ -1177,10 +1225,12 @@ static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco");
- if (orcodm->getNumVerts(orcodm) == totvert)
+ if (orcodm->getNumVerts(orcodm) == totvert) {
orcodm->getVertCos(orcodm, orco);
- else
+ }
+ else {
dm->getVertCos(dm, orco);
+ }
for (a = 0; a < totvert; a++) {
float *co = orco[a];
@@ -1193,8 +1243,9 @@ static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
memcpy(layerorco, orco, sizeof(float) * totvert);
MEM_freeN(orco);
}
- else
+ else {
DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco);
+ }
}
#endif
@@ -1223,15 +1274,17 @@ static void curve_calc_orcodm(Depsgraph *depsgraph,
app_flag |= MOD_APPLY_RENDER;
required_mode = eModifierMode_Render;
}
- else
+ else {
required_mode = eModifierMode_Realtime;
+ }
const ModifierEvalContext mectx = {depsgraph, ob, app_flag};
pretessellatePoint = curve_get_tessellate_point(scene, ob, use_render_resolution, editmode);
- if (editmode)
+ if (editmode) {
required_mode |= eModifierMode_Editmode;
+ }
if (pretessellatePoint) {
md = pretessellatePoint->next;
@@ -1251,10 +1304,12 @@ static void curve_calc_orcodm(Depsgraph *depsgraph,
md->scene = scene;
- if (!modifier_isEnabled(scene, md, required_mode))
+ if (!modifier_isEnabled(scene, md, required_mode)) {
continue;
- if (mti->type != eModifierTypeType_Constructive)
+ }
+ if (mti->type != eModifierTypeType_Constructive) {
continue;
+ }
ndm = modwrap_applyModifier(md, &mectx, orcodm);
@@ -1297,18 +1352,21 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
BKE_nurbList_duplicate(&nubase, &cu->nurb);
}
- if (!for_orco)
+ if (!for_orco) {
curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render, use_render_resolution);
+ }
for (nu = nubase.first; nu; nu = nu->next) {
if ((for_render || nu->hide == 0) && BKE_nurb_check_valid_uv(nu)) {
int resolu = nu->resolu, resolv = nu->resolv;
if (use_render_resolution) {
- if (cu->resolu_ren)
+ if (cu->resolu_ren) {
resolu = cu->resolu_ren;
- if (cu->resolv_ren)
+ }
+ if (cu->resolv_ren) {
resolv = cu->resolv_ren;
+ }
}
if (nu->pntsv == 1) {
@@ -1328,10 +1386,12 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
dl->rt = nu->flag & ~CU_2D;
data = dl->verts;
- if (nu->flagu & CU_NURB_CYCLIC)
+ if (nu->flagu & CU_NURB_CYCLIC) {
dl->type = DL_POLY;
- else
+ }
+ else {
dl->type = DL_SEGM;
+ }
BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float));
}
@@ -1354,10 +1414,12 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
dl->parts = (nu->pntsu * resolu); /* in reverse, because makeNurbfaces works that way */
dl->nr = (nu->pntsv * resolv);
- if (nu->flagv & CU_NURB_CYCLIC)
+ if (nu->flagv & CU_NURB_CYCLIC) {
dl->flag |= DL_CYCL_U; /* reverse too! */
- if (nu->flagu & CU_NURB_CYCLIC)
+ }
+ if (nu->flagu & CU_NURB_CYCLIC) {
dl->flag |= DL_CYCL_V;
+ }
BKE_nurb_makeFaces(nu, data, 0, resolu, resolv);
@@ -1610,8 +1672,9 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
Curve *cu = ob->data;
/* we do allow duplis... this is only displist on curve level */
- if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT))
+ if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
return;
+ }
if (ob->type == OB_SURF) {
BKE_displist_make_surf(
@@ -1628,8 +1691,9 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
* was needed before and only not needed for orco calculation.
*/
if (!for_orco) {
- if (ob->runtime.curve_cache->path)
+ if (ob->runtime.curve_cache->path) {
free_path(ob->runtime.curve_cache->path);
+ }
ob->runtime.curve_cache->path = NULL;
}
@@ -1640,8 +1704,9 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(cu));
}
- if (!for_orco)
+ if (!for_orco) {
curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, for_render, use_render_resolution);
+ }
BKE_curve_bevelList_make(ob, &nubase, use_render_resolution);
@@ -1672,13 +1737,16 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
dl->verts = MEM_mallocN(sizeof(float[3]) * bl->nr, "dlverts");
BLI_addtail(dispbase, dl);
- if (bl->poly != -1)
+ if (bl->poly != -1) {
dl->type = DL_POLY;
- else
+ }
+ else {
dl->type = DL_SEGM;
+ }
- if (dl->type == DL_SEGM)
+ if (dl->type == DL_SEGM) {
dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE);
+ }
dl->parts = 1;
dl->nr = bl->nr;
@@ -1767,21 +1835,26 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
if (cu->flag & CU_MAP_TAPER) {
len = (steps - 3) + firstblend + lastblend;
- if (a == 0)
+ if (a == 0) {
taper_fac = 0.0f;
- else if (a == steps - 1)
+ }
+ else if (a == steps - 1) {
taper_fac = 1.0f;
- else
+ }
+ else {
taper_fac = ((float)a - (1.0f - firstblend)) / len;
+ }
}
else {
len = bl->nr - 1;
taper_fac = (float)i / len;
- if (a == 0)
+ if (a == 0) {
taper_fac += (1.0f - firstblend) / len;
- else if (a == steps - 1)
+ }
+ else if (a == steps - 1) {
taper_fac -= (1.0f - lastblend) / len;
+ }
}
fac = displist_calc_taper(depsgraph, scene, cu->taperobj, taper_fac);
@@ -1867,8 +1940,9 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph,
/* The same check for duplis as in do_makeDispListCurveTypes.
* Happens when curve used for constraint/bevel was converted to mesh.
* check there is still needed for render displist and orco displists. */
- if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT))
+ if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
return;
+ }
BKE_object_free_derived_caches(ob);
@@ -1957,8 +2031,9 @@ static void boundbox_displist_object(Object *ob)
*/
/* object's BB is calculated from final displist */
- if (ob->runtime.bb == NULL)
+ if (ob->runtime.bb == NULL) {
ob->runtime.bb = MEM_callocN(sizeof(BoundBox), "boundbox");
+ }
if (ob->runtime.mesh_eval) {
BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval);
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 7bbdfa6c52d..0ee32af336d 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -153,12 +153,17 @@ typedef struct Bounds3D {
typedef struct VolumeGrid {
int dim[3];
- Bounds3D grid_bounds; /* whole grid bounds */
-
- Bounds3D *bounds; /* (x*y*z) precalculated grid cell bounds */
- int *s_pos; /* (x*y*z) t_index begin id */
- int *s_num; /* (x*y*z) number of t_index points */
- int *t_index; /* actual surface point index, access: (s_pos + s_num) */
+ /** whole grid bounds */
+ Bounds3D grid_bounds;
+
+ /** (x*y*z) precalculated grid cell bounds */
+ Bounds3D *bounds;
+ /** (x*y*z) t_index begin id */
+ int *s_pos;
+ /** (x*y*z) number of t_index points */
+ int *s_num;
+ /** actual surface point index, access: (s_pos + s_num) */
+ int *t_index;
int *temp_t_index;
} VolumeGrid;
@@ -168,51 +173,67 @@ typedef struct Vec3f {
} Vec3f;
typedef struct BakeAdjPoint {
- float dir[3]; /* vector pointing towards this neighbor */
- float dist; /* distance to */
+ /** vector pointing towards this neighbor */
+ float dir[3];
+ /** distance to */
+ float dist;
} BakeAdjPoint;
-/* Surface data used while processing a frame */
+/** Surface data used while processing a frame */
typedef struct PaintBakeNormal {
- float invNorm[3]; /* current pixel world-space inverted normal */
- float normal_scale; /* normal directional scale for displace mapping */
+ /** current pixel world-space inverted normal */
+ float invNorm[3];
+ /** normal directional scale for displace mapping */
+ float normal_scale;
} PaintBakeNormal;
-/* Temp surface data used to process a frame */
+/** Temp surface data used to process a frame */
typedef struct PaintBakeData {
/* point space data */
PaintBakeNormal *bNormal;
- int *s_pos; /* index to start reading point sample realCoord */
- int *s_num; /* num of realCoord samples */
- Vec3f *
- realCoord; /* current pixel center world-space coordinates for each sample ordered as (s_pos + s_num) */
+ /** index to start reading point sample realCoord */
+ int *s_pos;
+ /** num of realCoord samples */
+ int *s_num;
+ /** current pixel center world-space coordinates for each sample ordered as (s_pos + s_num) */
+ Vec3f *realCoord;
Bounds3D mesh_bounds;
float dim[3];
/* adjacency info */
- BakeAdjPoint *bNeighs; /* current global neighbor distances and directions, if required */
+ /** current global neighbor distances and directions, if required */
+ BakeAdjPoint *bNeighs;
double average_dist;
/* space partitioning */
- VolumeGrid *grid; /* space partitioning grid to optimize brush checks */
+ /** space partitioning grid to optimize brush checks */
+ VolumeGrid *grid;
/* velocity and movement */
- Vec3f *velocity; /* speed vector in global space movement per frame, if required */
+ /** speed vector in global space movement per frame, if required */
+ Vec3f *velocity;
Vec3f *prev_velocity;
- float *brush_velocity; /* special temp data for post-p velocity based brushes like smudge
- * 3 float dir vec + 1 float str */
- MVert *prev_verts; /* copy of previous frame vertices. used to observe surface movement */
- float prev_obmat[4][4]; /* previous frame object matrix */
- int clear; /* flag to check if surface was cleared/reset -> have to redo velocity etc. */
+ /** special temp data for post-p velocity based brushes like smudge
+ * 3 float dir vec + 1 float str */
+ float *brush_velocity;
+ /** copy of previous frame vertices. used to observe surface movement. */
+ MVert *prev_verts;
+ /** Previous frame object matrix. */
+ float prev_obmat[4][4];
+ /** flag to check if surface was cleared/reset -> have to redo velocity etc. */
+ int clear;
} PaintBakeData;
-/* UV Image sequence format point */
+/** UV Image sequence format point */
typedef struct PaintUVPoint {
/* Pixel / mesh data */
- unsigned int tri_index, pixel_index; /* tri index on domain derived mesh */
- unsigned int v1, v2, v3; /* vertex indexes */
-
- unsigned int
- neighbour_pixel; /* If this pixel isn't uv mapped to any face, but it's neighboring pixel is */
+ /** tri index on domain derived mesh */
+ unsigned int tri_index;
+ unsigned int pixel_index;
+ /* vertex indexes */
+ unsigned int v1, v2, v3;
+
+ /** If this pixel isn't uv mapped to any face, but it's neighboring pixel is. */
+ unsigned int neighbour_pixel;
} PaintUVPoint;
typedef struct ImgSeqFormatData {
@@ -225,14 +246,20 @@ typedef struct ImgSeqFormatData {
#define ADJ_BORDER_PIXEL (1 << 1)
typedef struct PaintAdjData {
- int *
- n_target; /* array of neighboring point indexes, for single sample use (n_index + neigh_num) */
- int *n_index; /* index to start reading n_target for each point */
- int *n_num; /* num of neighs for each point */
- int *flags; /* vertex adjacency flags */
- int total_targets; /* size of n_target */
- int *border; /* indices of border pixels (only for texture paint) */
- int total_border; /* size of border */
+ /** Array of neighboring point indexes, for single sample use (n_index + neigh_num). */
+ int *n_target;
+ /** Index to start reading n_target for each point. */
+ int *n_index;
+ /** Num of neighs for each point. */
+ int *n_num;
+ /** Vertex adjacency flags. */
+ int *flags;
+ /** Size of n_target. */
+ int total_targets;
+ /** Indices of border pixels (only for texture paint). */
+ int *border;
+ /** Size of border. */
+ int total_border;
} PaintAdjData;
/************************* Runtime evaluation store ***************************/
@@ -302,64 +329,25 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
return 0;
}
-/* checks whether surface's format/type has realtime preview */
-bool dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface)
-{
- if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
- return false;
- }
- else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
- return !ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WAVE);
- }
-
- return true;
-}
-
/* get currently active surface (in user interface) */
DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas)
{
return BLI_findlink(&canvas->surfaces, canvas->active_sur);
}
-/* set preview to first previewable surface */
-void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
-{
- DynamicPaintSurface *surface = canvas->surfaces.first;
- bool done = false;
-
- for (; surface; surface = surface->next) {
- if (!done && dynamicPaint_surfaceHasColorPreview(surface)) {
- surface->flags |= MOD_DPAINT_PREVIEW;
- done = true;
- }
- else {
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- }
- }
-}
-
-/* set preview to defined surface */
-static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
-{
- DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
- for (; surface; surface = surface->next) {
- if (surface == t_surface)
- surface->flags |= MOD_DPAINT_PREVIEW;
- else
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- }
-}
-
bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object *ob, int output)
{
const char *name;
- if (output == 0)
+ if (output == 0) {
name = surface->output_name;
- else if (output == 1)
+ }
+ else if (output == 1) {
name = surface->output_name2;
- else
+ }
+ else {
return false;
+ }
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
@@ -419,8 +407,9 @@ static bool surface_duplicateNameExists(void *arg, const char *name)
DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
for (; surface; surface = surface->next) {
- if (surface != t_surface && STREQ(name, surface->name))
+ if (surface != t_surface && STREQ(name, surface->name)) {
return true;
+ }
}
return false;
}
@@ -465,12 +454,6 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
}
surface_setUniqueOutputName(surface, surface->output_name, 0);
-
- /* update preview */
- if (dynamicPaint_surfaceHasColorPreview(surface))
- dynamicPaint_setPreview(surface);
- else
- dynamicPaint_resetPreview(surface->canvas);
}
static int surface_totalSamples(DynamicPaintSurface *surface)
@@ -565,8 +548,9 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Depsgraph *depsgr
if (pmd2->brush) {
DynamicPaintBrushSettings *brush = pmd2->brush;
- if (brush->flags & MOD_DPAINT_USES_VELOCITY)
+ if (brush->flags & MOD_DPAINT_USES_VELOCITY) {
flags |= BRUSH_USES_VELOCITY;
+ }
}
}
}
@@ -579,11 +563,13 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Depsgraph *depsgr
/* check whether two bounds intersect */
static bool boundsIntersect(Bounds3D *b1, Bounds3D *b2)
{
- if (!b1->valid || !b2->valid)
+ if (!b1->valid || !b2->valid) {
return false;
+ }
for (int i = 2; i--;) {
- if (!(b1->min[i] <= b2->max[i] && b1->max[i] >= b2->min[i]))
+ if (!(b1->min[i] <= b2->max[i] && b1->max[i] >= b2->min[i])) {
return false;
+ }
}
return true;
}
@@ -591,11 +577,13 @@ static bool boundsIntersect(Bounds3D *b1, Bounds3D *b2)
/* check whether two bounds intersect inside defined proximity */
static bool boundsIntersectDist(Bounds3D *b1, Bounds3D *b2, const float dist)
{
- if (!b1->valid || !b2->valid)
+ if (!b1->valid || !b2->valid) {
return false;
+ }
for (int i = 2; i--;) {
- if (!(b1->min[i] <= (b2->max[i] + dist) && b1->max[i] >= (b2->min[i] - dist)))
+ if (!(b1->min[i] <= (b2->max[i] + dist) && b1->max[i] >= (b2->min[i] - dist))) {
return false;
+ }
}
return true;
}
@@ -603,11 +591,13 @@ static bool boundsIntersectDist(Bounds3D *b1, Bounds3D *b2, const float dist)
/* check whether bounds intersects a point with given radius */
static bool boundIntersectPoint(Bounds3D *b, float point[3], const float radius)
{
- if (!b->valid)
+ if (!b->valid) {
return false;
+ }
for (int i = 2; i--;) {
- if (!(b->min[i] <= (point[i] + radius) && b->max[i] >= (point[i] - radius)))
+ if (!(b->min[i] <= (point[i] + radius) && b->max[i] >= (point[i] - radius))) {
return false;
+ }
}
return true;
}
@@ -636,14 +626,18 @@ static void freeGrid(PaintSurfaceData *data)
PaintBakeData *bData = data->bData;
VolumeGrid *grid = bData->grid;
- if (grid->bounds)
+ if (grid->bounds) {
MEM_freeN(grid->bounds);
- if (grid->s_pos)
+ }
+ if (grid->s_pos) {
MEM_freeN(grid->s_pos);
- if (grid->s_num)
+ }
+ if (grid->s_num) {
MEM_freeN(grid->s_num);
- if (grid->t_index)
+ }
+ if (grid->t_index) {
MEM_freeN(grid->t_index);
+ }
MEM_freeN(bData->grid);
bData->grid = NULL;
@@ -738,8 +732,9 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
int *temp_t_index = NULL;
int *temp_s_num = NULL;
- if (bData->grid)
+ if (bData->grid) {
freeGrid(sData);
+ }
bData->grid = MEM_callocN(sizeof(VolumeGrid), "Surface Grid");
grid = bData->grid;
@@ -808,8 +803,9 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
/* in case of an allocation failure abort here */
if (!grid->bounds || !grid->s_pos || !grid->s_num || !grid->t_index || !temp_s_num ||
- !temp_t_index)
+ !temp_t_index) {
error = 1;
+ }
if (!error) {
/* calculate number of points within each cell */
@@ -845,10 +841,12 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
}
}
- if (temp_s_num)
+ if (temp_s_num) {
MEM_freeN(temp_s_num);
- if (temp_t_index)
+ }
+ if (temp_t_index) {
MEM_freeN(temp_t_index);
+ }
grid->temp_t_index = NULL;
if (error || !grid->s_num) {
@@ -864,10 +862,12 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd)
{
if (pmd->brush) {
- if (pmd->brush->paint_ramp)
+ if (pmd->brush->paint_ramp) {
MEM_freeN(pmd->brush->paint_ramp);
- if (pmd->brush->vel_ramp)
+ }
+ if (pmd->brush->vel_ramp) {
MEM_freeN(pmd->brush->vel_ramp);
+ }
MEM_freeN(pmd->brush);
pmd->brush = NULL;
@@ -877,16 +877,21 @@ void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd)
static void dynamicPaint_freeAdjData(PaintSurfaceData *data)
{
if (data->adj_data) {
- if (data->adj_data->n_index)
+ if (data->adj_data->n_index) {
MEM_freeN(data->adj_data->n_index);
- if (data->adj_data->n_num)
+ }
+ if (data->adj_data->n_num) {
MEM_freeN(data->adj_data->n_num);
- if (data->adj_data->n_target)
+ }
+ if (data->adj_data->n_target) {
MEM_freeN(data->adj_data->n_target);
- if (data->adj_data->flags)
+ }
+ if (data->adj_data->flags) {
MEM_freeN(data->adj_data->flags);
- if (data->adj_data->border)
+ }
+ if (data->adj_data->border) {
MEM_freeN(data->adj_data->border);
+ }
MEM_freeN(data->adj_data);
data->adj_data = NULL;
}
@@ -896,24 +901,33 @@ static void free_bakeData(PaintSurfaceData *data)
{
PaintBakeData *bData = data->bData;
if (bData) {
- if (bData->bNormal)
+ if (bData->bNormal) {
MEM_freeN(bData->bNormal);
- if (bData->s_pos)
+ }
+ if (bData->s_pos) {
MEM_freeN(bData->s_pos);
- if (bData->s_num)
+ }
+ if (bData->s_num) {
MEM_freeN(bData->s_num);
- if (bData->realCoord)
+ }
+ if (bData->realCoord) {
MEM_freeN(bData->realCoord);
- if (bData->bNeighs)
+ }
+ if (bData->bNeighs) {
MEM_freeN(bData->bNeighs);
- if (bData->grid)
+ }
+ if (bData->grid) {
freeGrid(data);
- if (bData->prev_verts)
+ }
+ if (bData->prev_verts) {
MEM_freeN(bData->prev_verts);
- if (bData->velocity)
+ }
+ if (bData->velocity) {
MEM_freeN(bData->velocity);
- if (bData->prev_velocity)
+ }
+ if (bData->prev_velocity) {
MEM_freeN(bData->prev_velocity);
+ }
MEM_freeN(data->bData);
data->bData = NULL;
@@ -923,8 +937,9 @@ static void free_bakeData(PaintSurfaceData *data)
/* free surface data if it's not used anymore */
static void surface_freeUnusedData(DynamicPaintSurface *surface)
{
- if (!surface->data)
+ if (!surface->data) {
return;
+ }
/* free bakedata if not active or surface is baked */
if (!(surface->flags & MOD_DPAINT_ACTIVE) ||
@@ -936,23 +951,27 @@ static void surface_freeUnusedData(DynamicPaintSurface *surface)
void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface)
{
PaintSurfaceData *data = surface->data;
- if (!data)
+ if (!data) {
return;
+ }
if (data->format_data) {
/* format specific free */
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
ImgSeqFormatData *format_data = (ImgSeqFormatData *)data->format_data;
- if (format_data->uv_p)
+ if (format_data->uv_p) {
MEM_freeN(format_data->uv_p);
- if (format_data->barycentricWeights)
+ }
+ if (format_data->barycentricWeights) {
MEM_freeN(format_data->barycentricWeights);
+ }
}
MEM_freeN(data->format_data);
}
/* type data */
- if (data->type_data)
+ if (data->type_data) {
MEM_freeN(data->type_data);
+ }
dynamicPaint_freeAdjData(data);
/* bake data */
free_bakeData(data);
@@ -969,8 +988,9 @@ void dynamicPaint_freeSurface(const DynamicPaintModifierData *pmd, DynamicPaintS
}
surface->pointcache = NULL;
- if (surface->effector_weights)
+ if (surface->effector_weights) {
MEM_freeN(surface->effector_weights);
+ }
surface->effector_weights = NULL;
BLI_remlink(&(surface->canvas->surfaces), surface);
@@ -1019,8 +1039,9 @@ DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *c
Scene *scene)
{
DynamicPaintSurface *surface = MEM_callocN(sizeof(DynamicPaintSurface), "DynamicPaintSurface");
- if (!surface)
+ if (!surface) {
return NULL;
+ }
surface->canvas = canvas;
surface->format = MOD_DPAINT_SURFACE_F_VERTEX;
@@ -1033,8 +1054,8 @@ DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *c
/* Set initial values */
surface->flags = MOD_DPAINT_ANTIALIAS | MOD_DPAINT_MULALPHA | MOD_DPAINT_DRY_LOG |
- MOD_DPAINT_DISSOLVE_LOG | MOD_DPAINT_ACTIVE | MOD_DPAINT_PREVIEW |
- MOD_DPAINT_OUT1 | MOD_DPAINT_USE_DRYING;
+ MOD_DPAINT_DISSOLVE_LOG | MOD_DPAINT_ACTIVE | MOD_DPAINT_OUT1 |
+ MOD_DPAINT_USE_DRYING;
surface->effect = 0;
surface->effect_ui = 1;
@@ -1099,27 +1120,32 @@ bool dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, str
if (pmd) {
if (type == MOD_DYNAMICPAINT_TYPE_CANVAS) {
DynamicPaintCanvasSettings *canvas;
- if (pmd->canvas)
+ if (pmd->canvas) {
dynamicPaint_freeCanvas(pmd);
+ }
canvas = pmd->canvas = MEM_callocN(sizeof(DynamicPaintCanvasSettings),
"DynamicPaint Canvas");
- if (!canvas)
+ if (!canvas) {
return false;
+ }
canvas->pmd = pmd;
/* Create one surface */
- if (!dynamicPaint_createNewSurface(canvas, scene))
+ if (!dynamicPaint_createNewSurface(canvas, scene)) {
return false;
+ }
}
else if (type == MOD_DYNAMICPAINT_TYPE_BRUSH) {
DynamicPaintBrushSettings *brush;
- if (pmd->brush)
+ if (pmd->brush) {
dynamicPaint_freeBrush(pmd);
+ }
brush = pmd->brush = MEM_callocN(sizeof(DynamicPaintBrushSettings), "DynamicPaint Paint");
- if (!brush)
+ if (!brush) {
return false;
+ }
brush->pmd = pmd;
brush->psys = NULL;
@@ -1150,8 +1176,9 @@ bool dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, str
CBData *ramp;
brush->paint_ramp = BKE_colorband_add(false);
- if (!brush->paint_ramp)
+ if (!brush->paint_ramp) {
return false;
+ }
ramp = brush->paint_ramp->data;
/* Add default smooth-falloff ramp. */
ramp[0].r = ramp[0].g = ramp[0].b = ramp[0].a = 1.0f;
@@ -1166,8 +1193,9 @@ bool dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, str
CBData *ramp;
brush->vel_ramp = BKE_colorband_add(false);
- if (!brush->vel_ramp)
+ if (!brush->vel_ramp) {
return false;
+ }
ramp = brush->vel_ramp->data;
ramp[0].r = ramp[0].g = ramp[0].b = ramp[0].a = ramp[0].pos = 0.0f;
ramp[1].r = ramp[1].g = ramp[1].b = ramp[1].a = ramp[1].pos = 1.0f;
@@ -1188,18 +1216,21 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
{
/* Init modifier */
tpmd->type = pmd->type;
- if (pmd->canvas)
+ if (pmd->canvas) {
dynamicPaint_createType(tpmd, MOD_DYNAMICPAINT_TYPE_CANVAS, NULL);
- if (pmd->brush)
+ }
+ if (pmd->brush) {
dynamicPaint_createType(tpmd, MOD_DYNAMICPAINT_TYPE_BRUSH, NULL);
+ }
/* Copy data */
if (tpmd->canvas) {
DynamicPaintSurface *surface;
tpmd->canvas->pmd = tpmd;
/* free default surface */
- if (tpmd->canvas->surfaces.first)
+ if (tpmd->canvas->surfaces.first) {
dynamicPaint_freeSurface(tpmd, tpmd->canvas->surfaces.first);
+ }
/* copy existing surfaces */
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
@@ -1224,7 +1255,6 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
t_surface->disp_type = surface->disp_type;
t_surface->image_fileformat = surface->image_fileformat;
t_surface->effect_ui = surface->effect_ui;
- t_surface->preview_id = surface->preview_id;
t_surface->init_color_type = surface->init_color_type;
t_surface->flags = surface->flags;
t_surface->effect = surface->effect;
@@ -1267,7 +1297,6 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
BLI_strncpy(t_surface->output_name, surface->output_name, sizeof(t_surface->output_name));
BLI_strncpy(t_surface->output_name2, surface->output_name2, sizeof(t_surface->output_name2));
}
- dynamicPaint_resetPreview(tpmd->canvas);
}
else if (tpmd->brush) {
DynamicPaintBrushSettings *brush = pmd->brush, *t_brush = tpmd->brush;
@@ -1287,10 +1316,12 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
t_brush->paint_distance = brush->paint_distance;
t_brush->psys = brush->psys;
- if (brush->paint_ramp)
+ if (brush->paint_ramp) {
memcpy(t_brush->paint_ramp, brush->paint_ramp, sizeof(ColorBand));
- if (brush->vel_ramp)
+ }
+ if (brush->vel_ramp) {
memcpy(t_brush->vel_ramp, brush->vel_ramp, sizeof(ColorBand));
+ }
t_brush->proximity_falloff = brush->proximity_falloff;
t_brush->wave_type = brush->wave_type;
@@ -1327,8 +1358,9 @@ static void dynamicPaint_allocateSurfaceType(DynamicPaintSurface *surface)
break;
}
- if (sData->type_data == NULL)
+ if (sData->type_data == NULL) {
setError(surface->canvas, N_("Not enough free memory"));
+ }
}
static bool surface_usesAdjDistance(DynamicPaintSurface *surface)
@@ -1352,8 +1384,9 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, const b
int *temp_data;
int neigh_points = 0;
- if (!force_init && !surface_usesAdjData(surface))
+ if (!force_init && !surface_usesAdjData(surface)) {
return;
+ }
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
/* For vertex format, neighbors are connected by edges */
@@ -1363,13 +1396,15 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, const b
neigh_points = sData->total_points * 8;
}
- if (!neigh_points)
+ if (!neigh_points) {
return;
+ }
/* allocate memory */
ad = sData->adj_data = MEM_callocN(sizeof(PaintAdjData), "Surface Adj Data");
- if (!ad)
+ if (!ad) {
return;
+ }
ad->n_index = MEM_callocN(sizeof(int) * sData->total_points, "Surface Adj Index");
ad->n_num = MEM_callocN(sizeof(int) * sData->total_points, "Surface Adj Counts");
temp_data = MEM_callocN(sizeof(int) * sData->total_points, "Temp Adj Data");
@@ -1382,8 +1417,9 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, const b
/* in case of allocation error, free memory */
if (!ad->n_index || !ad->n_num || !ad->n_target || !temp_data) {
dynamicPaint_freeAdjData(sData);
- if (temp_data)
+ if (temp_data) {
MEM_freeN(temp_data);
+ }
setError(surface->canvas, N_("Not enough free memory"));
return;
}
@@ -1579,11 +1615,13 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
int i;
const bool scene_color_manage = BKE_scene_check_color_management_enabled(scene);
- if (surface->type != MOD_DPAINT_SURFACE_T_PAINT)
+ if (surface->type != MOD_DPAINT_SURFACE_T_PAINT) {
return;
+ }
- if (surface->init_color_type == MOD_DPAINT_INITIAL_NONE)
+ if (surface->init_color_type == MOD_DPAINT_INITIAL_NONE) {
return;
+ }
/* Single color */
if (surface->init_color_type == MOD_DPAINT_INITIAL_COLOR) {
@@ -1603,14 +1641,16 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
- if (!tex)
+ if (!tex) {
return;
+ }
/* get uv map */
CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, surface->init_layername, uvname);
mloopuv = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvname);
- if (!mloopuv)
+ if (!mloopuv) {
return;
+ }
/* for vertex surface loop through tfaces and find uv color
* that provides highest alpha */
@@ -1655,8 +1695,9 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
const int totloop = mesh->totloop;
const MLoopCol *col = CustomData_get_layer_named(
&mesh->ldata, CD_MLOOPCOL, surface->init_layername);
- if (!col)
+ if (!col) {
return;
+ }
for (i = 0; i < totloop; i++) {
rgba_uchar_to_float(pPoint[mloop[i].v].color, (const unsigned char *)&col[mloop[i].v].r);
@@ -1666,8 +1707,9 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
MLoopCol *col = CustomData_get_layer_named(
&mesh->ldata, CD_MLOOPCOL, surface->init_layername);
- if (!col)
+ if (!col) {
return;
+ }
DynamicPaintSetInitColorData data = {
.surface = surface,
@@ -1690,21 +1732,26 @@ void dynamicPaint_clearSurface(const Scene *scene, DynamicPaintSurface *surface)
if (sData && sData->type_data) {
unsigned int data_size;
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
+ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
data_size = sizeof(PaintPoint);
- else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE)
+ }
+ else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
data_size = sizeof(PaintWavePoint);
- else
+ }
+ else {
data_size = sizeof(float);
+ }
memset(sData->type_data, 0, data_size * sData->total_points);
/* set initial color */
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
+ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
dynamicPaint_setInitialColor(scene, surface);
+ }
- if (sData->bData)
+ if (sData->bData) {
sData->bData->clear = 1;
+ }
}
}
@@ -1713,19 +1760,23 @@ bool dynamicPaint_resetSurface(const Scene *scene, DynamicPaintSurface *surface)
{
int numOfPoints = dynamicPaint_surfaceNumOfPoints(surface);
/* free existing data */
- if (surface->data)
+ if (surface->data) {
dynamicPaint_freeSurfaceData(surface);
+ }
/* don't reallocate for image sequence types. they get handled only on bake */
- if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ)
+ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
return true;
- if (numOfPoints < 1)
+ }
+ if (numOfPoints < 1) {
return false;
+ }
/* allocate memory */
surface->data = MEM_callocN(sizeof(PaintSurfaceData), "PaintSurfaceData");
- if (!surface->data)
+ if (!surface->data) {
return false;
+ }
/* allocate data depending on surface type and format */
surface->data->total_points = numOfPoints;
@@ -1733,8 +1784,9 @@ bool dynamicPaint_resetSurface(const Scene *scene, DynamicPaintSurface *surface)
dynamicPaint_initAdjacencyData(surface, false);
/* set initial color */
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
+ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
dynamicPaint_setInitialColor(scene, surface);
+ }
return true;
}
@@ -1762,7 +1814,6 @@ typedef struct DynamicPaintModifierApplyData {
float (*fcolor)[4];
MLoopCol *mloopcol;
MLoopCol *mloopcol_wet;
- MLoopCol *mloopcol_preview;
} DynamicPaintModifierApplyData;
static void dynamic_paint_apply_surface_displace_cb(void *__restrict userdata,
@@ -1789,8 +1840,9 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Mesh
{
PaintSurfaceData *sData = surface->data;
- if (!sData || surface->format != MOD_DPAINT_SURFACE_F_VERTEX)
+ if (!sData || surface->format != MOD_DPAINT_SURFACE_F_VERTEX) {
return;
+ }
/* displace paint */
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) {
@@ -1826,7 +1878,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
const ParallelRangeTLS *__restrict UNUSED(tls))
{
const DynamicPaintModifierApplyData *data = userdata;
- Object *ob = data->ob;
const MLoop *mloop = data->mloop;
const MPoly *mpoly = data->mpoly;
@@ -1837,11 +1888,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
MLoopCol *mloopcol = data->mloopcol;
MLoopCol *mloopcol_wet = data->mloopcol_wet;
- MLoopCol *mloopcol_preview = data->mloopcol_preview;
-
- const Material *material = mloopcol_preview ?
- give_current_material(ob, mpoly[p_index].mat_nr + 1) :
- NULL;
for (int j = 0; j < mpoly[p_index].totloop; j++) {
const int l_index = mpoly[p_index].loopstart + j;
@@ -1860,37 +1906,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
mloopcol_wet[l_index].b = c;
mloopcol_wet[l_index].a = 255;
}
-
- /* viewport preview */
- if (mloopcol_preview) {
- if (surface->preview_id == MOD_DPAINT_SURFACE_PREV_PAINT) {
- float c[3];
-
- /* Apply material color as base vertex color for preview */
- mloopcol_preview[l_index].a = 255;
- if (material) {
- c[0] = material->r;
- c[1] = material->g;
- c[2] = material->b;
- }
- else { /* default gray */
- c[0] = 0.65f;
- c[1] = 0.65f;
- c[2] = 0.65f;
- }
- /* mix surface color */
- interp_v3_v3v3(c, c, fcolor[v_index], fcolor[v_index][3]);
-
- rgb_float_to_uchar((unsigned char *)&mloopcol_preview[l_index].r, c);
- }
- else {
- const char c = unit_float_to_uchar_clamp(pPoint[v_index].wetness);
- mloopcol_preview[l_index].r = c;
- mloopcol_preview[l_index].g = c;
- mloopcol_preview[l_index].b = c;
- mloopcol_preview[l_index].a = 255;
- }
- }
}
}
@@ -1925,8 +1940,9 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
PaintSurfaceData *sData = surface->data;
if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && sData) {
- if (!(surface->flags & MOD_DPAINT_ACTIVE))
+ if (!(surface->flags & MOD_DPAINT_ACTIVE)) {
continue;
+ }
/* process vertex surface previews */
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
@@ -1975,22 +1991,11 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
&result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, totloop, surface->output_name2);
}
- /* Save preview results to weight layer to be able to share same drawing methods */
- MLoopCol *mloopcol_preview = NULL;
- if (surface->flags & MOD_DPAINT_PREVIEW) {
- mloopcol_preview = CustomData_get_layer(&result->ldata, CD_PREVIEW_MLOOPCOL);
- if (!mloopcol_preview) {
- mloopcol_preview = CustomData_add_layer(
- &result->ldata, CD_PREVIEW_MLOOPCOL, CD_CALLOC, NULL, totloop);
- }
- }
-
data.ob = ob;
data.mloop = mloop;
data.mpoly = mpoly;
data.mloopcol = mloopcol;
data.mloopcol_wet = mloopcol_wet;
- data.mloopcol_preview = mloopcol_preview;
{
ParallelRangeSettings settings;
@@ -2003,7 +2008,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
MEM_freeN(fcolor);
/* Mark tessellated CD layers as dirty. */
- //result->dirty |= DM_DIRTY_TESS_CDLAYERS;
+ // result->dirty |= DM_DIRTY_TESS_CDLAYERS;
}
/* vertex group paint */
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
@@ -2011,15 +2016,6 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
MDeformVert *dvert = CustomData_get_layer(&result->vdata, CD_MDEFORMVERT);
float *weight = (float *)sData->type_data;
- /* viewport preview */
- if (surface->flags & MOD_DPAINT_PREVIEW) {
- /* Save preview results to weight layer to be
- * able to share same drawing methods.
- * Note this func also sets DM_DIRTY_TESS_CDLAYERS flag! */
- //TODO port this function
- //DM_update_weight_mcol(ob, result, 0, weight, 0, NULL);
- }
-
/* apply weights into a vertex group, if doesn't exists add a new layer */
if (defgrp_index != -1 && !dvert && (surface->output_name[0] != '\0')) {
dvert = CustomData_add_layer(
@@ -2070,7 +2066,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
}
if (update_normals) {
- //result->dirty |= DM_DIRTY_NORMALS;
+ // result->dirty |= DM_DIRTY_NORMALS;
}
}
/* make a copy of mesh to use as brush data */
@@ -2121,8 +2117,9 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd,
canvas_copyMesh(canvas, mesh);
/* in case image sequence baking, stop here */
- if (canvas->flags & MOD_DPAINT_BAKING)
+ if (canvas->flags & MOD_DPAINT_BAKING) {
return;
+ }
/* loop through surfaces */
for (; surface; surface = surface->next) {
@@ -2134,13 +2131,15 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd,
/* image sequences are handled by bake operator */
if ((surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) ||
- !(surface->flags & MOD_DPAINT_ACTIVE))
+ !(surface->flags & MOD_DPAINT_ACTIVE)) {
continue;
+ }
/* make sure surface is valid */
no_surface_data = surface->data == NULL;
- if (!dynamicPaint_checkSurfaceData(scene, surface))
+ if (!dynamicPaint_checkSurfaceData(scene, surface)) {
continue;
+ }
/* limit frame range */
CLAMP(current_frame, surface->start_frame, surface->end_frame);
@@ -2219,11 +2218,11 @@ Mesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd,
}
}
-/***************************** Image Sequence / UV Image Surface Calls ******************************/
+/* -------------------------------------------------------------------- */
+/** \name Image Sequence / UV Image Surface Calls
+ * \{ */
-/*
- * Create a surface for uv image sequence format
- */
+/* Create a surface for uv image sequence format. */
#define JITTER_SAMPLES \
{ \
0.0f, 0.0f, -0.2f, -0.4f, 0.2f, 0.4f, 0.4f, -0.2f, -0.4f, 0.3f, \
@@ -2426,8 +2425,9 @@ static void dynamic_paint_create_uv_surface_neighbor_cb(
}
/* Increase the final number of active surface points if relevant. */
- if (tPoint->tri_index != -1)
+ if (tPoint->tri_index != -1) {
atomic_add_and_fetch_uint32(active_points, 1);
+ }
}
}
@@ -2492,16 +2492,19 @@ static int dynamic_paint_find_neighbour_pixel(const DynamicPaintCreateUVSurfaceD
const int x = px + neighX[n_index];
const int y = py + neighY[n_index];
- if (x < 0 || x >= w || y < 0 || y >= h)
+ if (x < 0 || x >= w || y < 0 || y >= h) {
return OUT_OF_TEXTURE;
+ }
const PaintUVPoint *tempPoints = data->tempPoints;
const PaintUVPoint *tPoint = &tempPoints[x + w * y]; /* UV neighbor */
const PaintUVPoint *cPoint = &tempPoints[px + w * py]; /* Origin point */
- /* Check if shifted point is on same face -> it's a correct neighbor (and if it isn't marked as an "edge pixel") */
- if ((tPoint->tri_index == cPoint->tri_index) && (tPoint->neighbour_pixel == -1))
+ /* Check if shifted point is on same face -> it's a correct neighbor
+ * (and if it isn't marked as an "edge pixel") */
+ if ((tPoint->tri_index == cPoint->tri_index) && (tPoint->neighbour_pixel == -1)) {
return (x + w * y);
+ }
/* Even if shifted point is on another face
* -> use this point.
@@ -2561,8 +2564,9 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
/* Enumerate all edges of the triangle, rotating the vertex list accordingly. */
for (int edge_idx = 0; edge_idx < 3; edge_idx++) {
/* but not the edge we have just recursed through */
- if (edge_idx == in_edge)
+ if (edge_idx == in_edge) {
continue;
+ }
float uv0[2], uv1[2], uv2[2];
@@ -2575,22 +2579,25 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
const float sidep = line_point_side_v2(uv0, uv1, pixel);
const float side2 = line_point_side_v2(uv0, uv1, uv2);
- if (side2 == 0.0f)
+ if (side2 == 0.0f) {
continue;
+ }
/* Hack: allow all edges of the original triangle */
const bool correct_side = (in_edge == -1) || (sidep < 0 && side2 > 0) ||
(sidep > 0 && side2 < 0);
/* Allow exactly on edge for the non-recursive case */
- if (!correct_side && sidep != 0.0f)
+ if (!correct_side && sidep != 0.0f) {
continue;
+ }
/* Now find another face that is linked to that edge. */
const int vert0 = mloop[loop_idx[(edge_idx + 0)]].v;
const int vert1 = mloop[loop_idx[(edge_idx + 1) % 3]].v;
- /* Use a pre-computed vert-to-looptri mapping, speeds up things a lot compared to looping over all loopti. */
+ /* Use a pre-computed vert-to-looptri mapping,
+ * speeds up things a lot compared to looping over all loopti. */
const MeshElemMap *map = &bdata->vert_to_looptri_map[vert0];
bool found_other = false;
@@ -2602,8 +2609,9 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
for (int i = 0; i < map->count && !found_other; i++) {
const int lt_index = map->indices[i];
- if (lt_index == tri_index)
+ if (lt_index == tri_index) {
continue;
+ }
const unsigned int *other_loop_idx = mlooptri[lt_index].tri;
@@ -2633,8 +2641,9 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
}
if (!found_other) {
- if (bdata->best_index < 0)
+ if (bdata->best_index < 0) {
bdata->best_index = ON_MESH_EDGE;
+ }
continue;
}
@@ -2652,8 +2661,9 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
* First check if there already is a better solution. */
const float dist_squared = dist_squared_to_line_segment_v2(pixel, uv0, uv1);
- if (bdata->best_index >= 0 && dist_squared >= bdata->best_weight)
+ if (bdata->best_index >= 0 && dist_squared >= bdata->best_weight) {
continue;
+ }
/*
* Find a point that is relatively at same edge position
@@ -2673,8 +2683,9 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
/* If current pixel uv is outside of texture */
if (final_pixel[0] < 0 || final_pixel[0] >= w || final_pixel[1] < 0 || final_pixel[1] >= h) {
- if (bdata->best_index == NOT_FOUND)
+ if (bdata->best_index == NOT_FOUND) {
bdata->best_index = OUT_OF_TEXTURE;
+ }
continue;
}
@@ -2683,16 +2694,18 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
int final_index = final_pixel[0] + w * final_pixel[1];
/* If we ended up to our origin point ( mesh has smaller than pixel sized faces) */
- if (final_index == (px + w * py))
+ if (final_index == (px + w * py)) {
continue;
+ }
/* If final point is an "edge pixel", use it's "real" neighbor instead */
if (tempPoints[final_index].neighbour_pixel != -1) {
final_index = tempPoints[final_index].neighbour_pixel;
/* If we ended up to our origin point */
- if (final_index == (px + w * py))
+ if (final_index == (px + w * py)) {
continue;
+ }
}
/* If found pixel still lies on wrong face ( mesh has smaller than pixel sized faces) */
@@ -2703,8 +2716,9 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
const float threshold = SQUARE(0.7f) / (w * h);
if (dist_squared_to_looptri_uv_edges(
- mlooptri, mloopuv, tempPoints[final_index].tri_index, final_pt) > threshold)
+ mlooptri, mloopuv, tempPoints[final_index].tri_index, final_pt) > threshold) {
continue;
+ }
}
bdata->best_index = final_index;
@@ -2725,7 +2739,8 @@ static bool dynamicPaint_pointHasNeighbor(PaintAdjData *ed, int index, int neigh
return false;
}
-/* Makes the adjacency data symmetric, except for border pixels. I.e. if A is neighbor of B, B is neighbor of A. */
+/* Makes the adjacency data symmetric, except for border pixels.
+ * I.e. if A is neighbor of B, B is neighbor of A. */
static bool dynamicPaint_symmetrizeAdjData(PaintAdjData *ed, int active_points)
{
int *new_n_index = MEM_callocN(sizeof(int) * active_points, "Surface Adj Index");
@@ -2808,10 +2823,12 @@ static bool dynamicPaint_symmetrizeAdjData(PaintAdjData *ed, int active_points)
}
}
- if (new_n_index)
+ if (new_n_index) {
MEM_freeN(new_n_index);
- if (new_n_num)
+ }
+ if (new_n_num) {
MEM_freeN(new_n_num);
+ }
return false;
}
@@ -2843,10 +2860,12 @@ int dynamicPaint_createUVSurface(Scene *scene,
*progress = 0.0f;
*do_update = true;
- if (!mesh)
+ if (!mesh) {
return setError(canvas, N_("Canvas mesh not updated"));
- if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ)
+ }
+ if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) {
return setError(canvas, N_("Cannot bake non-'image sequence' formats"));
+ }
mloop = mesh->mloop;
mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
@@ -2859,10 +2878,12 @@ int dynamicPaint_createUVSurface(Scene *scene,
}
/* Check for validity */
- if (!mloopuv)
+ if (!mloopuv) {
return setError(canvas, N_("No UV data on canvas"));
- if (surface->image_resolution < 16 || surface->image_resolution > 8192)
+ }
+ if (surface->image_resolution < 16 || surface->image_resolution > 8192) {
return setError(canvas, N_("Invalid resolution"));
+ }
const int w = surface->image_resolution;
const int h = w;
@@ -2873,23 +2894,28 @@ int dynamicPaint_createUVSurface(Scene *scene,
CLOG_INFO(&LOG, 1, "Preparing UV surface of %ix%i pixels and %i tris.", w, h, tottri);
/* Init data struct */
- if (surface->data)
+ if (surface->data) {
dynamicPaint_freeSurfaceData(surface);
+ }
sData = surface->data = MEM_callocN(sizeof(PaintSurfaceData), "PaintSurfaceData");
- if (!surface->data)
+ if (!surface->data) {
return setError(canvas, N_("Not enough free memory"));
+ }
tempPoints = MEM_callocN(w * h * sizeof(*tempPoints), "Temp PaintUVPoint");
- if (!tempPoints)
+ if (!tempPoints) {
error = true;
+ }
final_index = MEM_callocN(w * h * sizeof(*final_index), "Temp UV Final Indexes");
- if (!final_index)
+ if (!final_index) {
error = true;
+ }
tempWeights = MEM_mallocN(w * h * aa_samples * sizeof(*tempWeights), "Temp bWeights");
- if (!tempWeights)
+ if (!tempWeights) {
error = true;
+ }
/*
* Generate a temporary bounding box array for UV faces to optimize
@@ -2897,8 +2923,9 @@ int dynamicPaint_createUVSurface(Scene *scene,
*/
if (!error) {
faceBB = MEM_mallocN(tottri * sizeof(*faceBB), "MPCanvasFaceBB");
- if (!faceBB)
+ if (!faceBB) {
error = true;
+ }
}
*progress = 0.01f;
@@ -3003,7 +3030,8 @@ int dynamicPaint_createUVSurface(Scene *scene,
}
for (int i = 0; i < 8; i++) {
- /* Try to find a neighboring pixel in defined direction. If not found, -1 is returned */
+ /* Try to find a neighboring pixel in defined direction.
+ * If not found, -1 is returned */
const int n_target = dynamic_paint_find_neighbour_pixel(
&data, vert_to_looptri_map, w, h, tx, ty, i);
@@ -3064,10 +3092,18 @@ int dynamicPaint_createUVSurface(Scene *scene,
if (tempPoints[index].tri_index != -1) {
int nidx = tempPoints[index].neighbour_pixel;
- fprintf(dump_file, "%d\t%d,%d\t%u\t%d,%d\t%d\t", fidx, tx, h-1-ty, tempPoints[index].tri_index, nidx<0?-1:(nidx%w), nidx<0?-1:h-1-(nidx/w), ed->flags[fidx]);
+ fprintf(dump_file,
+ "%d\t%d,%d\t%u\t%d,%d\t%d\t",
+ fidx,
+ tx,
+ h - 1 - ty,
+ tempPoints[index].tri_index,
+ nidx < 0 ? -1 : (nidx % w),
+ nidx < 0 ? -1 : h - 1 - (nidx / w),
+ ed->flags[fidx]);
for (int i = 0; i < ed->n_num[fidx]; i++) {
- int tgt = tmp[ed->n_target[ed->n_index[fidx]+i]];
- fprintf(dump_file, "%s%d,%d", i?" ":"", tgt%w, h-1-tgt/w);
+ int tgt = tmp[ed->n_target[ed->n_index[fidx] + i]];
+ fprintf(dump_file, "%s%d,%d", i ? " " : "", tgt % w, h - 1 - tgt / w);
}
fprintf(dump_file, "\n");
}
@@ -3089,8 +3125,9 @@ int dynamicPaint_createUVSurface(Scene *scene,
f_data->barycentricWeights = MEM_callocN(
active_points * aa_samples * sizeof(*f_data->barycentricWeights), "PaintUVPoint");
- if (!f_data->uv_p || !f_data->barycentricWeights)
+ if (!f_data->uv_p || !f_data->barycentricWeights) {
error = 1;
+ }
}
else {
error = 1;
@@ -3099,10 +3136,12 @@ int dynamicPaint_createUVSurface(Scene *scene,
/* in case of allocation error, free everything */
if (error) {
if (f_data) {
- if (f_data->uv_p)
+ if (f_data->uv_p) {
MEM_freeN(f_data->uv_p);
- if (f_data->barycentricWeights)
+ }
+ if (f_data->barycentricWeights) {
MEM_freeN(f_data->barycentricWeights);
+ }
MEM_freeN(f_data);
}
sData->total_points = 0;
@@ -3122,17 +3161,22 @@ int dynamicPaint_createUVSurface(Scene *scene,
}
}
}
- if (error == 1)
+ if (error == 1) {
setError(canvas, N_("Not enough free memory"));
+ }
- if (faceBB)
+ if (faceBB) {
MEM_freeN(faceBB);
- if (tempPoints)
+ }
+ if (tempPoints) {
MEM_freeN(tempPoints);
- if (tempWeights)
+ }
+ if (tempWeights) {
MEM_freeN(tempWeights);
- if (final_index)
+ }
+ if (final_index) {
MEM_freeN(final_index);
+ }
/* Init surface type data */
if (!error) {
@@ -3211,8 +3255,9 @@ static void dynamic_paint_output_surface_image_displace_cb(
/* image buffer position */
const int pos = ((ImgSeqFormatData *)(surface->data->format_data))->uv_p[index].pixel_index * 4;
- if (surface->depth_clamp)
+ if (surface->depth_clamp) {
depth /= surface->depth_clamp;
+ }
if (surface->disp_type == MOD_DPAINT_DISP_DISPLACE) {
depth = (0.5f - depth / 2.0f);
@@ -3237,8 +3282,9 @@ static void dynamic_paint_output_surface_image_wave_cb(
/* image buffer position */
const int pos = ((ImgSeqFormatData *)(surface->data->format_data))->uv_p[index].pixel_index * 4;
- if (surface->depth_clamp)
+ if (surface->depth_clamp) {
depth /= surface->depth_clamp;
+ }
depth = (0.5f + depth / 2.0f);
CLAMP(depth, 0.0f, 1.0f);
@@ -3280,8 +3326,9 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
}
/* if selected format is openexr, but current build doesn't support one */
#ifndef WITH_OPENEXR
- if (format == R_IMF_IMTYPE_OPENEXR)
+ if (format == R_IMF_IMTYPE_OPENEXR) {
format = R_IMF_IMTYPE_PNG;
+ }
#endif
BLI_strncpy(output_file, filename, sizeof(output_file));
BKE_image_path_ensure_ext_from_imtype(output_file, format);
@@ -3394,10 +3441,13 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface,
IMB_freeImBuf(ibuf);
}
+/** \} */
+
/***************************** Ray / Nearest Point Utils ******************************/
-/* A modified callback to bvh tree raycast. The tree must have been built using bvhtree_from_mesh_looptri.
- * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
+/* A modified callback to bvh tree raycast.
+ * The tree must have been built using bvhtree_from_mesh_looptri.
+ * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
*
* To optimize brush detection speed this doesn't calculate hit coordinates or normal.
*/
@@ -3427,7 +3477,8 @@ static void mesh_tris_spherecast_dp(void *userdata,
}
}
-/* A modified callback to bvh tree nearest point. The tree must have been built using bvhtree_from_mesh_looptri.
+/* A modified callback to bvh tree nearest point.
+ * The tree must have been built using bvhtree_from_mesh_looptri.
* userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree.
*
* To optimize brush detection speed this doesn't calculate hit normal.
@@ -3554,10 +3605,12 @@ static void dynamicPaint_mixWaveHeight(PaintWavePoint *wPoint,
isect_height *= wave_factor;
/* determine hit depending on wave_factor */
- if (wave_factor > 0.0f && wPoint->height > isect_height)
+ if (wave_factor > 0.0f && wPoint->height > isect_height) {
hit = true;
- else if (wave_factor < 0.0f && wPoint->height < isect_height)
+ }
+ else if (wave_factor < 0.0f && wPoint->height < isect_height) {
hit = true;
+ }
if (hit) {
switch (brush->wave_type) {
@@ -3573,8 +3626,9 @@ static void dynamicPaint_mixWaveHeight(PaintWavePoint *wPoint,
wPoint->state = DPAINT_WAVE_REFLECT_ONLY;
break;
case MOD_DPAINT_WAVEB_CHANGE:
- if (isect_change < 0.0f)
+ if (isect_change < 0.0f) {
wPoint->height += isect_change * wave_factor;
+ }
break;
default:
BLI_assert(0);
@@ -3616,10 +3670,12 @@ static void dynamicPaint_updatePointData(const DynamicPaintSurface *surface,
if (brush->flags & MOD_DPAINT_VELOCITY_COLOR) {
copy_v3_v3(paint, coba_res);
}
- if (brush->flags & MOD_DPAINT_VELOCITY_ALPHA)
+ if (brush->flags & MOD_DPAINT_VELOCITY_ALPHA) {
strength *= coba_res[3];
- if (brush->flags & MOD_DPAINT_VELOCITY_DEPTH)
+ }
+ if (brush->flags & MOD_DPAINT_VELOCITY_DEPTH) {
depth *= coba_res[3];
+ }
}
}
@@ -3635,8 +3691,9 @@ static void dynamicPaint_updatePointData(const DynamicPaintSurface *surface,
else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) {
float *value = (float *)sData->type_data;
- if (surface->flags & MOD_DPAINT_DISP_INCREMENTAL)
+ if (surface->flags & MOD_DPAINT_DISP_INCREMENTAL) {
depth = value[index] + depth;
+ }
if (surface->depth_clamp) {
CLAMP(depth, 0.0f - surface->depth_clamp, surface->depth_clamp);
@@ -3683,10 +3740,12 @@ static bool meshBrush_boundsIntersect(Bounds3D *b1,
DynamicPaintBrushSettings *brush,
float brush_radius)
{
- if (brush->collision == MOD_DPAINT_COL_VOLUME)
+ if (brush->collision == MOD_DPAINT_COL_VOLUME) {
return boundsIntersect(b1, b2);
- else if (brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST)
+ }
+ else if (brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST) {
return boundsIntersectDist(b1, b2, brush_radius);
+ }
return true;
}
@@ -3786,12 +3845,14 @@ static void dynamicPaint_brushMeshCalculateVelocity(Depsgraph *depsgraph,
(*brushVel) = (struct Vec3f *)MEM_mallocN(numOfVerts_c * sizeof(Vec3f),
"Dynamic Paint brush velocity");
- if (!(*brushVel))
+ if (!(*brushVel)) {
return;
+ }
/* if mesh is constructive -> num of verts has changed, only use current frame derived mesh */
- if (numOfVerts_p != numOfVerts_c)
+ if (numOfVerts_p != numOfVerts_c) {
mvert_p = mvert_c;
+ }
/* calculate speed */
DynamicPaintBrushVelocityData data = {
@@ -3922,8 +3983,9 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
int numOfHits = 0;
/* for image sequence anti-aliasing, use gaussian factors */
- if (samples > 1 && surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ)
+ if (samples > 1 && surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
total_sample = gaussianTotal;
+ }
/* Supersampling */
for (ss = 0; ss < samples; ss++) {
@@ -3947,10 +4009,12 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
int hitTri = -1;
/* Supersampling factor */
- if (samples > 1 && surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ)
+ if (samples > 1 && surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
sample_factor = gaussianFactors[ss];
- else
+ }
+ else {
sample_factor = 1.0f;
+ }
/* Get current sample position in world coordinates */
copy_v3_v3(ray_start, bData->realCoord[bData->s_pos[index] + ss].v);
@@ -4020,8 +4084,9 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
int tri = 0;
/* if inverse prox and no hit found, skip this sample */
- if (inner_proximity && !hit_found)
+ if (inner_proximity && !hit_found) {
continue;
+ }
/* If pure distance proximity, find the nearest point on the mesh */
if (!(brush->flags & MOD_DPAINT_PROX_PROJECT)) {
@@ -4064,8 +4129,9 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
if (proxDist >= 0.0f && proxDist <= brush_radius) {
proximity_factor = proxDist / brush_radius;
CLAMP(proximity_factor, 0.0f, 1.0f);
- if (!inner_proximity)
+ if (!inner_proximity) {
proximity_factor = 1.0f - proximity_factor;
+ }
hit_found = HIT_PROXIMITY;
@@ -4082,8 +4148,9 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
/* if "negate volume" enabled, negate all factors within volume*/
if (brush->collision == MOD_DPAINT_COL_VOLDIST && brush->flags & MOD_DPAINT_NEGATE_VOLUME) {
volume_factor = 1.0f - volume_factor;
- if (inner_proximity)
+ if (inner_proximity) {
proximity_factor = 1.0f - proximity_factor;
+ }
}
/* apply final sample depending on final hit type */
@@ -4221,9 +4288,10 @@ static int dynamicPaint_paintMesh(Depsgraph *depsgraph,
const MLoopTri *mlooptri = NULL;
const MLoop *mloop = NULL;
- if (brush->flags & MOD_DPAINT_USES_VELOCITY)
+ if (brush->flags & MOD_DPAINT_USES_VELOCITY) {
dynamicPaint_brushMeshCalculateVelocity(
depsgraph, scene, brushOb, brush, &brushVelocity, timescale);
+ }
Mesh *brush_mesh = dynamicPaint_brush_mesh_get(brush);
if (brush_mesh == NULL) {
@@ -4320,8 +4388,9 @@ static int dynamicPaint_paintMesh(Depsgraph *depsgraph,
}
/* free brush velocity data */
- if (brushVelocity)
+ if (brushVelocity) {
MEM_freeN(brushVelocity);
+ }
return 1;
}
@@ -4370,8 +4439,9 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
/* Find nearest particle and get distance to it */
BLI_kdtree_3d_find_nearest(tree, bData->realCoord[bData->s_pos[index]].v, &nearest);
/* if outside maximum range, no other particle can influence either */
- if (nearest.dist > range)
+ if (nearest.dist > range) {
return;
+ }
if (brush->flags & MOD_DPAINT_PART_RAD) {
/* use particles individual size */
@@ -4386,8 +4456,9 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
/* distances inside solid radius has maximum influence -> dist = 0 */
smooth_range = max_ff(0.0f, (nearest.dist - part_solidradius));
/* do smoothness if enabled */
- if (smooth)
+ if (smooth) {
smooth_range /= smooth;
+ }
strength = 1.0f - smooth_range;
disp_intersect = radius - nearest.dist;
@@ -4416,14 +4487,16 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
ParticleData *pa = &psys->particles[nearest[n].index];
/* skip if out of range */
- if (nearest[n].dist > (pa->size + smooth))
+ if (nearest[n].dist > (pa->size + smooth)) {
continue;
+ }
/* update hit data */
const float s_range = nearest[n].dist - pa->size;
/* skip if higher influence is already found */
- if (smooth_range < s_range)
+ if (smooth_range < s_range) {
continue;
+ }
/* update hit data */
smooth_range = s_range;
@@ -4437,8 +4510,9 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
}
}
- if (nearest)
+ if (nearest) {
MEM_freeN(nearest);
+ }
/* now calculate influence for this particle */
const float rad = radius + smooth;
@@ -4449,13 +4523,15 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex(
/* do smoothness if enabled */
CLAMP_MIN(smooth_range, 0.0f);
- if (smooth)
+ if (smooth) {
smooth_range /= smooth;
+ }
const float str = 1.0f - smooth_range;
/* if influence is greater, use this one */
- if (str > strength)
+ if (str > strength) {
strength = str;
+ }
}
if (strength > 0.001f) {
@@ -4521,8 +4597,9 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
Bounds3D part_bb = {{0}};
- if (psys->totpart < 1)
+ if (psys->totpart < 1) {
return 1;
+ }
/*
* Build a kd-tree to optimize distance search
@@ -4546,8 +4623,9 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
}
/* make sure particle is close enough to canvas */
- if (!boundIntersectPoint(&grid->grid_bounds, pa->state.co, range))
+ if (!boundIntersectPoint(&grid->grid_bounds, pa->state.co, range)) {
continue;
+ }
BLI_kdtree_3d_insert(tree, p, pa->state.co);
@@ -4556,8 +4634,9 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
particlesAdded++;
}
- if (invalidParticles)
+ if (invalidParticles) {
CLOG_WARN(&LOG, "Invalid particle(s) found!");
+ }
/* If no suitable particles were found, exit */
if (particlesAdded < 1) {
@@ -4633,8 +4712,9 @@ static void dynamic_paint_paint_single_point_cb_ex(void *__restrict userdata,
float colorband[4] = {0.0f};
float strength;
- if (distance > brush_radius)
+ if (distance > brush_radius) {
return;
+ }
/* Smooth range or color ramp */
if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH ||
@@ -4713,8 +4793,9 @@ static int dynamicPaint_paintSinglePoint(Depsgraph *depsgraph,
float brush_radius = brush->paint_distance * surface->radius_scale;
Vec3f brushVel;
- if (brush->flags & MOD_DPAINT_USES_VELOCITY)
+ if (brush->flags & MOD_DPAINT_USES_VELOCITY) {
dynamicPaint_brushObjectCalculateVelocity(depsgraph, scene, brushOb, &brushVel, timescale);
+ }
const Mesh *brush_mesh = dynamicPaint_brush_mesh_get(brush);
const MVert *mvert = brush_mesh->mvert;
@@ -4782,15 +4863,18 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, cons
int index;
- if ((!surface_usesAdjDistance(surface) && !force_init) || !sData->adj_data)
+ if ((!surface_usesAdjDistance(surface) && !force_init) || !sData->adj_data) {
return;
+ }
- if (bData->bNeighs)
+ if (bData->bNeighs) {
MEM_freeN(bData->bNeighs);
+ }
bNeighs = bData->bNeighs = MEM_mallocN(sData->adj_data->total_targets * sizeof(*bNeighs),
"PaintEffectBake");
- if (!bNeighs)
+ if (!bNeighs) {
return;
+ }
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
@@ -4799,7 +4883,8 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, cons
0, sData->total_points, sData, dynamic_paint_prepare_adjacency_cb, &settings);
/* calculate average values (single thread).
- * Note: tried to put this in threaded callback (using _finalize feature), but gave ~30% slower result! */
+ * Note: tried to put this in threaded callback (using _finalize feature),
+ * but gave ~30% slower result! */
bData->average_dist = 0.0;
for (index = 0; index < sData->total_points; index++) {
int numOfNeighs = adj_data->n_num[index];
@@ -4811,7 +4896,8 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, cons
bData->average_dist /= adj_data->total_targets;
}
-/* find two adjacency points (closest_id) and influence (closest_d) to move paint towards when affected by a force */
+/* Find two adjacency points (closest_id) and influence (closest_d)
+ * to move paint towards when affected by a force. */
static void surface_determineForceTargetPoints(const PaintSurfaceData *sData,
const int index,
const float force[3],
@@ -4836,15 +4922,17 @@ static void surface_determineForceTargetPoints(const PaintSurfaceData *sData,
}
}
- if (closest_d[0] < 0.0f)
+ if (closest_d[0] < 0.0f) {
return;
+ }
/* find second closest neigh */
for (i = 0; i < numOfNeighs; i++) {
const int n_index = sData->adj_data->n_index[index] + i;
- if (n_index == closest_id[0])
+ if (n_index == closest_id[0]) {
continue;
+ }
const float dir_dot = dot_v3v3(bNeighs[n_index].dir, force);
const float closest_dot = dot_v3v3(bNeighs[n_index].dir, bNeighs[closest_id[0]].dir);
@@ -4902,8 +4990,9 @@ static void dynamicPaint_doSmudge(DynamicPaintSurface *surface,
int index, steps, step;
float eff_scale, max_velocity = 0.0f;
- if (!sData->adj_data)
+ if (!sData->adj_data) {
return;
+ }
/* find max velocity */
for (index = 0; index < sData->total_points; index++) {
@@ -4919,8 +5008,9 @@ static void dynamicPaint_doSmudge(DynamicPaintSurface *surface,
for (index = 0; index < sData->total_points; index++) {
int i;
- if (sData->adj_data->flags[index] & ADJ_BORDER_PIXEL)
+ if (sData->adj_data->flags[index] & ADJ_BORDER_PIXEL) {
continue;
+ }
PaintPoint *pPoint = &((PaintPoint *)sData->type_data)[index];
float smudge_str = bData->brush_velocity[index * 4 + 3];
@@ -4929,8 +5019,9 @@ static void dynamicPaint_doSmudge(DynamicPaintSurface *surface,
int closest_id[2];
float closest_d[2];
- if (!smudge_str)
+ if (!smudge_str) {
continue;
+ }
/* get force affect points */
surface_determineForceTargetPoints(
@@ -4946,8 +5037,9 @@ static void dynamicPaint_doSmudge(DynamicPaintSurface *surface,
(PaintPoint *)sData->type_data)[sData->adj_data->n_target[n_index]];
/* just skip if angle is too extreme */
- if (dir_dot <= 0.0f)
+ if (dir_dot <= 0.0f) {
continue;
+ }
dir_factor = dir_dot * speed_scale;
CLAMP_MAX(dir_factor, brush->smudge_strength);
@@ -5025,18 +5117,20 @@ static void dynamic_paint_prepare_effect_cb(void *__restrict userdata,
}
/* if global gravity is enabled, add it too */
- if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)
+ if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
/* also divide by 10 to about match default grav
* with default force strength (1.0). */
madd_v3_v3fl(forc,
scene->physics_settings.gravity,
surface->effector_weights->global_gravity * surface->effector_weights->weight[0] /
10.f);
+ }
/* add surface point velocity and acceleration if enabled */
if (bData->velocity) {
- if (surface->drip_vel)
+ if (surface->drip_vel) {
madd_v3_v3fl(forc, bData->velocity[index].v, surface->drip_vel * (-1.0f));
+ }
/* acceleration */
if (bData->prev_velocity && surface->drip_acc) {
@@ -5098,10 +5192,12 @@ static int dynamicPaint_prepareEffectStep(struct Depsgraph *depsgraph,
* so that just a few ultra close pixels wont up substeps to max. */
/* adjust number of required substep by fastest active effect */
- if (surface->effect & MOD_DPAINT_EFFECT_DO_SPREAD)
+ if (surface->effect & MOD_DPAINT_EFFECT_DO_SPREAD) {
spread_speed = surface->spread_speed;
- if (surface->effect & MOD_DPAINT_EFFECT_DO_SHRINK)
+ }
+ if (surface->effect & MOD_DPAINT_EFFECT_DO_SHRINK) {
shrink_speed = surface->shrink_speed;
+ }
fastest_effect = max_fff(spread_speed, shrink_speed, average_force);
avg_dist = bData->average_dist * (double)CANVAS_REL_SIZE / (double)getSurfaceDimension(sData);
@@ -5124,8 +5220,9 @@ static void dynamic_paint_effect_spread_cb(void *__restrict userdata,
const DynamicPaintSurface *surface = data->surface;
const PaintSurfaceData *sData = surface->data;
- if (sData->adj_data->flags[index] & ADJ_BORDER_PIXEL)
+ if (sData->adj_data->flags[index] & ADJ_BORDER_PIXEL) {
return;
+ }
const int numOfNeighs = sData->adj_data->n_num[index];
BakeAdjPoint *bNeighs = sData->bData->bNeighs;
@@ -5147,16 +5244,18 @@ static void dynamic_paint_effect_spread_cb(void *__restrict userdata,
surface->color_spread_speed;
/* do color mixing */
- if (color_mix)
+ if (color_mix) {
mixColors(pPoint->e_color,
pPoint->e_color[3],
pPoint_prev->e_color,
pPoint_prev->e_color[3],
color_mix);
+ }
/* Only continue if surrounding point has higher wetness */
- if (pPoint_prev->wetness < pPoint->wetness || pPoint_prev->wetness < MIN_WETNESS)
+ if (pPoint_prev->wetness < pPoint->wetness || pPoint_prev->wetness < MIN_WETNESS) {
continue;
+ }
w_factor = 1.0f / numOfNeighs * min_ff(pPoint_prev->wetness, 1.0f) * speed_scale;
CLAMP(w_factor, 0.0f, 1.0f);
@@ -5180,8 +5279,9 @@ static void dynamic_paint_effect_shrink_cb(void *__restrict userdata,
const DynamicPaintSurface *surface = data->surface;
const PaintSurfaceData *sData = surface->data;
- if (sData->adj_data->flags[index] & ADJ_BORDER_PIXEL)
+ if (sData->adj_data->flags[index] & ADJ_BORDER_PIXEL) {
return;
+ }
const int numOfNeighs = sData->adj_data->n_num[index];
BakeAdjPoint *bNeighs = sData->bData->bNeighs;
@@ -5205,8 +5305,9 @@ static void dynamic_paint_effect_shrink_cb(void *__restrict userdata,
/* Check if neighboring point has lower alpha,
* if so, decrease this point's alpha as well. */
- if (pPoint->color[3] <= 0.0f && pPoint->e_color[3] <= 0.0f && pPoint->wetness <= 0.0f)
+ if (pPoint->color[3] <= 0.0f && pPoint->e_color[3] <= 0.0f && pPoint->wetness <= 0.0f) {
continue;
+ }
/* decrease factor for dry paint alpha */
a_factor = max_ff((1.0f - pPoint_prev->color[3]) / numOfNeighs *
@@ -5239,8 +5340,9 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
const DynamicPaintSurface *surface = data->surface;
const PaintSurfaceData *sData = surface->data;
- if (sData->adj_data->flags[index] & ADJ_BORDER_PIXEL)
+ if (sData->adj_data->flags[index] & ADJ_BORDER_PIXEL) {
return;
+ }
BakeAdjPoint *bNeighs = sData->bData->bNeighs;
PaintPoint *pPoint = &((PaintPoint *)sData->type_data)[index];
@@ -5258,8 +5360,9 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
/* adjust drip speed depending on wetness */
float w_factor = pPoint_prev->wetness - 0.025f;
- if (w_factor <= 0)
+ if (w_factor <= 0) {
return;
+ }
CLAMP(w_factor, 0.0f, 1.0f);
float ppoint_wetness_diff = 0.0f;
@@ -5274,8 +5377,9 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
const float dir_dot = closest_d[i];
/* just skip if angle is too extreme */
- if (dir_dot <= 0.0f)
+ if (dir_dot <= 0.0f) {
continue;
+ }
float dir_factor, a_factor;
const float speed_scale = eff_scale * force[index * 4 + 3] / bNeighs[n_idx].dist;
@@ -5283,13 +5387,14 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
const unsigned int n_trgt = (unsigned int)n_target[n_idx];
/* Sort of spinlock, but only for given ePoint.
- * Since the odds a same ePoint is modified at the same time by several threads is very low, this is
- * much more efficient than a global spin lock. */
+ * Since the odds a same ePoint is modified at the same time by several threads is very low,
+ * this is much more efficient than a global spin lock. */
const unsigned int epointlock_idx = n_trgt / 8;
const uint8_t epointlock_bitmask = 1 << (n_trgt & 7); /* 7 == 0b111 */
while (atomic_fetch_and_or_uint8(&point_locks[epointlock_idx], epointlock_bitmask) &
- epointlock_bitmask)
+ epointlock_bitmask) {
;
+ }
PaintPoint *ePoint = &((PaintPoint *)sData->type_data)[n_trgt];
const float e_wet = ePoint->wetness;
@@ -5314,8 +5419,8 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
CLAMP_MAX(ePoint->e_color[3], pPoint_prev->e_color[3]);
}
- /* Decrease paint wetness on current point
- * (just store diff here, that way we can only lock current point once at the end to apply it). */
+ /* Decrease paint wetness on current point (just store diff here,
+ * that way we can only lock current point once at the end to apply it). */
ppoint_wetness_diff += (ePoint->wetness - e_wet);
#ifndef NDEBUG
@@ -5334,8 +5439,9 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata,
const unsigned int ppointlock_idx = index / 8;
const uint8_t ppointlock_bitmask = 1 << (index & 7); /* 7 == 0b111 */
while (atomic_fetch_and_or_uint8(&point_locks[ppointlock_idx], ppointlock_bitmask) &
- ppointlock_bitmask)
+ ppointlock_bitmask) {
;
+ }
pPoint->wetness -= ppoint_wetness_diff;
CLAMP(pPoint->wetness, 0.0f, MAX_WETNESS);
@@ -5362,8 +5468,9 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface,
const float distance_scale = getSurfaceDimension(sData) / CANVAS_REL_SIZE;
timescale /= steps;
- if (!sData->adj_data)
+ if (!sData->adj_data) {
return;
+ }
/*
* Spread Effect
@@ -5503,8 +5610,9 @@ static void dynamicPaint_doBorderStep(DynamicPaintSurface *surface)
{
PaintSurfaceData *sData = surface->data;
- if (!sData->adj_data || !sData->adj_data->border)
+ if (!sData->adj_data || !sData->adj_data->border) {
return;
+ }
/* Don't use prevPoint, relying on the condition that neighbors are never border pixels. */
DynamicPaintEffectData data = {
@@ -5542,8 +5650,9 @@ static void dynamic_paint_wave_step_cb(void *__restrict userdata,
float force = 0.0f, avg_dist = 0.0f, avg_height = 0.0f, avg_n_height = 0.0f;
int numOfN = 0, numOfRN = 0;
- if (wPoint->state > 0)
+ if (wPoint->state > 0) {
return;
+ }
const int *n_index = sData->adj_data->n_index;
const int *n_target = sData->adj_data->n_target;
@@ -5555,8 +5664,9 @@ static void dynamic_paint_wave_step_cb(void *__restrict userdata,
float dist = bNeighs[n_idx].dist * wave_scale;
const PaintWavePoint *tPoint = &prevPoint[n_target[n_idx]];
- if (!dist || tPoint->state > 0)
+ if (!dist || tPoint->state > 0) {
continue;
+ }
CLAMP_MIN(dist, min_dist);
avg_dist += dist;
@@ -5582,8 +5692,9 @@ static void dynamic_paint_wave_step_cb(void *__restrict userdata,
/* else do wave eq */
else {
/* add force towards zero height based on average dist */
- if (avg_dist)
+ if (avg_dist) {
force += (0.0f - wPoint->height) * surface->wave_spring / (avg_dist * avg_dist) / 2.0f;
+ }
/* change point velocity */
wPoint->velocity += force * dt * wave_speed * wave_speed;
@@ -5596,10 +5707,12 @@ static void dynamic_paint_wave_step_cb(void *__restrict userdata,
if (wave_max_slope && avg_dist) {
const float max_offset = wave_max_slope * avg_dist;
const float offset = (numOfN) ? (avg_height / numOfN - wPoint->height) : 0.0f;
- if (offset > max_offset)
+ if (offset > max_offset) {
wPoint->height += offset - max_offset;
- else if (offset < -max_offset)
+ }
+ else if (offset < -max_offset) {
wPoint->height += offset + max_offset;
+ }
}
}
@@ -5629,8 +5742,9 @@ static void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescal
/* allocate memory */
PaintWavePoint *prevPoint = MEM_mallocN(sData->total_points * sizeof(PaintWavePoint), __func__);
- if (!prevPoint)
+ if (!prevPoint) {
return;
+ }
/* calculate average neigh distance (single thread) */
for (index = 0; index < sData->total_points; index++) {
@@ -5734,10 +5848,10 @@ static void dynamic_paint_surface_pre_step_cb(void *__restrict userdata,
/* reduce wet layer alpha by dry factor */
pPoint->e_color[3] *= dry_ratio;
- /* now calculate new alpha for dry layer that keeps final blended color unchanged */
+ /* Now calculate new alpha for dry layer that keeps final blended color unchanged. */
pPoint->color[3] = (f_color[3] - pPoint->e_color[3]) / (1.0f - pPoint->e_color[3]);
- /* for each rgb component, calculate a new dry layer color that keeps the final blend color
- * with these new alpha values. (wet layer color doesn't change)*/
+ /* For each rgb component, calculate a new dry layer color that keeps the final blend
+ * color with these new alpha values. (wet layer color doesn't change). */
if (pPoint->color[3]) {
for (i = 0; i < 3; i++) {
pPoint->color[i] = (f_color[i] * f_color[3] -
@@ -5797,12 +5911,14 @@ static bool dynamicPaint_surfaceHasMoved(DynamicPaintSurface *surface, Object *o
int numOfVerts = mesh->totvert;
int i;
- if (!bData->prev_verts)
+ if (!bData->prev_verts) {
return true;
+ }
/* matrix comparison */
- if (!equals_m4m4(bData->prev_obmat, ob->obmat))
+ if (!equals_m4m4(bData->prev_obmat, ob->obmat)) {
return true;
+ }
/* vertices */
for (i = 0; i < numOfVerts; i++) {
@@ -5958,30 +6074,35 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface,
const bool surface_moved = dynamicPaint_surfaceHasMoved(surface, ob);
/* get previous speed for accelertaion */
- if (do_accel_data && bData->prev_velocity && bData->velocity)
+ if (do_accel_data && bData->prev_velocity && bData->velocity) {
memcpy(bData->prev_velocity, bData->velocity, sData->total_points * sizeof(Vec3f));
+ }
/* reset speed vectors */
- if (do_velocity_data && bData->velocity && (bData->clear || !surface_moved))
+ if (do_velocity_data && bData->velocity && (bData->clear || !surface_moved)) {
memset(bData->velocity, 0, sData->total_points * sizeof(Vec3f));
+ }
/* if previous data exists and mesh hasn't moved, no need to recalc */
- if (!surface_moved)
+ if (!surface_moved) {
return 1;
+ }
}
canvas_verts = (struct Vec3f *)MEM_mallocN(canvasNumOfVerts * sizeof(struct Vec3f),
"Dynamic Paint transformed canvas verts");
- if (!canvas_verts)
+ if (!canvas_verts) {
return 0;
+ }
/* allocate memory if required */
if (!bData) {
sData->bData = bData = (struct PaintBakeData *)MEM_callocN(sizeof(struct PaintBakeData),
"Dynamic Paint bake data");
if (!bData) {
- if (canvas_verts)
+ if (canvas_verts) {
MEM_freeN(canvas_verts);
+ }
return 0;
}
@@ -5999,16 +6120,21 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface,
/* if any allocation failed, free everything */
if (!bData->bNormal || !bData->s_pos || !bData->s_num || !bData->realCoord || !canvas_verts) {
- if (bData->bNormal)
+ if (bData->bNormal) {
MEM_freeN(bData->bNormal);
- if (bData->s_pos)
+ }
+ if (bData->s_pos) {
MEM_freeN(bData->s_pos);
- if (bData->s_num)
+ }
+ if (bData->s_num) {
MEM_freeN(bData->s_num);
- if (bData->realCoord)
+ }
+ if (bData->realCoord) {
MEM_freeN(bData->realCoord);
- if (canvas_verts)
+ }
+ if (canvas_verts) {
MEM_freeN(canvas_verts);
+ }
return setError(surface->canvas, N_("Not enough free memory"));
}
@@ -6024,8 +6150,9 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface,
bData->prev_velocity = (struct Vec3f *)MEM_mallocN(sData->total_points * sizeof(Vec3f),
"Dynamic Paint prev velocity");
/* copy previous vel */
- if (bData->prev_velocity && bData->velocity)
+ if (bData->prev_velocity && bData->velocity) {
memcpy(bData->prev_velocity, bData->velocity, sData->total_points * sizeof(Vec3f));
+ }
}
/*
@@ -6087,8 +6214,9 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph,
const bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
int ret = 1;
- if (sData->total_points < 1)
+ if (sData->total_points < 1) {
return 0;
+ }
if (dynamic_paint_surface_needs_dry_dissolve(surface)) {
DynamicPaintDissolveDryData data = {
@@ -6130,10 +6258,12 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph,
bData->brush_velocity = MEM_callocN(sData->total_points * sizeof(float) * 4,
"Dynamic Paint brush velocity");
/* init adjacency data if not already */
- if (!sData->adj_data)
+ if (!sData->adj_data) {
dynamicPaint_initAdjacencyData(surface, true);
- if (!bData->bNeighs)
+ }
+ if (!bData->bNeighs) {
dynamicPaint_prepareAdjacencyData(surface, true);
+ }
}
/* update object data on this subframe */
@@ -6180,8 +6310,10 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph,
/* process special brush effects, like smudge */
if (bData->brush_velocity) {
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && brush->flags & MOD_DPAINT_DO_SMUDGE)
+ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT &&
+ brush->flags & MOD_DPAINT_DO_SMUDGE) {
dynamicPaint_doSmudge(surface, brush, timescale);
+ }
MEM_freeN(bData->brush_velocity);
bData->brush_velocity = NULL;
}
@@ -6208,8 +6340,9 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph,
/* Allocate memory for surface previous points to read unchanged values from */
prevPoint = MEM_mallocN(sData->total_points * sizeof(struct PaintPoint),
"PaintSurfaceDataCopy");
- if (!prevPoint)
+ if (!prevPoint) {
return setError(canvas, N_("Not enough free memory"));
+ }
/* Prepare effects and get number of required steps */
steps = dynamicPaint_prepareEffectStep(depsgraph, surface, scene, ob, &force, timescale);
@@ -6218,10 +6351,12 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph,
}
/* Free temporary effect data */
- if (prevPoint)
+ if (prevPoint) {
MEM_freeN(prevPoint);
- if (force)
+ }
+ if (force) {
MEM_freeN(force);
+ }
}
/* paint island border pixels */
@@ -6259,8 +6394,9 @@ int dynamicPaint_calculateFrame(DynamicPaintSurface *surface,
for (st = 1; st <= surface->substeps; st++) {
float subframe = ((float)st) / (surface->substeps + 1);
- if (!dynamicPaint_doStep(depsgraph, scene, cObject, surface, timescale, subframe))
+ if (!dynamicPaint_doStep(depsgraph, scene, cObject, surface, timescale, subframe)) {
return 0;
+ }
}
}
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index e2b63b650fb..06f297b23e0 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -61,10 +61,12 @@
static void axis_from_enum_v3(float v[3], const char axis)
{
zero_v3(v);
- if (axis < 3)
+ if (axis < 3) {
v[axis] = 1.0f;
- else
+ }
+ else {
v[axis - 3] = -1.0f;
+ }
}
static void statvis_calc_overhang(BMEditMesh *em,
@@ -397,7 +399,7 @@ static void statvis_calc_sharp(BMEditMesh *em,
BMIter iter;
BMesh *bm = em->bm;
BMEdge *e;
- //float f_no[3];
+ // float f_no[3];
const float minmax_irange = 1.0f / (max - min);
int i;
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c
index 9c412c3c1b0..130f4ae88f1 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -115,8 +115,9 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em)
looptris = em->looptris;
}
else {
- if (em->looptris)
+ if (em->looptris) {
MEM_freeN(em->looptris);
+ }
looptris = MEM_mallocN(sizeof(*looptris) * looptris_tot, __func__);
}
@@ -160,19 +161,23 @@ void BKE_editmesh_free(BMEditMesh *em)
BKE_editmesh_color_free(em);
- if (em->looptris)
+ if (em->looptris) {
MEM_freeN(em->looptris);
+ }
- if (em->bm)
+ if (em->bm) {
BM_mesh_free(em->bm);
+ }
}
void BKE_editmesh_color_free(BMEditMesh *em)
{
- if (em->derivedVertColor)
+ if (em->derivedVertColor) {
MEM_freeN(em->derivedVertColor);
- if (em->derivedFaceColor)
+ }
+ if (em->derivedFaceColor) {
MEM_freeN(em->derivedFaceColor);
+ }
em->derivedVertColor = NULL;
em->derivedFaceColor = NULL;
@@ -228,11 +233,11 @@ void BKE_editmesh_lnorspace_update(BMEditMesh *em)
BMesh *bm = em->bm;
/* We need to create clnors data if none exist yet, otherwise there is no way to edit them.
- * Similar code to MESH_OT_customdata_custom_splitnormals_add operator, we want to keep same shading
- * in case we were using autosmooth so far...
- * Note: there is a problem here, which is that if someone starts a normal editing operation on previously
- * autosmooth-ed mesh, and cancel that operation, generated clnors data remain, with related sharp edges
- * (and hence autosmooth is 'lost').
+ * Similar code to MESH_OT_customdata_custom_splitnormals_add operator,
+ * we want to keep same shading in case we were using autosmooth so far.
+ * Note: there is a problem here, which is that if someone starts a normal editing operation on
+ * previously autosmooth-ed mesh, and cancel that operation, generated clnors data remain,
+ * with related sharp edges (and hence autosmooth is 'lost').
* Not sure how critical this is, and how to fix that issue? */
if (!CustomData_has_layer(&bm->ldata, CD_CUSTOMLOOPNORMAL)) {
Mesh *me = em->ob->data;
diff --git a/source/blender/blenkernel/intern/editmesh_bvh.c b/source/blender/blenkernel/intern/editmesh_bvh.c
index 31ea8fe581d..f23276d7be0 100644
--- a/source/blender/blenkernel/intern/editmesh_bvh.c
+++ b/source/blender/blenkernel/intern/editmesh_bvh.c
@@ -316,8 +316,9 @@ BMFace *BKE_bmbvh_ray_cast(BMBVHTree *bmtree,
struct RayCastUserData bmcb_data;
const float dist = r_dist ? *r_dist : FLT_MAX;
- if (bmtree->cos_cage)
+ if (bmtree->cos_cage) {
BLI_assert(!(bmtree->bm->elem_index_dirty & BM_VERT));
+ }
hit.dist = dist;
hit.index = -1;
@@ -380,8 +381,9 @@ BMFace *BKE_bmbvh_ray_cast_filter(BMBVHTree *bmtree,
bmcb_data_filter.filter_cb = filter_cb;
bmcb_data_filter.filter_userdata = filter_userdata;
- if (bmtree->cos_cage)
+ if (bmtree->cos_cage) {
BLI_assert(!(bmtree->bm->elem_index_dirty & BM_VERT));
+ }
hit.dist = dist;
hit.index = -1;
@@ -445,8 +447,9 @@ BMVert *BKE_bmbvh_find_vert_closest(BMBVHTree *bmtree, const float co[3], const
struct VertSearchUserData bmcb_data;
const float dist_max_sq = dist_max * dist_max;
- if (bmtree->cos_cage)
+ if (bmtree->cos_cage) {
BLI_assert(!(bmtree->bm->elem_index_dirty & BM_VERT));
+ }
hit.dist_sq = dist_max_sq;
hit.index = -1;
@@ -505,8 +508,9 @@ struct BMFace *BKE_bmbvh_find_face_closest(BMBVHTree *bmtree,
struct FaceSearchUserData bmcb_data;
const float dist_max_sq = dist_max * dist_max;
- if (bmtree->cos_cage)
+ if (bmtree->cos_cage) {
BLI_assert(!(bmtree->bm->elem_index_dirty & BM_VERT));
+ }
hit.dist_sq = dist_max_sq;
hit.index = -1;
diff --git a/source/blender/blenkernel/intern/editmesh_tangent.c b/source/blender/blenkernel/intern/editmesh_tangent.c
index 1bfd40c26af..df2fb8c8348 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -104,7 +104,7 @@ static void emdm_ts_GetPosition(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLEditMeshToTangent *pMesh = pContext->m_pUserData;
const BMLoop **lt;
const BMLoop *l;
@@ -138,7 +138,7 @@ static void emdm_ts_GetTextureCoordinate(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLEditMeshToTangent *pMesh = pContext->m_pUserData;
const BMLoop **lt;
const BMLoop *l;
@@ -176,7 +176,7 @@ static void emdm_ts_GetNormal(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLEditMeshToTangent *pMesh = pContext->m_pUserData;
const BMLoop **lt;
const BMLoop *l;
@@ -221,7 +221,7 @@ static void emdm_ts_SetTSpace(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLEditMeshToTangent *pMesh = pContext->m_pUserData;
const BMLoop **lt;
const BMLoop *l;
@@ -276,7 +276,8 @@ static void emDM_calc_loop_tangents_thread(TaskPool *__restrict UNUSED(pool),
/**
* \see #BKE_mesh_calc_loop_tangent, same logic but used arrays instead of #BMesh data.
*
- * \note This function is not so normal, its using `bm->ldata` as input, but output's to `dm->loopData`.
+ * \note This function is not so normal, its using `bm->ldata` as input,
+ * but output's to `dm->loopData`.
* This is done because #CD_TANGENT is cache data used only for drawing.
*/
void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
@@ -322,15 +323,18 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
}
}
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
- CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1)
+ CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1) {
CustomData_add_layer_named(
loopdata_out, CD_TANGENT, CD_CALLOC, NULL, (int)loopdata_out_len, "");
- if (calc_act && act_uv_name[0])
+ }
+ if (calc_act && act_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
&bm->ldata, loopdata_out, (int)loopdata_out_len, act_uv_name);
- if (calc_ren && ren_uv_name[0])
+ }
+ if (calc_ren && ren_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
&bm->ldata, loopdata_out, (int)loopdata_out_len, ren_uv_name);
+ }
int totface = em->tottri;
#ifdef USE_LOOPTRI_DETECT_QUADS
int num_face_as_quad_map;
@@ -379,9 +383,8 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
mesh2tangent->num_face_as_quad_map = num_face_as_quad_map;
#endif
mesh2tangent->precomputedFaceNormals = poly_normals;
- /* Note, we assume we do have tessellated loop normals at this point (in case it is object-enabled),
- * have to check this is valid...
- */
+ /* Note, we assume we do have tessellated loop normals at this point
+ * (in case it is object-enabled), have to check this is valid. */
mesh2tangent->precomputedLoopNormals = loop_normals;
mesh2tangent->cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, n);
@@ -389,8 +392,9 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
int htype_index = BM_LOOP;
if (mesh2tangent->cd_loop_uv_offset == -1) {
mesh2tangent->orco = vert_orco;
- if (!mesh2tangent->orco)
+ if (!mesh2tangent->orco) {
continue;
+ }
/* needed for orco lookups */
htype_index |= BM_VERT;
tangent_mask_curr |= DM_TANGENT_MASK_ORCO;
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 67b57d6f613..51715c3a223 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -171,8 +171,9 @@ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *ef
Curve *cu = eff->ob->data;
if (cu->flag & CU_PATH) {
if (eff->ob->runtime.curve_cache == NULL || eff->ob->runtime.curve_cache->path == NULL ||
- eff->ob->runtime.curve_cache->path->data == NULL)
+ eff->ob->runtime.curve_cache->path->data == NULL) {
BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, false, false, NULL);
+ }
if (eff->ob->runtime.curve_cache->path && eff->ob->runtime.curve_cache->path->data) {
where_on_path(
@@ -184,11 +185,13 @@ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *ef
}
else if (eff->pd->shape == PFIELD_SHAPE_SURFACE) {
eff->surmd = (SurfaceModifierData *)modifiers_findByType(eff->ob, eModifierType_Surface);
- if (eff->ob->type == OB_CURVE)
+ if (eff->ob->type == OB_CURVE) {
eff->flag |= PE_USE_NORMAL_DATA;
+ }
}
- else if (eff->psys)
+ else if (eff->psys) {
psys_update_particle_tree(eff->psys, ctime);
+ }
}
static void add_effector_relation(ListBase *relations,
@@ -356,11 +359,13 @@ void pd_point_from_particle(ParticleSimulationData *sim,
point->size = pa->size;
point->charge = 0.0f;
- if (part->pd && part->pd->forcefield == PFIELD_CHARGE)
+ if (part->pd && part->pd->forcefield == PFIELD_CHARGE) {
point->charge += part->pd->f_strength;
+ }
- if (part->pd2 && part->pd2->forcefield == PFIELD_CHARGE)
+ if (part->pd2 && part->pd2->forcefield == PFIELD_CHARGE) {
point->charge += part->pd2->f_strength;
+ }
point->vel_to_sec = 1.0f;
point->vel_to_frame = psys_get_timestep(sim);
@@ -371,8 +376,9 @@ void pd_point_from_particle(ParticleSimulationData *sim,
point->ave = state->ave;
point->rot = state->rot;
}
- else
+ else {
point->ave = point->rot = NULL;
+ }
point->psys = sim->psys;
}
@@ -482,8 +488,9 @@ static float eff_calc_visibility(ListBase *colliders,
}
}
- if (!colliders)
+ if (!colliders) {
BKE_collider_cache_free(&colls);
+ }
return visibility;
}
@@ -511,14 +518,17 @@ static float falloff_func(
float fac, int usemin, float mindist, int usemax, float maxdist, float power)
{
/* first quick checks */
- if (usemax && fac > maxdist)
+ if (usemax && fac > maxdist) {
return 0.0f;
+ }
- if (usemin && fac < mindist)
+ if (usemin && fac < mindist) {
return 1.0f;
+ }
- if (!usemin)
+ if (!usemin) {
mindist = 0.0;
+ }
return pow((double)(1.0f + fac - mindist), (double)(-power));
}
@@ -554,10 +564,12 @@ float effector_falloff(EffectorCache *eff,
fac = dot_v3v3(efd->nor, efd->vec_to_point2);
- if (eff->pd->zdir == PFIELD_Z_POS && fac < 0.0f)
+ if (eff->pd->zdir == PFIELD_Z_POS && fac < 0.0f) {
falloff = 0.0f;
- else if (eff->pd->zdir == PFIELD_Z_NEG && fac > 0.0f)
+ }
+ else if (eff->pd->zdir == PFIELD_Z_NEG && fac > 0.0f) {
falloff = 0.0f;
+ }
else {
switch (eff->pd->falloff) {
case PFIELD_FALL_SPHERE:
@@ -566,8 +578,9 @@ float effector_falloff(EffectorCache *eff,
case PFIELD_FALL_TUBE:
falloff *= falloff_func_dist(eff->pd, ABS(fac));
- if (falloff == 0.0f)
+ if (falloff == 0.0f) {
break;
+ }
madd_v3_v3v3fl(temp, efd->vec_to_point2, efd->nor, -fac);
r_fac = len_v3(temp);
@@ -575,8 +588,9 @@ float effector_falloff(EffectorCache *eff,
break;
case PFIELD_FALL_CONE:
falloff *= falloff_func_dist(eff->pd, ABS(fac));
- if (falloff == 0.0f)
+ if (falloff == 0.0f) {
break;
+ }
r_fac = RAD2DEGF(saacos(fac / len_v3(efd->vec_to_point2)));
falloff *= falloff_func_rad(eff->pd, r_fac);
@@ -632,8 +646,8 @@ int get_effector_data(EffectorCache *eff,
float cfra = DEG_get_ctime(eff->depsgraph);
int ret = 0;
- /* In case surface object is in Edit mode when loading the .blend, surface modifier is never executed
- * and bvhtree never built, see T48415. */
+ /* In case surface object is in Edit mode when loading the .blend,
+ * surface modifier is never executed and bvhtree never built, see T48415. */
if (eff->pd && eff->pd->shape == PFIELD_SHAPE_SURFACE && eff->surmd && eff->surmd->bvhtree) {
/* closest point in the object surface is an effector */
float vec[3];
@@ -684,7 +698,7 @@ int get_effector_data(EffectorCache *eff,
ret = psys_get_particle_state(&sim, *efd->index, &state, 0);
/* TODO */
- //if (eff->pd->forcefiled == PFIELD_HARMONIC && ret==0) {
+ // if (eff->pd->forcefiled == PFIELD_HARMONIC && ret==0) {
// if (pa->dietime < eff->psys->cfra)
// eff->flag |= PE_VELOCITY_TO_IMPULSE;
//}
@@ -736,9 +750,11 @@ int get_effector_data(EffectorCache *eff,
sub_v3_v3v3(efd->vec_to_point, point->loc, efd->loc);
efd->distance = len_v3(efd->vec_to_point);
- /* rest length for harmonic effector, will have to see later if this could be extended to other effectors */
- if (eff->pd && eff->pd->forcefield == PFIELD_HARMONIC && eff->pd->f_size)
+ /* Rest length for harmonic effector,
+ * will have to see later if this could be extended to other effectors. */
+ if (eff->pd && eff->pd->forcefield == PFIELD_HARMONIC && eff->pd->f_size) {
mul_v3_fl(efd->vec_to_point, (efd->distance - eff->pd->f_size) / efd->distance);
+ }
if (eff->flag & PE_USE_NORMAL_DATA) {
copy_v3_v3(efd->vec_to_point2, efd->vec_to_point);
@@ -810,8 +826,9 @@ static void do_texture_effector(EffectorCache *eff,
short mode = eff->pd->tex_mode;
bool scene_color_manage;
- if (!eff->pd->tex)
+ if (!eff->pd->tex) {
return;
+ }
result[0].nor = result[1].nor = result[2].nor = result[3].nor = NULL;
@@ -822,8 +839,9 @@ static void do_texture_effector(EffectorCache *eff,
if (eff->pd->flag & PFIELD_TEX_OBJECT) {
mul_m4_v3(eff->ob->imat, tex_co);
- if (eff->pd->flag & PFIELD_TEX_2D)
+ if (eff->pd->flag & PFIELD_TEX_2D) {
tex_co[2] = 0.0f;
+ }
}
else if (eff->pd->flag & PFIELD_TEX_2D) {
float fac = -dot_v3v3(tex_co, efd->nor);
@@ -955,11 +973,13 @@ static void do_physical_effector(EffectorCache *eff,
}
break;
case PFIELD_MAGNET:
- if (ELEM(eff->pd->shape, PFIELD_SHAPE_POINT, PFIELD_SHAPE_LINE))
+ if (ELEM(eff->pd->shape, PFIELD_SHAPE_POINT, PFIELD_SHAPE_LINE)) {
/* magnetic field of a moving charge */
cross_v3_v3v3(temp, efd->nor, efd->vec_to_point);
- else
+ }
+ else {
copy_v3_v3(temp, efd->nor);
+ }
normalize_v3(temp);
mul_v3_fl(temp, strength * efd->falloff);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 4a2a610918c..8c95e4c7ff3 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -81,8 +81,9 @@ static CLG_LogRef LOG = {"bke.fcurve"};
/* Frees the F-Curve itself too, so make sure BLI_remlink is called before calling this... */
void free_fcurve(FCurve *fcu)
{
- if (fcu == NULL)
+ if (fcu == NULL) {
return;
+ }
/* free curve data */
MEM_SAFE_FREE(fcu->bezt);
@@ -105,8 +106,9 @@ void free_fcurves(ListBase *list)
FCurve *fcu, *fcn;
/* sanity check */
- if (list == NULL)
+ if (list == NULL) {
return;
+ }
/* free data - no need to call remlink before freeing each curve,
* as we store reference to next, and freeing only touches the curve
@@ -129,8 +131,9 @@ FCurve *copy_fcurve(const FCurve *fcu)
FCurve *fcu_d;
/* sanity check */
- if (fcu == NULL)
+ if (fcu == NULL) {
return NULL;
+ }
/* make a copy */
fcu_d = MEM_dupallocN(fcu);
@@ -161,8 +164,9 @@ void copy_fcurves(ListBase *dst, ListBase *src)
FCurve *dfcu, *sfcu;
/* sanity checks */
- if (ELEM(NULL, dst, src))
+ if (ELEM(NULL, dst, src)) {
return;
+ }
/* clear destination list first */
BLI_listbase_clear(dst);
@@ -189,12 +193,14 @@ FCurve *id_data_find_fcurve(
PropertyRNA *prop;
char *path;
- if (r_driven)
+ if (r_driven) {
*r_driven = false;
+ }
/* only use the current action ??? */
- if (ELEM(NULL, adt, adt->action))
+ if (ELEM(NULL, adt, adt->action)) {
return NULL;
+ }
RNA_pointer_create(id, type, data, &ptr);
prop = RNA_struct_find_property(&ptr, prop_name);
@@ -204,14 +210,16 @@ FCurve *id_data_find_fcurve(
if (path) {
/* animation takes priority over drivers */
- if ((adt->action) && (adt->action->curves.first))
+ if ((adt->action) && (adt->action->curves.first)) {
fcu = list_find_fcurve(&adt->action->curves, path, index);
+ }
/* if not animated, check if driven */
if ((fcu == NULL) && (adt->drivers.first)) {
fcu = list_find_fcurve(&adt->drivers, path, index);
- if (fcu && r_driven)
+ if (fcu && r_driven) {
*r_driven = true;
+ }
fcu = NULL;
}
@@ -222,22 +230,25 @@ FCurve *id_data_find_fcurve(
return fcu;
}
-/* Find the F-Curve affecting the given RNA-access path + index, in the list of F-Curves provided */
+/* Find the F-Curve affecting the given RNA-access path + index,
+ * in the list of F-Curves provided. */
FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index)
{
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, list, rna_path) || (array_index < 0))
+ if (ELEM(NULL, list, rna_path) || (array_index < 0)) {
return NULL;
+ }
/* check paths of curves, then array indices... */
for (fcu = list->first; fcu; fcu = fcu->next) {
/* simple string-compare (this assumes that they have the same root...) */
if (fcu->rna_path && STREQ(fcu->rna_path, rna_path)) {
/* now check indices */
- if (fcu->array_index == array_index)
+ if (fcu->array_index == array_index) {
return fcu;
+ }
}
}
@@ -251,8 +262,9 @@ FCurve *iter_step_fcurve(FCurve *fcu_iter, const char rna_path[])
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, fcu_iter, rna_path))
+ if (ELEM(NULL, fcu_iter, rna_path)) {
return NULL;
+ }
/* check paths of curves, then array indices... */
for (fcu = fcu_iter; fcu; fcu = fcu->next) {
@@ -266,7 +278,10 @@ FCurve *iter_step_fcurve(FCurve *fcu_iter, const char rna_path[])
return NULL;
}
-/* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated
+/**
+ * Get list of LinkData's containing pointers to the F-Curves
+ * which control the types of data indicated.
+ *
* Lists...
* - dst: list of LinkData's matching the criteria returned.
* List must be freed after use, and is assumed to be empty when passed.
@@ -284,10 +299,12 @@ int list_find_data_fcurves(ListBase *dst,
int matches = 0;
/* sanity checks */
- if (ELEM(NULL, dst, src, dataPrefix, dataName))
+ if (ELEM(NULL, dst, src, dataPrefix, dataName)) {
return 0;
- else if ((dataPrefix[0] == 0) || (dataName[0] == 0))
+ }
+ else if ((dataPrefix[0] == 0) || (dataName[0] == 0)) {
return 0;
+ }
/* search each F-Curve one by one */
for (fcu = src->first; fcu; fcu = fcu->next) {
@@ -343,10 +360,12 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
*r_driven = false;
*r_special = false;
- if (r_animdata)
+ if (r_animdata) {
*r_animdata = NULL;
- if (r_action)
+ }
+ if (r_action) {
*r_action = NULL;
+ }
/* Special case for NLA Control Curves... */
if (BKE_nlastrip_has_curves_for_property(ptr, prop)) {
@@ -365,9 +384,9 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
/* there must be some RNA-pointer + property combon */
if (prop && tptr.id.data && RNA_property_animateable(&tptr, prop)) {
AnimData *adt = BKE_animdata_from_id(tptr.id.data);
- int step =
- C ? 2 :
- 1; /* Always 1 in case we have no context (can't check in 'ancestors' of given RNA ptr). */
+ int step = (
+ /* Always 1 in case we have no context (can't check in 'ancestors' of given RNA ptr). */
+ C ? 2 : 1);
char *path = NULL;
if (!adt && C) {
@@ -390,8 +409,9 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
if (adt->action && adt->action->curves.first) {
fcu = list_find_fcurve(&adt->action->curves, path, rnaindex);
- if (fcu && r_action)
+ if (fcu && r_action) {
*r_action = adt->action;
+ }
}
/* if not animated, check if driven */
@@ -399,15 +419,17 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
fcu = list_find_fcurve(&adt->drivers, path, rnaindex);
if (fcu) {
- if (r_animdata)
+ if (r_animdata) {
*r_animdata = adt;
+ }
*r_driven = true;
}
}
if (fcu && r_action) {
- if (r_animdata)
+ if (r_animdata) {
*r_animdata = adt;
+ }
*r_action = adt->action;
break;
}
@@ -433,7 +455,8 @@ FCurve *rna_get_fcurve_context_ui(bContext *C,
/* ----------------- Finding Keyframes/Extents -------------------------- */
-/* Binary search algorithm for finding where to insert BezTriple, with optional argument for precision required.
+/* Binary search algorithm for finding where to insert BezTriple,
+ * with optional argument for precision required.
* Returns the index to insert at (data already at that index will be offset if replace is 0)
*/
static int binarysearch_bezt_index_ex(
@@ -463,8 +486,9 @@ static int binarysearch_bezt_index_ex(
*r_replace = true;
return 0;
}
- else if (frame < framenum)
+ else if (frame < framenum) {
return 0;
+ }
/* 'Last' Keyframe */
framenum = array[(arraylen - 1)].vec[1][0];
@@ -472,8 +496,9 @@ static int binarysearch_bezt_index_ex(
*r_replace = true;
return (arraylen - 1);
}
- else if (frame > framenum)
+ else if (frame > framenum) {
return arraylen;
+ }
}
/* most of the time, this loop is just to find where to put it
@@ -492,10 +517,12 @@ static int binarysearch_bezt_index_ex(
}
/* repeat in upper/lower half */
- if (frame > midfra)
+ if (frame > midfra) {
start = mid + 1;
- else if (frame < midfra)
+ }
+ else if (frame < midfra) {
end = mid - 1;
+ }
}
/* print error if loop-limit exceeded */
@@ -539,8 +566,9 @@ static short get_fcurve_end_keyframes(FCurve *fcu,
*last = NULL;
/* sanity checks */
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
return found;
+ }
/* only include selected items? */
if (do_sel_only) {
@@ -625,8 +653,8 @@ bool calc_fcurve_bounds(FCurve *fcu,
if (include_handles) {
/* left handle - only if applicable
- * NOTE: for the very first keyframe, the left handle actually has no bearings on anything
- */
+ * NOTE: for the very first keyframe,
+ * the left handle actually has no bearings on anything. */
if (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)) {
yminv = min_ff(yminv, bezt->vec[0][1]);
ymaxv = max_ff(ymaxv, bezt->vec[0][1]);
@@ -656,10 +684,12 @@ bool calc_fcurve_bounds(FCurve *fcu,
FPoint *fpt;
for (fpt = fcu->fpt, i = 0; i < fcu->totvert; fpt++, i++) {
- if (fpt->vec[1] < yminv)
+ if (fpt->vec[1] < yminv) {
yminv = fpt->vec[1];
- if (fpt->vec[1] > ymaxv)
+ }
+ if (fpt->vec[1] > ymaxv) {
ymaxv = fpt->vec[1];
+ }
foundvert = true;
}
@@ -668,29 +698,38 @@ bool calc_fcurve_bounds(FCurve *fcu,
}
if (foundvert) {
- if (xmin)
+ if (xmin) {
*xmin = xminv;
- if (xmax)
+ }
+ if (xmax) {
*xmax = xmaxv;
+ }
- if (ymin)
+ if (ymin) {
*ymin = yminv;
- if (ymax)
+ }
+ if (ymax) {
*ymax = ymaxv;
+ }
}
else {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("F-Curve calc bounds didn't find anything, so assuming minimum bounds of 1.0\n");
+ }
- if (xmin)
+ if (xmin) {
*xmin = 0.0f;
- if (xmax)
+ }
+ if (xmax) {
*xmax = 1.0f;
+ }
- if (ymin)
+ if (ymin) {
*ymin = 0.0f;
- if (ymax)
+ }
+ if (ymax) {
*ymax = 1.0f;
+ }
}
return foundvert;
@@ -753,12 +792,14 @@ bool calc_fcurve_range(
bool fcurve_are_keyframes_usable(FCurve *fcu)
{
/* F-Curve must exist */
- if (fcu == NULL)
+ if (fcu == NULL) {
return false;
+ }
/* F-Curve must not have samples - samples are mutually exclusive of keyframes */
- if (fcu->fpt)
+ if (fcu->fpt) {
return false;
+ }
/* if it has modifiers, none of these should "drastically" alter the curve */
if (fcu->modifiers.first) {
@@ -768,8 +809,9 @@ bool fcurve_are_keyframes_usable(FCurve *fcu)
/* TODO: optionally, only check modifier if it is the active one... */
for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) {
/* ignore if muted/disabled */
- if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED))
+ if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) {
continue;
+ }
/* type checks */
switch (fcm->type) {
@@ -783,15 +825,17 @@ bool fcurve_are_keyframes_usable(FCurve *fcu)
case FMODIFIER_TYPE_GENERATOR: {
FMod_Generator *data = (FMod_Generator *)fcm->data;
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) {
return false;
+ }
break;
}
case FMODIFIER_TYPE_FN_GENERATOR: {
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data;
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) {
return false;
+ }
break;
}
/* always harmful - cannot allow */
@@ -816,12 +860,14 @@ bool BKE_fcurve_is_protected(FCurve *fcu)
bool fcurve_is_keyframable(FCurve *fcu)
{
/* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on final result) */
- if (fcurve_are_keyframes_usable(fcu) == 0)
+ if (fcurve_are_keyframes_usable(fcu) == 0) {
return false;
+ }
/* F-Curve must currently be editable too */
- if (BKE_fcurve_is_protected(fcu))
+ if (BKE_fcurve_is_protected(fcu)) {
return false;
+ }
/* F-Curve is keyframable */
return true;
@@ -837,21 +883,25 @@ void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt)
for (ce = lb->first; ce; ce = ce->next) {
/* double key? */
if (IS_EQT(ce->cfra, bezt->vec[1][0], BEZT_BINARYSEARCH_THRESH)) {
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
ce->sel = bezt->f2;
+ }
return;
}
/* should key be inserted before this column? */
- else if (ce->cfra > bezt->vec[1][0])
+ else if (ce->cfra > bezt->vec[1][0]) {
break;
+ }
}
/* create a new column */
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
- if (ce)
+ if (ce) {
BLI_insertlinkbefore(lb, ce, cen);
- else
+ }
+ else {
BLI_addtail(lb, cen);
+ }
cen->cfra = bezt->vec[1][0];
cen->sel = bezt->f2;
@@ -901,10 +951,12 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample
}
/* free any existing sample/keyframe data on curve */
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
- if (fcu->fpt)
+ }
+ if (fcu->fpt) {
MEM_freeN(fcu->fpt);
+ }
/* store the samples */
fcu->bezt = NULL;
@@ -952,28 +1004,32 @@ eFCU_Cycle_Type BKE_fcurve_get_cycle_type(FCurve *fcu)
return FCU_CYCLE_NONE;
}
-/* Checks if the F-Curve has a Cycles modifier with simple settings that warrant transition smoothing */
+/* Checks if the F-Curve has a Cycles modifier with simple settings
+ * that warrant transition smoothing. */
bool BKE_fcurve_is_cyclic(FCurve *fcu)
{
return BKE_fcurve_get_cycle_type(fcu) != FCU_CYCLE_NONE;
}
-/* Shifts 'in' by the difference in coordinates between 'to' and 'from', using 'out' as the output buffer.
+/* Shifts 'in' by the difference in coordinates between 'to' and 'from',
+ * using 'out' as the output buffer.
* When 'to' and 'from' are end points of the loop, this moves the 'in' point one loop cycle.
*/
static BezTriple *cycle_offset_triple(
bool cycle, BezTriple *out, const BezTriple *in, const BezTriple *from, const BezTriple *to)
{
- if (!cycle)
+ if (!cycle) {
return NULL;
+ }
memcpy(out, in, sizeof(BezTriple));
float delta[3];
sub_v3_v3v3(delta, to->vec[1], from->vec[1]);
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
add_v3_v3(out->vec[i], delta);
+ }
return out;
}
@@ -991,8 +1047,9 @@ void calchandles_fcurve(FCurve *fcu)
* - need bezier keys
* - only bezier-interpolation has handles (for now)
*/
- if (ELEM(NULL, fcu, fcu->bezt) || (a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN)*/)
+ if (ELEM(NULL, fcu, fcu->bezt) || (a < 2) /*|| ELEM(fcu->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN)*/) {
return;
+ }
/* if the first modifier is Cycles, smooth the curve through the cycle */
BezTriple *first = &fcu->bezt[0], *last = &fcu->bezt[fcu->totvert - 1];
@@ -1008,10 +1065,12 @@ void calchandles_fcurve(FCurve *fcu)
/* loop over all beztriples, adjusting handles */
while (a--) {
/* clamp timing of handles to be on either side of beztriple */
- if (bezt->vec[0][0] > bezt->vec[1][0])
+ if (bezt->vec[0][0] > bezt->vec[1][0]) {
bezt->vec[0][0] = bezt->vec[1][0];
- if (bezt->vec[2][0] < bezt->vec[1][0])
+ }
+ if (bezt->vec[2][0] < bezt->vec[1][0]) {
bezt->vec[2][0] = bezt->vec[1][0];
+ }
/* calculate auto-handles */
BKE_nurb_handle_calc(bezt, prev, next, true, fcu->auto_smoothing);
@@ -1066,8 +1125,9 @@ void testhandles_fcurve(FCurve *fcu, const bool use_handle)
unsigned int a;
/* only beztriples have handles (bpoints don't though) */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return;
+ }
/* loop over beztriples */
for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) {
@@ -1126,8 +1186,9 @@ short test_time_fcurve(FCurve *fcu)
unsigned int a;
/* sanity checks */
- if (fcu == NULL)
+ if (fcu == NULL) {
return 0;
+ }
/* currently, only need to test beztriples */
if (fcu->bezt) {
@@ -1135,8 +1196,9 @@ short test_time_fcurve(FCurve *fcu)
/* loop through all BezTriples, stopping when one exceeds the one after it */
for (a = 0, bezt = fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) {
- if (bezt->vec[1][0] > (bezt + 1)->vec[1][0])
+ if (bezt->vec[1][0] > (bezt + 1)->vec[1][0]) {
return 1;
+ }
}
}
else if (fcu->fpt) {
@@ -1144,8 +1206,9 @@ short test_time_fcurve(FCurve *fcu)
/* loop through all FPoints, stopping when one exceeds the one after it */
for (a = 0, fpt = fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) {
- if (fpt->vec[0] > (fpt + 1)->vec[0])
+ if (fpt->vec[0] > (fpt + 1)->vec[0]) {
return 1;
+ }
}
}
@@ -1178,12 +1241,16 @@ typedef struct DriverVarTypeInfo {
static ID *dtar_id_ensure_proxy_from(ID *id)
{
- if (id && GS(id->name) == ID_OB && ((Object *)id)->proxy_from)
+ if (id && GS(id->name) == ID_OB && ((Object *)id)->proxy_from) {
return (ID *)(((Object *)id)->proxy_from);
+ }
return id;
}
-/* Helper function to obtain a value using RNA from the specified source (for evaluating drivers) */
+/**
+ * Helper function to obtain a value using RNA from the specified source
+ * (for evaluating drivers).
+ */
static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar)
{
PointerRNA id_ptr, ptr;
@@ -1193,8 +1260,9 @@ static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar)
float value = 0.0f;
/* sanity check */
- if (ELEM(NULL, driver, dtar))
+ if (ELEM(NULL, driver, dtar)) {
return 0.0f;
+ }
id = dtar_id_ensure_proxy_from(dtar->id);
@@ -1301,8 +1369,9 @@ bool driver_get_variable_property(ChannelDriver *driver,
int index = -1;
/* sanity check */
- if (ELEM(NULL, driver, dtar))
+ if (ELEM(NULL, driver, dtar)) {
return false;
+ }
id = dtar_id_ensure_proxy_from(dtar->id);
@@ -1703,10 +1772,12 @@ static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = {
static const DriverVarTypeInfo *get_dvar_typeinfo(int type)
{
/* check if valid type */
- if ((type >= 0) && (type < MAX_DVAR_TYPES))
+ if ((type >= 0) && (type < MAX_DVAR_TYPES)) {
return &dvar_types[type];
- else
+ }
+ else {
return NULL;
+ }
}
/* Driver API --------------------------------- */
@@ -1715,8 +1786,9 @@ static const DriverVarTypeInfo *get_dvar_typeinfo(int type)
void driver_free_variable(ListBase *variables, DriverVar *dvar)
{
/* sanity checks */
- if (dvar == NULL)
+ if (dvar == NULL) {
return;
+ }
/* free target vars
* - need to go over all of them, not just up to the ones that are used
@@ -1725,8 +1797,9 @@ void driver_free_variable(ListBase *variables, DriverVar *dvar)
*/
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* free RNA path if applicable */
- if (dtar->rna_path)
+ if (dtar->rna_path) {
MEM_freeN(dtar->rna_path);
+ }
}
DRIVER_TARGETS_LOOPER_END;
@@ -1754,8 +1827,9 @@ void driver_variables_copy(ListBase *dst_vars, const ListBase *src_vars)
/* need to go over all targets so that we don't leave any dangling paths */
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* make a copy of target's rna path if available */
- if (dtar->rna_path)
+ if (dtar->rna_path) {
dtar->rna_path = MEM_dupallocN(dtar->rna_path);
+ }
}
DRIVER_TARGETS_LOOPER_END;
}
@@ -1767,8 +1841,9 @@ void driver_change_variable_type(DriverVar *dvar, int type)
const DriverVarTypeInfo *dvti = get_dvar_typeinfo(type);
/* sanity check */
- if (ELEM(NULL, dvar, dvti))
+ if (ELEM(NULL, dvar, dvti)) {
return;
+ }
/* set the new settings */
dvar->type = type;
@@ -1784,8 +1859,9 @@ void driver_change_variable_type(DriverVar *dvar, int type)
dtar->flag = flags;
/* object ID types only, or idtype not yet initialized */
- if ((flags & DTAR_FLAG_ID_OB_ONLY) || (dtar->idtype == 0))
+ if ((flags & DTAR_FLAG_ID_OB_ONLY) || (dtar->idtype == 0)) {
dtar->idtype = ID_OB;
+ }
}
DRIVER_TARGETS_LOOPER_END;
}
@@ -1800,8 +1876,9 @@ void driver_variable_name_validate(DriverVar *dvar)
};
/* sanity checks */
- if (dvar == NULL)
+ if (dvar == NULL) {
return;
+ }
/* clear all invalid-name flags */
dvar->flag &= ~DVAR_ALL_INVALID_FLAGS;
@@ -1812,12 +1889,14 @@ void driver_variable_name_validate(DriverVar *dvar)
}
/* 1) Must start with a letter */
- /* XXX: We assume that valid unicode letters in other languages are ok too, hence the blacklisting */
+ /* XXX: We assume that valid unicode letters in other languages are ok too,
+ * hence the blacklisting. */
if (IN_RANGE_INCL(dvar->name[0], '0', '9')) {
dvar->flag |= DVAR_FLAG_INVALID_START_NUM;
}
else if (dvar->name[0] == '_') {
- /* NOTE: We don't allow names to start with underscores (i.e. it helps when ruling out security risks) */
+ /* NOTE: We don't allow names to start with underscores
+ * (i.e. it helps when ruling out security risks) */
dvar->flag |= DVAR_FLAG_INVALID_START_CHAR;
}
@@ -1833,10 +1912,12 @@ void driver_variable_name_validate(DriverVar *dvar)
for (int i = 0; i < sizeof(special_char_blacklist); i++) {
char *match = strchr(dvar->name, special_char_blacklist[i]);
- if (match == dvar->name)
+ if (match == dvar->name) {
dvar->flag |= DVAR_FLAG_INVALID_START_CHAR;
- else if (match != NULL)
+ }
+ else if (match != NULL) {
dvar->flag |= DVAR_FLAG_INVALID_HAS_SPECIAL;
+ }
}
/* 4) Check if the name is a reserved keyword
@@ -1850,8 +1931,9 @@ void driver_variable_name_validate(DriverVar *dvar)
#endif
/* If any these conditions match, the name is invalid */
- if (dvar->flag & DVAR_ALL_INVALID_FLAGS)
+ if (dvar->flag & DVAR_ALL_INVALID_FLAGS) {
dvar->flag |= DVAR_FLAG_INVALID_NAME;
+ }
}
/* Add a new driver variable */
@@ -1860,8 +1942,9 @@ DriverVar *driver_add_new_variable(ChannelDriver *driver)
DriverVar *dvar;
/* sanity checks */
- if (driver == NULL)
+ if (driver == NULL) {
return NULL;
+ }
/* make a new variable */
dvar = MEM_callocN(sizeof(DriverVar), "DriverVar");
@@ -1893,8 +1976,9 @@ void fcurve_free_driver(FCurve *fcu)
DriverVar *dvar, *dvarn;
/* sanity checks */
- if (ELEM(NULL, fcu, fcu->driver))
+ if (ELEM(NULL, fcu, fcu->driver)) {
return;
+ }
driver = fcu->driver;
/* free driver targets */
@@ -1905,13 +1989,15 @@ void fcurve_free_driver(FCurve *fcu)
#ifdef WITH_PYTHON
/* free compiled driver expression */
- if (driver->expr_comp)
+ if (driver->expr_comp) {
BPY_DECREF(driver->expr_comp);
+ }
#endif
BLI_expr_pylike_free(driver->expr_simple);
- /* free driver itself, then set F-Curve's point to this to NULL (as the curve may still be used) */
+ /* Free driver itself, then set F-Curve's point to this to NULL
+ * (as the curve may still be used). */
MEM_freeN(driver);
fcu->driver = NULL;
}
@@ -1922,8 +2008,9 @@ ChannelDriver *fcurve_copy_driver(const ChannelDriver *driver)
ChannelDriver *ndriver;
/* sanity checks */
- if (driver == NULL)
+ if (driver == NULL) {
return NULL;
+ }
/* copy all data */
ndriver = MEM_dupallocN(driver);
@@ -1931,9 +2018,9 @@ ChannelDriver *fcurve_copy_driver(const ChannelDriver *driver)
ndriver->expr_simple = NULL;
/* copy variables */
- BLI_listbase_clear(
- &ndriver
- ->variables); /* to get rid of refs to non-copied data (that's still used on original) */
+
+ /* to get rid of refs to non-copied data (that's still used on original) */
+ BLI_listbase_clear(&ndriver->variables);
driver_variables_copy(&ndriver->variables, &driver->variables);
/* return the new driver */
@@ -2074,8 +2161,9 @@ float driver_get_variable_value(ChannelDriver *driver, DriverVar *dvar)
const DriverVarTypeInfo *dvti;
/* sanity check */
- if (ELEM(NULL, driver, dvar))
+ if (ELEM(NULL, driver, dvar)) {
return 0.0f;
+ }
/* call the relevant callbacks to get the variable value
* using the variable type info, storing the obtained value
@@ -2083,10 +2171,12 @@ float driver_get_variable_value(ChannelDriver *driver, DriverVar *dvar)
*/
dvti = get_dvar_typeinfo(dvar->type);
- if (dvti && dvti->get_value)
+ if (dvti && dvti->get_value) {
dvar->curval = dvti->get_value(driver, dvar);
- else
+ }
+ else {
dvar->curval = 0.0f;
+ }
return dvar->curval;
}
@@ -2104,8 +2194,9 @@ float evaluate_driver(PathResolvedRNA *anim_rna,
DriverVar *dvar;
/* check if driver can be evaluated */
- if (driver_orig->flag & DRIVER_FLAG_INVALID)
+ if (driver_orig->flag & DRIVER_FLAG_INVALID) {
return 0.0f;
+ }
switch (driver->type) {
case DRIVER_TYPE_AVERAGE: /* average values of driver targets */
@@ -2129,10 +2220,12 @@ float evaluate_driver(PathResolvedRNA *anim_rna,
}
/* perform operations on the total if appropriate */
- if (driver->type == DRIVER_TYPE_AVERAGE)
+ if (driver->type == DRIVER_TYPE_AVERAGE) {
driver->curval = tot ? (value / (float)tot) : 0.0f;
- else
+ }
+ else {
driver->curval = value;
+ }
}
break;
}
@@ -2151,13 +2244,15 @@ float evaluate_driver(PathResolvedRNA *anim_rna,
/* check if greater/smaller than the baseline */
if (driver->type == DRIVER_TYPE_MAX) {
/* max? */
- if (tmp_val > value)
+ if (tmp_val > value) {
value = tmp_val;
+ }
}
else {
/* min? */
- if (tmp_val < value)
+ if (tmp_val < value) {
value = tmp_val;
+ }
}
}
else {
@@ -2232,8 +2327,9 @@ void correct_bezpart(float v1[2], float v2[2], float v3[2], float v4[2])
len2 = fabsf(h2[0]);
/* if the handles have no length, no need to do any corrections */
- if ((len1 + len2) == 0.0f)
+ if ((len1 + len2) == 0.0f) {
return;
+ }
/* the two handles cross over each other, so force them
* apart using the proportion they overlap
@@ -2274,23 +2370,28 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
t = sqrt(d);
o[0] = (float)(sqrt3d(-q + t) + sqrt3d(-q - t) - a);
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
else if (d == 0.0) {
t = sqrt3d(-q);
o[0] = (float)(2 * t - a);
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
nr++;
+ }
o[nr] = (float)(-t - a);
- if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f))
+ if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
return nr + 1;
- else
+ }
+ else {
return nr;
+ }
}
else {
phi = acos(-q / sqrt(-(p * p * p)));
@@ -2299,18 +2400,22 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
q = sqrt(3 - 3 * p * p);
o[0] = (float)(2 * t * p - a);
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
nr++;
+ }
o[nr] = (float)(-t * (p + q) - a);
- if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f))
+ if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
nr++;
+ }
o[nr] = (float)(-t * (p - q) - a);
- if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f))
+ if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
return nr + 1;
- else
+ }
+ else {
return nr;
+ }
}
}
else {
@@ -2326,30 +2431,37 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
p = sqrt(p);
o[0] = (float)((-b - p) / (2 * a));
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
nr++;
+ }
o[nr] = (float)((-b + p) / (2 * a));
- if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f))
+ if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) {
return nr + 1;
- else
+ }
+ else {
return nr;
+ }
}
else if (p == 0) {
o[0] = (float)(-b / (2 * a));
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
}
else if (b != 0.0) {
o[0] = (float)(-c / b);
- if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f))
+ if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
else if (c == 0.0) {
o[0] = 0.0;
@@ -2504,14 +2616,14 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
/* Use binary search to find appropriate keyframes...
*
* The threshold here has the following constraints:
- * - 0.001 is too coarse -> We get artifacts with 2cm driver movements at 1BU = 1m (see T40332)
- * - 0.00001 is too fine -> Weird errors, like selecting the wrong keyframe range (see T39207), occur.
- * This lower bound was established in b888a32eee8147b028464336ad2404d8155c64dd
+ * - 0.001 is too coarse:
+ * We get artifacts with 2cm driver movements at 1BU = 1m (see T40332)
+ *
+ * - 0.00001 is too fine:
+ * Weird errors, like selecting the wrong keyframe range (see T39207), occur.
+ * This lower bound was established in b888a32eee8147b028464336ad2404d8155c64dd.
*/
a = binarysearch_bezt_index_ex(bezts, evaltime, fcu->totvert, 0.0001, &exact);
- if (G.debug & G_DEBUG)
- printf(
- "eval fcurve '%s' - %f => %u/%u, %d\n", fcu->rna_path, evaltime, a, fcu->totvert, exact);
if (exact) {
/* index returned must be interpreted differently when it sits on top of an existing keyframe
@@ -2528,7 +2640,8 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
prevbezt = (a > 0) ? (bezt - 1) : bezt;
}
- /* use if the key is directly on the frame, rare cases this is needed else we get 0.0 instead. */
+ /* use if the key is directly on the frame,
+ * rare cases this is needed else we get 0.0 instead. */
/* XXX: consult T39207 for examples of files where failure of these checks can cause issues */
if (exact) {
cvalue = prevbezt->vec[1][1];
@@ -2586,13 +2699,14 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
/* break; */
}
else {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf(" ERROR: findzero() failed at %f with %f %f %f %f\n",
evaltime,
v1[0],
v2[0],
v3[0],
v4[0]);
+ }
}
}
break;
@@ -2795,12 +2909,13 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
}
}
else {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf(" ERROR: failed eval - p=%f b=%f, t=%f (%f)\n",
prevbezt->vec[1][0],
bezt->vec[1][0],
evaltime,
fabsf(bezt->vec[1][0] - evaltime));
+ }
}
}
@@ -2834,10 +2949,12 @@ static float fcurve_eval_samples(FCurve *fcu, FPoint *fpts, float evaltime)
fpt = prevfpt + ((int)evaltime - (int)prevfpt->vec[0]);
/* if not exactly on the frame, perform linear interpolation with the next one */
- if ((t != 0.0f) && (t < 1.0f))
+ if ((t != 0.0f) && (t < 1.0f)) {
cvalue = interpf(fpt->vec[1], (fpt + 1)->vec[1], 1.0f - t);
- else
+ }
+ else {
cvalue = fpt->vec[1];
+ }
}
/* return value */
@@ -2851,32 +2968,36 @@ static float fcurve_eval_samples(FCurve *fcu, FPoint *fpts, float evaltime)
*/
static float evaluate_fcurve_ex(FCurve *fcu, float evaltime, float cvalue)
{
- FModifierStackStorage *storage;
float devaltime;
/* evaluate modifiers which modify time to evaluate the base curve at */
- storage = evaluate_fmodifiers_storage_new(&fcu->modifiers);
- devaltime = evaluate_time_fmodifiers(storage, &fcu->modifiers, fcu, cvalue, evaltime);
+ FModifiersStackStorage storage;
+ storage.modifier_count = BLI_listbase_count(&fcu->modifiers);
+ storage.size_per_modifier = evaluate_fmodifiers_storage_size_per_modifier(&fcu->modifiers);
+ storage.buffer = alloca(storage.modifier_count * storage.size_per_modifier);
+
+ devaltime = evaluate_time_fmodifiers(&storage, &fcu->modifiers, fcu, cvalue, evaltime);
/* evaluate curve-data
* - 'devaltime' instead of 'evaltime', as this is the time that the last time-modifying
* F-Curve modifier on the stack requested the curve to be evaluated at
*/
- if (fcu->bezt)
+ if (fcu->bezt) {
cvalue = fcurve_eval_keyframes(fcu, fcu->bezt, devaltime);
- else if (fcu->fpt)
+ }
+ else if (fcu->fpt) {
cvalue = fcurve_eval_samples(fcu, fcu->fpt, devaltime);
+ }
/* evaluate modifiers */
- evaluate_value_fmodifiers(storage, &fcu->modifiers, fcu, &cvalue, devaltime);
-
- evaluate_fmodifiers_storage_free(storage);
+ evaluate_value_fmodifiers(&storage, &fcu->modifiers, fcu, &cvalue, devaltime);
/* if curve can only have integral values, perform truncation (i.e. drop the decimal part)
* here so that the curve can be sampled correctly
*/
- if (fcu->flag & FCURVE_INT_VALUES)
+ if (fcu->flag & FCURVE_INT_VALUES) {
cvalue = floorf(cvalue + 0.5f);
+ }
/* return evaluated value */
return cvalue;
@@ -2905,9 +3026,9 @@ float evaluate_fcurve_driver(PathResolvedRNA *anim_rna,
BLI_assert(fcu->driver != NULL);
float cvalue = 0.0f;
- /* if there is a driver (only if this F-Curve is acting as 'driver'), evaluate it to find value to use as "evaltime"
- * since drivers essentially act as alternative input (i.e. in place of 'time') for F-Curves
- */
+ /* If there is a driver (only if this F-Curve is acting as 'driver'),
+ * evaluate it to find value to use as "evaltime" since drivers essentially act as alternative
+ * input (i.e. in place of 'time') for F-Curves. */
if (fcu->driver) {
/* evaltime now serves as input for the curve */
evaltime = evaluate_driver(anim_rna, fcu->driver, driver_orig, evaltime);
@@ -2924,12 +3045,12 @@ float evaluate_fcurve_driver(PathResolvedRNA *anim_rna,
/* if there are range-restrictions, we must definitely block [#36950] */
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) {
- /* within range: here it probably doesn't matter, though we'd want to check on additive... */
+ /* Within range: here it probably doesn't matter,
+ * though we'd want to check on additive. */
}
else {
- /* outside range: modifier shouldn't contribute to the curve here, though it does in other areas,
- * so neither should the driver!
- */
+ /* Outside range: modifier shouldn't contribute to the curve here,
+ * though it does in other areas, so neither should the driver! */
do_linear = false;
}
}
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index d54a3bdaa37..c6188642e41 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -48,11 +48,6 @@ static CLG_LogRef LOG = {"bke.fmodifier"};
/* ******************************** F-Modifiers ********************************* */
-/* Forward declarations. */
-void fmodifiers_storage_put(FModifierStackStorage *storage, FModifier *fcm, void *data);
-void fmodifiers_storage_remove(FModifierStackStorage *storage, FModifier *fcm);
-void *fmodifiers_storage_get(FModifierStackStorage *storage, FModifier *fcm);
-
/* Info ------------------------------- */
/* F-Modifiers are modifiers which operate on F-Curves. However, they can also be defined
@@ -75,25 +70,24 @@ void *fmodifiers_storage_get(FModifierStackStorage *storage, FModifier *fcm);
* for such cases, just use NULL
* - these should be defined after all the functions have been defined, so that
* forward-definitions/prototypes don't need to be used!
- * - keep this copy #if-def'd so that future constraints can get based off this
+ * - keep this copy #if-def'd so that future modifier can get based off this
*/
#if 0
static FModifierTypeInfo FMI_MODNAME = {
- FMODIFIER_TYPE_MODNAME, /* type */
- sizeof(FMod_ModName), /* size */
- FMI_TYPE_SOME_ACTION, /* action type */
- FMI_REQUIRES_SOME_REQUIREMENT, /* requirements */
- "Modifier Name", /* name */
- "FMod_ModName", /* struct name */
- fcm_modname_free, /* free data */
- fcm_modname_relink, /* relink data */
- fcm_modname_copy, /* copy data */
- fcm_modname_new_data, /* new data */
- fcm_modname_verify, /* verify */
- fcm_modname_time, /* evaluate time */
- fcm_modname_evaluate, /* evaluate */
- fcm_modname_time_storage, /* evaluate time with storage */
- fcm_modname_evaluate_storage, /* evaluate with storage */
+ FMODIFIER_TYPE_MODNAME, /* type */
+ sizeof(FMod_ModName), /* size */
+ FMI_TYPE_SOME_ACTION, /* action type */
+ FMI_REQUIRES_SOME_REQUIREMENT, /* requirements */
+ "Modifier Name", /* name */
+ "FMod_ModName", /* struct name */
+ 0, /* storage size */
+ fcm_modname_free, /* free data */
+ fcm_modname_relink, /* relink data */
+ fcm_modname_copy, /* copy data */
+ fcm_modname_new_data, /* new data */
+ fcm_modname_verify, /* verify */
+ fcm_modname_time, /* evaluate time */
+ fcm_modname_evaluate, /* evaluate */
};
#endif
@@ -101,8 +95,10 @@ static FModifierTypeInfo FMI_MODNAME = {
/* Generators available:
* 1) simple polynomial generator:
- * - Expanded form - (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... + C[n])
- * - Factorized form - (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1]))
+ * - Expanded form:
+ * (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... + C[n])
+ * - Factorized form:
+ * (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1]))
*/
static void fcm_generator_free(FModifier *fcm)
@@ -110,8 +106,9 @@ static void fcm_generator_free(FModifier *fcm)
FMod_Generator *data = (FMod_Generator *)fcm->data;
/* free polynomial coefficients array */
- if (data->coefficients)
+ if (data->coefficients) {
MEM_freeN(data->coefficients);
+ }
}
static void fcm_generator_copy(FModifier *fcm, const FModifier *src)
@@ -120,8 +117,9 @@ static void fcm_generator_copy(FModifier *fcm, const FModifier *src)
FMod_Generator *ogen = (FMod_Generator *)src->data;
/* copy coefficients array? */
- if (ogen->coefficients)
+ if (ogen->coefficients) {
gen->coefficients = MEM_dupallocN(ogen->coefficients);
+ }
}
static void fcm_generator_new_data(void *mdata)
@@ -166,10 +164,8 @@ static void fcm_generator_verify(FModifier *fcm)
}
}
-static void fcm_generator_evaluate(FCurve *UNUSED(fcu),
- FModifier *fcm,
- float *cvalue,
- float evaltime)
+static void fcm_generator_evaluate(
+ FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime, void *UNUSED(storage))
{
FMod_Generator *data = (FMod_Generator *)fcm->data;
@@ -189,27 +185,33 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu),
*/
for (i = 0; i < data->arraysize; i++) {
/* first entry is x^0 = 1, otherwise, calculate based on previous */
- if (i)
+ if (i) {
powers[i] = powers[i - 1] * evaltime;
- else
+ }
+ else {
powers[0] = 1;
+ }
}
/* for each coefficient, add to value, which we'll write to *cvalue in one go */
- for (i = 0; i < data->arraysize; i++)
+ for (i = 0; i < data->arraysize; i++) {
value += data->coefficients[i] * powers[i];
+ }
/* only if something changed, write *cvalue in one go */
if (data->poly_order) {
- if (data->flag & FCM_GENERATOR_ADDITIVE)
+ if (data->flag & FCM_GENERATOR_ADDITIVE) {
*cvalue += value;
- else
+ }
+ else {
*cvalue = value;
+ }
}
/* cleanup */
- if (powers)
+ if (powers) {
MEM_freeN(powers);
+ }
break;
}
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial */
@@ -217,17 +219,20 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu),
float value = 1.0f, *cp = NULL;
unsigned int i;
- /* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */
- for (cp = data->coefficients, i = 0; (cp) && (i < (unsigned int)data->poly_order);
- cp += 2, i++)
+ /* For each coefficient pair,
+ * solve for that bracket before accumulating in value by multiplying. */
+ for (cp = data->coefficients, i = 0; (cp) && (i < (uint)data->poly_order); cp += 2, i++) {
value *= (cp[0] * evaltime + cp[1]);
+ }
/* only if something changed, write *cvalue in one go */
if (data->poly_order) {
- if (data->flag & FCM_GENERATOR_ADDITIVE)
+ if (data->flag & FCM_GENERATOR_ADDITIVE) {
*cvalue += value;
- else
+ }
+ else {
*cvalue = value;
+ }
}
break;
}
@@ -241,14 +246,13 @@ static FModifierTypeInfo FMI_GENERATOR = {
FMI_REQUIRES_NOTHING, /* requirements */
N_("Generator"), /* name */
"FMod_Generator", /* struct name */
+ 0, /* storage size */
fcm_generator_free, /* free data */
fcm_generator_copy, /* copy data */
fcm_generator_new_data, /* new data */
fcm_generator_verify, /* verify */
NULL, /* evaluate time */
fcm_generator_evaluate, /* evaluate */
- NULL, /* evaluate time with storage */
- NULL, /* evaluate with storage */
};
/* Built-In Function Generator F-Curve Modifier --------------------------- */
@@ -278,16 +282,16 @@ static void fcm_fn_generator_new_data(void *mdata)
*/
static double sinc(double x)
{
- if (fabs(x) < 0.0001)
+ if (fabs(x) < 0.0001) {
return 1.0;
- else
+ }
+ else {
return sin(M_PI * x) / (M_PI * x);
+ }
}
-static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu),
- FModifier *fcm,
- float *cvalue,
- float evaltime)
+static void fcm_fn_generator_evaluate(
+ FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime, void *UNUSED(storage))
{
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data;
double arg = data->phase_multiplier * evaltime + data->phase_offset;
@@ -313,11 +317,13 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu),
{
/* check that argument is not on one of the discontinuities (i.e. 90deg, 270 deg, etc) */
if (IS_EQ(fmod((arg - M_PI_2), M_PI), 0.0)) {
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) {
*cvalue = 0.0f; /* no value possible here */
+ }
}
- else
+ else {
fn = tan;
+ }
break;
}
case FCM_GENERATOR_FN_LN: /* natural log */
@@ -327,8 +333,9 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu),
fn = log;
}
else {
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) {
*cvalue = 0.0f; /* no value possible here */
+ }
}
break;
}
@@ -339,8 +346,9 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu),
fn = sqrt;
}
else {
- if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
+ if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) {
*cvalue = 0.0f; /* no value possible here */
+ }
}
break;
}
@@ -353,10 +361,12 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu),
if (fn) {
float value = (float)(data->amplitude * (float)fn(arg) + data->value_offset);
- if (data->flag & FCM_GENERATOR_ADDITIVE)
+ if (data->flag & FCM_GENERATOR_ADDITIVE) {
*cvalue += value;
- else
+ }
+ else {
*cvalue = value;
+ }
}
}
@@ -367,14 +377,13 @@ static FModifierTypeInfo FMI_FN_GENERATOR = {
FMI_REQUIRES_NOTHING, /* requirements */
N_("Built-In Function"), /* name */
"FMod_FunctionGenerator", /* struct name */
+ 0, /* storage size */
NULL, /* free data */
NULL, /* copy data */
fcm_fn_generator_new_data, /* new data */
NULL, /* verify */
NULL, /* evaluate time */
fcm_fn_generator_evaluate, /* evaluate */
- NULL, /* evaluate time with storage */
- NULL, /* evaluate with storage */
};
/* Envelope F-Curve Modifier --------------------------- */
@@ -384,8 +393,9 @@ static void fcm_envelope_free(FModifier *fcm)
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
/* free envelope data array */
- if (env->data)
+ if (env->data) {
MEM_freeN(env->data);
+ }
}
static void fcm_envelope_copy(FModifier *fcm, const FModifier *src)
@@ -394,8 +404,9 @@ static void fcm_envelope_copy(FModifier *fcm, const FModifier *src)
FMod_Envelope *oenv = (FMod_Envelope *)src->data;
/* copy envelope data array */
- if (oenv->data)
+ if (oenv->data) {
env->data = MEM_dupallocN(oenv->data);
+ }
}
static void fcm_envelope_new_data(void *mdata)
@@ -417,10 +428,8 @@ static void fcm_envelope_verify(FModifier *fcm)
}
}
-static void fcm_envelope_evaluate(FCurve *UNUSED(fcu),
- FModifier *fcm,
- float *cvalue,
- float evaltime)
+static void fcm_envelope_evaluate(
+ FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime, void *UNUSED(storage))
{
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
FCM_EnvelopeData *fed, *prevfed, *lastfed;
@@ -428,8 +437,9 @@ static void fcm_envelope_evaluate(FCurve *UNUSED(fcu),
int a;
/* get pointers */
- if (env->data == NULL)
+ if (env->data == NULL) {
return;
+ }
prevfed = env->data;
fed = prevfed + 1;
lastfed = prevfed + (env->totvert - 1);
@@ -480,14 +490,13 @@ static FModifierTypeInfo FMI_ENVELOPE = {
0, /* requirements */
N_("Envelope"), /* name */
"FMod_Envelope", /* struct name */
+ 0, /* storage size */
fcm_envelope_free, /* free data */
fcm_envelope_copy, /* copy data */
fcm_envelope_new_data, /* new data */
fcm_envelope_verify, /* verify */
NULL, /* evaluate time */
fcm_envelope_evaluate, /* evaluate */
- NULL, /* evaluate time with storage */
- NULL, /* evaluate with storage */
};
/* exported function for finding points */
@@ -587,14 +596,14 @@ int BKE_fcm_envelope_find_index(FCM_EnvelopeData array[],
/* This modifier changes evaltime to something that exists within the curve's frame-range,
* then re-evaluates modifier stack up to this point using the new time. This re-entrant behavior
- * is very likely to be more time-consuming than the original approach... (which was tightly integrated into
- * the calculation code...).
+ * is very likely to be more time-consuming than the original approach...
+ * (which was tightly integrated into the calculation code...).
*
- * NOTE: this needs to be at the start of the stack to be of use, as it needs to know the extents of the
- * keyframes/sample-data.
+ * NOTE: this needs to be at the start of the stack to be of use,
+ * as it needs to know the extents of the keyframes/sample-data.
*
- * Possible TODO - store length of cycle information that can be initialized from the extents of the
- * keyframes/sample-data, and adjusted as appropriate.
+ * Possible TODO - store length of cycle information that can be initialized from the extents of
+ * the keyframes/sample-data, and adjusted as appropriate.
*/
/* temp data used during evaluation */
@@ -610,18 +619,19 @@ static void fcm_cycles_new_data(void *mdata)
data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC;
}
-static float fcm_cycles_time(FModifierStackStorage *storage,
- FCurve *fcu,
- FModifier *fcm,
- float UNUSED(cvalue),
- float evaltime)
+static float fcm_cycles_time(
+ FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime, void *storage_)
{
FMod_Cycles *data = (FMod_Cycles *)fcm->data;
+ tFCMED_Cycles *storage = storage_;
float prevkey[2], lastkey[2], cycyofs = 0.0f;
short side = 0, mode = 0;
int cycles = 0;
float ofs = 0;
+ /* Initialize storage. */
+ storage->cycyofs = 0;
+
/* check if modifier is first in stack, otherwise disable ourself... */
/* FIXME... */
if (fcm->prev) {
@@ -650,8 +660,9 @@ static float fcm_cycles_time(FModifierStackStorage *storage,
lastkey[0] = lastfpt->vec[0];
lastkey[1] = lastfpt->vec[1];
}
- else
+ else {
return evaltime;
+ }
/* check if modifier will do anything
* 1) if in data range, definitely don't do anything
@@ -673,8 +684,9 @@ static float fcm_cycles_time(FModifierStackStorage *storage,
ofs = lastkey[0];
}
}
- if ((ELEM(0, side, mode)))
+ if ((ELEM(0, side, mode))) {
return evaltime;
+ }
/* find relative place within a cycle */
{
@@ -686,8 +698,9 @@ static float fcm_cycles_time(FModifierStackStorage *storage,
cycdy = lastkey[1] - prevkey[1];
/* check if cycle is infinitely small, to be point of being impossible to use */
- if (cycdx == 0)
+ if (cycdx == 0) {
return evaltime;
+ }
/* calculate the 'number' of the cycle */
cycle = ((float)side * (evaltime - ofs) / cycdx);
@@ -710,10 +723,12 @@ static float fcm_cycles_time(FModifierStackStorage *storage,
/* check if 'cyclic extrapolation', and thus calculate y-offset for this cycle */
if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) {
- if (side < 0)
+ if (side < 0) {
cycyofs = (float)floor((evaltime - ofs) / cycdx);
- else
+ }
+ else {
cycyofs = (float)ceil((evaltime - ofs) / cycdx);
+ }
cycyofs *= cycdy;
}
@@ -721,77 +736,66 @@ static float fcm_cycles_time(FModifierStackStorage *storage,
if (cyct == 0.0f) {
evaltime = (side == 1 ? lastkey[0] : prevkey[0]);
- if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)cycle % 2))
+ if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)cycle % 2)) {
evaltime = (side == 1 ? prevkey[0] : lastkey[0]);
+ }
}
/* calculate where in the cycle we are (overwrite evaltime to reflect this) */
else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle + 1) % 2)) {
- /* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse
+ /* When 'mirror' option is used and cycle number is odd, this cycle is played in reverse
* - for 'before' extrapolation, we need to flip in a different way, otherwise values past
- * then end of the curve get referenced (result of fmod will be negative, and with different phase)
+ * then end of the curve get referenced
+ * (result of fmod will be negative, and with different phase).
*/
- if (side < 0)
+ if (side < 0) {
evaltime = prevkey[0] - cyct;
- else
+ }
+ else {
evaltime = lastkey[0] - cyct;
+ }
}
else {
/* the cycle is played normally... */
evaltime = prevkey[0] + cyct;
}
- if (evaltime < prevkey[0])
+ if (evaltime < prevkey[0]) {
evaltime += cycdx;
+ }
}
/* store temp data if needed */
if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) {
- tFCMED_Cycles *edata;
-
- /* for now, this is just a float, but we could get more stuff... */
- edata = MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles");
- edata->cycyofs = cycyofs;
-
- fmodifiers_storage_put(storage, fcm, edata);
+ storage->cycyofs = cycyofs;
}
/* return the new frame to evaluate */
return evaltime;
}
-static void fcm_cycles_evaluate(FModifierStackStorage *storage,
- FCurve *UNUSED(fcu),
- FModifier *fcm,
+static void fcm_cycles_evaluate(FCurve *UNUSED(fcu),
+ FModifier *UNUSED(fcm),
float *cvalue,
- float UNUSED(evaltime))
+ float UNUSED(evaltime),
+ void *storage_)
{
- tFCMED_Cycles *edata = fmodifiers_storage_get(storage, fcm);
-
- /* use temp data */
- if (edata) {
- /* add cyclic offset - no need to check for now, otherwise the data wouldn't exist! */
- *cvalue += edata->cycyofs;
-
- /* free temp data */
- MEM_freeN(edata);
- fmodifiers_storage_remove(storage, fcm);
- }
+ tFCMED_Cycles *storage = storage_;
+ *cvalue += storage->cycyofs;
}
static FModifierTypeInfo FMI_CYCLES = {
- FMODIFIER_TYPE_CYCLES, /* type */
- sizeof(FMod_Cycles), /* size */
- FMI_TYPE_EXTRAPOLATION, /* action type */
- FMI_REQUIRES_ORIGINAL_DATA | FMI_REQUIRES_STORAGE, /* requirements */
- N_("Cycles"), /* name */
- "FMod_Cycles", /* struct name */
- NULL, /* free data */
- NULL, /* copy data */
- fcm_cycles_new_data, /* new data */
- NULL /*fcm_cycles_verify*/, /* verify */
- NULL, /* evaluate time */
- NULL, /* evaluate */
- fcm_cycles_time, /* evaluate time with storage */
- fcm_cycles_evaluate, /* evaluate with storage */
+ FMODIFIER_TYPE_CYCLES, /* type */
+ sizeof(FMod_Cycles), /* size */
+ FMI_TYPE_EXTRAPOLATION, /* action type */
+ FMI_REQUIRES_ORIGINAL_DATA, /* requirements */
+ N_("Cycles"), /* name */
+ "FMod_Cycles", /* struct name */
+ sizeof(tFCMED_Cycles), /* storage size */
+ NULL, /* free data */
+ NULL, /* copy data */
+ fcm_cycles_new_data, /* new data */
+ NULL /*fcm_cycles_verify*/, /* verify */
+ fcm_cycles_time, /* evaluate time */
+ fcm_cycles_evaluate, /* evaluate */
};
/* Noise F-Curve Modifier --------------------------- */
@@ -809,7 +813,8 @@ static void fcm_noise_new_data(void *mdata)
data->modification = FCM_NOISE_MODIF_REPLACE;
}
-static void fcm_noise_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime)
+static void fcm_noise_evaluate(
+ FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime, void *UNUSED(storage))
{
FMod_Noise *data = (FMod_Noise *)fcm->data;
float noise;
@@ -845,14 +850,13 @@ static FModifierTypeInfo FMI_NOISE = {
0, /* requirements */
N_("Noise"), /* name */
"FMod_Noise", /* struct name */
+ 0, /* storage size */
NULL, /* free data */
NULL, /* copy data */
fcm_noise_new_data, /* new data */
NULL /*fcm_noise_verify*/, /* verify */
NULL, /* evaluate time */
fcm_noise_evaluate, /* evaluate */
- NULL, /* evaluate time with storage */
- NULL, /* evaluate with storage */
};
/* Python F-Curve Modifier --------------------------- */
@@ -886,10 +890,11 @@ static void fcm_python_copy(FModifier *fcm, const FModifier *src)
static void fcm_python_evaluate(FCurve *UNUSED(fcu),
FModifier *UNUSED(fcm),
float *UNUSED(cvalue),
- float UNUSED(evaltime))
+ float UNUSED(evaltime),
+ void *UNUSED(storage))
{
#ifdef WITH_PYTHON
- //FMod_Python *data = (FMod_Python *)fcm->data;
+ // FMod_Python *data = (FMod_Python *)fcm->data;
/* FIXME... need to implement this modifier...
* It will need it execute a script using the custom properties
@@ -904,14 +909,13 @@ static FModifierTypeInfo FMI_PYTHON = {
FMI_REQUIRES_RUNTIME_CHECK, /* requirements */
N_("Python"), /* name */
"FMod_Python", /* struct name */
+ 0, /* storage size */
fcm_python_free, /* free data */
fcm_python_copy, /* copy data */
fcm_python_new_data, /* new data */
NULL /*fcm_python_verify*/, /* verify */
NULL /*fcm_python_time*/, /* evaluate time */
fcm_python_evaluate, /* evaluate */
- NULL, /* evaluate time with storage */
- NULL, /* evaluate with storage */
};
/* Limits F-Curve Modifier --------------------------- */
@@ -919,15 +923,18 @@ static FModifierTypeInfo FMI_PYTHON = {
static float fcm_limits_time(FCurve *UNUSED(fcu),
FModifier *fcm,
float UNUSED(cvalue),
- float evaltime)
+ float evaltime,
+ void *UNUSED(storage))
{
FMod_Limits *data = (FMod_Limits *)fcm->data;
/* check for the time limits */
- if ((data->flag & FCM_LIMIT_XMIN) && (evaltime < data->rect.xmin))
+ if ((data->flag & FCM_LIMIT_XMIN) && (evaltime < data->rect.xmin)) {
return data->rect.xmin;
- if ((data->flag & FCM_LIMIT_XMAX) && (evaltime > data->rect.xmax))
+ }
+ if ((data->flag & FCM_LIMIT_XMAX) && (evaltime > data->rect.xmax)) {
return data->rect.xmax;
+ }
/* modifier doesn't change time */
return evaltime;
@@ -936,15 +943,18 @@ static float fcm_limits_time(FCurve *UNUSED(fcu),
static void fcm_limits_evaluate(FCurve *UNUSED(fcu),
FModifier *fcm,
float *cvalue,
- float UNUSED(evaltime))
+ float UNUSED(evaltime),
+ void *UNUSED(storage))
{
FMod_Limits *data = (FMod_Limits *)fcm->data;
/* value limits now */
- if ((data->flag & FCM_LIMIT_YMIN) && (*cvalue < data->rect.ymin))
+ if ((data->flag & FCM_LIMIT_YMIN) && (*cvalue < data->rect.ymin)) {
*cvalue = data->rect.ymin;
- if ((data->flag & FCM_LIMIT_YMAX) && (*cvalue > data->rect.ymax))
+ }
+ if ((data->flag & FCM_LIMIT_YMAX) && (*cvalue > data->rect.ymax)) {
*cvalue = data->rect.ymax;
+ }
}
static FModifierTypeInfo FMI_LIMITS = {
@@ -955,14 +965,13 @@ static FModifierTypeInfo FMI_LIMITS = {
FMI_REQUIRES_RUNTIME_CHECK, /* requirements */
N_("Limits"), /* name */
"FMod_Limits", /* struct name */
+ 0, /* storage size */
NULL, /* free data */
NULL, /* copy data */
NULL, /* new data */
NULL, /* verify */
fcm_limits_time, /* evaluate time */
fcm_limits_evaluate, /* evaluate */
- NULL, /* evaluate time with storage */
- NULL, /* evaluate with storage */
};
/* Stepped F-Curve Modifier --------------------------- */
@@ -979,19 +988,22 @@ static void fcm_stepped_new_data(void *mdata)
static float fcm_stepped_time(FCurve *UNUSED(fcu),
FModifier *fcm,
float UNUSED(cvalue),
- float evaltime)
+ float evaltime,
+ void *UNUSED(storage))
{
FMod_Stepped *data = (FMod_Stepped *)fcm->data;
int snapblock;
/* check range clamping to see if we should alter the timing to achieve the desired results */
if (data->flag & FCM_STEPPED_NO_BEFORE) {
- if (evaltime < data->start_frame)
+ if (evaltime < data->start_frame) {
return evaltime;
+ }
}
if (data->flag & FCM_STEPPED_NO_AFTER) {
- if (evaltime > data->end_frame)
+ if (evaltime > data->end_frame) {
return evaltime;
+ }
}
/* we snap to the start of the previous closest block of 'step_size' frames
@@ -1014,14 +1026,13 @@ static FModifierTypeInfo FMI_STEPPED = {
FMI_REQUIRES_RUNTIME_CHECK, /* requirements */
N_("Stepped"), /* name */
"FMod_Stepped", /* struct name */
+ 0, /* storage size */
NULL, /* free data */
NULL, /* copy data */
fcm_stepped_new_data, /* new data */
NULL, /* verify */
fcm_stepped_time, /* evaluate time */
NULL, /* evaluate */
- NULL, /* evaluate time with storage */
- NULL, /* evaluate with storage */
};
/* F-Curve Modifier API --------------------------- */
@@ -1077,10 +1088,12 @@ const FModifierTypeInfo *get_fmodifier_typeinfo(const int type)
const FModifierTypeInfo *fmodifier_get_typeinfo(const FModifier *fcm)
{
/* only return typeinfo for valid modifiers */
- if (fcm)
+ if (fcm) {
return get_fmodifier_typeinfo(fcm->type);
- else
+ }
+ else {
return NULL;
+ }
}
/* API --------------------------- */
@@ -1092,8 +1105,9 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
FModifier *fcm;
/* sanity checks */
- if (ELEM(NULL, modifiers, fmi))
+ if (ELEM(NULL, modifiers, fmi)) {
return NULL;
+ }
/* special checks for whether modifier can be added */
if ((modifiers->first) && (type == FMODIFIER_TYPE_CYCLES)) {
@@ -1114,19 +1128,22 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
BLI_addtail(modifiers, fcm);
/* tag modifier as "active" if no other modifiers exist in the stack yet */
- if (BLI_listbase_is_single(modifiers))
+ if (BLI_listbase_is_single(modifiers)) {
fcm->flag |= FMODIFIER_FLAG_ACTIVE;
+ }
/* add modifier's data */
fcm->data = MEM_callocN(fmi->size, fmi->structName);
/* init custom settings if necessary */
- if (fmi->new_data)
+ if (fmi->new_data) {
fmi->new_data(fcm->data);
+ }
/* update the fcurve if the Cycles modifier is added */
- if ((owner_fcu) && (type == FMODIFIER_TYPE_CYCLES))
+ if ((owner_fcu) && (type == FMODIFIER_TYPE_CYCLES)) {
calchandles_fcurve(owner_fcu);
+ }
/* return modifier for further editing */
return fcm;
@@ -1139,8 +1156,9 @@ FModifier *copy_fmodifier(const FModifier *src)
FModifier *dst;
/* sanity check */
- if (src == NULL)
+ if (src == NULL) {
return NULL;
+ }
/* copy the base data, clearing the links */
dst = MEM_dupallocN(src);
@@ -1151,8 +1169,9 @@ FModifier *copy_fmodifier(const FModifier *src)
dst->data = MEM_dupallocN(src->data);
/* only do specific constraints if required */
- if (fmi && fmi->copy_data)
+ if (fmi && fmi->copy_data) {
fmi->copy_data(dst, src);
+ }
/* return the new modifier */
return dst;
@@ -1163,8 +1182,9 @@ void copy_fmodifiers(ListBase *dst, const ListBase *src)
{
FModifier *fcm, *srcfcm;
- if (ELEM(NULL, dst, src))
+ if (ELEM(NULL, dst, src)) {
return;
+ }
BLI_listbase_clear(dst);
BLI_duplicatelist(dst, src);
@@ -1178,8 +1198,9 @@ void copy_fmodifiers(ListBase *dst, const ListBase *src)
fcm->curve = NULL;
/* only do specific constraints if required */
- if (fmi && fmi->copy_data)
+ if (fmi && fmi->copy_data) {
fmi->copy_data(fcm, srcfcm);
+ }
}
}
@@ -1189,16 +1210,18 @@ bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
/* sanity check */
- if (fcm == NULL)
+ if (fcm == NULL) {
return false;
+ }
/* removing the cycles modifier requires a handle update */
FCurve *update_fcu = (fcm->type == FMODIFIER_TYPE_CYCLES) ? fcm->curve : NULL;
/* free modifier's special data (stored inside fcm->data) */
if (fcm->data) {
- if (fmi && fmi->free_data)
+ if (fmi && fmi->free_data) {
fmi->free_data(fcm);
+ }
/* free modifier's data (fcm->data) */
MEM_freeN(fcm->data);
@@ -1209,8 +1232,9 @@ bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
BLI_freelinkN(modifiers, fcm);
/* update the fcurve if the Cycles modifier is removed */
- if (update_fcu)
+ if (update_fcu) {
calchandles_fcurve(update_fcu);
+ }
return true;
}
@@ -1228,8 +1252,9 @@ void free_fmodifiers(ListBase *modifiers)
FModifier *fcm, *fmn;
/* sanity check */
- if (modifiers == NULL)
+ if (modifiers == NULL) {
return;
+ }
/* free each modifier in order - modifier is unlinked from list and freed */
for (fcm = modifiers->first; fcm; fcm = fmn) {
@@ -1244,13 +1269,15 @@ FModifier *find_active_fmodifier(ListBase *modifiers)
FModifier *fcm;
/* sanity checks */
- if (ELEM(NULL, modifiers, modifiers->first))
+ if (ELEM(NULL, modifiers, modifiers->first)) {
return NULL;
+ }
/* loop over modifiers until 'active' one is found */
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
- if (fcm->flag & FMODIFIER_FLAG_ACTIVE)
+ if (fcm->flag & FMODIFIER_FLAG_ACTIVE) {
return fcm;
+ }
}
/* no modifier is active */
@@ -1263,16 +1290,19 @@ void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
FModifier *fm;
/* sanity checks */
- if (ELEM(NULL, modifiers, modifiers->first))
+ if (ELEM(NULL, modifiers, modifiers->first)) {
return;
+ }
/* deactivate all, and set current one active */
- for (fm = modifiers->first; fm; fm = fm->next)
+ for (fm = modifiers->first; fm; fm = fm->next) {
fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
+ }
/* make given modifier active */
- if (fcm)
+ if (fcm) {
fcm->flag |= FMODIFIER_FLAG_ACTIVE;
+ }
}
/* Do we have any modifiers which match certain criteria
@@ -1284,12 +1314,14 @@ bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
FModifier *fcm;
/* if there are no specific filtering criteria, just skip */
- if ((mtype == 0) && (acttype == 0))
+ if ((mtype == 0) && (acttype == 0)) {
return (modifiers && modifiers->first);
+ }
/* sanity checks */
- if (ELEM(NULL, modifiers, modifiers->first))
+ if (ELEM(NULL, modifiers, modifiers->first)) {
return false;
+ }
/* find the first mdifier fitting these criteria */
for (fcm = modifiers->first; fcm; fcm = fcm->next) {
@@ -1297,14 +1329,17 @@ bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
short mOk = 1, aOk = 1; /* by default 1, so that when only one test, won't fail */
/* check if applicable ones are fulfilled */
- if (mtype)
+ if (mtype) {
mOk = (fcm->type == mtype);
- if (acttype > -1)
+ }
+ if (acttype > -1) {
aOk = (fmi->acttype == acttype);
+ }
/* if both are ok, we've found a hit */
- if (mOk && aOk)
+ if (mOk && aOk) {
return true;
+ }
}
/* no matches */
@@ -1313,57 +1348,26 @@ bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype)
/* Evaluation API --------------------------- */
-FModifierStackStorage *evaluate_fmodifiers_storage_new(ListBase *modifiers)
+uint evaluate_fmodifiers_storage_size_per_modifier(ListBase *modifiers)
{
- FModifier *fcm;
-
/* Sanity checks. */
- if (ELEM(NULL, modifiers, modifiers->last)) {
- return NULL;
+ if (ELEM(NULL, modifiers, modifiers->first)) {
+ return 0;
}
- for (fcm = modifiers->last; fcm; fcm = fcm->prev) {
+ uint max_size = 0;
+
+ for (FModifier *fcm = modifiers->first; fcm; fcm = fcm->next) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
if (fmi == NULL) {
continue;
}
- if (fmi->requires & FMI_REQUIRES_STORAGE) {
- return (FModifierStackStorage *)BLI_ghash_new(
- BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "fmodifier stack temp storage");
- }
- }
-
- return NULL;
-}
-
-void evaluate_fmodifiers_storage_free(FModifierStackStorage *storage)
-{
- if (storage != NULL) {
- BLI_ghash_free((GHash *)storage, NULL, NULL);
+ max_size = MAX2(max_size, fmi->storage_size);
}
-}
-
-void fmodifiers_storage_put(FModifierStackStorage *storage, FModifier *fcm, void *data)
-{
- BLI_assert(storage != NULL);
- BLI_ghash_insert((GHash *)storage, fcm, data);
-}
-
-void fmodifiers_storage_remove(FModifierStackStorage *storage, FModifier *fcm)
-{
- BLI_assert(storage != NULL);
-
- BLI_ghash_remove((GHash *)storage, fcm, NULL, NULL);
-}
-
-void *fmodifiers_storage_get(FModifierStackStorage *storage, FModifier *fcm)
-{
- BLI_assert(storage != NULL);
-
- return BLI_ghash_lookup((GHash *)storage, fcm);
+ return max_size;
}
/* helper function - calculate influence of FModifier */
@@ -1372,16 +1376,19 @@ static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
float influence;
/* sanity check */
- if (fcm == NULL)
+ if (fcm == NULL) {
return 0.0f;
+ }
/* should we use influence stored in modifier or not
* NOTE: this is really just a hack so that we don't need to version patch old files ;)
*/
- if (fcm->flag & FMODIFIER_FLAG_USEINFLUENCE)
+ if (fcm->flag & FMODIFIER_FLAG_USEINFLUENCE) {
influence = fcm->influence;
- else
+ }
+ else {
influence = 1.0f;
+ }
/* restricted range or full range? */
if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) {
@@ -1418,17 +1425,20 @@ static float eval_fmodifier_influence(FModifier *fcm, float evaltime)
*
* Note: *fcu might be NULL
*/
-float evaluate_time_fmodifiers(
- FModifierStackStorage *storage, ListBase *modifiers, FCurve *fcu, float cvalue, float evaltime)
+float evaluate_time_fmodifiers(FModifiersStackStorage *storage,
+ ListBase *modifiers,
+ FCurve *fcu,
+ float cvalue,
+ float evaltime)
{
- FModifier *fcm;
-
/* sanity checks */
- if (ELEM(NULL, modifiers, modifiers->last))
+ if (ELEM(NULL, modifiers, modifiers->last)) {
return evaltime;
+ }
- if (fcu && fcu->flag & FCURVE_MOD_OFF)
+ if (fcu && fcu->flag & FCURVE_MOD_OFF) {
return evaltime;
+ }
/* Starting from the end of the stack, calculate the time effects of various stacked modifiers
* on the time the F-Curve should be evaluated at.
@@ -1440,30 +1450,28 @@ float evaluate_time_fmodifiers(
* effect, which should get us the desired effects when using layered time manipulations
* (such as multiple 'stepped' modifiers in sequence, causing different stepping rates)
*/
- for (fcm = modifiers->last; fcm; fcm = fcm->prev) {
+ uint fcm_index = storage->modifier_count - 1;
+ for (FModifier *fcm = modifiers->last; fcm; fcm = fcm->prev, fcm_index--) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
- if (fmi == NULL)
+ if (fmi == NULL) {
continue;
+ }
- /* if modifier cannot be applied on this frame (whatever scale it is on, it won't affect the results)
- * hence we shouldn't bother seeing what it would do given the chance
- */
+ /* If modifier cannot be applied on this frame
+ * (whatever scale it is on, it won't affect the results)
+ * hence we shouldn't bother seeing what it would do given the chance. */
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) {
/* only evaluate if there's a callback for this */
- if (fmi->evaluate_modifier_time || fmi->evaluate_modifier_time_storage) {
+ if (fmi->evaluate_modifier_time) {
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) {
- float influence = eval_fmodifier_influence(fcm, evaltime);
- float nval;
+ void *storage_ptr = POINTER_OFFSET(storage->buffer,
+ fcm_index * storage->size_per_modifier);
- if ((fmi->requires & FMI_REQUIRES_STORAGE) == 0) {
- nval = fmi->evaluate_modifier_time(fcu, fcm, cvalue, evaltime);
- }
- else {
- nval = fmi->evaluate_modifier_time_storage(storage, fcu, fcm, cvalue, evaltime);
- }
+ float nval = fmi->evaluate_modifier_time(fcu, fcm, cvalue, evaltime, storage_ptr);
+ float influence = eval_fmodifier_influence(fcm, evaltime);
evaltime = interpf(nval, evaltime, influence);
}
}
@@ -1477,7 +1485,7 @@ float evaluate_time_fmodifiers(
/* Evaluates the given set of F-Curve Modifiers using the given data
* Should only be called after evaluate_time_fmodifiers() has been called...
*/
-void evaluate_value_fmodifiers(FModifierStackStorage *storage,
+void evaluate_value_fmodifiers(FModifiersStackStorage *storage,
ListBase *modifiers,
FCurve *fcu,
float *cvalue,
@@ -1486,34 +1494,36 @@ void evaluate_value_fmodifiers(FModifierStackStorage *storage,
FModifier *fcm;
/* sanity checks */
- if (ELEM(NULL, modifiers, modifiers->first))
+ if (ELEM(NULL, modifiers, modifiers->first)) {
return;
+ }
- if (fcu->flag & FCURVE_MOD_OFF)
+ if (fcu->flag & FCURVE_MOD_OFF) {
return;
+ }
/* evaluate modifiers */
- for (fcm = modifiers->first; fcm; fcm = fcm->next) {
+ uint fcm_index = 0;
+ for (fcm = modifiers->first; fcm; fcm = fcm->next, fcm_index++) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
- if (fmi == NULL)
+ if (fmi == NULL) {
continue;
+ }
- /* only evaluate if there's a callback for this, and if F-Modifier can be evaluated on this frame */
+ /* Only evaluate if there's a callback for this,
+ * and if F-Modifier can be evaluated on this frame. */
if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 ||
((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) {
- if (fmi->evaluate_modifier || fmi->evaluate_modifier_storage) {
+ if (fmi->evaluate_modifier) {
if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) {
- float influence = eval_fmodifier_influence(fcm, evaltime);
- float nval = *cvalue;
+ void *storage_ptr = POINTER_OFFSET(storage->buffer,
+ fcm_index * storage->size_per_modifier);
- if ((fmi->requires & FMI_REQUIRES_STORAGE) == 0) {
- fmi->evaluate_modifier(fcu, fcm, &nval, evaltime);
- }
- else {
- fmi->evaluate_modifier_storage(storage, fcu, fcm, &nval, evaltime);
- }
+ float nval = *cvalue;
+ fmi->evaluate_modifier(fcu, fcm, &nval, evaltime, storage_ptr);
+ float influence = eval_fmodifier_influence(fcm, evaltime);
*cvalue = interpf(nval, *cvalue, influence);
}
}
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 4311402ef42..70a8f4f124c 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -69,8 +69,9 @@ void BKE_vfont_free_data(struct VFont *vfont)
while (che->nurbsbase.first) {
Nurb *nu = che->nurbsbase.first;
- if (nu->bezt)
+ if (nu->bezt) {
MEM_freeN(nu->bezt);
+ }
BLI_freelinkN(&che->nurbsbase, nu);
}
@@ -306,14 +307,16 @@ VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *
if (BLI_path_cmp(strtest, str) == 0) {
id_us_plus(&vfont->id); /* officially should not, it doesn't link here! */
- if (r_exists)
+ if (r_exists) {
*r_exists = true;
+ }
return vfont;
}
}
- if (r_exists)
+ if (r_exists) {
*r_exists = false;
+ }
return BKE_vfont_load(bmain, filepath);
}
@@ -377,8 +380,9 @@ static void build_underline(Curve *cu,
nu2->knotsu = nu2->knotsv = NULL;
nu2->flag = CU_2D;
nu2->charidx = charidx + 1000;
- if (mat_nr > 0)
+ if (mat_nr > 0) {
nu2->mat_nr = mat_nr - 1;
+ }
nu2->pntsu = 4;
nu2->pntsv = 1;
nu2->orderu = 4;
@@ -444,8 +448,9 @@ static void buildchar(Curve *cu,
int i;
vfd = vfont_get_data(which_vfont(cu, info));
- if (!vfd)
+ if (!vfd) {
return;
+ }
/* make a copy at distance ofsx, ofsy with shear */
shear = cu->shear;
@@ -455,16 +460,18 @@ static void buildchar(Curve *cu,
che = find_vfont_char(vfd, character);
/* Select the glyph data */
- if (che)
+ if (che) {
nu1 = che->nurbsbase.first;
+ }
/* Create the character */
while (nu1) {
bezt1 = nu1->bezt;
if (bezt1) {
nu2 = (Nurb *)MEM_mallocN(sizeof(Nurb), "duplichar_nurb");
- if (nu2 == NULL)
+ if (nu2 == NULL) {
break;
+ }
memcpy(nu2, nu1, sizeof(struct Nurb));
nu2->resolu = cu->resolu;
nu2->bp = NULL;
@@ -558,8 +565,9 @@ int BKE_vfont_select_get(Object *ob, int *r_start, int *r_end)
EditFont *ef = cu->editfont;
int start, end, direction;
- if ((ob->type != OB_FONT) || (ef == NULL))
+ if ((ob->type != OB_FONT) || (ef == NULL)) {
return 0;
+ }
BLI_assert(ef->len >= 0);
BLI_assert(ef->selstart >= 0 && ef->selstart <= ef->len + 1);
@@ -666,10 +674,11 @@ enum {
* Descent: the recommended distance below the baseline to fit most characters.
*
* We obtain ascent and descent from the font itself (FT_Face->ascender / face->height).
- * And in some cases it is even the same value as FT_Face->bbox.yMax/yMin (font top and bottom respectively).
+ * And in some cases it is even the same value as FT_Face->bbox.yMax/yMin
+ * (font top and bottom respectively).
*
* The em_height here is relative to FT_Face->bbox.
-*/
+ */
#define ASCENT(vfd) ((vfd)->ascender * (vfd)->em_height)
#define DESCENT(vfd) ((vfd)->em_height - ASCENT(vfd))
@@ -726,16 +735,19 @@ static bool vfont_to_curve(Object *ob,
/* Set font data */
vfont = cu->vfont;
- if (cu->str == NULL)
+ if (cu->str == NULL) {
return ok;
- if (vfont == NULL)
+ }
+ if (vfont == NULL) {
return ok;
+ }
vfd = vfont_get_data(vfont);
/* The VFont Data can not be found */
- if (!vfd)
+ if (!vfd) {
return ok;
+ }
if (ef) {
slen = ef->len;
@@ -765,12 +777,14 @@ static bool vfont_to_curve(Object *ob,
mem = mem_tmp;
}
- if (cu->tb == NULL)
+ if (cu->tb == NULL) {
cu->tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "TextBox compat");
+ }
if (ef != NULL && ob != NULL) {
- if (ef->selboxes)
+ if (ef->selboxes) {
MEM_freeN(ef->selboxes);
+ }
if (BKE_vfont_select_get(ob, &selstart, &selend)) {
ef->selboxes_len = (selend - selstart) + 1;
@@ -821,8 +835,9 @@ static bool vfont_to_curve(Object *ob,
vfont = which_vfont(cu, info);
- if (vfont == NULL)
+ if (vfont == NULL) {
break;
+ }
if (vfont != oldvfont) {
vfd = vfont_get_data(vfont);
@@ -876,10 +891,12 @@ static bool vfont_to_curve(Object *ob,
if (mem[j] == ' ' || mem[j] == '-') {
ct -= (i - (j - 1));
cnr -= (i - (j - 1));
- if (mem[j] == ' ')
+ if (mem[j] == ' ') {
wsnr--;
- if (mem[j] == '-')
+ }
+ if (mem[j] == '-') {
wsnr++;
+ }
i = j - 1;
xof = ct->xof;
ct[1].dobreak = 1;
@@ -1013,8 +1030,9 @@ static bool vfont_to_curve(Object *ob,
for (i = 0; i <= slen; i++) {
ascii = mem[i];
ct = &chartransdata[i];
- if (ascii == '\n' || ct->dobreak)
+ if (ascii == '\n' || ct->dobreak) {
cu->lines++;
+ }
}
/* linedata is now: width of line */
@@ -1085,8 +1103,9 @@ static bool vfont_to_curve(Object *ob,
}
ct->xof += curofs;
}
- if (mem[i] == '\n' || chartransdata[i].dobreak)
+ if (mem[i] == '\n' || chartransdata[i].dobreak) {
curofs = 0;
+ }
ct++;
}
}
@@ -1198,14 +1217,18 @@ static bool vfont_to_curve(Object *ob,
maxx = maxy = -1.0e20f;
ct = chartransdata;
for (i = 0; i <= slen; i++, ct++) {
- if (minx > ct->xof)
+ if (minx > ct->xof) {
minx = ct->xof;
- if (maxx < ct->xof)
+ }
+ if (maxx < ct->xof) {
maxx = ct->xof;
- if (miny > ct->yof)
+ }
+ if (miny > ct->yof) {
miny = ct->yof;
- if (maxy < ct->yof)
+ }
+ if (maxy < ct->yof) {
maxy = ct->yof;
+ }
}
/* we put the x-coordinaat exact at the curve, the y is rotated */
@@ -1383,12 +1406,14 @@ static bool vfont_to_curve(Object *ob,
}
if (ob == NULL || info->mat_nr > (ob->totcol)) {
- /* CLOG_ERROR(&LOG, "Illegal material index (%d) in text object, setting to 0", info->mat_nr); */
+ // CLOG_ERROR(
+ // &LOG, "Illegal material index (%d) in text object, setting to 0", info->mat_nr);
info->mat_nr = 0;
}
/* We do not want to see any character for \n or \r */
- if (cha != '\n')
+ if (cha != '\n') {
buildchar(cu, r_nubase, cha, info, ct->xof, ct->yof, ct->rot, i, font_size);
+ }
if ((info->flag & CU_CHINFO_UNDERLINE) && (cha != '\n')) {
float ulwidth, uloverlap = 0.0f;
@@ -1602,7 +1627,8 @@ bool BKE_vfont_to_curve_nubase(Object *ob, int mode, ListBase *r_nubase)
return BKE_vfont_to_curve_ex(ob, ob->data, mode, r_nubase, NULL, NULL, NULL, NULL);
}
-/** Warning: expects to have access to evaluated data (i.e. passed object should be evaluated one...). */
+/** Warning: expects to have access to evaluated data
+ * (i.e. passed object should be evaluated one...). */
bool BKE_vfont_to_curve(Object *ob, int mode)
{
Curve *cu = ob->data;
diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c
index 72b81651124..19c5012dc54 100644
--- a/source/blender/blenkernel/intern/freestyle.c
+++ b/source/blender/blenkernel/intern/freestyle.c
@@ -145,8 +145,9 @@ static void copy_module(FreestyleModuleConfig *new_module, FreestyleModuleConfig
bool BKE_freestyle_module_delete(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
{
- if (BLI_findindex(&config->modules, module_conf) == -1)
+ if (BLI_findindex(&config->modules, module_conf) == -1) {
return false;
+ }
BLI_freelinkN(&config->modules, module_conf);
return true;
}
@@ -214,8 +215,9 @@ FreestyleLineSet *BKE_freestyle_lineset_add(struct Main *bmain,
bool BKE_freestyle_lineset_delete(FreestyleConfig *config, FreestyleLineSet *lineset)
{
- if (BLI_findindex(&config->linesets, lineset) == -1)
+ if (BLI_findindex(&config->linesets, lineset) == -1) {
return false;
+ }
if (lineset->group) {
id_us_min(&lineset->group->id);
}
@@ -233,8 +235,9 @@ FreestyleLineSet *BKE_freestyle_lineset_get_active(FreestyleConfig *config)
FreestyleLineSet *lineset;
for (lineset = (FreestyleLineSet *)config->linesets.first; lineset; lineset = lineset->next) {
- if (lineset->flags & FREESTYLE_LINESET_CURRENT)
+ if (lineset->flags & FREESTYLE_LINESET_CURRENT) {
return lineset;
+ }
}
return NULL;
}
@@ -246,8 +249,9 @@ short BKE_freestyle_lineset_get_active_index(FreestyleConfig *config)
for (lineset = (FreestyleLineSet *)config->linesets.first, i = 0; lineset;
lineset = lineset->next, i++) {
- if (lineset->flags & FREESTYLE_LINESET_CURRENT)
+ if (lineset->flags & FREESTYLE_LINESET_CURRENT) {
return i;
+ }
}
return 0;
}
@@ -259,9 +263,11 @@ void BKE_freestyle_lineset_set_active_index(FreestyleConfig *config, short index
for (lineset = (FreestyleLineSet *)config->linesets.first, i = 0; lineset;
lineset = lineset->next, i++) {
- if (i == index)
+ if (i == index) {
lineset->flags |= FREESTYLE_LINESET_CURRENT;
- else
+ }
+ else {
lineset->flags &= ~FREESTYLE_LINESET_CURRENT;
+ }
}
}
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index d1181eeb03d..c82b2c377fa 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -124,8 +124,9 @@ void BKE_gpencil_free_stroke(bGPDstroke *gps)
BKE_gpencil_free_stroke_weights(gps);
MEM_freeN(gps->dvert);
}
- if (gps->triangles)
+ if (gps->triangles) {
MEM_freeN(gps->triangles);
+ }
MEM_freeN(gps);
}
@@ -170,8 +171,9 @@ void BKE_gpencil_free_frames(bGPDlayer *gpl)
bGPDframe *gpf_next;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* free frames */
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf_next) {
@@ -190,8 +192,9 @@ void BKE_gpencil_free_layers(ListBase *list)
bGPDlayer *gpl_next;
/* error checking */
- if (list == NULL)
+ if (list == NULL) {
return;
+ }
/* delete layers */
for (bGPDlayer *gpl = list->first; gpl; gpl = gpl_next) {
@@ -232,8 +235,9 @@ bGPDframe *BKE_gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
short state = 0;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return NULL;
+ }
/* allocate memory for this frame */
gpf = MEM_callocN(sizeof(bGPDframe), "bGPDframe");
@@ -339,8 +343,9 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
bGPDlayer *gpl_active = NULL;
/* check that list is ok */
- if (gpd == NULL)
+ if (gpd == NULL) {
return NULL;
+ }
/* allocate memory for frame and add to end of list */
gpl = MEM_callocN(sizeof(bGPDlayer), "bGPDlayer");
@@ -387,8 +392,9 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
sizeof(gpl->info));
/* make this one the active one */
- if (setactive)
+ if (setactive) {
BKE_gpencil_layer_setactive(gpd, gpl);
+ }
/* return layer */
return gpl;
@@ -606,8 +612,9 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
BLI_addtail(&gpl_dst->frames, gpf_dst);
/* if source frame was the current layer's 'active' frame, reassign that too */
- if (gpf_src == gpl_dst->actframe)
+ if (gpf_src == gpl_dst->actframe) {
gpl_dst->actframe = gpf_dst;
+ }
}
/* return new layer */
@@ -615,8 +622,10 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
}
/**
- * Only copy internal data of GreasePencil ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of GreasePencil ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -693,8 +702,9 @@ void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps)
int i;
/* error checking */
- if (gps == NULL)
+ if (gps == NULL) {
return;
+ }
/* we'll stop when we find the first selected point,
* so initially, we must deselect
@@ -719,8 +729,9 @@ void BKE_gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf)
int cfra = (gpf) ? gpf->framenum : 0; /* assume that the current frame was not locked */
/* error checking */
- if (ELEM(NULL, gpf, gps))
+ if (ELEM(NULL, gpf, gps)) {
return;
+ }
/* free the stroke and its data */
if (gps->points) {
@@ -747,8 +758,9 @@ void BKE_gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf)
bool gpencil_layer_is_editable(const bGPDlayer *gpl)
{
/* Sanity check */
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* Layer must be: Visible + Editable */
if ((gpl->flag & (GP_LAYER_HIDE | GP_LAYER_LOCKED)) == 0) {
@@ -791,8 +803,9 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
short found = 0;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return NULL;
+ }
/* check if there is already an active frame */
if (gpl->actframe) {
@@ -801,11 +814,13 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
/* do not allow any changes to layer's active frame if layer is locked from changes
* or if the layer has been set to stay on the current frame
*/
- if (gpl->flag & GP_LAYER_FRAMELOCK)
+ if (gpl->flag & GP_LAYER_FRAMELOCK) {
return gpf;
+ }
/* do not allow any changes to actframe if frame has painting tag attached to it */
- if (gpf->flag & GP_FRAME_PAINT)
+ if (gpf->flag & GP_FRAME_PAINT) {
return gpf;
+ }
/* try to find matching frame */
if (gpf->framenum < cframe) {
@@ -822,17 +837,22 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
/* set the appropriate frame */
if (addnew) {
- if ((found) && (gpf->framenum == cframe))
+ if ((found) && (gpf->framenum == cframe)) {
gpl->actframe = gpf;
- else if (addnew == GP_GETFRAME_ADD_COPY)
+ }
+ else if (addnew == GP_GETFRAME_ADD_COPY) {
gpl->actframe = BKE_gpencil_frame_addcopy(gpl, cframe);
- else
+ }
+ else {
gpl->actframe = BKE_gpencil_frame_addnew(gpl, cframe);
+ }
}
- else if (found)
+ else if (found) {
gpl->actframe = gpf;
- else
+ }
+ else {
gpl->actframe = gpl->frames.last;
+ }
}
else {
for (; gpf; gpf = gpf->prev) {
@@ -844,17 +864,22 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
/* set the appropriate frame */
if (addnew) {
- if ((found) && (gpf->framenum == cframe))
+ if ((found) && (gpf->framenum == cframe)) {
gpl->actframe = gpf;
- else if (addnew == GP_GETFRAME_ADD_COPY)
+ }
+ else if (addnew == GP_GETFRAME_ADD_COPY) {
gpl->actframe = BKE_gpencil_frame_addcopy(gpl, cframe);
- else
+ }
+ else {
gpl->actframe = BKE_gpencil_frame_addnew(gpl, cframe);
+ }
}
- else if (found)
+ else if (found) {
gpl->actframe = gpf;
- else
+ }
+ else {
gpl->actframe = gpl->frames.first;
+ }
}
}
else if (gpl->frames.first) {
@@ -883,13 +908,16 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
/* set the appropriate frame */
if (addnew) {
- if ((found) && (gpf->framenum == cframe))
+ if ((found) && (gpf->framenum == cframe)) {
gpl->actframe = gpf;
- else
+ }
+ else {
gpl->actframe = BKE_gpencil_frame_addnew(gpl, cframe);
+ }
}
- else if (found)
+ else if (found) {
gpl->actframe = gpf;
+ }
else {
/* unresolved errogenous situation! */
CLOG_STR_ERROR(&LOG, "cannot find appropriate gp-frame");
@@ -898,8 +926,9 @@ bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_M
}
else {
/* currently no frames (add if allowed to) */
- if (addnew)
+ if (addnew) {
gpl->actframe = BKE_gpencil_frame_addnew(gpl, cframe);
+ }
else {
/* don't do anything... this may be when no frames yet! */
/* gpl->actframe should still be NULL */
@@ -916,14 +945,16 @@ bool BKE_gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf)
bool changed = false;
/* error checking */
- if (ELEM(NULL, gpl, gpf))
+ if (ELEM(NULL, gpl, gpf)) {
return false;
+ }
/* if this frame was active, make the previous frame active instead
* since it's tricky to set active frame otherwise
*/
- if (gpl->actframe == gpf)
+ if (gpl->actframe == gpf) {
gpl->actframe = gpf->prev;
+ }
/* free the frame and its data */
changed = BKE_gpencil_free_strokes(gpf);
@@ -938,13 +969,15 @@ bGPDlayer *BKE_gpencil_layer_getactive(bGPdata *gpd)
bGPDlayer *gpl;
/* error checking */
- if (ELEM(NULL, gpd, gpd->layers.first))
+ if (ELEM(NULL, gpd, gpd->layers.first)) {
return NULL;
+ }
/* loop over layers until found (assume only one active) */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- if (gpl->flag & GP_LAYER_ACTIVE)
+ if (gpl->flag & GP_LAYER_ACTIVE) {
return gpl;
+ }
}
/* no active layer found */
@@ -957,8 +990,9 @@ void BKE_gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
bGPDlayer *gpl;
/* error checking */
- if (ELEM(NULL, gpd, gpd->layers.first, active))
+ if (ELEM(NULL, gpd, gpd->layers.first, active)) {
return;
+ }
/* loop over layers deactivating all */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -979,8 +1013,9 @@ void BKE_gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
void BKE_gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
{
/* error checking */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return;
+ }
/* free layer */
BKE_gpencil_free_frames(gpl);
@@ -1126,7 +1161,10 @@ Material *BKE_gpencil_object_material_ensure_from_active_input_brush(Main *bmain
return BKE_gpencil_object_material_ensure_from_active_input_material(bmain, ob);
}
-/* Guaranteed to return a material assigned to object. Returns never NULL. Only use this for materials unrelated to user input */
+/**
+ * Guaranteed to return a material assigned to object. Returns never NULL.
+ * Only use this for materials unrelated to user input.
+ */
Material *BKE_gpencil_object_material_ensure_from_active_input_material(Main *bmain, Object *ob)
{
Material *ma = give_current_material(ob, ob->actcol);
@@ -1142,8 +1180,9 @@ Material *BKE_gpencil_object_material_ensure_active(Main *bmain, Object *ob)
Material *ma = NULL;
/* sanity checks */
- if (ELEM(NULL, bmain, ob))
+ if (ELEM(NULL, bmain, ob)) {
return NULL;
+ }
ma = BKE_gpencil_object_material_ensure_from_active_input_material(bmain, ob);
if (ma->gp_style == NULL) {
@@ -1169,8 +1208,9 @@ bool BKE_gpencil_stroke_minmax(const bGPDstroke *gps,
int i;
bool changed = false;
- if (ELEM(NULL, gps, r_min, r_max))
+ if (ELEM(NULL, gps, r_min, r_max)) {
return false;
+ }
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if ((use_select == false) || (pt->flag & GP_SPOINT_SELECT)) {
@@ -1188,8 +1228,9 @@ bool BKE_gpencil_data_minmax(const bGPdata *gpd, float r_min[3], float r_max[3])
INIT_MINMAX(r_min, r_max);
- if (gpd == NULL)
+ if (gpd == NULL) {
return changed;
+ }
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
bGPDframe *gpf = gpl->actframe;
@@ -1254,8 +1295,9 @@ static void boundbox_gpencil(Object *ob)
/* get bounding box */
BoundBox *BKE_gpencil_boundbox_get(Object *ob)
{
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return NULL;
+ }
bGPdata *gpd = (bGPdata *)ob->data;
if ((ob->runtime.bb) && ((gpd->flag & GP_DATA_CACHE_IS_DIRTY) == 0)) {
@@ -1272,8 +1314,9 @@ BoundBox *BKE_gpencil_boundbox_get(Object *ob)
void BKE_gpencil_transform(bGPdata *gpd, float mat[4][4])
{
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* FIXME: For now, we just skip parented layers.
@@ -1378,9 +1421,11 @@ bool BKE_gpencil_smooth_stroke(bGPDstroke *gps, int i, float inf)
}
/* Compute smoothed coordinate by taking the ones nearby */
- /* XXX: This is potentially slow, and suffers from accumulation error as earlier points are handled before later ones */
+ /* XXX: This is potentially slow,
+ * and suffers from accumulation error as earlier points are handled before later ones. */
{
- // XXX: this is hardcoded to look at 2 points on either side of the current one (i.e. 5 items total)
+ /* XXX: this is hardcoded to look at 2 points on either side of the current one
+ * (i.e. 5 items total). */
const int steps = 2;
const float average_fac = 1.0f / (float)(steps * 2 + 1);
int step;
@@ -1389,8 +1434,9 @@ bool BKE_gpencil_smooth_stroke(bGPDstroke *gps, int i, float inf)
madd_v3_v3fl(sco, &pt->x, average_fac);
/* n-steps before/after current point */
- // XXX: review how the endpoints are treated by this algorithm
- // XXX: falloff measures should also introduce some weighting variations, so that further-out points get less weight
+ /* XXX: review how the endpoints are treated by this algorithm. */
+ /* XXX: falloff measures should also introduce some weighting variations,
+ * so that further-out points get less weight. */
for (step = 1; step <= steps; step++) {
bGPDspoint *pt1, *pt2;
int before = i - step;
@@ -1610,8 +1656,9 @@ void BKE_gpencil_material_index_remove(bGPdata *gpd, int index)
BKE_gpencil_free_stroke_weights(gps);
MEM_freeN(gps->dvert);
}
- if (gps->triangles)
+ if (gps->triangles) {
MEM_freeN(gps->triangles);
+ }
BLI_freelinkN(&gpf->strokes, gps);
}
else {
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 63f6fc6307b..c8a45a92758 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -553,11 +553,13 @@ GpencilModifierData *BKE_gpencil_modifier_new(int type)
eGpencilModifierMode_Expanded;
md->flag = eGpencilModifierFlag_StaticOverride_Local;
- if (mti->flags & eGpencilModifierTypeFlag_EnableInEditmode)
+ if (mti->flags & eGpencilModifierTypeFlag_EnableInEditmode) {
md->mode |= eGpencilModifierMode_Editmode;
+ }
- if (mti->initData)
+ if (mti->initData) {
mti->initData(md);
+ }
return md;
}
@@ -587,10 +589,12 @@ void BKE_gpencil_modifier_free_ex(GpencilModifierData *md, const int flag)
}
}
- if (mti->freeData)
+ if (mti->freeData) {
mti->freeData(md);
- if (md->error)
+ }
+ if (md->error) {
MEM_freeN(md->error);
+ }
MEM_freeN(md);
}
@@ -695,9 +699,11 @@ GpencilModifierData *BKE_gpencil_modifiers_findByType(Object *ob, GpencilModifie
{
GpencilModifierData *md = ob->greasepencil_modifiers.first;
- for (; md; md = md->next)
- if (md->type == type)
+ for (; md; md = md->next) {
+ if (md->type == type) {
break;
+ }
+ }
return md;
}
@@ -727,8 +733,9 @@ void BKE_gpencil_modifiers_foreachTexLink(Object *ob, GreasePencilTexWalkFunc wa
for (; md; md = md->next) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
- if (mti->foreachTexLink)
+ if (mti->foreachTexLink) {
mti->foreachTexLink(md, ob, walk, userData);
+ }
}
}
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 7ddd99c0fc0..8a5a36481cf 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -147,16 +147,19 @@ static int get_next_free_id(void)
int startId = gFirstIconId;
/* if we haven't used up the int number range, we just return the next int */
- if (gNextIconId >= gFirstIconId)
+ if (gNextIconId >= gFirstIconId) {
return gNextIconId++;
+ }
/* now we try to find the smallest icon id not stored in the gIcons hash */
- while (BLI_ghash_lookup(gIcons, POINTER_FROM_INT(startId)) && startId >= gFirstIconId)
+ while (BLI_ghash_lookup(gIcons, POINTER_FROM_INT(startId)) && startId >= gFirstIconId) {
startId++;
+ }
/* if we found a suitable one that isn't used yet, return it */
- if (startId >= gFirstIconId)
+ if (startId >= gFirstIconId) {
return startId;
+ }
/* fail */
return 0;
@@ -243,8 +246,9 @@ void BKE_previewimg_freefunc(void *link)
if (prv->rect[i]) {
MEM_freeN(prv->rect[i]);
}
- if (prv->gputexture[i])
+ if (prv->gputexture[i]) {
GPU_texture_free(prv->gputexture[i]);
+ }
}
MEM_freeN(prv);
@@ -296,7 +300,10 @@ PreviewImage *BKE_previewimg_copy(const PreviewImage *prv)
return prv_img;
}
-/** Duplicate preview image from \a id and clear icon_id, to be used by datablock copy functions. */
+/**
+ * Duplicate preview image from \a id and clear icon_id,
+ * to be used by datablock copy functions.
+ */
void BKE_previewimg_id_copy(ID *new_id, const ID *old_id)
{
PreviewImage **old_prv_p = BKE_previewimg_id_get_p(old_id);
@@ -519,8 +526,9 @@ void BKE_icon_changed(const int icon_id)
Icon *icon = NULL;
- if (!icon_id || G.background)
+ if (!icon_id || G.background) {
return;
+ }
icon = BLI_ghash_lookup(gIcons, POINTER_FROM_INT(icon_id));
@@ -529,8 +537,9 @@ void BKE_icon_changed(const int icon_id)
BLI_assert(icon->id_type != 0);
BLI_assert(icon->obj_type == ICON_DATA_ID);
- /* Do not enforce creation of previews for valid ID types using BKE_previewimg_id_ensure() here ,
- * we only want to ensure *existing* preview images are properly tagged as changed/invalid, that's all. */
+ /* Do not enforce creation of previews for valid ID types using BKE_previewimg_id_ensure()
+ * here, we only want to ensure *existing* preview images are properly tagged as
+ * changed/invalid, that's all. */
PreviewImage **p_prv = BKE_previewimg_id_get_p((ID *)icon->obj);
/* If we have previews, they all are now invalid changed. */
@@ -582,8 +591,9 @@ int BKE_icon_id_ensure(struct ID *id)
return 0;
}
- if (id->icon_id)
+ if (id->icon_id) {
return id->icon_id;
+ }
id->icon_id = get_next_free_id();
@@ -626,8 +636,9 @@ int BKE_icon_gplayer_color_ensure(bGPDlayer *gpl)
return 0;
}
- if (gpl->runtime.icon_id)
+ if (gpl->runtime.icon_id) {
return gpl->runtime.icon_id;
+ }
gpl->runtime.icon_id = get_next_free_id();
@@ -644,8 +655,9 @@ int BKE_icon_gplayer_color_ensure(bGPDlayer *gpl)
*/
int BKE_icon_preview_ensure(ID *id, PreviewImage *preview)
{
- if (!preview || G.background)
+ if (!preview || G.background) {
return 0;
+ }
if (id) {
BLI_assert(BKE_previewimg_id_ensure(id) == preview);
@@ -668,7 +680,8 @@ int BKE_icon_preview_ensure(ID *id, PreviewImage *preview)
return 0;
}
- /* Ensure we synchronize ID icon_id with its previewimage if available, and generate suitable 'ID' icon. */
+ /* Ensure we synchronize ID icon_id with its previewimage if available,
+ * and generate suitable 'ID' icon. */
if (id) {
id->icon_id = preview->icon_id;
return icon_id_ensure_create_icon(id);
@@ -720,8 +733,9 @@ static void icon_add_to_deferred_delete_queue(int icon_id)
void BKE_icon_id_delete(struct ID *id)
{
const int icon_id = id->icon_id;
- if (!icon_id)
+ if (!icon_id) {
return; /* no icon defined for library object */
+ }
id->icon_id = 0;
if (!BLI_thread_is_main()) {
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 0e9960755d8..0a9178a8b6d 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -116,9 +116,11 @@ static IDType *idtype_from_code(short idcode)
{
int i = ARRAY_SIZE(idtypes);
- while (i--)
- if (idcode == idtypes[i].code)
+ while (i--) {
+ if (idcode == idtypes[i].code) {
return &idtypes[i];
+ }
+ }
return NULL;
}
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 378d551916c..39e72d7e3a8 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -120,11 +120,13 @@ static void IDP_FreeIDPArray(IDProperty *prop, const bool do_id_user)
BLI_assert(prop->type == IDP_IDPARRAY);
- for (i = 0; i < prop->len; i++)
+ for (i = 0; i < prop->len; i++) {
IDP_FreeProperty_ex(GETPROP(prop, i), do_id_user);
+ }
- if (prop->data.pointer)
+ if (prop->data.pointer) {
MEM_freeN(prop->data.pointer);
+ }
}
/* shallow copies item */
@@ -134,8 +136,9 @@ void IDP_SetIndexArray(IDProperty *prop, int index, IDProperty *item)
BLI_assert(prop->type == IDP_IDPARRAY);
- if (index >= prop->len || index < 0)
+ if (index >= prop->len || index < 0) {
return;
+ }
old = GETPROP(prop, index);
if (item != old) {
@@ -171,8 +174,9 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
if (newlen < prop->len && prop->totallen - newlen < IDP_ARRAY_REALLOC_LIMIT) {
int i;
- for (i = newlen; i < prop->len; i++)
+ for (i = newlen; i < prop->len; i++) {
IDP_FreeProperty(GETPROP(prop, i));
+ }
prop->len = newlen;
return;
@@ -210,8 +214,9 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
/* ----------- Numerical Array Type ----------- */
static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
{
- if (prop->subtype != IDP_GROUP)
+ if (prop->subtype != IDP_GROUP) {
return;
+ }
if (newlen >= prop->len) {
/* bigger */
@@ -260,14 +265,16 @@ void IDP_ResizeArray(IDProperty *prop, int newlen)
newsize = newlen;
newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
- if (is_grow == false)
+ if (is_grow == false) {
idp_resize_group_array(prop, newlen, prop->data.pointer);
+ }
prop->data.pointer = MEM_recallocN(prop->data.pointer,
idp_size_table[(int)prop->subtype] * (size_t)newsize);
- if (is_grow == true)
+ if (is_grow == true) {
idp_resize_group_array(prop, newlen, prop->data.pointer);
+ }
prop->len = newlen;
prop->totallen = newsize;
@@ -305,8 +312,9 @@ static IDProperty *IDP_CopyArray(const IDProperty *prop, const int flag)
IDProperty **array = newp->data.pointer;
int a;
- for (a = 0; a < prop->len; a++)
+ for (a = 0; a < prop->len; a++) {
array[a] = IDP_CopyProperty_ex(array[a], flag);
+ }
}
}
newp->len = prop->len;
@@ -344,8 +352,9 @@ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen)
/* include null terminator '\0' */
int stlen = (int)strlen(st) + 1;
- if (maxlen > 0 && maxlen < stlen)
+ if (maxlen > 0 && maxlen < stlen) {
stlen = maxlen;
+ }
prop->data.pointer = MEM_mallocN((size_t)stlen, "id property string 2");
prop->len = prop->totallen = stlen;
@@ -365,8 +374,9 @@ static IDProperty *IDP_CopyString(const IDProperty *prop, const int flag)
BLI_assert(prop->type == IDP_STRING);
newp = idp_generic_copy(prop, flag);
- if (prop->data.pointer)
+ if (prop->data.pointer) {
newp->data.pointer = MEM_dupallocN(prop->data.pointer);
+ }
newp->len = prop->len;
newp->subtype = prop->subtype;
newp->totallen = prop->totallen;
@@ -380,8 +390,9 @@ void IDP_AssignString(IDProperty *prop, const char *st, int maxlen)
BLI_assert(prop->type == IDP_STRING);
stlen = (int)strlen(st);
- if (maxlen > 0 && maxlen < stlen)
+ if (maxlen > 0 && maxlen < stlen) {
stlen = maxlen;
+ }
if (prop->subtype == IDP_STRING_SUB_BYTE) {
IDP_ResizeArray(prop, stlen);
@@ -424,8 +435,9 @@ void IDP_FreeString(IDProperty *prop)
{
BLI_assert(prop->type == IDP_STRING);
- if (prop->data.pointer)
+ if (prop->data.pointer) {
MEM_freeN(prop->data.pointer);
+ }
}
/** \} */
@@ -653,13 +665,14 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw
*
* The sanity check just means the property is not added to the group if another property
* exists with the same name; the client code using ID properties then needs to detect this
- * (the function that adds new properties to groups, IDP_AddToGroup, returns false if a property can't
- * be added to the group, and true if it can) and free the property.
+ * (the function that adds new properties to groups, #IDP_AddToGroup,
+ * returns false if a property can't be added to the group, and true if it can)
+ * and free the property.
*
* Currently the code to free ID properties is designed to leave the actual struct
* you pass it un-freed, this is needed for how the system works. This means
- * to free an ID property, you first call IDP_FreeProperty then MEM_freeN the
- * struct. In the future this will just be IDP_FreeProperty and the code will
+ * to free an ID property, you first call #IDP_FreeProperty then #MEM_freeN the struct.
+ * In the future this will just be #IDP_FreeProperty and the code will
* be reorganized to work properly.
*/
bool IDP_AddToGroup(IDProperty *group, IDProperty *prop)
@@ -775,11 +788,13 @@ IDProperty *IDP_CopyProperty(const IDProperty *prop)
}
/* Updates ID pointers after an object has been copied */
-/* TODO Nuke this once its only user has been correctly converted to use generic ID management from BKE_library! */
+/* TODO Nuke this once its only user has been correctly converted
+ * to use generic ID management from BKE_library! */
void IDP_RelinkProperty(struct IDProperty *prop)
{
- if (!prop)
+ if (!prop) {
return;
+ }
switch (prop->type) {
case IDP_GROUP: {
@@ -836,12 +851,15 @@ IDProperty *IDP_GetProperties(ID *id, const bool create_if_needed)
* \param is_strict: When false treat missing items as a match */
bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is_strict)
{
- if (prop1 == NULL && prop2 == NULL)
+ if (prop1 == NULL && prop2 == NULL) {
return true;
- else if (prop1 == NULL || prop2 == NULL)
+ }
+ else if (prop1 == NULL || prop2 == NULL) {
return is_strict ? false : true;
- else if (prop1->type != prop2->type)
+ }
+ else if (prop1->type != prop2->type) {
return false;
+ }
switch (prop1->type) {
case IDP_INT:
@@ -881,14 +899,16 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is
case IDP_GROUP: {
IDProperty *link1, *link2;
- if (is_strict && prop1->len != prop2->len)
+ if (is_strict && prop1->len != prop2->len) {
return false;
+ }
for (link1 = prop1->data.group.first; link1; link1 = link1->next) {
link2 = IDP_GetPropertyFromGroup(prop2, link1->name);
- if (!IDP_EqualsProperties_ex(link1, link2, is_strict))
+ if (!IDP_EqualsProperties_ex(link1, link2, is_strict)) {
return false;
+ }
}
return true;
@@ -898,12 +918,14 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is
IDProperty *array2 = IDP_IDPArray(prop2);
int i;
- if (prop1->len != prop2->len)
+ if (prop1->len != prop2->len) {
return false;
+ }
for (i = 0; i < prop1->len; i++) {
- if (!IDP_EqualsProperties_ex(&array1[i], &array2[i], is_strict))
+ if (!IDP_EqualsProperties_ex(&array1[i], &array2[i], is_strict)) {
return false;
+ }
}
return true;
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 75807ebbfa3..f23c58befdf 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -304,8 +304,9 @@ static void image_init(Image *ima, short source, short type)
ima->source = source;
ima->type = type;
- if (source == IMA_SRC_VIEWER)
+ if (source == IMA_SRC_VIEWER) {
ima->flag |= IMA_VIEW_AS_RENDER;
+ }
if (type == IMA_TYPE_R_RESULT) {
for (int i = 0; i < 8; i++) {
@@ -356,8 +357,9 @@ static ImBuf *image_get_cached_ibuf_for_index_frame(Image *ima, int index, int f
static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame)
{
if (ibuf) {
- if (index != IMA_NO_INDEX)
+ if (index != IMA_NO_INDEX) {
index = IMA_MAKE_INDEX(frame, index);
+ }
imagecache_put(ima, index, ibuf);
}
@@ -372,16 +374,19 @@ static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src)
ImagePackedFile *imapf_dst = MEM_mallocN(sizeof(ImagePackedFile), "Image Packed Files (copy)");
STRNCPY(imapf_dst->filepath, imapf_src->filepath);
- if (imapf_src->packedfile)
+ if (imapf_src->packedfile) {
imapf_dst->packedfile = dupPackedFile(imapf_src->packedfile);
+ }
BLI_addtail(lb_dst, imapf_dst);
}
}
/**
- * Only copy internal data of Image ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Image ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -494,10 +499,12 @@ static void image_init_color_management(Image *ima)
ibuf = IMB_loadiffname(name, IB_test | IB_alphamode_detect, ima->colorspace_settings.name);
if (ibuf) {
- if (ibuf->flags & IB_alphamode_premul)
+ if (ibuf->flags & IB_alphamode_premul) {
ima->alpha_mode = IMA_ALPHA_PREMUL;
- else
+ }
+ else {
ima->alpha_mode = IMA_ALPHA_STRAIGHT;
+ }
IMB_freeImBuf(ibuf);
}
@@ -529,15 +536,17 @@ Image *BKE_image_load(Main *bmain, const char *filepath)
/* exists? */
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
- if (file == -1)
+ if (file == -1) {
return NULL;
+ }
close(file);
ima = image_alloc(bmain, BLI_path_basename(filepath), IMA_SRC_FILE, IMA_TYPE_IMAGE);
STRNCPY(ima->name, filepath);
- if (BLI_path_extension_check_array(filepath, imb_ext_movie))
+ if (BLI_path_extension_check_array(filepath, imb_ext_movie)) {
ima->source = IMA_SRC_MOVIE;
+ }
image_init_color_management(ima);
@@ -565,18 +574,21 @@ Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exist
if (BLI_path_cmp(strtest, str) == 0) {
if ((BKE_image_has_anim(ima) == false) || (ima->id.us == 0)) {
id_us_plus(&ima->id); /* officially should not, it doesn't link here! */
- if (ima->ok == 0)
+ if (ima->ok == 0) {
ima->ok = IMA_OK;
- if (r_exists)
+ }
+ if (r_exists) {
*r_exists = true;
+ }
return ima;
}
}
}
}
- if (r_exists)
+ if (r_exists) {
*r_exists = false;
+ }
return BKE_image_load(bmain, filepath);
}
@@ -685,8 +697,9 @@ Image *BKE_image_add_generated(Main *bmain,
/* image_assign_ibuf puts buffer to the cache, which increments user counter. */
IMB_freeImBuf(ibuf);
- if (!stereo3d)
+ if (!stereo3d) {
break;
+ }
image_add_view(ima, names[view_id], "");
}
@@ -720,109 +733,88 @@ Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name)
return ima;
}
-/* packs rects from memory as PNG
- * convert multiview images to R_IMF_VIEWS_INDIVIDUAL
- */
-static void image_memorypack_multiview(Image *ima)
+/* Pack image buffer to memory as PNG or EXR. */
+static bool image_memorypack_imbuf(Image *ima, ImBuf *ibuf, const char *filepath)
{
- ImageView *iv;
- int i;
-
- image_free_packedfiles(ima);
-
- for (i = 0, iv = ima->views.first; iv; iv = iv->next, i++) {
- ImBuf *ibuf = image_get_cached_ibuf_for_index_frame(ima, i, 0);
-
- ibuf->ftype = IMB_FTYPE_PNG;
- ibuf->planes = R_IMF_PLANES_RGBA;
+ ibuf->ftype = (ibuf->rect_float) ? IMB_FTYPE_OPENEXR : IMB_FTYPE_PNG;
- /* if the image was a R_IMF_VIEWS_STEREO_3D we force _L, _R suffices */
- if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
- const char *suffix[2] = {STEREO_LEFT_SUFFIX, STEREO_RIGHT_SUFFIX};
- BLI_path_suffix(iv->filepath, FILE_MAX, suffix[i], "");
- }
+ IMB_saveiff(ibuf, filepath, IB_rect | IB_mem);
- IMB_saveiff(ibuf, iv->filepath, IB_rect | IB_mem);
+ if (ibuf->encodedbuffer == NULL) {
+ CLOG_STR_ERROR(&LOG, "memory save for pack error");
+ IMB_freeImBuf(ibuf);
+ image_free_packedfiles(ima);
+ return false;
+ }
- if (ibuf->encodedbuffer == NULL) {
- CLOG_STR_ERROR(&LOG, "memory save for pack error");
- IMB_freeImBuf(ibuf);
- image_free_packedfiles(ima);
- return;
- }
- else {
- ImagePackedFile *imapf;
- PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile");
+ ImagePackedFile *imapf;
+ PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile");
- pf->data = ibuf->encodedbuffer;
- pf->size = ibuf->encodedsize;
+ pf->data = ibuf->encodedbuffer;
+ pf->size = ibuf->encodedsize;
- imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image PackedFile");
- STRNCPY(imapf->filepath, iv->filepath);
- imapf->packedfile = pf;
- BLI_addtail(&ima->packedfiles, imapf);
+ imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image PackedFile");
+ STRNCPY(imapf->filepath, filepath);
+ imapf->packedfile = pf;
+ BLI_addtail(&ima->packedfiles, imapf);
- ibuf->encodedbuffer = NULL;
- ibuf->encodedsize = 0;
- ibuf->userflags &= ~IB_BITMAPDIRTY;
- }
- IMB_freeImBuf(ibuf);
- }
+ ibuf->encodedbuffer = NULL;
+ ibuf->encodedsize = 0;
+ ibuf->userflags &= ~IB_BITMAPDIRTY;
- if (ima->source == IMA_SRC_GENERATED) {
- ima->source = IMA_SRC_FILE;
- ima->type = IMA_TYPE_IMAGE;
- }
- ima->views_format = R_IMF_VIEWS_INDIVIDUAL;
+ return true;
}
-/* packs rect from memory as PNG */
-void BKE_image_memorypack(Image *ima)
+/* Pack image to memory. */
+bool BKE_image_memorypack(Image *ima)
{
- ImBuf *ibuf;
+ bool ok = true;
+
+ image_free_packedfiles(ima);
if (BKE_image_is_multiview(ima)) {
- image_memorypack_multiview(ima);
- return;
- }
+ /* Store each view as a separate packed files with R_IMF_VIEWS_INDIVIDUAL. */
+ ImageView *iv;
+ int i;
- ibuf = image_get_cached_ibuf_for_index_frame(ima, IMA_NO_INDEX, 0);
+ for (i = 0, iv = ima->views.first; iv; iv = iv->next, i++) {
+ ImBuf *ibuf = image_get_cached_ibuf_for_index_frame(ima, i, 0);
- if (ibuf == NULL)
- return;
+ if (!ibuf) {
+ ok = false;
+ break;
+ }
- image_free_packedfiles(ima);
+ /* if the image was a R_IMF_VIEWS_STEREO_3D we force _L, _R suffices */
+ if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
+ const char *suffix[2] = {STEREO_LEFT_SUFFIX, STEREO_RIGHT_SUFFIX};
+ BLI_path_suffix(iv->filepath, FILE_MAX, suffix[i], "");
+ }
- ibuf->ftype = IMB_FTYPE_PNG;
- ibuf->planes = R_IMF_PLANES_RGBA;
+ ok = ok && image_memorypack_imbuf(ima, ibuf, iv->filepath);
+ IMB_freeImBuf(ibuf);
+ }
- IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem);
- if (ibuf->encodedbuffer == NULL) {
- CLOG_STR_ERROR(&LOG, "memory save for pack error");
+ ima->views_format = R_IMF_VIEWS_INDIVIDUAL;
}
else {
- ImagePackedFile *imapf;
- PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile");
-
- pf->data = ibuf->encodedbuffer;
- pf->size = ibuf->encodedsize;
-
- imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image PackedFile");
- STRNCPY(imapf->filepath, ima->name);
- imapf->packedfile = pf;
- BLI_addtail(&ima->packedfiles, imapf);
-
- ibuf->encodedbuffer = NULL;
- ibuf->encodedsize = 0;
- ibuf->userflags &= ~IB_BITMAPDIRTY;
+ ImBuf *ibuf = image_get_cached_ibuf_for_index_frame(ima, IMA_NO_INDEX, 0);
- if (ima->source == IMA_SRC_GENERATED) {
- ima->source = IMA_SRC_FILE;
- ima->type = IMA_TYPE_IMAGE;
+ if (ibuf) {
+ ok = ok && image_memorypack_imbuf(ima, ibuf, ibuf->name);
+ IMB_freeImBuf(ibuf);
+ }
+ else {
+ ok = false;
}
}
- IMB_freeImBuf(ibuf);
+ if (ok && ima->source == IMA_SRC_GENERATED) {
+ ima->source = IMA_SRC_FILE;
+ ima->type = IMA_TYPE_IMAGE;
+ }
+
+ return ok;
}
void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
@@ -885,8 +877,9 @@ static uintptr_t image_mem_size(Image *image)
uintptr_t size = 0;
/* viewers have memory depending on other rules, has no valid rect pointer */
- if (image->source == IMA_SRC_VIEWER)
+ if (image->source == IMA_SRC_VIEWER) {
return 0;
+ }
BLI_spin_lock(&image_spin);
if (image->cache != NULL) {
@@ -930,16 +923,18 @@ void BKE_image_print_memlist(Main *bmain)
Image *ima;
uintptr_t size, totsize = 0;
- for (ima = bmain->images.first; ima; ima = ima->id.next)
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
totsize += image_mem_size(ima);
+ }
printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024));
for (ima = bmain->images.first; ima; ima = ima->id.next) {
size = image_mem_size(ima);
- if (size)
+ if (size) {
printf("%s len: %.3f MB\n", ima->id.name + 2, (double)size / (double)(1024 * 1024));
+ }
}
}
@@ -958,12 +953,15 @@ void BKE_image_free_all_textures(Main *bmain)
uintptr_t tot_freed_size = 0;
#endif
- for (ima = bmain->images.first; ima; ima = ima->id.next)
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
ima->id.tag &= ~LIB_TAG_DOIT;
+ }
- for (tex = bmain->textures.first; tex; tex = tex->id.next)
- if (tex->ima)
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ if (tex->ima) {
tex->ima->id.tag |= LIB_TAG_DOIT;
+ }
+ }
for (ima = bmain->images.first; ima; ima = ima->id.next) {
if (ima->cache && (ima->id.tag & LIB_TAG_DOIT)) {
@@ -1004,9 +1002,11 @@ void BKE_image_all_free_anim_ibufs(Main *bmain, int cfra)
{
Image *ima;
- for (ima = bmain->images.first; ima; ima = ima->id.next)
- if (BKE_image_is_animated(ima))
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ if (BKE_image_is_animated(ima)) {
BKE_image_free_anim_ibufs(ima, cfra);
+ }
+ }
}
/* *********** READ AND WRITE ************** */
@@ -1193,8 +1193,9 @@ char BKE_imtype_valid_channels(const char imtype, bool write_file)
/* alpha */
switch (imtype) {
case R_IMF_IMTYPE_BMP:
- if (write_file)
+ if (write_file) {
break;
+ }
ATTR_FALLTHROUGH;
case R_IMF_IMTYPE_TARGA:
case R_IMF_IMTYPE_RAWTGA:
@@ -1255,60 +1256,81 @@ char BKE_imtype_valid_depths(const char imtype)
* creator_args.c help info */
char BKE_imtype_from_arg(const char *imtype_arg)
{
- if (STREQ(imtype_arg, "TGA"))
+ if (STREQ(imtype_arg, "TGA")) {
return R_IMF_IMTYPE_TARGA;
- else if (STREQ(imtype_arg, "IRIS"))
+ }
+ else if (STREQ(imtype_arg, "IRIS")) {
return R_IMF_IMTYPE_IRIS;
+ }
#ifdef WITH_DDS
- else if (STREQ(imtype_arg, "DDS"))
+ else if (STREQ(imtype_arg, "DDS")) {
return R_IMF_IMTYPE_DDS;
+ }
#endif
- else if (STREQ(imtype_arg, "JPEG"))
+ else if (STREQ(imtype_arg, "JPEG")) {
return R_IMF_IMTYPE_JPEG90;
- else if (STREQ(imtype_arg, "IRIZ"))
+ }
+ else if (STREQ(imtype_arg, "IRIZ")) {
return R_IMF_IMTYPE_IRIZ;
- else if (STREQ(imtype_arg, "RAWTGA"))
+ }
+ else if (STREQ(imtype_arg, "RAWTGA")) {
return R_IMF_IMTYPE_RAWTGA;
- else if (STREQ(imtype_arg, "AVIRAW"))
+ }
+ else if (STREQ(imtype_arg, "AVIRAW")) {
return R_IMF_IMTYPE_AVIRAW;
- else if (STREQ(imtype_arg, "AVIJPEG"))
+ }
+ else if (STREQ(imtype_arg, "AVIJPEG")) {
return R_IMF_IMTYPE_AVIJPEG;
- else if (STREQ(imtype_arg, "PNG"))
+ }
+ else if (STREQ(imtype_arg, "PNG")) {
return R_IMF_IMTYPE_PNG;
- else if (STREQ(imtype_arg, "BMP"))
+ }
+ else if (STREQ(imtype_arg, "BMP")) {
return R_IMF_IMTYPE_BMP;
+ }
#ifdef WITH_HDR
- else if (STREQ(imtype_arg, "HDR"))
+ else if (STREQ(imtype_arg, "HDR")) {
return R_IMF_IMTYPE_RADHDR;
+ }
#endif
#ifdef WITH_TIFF
- else if (STREQ(imtype_arg, "TIFF"))
+ else if (STREQ(imtype_arg, "TIFF")) {
return R_IMF_IMTYPE_TIFF;
+ }
#endif
#ifdef WITH_OPENEXR
- else if (STREQ(imtype_arg, "OPEN_EXR"))
+ else if (STREQ(imtype_arg, "OPEN_EXR")) {
return R_IMF_IMTYPE_OPENEXR;
- else if (STREQ(imtype_arg, "OPEN_EXR_MULTILAYER"))
+ }
+ else if (STREQ(imtype_arg, "OPEN_EXR_MULTILAYER")) {
return R_IMF_IMTYPE_MULTILAYER;
- else if (STREQ(imtype_arg, "EXR"))
+ }
+ else if (STREQ(imtype_arg, "EXR")) {
return R_IMF_IMTYPE_OPENEXR;
- else if (STREQ(imtype_arg, "MULTILAYER"))
+ }
+ else if (STREQ(imtype_arg, "MULTILAYER")) {
return R_IMF_IMTYPE_MULTILAYER;
+ }
#endif
- else if (STREQ(imtype_arg, "FFMPEG"))
+ else if (STREQ(imtype_arg, "FFMPEG")) {
return R_IMF_IMTYPE_FFMPEG;
+ }
#ifdef WITH_CINEON
- else if (STREQ(imtype_arg, "CINEON"))
+ else if (STREQ(imtype_arg, "CINEON")) {
return R_IMF_IMTYPE_CINEON;
- else if (STREQ(imtype_arg, "DPX"))
+ }
+ else if (STREQ(imtype_arg, "DPX")) {
return R_IMF_IMTYPE_DPX;
+ }
#endif
#ifdef WITH_OPENJPEG
- else if (STREQ(imtype_arg, "JP2"))
+ else if (STREQ(imtype_arg, "JP2")) {
return R_IMF_IMTYPE_JP2;
+ }
#endif
- else
+ else {
return R_IMF_IMTYPE_INVALID;
+ }
}
static bool do_add_image_extension(char *string,
@@ -1320,17 +1342,20 @@ static bool do_add_image_extension(char *string,
(void)im_format; /* may be unused, depends on build options */
if (imtype == R_IMF_IMTYPE_IRIS) {
- if (!BLI_path_extension_check(string, extension_test = ".rgb"))
+ if (!BLI_path_extension_check(string, extension_test = ".rgb")) {
extension = extension_test;
+ }
}
else if (imtype == R_IMF_IMTYPE_IRIZ) {
- if (!BLI_path_extension_check(string, extension_test = ".rgb"))
+ if (!BLI_path_extension_check(string, extension_test = ".rgb")) {
extension = extension_test;
+ }
}
#ifdef WITH_HDR
else if (imtype == R_IMF_IMTYPE_RADHDR) {
- if (!BLI_path_extension_check(string, extension_test = ".hdr"))
+ if (!BLI_path_extension_check(string, extension_test = ".hdr")) {
extension = extension_test;
+ }
}
#endif
else if (ELEM(imtype,
@@ -1339,22 +1364,26 @@ static bool do_add_image_extension(char *string,
R_IMF_IMTYPE_H264,
R_IMF_IMTYPE_THEORA,
R_IMF_IMTYPE_XVID)) {
- if (!BLI_path_extension_check(string, extension_test = ".png"))
+ if (!BLI_path_extension_check(string, extension_test = ".png")) {
extension = extension_test;
+ }
}
#ifdef WITH_DDS
else if (imtype == R_IMF_IMTYPE_DDS) {
- if (!BLI_path_extension_check(string, extension_test = ".dds"))
+ if (!BLI_path_extension_check(string, extension_test = ".dds")) {
extension = extension_test;
+ }
}
#endif
else if (ELEM(imtype, R_IMF_IMTYPE_TARGA, R_IMF_IMTYPE_RAWTGA)) {
- if (!BLI_path_extension_check(string, extension_test = ".tga"))
+ if (!BLI_path_extension_check(string, extension_test = ".tga")) {
extension = extension_test;
+ }
}
else if (imtype == R_IMF_IMTYPE_BMP) {
- if (!BLI_path_extension_check(string, extension_test = ".bmp"))
+ if (!BLI_path_extension_check(string, extension_test = ".bmp")) {
extension = extension_test;
+ }
}
#ifdef WITH_TIFF
else if (imtype == R_IMF_IMTYPE_TIFF) {
@@ -1365,49 +1394,58 @@ static bool do_add_image_extension(char *string,
#endif
#ifdef WITH_OPENIMAGEIO
else if (imtype == R_IMF_IMTYPE_PSD) {
- if (!BLI_path_extension_check(string, extension_test = ".psd"))
+ if (!BLI_path_extension_check(string, extension_test = ".psd")) {
extension = extension_test;
+ }
}
#endif
#ifdef WITH_OPENEXR
else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) {
- if (!BLI_path_extension_check(string, extension_test = ".exr"))
+ if (!BLI_path_extension_check(string, extension_test = ".exr")) {
extension = extension_test;
+ }
}
#endif
#ifdef WITH_CINEON
else if (imtype == R_IMF_IMTYPE_CINEON) {
- if (!BLI_path_extension_check(string, extension_test = ".cin"))
+ if (!BLI_path_extension_check(string, extension_test = ".cin")) {
extension = extension_test;
+ }
}
else if (imtype == R_IMF_IMTYPE_DPX) {
- if (!BLI_path_extension_check(string, extension_test = ".dpx"))
+ if (!BLI_path_extension_check(string, extension_test = ".dpx")) {
extension = extension_test;
+ }
}
#endif
#ifdef WITH_OPENJPEG
else if (imtype == R_IMF_IMTYPE_JP2) {
if (im_format) {
if (im_format->jp2_codec == R_IMF_JP2_CODEC_JP2) {
- if (!BLI_path_extension_check(string, extension_test = ".jp2"))
+ if (!BLI_path_extension_check(string, extension_test = ".jp2")) {
extension = extension_test;
+ }
}
else if (im_format->jp2_codec == R_IMF_JP2_CODEC_J2K) {
- if (!BLI_path_extension_check(string, extension_test = ".j2c"))
+ if (!BLI_path_extension_check(string, extension_test = ".j2c")) {
extension = extension_test;
+ }
}
- else
+ else {
BLI_assert(!"Unsupported jp2 codec was specified in im_format->jp2_codec");
+ }
}
else {
- if (!BLI_path_extension_check(string, extension_test = ".jp2"))
+ if (!BLI_path_extension_check(string, extension_test = ".jp2")) {
extension = extension_test;
+ }
}
}
#endif
else { // R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90 etc
- if (!(BLI_path_extension_check_n(string, extension_test = ".jpg", ".jpeg", NULL)))
+ if (!(BLI_path_extension_check_n(string, extension_test = ".jpg", ".jpeg", NULL))) {
extension = extension_test;
+ }
}
if (extension) {
@@ -1459,97 +1497,116 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i
/* file type */
- if (ftype == IMB_FTYPE_IMAGIC)
+ if (ftype == IMB_FTYPE_IMAGIC) {
im_format->imtype = R_IMF_IMTYPE_IRIS;
-
+ }
#ifdef WITH_HDR
- else if (ftype == IMB_FTYPE_RADHDR)
+ else if (ftype == IMB_FTYPE_RADHDR) {
im_format->imtype = R_IMF_IMTYPE_RADHDR;
+ }
#endif
-
else if (ftype == IMB_FTYPE_PNG) {
im_format->imtype = R_IMF_IMTYPE_PNG;
- if (custom_flags & PNG_16BIT)
+ if (custom_flags & PNG_16BIT) {
im_format->depth = R_IMF_CHAN_DEPTH_16;
+ }
im_format->compress = quality;
}
#ifdef WITH_DDS
- else if (ftype == IMB_FTYPE_DDS)
+ else if (ftype == IMB_FTYPE_DDS) {
im_format->imtype = R_IMF_IMTYPE_DDS;
+ }
#endif
-
- else if (ftype == IMB_FTYPE_BMP)
+ else if (ftype == IMB_FTYPE_BMP) {
im_format->imtype = R_IMF_IMTYPE_BMP;
-
+ }
#ifdef WITH_TIFF
else if (ftype == IMB_FTYPE_TIF) {
im_format->imtype = R_IMF_IMTYPE_TIFF;
- if (custom_flags & TIF_16BIT)
+ if (custom_flags & TIF_16BIT) {
im_format->depth = R_IMF_CHAN_DEPTH_16;
- if (custom_flags & TIF_COMPRESS_NONE)
+ }
+ if (custom_flags & TIF_COMPRESS_NONE) {
im_format->tiff_codec = R_IMF_TIFF_CODEC_NONE;
- if (custom_flags & TIF_COMPRESS_DEFLATE)
+ }
+ if (custom_flags & TIF_COMPRESS_DEFLATE) {
im_format->tiff_codec = R_IMF_TIFF_CODEC_DEFLATE;
- if (custom_flags & TIF_COMPRESS_LZW)
+ }
+ if (custom_flags & TIF_COMPRESS_LZW) {
im_format->tiff_codec = R_IMF_TIFF_CODEC_LZW;
- if (custom_flags & TIF_COMPRESS_PACKBITS)
+ }
+ if (custom_flags & TIF_COMPRESS_PACKBITS) {
im_format->tiff_codec = R_IMF_TIFF_CODEC_PACKBITS;
+ }
}
#endif
#ifdef WITH_OPENEXR
else if (ftype == IMB_FTYPE_OPENEXR) {
im_format->imtype = R_IMF_IMTYPE_OPENEXR;
- if (custom_flags & OPENEXR_HALF)
+ if (custom_flags & OPENEXR_HALF) {
im_format->depth = R_IMF_CHAN_DEPTH_16;
- if (custom_flags & OPENEXR_COMPRESS)
+ }
+ if (custom_flags & OPENEXR_COMPRESS) {
im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; // Can't determine compression
- if (imbuf->zbuf_float)
+ }
+ if (imbuf->zbuf_float) {
im_format->flag |= R_IMF_FLAG_ZBUF;
+ }
}
#endif
#ifdef WITH_CINEON
- else if (ftype == IMB_FTYPE_CINEON)
+ else if (ftype == IMB_FTYPE_CINEON) {
im_format->imtype = R_IMF_IMTYPE_CINEON;
- else if (ftype == IMB_FTYPE_DPX)
+ }
+ else if (ftype == IMB_FTYPE_DPX) {
im_format->imtype = R_IMF_IMTYPE_DPX;
+ }
#endif
-
else if (ftype == IMB_FTYPE_TGA) {
- if (custom_flags & RAWTGA)
+ if (custom_flags & RAWTGA) {
im_format->imtype = R_IMF_IMTYPE_RAWTGA;
- else
+ }
+ else {
im_format->imtype = R_IMF_IMTYPE_TARGA;
+ }
}
#ifdef WITH_OPENJPEG
else if (ftype == IMB_FTYPE_JP2) {
im_format->imtype = R_IMF_IMTYPE_JP2;
im_format->quality = quality;
- if (custom_flags & JP2_16BIT)
+ if (custom_flags & JP2_16BIT) {
im_format->depth = R_IMF_CHAN_DEPTH_16;
- else if (custom_flags & JP2_12BIT)
+ }
+ else if (custom_flags & JP2_12BIT) {
im_format->depth = R_IMF_CHAN_DEPTH_12;
+ }
- if (custom_flags & JP2_YCC)
+ if (custom_flags & JP2_YCC) {
im_format->jp2_flag |= R_IMF_JP2_FLAG_YCC;
+ }
if (custom_flags & JP2_CINE) {
im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
- if (custom_flags & JP2_CINE_48FPS)
+ if (custom_flags & JP2_CINE_48FPS) {
im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
+ }
}
- if (custom_flags & JP2_JP2)
+ if (custom_flags & JP2_JP2) {
im_format->jp2_codec = R_IMF_JP2_CODEC_JP2;
- else if (custom_flags & JP2_J2K)
+ }
+ else if (custom_flags & JP2_J2K) {
im_format->jp2_codec = R_IMF_JP2_CODEC_J2K;
- else
+ }
+ else {
BLI_assert(!"Unsupported jp2 codec was specified in file type");
+ }
}
#endif
@@ -1646,10 +1703,12 @@ static void stampdata(
if (use_dynamic && scene->r.stamp & R_STAMP_MARKER) {
const char *name = BKE_scene_find_last_marker_name(scene, CFRA);
- if (name)
+ if (name) {
STRNCPY(text, name);
- else
+ }
+ else {
STRNCPY(text, "<none>");
+ }
SNPRINTF(stamp_data->marker, do_prefix ? "Marker %s" : "%s", text);
}
@@ -1671,8 +1730,9 @@ static void stampdata(
char fmtstr[32];
int digits = 1;
- if (scene->r.efra > 9)
+ if (scene->r.efra > 9) {
digits = integer_digits_i(scene->r.efra);
+ }
SNPRINTF(fmtstr, do_prefix ? "Frame %%0%di" : "%%0%di", digits);
SNPRINTF(stamp_data->frame, fmtstr, scene->r.cfra);
@@ -1724,10 +1784,12 @@ static void stampdata(
if (use_dynamic && scene->r.stamp & R_STAMP_SEQSTRIP) {
Sequence *seq = BKE_sequencer_foreground_frame_get(scene, scene->r.cfra);
- if (seq)
+ if (seq) {
STRNCPY(text, seq->name + 2);
- else
+ }
+ else {
STRNCPY(text, "<none>");
+ }
SNPRINTF(stamp_data->strip, do_prefix ? "Strip %s" : "%s", text);
}
@@ -1898,8 +1960,9 @@ void BKE_image_stamp_buf(Scene *scene,
#define BUFF_MARGIN_X 2
#define BUFF_MARGIN_Y 1
- if (!rect && !rectf)
+ if (!rect && !rectf) {
return;
+ }
display_device = scene->display_settings.display_device;
display = IMB_colormanagement_display_get_named(display_device);
@@ -1912,8 +1975,9 @@ void BKE_image_stamp_buf(Scene *scene,
}
/* TODO, do_versions */
- if (scene->r.stamp_font_id < 8)
+ if (scene->r.stamp_font_id < 8) {
scene->r.stamp_font_id = 12;
+ }
/* set before return */
BLF_size(mono, scene->r.stamp_font_id, 72);
@@ -2237,8 +2301,9 @@ void BKE_render_result_stamp_info(Scene *scene,
{
struct StampData *stamp_data;
- if (!(scene && (scene->r.stamp & R_STAMP_ALL)) && !allocate_only)
+ if (!(scene && (scene->r.stamp & R_STAMP_ALL)) && !allocate_only) {
return;
+ }
if (!rr->stamp_data) {
stamp_data = MEM_callocN(sizeof(StampData), "RenderResult.stamp_data");
@@ -2247,8 +2312,9 @@ void BKE_render_result_stamp_info(Scene *scene,
stamp_data = rr->stamp_data;
}
- if (!allocate_only)
+ if (!allocate_only) {
stampdata(scene, camera, stamp_data, 0, true);
+ }
if (!rr->stamp_data) {
rr->stamp_data = stamp_data;
@@ -2259,8 +2325,9 @@ struct StampData *BKE_stamp_info_from_scene_static(Scene *scene)
{
struct StampData *stamp_data;
- if (!(scene && (scene->r.stamp & R_STAMP_ALL)))
+ if (!(scene && (scene->r.stamp & R_STAMP_ALL))) {
return NULL;
+ }
/* Memory is allocated here (instead of by the caller) so that the caller
* doesn't have to know the size of the StampData struct. */
@@ -2479,8 +2546,9 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
ibuf->ftype = IMB_FTYPE_PNG;
if (imtype == R_IMF_IMTYPE_PNG) {
- if (imf->depth == R_IMF_CHAN_DEPTH_16)
+ if (imf->depth == R_IMF_CHAN_DEPTH_16) {
ibuf->foptions.flag |= PNG_16BIT;
+ }
ibuf->foptions.quality = compress;
}
@@ -2517,8 +2585,9 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
#ifdef WITH_OPENEXR
else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
ibuf->ftype = IMB_FTYPE_OPENEXR;
- if (imf->depth == R_IMF_CHAN_DEPTH_16)
+ if (imf->depth == R_IMF_CHAN_DEPTH_16) {
ibuf->foptions.flag |= OPENEXR_HALF;
+ }
ibuf->foptions.flag |= (imf->exr_codec & OPENEXR_COMPRESS);
if (!(imf->flag & R_IMF_FLAG_ZBUF)) {
@@ -2568,8 +2637,9 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
}
#ifdef WITH_OPENJPEG
else if (imtype == R_IMF_IMTYPE_JP2) {
- if (quality < 10)
+ if (quality < 10) {
quality = 90;
+ }
ibuf->ftype = IMB_FTYPE_JP2;
ibuf->foptions.quality = quality;
@@ -2586,22 +2656,27 @@ void BKE_imbuf_write_prepare(ImBuf *ibuf, const ImageFormatData *imf)
if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_PRESET) {
ibuf->foptions.flag |= JP2_CINE;
- if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_48)
+ if (imf->jp2_flag & R_IMF_JP2_FLAG_CINE_48) {
ibuf->foptions.flag |= JP2_CINE_48FPS;
+ }
}
- if (imf->jp2_codec == R_IMF_JP2_CODEC_JP2)
+ if (imf->jp2_codec == R_IMF_JP2_CODEC_JP2) {
ibuf->foptions.flag |= JP2_JP2;
- else if (imf->jp2_codec == R_IMF_JP2_CODEC_J2K)
+ }
+ else if (imf->jp2_codec == R_IMF_JP2_CODEC_J2K) {
ibuf->foptions.flag |= JP2_J2K;
- else
+ }
+ else {
BLI_assert(!"Unsupported jp2 codec was specified in im_format->jp2_codec");
+ }
}
#endif
else {
/* R_IMF_IMTYPE_JPEG90, etc. default we save jpegs */
- if (quality < 10)
+ if (quality < 10) {
quality = 90;
+ }
ibuf->ftype = IMB_FTYPE_JPG;
ibuf->foptions.quality = quality;
}
@@ -2652,8 +2727,9 @@ int BKE_imbuf_write_stamp(Scene *scene,
const char *name,
const struct ImageFormatData *imf)
{
- if (scene && scene->r.stamp & R_STAMP_ALL)
+ if (scene && scene->r.stamp & R_STAMP_ALL) {
BKE_imbuf_stamp_info(rr, ibuf);
+ }
return BKE_imbuf_write(ibuf, name, imf);
}
@@ -2668,19 +2744,23 @@ static void do_makepicstring(char *string,
const short use_frames,
const char *suffix)
{
- if (string == NULL)
+ if (string == NULL) {
return;
+ }
BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */
BLI_path_abs(string, relbase);
- if (use_frames)
+ if (use_frames) {
BLI_path_frame(string, frame, 4);
+ }
- if (suffix)
+ if (suffix) {
BLI_path_suffix(string, FILE_MAX, suffix, "");
+ }
- if (use_ext)
+ if (use_ext) {
do_add_image_extension(string, imtype, im_format);
+ }
}
void BKE_image_path_from_imformat(char *string,
@@ -2726,15 +2806,18 @@ struct anim *openanim(const char *name, int flags, int streamindex, char colorsp
struct ImBuf *ibuf;
anim = IMB_open_anim(name, flags, streamindex, colorspace);
- if (anim == NULL)
+ if (anim == NULL) {
return NULL;
+ }
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (ibuf == NULL) {
- if (BLI_exists(name))
+ if (BLI_exists(name)) {
printf("not an anim: %s\n", name);
- else
+ }
+ else {
printf("anim file doesn't exist: %s\n", name);
+ }
IMB_free_anim(anim);
return NULL;
}
@@ -2768,17 +2851,22 @@ Image *BKE_image_verify_viewer(Main *bmain, int type, const char *name)
{
Image *ima;
- for (ima = bmain->images.first; ima; ima = ima->id.next)
- if (ima->source == IMA_SRC_VIEWER)
- if (ima->type == type)
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ if (ima->source == IMA_SRC_VIEWER) {
+ if (ima->type == type) {
break;
+ }
+ }
+ }
- if (ima == NULL)
+ if (ima == NULL) {
ima = image_alloc(bmain, name, IMA_SRC_VIEWER, type);
+ }
/* happens on reload, imagewindow cannot be image user when hidden*/
- if (ima->id.us == 0)
+ if (ima->id.us == 0) {
id_us_plus(&ima->id);
+ }
return ima;
}
@@ -2791,8 +2879,9 @@ static void image_viewer_create_views(const RenderData *rd, Image *ima)
else {
SceneRenderView *srv;
for (srv = rd->views.first; srv; srv = srv->next) {
- if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
+ if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
continue;
+ }
image_add_view(ima, srv->name, "");
}
}
@@ -2806,8 +2895,9 @@ void BKE_image_verify_viewer_views(const RenderData *rd, Image *ima, ImageUser *
BLI_thread_lock(LOCK_DRAW_IMAGE);
- if (!BKE_scene_multiview_is_stereo3d(rd))
+ if (!BKE_scene_multiview_is_stereo3d(rd)) {
iuser->flag &= ~IMA_SHOW_STEREO;
+ }
/* see if all scene render views are in the image view list */
do_reset = (BKE_scene_multiview_num_views_get(rd) != BLI_listbase_count(&ima->views));
@@ -3029,26 +3119,31 @@ static void image_tag_reload(Image *ima, ImageUser *iuser, void *customdata)
}
}
-static void image_init_imageuser(Image *ima, ImageUser *iuser)
+void BKE_imageuser_default(ImageUser *iuser)
+{
+ memset(iuser, 0, sizeof(ImageUser));
+ iuser->ok = true;
+ iuser->frames = 100;
+ iuser->sfra = 1;
+}
+
+void BKE_image_init_imageuser(Image *ima, ImageUser *iuser)
{
RenderResult *rr = ima->rr;
iuser->multi_index = 0;
iuser->layer = iuser->pass = iuser->view = 0;
- if (rr)
+ if (rr) {
BKE_image_multilayer_index(rr, iuser);
-}
-
-void BKE_image_init_imageuser(Image *ima, ImageUser *iuser)
-{
- image_init_imageuser(ima, iuser);
+ }
}
void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
{
- if (ima == NULL)
+ if (ima == NULL) {
return;
+ }
BLI_spin_lock(&image_spin);
@@ -3064,9 +3159,11 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
}
break;
case IMA_SIGNAL_SRC_CHANGE:
- if (ima->type == IMA_TYPE_UV_TEST)
- if (ima->source != IMA_SRC_GENERATED)
+ if (ima->type == IMA_TYPE_UV_TEST) {
+ if (ima->source != IMA_SRC_GENERATED) {
ima->type = IMA_TYPE_IMAGE;
+ }
+ }
if (ima->source == IMA_SRC_GENERATED) {
if (ima->gen_x == 0 || ima->gen_y == 0) {
@@ -3130,11 +3227,13 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
}
}
- if (BKE_image_has_packedfile(ima))
+ if (BKE_image_has_packedfile(ima)) {
BKE_image_free_buffers(ima);
+ }
}
- else
+ else {
BKE_image_free_buffers(ima);
+ }
if (iuser) {
image_tag_reload(ima, iuser, ima);
@@ -3146,7 +3245,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
iuser->ok = 1;
if (ima->source == IMA_SRC_FILE || ima->source == IMA_SRC_SEQUENCE) {
if (ima->type == IMA_TYPE_MULTILAYER) {
- image_init_imageuser(ima, iuser);
+ BKE_image_init_imageuser(ima, iuser);
}
}
}
@@ -3156,8 +3255,9 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
ima->ok = 1;
- if (iuser)
+ if (iuser) {
iuser->ok = 1;
+ }
break;
}
@@ -3228,16 +3328,18 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser)
RenderLayer *rl;
RenderPass *rpass = NULL;
- if (rr == NULL)
+ if (rr == NULL) {
return NULL;
+ }
if (iuser) {
short index = 0, rv_index, rl_index = 0;
bool is_stereo = (iuser->flag & IMA_SHOW_STEREO) && RE_RenderResult_is_stereo(rr);
rv_index = is_stereo ? iuser->multiview_eye : iuser->view;
- if (RE_HasCombinedLayer(rr))
+ if (RE_HasCombinedLayer(rr)) {
rl_index += 1;
+ }
for (rl = rr->layers.first; rl; rl = rl->next, rl_index++) {
if (iuser->layer == rl_index) {
@@ -3318,8 +3420,9 @@ static void image_init_multilayer_multiview(Image *ima, RenderResult *rr)
for (; rv; rv = rv->next, iv = iv->next) {
modified |= !STREQ(rv->name, iv->name);
}
- if (!modified)
+ if (!modified) {
return;
+ }
}
BKE_image_free_views(ima);
@@ -3340,10 +3443,12 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima)
rr = ima->rr;
}
else if (ima->type == IMA_TYPE_R_RESULT) {
- if (ima->render_slot == ima->last_render_slot)
+ if (ima->render_slot == ima->last_render_slot) {
rr = RE_AcquireResultRead(RE_GetSceneRender(scene));
- else
+ }
+ else {
rr = BKE_image_get_renderslot(ima, ima->render_slot)->render;
+ }
/* set proper views */
image_init_multilayer_multiview(ima, rr);
@@ -3358,8 +3463,9 @@ void BKE_image_release_renderresult(Scene *scene, Image *ima)
/* pass */
}
else if (ima->type == IMA_TYPE_R_RESULT) {
- if (ima->render_slot == ima->last_render_slot)
+ if (ima->render_slot == ima->last_render_slot) {
RE_ReleaseResult(RE_GetSceneRender(scene));
+ }
}
}
@@ -3453,8 +3559,9 @@ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr)
bool predivide = (ima->alpha_mode == IMA_ALPHA_PREMUL);
/* only load rr once for multiview */
- if (!ima->rr)
+ if (!ima->rr) {
ima->rr = RE_MultilayerConvert(ibuf->userdata, colorspace, predivide, ibuf->x, ibuf->y);
+ }
IMB_exr_close(ibuf->userdata);
@@ -3488,10 +3595,12 @@ static int imbuf_alpha_flags_for_image(Image *ima)
{
int flag = 0;
- if (ima->flag & IMA_IGNORE_ALPHA)
+ if (ima->flag & IMA_IGNORE_ALPHA) {
flag |= IB_ignore_alpha;
- else if (ima->alpha_mode == IMA_ALPHA_PREMUL)
+ }
+ else if (ima->alpha_mode == IMA_ALPHA_PREMUL) {
flag |= IB_alphamode_premul;
+ }
return flag;
}
@@ -3593,11 +3702,13 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
ibuf_arr = MEM_mallocN(sizeof(ImBuf *) * totviews, "Image Views Imbufs");
- for (i = 0; i < totfiles; i++)
+ for (i = 0; i < totfiles; i++) {
ibuf_arr[i] = load_sequence_single(ima, iuser, frame, i, &assign);
+ }
- if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D)
+ if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D) {
IMB_ImBufFromStereo3d(ima->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
+ }
/* return the original requested ImBuf */
ibuf = ibuf_arr[(iuser ? iuser->multi_index : 0)];
@@ -3666,11 +3777,13 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f
}
// else printf("pass not found\n");
}
- else
+ else {
ima->ok = 0;
+ }
- if (iuser)
+ if (iuser) {
iuser->ok = ima->ok;
+ }
return ibuf;
}
@@ -3691,8 +3804,9 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i
flags |= IB_animdeinterlace;
}
- if (iuser)
+ if (iuser) {
iuser_t = *iuser;
+ }
iuser_t.view = view_id;
@@ -3702,28 +3816,33 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i
ia->anim = openanim(str, flags, 0, ima->colorspace_settings.name);
/* let's initialize this user */
- if (ia->anim && iuser && iuser->frames == 0)
+ if (ia->anim && iuser && iuser->frames == 0) {
iuser->frames = IMB_anim_get_duration(ia->anim, IMB_TC_RECORD_RUN);
+ }
}
if (ia->anim) {
int dur = IMB_anim_get_duration(ia->anim, IMB_TC_RECORD_RUN);
int fra = frame - 1;
- if (fra < 0)
+ if (fra < 0) {
fra = 0;
- if (fra > (dur - 1))
+ }
+ if (fra > (dur - 1)) {
fra = dur - 1;
+ }
ibuf = IMB_makeSingleUser(IMB_anim_absolute(ia->anim, fra, IMB_TC_RECORD_RUN, IMB_PROXY_NONE));
if (ibuf) {
image_initialize_after_load(ima, ibuf);
}
- else
+ else {
ima->ok = 0;
+ }
}
- else
+ else {
ima->ok = 0;
+ }
return ibuf;
}
@@ -3759,8 +3878,9 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
ibuf_arr[i] = load_movie_single(ima, iuser, frame, i);
}
- if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D)
+ if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D) {
IMB_ImBufFromStereo3d(ima->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]);
+ }
for (i = 0; i < totviews; i++) {
if (ibuf_arr[i]) {
@@ -3785,8 +3905,9 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
MEM_freeN(ibuf_arr);
}
- if (iuser)
+ if (iuser) {
iuser->ok = ima->ok;
+ }
return ibuf;
}
@@ -3827,10 +3948,12 @@ static ImBuf *load_image_single(Image *ima,
/* get the correct filepath */
BKE_image_user_frame_calc(iuser, cfra);
- if (iuser)
+ if (iuser) {
iuser_t = *iuser;
- else
+ }
+ else {
iuser_t.framenr = ima->lastframe;
+ }
iuser_t.view = view_id;
@@ -3911,8 +4034,9 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Image Views Imbufs");
- for (i = 0; i < totfiles; i++)
+ for (i = 0; i < totfiles; i++) {
ibuf_arr[i] = load_image_single(ima, iuser, cfra, i, has_packed, &assign);
+ }
/* multi-views/multi-layers OpenEXR files directly populate ima, and return NULL ibuf... */
if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D && ibuf_arr[0] &&
@@ -3941,8 +4065,9 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
MEM_freeN(ibuf_arr);
}
- if (iuser)
+ if (iuser) {
iuser->ok = ima->ok;
+ }
return ibuf;
}
@@ -3976,10 +4101,12 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
}
}
- if (ibuf == NULL)
+ if (ibuf == NULL) {
ima->ok = 0;
- if (iuser)
+ }
+ if (iuser) {
iuser->ok = ima->ok;
+ }
return ibuf;
}
@@ -4001,12 +4128,14 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
int actview;
bool byte_buffer_in_display_space = false;
- if (!(iuser && iuser->scene))
+ if (!(iuser && iuser->scene)) {
return NULL;
+ }
/* if we the caller is not going to release the lock, don't give the image */
- if (!r_lock)
+ if (!r_lock) {
return NULL;
+ }
re = RE_GetSceneRender(iuser->scene);
@@ -4015,8 +4144,9 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
pass = iuser->pass;
actview = iuser->view;
- if (BKE_image_is_stereo(ima) && (iuser->flag & IMA_SHOW_STEREO))
+ if (BKE_image_is_stereo(ima) && (iuser->flag & IMA_SHOW_STEREO)) {
actview = iuser->multiview_eye;
+ }
RenderSlot *slot;
if (from_render) {
@@ -4026,12 +4156,14 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
rres = *(slot->render);
rres.have_combined = ((RenderView *)rres.views.first)->rectf != NULL;
}
- else
+ else {
memset(&rres, 0, sizeof(RenderResult));
+ }
if (!(rres.rectx > 0 && rres.recty > 0)) {
- if (from_render)
+ if (from_render) {
RE_ReleaseResultImage(re);
+ }
return NULL;
}
@@ -4043,8 +4175,9 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
}
else {
rv = BLI_findlink(&rres.views, actview);
- if (rv == NULL)
+ if (rv == NULL) {
rv = rres.views.first;
+ }
}
/* this gives active layer, composite or sequence result */
@@ -4094,9 +4227,11 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
}
}
- for (rpass = rl->passes.first; rpass; rpass = rpass->next)
- if (STREQ(rpass->name, RE_PASSNAME_Z) && rpass->view_id == actview)
+ for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
+ if (STREQ(rpass->name, RE_PASSNAME_Z) && rpass->view_id == actview) {
rectz = rpass->rect;
+ }
+ }
}
}
@@ -4148,8 +4283,9 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
* need check for whether byte buffer was allocated and owned by image itself
* or if it's reusing buffer from render result
*/
- if ((ibuf->mall & IB_rect) == 0)
+ if ((ibuf->mall & IB_rect) == 0) {
ibuf->rect = NULL;
+ }
}
if (rectf) {
@@ -4262,8 +4398,9 @@ static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_frame,
if (ibuf) {
ima->ok = IMA_OK_LOADED;
- if (iuser)
+ if (iuser) {
iuser->ok = ima->ok;
+ }
}
}
else if (ima->type == IMA_TYPE_MULTILAYER) {
@@ -4272,10 +4409,12 @@ static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_frame,
}
}
else if (ima->source == IMA_SRC_FILE) {
- if (ima->type == IMA_TYPE_IMAGE)
+ if (ima->type == IMA_TYPE_IMAGE) {
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, 0);
- else if (ima->type == IMA_TYPE_MULTILAYER)
+ }
+ else if (ima->type == IMA_TYPE_MULTILAYER) {
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, 0);
+ }
}
else if (ima->source == IMA_SRC_GENERATED) {
ibuf = image_get_cached_ibuf_for_index_frame(ima, index, 0);
@@ -4286,26 +4425,31 @@ static ImBuf *image_get_cached_ibuf(Image *ima, ImageUser *iuser, int *r_frame,
* a big bottleneck */
}
- if (r_frame)
+ if (r_frame) {
*r_frame = frame;
+ }
- if (r_index)
+ if (r_index) {
*r_index = index;
+ }
return ibuf;
}
BLI_INLINE bool image_quick_test(Image *ima, ImageUser *iuser)
{
- if (ima == NULL)
+ if (ima == NULL) {
return false;
+ }
if (iuser) {
- if (iuser->ok == 0)
+ if (iuser->ok == 0) {
return false;
+ }
}
- else if (ima->ok == 0)
+ else if (ima->ok == 0) {
return false;
+ }
return true;
}
@@ -4319,12 +4463,14 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
ImBuf *ibuf = NULL;
int frame = 0, index = 0;
- if (r_lock)
+ if (r_lock) {
*r_lock = NULL;
+ }
/* quick reject tests */
- if (!image_quick_test(ima, iuser))
+ if (!image_quick_test(ima, iuser)) {
return NULL;
+ }
ibuf = image_get_cached_ibuf(ima, iuser, &frame, &index);
@@ -4347,22 +4493,27 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
}
else if (ima->source == IMA_SRC_FILE) {
- if (ima->type == IMA_TYPE_IMAGE)
+ if (ima->type == IMA_TYPE_IMAGE) {
ibuf = image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */
+ }
/* no else; on load the ima type can change */
- if (ima->type == IMA_TYPE_MULTILAYER)
+ if (ima->type == IMA_TYPE_MULTILAYER) {
/* keeps render result, stores ibufs in listbase, allows saving */
ibuf = image_get_ibuf_multilayer(ima, iuser);
+ }
}
else if (ima->source == IMA_SRC_GENERATED) {
/* generated is: ibuf is allocated dynamically */
/* UV testgrid or black or solid etc */
- if (ima->gen_x == 0)
+ if (ima->gen_x == 0) {
ima->gen_x = 1024;
- if (ima->gen_y == 0)
+ }
+ if (ima->gen_y == 0) {
ima->gen_y = 1024;
- if (ima->gen_depth == 0)
+ }
+ if (ima->gen_depth == 0) {
ima->gen_depth = 24;
+ }
ibuf = add_ibuf_size(ima->gen_x,
ima->gen_y,
ima->name,
@@ -4458,15 +4609,17 @@ bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
ImBuf *ibuf;
/* quick reject tests */
- if (!image_quick_test(ima, iuser))
+ if (!image_quick_test(ima, iuser)) {
return false;
+ }
BLI_spin_lock(&image_spin);
ibuf = image_get_cached_ibuf(ima, iuser, NULL, NULL);
- if (!ibuf)
+ if (!ibuf) {
ibuf = image_acquire_ibuf(ima, iuser, NULL);
+ }
BLI_spin_unlock(&image_spin);
@@ -4536,8 +4689,9 @@ ImBuf *BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool
int index, frame;
bool found;
- if (!image_quick_test(ima, iuser))
+ if (!image_quick_test(ima, iuser)) {
return NULL;
+ }
if (pool == NULL) {
/* pool could be NULL, in this case use general acquire function */
@@ -4547,8 +4701,9 @@ ImBuf *BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool
image_get_frame_and_index(ima, iuser, &frame, &index);
ibuf = image_pool_find_entry(pool, ima, frame, index, &found);
- if (found)
+ if (found) {
return ibuf;
+ }
BLI_spin_lock(&image_spin);
@@ -4604,10 +4759,12 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, bool *r_is_in_ran
/* cyclic */
if (iuser->cycl) {
cfra = ((cfra) % len);
- if (cfra < 0)
+ if (cfra < 0) {
cfra += len;
- if (cfra == 0)
+ }
+ if (cfra == 0) {
cfra = len;
+ }
if (r_is_in_range) {
*r_is_in_range = true;
@@ -4628,15 +4785,18 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, bool *r_is_in_ran
/* transform to images space */
framenr = cfra;
- if (framenr > iuser->frames)
+ if (framenr > iuser->frames) {
framenr = iuser->frames;
+ }
if (iuser->cycl) {
framenr = ((framenr) % len);
- while (framenr < 0)
+ while (framenr < 0) {
framenr += len;
- if (framenr == 0)
+ }
+ if (framenr == 0) {
framenr = len;
+ }
}
/* important to apply after else we cant loop on frames 100 - 110 for eg. */
@@ -4660,8 +4820,9 @@ void BKE_image_user_frame_calc(ImageUser *iuser, int cfra)
}
iuser->framenr = framenr;
- if (iuser->ok == 0)
+ if (iuser->ok == 0) {
iuser->ok = 1;
+ }
}
}
@@ -4751,10 +4912,12 @@ void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath)
{
if (BKE_image_is_multiview(ima)) {
ImageView *iv = BLI_findlink(&ima->views, iuser->view);
- if (iv->filepath[0])
+ if (iv->filepath[0]) {
BLI_strncpy(filepath, iv->filepath, FILE_MAX);
- else
+ }
+ else {
BLI_strncpy(filepath, ima->name, FILE_MAX);
+ }
}
else {
BLI_strncpy(filepath, ima->name, FILE_MAX);
@@ -4782,10 +4945,12 @@ bool BKE_image_has_alpha(struct Image *image)
planes = (ibuf ? ibuf->planes : 0);
BKE_image_release_ibuf(image, ibuf, lock);
- if (planes == 32)
+ if (planes == 32) {
return true;
- else
+ }
+ else {
return false;
+ }
}
void BKE_image_get_size(Image *image, ImageUser *iuser, int *width, int *height)
@@ -4835,10 +5000,12 @@ void BKE_image_get_aspect(Image *image, float *aspx, float *aspy)
*aspx = 1.0;
/* x is always 1 */
- if (image)
+ if (image) {
*aspy = image->aspy / image->aspx;
- else
+ }
+ else {
*aspy = 1.0f;
+ }
}
unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame)
@@ -4856,14 +5023,16 @@ unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame)
if (ibuf) {
pixels = (unsigned char *)ibuf->rect;
- if (pixels)
+ if (pixels) {
pixels = MEM_dupallocN(pixels);
+ }
BKE_image_release_ibuf(image, ibuf, lock);
}
- if (!pixels)
+ if (!pixels) {
return NULL;
+ }
return pixels;
}
@@ -4883,14 +5052,16 @@ float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame)
if (ibuf) {
pixels = ibuf->rect_float;
- if (pixels)
+ if (pixels) {
pixels = MEM_dupallocN(pixels);
+ }
BKE_image_release_ibuf(image, ibuf, lock);
}
- if (!pixels)
+ if (!pixels) {
return NULL;
+ }
return pixels;
}
@@ -5142,20 +5313,26 @@ bool BKE_image_remove_renderslot(Image *ima, ImageUser *iuser, int index)
next_slot = current_slot;
}
- /* If the slot to be removed is the slot with the last render, make another slot the last render slot. */
+ /* If the slot to be removed is the slot with the last render,
+ * make another slot the last render slot. */
if (remove_slot == current_last_slot) {
- /* Choose the currently selected slot unless that one is being removed, in that case take the next one. */
+ /* Choose the currently selected slot unless that one is being removed,
+ * in that case take the next one. */
RenderSlot *next_last_slot;
- if (current_slot == remove_slot)
+ if (current_slot == remove_slot) {
next_last_slot = next_slot;
- else
+ }
+ else {
next_last_slot = current_slot;
+ }
- if (!iuser)
+ if (!iuser) {
return false;
+ }
Render *re = RE_GetSceneRender(iuser->scene);
- if (!re)
+ if (!re) {
return false;
+ }
RE_SwapResult(re, &current_last_slot->render);
RE_SwapResult(re, &next_last_slot->render);
current_last_slot = next_last_slot;
@@ -5179,20 +5356,24 @@ bool BKE_image_remove_renderslot(Image *ima, ImageUser *iuser, int index)
bool BKE_image_clear_renderslot(Image *ima, ImageUser *iuser, int index)
{
if (index == ima->last_render_slot) {
- if (!iuser)
+ if (!iuser) {
return false;
- if (G.is_rendering)
+ }
+ if (G.is_rendering) {
return false;
+ }
Render *re = RE_GetSceneRender(iuser->scene);
- if (!re)
+ if (!re) {
return false;
+ }
RE_ClearResult(re);
return true;
}
else {
RenderSlot *slot = BLI_findlink(&ima->renderslots, index);
- if (!slot)
+ if (!slot) {
return false;
+ }
if (slot->render) {
RE_FreeRenderResult(slot->render);
slot->render = NULL;
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index 9972e90dcdd..c7fdfb60a1c 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -123,8 +123,9 @@ static void image_buf_fill_checker_slice(
dark = powf(-1.0f, floorf(y / checkerwidth));
for (x = 0; x < width; x++) {
- if (x % checkerwidth == 0)
+ if (x % checkerwidth == 0) {
dark = -dark;
+ }
if (rect_float) {
if (dark > 0) {
@@ -182,10 +183,12 @@ static void image_buf_fill_checker_slice(
}
}
- if (rect_float)
+ if (rect_float) {
rect_float += 4;
- if (rect)
+ }
+ if (rect) {
rect += 4;
+ }
}
}
}
@@ -234,8 +237,9 @@ static void checker_board_color_fill(
hsv[1] = 1.0;
hue_step = power_of_2_max_i(width / 8);
- if (hue_step < 8)
+ if (hue_step < 8) {
hue_step = 8;
+ }
for (y = offset; y < height + offset; y++) {
@@ -345,10 +349,12 @@ static void checker_board_grid_fill(
}
}
else {
- if (rect_float)
+ if (rect_float) {
rect_float += 4;
- if (rect)
+ }
+ if (rect) {
rect += 4;
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/image_save.c b/source/blender/blenkernel/intern/image_save.c
new file mode 100644
index 00000000000..cc621e8468c
--- /dev/null
+++ b/source/blender/blenkernel/intern/image_save.c
@@ -0,0 +1,394 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation, 2019
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/image_save.c
+ * \ingroup bke
+ */
+
+#include <errno.h>
+#include <string.h>
+
+#include "BLI_listbase.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+
+#include "DNA_image_types.h"
+
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "BKE_colortools.h"
+#include "BKE_image.h"
+#include "BKE_image_save.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
+
+#include "RE_pipeline.h"
+
+void BKE_image_save_options_init(ImageSaveOptions *opts, Main *bmain, Scene *scene)
+{
+ memset(opts, 0, sizeof(*opts));
+
+ opts->bmain = bmain;
+ opts->scene = scene;
+
+ BKE_imformat_defaults(&opts->im_format);
+}
+
+static void image_save_post(ReportList *reports,
+ Main *bmain,
+ Image *ima,
+ ImBuf *ibuf,
+ int ok,
+ ImageSaveOptions *opts,
+ int save_copy,
+ const char *filepath)
+{
+ if (!ok) {
+ BKE_reportf(reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
+ return;
+ }
+
+ if (save_copy) {
+ return;
+ }
+
+ if (opts->do_newpath) {
+ BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name));
+ BLI_strncpy(ima->name, filepath, sizeof(ima->name));
+ }
+
+ ibuf->userflags &= ~IB_BITMAPDIRTY;
+
+ /* change type? */
+ if (ima->type == IMA_TYPE_R_RESULT) {
+ ima->type = IMA_TYPE_IMAGE;
+
+ /* workaround to ensure the render result buffer is no longer used
+ * by this image, otherwise can crash when a new render result is
+ * created. */
+ if (ibuf->rect && !(ibuf->mall & IB_rect)) {
+ imb_freerectImBuf(ibuf);
+ }
+ if (ibuf->rect_float && !(ibuf->mall & IB_rectfloat)) {
+ imb_freerectfloatImBuf(ibuf);
+ }
+ if (ibuf->zbuf && !(ibuf->mall & IB_zbuf)) {
+ IMB_freezbufImBuf(ibuf);
+ }
+ if (ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat)) {
+ IMB_freezbuffloatImBuf(ibuf);
+ }
+ }
+ if (ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
+ ima->source = IMA_SRC_FILE;
+ ima->type = IMA_TYPE_IMAGE;
+ }
+
+ /* only image path, never ibuf */
+ if (opts->relative) {
+ const char *relbase = ID_BLEND_PATH(opts->bmain, &ima->id);
+ BLI_path_rel(ima->name, relbase); /* only after saving */
+ }
+
+ ColorManagedColorspaceSettings old_colorspace_settings;
+ BKE_color_managed_colorspace_settings_copy(&old_colorspace_settings, &ima->colorspace_settings);
+ IMB_colormanagement_colorspace_from_ibuf_ftype(&ima->colorspace_settings, ibuf);
+ if (!BKE_color_managed_colorspace_settings_equals(&old_colorspace_settings,
+ &ima->colorspace_settings)) {
+ BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE);
+ }
+}
+
+static void imbuf_save_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf)
+{
+ if (colormanaged_ibuf != ibuf) {
+ /* This guys might be modified by image buffer write functions,
+ * need to copy them back from color managed image buffer to an
+ * original one, so file type of image is being properly updated.
+ */
+ ibuf->ftype = colormanaged_ibuf->ftype;
+ ibuf->foptions = colormanaged_ibuf->foptions;
+ ibuf->planes = colormanaged_ibuf->planes;
+
+ IMB_freeImBuf(colormanaged_ibuf);
+ }
+}
+
+/**
+ * \return success.
+ * \note ``ima->name`` and ``ibuf->name`` should end up the same.
+ * \note for multiview the first ``ibuf`` is important to get the settings.
+ */
+bool BKE_image_save(
+ ReportList *reports, Main *bmain, Image *ima, ImageUser *iuser, ImageSaveOptions *opts)
+{
+ void *lock;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
+ RenderResult *rr = NULL;
+ bool ok = false;
+
+ if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ goto cleanup;
+ }
+
+ ImBuf *colormanaged_ibuf = NULL;
+ const bool save_copy = opts->save_copy;
+ const bool save_as_render = opts->save_as_render;
+ ImageFormatData *imf = &opts->im_format;
+
+ if (ima->type == IMA_TYPE_R_RESULT) {
+ /* enforce user setting for RGB or RGBA, but skip BW */
+ if (opts->im_format.planes == R_IMF_PLANES_RGBA) {
+ ibuf->planes = R_IMF_PLANES_RGBA;
+ }
+ else if (opts->im_format.planes == R_IMF_PLANES_RGB) {
+ ibuf->planes = R_IMF_PLANES_RGB;
+ }
+ }
+ else {
+ /* TODO, better solution, if a 24bit image is painted onto it may contain alpha */
+ if ((opts->im_format.planes == R_IMF_PLANES_RGBA) &&
+ /* it has been painted onto */
+ (ibuf->userflags & IB_BITMAPDIRTY)) {
+ /* checks each pixel, not ideal */
+ ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? R_IMF_PLANES_RGBA : R_IMF_PLANES_RGB;
+ }
+ }
+
+ /* we need renderresult for exr and rendered multiview */
+ rr = BKE_image_acquire_renderresult(opts->scene, ima);
+ bool is_mono = rr ? BLI_listbase_count_at_most(&rr->views, 2) < 2 :
+ BLI_listbase_count_at_most(&ima->views, 2) < 2;
+ bool is_exr_rr = rr && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER) &&
+ RE_HasFloatPixels(rr);
+ bool is_multilayer = is_exr_rr && (imf->imtype == R_IMF_IMTYPE_MULTILAYER);
+ int layer = (iuser && !is_multilayer) ? iuser->layer : -1;
+
+ /* error handling */
+ if (!rr) {
+ if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) {
+ BKE_report(reports, RPT_ERROR, "Did not write, no Multilayer Image");
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ goto cleanup;
+ }
+ }
+ else {
+ if (imf->views_format == R_IMF_VIEWS_STEREO_3D) {
+ if (!BKE_image_is_stereo(ima)) {
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "Did not write, the image doesn't have a \"%s\" and \"%s\" views",
+ STEREO_LEFT_NAME,
+ STEREO_RIGHT_NAME);
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ goto cleanup;
+ }
+
+ /* it shouldn't ever happen*/
+ if ((BLI_findstring(&rr->views, STEREO_LEFT_NAME, offsetof(RenderView, name)) == NULL) ||
+ (BLI_findstring(&rr->views, STEREO_RIGHT_NAME, offsetof(RenderView, name)) == NULL)) {
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "Did not write, the image doesn't have a \"%s\" and \"%s\" views",
+ STEREO_LEFT_NAME,
+ STEREO_RIGHT_NAME);
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ goto cleanup;
+ }
+ }
+ BKE_imbuf_stamp_info(rr, ibuf);
+ }
+
+ /* fancy multiview OpenEXR */
+ if (imf->views_format == R_IMF_VIEWS_MULTIVIEW && is_exr_rr) {
+ /* save render result */
+ ok = RE_WriteRenderResult(reports, rr, opts->filepath, imf, NULL, layer);
+ image_save_post(reports, bmain, ima, ibuf, ok, opts, true, opts->filepath);
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ }
+ /* regular mono pipeline */
+ else if (is_mono) {
+ if (is_exr_rr) {
+ ok = RE_WriteRenderResult(reports, rr, opts->filepath, imf, NULL, layer);
+ }
+ else {
+ colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(
+ ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
+ ok = BKE_imbuf_write_as(colormanaged_ibuf, opts->filepath, imf, save_copy);
+ imbuf_save_post(ibuf, colormanaged_ibuf);
+ }
+ image_save_post(
+ reports, bmain, ima, ibuf, ok, opts, (is_exr_rr ? true : save_copy), opts->filepath);
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ }
+ /* individual multiview images */
+ else if (imf->views_format == R_IMF_VIEWS_INDIVIDUAL) {
+ int i;
+ unsigned char planes = ibuf->planes;
+ const int totviews = (rr ? BLI_listbase_count(&rr->views) : BLI_listbase_count(&ima->views));
+
+ if (!is_exr_rr) {
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ }
+
+ for (i = 0; i < totviews; i++) {
+ char filepath[FILE_MAX];
+ bool ok_view = false;
+ const char *view = rr ? ((RenderView *)BLI_findlink(&rr->views, i))->name :
+ ((ImageView *)BLI_findlink(&ima->views, i))->name;
+
+ if (is_exr_rr) {
+ BKE_scene_multiview_view_filepath_get(&opts->scene->r, opts->filepath, view, filepath);
+ ok_view = RE_WriteRenderResult(reports, rr, filepath, imf, view, layer);
+ image_save_post(reports, bmain, ima, ibuf, ok_view, opts, true, filepath);
+ }
+ else {
+ /* copy iuser to get the correct ibuf for this view */
+ ImageUser view_iuser;
+
+ if (iuser) {
+ /* copy iuser to get the correct ibuf for this view */
+ view_iuser = *iuser;
+ }
+ else {
+ BKE_imageuser_default(&view_iuser);
+ }
+
+ view_iuser.view = i;
+ view_iuser.flag &= ~IMA_SHOW_STEREO;
+
+ if (rr) {
+ BKE_image_multilayer_index(rr, &view_iuser);
+ }
+ else {
+ BKE_image_multiview_index(ima, &view_iuser);
+ }
+
+ ibuf = BKE_image_acquire_ibuf(ima, &view_iuser, &lock);
+ ibuf->planes = planes;
+
+ BKE_scene_multiview_view_filepath_get(&opts->scene->r, opts->filepath, view, filepath);
+
+ colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(
+ ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
+ ok_view = BKE_imbuf_write_as(colormanaged_ibuf, filepath, &opts->im_format, save_copy);
+ imbuf_save_post(ibuf, colormanaged_ibuf);
+ image_save_post(reports, bmain, ima, ibuf, ok_view, opts, true, filepath);
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ }
+ ok &= ok_view;
+ }
+
+ if (is_exr_rr) {
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ }
+ }
+ /* stereo (multiview) images */
+ else if (opts->im_format.views_format == R_IMF_VIEWS_STEREO_3D) {
+ if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) {
+ ok = RE_WriteRenderResult(reports, rr, opts->filepath, imf, NULL, layer);
+ image_save_post(reports, bmain, ima, ibuf, ok, opts, true, opts->filepath);
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ }
+ else {
+ ImBuf *ibuf_stereo[2] = {NULL};
+
+ unsigned char planes = ibuf->planes;
+ const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
+ int i;
+
+ /* we need to get the specific per-view buffers */
+ BKE_image_release_ibuf(ima, ibuf, lock);
+
+ for (i = 0; i < 2; i++) {
+ ImageUser view_iuser;
+
+ if (iuser) {
+ view_iuser = *iuser;
+ }
+ else {
+ BKE_imageuser_default(&view_iuser);
+ }
+
+ view_iuser.flag &= ~IMA_SHOW_STEREO;
+
+ if (rr) {
+ int id = BLI_findstringindex(&rr->views, names[i], offsetof(RenderView, name));
+ view_iuser.view = id;
+ BKE_image_multilayer_index(rr, &view_iuser);
+ }
+ else {
+ view_iuser.view = i;
+ BKE_image_multiview_index(ima, &view_iuser);
+ }
+
+ ibuf = BKE_image_acquire_ibuf(ima, &view_iuser, &lock);
+
+ if (ibuf == NULL) {
+ BKE_report(
+ reports, RPT_ERROR, "Did not write, unexpected error when saving stereo image");
+ goto cleanup;
+ }
+
+ ibuf->planes = planes;
+
+ /* color manage the ImBuf leaving it ready for saving */
+ colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(
+ ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
+
+ BKE_imbuf_write_prepare(colormanaged_ibuf, imf);
+ IMB_prepare_write_ImBuf(IMB_isfloat(colormanaged_ibuf), colormanaged_ibuf);
+
+ /* duplicate buffer to prevent locker issue when using render result */
+ ibuf_stereo[i] = IMB_dupImBuf(colormanaged_ibuf);
+
+ imbuf_save_post(ibuf, colormanaged_ibuf);
+ BKE_image_release_ibuf(ima, ibuf, lock);
+ }
+
+ ibuf = IMB_stereo3d_ImBuf(imf, ibuf_stereo[0], ibuf_stereo[1]);
+
+ /* save via traditional path */
+ ok = BKE_imbuf_write_as(ibuf, opts->filepath, imf, save_copy);
+
+ IMB_freeImBuf(ibuf);
+
+ for (i = 0; i < 2; i++) {
+ IMB_freeImBuf(ibuf_stereo[i]);
+ }
+ }
+ }
+
+cleanup:
+ if (rr) {
+ BKE_image_release_renderresult(opts->scene, ima);
+ }
+
+ return ok;
+}
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 8f3b1fed692..63ef1458de8 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -92,18 +92,22 @@ void BKE_ipo_free(Ipo *ipo)
icn = icu->next;
n++;
- if (icu->bezt)
+ if (icu->bezt) {
MEM_freeN(icu->bezt);
- if (icu->bp)
+ }
+ if (icu->bp) {
MEM_freeN(icu->bp);
- if (icu->driver)
+ }
+ if (icu->driver) {
MEM_freeN(icu->driver);
+ }
BLI_freelinkN(&ipo->curve, icu);
}
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s'\n", n, ipo->id.name + 2);
+ }
}
/* *************************************************** */
@@ -235,22 +239,28 @@ static const char *ob_adrcodes_to_paths(int adrcode, int *array_index)
return "color";
#if 0
case OB_PD_FSTR:
- if (ob->pd) poin = &(ob->pd->f_strength);
+ if (ob->pd)
+ poin = &(ob->pd->f_strength);
break;
case OB_PD_FFALL:
- if (ob->pd) poin = &(ob->pd->f_power);
+ if (ob->pd)
+ poin = &(ob->pd->f_power);
break;
case OB_PD_SDAMP:
- if (ob->pd) poin = &(ob->pd->pdef_damp);
+ if (ob->pd)
+ poin = &(ob->pd->pdef_damp);
break;
case OB_PD_RDAMP:
- if (ob->pd) poin = &(ob->pd->pdef_rdamp);
+ if (ob->pd)
+ poin = &(ob->pd->pdef_rdamp);
break;
case OB_PD_PERM:
- if (ob->pd) poin = &(ob->pd->pdef_perm);
+ if (ob->pd)
+ poin = &(ob->pd->pdef_perm);
break;
case OB_PD_FMAXD:
- if (ob->pd) poin = &(ob->pd->maxdist);
+ if (ob->pd)
+ poin = &(ob->pd->maxdist);
break;
#endif
}
@@ -327,7 +337,8 @@ static const char *constraint_adrcodes_to_paths(int adrcode, int *array_index)
switch (adrcode) {
case CO_ENFORCE:
return "influence";
- case CO_HEADTAIL: // XXX this needs to be wrapped in RNA.. probably then this path will be invalid
+ case CO_HEADTAIL:
+ /* XXX this needs to be wrapped in RNA.. probably then this path will be invalid. */
return "data.head_tail";
}
@@ -372,73 +383,104 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
static char buf[128];
/* base part of path */
- if (adrcode & MA_MAP1)
+ if (adrcode & MA_MAP1) {
base = "textures[0]";
- else if (adrcode & MA_MAP2)
+ }
+ else if (adrcode & MA_MAP2) {
base = "textures[1]";
- else if (adrcode & MA_MAP3)
+ }
+ else if (adrcode & MA_MAP3) {
base = "textures[2]";
- else if (adrcode & MA_MAP4)
+ }
+ else if (adrcode & MA_MAP4) {
base = "textures[3]";
- else if (adrcode & MA_MAP5)
+ }
+ else if (adrcode & MA_MAP5) {
base = "textures[4]";
- else if (adrcode & MA_MAP6)
+ }
+ else if (adrcode & MA_MAP6) {
base = "textures[5]";
- else if (adrcode & MA_MAP7)
+ }
+ else if (adrcode & MA_MAP7) {
base = "textures[6]";
- else if (adrcode & MA_MAP8)
+ }
+ else if (adrcode & MA_MAP8) {
base = "textures[7]";
- else if (adrcode & MA_MAP9)
+ }
+ else if (adrcode & MA_MAP9) {
base = "textures[8]";
- else if (adrcode & MA_MAP10)
+ }
+ else if (adrcode & MA_MAP10) {
base = "textures[9]";
- else if (adrcode & MA_MAP11)
+ }
+ else if (adrcode & MA_MAP11) {
base = "textures[10]";
- else if (adrcode & MA_MAP12)
+ }
+ else if (adrcode & MA_MAP12) {
base = "textures[11]";
- else if (adrcode & MA_MAP13)
+ }
+ else if (adrcode & MA_MAP13) {
base = "textures[12]";
- else if (adrcode & MA_MAP14)
+ }
+ else if (adrcode & MA_MAP14) {
base = "textures[13]";
- else if (adrcode & MA_MAP15)
+ }
+ else if (adrcode & MA_MAP15) {
base = "textures[14]";
- else if (adrcode & MA_MAP16)
+ }
+ else if (adrcode & MA_MAP16) {
base = "textures[15]";
- else if (adrcode & MA_MAP17)
+ }
+ else if (adrcode & MA_MAP17) {
base = "textures[16]";
- else if (adrcode & MA_MAP18)
+ }
+ else if (adrcode & MA_MAP18) {
base = "textures[17]";
+ }
/* property identifier for path */
adrcode = (adrcode & (MA_MAP1 - 1));
switch (adrcode) {
#if 0 // XXX these are not wrapped in RNA yet!
case MAP_OFS_X:
- poin = &(mtex->ofs[0]); break;
+ poin = &(mtex->ofs[0]);
+ break;
case MAP_OFS_Y:
- poin = &(mtex->ofs[1]); break;
+ poin = &(mtex->ofs[1]);
+ break;
case MAP_OFS_Z:
- poin = &(mtex->ofs[2]); break;
+ poin = &(mtex->ofs[2]);
+ break;
case MAP_SIZE_X:
- poin = &(mtex->size[0]); break;
+ poin = &(mtex->size[0]);
+ break;
case MAP_SIZE_Y:
- poin = &(mtex->size[1]); break;
+ poin = &(mtex->size[1]);
+ break;
case MAP_SIZE_Z:
- poin = &(mtex->size[2]); break;
+ poin = &(mtex->size[2]);
+ break;
case MAP_R:
- poin = &(mtex->r); break;
+ poin = &(mtex->r);
+ break;
case MAP_G:
- poin = &(mtex->g); break;
+ poin = &(mtex->g);
+ break;
case MAP_B:
- poin = &(mtex->b); break;
+ poin = &(mtex->b);
+ break;
case MAP_DVAR:
- poin = &(mtex->def_var); break;
+ poin = &(mtex->def_var);
+ break;
case MAP_COLF:
- poin = &(mtex->colfac); break;
+ poin = &(mtex->colfac);
+ break;
case MAP_NORF:
- poin = &(mtex->norfac); break;
+ poin = &(mtex->norfac);
+ break;
case MAP_VARF:
- poin = &(mtex->varfac); break;
+ poin = &(mtex->varfac);
+ break;
#endif
case MAP_DISP:
prop = "warp_factor";
@@ -450,8 +492,9 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index))
BLI_snprintf(buf, 128, "%s.%s", base, prop);
return buf;
}
- else
+ else {
return NULL;
+ }
}
/* Texture types */
@@ -468,10 +511,10 @@ static const char *texture_adrcodes_to_paths(int adrcode, int *array_index)
return "turbulence";
case TE_NDEPTH: // XXX texture RNA undefined
- //poin= &(tex->noisedepth); *type= IPO_SHORT; break;
+ // poin= &(tex->noisedepth); *type= IPO_SHORT; break;
break;
case TE_NTYPE: // XXX texture RNA undefined
- //poin= &(tex->noisetype); *type= IPO_SHORT; break;
+ // poin= &(tex->noisetype); *type= IPO_SHORT; break;
break;
case TE_N_BAS1:
@@ -643,12 +686,13 @@ static const char *camera_adrcodes_to_paths(int adrcode, int *array_index)
/* result depends on adrcode */
switch (adrcode) {
case CAM_LENS:
-#if 0 // XXX this cannot be resolved easily... perhaps we assume camera is perspective (works for most cases...
+#if 0 /* XXX this cannot be resolved easily... \
+ * perhaps we assume camera is perspective (works for most cases... */
if (ca->type == CAM_ORTHO)
return "ortho_scale";
else
return "lens";
-#else // XXX lazy hack for now...
+#else // XXX lazy hack for now...
return "lens";
#endif // XXX this cannot be resolved easily
@@ -659,9 +703,11 @@ static const char *camera_adrcodes_to_paths(int adrcode, int *array_index)
#if 0 // XXX these are not defined in RNA
case CAM_YF_APERT:
- poin = &(ca->YF_aperture); break;
+ poin = &(ca->YF_aperture);
+ break;
case CAM_YF_FDIST:
- poin = &(ca->dof_distance); break;
+ poin = &(ca->dof_distance);
+ break;
#endif // XXX these are not defined in RNA
case CAM_SHIFT_X:
@@ -731,7 +777,8 @@ static const char *sound_adrcodes_to_paths(int adrcode, int *array_index)
return "volume";
case SND_PITCH:
return "pitch";
- /* XXX Joshua -- I had wrapped panning in rna, but someone commented out, calling it "unused" */
+ /* XXX Joshua -- I had wrapped panning in rna,
+ * but someone commented out, calling it "unused" */
#if 0
case SND_PANNING:
return "panning";
@@ -831,28 +878,34 @@ static const char *particle_adrcodes_to_paths(int adrcode, int *array_index)
return "settings.billboard_tilt";
/* PartDeflect needs to be sorted out properly in rna_object_force;
- * If anyone else works on this, but is unfamiliar, these particular
- * settings reference the particles of the system themselves
- * being used as forces -- it will use the same rna structure
- * as the similar object forces */
+ * If anyone else works on this, but is unfamiliar, these particular
+ * settings reference the particles of the system themselves
+ * being used as forces -- it will use the same rna structure
+ * as the similar object forces */
#if 0
case PART_PD_FSTR:
- if (part->pd) poin = &(part->pd->f_strength);
+ if (part->pd)
+ poin = &(part->pd->f_strength);
break;
case PART_PD_FFALL:
- if (part->pd) poin = &(part->pd->f_power);
+ if (part->pd)
+ poin = &(part->pd->f_power);
break;
case PART_PD_FMAXD:
- if (part->pd) poin = &(part->pd->maxdist);
+ if (part->pd)
+ poin = &(part->pd->maxdist);
break;
case PART_PD2_FSTR:
- if (part->pd2) poin = &(part->pd2->f_strength);
+ if (part->pd2)
+ poin = &(part->pd2->f_strength);
break;
case PART_PD2_FFALL:
- if (part->pd2) poin = &(part->pd2->f_power);
+ if (part->pd2)
+ poin = &(part->pd2->f_power);
break;
case PART_PD2_FMAXD:
- if (part->pd2) poin = &(part->pd2->maxdist);
+ if (part->pd2)
+ poin = &(part->pd2->maxdist);
break;
#endif
}
@@ -862,14 +915,17 @@ static const char *particle_adrcodes_to_paths(int adrcode, int *array_index)
/* ------- */
-/* Allocate memory for RNA-path for some property given a blocktype, adrcode, and 'root' parts of path
+/* Allocate memory for RNA-path for some property given a blocktype, adrcode,
+ * and 'root' parts of path.
+ *
* Input:
- * - id - the datablock that the curve's IPO block is attached to and/or which the new paths will start from
- * - blocktype, adrcode - determines setting to get
- * - actname, constname,seq - used to build path
+ * - id - the datablock that the curve's IPO block
+ * is attached to and/or which the new paths will start from
+ * - blocktype, adrcode - determines setting to get
+ * - actname, constname, seq - used to build path
* Output:
- * - array_index - index in property's array (if applicable) to use
- * - return - the allocated path...
+ * - array_index - index in property's array (if applicable) to use
+ * - return - the allocated path...
*/
static char *get_rna_access(ID *id,
int blocktype,
@@ -886,8 +942,9 @@ static char *get_rna_access(ID *id,
int dummy_index = 0;
/* hack: if constname is set, we can only be dealing with an Constraint curve */
- if (constname)
+ if (constname) {
blocktype = ID_CO;
+ }
/* get property name based on blocktype */
switch (blocktype) {
@@ -944,7 +1001,7 @@ static char *get_rna_access(ID *id,
/* XXX problematic blocktypes */
case ID_SEQ: /* sequencer strip */
- //SEQ_FAC1:
+ // SEQ_FAC1:
switch (adrcode) {
case SEQ_FAC1:
propname = "effect_fader";
@@ -971,20 +1028,23 @@ static char *get_rna_access(ID *id,
}
/* check if any property found
- * - blocktype < 0 is special case for a specific type of driver, where we don't need a property name...
+ * - blocktype < 0 is special case for a specific type of driver,
+ * where we don't need a property name...
*/
if ((propname == NULL) && (blocktype > 0)) {
/* nothing was found, so exit */
- if (array_index)
+ if (array_index) {
*array_index = 0;
+ }
BLI_dynstr_free(path);
return NULL;
}
else {
- if (array_index)
+ if (array_index) {
*array_index = dummy_index;
+ }
}
/* 'buf' _must_ be initialized in this block */
@@ -1000,7 +1060,8 @@ static char *get_rna_access(ID *id,
buf[0] = '\0'; /* empty string */
}
else if ((blocktype == ID_KE) && STREQ(actname, "Shape")) {
- /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */
+ /* Actionified "Shape" IPO's -
+ * these are forced onto object level via the action container there... */
strcpy(buf, "data.shape_keys");
}
else {
@@ -1023,8 +1084,9 @@ static char *get_rna_access(ID *id,
BLI_dynstr_append(path, buf);
/* need to add dot before property if there was anything precceding this */
- if (buf[0])
+ if (buf[0]) {
BLI_dynstr_append(path, ".");
+ }
/* now write name of property */
BLI_dynstr_append(path, propname);
@@ -1089,8 +1151,9 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
/* PyDriver only requires the expression to be copied */
// FIXME: expression will be useless due to API changes, but at least not totally lost
cdriver->type = DRIVER_TYPE_PYTHON;
- if (idriver->name[0])
+ if (idriver->name[0]) {
BLI_strncpy(cdriver->expression, idriver->name, sizeof(cdriver->expression));
+ }
}
else {
DriverVar *dvar = NULL;
@@ -1110,16 +1173,18 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
dtar = &dvar->targets[0];
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
- if (idriver->name[0])
+ if (idriver->name[0]) {
BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
+ }
/* second bone target (name was stored in same var as the first one) */
dtar = &dvar->targets[1];
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
- if (idriver->name[0]) // xxx... for safety
+ if (idriver->name[0]) { // xxx... for safety
BLI_strncpy(
dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS, sizeof(dtar->pchan_name));
+ }
}
else {
/* only a single variable, of type 'transform channel' */
@@ -1130,8 +1195,9 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver)
dtar = &dvar->targets[0];
dtar->id = (ID *)idriver->ob;
dtar->idtype = ID_OB;
- if (idriver->name[0])
+ if (idriver->name[0]) {
BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name));
+ }
dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode);
dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */
}
@@ -1183,8 +1249,9 @@ static void fcurve_add_to_list(
agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup");
agrp->flag = AGRP_SELECTED;
- if (muteipo)
+ if (muteipo) {
agrp->flag |= AGRP_MUTED;
+ }
BLI_strncpy(agrp->name, grpname, sizeof(agrp->name));
@@ -1198,11 +1265,13 @@ static void fcurve_add_to_list(
}
/* add F-Curve to group */
- /* WARNING: this func should only need to look at the stuff we initialized, if not, things may crash */
+ /* WARNING: this func should only need to look at the stuff we initialized,
+ * if not, things may crash. */
action_groups_add_channel(&tmp_act, agrp, fcu);
- if (agrp->flag & AGRP_MUTED) /* flush down */
+ if (agrp->flag & AGRP_MUTED) { /* flush down */
fcu->flag |= FCURVE_MUTED;
+ }
/* set the output lists based on the ones in the temp action */
groups->first = tmp_act.groups.first;
@@ -1216,11 +1285,14 @@ static void fcurve_add_to_list(
}
}
-/* Convert IPO-Curve to F-Curve (including Driver data), and free any of the old data that
+/**
+ * Convert IPO-Curve to F-Curve (including Driver data), and free any of the old data that
* is not relevant, BUT do not free the IPO-Curve itself...
- * actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to
- * constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to
- * seq: sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to
+ *
+ * \param actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to.
+ * \param constname: name of Constraint-Channel (if applicable)
+ * that IPO-Curve's IPO-block belonged to \a seq.
+ * \param seq: sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to.
*/
static void icu_to_fcurves(ID *id,
ListBase *groups,
@@ -1239,20 +1311,26 @@ static void icu_to_fcurves(ID *id,
fcu = MEM_callocN(sizeof(FCurve), "FCurve");
/* convert driver */
- if (icu->driver)
+ if (icu->driver) {
fcu->driver = idriver_to_cdriver(icu->driver);
+ }
/* copy flags */
- if (icu->flag & IPO_VISIBLE)
+ if (icu->flag & IPO_VISIBLE) {
fcu->flag |= FCURVE_VISIBLE;
- if (icu->flag & IPO_SELECT)
+ }
+ if (icu->flag & IPO_SELECT) {
fcu->flag |= FCURVE_SELECTED;
- if (icu->flag & IPO_ACTIVE)
+ }
+ if (icu->flag & IPO_ACTIVE) {
fcu->flag |= FCURVE_ACTIVE;
- if (icu->flag & IPO_MUTE)
+ }
+ if (icu->flag & IPO_MUTE) {
fcu->flag |= FCURVE_MUTED;
- if (icu->flag & IPO_PROTECT)
+ }
+ if (icu->flag & IPO_PROTECT) {
fcu->flag |= FCURVE_PROTECTED;
+ }
/* set extrapolation */
switch (icu->extrap) {
@@ -1273,10 +1351,12 @@ static void icu_to_fcurves(ID *id,
FMod_Cycles *data = (FMod_Cycles *)fcm->data;
/* if 'offset' one is in use, set appropriate settings */
- if (icu->extrap == IPO_CYCLX)
+ if (icu->extrap == IPO_CYCLX) {
data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC_OFFSET;
- else
+ }
+ else {
data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC;
+ }
break;
}
}
@@ -1289,8 +1369,9 @@ static void icu_to_fcurves(ID *id,
FCurve *fcurve;
int b;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconvert bitflag ipocurve, totbits = %d\n", totbits);
+ }
/* add the 'only int values' flag */
fcu->flag |= (FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES);
@@ -1305,18 +1386,22 @@ static void icu_to_fcurves(ID *id,
unsigned int i = 0;
/* make a copy of existing base-data if not the last curve */
- if (b < (totbits - 1))
+ if (b < (totbits - 1)) {
fcurve = copy_fcurve(fcu);
- else
+ }
+ else {
fcurve = fcu;
+ }
/* set path */
fcurve->rna_path = BLI_strdup(abp->path);
fcurve->array_index = abp->array_index;
- /* convert keyframes
- * - beztriples and bpoints are mutually exclusive, so we won't have both at the same time
- * - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet)
+ /* Convert keyframes:
+ * - Beztriples and bpoints are mutually exclusive,
+ * so we won't have both at the same time.
+ * - Beztriples are more likely to be encountered as they are keyframes
+ * (the other type wasn't used yet).
*/
fcurve->totvert = icu->totvert;
@@ -1339,23 +1424,28 @@ static void icu_to_fcurves(ID *id,
/* auto-handles - per curve to per handle */
if (icu->flag & IPO_AUTO_HORIZ) {
- if (dst->h1 == HD_AUTO)
+ if (dst->h1 == HD_AUTO) {
dst->h1 = HD_AUTO_ANIM;
- if (dst->h2 == HD_AUTO)
+ }
+ if (dst->h2 == HD_AUTO) {
dst->h2 = HD_AUTO_ANIM;
+ }
}
/* correct values, by checking if the flag of interest is set */
- if (((int)(dst->vec[1][1])) & (abp->bit))
+ if (((int)(dst->vec[1][1])) & (abp->bit)) {
dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 1.0f;
- else
+ }
+ else {
dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 0.0f;
+ }
}
}
else if (icu->bp) {
- /* TODO: need to convert from BPoint type to the more compact FPoint type... but not priority, since no data used this */
- //BPoint *bp;
- //FPoint *fpt;
+ /* TODO: need to convert from BPoint type to the more compact FPoint type...
+ * but not priority, since no data used this. */
+ // BPoint *bp;
+ // FPoint *fpt;
}
/* add new F-Curve to list */
@@ -1370,12 +1460,14 @@ static void icu_to_fcurves(ID *id,
*/
fcu->rna_path = get_rna_access(
id, icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index);
- if (fcu->rna_path == NULL)
+ if (fcu->rna_path == NULL) {
fcu->flag |= FCURVE_DISABLED;
+ }
- /* convert keyframes
- * - beztriples and bpoints are mutually exclusive, so we won't have both at the same time
- * - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet)
+ /* Convert keyframes:
+ * - Beztriples and bpoints are mutually exclusive, so we won't have both at the same time.
+ * - Beztriples are more likely to be encountered as they are keyframes
+ * (the other type wasn't used yet).
*/
fcu->totvert = icu->totvert;
@@ -1391,18 +1483,21 @@ static void icu_to_fcurves(ID *id,
*dst = *src;
/* now copy interpolation from curve (if not already set) */
- if (icu->ipo != IPO_MIXED)
+ if (icu->ipo != IPO_MIXED) {
dst->ipo = icu->ipo;
+ }
/* 'hide' flag is now used for keytype - only 'keyframes' existed before */
dst->hide = BEZT_KEYTYPE_KEYFRAME;
/* auto-handles - per curve to per handle */
if (icu->flag & IPO_AUTO_HORIZ) {
- if (dst->h1 == HD_AUTO)
+ if (dst->h1 == HD_AUTO) {
dst->h1 = HD_AUTO_ANIM;
- if (dst->h2 == HD_AUTO)
+ }
+ if (dst->h2 == HD_AUTO) {
dst->h2 = HD_AUTO_ANIM;
+ }
}
/* correct values for euler rotation curves
@@ -1411,7 +1506,7 @@ static void icu_to_fcurves(ID *id,
*/
if (((icu->blocktype == ID_OB) && ELEM(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) ||
((icu->blocktype == ID_PO) && ELEM(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z))) {
- const float fac = (float)M_PI / 18.0f; //10.0f * M_PI/180.0f;
+ const float fac = (float)M_PI / 18.0f; // 10.0f * M_PI/180.0f;
dst->vec[0][1] *= fac;
dst->vec[1][1] *= fac;
@@ -1469,9 +1564,10 @@ static void icu_to_fcurves(ID *id,
}
}
else if (icu->bp) {
- /* TODO: need to convert from BPoint type to the more compact FPoint type... but not priority, since no data used this */
- //BPoint *bp;
- //FPoint *fpt;
+ /* TODO: need to convert from BPoint type to the more compact FPoint type...
+ * but not priority, since no data used this */
+ // BPoint *bp;
+ // FPoint *fpt;
}
/* add new F-Curve to list */
@@ -1497,11 +1593,13 @@ static void ipo_to_animato(ID *id,
IpoCurve *icu;
/* sanity check */
- if (ELEM(NULL, ipo, anim, drivers))
+ if (ELEM(NULL, ipo, anim, drivers)) {
return;
+ }
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("ipo_to_animato\n");
+ }
/* validate actname and constname
* - clear actname if it was one of the generic <builtin> ones (i.e. 'Object', or 'Shapes')
@@ -1510,19 +1608,22 @@ static void ipo_to_animato(ID *id,
* F-Curves for bones). This may be added later... for now let's just dump without them...
*/
if (actname) {
- if ((ipo->blocktype == ID_OB) && STREQ(actname, "Object"))
+ if ((ipo->blocktype == ID_OB) && STREQ(actname, "Object")) {
actname = NULL;
- else if ((ipo->blocktype == ID_OB) && STREQ(actname, "Shape"))
+ }
+ else if ((ipo->blocktype == ID_OB) && STREQ(actname, "Shape")) {
actname = NULL;
+ }
}
/* loop over IPO-Curves, freeing as we progress */
for (icu = ipo->curve.first; icu; icu = icu->next) {
/* Since an IPO-Curve may end up being made into many F-Curves (i.e. bitflag curves),
- * we figure out the best place to put the channel, then tell the curve-converter to just dump there
- */
+ * we figure out the best place to put the channel,
+ * then tell the curve-converter to just dump there. */
if (icu->driver) {
- /* Blender 2.4x allowed empty drivers, but we don't now, since they cause more trouble than they're worth */
+ /* Blender 2.4x allowed empty drivers,
+ * but we don't now, since they cause more trouble than they're worth. */
if ((icu->driver->ob) || (icu->driver->type == IPO_DRIVER_TYPE_PYTHON)) {
icu_to_fcurves(id, NULL, drivers, icu, actname, constname, seq, ipo->muteipo);
}
@@ -1531,8 +1632,9 @@ static void ipo_to_animato(ID *id,
icu->driver = NULL;
}
}
- else
+ else {
icu_to_fcurves(id, animgroups, anim, icu, actname, constname, seq, ipo->muteipo);
+ }
}
/* if this IPO block doesn't have any users after this one, free... */
@@ -1544,14 +1646,17 @@ static void ipo_to_animato(ID *id,
icn = icu->next;
/* free driver */
- if (icu->driver)
+ if (icu->driver) {
MEM_freeN(icu->driver);
+ }
/* free old data of curve now that it's no longer needed for converting any more curves */
- if (icu->bezt)
+ if (icu->bezt) {
MEM_freeN(icu->bezt);
- if (icu->bp)
+ }
+ if (icu->bp) {
MEM_freeN(icu->bezt);
+ }
/* free this IPO-Curve */
BLI_freelinkN(&ipo->curve, icu);
@@ -1571,13 +1676,15 @@ static void action_to_animato(
bConstraintChannel *conchan, *conchann;
/* only continue if there are Action Channels (indicating unconverted data) */
- if (BLI_listbase_is_empty(&act->chanbase))
+ if (BLI_listbase_is_empty(&act->chanbase)) {
return;
+ }
/* get rid of all Action Groups */
// XXX this is risky if there's some old + some new data in the Action...
- if (act->groups.first)
+ if (act->groups.first) {
BLI_freelistN(&act->groups);
+ }
/* loop through Action-Channels, converting data, freeing as we go */
for (achan = act->chanbase.first; achan; achan = achann) {
@@ -1627,8 +1734,9 @@ static void ipo_to_animdata(
ListBase drivers = {NULL, NULL};
/* sanity check */
- if (ELEM(NULL, id, ipo))
+ if (ELEM(NULL, id, ipo)) {
return;
+ }
if (adt == NULL) {
CLOG_ERROR(&LOG, "adt invalid");
return;
@@ -1644,16 +1752,17 @@ static void ipo_to_animdata(
BLI_listbase_count(&ipo->curve));
}
- /* Convert curves to animato system (separated into separate lists of F-Curves for animation and drivers),
- * and the try to put these lists in the right places, but do not free the lists here
- */
+ /* Convert curves to animato system
+ * (separated into separate lists of F-Curves for animation and drivers),
+ * and the try to put these lists in the right places, but do not free the lists here. */
// XXX there shouldn't be any need for the groups, so don't supply pointer for that now...
ipo_to_animato(id, ipo, actname, constname, seq, NULL, &anim, &drivers);
/* deal with animation first */
if (anim.first) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\thas anim\n");
+ }
/* try to get action */
if (adt->action == NULL) {
char nameBuf[MAX_ID_NAME];
@@ -1661,8 +1770,9 @@ static void ipo_to_animdata(
BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2);
adt->action = BKE_action_add(bmain, nameBuf);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\t\tadded new action - '%s'\n", nameBuf);
+ }
}
/* add F-Curves to action */
@@ -1671,8 +1781,9 @@ static void ipo_to_animdata(
/* deal with drivers */
if (drivers.first) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\thas drivers\n");
+ }
/* add drivers to end of driver stack */
BLI_movelisttolist(&adt->drivers, &drivers);
}
@@ -1686,14 +1797,16 @@ static void action_to_animdata(ID *id, bAction *act)
AnimData *adt = BKE_animdata_from_id(id);
/* only continue if there are Action Channels (indicating unconverted data) */
- if (ELEM(NULL, adt, act->chanbase.first))
+ if (ELEM(NULL, adt, act->chanbase.first)) {
return;
+ }
/* check if we need to set this Action as the AnimData's action */
if (adt->action == NULL) {
/* set this Action as AnimData's Action */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("act_to_adt - set adt action to act\n");
+ }
adt->action = act;
}
@@ -1724,7 +1837,8 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
/* convert Action data (if not yet converted), storing the results in the same Action */
action_to_animato(id, as->act, &as->act->groups, &as->act->curves, &adt->drivers);
- /* create a new-style NLA-strip which references this Action, then copy over relevant settings */
+ /* Create a new-style NLA-strip which references this Action,
+ * then copy over relevant settings. */
{
/* init a new strip, and assign the action to it
* - no need to muck around with the user-counts, since this is just
@@ -1742,31 +1856,38 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
/* action reuse */
strip->repeat = as->repeat;
strip->scale = as->scale;
- if (as->flag & ACTSTRIP_LOCK_ACTION)
+ if (as->flag & ACTSTRIP_LOCK_ACTION) {
strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH;
+ }
/* blending */
strip->blendin = as->blendin;
strip->blendout = as->blendout;
strip->blendmode = (as->mode == ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD :
NLASTRIP_MODE_REPLACE;
- if (as->flag & ACTSTRIP_AUTO_BLENDS)
+ if (as->flag & ACTSTRIP_AUTO_BLENDS) {
strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS;
+ }
/* assorted setting flags */
- if (as->flag & ACTSTRIP_SELECT)
+ if (as->flag & ACTSTRIP_SELECT) {
strip->flag |= NLASTRIP_FLAG_SELECT;
- if (as->flag & ACTSTRIP_ACTIVE)
+ }
+ if (as->flag & ACTSTRIP_ACTIVE) {
strip->flag |= NLASTRIP_FLAG_ACTIVE;
+ }
- if (as->flag & ACTSTRIP_MUTE)
+ if (as->flag & ACTSTRIP_MUTE) {
strip->flag |= NLASTRIP_FLAG_MUTED;
- if (as->flag & ACTSTRIP_REVERSE)
+ }
+ if (as->flag & ACTSTRIP_REVERSE) {
strip->flag |= NLASTRIP_FLAG_REVERSE;
+ }
/* by default, we now always extrapolate, while in the past this was optional */
- if ((as->flag & ACTSTRIP_HOLDLASTFRAME) == 0)
+ if ((as->flag & ACTSTRIP_HOLDLASTFRAME) == 0) {
strip->extendmode = NLASTRIP_EXTEND_NOTHING;
+ }
}
/* try to add this strip to the current NLA-Track (i.e. the 'last' one on the stack atm) */
@@ -1784,8 +1905,9 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
/* modifiers */
// FIXME: for now, we just free them...
- if (as->modifiers.first)
+ if (as->modifiers.first) {
BLI_freelistN(&as->modifiers);
+ }
/* free the old strip */
BLI_freelinkN(strips, as);
@@ -1821,8 +1943,9 @@ void do_versions_ipos_to_animato(Main *bmain)
CLOG_WARN(&LOG, "Animation data too new to convert (Version %d)", bmain->versionfile);
return;
}
- else if (G.debug & G_DEBUG)
+ else if (G.debug & G_DEBUG) {
printf("INFO: Converting to Animato...\n");
+ }
/* ----------- Animation Attached to Data -------------- */
@@ -1833,8 +1956,9 @@ void do_versions_ipos_to_animato(Main *bmain)
bConstraint *con;
bConstraintChannel *conchan, *conchann;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting ob %s\n", id->name + 2);
+ }
/* check if object has any animation data */
if (ob->nlastrips.first) {
@@ -1949,8 +2073,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* object's action will always be object-rooted */
{
AnimData *adt = BKE_animdata_from_id(id);
- if (adt && adt->action)
+ if (adt && adt->action) {
adt->action->idroot = ID_OB;
+ }
}
}
@@ -1958,8 +2083,9 @@ void do_versions_ipos_to_animato(Main *bmain)
for (id = bmain->shapekeys.first; id; id = id->next) {
Key *key = (Key *)id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting key %s\n", id->name + 2);
+ }
/* we're only interested in the IPO
* NOTE: for later, it might be good to port these over to Object instead, as many of these
@@ -1972,8 +2098,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* Convert Shapekey data... */
ipo_to_animdata(bmain, id, key->ipo, NULL, NULL, NULL);
- if (adt->action)
+ if (adt->action) {
adt->action->idroot = key->ipo->blocktype;
+ }
id_us_min(&key->ipo->id);
key->ipo = NULL;
@@ -1984,8 +2111,9 @@ void do_versions_ipos_to_animato(Main *bmain)
for (id = bmain->materials.first; id; id = id->next) {
Material *ma = (Material *)id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting material %s\n", id->name + 2);
+ }
/* we're only interested in the IPO */
if (ma->ipo) {
@@ -1995,8 +2123,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* Convert Material data... */
ipo_to_animdata(bmain, id, ma->ipo, NULL, NULL, NULL);
- if (adt->action)
+ if (adt->action) {
adt->action->idroot = ma->ipo->blocktype;
+ }
id_us_min(&ma->ipo->id);
ma->ipo = NULL;
@@ -2007,8 +2136,9 @@ void do_versions_ipos_to_animato(Main *bmain)
for (id = bmain->worlds.first; id; id = id->next) {
World *wo = (World *)id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting world %s\n", id->name + 2);
+ }
/* we're only interested in the IPO */
if (wo->ipo) {
@@ -2018,8 +2148,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* Convert World data... */
ipo_to_animdata(bmain, id, wo->ipo, NULL, NULL, NULL);
- if (adt->action)
+ if (adt->action) {
adt->action->idroot = wo->ipo->blocktype;
+ }
id_us_min(&wo->ipo->id);
wo->ipo = NULL;
@@ -2039,8 +2170,9 @@ void do_versions_ipos_to_animato(Main *bmain)
IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL;
short adrcode = SEQ_FAC1;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting sequence strip %s\n", seq->name + 2);
+ }
if (ELEM(NULL, seq->ipo, icu)) {
seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
@@ -2068,8 +2200,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* convert IPO */
ipo_to_animdata(bmain, (ID *)scene, seq->ipo, NULL, NULL, seq);
- if (adt->action)
+ if (adt->action) {
adt->action->idroot = ID_SCE; /* scene-rooted */
+ }
id_us_min(&seq->ipo->id);
seq->ipo = NULL;
@@ -2082,8 +2215,9 @@ void do_versions_ipos_to_animato(Main *bmain)
for (id = bmain->textures.first; id; id = id->next) {
Tex *te = (Tex *)id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting texture %s\n", id->name + 2);
+ }
/* we're only interested in the IPO */
if (te->ipo) {
@@ -2093,8 +2227,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* Convert Texture data... */
ipo_to_animdata(bmain, id, te->ipo, NULL, NULL, NULL);
- if (adt->action)
+ if (adt->action) {
adt->action->idroot = te->ipo->blocktype;
+ }
id_us_min(&te->ipo->id);
te->ipo = NULL;
@@ -2105,8 +2240,9 @@ void do_versions_ipos_to_animato(Main *bmain)
for (id = bmain->cameras.first; id; id = id->next) {
Camera *ca = (Camera *)id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting camera %s\n", id->name + 2);
+ }
/* we're only interested in the IPO */
if (ca->ipo) {
@@ -2116,8 +2252,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* Convert Camera data... */
ipo_to_animdata(bmain, id, ca->ipo, NULL, NULL, NULL);
- if (adt->action)
+ if (adt->action) {
adt->action->idroot = ca->ipo->blocktype;
+ }
id_us_min(&ca->ipo->id);
ca->ipo = NULL;
@@ -2128,8 +2265,9 @@ void do_versions_ipos_to_animato(Main *bmain)
for (id = bmain->lights.first; id; id = id->next) {
Light *la = (Light *)id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting light %s\n", id->name + 2);
+ }
/* we're only interested in the IPO */
if (la->ipo) {
@@ -2139,8 +2277,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* Convert Light data... */
ipo_to_animdata(bmain, id, la->ipo, NULL, NULL, NULL);
- if (adt->action)
+ if (adt->action) {
adt->action->idroot = la->ipo->blocktype;
+ }
id_us_min(&la->ipo->id);
la->ipo = NULL;
@@ -2151,8 +2290,9 @@ void do_versions_ipos_to_animato(Main *bmain)
for (id = bmain->curves.first; id; id = id->next) {
Curve *cu = (Curve *)id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting curve %s\n", id->name + 2);
+ }
/* we're only interested in the IPO */
if (cu->ipo) {
@@ -2162,8 +2302,9 @@ void do_versions_ipos_to_animato(Main *bmain)
/* Convert Curve data... */
ipo_to_animdata(bmain, id, cu->ipo, NULL, NULL, NULL);
- if (adt->action)
+ if (adt->action) {
adt->action->idroot = cu->ipo->blocktype;
+ }
id_us_min(&cu->ipo->id);
cu->ipo = NULL;
@@ -2173,24 +2314,26 @@ void do_versions_ipos_to_animato(Main *bmain)
/* --------- Unconverted Animation Data ------------------ */
/* For Animation data which may not be directly connected (i.e. not linked) to any other
* data, we need to perform a separate pass to make sure that they are converted to standalone
- * Actions which may then be able to be reused. This does mean that we will be going over data that's
- * already been converted, but there are no problems with that.
+ * Actions which may then be able to be reused. This does mean that we will be going over data
+ * that's already been converted, but there are no problems with that.
*
* The most common case for this will be Action Constraints, or IPO's with Fake-Users.
- * We collect all drivers that were found into a temporary collection, and free them in one go, as they're
- * impossible to resolve.
+ * We collect all drivers that were found into a temporary collection, and free them in one go,
+ * as they're impossible to resolve.
*/
/* actions */
for (id = bmain->actions.first; id; id = id->next) {
bAction *act = (bAction *)id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting action %s\n", id->name + 2);
+ }
/* if old action, it will be object-only... */
- if (act->chanbase.first)
+ if (act->chanbase.first) {
act->idroot = ID_OB;
+ }
/* be careful! some of the actions we encounter will be converted ones... */
action_to_animato(NULL, act, &act->groups, &act->curves, &drivers);
@@ -2200,8 +2343,9 @@ void do_versions_ipos_to_animato(Main *bmain)
for (id = bmain->ipo.first; id; id = id->next) {
Ipo *ipo = (Ipo *)id;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tconverting ipo %s\n", id->name + 2);
+ }
/* most likely this IPO has already been processed, so check if any curves left to convert */
if (ipo->curve.first) {
@@ -2221,6 +2365,7 @@ void do_versions_ipos_to_animato(Main *bmain)
/* free unused drivers from actions + ipos */
free_fcurves(&drivers);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("INFO: Animato convert done\n");
+ }
}
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 1d1c04e173c..61de6a8c06a 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -79,8 +79,9 @@ void BKE_key_free(Key *key)
BKE_animdata_free((ID *)key, false);
while ((kb = BLI_pophead(&key->block))) {
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
MEM_freeN(kb);
}
}
@@ -90,8 +91,9 @@ void BKE_key_free_nolib(Key *key)
KeyBlock *kb;
while ((kb = BLI_pophead(&key->block))) {
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
MEM_freeN(kb);
}
}
@@ -149,8 +151,10 @@ Key *BKE_key_add(Main *bmain, ID *id) /* common function */
}
/**
- * Only copy internal data of ShapeKey ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of ShapeKey ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -198,10 +202,12 @@ Key *BKE_key_copy_nolib(Key *key)
kbn = keyn->block.first;
while (kbn) {
- if (kbn->data)
+ if (kbn->data) {
kbn->data = MEM_dupallocN(kbn->data);
- if (kb == key->refkey)
+ }
+ if (kb == key->refkey) {
keyn->refkey = kbn;
+ }
kbn = kbn->next;
kb = kb->next;
@@ -221,9 +227,11 @@ void BKE_key_sort(Key *key)
KeyBlock *kb2;
/* locate the key which is out of position */
- for (kb = key->block.first; kb; kb = kb->next)
- if ((kb->next) && (kb->pos > kb->next->pos))
+ for (kb = key->block.first; kb; kb = kb->next) {
+ if ((kb->next) && (kb->pos > kb->next->pos)) {
break;
+ }
+ }
/* if we find a key, move it */
if (kb) {
@@ -372,27 +380,32 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl)
lastpos = k1->pos;
dpos = lastpos - firstkey->pos;
- if (fac < firstkey->pos)
+ if (fac < firstkey->pos) {
fac = firstkey->pos;
- else if (fac > k1->pos)
+ }
+ else if (fac > k1->pos) {
fac = k1->pos;
+ }
k1 = k[0] = k[1] = k[2] = k[3] = firstkey;
t[0] = t[1] = t[2] = t[3] = k1->pos;
/* if (fac < 0.0 || fac > 1.0) return 1; */
- if (k1->next == NULL)
+ if (k1->next == NULL) {
return 1;
+ }
if (cycl) { /* pre-sort */
k[2] = k1->next;
k[3] = k[2]->next;
- if (k[3] == NULL)
+ if (k[3] == NULL) {
k[3] = k1;
+ }
while (k1) {
- if (k1->next == NULL)
+ if (k1->next == NULL) {
k[0] = k1;
+ }
k1 = k1->next;
}
/* k1 = k[1]; */ /* UNUSED */
@@ -406,16 +419,18 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl)
t[3] += dpos;
ofs = 2.0f * dpos;
}
- if (fac < t[1])
+ if (fac < t[1]) {
fac += dpos;
+ }
k1 = k[3];
}
else { /* pre-sort */
k[2] = k1->next;
t[2] = k[2]->pos;
k[3] = k[2]->next;
- if (k[3] == NULL)
+ if (k[3] == NULL) {
k[3] = k[2];
+ }
t[3] = k[3]->pos;
k1 = k[3];
}
@@ -443,13 +458,15 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl)
t[3] = k1->pos + ofs;
k[3] = k1;
- if (ofs > 2.1f + lastpos)
+ if (ofs > 2.1f + lastpos) {
break;
+ }
}
bsplinetype = 0;
- if (k[1]->type == KEY_BSPLINE || k[2]->type == KEY_BSPLINE)
+ if (k[1]->type == KEY_BSPLINE || k[2]->type == KEY_BSPLINE) {
bsplinetype = 1;
+ }
if (cycl == 0) {
if (bsplinetype == 0) { /* B spline doesn't go through the control points */
@@ -597,11 +614,13 @@ static void cp_key(const int start,
/* currently always 0, in future key_pointer_size may assign */
ofs[1] = 0;
- if (!key_pointer_size(key, mode, &poinsize, &ofs[0], &step))
+ if (!key_pointer_size(key, mode, &poinsize, &ofs[0], &step)) {
return;
+ }
- if (end > tot)
+ if (end > tot) {
end = tot;
+ }
if (tot != kb->totelem) {
ktot = 0.0;
@@ -646,8 +665,9 @@ static void cp_key(const int start,
for (a = start; a < end; a += step) {
cp = key->elemstr;
- if (mode == KEY_MODE_BEZTRIPLE)
+ if (mode == KEY_MODE_BEZTRIPLE) {
cp = elemstr;
+ }
ofsp = ofs;
@@ -657,9 +677,10 @@ static void cp_key(const int start,
case IPO_FLOAT:
if (weights) {
memcpy(poin, kref, sizeof(float[KEYELEM_FLOAT_LEN_COORD]));
- if (*weights != 0.0f)
+ if (*weights != 0.0f) {
rel_flerp(
KEYELEM_FLOAT_LEN_COORD, (float *)poin, (float *)kref, (float *)k1, *weights);
+ }
weights++;
}
else {
@@ -674,10 +695,12 @@ static void cp_key(const int start,
break;
default:
/* should never happen */
- if (freek1)
+ if (freek1) {
MEM_freeN(freek1);
- if (freekref)
+ }
+ if (freekref) {
MEM_freeN(freekref);
+ }
BLI_assert(!"invalid 'cp[1]'");
return;
}
@@ -702,10 +725,12 @@ static void cp_key(const int start,
}
}
- if (freek1)
+ if (freek1) {
MEM_freeN(freek1);
- if (freekref)
+ }
+ if (freekref) {
MEM_freeN(freekref);
+ }
}
static void cp_cu_key(Curve *cu,
@@ -727,8 +752,9 @@ static void cp_cu_key(Curve *cu,
a1 = max_ii(a, start);
a2 = min_ii(a + step, end);
- if (a1 < a2)
+ if (a1 < a2) {
cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BPOINT);
+ }
}
else if (nu->bezt) {
step = KEYELEM_ELEM_LEN_BEZTRIPLE * nu->pntsu;
@@ -737,8 +763,9 @@ static void cp_cu_key(Curve *cu,
a1 = max_ii(a, start);
a2 = min_ii(a + step, end);
- if (a1 < a2)
+ if (a1 < a2) {
cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BEZTRIPLE);
+ }
}
else {
step = 0;
@@ -763,11 +790,13 @@ static void key_evaluate_relative(const int start,
/* currently always 0, in future key_pointer_size may assign */
ofs[1] = 0;
- if (!key_pointer_size(key, mode, &poinsize, &ofs[0], &step))
+ if (!key_pointer_size(key, mode, &poinsize, &ofs[0], &step)) {
return;
+ }
- if (end > tot)
+ if (end > tot) {
end = tot;
+ }
/* in case of beztriple */
elemstr[0] = 1; /* nr of ipofloats */
@@ -795,8 +824,9 @@ static void key_evaluate_relative(const int start,
/* reference now can be any block */
refb = BLI_findlink(&key->block, kb->relative);
- if (refb == NULL)
+ if (refb == NULL) {
continue;
+ }
poin = basispoin;
from = key_block_get_data(key, actkb, kb, &freefrom);
@@ -811,8 +841,9 @@ static void key_evaluate_relative(const int start,
weight = weights ? (*weights * icuval) : icuval;
cp = key->elemstr;
- if (mode == KEY_MODE_BEZTRIPLE)
+ if (mode == KEY_MODE_BEZTRIPLE) {
cp = elemstr;
+ }
ofsp = ofs;
@@ -842,10 +873,12 @@ static void key_evaluate_relative(const int start,
break;
default:
/* should never happen */
- if (freefrom)
+ if (freefrom) {
MEM_freeN(freefrom);
- if (freereffrom)
+ }
+ if (freereffrom) {
MEM_freeN(freereffrom);
+ }
BLI_assert(!"invalid 'cp[1]'");
return;
}
@@ -859,14 +892,17 @@ static void key_evaluate_relative(const int start,
reffrom += elemsize;
from += elemsize;
- if (weights)
+ if (weights) {
weights++;
+ }
}
- if (freefrom)
+ if (freefrom) {
MEM_freeN(freefrom);
- if (freereffrom)
+ }
+ if (freereffrom) {
MEM_freeN(freereffrom);
+ }
}
}
}
@@ -892,11 +928,13 @@ static void do_key(const int start,
/* currently always 0, in future key_pointer_size may assign */
ofs[1] = 0;
- if (!key_pointer_size(key, mode, &poinsize, &ofs[0], &step))
+ if (!key_pointer_size(key, mode, &poinsize, &ofs[0], &step)) {
return;
+ }
- if (end > tot)
+ if (end > tot) {
end = tot;
+ }
k1 = key_block_get_data(key, actkb, k[0], &freek1);
k2 = key_block_get_data(key, actkb, k[1], &freek2);
@@ -1014,8 +1052,9 @@ static void do_key(const int start,
for (a = start; a < end; a += step) {
cp = key->elemstr;
- if (mode == KEY_MODE_BEZTRIPLE)
+ if (mode == KEY_MODE_BEZTRIPLE) {
cp = elemstr;
+ }
ofsp = ofs;
@@ -1051,14 +1090,18 @@ static void do_key(const int start,
break;
default:
/* should never happen */
- if (freek1)
+ if (freek1) {
MEM_freeN(freek1);
- if (freek2)
+ }
+ if (freek2) {
MEM_freeN(freek2);
- if (freek3)
+ }
+ if (freek3) {
MEM_freeN(freek3);
- if (freek4)
+ }
+ if (freek4) {
MEM_freeN(freek4);
+ }
BLI_assert(!"invalid 'cp[1]'");
return;
}
@@ -1118,14 +1161,18 @@ static void do_key(const int start,
}
}
- if (freek1)
+ if (freek1) {
MEM_freeN(freek1);
- if (freek2)
+ }
+ if (freek2) {
MEM_freeN(freek2);
- if (freek3)
+ }
+ if (freek3) {
MEM_freeN(freek3);
- if (freek4)
+ }
+ if (freek4) {
MEM_freeN(freek4);
+ }
}
static float *get_weights_array(Object *ob, char *vgroup, WeightsArrayCache *cache)
@@ -1137,8 +1184,9 @@ static float *get_weights_array(Object *ob, char *vgroup, WeightsArrayCache *cac
int totvert = 0, defgrp_index = 0;
/* no vgroup string set? */
- if (vgroup[0] == 0)
+ if (vgroup[0] == 0) {
return NULL;
+ }
/* gather dvert and totvert */
if (ob->type == OB_MESH) {
@@ -1146,8 +1194,9 @@ static float *get_weights_array(Object *ob, char *vgroup, WeightsArrayCache *cac
dvert = me->dvert;
totvert = me->totvert;
- if (me->edit_mesh && me->edit_mesh->bm->totvert == totvert)
+ if (me->edit_mesh && me->edit_mesh->bm->totvert == totvert) {
em = me->edit_mesh;
+ }
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
@@ -1155,8 +1204,9 @@ static float *get_weights_array(Object *ob, char *vgroup, WeightsArrayCache *cac
totvert = lt->pntsu * lt->pntsv * lt->pntsw;
}
- if (dvert == NULL)
+ if (dvert == NULL) {
return NULL;
+ }
/* find the group (weak loop-in-loop) */
defgrp_index = defgroup_name_index(ob, vgroup);
@@ -1366,8 +1416,9 @@ static void do_latt_key(Object *ob, Key *key, char *out, const int tot)
}
}
- if (lt->flag & LT_OUTSIDE)
+ if (lt->flag & LT_OUTSIDE) {
outside_lattice(lt);
+ }
}
/* returns key coordinates (+ tilt) when key applied, NULL otherwise */
@@ -1378,8 +1429,9 @@ float *BKE_key_evaluate_object_ex(Object *ob, int *r_totelem, float *arr, size_t
char *out;
int tot = 0, size = 0;
- if (key == NULL || BLI_listbase_is_empty(&key->block))
+ if (key == NULL || BLI_listbase_is_empty(&key->block)) {
return NULL;
+ }
/* compute size of output array */
if (ob->type == OB_MESH) {
@@ -1402,8 +1454,9 @@ float *BKE_key_evaluate_object_ex(Object *ob, int *r_totelem, float *arr, size_t
}
/* if nothing to interpolate, cancel */
- if (tot == 0 || size == 0)
+ if (tot == 0 || size == 0) {
return NULL;
+ }
/* allocate array */
if (arr == NULL) {
@@ -1421,8 +1474,9 @@ float *BKE_key_evaluate_object_ex(Object *ob, int *r_totelem, float *arr, size_t
/* shape locked, copy the locked shape instead of blending */
KeyBlock *kb = BLI_findlink(&key->block, ob->shapenr - 1);
- if (kb && (kb->flag & KEYBLOCK_MUTE))
+ if (kb && (kb->flag & KEYBLOCK_MUTE)) {
kb = key->refkey;
+ }
if (kb == NULL) {
kb = key->block.first;
@@ -1434,22 +1488,28 @@ float *BKE_key_evaluate_object_ex(Object *ob, int *r_totelem, float *arr, size_t
cp_key(0, tot, tot, out, key, actkb, kb, weights, 0);
- if (weights)
+ if (weights) {
MEM_freeN(weights);
+ }
}
- else if (ELEM(ob->type, OB_CURVE, OB_SURF))
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
cp_cu_key(ob->data, key, actkb, kb, 0, tot, out, tot);
+ }
}
else {
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
do_mesh_key(ob, key, out, tot);
- else if (ob->type == OB_LATTICE)
+ }
+ else if (ob->type == OB_LATTICE) {
do_latt_key(ob, key, out, tot);
- else if (ob->type == OB_CURVE)
+ }
+ else if (ob->type == OB_CURVE) {
do_curve_key(ob, key, out, tot);
- else if (ob->type == OB_SURF)
+ }
+ else if (ob->type == OB_SURF) {
do_curve_key(ob, key, out, tot);
+ }
}
if (r_totelem) {
@@ -1513,8 +1573,9 @@ Key *BKE_key_from_id(ID *id)
Key **BKE_key_from_object_p(const Object *ob)
{
- if (ob == NULL || ob->data == NULL)
+ if (ob == NULL || ob->data == NULL) {
return NULL;
+ }
return BKE_key_from_id_p(ob->data);
}
@@ -1537,8 +1598,9 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name)
int tot;
kb = key->block.last;
- if (kb)
+ if (kb) {
curpos = kb->pos;
+ }
kb = MEM_callocN(sizeof(KeyBlock), "Keyblock");
BLI_addtail(&key->block, kb);
@@ -1549,10 +1611,12 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name)
BLI_strncpy(kb->name, name, sizeof(kb->name));
}
else {
- if (tot == 1)
+ if (tot == 1) {
BLI_strncpy(kb->name, DATA_("Basis"), sizeof(kb->name));
- else
+ }
+ else {
BLI_snprintf(kb->name, sizeof(kb->name), DATA_("Key %d"), tot - 1);
+ }
}
BLI_uniquename(&key->block, kb, DATA_("Key"), '.', offsetof(KeyBlock, name), sizeof(kb->name));
@@ -1560,8 +1624,9 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name)
kb->uid = key->uidgen++;
key->totkey++;
- if (key->totkey == 1)
+ if (key->totkey == 1) {
key->refkey = kb;
+ }
kb->slidermin = 0.0f;
kb->slidermax = 1.0f;
@@ -1627,8 +1692,9 @@ KeyBlock *BKE_keyblock_from_object_reference(Object *ob)
{
Key *key = BKE_key_from_object(ob);
- if (key)
+ if (key) {
return key->refkey;
+ }
return NULL;
}
@@ -1645,8 +1711,9 @@ KeyBlock *BKE_keyblock_from_key(Key *key, int index)
for (i = 1; i < key->totkey; i++) {
kb = kb->next;
- if (index == i)
+ if (index == i) {
return kb;
+ }
}
}
@@ -1682,8 +1749,9 @@ char *BKE_keyblock_curval_rnapath_get(Key *key, KeyBlock *kb)
PropertyRNA *prop;
/* sanity checks */
- if (ELEM(NULL, key, kb))
+ if (ELEM(NULL, key, kb)) {
return NULL;
+ }
/* create the RNA pointer */
RNA_pointer_create(&key->id, &RNA_ShapeKey, kb, &ptr);
@@ -1706,8 +1774,9 @@ void BKE_keyblock_update_from_lattice(Lattice *lt, KeyBlock *kb)
BLI_assert(kb->totelem == lt->pntsu * lt->pntsv * lt->pntsw);
tot = kb->totelem;
- if (tot == 0)
+ if (tot == 0) {
return;
+ }
bp = lt->def;
fp = kb->data;
@@ -1721,8 +1790,9 @@ void BKE_keyblock_convert_from_lattice(Lattice *lt, KeyBlock *kb)
int tot;
tot = lt->pntsu * lt->pntsv * lt->pntsw;
- if (tot == 0)
+ if (tot == 0) {
return;
+ }
MEM_SAFE_FREE(kb->data);
@@ -1758,10 +1828,12 @@ int BKE_keyblock_curve_element_count(ListBase *nurb)
nu = nurb->first;
while (nu) {
- if (nu->bezt)
+ if (nu->bezt) {
tot += KEYELEM_ELEM_LEN_BEZTRIPLE * nu->pntsu;
- else if (nu->bp)
+ }
+ else if (nu->bp) {
tot += KEYELEM_ELEM_LEN_BPOINT * nu->pntsu * nu->pntsv;
+ }
nu = nu->next;
}
@@ -1780,8 +1852,9 @@ void BKE_keyblock_update_from_curve(Curve *UNUSED(cu), KeyBlock *kb, ListBase *n
BLI_assert(BKE_keyblock_curve_element_count(nurb) == kb->totelem);
tot = kb->totelem;
- if (tot == 0)
+ if (tot == 0) {
return;
+ }
fp = kb->data;
for (nu = nurb->first; nu; nu = nu->next) {
@@ -1812,8 +1885,9 @@ void BKE_keyblock_convert_from_curve(Curve *cu, KeyBlock *kb, ListBase *nurb)
/* count */
tot = BKE_keyblock_curve_element_count(nurb);
- if (tot == 0)
+ if (tot == 0) {
return;
+ }
MEM_SAFE_FREE(kb->data);
@@ -1869,8 +1943,9 @@ void BKE_keyblock_update_from_mesh(Mesh *me, KeyBlock *kb)
BLI_assert(me->totvert == kb->totelem);
tot = me->totvert;
- if (tot == 0)
+ if (tot == 0) {
return;
+ }
mvert = me->mvert;
fp = kb->data;
@@ -1883,8 +1958,9 @@ void BKE_keyblock_convert_from_mesh(Mesh *me, Key *key, KeyBlock *kb)
{
const int len = me->totvert;
- if (me->totvert == 0)
+ if (me->totvert == 0) {
return;
+ }
MEM_SAFE_FREE(kb->data);
@@ -2015,8 +2091,9 @@ void BKE_keyblock_update_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos)
#endif
tot = kb->totelem;
- if (tot == 0)
+ if (tot == 0) {
return;
+ }
/* Copy coords to keyblock */
if (ELEM(ob->type, OB_MESH, OB_LATTICE)) {
@@ -2072,8 +2149,9 @@ void BKE_keyblock_convert_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos
tot = BKE_keyblock_curve_element_count(&cu->nurb);
}
- if (tot == 0)
+ if (tot == 0) {
return;
+ }
kb->data = MEM_mallocN(tot * elemsize, __func__);
@@ -2101,8 +2179,9 @@ float (*BKE_keyblock_convert_to_vertcos(Object *ob, KeyBlock *kb))[3]
tot = BKE_nurbList_verts_count(&cu->nurb);
}
- if (tot == 0)
+ if (tot == 0) {
return NULL;
+ }
co = vertCos = MEM_mallocN(tot * sizeof(*vertCos), __func__);
@@ -2177,8 +2256,9 @@ void BKE_keyblock_update_from_offset(Object *ob, KeyBlock *kb, float (*ofs)[3])
/* ==========================================================*/
-/** Move shape key from org_index to new_index. Safe, clamps index to valid range, updates reference keys,
- * the object's active shape index, the 'frame' value in case of absolute keys, etc.
+/** Move shape key from org_index to new_index. Safe, clamps index to valid range,
+ * updates reference keys, the object's active shape index,
+ * the 'frame' value in case of absolute keys, etc.
* Note indices are expected in real values (not 'fake' shapenr +1 ones).
*
* \param org_index: if < 0, current object's active shape will be used as skey to move.
@@ -2206,8 +2286,8 @@ bool BKE_keyblock_move(Object *ob, int org_index, int new_index)
rev = ((new_index - org_index) < 0) ? true : false;
- /* We swap 'org' element with its previous/next neighbor (depending on direction of the move) repeatedly,
- * until we reach final position.
+ /* We swap 'org' element with its previous/next neighbor (depending on direction of the move)
+ * repeatedly, until we reach final position.
* This allows us to only loop on the list once! */
for (kb = (rev ? key->block.last : key->block.first), i = (rev ? totkey - 1 : 0); kb;
kb = (rev ? kb->prev : kb->next), rev ? i-- : i++) {
@@ -2244,7 +2324,8 @@ bool BKE_keyblock_move(Object *ob, int org_index, int new_index)
}
}
- /* Need to update active shape number if it's affected, same principle as for relative indices above. */
+ /* Need to update active shape number if it's affected,
+ * same principle as for relative indices above. */
if (org_index == act_index) {
ob->shapenr = new_index + 1;
}
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index d301405bdb4..b8178bec52f 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -32,6 +32,7 @@
#include "BLI_listbase.h"
#include "BLI_bitmap.h"
#include "BLI_math.h"
+#include "BLI_task.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -147,12 +148,15 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
}
while (uNew * vNew * wNew > 32000) {
- if (uNew >= vNew && uNew >= wNew)
+ if (uNew >= vNew && uNew >= wNew) {
uNew--;
- else if (vNew >= uNew && vNew >= wNew)
+ }
+ else if (vNew >= uNew && vNew >= wNew) {
vNew--;
- else
+ }
+ else {
wNew--;
+ }
}
vertexCos = MEM_mallocN(sizeof(*vertexCos) * uNew * vNew * wNew, "tmp_vcos");
@@ -265,8 +269,10 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Lattice ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Lattice ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -311,10 +317,12 @@ void BKE_lattice_free(Lattice *lt)
if (lt->editlatt) {
Lattice *editlt = lt->editlatt->latt;
- if (editlt->def)
+ if (editlt->def) {
MEM_freeN(editlt->def);
- if (editlt->dvert)
+ }
+ if (editlt->dvert) {
BKE_defvert_array_free(editlt->dvert, lt->pntsu * lt->pntsv * lt->pntsw);
+ }
MEM_freeN(editlt);
MEM_freeN(lt->editlatt);
@@ -349,8 +357,9 @@ LatticeDeformData *init_latt_deform(Object *oblatt, Object *ob)
float latmat[4][4];
LatticeDeformData *lattice_deform_data;
- if (lt->editlatt)
+ if (lt->editlatt) {
lt = lt->editlatt->latt;
+ }
bp = lt->def;
fp = latticedata = MEM_mallocN(sizeof(float) * 3 * lt->pntsu * lt->pntsv * lt->pntsw,
@@ -415,10 +424,12 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float
MDeformVert *dvert = BKE_lattice_deform_verts_get(ob);
float *__restrict latticedata = lattice_deform_data->latticedata;
- if (lt->editlatt)
+ if (lt->editlatt) {
lt = lt->editlatt->latt;
- if (latticedata == NULL)
+ }
+ if (latticedata == NULL) {
return;
+ }
if (lt->vgroup[0] && dvert) {
defgrp_index = defgroup_name_index(ob, lt->vgroup);
@@ -471,10 +482,12 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float
if (w != 0.0f) {
if (ww > 0) {
- if (ww < lt->pntsw)
+ if (ww < lt->pntsw) {
idx_w = ww * lt->pntsu * lt->pntsv;
- else
+ }
+ else {
idx_w = (lt->pntsw - 1) * lt->pntsu * lt->pntsv;
+ }
}
else {
idx_w = 0;
@@ -485,10 +498,12 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float
if (v != 0.0f) {
if (vv > 0) {
- if (vv < lt->pntsv)
+ if (vv < lt->pntsv) {
idx_v = idx_w + vv * lt->pntsu;
- else
+ }
+ else {
idx_v = idx_w + (lt->pntsv - 1) * lt->pntsu;
+ }
}
else {
idx_v = idx_w;
@@ -499,10 +514,12 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float
if (u != 0.0f) {
if (uu > 0) {
- if (uu < lt->pntsu)
+ if (uu < lt->pntsu) {
idx_u = idx_v + uu;
- else
+ }
+ else {
idx_u = idx_v + (lt->pntsu - 1);
+ }
}
else {
idx_u = idx_v;
@@ -510,8 +527,9 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float
madd_v3_v3fl(co, &latticedata[idx_u * 3], u);
- if (defgrp_index != -1)
+ if (defgrp_index != -1) {
weight_blend += (u * defvert_find_weight(dvert + idx_u, defgrp_index));
+ }
}
}
}
@@ -519,14 +537,16 @@ void calc_latt_deform(LatticeDeformData *lattice_deform_data, float co[3], float
}
}
- if (defgrp_index != -1)
+ if (defgrp_index != -1) {
interp_v3_v3v3(co, co_prev, co, weight_blend);
+ }
}
void end_latt_deform(LatticeDeformData *lattice_deform_data)
{
- if (lattice_deform_data->latticedata)
+ if (lattice_deform_data->latticedata) {
MEM_freeN(lattice_deform_data->latticedata);
+ }
MEM_freeN(lattice_deform_data);
}
@@ -562,10 +582,12 @@ static bool where_on_path_deform(
/* test for cyclic */
bl = ob->runtime.curve_cache->bev.first;
- if (!bl->nr)
+ if (!bl->nr) {
return false;
- if (bl->poly > -1)
+ }
+ if (bl->poly > -1) {
cycl = 1;
+ }
if (cycl == 0) {
ctime1 = CLAMPIS(ctime, 0.0f, 1.0f);
@@ -585,19 +607,23 @@ static bool where_on_path_deform(
sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec);
mul_v3_fl(dvec, ctime * (float)path->len);
add_v3_v3(vec, dvec);
- if (quat)
+ if (quat) {
copy_qt_qt(quat, path->data[0].quat);
- if (radius)
+ }
+ if (radius) {
*radius = path->data[0].radius;
+ }
}
else if (ctime > 1.0f) {
sub_v3_v3v3(dvec, path->data[path->len - 1].vec, path->data[path->len - 2].vec);
mul_v3_fl(dvec, (ctime - 1.0f) * (float)path->len);
add_v3_v3(vec, dvec);
- if (quat)
+ if (quat) {
copy_qt_qt(quat, path->data[path->len - 1].quat);
- if (radius)
+ }
+ if (radius) {
*radius = path->data[path->len - 1].radius;
+ }
/* weight - not used but could be added */
}
}
@@ -631,10 +657,12 @@ static bool calc_curve_deform(
/* options */
if (is_neg_axis) {
index = axis - 3;
- if (cu->flag & CU_STRETCH)
+ if (cu->flag & CU_STRETCH) {
fac = -(co[index] - cd->dmax[index]) / (cd->dmax[index] - cd->dmin[index]);
- else
+ }
+ else {
fac = -(co[index] - cd->dmax[index]) / (par->runtime.curve_cache->path->totdist);
+ }
}
else {
index = axis;
@@ -656,8 +684,8 @@ static bool calc_curve_deform(
if (cd->no_rot_axis) { /* set by caller */
- /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather than
- * changing the axis before calculating the tilt but serves much the same purpose */
+ /* This is not exactly the same as 2.4x, since the axis is having rotation removed rather
+ * than changing the axis before calculating the tilt but serves much the same purpose. */
float dir_flat[3] = {0, 0, 0}, q[4];
copy_v3_v3(dir_flat, dir);
dir_flat[cd->no_rot_axis - 1] = 0.0f;
@@ -674,8 +702,10 @@ static bool calc_curve_deform(
*
* The way 'co' is copied to 'cent' may seem to have no meaning, but it does.
*
- * Use a curve modifier to stretch a cube out, color each side RGB, positive side light, negative dark.
- * view with X up (default), from the angle that you can see 3 faces RGB colors (light), anti-clockwise
+ * Use a curve modifier to stretch a cube out, color each side RGB,
+ * positive side light, negative dark.
+ * view with X up (default), from the angle that you can see 3 faces RGB colors (light),
+ * anti-clockwise
* Notice X,Y,Z Up all have light colors and each ordered CCW.
*
* Now for Neg Up XYZ, the colors are all dark, and ordered clockwise - Campbell
@@ -695,8 +725,9 @@ static bool calc_curve_deform(
cent[index] = 0.0f;
/* scale if enabled */
- if (cu->flag & CU_PATH_RADIUS)
+ if (cu->flag & CU_PATH_RADIUS) {
mul_v3_fl(cent, radius);
+ }
/* local rotation */
normalize_qt(quat);
@@ -705,8 +736,9 @@ static bool calc_curve_deform(
/* translation */
add_v3_v3v3(co, cent, loc);
- if (r_quat)
+ if (r_quat) {
copy_qt_qt(r_quat, quat);
+ }
return true;
}
@@ -726,8 +758,9 @@ void curve_deform_verts(Object *cuOb,
CurveDeform cd;
const bool is_neg_axis = (defaxis > 2);
- if (cuOb->type != OB_CURVE)
+ if (cuOb->type != OB_CURVE) {
return;
+ }
cu = cuOb->data;
@@ -839,12 +872,38 @@ void curve_deform_vector(
quat_to_mat3(qmat, quat);
mul_m3_m3m3(mat, qmat, cd.objectspace3);
}
- else
+ else {
unit_m3(mat);
+ }
mul_m4_v3(cd.objectspace, vec);
}
+typedef struct LatticeDeformUserdata {
+ LatticeDeformData *lattice_deform_data;
+ float (*vertexCos)[3];
+ MDeformVert *dvert;
+ int defgrp_index;
+ float fac;
+} LatticeDeformUserdata;
+
+static void lattice_deform_vert_task(void *__restrict userdata,
+ const int index,
+ const ParallelRangeTLS *__restrict UNUSED(tls))
+{
+ const LatticeDeformUserdata *data = userdata;
+
+ if (data->dvert != NULL) {
+ const float weight = defvert_find_weight(data->dvert + index, data->defgrp_index);
+ if (weight > 0.0f) {
+ calc_latt_deform(data->lattice_deform_data, data->vertexCos[index], weight * data->fac);
+ }
+ }
+ else {
+ calc_latt_deform(data->lattice_deform_data, data->vertexCos[index], data->fac);
+ }
+}
+
void lattice_deform_verts(Object *laOb,
Object *target,
Mesh *mesh,
@@ -856,10 +915,10 @@ void lattice_deform_verts(Object *laOb,
LatticeDeformData *lattice_deform_data;
MDeformVert *dvert = NULL;
int defgrp_index = -1;
- int a;
- if (laOb->type != OB_LATTICE)
+ if (laOb->type != OB_LATTICE) {
return;
+ }
lattice_deform_data = init_latt_deform(laOb, target);
@@ -882,20 +941,18 @@ void lattice_deform_verts(Object *laOb,
}
}
}
- if (dvert) {
- MDeformVert *dvert_iter;
- for (a = 0, dvert_iter = dvert; a < numVerts; a++, dvert_iter++) {
- const float weight = defvert_find_weight(dvert_iter, defgrp_index);
- if (weight > 0.0f) {
- calc_latt_deform(lattice_deform_data, vertexCos[a], weight * fac);
- }
- }
- }
- else {
- for (a = 0; a < numVerts; a++) {
- calc_latt_deform(lattice_deform_data, vertexCos[a], fac);
- }
- }
+
+ LatticeDeformUserdata data = {.lattice_deform_data = lattice_deform_data,
+ .vertexCos = vertexCos,
+ .dvert = dvert,
+ .defgrp_index = defgrp_index,
+ .fac = fac};
+
+ ParallelRangeSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.min_iter_per_thread = 32;
+ BLI_task_parallel_range(0, numVerts, &data, lattice_deform_vert_task, &settings);
+
end_latt_deform(lattice_deform_data);
}
@@ -929,12 +986,15 @@ void outside_lattice(Lattice *lt)
if (lt->flag & LT_OUTSIDE) {
bp = lt->def;
- if (lt->pntsu > 1)
+ if (lt->pntsu > 1) {
du = 1.0f / ((float)lt->pntsu - 1);
- if (lt->pntsv > 1)
+ }
+ if (lt->pntsv > 1) {
dv = 1.0f / ((float)lt->pntsv - 1);
- if (lt->pntsw > 1)
+ }
+ if (lt->pntsw > 1) {
dw = 1.0f / ((float)lt->pntsw - 1);
+ }
for (w = 0; w < lt->pntsw; w++) {
@@ -985,10 +1045,13 @@ void outside_lattice(Lattice *lt)
else {
bp = lt->def;
- for (w = 0; w < lt->pntsw; w++)
- for (v = 0; v < lt->pntsv; v++)
- for (u = 0; u < lt->pntsu; u++, bp++)
+ for (w = 0; w < lt->pntsw; w++) {
+ for (v = 0; v < lt->pntsv; v++) {
+ for (u = 0; u < lt->pntsu; u++, bp++) {
bp->hide = 0;
+ }
+ }
+ }
}
}
@@ -998,8 +1061,9 @@ float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3]
int i, numVerts;
float(*vertexCos)[3];
- if (lt->editlatt)
+ if (lt->editlatt) {
lt = lt->editlatt->latt;
+ }
numVerts = *r_numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
vertexCos = MEM_mallocN(sizeof(*vertexCos) * numVerts, "lt_vcos");
@@ -1024,7 +1088,8 @@ void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3])
void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
{
Lattice *lt = ob->data;
- /* Get vertex coordinates from the original copy; otherwise we get already-modified coordinates. */
+ /* Get vertex coordinates from the original copy;
+ * otherwise we get already-modified coordinates. */
Object *ob_orig = DEG_get_original_object(ob);
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -1042,19 +1107,25 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!(mti->flags & eModifierTypeFlag_AcceptsLattice))
+ if (!(mti->flags & eModifierTypeFlag_AcceptsLattice)) {
continue;
- if (!(md->mode & eModifierMode_Realtime))
+ }
+ if (!(md->mode & eModifierMode_Realtime)) {
continue;
- if (editmode && !(md->mode & eModifierMode_Editmode))
+ }
+ if (editmode && !(md->mode & eModifierMode_Editmode)) {
continue;
- if (mti->isDisabled && mti->isDisabled(scene, md, 0))
+ }
+ if (mti->isDisabled && mti->isDisabled(scene, md, 0)) {
continue;
- if (mti->type != eModifierTypeType_OnlyDeform)
+ }
+ if (mti->type != eModifierTypeType_OnlyDeform) {
continue;
+ }
- if (!vertexCos)
+ if (!vertexCos) {
vertexCos = BKE_lattice_vertexcos_get(ob_orig, &numVerts);
+ }
mti->deformVerts(md, &mectx, NULL, vertexCos, numVerts);
}
@@ -1066,8 +1137,9 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec
}
else {
/* Displist won't do anything; this is just for posterity's sake until we remove it. */
- if (!vertexCos)
+ if (!vertexCos) {
vertexCos = BKE_lattice_vertexcos_get(ob_orig, &numVerts);
+ }
DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl");
dl->type = DL_VERTS;
@@ -1083,8 +1155,9 @@ struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *oblatt)
{
Lattice *lt = (Lattice *)oblatt->data;
BLI_assert(oblatt->type == OB_LATTICE);
- if (lt->editlatt)
+ if (lt->editlatt) {
lt = lt->editlatt->latt;
+ }
return lt->dvert;
}
@@ -1110,14 +1183,16 @@ void BKE_lattice_center_median(Lattice *lt, float cent[3])
{
int i, numVerts;
- if (lt->editlatt)
+ if (lt->editlatt) {
lt = lt->editlatt->latt;
+ }
numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
zero_v3(cent);
- for (i = 0; i < numVerts; i++)
+ for (i = 0; i < numVerts; i++) {
add_v3_v3(cent, lt->def[i].vec);
+ }
mul_v3_fl(cent, 1.0f / (float)numVerts);
}
@@ -1161,12 +1236,14 @@ void BKE_lattice_minmax_dl(Object *ob, Lattice *lt, float min[3], float max[3])
else {
int i, numVerts;
- if (lt->editlatt)
+ if (lt->editlatt) {
lt = lt->editlatt->latt;
+ }
numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
- for (i = 0; i < numVerts; i++)
+ for (i = 0; i < numVerts; i++) {
minmax_v3v3_v3(min, max, &dl->verts[i * 3]);
+ }
}
}
@@ -1174,12 +1251,14 @@ void BKE_lattice_minmax(Lattice *lt, float min[3], float max[3])
{
int i, numVerts;
- if (lt->editlatt)
+ if (lt->editlatt) {
lt = lt->editlatt->latt;
+ }
numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
- for (i = 0; i < numVerts; i++)
+ for (i = 0; i < numVerts; i++) {
minmax_v3v3_v3(min, max, lt->def[i].vec);
+ }
}
void BKE_lattice_center_bounds(Lattice *lt, float cent[3])
@@ -1220,13 +1299,17 @@ void BKE_lattice_translate(Lattice *lt, float offset[3], bool do_keys)
numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
- if (lt->def)
- for (i = 0; i < numVerts; i++)
+ if (lt->def) {
+ for (i = 0; i < numVerts; i++) {
add_v3_v3(lt->def[i].vec, offset);
+ }
+ }
- if (lt->editlatt)
- for (i = 0; i < numVerts; i++)
+ if (lt->editlatt) {
+ for (i = 0; i < numVerts; i++) {
add_v3_v3(lt->editlatt->latt->def[i].vec, offset);
+ }
+ }
if (do_keys && lt->key) {
KeyBlock *kb;
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 133deb13836..fc349e62809 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -35,7 +35,6 @@
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_object.h"
-#include "BKE_scene.h"
#include "DNA_ID.h"
#include "DNA_space_types.h"
@@ -91,7 +90,9 @@ static Base *object_base_new(Object *ob)
{
Base *base = MEM_callocN(sizeof(Base), "Object Base");
base->object = ob;
- BKE_scene_object_base_flag_sync_from_object(base);
+ if (ob->base_flag & BASE_SELECTED) {
+ base->flag |= BASE_SELECTED;
+ }
return base;
}
@@ -345,19 +346,14 @@ void BKE_view_layer_base_deselect_all(ViewLayer *view_layer)
}
}
-void BKE_view_layer_base_select(Base *selbase)
+void BKE_view_layer_base_select_and_set_active(struct ViewLayer *view_layer, Base *selbase)
{
+ view_layer->basact = selbase;
if ((selbase->flag & BASE_SELECTABLE) != 0) {
selbase->flag |= BASE_SELECTED;
}
}
-void BKE_view_layer_base_select_and_set_active(struct ViewLayer *view_layer, Base *selbase)
-{
- view_layer->basact = selbase;
- BKE_view_layer_base_select(selbase);
-}
-
/**************************** Copy View Layer and Layer Collections ***********************/
static void layer_collections_copy_data(ViewLayer *view_layer_dst,
@@ -450,8 +446,9 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
for (node = scene->nodetree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_R_LAYERS && node->id == NULL) {
- if (node->custom1 == index)
+ if (node->custom1 == index) {
BLI_strncpy(node->name, view_layer->name, NODE_MAXSTR);
+ }
}
}
}
@@ -1099,7 +1096,8 @@ static void layer_collection_bases_hide_recursive(ViewLayer *view_layer, LayerCo
/**
* Hide/show all the elements of a collection.
- * Don't change the collection children enable/disable state, but it may change it for the collection itself.
+ * Don't change the collection children enable/disable state,
+ * but it may change it for the collection itself.
*
* Return true if depsgraph needs update.
*/
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 4230ab313d0..ad0c405ab28 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -170,11 +170,14 @@ void id_lib_extern(ID *id)
}
}
-/* ensure we have a real user */
-/* Note: Now that we have flags, we could get rid of the 'fake_user' special case, flags are enough to ensure
- * we always have a real user.
- * However, ID_REAL_USERS is used in several places outside of core library.c, so think we can wait later
- * to make this change... */
+/**
+ * Ensure we have a real user
+ *
+ * \note Now that we have flags, we could get rid of the 'fake_user' special case,
+ * flags are enough to ensure we always have a real user.
+ * However, #ID_REAL_USERS is used in several places outside of core library.c,
+ * so think we can wait later to make this change.
+ */
void id_us_ensure_real(ID *id)
{
if (id) {
@@ -254,7 +257,8 @@ void id_us_min(ID *id)
}
if ((id->us == limit) && (id->tag & LIB_TAG_EXTRAUSER)) {
- /* We need an extra user here, but never actually incremented user count for it so far, do it now. */
+ /* We need an extra user here, but never actually incremented user count for it so far,
+ * do it now. */
id_us_ensure_real(id);
}
}
@@ -293,7 +297,8 @@ static int id_expand_local_callback(void *UNUSED(user_data),
return IDWALK_RET_NOP;
}
- /* Can happen that we get unlinkable ID here, e.g. with shapekey referring to itself (through drivers)...
+ /* Can happen that we get un-linkable ID here, e.g. with shape-key referring to itself
+ * (through drivers)...
* Just skip it, shape key can only be either indirectly linked, or fully local, period.
* And let's curse one more time that stupid useless shapekey ID type! */
if (*id_pointer && *id_pointer != id_self && BKE_idcode_is_linkable(GS((*id_pointer)->name))) {
@@ -304,7 +309,8 @@ static int id_expand_local_callback(void *UNUSED(user_data),
}
/**
- * Expand ID usages of given id as 'extern' (and no more indirect) linked data. Used by ID copy/make_local functions.
+ * Expand ID usages of given id as 'extern' (and no more indirect) linked data.
+ * Used by ID copy/make_local functions.
*/
void BKE_id_expand_local(Main *bmain, ID *id)
{
@@ -335,7 +341,8 @@ void BKE_id_make_local_generic(Main *bmain,
/* - only lib users: do nothing (unless force_local is set)
* - only local users: set flag
* - mixed: make copy
- * In case we make a whole lib's content local, we always want to localize, and we skip remapping (done later).
+ * In case we make a whole lib's content local,
+ * we always want to localize, and we skip remapping (done later).
*/
if (!ID_IS_LINKED(id)) {
@@ -352,7 +359,8 @@ void BKE_id_make_local_generic(Main *bmain,
else {
ID *id_new;
- /* Should not fail in expected usecases, but a few ID types cannot be copied (LIB, WM, SCR...). */
+ /* Should not fail in expected use cases,
+ * but a few ID types cannot be copied (LIB, WM, SCR...). */
if (BKE_id_copy(bmain, id, &id_new)) {
id_new->us = 0;
@@ -380,137 +388,169 @@ void BKE_id_make_local_generic(Main *bmain,
*
* \note Always set ID->newid pointer in case it gets duplicated...
*
- * \param lib_local: Special flag used when making a whole library's content local, it needs specific handling.
+ * \param lib_local: Special flag used when making a whole library's content local,
+ * it needs specific handling.
*
* \return true if the block can be made local.
*/
bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
{
- /* We don't care whether ID is directly or indirectly linked in case we are making a whole lib local... */
+ /* We don't care whether ID is directly or indirectly linked
+ * in case we are making a whole lib local... */
if (!lib_local && (id->tag & LIB_TAG_INDIRECT)) {
return false;
}
switch ((ID_Type)GS(id->name)) {
case ID_SCE:
- if (!test)
+ if (!test) {
BKE_scene_make_local(bmain, (Scene *)id, lib_local);
+ }
return true;
case ID_OB:
- if (!test)
+ if (!test) {
BKE_object_make_local(bmain, (Object *)id, lib_local);
+ }
return true;
case ID_ME:
- if (!test)
+ if (!test) {
BKE_mesh_make_local(bmain, (Mesh *)id, lib_local);
+ }
return true;
case ID_CU:
- if (!test)
+ if (!test) {
BKE_curve_make_local(bmain, (Curve *)id, lib_local);
+ }
return true;
case ID_MB:
- if (!test)
+ if (!test) {
BKE_mball_make_local(bmain, (MetaBall *)id, lib_local);
+ }
return true;
case ID_MA:
- if (!test)
+ if (!test) {
BKE_material_make_local(bmain, (Material *)id, lib_local);
+ }
return true;
case ID_TE:
- if (!test)
+ if (!test) {
BKE_texture_make_local(bmain, (Tex *)id, lib_local);
+ }
return true;
case ID_IM:
- if (!test)
+ if (!test) {
BKE_image_make_local(bmain, (Image *)id, lib_local);
+ }
return true;
case ID_LT:
- if (!test)
+ if (!test) {
BKE_lattice_make_local(bmain, (Lattice *)id, lib_local);
+ }
return true;
case ID_LA:
- if (!test)
+ if (!test) {
BKE_light_make_local(bmain, (Light *)id, lib_local);
+ }
return true;
case ID_CA:
- if (!test)
+ if (!test) {
BKE_camera_make_local(bmain, (Camera *)id, lib_local);
+ }
return true;
case ID_SPK:
- if (!test)
+ if (!test) {
BKE_speaker_make_local(bmain, (Speaker *)id, lib_local);
+ }
return true;
case ID_LP:
- if (!test)
+ if (!test) {
BKE_lightprobe_make_local(bmain, (LightProbe *)id, lib_local);
+ }
return true;
case ID_WO:
- if (!test)
+ if (!test) {
BKE_world_make_local(bmain, (World *)id, lib_local);
+ }
return true;
case ID_VF:
- if (!test)
+ if (!test) {
BKE_vfont_make_local(bmain, (VFont *)id, lib_local);
+ }
return true;
case ID_TXT:
- if (!test)
+ if (!test) {
BKE_text_make_local(bmain, (Text *)id, lib_local);
+ }
return true;
case ID_SO:
- if (!test)
+ if (!test) {
BKE_sound_make_local(bmain, (bSound *)id, lib_local);
+ }
return true;
case ID_GR:
- if (!test)
+ if (!test) {
BKE_collection_make_local(bmain, (Collection *)id, lib_local);
+ }
return true;
case ID_AR:
- if (!test)
+ if (!test) {
BKE_armature_make_local(bmain, (bArmature *)id, lib_local);
+ }
return true;
case ID_AC:
- if (!test)
+ if (!test) {
BKE_action_make_local(bmain, (bAction *)id, lib_local);
+ }
return true;
case ID_NT:
- if (!test)
+ if (!test) {
ntreeMakeLocal(bmain, (bNodeTree *)id, true, lib_local);
+ }
return true;
case ID_BR:
- if (!test)
+ if (!test) {
BKE_brush_make_local(bmain, (Brush *)id, lib_local);
+ }
return true;
case ID_PA:
- if (!test)
+ if (!test) {
BKE_particlesettings_make_local(bmain, (ParticleSettings *)id, lib_local);
+ }
return true;
case ID_GD:
- if (!test)
+ if (!test) {
BKE_gpencil_make_local(bmain, (bGPdata *)id, lib_local);
+ }
return true;
case ID_MC:
- if (!test)
+ if (!test) {
BKE_movieclip_make_local(bmain, (MovieClip *)id, lib_local);
+ }
return true;
case ID_MSK:
- if (!test)
+ if (!test) {
BKE_mask_make_local(bmain, (Mask *)id, lib_local);
+ }
return true;
case ID_LS:
- if (!test)
+ if (!test) {
BKE_linestyle_make_local(bmain, (FreestyleLineStyle *)id, lib_local);
+ }
return true;
case ID_PAL:
- if (!test)
+ if (!test) {
BKE_palette_make_local(bmain, (Palette *)id, lib_local);
+ }
return true;
case ID_PC:
- if (!test)
+ if (!test) {
BKE_paint_curve_make_local(bmain, (PaintCurve *)id, lib_local);
+ }
return true;
case ID_CF:
- if (!test)
+ if (!test) {
BKE_cachefile_make_local(bmain, (CacheFile *)id, lib_local);
+ }
return true;
case ID_WS:
case ID_SCR:
@@ -571,15 +611,18 @@ bool BKE_id_copy_is_allowed(const ID *id)
/**
* Generic entry point for copying a datablock (new API).
*
- * \note Copy is only affecting given data-block (no ID used by copied one will be affected, besides usercount).
- * There is only one exception, if LIB_ID_COPY_ACTIONS is defined, actions used by animdata will be duplicated.
+ * \note Copy is only affecting given data-block
+ * (no ID used by copied one will be affected, besides usercount).
+ * There is only one exception, if #LIB_ID_COPY_ACTIONS is defined,
+ * actions used by animdata will be duplicated.
*
* \note Usercount of new copy is always set to 1.
*
* \param bmain: Main database, may be NULL only if LIB_ID_CREATE_NO_MAIN is specified.
* \param id: Source datablock.
* \param r_newid: Pointer to new (copied) ID pointer.
- * \param flag: Set of copy options, see DNA_ID.h enum for details (leave to zero for default, full copy).
+ * \param flag: Set of copy options, see DNA_ID.h enum for details
+ * (leave to zero for default, full copy).
* \return False when copying that ID type is not supported, true otherwise.
*/
bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
@@ -818,7 +861,8 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
PointerRNA idptr;
if (id) {
- /* if property isn't editable, we're going to have an extra block hanging around until we save */
+ /* If property isn't editable,
+ * we're going to have an extra block hanging around until we save. */
if (RNA_property_editable(ptr, prop)) {
Main *bmain = CTX_data_main(C);
/* copy animation actions too */
@@ -1004,13 +1048,15 @@ void BKE_main_id_flag_listbase(ListBase *lb, const int flag, const bool value)
{
ID *id;
if (value) {
- for (id = lb->first; id; id = id->next)
+ for (id = lb->first; id; id = id->next) {
id->tag |= flag;
+ }
}
else {
const int nflag = ~flag;
- for (id = lb->first; id; id = id->next)
+ for (id = lb->first; id; id = id->next) {
id->tag &= nflag;
+ }
}
}
@@ -1340,7 +1386,9 @@ void *BKE_id_new(Main *bmain, const short type, const char *name)
return id;
}
-/** Generic helper to create a new temporary empty datablock of given type, *outside* of any Main database.
+/**
+ * Generic helper to create a new temporary empty datablock of given type,
+ * *outside* of any Main database.
*
* \param name: can be NULL, in which case we get default name for this ID type. */
void *BKE_id_new_nomain(const short type, const char *name)
@@ -1452,8 +1500,9 @@ void *BKE_libblock_copy_for_localize(const ID *id)
void BKE_library_free(Library *lib)
{
- if (lib->packedfile)
+ if (lib->packedfile) {
freePackedFile(lib->packedfile);
+ }
}
/* ***************** ID ************************ */
@@ -1501,8 +1550,9 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name)
/* do not test alphabetic! */
/* optimized */
if (idtest->name[2] == name[0]) {
- if (STREQ(name, idtest->name + 2))
+ if (STREQ(name, idtest->name + 2)) {
break;
+ }
}
}
}
@@ -1537,8 +1587,9 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
idtest = is_dupid(lb, id, name);
/* if there is no double, done */
- if (idtest == NULL)
+ if (idtest == NULL) {
return false;
+ }
/* we have a dup; need to make a new name */
/* quick check so we can reuse one of first MAX_IN_USE - 1 ids if vacant */
@@ -1567,10 +1618,12 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
STREQLEN(name, idtest->name + 2, left_len) &&
(BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len)) {
/* will get here at least once, otherwise is_dupid call above would have returned NULL */
- if (nrtest < MAX_IN_USE)
+ if (nrtest < MAX_IN_USE) {
in_use[nrtest] = true; /* mark as used */
- if (nr <= nrtest)
+ }
+ if (nr <= nrtest) {
nr = nrtest + 1; /* track largest unused */
+ }
}
}
/* At this point, 'nr' will typically be at least 1. (but not always) */
@@ -1578,9 +1631,10 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
/* decide which value of nr to use */
for (a = 0; a < MAX_IN_USE; a++) {
- if (a >= nr)
+ if (a >= nr) {
break; /* stop when we've checked up to biggest */ /* redundant check */
- if (!in_use[a]) { /* found an unused value */
+ }
+ if (!in_use[a]) { /* found an unused value */
nr = a;
/* can only be zero if all potential duplicate names had
* nonzero numeric suffixes, which means name itself has
@@ -1610,8 +1664,9 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
name[len--] = '\0';
idtest = is_dupid(lb, id, name);
}
- if (idtest == NULL)
+ if (idtest == NULL) {
return true;
+ }
/* otherwise just continue and use a number suffix */
}
@@ -1644,13 +1699,15 @@ bool BKE_id_new_name_validate(ListBase *lb, ID *id, const char *tname)
char name[MAX_ID_NAME - 2];
/* if library, don't rename */
- if (ID_IS_LINKED(id))
+ if (ID_IS_LINKED(id)) {
return false;
+ }
/* if no name given, use name of current ID
* else make a copy (tname args can be const) */
- if (tname == NULL)
+ if (tname == NULL) {
tname = id->name + 2;
+ }
BLI_strncpy(name, tname, sizeof(name));
@@ -1702,7 +1759,8 @@ void id_clear_lib_data_ex(Main *bmain, ID *id, const bool id_in_mainlist)
}
}
- /* Internal bNodeTree blocks inside datablocks also stores id->lib, make sure this stays in sync. */
+ /* Internal bNodeTree blocks inside datablocks also stores id->lib,
+ * make sure this stays in sync. */
if ((ntree = ntreeFromID(id))) {
id_clear_lib_data_ex(bmain, &ntree->id, false); /* Datablocks' nodetree is never in Main. */
}
@@ -1723,8 +1781,7 @@ void BKE_main_id_clear_newpoins(Main *bmain)
{
ID *id;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
id->newid = NULL;
id->tag &= ~LIB_TAG_NEW;
}
@@ -1748,14 +1805,15 @@ static void library_make_local_copying_check(ID *id,
/* Our oh-so-beloved 'from' pointers... */
if (entry->usage_flag & IDWALK_CB_LOOPBACK) {
- /* We totally disregard Object->proxy_from 'usage' here, this one would only generate fake positives. */
+ /* We totally disregard Object->proxy_from 'usage' here,
+ * this one would only generate fake positives. */
if (GS(par_id->name) == ID_OB) {
BLI_assert(((Object *)par_id)->proxy_from == (Object *)id);
continue;
}
- /* Shapekeys are considered 'private' to their owner ID here, and never tagged (since they cannot be linked),
- * so we have to switch effective parent to their owner. */
+ /* Shapekeys are considered 'private' to their owner ID here, and never tagged
+ * (since they cannot be linked), * so we have to switch effective parent to their owner. */
if (GS(par_id->name) == ID_KE) {
par_id = ((Key *)par_id)->from;
}
@@ -1769,8 +1827,9 @@ static void library_make_local_copying_check(ID *id,
if (BLI_gset_haskey(loop_tags, par_id)) {
/* We are in a 'dependency loop' of IDs, this does not say us anything, skip it.
* Note that this is the situation that can lead to archipelagoes of linked data-blocks
- * (since all of them have non-local users, they would all be duplicated, leading to a loop of unused
- * linked data-blocks that cannot be freed since they all use each other...). */
+ * (since all of them have non-local users, they would all be duplicated,
+ * leading to a loop of unused linked data-blocks that cannot be freed since they all use
+ * each other...). */
continue;
}
/* Else, recursively check that user ID. */
@@ -1778,10 +1837,12 @@ static void library_make_local_copying_check(ID *id,
}
if (par_id->tag & LIB_TAG_DOIT) {
- /* This user will be fully local in future, so far so good, nothing to do here but check next user. */
+ /* This user will be fully local in future, so far so good,
+ * nothing to do here but check next user. */
}
else {
- /* This user won't be fully local in future, so current ID won't be either. And we are done checking it. */
+ /* This user won't be fully local in future, so current ID won't be either.
+ * And we are done checking it. */
id->tag &= ~LIB_TAG_DOIT;
break;
}
@@ -1795,15 +1856,16 @@ static void library_make_local_copying_check(ID *id,
* \param bmain: Almost certainly global main.
* \param lib: If not NULL, only make local datablocks from this library.
* \param untagged_only: If true, only make local datablocks not tagged with LIB_TAG_PRE_EXISTING.
- * \param set_fake: If true, set fake user on all localized datablocks (except group and objects ones).
+ * \param set_fake: If true, set fake user on all localized data-blocks
+ * (except group and objects ones).
*/
-/* Note: Old (2.77) version was simply making (tagging) datablocks as local, without actually making any check whether
- * they were also indirectly used or not...
+/* Note: Old (2.77) version was simply making (tagging) data-blocks as local,
+ * without actually making any check whether * they were also indirectly used or not...
*
- * Current version uses regular id_make_local callback, with advanced pre-processing step to detect all cases of
- * IDs currently indirectly used, but which will be used by local data only once this function is finished.
- * This allows to avoid any unneeded duplication of IDs, and hence all time lost afterwards to remove
- * orphaned linked data-blocks...
+ * Current version uses regular id_make_local callback, with advanced pre-processing step to detect
+ * all cases of IDs currently indirectly used, but which will be used by local data only once this
+ * function is finished. This allows to avoid any unneeded duplication of IDs, and hence all time
+ * lost afterwards to remove orphaned linked data-blocks...
*/
void BKE_library_make_local(Main *bmain,
const Library *lib,
@@ -1834,8 +1896,8 @@ void BKE_library_make_local(Main *bmain,
for (int a = set_listbasepointers(bmain, lbarray); a--;) {
ID *id = lbarray[a]->first;
- /* Do not explicitly make local non-linkable IDs (shapekeys, in fact), they are assumed to be handled
- * by real datablocks responsible of them. */
+ /* Do not explicitly make local non-linkable IDs (shapekeys, in fact),
+ * they are assumed to be handled by real datablocks responsible of them. */
const bool do_skip = (id && !BKE_idcode_is_linkable(GS(id->name)));
for (; id; id = id->next) {
@@ -1849,14 +1911,17 @@ void BKE_library_make_local(Main *bmain,
if (id->lib == NULL) {
id->tag &= ~(LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW);
}
- /* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so its possible to tag data you don't want to
- * be made local, used for appending data, so any libdata already linked wont become local (very nasty
+ /* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so it's possible to tag data
+ * you don't want to be made local, used for appending data,
+ * so any libdata already linked wont become local (very nasty
* to discover all your links are lost after appending).
* Also, never ever make proxified objects local, would not make any sense. */
/* Some more notes:
* - Shapekeys are never tagged here (since they are not linkable).
- * - Nodetrees used in materials etc. have to be tagged manually, since they do not exist in Main (!).
- * This is ok-ish on 'make local' side of things (since those are handled by their 'owner' IDs),
+ * - Nodetrees used in materials etc. have to be tagged manually,
+ * since they do not exist in Main (!).
+ * This is ok-ish on 'make local' side of things
+ * (since those are handled by their 'owner' IDs),
* but complicates slightly the pre-processing of relations between IDs at step 2... */
else if (!do_skip && id->tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW) &&
ELEM(lib, NULL, id->lib) &&
@@ -1865,8 +1930,9 @@ void BKE_library_make_local(Main *bmain,
BLI_linklist_prepend_arena(&todo_ids, id, linklist_mem);
id->tag |= LIB_TAG_DOIT;
- /* Tag those nasty non-ID nodetrees, but do not add them to todo list, making them local is handled
- * by 'owner' ID. This is needed for library_make_local_copying_check() to work OK at step 2. */
+ /* Tag those nasty non-ID nodetrees,
+ * but do not add them to todo list, making them local is handled by 'owner' ID.
+ * This is needed for library_make_local_copying_check() to work OK at step 2. */
if (ntree != NULL) {
ntree->tag |= LIB_TAG_DOIT;
}
@@ -1883,8 +1949,9 @@ void BKE_library_make_local(Main *bmain,
TIMEIT_VALUE_PRINT(make_local);
#endif
- /* Step 2: Check which datablocks we can directly make local (because they are only used by already, or future,
- * local data), others will need to be duplicated. */
+ /* Step 2: Check which datablocks we can directly make local
+ * (because they are only used by already, or future, local data),
+ * others will need to be duplicated. */
GSet *loop_tags = BLI_gset_ptr_new(__func__);
for (LinkNode *it = todo_ids; it; it = it->next) {
library_make_local_copying_check(it->link, loop_tags, bmain->relations, done_ids);
@@ -1902,15 +1969,17 @@ void BKE_library_make_local(Main *bmain,
#endif
/* Step 3: Make IDs local, either directly (quick and simple), or using generic process,
- * which involves more complex checks and might instead create a local copy of original linked ID. */
+ * which involves more complex checks and might instead
+ * create a local copy of original linked ID. */
for (LinkNode *it = todo_ids, *it_next; it; it = it_next) {
it_next = it->next;
ID *id = it->link;
if (id->tag & LIB_TAG_DOIT) {
- /* We know all users of this object are local or will be made fully local, even if currently there are
- * some indirect usages. So instead of making a copy that we'll likely get rid of later, directly make
- * that data block local. Saves a tremendous amount of time with complex scenes... */
+ /* We know all users of this object are local or will be made fully local, even if currently
+ * there are some indirect usages. So instead of making a copy that we'll likely get rid of
+ * later, directly make that data block local.
+ * Saves a tremendous amount of time with complex scenes... */
id_clear_lib_data_ex(bmain, id, true);
BKE_id_expand_local(bmain, id);
id->tag &= ~LIB_TAG_DOIT;
@@ -1946,16 +2015,19 @@ void BKE_library_make_local(Main *bmain,
TIMEIT_VALUE_PRINT(make_local);
#endif
- /* At this point, we are done with directly made local IDs. Now we have to handle duplicated ones, since their
+ /* At this point, we are done with directly made local IDs.
+ * Now we have to handle duplicated ones, since their
* remaining linked original counterpart may not be needed anymore... */
todo_ids = NULL;
- /* Step 4: We have to remap local usages of old (linked) ID to new (local) ID in a separated loop,
+ /* Step 4: We have to remap local usages of old (linked) ID to new (local)
+ * ID in a separated loop,
* as lbarray ordering is not enough to ensure us we did catch all dependencies
* (e.g. if making local a parent object before its child...). See T48907. */
- /* TODO This is now the biggest step by far (in term of processing time). We may be able to gain here by
- * using again main->relations mapping, but... this implies BKE_libblock_remap & co to be able to update
- * main->relations on the fly. Have to think about it a bit more, and see whether new code is OK first, anyway. */
+ /* TODO This is now the biggest step by far (in term of processing time).
+ * We may be able to gain here by using again main->relations mapping, but...
+ * this implies BKE_libblock_remap & co to be able to update main->relations on the fly.
+ * Have to think about it a bit more, and see whether new code is OK first, anyway. */
for (LinkNode *it = copied_ids; it; it = it->next) {
ID *id = it->link;
@@ -2036,10 +2108,11 @@ void BKE_library_make_local(Main *bmain,
#endif
/* This is probably more of a hack than something we should do here, but...
- * Issue is, the whole copying + remapping done in complex cases above may leave pose channels of armatures
- * in complete invalid state (more precisely, the bone pointers of the pchans - very crappy cross-datablocks
- * relationship), se we tag it to be fully recomputed, but this does not seems to be enough in some cases,
- * and evaluation code ends up trying to evaluate a not-yet-updated armature object's deformations.
+ * Issue is, the whole copying + remapping done in complex cases above may leave pose-channels of
+ * armatures in complete invalid state (more precisely, the bone pointers of the pose-channels -
+ * very crappy cross-data-blocks relationship), se we tag it to be fully recomputed,
+ * but this does not seems to be enough in some cases, and evaluation code ends up trying to
+ * evaluate a not-yet-updated armature object's deformations.
* Try "make all local" in 04_01_H.lighting.blend from Agent327 without this, e.g. */
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->data != NULL && ob->type == OB_ARMATURE && ob->pose != NULL &&
@@ -2091,8 +2164,9 @@ void BLI_libblock_ensure_unique_name(Main *bmain, const char *name)
ID *idtest;
lb = which_libbase(bmain, GS(name));
- if (lb == NULL)
+ if (lb == NULL) {
return;
+ }
/* search for id */
idtest = BLI_findstring(lb, name + 2, offsetof(ID, name) + 2);
@@ -2119,7 +2193,8 @@ void BKE_libblock_rename(Main *bmain, ID *id, const char *name)
*
* \note Result is unique to a given ID type in a given Main database.
*
- * \param name: An allocated string of minimal length MAX_ID_FULL_NAME, will be filled with generated string.
+ * \param name: An allocated string of minimal length #MAX_ID_FULL_NAME,
+ * will be filled with generated string.
*/
void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id)
{
@@ -2138,12 +2213,14 @@ void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id)
}
/**
- * Generate full name of the data-block (without ID code, but with library if any), with a 3-character prefix prepended
- * indicating whether it comes from a library, is overriding, has a fake or no user, etc.
+ * Generate full name of the data-block (without ID code, but with library if any),
+ * with a 3-character prefix prepended indicating whether it comes from a library,
+ * is overriding, has a fake or no user, etc.
*
* \note Result is unique to a given ID type in a given Main database.
*
- * \param name: An allocated string of minimal length MAX_ID_FULL_NAME_UI, will be filled with generated string.
+ * \param name: An allocated string of minimal length #MAX_ID_FULL_NAME_UI,
+ * will be filled with generated string.
*/
void BKE_id_full_name_ui_prefix_get(char name[MAX_ID_FULL_NAME_UI], const ID *id)
{
@@ -2191,8 +2268,8 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
* outliner, and its not really supported but allow from here for now
* since making local could cause this to be directly linked - campbell
*/
- /* Never make paths relative to parent lib - reading code (blenloader) always set *all* lib->name relative to
- * current main, not to their parent for indirectly linked ones. */
+ /* Never make paths relative to parent lib - reading code (blenloader) always set *all*
+ * lib->name relative to current main, not to their parent for indirectly linked ones. */
const char *basepath = BKE_main_blendfile_path(bmain);
BLI_path_abs(lib->filepath, basepath);
}
diff --git a/source/blender/blenkernel/intern/library_idmap.c b/source/blender/blenkernel/intern/library_idmap.c
index d520df31a75..cc7e2e31d07 100644
--- a/source/blender/blenkernel/intern/library_idmap.c
+++ b/source/blender/blenkernel/intern/library_idmap.c
@@ -182,7 +182,8 @@ ID *BKE_main_idmap_lookup(struct IDNameLib_Map *id_map,
ID *BKE_main_idmap_lookup_id(struct IDNameLib_Map *id_map, const ID *id)
{
/* When used during undo/redo, this function cannot assume that given id points to valid memory
- * (i.e. has not been freed), so it has to check that it does exist in 'old' (aka current) Main database.
+ * (i.e. has not been freed),
+ * so it has to check that it does exist in 'old' (aka current) Main database.
* Otherwise, we cannot provide new ID pointer that way (would crash accessing freed memory
* when trying to get ID name).
*/
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c
index 7a29575dffe..5ed6577e90a 100644
--- a/source/blender/blenkernel/intern/library_override.c
+++ b/source/blender/blenkernel/intern/library_override.c
@@ -55,7 +55,8 @@ static void bke_override_property_operation_copy(IDOverrideStaticPropertyOperati
static void bke_override_property_clear(IDOverrideStaticProperty *op);
static void bke_override_property_operation_clear(IDOverrideStaticPropertyOperation *opop);
-/* Temp, for until static override is ready and tested enough to go 'public', we hide it by default in UI and such. */
+/* Temp, for until static override is ready and tested enough to go 'public',
+ * we hide it by default in UI and such. */
static bool _override_static_enabled = false;
void BKE_override_static_enable(const bool do_enable)
@@ -79,8 +80,9 @@ IDOverrideStatic *BKE_override_static_init(ID *local_id, ID *reference_id)
ID *ancestor_id;
for (ancestor_id = reference_id; ancestor_id != NULL && ancestor_id->override_static != NULL &&
ancestor_id->override_static->reference != NULL;
- ancestor_id = ancestor_id->override_static->reference)
+ ancestor_id = ancestor_id->override_static->reference) {
;
+ }
if (ancestor_id != NULL && ancestor_id->override_static != NULL) {
/* Original ID has a template, use it! */
@@ -188,7 +190,8 @@ ID *BKE_override_static_create_from_id(Main *bmain, ID *reference_id)
ID *local_id = override_static_create_from(bmain, reference_id);
- /* Remapping, we obviously only want to affect local data (and not our own reference pointer to overridden ID). */
+ /* Remapping, we obviously only want to affect local data
+ * (and not our own reference pointer to overridden ID). */
BKE_libblock_remap(
bmain, reference_id, local_id, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_STATIC_OVERRIDE);
@@ -197,8 +200,8 @@ ID *BKE_override_static_create_from_id(Main *bmain, ID *reference_id)
/** Create overridden local copies of all tagged data-blocks in given Main.
*
- * \note Set id->newid of overridden libs with newly created overrides, caller is responsible to clean those pointers
- * before/after usage as needed.
+ * \note Set id->newid of overridden libs with newly created overrides,
+ * caller is responsible to clean those pointers before/after usage as needed.
*
* \return \a true on success, \a false otherwise.
*/
@@ -207,8 +210,7 @@ bool BKE_override_static_create_from_tag(Main *bmain)
ID *reference_id;
bool ret = true;
- FOREACH_MAIN_ID_BEGIN(bmain, reference_id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, reference_id) {
if ((reference_id->tag & LIB_TAG_DOIT) != 0 && reference_id->lib != NULL) {
if ((reference_id->newid = override_static_create_from(bmain, reference_id)) == NULL) {
ret = false;
@@ -217,8 +219,7 @@ bool BKE_override_static_create_from_tag(Main *bmain)
}
FOREACH_MAIN_ID_END;
- FOREACH_MAIN_ID_BEGIN(bmain, reference_id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, reference_id) {
if ((reference_id->tag & LIB_TAG_DOIT) != 0 && reference_id->lib != NULL &&
reference_id->newid != NULL) {
ID *local_id = reference_id->newid;
@@ -475,11 +476,11 @@ void BKE_override_static_property_operation_delete(
/**
* Check that status of local data-block is still valid against current reference one.
*
- * It means that all overridable, but not overridden, properties' local values must be equal to reference ones.
- * Clears LIB_TAG_OVERRIDE_OK if they do not.
+ * It means that all overridable, but not overridden, properties' local values must be equal to
+ * reference ones. Clears #LIB_TAG_OVERRIDE_OK if they do not.
*
- * This is typically used to detect whether some property has been changed in local and a new IDOverrideProperty
- * (of IDOverridePropertyOperation) has to be added.
+ * This is typically used to detect whether some property has been changed in local and a new
+ * #IDOverrideProperty (of #IDOverridePropertyOperation) has to be added.
*
* \return true if status is OK, false otherwise. */
bool BKE_override_static_status_check_local(Main *bmain, ID *local)
@@ -522,7 +523,8 @@ bool BKE_override_static_status_check_local(Main *bmain, ID *local)
* It means that all non-overridden properties' local values must be equal to reference ones.
* Clears LIB_TAG_OVERRIDE_OK if they do not.
*
- * This is typically used to detect whether some reference has changed and local needs to be updated against it.
+ * This is typically used to detect whether some reference has changed and local
+ * needs to be updated against it.
*
* \return true if status is OK, false otherwise. */
bool BKE_override_static_status_check_reference(Main *bmain, ID *local)
@@ -570,12 +572,13 @@ bool BKE_override_static_status_check_reference(Main *bmain, ID *local)
* Compares local and reference data-blocks and create new override operations as needed,
* or reset to reference values if overriding is not allowed.
*
- * \note Defining override operations is only mandatory before saving a .blend file on disk (not for undo!).
+ * \note Defining override operations is only mandatory before saving a `.blend` file on disk
+ * (not for undo!).
* Knowing that info at runtime is only useful for UI/UX feedback.
*
- * \note This is by far the biggest operation (the more time-consuming) of the three so far, since it has to go over
- * all properties in depth (all overridable ones at least). Generating diff values and applying overrides
- * are much cheaper.
+ * \note This is by far the biggest operation (the more time-consuming) of the three so far,
+ * since it has to go over all properties in depth (all overridable ones at least).
+ * Generating diff values and applying overrides are much cheaper.
*
* \return true if new overriding op was created, or some local data was reset. */
bool BKE_override_static_operations_create(Main *bmain, ID *local, const bool force_auto)
@@ -620,8 +623,7 @@ void BKE_main_override_static_operations_create(Main *bmain, const bool force_au
{
ID *id;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
if (force_auto ||
(ID_IS_STATIC_OVERRIDE_AUTO(id) && (id->tag & LIB_TAG_OVERRIDESTATIC_AUTOREFRESH))) {
BKE_override_static_operations_create(bmain, id, force_auto);
@@ -644,19 +646,20 @@ void BKE_override_static_update(Main *bmain, ID *local)
BKE_override_static_update(bmain, local->override_static->reference);
}
- /* We want to avoid having to remap here, however creating up-to-date override is much simpler if based
- * on reference than on current override.
+ /* We want to avoid having to remap here, however creating up-to-date override is much simpler
+ * if based on reference than on current override.
* So we work on temp copy of reference, and 'swap' its content with local. */
/* XXX We need a way to get off-Main copies of IDs (similar to localized mats/texts/ etc.)!
- * However, this is whole bunch of code work in itself, so for now plain stupid ID copy will do,
- * as innefficient as it is. :/
- * Actually, maybe not! Since we are swapping with original ID's local content, we want to keep
- * usercount in correct state when freeing tmp_id (and that usercounts of IDs used by 'new' local data
- * also remain correct). */
- /* This would imply change in handling of usercout all over RNA (and possibly all over Blender code).
- * Not impossible to do, but would rather see first if extra useless usual user handling is actually
- * a (performances) issue here. */
+ * However, this is whole bunch of code work in itself, so for now plain stupid ID copy will
+ * do, as inn-efficient as it is. :/
+ * Actually, maybe not! Since we are swapping with original ID's local content, we want to
+ * keep user-count in correct state when freeing tmp_id
+ * (and that user-counts of IDs used by 'new' local data also remain correct). */
+ /* This would imply change in handling of usercout all over RNA
+ * (and possibly all over Blender code).
+ * Not impossible to do, but would rather see first if extra useless usual user handling
+ * is actually a (performances) issue here. */
ID *tmp_id;
BKE_id_copy(bmain, local->override_static->reference, &tmp_id);
@@ -676,11 +679,12 @@ void BKE_override_static_update(Main *bmain, ID *local)
RNA_struct_override_apply(
bmain, &rnaptr_dst, &rnaptr_src, rnaptr_storage, local->override_static);
- /* This also transfers all pointers (memory) owned by local to tmp_id, and vice-versa. So when we'll free tmp_id,
- * we'll actually free old, outdated data from local. */
+ /* This also transfers all pointers (memory) owned by local to tmp_id, and vice-versa.
+ * So when we'll free tmp_id, we'll actually free old, outdated data from local. */
BKE_id_swap(bmain, local, tmp_id);
- /* Again, horribly innefficient in our case, we need something off-Main (aka moar generic nolib copy/free stuff)! */
+ /* Again, horribly inn-efficient in our case, we need something off-Main
+ * (aka more generic nolib copy/free stuff)! */
/* XXX And crashing in complex cases (e.g. because depsgraph uses same data...). */
BKE_id_free_ex(bmain, tmp_id, LIB_ID_FREE_NO_UI_USER, true);
@@ -705,8 +709,7 @@ void BKE_main_override_static_update(Main *bmain)
{
ID *id;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
if (id->override_static != NULL && id->lib == NULL) {
BKE_override_static_update(bmain, id);
}
@@ -714,18 +717,21 @@ void BKE_main_override_static_update(Main *bmain)
FOREACH_MAIN_ID_END;
}
-/***********************************************************************************************************************
- * Storage (how to wtore overriding data into .blend files).
+/**
+ * Storage (how to store overriding data into `.blend` files).
*
* Basically:
- * I) Only 'differential' storage needs special handling here. All others (replacing values or
- * inserting/removing items from a collection) can be handled with simply storing current content of local data-block.
- * II) We store the differential value into a second 'ghost' data-block, which is an empty ID of same type as local one,
- * where we only define values that need differential data.
+ * 1) Only 'differential' storage needs special handling here. All others (replacing values or
+ * inserting/removing items from a collection) can be handled with simply storing current
+ * content of local data-block.
+ * 2) We store the differential value into a second 'ghost' data-block,
+ * which is an empty ID of same type as local one,
+ * where we only define values that need differential data.
*
- * This avoids us having to modify 'real' data-block at write time (and restoring it afterwards), which is inneficient,
- * and potentially dangerous (in case of concurrent access...), while not using much extra memory in typical cases.
- * It also ensures stored data-block always contains exact same data as "desired" ones (kind of "baked" data-blocks).
+ * This avoids us having to modify 'real' data-block at write time (and restoring it afterwards),
+ * which is inneficient, and potentially dangerous (in case of concurrent access...), while not
+ * using much extra memory in typical cases. It also ensures stored data-block always contains
+ * exact same data as "desired" ones (kind of "baked" data-blocks).
*/
/** Initialize an override storage. */
@@ -737,7 +743,8 @@ OverrideStaticStorage *BKE_override_static_operations_store_initialize(void)
/**
* Generate suitable 'write' data (this only affects differential override operations).
*
- * Note that \a local ID is no more modified by this call, all extra data are stored in its temp \a storage_id copy. */
+ * Note that \a local ID is no more modified by this call,
+ * all extra data are stored in its temp \a storage_id copy. */
ID *BKE_override_static_operations_store_start(Main *bmain,
OverrideStaticStorage *override_storage,
ID *local)
@@ -759,11 +766,13 @@ ID *BKE_override_static_operations_store_start(Main *bmain,
TIMEIT_START_AVERAGED(BKE_override_operations_store_start);
#endif
- /* XXX TODO We may also want a specialized handling of things here too, to avoid copying heavy never-overridable
- * data (like Mesh geometry etc.)? And also maybe avoid lib refcounting completely (shallow copy...). */
- /* This would imply change in handling of usercout all over RNA (and possibly all over Blender code).
- * Not impossible to do, but would rather see first is extra useless usual user handling is actually
- * a (performances) issue here, before doing it. */
+ /* XXX TODO We may also want a specialized handling of things here too, to avoid copying heavy
+ * never-overridable data (like Mesh geometry etc.)? And also maybe avoid lib reference-counting
+ * completely (shallow copy...). */
+ /* This would imply change in handling of user-count all over RNA
+ * (and possibly all over Blender code).
+ * Not impossible to do, but would rather see first is extra useless usual user handling is
+ * actually a (performances) issue here, before doing it. */
BKE_id_copy((Main *)override_storage, local, &storage_id);
if (storage_id != NULL) {
@@ -793,19 +802,18 @@ void BKE_override_static_operations_store_end(OverrideStaticStorage *UNUSED(over
{
BLI_assert(local->override_static != NULL);
- /* Nothing else to do here really, we need to keep all temp override storage data-blocks in memory until
- * whole file is written anyway (otherwise we'd get mem pointers overlap...). */
+ /* Nothing else to do here really, we need to keep all temp override storage data-blocks in
+ * memory until whole file is written anyway (otherwise we'd get mem pointers overlap...). */
local->override_static->storage = NULL;
}
void BKE_override_static_operations_store_finalize(OverrideStaticStorage *override_storage)
{
- /* We cannot just call BKE_main_free(override_storage), not until we have option to make 'ghost' copies of IDs
- * without increasing usercount of used data-blocks... */
+ /* We cannot just call BKE_main_free(override_storage), not until we have option to make 'ghost'
+ * copies of IDs without increasing usercount of used data-blocks. */
ID *id;
- FOREACH_MAIN_ID_BEGIN(override_storage, id)
- {
+ FOREACH_MAIN_ID_BEGIN (override_storage, id) {
BKE_id_free_ex(override_storage, id, LIB_ID_FREE_NO_UI_USER, true);
}
FOREACH_MAIN_ID_END;
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 7152c9786fb..d0515d8783d 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -161,8 +161,9 @@ static void library_foreach_idproperty_ID_link(LibraryForeachIDData *data,
IDProperty *prop,
int flag)
{
- if (!prop)
+ if (!prop) {
return;
+ }
switch (prop->type) {
case IDP_GROUP: {
@@ -351,8 +352,8 @@ static void library_foreach_ID_as_subdata_link(ID **id_pp,
BLI_assert(id == *id_pp);
if (flag & IDWALK_RECURSE) {
- /* Defer handling into main loop, recursively calling BKE_library_foreach_ID_link in IDWALK_RECURSE case is
- * troublesome, see T49553. */
+ /* Defer handling into main loop, recursively calling BKE_library_foreach_ID_link in
+ * IDWALK_RECURSE case is troublesome, see T49553. */
if (BLI_gset_add(data->ids_handled, id)) {
BLI_LINKSTACK_PUSH(data->ids_todo, id);
}
@@ -401,8 +402,8 @@ static void library_foreach_ID_link(Main *bmain,
/* inherit_data is non-NULL when this function is called for some sub-data ID
* (like root nodetree of a material).
- * In that case, we do not want to generate those 'generic flags' from our current sub-data ID (the node tree),
- * but re-use those generated for the 'owner' ID (the material)... */
+ * In that case, we do not want to generate those 'generic flags' from our current sub-data ID
+ * (the node tree), but re-use those generated for the 'owner' ID (the material). */
if (inherit_data == NULL) {
data.cb_flag = ID_IS_LINKED(id) ? IDWALK_CB_INDIRECT_USAGE : 0;
/* When an ID is not in Main database, it should never refcount IDs it is using.
@@ -415,10 +416,11 @@ static void library_foreach_ID_link(Main *bmain,
}
if (bmain != NULL && bmain->relations != NULL && (flag & IDWALK_READONLY)) {
- /* Note that this is minor optimization, even in worst cases (like id being an object with lots of
- * drivers and constraints and modifiers, or material etc. with huge node tree),
- * but we might as well use it (Main->relations is always assumed valid, it's responsibility of code
- * creating it to free it, especially if/when it starts modifying Main database). */
+ /* Note that this is minor optimization, even in worst cases (like id being an object with
+ * lots of drivers and constraints and modifiers, or material etc. with huge node tree),
+ * but we might as well use it (Main->relations is always assumed valid,
+ * it's responsibility of code creating it to free it,
+ * especially if/when it starts modifying Main database). */
MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->id_user_to_used, id);
for (; entry != NULL; entry = entry->next) {
FOREACH_CALLBACK_INVOKE_ID_PP(&data, entry->id_pointer, entry->usage_flag);
@@ -593,8 +595,8 @@ static void library_foreach_ID_link(Main *bmain,
CALLBACK_INVOKE(object->proxy_group, IDWALK_CB_NOP);
/* Special case!
- * Since this field is set/owned by 'user' of this ID (and not ID itself), it is only indirect usage
- * if proxy object is linked... Twisted. */
+ * Since this field is set/owned by 'user' of this ID (and not ID itself),
+ * it is only indirect usage if proxy object is linked... Twisted. */
if (object->proxy_from) {
data.cb_flag = ID_IS_LINKED(object->proxy_from) ? IDWALK_CB_INDIRECT_USAGE : 0;
}
@@ -1017,7 +1019,8 @@ static void library_foreach_ID_link(Main *bmain,
bScreen *screen = BKE_workspace_layout_screen_get(layout);
/* CALLBACK_INVOKE expects an actual pointer, not a variable holding the pointer.
- * However we can't access layout->screen here since we are outside the workspace project. */
+ * However we can't access layout->screen here
+ * since we are outside the workspace project. */
CALLBACK_INVOKE(screen, IDWALK_CB_USER);
/* allow callback to set a different screen */
BKE_workspace_layout_screen_set(layout, screen);
@@ -1095,11 +1098,12 @@ void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cb_flag)
/**
* Say whether given \a id_type_owner can use (in any way) a datablock of \a id_type_used.
*
- * This is a 'simplified' abstract version of #BKE_library_foreach_ID_link() above, quite useful to reduce
- * useless iterations in some cases.
+ * This is a 'simplified' abstract version of #BKE_library_foreach_ID_link() above,
+ * quite useful to reduce* useless iterations in some cases.
*/
-/* XXX This has to be fully rethink, basing check on ID type is not really working anymore (and even worth once
- * IDProps will support ID pointers), we'll have to do some quick checks on IDs themselves... */
+/* XXX This has to be fully rethink, basing check on ID type is not really working anymore
+ * (and even worth once IDProps will support ID pointers),
+ * we'll have to do some quick checks on IDs themselves... */
bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
{
/* any type of ID can be used in custom props. */
@@ -1119,7 +1123,8 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
}
if (BKE_animdata_from_id(id_owner)) {
- return true; /* AnimationData can use virtually any kind of datablocks, through drivers especially. */
+ /* AnimationData can use virtually any kind of datablocks, through drivers especially. */
+ return true;
}
switch ((ID_Type)id_type_owner) {
@@ -1240,10 +1245,16 @@ static int foreach_libblock_id_users_callback(void *user_data,
if (*id_p == iter->id) {
#if 0
- printf("%s uses %s (refcounted: %d, userone: %d, used_one: %d, used_one_active: %d, indirect_usage: %d)\n",
- iter->curr_id->name, iter->id->name, (cb_flag & IDWALK_USER) ? 1 : 0, (cb_flag & IDWALK_USER_ONE) ? 1 : 0,
- (iter->id->tag & LIB_TAG_EXTRAUSER) ? 1 : 0, (iter->id->tag & LIB_TAG_EXTRAUSER_SET) ? 1 : 0,
- (cb_flag & IDWALK_INDIRECT_USAGE) ? 1 : 0);
+ printf(
+ "%s uses %s (refcounted: %d, userone: %d, used_one: %d, used_one_active: %d, "
+ "indirect_usage: %d)\n",
+ iter->curr_id->name,
+ iter->id->name,
+ (cb_flag & IDWALK_USER) ? 1 : 0,
+ (cb_flag & IDWALK_USER_ONE) ? 1 : 0,
+ (iter->id->tag & LIB_TAG_EXTRAUSER) ? 1 : 0,
+ (iter->id->tag & LIB_TAG_EXTRAUSER_SET) ? 1 : 0,
+ (cb_flag & IDWALK_INDIRECT_USAGE) ? 1 : 0);
#endif
if (cb_flag & IDWALK_CB_INDIRECT_USAGE) {
iter->count_indirect++;
@@ -1260,8 +1271,8 @@ static int foreach_libblock_id_users_callback(void *user_data,
/**
* Return the number of times given \a id_user uses/references \a id_used.
*
- * \note This only checks for pointer references of an ID, shallow usages (like e.g. by RNA paths, as done
- * for FCurves) are not detected at all.
+ * \note This only checks for pointer references of an ID, shallow usages
+ * (like e.g. by RNA paths, as done for FCurves) are not detected at all.
*
* \param id_user: the ID which is supposed to use (reference) \a id_used.
* \param id_used: the ID which is supposed to be used (referenced) by \a id_user.
@@ -1332,7 +1343,8 @@ bool BKE_library_ID_is_indirectly_used(Main *bmain, void *idv)
}
/**
- * Combine #BKE_library_ID_is_locally_used() and #BKE_library_ID_is_indirectly_used() in a single call.
+ * Combine #BKE_library_ID_is_locally_used() and #BKE_library_ID_is_indirectly_used()
+ * in a single call.
*/
void BKE_library_ID_test_usages(Main *bmain, void *idv, bool *is_used_local, bool *is_used_linked)
{
@@ -1383,7 +1395,8 @@ static int foreach_libblock_used_linked_data_tag_clear_cb(void *user_data,
return IDWALK_RET_NOP;
}
- /* If checked id is used by an assumed used ID, then it is also used and not part of any linked archipelago. */
+ /* If checked id is used by an assumed used ID,
+ * then it is also used and not part of any linked archipelago. */
if (!(self_id->tag & LIB_TAG_DOIT) && ((*id_p)->tag & LIB_TAG_DOIT)) {
(*id_p)->tag &= ~LIB_TAG_DOIT;
*is_changed = true;
@@ -1394,20 +1407,20 @@ static int foreach_libblock_used_linked_data_tag_clear_cb(void *user_data,
}
/**
- * Detect orphaned linked data blocks (i.e. linked data not used (directly or indirectly) in any way by any local data),
- * including complex cases like 'linked archipelagoes', i.e. linked datablocks that use each other in loops,
- * which prevents their deletion by 'basic' usage checks...
+ * Detect orphaned linked data blocks (i.e. linked data not used (directly or indirectly)
+ * in any way by any local data), including complex cases like 'linked archipelagoes', i.e.
+ * linked datablocks that use each other in loops,
+ * which prevents their deletion by 'basic' usage checks.
*
- * \param do_init_tag: if \a true, all linked data are checked, if \a false, only linked datablocks already tagged with
- * LIB_TAG_DOIT are checked.
+ * \param do_init_tag: if \a true, all linked data are checked, if \a false,
+ * only linked datablocks already tagged with #LIB_TAG_DOIT are checked.
*/
void BKE_library_unused_linked_data_set_tag(Main *bmain, const bool do_init_tag)
{
ID *id;
if (do_init_tag) {
- FOREACH_MAIN_ID_BEGIN(bmain, id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
if (id->lib && (id->tag & LIB_TAG_INDIRECT) != 0) {
id->tag |= LIB_TAG_DOIT;
}
@@ -1420,8 +1433,7 @@ void BKE_library_unused_linked_data_set_tag(Main *bmain, const bool do_init_tag)
for (bool do_loop = true; do_loop;) {
do_loop = false;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
/* We only want to check that ID if it is currently known as used... */
if ((id->tag & LIB_TAG_DOIT) == 0) {
BKE_library_foreach_ID_link(
@@ -1434,9 +1446,11 @@ void BKE_library_unused_linked_data_set_tag(Main *bmain, const bool do_init_tag)
/**
* Untag linked data blocks used by other untagged linked datablocks.
- * Used to detect datablocks that we can forcefully make local (instead of copying them to later get rid of original):
- * All datablocks we want to make local are tagged by caller, after this function has ran caller knows datablocks still
- * tagged can directly be made local, since they are only used by other datablocks that will also be made fully local.
+ * Used to detect datablocks that we can forcefully make local
+ * (instead of copying them to later get rid of original):
+ * All datablocks we want to make local are tagged by caller,
+ * after this function has ran caller knows datablocks still tagged can directly be made local,
+ * since they are only used by other datablocks that will also be made fully local.
*/
void BKE_library_indirectly_used_data_tag_clear(Main *bmain)
{
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 9b6de945db8..3b6f11935d1 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -145,14 +145,18 @@ typedef struct IDRemap {
Main *bmain; /* Only used to trigger depsgraph updates in the right bmain. */
ID *old_id;
ID *new_id;
- ID *id; /* The ID in which we are replacing old_id by new_id usages. */
+ /** The ID in which we are replacing old_id by new_id usages. */
+ ID *id;
short flag;
/* 'Output' data. */
short status;
- int skipped_direct; /* Number of direct usecases that could not be remapped (e.g.: obdata when in edit mode). */
- int skipped_indirect; /* Number of indirect usecases that could not be remapped. */
- int skipped_refcounted; /* Number of skipped usecases that refcount the datablock. */
+ /** Number of direct usecases that could not be remapped (e.g.: obdata when in edit mode). */
+ int skipped_direct;
+ /** Number of indirect usecases that could not be remapped. */
+ int skipped_indirect;
+ /** Number of skipped usecases that refcount the datablock. */
+ int skipped_refcounted;
} IDRemap;
/* IDRemap->flag enums defined in BKE_library.h */
@@ -181,7 +185,8 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
}
if (*id_p && (*id_p == old_id)) {
- /* Better remap to NULL than not remapping at all, then we can handle it as a regular remap-to-NULL case... */
+ /* Better remap to NULL than not remapping at all,
+ * then we can handle it as a regular remap-to-NULL case. */
if ((cb_flag & IDWALK_CB_NEVER_SELF) && (new_id == id_self)) {
new_id = NULL;
}
@@ -190,8 +195,8 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
const bool is_indirect = (cb_flag & IDWALK_CB_INDIRECT_USAGE) != 0;
const bool skip_indirect = (id_remap_data->flag & ID_REMAP_SKIP_INDIRECT_USAGE) != 0;
/* Note: proxy usage implies LIB_TAG_EXTERN, so on this aspect it is direct,
- * on the other hand since they get reset to lib data on file open/reload it is indirect too...
- * Edit Mode is also a 'skip direct' case. */
+ * on the other hand since they get reset to lib data on file open/reload it is indirect too.
+ * Edit Mode is also a 'skip direct' case. */
const bool is_obj = (GS(id->name) == ID_OB);
const bool is_obj_proxy = (is_obj && (((Object *)id)->proxy || ((Object *)id)->proxy_group));
const bool is_obj_editmode = (is_obj && BKE_object_is_in_editmode((Object *)id));
@@ -276,8 +281,8 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
}
else if (cb_flag & IDWALK_CB_USER_ONE) {
id_us_ensure_real(new_id);
- /* We cannot affect old_id->us directly, LIB_TAG_EXTRAUSER(_SET) are assumed to be set as needed,
- * that extra user is processed in final handling... */
+ /* We cannot affect old_id->us directly, LIB_TAG_EXTRAUSER(_SET)
+ * are assumed to be set as needed, that extra user is processed in final handling. */
}
if (!is_indirect || is_obj_proxy) {
id_remap_data->status |= ID_REMAP_IS_LINKED_DIRECT;
@@ -296,15 +301,16 @@ static void libblock_remap_data_preprocess(IDRemap *r_id_remap_data)
if (!old_id || GS(old_id->name) == ID_AR) {
Object *ob = (Object *)r_id_remap_data->id;
/* Object's pose holds reference to armature bones... sic */
- /* Note that in theory, we should have to bother about linked/non-linked/never-null/etc. flags/states.
- * Fortunately, this is just a tag, so we can accept to 'over-tag' a bit for pose recalc, and avoid
- * another complex and risky condition nightmare like the one we have in
+ /* Note that in theory, we should have to bother about
+ * linked/non-linked/never-null/etc. flags/states.
+ * Fortunately, this is just a tag, so we can accept to 'over-tag' a bit for pose recalc,
+ * and avoid another complex and risky condition nightmare like the one we have in
* foreach_libblock_remap_callback()... */
if (ob->pose && (!old_id || ob->data == old_id)) {
BLI_assert(ob->type == OB_ARMATURE);
ob->pose->flag |= POSE_RECALC;
- /* We need to clear pose bone pointers immediately, things like undo writefile may be called
- * before pose is actually recomputed, can lead to segfault... */
+ /* We need to clear pose bone pointers immediately, things like undo writefile may be
+ * called before pose is actually recomputed, can lead to segfault... */
BKE_pose_clear_pointers(ob->pose);
}
}
@@ -315,7 +321,10 @@ static void libblock_remap_data_preprocess(IDRemap *r_id_remap_data)
}
}
-/* Can be called with both old_ob and new_ob being NULL, this means we have to check whole Main database then. */
+/**
+ * Can be called with both old_ob and new_ob being NULL,
+ * this means we have to check whole Main database then.
+ */
static void libblock_remap_data_postprocess_object_update(Main *bmain,
Object *old_ob,
Object *new_ob)
@@ -354,8 +363,8 @@ static void libblock_remap_data_postprocess_collection_update(Main *bmain,
{
if (new_collection == NULL) {
/* XXX Complex cases can lead to NULL pointers in other collections than old_collection,
- * and BKE_main_collection_sync_remap() does not tolerate any of those, so for now always check whole
- * existing collections for NULL pointers.
+ * and BKE_main_collection_sync_remap() does not tolerate any of those, so for now always check
+ * whole existing collections for NULL pointers.
* I'd consider optimizing that whole collection remapping process a TODO for later. */
BKE_collections_child_remove_nulls(bmain, NULL /*old_collection*/);
}
@@ -383,15 +392,8 @@ static void libblock_remap_data_postprocess_obdata_relink(Main *bmain, Object *o
static void libblock_remap_data_postprocess_nodetree_update(Main *bmain, ID *new_id)
{
- /* Verify all nodetree user nodes. */
- ntreeVerifyNodes(bmain, new_id);
-
- /* Update node trees as necessary. */
- FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
- /* make an update call for the tree */
- ntreeUpdateTree(bmain, ntree);
- }
- FOREACH_NODETREE_END;
+ /* Update all group nodes using a node group. */
+ ntreeUpdateAllUsers(bmain, new_id);
}
/**
@@ -399,18 +401,22 @@ static void libblock_remap_data_postprocess_nodetree_update(Main *bmain, ID *new
*
* Behavior differs depending on whether given \a id is NULL or not:
* - \a id NULL: \a old_id must be non-NULL, \a new_id may be NULL (unlinking \a old_id) or not
- * (remapping \a old_id to \a new_id). The whole \a bmain database is checked, and all pointers to \a old_id
+ * (remapping \a old_id to \a new_id).
+ * The whole \a bmain database is checked, and all pointers to \a old_id
* are remapped to \a new_id.
* - \a id is non-NULL:
- * + If \a old_id is NULL, \a new_id must also be NULL, and all ID pointers from \a id are cleared (i.e. \a id
- * does not references any other datablock anymore).
+ * + If \a old_id is NULL, \a new_id must also be NULL,
+ * and all ID pointers from \a id are cleared
+ * (i.e. \a id does not references any other datablock anymore).
* + If \a old_id is non-NULL, behavior is as with a NULL \a id, but only within given \a id.
*
* \param bmain: the Main data storage to operate on (must never be NULL).
- * \param id: the datablock to operate on (can be NULL, in which case we operate over all IDs from given bmain).
+ * \param id: the datablock to operate on
+ * (can be NULL, in which case we operate over all IDs from given bmain).
* \param old_id: the datablock to dereference (may be NULL if \a id is non-NULL).
* \param new_id: the new datablock to replace \a old_id references with (may be NULL).
- * \param r_id_remap_data: if non-NULL, the IDRemap struct to use (uselful to retrieve info about remapping process).
+ * \param r_id_remap_data: if non-NULL, the IDRemap struct to use
+ * (uselful to retrieve info about remapping process).
*/
ATTR_NONNULL(1)
static void libblock_remap_data(
@@ -444,15 +450,15 @@ static void libblock_remap_data(
NULL, id, foreach_libblock_remap_callback, (void *)r_id_remap_data, foreach_id_flags);
}
else {
- /* Note that this is a very 'brute force' approach, maybe we could use some depsgraph to only process
- * objects actually using given old_id... sounds rather unlikely currently, though, so this will do for now. */
+ /* Note that this is a very 'brute force' approach,
+ * maybe we could use some depsgraph to only process objects actually using given old_id...
+ * sounds rather unlikely currently, though, so this will do for now. */
ID *id_curr;
- FOREACH_MAIN_ID_BEGIN(bmain, id_curr)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id_curr) {
if (BKE_library_id_can_use_idtype(id_curr, GS(old_id->name))) {
- /* Note that we cannot skip indirect usages of old_id here (if requested), we still need to check it for
- * the user count handling...
+ /* Note that we cannot skip indirect usages of old_id here (if requested),
+ * we still need to check it for the user count handling...
* XXX No more true (except for debug usage of those skipping counters). */
r_id_remap_data->id = id_curr;
libblock_remap_data_preprocess(r_id_remap_data);
@@ -466,8 +472,9 @@ static void libblock_remap_data(
FOREACH_MAIN_ID_END;
}
- /* XXX We may not want to always 'transfer' fakeuser from old to new id... Think for now it's desired behavior
- * though, we can always add an option (flag) to control this later if needed. */
+ /* XXX We may not want to always 'transfer' fakeuser from old to new id...
+ * Think for now it's desired behavior though,
+ * we can always add an option (flag) to control this later if needed. */
if (old_id && (old_id->flag & LIB_FAKEUSER)) {
id_fake_user_clear(old_id);
id_fake_user_set(new_id);
@@ -512,7 +519,8 @@ void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const
}
/* We assume editors do not hold references to their IDs... This is false in some cases
- * (Image is especially tricky here), editors' code is to handle refcount (id->us) itself then. */
+ * (Image is especially tricky here),
+ * editors' code is to handle refcount (id->us) itself then. */
if (remap_editor_id_reference_cb) {
remap_editor_id_reference_cb(old_id, new_id);
}
@@ -520,9 +528,9 @@ void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const
skipped_direct = id_remap_data.skipped_direct;
skipped_refcounted = id_remap_data.skipped_refcounted;
- /* If old_id was used by some ugly 'user_one' stuff (like Image or Clip editors...), and user count has actually
- * been incremented for that, we have to decrease once more its user count... unless we had to skip
- * some 'user_one' cases. */
+ /* If old_id was used by some ugly 'user_one' stuff (like Image or Clip editors...), and user
+ * count has actually been incremented for that, we have to decrease once more its user count...
+ * unless we had to skip some 'user_one' cases. */
if ((old_id->tag & LIB_TAG_EXTRAUSER_SET) &&
!(id_remap_data.status & ID_REMAP_IS_USER_ONE_SKIPPED)) {
id_us_clear_real(old_id);
@@ -549,8 +557,8 @@ void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const
}
/* Some after-process updates.
- * This is a bit ugly, but cannot see a way to avoid it. Maybe we should do a per-ID callback for this instead?
- */
+ * This is a bit ugly, but cannot see a way to avoid it.
+ * Maybe we should do a per-ID callback for this instead? */
switch (GS(old_id->name)) {
case ID_OB:
libblock_remap_data_postprocess_object_update(bmain, (Object *)old_id, (Object *)new_id);
@@ -594,10 +602,11 @@ void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, const short r
}
/**
- * Unlink given \a id from given \a bmain (does not touch to indirect, i.e. library, usages of the ID).
+ * Unlink given \a id from given \a bmain
+ * (does not touch to indirect, i.e. library, usages of the ID).
*
- * \param do_flag_never_null: If true, all IDs using \a idv in a 'non-NULL' way are flagged by \a LIB_TAG_DOIT flag
- * (quite obviously, 'non-NULL' usages can never be unlinked by this function...).
+ * \param do_flag_never_null: If true, all IDs using \a idv in a 'non-NULL' way are flagged by
+ * #LIB_TAG_DOIT flag (quite obviously, 'non-NULL' usages can never be unlinked by this function).
*/
void BKE_libblock_unlink(Main *bmain,
void *idv,
@@ -652,7 +661,8 @@ void BKE_libblock_relink_ex(
libblock_remap_data(bmain, id, old_id, new_id, remap_flags, NULL);
/* Some after-process updates.
- * This is a bit ugly, but cannot see a way to avoid it. Maybe we should do a per-ID callback for this instead?
+ * This is a bit ugly, but cannot see a way to avoid it.
+ * Maybe we should do a per-ID callback for this instead?
*/
switch (GS(id->name)) {
case ID_SCE: {
@@ -711,14 +721,18 @@ static int id_relink_to_newid_looper(void *UNUSED(user_data),
return IDWALK_RET_NOP;
}
-/** Similar to libblock_relink_ex, but is remapping IDs to their newid value if non-NULL, in given \a id.
+/**
+ * Similar to #libblock_relink_ex,
+ * but is remapping IDs to their newid value if non-NULL, in given \a id.
*
- * Very specific usage, not sure we'll keep it on the long run, currently only used in Object/Collection duplication code...
+ * Very specific usage, not sure we'll keep it on the long run,
+ * currently only used in Object/Collection duplication code...
*/
void BKE_libblock_relink_to_newid(ID *id)
{
- if (ID_IS_LINKED(id))
+ if (ID_IS_LINKED(id)) {
return;
+ }
BKE_library_foreach_ID_link(NULL, id, id_relink_to_newid_looper, NULL, 0);
}
@@ -734,7 +748,8 @@ void BKE_libblock_free_data(ID *id, const bool do_id_user)
BKE_override_static_free(&id->override_static);
}
- /* XXX TODO remove animdata handling from each type's freeing func, and do it here, like for copy! */
+ /* XXX TODO remove animdata handling from each type's freeing func,
+ * and do it here, like for copy! */
}
void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
@@ -823,8 +838,9 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
BKE_particlesettings_free((ParticleSettings *)id);
break;
case ID_WM:
- if (free_windowmanager_cb)
+ if (free_windowmanager_cb) {
free_windowmanager_cb(NULL, (wmWindowManager *)id);
+ }
break;
case ID_GD:
BKE_gpencil_free((bGPdata *)id, true);
@@ -860,13 +876,14 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
* At that point, given id is assumed to not be used by any other data-block already
* (might not be actually true, in case e.g. several inter-related IDs get freed together...).
* However, they might still be using (referencing) other IDs, this code takes care of it if
- * \a LIB_TAG_NO_USER_REFCOUNT is not defined.
+ * #LIB_TAG_NO_USER_REFCOUNT is not defined.
*
- * \param bmain: Main database containing the freed ID, can be NULL in case it's a temp ID outside of any Main.
+ * \param bmain: #Main database containing the freed #ID,
+ * can be NULL in case it's a temp ID outside of any #Main.
* \param idv: Pointer to ID to be freed.
* \param flag: Set of \a LIB_ID_FREE_... flags controlling/overriding usual freeing process,
* 0 to get default safe behavior.
- * \param use_flag_from_idtag: Still use freeing info flags from given ID datablock,
+ * \param use_flag_from_idtag: Still use freeing info flags from given #ID datablock,
* even if some overriding ones are passed in \a flag parameter.
*/
void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_idtag)
@@ -957,7 +974,8 @@ void BKE_id_free_ex(Main *bmain, void *idv, int flag, const bool use_flag_from_i
*
* See #BKE_id_free_ex description for full details.
*
- * \param bmain: Main database containing the freed ID, can be NULL in case it's a temp ID outside of any Main.
+ * \param bmain: Main database containing the freed ID,
+ * can be NULL in case it's a temp ID outside of any Main.
* \param idv: Pointer to ID to be freed.
*/
void BKE_id_free(Main *bmain, void *idv)
@@ -966,7 +984,8 @@ void BKE_id_free(Main *bmain, void *idv)
}
/**
- * Not really a freeing function by itself, it decrements usercount of given id, and only frees it if it reaches 0.
+ * Not really a freeing function by itself,
+ * it decrements usercount of given id, and only frees it if it reaches 0.
*/
void BKE_id_free_us(Main *bmain, void *idv) /* test users */
{
@@ -974,12 +993,13 @@ void BKE_id_free_us(Main *bmain, void *idv) /* test users */
id_us_min(id);
- /* XXX This is a temp (2.77) hack so that we keep same behavior as in 2.76 regarding collections when deleting an object.
- * Since only 'user_one' usage of objects is collections, and only 'real user' usage of objects is scenes,
- * removing that 'user_one' tag when there is no more real (scene) users of an object ensures it gets
- * fully unlinked.
+ /* XXX This is a temp (2.77) hack so that we keep same behavior as in 2.76 regarding collections
+ * when deleting an object. Since only 'user_one' usage of objects is collections,
+ * and only 'real user' usage of objects is scenes, removing that 'user_one' tag when there
+ * is no more real (scene) users of an object ensures it gets fully unlinked.
* But only for local objects, not linked ones!
- * Otherwise, there is no real way to get rid of an object anymore - better handling of this is TODO.
+ * Otherwise, there is no real way to get rid of an object anymore -
+ * better handling of this is TODO.
*/
if ((GS(id->name) == ID_OB) && (id->us == 1) && (id->lib == NULL)) {
id_us_clear_real(id);
@@ -1036,8 +1056,9 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
if ((id->tag & tag) || (id->lib != NULL && (id->lib->id.tag & tag))) {
BLI_remlink(lb, id);
BLI_addtail(&tagged_deleted_ids, id);
- /* Do not tag as no_main now, we want to unlink it first (lower-level ID management code
- * has some specific handling of 'nom main' IDs that would be a problem in that case). */
+ /* Do not tag as no_main now, we want to unlink it first (lower-level ID management
+ * code has some specific handling of 'nom main'
+ * IDs that would be a problem in that case). */
id->tag |= tag;
keep_looping = true;
}
@@ -1049,24 +1070,28 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
}
for (id = last_remapped_id->next; id; id = id->next) {
/* Will tag 'never NULL' users of this ID too.
- * Note that we cannot use BKE_libblock_unlink() here, since it would ignore indirect (and proxy!)
+ * Note that we cannot use BKE_libblock_unlink() here,
+ * since it would ignore indirect (and proxy!)
* links, this can lead to nasty crashing here in second, actual deleting loop.
* Also, this will also flag users of deleted data that cannot be unlinked
* (object using deleted obdata, etc.), so that they also get deleted. */
BKE_libblock_remap_locked(
bmain, id, NULL, ID_REMAP_FLAG_NEVER_NULL_USAGE | ID_REMAP_FORCE_NEVER_NULL_USAGE);
- /* Since we removed ID from Main, we also need to unlink its own other IDs usages ourself. */
+ /* Since we removed ID from Main,
+ * we also need to unlink its own other IDs usages ourself. */
BKE_libblock_relink_ex(bmain, id, NULL, NULL, true);
/* Now we can safely mark that ID as not being in Main database anymore. */
id->tag |= LIB_TAG_NO_MAIN;
- /* This is needed because we may not have remapped usages of that ID by other deleted ones. */
- // id->us = 0; /* Is it actually? */
+ /* This is needed because we may not have remapped usages
+ * of that ID by other deleted ones. */
+ // id->us = 0; /* Is it actually? */
}
}
}
else {
/* First tag all datablocks directly from target lib.
- * Note that we go forward here, since we want to check dependencies before users (e.g. meshes before objects).
+ * Note that we go forward here, since we want to check dependencies before users
+ * (e.g. meshes before objects).
* Avoids to have to loop twice. */
for (i = 0; i < base_count; i++) {
ListBase *lb = lbarray[i];
@@ -1079,8 +1104,9 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
id->tag |= tag;
/* Will tag 'never NULL' users of this ID too.
- * Note that we cannot use BKE_libblock_unlink() here, since it would ignore indirect (and proxy!)
- * links, this can lead to nasty crashing here in second, actual deleting loop.
+ * Note that we cannot use BKE_libblock_unlink() here, since it would ignore indirect
+ * (and proxy!) links, this can lead to nasty crashing here in second,
+ * actual deleting loop.
* Also, this will also flag users of deleted data that cannot be unlinked
* (object using deleted obdata, etc.), so that they also get deleted. */
BKE_libblock_remap_locked(
@@ -1091,8 +1117,9 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
}
BKE_main_unlock(bmain);
- /* In usual reversed order, such that all usage of a given ID, even 'never NULL' ones, have been already cleared
- * when we reach it (e.g. Objects being processed before meshes, they'll have already released their 'reference'
+ /* In usual reversed order, such that all usage of a given ID, even 'never NULL' ones,
+ * have been already cleared when we reach it
+ * (e.g. Objects being processed before meshes, they'll have already released their 'reference'
* over meshes when we come to freeing obdata). */
for (i = do_tagged_deletion ? 1 : base_count; i--;) {
ListBase *lb = lbarray[i];
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index f0943bc2749..05b2eb82daf 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -96,8 +96,10 @@ Light *BKE_light_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Light ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Light ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -144,8 +146,9 @@ Light *BKE_light_localize(Light *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
- if (la->nodetree)
+ if (la->nodetree) {
lan->nodetree = ntreeLocalize(la->nodetree);
+ }
lan->preview = NULL;
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index 6b1951498cc..5e6d298adbf 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -60,8 +60,10 @@ void *BKE_lightprobe_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of LightProbe ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of LightProbe ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index a0cfe7dfe41..31e6d2e89e5 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -136,19 +136,25 @@ void BKE_linestyle_free(FreestyleLineStyle *linestyle)
linestyle->nodetree = NULL;
}
- while ((m = (LineStyleModifier *)linestyle->color_modifiers.first))
+ while ((m = (LineStyleModifier *)linestyle->color_modifiers.first)) {
BKE_linestyle_color_modifier_remove(linestyle, m);
- while ((m = (LineStyleModifier *)linestyle->alpha_modifiers.first))
+ }
+ while ((m = (LineStyleModifier *)linestyle->alpha_modifiers.first)) {
BKE_linestyle_alpha_modifier_remove(linestyle, m);
- while ((m = (LineStyleModifier *)linestyle->thickness_modifiers.first))
+ }
+ while ((m = (LineStyleModifier *)linestyle->thickness_modifiers.first)) {
BKE_linestyle_thickness_modifier_remove(linestyle, m);
- while ((m = (LineStyleModifier *)linestyle->geometry_modifiers.first))
+ }
+ while ((m = (LineStyleModifier *)linestyle->geometry_modifiers.first)) {
BKE_linestyle_geometry_modifier_remove(linestyle, m);
+ }
}
/**
- * Only copy internal data of Linestyle ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Linestyle ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -426,8 +432,9 @@ LineStyleModifier *BKE_linestyle_color_modifier_copy(FreestyleLineStyle *linesty
int BKE_linestyle_color_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
{
- if (BLI_findindex(&linestyle->color_modifiers, m) == -1)
+ if (BLI_findindex(&linestyle->color_modifiers, m) == -1) {
return -1;
+ }
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
MEM_freeN(((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
@@ -601,8 +608,9 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty
m;
LineStyleAlphaModifier_DistanceFromObject *q = (LineStyleAlphaModifier_DistanceFromObject *)
new_m;
- if (p->target)
+ if (p->target) {
id_us_plus(&p->target->id);
+ }
q->target = p->target;
q->curve = curvemapping_copy(p->curve);
q->flags = p->flags;
@@ -663,8 +671,9 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty
int BKE_linestyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
{
- if (BLI_findindex(&linestyle->alpha_modifiers, m) == -1)
+ if (BLI_findindex(&linestyle->alpha_modifiers, m) == -1) {
return -1;
+ }
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
curvemapping_free(((LineStyleAlphaModifier_AlongStroke *)m)->curve);
@@ -835,8 +844,9 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin
LineStyleModifier *new_m;
new_m = alloc_thickness_modifier(m->name, m->type);
- if (!new_m)
+ if (!new_m) {
return NULL;
+ }
new_m->influence = m->influence;
new_m->flags = m->flags;
new_m->blend = m->blend;
@@ -950,8 +960,9 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin
int BKE_linestyle_thickness_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
{
- if (BLI_findindex(&linestyle->thickness_modifiers, m) == -1)
+ if (BLI_findindex(&linestyle->thickness_modifiers, m) == -1) {
return -1;
+ }
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
curvemapping_free(((LineStyleThicknessModifier_AlongStroke *)m)->curve);
@@ -1290,8 +1301,9 @@ LineStyleModifier *BKE_linestyle_geometry_modifier_copy(FreestyleLineStyle *line
int BKE_linestyle_geometry_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m)
{
- if (BLI_findindex(&linestyle->geometry_modifiers, m) == -1)
+ if (BLI_findindex(&linestyle->geometry_modifiers, m) == -1) {
return -1;
+ }
BLI_freelinkN(&linestyle->geometry_modifiers, m);
return 0;
}
@@ -1364,36 +1376,44 @@ char *BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle, ColorBand
for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
- if (color_ramp == ((LineStyleColorModifier_AlongStroke *)m)->color_ramp)
+ if (color_ramp == ((LineStyleColorModifier_AlongStroke *)m)->color_ramp) {
found = true;
+ }
break;
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- if (color_ramp == ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp)
+ if (color_ramp == ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp) {
found = true;
+ }
break;
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- if (color_ramp == ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp)
+ if (color_ramp == ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp) {
found = true;
+ }
break;
case LS_MODIFIER_MATERIAL:
- if (color_ramp == ((LineStyleColorModifier_Material *)m)->color_ramp)
+ if (color_ramp == ((LineStyleColorModifier_Material *)m)->color_ramp) {
found = true;
+ }
break;
case LS_MODIFIER_TANGENT:
- if (color_ramp == ((LineStyleColorModifier_Tangent *)m)->color_ramp)
+ if (color_ramp == ((LineStyleColorModifier_Tangent *)m)->color_ramp) {
found = true;
+ }
break;
case LS_MODIFIER_NOISE:
- if (color_ramp == ((LineStyleColorModifier_Noise *)m)->color_ramp)
+ if (color_ramp == ((LineStyleColorModifier_Noise *)m)->color_ramp) {
found = true;
+ }
break;
case LS_MODIFIER_CREASE_ANGLE:
- if (color_ramp == ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp)
+ if (color_ramp == ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp) {
found = true;
+ }
break;
case LS_MODIFIER_CURVATURE_3D:
- if (color_ramp == ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp)
+ if (color_ramp == ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp) {
found = true;
+ }
break;
}
diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c
index ef196430da7..e50e37c5428 100644
--- a/source/blender/blenkernel/intern/main.c
+++ b/source/blender/blenkernel/intern/main.c
@@ -56,7 +56,8 @@ void BKE_main_free(Main *mainvar)
ListBase *lbarray[MAX_LIBARRAY];
int a;
- /* Since we are removing whole main, no need to bother 'properly' (and slowly) removing each ID from it. */
+ /* Since we are removing whole main, no need to bother 'properly'
+ * (and slowly) removing each ID from it. */
const int free_flag = (LIB_ID_FREE_NO_MAIN | LIB_ID_FREE_NO_UI_USER |
LIB_ID_FREE_NO_USER_REFCOUNT | LIB_ID_FREE_NO_DEG_TAG);
@@ -260,8 +261,7 @@ void BKE_main_relations_create(Main *bmain)
sizeof(MainIDRelationsEntry), 128, 128, BLI_MEMPOOL_NOP);
ID *id;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
BKE_library_foreach_ID_link(
NULL, id, main_relations_create_idlink_cb, bmain->relations, IDWALK_READONLY);
}
@@ -286,7 +286,8 @@ void BKE_main_relations_free(Main *bmain)
/**
* Create a GSet storing all IDs present in given \a bmain, by their pointers.
*
- * \param gset: If not NULL, given GSet will be extended with IDs from given \a bmain, instead of creating a new one.
+ * \param gset: If not NULL, given GSet will be extended with IDs from given \a bmain,
+ * instead of creating a new one.
*/
GSet *BKE_main_gset_create(Main *bmain, GSet *gset)
{
@@ -295,8 +296,7 @@ GSet *BKE_main_gset_create(Main *bmain, GSet *gset)
}
ID *id;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
BLI_gset_add(gset, id);
}
FOREACH_MAIN_ID_END;
@@ -350,8 +350,8 @@ ImBuf *BKE_main_thumbnail_to_imbuf(Main *bmain, BlendThumbnail *data)
}
if (data) {
- /* Note: we cannot use IMB_allocFromBuffer(), since it tries to dupalloc passed buffer, which will fail
- * here (we do not want to pass the first two ints!). */
+ /* Note: we cannot use IMB_allocFromBuffer(), since it tries to dupalloc passed buffer,
+ * which will fail here (we do not want to pass the first two ints!). */
img = IMB_allocImBuf(
(unsigned int)data->width, (unsigned int)data->height, 32, IB_rect | IB_metadata);
memcpy(img->rect, data->rect, BLEN_THUMB_MEMSIZE(data->width, data->height) - sizeof(*data));
@@ -383,7 +383,8 @@ const char *BKE_main_blendfile_path(const Main *bmain)
/**
* Return filepath of global main #G_MAIN.
*
- * \warning Usage is not recommended, you should always try to get a valid Main pointer from context...
+ * \warning Usage is not recommended,
+ * you should always try to get a valid Main pointer from context...
*/
const char *BKE_main_blendfile_path_from_global(void)
{
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index e307ad6cac8..9a9b3757ef2 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -142,10 +142,12 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
{
MaskLayer *masklay = MEM_callocN(sizeof(MaskLayer), __func__);
- if (name && name[0])
+ if (name && name[0]) {
BLI_strncpy(masklay->name, name, sizeof(masklay->name));
- else
+ }
+ else {
strcpy(masklay->name, "MaskLayer");
+ }
BLI_addtail(&mask->masklayers, masklay);
@@ -178,8 +180,9 @@ void BKE_mask_layer_remove(Mask *mask, MaskLayer *masklay)
mask->masklay_tot--;
- if (mask->masklay_act >= mask->masklay_tot)
+ if (mask->masklay_act >= mask->masklay_tot) {
mask->masklay_act = mask->masklay_tot - 1;
+ }
}
void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay)
@@ -270,7 +273,10 @@ MaskSpline *BKE_mask_spline_add(MaskLayer *masklay)
spline->tot_point = 1;
/* cyclic shapes are more usually used */
- // spline->flag |= MASK_SPLINE_CYCLIC; // disable because its not so nice for drawing. could be done differently
+ /* Disable because its not so nice for drawing. could be done differently. */
+#if 0
+ spline->flag |= MASK_SPLINE_CYCLIC;
+#endif
spline->weight_interp = MASK_SPLINE_INTERP_EASE;
@@ -399,8 +405,9 @@ float BKE_mask_spline_project_co(MaskSpline *spline,
if (len_squared_v2(v1) > proj_eps_sq) {
ang1 = angle_v2v2(v1, n1);
- if (ang1 > (float)M_PI / 2.0f)
+ if (ang1 > (float)M_PI / 2.0f) {
ang1 = (float)M_PI - ang1;
+ }
if (ang < 0.0f || ang1 < ang) {
ang = ang1;
@@ -424,8 +431,9 @@ float BKE_mask_spline_project_co(MaskSpline *spline,
if (len_squared_v2(v2) > proj_eps_sq) {
ang2 = angle_v2v2(v2, n2);
- if (ang2 > (float)M_PI / 2.0f)
+ if (ang2 > (float)M_PI / 2.0f) {
ang2 = (float)M_PI - ang2;
+ }
if (ang2 < ang) {
ang = ang2;
@@ -728,10 +736,12 @@ MaskSplinePointUW *BKE_mask_point_sort_uw(MaskSplinePoint *point, MaskSplinePoin
void BKE_mask_point_add_uw(MaskSplinePoint *point, float u, float w)
{
- if (!point->uw)
+ if (!point->uw) {
point->uw = MEM_mallocN(sizeof(*point->uw), "mask point uw");
- else
+ }
+ else {
point->uw = MEM_reallocN(point->uw, (point->tot_uw + 1) * sizeof(*point->uw));
+ }
point->uw[point->tot_uw].u = u;
point->uw[point->tot_uw].w = w;
@@ -816,10 +826,12 @@ Mask *BKE_mask_new(Main *bmain, const char *name)
Mask *mask;
char mask_name[MAX_ID_NAME - 2];
- if (name && name[0])
+ if (name && name[0]) {
BLI_strncpy(mask_name, name, sizeof(mask_name));
- else
+ }
+ else {
strcpy(mask_name, "Mask");
+ }
mask = mask_alloc(bmain, mask_name);
@@ -854,8 +866,10 @@ Mask *BKE_mask_copy_nolib(Mask *mask)
}
/**
- * Only copy internal data of Mask ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Mask ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -889,8 +903,9 @@ void BKE_mask_make_local(Main *bmain, Mask *mask, const bool lib_local)
void BKE_mask_point_free(MaskSplinePoint *point)
{
- if (point->uw)
+ if (point->uw) {
MEM_freeN(point->uw);
+ }
}
void BKE_mask_spline_free(MaskSpline *spline)
@@ -940,8 +955,9 @@ static MaskSplinePoint *mask_spline_points_copy(const MaskSplinePoint *points, i
for (i = 0; i < tot_point; i++) {
MaskSplinePoint *point = &npoints[i];
- if (point->uw)
+ if (point->uw) {
point->uw = MEM_dupallocN(point->uw);
+ }
}
return npoints;
@@ -1212,13 +1228,15 @@ static void mask_calc_point_handle(MaskSplinePoint *point,
{
BezTriple *bezt = &point->bezt;
BezTriple *bezt_prev = NULL, *bezt_next = NULL;
- //int handle_type = bezt->h1;
+ // int handle_type = bezt->h1;
- if (point_prev)
+ if (point_prev) {
bezt_prev = &point_prev->bezt;
+ }
- if (point_next)
+ if (point_next) {
bezt_next = &point_next->bezt;
+ }
#if 1
if (bezt_prev || bezt_next) {
@@ -1699,12 +1717,15 @@ static int mask_layer_shape_sort_cb(const void *masklay_shape_a_ptr,
const MaskLayerShape *masklay_shape_a = masklay_shape_a_ptr;
const MaskLayerShape *masklay_shape_b = masklay_shape_b_ptr;
- if (masklay_shape_a->frame < masklay_shape_b->frame)
+ if (masklay_shape_a->frame < masklay_shape_b->frame) {
return -1;
- else if (masklay_shape_a->frame > masklay_shape_b->frame)
+ }
+ else if (masklay_shape_a->frame > masklay_shape_b->frame) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
void BKE_mask_layer_shape_sort(MaskLayer *masklay)
@@ -1786,7 +1807,8 @@ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay,
if (BKE_mask_layer_shape_spline_from_index(masklay, index, &spline, &spline_point_index)) {
/* sanity check */
- /* the point has already been removed in this array so subtract one when comparing with the shapes */
+ /* The point has already been removed in this array
+ * so subtract one when comparing with the shapes. */
int tot = BKE_mask_layer_shape_totvert(masklay) - 1;
/* for interpolation */
diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c
index 2b84c1f32c1..4e6ca878b7a 100644
--- a/source/blender/blenkernel/intern/mask_evaluate.c
+++ b/source/blender/blenkernel/intern/mask_evaluate.c
@@ -153,8 +153,9 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline,
diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets");
a = spline->tot_point - 1;
- if (spline->flag & MASK_SPLINE_CYCLIC)
+ if (spline->flag & MASK_SPLINE_CYCLIC) {
a++;
+ }
point_prev = points_array;
point_curr = point_prev + 1;
@@ -164,8 +165,9 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline,
BezTriple *bezt_curr;
int j;
- if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC))
+ if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) {
point_curr = points_array;
+ }
bezt_prev = &point_prev->bezt;
bezt_curr = &point_curr->bezt;
@@ -250,8 +252,9 @@ static void feather_bucket_check_intersect(float (*feather_points)[2],
const float *v3 = (float *)feather_points[check_a];
const float *v4 = (float *)feather_points[check_b];
- if (check_a >= cur_a - 1 || cur_b == check_a)
+ if (check_a >= cur_a - 1 || cur_b == check_a) {
continue;
+ }
if (isect_seg_seg_v2_simple(v1, v2, v3, v4)) {
int k;
@@ -302,11 +305,13 @@ static int feather_bucket_index_from_coord(const float co[2],
int x = (int)((co[0] - min[0]) * bucket_scale[0]);
int y = (int)((co[1] - min[1]) * bucket_scale[1]);
- if (x == buckets_per_side)
+ if (x == buckets_per_side) {
x--;
+ }
- if (y == buckets_per_side)
+ if (y == buckets_per_side) {
y--;
+ }
return y * buckets_per_side + x;
}
@@ -364,19 +369,23 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline,
minmax_v2v2_v2(min, max, feather_points[i]);
if (next == tot_feather_point) {
- if (spline->flag & MASK_SPLINE_CYCLIC)
+ if (spline->flag & MASK_SPLINE_CYCLIC) {
next = 0;
- else
+ }
+ else {
break;
+ }
}
delta = fabsf(feather_points[i][0] - feather_points[next][0]);
- if (delta > max_delta_x)
+ if (delta > max_delta_x) {
max_delta_x = delta;
+ }
delta = fabsf(feather_points[i][1] - feather_points[next][1]);
- if (delta > max_delta_y)
+ if (delta > max_delta_y) {
max_delta_y = delta;
+ }
}
/* prevent divisionsby zero by ensuring bounding box is not collapsed */
@@ -423,10 +432,12 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline,
int start_bucket_index, end_bucket_index;
if (end == tot_feather_point) {
- if (spline->flag & MASK_SPLINE_CYCLIC)
+ if (spline->flag & MASK_SPLINE_CYCLIC) {
end = 0;
- else
+ }
+ else {
break;
+ }
}
start_bucket_index = BUCKET_INDEX(feather_points[start]);
@@ -458,8 +469,9 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline,
FeatherEdgesBucket *start_bucket;
- if (cur_b == tot_feather_point)
+ if (cur_b == tot_feather_point) {
cur_b = 0;
+ }
start_bucket_index = BUCKET_INDEX(feather_points[cur_a]);
end_bucket_index = BUCKET_INDEX(feather_points[cur_b]);
@@ -489,8 +501,9 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline,
/* free buckets */
for (i = 0; i < tot_bucket; i++) {
- if (buckets[i].segments)
+ if (buckets[i].segments) {
MEM_freeN(buckets[i].segments);
+ }
}
MEM_freeN(buckets);
@@ -516,8 +529,9 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__even(
feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline feather diff points");
a = spline->tot_point - 1;
- if (spline->flag & MASK_SPLINE_CYCLIC)
+ if (spline->flag & MASK_SPLINE_CYCLIC) {
a++;
+ }
point_prev = points_array;
point_curr = point_prev + 1;
@@ -527,8 +541,9 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__even(
/* BezTriple *bezt_curr; */ /* UNUSED */
int j;
- if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC))
+ if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) {
point_curr = points_array;
+ }
/* bezt_prev = &point_prev->bezt; */
/* bezt_curr = &point_curr->bezt; */
@@ -595,8 +610,9 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__double
feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline vets");
a = spline->tot_point - 1;
- if (spline->flag & MASK_SPLINE_CYCLIC)
+ if (spline->flag & MASK_SPLINE_CYCLIC) {
a++;
+ }
point_prev = points_array;
point_curr = point_prev + 1;
@@ -612,8 +628,9 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__double
BezTriple *bezt_curr;
int j;
- if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC))
+ if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) {
point_curr = points_array;
+ }
bezt_prev = &point_prev->bezt;
bezt_curr = &point_curr->bezt;
@@ -823,8 +840,9 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline,
bezt = &point->bezt;
bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, point);
- if (!bezt_next)
+ if (!bezt_next) {
return NULL;
+ }
/* resol+1 because of 'forward_diff_bezier' function */
*tot_diff_point = resol + 1;
@@ -879,7 +897,8 @@ void BKE_mask_layer_evaluate_animation(MaskLayer *masklay, const float ctime)
__func__,
(int)ctime,
BLI_listbase_count(&masklay->splines_shapes),
- masklay_shape_a->frame, masklay_shape_b->frame);
+ masklay_shape_a->frame,
+ masklay_shape_b->frame);
#endif
BKE_mask_layer_shape_to_mask_interp(
masklay, masklay_shape_a, masklay_shape_b, (ctime - masklay_shape_a->frame) / w);
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 24137b680ba..fe6ef2e047d 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -20,14 +20,16 @@
/** \file
* \ingroup bke
*
- * This module exposes a rasterizer that works as a black box - implementation details are confined to this file,
+ * This module exposes a rasterizer that works as a black box - implementation details
+ * are confined to this file.
*
* The basic method to access is:
* - create & initialize a handle from a #Mask datablock.
* - execute pixel lookups.
* - free the handle.
*
- * This file is admittedly a bit confusticated, in quite few areas speed was chosen over readability,
+ * This file is admittedly a bit confusticated,
+ * in quite few areas speed was chosen over readability,
* though it is commented - so shouldn't be so hard to see what's going on.
* Implementation:
*
@@ -35,12 +37,16 @@
*
* Initially 'kdopbvh' was used but this ended up being too slow.
*
- * To gain some extra speed we take advantage of a few shortcuts that can be made rasterizing masks specifically.
- * - all triangles are known to be completely white - so no depth check is done on triangle intersection.
- * - all quads are known to be feather outlines - the 1 and 0 depths are known by the vertex order in the quad,
- * - there is no color - just a value for each mask pixel.
- * - the mask spacial structure always maps to space 0-1 on X and Y axis.
- * - bucketing is used to speed up lookups for geometry.
+ * To gain some extra speed we take advantage of a few shortcuts
+ * that can be made rasterizing masks specifically.
+ *
+ * - All triangles are known to be completely white -
+ * so no depth check is done on triangle intersection.
+ * - All quads are known to be feather outlines -
+ * the 1 and 0 depths are known by the vertex order in the quad,
+ * - There is no color - just a value for each mask pixel.
+ * - The mask spacial structure always maps to space 0-1 on X and Y axis.
+ * - Bucketing is used to speed up lookups for geometry.
*
* Other Details:
* - used unsigned values all over for some extra speed on some arch's.
@@ -48,7 +54,8 @@
* - initializing the spacial structure doesn't need to be as optimized as pixel lookups are.
* - mask lookups need not be pixel aligned so any sub-pixel values from x/y (0 - 1), can be found.
* (perhaps masks can be used as a vector texture in 3D later on)
- * Currently, to build the spacial structure we have to calculate the total number of faces ahead of time.
+ * Currently, to build the spacial structure we have to calculate
+ * the total number of faces ahead of time.
*
* This is getting a bit complicated with the addition of unfilled splines and end capping -
* If large changes are needed here we would be better off using an iterable
@@ -488,28 +495,34 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
/* this should _almost_ never happen but since it can in extreme cases,
* we have to clamp the values or we overrun the buffer and crash */
- if (xi_min >= layer->buckets_x)
+ if (xi_min >= layer->buckets_x) {
xi_min = layer->buckets_x - 1;
- if (xi_max >= layer->buckets_x)
+ }
+ if (xi_max >= layer->buckets_x) {
xi_max = layer->buckets_x - 1;
- if (yi_min >= layer->buckets_y)
+ }
+ if (yi_min >= layer->buckets_y) {
yi_min = layer->buckets_y - 1;
- if (yi_max >= layer->buckets_y)
+ }
+ if (yi_max >= layer->buckets_y) {
yi_max = layer->buckets_y - 1;
+ }
for (yi = yi_min; yi <= yi_max; yi++) {
unsigned int bucket_index = (layer->buckets_x * yi) + xi_min;
for (xi = xi_min; xi <= xi_max; xi++, bucket_index++) {
- // unsigned int bucket_index = (layer->buckets_x * yi) + xi; /* correct but do in outer loop */
+ /* correct but do in outer loop */
+ // unsigned int bucket_index = (layer->buckets_x * yi) + xi;
BLI_assert(xi < layer->buckets_x);
BLI_assert(yi < layer->buckets_y);
BLI_assert(bucket_index < bucket_tot);
- /* check if the bucket intersects with the face */
- /* note: there is a trade off here since checking box/tri intersections isn't
- * as optimal as it could be, but checking pixels against faces they will never intersect
- * with is likely the greater slowdown here - so check if the cell intersects the face */
+ /* Check if the bucket intersects with the face. */
+ /* Note: there is a trade off here since checking box/tri intersections isn't as
+ * optimal as it could be, but checking pixels against faces they will never
+ * intersect with is likely the greater slowdown here -
+ * so check if the cell intersects the face. */
if (layer_bucket_isect_test(layer,
face_index,
xi,
@@ -979,8 +992,9 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
/* --- end inefficient code --- */
/* main scan-fill */
- if ((masklay->flag & MASK_LAYERFLAG_FILL_DISCRETE) == 0)
+ if ((masklay->flag & MASK_LAYERFLAG_FILL_DISCRETE) == 0) {
scanfill_flag |= BLI_SCANFILL_CALC_HOLES;
+ }
sf_tri_tot = (unsigned int)BLI_scanfill_calc_ex(&sf_ctx, scanfill_flag, zvec);
@@ -1155,7 +1169,15 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
MEM_freeN(open_spline_ranges);
- // fprintf(stderr, "%u %u (%u %u), %u\n", face_index, sf_tri_tot + tot_feather_quads, sf_tri_tot, tot_feather_quads, tot_boundary_used - tot_boundary_found);
+#if 0
+ fprintf(stderr,
+ "%u %u (%u %u), %u\n",
+ face_index,
+ sf_tri_tot + tot_feather_quads,
+ sf_tri_tot,
+ tot_feather_quads,
+ tot_boundary_used - tot_boundary_found);
+#endif
#ifdef USE_SCANFILL_EDGE_WORKAROUND
BLI_assert(face_index + (tot_boundary_used - tot_boundary_found) ==
@@ -1212,7 +1234,9 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle,
/* 2D ray test */
#if 0
static float maskrasterize_layer_z_depth_tri(const float pt[2],
- const float v1[3], const float v2[3], const float v3[3])
+ const float v1[3],
+ const float v2[3],
+ const float v3[3])
{
float w[3];
barycentric_weights_v2(v1, v2, v3, pt, w);
@@ -1225,7 +1249,7 @@ static float maskrasterize_layer_z_depth_quad(
{
float w[4];
barycentric_weights_v2_quad(v1, v2, v3, v4, pt, w);
- //return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]) + (v4[2] * w[3]);
+ // return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]) + (v4[2] * w[3]);
return w[2] + w[3]; /* we can make this assumption for small speedup */
}
@@ -1240,10 +1264,7 @@ static float maskrasterize_layer_isect(unsigned int *face,
#if 0
/* not essential but avoids unneeded extra lookups */
- if ((cos[0][2] < dist_orig) ||
- (cos[1][2] < dist_orig) ||
- (cos[2][2] < dist_orig))
- {
+ if ((cos[0][2] < dist_orig) || (cos[1][2] < dist_orig) || (cos[2][2] < dist_orig)) {
if (isect_point_tri_v2_cw(xy, cos[face[0]], cos[face[1]], cos[face[2]])) {
/* we know all tris are close for now */
return maskrasterize_layer_z_depth_tri(xy, cos[face[0]], cos[face[1]], cos[face[2]]);
@@ -1266,7 +1287,7 @@ static float maskrasterize_layer_isect(unsigned int *face,
/* needs work */
#if 1
/* quad check fails for bow-tie, so keep using 2 tri checks */
- //if (isect_point_quad_v2(xy, cos[face[0]], cos[face[1]], cos[face[2]], cos[face[3]]))
+ // if (isect_point_quad_v2(xy, cos[face[0]], cos[face[1]], cos[face[2]], cos[face[3]]))
if (isect_point_tri_v2(xy, cos[face[0]], cos[face[1]], cos[face[2]]) ||
isect_point_tri_v2(xy, cos[face[0]], cos[face[2]], cos[face[3]])) {
return maskrasterize_layer_z_depth_quad(
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index a4da6663de8..75b9e355df9 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -169,8 +169,10 @@ Material *BKE_material_add_gpencil(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Material ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Material ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -424,10 +426,12 @@ void BKE_material_append_id(Main *bmain, ID *id, Material *ma)
if ((matar = give_matarar_id(id))) {
short *totcol = give_totcolp_id(id);
Material **mat = MEM_callocN(sizeof(void *) * ((*totcol) + 1), "newmatar");
- if (*totcol)
+ if (*totcol) {
memcpy(mat, *matar, sizeof(void *) * (*totcol));
- if (*matar)
+ }
+ if (*matar) {
MEM_freeN(*matar);
+ }
*matar = mat;
(*matar)[(*totcol)++] = ma;
@@ -457,10 +461,11 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i, bool update_data
*matar = NULL;
}
else {
- if (index + 1 != (*totcol))
+ if (index + 1 != (*totcol)) {
memmove((*matar) + index,
(*matar) + (index + 1),
sizeof(void *) * ((*totcol) - (index + 1)));
+ }
(*totcol)--;
*matar = MEM_reallocN(*matar, sizeof(void *) * (*totcol));
@@ -510,17 +515,20 @@ Material **give_current_material_p(Object *ob, short act)
Material ***matarar, **ma_p;
const short *totcolp;
- if (ob == NULL)
+ if (ob == NULL) {
return NULL;
+ }
/* if object cannot have material, (totcolp == NULL) */
totcolp = give_totcolp(ob);
- if (totcolp == NULL || ob->totcol == 0)
+ if (totcolp == NULL || ob->totcol == 0) {
return NULL;
+ }
/* return NULL for invalid 'act', can happen for mesh face indices */
- if (act > ob->totcol)
+ if (act > ob->totcol) {
return NULL;
+ }
else if (act <= 0) {
if (act < 0) {
CLOG_ERROR(&LOG, "Negative material index!");
@@ -534,10 +542,12 @@ Material **give_current_material_p(Object *ob, short act)
else { /* in data */
/* check for inconsistency */
- if (*totcolp < ob->totcol)
+ if (*totcolp < ob->totcol) {
ob->totcol = *totcolp;
- if (act > ob->totcol)
+ }
+ if (act > ob->totcol) {
act = ob->totcol;
+ }
matarar = give_matarar(ob);
@@ -578,8 +588,9 @@ Material *give_node_material(Material *ma)
if (ma && ma->use_nodes && ma->nodetree) {
bNode *node = nodeGetActiveID(ma->nodetree, ID_MA);
- if (node)
+ if (node) {
return (Material *)node->id;
+ }
}
return NULL;
@@ -620,10 +631,12 @@ void BKE_material_resize_object(Main *bmain, Object *ob, const short totcol, boo
/* XXX, why not realloc on shrink? - campbell */
ob->totcol = totcol;
- if (ob->totcol && ob->actcol == 0)
+ if (ob->totcol && ob->actcol == 0) {
ob->actcol = 1;
- if (ob->actcol > ob->totcol)
+ }
+ if (ob->actcol > ob->totcol) {
ob->actcol = ob->totcol;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_GEOMETRY);
DEG_relations_tag_update(bmain);
@@ -665,18 +678,21 @@ void assign_material_id(Main *bmain, ID *id, Material *ma, short act)
Material *mao, **matar, ***matarar;
short *totcolp;
- if (act > MAXMAT)
+ if (act > MAXMAT) {
return;
- if (act < 1)
+ }
+ if (act < 1) {
act = 1;
+ }
/* test arraylens */
totcolp = give_totcolp_id(id);
matarar = give_matarar_id(id);
- if (totcolp == NULL || matarar == NULL)
+ if (totcolp == NULL || matarar == NULL) {
return;
+ }
if (act > *totcolp) {
matar = MEM_callocN(sizeof(void *) * act, "matarray1");
@@ -692,12 +708,14 @@ void assign_material_id(Main *bmain, ID *id, Material *ma, short act)
/* in data */
mao = (*matarar)[act - 1];
- if (mao)
+ if (mao) {
id_us_min(&mao->id);
+ }
(*matarar)[act - 1] = ma;
- if (ma)
+ if (ma) {
id_us_plus(&ma->id);
+ }
test_all_objects_materials(bmain, id);
}
@@ -708,23 +726,27 @@ void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assig
short *totcolp;
char bit = 0;
- if (act > MAXMAT)
+ if (act > MAXMAT) {
return;
- if (act < 1)
+ }
+ if (act < 1) {
act = 1;
+ }
/* prevent crashing when using accidentally */
BLI_assert(!ID_IS_LINKED(ob));
- if (ID_IS_LINKED(ob))
+ if (ID_IS_LINKED(ob)) {
return;
+ }
/* test arraylens */
totcolp = give_totcolp(ob);
matarar = give_matarar(ob);
- if (totcolp == NULL || matarar == NULL)
+ if (totcolp == NULL || matarar == NULL) {
return;
+ }
if (act > *totcolp) {
matar = MEM_callocN(sizeof(void *) * act, "matarray1");
@@ -775,21 +797,24 @@ void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assig
ob->matbits[act - 1] = bit;
if (bit == 1) { /* in object */
mao = ob->mat[act - 1];
- if (mao)
+ if (mao) {
id_us_min(&mao->id);
+ }
ob->mat[act - 1] = ma;
test_object_materials(bmain, ob, ob->data);
}
else { /* in data */
mao = (*matarar)[act - 1];
- if (mao)
+ if (mao) {
id_us_min(&mao->id);
+ }
(*matarar)[act - 1] = ma;
test_all_objects_materials(bmain, ob->data); /* Data may be used by several objects... */
}
- if (ma)
+ if (ma) {
id_us_plus(&ma->id);
+ }
}
void BKE_material_remap_object(Object *ob, const unsigned int *remap)
@@ -887,11 +912,13 @@ void assign_matarar(Main *bmain, struct Object *ob, struct Material ***matar, sh
}
/* now we have the right number of slots */
- for (i = 0; i < totcol; i++)
+ for (i = 0; i < totcol; i++) {
assign_material(bmain, ob, (*matar)[i], i + 1, BKE_MAT_ASSIGN_USERPREF);
+ }
- if (actcol_orig > ob->totcol)
+ if (actcol_orig > ob->totcol) {
actcol_orig = ob->totcol;
+ }
ob->actcol = actcol_orig;
}
@@ -901,29 +928,36 @@ short BKE_object_material_slot_find_index(Object *ob, Material *ma)
Material ***matarar;
short a, *totcolp;
- if (ma == NULL)
+ if (ma == NULL) {
return 0;
+ }
totcolp = give_totcolp(ob);
matarar = give_matarar(ob);
- if (totcolp == NULL || matarar == NULL)
+ if (totcolp == NULL || matarar == NULL) {
return 0;
+ }
- for (a = 0; a < *totcolp; a++)
- if ((*matarar)[a] == ma)
+ for (a = 0; a < *totcolp; a++) {
+ if ((*matarar)[a] == ma) {
break;
- if (a < *totcolp)
+ }
+ }
+ if (a < *totcolp) {
return a + 1;
+ }
return 0;
}
bool BKE_object_material_slot_add(Main *bmain, Object *ob)
{
- if (ob == NULL)
+ if (ob == NULL) {
return false;
- if (ob->totcol >= MAXMAT)
+ }
+ if (ob->totcol >= MAXMAT) {
return false;
+ }
assign_material(bmain, ob, NULL, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
ob->actcol = ob->totcol;
@@ -969,11 +1003,13 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
/* we delete the actcol */
mao = (*matarar)[ob->actcol - 1];
- if (mao)
+ if (mao) {
id_us_min(&mao->id);
+ }
- for (a = ob->actcol; a < ob->totcol; a++)
+ for (a = ob->actcol; a < ob->totcol; a++) {
(*matarar)[a - 1] = (*matarar)[a];
+ }
(*totcolp)--;
if (*totcolp == 0) {
@@ -991,16 +1027,18 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
}
/* WATCH IT: do not use actcol from ob or from obt (can become zero) */
mao = obt->mat[actcol - 1];
- if (mao)
+ if (mao) {
id_us_min(&mao->id);
+ }
for (a = actcol; a < obt->totcol; a++) {
obt->mat[a - 1] = obt->mat[a];
obt->matbits[a - 1] = obt->matbits[a];
}
obt->totcol--;
- if (obt->actcol > obt->totcol)
+ if (obt->actcol > obt->totcol) {
obt->actcol = obt->totcol;
+ }
if (obt->totcol == 0) {
MEM_freeN(obt->mat);
@@ -1102,8 +1140,9 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
int count = 0;
int index = 0;
- if (!ma)
+ if (!ma) {
return;
+ }
/* COW needed when adding texture slot on an object with no materials. */
DEG_id_tag_update(&ma->id, ID_RECALC_SHADING | ID_RECALC_COPY_ON_WRITE);
@@ -1190,18 +1229,24 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
r_col[2] = 1.0f - (facm + fac * (1.0f - col[2])) * (1.0f - r_col[2]);
break;
case MA_RAMP_OVERLAY:
- if (r_col[0] < 0.5f)
+ if (r_col[0] < 0.5f) {
r_col[0] *= (facm + 2.0f * fac * col[0]);
- else
+ }
+ else {
r_col[0] = 1.0f - (facm + 2.0f * fac * (1.0f - col[0])) * (1.0f - r_col[0]);
- if (r_col[1] < 0.5f)
+ }
+ if (r_col[1] < 0.5f) {
r_col[1] *= (facm + 2.0f * fac * col[1]);
- else
+ }
+ else {
r_col[1] = 1.0f - (facm + 2.0f * fac * (1.0f - col[1])) * (1.0f - r_col[1]);
- if (r_col[2] < 0.5f)
+ }
+ if (r_col[2] < 0.5f) {
r_col[2] *= (facm + 2.0f * fac * col[2]);
- else
+ }
+ else {
r_col[2] = 1.0f - (facm + 2.0f * fac * (1.0f - col[2])) * (1.0f - r_col[2]);
+ }
break;
case MA_RAMP_SUB:
r_col[0] -= fac * col[0];
@@ -1209,12 +1254,15 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
r_col[2] -= fac * col[2];
break;
case MA_RAMP_DIV:
- if (col[0] != 0.0f)
+ if (col[0] != 0.0f) {
r_col[0] = facm * (r_col[0]) + fac * (r_col[0]) / col[0];
- if (col[1] != 0.0f)
+ }
+ if (col[1] != 0.0f) {
r_col[1] = facm * (r_col[1]) + fac * (r_col[1]) / col[1];
- if (col[2] != 0.0f)
+ }
+ if (col[2] != 0.0f) {
r_col[2] = facm * (r_col[2]) + fac * (r_col[2]) / col[2];
+ }
break;
case MA_RAMP_DIFF:
r_col[0] = facm * (r_col[0]) + fac * fabsf(r_col[0] - col[0]);
@@ -1228,75 +1276,99 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
break;
case MA_RAMP_LIGHT:
tmp = fac * col[0];
- if (tmp > r_col[0])
+ if (tmp > r_col[0]) {
r_col[0] = tmp;
+ }
tmp = fac * col[1];
- if (tmp > r_col[1])
+ if (tmp > r_col[1]) {
r_col[1] = tmp;
+ }
tmp = fac * col[2];
- if (tmp > r_col[2])
+ if (tmp > r_col[2]) {
r_col[2] = tmp;
+ }
break;
case MA_RAMP_DODGE:
if (r_col[0] != 0.0f) {
tmp = 1.0f - fac * col[0];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
r_col[0] = 1.0f;
- else if ((tmp = (r_col[0]) / tmp) > 1.0f)
+ }
+ else if ((tmp = (r_col[0]) / tmp) > 1.0f) {
r_col[0] = 1.0f;
- else
+ }
+ else {
r_col[0] = tmp;
+ }
}
if (r_col[1] != 0.0f) {
tmp = 1.0f - fac * col[1];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
r_col[1] = 1.0f;
- else if ((tmp = (r_col[1]) / tmp) > 1.0f)
+ }
+ else if ((tmp = (r_col[1]) / tmp) > 1.0f) {
r_col[1] = 1.0f;
- else
+ }
+ else {
r_col[1] = tmp;
+ }
}
if (r_col[2] != 0.0f) {
tmp = 1.0f - fac * col[2];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
r_col[2] = 1.0f;
- else if ((tmp = (r_col[2]) / tmp) > 1.0f)
+ }
+ else if ((tmp = (r_col[2]) / tmp) > 1.0f) {
r_col[2] = 1.0f;
- else
+ }
+ else {
r_col[2] = tmp;
+ }
}
break;
case MA_RAMP_BURN:
tmp = facm + fac * col[0];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
r_col[0] = 0.0f;
- else if ((tmp = (1.0f - (1.0f - (r_col[0])) / tmp)) < 0.0f)
+ }
+ else if ((tmp = (1.0f - (1.0f - (r_col[0])) / tmp)) < 0.0f) {
r_col[0] = 0.0f;
- else if (tmp > 1.0f)
+ }
+ else if (tmp > 1.0f) {
r_col[0] = 1.0f;
- else
+ }
+ else {
r_col[0] = tmp;
+ }
tmp = facm + fac * col[1];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
r_col[1] = 0.0f;
- else if ((tmp = (1.0f - (1.0f - (r_col[1])) / tmp)) < 0.0f)
+ }
+ else if ((tmp = (1.0f - (1.0f - (r_col[1])) / tmp)) < 0.0f) {
r_col[1] = 0.0f;
- else if (tmp > 1.0f)
+ }
+ else if (tmp > 1.0f) {
r_col[1] = 1.0f;
- else
+ }
+ else {
r_col[1] = tmp;
+ }
tmp = facm + fac * col[2];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
r_col[2] = 0.0f;
- else if ((tmp = (1.0f - (1.0f - (r_col[2])) / tmp)) < 0.0f)
+ }
+ else if ((tmp = (1.0f - (1.0f - (r_col[2])) / tmp)) < 0.0f) {
r_col[2] = 0.0f;
- else if (tmp > 1.0f)
+ }
+ else if (tmp > 1.0f) {
r_col[2] = 1.0f;
- else
+ }
+ else {
r_col[2] = tmp;
+ }
break;
case MA_RAMP_HUE: {
float rH, rS, rV;
@@ -1361,18 +1433,24 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
break;
}
case MA_RAMP_LINEAR:
- if (col[0] > 0.5f)
+ if (col[0] > 0.5f) {
r_col[0] = r_col[0] + fac * (2.0f * (col[0] - 0.5f));
- else
+ }
+ else {
r_col[0] = r_col[0] + fac * (2.0f * (col[0]) - 1.0f);
- if (col[1] > 0.5f)
+ }
+ if (col[1] > 0.5f) {
r_col[1] = r_col[1] + fac * (2.0f * (col[1] - 0.5f));
- else
+ }
+ else {
r_col[1] = r_col[1] + fac * (2.0f * (col[1]) - 1.0f);
- if (col[2] > 0.5f)
+ }
+ if (col[2] > 0.5f) {
r_col[2] = r_col[2] + fac * (2.0f * (col[2] - 0.5f));
- else
+ }
+ else {
r_col[2] = r_col[2] + fac * (2.0f * (col[2]) - 1.0f);
+ }
break;
}
}
@@ -1404,8 +1482,9 @@ void free_matcopybuf(void)
void copy_matcopybuf(Main *bmain, Material *ma)
{
- if (matcopied)
+ if (matcopied) {
free_matcopybuf();
+ }
memcpy(&matcopybuf, ma, sizeof(Material));
@@ -1423,8 +1502,9 @@ void paste_matcopybuf(Main *bmain, Material *ma)
{
ID id;
- if (matcopied == 0)
+ if (matcopied == 0) {
return;
+ }
/* Free gpu material before the ntree */
GPU_material_free(&ma->gpumaterial);
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 8ab042d5446..d6fa071009e 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -70,8 +70,9 @@ void BKE_mball_free(MetaBall *mb)
MEM_SAFE_FREE(mb->mat);
BLI_freelistN(&mb->elems);
- if (mb->disp.first)
+ if (mb->disp.first) {
BKE_displist_free(&mb->disp);
+ }
}
void BKE_mball_init(MetaBall *mb)
@@ -98,8 +99,10 @@ MetaBall *BKE_mball_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of MetaBall ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of MetaBall ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -206,8 +209,9 @@ void BKE_mball_texspace_calc(Object *ob)
dl = ob->runtime.curve_cache->disp.first;
while (dl) {
tot = dl->nr;
- if (tot)
+ if (tot) {
do_it = true;
+ }
data = dl->verts;
while (tot--) {
/* Also weird... but longer. From utildefines. */
@@ -236,7 +240,8 @@ BoundBox *BKE_mball_boundbox_get(Object *ob)
return ob->runtime.bb;
}
- /* This should always only be called with evaluated objects, but currently RNA is a problem here... */
+ /* This should always only be called with evaluated objects,
+ * but currently RNA is a problem here... */
if (ob->runtime.curve_cache != NULL) {
BKE_mball_texspace_calc(ob);
}
@@ -281,12 +286,15 @@ float *BKE_mball_make_orco(Object *ob, ListBase *dispbase)
/* Note on mball basis stuff 2.5x (this is a can of worms)
* This really needs a rewrite/refactor its totally broken in anything other then basic cases
- * Multiple Scenes + Set Scenes & mixing mball basis SHOULD work but fails to update the depsgraph on rename
- * and linking into scenes or removal of basis mball. so take care when changing this code.
+ * Multiple Scenes + Set Scenes & mixing mball basis SHOULD work but fails to update the depsgraph
+ * on rename and linking into scenes or removal of basis mball.
+ * So take care when changing this code.
*
- * Main idiot thing here is that the system returns find_basis_mball() objects which fail a is_basis_mball() test.
+ * Main idiot thing here is that the system returns find_basis_mball()
+ * objects which fail a is_basis_mball() test.
*
- * Not only that but the depsgraph and their areas depend on this behavior!, so making small fixes here isn't worth it.
+ * Not only that but the depsgraph and their areas depend on this behavior!,
+ * so making small fixes here isn't worth it.
* - Campbell
*/
@@ -358,8 +366,8 @@ bool BKE_mball_is_any_unselected(const MetaBall *mb)
/* \brief copy some properties from object to other metaball object with same base name
*
- * When some properties (wiresize, threshold, update flags) of metaball are changed, then this properties
- * are copied to all metaballs in same "group" (metaballs with same base name: MBall,
+ * When some properties (wiresize, threshold, update flags) of metaball are changed, then this
+ * properties are copied to all metaballs in same "group" (metaballs with same base name: MBall,
* MBall.001, MBall.002, etc). The most important is to copy properties to the base metaball,
* because this metaball influence polygonisation of metaballs. */
void BKE_mball_properties_copy(Scene *scene, Object *active_object)
@@ -425,7 +433,8 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis)
if (ob != bob) {
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
- /* object ob has to be in same "group" ... it means, that it has to have same base of its name */
+ /* Object ob has to be in same "group" ... it means,
+ * that it has to have same base of its name. */
if (STREQ(obname, basisname)) {
if (obnr < basisnr) {
basis = ob;
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index 3ca46b7be61..1218e78c6f0 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -172,13 +172,16 @@ static unsigned int partition_mainb(
div *= 2.0f;
while (1) {
- while (i < j && div > (mainb[i]->bb->vec[6][s] + mainb[i]->bb->vec[0][s]))
+ while (i < j && div > (mainb[i]->bb->vec[6][s] + mainb[i]->bb->vec[0][s])) {
i++;
- while (j > i && div < (mainb[j]->bb->vec[6][s] + mainb[j]->bb->vec[0][s]))
+ }
+ while (j > i && div < (mainb[j]->bb->vec[6][s] + mainb[j]->bb->vec[0][s])) {
j--;
+ }
- if (i >= j)
+ if (i >= j) {
break;
+ }
SWAP(MetaElem *, mainb[i], mainb[j]);
i++;
@@ -212,10 +215,12 @@ static void build_bvh_spatial(PROCESS *process,
dim[2] = allbox->max[2] - allbox->min[2];
s = 0;
- if (dim[1] > dim[0] && dim[1] > dim[2])
+ if (dim[1] > dim[0] && dim[1] > dim[2]) {
s = 1;
- else if (dim[2] > dim[1] && dim[2] > dim[0])
+ }
+ else if (dim[2] > dim[1] && dim[2] > dim[0]) {
s = 2;
+ }
div = allbox->min[s] + (dim[s] / 2.0f);
@@ -316,28 +321,37 @@ static float densfunc(const MetaElem *ball, float x, float y, float z)
/* do nothing */
break;
case MB_CUBE:
- if (dvec[2] > ball->expz)
+ if (dvec[2] > ball->expz) {
dvec[2] -= ball->expz;
- else if (dvec[2] < -ball->expz)
+ }
+ else if (dvec[2] < -ball->expz) {
dvec[2] += ball->expz;
- else
+ }
+ else {
dvec[2] = 0.0;
+ }
ATTR_FALLTHROUGH;
case MB_PLANE:
- if (dvec[1] > ball->expy)
+ if (dvec[1] > ball->expy) {
dvec[1] -= ball->expy;
- else if (dvec[1] < -ball->expy)
+ }
+ else if (dvec[1] < -ball->expy) {
dvec[1] += ball->expy;
- else
+ }
+ else {
dvec[1] = 0.0;
+ }
ATTR_FALLTHROUGH;
case MB_TUBE:
- if (dvec[0] > ball->expx)
+ if (dvec[0] > ball->expx) {
dvec[0] -= ball->expx;
- else if (dvec[0] < -ball->expx)
+ }
+ else if (dvec[0] < -ball->expx) {
dvec[0] += ball->expx;
- else
+ }
+ else {
dvec[0] = 0.0;
+ }
break;
case MB_ELIPSOID:
dvec[0] /= ball->expx;
@@ -347,28 +361,37 @@ static float densfunc(const MetaElem *ball, float x, float y, float z)
/* *** deprecated, could be removed?, do-versioned at least *** */
case MB_TUBEX:
- if (dvec[0] > ball->len)
+ if (dvec[0] > ball->len) {
dvec[0] -= ball->len;
- else if (dvec[0] < -ball->len)
+ }
+ else if (dvec[0] < -ball->len) {
dvec[0] += ball->len;
- else
+ }
+ else {
dvec[0] = 0.0;
+ }
break;
case MB_TUBEY:
- if (dvec[1] > ball->len)
+ if (dvec[1] > ball->len) {
dvec[1] -= ball->len;
- else if (dvec[1] < -ball->len)
+ }
+ else if (dvec[1] < -ball->len) {
dvec[1] += ball->len;
- else
+ }
+ else {
dvec[1] = 0.0;
+ }
break;
case MB_TUBEZ:
- if (dvec[2] > ball->len)
+ if (dvec[2] > ball->len) {
dvec[2] -= ball->len;
- else if (dvec[2] < -ball->len)
+ }
+ else if (dvec[2] < -ball->len) {
dvec[2] += ball->len;
- else
+ }
+ else {
dvec[2] = 0.0;
+ }
break;
/* *** end deprecated *** */
}
@@ -399,10 +422,12 @@ static float metaball(PROCESS *process, float x, float y, float z)
for (i = 0; i < 2; i++) {
if ((node->bb[i].min[0] <= x) && (node->bb[i].max[0] >= x) && (node->bb[i].min[1] <= y) &&
(node->bb[i].max[1] >= y) && (node->bb[i].min[2] <= z) && (node->bb[i].max[2] >= z)) {
- if (node->child[i])
+ if (node->child[i]) {
process->bvh_queue[front++] = node->child[i];
- else
+ }
+ else {
dens += densfunc(node->bb[i].ml, x, y, z);
+ }
}
}
}
@@ -466,18 +491,24 @@ static void make_face(PROCESS *process, int i1, int i2, int i3, int i4)
/* Frees allocated memory */
static void freepolygonize(PROCESS *process)
{
- if (process->corners)
+ if (process->corners) {
MEM_freeN(process->corners);
- if (process->edges)
+ }
+ if (process->edges) {
MEM_freeN(process->edges);
- if (process->centers)
+ }
+ if (process->centers) {
MEM_freeN(process->centers);
- if (process->mainb)
+ }
+ if (process->mainb) {
MEM_freeN(process->mainb);
- if (process->bvh_queue)
+ }
+ if (process->bvh_queue) {
MEM_freeN(process->bvh_queue);
- if (process->pgn_elements)
+ }
+ if (process->pgn_elements) {
BLI_memarena_free(process->pgn_elements);
+ }
}
/* **************** POLYGONIZATION ************************ */
@@ -577,18 +608,24 @@ static void docube(PROCESS *process, CUBE *cube)
}
/* Using faces[] table, adds neighbouring cube if surface intersects face in this direction. */
- if (MB_BIT(faces[index], 0))
+ if (MB_BIT(faces[index], 0)) {
add_cube(process, cube->i - 1, cube->j, cube->k);
- if (MB_BIT(faces[index], 1))
+ }
+ if (MB_BIT(faces[index], 1)) {
add_cube(process, cube->i + 1, cube->j, cube->k);
- if (MB_BIT(faces[index], 2))
+ }
+ if (MB_BIT(faces[index], 2)) {
add_cube(process, cube->i, cube->j - 1, cube->k);
- if (MB_BIT(faces[index], 3))
+ }
+ if (MB_BIT(faces[index], 3)) {
add_cube(process, cube->i, cube->j + 1, cube->k);
- if (MB_BIT(faces[index], 4))
+ }
+ if (MB_BIT(faces[index], 4)) {
add_cube(process, cube->i, cube->j, cube->k - 1);
- if (MB_BIT(faces[index], 5))
+ }
+ if (MB_BIT(faces[index], 5)) {
add_cube(process, cube->i, cube->j, cube->k + 1);
+ }
/* Using cubetable[], determines polygons for output. */
for (polys = cubetable[index]; polys; polys = polys->next) {
@@ -719,15 +756,18 @@ static void makecubetable(void)
static bool is_done = false;
int i, e, c, done[12], pos[8];
- if (is_done)
+ if (is_done) {
return;
+ }
is_done = true;
for (i = 0; i < 256; i++) {
- for (e = 0; e < 12; e++)
+ for (e = 0; e < 12; e++) {
done[e] = 0;
- for (c = 0; c < 8; c++)
+ }
+ for (c = 0; c < 8; c++) {
pos[c] = MB_BIT(i, c);
+ }
for (e = 0; e < 12; e++) {
if (!done[e] && (pos[corner1[e]] != pos[corner2[e]])) {
INTLIST *ints = NULL;
@@ -747,8 +787,9 @@ static void makecubetable(void)
ints->i = edge;
ints->next = tmp; /* add edge to head of list */
- if (edge == start)
+ if (edge == start) {
break;
+ }
face = otherface(edge, face);
}
}
@@ -766,18 +807,24 @@ static void makecubetable(void)
INTLIST *edges;
for (edges = polys->list; edges; edges = edges->next) {
- if (edges->i == LB || edges->i == LT || edges->i == LN || edges->i == LF)
+ if (edges->i == LB || edges->i == LT || edges->i == LN || edges->i == LF) {
faces[i] |= 1 << L;
- if (edges->i == RB || edges->i == RT || edges->i == RN || edges->i == RF)
+ }
+ if (edges->i == RB || edges->i == RT || edges->i == RN || edges->i == RF) {
faces[i] |= 1 << R;
- if (edges->i == LB || edges->i == RB || edges->i == BN || edges->i == BF)
+ }
+ if (edges->i == LB || edges->i == RB || edges->i == BN || edges->i == BF) {
faces[i] |= 1 << B;
- if (edges->i == LT || edges->i == RT || edges->i == TN || edges->i == TF)
+ }
+ if (edges->i == LT || edges->i == RT || edges->i == TN || edges->i == TF) {
faces[i] |= 1 << T;
- if (edges->i == LN || edges->i == RN || edges->i == BN || edges->i == TN)
+ }
+ if (edges->i == LN || edges->i == RN || edges->i == BN || edges->i == TN) {
faces[i] |= 1 << N;
- if (edges->i == LF || edges->i == RF || edges->i == BF || edges->i == TF)
+ }
+ if (edges->i == LF || edges->i == RF || edges->i == BF || edges->i == TF) {
faces[i] |= 1 << F;
+ }
}
}
}
@@ -822,8 +869,9 @@ static int setcenter(PROCESS *process, CENTERLIST *table[], const int i, const i
q = table[index];
for (l = q; l != NULL; l = l->next) {
- if (l->i == i && l->j == j && l->k == k)
+ if (l->i == i && l->j == j && l->k == k) {
return 1;
+ }
}
newc = BLI_memarena_alloc(process->pgn_elements, sizeof(CENTERLIST));
@@ -940,8 +988,9 @@ static int vertid(PROCESS *process, const CORNER *c1, const CORNER *c2)
float v[3], no[3];
int vid = getedge(process->edges, c1->i, c1->j, c1->k, c2->i, c2->j, c2->k);
- if (vid != -1)
+ if (vid != -1) {
return vid; /* previously computed */
+ }
converge(process, c1, c2, v); /* position */
@@ -1020,9 +1069,10 @@ static void add_cube(PROCESS *process, int i, int j, int k)
ncube->cube.k = k;
/* set corners of initial cube: */
- for (n = 0; n < 8; n++)
+ for (n = 0; n < 8; n++) {
ncube->cube.corners[n] = setcorner(
process, i + MB_BIT(n, 2), j + MB_BIT(n, 1), k + MB_BIT(n, 0));
+ }
}
}
@@ -1157,10 +1207,12 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
if (bob == ob && (base->flag_legacy & OB_FROMDUPLI) == 0) {
mb = ob->data;
- if (mb->editelems)
+ if (mb->editelems) {
ml = mb->editelems->first;
- else
+ }
+ else {
ml = mb->elems.first;
+ }
}
else {
char name[MAX_ID_NAME];
@@ -1170,10 +1222,12 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
if (STREQ(obname, name)) {
mb = bob->data;
- if (mb->editelems)
+ if (mb->editelems) {
ml = mb->editelems->first;
- else
+ }
+ else {
ml = mb->elems.first;
+ }
}
}
@@ -1216,14 +1270,17 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
/* too big stiffness seems only ugly due to linear interpolation
* no need to have possibility for too big stiffness */
- if (ml->s > 10.0f)
+ if (ml->s > 10.0f) {
new_ml->s = 10.0f;
- else
+ }
+ else {
new_ml->s = ml->s;
+ }
/* if metaball is negative, set stiffness negative */
- if (new_ml->flag & MB_NEGATIVE)
+ if (new_ml->flag & MB_NEGATIVE) {
new_ml->s = -new_ml->s;
+ }
/* Translation of MetaElem */
unit_m4(pos);
@@ -1234,7 +1291,14 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
/* Rotation of MetaElem is stored in quat */
quat_to_mat4(rot, ml->quat);
- /* basis object space -> world -> ml object space -> position -> rotation -> ml local space */
+ /* Matrix multiply is as follows:
+ * basis object space ->
+ * world ->
+ * ml object space ->
+ * position ->
+ * rotation ->
+ * ml local space
+ */
mul_m4_series((float(*)[4])new_ml->mat, obinv, bob->obmat, pos, rot);
/* ml local space -> basis object space */
invert_m4_m4((float(*)[4])new_ml->imat, (float(*)[4])new_ml->mat);
@@ -1267,7 +1331,8 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
}
/* untransformed Bounding Box of MetaElem */
- /* TODO, its possible the elem type has been changed and the exp* values can use a fallback */
+ /* TODO, its possible the elem type has been changed and the exp*
+ * values can use a fallback. */
copy_v3_fl3(new_ml->bb->vec[0], -expx, -expy, -expz); /* 0 */
copy_v3_fl3(new_ml->bb->vec[1], +expx, -expy, -expz); /* 1 */
copy_v3_fl3(new_ml->bb->vec[2], +expx, +expy, -expz); /* 2 */
@@ -1278,8 +1343,9 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
copy_v3_fl3(new_ml->bb->vec[7], -expx, +expy, +expz); /* 7 */
/* transformation of Metalem bb */
- for (i = 0; i < 8; i++)
+ for (i = 0; i < 8; i++) {
mul_m4_v3((float(*)[4])new_ml->mat, new_ml->bb->vec[i]);
+ }
/* find max and min of transformed bb */
INIT_MINMAX(tempmin, tempmax);
@@ -1308,8 +1374,9 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje
if (process->totelem > 0) {
copy_v3_v3(process->allbb.min, process->mainb[0]->bb->vec[0]);
copy_v3_v3(process->allbb.max, process->mainb[0]->bb->vec[6]);
- for (i = 1; i < process->totelem; i++)
+ for (i = 1; i < process->totelem; i++) {
make_box_union(process->mainb[i]->bb, &process->allbb, &process->allbb);
+ }
}
}
@@ -1325,19 +1392,25 @@ void BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob, ListBa
process.thresh = mb->thresh;
- if (process.thresh < 0.001f)
+ if (process.thresh < 0.001f) {
process.converge_res = 16;
- else if (process.thresh < 0.01f)
+ }
+ else if (process.thresh < 0.01f) {
process.converge_res = 8;
- else if (process.thresh < 0.1f)
+ }
+ else if (process.thresh < 0.1f) {
process.converge_res = 4;
- else
+ }
+ else {
process.converge_res = 2;
+ }
- if (is_render && (mb->flag == MB_UPDATE_NEVER))
+ if (is_render && (mb->flag == MB_UPDATE_NEVER)) {
return;
- if ((G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_FAST)
+ }
+ if ((G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) && mb->flag == MB_UPDATE_FAST) {
return;
+ }
if (is_render) {
process.size = mb->rendersize;
@@ -1359,8 +1432,9 @@ void BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob, ListBa
if (process.totelem > 0) {
build_bvh_spatial(&process, &process.metaball_bvh, 0, process.totelem, &process.allbb);
- /* don't polygonize metaballs with too high resolution (base mball to small)
- * note: Eps was 0.0001f but this was giving problems for blood animation for durian, using 0.00001f */
+ /* Don't polygonize metaballs with too high resolution (base mball to small)
+ * note: Eps was 0.0001f but this was giving problems for blood animation for durian,
+ * using 0.00001f. */
if (ob->scale[0] > 0.00001f * (process.allbb.max[0] - process.allbb.min[0]) ||
ob->scale[1] > 0.00001f * (process.allbb.max[1] - process.allbb.min[1]) ||
ob->scale[2] > 0.00001f * (process.allbb.max[2] - process.allbb.min[2])) {
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 5df06e61744..56832c1724a 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -128,8 +128,9 @@ static int customdata_compare(
}
}
- if (i1 != i2)
+ if (i1 != i2) {
return MESHCMP_CDLAYERS_MISMATCH;
+ }
l1 = c1->layers;
l2 = c2->layers;
@@ -157,8 +158,9 @@ static int customdata_compare(
int vtot = m1->totvert;
for (j = 0; j < vtot; j++, v1++, v2++) {
- if (len_squared_v3v3(v1->co, v2->co) > thresh_sq)
+ if (len_squared_v3v3(v1->co, v2->co) > thresh_sq) {
return MESHCMP_VERTCOMISMATCH;
+ }
/* I don't care about normals, let's just do coordinates */
}
}
@@ -175,8 +177,9 @@ static int customdata_compare(
}
for (j = 0; j < etot; j++, e2++) {
- if (!BLI_edgehash_lookup(eh, e2->v1, e2->v2))
+ if (!BLI_edgehash_lookup(eh, e2->v1, e2->v2)) {
return MESHCMP_EDGEUNKNOWN;
+ }
}
BLI_edgehash_free(eh, NULL);
}
@@ -190,15 +193,17 @@ static int customdata_compare(
MLoop *lp1, *lp2;
int k;
- if (p1->totloop != p2->totloop)
+ if (p1->totloop != p2->totloop) {
return MESHCMP_POLYMISMATCH;
+ }
lp1 = m1->mloop + p1->loopstart;
lp2 = m2->mloop + p2->loopstart;
for (k = 0; k < p1->totloop; k++, lp1++, lp2++) {
- if (lp1->v != lp2->v)
+ if (lp1->v != lp2->v) {
return MESHCMP_POLYVERTMISMATCH;
+ }
}
}
}
@@ -208,8 +213,9 @@ static int customdata_compare(
int ltot = m1->totloop;
for (j = 0; j < ltot; j++, lp1++, lp2++) {
- if (lp1->v != lp2->v)
+ if (lp1->v != lp2->v) {
return MESHCMP_LOOPMISMATCH;
+ }
}
}
if (l1->type == CD_MLOOPUV) {
@@ -218,8 +224,9 @@ static int customdata_compare(
int ltot = m1->totloop;
for (j = 0; j < ltot; j++, lp1++, lp2++) {
- if (len_squared_v2v2(lp1->uv, lp2->uv) > thresh_sq)
+ if (len_squared_v2v2(lp1->uv, lp2->uv) > thresh_sq) {
return MESHCMP_LOOPUVMISMATCH;
+ }
}
}
@@ -245,14 +252,17 @@ static int customdata_compare(
int k;
MDeformWeight *dw1 = dv1->dw, *dw2 = dv2->dw;
- if (dv1->totweight != dv2->totweight)
+ if (dv1->totweight != dv2->totweight) {
return MESHCMP_DVERT_TOTGROUPMISMATCH;
+ }
for (k = 0; k < dv1->totweight; k++, dw1++, dw2++) {
- if (dw1->def_nr != dw2->def_nr)
+ if (dw1->def_nr != dw2->def_nr) {
return MESHCMP_DVERT_GROUPMISMATCH;
- if (fabsf(dw1->weight - dw2->weight) > thresh)
+ }
+ if (fabsf(dw1->weight - dw2->weight) > thresh) {
return MESHCMP_DVERT_WEIGHTMISMATCH;
+ }
}
}
}
@@ -271,32 +281,41 @@ const char *BKE_mesh_cmp(Mesh *me1, Mesh *me2, float thresh)
{
int c;
- if (!me1 || !me2)
+ if (!me1 || !me2) {
return "Requires two input meshes";
+ }
- if (me1->totvert != me2->totvert)
+ if (me1->totvert != me2->totvert) {
return "Number of verts don't match";
+ }
- if (me1->totedge != me2->totedge)
+ if (me1->totedge != me2->totedge) {
return "Number of edges don't match";
+ }
- if (me1->totpoly != me2->totpoly)
+ if (me1->totpoly != me2->totpoly) {
return "Number of faces don't match";
+ }
- if (me1->totloop != me2->totloop)
+ if (me1->totloop != me2->totloop) {
return "Number of loops don't match";
+ }
- if ((c = customdata_compare(&me1->vdata, &me2->vdata, me1, me2, thresh)))
+ if ((c = customdata_compare(&me1->vdata, &me2->vdata, me1, me2, thresh))) {
return cmpcode_to_str(c);
+ }
- if ((c = customdata_compare(&me1->edata, &me2->edata, me1, me2, thresh)))
+ if ((c = customdata_compare(&me1->edata, &me2->edata, me1, me2, thresh))) {
return cmpcode_to_str(c);
+ }
- if ((c = customdata_compare(&me1->ldata, &me2->ldata, me1, me2, thresh)))
+ if ((c = customdata_compare(&me1->ldata, &me2->ldata, me1, me2, thresh))) {
return cmpcode_to_str(c);
+ }
- if ((c = customdata_compare(&me1->pdata, &me2->pdata, me1, me2, thresh)))
+ if ((c = customdata_compare(&me1->pdata, &me2->pdata, me1, me2, thresh))) {
return cmpcode_to_str(c);
+ }
return NULL;
}
@@ -517,8 +536,10 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Mesh ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Mesh ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -573,17 +594,22 @@ void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int
/* Custom data layer functions; those assume that totXXX are set correctly. */
static void mesh_ensure_cdlayers_primary(Mesh *mesh, bool do_tessface)
{
- if (!CustomData_get_layer(&mesh->vdata, CD_MVERT))
+ if (!CustomData_get_layer(&mesh->vdata, CD_MVERT)) {
CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, NULL, mesh->totvert);
- if (!CustomData_get_layer(&mesh->edata, CD_MEDGE))
+ }
+ if (!CustomData_get_layer(&mesh->edata, CD_MEDGE)) {
CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_CALLOC, NULL, mesh->totedge);
- if (!CustomData_get_layer(&mesh->ldata, CD_MLOOP))
+ }
+ if (!CustomData_get_layer(&mesh->ldata, CD_MLOOP)) {
CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, NULL, mesh->totloop);
- if (!CustomData_get_layer(&mesh->pdata, CD_MPOLY))
+ }
+ if (!CustomData_get_layer(&mesh->pdata, CD_MPOLY)) {
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, NULL, mesh->totpoly);
+ }
- if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_MFACE))
+ if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_MFACE)) {
CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_CALLOC, NULL, mesh->totface);
+ }
}
Mesh *BKE_mesh_new_nomain(
@@ -831,8 +857,9 @@ bool BKE_mesh_uv_cdlayer_rename(Mesh *me,
/* Go back to absolute indices! */
lidx += lidx_start;
- if (fidx != -1)
+ if (fidx != -1) {
fidx += fidx_start;
+ }
return BKE_mesh_uv_cdlayer_rename_index(me, lidx, fidx, new_name, do_tessface);
}
@@ -844,14 +871,17 @@ void BKE_mesh_boundbox_calc(Mesh *me, float r_loc[3], float r_size[3])
float min[3], max[3];
float mloc[3], msize[3];
- if (me->bb == NULL)
+ if (me->bb == NULL) {
me->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
+ }
bb = me->bb;
- if (!r_loc)
+ if (!r_loc) {
r_loc = mloc;
- if (!r_size)
+ }
+ if (!r_size) {
r_size = msize;
+ }
INIT_MINMAX(min, max);
if (!BKE_mesh_minmax(me, min, max)) {
@@ -879,12 +909,15 @@ void BKE_mesh_texspace_calc(Mesh *me)
if (me->texflag & ME_AUTOSPACE) {
for (a = 0; a < 3; a++) {
- if (size[a] == 0.0f)
+ if (size[a] == 0.0f) {
size[a] = 1.0f;
- else if (size[a] > 0.0f && size[a] < 0.00001f)
+ }
+ else if (size[a] > 0.0f && size[a] < 0.00001f) {
size[a] = 0.00001f;
- else if (size[a] < 0.0f && size[a] > -0.00001f)
+ }
+ else if (size[a] < 0.0f && size[a] > -0.00001f) {
size[a] = -0.00001f;
+ }
}
copy_v3_v3(me->loc, loc);
@@ -895,7 +928,8 @@ void BKE_mesh_texspace_calc(Mesh *me)
BoundBox *BKE_mesh_boundbox_get(Object *ob)
{
- /* This is Object-level data access, DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
+ /* This is Object-level data access,
+ * DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
if (ob->runtime.bb == NULL || ob->runtime.bb->flag & BOUNDBOX_DIRTY) {
Mesh *me = ob->data;
float min[3], max[3];
@@ -922,12 +956,15 @@ BoundBox *BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float
BKE_mesh_texspace_calc(me);
}
- if (r_loc)
+ if (r_loc) {
copy_v3_v3(r_loc, me->loc);
- if (r_rot)
+ }
+ if (r_rot) {
copy_v3_v3(r_rot, me->rot);
- if (r_size)
+ }
+ if (r_size) {
copy_v3_v3(r_size, me->size);
+ }
return me->bb;
}
@@ -939,14 +976,18 @@ void BKE_mesh_texspace_get_reference(
BKE_mesh_texspace_calc(me);
}
- if (r_texflag != NULL)
+ if (r_texflag != NULL) {
*r_texflag = &me->texflag;
- if (r_loc != NULL)
+ }
+ if (r_loc != NULL) {
*r_loc = me->loc;
- if (r_rot != NULL)
+ }
+ if (r_rot != NULL) {
*r_rot = me->rot;
- if (r_size != NULL)
+ }
+ if (r_size != NULL) {
*r_size = me->size;
+ }
}
void BKE_mesh_texspace_copy_from_object(Mesh *me, Object *ob)
@@ -1026,7 +1067,8 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
nr--;
}
- /* check corrupt cases, bow-tie geometry, cant handle these because edge data wont exist so just return 0 */
+ /* Check corrupt cases, bow-tie geometry,
+ * cant handle these because edge data wont exist so just return 0. */
if (nr == 3) {
if (
/* real edges */
@@ -1053,8 +1095,9 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
SWAP(unsigned int, mface->v1, mface->v2);
SWAP(unsigned int, mface->v2, mface->v3);
- if (fdata)
+ if (fdata) {
CustomData_swap_corners(fdata, mfindex, corner_indices);
+ }
}
}
else if (nr == 4) {
@@ -1064,8 +1107,9 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
SWAP(unsigned int, mface->v1, mface->v3);
SWAP(unsigned int, mface->v2, mface->v4);
- if (fdata)
+ if (fdata) {
CustomData_swap_corners(fdata, mfindex, corner_indices);
+ }
}
}
@@ -1075,12 +1119,15 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
Mesh *BKE_mesh_from_object(Object *ob)
{
- if (ob == NULL)
+ if (ob == NULL) {
return NULL;
- if (ob->type == OB_MESH)
+ }
+ if (ob->type == OB_MESH) {
return ob->data;
- else
+ }
+ else {
return NULL;
+ }
}
void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *me)
@@ -1089,13 +1136,15 @@ void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *me)
multires_force_update(ob);
- if (ob == NULL)
+ if (ob == NULL) {
return;
+ }
if (ob->type == OB_MESH) {
old = ob->data;
- if (old)
+ if (old) {
id_us_min(&old->id);
+ }
ob->data = me;
id_us_plus((ID *)me);
}
@@ -1206,10 +1255,12 @@ float (*BKE_mesh_vertexCos_get(const Mesh *me, int *r_verts_len))[3]
int i, verts_len = me->totvert;
float(*cos)[3] = MEM_malloc_arrayN(verts_len, sizeof(*cos), "vertexcos1");
- if (r_verts_len)
+ if (r_verts_len) {
*r_verts_len = verts_len;
- for (i = 0; i < verts_len; i++)
+ }
+ for (i = 0; i < verts_len; i++) {
copy_v3_v3(cos[i], me->mvert[i].co);
+ }
return cos;
}
@@ -1222,8 +1273,9 @@ int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, unsigned
{
int j;
for (j = 0; j < poly->totloop; j++, loopstart++) {
- if (loopstart->v == vert)
+ if (loopstart->v == vert) {
return j;
+ }
}
return -1;
@@ -1256,12 +1308,15 @@ int poly_get_adj_loops_from_vert(const MPoly *poly,
*/
int BKE_mesh_edge_other_vert(const MEdge *e, int v)
{
- if (e->v1 == v)
+ if (e->v1 == v) {
return e->v2;
- else if (e->v2 == v)
+ }
+ else if (e->v2 == v) {
return e->v1;
- else
+ }
+ else {
return -1;
+ }
}
/**
@@ -1297,8 +1352,9 @@ void BKE_mesh_transform(Mesh *me, float mat[4][4], bool do_keys)
MVert *mvert = me->mvert;
float(*lnors)[3] = CustomData_get_layer(&me->ldata, CD_NORMAL);
- for (i = 0; i < me->totvert; i++, mvert++)
+ for (i = 0; i < me->totvert; i++, mvert++) {
mul_m4_v3(mat, mvert->co);
+ }
if (do_keys && me->key) {
KeyBlock *kb;
@@ -1311,7 +1367,8 @@ void BKE_mesh_transform(Mesh *me, float mat[4][4], bool do_keys)
}
/* don't update normals, caller can do this explicitly.
- * We do update loop normals though, those may not be auto-generated (see e.g. STL import script)! */
+ * We do update loop normals though, those may not be auto-generated
+ * (see e.g. STL import script)! */
if (lnors) {
float m3[3][3];
@@ -1436,8 +1493,9 @@ void BKE_mesh_mselect_validate(Mesh *me)
MSelect *mselect_src, *mselect_dst;
int i_src, i_dst;
- if (me->totselect == 0)
+ if (me->totselect == 0) {
return;
+ }
mselect_src = me->mselect;
mselect_dst = MEM_malloc_arrayN((me->totselect), sizeof(MSelect), "Mesh selection history");
@@ -1561,8 +1619,9 @@ void BKE_mesh_apply_vert_coords(Mesh *mesh, float (*vertCoords)[3])
vert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert);
mesh->mvert = vert;
- for (i = 0; i < mesh->totvert; ++i, ++vert)
+ for (i = 0; i < mesh->totvert; ++i, ++vert) {
copy_v3_v3(vert->co, vertCoords[i]);
+ }
mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
}
@@ -1576,8 +1635,9 @@ void BKE_mesh_apply_vert_normals(Mesh *mesh, short (*vertNormals)[3])
vert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert);
mesh->mvert = vert;
- for (i = 0; i < mesh->totvert; ++i, ++vert)
+ for (i = 0; i < mesh->totvert; ++i, ++vert) {
copy_v3_v3_short(vert->no, vertNormals[i]);
+ }
mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
}
@@ -1585,8 +1645,9 @@ void BKE_mesh_apply_vert_normals(Mesh *mesh, short (*vertNormals)[3])
/**
* Compute 'split' (aka loop, or per face corner's) normals.
*
- * \param r_lnors_spacearr: Allows to get computed loop normal space array. That data, among other things,
- * contains 'smooth fan' info, useful e.g. to split geometry along sharp edges...
+ * \param r_lnors_spacearr: Allows to get computed loop normal space array.
+ * That data, among other things, contains 'smooth fan' info, useful e.g.
+ * to split geometry along sharp edges...
*/
void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spacearr)
{
@@ -1596,7 +1657,8 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac
bool free_polynors = false;
/* Note that we enforce computing clnors when the clnor space array is requested by caller here.
- * However, we obviously only use the autosmooth angle threshold only in case autosmooth is enabled. */
+ * However, we obviously only use the autosmooth angle threshold
+ * only in case autosmooth is enabled. */
const bool use_split_normals = (r_lnors_spacearr != NULL) || ((mesh->flag & ME_AUTOSMOOTH) != 0);
const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? mesh->smoothresh : (float)M_PI;
@@ -1613,7 +1675,8 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac
clnors = CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL);
if (CustomData_has_layer(&mesh->pdata, CD_NORMAL)) {
- /* This assume that layer is always up to date, not sure this is the case (esp. in Edit mode?)... */
+ /* This assume that layer is always up to date, not sure this is the case
+ * (esp. in Edit mode?)... */
polynors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
free_polynors = false;
}
@@ -1683,8 +1746,9 @@ static int split_faces_prepare_new_verts(const Mesh *mesh,
SplitFaceNewVert **new_verts,
MemArena *memarena)
{
- /* This is now mandatory, trying to do the job in simple way without that data is doomed to fail, even when only
- * dealing with smooth/flat faces one can find cases that no simple algorithm can handle properly. */
+ /* This is now mandatory, trying to do the job in simple way without that data is doomed to fail,
+ * even when only dealing with smooth/flat faces one can find cases that no simple algorithm
+ * can handle properly. */
BLI_assert(lnors_spacearr != NULL);
const int loops_len = mesh->totloop;
@@ -1730,8 +1794,9 @@ static int split_faces_prepare_new_verts(const Mesh *mesh,
if (!vert_used) {
BLI_BITMAP_ENABLE(verts_used, vert_idx);
/* We need to update that vertex's normal here, we won't go over it again. */
- /* This is important! *DO NOT* set vnor to final computed lnor, vnor should always be defined to
- * 'automatic normal' value computed from its polys, not some custom normal.
+ /* This is important! *DO NOT* set vnor to final computed lnor,
+ * vnor should always be defined to 'automatic normal' value computed from its polys,
+ * not some custom normal.
* Fortunately, that's the loop normal space's 'lnor' reference vector. ;) */
normal_float_to_short_v3(mvert[vert_idx].no, (*lnor_space)->vec_lnor);
}
@@ -1883,8 +1948,9 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
mesh, &lnors_spacearr, &new_verts, memarena);
if (num_new_verts > 0) {
- /* Reminder: beyond this point, there is no way out, mesh is in invalid state (due to early-reassignment of
- * loops' vertex and edge indices to new, to-be-created split ones). */
+ /* Reminder: beyond this point, there is no way out, mesh is in invalid state
+ * (due to early-reassignment of loops' vertex and edge indices to new,
+ * to-be-created split ones). */
const int num_new_edges = split_faces_prepare_new_edges(mesh, &new_edges, memarena);
/* We can have to split a vertex without having to add a single new edge... */
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 6f96267ff55..3f4e504867c 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -77,8 +77,9 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me)
int a, *index;
dl = lb->first;
- if (dl == NULL)
+ if (dl == NULL) {
return;
+ }
if (dl->type == DL_INDEX4) {
mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, dl->nr);
@@ -109,8 +110,9 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me)
mloop[0].v = index[0];
mloop[1].v = index[1];
mloop[2].v = index[2];
- if (count == 4)
+ if (count == 4) {
mloop[3].v = index[3];
+ }
mpoly->totloop = count;
mpoly->loopstart = (int)(mloop - allloop);
@@ -307,8 +309,9 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
totpoly, 4 * sizeof(MLoop), "nurbs_init mloop"); // totloop
*r_allpoly = mpoly = MEM_calloc_arrayN(totpoly, sizeof(MPoly), "nurbs_init mloop");
- if (r_alluv)
+ if (r_alluv) {
*r_alluv = mloopuv = MEM_calloc_arrayN(totpoly, 4 * sizeof(MLoopUV), "nurbs_init mloopuv");
+ }
/* verts and faces */
vertcount = 0;
@@ -355,10 +358,12 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
ofs = a * dl->nr;
for (b = 0; b < dl->nr; b++) {
medge->v1 = startvert + ofs + b;
- if (b == dl->nr - 1)
+ if (b == dl->nr - 1) {
medge->v2 = startvert + ofs;
- else
+ }
+ else {
medge->v2 = startvert + ofs + b + 1;
+ }
medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW;
medge++;
}
@@ -395,8 +400,9 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
}
}
- if (is_smooth)
+ if (is_smooth) {
mpoly->flag |= ME_SMOOTH;
+ }
mpoly++;
mloop += 3;
index += 3;
@@ -415,8 +421,9 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
for (a = 0; a < dl->parts; a++) {
- if ((dl->flag & DL_CYCL_V) == 0 && a == dl->parts - 1)
+ if ((dl->flag & DL_CYCL_V) == 0 && a == dl->parts - 1) {
break;
+ }
if (dl->flag & DL_CYCL_U) { /* p2 -> p1 -> */
p1 = startvert + dl->nr * a; /* p4 -> p3 -> */
@@ -454,8 +461,9 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
/* exception as handled in convertblender.c too */
if (dl->flag & DL_CYCL_U) {
orco_sizeu++;
- if (dl->flag & DL_CYCL_V)
+ if (dl->flag & DL_CYCL_V) {
orco_sizev++;
+ }
}
else if (dl->flag & DL_CYCL_V) {
orco_sizev++;
@@ -469,15 +477,18 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob,
mloopuv->uv[1] = (v % dl->nr) / (float)orco_sizeu;
/* cyclic correction */
- if ((i == 1 || i == 2) && mloopuv->uv[0] == 0.0f)
+ if ((i == 1 || i == 2) && mloopuv->uv[0] == 0.0f) {
mloopuv->uv[0] = 1.0f;
- if ((i == 0 || i == 1) && mloopuv->uv[1] == 0.0f)
+ }
+ if ((i == 0 || i == 1) && mloopuv->uv[1] == 0.0f) {
mloopuv->uv[1] = 1.0f;
+ }
}
}
- if (is_smooth)
+ if (is_smooth) {
mpoly->flag |= ME_SMOOTH;
+ }
mpoly++;
mloop += 4;
@@ -645,7 +656,8 @@ void BKE_mesh_from_nurbs_displist(Main *bmain,
cu->mat = NULL;
cu->totcol = 0;
- /* Do not decrement ob->data usercount here, it's done at end of func with BKE_id_free_us() call. */
+ /* Do not decrement ob->data usercount here,
+ * it's done at end of func with BKE_id_free_us() call. */
ob->data = me;
ob->type = OB_MESH;
@@ -974,8 +986,9 @@ Mesh *BKE_mesh_new_from_object(Depsgraph *depsgraph,
}
/* if getting the original caged mesh, delete object modifiers */
- if (cage)
+ if (cage) {
BKE_object_free_modifiers(tmpobj, LIB_ID_CREATE_NO_USER_REFCOUNT);
+ }
/* copies the data, but *not* the shapekeys. */
BKE_id_copy_ex(NULL, object_for_eval.data, (ID **)&copycu, LIB_ID_COPY_LOCALIZE);
@@ -1024,9 +1037,10 @@ Mesh *BKE_mesh_new_from_object(Depsgraph *depsgraph,
BKE_id_free(NULL, tmpobj);
- /* XXX The curve to mesh conversion is convoluted... But essentially, BKE_mesh_from_nurbs_displist()
- * already transfers the ownership of materials from the temp copy of the Curve ID to the new
- * Mesh ID, so we do not want to increase materials' usercount later. */
+ /* XXX The curve to mesh conversion is convoluted...
+ * But essentially, BKE_mesh_from_nurbs_displist()
+ * already transfers the ownership of materials from the temp copy of the Curve ID to the
+ * new Mesh ID, so we do not want to increase materials' usercount later. */
do_mat_id_data_us = false;
break;
@@ -1182,8 +1196,9 @@ static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src)
Key *key = mesh_src->key;
int i;
- if (!mesh_src->key)
+ if (!mesh_src->key) {
return;
+ }
/* ensure we can use mesh vertex count for derived mesh custom data */
if (mesh_src->totvert != mesh_dest->totvert) {
@@ -1223,25 +1238,26 @@ static void add_shapekey_layers(Mesh *mesh_dest, Mesh *mesh_src)
Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
Scene *scene,
- Object *ob,
- ModifierData *md,
+ Object *ob_eval,
+ ModifierData *md_eval,
int build_shapekey_layers)
{
- Mesh *me = ob->runtime.mesh_orig ? ob->runtime.mesh_orig : ob->data;
- const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ Mesh *me = ob_eval->runtime.mesh_orig ? ob_eval->runtime.mesh_orig : ob_eval->data;
+ const ModifierTypeInfo *mti = modifierType_getInfo(md_eval->type);
Mesh *result;
KeyBlock *kb;
- ModifierEvalContext mectx = {depsgraph, ob, 0};
+ ModifierEvalContext mectx = {depsgraph, ob_eval, 0};
- if (!(md->mode & eModifierMode_Realtime)) {
+ if (!(md_eval->mode & eModifierMode_Realtime)) {
return NULL;
}
- if (mti->isDisabled && mti->isDisabled(scene, md, 0)) {
+ if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
return NULL;
}
- if (build_shapekey_layers && me->key && (kb = BLI_findlink(&me->key->block, ob->shapenr - 1))) {
+ if (build_shapekey_layers && me->key &&
+ (kb = BLI_findlink(&me->key->block, ob_eval->shapenr - 1))) {
BKE_keyblock_convert_to_mesh(kb, me);
}
@@ -1249,12 +1265,13 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
int numVerts;
float(*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
- mti->deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
BKE_id_copy_ex(NULL, &me->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
+ mti->deformVerts(md_eval, &mectx, result, deformedVerts, numVerts);
BKE_mesh_apply_vert_coords(result, deformedVerts);
- if (build_shapekey_layers)
+ if (build_shapekey_layers) {
add_shapekey_layers(result, me);
+ }
MEM_freeN(deformedVerts);
}
@@ -1262,10 +1279,11 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
Mesh *mesh_temp;
BKE_id_copy_ex(NULL, &me->id, (ID **)&mesh_temp, LIB_ID_COPY_LOCALIZE);
- if (build_shapekey_layers)
+ if (build_shapekey_layers) {
add_shapekey_layers(mesh_temp, me);
+ }
- result = mti->applyModifier(md, &mectx, mesh_temp);
+ result = mti->applyModifier(md_eval, &mectx, mesh_temp);
ASSERT_IS_VALID_MESH(result);
if (mesh_temp != result) {
@@ -1282,8 +1300,9 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act
KeyBlock *kb;
int i, j, tot;
- if (!mesh_dst->key)
+ if (!mesh_dst->key) {
return;
+ }
tot = CustomData_number_of_layers(&mesh_src->vdata, CD_SHAPEKEY);
for (i = 0; i < tot; i++) {
@@ -1292,8 +1311,9 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act
float(*cos)[3], (*kbcos)[3];
for (kb = mesh_dst->key->block.first; kb; kb = kb->next) {
- if (kb->uid == layer->uid)
+ if (kb->uid == layer->uid) {
break;
+ }
}
if (!kb) {
@@ -1301,8 +1321,9 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act
kb->uid = layer->uid;
}
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
cos = CustomData_get_layer_n(&mesh_src->vdata, CD_SHAPEKEY, i);
kb->totelem = mesh_src->totvert;
@@ -1324,8 +1345,9 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act
for (kb = mesh_dst->key->block.first; kb; kb = kb->next) {
if (kb->totelem != mesh_src->totvert) {
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
kb->totelem = mesh_src->totvert;
kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), __func__);
@@ -1342,7 +1364,8 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src,
bool take_ownership)
{
/* mesh_src might depend on mesh_dst, so we need to do everything with a local copy */
- /* TODO(Sybren): the above claim came from DM_to_mesh(); check whether it is still true with Mesh */
+ /* TODO(Sybren): the above claim came from DM_to_mesh();
+ * check whether it is still true with Mesh */
Mesh tmp = *mesh_dst;
int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly;
int did_shapekeys = 0;
@@ -1410,8 +1433,8 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src,
/* not all DerivedMeshes store their verts/edges/faces in CustomData, so
* we set them here in case they are missing */
- /* TODO(Sybren): we could probably replace CD_ASSIGN with alloctype and always directly pass mesh_src->mxxx,
- * instead of using a ternary operator. */
+ /* TODO(Sybren): we could probably replace CD_ASSIGN with alloctype and
+ * always directly pass mesh_src->mxxx, instead of using a ternary operator. */
if (!CustomData_has_layer(&tmp.vdata, CD_MVERT)) {
CustomData_add_layer(&tmp.vdata,
CD_MVERT,
@@ -1504,8 +1527,9 @@ void BKE_mesh_nomain_to_meshkey(Mesh *mesh_src, Mesh *mesh_dst, KeyBlock *kb)
return;
}
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
kb->data = MEM_malloc_arrayN(mesh_dst->key->elemsize, mesh_dst->totvert, "kb->data");
kb->totelem = totvert;
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 2ef1a009321..d889fca3a3a 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -165,9 +165,11 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
return;
}
- if (!pnors)
+ if (!pnors) {
pnors = MEM_calloc_arrayN((size_t)numPolys, sizeof(float[3]), __func__);
- /* if (!fnors) fnors = MEM_calloc_arrayN(numFaces, sizeof(float[3]), "face nors mesh.c"); */ /* NO NEED TO ALLOC YET */
+ }
+ /* NO NEED TO ALLOC YET */
+ /* if (!fnors) fnors = MEM_calloc_arrayN(numFaces, sizeof(float[3]), "face nors mesh.c"); */
if (only_face_normals == false) {
/* vertex normals are optional, they require some extra calculations,
@@ -199,8 +201,9 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts,
}
}
- if (pnors != r_polyNors)
+ if (pnors != r_polyNors) {
MEM_freeN(pnors);
+ }
/* if (fnors != r_faceNors) MEM_freeN(fnors); */ /* NO NEED TO ALLOC YET */
fnors = pnors = NULL;
@@ -364,7 +367,8 @@ void BKE_mesh_calc_normals_poly(MVert *mverts,
BLI_task_parallel_range(0, numPolys, &data, mesh_calc_normals_poly_prepare_cb, &settings);
/* Actually accumulate weighted loop normals into vertex ones. */
- /* Unfortunately, not possible to thread that (not in a reasonable, totally lock- and barrier-free fashion),
+ /* Unfortunately, not possible to thread that
+ * (not in a reasonable, totally lock- and barrier-free fashion),
* since several loops will point to the same vertex... */
for (int lidx = 0; lidx < numLoops; lidx++) {
add_v3_v3(vnors[mloop[lidx].v], data.lnors_weighted[lidx]);
@@ -422,7 +426,8 @@ void BKE_mesh_ensure_normals_for_display(Mesh *mesh)
}
}
-/* Note that this does not update the CD_NORMAL layer, but does update the normals in the CD_MVERT layer. */
+/* Note that this does not update the CD_NORMAL layer,
+ * but does update the normals in the CD_MVERT layer. */
void BKE_mesh_calc_normals(Mesh *mesh)
{
#ifdef DEBUG_TIME
@@ -462,11 +467,13 @@ void BKE_mesh_calc_normals_tessface(
float *n4 = (mf->v4) ? tnorms[mf->v4] : NULL;
const float *c4 = (mf->v4) ? mverts[mf->v4].co : NULL;
- if (mf->v4)
+ if (mf->v4) {
normal_quad_v3(
f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co);
- else
+ }
+ else {
normal_tri_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co);
+ }
accumulate_vertex_normals_v3(tnorms[mf->v1],
tnorms[mf->v2],
@@ -494,8 +501,9 @@ void BKE_mesh_calc_normals_tessface(
cleanup:
MEM_freeN(tnorms);
- if (fnors != r_faceNors)
+ if (fnors != r_faceNors) {
MEM_freeN(fnors);
+ }
}
void BKE_mesh_calc_normals_looptri(MVert *mverts,
@@ -550,8 +558,9 @@ void BKE_mesh_calc_normals_looptri(MVert *mverts,
cleanup:
MEM_freeN(tnorms);
- if (fnors != r_tri_nors)
+ if (fnors != r_tri_nors) {
MEM_freeN(fnors);
+ }
}
void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr,
@@ -603,7 +612,8 @@ MLoopNorSpace *BKE_lnor_space_create(MLoopNorSpaceArray *lnors_spacearr)
/* Should only be called once.
* Beware, this modifies ref_vec and other_vec in place!
- * In case no valid space can be generated, ref_alpha and ref_beta are set to zero (which means 'use auto lnors').
+ * In case no valid space can be generated, ref_alpha and ref_beta are set to zero
+ * (which means 'use auto lnors').
*/
void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
const float lnor[3],
@@ -640,8 +650,10 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
BLI_stack_discard(edge_vectors);
nbr++;
}
- /* Note: In theory, this could be 'nbr > 2', but there is one case where we only have two edges for
- * two loops: a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.). */
+ /* Note: In theory, this could be 'nbr > 2',
+ * but there is one case where we only have two edges for two loops:
+ * a smooth vertex with only two edges and two faces (our Monkey's nose has that, e.g.).
+ */
BLI_assert(nbr >= 2); /* This piece of code shall only be called for more than one loop... */
lnor_space->ref_alpha = alpha / (float)nbr;
}
@@ -677,10 +689,11 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
/**
* Add a new given loop to given lnor_space.
- * Depending on \a lnor_space->data_type, we expect \a bm_loop to be a pointer to BMLoop struct (in case of BMLOOP_PTR),
- * or NULL (in case of LOOP_INDEX), loop index is then stored in pointer.
- * If \a is_single is set, the BMLoop or loop index is directly stored in \a lnor_space->loops pointer (since there
- * is only one loop in this fan), else it is added to the linked list of loops in the fan.
+ * Depending on \a lnor_space->data_type, we expect \a bm_loop to be a pointer to BMLoop struct
+ * (in case of BMLOOP_PTR), or NULL (in case of LOOP_INDEX), loop index is then stored in pointer.
+ * If \a is_single is set, the BMLoop or loop index is directly stored in \a lnor_space->loops
+ * pointer (since there is only one loop in this fan),
+ * else it is added to the linked list of loops in the fan.
*/
void BKE_lnor_space_add_loop(MLoopNorSpaceArray *lnors_spacearr,
MLoopNorSpace *lnor_space,
@@ -769,7 +782,8 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space,
alpha = saacosf(cos_alpha);
if (alpha > lnor_space->ref_alpha) {
- /* Note we could stick to [0, pi] range here, but makes decoding more complex, not worth it. */
+ /* Note we could stick to [0, pi] range here,
+ * but makes decoding more complex, not worth it. */
r_clnor_data[0] = unit_float_to_short(-(pi2 - alpha) / (pi2 - lnor_space->ref_alpha));
}
else {
@@ -806,17 +820,20 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space,
typedef struct LoopSplitTaskData {
/* Specific to each instance (each task). */
- MLoopNorSpace *
- lnor_space; /* We have to create those outside of tasks, since afaik memarena is not threadsafe. */
+
+ /** We have to create those outside of tasks, since afaik memarena is not threadsafe. */
+ MLoopNorSpace *lnor_space;
float (*lnor)[3];
const MLoop *ml_curr;
const MLoop *ml_prev;
int ml_curr_index;
int ml_prev_index;
- const int *e2l_prev; /* Also used a flag to switch between single or fan process! */
+ /** Also used a flag to switch between single or fan process! */
+ const int *e2l_prev;
int mp_index;
- /* This one is special, it's owned and managed by worker tasks, avoid to have to create it for each fan! */
+ /** This one is special, it's owned and managed by worker tasks,
+ * avoid to have to create it for each fan! */
BLI_Stack *edge_vectors;
char pad_c;
@@ -824,8 +841,8 @@ typedef struct LoopSplitTaskData {
typedef struct LoopSplitTaskDataCommon {
/* Read/write.
- * Note we do not need to protect it, though, since two different tasks will *always* affect different
- * elements in the arrays. */
+ * Note we do not need to protect it, though, since two different tasks will *always* affect
+ * different elements in the arrays. */
MLoopNorSpaceArray *lnors_spacearr;
float (*loopnors)[3];
short (*clnors_data)[2];
@@ -889,8 +906,8 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
loop_to_poly[ml_curr_index] = mp_index;
- /* Pre-populate all loop normals as if their verts were all-smooth, this way we don't have to compute
- * those later!
+ /* Pre-populate all loop normals as if their verts were all-smooth,
+ * this way we don't have to compute those later!
*/
if (loopnors) {
normal_short_to_float_v3(loopnors[ml_curr_index], mverts[ml_curr->v].no);
@@ -910,8 +927,8 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
/* Second loop using this edge, time to test its sharpness.
* An edge is sharp if it is tagged as such, or its face is not smooth,
- * or both poly have opposed (flipped) normals, i.e. both loops on the same edge share the same vertex,
- * or angle between both its polys' normals is above split_angle value.
+ * or both poly have opposed (flipped) normals, i.e. both loops on the same edge share the
+ * same vertex, or angle between both its polys' normals is above split_angle value.
*/
if (!(mp->flag & ME_SMOOTH) || (medges[ml_curr->e].flag & ME_SHARP) ||
ml_curr->v == mloops[e2l[0]].v || is_angle_sharp) {
@@ -958,7 +975,8 @@ static void mesh_edges_sharp_tag(LoopSplitTaskDataCommon *data,
/** Define sharp edges as needed to mimic 'autosmooth' from angle threshold.
*
- * Used when defining an empty custom loop normals data layer, to keep same shading as with autosmooth!
+ * Used when defining an empty custom loop normals data layer,
+ * to keep same shading as with autosmooth!
*/
void BKE_edges_sharp_from_angle_set(const struct MVert *mverts,
const int UNUSED(numVerts),
@@ -1073,7 +1091,13 @@ static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopS
*/
copy_v3_v3(*lnor, polynors[mp_index]);
- // printf("BASIC: handling loop %d / edge %d / vert %d / poly %d\n", ml_curr_index, ml_curr->e, ml_curr->v, mp_index);
+#if 0
+ printf("BASIC: handling loop %d / edge %d / vert %d / poly %d\n",
+ ml_curr_index,
+ ml_curr->e,
+ ml_curr->v,
+ mp_index);
+#endif
/* If needed, generate this (simple!) lnor space. */
if (lnors_spacearr) {
@@ -1094,7 +1118,8 @@ static void split_loop_nor_single_do(LoopSplitTaskDataCommon *common_data, LoopS
normalize_v3(vec_prev);
BKE_lnor_space_define(lnor_space, *lnor, vec_curr, vec_prev, NULL);
- /* We know there is only one loop in this space, no need to create a linklist in this case... */
+ /* We know there is only one loop in this space,
+ * no need to create a linklist in this case... */
BKE_lnor_space_add_loop(lnors_spacearr, lnor_space, ml_curr_index, NULL, true);
if (clnors_data) {
@@ -1119,7 +1144,7 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
MLoopNorSpace *lnor_space = data->lnor_space;
#if 0 /* Not needed for 'fan' loops. */
- float (*lnor)[3] = data->lnor;
+ float(*lnor)[3] = data->lnor;
#endif
const MLoop *ml_curr = data->ml_curr;
const MLoop *ml_prev = data->ml_prev;
@@ -1132,10 +1157,10 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
/* Gah... We have to fan around current vertex, until we find the other non-smooth edge,
* and accumulate face normals into the vertex!
- * Note in case this vertex has only one sharp edges, this is a waste because the normal is the same as
- * the vertex normal, but I do not see any easy way to detect that (would need to count number
- * of sharp edges per vertex, I doubt the additional memory usage would be worth it, especially as
- * it should not be a common case in real-life meshes anyway).
+ * Note in case this vertex has only one sharp edges, this is a waste because the normal is the
+ * same as the vertex normal, but I do not see any easy way to detect that (would need to count
+ * number of sharp edges per vertex, I doubt the additional memory usage would be worth it,
+ * especially as it should not be a common case in real-life meshes anyway).
*/
const unsigned int mv_pivot_index = ml_curr->v; /* The vertex we are "fanning" around! */
const MVert *mv_pivot = &mverts[mv_pivot_index];
@@ -1187,8 +1212,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
while (true) {
const MEdge *me_curr = &medges[mlfan_curr->e];
/* Compute edge vectors.
- * NOTE: We could pre-compute those into an array, in the first iteration, instead of computing them
- * twice (or more) here. However, time gained is not worth memory and time lost,
+ * NOTE: We could pre-compute those into an array, in the first iteration, instead of computing
+ * them twice (or more) here. However, time gained is not worth memory and time lost,
* given the fact that this code should not be called that much in real-life meshes...
*/
{
@@ -1287,13 +1312,14 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
printf("Invalid clnors in this fan!\n");
}
while ((clnor = BLI_SMALLSTACK_POP(clnors))) {
- //print_v2("org clnor", clnor);
+ // print_v2("org clnor", clnor);
clnor[0] = (short)clnors_avg[0];
clnor[1] = (short)clnors_avg[1];
}
- //print_v2("new clnors", clnors_avg);
+ // print_v2("new clnors", clnors_avg);
}
- /* Extra bonus: since smallstack is local to this func, no more need to empty it at all cost! */
+ /* Extra bonus: since smallstack is local to this func,
+ * no more need to empty it at all cost! */
BKE_lnor_space_custom_data_to_normal(lnor_space, *clnor_ref, lnor);
}
@@ -1308,7 +1334,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
copy_v3_v3(nor, lnor);
}
}
- /* Extra bonus: since smallstack is local to this func, no more need to empty it at all cost! */
+ /* Extra bonus: since smallstack is local to this func,
+ * no more need to empty it at all cost! */
}
}
@@ -1361,7 +1388,8 @@ static void loop_split_worker(TaskPool *__restrict pool, void *taskdata, int UNU
}
/* Check whether gievn loop is part of an unknown-so-far cyclic smooth fan, or not.
- * Needed because cyclic smooth fans have no obvious 'entry point', and yet we need to walk them once, and only once. */
+ * Needed because cyclic smooth fans have no obvious 'entry point',
+ * and yet we need to walk them once, and only once. */
static bool loop_split_generator_check_cyclic_smooth_fan(const MLoop *mloops,
const MPoly *mpolys,
const int (*edge_to_loops)[2],
@@ -1419,8 +1447,8 @@ static bool loop_split_generator_check_cyclic_smooth_fan(const MLoop *mloops,
/* Smooth loop/edge... */
else if (BLI_BITMAP_TEST(skip_loops, mlfan_vert_index)) {
if (mlfan_vert_index == ml_curr_index) {
- /* We walked around a whole cyclic smooth fan without finding any already-processed loop, means we can
- * use initial ml_curr/ml_prev edge as start for this smooth fan. */
+ /* We walked around a whole cyclic smooth fan without finding any already-processed loop,
+ * means we can use initial ml_curr/ml_prev edge as start for this smooth fan. */
return true;
}
/* ... already checked in some previous looping, we can abort. */
@@ -1458,7 +1486,8 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
LoopSplitTaskData *data_buff = NULL;
int data_idx = 0;
- /* Temp edge vectors stack, only used when computing lnor spacearr (and we are not multi-threading). */
+ /* Temp edge vectors stack, only used when computing lnor spacearr
+ * (and we are not multi-threading). */
BLI_Stack *edge_vectors = NULL;
#ifdef DEBUG_TIME
@@ -1471,8 +1500,8 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
}
}
- /* We now know edges that can be smoothed (with their vector, and their two loops), and edges that will be hard!
- * Now, time to generate the normals.
+ /* We now know edges that can be smoothed (with their vector, and their two loops),
+ * and edges that will be hard! Now, time to generate the normals.
*/
for (mp = mpolys, mp_index = 0; mp_index < numPolys; mp++, mp_index++) {
float(*lnors)[3];
@@ -1488,17 +1517,25 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
const int *e2l_curr = edge_to_loops[ml_curr->e];
const int *e2l_prev = edge_to_loops[ml_prev->e];
- // printf("Checking loop %d / edge %u / vert %u (sharp edge: %d, skiploop: %d)...",
- // ml_curr_index, ml_curr->e, ml_curr->v, IS_EDGE_SHARP(e2l_curr), BLI_BITMAP_TEST_BOOL(skip_loops, ml_curr_index));
+#if 0
+ printf("Checking loop %d / edge %u / vert %u (sharp edge: %d, skiploop: %d)...",
+ ml_curr_index,
+ ml_curr->e,
+ ml_curr->v,
+ IS_EDGE_SHARP(e2l_curr),
+ BLI_BITMAP_TEST_BOOL(skip_loops, ml_curr_index));
+#endif
/* A smooth edge, we have to check for cyclic smooth fan case.
- * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge as
- * 'entry point', otherwise we can skip it. */
+ * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge
+ * as 'entry point', otherwise we can skip it. */
+
/* Note: In theory, we could make loop_split_generator_check_cyclic_smooth_fan() store
- * mlfan_vert_index'es and edge indexes in two stacks, to avoid having to fan again around the vert during
- * actual computation of clnor & clnorspace. However, this would complicate the code, add more memory usage,
- * and despite its logical complexity, loop_manifold_fan_around_vert_next() is quite cheap in term of
- * CPU cycles, so really think it's not worth it. */
+ * mlfan_vert_index'es and edge indexes in two stacks, to avoid having to fan again around
+ * the vert during actual computation of clnor & clnorspace. However, this would complicate
+ * the code, add more memory usage, and despite its logical complexity,
+ * loop_manifold_fan_around_vert_next() is quite cheap in term of CPU cycles,
+ * so really think it's not worth it. */
if (!IS_EDGE_SHARP(e2l_curr) && (BLI_BITMAP_TEST(skip_loops, ml_curr_index) ||
!loop_split_generator_check_cyclic_smooth_fan(mloops,
mpolys,
@@ -1537,7 +1574,7 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
data->ml_curr_index = ml_curr_index;
#if 0 /* Not needed for 'single' loop. */
data->ml_prev_index = ml_prev_index;
- data->e2l_prev = NULL; /* Tag as 'single' task. */
+ data->e2l_prev = NULL; /* Tag as 'single' task. */
#endif
data->mp_index = mp_index;
if (lnors_spacearr) {
@@ -1545,10 +1582,11 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
}
}
/* We *do not need* to check/tag loops as already computed!
- * Due to the fact a loop only links to one of its two edges, a same fan *will never be walked
- * more than once!*
- * Since we consider edges having neighbor polys with inverted (flipped) normals as sharp, we are sure
- * that no fan will be skipped, even only considering the case (sharp curr_edge, smooth prev_edge),
+ * Due to the fact a loop only links to one of its two edges,
+ * a same fan *will never be walked more than once!*
+ * Since we consider edges having neighbor polys with inverted
+ * (flipped) normals as sharp, we are sure that no fan will be skipped,
+ * even only considering the case (sharp curr_edge, smooth prev_edge),
* and not the alternative (smooth curr_edge, sharp prev_edge).
* All this due/thanks to link between normals and loop ordering (i.e. winding).
*/
@@ -1584,7 +1622,8 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
}
}
- /* Last block of data... Since it is calloc'ed and we use first NULL item as stopper, everything is fine. */
+ /* Last block of data... Since it is calloc'ed and we use first NULL item as stopper,
+ * everything is fine. */
if (pool && data_idx) {
BLI_task_pool_push(pool, loop_split_worker, data_buff, true, TASK_PRIORITY_LOW);
}
@@ -1601,7 +1640,8 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
/**
* Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals').
- * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges).
+ * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry
+ * (splitting edges).
*/
void BKE_mesh_normals_loop_split(const MVert *mverts,
const int UNUSED(numVerts),
@@ -1619,14 +1659,17 @@ void BKE_mesh_normals_loop_split(const MVert *mverts,
short (*clnors_data)[2],
int *r_loop_to_poly)
{
- /* For now this is not supported. If we do not use split normals, we do not generate anything fancy! */
+ /* For now this is not supported.
+ * If we do not use split normals, we do not generate anything fancy! */
BLI_assert(use_split_normals || !(r_lnors_spacearr));
if (!use_split_normals) {
/* In this case, we simply fill lnors with vnors (or fnors for flat faces), quite simple!
* Note this is done here to keep some logic and consistency in this quite complex code,
- * since we may want to use lnors even when mesh's 'autosmooth' is disabled (see e.g. mesh mapping code).
- * As usual, we could handle that on case-by-case basis, but simpler to keep it well confined here.
+ * since we may want to use lnors even when mesh's 'autosmooth' is disabled
+ * (see e.g. mesh mapping code).
+ * As usual, we could handle that on case-by-case basis,
+ * but simpler to keep it well confined here.
*/
int mp_index;
@@ -1651,15 +1694,20 @@ void BKE_mesh_normals_loop_split(const MVert *mverts,
return;
}
- /* Mapping edge -> loops.
- * If that edge is used by more than two loops (polys), it is always sharp (and tagged as such, see below).
- * We also use the second loop index as a kind of flag: smooth edge: > 0,
- * sharp edge: < 0 (INDEX_INVALID || INDEX_UNSET),
- * unset: INDEX_UNSET
- * Note that currently we only have two values for second loop of sharp edges. However, if needed, we can
- * store the negated value of loop index instead of INDEX_INVALID to retrieve the real value later in code).
- * Note also that lose edges always have both values set to 0!
- */
+ /**
+ * Mapping edge -> loops.
+ * If that edge is used by more than two loops (polys),
+ * it is always sharp (and tagged as such, see below).
+ * We also use the second loop index as a kind of flag:
+ *
+ * - smooth edge: > 0.
+ * - sharp edge: < 0 (INDEX_INVALID || INDEX_UNSET).
+ * - unset: INDEX_UNSET.
+ *
+ * Note that currently we only have two values for second loop of sharp edges.
+ * However, if needed, we can store the negated value of loop index instead of INDEX_INVALID
+ * to retrieve the real value later in code).
+ * Note also that lose edges always have both values set to 0! */
int(*edge_to_loops)[2] = MEM_calloc_arrayN((size_t)numEdges, sizeof(*edge_to_loops), __func__);
/* Simple mapping from a loop to its polygon index. */
@@ -1744,12 +1792,12 @@ void BKE_mesh_normals_loop_split(const MVert *mverts,
/**
* Compute internal representation of given custom normals (as an array of float[2]).
- * It also makes sure the mesh matches those custom normals, by setting sharp edges flag as needed to get a
- * same custom lnor for all loops sharing a same smooth fan.
+ * It also makes sure the mesh matches those custom normals, by setting sharp edges flag as needed
+ * to get a same custom lnor for all loops sharing a same smooth fan.
* If use_vertices if true, r_custom_loopnors is assumed to be per-vertex, not per-loop
* (this allows to set whole vert's normals at once, useful in some cases).
- * r_custom_loopnors is expected to have normalized normals, or zero ones, in which case they will be replaced
- * by default loop/vertex normal.
+ * r_custom_loopnors is expected to have normalized normals, or zero ones,
+ * in which case they will be replaced by default loop/vertex normal.
*/
static void mesh_normals_loop_custom_set(const MVert *mverts,
const int numVerts,
@@ -1764,17 +1812,19 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
short (*r_clnors_data)[2],
const bool use_vertices)
{
- /* We *may* make that poor BKE_mesh_normals_loop_split() even more complex by making it handling that
- * feature too, would probably be more efficient in absolute.
+ /* We *may* make that poor BKE_mesh_normals_loop_split() even more complex by making it handling
+ * that feature too, would probably be more efficient in absolute.
* However, this function *is not* performance-critical, since it is mostly expected to be called
- * by io addons when importing custom normals, and modifier (and perhaps from some editing tools later?).
+ * by io addons when importing custom normals, and modifier
+ * (and perhaps from some editing tools later?).
* So better to keep some simplicity here, and just call BKE_mesh_normals_loop_split() twice!
*/
MLoopNorSpaceArray lnors_spacearr = {NULL};
BLI_bitmap *done_loops = BLI_BITMAP_NEW((size_t)numLoops, __func__);
float(*lnors)[3] = MEM_calloc_arrayN((size_t)numLoops, sizeof(*lnors), __func__);
int *loop_to_poly = MEM_malloc_arrayN((size_t)numLoops, sizeof(int), __func__);
- /* In this case we always consider split nors as ON, and do not want to use angle to define smooth fans! */
+ /* In this case we always consider split nors as ON,
+ * and do not want to use angle to define smooth fans! */
const bool use_split_normals = true;
const float split_angle = (float)M_PI;
int i;
@@ -1816,12 +1866,12 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
BLI_assert(lnors_spacearr.data_type == MLNOR_SPACEARR_LOOP_INDEX);
- /* Now, check each current smooth fan (one lnor space per smooth fan!), and if all its matching custom lnors
- * are not (enough) equal, add sharp edges as needed.
- * This way, next time we run BKE_mesh_normals_loop_split(), we'll get lnor spacearr/smooth fans matching
- * given custom lnors.
- * Note this code *will never* unsharp edges!
- * And quite obviously, when we set custom normals per vertices, running this is absolutely useless.
+ /* Now, check each current smooth fan (one lnor space per smooth fan!),
+ * and if all its matching custom lnors are not (enough) equal, add sharp edges as needed.
+ * This way, next time we run BKE_mesh_normals_loop_split(), we'll get lnor spacearr/smooth fans
+ * matching given custom lnors.
+ * Note this code *will never* unsharp edges! And quite obviously,
+ * when we set custom normals per vertices, running this is absolutely useless.
*/
if (!use_vertices) {
for (i = 0; i < numLoops; i++) {
@@ -1839,13 +1889,13 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
if (!BLI_BITMAP_TEST(done_loops, i)) {
/* Notes:
- * * In case of mono-loop smooth fan, we have nothing to do.
- * * Loops in this linklist are ordered (in reversed order compared to how they were discovered by
- * BKE_mesh_normals_loop_split(), but this is not a problem). Which means if we find a
- * mismatching clnor, we know all remaining loops will have to be in a new, different smooth fan/
- * lnor space.
- * * In smooth fan case, we compare each clnor against a ref one, to avoid small differences adding
- * up into a real big one in the end!
+ * * In case of mono-loop smooth fan, we have nothing to do.
+ * * Loops in this linklist are ordered (in reversed order compared to how they were
+ * discovered by BKE_mesh_normals_loop_split(), but this is not a problem).
+ * Which means if we find a mismatching clnor,
+ * we know all remaining loops will have to be in a new, different smooth fan/lnor space.
+ * * In smooth fan case, we compare each clnor against a ref one,
+ * to avoid small differences adding up into a real big one in the end!
*/
if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
BLI_BITMAP_ENABLE(done_loops, i);
@@ -1868,8 +1918,8 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
else if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) {
/* Current normal differs too much from org one, we have to tag the edge between
* previous loop's face and current's one as sharp.
- * We know those two loops do not point to the same edge, since we do not allow reversed winding
- * in a same smooth fan.
+ * We know those two loops do not point to the same edge,
+ * since we do not allow reversed winding in a same smooth fan.
*/
const MPoly *mp = &mpolys[loop_to_poly[lidx]];
const MLoop *mlp =
@@ -1884,7 +1934,8 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
BLI_BITMAP_ENABLE(done_loops, lidx);
}
- /* We also have to check between last and first loops, otherwise we may miss some sharp edges here!
+ /* We also have to check between last and first loops,
+ * otherwise we may miss some sharp edges here!
* This is just a simplified version of above while loop.
* See T45984. */
loops = lnors_spacearr.lspacearr[i]->loops;
@@ -1926,7 +1977,8 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
BLI_bitmap_set_all(done_loops, true, (size_t)numLoops);
}
- /* And we just have to convert plain object-space custom normals to our lnor space-encoded ones. */
+ /* And we just have to convert plain object-space custom normals to our
+ * lnor space-encoded ones. */
for (i = 0; i < numLoops; i++) {
if (!lnors_spacearr.lspacearr[i]) {
BLI_BITMAP_DISABLE(done_loops, i);
@@ -1937,9 +1989,9 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
}
if (BLI_BITMAP_TEST_BOOL(done_loops, i)) {
- /* Note we accumulate and average all custom normals in current smooth fan, to avoid getting different
- * clnors data (tiny differences in plain custom normals can give rather huge differences in
- * computed 2D factors).
+ /* Note we accumulate and average all custom normals in current smooth fan,
+ * to avoid getting different clnors data (tiny differences in plain custom normals can
+ * give rather huge differences in computed 2D factors).
*/
LinkNode *loops = lnors_spacearr.lspacearr[i]->loops;
if (lnors_spacearr.lspacearr[i]->flags & MLNOR_SPACE_IS_SINGLE) {
@@ -2086,7 +2138,8 @@ static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const
}
/**
- * Higher level functions hiding most of the code needed around call to #BKE_mesh_normals_loop_custom_set().
+ * Higher level functions hiding most of the code needed around call to
+ * #BKE_mesh_normals_loop_custom_set().
*
* \param r_custom_loopnors is not const, since code will replace zero_v3 normals there
* with automatically computed vectors.
@@ -2097,7 +2150,8 @@ void BKE_mesh_set_custom_normals(Mesh *mesh, float (*r_custom_loopnors)[3])
}
/**
- * Higher level functions hiding most of the code needed around call to #BKE_mesh_normals_loop_custom_from_vertices_set().
+ * Higher level functions hiding most of the code needed around call to
+ * #BKE_mesh_normals_loop_custom_from_vertices_set().
*
* \param r_custom_loopnors is not const, since code will replace zero_v3 normals there
* with automatically computed vectors.
@@ -2321,7 +2375,8 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const
}
/**
- * Calculate the volume and volume-weighted centroid of the volume formed by the polygon and the origin.
+ * Calculate the volume and volume-weighted centroid of the volume
+ * formed by the polygon and the origin.
* Results will be negative if the origin is "outside" the polygon
* (+ve normal side), but the polygon may be non-planar with no effect.
*
@@ -2333,8 +2388,8 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const
* - Volume is 6x actual volume, and centroid is 4x actual volume-weighted centroid
* (so division can be done once at the end).
* - Results will have bias if polygon is non-planar.
- * - The resulting volume will only be correct if the mesh is manifold and has consistent face winding
- * (non-contiguous face normals or holes in the mesh surface).
+ * - The resulting volume will only be correct if the mesh is manifold and has consistent
+ * face winding (non-contiguous face normals or holes in the mesh surface).
*/
static float mesh_calc_poly_volume_centroid(const MPoly *mpoly,
const MLoop *loopstart,
@@ -2363,7 +2418,8 @@ static float mesh_calc_poly_volume_centroid(const MPoly *mpoly,
* of the triangle and the origin as the fourth vertex.
* The centroid is simply the average of the 4 vertices.
*
- * Note that the vector is 4x the actual centroid so the division can be done once at the end. */
+ * Note that the vector is 4x the actual centroid
+ * so the division can be done once at the end. */
for (uint j = 0; j < 3; j++) {
r_cent[j] += tetra_volume * (v_pivot[j] + v_step1[j] + v_step2[j]);
}
@@ -2535,7 +2591,8 @@ bool BKE_mesh_center_of_surface(const Mesh *me, float r_cent[3])
}
/**
- * \note Mesh must be manifold with consistent face-winding, see #mesh_calc_poly_volume_centroid for details.
+ * \note Mesh must be manifold with consistent face-winding,
+ * see #mesh_calc_poly_volume_centroid for details.
*/
bool BKE_mesh_center_of_volume(const Mesh *me, float r_cent[3])
{
@@ -2559,7 +2616,8 @@ bool BKE_mesh_center_of_volume(const Mesh *me, float r_cent[3])
/* otherwise we get NAN for 0 polys */
if (total_volume != 0.0f) {
/* multiply by 0.25 to get the correct centroid */
- /* no need to divide volume by 6 as the centroid is weighted by 6x the volume, so it all cancels out */
+ /* no need to divide volume by 6 as the centroid is weighted by 6x the volume,
+ * so it all cancels out. */
mul_v3_fl(r_cent, 0.25f / total_volume);
}
@@ -2590,8 +2648,9 @@ static bool mesh_calc_center_centroid_ex(const MVert *mverts,
zero_v3(r_center);
- if (looptri_num == 0)
+ if (looptri_num == 0) {
return false;
+ }
totweight = 0.0f;
for (i = 0, lt = looptri; i < looptri_num; i++, lt++) {
@@ -2606,8 +2665,9 @@ static bool mesh_calc_center_centroid_ex(const MVert *mverts,
madd_v3_v3fl(r_center, v3->co, area);
totweight += area;
}
- if (totweight == 0.0f)
+ if (totweight == 0.0f) {
return false;
+ }
mul_v3_fl(r_center, 1.0f / (3.0f * totweight));
@@ -2633,16 +2693,20 @@ void BKE_mesh_calc_volume(const MVert *mverts,
float totvol;
int i;
- if (r_volume)
+ if (r_volume) {
*r_volume = 0.0f;
- if (r_center)
+ }
+ if (r_center) {
zero_v3(r_center);
+ }
- if (looptri_num == 0)
+ if (looptri_num == 0) {
return;
+ }
- if (!mesh_calc_center_centroid_ex(mverts, mverts_num, looptri, looptri_num, mloop, center))
+ if (!mesh_calc_center_centroid_ex(mverts, mverts_num, looptri, looptri_num, mloop, center)) {
return;
+ }
totvol = 0.0f;
@@ -2675,8 +2739,9 @@ void BKE_mesh_calc_volume(const MVert *mverts,
/* Note: Factor 1/3 is applied once for all vertices here.
* This also automatically negates the vector if totvol is negative.
*/
- if (totvol != 0.0f)
+ if (totvol != 0.0f) {
mul_v3_fl(r_center, (1.0f / 3.0f) / totvol);
+ }
}
}
@@ -2761,9 +2826,11 @@ void BKE_mesh_loops_to_mface_corners(
/**
* Convert all CD layers from loop/poly to tessface data.
*
- * \param loopindices: is an array of an int[4] per tessface, mapping tessface's verts to loops indices.
+ * \param loopindices: is an array of an int[4] per tessface,
+ * mapping tessface's verts to loops indices.
*
- * \note when mface is not NULL, mface[face_index].v4 is used to test quads, else, loopindices[face_index][3] is used.
+ * \note when mface is not NULL, mface[face_index].v4
+ * is used to test quads, else, loopindices[face_index][3] is used.
*/
void BKE_mesh_loops_to_tessdata(CustomData *fdata,
CustomData *ldata,
@@ -2772,9 +2839,10 @@ void BKE_mesh_loops_to_tessdata(CustomData *fdata,
unsigned int (*loopindices)[4],
const int num_faces)
{
- /* Note: performances are sub-optimal when we get a NULL mface, we could be ~25% quicker with dedicated code...
- * Issue is, unless having two different functions with nearly the same code, there's not much ways to solve
- * this. Better imho to live with it for now. :/ --mont29
+ /* Note: performances are sub-optimal when we get a NULL mface,
+ * we could be ~25% quicker with dedicated code...
+ * Issue is, unless having two different functions with nearly the same code,
+ * there's not much ways to solve this. Better imho to live with it for now. :/ --mont29
*/
const int numUV = CustomData_number_of_layers(ldata, CD_MLOOPUV);
const int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
@@ -2865,9 +2933,10 @@ void BKE_mesh_tangent_loops_to_tessdata(CustomData *fdata,
const int num_faces,
const char *layer_name)
{
- /* Note: performances are sub-optimal when we get a NULL mface, we could be ~25% quicker with dedicated code...
- * Issue is, unless having two different functions with nearly the same code, there's not much ways to solve
- * this. Better imho to live with it for now. :/ --mont29
+ /* Note: performances are sub-optimal when we get a NULL mface,
+ * we could be ~25% quicker with dedicated code...
+ * Issue is, unless having two different functions with nearly the same code,
+ * there's not much ways to solve this. Better imho to live with it for now. :/ --mont29
*/
float(*ftangents)[4] = NULL;
@@ -2877,17 +2946,21 @@ void BKE_mesh_tangent_loops_to_tessdata(CustomData *fdata,
const int *pidx;
unsigned int(*lidx)[4];
- if (layer_name)
+ if (layer_name) {
ltangents = CustomData_get_layer_named(ldata, CD_TANGENT, layer_name);
- else
+ }
+ else {
ltangents = CustomData_get_layer(ldata, CD_TANGENT);
+ }
if (ltangents) {
/* need to do for all uv maps at some point */
- if (layer_name)
+ if (layer_name) {
ftangents = CustomData_get_layer_named(fdata, CD_TANGENT, layer_name);
- else
+ }
+ else {
ftangents = CustomData_get_layer(fdata, CD_TANGENT);
+ }
if (ftangents) {
for (findex = 0, pidx = polyindices, lidx = loopindices; findex < num_faces;
pidx++, lidx++, findex++) {
@@ -2903,7 +2976,8 @@ void BKE_mesh_tangent_loops_to_tessdata(CustomData *fdata,
/**
* Recreate tessellation.
*
- * \param do_face_nor_copy: Controls whether the normals from the poly are copied to the tessellated faces.
+ * \param do_face_nor_copy: Controls whether the normals from the poly
+ * are copied to the tessellated faces.
*
* \return number of tessellation faces.
*/
@@ -3133,9 +3207,11 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
/* NOTE: quad detection issue - fourth vertidx vs fourth loopidx:
* Polygons take care of their loops ordering, hence not of their vertices ordering.
- * Currently, our tfaces' fourth vertex index might be 0 even for a quad. However, we know our fourth loop index is
- * never 0 for quads (because they are sorted for polygons, and our quads are still mere copies of their polygons).
- * So we pass NULL as MFace pointer, and BKE_mesh_loops_to_tessdata will use the fourth loop index as quad test.
+ * Currently, our tfaces' fourth vertex index might be 0 even for a quad. However,
+ * we know our fourth loop index is never 0 for quads (because they are sorted for polygons,
+ * and our quads are still mere copies of their polygons).
+ * So we pass NULL as MFace pointer, and BKE_mesh_loops_to_tessdata
+ * will use the fourth loop index as quad test.
* ...
*/
BKE_mesh_loops_to_tessdata(fdata, ldata, NULL, mface_to_poly_map, lindices, totface);
@@ -3398,8 +3474,9 @@ static void bm_corners_to_loops_ex(ID *id,
ld->totdisp = side_sq;
ld->level = (int)(logf((float)side - 1.0f) / (float)M_LN2) + 1;
- if (ld->disps)
+ if (ld->disps) {
MEM_freeN(ld->disps);
+ }
ld->disps = MEM_malloc_arrayN((size_t)side_sq, sizeof(float[3]), "converted loop mdisps");
if (fd->disps) {
@@ -3433,15 +3510,17 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
BKE_mesh_update_customdata_pointers(mesh, true);
}
-/* the same as BKE_mesh_convert_mfaces_to_mpolys but oriented to be used in do_versions from readfile.c
+/**
+ * The same as #BKE_mesh_convert_mfaces_to_mpolys
+ * but oriented to be used in #do_versions from readfile.c
* the difference is how active/render/clone/stencil indices are handled here
*
* normally thay're being set from pdata which totally makes sense for meshes which are already
* converted to bmesh structures, but when loading older files indices shall be updated in other
* way around, so newly added pdata and ldata would have this indices set based on fdata layer
*
- * this is normally only needed when reading older files, in all other cases BKE_mesh_convert_mfaces_to_mpolys
- * shall be always used
+ * this is normally only needed when reading older files,
+ * in all other cases #BKE_mesh_convert_mfaces_to_mpolys shall be always used
*/
void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
{
@@ -3526,7 +3605,8 @@ void BKE_mesh_convert_mfaces_to_mpolys_ex(ID *id,
for (i = 0; i < totedge_i; i++, me++) {
BLI_edgehash_insert(eh, me->v1, me->v2, POINTER_FROM_UINT(i));
- /* unrelated but avoid having the FGON flag enabled, so we can reuse it later for something else */
+ /* unrelated but avoid having the FGON flag enabled,
+ * so we can reuse it later for something else */
me->flag &= ~ME_FGON;
}
@@ -3655,7 +3735,8 @@ void BKE_mesh_polygon_flip_ex(MPoly *mpoly,
/* Note that we keep same start vertex for flipped face. */
/* We also have to update loops edge
- * (they will get their original 'other edge', that is, the original edge of their original previous loop)... */
+ * (they will get their original 'other edge', that is,
+ * the original edge of their original previous loop)... */
unsigned int prev_edge_index = mloop[loopstart].e;
mloop[loopstart].e = mloop[loopend].e;
@@ -3727,8 +3808,9 @@ void BKE_mesh_flush_hidden_from_verts_ex(const MVert *mvert,
MPoly *p = &mpoly[i];
p->flag &= (char)~ME_HIDE;
for (j = 0; j < p->totloop; j++) {
- if (mvert[mloop[p->loopstart + j].v].flag & ME_HIDE)
+ if (mvert[mloop[p->loopstart + j].v].flag & ME_HIDE) {
p->flag |= ME_HIDE;
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/mesh_iterators.c b/source/blender/blenkernel/intern/mesh_iterators.c
index 1f8436408fb..df6517066b8 100644
--- a/source/blender/blenkernel/intern/mesh_iterators.c
+++ b/source/blender/blenkernel/intern/mesh_iterators.c
@@ -99,7 +99,8 @@ void BKE_mesh_foreach_mapped_loop(Mesh *mesh,
void *userData,
MeshForeachFlag flag)
{
- /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
+ /* We can't use dm->getLoopDataLayout(dm) here,
+ * we want to always access dm->loopData, EditDerivedBMesh would
* return loop data from bmesh itself. */
const float(*lnors)[3] = (flag & MESH_FOREACH_USE_NORMAL) ?
CustomData_get_layer(&mesh->ldata, CD_NORMAL) :
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 811b78411a3..40e300e6e2d 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -42,8 +42,8 @@
* \{ */
/* ngon version wip, based on BM_uv_vert_map_create */
-/* this replaces the non bmesh function (in trunk) which takes MTFace's, if we ever need it back we could
- * but for now this replaces it because its unused. */
+/* this replaces the non bmesh function (in trunk) which takes MTFace's,
+ * if we ever need it back we could but for now this replaces it because its unused. */
UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
const MLoop *mloop,
@@ -67,12 +67,15 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
/* generate UvMapVert array */
mp = mpoly;
- for (a = 0; a < totpoly; a++, mp++)
- if (!selected || (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL)))
+ for (a = 0; a < totpoly; a++, mp++) {
+ if (!selected || (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL))) {
totuv += mp->totloop;
+ }
+ }
- if (totuv == 0)
+ if (totuv == 0) {
return NULL;
+ }
vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap");
buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * (size_t)totuv, "UvMapVert");
@@ -142,15 +145,18 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
if (fabsf(uv[0] - uv2[0]) < limit[0] && fabsf(uv[1] - uv2[1]) < limit[1] &&
(!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) {
- if (lastv)
+ if (lastv) {
lastv->next = next;
- else
+ }
+ else {
vlist = next;
+ }
iterv->next = newvlist;
newvlist = iterv;
}
- else
+ else {
lastv = iterv;
+ }
iterv = next;
}
@@ -178,10 +184,12 @@ UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v)
void BKE_mesh_uv_vert_map_free(UvVertMap *vmap)
{
if (vmap) {
- if (vmap->vert)
+ if (vmap->vert) {
MEM_freeN(vmap->vert);
- if (vmap->buf)
+ }
+ if (vmap->buf) {
MEM_freeN(vmap->buf);
+ }
MEM_freeN(vmap);
}
}
@@ -212,8 +220,9 @@ static void mesh_vert_poly_or_loop_map_create(MeshElemMap **r_map,
for (i = 0; i < totpoly; i++) {
const MPoly *p = &mpoly[i];
- for (j = 0; j < p->totloop; j++)
+ for (j = 0; j < p->totloop; j++) {
map[mloop[p->loopstart + j].v].count++;
+ }
}
/* Assign indices mem */
@@ -242,7 +251,8 @@ static void mesh_vert_poly_or_loop_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the vertex and the value is a list of polys that use that vertex as a corner.
+ * Generates a map where the key is the vertex and the value
+ * is a list of polys that use that vertex as a corner.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map,
@@ -257,7 +267,8 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the vertex and the value is a list of loops that use that vertex as a corner.
+ * Generates a map where the key is the vertex and the value
+ * is a list of loops that use that vertex as a corner.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map,
@@ -272,7 +283,8 @@ void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the edge and the value is a list of looptris that use that edge.
+ * Generates a map where the key is the edge and the value
+ * is a list of looptris that use that edge.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
@@ -320,7 +332,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the vertex and the value is a list of edges that use that vertex as an endpoint.
+ * Generates a map where the key is the vertex and the value
+ * is a list of edges that use that vertex as an endpoint.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_vert_edge_map_create(
@@ -363,7 +376,8 @@ void BKE_mesh_vert_edge_map_create(
}
/**
- * A version of #BKE_mesh_vert_edge_map_create that references connected vertices directly (not their edges).
+ * A version of #BKE_mesh_vert_edge_map_create that references connected vertices directly
+ * (not their edges).
*/
void BKE_mesh_vert_edge_vert_map_create(
MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge)
@@ -463,7 +477,8 @@ void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map,
}
/**
- * Generates a map where the key is the edge and the value is a list of polygons that use that edge.
+ * Generates a map where the key is the edge and the value
+ * is a list of polygons that use that edge.
* The lists are allocated from one memory pool.
*/
void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map,
@@ -730,7 +745,8 @@ static void poly_edge_loop_islands_calc(const MEdge *medge,
num_edgeborders++;
}
if (use_bitflags) {
- /* Find contiguous smooth groups already assigned, these are the values we can't reuse! */
+ /* Find contiguous smooth groups already assigned,
+ * these are the values we can't reuse! */
for (; i--; p++) {
int bit = poly_groups[*p];
if (!ELEM(bit, 0, poly_group_id, poly_group_id_overflowed) &&
@@ -742,8 +758,9 @@ static void poly_edge_loop_islands_calc(const MEdge *medge,
}
}
}
- /* And now, we have all our poly from current group in poly_stack (from 0 to (ps_end_idx - 1)), as well as
- * all smoothgroups bits we can't use in bit_poly_group_mask.
+ /* And now, we have all our poly from current group in poly_stack
+ * (from 0 to (ps_end_idx - 1)),
+ * as well as all smoothgroups bits we can't use in bit_poly_group_mask.
*/
if (use_bitflags) {
int i, *p, gid_bit = 0;
@@ -755,8 +772,9 @@ static void poly_edge_loop_islands_calc(const MEdge *medge,
}
if (UNLIKELY(gid_bit > 31)) {
/* All bits used in contiguous smooth groups, we can't do much!
- * Note: this is *very* unlikely - theoretically, four groups are enough, I don't think we can reach
- * this goal with such a simple algo, but I don't think either we'll never need all 32 groups!
+ * Note: this is *very* unlikely - theoretically, four groups are enough,
+ * I don't think we can reach this goal with such a simple algo,
+ * but I don't think either we'll never need all 32 groups!
*/
printf(
"Warning, could not find an available id for current smooth group, faces will me "
@@ -812,7 +830,8 @@ static bool poly_is_island_boundary_smooth_cb(const MPoly *mp,
const int nbr_egde_users,
void *UNUSED(user_data))
{
- /* Edge is sharp if its poly is sharp, or edge itself is sharp, or edge is not used by exactly two polygons. */
+ /* Edge is sharp if its poly is sharp, or edge itself is sharp,
+ * or edge is not used by exactly two polygons. */
return (!(mp->flag & ME_SMOOTH) || (me->flag & ME_SHARP) || (nbr_egde_users != 2));
}
@@ -820,9 +839,9 @@ static bool poly_is_island_boundary_smooth_cb(const MPoly *mp,
* Calculate smooth groups from sharp edges.
*
* \param r_totgroup: The total number of groups, 1 or more.
- * \return Polygon aligned array of group index values (bitflags if use_bitflags is true), starting at 1
- * (0 being used as 'invalid' flag).
- * Note it's callers's responsibility to MEM_freeN returned array.
+ * \return Polygon aligned array of group index values (bitflags if use_bitflags is true),
+ * starting at 1 (0 being used as 'invalid' flag).
+ * Note it's callers's responsibility to MEM_freeN returned array.
*/
int *BKE_mesh_calc_smoothgroups(const MEdge *medge,
const int totedge,
@@ -963,10 +982,11 @@ void BKE_mesh_loop_islands_add(MeshIslandStore *island_store,
sizeof(*innrcut->indices) * (size_t)num_innercut_items);
}
-/* TODO: I'm not sure edge seam flag is enough to define UV islands? Maybe we should also consider UVmaps values
+/* TODO: I'm not sure edge seam flag is enough to define UV islands?
+ * Maybe we should also consider UVmaps values
* themselves (i.e. different UV-edges for a same mesh-edge => boundary edge too?).
- * Would make things much more complex though, and each UVMap would then need its own mesh mapping,
- * not sure we want that at all!
+ * Would make things much more complex though,
+ * and each UVMap would then need its own mesh mapping, not sure we want that at all!
*/
typedef struct MeshCheckIslandBoundaryUv {
const MLoop *loops;
@@ -1043,8 +1063,9 @@ static bool mesh_calc_islands_loop_poly_uv(MVert *UNUSED(verts),
int *loop_indices;
int num_pidx, num_lidx;
- /* Those are used to detect 'inner cuts', i.e. edges that are borders, and yet have two or more polys of
- * a same group using them (typical case: seam used to unwrap properly a cylinder). */
+ /* Those are used to detect 'inner cuts', i.e. edges that are borders,
+ * and yet have two or more polys of a same group using them
+ * (typical case: seam used to unwrap properly a cylinder). */
BLI_bitmap *edge_borders = NULL;
int num_edge_borders = 0;
char *edge_border_count = NULL;
@@ -1166,7 +1187,8 @@ static bool mesh_calc_islands_loop_poly_uv(MVert *UNUSED(verts),
}
/**
- * Calculate 'generic' UV islands, i.e. based only on actual geometry data (edge seams), not some UV layers coordinates.
+ * Calculate 'generic' UV islands, i.e. based only on actual geometry data (edge seams),
+ * not some UV layers coordinates.
*/
bool BKE_mesh_calc_islands_loop_poly_edgeseam(MVert *verts,
const int totvert,
@@ -1186,12 +1208,14 @@ bool BKE_mesh_calc_islands_loop_poly_edgeseam(MVert *verts,
* Calculate UV islands.
*
* \note If no MLoopUV layer is passed, we only consider edges tagged as seams as UV boundaries.
- * This has the advantages of simplicity, and being valid/common to all UV maps.
- * However, it means actual UV islands without matching UV seams will not be handled correctly...
- * If a valid UV layer is passed as \a luvs parameter, UV coordinates are also used to detect islands boundaries.
+ * This has the advantages of simplicity, and being valid/common to all UV maps.
+ * However, it means actual UV islands without matching UV seams will not be handled correctly...
+ * If a valid UV layer is passed as \a luvs parameter,
+ * UV coordinates are also used to detect islands boundaries.
*
* \note All this could be optimized...
- * Not sure it would be worth the more complex code, though, those loops are supposed to be really quick to do...
+ * Not sure it would be worth the more complex code, though,
+ * those loops are supposed to be really quick to do...
*/
bool BKE_mesh_calc_islands_loop_poly_uvmap(MVert *verts,
const int totvert,
diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c
index 1d534f72842..71cc20c78b7 100644
--- a/source/blender/blenkernel/intern/mesh_merge.c
+++ b/source/blender/blenkernel/intern/mesh_merge.c
@@ -41,8 +41,8 @@
* Poly compare with vtargetmap
* Function used by #BKE_mesh_merge_verts.
* The function compares poly_source after applying vtargetmap, with poly_target.
- * The two polys are identical if they share the same vertices in the same order, or in reverse order,
- * but starting position loopstart may be different.
+ * The two polys are identical if they share the same vertices in the same order,
+ * or in reverse order, but starting position loopstart may be different.
* The function is called with direct_reverse=1 for same order (i.e. same normal),
* and may be called again with direct_reverse=-1 for reverse order.
* \return 1 if polys are identical, 0 if polys are different.
@@ -159,7 +159,8 @@ static int cddm_poly_compare(MLoop *mloop_array,
break;
}
- /* Adjust i_loop_target for cycling around and for direct/reverse order defined by delta = +1 or -1 */
+ /* Adjust i_loop_target for cycling around and for direct/reverse order
+ * defined by delta = +1 or -1 */
i_loop_target_adjusted = (i_loop_target_start + direct_reverse * i_loop_target_offset) %
mpoly_target->totloop;
if (i_loop_target_adjusted < 0) {
@@ -213,8 +214,8 @@ static bool poly_gset_compare_fn(const void *k1, const void *k2)
* \param vtargetmap: The table that maps vertices to target vertices. a value of -1
* indicates a vertex is a target, and is to be kept.
* This array is aligned with 'mesh->totvert'
- * \warning \a vtargetmap must **not** contain any chained mapping (v1 -> v2 -> v3 etc.), this is not supported
- * and will likely generate corrupted geometry.
+ * \warning \a vtargetmap must **not** contain any chained mapping (v1 -> v2 -> v3 etc.),
+ * this is not supported and will likely generate corrupted geometry.
*
* \param tot_vtargetmap: The number of non '-1' values in vtargetmap. (not the size)
*
@@ -230,10 +231,12 @@ static bool poly_gset_compare_fn(const void *k1, const void *k2)
* Indeed it could be that all of a poly's vertices are merged,
* but merged to vertices that do not make up a single poly,
* in which case the original poly should not be dumped.
- * Actually this later behavior could apply to the Mirror Modifier as well, but the additional checks are
- * costly and not necessary in the case of mirror, because each vertex is only merged to its own mirror.
+ * Actually this later behavior could apply to the Mirror Modifier as well,
+ * but the additional checks are costly and not necessary in the case of mirror,
+ * because each vertex is only merged to its own mirror.
*
- * \note #BKE_mesh_recalc_tessellation has to run on the returned DM if you want to access tessfaces.
+ * \note #BKE_mesh_recalc_tessellation has to run on the returned DM
+ * if you want to access tessfaces.
*/
Mesh *BKE_mesh_merge_verts(Mesh *mesh,
const int *vtargetmap,
@@ -258,9 +261,9 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
STACK_DECLARE(mvert);
STACK_DECLARE(oldv);
- /* Note: create (totedge + totloop) elements because partially invalid polys due to merge may require
- * generating new edges, and while in 99% cases we'll still end with less final edges than totedge,
- * cases can be forged that would end requiring more... */
+ /* Note: create (totedge + totloop) elements because partially invalid polys due to merge may
+ * require generating new edges, and while in 99% cases we'll still end with less final edges
+ * than totedge, cases can be forged that would end requiring more. */
MEdge *med, *medge = MEM_malloc_arrayN((totedge + totloop), sizeof(*medge), __func__);
int *olde = MEM_malloc_arrayN((totedge + totloop), sizeof(*olde), __func__);
int *newe = MEM_malloc_arrayN((totedge + totloop), sizeof(*newe), __func__);
@@ -354,7 +357,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
if (merge_mode == MESH_MERGE_VERTS_DUMP_IF_EQUAL) {
/* In this mode, we need to determine, whenever a poly' vertices are all mapped */
/* if the targets already make up a poly, in which case the new poly is dropped */
- /* This poly equality check is rather complex. We use a BLI_ghash to speed it up with a first level check */
+ /* This poly equality check is rather complex.
+ * We use a BLI_ghash to speed it up with a first level check */
PolyKey *mpgh;
poly_keys = MEM_malloc_arrayN(totpoly, sizeof(PolyKey), __func__);
poly_gset = BLI_gset_new_ex(poly_gset_hash_fn, poly_gset_compare_fn, __func__, totpoly);
@@ -484,7 +488,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
BLI_assert((mlv == v1 && next_mlv == v2) || (mlv == v2 && next_mlv == v1));
}
#endif
- /* A loop is only valid if its matching edge is, and it's not reusing a vertex already used by this poly. */
+ /* A loop is only valid if its matching edge is,
+ * and it's not reusing a vertex already used by this poly. */
if (LIKELY((newe[ml->e] != -1) && ((mv[mlv].flag & ME_VERT_TMP_TAG) == 0))) {
mv[mlv].flag |= ME_VERT_TMP_TAG;
@@ -505,7 +510,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
STACK_PUSH(medge, mesh->medge[last_valid_ml->e]);
medge[new_eidx].v1 = last_valid_ml->v;
medge[new_eidx].v2 = ml->v;
- /* DO NOT change newe mapping, could break actual values due to some deleted original edges. */
+ /* DO NOT change newe mapping,
+ * could break actual values due to some deleted original edges. */
*val_p = POINTER_FROM_INT(new_eidx);
created_edges++;
@@ -525,8 +531,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
}
c++;
- /* We absolutely HAVE to handle edge index remapping here, otherwise potential newly created edges
- * in that part of code make remapping later totally unreliable. */
+ /* We absolutely HAVE to handle edge index remapping here, otherwise potential newly
+ * created edges in that part of code make remapping later totally unreliable. */
BLI_assert(newe[ml->e] != -1);
last_valid_ml->e = newe[ml->e];
}
@@ -558,7 +564,8 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
STACK_PUSH(medge, mesh->medge[last_valid_ml->e]);
medge[new_eidx].v1 = last_valid_ml->v;
medge[new_eidx].v2 = first_valid_ml->v;
- /* DO NOT change newe mapping, could break actual values due to some deleted original edges. */
+ /* DO NOT change newe mapping,
+ * could break actual values due to some deleted original edges. */
*val_p = POINTER_FROM_INT(new_eidx);
created_edges++;
@@ -664,10 +671,12 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
BLI_edgehash_free(ehash, NULL);
- if (poly_map != NULL)
+ if (poly_map != NULL) {
MEM_freeN(poly_map);
- if (poly_map_mem != NULL)
+ }
+ if (poly_map_mem != NULL) {
MEM_freeN(poly_map_mem);
+ }
BKE_id_free(NULL, mesh);
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index b43339bf73f..db158ca8fb2 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -124,9 +124,11 @@ static bool mesh_remap_bvhtree_query_raycast(BVHTreeFromMesh *treedata,
* Compute a value of the difference between both given meshes.
* The smaller the result, the better the match.
*
- * We return the inverse of the average of the inversed shortest distance from each dst vertex to src ones.
- * In other words, beyond a certain (relatively small) distance, all differences have more or less the same weight
- * in final result, which allows to reduce influence of a few high differences, in favor of a global good matching.
+ * We return the inverse of the average of the inversed
+ * shortest distance from each dst vertex to src ones.
+ * In other words, beyond a certain (relatively small) distance, all differences have more or less
+ * the same weight in final result, which allows to reduce influence of a few high differences,
+ * in favor of a global good matching.
*/
float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_transform,
const MVert *verts_dst,
@@ -164,20 +166,24 @@ float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_trans
result = ((float)numverts_dst / result) - 1.0f;
- // printf("%s: Computed difference between meshes (the lower the better): %f\n", __func__, result);
+#if 0
+ printf("%s: Computed difference between meshes (the lower the better): %f\n", __func__, result);
+#endif
return result;
}
-/* This helper computes the eigen values & vectors for covariance matrix of all given vertices coordinates.
+/* This helper computes the eigen values & vectors for
+ * covariance matrix of all given vertices coordinates.
*
* Those vectors define the 'average ellipsoid' of the mesh (i.e. the 'best fitting' ellipsoid
* containing 50% of the vertices).
*
- * Note that it will not perform fantastic in case two or more eigen values are equal (e.g. a cylinder or
- * parallelepiped with a square section give two identical eigenvalues, a sphere or tetrahedron give
- * three identical ones, etc.), since you cannot really define all axes in those cases. We default to dummy
- * generated orthogonal vectors in this case, instead of using eigen vectors.
+ * Note that it will not perform fantastic in case two or more eigen values are equal
+ * (e.g. a cylinder or parallelepiped with a square section give two identical eigenvalues,
+ * a sphere or tetrahedron give three identical ones, etc.), since you cannot really define all
+ * axes in those cases. We default to dummy generated orthogonal vectors in this case,
+ * instead of using eigen vectors.
*/
static void mesh_calc_eigen_matrix(const MVert *verts,
const float (*vcos)[3],
@@ -207,8 +213,8 @@ static void mesh_calc_eigen_matrix(const MVert *verts,
}
unit_m4(r_mat);
- /* Note: here we apply sample correction to covariance matrix, since we consider the vertices as a sample
- * of the whole 'surface' population of our mesh... */
+ /* Note: here we apply sample correction to covariance matrix, since we consider the vertices
+ * as a sample of the whole 'surface' population of our mesh. */
BLI_covariance_m3_v3n(vcos, numverts, true, covmat, center);
if (cos) {
@@ -247,8 +253,9 @@ static void mesh_calc_eigen_matrix(const MVert *verts,
float evi = eigen_val[i];
/* Protect against 1D/2D degenerated cases! */
- /* Note: not sure why we need square root of eigen values here (which are equivalent to singular values,
- * as far as I have understood), but it seems to heavily reduce (if not completely nullify)
+ /* Note: not sure why we need square root of eigen values here
+ * (which are equivalent to singular values, as far as I have understood),
+ * but it seems to heavily reduce (if not completely nullify)
* the error due to non-uniform scalings... */
evi = (evi < 1e-6f && evi > -1e-6f) ? ((evi < 0.0f) ? -1e-3f : 1e-3f) : sqrtf_signed(evi);
mul_v3_fl(eigen_vec[i], evi);
@@ -266,7 +273,8 @@ void BKE_mesh_remap_find_best_match_from_mesh(const MVert *verts_dst,
Mesh *me_src,
SpaceTransform *r_space_transform)
{
- /* Note that those are done so that we successively get actual mirror matrix (by multiplication of columns)... */
+ /* Note that those are done so that we successively get actual mirror matrix
+ * (by multiplication of columns). */
const float mirrors[][3] = {
{-1.0f, 1.0f, 1.0f}, /* -> -1, 1, 1 */
{1.0f, -1.0f, 1.0f}, /* -> -1, -1, 1 */
@@ -323,7 +331,7 @@ void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(const int UNUSED(ver
const int UNUSED(edge_mode),
const int loop_mode,
const int UNUSED(poly_mode),
- CustomData_MeshMasks *cddata_mask)
+ CustomData_MeshMasks *r_cddata_mask)
{
/* vert, edge and poly mapping modes never need extra cddata from source object. */
const bool need_lnors_src = (loop_mode & MREMAP_USE_LOOP) && (loop_mode & MREMAP_USE_NORMAL);
@@ -331,10 +339,10 @@ void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(const int UNUSED(ver
((loop_mode & MREMAP_USE_POLY) && (loop_mode & MREMAP_USE_NORMAL));
if (need_lnors_src) {
- cddata_mask->lmask |= CD_MASK_NORMAL;
+ r_cddata_mask->lmask |= CD_MASK_NORMAL;
}
if (need_pnors_src) {
- cddata_mask->pmask |= CD_MASK_NORMAL;
+ r_cddata_mask->pmask |= CD_MASK_NORMAL;
}
}
@@ -445,25 +453,32 @@ static int mesh_remap_interp_poly_data_get(const MPoly *mp,
return sources_num;
}
-/* Little helper when dealing with source islands */
+/** Little helper when dealing with source islands */
typedef struct IslandResult {
- float
- factor; /* A factor, based on which best island for a given set of elements will be selected. */
- int index_src; /* Index of the source. */
- float hit_dist; /* The actual hit distance. */
- float hit_point[3]; /* The hit point, if relevant. */
+ /** A factor, based on which best island for a given set of elements will be selected. */
+ float factor;
+ /** Index of the source. */
+ int index_src;
+ /** The actual hit distance. */
+ float hit_dist;
+ /** The hit point, if relevant. */
+ float hit_point[3];
} IslandResult;
-/* Note about all bvh/raycasting stuff below:
- * * We must use our ray radius as BVH epsilon too, else rays not hitting anything but 'passing near' an item
- * would be missed (since BVH handling would not detect them, 'refining' callbacks won't be executed,
- * even though they would return a valid hit).
- * * However, in 'islands' case where each hit gets a weight, 'precise' hits should have a better weight than
- * 'approximate' hits. To address that, we simplify things with:
- * ** A first raycast with default, given rayradius;
- * ** If first one fails, we do more raycasting with bigger radius, but if hit is found
- * it will get smaller weight.
- * This only concerns loops, currently (because of islands), and 'sampled' edges/polys norproj.
+/**
+ * \note About all bvh/raycasting stuff below:
+ *
+ * * We must use our ray radius as BVH epsilon too, else rays not hitting anything but
+ * 'passing near' an item would be missed (since BVH handling would not detect them,
+ * 'refining' callbacks won't be executed, even though they would return a valid hit).
+ * * However, in 'islands' case where each hit gets a weight, 'precise' hits should have a better
+ * weight than 'approximate' hits.
+ * To address that, we simplify things with:
+ * * A first raycast with default, given rayradius;
+ * * If first one fails, we do more raycasting with bigger radius, but if hit is found
+ * it will get smaller weight.
+ *
+ * This only concerns loops, currently (because of islands), and 'sampled' edges/polys norproj.
*/
/* At most n raycasts per 'real' ray. */
@@ -791,8 +806,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
}
}
- /* Now, check all source edges of closest sources vertices, and select the one giving the smallest
- * total verts-to-verts distance. */
+ /* Now, check all source edges of closest sources vertices,
+ * and select the one giving the smallest total verts-to-verts distance. */
for (j = 2; j--;) {
const unsigned int vidx_dst = j ? e_dst->v1 : e_dst->v2;
const float first_dist = v_dst_to_src_map[vidx_dst].hit_dist;
@@ -1009,8 +1024,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
w /= MREMAP_RAYCAST_APPROXIMATE_FAC;
}
}
- /* A sampling is valid (as in, its result can be considered as valid sources) only if at least
- * half of the rays found a source! */
+ /* A sampling is valid (as in, its result can be considered as valid sources)
+ * only if at least half of the rays found a source! */
if (totweights > ((float)grid_size / 2.0f)) {
for (j = 0; j < (int)numedges_src; j++) {
if (!weights[j]) {
@@ -1201,7 +1216,8 @@ static void mesh_island_to_astar_graph(MeshIslandStore *islands,
#undef POLY_COMPLETE
/* Our 'f_cost' callback func, to find shortest poly-path between two remapped-loops.
- * Note we do not want to make innercuts 'walls' here, just detect when the shortest path goes by those. */
+ * Note we do not want to make innercuts 'walls' here,
+ * just detect when the shortest path goes by those. */
static float mesh_remap_calc_loops_astar_f_cost(BLI_AStarGraph *as_graph,
BLI_AStarSolution *as_solution,
BLI_AStarGNLink *link,
@@ -1221,8 +1237,8 @@ static float mesh_remap_calc_loops_astar_f_cost(BLI_AStarGraph *as_graph,
}
/* Our heuristic part of current f_cost is distance from next node to destination one.
- * It is guaranteed to be less than (or equal to) actual shortest poly-path between next node and destination one.
- */
+ * It is guaranteed to be less than (or equal to)
+ * actual shortest poly-path between next node and destination one. */
co_next = (float *)as_graph->nodes[node_idx_next].custom_data;
co_dest = (float *)as_graph->nodes[node_idx_dst].custom_data;
return (link ? (as_solution->g_costs[node_idx_curr] + link->cost) : 0.0f) +
@@ -1598,8 +1614,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
for (pidx_dst = 0, mp_dst = polys_dst; pidx_dst < numpolys_dst; pidx_dst++, mp_dst++) {
float pnor_dst[3];
- /* Only in use_from_vert case, we may need polys' centers as fallback in case we cannot decide which
- * corner to use from normals only. */
+ /* Only in use_from_vert case, we may need polys' centers as fallback
+ * in case we cannot decide which corner to use from normals only. */
float pcent_dst[3];
bool pcent_dst_valid = false;
@@ -1760,8 +1776,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
/* Fallback to 'nearest' hit here, loops usually comes in 'face group', not good to
* have only part of one dest face's loops to map to source.
* Note that since we give this a null weight, if whole weight for a given face
- * is null, it means none of its loop mapped to this source island, hence we can skip it
- * later.
+ * is null, it means none of its loop mapped to this source island,
+ * hence we can skip it later.
*/
copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
nearest.index = -1;
@@ -1818,12 +1834,14 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
/* We have to first select the 'best source island' for given dst poly and its loops.
* Then, we have to check that poly does not 'spread' across some island's limits
* (like inner seams for UVs, etc.).
- * Note we only still partially support that kind of situation here, i.e. polys spreading over actual cracks
- * (like a narrow space without faces on src, splitting a 'tube-like' geometry). That kind of situation
- * should be relatively rare, though.
+ * Note we only still partially support that kind of situation here, i.e.
+ * Polys spreading over actual cracks
+ * (like a narrow space without faces on src, splitting a 'tube-like' geometry).
+ * That kind of situation should be relatively rare, though.
*/
- /* XXX This block in itself is big and complex enough to be a separate function but... it uses a bunch
- * of locale vars. Not worth sending all that through parameters (for now at least). */
+ /* XXX This block in itself is big and complex enough to be a separate function but...
+ * it uses a bunch of locale vars.
+ * Not worth sending all that through parameters (for now at least). */
{
BLI_AStarGraph *as_graph = NULL;
int *poly_island_index_map = NULL;
@@ -1893,7 +1911,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
if (POINTER_AS_INT(as_solution.custom_data) && (as_solution.steps > 0)) {
/* Find first 'cutting edge' on path, and bring back lidx_src on poly just
* before that edge.
- * Note we could try to be much smarter (like e.g. storing a whole poly's indices,
+ * Note we could try to be much smarter, g.g. Storing a whole poly's indices,
* and making decision (on which side of cutting edge(s!) to be) on the end,
* but this is one more level of complexity, better to first see if
* simple solution works!
@@ -1919,7 +1937,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
ml_dst = &loops_dst[lidx_dst];
copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
- /* We do our transform here, since we may do several raycast/nearest queries. */
+ /* We do our transform here,
+ * since we may do several raycast/nearest queries. */
if (space_transform) {
BLI_space_transform_apply(space_transform, tmp_co);
}
@@ -1949,7 +1968,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
}
else {
/* No source for this loop in this island. */
- /* TODO: would probably be better to get a source at all cost in best island anyway? */
+ /* TODO: would probably be better to get a source
+ * at all cost in best island anyway? */
mesh_remap_item_define(r_map, lidx_dst, FLT_MAX, best_island_index, 0, NULL, NULL);
}
}
@@ -1982,8 +2002,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
if (POINTER_AS_INT(as_solution.custom_data) && (as_solution.steps > 0)) {
/* Find first 'cutting edge' on path, and bring back lidx_src on poly just
* before that edge.
- * Note we could try to be much smarter (like e.g. storing a whole poly's indices,
- * and making decision (one which side of cutting edge(s!) to be on the end,
+ * Note we could try to be much smarter: e.g. Storing a whole poly's indices,
+ * and making decision (one which side of cutting edge(s)!) to be on the end,
* but this is one more level of complexity, better to first see if
* simple solution works!
*/
@@ -2009,7 +2029,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
ml_dst = &loops_dst[lidx_dst];
copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
- /* We do our transform here, since we may do several raycast/nearest queries. */
+ /* We do our transform here,
+ * since we may do several raycast/nearest queries. */
if (space_transform) {
BLI_space_transform_apply(space_transform, tmp_co);
}
@@ -2097,7 +2118,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
}
else {
/* No source for this loop in this island. */
- /* TODO: would probably be better to get a source at all cost in best island anyway? */
+ /* TODO: would probably be better to get a source
+ * at all cost in best island anyway? */
mesh_remap_item_define(r_map, lidx_dst, FLT_MAX, best_island_index, 0, NULL, NULL);
}
}
@@ -2280,7 +2302,8 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
}
}
else if (mode == MREMAP_MODE_POLY_POLYINTERP_PNORPROJ) {
- /* We cast our rays randomly, with a pseudo-even distribution (since we spread across tessellated tris,
+ /* We cast our rays randomly, with a pseudo-even distribution
+ * (since we spread across tessellated tris,
* with additional weighting based on each tri's relative area).
*/
RNG *rng = BLI_rng_new(0);
@@ -2396,8 +2419,8 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
float *v3 = poly_vcos_2d[tri_vidx_2d[j][2]];
int rays_num;
- /* All this allows us to get 'absolute' number of rays for each tri, avoiding accumulating
- * errors over iterations, and helping better even distribution. */
+ /* All this allows us to get 'absolute' number of rays for each tri,
+ * avoiding accumulating errors over iterations, and helping better even distribution. */
done_area += area_tri_v2(v1, v2, v3);
rays_num = max_ii(
(int)((float)tot_rays * done_area * poly_area_2d_inv + 0.5f) - done_rays, 0);
diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c
index dea64e64377..06abd80b86f 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -78,7 +78,8 @@ void BKE_mesh_runtime_clear_cache(Mesh *mesh)
/**
* Ensure the array is large enough
*
- * \note This function must always be thread-protected by caller. It should only be used by internal code.
+ * \note This function must always be thread-protected by caller.
+ * It should only be used by internal code.
*/
static void mesh_ensure_looptri_data(Mesh *mesh)
{
@@ -149,8 +150,8 @@ const MLoopTri *BKE_mesh_runtime_looptri_ensure(Mesh *mesh)
}
else {
BLI_rw_mutex_lock(&loops_cache_lock, THREAD_LOCK_WRITE);
- /* We need to ensure array is still NULL inside mutex-protected code, some other thread might have already
- * recomputed those looptris. */
+ /* We need to ensure array is still NULL inside mutex-protected code,
+ * some other thread might have already recomputed those looptris. */
if (mesh->runtime.looptris.array == NULL) {
BKE_mesh_runtime_looptri_recalc(mesh);
}
@@ -190,14 +191,18 @@ bool BKE_mesh_runtime_clear_edit_data(Mesh *mesh)
return false;
}
- if (mesh->runtime.edit_data->polyCos != NULL)
+ if (mesh->runtime.edit_data->polyCos != NULL) {
MEM_freeN((void *)mesh->runtime.edit_data->polyCos);
- if (mesh->runtime.edit_data->polyNos != NULL)
+ }
+ if (mesh->runtime.edit_data->polyNos != NULL) {
MEM_freeN((void *)mesh->runtime.edit_data->polyNos);
- if (mesh->runtime.edit_data->vertexCos != NULL)
+ }
+ if (mesh->runtime.edit_data->vertexCos != NULL) {
MEM_freeN((void *)mesh->runtime.edit_data->vertexCos);
- if (mesh->runtime.edit_data->vertexNos != NULL)
+ }
+ if (mesh->runtime.edit_data->vertexNos != NULL) {
MEM_freeN((void *)mesh->runtime.edit_data->vertexNos);
+ }
MEM_SAFE_FREE(mesh->runtime.edit_data);
return true;
@@ -285,9 +290,15 @@ char *BKE_mesh_runtime_debug_info(Mesh *me_eval)
# if 0
const char *tstr;
switch (me_eval->type) {
- case DM_TYPE_CDDM: tstr = "DM_TYPE_CDDM"; break;
- case DM_TYPE_CCGDM: tstr = "DM_TYPE_CCGDM"; break;
- default: tstr = "UNKNOWN"; break;
+ case DM_TYPE_CDDM:
+ tstr = "DM_TYPE_CDDM";
+ break;
+ case DM_TYPE_CCGDM:
+ tstr = "DM_TYPE_CCGDM";
+ break;
+ default:
+ tstr = "UNKNOWN";
+ break;
}
BLI_dynstr_appendf(dynstr, " 'type': '%s',\n", tstr);
# endif
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index e6c4e9ff4be..19d94be9b6e 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -116,7 +116,8 @@ static void set_tspace(const SMikkTSpaceContext *pContext,
}
/**
- * Compute simplified tangent space normals, i.e. tangent vector + sign of bi-tangent one, which combined with
+ * Compute simplified tangent space normals, i.e.
+ * tangent vector + sign of bi-tangent one, which combined with
* split normals can be used to recreate the full tangent space.
* Note: * The mesh should be made of only tris and quads!
*/
@@ -284,7 +285,7 @@ static void dm_ts_GetPosition(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = pContext->m_pUserData;
const MLoopTri *lt;
uint loop_index;
@@ -318,7 +319,7 @@ static void dm_ts_GetTextureCoordinate(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = pContext->m_pUserData;
const MLoopTri *lt;
uint loop_index;
@@ -357,7 +358,7 @@ static void dm_ts_GetNormal(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *)pContext->m_pUserData;
const MLoopTri *lt;
uint loop_index;
@@ -420,7 +421,7 @@ static void dm_ts_SetTSpace(const SMikkTSpaceContext *pContext,
const int face_num,
const int vert_index)
{
- //assert(vert_index >= 0 && vert_index < 4);
+ // assert(vert_index >= 0 && vert_index < 4);
SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *)pContext->m_pUserData;
const MLoopTri *lt;
uint loop_index;
@@ -487,7 +488,8 @@ void BKE_mesh_add_loop_tangent_named_layer_for_uv(CustomData *uv_data,
}
/**
- * Here we get some useful information such as active uv layer name and search if it is already in tangent_names.
+ * Here we get some useful information such as active uv layer name and
+ * search if it is already in tangent_names.
* Also, we calculate tangent_mask that works as a descriptor of tangents state.
* If tangent_mask has changed, then recalculate tangents.
*/
@@ -530,10 +532,12 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData,
*rcalc_act = true;
*rcalc_ren = true;
for (int i = 0; i < tangent_names_count; i++) {
- if (STREQ(ract_uv_name, tangent_names[i]))
+ if (STREQ(ract_uv_name, tangent_names[i])) {
*rcalc_act = false;
- if (STREQ(rren_uv_name, tangent_names[i]))
+ }
+ if (STREQ(rren_uv_name, tangent_names[i])) {
*rcalc_ren = false;
+ }
}
}
*rtangent_mask = 0;
@@ -552,12 +556,14 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData,
(*rcalc_ren && rren_uv_name[0] && STREQ(rren_uv_name, name)))) {
add = true;
}
- if (add)
+ if (add) {
*rtangent_mask |= (short)(1 << n);
+ }
}
- if (uv_layer_num == 0)
+ if (uv_layer_num == 0) {
*rtangent_mask |= DM_TANGENT_MASK_ORCO;
+ }
}
/**
@@ -605,20 +611,25 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
if ((tangent_mask_curr | tangent_mask) != tangent_mask_curr) {
/* Check we have all the needed layers */
/* Allocate needed tangent layers */
- for (int i = 0; i < tangent_names_len; i++)
- if (tangent_names[i][0])
+ for (int i = 0; i < tangent_names_len; i++) {
+ if (tangent_names[i][0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
loopdata, loopdata_out, (int)loopdata_out_len, tangent_names[i]);
+ }
+ }
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
- CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1)
+ CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1) {
CustomData_add_layer_named(
loopdata_out, CD_TANGENT, CD_CALLOC, NULL, (int)loopdata_out_len, "");
- if (calc_act && act_uv_name[0])
+ }
+ if (calc_act && act_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
loopdata, loopdata_out, (int)loopdata_out_len, act_uv_name);
- if (calc_ren && ren_uv_name[0])
+ }
+ if (calc_ren && ren_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
loopdata, loopdata_out, (int)loopdata_out_len, ren_uv_name);
+ }
#ifdef USE_LOOPTRI_DETECT_QUADS
int num_face_as_quad_map;
@@ -668,9 +679,8 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
mesh2tangent->mpoly = mpoly;
mesh2tangent->mloop = mloop;
mesh2tangent->looptri = looptri;
- /* Note, we assume we do have tessellated loop normals at this point (in case it is object-enabled),
- * have to check this is valid...
- */
+ /* Note, we assume we do have tessellated loop normals at this point
+ * (in case it is object-enabled), have to check this is valid. */
mesh2tangent->precomputedLoopNormals = loop_normals;
mesh2tangent->precomputedFaceNormals = poly_normals;
@@ -681,8 +691,9 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
/* Fill the resulting tangent_mask */
if (!mesh2tangent->mloopuv) {
mesh2tangent->orco = vert_orco;
- if (!mesh2tangent->orco)
+ if (!mesh2tangent->orco) {
continue;
+ }
tangent_mask_curr |= DM_TANGENT_MASK_ORCO;
}
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index d54796a66c4..dac12233539 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -166,8 +166,9 @@ static int search_poly_cmp(const void *v1, const void *v2)
int idx;
/* Reject all invalid polys at end of list! */
- if (sp1->invalid || sp2->invalid)
+ if (sp1->invalid || sp2->invalid) {
return sp1->invalid ? (sp2->invalid ? 0 : 1) : -1;
+ }
/* Else, sort on first non-equal verts (remember verts of valid polys are sorted). */
for (idx = 0; idx < max_idx; idx++) {
const int v1_i = sp1->verts[idx];
@@ -184,8 +185,9 @@ static int search_polyloop_cmp(const void *v1, const void *v2)
const SortPoly *sp1 = v1, *sp2 = v2;
/* Reject all invalid polys at end of list! */
- if (sp1->invalid || sp2->invalid)
+ if (sp1->invalid || sp2->invalid) {
return sp1->invalid && sp2->invalid ? 0 : sp1->invalid ? 1 : -1;
+ }
/* Else, sort on loopstart. */
return sp1->loopstart > sp2->loopstart ? 1 : sp1->loopstart < sp2->loopstart ? -1 : 0;
}
@@ -314,8 +316,9 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
}
}
- if (mv->no[j] != 0)
+ if (mv->no[j] != 0) {
fix_normal = false;
+ }
}
if (fix_normal) {
@@ -570,8 +573,9 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
sp->numverts = mp->totloop;
sp->loopstart = mp->loopstart;
- /* Ideally we would only have to do that once on all vertices before we start checking each poly, but
- * several polys can use same vert, so we have to ensure here all verts of current poly are cleared. */
+ /* Ideally we would only have to do that once on all vertices
+ * before we start checking each poly, but several polys can use same vert,
+ * so we have to ensure here all verts of current poly are cleared. */
for (j = 0, ml = &mloops[sp->loopstart]; j < mp->totloop; j++, ml++) {
if (ml->v < totvert) {
mverts[ml->v].flag &= ~ME_VERT_TMP_TAG;
@@ -595,8 +599,9 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
*v = ml->v;
}
- if (sp->invalid)
+ if (sp->invalid) {
continue;
+ }
/* Test all poly's loops. */
for (j = 0, ml = &mloops[sp->loopstart]; j < mp->totloop; j++, ml++) {
@@ -605,10 +610,12 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
if (!BLI_edgehash_haskey(edge_hash, v1, v2)) {
/* Edge not existing. */
PRINT_ERR("\tPoly %u needs missing edge (%d, %d)", sp->index, v1, v2);
- if (do_fixes)
+ if (do_fixes) {
recalc_flag.edges = true;
- else
+ }
+ else {
sp->invalid = true;
+ }
}
else if (ml->e >= totedge) {
/* Invalid edge idx.
@@ -632,7 +639,8 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
if (IS_REMOVED_EDGE(me) ||
!((me->v1 == v1 && me->v2 == v2) || (me->v1 == v2 && me->v2 == v1))) {
/* The pointed edge is invalid (tagged as removed, or vert idx mismatch),
- * and we already know from previous test that a valid one exists, use it (if allowed)! */
+ * and we already know from previous test that a valid one exists,
+ * use it (if allowed)! */
if (do_fixes) {
int prev_e = ml->e;
ml->e = POINTER_AS_INT(BLI_edgehash_lookup(edge_hash, v1, v2));
@@ -670,7 +678,8 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
const int *p1_v = sp->verts, *p2_v = prev_sp->verts;
if (sp->invalid) {
- /* break, because all known invalid polys have been put at the end by qsort with search_poly_cmp. */
+ /* Break, because all known invalid polys have been put at the end
+ * by qsort with search_poly_cmp. */
break;
}
@@ -679,8 +688,9 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
if (do_verbose) {
// TODO: convert list to string
PRINT_ERR("\tPolys %u and %u use same vertices (%d", prev_sp->index, sp->index, *p1_v);
- for (j = 1; j < p1_nv; j++)
+ for (j = 1; j < p1_nv; j++) {
PRINT_ERR(", %d", p1_v[j]);
+ }
PRINT_ERR("), considering poly %u as invalid.", sp->index);
}
else {
@@ -700,8 +710,9 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
prev_end = 0;
for (i = 0; i < totpoly; i++, sp++) {
/* Free this now, we don't need it anymore, and avoid us another loop! */
- if (sp->verts)
+ if (sp->verts) {
MEM_freeN(sp->verts);
+ }
/* Note above prev_sp: in following code, we make sure it is always valid poly (or NULL). */
if (sp->invalid) {
@@ -720,8 +731,9 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
if (prev_end < sp->loopstart) {
for (j = prev_end, ml = &mloops[prev_end]; j < sp->loopstart; j++, ml++) {
PRINT_ERR("\tLoop %u is unused.", j);
- if (do_fixes)
+ if (do_fixes) {
REMOVE_LOOP_TAG(ml);
+ }
}
prev_end = sp->loopstart + sp->numverts;
prev_sp = sp;
@@ -752,8 +764,9 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
if (prev_end < totloop) {
for (j = prev_end, ml = &mloops[prev_end]; j < totloop; j++, ml++) {
PRINT_ERR("\tLoop %u is unused.", j);
- if (do_fixes)
+ if (do_fixes) {
REMOVE_LOOP_TAG(ml);
+ }
}
}
@@ -1312,14 +1325,18 @@ static int vergedgesort(const void *v1, const void *v2)
{
const struct EdgeSort *x1 = v1, *x2 = v2;
- if (x1->v1 > x2->v1)
+ if (x1->v1 > x2->v1) {
return 1;
- else if (x1->v1 < x2->v1)
+ }
+ else if (x1->v1 < x2->v1) {
return -1;
- else if (x1->v2 > x2->v2)
+ }
+ else if (x1->v2 > x2->v2) {
return 1;
- else if (x1->v2 < x2->v2)
+ }
+ else if (x1->v2 < x2->v2) {
return -1;
+ }
return 0;
}
@@ -1351,12 +1368,15 @@ static void mesh_calc_edges_mdata(MVert *UNUSED(allvert),
/* we put all edges in array, sort them, and detect doubles that way */
for (a = totface, mface = allface; a > 0; a--, mface++) {
- if (mface->v4)
+ if (mface->v4) {
totedge += 4;
- else if (mface->v3)
+ }
+ else if (mface->v3) {
totedge += 3;
- else
+ }
+ else {
totedge += 1;
+ }
}
if (totedge == 0) {
@@ -1386,8 +1406,9 @@ static void mesh_calc_edges_mdata(MVert *UNUSED(allvert),
/* count final amount */
for (a = totedge, ed = edsort; a > 1; a--, ed++) {
/* edge is unique when it differs from next edge, or is last */
- if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2)
+ if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) {
totedge_final++;
+ }
}
totedge_final++;
@@ -1398,10 +1419,12 @@ static void mesh_calc_edges_mdata(MVert *UNUSED(allvert),
if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) {
med->v1 = ed->v1;
med->v2 = ed->v2;
- if (use_old == false || ed->is_draw)
+ if (use_old == false || ed->is_draw) {
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
- if (ed->is_loose)
+ }
+ if (ed->is_loose) {
med->flag |= ME_LOOSEEDGE;
+ }
/* order is swapped so extruding this edge as a surface wont flip face normals
* with cyclic curves */
@@ -1419,8 +1442,9 @@ static void mesh_calc_edges_mdata(MVert *UNUSED(allvert),
med->v1 = ed->v1;
med->v2 = ed->v2;
med->flag = ME_EDGEDRAW;
- if (ed->is_loose)
+ if (ed->is_loose) {
med->flag |= ME_LOOSEEDGE;
+ }
med->flag |= ME_EDGERENDER;
MEM_freeN(edsort);
@@ -1506,8 +1530,9 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool update, const bool select)
/* select for newly created meshes which are selected [#25595] */
const short ed_flag = (ME_EDGEDRAW | ME_EDGERENDER) | (select ? SELECT : 0);
- if (mesh->totedge == 0)
+ if (mesh->totedge == 0) {
update = false;
+ }
eh_reserve = max_ii(update ? mesh->totedge : 0, BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(totpoly));
eh = BLI_edgehash_new_ex(__func__, eh_reserve);
@@ -1516,8 +1541,9 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool update, const bool select)
/* assume existing edges are valid
* useful when adding more faces and generating edges from them */
med = mesh->medge;
- for (i = 0; i < mesh->totedge; i++, med++)
+ for (i = 0; i < mesh->totedge; i++, med++) {
BLI_edgehash_insert(eh, med->v1, med->v2, med);
+ }
}
/* mesh loops (bmesh only) */
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 7d4fc15ca56..9bc9865631f 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -36,6 +36,7 @@
#include "DNA_armature_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
@@ -129,11 +130,13 @@ ModifierData *modifier_new(int type)
md->mode = eModifierMode_Realtime | eModifierMode_Render | eModifierMode_Expanded;
md->flag = eModifierFlag_StaticOverride_Local;
- if (mti->flags & eModifierTypeFlag_EnableInEditmode)
+ if (mti->flags & eModifierTypeFlag_EnableInEditmode) {
md->mode |= eModifierMode_Editmode;
+ }
- if (mti->initData)
+ if (mti->initData) {
mti->initData(md);
+ }
return md;
}
@@ -162,10 +165,12 @@ void modifier_free_ex(ModifierData *md, const int flag)
}
}
- if (mti->freeData)
+ if (mti->freeData) {
mti->freeData(md);
- if (md->error)
+ }
+ if (md->error) {
MEM_freeN(md->error);
+ }
MEM_freeN(md);
}
@@ -222,9 +227,11 @@ ModifierData *modifiers_findByType(Object *ob, ModifierType type)
{
ModifierData *md = ob->modifiers.first;
- for (; md; md = md->next)
- if (md->type == type)
+ for (; md; md = md->next) {
+ if (md->type == type) {
break;
+ }
+ }
return md;
}
@@ -256,8 +263,9 @@ void modifiers_foreachObjectLink(Object *ob, ObjectWalkFunc walk, void *userData
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (mti->foreachObjectLink)
+ if (mti->foreachObjectLink) {
mti->foreachObjectLink(md, ob, walk, userData);
+ }
}
}
@@ -268,8 +276,9 @@ void modifiers_foreachIDLink(Object *ob, IDWalkFunc walk, void *userData)
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (mti->foreachIDLink)
+ if (mti->foreachIDLink) {
mti->foreachIDLink(md, ob, walk, userData);
+ }
else if (mti->foreachObjectLink) {
/* each Object can masquerade as an ID, so this should be OK */
ObjectWalkFunc fp = (ObjectWalkFunc)walk;
@@ -285,8 +294,9 @@ void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData)
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (mti->foreachTexLink)
+ if (mti->foreachTexLink) {
mti->foreachTexLink(md, ob, walk, userData);
+ }
}
}
@@ -391,8 +401,9 @@ void modifier_setError(ModifierData *md, const char *_format, ...)
va_end(ap);
buffer[sizeof(buffer) - 1] = '\0';
- if (md->error)
+ if (md->error) {
MEM_freeN(md->error);
+ }
md->error = BLI_strdup(buffer);
@@ -426,28 +437,35 @@ int modifiers_getCageIndex(struct Scene *scene,
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
bool supports_mapping;
- if (mti->isDisabled && mti->isDisabled(scene, md, 0))
+ if (mti->isDisabled && mti->isDisabled(scene, md, 0)) {
continue;
- if (!(mti->flags & eModifierTypeFlag_SupportsEditmode))
+ }
+ if (!(mti->flags & eModifierTypeFlag_SupportsEditmode)) {
continue;
- if (md->mode & eModifierMode_DisableTemporary)
+ }
+ if (md->mode & eModifierMode_DisableTemporary) {
continue;
+ }
supports_mapping = modifier_supportsMapping(md);
if (r_lastPossibleCageIndex && supports_mapping) {
*r_lastPossibleCageIndex = i;
}
- if (!(md->mode & eModifierMode_Realtime))
+ if (!(md->mode & eModifierMode_Realtime)) {
continue;
- if (!(md->mode & eModifierMode_Editmode))
+ }
+ if (!(md->mode & eModifierMode_Editmode)) {
continue;
+ }
- if (!supports_mapping)
+ if (!supports_mapping) {
break;
+ }
- if (md->mode & eModifierMode_OnCage)
+ if (md->mode & eModifierMode_OnCage) {
cageIndex = i;
+ }
}
return cageIndex;
@@ -484,22 +502,27 @@ bool modifiers_isParticleEnabled(Object *ob)
/**
* Check whether is enabled.
*
- * \param scene: Current scene, may be NULL, in which case isDisabled callback of the modifier is never called.
+ * \param scene: Current scene, may be NULL,
+ * in which case isDisabled callback of the modifier is never called.
*/
bool modifier_isEnabled(const struct Scene *scene, ModifierData *md, int required_mode)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if ((md->mode & required_mode) != required_mode)
+ if ((md->mode & required_mode) != required_mode) {
return false;
+ }
if (scene != NULL && mti->isDisabled &&
- mti->isDisabled(scene, md, required_mode == eModifierMode_Render))
+ mti->isDisabled(scene, md, required_mode == eModifierMode_Render)) {
return false;
- if (md->mode & eModifierMode_DisableTemporary)
+ }
+ if (md->mode & eModifierMode_DisableTemporary) {
return false;
+ }
if ((required_mode & eModifierMode_Editmode) &&
- !(mti->flags & eModifierTypeFlag_SupportsEditmode))
+ !(mti->flags & eModifierTypeFlag_SupportsEditmode)) {
return false;
+ }
return true;
}
@@ -522,8 +545,9 @@ CDMaskLink *modifiers_calcDataMasks(struct Scene *scene,
curr = MEM_callocN(sizeof(CDMaskLink), "CDMaskLink");
if (modifier_isEnabled(scene, md, required_mode)) {
- if (mti->requiredDataMask)
+ if (mti->requiredDataMask) {
mti->requiredDataMask(ob, md, &curr->mask);
+ }
if (previewmd == md && previewmask != NULL) {
CustomData_MeshMasks_update(&curr->mask, previewmask);
@@ -560,13 +584,15 @@ ModifierData *modifiers_getLastPreview(struct Scene *scene, ModifierData *md, in
{
ModifierData *tmp_md = NULL;
- if ((required_mode & ~eModifierMode_Editmode) != eModifierMode_Realtime)
+ if ((required_mode & ~eModifierMode_Editmode) != eModifierMode_Realtime) {
return tmp_md;
+ }
/* Find the latest modifier in stack generating preview. */
for (; md; md = md->next) {
- if (modifier_isEnabled(scene, md, required_mode) && modifier_isPreview(md))
+ if (modifier_isEnabled(scene, md, required_mode) && modifier_isPreview(md)) {
tmp_md = md;
+ }
}
return tmp_md;
}
@@ -605,10 +631,12 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob,
/* shape key modifier, not yet for curves */
if (ELEM(ob->type, OB_MESH, OB_LATTICE) && BKE_key_from_object(ob)) {
- if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE))
+ if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE)) {
virtualModifierData->smd.modifier.mode |= eModifierMode_Editmode | eModifierMode_OnCage;
- else
+ }
+ else {
virtualModifierData->smd.modifier.mode &= ~eModifierMode_Editmode | eModifierMode_OnCage;
+ }
virtualModifierData->smd.modifier.next = md;
md = &virtualModifierData->smd.modifier;
@@ -630,13 +658,15 @@ Object *modifiers_isDeformedByArmature(Object *ob)
for (; md; md = md->next) {
if (md->type == eModifierType_Armature) {
amd = (ArmatureModifierData *)md;
- if (amd->object && (amd->object->flag & SELECT))
+ if (amd->object && (amd->object->base_flag & BASE_SELECTED)) {
return amd->object;
+ }
}
}
- if (amd) /* if were still here then return the last armature */
+ if (amd) { /* if were still here then return the last armature */
return amd->object;
+ }
return NULL;
}
@@ -651,13 +681,15 @@ Object *modifiers_isDeformedByMeshDeform(Object *ob)
for (; md; md = md->next) {
if (md->type == eModifierType_MeshDeform) {
mdmd = (MeshDeformModifierData *)md;
- if (mdmd->object && (mdmd->object->flag & SELECT))
+ if (mdmd->object && (mdmd->object->base_flag & BASE_SELECTED)) {
return mdmd->object;
+ }
}
}
- if (mdmd) /* if were still here then return the last armature */
+ if (mdmd) { /* if were still here then return the last armature */
return mdmd->object;
+ }
return NULL;
}
@@ -675,13 +707,15 @@ Object *modifiers_isDeformedByLattice(Object *ob)
for (; md; md = md->next) {
if (md->type == eModifierType_Lattice) {
lmd = (LatticeModifierData *)md;
- if (lmd->object && (lmd->object->flag & SELECT))
+ if (lmd->object && (lmd->object->base_flag & BASE_SELECTED)) {
return lmd->object;
+ }
}
}
- if (lmd) /* if were still here then return the last lattice */
+ if (lmd) { /* if were still here then return the last lattice */
return lmd->object;
+ }
return NULL;
}
@@ -699,13 +733,15 @@ Object *modifiers_isDeformedByCurve(Object *ob)
for (; md; md = md->next) {
if (md->type == eModifierType_Curve) {
cmd = (CurveModifierData *)md;
- if (cmd->object && (cmd->object->flag & SELECT))
+ if (cmd->object && (cmd->object->base_flag & BASE_SELECTED)) {
return cmd->object;
+ }
}
}
- if (cmd) /* if were still here then return the last curve */
+ if (cmd) { /* if were still here then return the last curve */
return cmd->object;
+ }
return NULL;
}
@@ -718,8 +754,9 @@ bool modifiers_usesArmature(Object *ob, bArmature *arm)
for (; md; md = md->next) {
if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData *)md;
- if (amd->object && amd->object->data == arm)
+ if (amd->object && amd->object->data == arm) {
return true;
+ }
}
}
@@ -759,8 +796,9 @@ bool modifiers_isPreview(Object *ob)
ModifierData *md = ob->modifiers.first;
for (; md; md = md->next) {
- if (modifier_isPreview(md))
+ if (modifier_isPreview(md)) {
return true;
+ }
}
return false;
@@ -786,8 +824,9 @@ void test_object_modifiers(Object *ob)
/* just multires checked for now, since only multires
* modifies mesh data */
- if (ob->type != OB_MESH)
+ if (ob->type != OB_MESH) {
return;
+ }
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Multires) {
@@ -892,7 +931,8 @@ void modwrap_deformVertsEM(ModifierData *md,
/**
* Get evaluated mesh for other evaluated object, which is used as an operand for the modifier,
* e.g. second operand for boolean modifier.
- * Note that modifiers in stack always get fully evaluated COW ID pointers, never original ones. Makes things simpler.
+ * Note that modifiers in stack always get fully evaluated COW ID pointers,
+ * never original ones. Makes things simpler.
*
* \param get_cage_mesh Return evaluated mesh with only deforming modifiers applied
* (i.e. mesh topology remains the same as original one, a.k.a. 'cage' mesh).
@@ -905,8 +945,8 @@ Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(Object *ob_eval,
if ((ob_eval->type == OB_MESH) && (ob_eval->mode & OB_MODE_EDIT)) {
/* In EditMode, evaluated mesh is stored in BMEditMesh, not the object... */
BMEditMesh *em = BKE_editmesh_from_object(ob_eval);
- if (em !=
- NULL) { /* em might not exist yet in some cases, just after loading a .blend file, see T57878. */
+ /* 'em' might not exist yet in some cases, just after loading a .blend file, see T57878. */
+ if (em != NULL) {
me = (get_cage_mesh && em->mesh_eval_cage != NULL) ? em->mesh_eval_cage :
em->mesh_eval_final;
}
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 51f7fd2208c..8d149af6a1f 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -84,8 +84,9 @@ static int sequence_guess_offset(const char *full_name, int head_len, unsigned s
static int rendersize_to_proxy(const MovieClipUser *user, int flag)
{
- if ((flag & MCLIP_USE_PROXY) == 0)
+ if ((flag & MCLIP_USE_PROXY) == 0) {
return IMB_PROXY_NONE;
+ }
switch (user->render_size) {
case MCLIP_PROXY_RENDER_SIZE_25:
@@ -131,8 +132,9 @@ static int rendersize_to_number(int render_size)
static int get_timecode(MovieClip *clip, int flag)
{
- if ((flag & MCLIP_USE_PROXY) == 0)
+ if ((flag & MCLIP_USE_PROXY) == 0) {
return IMB_TC_NONE;
+ }
return clip->proxy.tc;
}
@@ -179,10 +181,12 @@ static void get_proxy_fname(
BLI_snprintf(dir, FILE_MAX, "%s/BL_proxy", clipdir);
}
- if (undistorted)
+ if (undistorted) {
BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d_undistorted/%08d", dir, clipfile, size, proxynr);
- else
+ }
+ else {
BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, proxynr);
+ }
BLI_path_abs(name, BKE_main_blendfile_path_from_global());
BLI_path_frame(name, 1, 0);
@@ -378,10 +382,12 @@ static void movieclip_calc_length(MovieClip *clip)
for (;;) {
get_sequence_fname(clip, clip->len + clip->start_frame, name);
- if (BLI_exists(name))
+ if (BLI_exists(name)) {
clip->len++;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -458,8 +464,9 @@ static int user_frame_to_cache_frame(MovieClip *clip, int framenr)
index += clip->cache->sequence_offset;
}
- if (index < 0)
+ if (index < 0) {
return framenr - index;
+ }
return framenr;
}
@@ -703,8 +710,9 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
/* exists? */
file = BLI_open(str, O_BINARY | O_RDONLY, 0);
- if (file == -1)
+ if (file == -1) {
return NULL;
+ }
close(file);
/* ** add new movieclip ** */
@@ -742,14 +750,16 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b
if (BLI_path_cmp(strtest, str) == 0) {
id_us_plus(&clip->id); /* officially should not, it doesn't link here! */
- if (r_exists)
+ if (r_exists) {
*r_exists = true;
+ }
return clip;
}
}
- if (r_exists)
+ if (r_exists) {
*r_exists = false;
+ }
return BKE_movieclip_file_add(bmain, filepath);
}
@@ -790,11 +800,13 @@ static ImBuf *get_undistorted_ibuf(MovieClip *clip,
{
ImBuf *undistibuf;
- if (distortion)
+ if (distortion) {
undistibuf = BKE_tracking_distortion_exec(
distortion, &clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f, 1);
- else
+ }
+ else {
undistibuf = BKE_tracking_undistort_frame(&clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f);
+ }
IMB_scaleImBuf(undistibuf, ibuf->x, ibuf->y);
@@ -861,26 +873,32 @@ static ImBuf *get_postprocessed_cached_frame(const MovieClip *clip,
}
/* no cache or no cached postprocessed image */
- if (!clip->cache || !clip->cache->postprocessed.ibuf)
+ if (!clip->cache || !clip->cache->postprocessed.ibuf) {
return NULL;
+ }
/* postprocessing happened for other frame */
- if (cache->postprocessed.framenr != framenr)
+ if (cache->postprocessed.framenr != framenr) {
return NULL;
+ }
/* cached ibuf used different proxy settings */
- if (cache->postprocessed.render_flag != render_flag || cache->postprocessed.proxy != proxy)
+ if (cache->postprocessed.render_flag != render_flag || cache->postprocessed.proxy != proxy) {
return NULL;
+ }
- if (cache->postprocessed.flag != postprocess_flag)
+ if (cache->postprocessed.flag != postprocess_flag) {
return NULL;
+ }
if (need_undistortion_postprocess(user, flag)) {
- if (!check_undistortion_cache_flags(clip))
+ if (!check_undistortion_cache_flags(clip)) {
return NULL;
+ }
}
- else if (cache->postprocessed.undistortion_used)
+ else if (cache->postprocessed.undistortion_used) {
return NULL;
+ }
IMB_refImBuf(cache->postprocessed.ibuf);
@@ -905,8 +923,9 @@ static ImBuf *postprocess_frame(
bool disable_blue = (postprocess_flag & MOVIECLIP_DISABLE_BLUE) != 0;
bool grayscale = (postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE) != 0;
- if (disable_red || disable_green || disable_blue || grayscale)
+ if (disable_red || disable_green || disable_blue || grayscale) {
BKE_tracking_disable_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
+ }
}
return postproc_ibuf;
@@ -943,8 +962,9 @@ static void put_postprocessed_frame_to_cache(
IMB_refImBuf(ibuf);
- if (cache->postprocessed.ibuf)
+ if (cache->postprocessed.ibuf) {
IMB_freeImBuf(cache->postprocessed.ibuf);
+ }
cache->postprocessed.ibuf = ibuf;
}
@@ -964,12 +984,14 @@ static ImBuf *movieclip_get_postprocessed_ibuf(
if (need_postprocessed_frame(user, flag, postprocess_flag)) {
ibuf = get_postprocessed_cached_frame(clip, user, flag, postprocess_flag);
- if (!ibuf)
+ if (!ibuf) {
need_postprocess = true;
+ }
}
- if (!ibuf)
+ if (!ibuf) {
ibuf = get_imbuf_cache(clip, user, flag);
+ }
if (!ibuf) {
bool use_sequence = false;
@@ -1054,25 +1076,31 @@ static ImBuf *get_stable_cached_frame(
}
/* there's no cached frame or it was calculated for another frame */
- if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr)
+ if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr) {
return NULL;
+ }
- if (cache->stabilized.reference_ibuf != reference_ibuf)
+ if (cache->stabilized.reference_ibuf != reference_ibuf) {
return NULL;
+ }
/* cached ibuf used different proxy settings */
- if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy)
+ if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy) {
return NULL;
+ }
- if (cache->stabilized.postprocess_flag != postprocess_flag)
+ if (cache->stabilized.postprocess_flag != postprocess_flag) {
return NULL;
+ }
/* stabilization also depends on pixel aspect ratio */
- if (cache->stabilized.aspect != tracking->camera.pixel_aspect)
+ if (cache->stabilized.aspect != tracking->camera.pixel_aspect) {
return NULL;
+ }
- if (cache->stabilized.filter != tracking->stabilization.filter)
+ if (cache->stabilized.filter != tracking->stabilization.filter) {
return NULL;
+ }
stableibuf = cache->stabilized.ibuf;
@@ -1121,8 +1149,9 @@ static ImBuf *put_stabilized_frame_to_cache(
cache->stabilized.postprocess_flag = postprocess_flag;
- if (cache->stabilized.ibuf)
+ if (cache->stabilized.ibuf) {
IMB_freeImBuf(cache->stabilized.ibuf);
+ }
cache->stabilized.ibuf = stableibuf;
@@ -1143,35 +1172,43 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip,
ibuf = BKE_movieclip_get_postprocessed_ibuf(clip, user, postprocess_flag);
- if (!ibuf)
+ if (!ibuf) {
return NULL;
+ }
if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
MovieClipCache *cache = clip->cache;
stableibuf = get_stable_cached_frame(clip, user, ibuf, framenr, postprocess_flag);
- if (!stableibuf)
+ if (!stableibuf) {
stableibuf = put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag);
+ }
- if (loc)
+ if (loc) {
copy_v2_v2(loc, cache->stabilized.loc);
+ }
- if (scale)
+ if (scale) {
*scale = cache->stabilized.scale;
+ }
- if (angle)
+ if (angle) {
*angle = cache->stabilized.angle;
+ }
}
else {
- if (loc)
+ if (loc) {
zero_v2(loc);
+ }
- if (scale)
+ if (scale) {
*scale = 1.0f;
+ }
- if (angle)
+ if (angle) {
*angle = 0.0f;
+ }
stableibuf = ibuf;
}
@@ -1224,8 +1261,9 @@ void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, in
*height = clip->lastsize[1];
}
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
}
}
void BKE_movieclip_get_size_fl(MovieClip *clip, MovieClipUser *user, float size[2])
@@ -1300,11 +1338,13 @@ static void free_buffers(MovieClip *clip)
if (clip->cache) {
IMB_moviecache_free(clip->cache->moviecache);
- if (clip->cache->postprocessed.ibuf)
+ if (clip->cache->postprocessed.ibuf) {
IMB_freeImBuf(clip->cache->postprocessed.ibuf);
+ }
- if (clip->cache->stabilized.ibuf)
+ if (clip->cache->stabilized.ibuf) {
IMB_freeImBuf(clip->cache->stabilized.ibuf);
+ }
MEM_freeN(clip->cache);
clip->cache = NULL;
@@ -1356,8 +1396,9 @@ void BKE_movieclip_reload(Main *bmain, MovieClip *clip)
void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClipScopes *scopes)
{
- if (scopes->ok)
+ if (scopes->ok) {
return;
+ }
if (scopes->track_preview) {
IMB_freeImBuf(scopes->track_preview);
@@ -1459,17 +1500,20 @@ static void movieclip_build_proxy_ibuf(
scaleibuf = IMB_dupImBuf(ibuf);
- if (threaded)
+ if (threaded) {
IMB_scaleImBuf_threaded(scaleibuf, (short)rectx, (short)recty);
- else
+ }
+ else {
IMB_scaleImBuf(scaleibuf, (short)rectx, (short)recty);
+ }
quality = clip->proxy.quality;
scaleibuf->ftype = IMB_FTYPE_JPG;
scaleibuf->foptions.quality = quality;
/* unsupported feature only confuses other s/w */
- if (scaleibuf->planes == 32)
+ if (scaleibuf->planes == 32) {
scaleibuf->planes = 24;
+ }
/* TODO: currently the most weak part of multithreaded proxies,
* could be solved in a way that thread only prepares memory
@@ -1478,8 +1522,9 @@ static void movieclip_build_proxy_ibuf(
BLI_thread_lock(LOCK_MOVIECLIP);
BLI_make_existing_file(name);
- if (IMB_saveiff(scaleibuf, name, IB_rect) == 0)
+ if (IMB_saveiff(scaleibuf, name, IB_rect) == 0) {
perror(name);
+ }
BLI_thread_unlock(LOCK_MOVIECLIP);
@@ -1500,8 +1545,9 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip,
ImBuf *ibuf;
MovieClipUser user;
- if (!build_count)
+ if (!build_count) {
return;
+ }
user.framenr = cfra;
user.render_flag = 0;
@@ -1513,16 +1559,19 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip,
ImBuf *tmpibuf = ibuf;
int i;
- if (undistorted)
+ if (undistorted) {
tmpibuf = get_undistorted_ibuf(clip, distortion, ibuf);
+ }
- for (i = 0; i < build_count; i++)
+ for (i = 0; i < build_count; i++) {
movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted, true);
+ }
IMB_freeImBuf(ibuf);
- if (tmpibuf != ibuf)
+ if (tmpibuf != ibuf) {
IMB_freeImBuf(tmpibuf);
+ }
}
}
@@ -1537,21 +1586,25 @@ void BKE_movieclip_build_proxy_frame_for_ibuf(MovieClip *clip,
int build_count,
bool undistorted)
{
- if (!build_count)
+ if (!build_count) {
return;
+ }
if (ibuf) {
ImBuf *tmpibuf = ibuf;
int i;
- if (undistorted)
+ if (undistorted) {
tmpibuf = get_undistorted_ibuf(clip, distortion, ibuf);
+ }
- for (i = 0; i < build_count; i++)
+ for (i = 0; i < build_count; i++) {
movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted, false);
+ }
- if (tmpibuf != ibuf)
+ if (tmpibuf != ibuf) {
IMB_freeImBuf(tmpibuf);
+ }
}
}
@@ -1566,8 +1619,10 @@ void BKE_movieclip_free(MovieClip *clip)
}
/**
- * Only copy internal data of MovieClip ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of MovieClip ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 5e404f7e264..e3953af7cbf 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -117,8 +117,9 @@ static BLI_bitmap *multires_mdisps_upsample_hidden(BLI_bitmap *lo_hidden,
BLI_assert(lo_level <= hi_level);
/* fast case */
- if (lo_level == hi_level)
+ if (lo_level == hi_level) {
return MEM_dupallocN(lo_hidden);
+ }
subd = BLI_BITMAP_NEW(SQUARE(hi_gridsize), "MDisps.hidden upsample");
@@ -133,13 +134,15 @@ static BLI_bitmap *multires_mdisps_upsample_hidden(BLI_bitmap *lo_hidden,
/* high-res blocks */
for (yo = -offset; yo <= offset; yo++) {
yh = yl * factor + yo;
- if (yh < 0 || yh >= hi_gridsize)
+ if (yh < 0 || yh >= hi_gridsize) {
continue;
+ }
for (xo = -offset; xo <= offset; xo++) {
xh = xl * factor + xo;
- if (xh < 0 || xh >= hi_gridsize)
+ if (xh < 0 || xh >= hi_gridsize) {
continue;
+ }
hi_ndx = yh * hi_gridsize + xh;
@@ -220,8 +223,9 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
BLI_assert(md->hidden);
/* nothing to do if already subdivided enough */
- if (md->level >= new_level)
+ if (md->level >= new_level) {
return;
+ }
subd = multires_mdisps_upsample_hidden(md->hidden, md->level, new_level, NULL);
@@ -247,8 +251,9 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
}
}
- if (!hide)
+ if (!hide) {
continue;
+ }
for (j = 0; j < me->mpoly[i].totloop; j++) {
MDisps *md = &mdisps[me->mpoly[i].loopstart + j];
@@ -291,8 +296,9 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData *
for (md = lastmd; md; md = md->prev) {
if (md->type == eModifierType_Multires) {
- if (modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
return (MultiresModifierData *)md;
+ }
}
}
@@ -310,8 +316,9 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, bool use_f
/* find first active multires modifier */
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Multires) {
- if (!firstmmd)
+ if (!firstmmd) {
firstmmd = (MultiresModifierData *)md;
+ }
if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
mmd = (MultiresModifierData *)md;
@@ -335,23 +342,28 @@ int multires_get_level(const Scene *scene,
bool render,
bool ignore_simplify)
{
- if (render)
+ if (render) {
return (scene != NULL) ? get_render_subsurf_level(&scene->r, mmd->renderlvl, true) :
mmd->renderlvl;
- else if (ob->mode == OB_MODE_SCULPT)
+ }
+ else if (ob->mode == OB_MODE_SCULPT) {
return mmd->sculptlvl;
- else if (ignore_simplify)
+ }
+ else if (ignore_simplify) {
return mmd->lvl;
- else
+ }
+ else {
return (scene != NULL) ? get_render_subsurf_level(&scene->r, mmd->lvl, false) : mmd->lvl;
+ }
}
void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl)
{
mmd->totlvl = lvl;
- if (ob->mode != OB_MODE_SCULPT)
+ if (ob->mode != OB_MODE_SCULPT) {
mmd->lvl = CLAMPIS(MAX2(mmd->lvl, lvl), 0, mmd->totlvl);
+ }
mmd->sculptlvl = CLAMPIS(MAX2(mmd->sculptlvl, lvl), 0, mmd->totlvl);
mmd->renderlvl = CLAMPIS(MAX2(mmd->renderlvl, lvl), 0, mmd->totlvl);
@@ -418,8 +430,9 @@ void multires_force_external_reload(Object *ob)
void multires_force_render_update(Object *ob)
{
- if (ob && (ob->mode & OB_MODE_SCULPT) && modifiers_findByType(ob, eModifierType_Multires))
+ if (ob && (ob->mode & OB_MODE_SCULPT) && modifiers_findByType(ob, eModifierType_Multires)) {
multires_force_update(ob);
+ }
}
/* reset the multires levels to match the number of mdisps */
@@ -435,18 +448,22 @@ static int get_levels_from_disps(Object *ob)
md = mdisp + me->mpoly[i].loopstart;
for (j = 0; j < me->mpoly[i].totloop; j++, md++) {
- if (md->totdisp == 0)
+ if (md->totdisp == 0) {
continue;
+ }
while (1) {
int side = (1 << (totlvl - 1)) + 1;
int lvl_totdisp = side * side;
- if (md->totdisp == lvl_totdisp)
+ if (md->totdisp == lvl_totdisp) {
break;
- else if (md->totdisp < lvl_totdisp)
+ }
+ else if (md->totdisp < lvl_totdisp) {
totlvl--;
- else
+ }
+ else {
totlvl++;
+ }
}
break;
@@ -462,10 +479,12 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o
Mesh *me = ob->data;
MDisps *mdisp;
- if (me->edit_mesh)
+ if (me->edit_mesh) {
mdisp = CustomData_get_layer(&me->edit_mesh->bm->ldata, CD_MDISPS);
- else
+ }
+ else {
mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS);
+ }
if (mdisp) {
mmd->totlvl = get_levels_from_disps(ob);
@@ -497,11 +516,13 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl)
int totdisp = multires_grid_tot[lvl];
float(*disps)[3] = MEM_calloc_arrayN(totdisp, 3 * sizeof(float), "multires disps");
- if (mdisps[i].disps)
+ if (mdisps[i].disps) {
MEM_freeN(mdisps[i].disps);
+ }
- if (mdisps[i].level && mdisps[i].hidden)
+ if (mdisps[i].level && mdisps[i].hidden) {
multires_mdisps_subdivide_hidden(&mdisps[i], lvl);
+ }
mdisps[i].disps = disps;
mdisps[i].totdisp = totdisp;
@@ -516,16 +537,20 @@ static void multires_copy_grid(float (*gridA)[3], float (*gridB)[3], int sizeA,
if (sizeA > sizeB) {
skip = (sizeA - 1) / (sizeB - 1);
- for (j = 0, y = 0; y < sizeB; y++)
- for (x = 0; x < sizeB; x++, j++)
+ for (j = 0, y = 0; y < sizeB; y++) {
+ for (x = 0; x < sizeB; x++, j++) {
copy_v3_v3(gridA[y * skip * sizeA + x * skip], gridB[j]);
+ }
+ }
}
else {
skip = (sizeB - 1) / (sizeA - 1);
- for (j = 0, y = 0; y < sizeA; y++)
- for (x = 0; x < sizeA; x++, j++)
+ for (j = 0, y = 0; y < sizeA; y++) {
+ for (x = 0; x < sizeA; x++, j++) {
copy_v3_v3(gridA[j], gridB[y * skip * sizeB + x * skip]);
+ }
+ }
}
}
@@ -536,20 +561,24 @@ static void multires_copy_dm_grid(CCGElem *gridA, CCGElem *gridB, CCGKey *keyA,
if (keyA->grid_size > keyB->grid_size) {
skip = (keyA->grid_size - 1) / (keyB->grid_size - 1);
- for (j = 0, y = 0; y < keyB->grid_size; y++)
- for (x = 0; x < keyB->grid_size; x++, j++)
+ for (j = 0, y = 0; y < keyB->grid_size; y++) {
+ for (x = 0; x < keyB->grid_size; x++, j++) {
memcpy(CCG_elem_offset_co(keyA, gridA, y * skip * keyA->grid_size + x * skip),
CCG_elem_offset_co(keyB, gridB, j),
keyA->elem_size);
+ }
+ }
}
else {
skip = (keyB->grid_size - 1) / (keyA->grid_size - 1);
- for (j = 0, y = 0; y < keyA->grid_size; y++)
- for (x = 0; x < keyA->grid_size; x++, j++)
+ for (j = 0, y = 0; y < keyA->grid_size; y++) {
+ for (x = 0; x < keyA->grid_size; x++, j++) {
memcpy(CCG_elem_offset_co(keyA, gridA, j),
CCG_elem_offset_co(keyB, gridB, y * skip * keyB->grid_size + x * skip),
keyA->elem_size);
+ }
+ }
}
}
@@ -679,8 +708,9 @@ static DerivedMesh *multires_dm_create_local(Scene *scene,
mmd.simple = simple;
flags |= MULTIRES_USE_LOCAL_MMD;
- if (alloc_paint_mask)
+ if (alloc_paint_mask) {
flags |= MULTIRES_ALLOC_PAINT_MASK;
+ }
return multires_make_derived_from_derived(dm, &mmd, scene, ob, flags);
}
@@ -749,8 +779,9 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Scene *scene, Object
totlvl = mmd->totlvl;
/* nothing to do */
- if (!totlvl)
+ if (!totlvl) {
return;
+ }
/* XXX - probably not necessary to regenerate the cddm so much? */
@@ -772,8 +803,9 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Scene *scene, Object
cddm = CDDM_from_mesh(me);
pmap = cddm->getPolyMap(ob, cddm);
origco = MEM_calloc_arrayN(me->totvert, 3 * sizeof(float), "multires apply base origco");
- for (i = 0; i < me->totvert; ++i)
+ for (i = 0; i < me->totvert; ++i) {
copy_v3_v3(origco[i], me->mvert[i].co);
+ }
for (i = 0; i < me->totvert; ++i) {
float avg_no[3] = {0, 0, 0}, center[3] = {0, 0, 0}, push[3];
@@ -781,8 +813,9 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Scene *scene, Object
int tot = 0;
/* don't adjust verts not used by at least one poly */
- if (!pmap[i].count)
+ if (!pmap[i].count) {
continue;
+ }
/* find center */
for (j = 0; j < pmap[i].count; j++) {
@@ -819,10 +852,12 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Scene *scene, Object
fake_loops[k].v = k;
- if (vndx == i)
+ if (vndx == i) {
copy_v3_v3(fake_co[k], center);
- else
+ }
+ else {
copy_v3_v3(fake_co[k], origco[vndx]);
+ }
}
BKE_mesh_calc_poly_normal_coords(&fake_poly, fake_loops, (const float(*)[3])fake_co, no);
@@ -879,16 +914,18 @@ static void multires_subdivide(
MDisps *mdisps;
const int lvl = mmd->totlvl;
- if ((totlvl > multires_max_levels) || (me->totpoly == 0))
+ if ((totlvl > multires_max_levels) || (me->totpoly == 0)) {
return;
+ }
BLI_assert(totlvl > lvl);
multires_force_update(ob);
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
- if (!mdisps)
+ if (!mdisps) {
mdisps = multires_mdisps_initialize_hidden(me, totlvl);
+ }
if (mdisps->disps && !updateblock && lvl != 0) {
/* upsample */
@@ -955,8 +992,9 @@ static void multires_subdivide(
/* free */
highdm->release(highdm);
- for (i = 0; i < numGrids; ++i)
+ for (i = 0; i < numGrids; ++i) {
MEM_freeN(subGridData[i]);
+ }
MEM_freeN(subGridData);
}
else {
@@ -977,25 +1015,31 @@ static void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *gri
{
if (axis == 0) {
if (x == key->grid_size - 1) {
- if (y == key->grid_size - 1)
+ if (y == key->grid_size - 1) {
sub_v3_v3v3(
t, CCG_grid_elem_co(key, grid, x, y - 1), CCG_grid_elem_co(key, grid, x - 1, y - 1));
- else
+ }
+ else {
sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x, y), CCG_grid_elem_co(key, grid, x - 1, y));
+ }
}
- else
+ else {
sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x + 1, y), CCG_grid_elem_co(key, grid, x, y));
+ }
}
else if (axis == 1) {
if (y == key->grid_size - 1) {
- if (x == key->grid_size - 1)
+ if (x == key->grid_size - 1) {
sub_v3_v3v3(
t, CCG_grid_elem_co(key, grid, x - 1, y), CCG_grid_elem_co(key, grid, x - 1, (y - 1)));
- else
+ }
+ else {
sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x, y), CCG_grid_elem_co(key, grid, x, (y - 1)));
+ }
}
- else
+ else {
sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x, (y + 1)), CCG_grid_elem_co(key, grid, x, y));
+ }
}
}
@@ -1147,10 +1191,12 @@ static void multiresModifier_disp_run(
}
if (!mdisps) {
- if (op == CALC_DISPLACEMENTS)
+ if (op == CALC_DISPLACEMENTS) {
mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_DEFAULT, NULL, me->totloop);
- else
+ }
+ else {
return;
+ }
}
/*numGrids = dm->getNumGrids(dm);*/ /*UNUSED*/
@@ -1164,8 +1210,9 @@ static void multiresModifier_disp_run(
dSkip = (dGridSize - 1) / (gridSize - 1);
/* multires paint masks */
- if (key.has_mask)
+ if (key.has_mask) {
grid_paint_mask = CustomData_get_layer(&me->ldata, CD_GRID_PAINT_MASK);
+ }
/* when adding new faces in edit mode, need to allocate disps */
for (i = 0; i < totloop; ++i) {
@@ -1229,10 +1276,12 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene)
const bool has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
/* create subsurf DM from original mesh at high level */
- if (ob->derivedDeform)
+ if (ob->derivedDeform) {
cddm = CDDM_copy(ob->derivedDeform);
- else
+ }
+ else {
cddm = CDDM_from_mesh(me);
+ }
DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
highdm = subsurf_dm_create_local(scene,
@@ -1297,18 +1346,21 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene)
/* free */
highdm->release(highdm);
- for (i = 0; i < numGrids; ++i)
+ for (i = 0; i < numGrids; ++i) {
MEM_freeN(subGridData[i]);
+ }
MEM_freeN(subGridData);
}
else {
DerivedMesh *cddm, *subdm;
const bool has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
- if (ob->derivedDeform)
+ if (ob->derivedDeform) {
cddm = CDDM_copy(ob->derivedDeform);
- else
+ }
+ else {
cddm = CDDM_from_mesh(me);
+ }
DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
subdm = subsurf_dm_create_local(scene,
@@ -1353,8 +1405,9 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
}
else if (gh) {
gh = multires_mdisps_upsample_hidden(gh, lvl, totlvl, md->hidden);
- if (md->hidden)
+ if (md->hidden) {
MEM_freeN(md->hidden);
+ }
md->hidden = gh;
}
@@ -1402,8 +1455,9 @@ DerivedMesh *multires_make_derived_from_derived(
int lvl = multires_get_level(scene, ob, mmd, render, ignore_simplify);
int i, gridSize, numGrids;
- if (lvl == 0)
+ if (lvl == 0) {
return dm;
+ }
const int subsurf_flags = ignore_simplify ? SUBSURF_IGNORE_SIMPLIFY : 0;
@@ -1448,11 +1502,13 @@ DerivedMesh *multires_make_derived_from_derived(
multiresModifier_disp_run(result, ob->data, dm, APPLY_DISPLACEMENTS, subGridData, mmd->totlvl);
/* copy hidden elements for this level */
- if (ccgdm)
+ if (ccgdm) {
multires_output_hidden_to_ccgdm(ccgdm, me, lvl);
+ }
- for (i = 0; i < numGrids; i++)
+ for (i = 0; i < numGrids; i++) {
MEM_freeN(subGridData[i]);
+ }
MEM_freeN(subGridData);
return result;
@@ -1469,27 +1525,34 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u,
float urat, vrat, uopp;
float d[4][3], d2[2][3];
- if (!disps || isnan(u) || isnan(v))
+ if (!disps || isnan(u) || isnan(v)) {
return;
+ }
- if (u < 0)
+ if (u < 0) {
u = 0;
- else if (u >= st)
+ }
+ else if (u >= st) {
u = st_max;
- if (v < 0)
+ }
+ if (v < 0) {
v = 0;
- else if (v >= st)
+ }
+ else if (v >= st) {
v = st_max;
+ }
x = floor(u);
y = floor(v);
x2 = x + 1;
y2 = y + 1;
- if (x2 >= st)
+ if (x2 >= st) {
x2 = st_max;
- if (y2 >= st)
+ }
+ if (y2 >= st) {
y2 = st_max;
+ }
urat = u - x;
vrat = v - y;
@@ -1585,9 +1648,11 @@ void multires_load_old_250(Mesh *me)
mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS);
if (mdisps) {
- for (i = 0; i < me->totface; i++)
- if (mdisps[i].totdisp)
+ for (i = 0; i < me->totface; i++) {
+ if (mdisps[i].totdisp) {
old_mdisps_convert(&me->mface[i], &mdisps[i]);
+ }
+ }
CustomData_add_layer(&me->ldata, CD_MDISPS, CD_CALLOC, NULL, me->totloop);
mdisps2 = CustomData_get_layer(&me->ldata, CD_MDISPS);
@@ -1613,12 +1678,15 @@ void multires_load_old_250(Mesh *me)
static void multires_free_level(MultiresLevel *lvl)
{
if (lvl) {
- if (lvl->faces)
+ if (lvl->faces) {
MEM_freeN(lvl->faces);
- if (lvl->edges)
+ }
+ if (lvl->edges) {
MEM_freeN(lvl->edges);
- if (lvl->colfaces)
+ }
+ if (lvl->colfaces) {
MEM_freeN(lvl->colfaces);
+ }
}
}
@@ -1631,10 +1699,12 @@ void multires_free(Multires *mr)
if (lvl) {
CustomData_free(&mr->vdata, lvl->totvert);
CustomData_free(&mr->fdata, lvl->totface);
- if (mr->edge_flags)
+ if (mr->edge_flags) {
MEM_freeN(mr->edge_flags);
- if (mr->edge_creases)
+ }
+ if (mr->edge_creases) {
MEM_freeN(mr->edge_creases);
+ }
}
while (lvl) {
@@ -1642,7 +1712,8 @@ void multires_free(Multires *mr)
lvl = lvl->next;
}
- /* mr->verts may be NULL when loading old files, see direct_link_mesh() in readfile.c, and T43560. */
+ /* mr->verts may be NULL when loading old files,
+ * see direct_link_mesh() in readfile.c, and T43560. */
MEM_SAFE_FREE(mr->verts);
BLI_freelistN(&mr->levels);
@@ -1716,13 +1787,15 @@ static MultiresFace *find_old_face(
for (i = 0; i < 4; ++i) {
for (j = 0; j < 4; ++j) {
- if (v[i] == faces[n1->index].v[j])
+ if (v[i] == faces[n1->index].v[j]) {
fnd[i] = 1;
+ }
}
}
- if (fnd[0] && fnd[1] && fnd[2] && fnd[3])
+ if (fnd[0] && fnd[1] && fnd[2] && fnd[3]) {
return &faces[n1->index];
+ }
}
return NULL;
@@ -1734,8 +1807,9 @@ static MultiresEdge *find_old_edge(ListBase *map, MultiresEdge *edges, int v1, i
for (n1 = map[v1].first; n1; n1 = n1->next) {
for (n2 = map[v2].first; n2; n2 = n2->next) {
- if (n1->index == n2->index)
+ if (n1->index == n2->index) {
return &edges[n1->index];
+ }
}
}
@@ -1941,8 +2015,9 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
int skip = multires_side_tot[totlvl - j + 2] - 1;
int st = multires_side_tot[j - 1] - 1;
- for (x = 0; x < st; ++x)
+ for (x = 0; x < st; ++x) {
vvmap[ldst + base + x * skip] = lsrc + st * i + x;
+ }
lsrc += lvl->totvert - lvl->prev->totvert;
lvl = lvl->next;
@@ -1998,10 +2073,12 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
dst += sides * (st_last - 1) * st_last;
- if (sides == 4)
+ if (sides == 4) {
++totquad;
- else
+ }
+ else {
++tottri;
+ }
}
/* calculate vert to edge/face maps for each level (except the last) */
@@ -2066,8 +2143,9 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl)
}
/* Transfer verts */
- for (i = 0; i < totvert; ++i)
+ for (i = 0; i < totvert; ++i) {
copy_v3_v3(vdst[i].co, vsrc[vvmap[i]].co);
+ }
MEM_freeN(vvmap);
@@ -2083,16 +2161,19 @@ static void multires_load_old_vcols(Mesh *me)
MCol *mcol;
int i, j;
- if (!(lvl = me->mr->levels.first))
+ if (!(lvl = me->mr->levels.first)) {
return;
+ }
- if (!(colface = lvl->colfaces))
+ if (!(colface = lvl->colfaces)) {
return;
+ }
/* older multires format never supported multiple vcol layers,
* so we can assume the active vcol layer is the correct one */
- if (!(mcol = CustomData_get_layer(&me->fdata, CD_MCOL)))
+ if (!(mcol = CustomData_get_layer(&me->fdata, CD_MCOL))) {
return;
+ }
for (i = 0; i < me->totface; ++i) {
for (j = 0; j < 4; ++j) {
@@ -2111,14 +2192,17 @@ static void multires_load_old_face_flags(Mesh *me)
MultiresFace *faces;
int i;
- if (!(lvl = me->mr->levels.first))
+ if (!(lvl = me->mr->levels.first)) {
return;
+ }
- if (!(faces = lvl->faces))
+ if (!(faces = lvl->faces)) {
return;
+ }
- for (i = 0; i < me->totface; ++i)
+ for (i = 0; i < me->totface; ++i) {
me->mface[i].flag = faces[i].flag;
+ }
}
void multires_load_old(Object *ob, Mesh *me)
@@ -2156,10 +2240,12 @@ void multires_load_old(Object *ob, Mesh *me)
/* Copy the first-level data to the mesh */
/* XXX We must do this before converting tessfaces to polys/lopps! */
- for (i = 0, l = me->mr->vdata.layers; i < me->mr->vdata.totlayer; ++i, ++l)
+ for (i = 0, l = me->mr->vdata.layers; i < me->mr->vdata.totlayer; ++i, ++l) {
CustomData_add_layer(&me->vdata, l->type, CD_REFERENCE, l->data, me->totvert);
- for (i = 0, l = me->mr->fdata.layers; i < me->mr->fdata.totlayer; ++i, ++l)
+ }
+ for (i = 0, l = me->mr->fdata.layers; i < me->mr->fdata.totlayer; ++i, ++l) {
CustomData_add_layer(&me->fdata, l->type, CD_REFERENCE, l->data, me->totface);
+ }
CustomData_reset(&me->mr->vdata);
CustomData_reset(&me->mr->fdata);
@@ -2171,13 +2257,15 @@ void multires_load_old(Object *ob, Mesh *me)
/* Add a multires modifier to the object */
md = ob->modifiers.first;
- while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform)
+ while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) {
md = md->next;
+ }
mmd = (MultiresModifierData *)modifier_new(eModifierType_Multires);
BLI_insertlinkbefore(&ob->modifiers, md, mmd);
- for (i = 0; i < me->mr->level_count - 1; ++i)
+ for (i = 0; i < me->mr->level_count - 1; ++i) {
multiresModifier_subdivide(mmd, NULL, ob, 1, 0);
+ }
mmd->lvl = mmd->totlvl;
orig = CDDM_from_mesh(me);
@@ -2283,8 +2371,9 @@ int multires_mdisp_corners(MDisps *s)
while (lvl > 0) {
int side = (1 << (lvl - 1)) + 1;
- if ((s->totdisp % (side * side)) == 0)
+ if ((s->totdisp % (side * side)) == 0) {
return s->totdisp / (side * side);
+ }
lvl--;
}
@@ -2327,8 +2416,9 @@ void multires_topology_changed(Mesh *me)
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS);
- if (!mdisp)
+ if (!mdisp) {
return;
+ }
cur = mdisp;
for (i = 0; i < me->totloop; i++, cur++) {
@@ -2369,14 +2459,18 @@ int mdisp_rot_face_to_crn(struct MVert *UNUSED(mvert),
int S = 0;
if (mpoly->totloop == 4) {
- if (u <= offset && v <= offset)
+ if (u <= offset && v <= offset) {
S = 0;
- else if (u > offset && v <= offset)
+ }
+ else if (u > offset && v <= offset) {
S = 1;
- else if (u > offset && v > offset)
+ }
+ else if (u > offset && v > offset) {
S = 2;
- else if (u <= offset && v >= offset)
+ }
+ else if (u <= offset && v >= offset) {
S = 3;
+ }
if (S == 0) {
*y = offset - u;
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 3b33af62073..15e53e12ece 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -74,8 +74,9 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
NlaStrip *cs, *csn;
/* sanity checks */
- if (strip == NULL)
+ if (strip == NULL) {
return;
+ }
/* free child-strips */
for (cs = strip->strips.first; cs; cs = csn) {
@@ -89,7 +90,7 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
}
/* free remapping info */
- //if (strip->remap)
+ // if (strip->remap)
// BKE_animremap_free();
/* free own F-Curves */
@@ -99,10 +100,12 @@ void BKE_nlastrip_free(ListBase *strips, NlaStrip *strip, bool do_id_user)
free_fmodifiers(&strip->modifiers);
/* free the strip itself */
- if (strips)
+ if (strips) {
BLI_freelinkN(strips, strip);
- else
+ }
+ else {
MEM_freeN(strip);
+ }
}
/* Remove the given NLA track from the set of NLA tracks, free the track's data,
@@ -113,8 +116,9 @@ void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
NlaStrip *strip, *stripn;
/* sanity checks */
- if (nlt == NULL)
+ if (nlt == NULL) {
return;
+ }
/* free strips */
for (strip = nlt->strips.first; strip; strip = stripn) {
@@ -123,10 +127,12 @@ void BKE_nlatrack_free(ListBase *tracks, NlaTrack *nlt, bool do_id_user)
}
/* free NLA track itself now */
- if (tracks)
+ if (tracks) {
BLI_freelinkN(tracks, nlt);
- else
+ }
+ else {
MEM_freeN(nlt);
+ }
}
/* Free the elements of type NLA Tracks provided in the given list, but do not free
@@ -137,8 +143,9 @@ void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user)
NlaTrack *nlt, *nltn;
/* sanity checks */
- if (ELEM(NULL, tracks, tracks->first))
+ if (ELEM(NULL, tracks, tracks->first)) {
return;
+ }
/* free tracks one by one */
for (nlt = tracks->first; nlt; nlt = nltn) {
@@ -156,7 +163,8 @@ void BKE_nla_tracks_free(ListBase *tracks, bool do_id_user)
* Copy NLA strip
*
* \param use_same_action: When true, the existing action is used (instead of being duplicated)
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_...
+ * flags in BKE_library.h
*/
NlaStrip *BKE_nlastrip_copy(Main *bmain,
NlaStrip *strip,
@@ -169,8 +177,9 @@ NlaStrip *BKE_nlastrip_copy(Main *bmain,
const bool do_id_user = (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0;
/* sanity check */
- if (strip == NULL)
+ if (strip == NULL) {
return NULL;
+ }
/* make a copy */
strip_d = MEM_dupallocN(strip);
@@ -208,7 +217,8 @@ NlaStrip *BKE_nlastrip_copy(Main *bmain,
/**
* Copy a single NLA Track.
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_...
+ * flags in BKE_library.h
*/
NlaTrack *BKE_nlatrack_copy(Main *bmain,
NlaTrack *nlt,
@@ -219,8 +229,9 @@ NlaTrack *BKE_nlatrack_copy(Main *bmain,
NlaTrack *nlt_d;
/* sanity check */
- if (nlt == NULL)
+ if (nlt == NULL) {
return NULL;
+ }
/* make a copy */
nlt_d = MEM_dupallocN(nlt);
@@ -240,15 +251,17 @@ NlaTrack *BKE_nlatrack_copy(Main *bmain,
/**
* Copy all NLA data.
- * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_... flags in BKE_library.h
+ * \param flag: Control ID pointers management, see LIB_ID_CREATE_.../LIB_ID_COPY_...
+ * flags in BKE_library.h
*/
void BKE_nla_tracks_copy(Main *bmain, ListBase *dst, ListBase *src, const int flag)
{
NlaTrack *nlt, *nlt_d;
/* sanity checks */
- if (ELEM(NULL, dst, src))
+ if (ELEM(NULL, dst, src)) {
return;
+ }
/* clear out the destination list first for precautions... */
BLI_listbase_clear(dst);
@@ -272,8 +285,9 @@ NlaTrack *BKE_nlatrack_add(AnimData *adt, NlaTrack *prev)
NlaTrack *nlt;
/* sanity checks */
- if (adt == NULL)
+ if (adt == NULL) {
return NULL;
+ }
/* allocate new track */
nlt = MEM_callocN(sizeof(NlaTrack), "NlaTrack");
@@ -283,10 +297,12 @@ NlaTrack *BKE_nlatrack_add(AnimData *adt, NlaTrack *prev)
nlt->index = BLI_listbase_count(&adt->nla_tracks);
/* add track to stack, and make it the active one */
- if (prev)
+ if (prev) {
BLI_insertlinkafter(&adt->nla_tracks, prev, nlt);
- else
+ }
+ else {
BLI_addtail(&adt->nla_tracks, nlt);
+ }
BKE_nlatrack_set_active(&adt->nla_tracks, nlt);
/* must have unique name, but we need to seed this */
@@ -304,8 +320,9 @@ NlaStrip *BKE_nlastrip_new(bAction *act)
NlaStrip *strip;
/* sanity checks */
- if (act == NULL)
+ if (act == NULL) {
return NULL;
+ }
/* allocate new strip */
strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
@@ -340,20 +357,23 @@ NlaStrip *BKE_nlastrip_new(bAction *act)
return strip;
}
-/* Add new NLA-strip to the top of the NLA stack - i.e. into the last track if space, or a new one otherwise */
+/* Add new NLA-strip to the top of the NLA stack - i.e.
+ * into the last track if space, or a new one otherwise. */
NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act)
{
NlaStrip *strip;
NlaTrack *nlt;
/* sanity checks */
- if (ELEM(NULL, adt, act))
+ if (ELEM(NULL, adt, act)) {
return NULL;
+ }
/* create a new NLA strip */
strip = BKE_nlastrip_new(act);
- if (strip == NULL)
+ if (strip == NULL) {
return NULL;
+ }
/* firstly try adding strip to last track, but if that fails, add to a new track */
if (BKE_nlatrack_add_strip(adt->nla_tracks.last, strip) == 0) {
@@ -422,20 +442,23 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
// float repeat; // UNUSED
/* get number of repeats */
- if (IS_EQF(strip->repeat, 0.0f))
+ if (IS_EQF(strip->repeat, 0.0f)) {
strip->repeat = 1.0f;
+ }
// repeat = strip->repeat; // UNUSED
/* scaling */
- if (IS_EQF(strip->scale, 0.0f))
+ if (IS_EQF(strip->scale, 0.0f)) {
strip->scale = 1.0f;
+ }
scale = fabsf(
strip->scale); /* scale must be positive - we've got a special flag for reversing */
/* length of referenced action */
actlength = strip->actend - strip->actstart;
- if (IS_EQF(actlength, 0.0f))
+ if (IS_EQF(actlength, 0.0f)) {
actlength = 1.0f;
+ }
/* reversed = play strip backwards */
if (strip->flag & NLASTRIP_FLAG_REVERSE) {
@@ -448,10 +471,9 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
}
else { /* if (mode == NLATIME_CONVERT_EVAL) */
if (IS_EQF((float)cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
- /* this case prevents the motion snapping back to the first frame at the end of the strip
- * by catching the case where repeats is a whole number, which means that the end of the strip
- * could also be interpreted as the end of the start of a repeat
- */
+ /* This case prevents the motion snapping back to the first frame at the end of the strip
+ * by catching the case where repeats is a whole number, which means that the end of the
+ * strip could also be interpreted as the end of the start of a repeat. */
return strip->actstart;
}
else {
@@ -471,10 +493,9 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short
}
else { /* if (mode == NLATIME_CONVERT_EVAL) */
if (IS_EQF(cframe, strip->end) && IS_EQF(strip->repeat, floorf(strip->repeat))) {
- /* this case prevents the motion snapping back to the first frame at the end of the strip
- * by catching the case where repeats is a whole number, which means that the end of the strip
- * could also be interpreted as the end of the start of a repeat
- */
+ /* This case prevents the motion snapping back to the first frame at the end of the strip
+ * by catching the case where repeats is a whole number, which means that the end of the
+ * strip could also be interpreted as the end of the start of a repeat. */
return strip->actend;
}
else {
@@ -499,16 +520,20 @@ static float nlastrip_get_frame_transition(NlaStrip *strip, float cframe, short
/* reversed = play strip backwards */
if (strip->flag & NLASTRIP_FLAG_REVERSE) {
- if (mode == NLATIME_CONVERT_MAP)
+ if (mode == NLATIME_CONVERT_MAP) {
return strip->end - (length * cframe);
- else
+ }
+ else {
return (strip->end - cframe) / length;
+ }
}
else {
- if (mode == NLATIME_CONVERT_MAP)
+ if (mode == NLATIME_CONVERT_MAP) {
return (length * cframe) + strip->start;
- else
+ }
+ else {
return (cframe - strip->start) / length;
+ }
}
}
@@ -521,7 +546,8 @@ static float nlastrip_get_frame_transition(NlaStrip *strip, float cframe, short
float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode)
{
switch (strip->type) {
- case NLASTRIP_TYPE_META: /* meta - for now, does the same as transition (is really just an empty container) */
+ case NLASTRIP_TYPE_META: /* Meta - for now, does the same as transition
+ * (is really just an empty container). */
case NLASTRIP_TYPE_TRANSITION: /* transition */
return nlastrip_get_frame_transition(strip, cframe, mode);
@@ -546,30 +572,34 @@ float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
* - when not in tweakmode, the active Action does not have any scaling applied :)
* - when in tweakmode, if the no-mapping flag is set, do not map
*/
- if ((adt == NULL) || (adt->flag & ADT_NLA_EDIT_ON) == 0 || (adt->flag & ADT_NLA_EDIT_NOMAP))
+ if ((adt == NULL) || (adt->flag & ADT_NLA_EDIT_ON) == 0 || (adt->flag & ADT_NLA_EDIT_NOMAP)) {
return cframe;
+ }
/* if the active-strip info has been stored already, access this, otherwise look this up
* and store for (very probable) future usage
*/
if (adt->act_track == NULL) {
- if (adt->actstrip)
+ if (adt->actstrip) {
adt->act_track = BKE_nlatrack_find_tweaked(adt);
- else
+ }
+ else {
adt->act_track = BKE_nlatrack_find_active(&adt->nla_tracks);
+ }
}
if (adt->actstrip == NULL) {
adt->actstrip = BKE_nlastrip_find_active(adt->act_track);
}
strip = adt->actstrip;
- /* sanity checks
- * - in rare cases, we may not be able to find this strip for some reason (internal error)
- * - for now, if the user has defined a curve to control the time, this correction cannot be performed
- * reliably...
+ /* Sanity checks:
+ * - In rare cases, we may not be able to find this strip for some reason (internal error)
+ * - For now, if the user has defined a curve to control the time, this correction cannot be
+ * performed reliably.
*/
- if ((strip == NULL) || (strip->flag & NLASTRIP_FLAG_USR_TIME))
+ if ((strip == NULL) || (strip->flag & NLASTRIP_FLAG_USR_TIME)) {
return cframe;
+ }
/* perform the correction now... */
return nlastrip_get_frame(strip, cframe, mode);
@@ -587,8 +617,9 @@ bool BKE_nlastrips_has_space(ListBase *strips, float start, float end)
NlaStrip *strip;
/* sanity checks */
- if ((strips == NULL) || IS_EQF(start, end))
+ if ((strips == NULL) || IS_EQF(start, end)) {
return false;
+ }
if (start > end) {
puts("BKE_nlastrips_has_space() error... start and end arguments swapped");
SWAP(float, start, end);
@@ -599,14 +630,16 @@ bool BKE_nlastrips_has_space(ListBase *strips, float start, float end)
/* if start frame of strip is past the target end-frame, that means that
* we've gone past the window we need to check for, so things are fine
*/
- if (strip->start >= end)
+ if (strip->start >= end) {
return true;
+ }
/* if the end of the strip is greater than either of the boundaries, the range
* must fall within the extents of the strip
*/
- if ((strip->end > start) || (strip->end > end))
+ if ((strip->end > start) || (strip->end > end)) {
return false;
+ }
}
/* if we are still here, we haven't encountered any overlapping strips */
@@ -622,8 +655,9 @@ void BKE_nlastrips_sort_strips(ListBase *strips)
NlaStrip *strip, *sstrip, *stripn;
/* sanity checks */
- if (ELEM(NULL, strips, strips->first))
+ if (ELEM(NULL, strips, strips->first)) {
return;
+ }
/* we simply perform insertion sort on this list, since it is assumed that per track,
* there are only likely to be at most 5-10 strips
@@ -648,8 +682,9 @@ void BKE_nlastrips_sort_strips(ListBase *strips)
}
/* add before first? */
- if (not_added)
+ if (not_added) {
BLI_addhead(&tmp, strip);
+ }
}
/* reassign the start and end points of the strips */
@@ -666,12 +701,14 @@ bool BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip)
bool not_added = true;
/* sanity checks */
- if (ELEM(NULL, strips, strip))
+ if (ELEM(NULL, strips, strip)) {
return false;
+ }
/* check if any space to add */
- if (BKE_nlastrips_has_space(strips, strip->start, strip->end) == 0)
+ if (BKE_nlastrips_has_space(strips, strip->start, strip->end) == 0) {
return false;
+ }
/* find the right place to add the strip to the nominated track */
for (ns = strips->first; ns; ns = ns->next) {
@@ -703,8 +740,9 @@ void BKE_nlastrips_make_metas(ListBase *strips, bool is_temp)
NlaStrip *strip, *stripn;
/* sanity checks */
- if (ELEM(NULL, strips, strips->first))
+ if (ELEM(NULL, strips, strips->first)) {
return;
+ }
/* group all continuous chains of selected strips into meta-strips */
for (strip = strips->first; strip; strip = stripn) {
@@ -722,8 +760,9 @@ void BKE_nlastrips_make_metas(ListBase *strips, bool is_temp)
mstrip->flag = NLASTRIP_FLAG_SELECT;
/* set temp flag if appropriate (i.e. for transform-type editing) */
- if (is_temp)
+ if (is_temp) {
mstrip->flag |= NLASTRIP_FLAG_TEMP_META;
+ }
/* set default repeat/scale values to prevent warnings */
mstrip->repeat = mstrip->scale = 1.0f;
@@ -754,8 +793,9 @@ void BKE_nlastrips_clear_metastrip(ListBase *strips, NlaStrip *strip)
NlaStrip *cs, *csn;
/* sanity check */
- if (ELEM(NULL, strips, strip))
+ if (ELEM(NULL, strips, strip)) {
return;
+ }
/* move each one of the meta-strip's children before the meta-strip
* in the list of strips after unlinking them from the meta-strip
@@ -779,8 +819,9 @@ void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp)
NlaStrip *strip, *stripn;
/* sanity checks */
- if (ELEM(NULL, strips, strips->first))
+ if (ELEM(NULL, strips, strips->first)) {
return;
+ }
/* remove meta-strips fitting the criteria of the arguments */
for (strip = strips->first; strip; strip = stripn) {
@@ -804,12 +845,14 @@ void BKE_nlastrips_clear_metas(ListBase *strips, bool only_sel, bool only_temp)
bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
{
/* sanity checks */
- if (ELEM(NULL, mstrip, strip))
+ if (ELEM(NULL, mstrip, strip)) {
return false;
+ }
/* firstly, check if the meta-strip has space for this */
- if (BKE_nlastrips_has_space(&mstrip->strips, strip->start, strip->end) == 0)
+ if (BKE_nlastrips_has_space(&mstrip->strips, strip->start, strip->end) == 0) {
return false;
+ }
/* check if this would need to be added to the ends of the meta,
* and subsequently, if the neighboring strips allow us enough room
@@ -825,8 +868,9 @@ bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
return true;
}
- else /* failed... no room before */
+ else { /* failed... no room before */
return false;
+ }
}
else if (strip->end > mstrip->end) {
/* check if strip to the right (if it exists) starts before the
@@ -839,8 +883,9 @@ bool BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
return true;
}
- else /* failed... no room after */
+ else { /* failed... no room after */
return false;
+ }
}
else {
/* just try to add to the meta-strip (no dimension changes needed) */
@@ -862,10 +907,12 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
* - strip must exist
* - strip must be a meta-strip with some contents
*/
- if (ELEM(NULL, mstrip, mstrip->strips.first))
+ if (ELEM(NULL, mstrip, mstrip->strips.first)) {
return;
- if (mstrip->type != NLASTRIP_TYPE_META)
+ }
+ if (mstrip->type != NLASTRIP_TYPE_META) {
return;
+ }
/* get the original start/end points, and calculate the start-frame offset
* - these are simply the start/end frames of the child strips,
@@ -879,14 +926,16 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
* don't flush if nothing changed yet
* TODO: maybe we need a flag to say always flush?
*/
- if (IS_EQF(oStart, mstrip->start) && IS_EQF(oEnd, mstrip->end))
+ if (IS_EQF(oStart, mstrip->start) && IS_EQF(oEnd, mstrip->end)) {
return;
+ }
/* check if scale changed */
oLen = oEnd - oStart;
nLen = mstrip->end - mstrip->start;
- if (IS_EQF(nLen, oLen) == 0)
+ if (IS_EQF(nLen, oLen) == 0) {
scaleChanged = 1;
+ }
/* for each child-strip, calculate new start/end points based on this new info */
for (strip = mstrip->strips.first; strip; strip = strip->next) {
@@ -897,7 +946,8 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
p1 = (strip->start - oStart) / oLen;
p2 = (strip->end - oStart) / oLen;
- /* apply new strip endpoints using the proportions, then wait for second pass to flush scale properly */
+ /* Apply new strip endpoints using the proportions,
+ * then wait for second pass to flush scale properly. */
strip->start = (p1 * nLen) + mstrip->start;
strip->end = (p2 * nLen) + mstrip->start;
}
@@ -934,13 +984,15 @@ NlaTrack *BKE_nlatrack_find_active(ListBase *tracks)
NlaTrack *nlt;
/* sanity check */
- if (ELEM(NULL, tracks, tracks->first))
+ if (ELEM(NULL, tracks, tracks->first)) {
return NULL;
+ }
/* try to find the first active track */
for (nlt = tracks->first; nlt; nlt = nlt->next) {
- if (nlt->flag & NLATRACK_ACTIVE)
+ if (nlt->flag & NLATRACK_ACTIVE) {
return nlt;
+ }
}
/* none found */
@@ -957,8 +1009,9 @@ NlaTrack *BKE_nlatrack_find_tweaked(AnimData *adt)
NlaTrack *nlt;
/* sanity check */
- if (adt == NULL)
+ if (adt == NULL) {
return NULL;
+ }
/* Since the track itself gets disabled, we want the first disabled... */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
@@ -990,13 +1043,15 @@ void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt)
NlaTrack *nt;
/* sanity check */
- if (ELEM(NULL, adt, adt->nla_tracks.first))
+ if (ELEM(NULL, adt, adt->nla_tracks.first)) {
return;
+ }
/* firstly, make sure 'solo' flag for all tracks is disabled */
for (nt = adt->nla_tracks.first; nt; nt = nt->next) {
- if (nt != nlt)
+ if (nt != nlt) {
nt->flag &= ~NLATRACK_SOLO;
+ }
}
/* now, enable 'solo' for the given track if appropriate */
@@ -1005,13 +1060,16 @@ void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt)
nlt->flag ^= NLATRACK_SOLO;
/* set or clear solo-status on AnimData */
- if (nlt->flag & NLATRACK_SOLO)
+ if (nlt->flag & NLATRACK_SOLO) {
adt->flag |= ADT_NLA_SOLO_TRACK;
- else
+ }
+ else {
adt->flag &= ~ADT_NLA_SOLO_TRACK;
+ }
}
- else
+ else {
adt->flag &= ~ADT_NLA_SOLO_TRACK;
+ }
}
/* Make the given NLA-track the active one for the given stack. If no track is provided,
@@ -1022,16 +1080,19 @@ void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt_a)
NlaTrack *nlt;
/* sanity check */
- if (ELEM(NULL, tracks, tracks->first))
+ if (ELEM(NULL, tracks, tracks->first)) {
return;
+ }
/* deactivate all the rest */
- for (nlt = tracks->first; nlt; nlt = nlt->next)
+ for (nlt = tracks->first; nlt; nlt = nlt->next) {
nlt->flag &= ~NLATRACK_ACTIVE;
+ }
/* set the given one as the active one */
- if (nlt_a)
+ if (nlt_a) {
nlt_a->flag |= NLATRACK_ACTIVE;
+ }
}
/* Check if there is any space in the given track to add a strip of the given length */
@@ -1042,8 +1103,9 @@ bool BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end)
* - track must be editable
* - bounds cannot be equal (0-length is nasty)
*/
- if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQF(start, end))
+ if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQF(start, end)) {
return false;
+ }
if (start > end) {
puts("BKE_nlatrack_has_space() error... start and end arguments swapped");
@@ -1060,8 +1122,9 @@ bool BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end)
void BKE_nlatrack_sort_strips(NlaTrack *nlt)
{
/* sanity checks */
- if (ELEM(NULL, nlt, nlt->strips.first))
+ if (ELEM(NULL, nlt, nlt->strips.first)) {
return;
+ }
/* sort the strips with a more generic function */
BKE_nlastrips_sort_strips(&nlt->strips);
@@ -1073,12 +1136,14 @@ void BKE_nlatrack_sort_strips(NlaTrack *nlt)
bool BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip)
{
/* sanity checks */
- if (ELEM(NULL, nlt, strip))
+ if (ELEM(NULL, nlt, strip)) {
return false;
+ }
/* do not allow adding strips if this track is locked */
- if (nlt->flag & NLATRACK_PROTECTED)
+ if (nlt->flag & NLATRACK_PROTECTED) {
return false;
+ }
/* try to add the strip to the track using a more generic function */
return BKE_nlastrips_add_strip(&nlt->strips, strip);
@@ -1092,14 +1157,17 @@ bool BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2])
NlaStrip *strip;
/* initialize bounds */
- if (bounds)
+ if (bounds) {
bounds[0] = bounds[1] = 0.0f;
- else
+ }
+ else {
return false;
+ }
/* sanity checks */
- if (ELEM(NULL, nlt, nlt->strips.first))
+ if (ELEM(NULL, nlt, nlt->strips.first)) {
return false;
+ }
/* lower bound is first strip's start frame */
strip = nlt->strips.first;
@@ -1121,13 +1189,15 @@ NlaStrip *BKE_nlastrip_find_active(NlaTrack *nlt)
NlaStrip *strip;
/* sanity check */
- if (ELEM(NULL, nlt, nlt->strips.first))
+ if (ELEM(NULL, nlt, nlt->strips.first)) {
return NULL;
+ }
/* try to find the first active strip */
for (strip = nlt->strips.first; strip; strip = strip->next) {
- if (strip->flag & NLASTRIP_FLAG_ACTIVE)
+ if (strip->flag & NLASTRIP_FLAG_ACTIVE) {
return strip;
+ }
}
/* none found */
@@ -1141,16 +1211,19 @@ void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
NlaStrip *nls;
/* sanity checks */
- if (adt == NULL)
+ if (adt == NULL) {
return;
+ }
/* loop over tracks, deactivating*/
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (nls = nlt->strips.first; nls; nls = nls->next) {
- if (nls != strip)
+ if (nls != strip) {
nls->flag &= ~NLASTRIP_FLAG_ACTIVE;
- else
+ }
+ else {
nls->flag |= NLASTRIP_FLAG_ACTIVE;
+ }
}
}
}
@@ -1162,8 +1235,9 @@ bool BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max)
const float boundsLen = fabsf(max - min);
/* sanity checks */
- if ((strip == NULL) || IS_EQF(stripLen, 0.0f) || IS_EQF(boundsLen, 0.0f))
+ if ((strip == NULL) || IS_EQF(stripLen, 0.0f) || IS_EQF(boundsLen, 0.0f)) {
return false;
+ }
/* only ok if at least part of the strip is within the bounding window
* - first 2 cases cover when the strip length is less than the bounding area
@@ -1182,7 +1256,8 @@ bool BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max)
return true;
}
-/* Ensure that strip doesn't overlap those around it after resizing by offsetting those which follow */
+/* Ensure that strip doesn't overlap those around it after resizing
+ * by offsetting those which follow. */
static void nlastrip_fix_resize_overlaps(NlaStrip *strip)
{
/* next strips - do this first, since we're often just getting longer */
@@ -1294,19 +1369,22 @@ void BKE_nlastrip_recalculate_bounds(NlaStrip *strip)
* - must have a strip
* - can only be done for action clips
*/
- if ((strip == NULL) || (strip->type != NLASTRIP_TYPE_CLIP))
+ if ((strip == NULL) || (strip->type != NLASTRIP_TYPE_CLIP)) {
return;
+ }
/* calculate new length factors */
actlen = strip->actend - strip->actstart;
- if (IS_EQF(actlen, 0.0f))
+ if (IS_EQF(actlen, 0.0f)) {
actlen = 1.0f;
+ }
mapping = strip->scale * strip->repeat;
/* adjust endpoint of strip in response to this */
- if (IS_EQF(mapping, 0.0f) == 0)
+ if (IS_EQF(mapping, 0.0f) == 0) {
strip->end = (actlen * mapping) + strip->start;
+ }
/* make sure we don't overlap our neighbors */
nlastrip_fix_resize_overlaps(strip);
@@ -1320,12 +1398,14 @@ static bool nlastrip_is_first(AnimData *adt, NlaStrip *strip)
NlaStrip *ns;
/* sanity checks */
- if (ELEM(NULL, adt, strip))
+ if (ELEM(NULL, adt, strip)) {
return false;
+ }
/* check if strip has any strips before it */
- if (strip->prev)
+ if (strip->prev) {
return false;
+ }
/* check other tracks to see if they have a strip that's earlier */
/* TODO: or should we check that the strip's track is also the first? */
@@ -1333,8 +1413,9 @@ static bool nlastrip_is_first(AnimData *adt, NlaStrip *strip)
/* only check the first strip, assuming that they're all in order */
ns = nlt->strips.first;
if (ns) {
- if (ns->start < strip->start)
+ if (ns->start < strip->start) {
return false;
+ }
}
}
@@ -1350,13 +1431,15 @@ bool BKE_nlatrack_has_animated_strips(NlaTrack *nlt)
NlaStrip *strip;
/* sanity checks */
- if (ELEM(NULL, nlt, nlt->strips.first))
+ if (ELEM(NULL, nlt, nlt->strips.first)) {
return false;
+ }
/* check each strip for F-Curves only (don't care about whether the flags are set) */
for (strip = nlt->strips.first; strip; strip = strip->next) {
- if (strip->fcurves.first)
+ if (strip->fcurves.first) {
return true;
+ }
}
/* none found */
@@ -1369,13 +1452,15 @@ bool BKE_nlatracks_have_animated_strips(ListBase *tracks)
NlaTrack *nlt;
/* sanity checks */
- if (ELEM(NULL, tracks, tracks->first))
+ if (ELEM(NULL, tracks, tracks->first)) {
return false;
+ }
/* check each track, stopping on the first hit */
for (nlt = tracks->first; nlt; nlt = nlt->next) {
- if (BKE_nlatrack_has_animated_strips(nlt))
+ if (BKE_nlatrack_has_animated_strips(nlt)) {
return true;
+ }
}
/* none found */
@@ -1388,8 +1473,9 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
FCurve *fcu;
/* sanity checks */
- if (strip == NULL)
+ if (strip == NULL) {
return;
+ }
/* if controlling influence... */
if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) {
@@ -1447,8 +1533,9 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
bool BKE_nlastrip_has_curves_for_property(const PointerRNA *ptr, const PropertyRNA *prop)
{
/* sanity checks */
- if (ELEM(NULL, ptr, prop))
+ if (ELEM(NULL, ptr, prop)) {
return false;
+ }
/* 1) Must be NLA strip */
if (ptr->type == &RNA_NlaStrip) {
@@ -1494,8 +1581,9 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
NlaTrack *nlt;
/* sanity checks */
- if (ELEM(NULL, adt, strip))
+ if (ELEM(NULL, adt, strip)) {
return;
+ }
/* give strip a default name if none already */
if (strip->name[0] == 0) {
@@ -1526,16 +1614,19 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (tstrip = nlt->strips.first; tstrip; tstrip = tstrip->next) {
/* don't add the strip of interest */
- if (tstrip == strip)
+ if (tstrip == strip) {
continue;
+ }
- /* use the name of the strip as the key, and the strip as the value, since we're mostly interested in the keys */
+ /* Use the name of the strip as the key, and the strip as the value,
+ * since we're mostly interested in the keys. */
BLI_ghash_insert(gh, tstrip->name, tstrip);
}
}
- /* if the hash-table has a match for this name, try other names...
- * - in an extreme case, it might not be able to find a name, but then everything else in Blender would fail too :)
+ /* If the hash-table has a match for this name, try other names...
+ * - In an extreme case, it might not be able to find a name,
+ * but then everything else in Blender would fail too :).
*/
BLI_uniquename_cb(nla_editbone_name_check,
(void *)gh,
@@ -1567,7 +1658,8 @@ static void nlastrip_get_endpoint_overlaps(NlaStrip *strip,
*/
/* TODO: this scheme could get quite slow for doing this on many strips... */
for (nls = track->strips.first; nls; nls = nls->next) {
- /* check if strip overlaps (extends over or exactly on) the entire range of the strip we're validating */
+ /* Check if strip overlaps (extends over or exactly on)
+ * the entire range of the strip we're validating. */
if ((nls->start <= strip->start) && (nls->end >= strip->end)) {
*start = NULL;
*end = NULL;
@@ -1575,21 +1667,25 @@ static void nlastrip_get_endpoint_overlaps(NlaStrip *strip,
}
/* check if strip doesn't even occur anywhere near... */
- if (nls->end < strip->start)
+ if (nls->end < strip->start) {
continue; /* skip checking this strip... not worthy of mention */
- if (nls->start > strip->end)
+ }
+ if (nls->start > strip->end) {
return; /* the range we're after has already passed */
+ }
/* if this strip is not part of an island of continuous strips, it can be used
* - this check needs to be done for each end of the strip we try and use...
*/
if ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end) == 0) {
- if ((nls->end > strip->start) && (nls->end < strip->end))
+ if ((nls->end > strip->start) && (nls->end < strip->end)) {
*start = &nls->end;
+ }
}
if ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0) {
- if ((nls->start < strip->end) && (nls->start > strip->start))
+ if ((nls->start < strip->end) && (nls->start > strip->start)) {
*end = &nls->start;
+ }
}
}
}
@@ -1601,18 +1697,23 @@ static void BKE_nlastrip_validate_autoblends(NlaTrack *nlt, NlaStrip *nls)
float *ns = NULL, *ne = NULL;
/* sanity checks */
- if (ELEM(NULL, nls, nlt))
+ if (ELEM(NULL, nls, nlt)) {
return;
- if ((nlt->prev == NULL) && (nlt->next == NULL))
+ }
+ if ((nlt->prev == NULL) && (nlt->next == NULL)) {
return;
- if ((nls->flag & NLASTRIP_FLAG_AUTO_BLENDS) == 0)
+ }
+ if ((nls->flag & NLASTRIP_FLAG_AUTO_BLENDS) == 0) {
return;
+ }
/* get test ranges */
- if (nlt->prev)
+ if (nlt->prev) {
nlastrip_get_endpoint_overlaps(nls, nlt->prev, &ps, &pe);
- if (nlt->next)
+ }
+ if (nlt->next) {
nlastrip_get_endpoint_overlaps(nls, nlt->next, &ns, &ne);
+ }
/* set overlaps for this strip
* - don't use the values obtained though if the end in question
@@ -1621,23 +1722,29 @@ static void BKE_nlastrip_validate_autoblends(NlaTrack *nlt, NlaStrip *nls)
*/
if ((ps || ns) && ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0)) {
/* start overlaps - pick the largest overlap */
- if (((ps && ns) && (*ps > *ns)) || (ps))
+ if (((ps && ns) && (*ps > *ns)) || (ps)) {
nls->blendin = *ps - nls->start;
- else
+ }
+ else {
nls->blendin = *ns - nls->start;
+ }
}
- else /* no overlap allowed/needed */
+ else { /* no overlap allowed/needed */
nls->blendin = 0.0f;
+ }
if ((pe || ne) && ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end) == 0)) {
/* end overlaps - pick the largest overlap */
- if (((pe && ne) && (*pe > *ne)) || (pe))
+ if (((pe && ne) && (*pe > *ne)) || (pe)) {
nls->blendout = nls->end - *pe;
- else
+ }
+ else {
nls->blendout = nls->end - *ne;
+ }
}
- else /* no overlap allowed/needed */
+ else { /* no overlap allowed/needed */
nls->blendout = 0.0f;
+ }
}
/* Ensure that auto-blending and other settings are set correctly */
@@ -1647,18 +1754,21 @@ void BKE_nla_validate_state(AnimData *adt)
NlaTrack *nlt;
/* sanity checks */
- if (ELEM(NULL, adt, adt->nla_tracks.first))
+ if (ELEM(NULL, adt, adt->nla_tracks.first)) {
return;
+ }
- /* adjust blending values for auto-blending, and also do an initial pass to find the earliest strip */
+ /* Adjust blending values for auto-blending,
+ * and also do an initial pass to find the earliest strip. */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* auto-blending first */
BKE_nlastrip_validate_autoblends(nlt, strip);
/* extend mode - find first strip */
- if ((fstrip == NULL) || (strip->start < fstrip->start))
+ if ((fstrip == NULL) || (strip->start < fstrip->start)) {
fstrip = strip;
+ }
}
}
@@ -1678,10 +1788,12 @@ void BKE_nla_validate_state(AnimData *adt)
*
* Should fix problems such as [#29869]
*/
- if (strip == fstrip)
+ if (strip == fstrip) {
strip->extendmode = NLASTRIP_EXTEND_HOLD;
- else if (strip->blendmode == NLASTRIP_MODE_REPLACE)
+ }
+ else if (strip->blendmode == NLASTRIP_MODE_REPLACE) {
strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD;
+ }
}
}
}
@@ -1706,8 +1818,9 @@ bool BKE_nla_action_is_stashed(AnimData *adt, bAction *act)
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
if (strstr(nlt->name, STASH_TRACK_NAME)) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
- if (strip->act == act)
+ if (strip->act == act) {
return true;
+ }
}
}
}
@@ -1731,8 +1844,9 @@ bool BKE_nla_action_stash(AnimData *adt)
}
/* do not add if it is already stashed */
- if (BKE_nla_action_is_stashed(adt, adt->action))
+ if (BKE_nla_action_is_stashed(adt, adt->action)) {
return false;
+ }
/* create a new track, and add this immediately above the previous stashing track */
for (prev_track = adt->nla_tracks.last; prev_track; prev_track = prev_track->prev) {
@@ -1744,7 +1858,8 @@ bool BKE_nla_action_stash(AnimData *adt)
nlt = BKE_nlatrack_add(adt, prev_track);
BLI_assert(nlt != NULL);
- /* we need to ensure that if there wasn't any previous instance, it must go to tbe bottom of the stack */
+ /* We need to ensure that if there wasn't any previous instance,
+ * it must go to tbe bottom of the stack. */
if (prev_track == NULL) {
BLI_remlink(&adt->nla_tracks, nlt);
BLI_addhead(&adt->nla_tracks, nlt);
@@ -1797,8 +1912,9 @@ void BKE_nla_action_pushdown(AnimData *adt)
/* sanity checks */
/* TODO: need to report the error for this */
- if (ELEM(NULL, adt, adt->action))
+ if (ELEM(NULL, adt, adt->action)) {
return;
+ }
/* if the action is empty, we also shouldn't try to add to stack,
* as that will cause us grief down the track
@@ -1849,12 +1965,13 @@ void BKE_nla_action_pushdown(AnimData *adt)
* mode accordingly
*/
if (nlastrip_is_first(adt, strip) == 0) {
- /* not first, so extend mode can only be NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD,
- * so that it doesn't override strips in previous tracks
- */
+ /* Not first, so extend mode can only be:
+ * NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD,
+ * so that it doesn't override strips in previous tracks. */
/* FIXME: this needs to be more automated, since user can rearrange strips */
- if (strip->extendmode == NLASTRIP_EXTEND_HOLD)
+ if (strip->extendmode == NLASTRIP_EXTEND_HOLD) {
strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD;
+ }
}
/* make strip the active one... */
@@ -1871,14 +1988,16 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
NlaStrip *strip, *activeStrip = NULL;
/* verify that data is valid */
- if (ELEM(NULL, adt, adt->nla_tracks.first))
+ if (ELEM(NULL, adt, adt->nla_tracks.first)) {
return false;
+ }
/* if block is already in tweakmode, just leave, but we should report
* that this block is in tweakmode (as our returncode)
*/
- if (adt->flag & ADT_NLA_EDIT_ON)
+ if (adt->flag & ADT_NLA_EDIT_ON) {
return true;
+ }
/* go over the tracks, finding the active one, and its active strip
* - if we cannot find both, then there's nothing to do
@@ -1895,9 +2014,10 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
}
}
- /* There are situations where we may have multiple strips selected and we want to enter tweakmode on all
- * of those at once. Usually in those cases, it will usually just be a single strip per AnimData.
- * In such cases, compromise and take the last selected track and/or last selected strip [#28468]
+ /* There are situations where we may have multiple strips selected and we want to enter tweakmode
+ * on all of those at once. Usually in those cases,
+ * it will usually just be a single strip per AnimData.
+ * In such cases, compromise and take the last selected track and/or last selected strip, T28468.
*/
if (activeTrack == NULL) {
/* try last selected track for active strip */
@@ -1913,7 +2033,8 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
}
}
if ((activeTrack) && (activeStrip == NULL)) {
- /* no active strip in active or last selected track; compromise for first selected (assuming only single)... */
+ /* No active strip in active or last selected track;
+ * compromise for first selected (assuming only single). */
for (strip = activeTrack->strips.first; strip; strip = strip->next) {
if (strip->flag & (NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE)) {
activeStrip = strip;
@@ -1935,32 +2056,39 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
*/
for (nlt = activeTrack->prev; nlt; nlt = nlt->prev) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
- if (strip->act == activeStrip->act)
+ if (strip->act == activeStrip->act) {
strip->flag |= NLASTRIP_FLAG_TWEAKUSER;
- else
+ }
+ else {
strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER;
+ }
}
}
/* tag all other strips in active track that uses the same action as the active strip */
for (strip = activeTrack->strips.first; strip; strip = strip->next) {
- if ((strip->act == activeStrip->act) && (strip != activeStrip))
+ if ((strip->act == activeStrip->act) && (strip != activeStrip)) {
strip->flag |= NLASTRIP_FLAG_TWEAKUSER;
- else
+ }
+ else {
strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER;
+ }
}
/* go over all the tracks after AND INCLUDING the active one, tagging them as being disabled
* - the active track needs to also be tagged, otherwise, it'll overlap with the tweaks going on
*/
- for (nlt = activeTrack; nlt; nlt = nlt->next)
+ for (nlt = activeTrack; nlt; nlt = nlt->next) {
nlt->flag |= NLATRACK_DISABLED;
+ }
/* handle AnimData level changes:
- * - 'real' active action to temp storage (no need to change user-counts)
- * - action of active strip set to be the 'active action', and have its usercount incremented
- * - editing-flag for this AnimData block should also get turned on (for more efficient restoring)
- * - take note of the active strip for mapping-correction of keyframes in the action being edited
+ * - 'real' active action to temp storage (no need to change user-counts).
+ * - Action of active strip set to be the 'active action', and have its usercount incremented.
+ * - Editing-flag for this AnimData block should also get turned on
+ * (for more efficient restoring).
+ * - Take note of the active strip for mapping-correction of keyframes
+ * in the action being edited.
*/
adt->tmpact = adt->action;
adt->action = activeStrip->act;
@@ -1980,12 +2108,14 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
NlaTrack *nlt;
/* verify that data is valid */
- if (ELEM(NULL, adt, adt->nla_tracks.first))
+ if (ELEM(NULL, adt, adt->nla_tracks.first)) {
return;
+ }
/* hopefully the flag is correct - skip if not on */
- if ((adt->flag & ADT_NLA_EDIT_ON) == 0)
+ if ((adt->flag & ADT_NLA_EDIT_ON) == 0) {
return;
+ }
/* sync the length of the user-strip with the new state of the action
* but only if the user has explicitly asked for this to happen
@@ -2033,8 +2163,9 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
* - editing-flag for this AnimData block should also get turned off
* - clear pointer to active strip
*/
- if (adt->action)
+ if (adt->action) {
id_us_min(&adt->action->id);
+ }
adt->action = adt->tmpact;
adt->tmpact = NULL;
adt->act_track = NULL;
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index ee6faeaee3d..3adb6cfe960 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -109,12 +109,14 @@ static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType
static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
{
bNodeType *ntype = node->typeinfo;
- if (ntype == &NodeTypeUndefined)
+ if (ntype == &NodeTypeUndefined) {
return;
+ }
/* only do this once */
- if (node->flag & NODE_INIT)
+ if (node->flag & NODE_INIT) {
return;
+ }
node->flag = NODE_SELECT | NODE_OPTIONS | ntype->flag;
node->width = ntype->width;
@@ -124,8 +126,9 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
/* initialize the node name with the node label.
* note: do this after the initfunc so nodes get their data set which may be used in naming
* (node groups for example) */
- /* XXX Do not use nodeLabel() here, it returns translated content for UI, which should *only* be used
- * in UI, *never* in data... Data have their own translation option!
+ /* XXX Do not use nodeLabel() here, it returns translated content for UI,
+ * which should *only* be used in UI, *never* in data...
+ * Data have their own translation option!
* This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler
* than adding "do_translate" flags to this func (and labelfunc() as well). */
BLI_strncpy(node->name, DATA_(ntype->ui_name), NODE_MAXSTR);
@@ -133,14 +136,17 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
node_add_sockets_from_type(ntree, node, ntype);
- if (ntype->initfunc != NULL)
+ if (ntype->initfunc != NULL) {
ntype->initfunc(ntree, node);
+ }
- if (ntree->typeinfo->node_add_init != NULL)
+ if (ntree->typeinfo->node_add_init != NULL) {
ntree->typeinfo->node_add_init(ntree, node);
+ }
- if (node->id)
+ if (node->id) {
id_us_plus(node->id);
+ }
/* extra init callback */
if (ntype->initfunc_api) {
@@ -179,8 +185,9 @@ static void node_set_typeinfo(const struct bContext *C,
{
/* for nodes saved in older versions storage can get lost, make undefined then */
if (node->flag & NODE_INIT) {
- if (typeinfo && typeinfo->storagename[0] && !node->storage)
+ if (typeinfo && typeinfo->storagename[0] && !node->storage) {
typeinfo = NULL;
+ }
}
if (typeinfo) {
@@ -229,8 +236,9 @@ static void update_typeinfo(Main *bmain,
bNodeSocketType *socktype,
bool unregister)
{
- if (!bmain)
+ if (!bmain) {
return;
+ }
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
bNode *node;
@@ -238,36 +246,47 @@ static void update_typeinfo(Main *bmain,
ntree->init |= NTREE_TYPE_INIT;
- if (treetype && STREQ(ntree->idname, treetype->idname))
+ if (treetype && STREQ(ntree->idname, treetype->idname)) {
ntree_set_typeinfo(ntree, unregister ? NULL : treetype);
+ }
/* initialize nodes */
for (node = ntree->nodes.first; node; node = node->next) {
- if (nodetype && STREQ(node->idname, nodetype->idname))
+ if (nodetype && STREQ(node->idname, nodetype->idname)) {
node_set_typeinfo(C, ntree, node, unregister ? NULL : nodetype);
+ }
/* initialize node sockets */
- for (sock = node->inputs.first; sock; sock = sock->next)
- if (socktype && STREQ(sock->idname, socktype->idname))
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (socktype && STREQ(sock->idname, socktype->idname)) {
node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
- for (sock = node->outputs.first; sock; sock = sock->next)
- if (socktype && STREQ(sock->idname, socktype->idname))
+ }
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ if (socktype && STREQ(sock->idname, socktype->idname)) {
node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
+ }
+ }
}
/* initialize tree sockets */
- for (sock = ntree->inputs.first; sock; sock = sock->next)
- if (socktype && STREQ(sock->idname, socktype->idname))
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
+ if (socktype && STREQ(sock->idname, socktype->idname)) {
node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
- for (sock = ntree->outputs.first; sock; sock = sock->next)
- if (socktype && STREQ(sock->idname, socktype->idname))
+ }
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
+ if (socktype && STREQ(sock->idname, socktype->idname)) {
node_socket_set_typeinfo(ntree, sock, unregister ? NULL : socktype);
+ }
+ }
}
FOREACH_NODETREE_END;
}
/* Try to initialize all typeinfo in a node tree.
- * NB: In general undefined typeinfo is a perfectly valid case, the type may just be registered later.
+ * NB: In general undefined typeinfo is a perfectly valid case,
+ * the type may just be registered later.
* In that case the update_typeinfo function will set typeinfo on registration
* and do necessary updates.
*/
@@ -283,16 +302,20 @@ void ntreeSetTypes(const struct bContext *C, bNodeTree *ntree)
for (node = ntree->nodes.first; node; node = node->next) {
node_set_typeinfo(C, ntree, node, nodeTypeFind(node->idname));
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(sock->idname));
- for (sock = node->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(sock->idname));
+ }
}
- for (sock = ntree->inputs.first; sock; sock = sock->next)
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(sock->idname));
- for (sock = ntree->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(sock->idname));
+ }
}
static GHash *nodetreetypes_hash = NULL;
@@ -306,8 +329,9 @@ bNodeTreeType *ntreeTypeFind(const char *idname)
if (idname[0]) {
nt = BLI_ghash_lookup(nodetreetypes_hash, idname);
- if (nt)
+ if (nt) {
return nt;
+ }
}
return NULL;
@@ -317,8 +341,8 @@ void ntreeTypeAdd(bNodeTreeType *nt)
{
BLI_ghash_insert(nodetreetypes_hash, nt->idname, nt);
/* XXX pass Main to register function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, nt, NULL, NULL, false);
}
@@ -327,8 +351,8 @@ static void ntree_free_type(void *treetype_v)
{
bNodeTreeType *treetype = treetype_v;
/* XXX pass Main to unregister function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, treetype, NULL, NULL, true);
MEM_freeN(treetype);
}
@@ -354,8 +378,9 @@ bNodeType *nodeTypeFind(const char *idname)
if (idname[0]) {
nt = BLI_ghash_lookup(nodetypes_hash, idname);
- if (nt)
+ if (nt) {
return nt;
+ }
}
return NULL;
@@ -378,16 +403,18 @@ static void node_free_type(void *nodetype_v)
{
bNodeType *nodetype = nodetype_v;
/* XXX pass Main to unregister function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, NULL, nodetype, NULL, true);
/* XXX deprecated */
- if (nodetype->type == NODE_DYNAMIC)
+ if (nodetype->type == NODE_DYNAMIC) {
free_dynamic_typeinfo(nodetype);
+ }
- if (nodetype->needs_free)
+ if (nodetype->needs_free) {
MEM_freeN(nodetype);
+ }
}
void nodeRegisterType(bNodeType *nt)
@@ -398,8 +425,8 @@ void nodeRegisterType(bNodeType *nt)
BLI_ghash_insert(nodetypes_hash, nt->idname, nt);
/* XXX pass Main to register function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, NULL, nt, NULL, false);
}
@@ -424,8 +451,9 @@ bNodeSocketType *nodeSocketTypeFind(const char *idname)
if (idname[0]) {
st = BLI_ghash_lookup(nodesockettypes_hash, idname);
- if (st)
+ if (st) {
return st;
+ }
}
return NULL;
@@ -436,8 +464,8 @@ static void node_free_socket_type(void *socktype_v)
{
bNodeSocketType *socktype = socktype_v;
/* XXX pass Main to unregister function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, NULL, NULL, socktype, true);
MEM_freeN(socktype);
@@ -447,8 +475,8 @@ void nodeRegisterSocketType(bNodeSocketType *st)
{
BLI_ghash_insert(nodesockettypes_hash, (void *)st->idname, st);
/* XXX pass Main to register function? */
- /* Probably not. It is pretty much expected we want to update G_MAIN her I think - or we'd want to update *all*
- * active Mains, which we cannot do anyway currently. */
+ /* Probably not. It is pretty much expected we want to update G_MAIN here I think -
+ * or we'd want to update *all* active Mains, which we cannot do anyway currently. */
update_typeinfo(G_MAIN, NULL, NULL, NULL, st, false);
}
@@ -471,8 +499,9 @@ struct bNodeSocket *nodeFindSocket(bNode *node, int in_out, const char *identifi
{
bNodeSocket *sock = (in_out == SOCK_IN ? node->inputs.first : node->outputs.first);
for (; sock; sock = sock->next) {
- if (STREQ(sock->identifier, identifier))
+ if (STREQ(sock->identifier, identifier)) {
return sock;
+ }
}
return NULL;
}
@@ -483,8 +512,9 @@ static bool unique_identifier_check(void *arg, const char *identifier)
struct ListBase *lb = arg;
bNodeSocket *sock;
for (sock = lb->first; sock; sock = sock->next) {
- if (STREQ(sock->identifier, identifier))
+ if (STREQ(sock->identifier, identifier)) {
return true;
+ }
}
return false;
}
@@ -761,8 +791,9 @@ static void node_socket_free(bNodeTree *UNUSED(ntree),
MEM_freeN(sock->prop);
}
- if (sock->default_value)
+ if (sock->default_value) {
MEM_freeN(sock->default_value);
+ }
}
void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock)
@@ -832,17 +863,20 @@ int nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockin
for (node = ntree->nodes.first; node; node = node->next) {
tsock = (in_out == SOCK_IN ? node->inputs.first : node->outputs.first);
for (index = 0; tsock; tsock = tsock->next, index++) {
- if (tsock == sock)
+ if (tsock == sock) {
break;
+ }
}
- if (tsock)
+ if (tsock) {
break;
+ }
}
if (node) {
*nodep = node;
- if (sockindex)
+ if (sockindex) {
*sockindex = index;
+ }
return 1;
}
@@ -899,7 +933,8 @@ void nodeChainIter(const bNodeTree *ntree,
continue;
}
if (link->tonode && link->fromnode) {
- /* is the link part of the chain meaning node_start == fromnode (or tonode for reversed case)? */
+ /* Is the link part of the chain meaning node_start == fromnode
+ * (or tonode for reversed case)? */
if ((reversed && (link->tonode == node_start)) ||
(!reversed && link->fromnode == node_start)) {
if (!callback(link->fromnode, link->tonode, userdata, reversed)) {
@@ -913,7 +948,8 @@ void nodeChainIter(const bNodeTree *ntree,
}
/**
- * Iterate over all parents of \a node, executing \a callback for each parent (which can return false to end iterator)
+ * Iterate over all parents of \a node, executing \a callback for each parent
+ * (which can return false to end iterator)
*
* \note Recursive
*/
@@ -1071,8 +1107,9 @@ bNodeLink *nodeAddLink(
if (fromsock->in_out == SOCK_OUT && tosock->in_out == SOCK_IN) {
link = MEM_callocN(sizeof(bNodeLink), "link");
- if (ntree)
+ if (ntree) {
BLI_addtail(&ntree->links, link);
+ }
link->fromnode = fromnode;
link->fromsock = fromsock;
link->tonode = tonode;
@@ -1081,16 +1118,18 @@ bNodeLink *nodeAddLink(
else if (fromsock->in_out == SOCK_IN && tosock->in_out == SOCK_OUT) {
/* OK but flip */
link = MEM_callocN(sizeof(bNodeLink), "link");
- if (ntree)
+ if (ntree) {
BLI_addtail(&ntree->links, link);
+ }
link->fromnode = tonode;
link->fromsock = tosock;
link->tonode = fromnode;
link->tosock = fromsock;
}
- if (ntree)
+ if (ntree) {
ntree->update |= NTREE_UPDATE_LINKS;
+ }
return link;
}
@@ -1098,15 +1137,18 @@ bNodeLink *nodeAddLink(
void nodeRemLink(bNodeTree *ntree, bNodeLink *link)
{
/* can be called for links outside a node tree (e.g. clipboard) */
- if (ntree)
+ if (ntree) {
BLI_remlink(&ntree->links, link);
+ }
- if (link->tosock)
+ if (link->tosock) {
link->tosock->link = NULL;
+ }
MEM_freeN(link);
- if (ntree)
+ if (ntree) {
ntree->update |= NTREE_UPDATE_LINKS;
+ }
}
void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock)
@@ -1133,8 +1175,9 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node)
bNodeLink *link, *link_next;
/* store link pointers in output sockets, for efficient lookup */
- for (link = node->internal_links.first; link; link = link->next)
+ for (link = node->internal_links.first; link; link = link->next) {
link->tosock->link = link;
+ }
/* redirect downstream links */
for (link = ntree->links.first; link; link = link_next) {
@@ -1153,16 +1196,19 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node)
/* if the up- or downstream link is invalid,
* the replacement link will be invalid too.
*/
- if (!(fromlink->flag & NODE_LINK_VALID))
+ if (!(fromlink->flag & NODE_LINK_VALID)) {
link->flag &= ~NODE_LINK_VALID;
+ }
ntree->update |= NTREE_UPDATE_LINKS;
}
- else
+ else {
nodeRemLink(ntree, link);
+ }
}
- else
+ else {
nodeRemLink(ntree, link);
+ }
}
}
@@ -1170,8 +1216,9 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node)
for (link = ntree->links.first; link; link = link_next) {
link_next = link->next;
- if (link->tonode == node)
+ if (link->tonode == node) {
nodeRemLink(ntree, link);
+ }
}
}
@@ -1327,8 +1374,10 @@ bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
}
/**
- * Only copy internal data of NodeTree ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of NodeTree ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -1389,8 +1438,7 @@ void BKE_node_tree_copy_data(Main *UNUSED(bmain),
ntree_dst->previews = BKE_node_instance_hash_new("node previews");
- NODE_INSTANCE_HASH_ITER(iter, ntree_src->previews)
- {
+ NODE_INSTANCE_HASH_ITER (iter, ntree_src->previews) {
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
BKE_node_instance_hash_insert(ntree_dst->previews, key, BKE_node_preview_copy(preview));
@@ -1463,13 +1511,15 @@ bNodePreview *BKE_node_preview_verify(
preview = MEM_callocN(sizeof(bNodePreview), "node preview");
BKE_node_instance_hash_insert(previews, key, preview);
}
- else
+ else {
return NULL;
+ }
}
/* node previews can get added with variable size this way */
- if (xsize == 0 || ysize == 0)
+ if (xsize == 0 || ysize == 0) {
return preview;
+ }
/* sanity checks & initialize */
if (preview->rect) {
@@ -1492,15 +1542,17 @@ bNodePreview *BKE_node_preview_verify(
bNodePreview *BKE_node_preview_copy(bNodePreview *preview)
{
bNodePreview *new_preview = MEM_dupallocN(preview);
- if (preview->rect)
+ if (preview->rect) {
new_preview->rect = MEM_dupallocN(preview->rect);
+ }
return new_preview;
}
void BKE_node_preview_free(bNodePreview *preview)
{
- if (preview->rect)
+ if (preview->rect) {
MEM_freeN(preview->rect);
+ }
MEM_freeN(preview);
}
@@ -1522,18 +1574,21 @@ static void node_preview_init_tree_recursive(bNodeInstanceHash *previews,
BKE_node_preview_verify(previews, key, xsize, ysize, create);
}
- if (node->type == NODE_GROUP && node->id)
+ if (node->type == NODE_GROUP && node->id) {
node_preview_init_tree_recursive(previews, (bNodeTree *)node->id, key, xsize, ysize, create);
+ }
}
}
void BKE_node_preview_init_tree(bNodeTree *ntree, int xsize, int ysize, int create_previews)
{
- if (!ntree)
+ if (!ntree) {
return;
+ }
- if (!ntree->previews)
+ if (!ntree->previews) {
ntree->previews = BKE_node_instance_hash_new("node previews");
+ }
node_preview_init_tree_recursive(
ntree->previews, ntree, NODE_INSTANCE_KEY_BASE, xsize, ysize, create_previews);
@@ -1547,18 +1602,21 @@ static void node_preview_tag_used_recursive(bNodeInstanceHash *previews,
for (node = ntree->nodes.first; node; node = node->next) {
bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node);
- if (BKE_node_preview_used(node))
+ if (BKE_node_preview_used(node)) {
BKE_node_instance_hash_tag_key(previews, key);
+ }
- if (node->type == NODE_GROUP && node->id)
+ if (node->type == NODE_GROUP && node->id) {
node_preview_tag_used_recursive(previews, (bNodeTree *)node->id, key);
+ }
}
}
void BKE_node_preview_remove_unused(bNodeTree *ntree)
{
- if (!ntree || !ntree->previews)
+ if (!ntree || !ntree->previews) {
return;
+ }
/* use the instance hash functions for tagging and removing unused previews */
BKE_node_instance_hash_clear_tags(ntree->previews);
@@ -1570,8 +1628,9 @@ void BKE_node_preview_remove_unused(bNodeTree *ntree)
void BKE_node_preview_free_tree(bNodeTree *ntree)
{
- if (!ntree)
+ if (!ntree) {
return;
+ }
if (ntree->previews) {
BKE_node_instance_hash_free(ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free);
@@ -1581,19 +1640,20 @@ void BKE_node_preview_free_tree(bNodeTree *ntree)
void BKE_node_preview_clear(bNodePreview *preview)
{
- if (preview && preview->rect)
+ if (preview && preview->rect) {
memset(preview->rect, 0, MEM_allocN_len(preview->rect));
+ }
}
void BKE_node_preview_clear_tree(bNodeTree *ntree)
{
bNodeInstanceHashIterator iter;
- if (!ntree || !ntree->previews)
+ if (!ntree || !ntree->previews) {
return;
+ }
- NODE_INSTANCE_HASH_ITER(iter, ntree->previews)
- {
+ NODE_INSTANCE_HASH_ITER (iter, ntree->previews) {
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
BKE_node_preview_clear(preview);
}
@@ -1618,17 +1678,18 @@ void BKE_node_preview_sync_tree(bNodeTree *to_ntree, bNodeTree *from_ntree)
bNodeInstanceHash *to_previews = to_ntree->previews;
bNodeInstanceHashIterator iter;
- if (!from_previews || !to_previews)
+ if (!from_previews || !to_previews) {
return;
+ }
- NODE_INSTANCE_HASH_ITER(iter, from_previews)
- {
+ NODE_INSTANCE_HASH_ITER (iter, from_previews) {
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
bNodePreview *from = BKE_node_instance_hash_iterator_get_value(&iter);
bNodePreview *to = BKE_node_instance_hash_lookup(to_previews, key);
- if (from && to)
+ if (from && to) {
node_preview_sync(to, from);
+ }
}
}
@@ -1636,8 +1697,9 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo
{
if (remove_old || !to_ntree->previews) {
/* free old previews */
- if (to_ntree->previews)
+ if (to_ntree->previews) {
BKE_node_instance_hash_free(to_ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free);
+ }
/* transfer previews */
to_ntree->previews = from_ntree->previews;
@@ -1650,8 +1712,7 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo
bNodeInstanceHashIterator iter;
if (from_ntree->previews) {
- NODE_INSTANCE_HASH_ITER(iter, from_ntree->previews)
- {
+ NODE_INSTANCE_HASH_ITER (iter, from_ntree->previews) {
bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
@@ -1661,7 +1722,8 @@ void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, boo
BKE_node_instance_hash_insert(to_ntree->previews, key, preview);
}
- /* Note: NULL free function here, because pointers have already been moved over to to_ntree->previews! */
+ /* Note: NULL free function here,
+ * because pointers have already been moved over to to_ntree->previews! */
BKE_node_instance_hash_free(from_ntree->previews, NULL);
from_ntree->previews = NULL;
}
@@ -1686,9 +1748,9 @@ void BKE_node_preview_set_pixel(
rgba_float_to_uchar(tar, col);
}
}
- //else printf("prv out bound x y %d %d\n", x, y);
+ // else printf("prv out bound x y %d %d\n", x, y);
}
- //else printf("prv out bound x y %d %d\n", x, y);
+ // else printf("prv out bound x y %d %d\n", x, y);
}
}
@@ -1706,18 +1768,22 @@ void nodeUnlinkNode(bNodeTree *ntree, bNode *node)
if (link->fromnode == node) {
lb = &node->outputs;
- if (link->tonode)
+ if (link->tonode) {
link->tonode->update |= NODE_UPDATE;
+ }
}
- else if (link->tonode == node)
+ else if (link->tonode == node) {
lb = &node->inputs;
- else
+ }
+ else {
lb = NULL;
+ }
if (lb) {
for (sock = lb->first; sock; sock = sock->next) {
- if (link->fromsock == sock || link->tosock == sock)
+ if (link->fromsock == sock || link->tosock == sock) {
break;
+ }
}
if (sock) {
nodeRemLink(ntree, link);
@@ -1730,8 +1796,9 @@ static void node_unlink_attached(bNodeTree *ntree, bNode *parent)
{
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->parent == parent)
+ if (node->parent == parent) {
nodeDetachNode(node);
+ }
}
}
@@ -1751,8 +1818,9 @@ static void node_free_node(bNodeTree *ntree, bNode *node)
BLI_remlink(&ntree->nodes, node);
- if (ntree->typeinfo->free_node_cache)
+ if (ntree->typeinfo->free_node_cache) {
ntree->typeinfo->free_node_cache(ntree, node);
+ }
/* texture node has bad habit of keeping exec data around */
if (ntree->type == NTREE_TEXTURE && ntree->execdata) {
@@ -1788,8 +1856,9 @@ static void node_free_node(bNodeTree *ntree, bNode *node)
MEM_freeN(node);
- if (ntree)
+ if (ntree) {
ntree->update |= NTREE_UPDATE_NODES;
+ }
}
void ntreeFreeLocalNode(bNodeTree *ntree, bNode *node)
@@ -1844,8 +1913,9 @@ static void node_socket_interface_free(bNodeTree *UNUSED(ntree), bNodeSocket *so
MEM_freeN(sock->prop);
}
- if (sock->default_value)
+ if (sock->default_value) {
MEM_freeN(sock->default_value);
+ }
}
static void free_localized_node_groups(bNodeTree *ntree)
@@ -1857,8 +1927,9 @@ static void free_localized_node_groups(bNodeTree *ntree)
* since it is a localized copy itself (no risk of accessing free'd
* data in main, see [#37939]).
*/
- if (!(ntree->id.tag & LIB_TAG_LOCALIZED))
+ if (!(ntree->id.tag & LIB_TAG_LOCALIZED)) {
return;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
if ((ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) && node->id) {
@@ -1925,8 +1996,9 @@ void ntreeFreeTree(bNodeTree *ntree)
BKE_node_instance_hash_free(ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free);
}
- if (ntree->duplilock)
+ if (ntree->duplilock) {
BLI_mutex_free(ntree->duplilock);
+ }
if (ntree->id.tag & LIB_TAG_LOCALIZED) {
BKE_libblock_free_data(&ntree->id, true);
@@ -1952,11 +2024,13 @@ void ntreeFreeLocalTree(bNodeTree *ntree)
void ntreeFreeCache(bNodeTree *ntree)
{
- if (ntree == NULL)
+ if (ntree == NULL) {
return;
+ }
- if (ntree->typeinfo->free_cache)
+ if (ntree->typeinfo->free_cache) {
ntree->typeinfo->free_cache(ntree);
+ }
}
void ntreeSetOutput(bNodeTree *ntree)
@@ -1970,8 +2044,9 @@ void ntreeSetOutput(bNodeTree *ntree)
int output = 0;
/* we need a check for which output node should be tagged like this, below an exception */
- if (node->type == CMP_NODE_OUTPUT_FILE)
+ if (node->type == CMP_NODE_OUTPUT_FILE) {
continue;
+ }
/* there is more types having output class, each one is checked */
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
@@ -1985,8 +2060,9 @@ void ntreeSetOutput(bNodeTree *ntree)
ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))) {
if (tnode->flag & NODE_DO_OUTPUT) {
output++;
- if (output > 1)
+ if (output > 1) {
tnode->flag &= ~NODE_DO_OUTPUT;
+ }
}
}
}
@@ -1995,15 +2071,17 @@ void ntreeSetOutput(bNodeTree *ntree)
if (tnode->type == node->type) {
if (tnode->flag & NODE_DO_OUTPUT) {
output++;
- if (output > 1)
+ if (output > 1) {
tnode->flag &= ~NODE_DO_OUTPUT;
+ }
}
}
}
}
}
- if (output == 0)
+ if (output == 0) {
node->flag |= NODE_DO_OUTPUT;
+ }
}
/* group node outputs use this flag too */
@@ -2015,13 +2093,15 @@ void ntreeSetOutput(bNodeTree *ntree)
if (tnode->type == NODE_GROUP_OUTPUT) {
if (tnode->flag & NODE_DO_OUTPUT) {
output++;
- if (output > 1)
+ if (output > 1) {
tnode->flag &= ~NODE_DO_OUTPUT;
+ }
}
}
}
- if (output == 0)
+ if (output == 0) {
node->flag |= NODE_DO_OUTPUT;
+ }
}
}
@@ -2057,18 +2137,22 @@ void ntreeMakeLocal(Main *bmain, bNodeTree *ntree, bool id_in_mainlist, const bo
int ntreeNodeExists(bNodeTree *ntree, bNode *testnode)
{
bNode *node = ntree->nodes.first;
- for (; node; node = node->next)
- if (node == testnode)
+ for (; node; node = node->next) {
+ if (node == testnode) {
return 1;
+ }
+ }
return 0;
}
int ntreeOutputExists(bNode *node, bNodeSocket *testsock)
{
bNodeSocket *sock = node->outputs.first;
- for (; sock; sock = sock->next)
- if (sock == testsock)
+ for (; sock; sock = sock->next) {
+ if (sock == testsock) {
return 1;
+ }
+ }
return 0;
}
@@ -2123,15 +2207,17 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
node->new_node->original = node;
}
- if (ntree->typeinfo->localize)
+ if (ntree->typeinfo->localize) {
ntree->typeinfo->localize(ltree, ntree);
+ }
BLI_mutex_unlock(ntree->duplilock);
return ltree;
}
- else
+ else {
return NULL;
+ }
}
/* sync local composite with real tree */
@@ -2140,8 +2226,9 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree)
{
if (localtree && ntree) {
- if (ntree->typeinfo->local_sync)
+ if (ntree->typeinfo->local_sync) {
ntree->typeinfo->local_sync(localtree, ntree);
+ }
}
}
@@ -2150,8 +2237,9 @@ void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree)
void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree)
{
if (ntree && localtree) {
- if (ntree->typeinfo->local_merge)
+ if (ntree->typeinfo->local_merge) {
ntree->typeinfo->local_merge(bmain, localtree, ntree);
+ }
ntreeFreeTree(localtree);
MEM_freeN(localtree);
@@ -2182,29 +2270,12 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
/* assign new unique index */
own_index = ntree->cur_index++;
/* use the own_index as socket identifier */
- if (in_out == SOCK_IN)
+ if (in_out == SOCK_IN) {
BLI_snprintf(sock->identifier, MAX_NAME, "Input_%d", own_index);
- else
+ }
+ else {
BLI_snprintf(sock->identifier, MAX_NAME, "Output_%d", own_index);
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* XXX forward compatibility:
- * own_index is deprecated, but needs to be set here.
- * Node sockets generally use the identifier string instead now,
- * but reconstructing own_index in writefile.c would require parsing the identifier string.
- */
-
-# if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-# endif
-
- sock->own_index = own_index;
-
-# if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__)
-# pragma GCC diagnostic pop
-# endif
-
-#endif /* USE_NODE_COMPAT_CUSTOMNODES */
+ }
sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF);
@@ -2218,9 +2289,11 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree, int in_out, const char *identifier)
{
bNodeSocket *iosock = (in_out == SOCK_IN ? ntree->inputs.first : ntree->outputs.first);
- for (; iosock; iosock = iosock->next)
- if (STREQ(iosock->identifier, identifier))
+ for (; iosock; iosock = iosock->next) {
+ if (STREQ(iosock->identifier, identifier)) {
return iosock;
+ }
+ }
return NULL;
}
@@ -2269,8 +2342,9 @@ struct bNodeSocket *ntreeAddSocketInterfaceFromSocket(bNodeTree *ntree,
bNodeSocket *iosock = ntreeAddSocketInterface(
ntree, from_sock->in_out, from_sock->idname, from_sock->name);
if (iosock) {
- if (iosock->typeinfo->interface_from_socket)
+ if (iosock->typeinfo->interface_from_socket) {
iosock->typeinfo->interface_from_socket(ntree, iosock, from_node, from_sock);
+ }
}
return iosock;
}
@@ -2283,8 +2357,9 @@ struct bNodeSocket *ntreeInsertSocketInterfaceFromSocket(bNodeTree *ntree,
bNodeSocket *iosock = ntreeInsertSocketInterface(
ntree, from_sock->in_out, from_sock->idname, next_sock, from_sock->name);
if (iosock) {
- if (iosock->typeinfo->interface_from_socket)
+ if (iosock->typeinfo->interface_from_socket) {
iosock->typeinfo->interface_from_socket(ntree, iosock, from_node, from_sock);
+ }
}
return iosock;
}
@@ -2358,13 +2433,15 @@ static void ntree_interface_type_create(bNodeTree *ntree)
/* add socket properties */
for (sock = ntree->inputs.first; sock; sock = sock->next) {
bNodeSocketType *stype = sock->typeinfo;
- if (stype && stype->interface_register_properties)
+ if (stype && stype->interface_register_properties) {
stype->interface_register_properties(ntree, sock, srna);
+ }
}
for (sock = ntree->outputs.first; sock; sock = sock->next) {
bNodeSocketType *stype = sock->typeinfo;
- if (stype && stype->interface_register_properties)
+ if (stype && stype->interface_register_properties) {
stype->interface_register_properties(ntree, sock, srna);
+ }
}
}
@@ -2444,13 +2521,17 @@ bool ntreeHasTree(const bNodeTree *ntree, const bNodeTree *lookup)
{
bNode *node;
- if (ntree == lookup)
+ if (ntree == lookup) {
return true;
+ }
- for (node = ntree->nodes.first; node; node = node->next)
- if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id)
- if (ntreeHasTree((bNodeTree *)node->id, lookup))
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) {
+ if (ntreeHasTree((bNodeTree *)node->id, lookup)) {
return true;
+ }
+ }
+ }
return false;
}
@@ -2460,10 +2541,12 @@ bNodeLink *nodeFindLink(bNodeTree *ntree, bNodeSocket *from, bNodeSocket *to)
bNodeLink *link;
for (link = ntree->links.first; link; link = link->next) {
- if (link->fromsock == from && link->tosock == to)
+ if (link->fromsock == from && link->tosock == to) {
return link;
- if (link->fromsock == to && link->tosock == from) /* hrms? */
+ }
+ if (link->fromsock == to && link->tosock == from) { /* hrms? */
return link;
+ }
}
return NULL;
}
@@ -2474,8 +2557,9 @@ int nodeCountSocketLinks(bNodeTree *ntree, bNodeSocket *sock)
int tot = 0;
for (link = ntree->links.first; link; link = link->next) {
- if (link->fromsock == sock || link->tosock == sock)
+ if (link->fromsock == sock || link->tosock == sock) {
tot++;
+ }
}
return tot;
}
@@ -2484,12 +2568,15 @@ bNode *nodeGetActive(bNodeTree *ntree)
{
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return NULL;
+ }
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->flag & NODE_ACTIVE)
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->flag & NODE_ACTIVE) {
break;
+ }
+ }
return node;
}
@@ -2500,10 +2587,13 @@ static bNode *node_get_active_id_recursive(bNodeInstanceKey active_key,
{
if (parent_key.value == active_key.value || active_key.value == 0) {
bNode *node;
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->id && GS(node->id->name) == idtype)
- if (node->flag & NODE_ACTIVE_ID)
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->id && GS(node->id->name) == idtype) {
+ if (node->flag & NODE_ACTIVE_ID) {
return node;
+ }
+ }
+ }
}
else {
bNode *node, *tnode;
@@ -2514,8 +2604,9 @@ static bNode *node_get_active_id_recursive(bNodeInstanceKey active_key,
if (group) {
bNodeInstanceKey group_key = BKE_node_instance_key(parent_key, ntree, node);
tnode = node_get_active_id_recursive(active_key, group_key, group, idtype);
- if (tnode)
+ if (tnode) {
return tnode;
+ }
}
}
}
@@ -2527,11 +2618,13 @@ static bNode *node_get_active_id_recursive(bNodeInstanceKey active_key,
/* two active flags, ID nodes have special flag for buttons display */
bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
{
- if (ntree)
+ if (ntree) {
return node_get_active_id_recursive(
ntree->active_viewer_key, NODE_INSTANCE_KEY_BASE, ntree, idtype);
- else
+ }
+ else {
return NULL;
+ }
}
bool nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
@@ -2539,8 +2632,9 @@ bool nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
bNode *node;
bool ok = false;
- if (ntree == NULL)
+ if (ntree == NULL) {
return ok;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
if (node->id && GS(node->id->name) == idtype) {
@@ -2559,8 +2653,9 @@ bool nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
* just pass NULL so other matching nodes are deactivated.
*/
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == NODE_GROUP)
+ if (node->type == NODE_GROUP) {
ok |= nodeSetActiveID((bNodeTree *)node->id, idtype, (ok == false ? id : NULL));
+ }
}
return ok;
@@ -2571,12 +2666,15 @@ void nodeClearActiveID(bNodeTree *ntree, short idtype)
{
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return;
+ }
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->id && GS(node->id->name) == idtype)
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->id && GS(node->id->name) == idtype) {
node->flag &= ~NODE_ACTIVE_ID;
+ }
+ }
}
void nodeSetSelected(bNode *node, bool select)
@@ -2590,10 +2688,12 @@ void nodeSetSelected(bNode *node, bool select)
node->flag &= ~NODE_SELECT;
/* deselect sockets too */
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
sock->flag &= ~NODE_SELECT;
- for (sock = node->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
sock->flag &= ~NODE_SELECT;
+ }
}
}
@@ -2601,11 +2701,13 @@ void nodeClearActive(bNodeTree *ntree)
{
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return;
+ }
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
node->flag &= ~(NODE_ACTIVE | NODE_ACTIVE_ID);
+ }
}
/* two active flags, ID nodes have special flag for buttons display */
@@ -2618,18 +2720,22 @@ void nodeSetActive(bNodeTree *ntree, bNode *node)
tnode->flag &= ~NODE_ACTIVE;
if (node->id && tnode->id) {
- if (GS(node->id->name) == GS(tnode->id->name))
+ if (GS(node->id->name) == GS(tnode->id->name)) {
tnode->flag &= ~NODE_ACTIVE_ID;
+ }
}
- if (node->typeinfo->nclass == NODE_CLASS_TEXTURE)
+ if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) {
tnode->flag &= ~NODE_ACTIVE_TEXTURE;
+ }
}
node->flag |= NODE_ACTIVE;
- if (node->id)
+ if (node->id) {
node->flag |= NODE_ACTIVE_ID;
- if (node->typeinfo->nclass == NODE_CLASS_TEXTURE)
+ }
+ if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) {
node->flag |= NODE_ACTIVE_TEXTURE;
+ }
}
int nodeSocketIsHidden(bNodeSocket *sock)
@@ -2809,8 +2915,9 @@ static bNodeInstanceKey node_hash_int_str(bNodeInstanceKey hash, const char *str
{
char c;
- while ((c = *str++))
+ while ((c = *str++)) {
hash.value = ((hash.value << 5) + hash.value) ^ c; /* (hash * 33) ^ c */
+ }
/* separator '\0' character, to avoid ambiguity from concatenated strings */
hash.value = (hash.value << 5) + hash.value; /* hash * 33 */
@@ -2824,8 +2931,9 @@ bNodeInstanceKey BKE_node_instance_key(bNodeInstanceKey parent_key, bNodeTree *n
key = node_hash_int_str(parent_key, ntree->id.name + 2);
- if (node)
+ if (node) {
key = node_hash_int_str(key, node->name);
+ }
return key;
}
@@ -2901,8 +3009,7 @@ void BKE_node_instance_hash_clear_tags(bNodeInstanceHash *hash)
{
bNodeInstanceHashIterator iter;
- NODE_INSTANCE_HASH_ITER(iter, hash)
- {
+ NODE_INSTANCE_HASH_ITER (iter, hash) {
bNodeInstanceHashEntry *value = BKE_node_instance_hash_iterator_get_value(&iter);
value->tag = 0;
@@ -2923,8 +3030,9 @@ bool BKE_node_instance_hash_tag_key(bNodeInstanceHash *hash, bNodeInstanceKey ke
entry->tag = 1;
return true;
}
- else
+ else {
return false;
+ }
}
void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash,
@@ -2940,12 +3048,12 @@ void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash,
int num_untagged, i;
num_untagged = 0;
- NODE_INSTANCE_HASH_ITER(iter, hash)
- {
+ NODE_INSTANCE_HASH_ITER (iter, hash) {
bNodeInstanceHashEntry *value = BKE_node_instance_hash_iterator_get_value(&iter);
- if (!value->tag)
+ if (!value->tag) {
untagged[num_untagged++] = BKE_node_instance_hash_iterator_get_key(&iter);
+ }
}
for (i = 0; i < num_untagged; ++i) {
@@ -2970,19 +3078,23 @@ static int node_get_deplist_recurs(bNodeTree *ntree, bNode *node, bNode ***nsort
for (link = ntree->links.first; link; link = link->next) {
if (link->tonode == node) {
fromnode = link->fromnode;
- if (fromnode->done == 0)
+ if (fromnode->done == 0) {
fromnode->level = node_get_deplist_recurs(ntree, fromnode, nsort);
- if (fromnode->level <= level)
+ }
+ if (fromnode->level <= level) {
level = fromnode->level - 1;
+ }
}
}
/* check parent node */
if (node->parent) {
- if (node->parent->done == 0)
+ if (node->parent->done == 0) {
node->parent->level = node_get_deplist_recurs(ntree, node->parent, nsort);
- if (node->parent->level <= level)
+ }
+ if (node->parent->level <= level) {
level = node->parent->level - 1;
+ }
}
if (nsort) {
@@ -3055,8 +3167,9 @@ void ntreeTagUsedSockets(bNodeTree *ntree)
for (link = ntree->links.first; link; link = link->next) {
/* link is unused if either side is disabled */
- if ((link->fromsock->flag & SOCK_UNAVAIL) || (link->tosock->flag & SOCK_UNAVAIL))
+ if ((link->fromsock->flag & SOCK_UNAVAIL) || (link->tosock->flag & SOCK_UNAVAIL)) {
continue;
+ }
link->fromsock->flag |= SOCK_IN_USE;
link->tosock->flag |= SOCK_IN_USE;
@@ -3089,23 +3202,55 @@ static void ntree_validate_links(bNodeTree *ntree)
for (link = ntree->links.first; link; link = link->next) {
link->flag |= NODE_LINK_VALID;
- if (link->fromnode && link->tonode && link->fromnode->level <= link->tonode->level)
+ if (link->fromnode && link->tonode && link->fromnode->level <= link->tonode->level) {
link->flag &= ~NODE_LINK_VALID;
+ }
else if (ntree->typeinfo->validate_link) {
- if (!ntree->typeinfo->validate_link(ntree, link))
+ if (!ntree->typeinfo->validate_link(ntree, link)) {
link->flag &= ~NODE_LINK_VALID;
+ }
}
}
}
-void ntreeVerifyNodes(struct Main *main, struct ID *id)
+void ntreeUpdateAllNew(Main *main)
{
+ /* Update all new node trees on file read or append, to add/remove sockets
+ * in groups nodes if the group changed, and handle any update flags that
+ * might have been set in file reading or versioning. */
FOREACH_NODETREE_BEGIN (main, ntree, owner_id) {
- bNode *node;
+ if (owner_id->tag & LIB_TAG_NEW) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->typeinfo->group_update_func) {
+ node->typeinfo->group_update_func(ntree, node);
+ }
+ }
+
+ ntreeUpdateTree(NULL, ntree);
+ }
+ }
+ FOREACH_NODETREE_END;
+}
+
+void ntreeUpdateAllUsers(Main *main, ID *ngroup)
+{
+ /* Update all users of ngroup, to add/remove sockets as needed. */
+ FOREACH_NODETREE_BEGIN (main, ntree, owner_id) {
+ bool need_update = false;
+
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->id == ngroup) {
+ if (node->typeinfo->group_update_func) {
+ node->typeinfo->group_update_func(ntree, node);
+ }
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->typeinfo->verifyfunc)
- node->typeinfo->verifyfunc(ntree, node, id);
+ need_update = true;
+ }
+ }
+
+ if (need_update) {
+ ntreeUpdateTree(NULL, ntree);
+ }
}
FOREACH_NODETREE_END;
}
@@ -3114,12 +3259,14 @@ void ntreeUpdateTree(Main *bmain, bNodeTree *ntree)
{
bNode *node;
- if (!ntree)
+ if (!ntree) {
return;
+ }
/* avoid reentrant updates, can be caused by RNA update callbacks */
- if (ntree->is_updating)
+ if (ntree->is_updating) {
return;
+ }
ntree->is_updating = true;
if (ntree->update & (NTREE_UPDATE_LINKS | NTREE_UPDATE_NODES)) {
@@ -3131,25 +3278,29 @@ void ntreeUpdateTree(Main *bmain, bNodeTree *ntree)
for (node = ntree->nodes.first; node; node = node->next) {
/* node tree update tags override individual node update flags */
if ((node->update & NODE_UPDATE) || (ntree->update & NTREE_UPDATE)) {
- if (node->typeinfo->updatefunc)
+ if (node->typeinfo->updatefunc) {
node->typeinfo->updatefunc(ntree, node);
+ }
nodeUpdateInternalLinks(ntree, node);
}
}
/* generic tree update callback */
- if (ntree->typeinfo->update)
+ if (ntree->typeinfo->update) {
ntree->typeinfo->update(ntree);
+ }
/* XXX this should be moved into the tree type update callback for tree supporting node groups.
* Currently the node tree interface is still a generic feature of the base NodeTree type.
*/
- if (ntree->update & NTREE_UPDATE_GROUP)
+ if (ntree->update & NTREE_UPDATE_GROUP) {
ntreeInterfaceTypeUpdate(ntree);
+ }
/* XXX hack, should be done by depsgraph!! */
- if (bmain)
- ntreeVerifyNodes(bmain, &ntree->id);
+ if (bmain) {
+ ntreeUpdateAllUsers(bmain, &ntree->id);
+ }
if (ntree->update & (NTREE_UPDATE_LINKS | NTREE_UPDATE_NODES)) {
/* node updates can change sockets or links, repeat link pointer update afterward */
@@ -3174,12 +3325,14 @@ void ntreeUpdateTree(Main *bmain, bNodeTree *ntree)
void nodeUpdate(bNodeTree *ntree, bNode *node)
{
/* avoid reentrant updates, can be caused by RNA update callbacks */
- if (ntree->is_updating)
+ if (ntree->is_updating) {
return;
+ }
ntree->is_updating = true;
- if (node->typeinfo->updatefunc)
+ if (node->typeinfo->updatefunc) {
node->typeinfo->updatefunc(ntree, node);
+ }
nodeUpdateInternalLinks(ntree, node);
@@ -3194,20 +3347,23 @@ bool nodeUpdateID(bNodeTree *ntree, ID *id)
bNode *node;
bool changed = false;
- if (ELEM(NULL, id, ntree))
+ if (ELEM(NULL, id, ntree)) {
return changed;
+ }
/* avoid reentrant updates, can be caused by RNA update callbacks */
- if (ntree->is_updating)
+ if (ntree->is_updating) {
return changed;
+ }
ntree->is_updating = true;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->id == id) {
changed = true;
node->update |= NODE_UPDATE_ID;
- if (node->typeinfo->updatefunc)
+ if (node->typeinfo->updatefunc) {
node->typeinfo->updatefunc(ntree, node);
+ }
/* clear update flag */
node->update = 0;
}
@@ -3225,8 +3381,9 @@ void nodeUpdateInternalLinks(bNodeTree *ntree, bNode *node)
{
BLI_freelistN(&node->internal_links);
- if (node->typeinfo && node->typeinfo->update_internal_links)
+ if (node->typeinfo && node->typeinfo->update_internal_links) {
node->typeinfo->update_internal_links(ntree, node);
+ }
}
/* ************* node type access ********** */
@@ -3372,8 +3529,9 @@ void node_type_socket_templates(struct bNodeType *ntype,
/* automatically generate unique identifiers */
if (inputs) {
/* clear identifier strings (uninitialized memory) */
- for (ntemp = inputs; ntemp->type >= 0; ++ntemp)
+ for (ntemp = inputs; ntemp->type >= 0; ++ntemp) {
ntemp->identifier[0] = '\0';
+ }
for (ntemp = inputs; ntemp->type >= 0; ++ntemp) {
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
@@ -3382,8 +3540,9 @@ void node_type_socket_templates(struct bNodeType *ntype,
}
if (outputs) {
/* clear identifier strings (uninitialized memory) */
- for (ntemp = outputs; ntemp->type >= 0; ++ntemp)
+ for (ntemp = outputs; ntemp->type >= 0; ++ntemp) {
ntemp->identifier[0] = '\0';
+ }
for (ntemp = outputs; ntemp->type >= 0; ++ntemp) {
BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier));
@@ -3402,10 +3561,12 @@ void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwid
{
ntype->width = width;
ntype->minwidth = minwidth;
- if (maxwidth <= minwidth)
+ if (maxwidth <= minwidth) {
ntype->maxwidth = FLT_MAX;
- else
+ }
+ else {
ntype->maxwidth = maxwidth;
+ }
}
void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size)
@@ -3437,10 +3598,12 @@ void node_type_storage(bNodeType *ntype,
struct bNode *dest_node,
struct bNode *src_node))
{
- if (storagename)
+ if (storagename) {
BLI_strncpy(ntype->storagename, storagename, sizeof(ntype->storagename));
- else
+ }
+ else {
ntype->storagename[0] = '\0';
+ }
ntype->copyfunc = copyfunc;
ntype->freefunc = freefunc;
}
@@ -3453,13 +3616,15 @@ void node_type_label(
}
void node_type_update(struct bNodeType *ntype,
- void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
- void (*verifyfunc)(struct bNodeTree *ntree,
- struct bNode *node,
- struct ID *id))
+ void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
{
ntype->updatefunc = updatefunc;
- ntype->verifyfunc = verifyfunc;
+}
+
+void node_type_group_update(struct bNodeType *ntype,
+ void (*group_update_func)(struct bNodeTree *ntree, struct bNode *node))
+{
+ ntype->group_update_func = group_update_func;
}
void node_type_exec(struct bNodeType *ntype,
@@ -3796,10 +3961,12 @@ void free_nodesystem(void)
if (nodesockettypes_hash) {
NODE_SOCKET_TYPES_BEGIN (st) {
- if (st->ext_socket.free)
+ if (st->ext_socket.free) {
st->ext_socket.free(st->ext_socket.data);
- if (st->ext_interface.free)
+ }
+ if (st->ext_interface.free) {
st->ext_interface.free(st->ext_interface.data);
+ }
}
NODE_SOCKET_TYPES_END;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 303d63d6a8b..38a8ad2769a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -223,7 +223,8 @@ void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd)
if (hmd->subtarget[0] && pchan) {
float imat[4][4], mat[4][4];
- /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
+ /* Calculate the world-space matrix for the pose-channel target first,
+ * then carry on as usual. */
mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
invert_m4_m4(imat, mat);
@@ -247,7 +248,8 @@ void BKE_object_modifier_gpencil_hook_reset(Object *ob, HookGpencilModifierData
if (hmd->subtarget[0] && pchan) {
float imat[4][4], mat[4][4];
- /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
+ /* Calculate the world-space matrix for the pose-channel target first,
+ * then carry on as usual. */
mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat);
invert_m4_m4(imat, mat);
@@ -300,8 +302,9 @@ void BKE_object_link_modifiers(Scene *scene, struct Object *ob_dst, const struct
continue;
}
- if (!BKE_object_support_modifier_type_check(ob_dst, md->type))
+ if (!BKE_object_support_modifier_type_check(ob_dst, md->type)) {
continue;
+ }
switch (md->type) {
case eModifierType_Softbody:
@@ -444,7 +447,6 @@ void BKE_object_free_derived_caches(Object *ob)
object_update_from_subsurf_ccg(ob);
BKE_object_free_derived_mesh_caches(ob);
- BKE_armature_cached_bbone_deformation_free(ob);
if (ob->runtime.mesh_eval != NULL) {
Mesh *mesh_eval = ob->runtime.mesh_eval;
@@ -580,8 +582,9 @@ void BKE_object_free(Object *ob)
/* Free runtime curves data. */
if (ob->runtime.curve_cache) {
BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
- if (ob->runtime.curve_cache->path)
+ if (ob->runtime.curve_cache->path) {
free_path(ob->runtime.curve_cache->path);
+ }
MEM_freeN(ob->runtime.curve_cache);
ob->runtime.curve_cache = NULL;
}
@@ -728,13 +731,15 @@ bool BKE_object_exists_check(Main *bmain, const Object *obtest)
{
Object *ob;
- if (obtest == NULL)
+ if (obtest == NULL) {
return false;
+ }
ob = bmain->objects.first;
while (ob) {
- if (ob == obtest)
+ if (ob == obtest) {
return true;
+ }
ob = ob->id.next;
}
return false;
@@ -878,8 +883,9 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
{
Object *ob;
- if (!name)
+ if (!name) {
name = get_obdata_defname(type);
+ }
ob = BKE_libblock_alloc(bmain, ID_OB, name, 0);
@@ -971,8 +977,9 @@ Object *BKE_object_add_for_data(
/* same as object_add_common, except we don't create new ob->data */
ob = BKE_object_add_only_object(bmain, type, name);
ob->data = data;
- if (do_id_user)
+ if (do_id_user) {
id_us_plus(data);
+ }
BKE_view_layer_base_deselect_all(view_layer);
DEG_id_tag_update_ex(
@@ -1016,13 +1023,15 @@ void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src
sbn->bpoint = MEM_dupallocN(sbn->bpoint);
for (i = 0; i < sbn->totpoint; i++) {
- if (sbn->bpoint[i].springs)
+ if (sbn->bpoint[i].springs) {
sbn->bpoint[i].springs = MEM_dupallocN(sbn->bpoint[i].springs);
+ }
}
}
- if (sb->bspring)
+ if (sb->bspring) {
sbn->bspring = MEM_dupallocN(sb->bspring);
+ }
}
sbn->keys = NULL;
@@ -1036,8 +1045,9 @@ void BKE_object_copy_softbody(struct Object *ob_dst, const struct Object *ob_src
&sbn->shared->ptcaches, &sb->shared->ptcaches, flag);
}
- if (sb->effector_weights)
+ if (sb->effector_weights) {
sbn->effector_weights = MEM_dupallocN(sb->effector_weights);
+ }
ob_dst->soft = sbn;
}
@@ -1110,8 +1120,9 @@ void BKE_object_copy_particlesystems(Object *ob_dst, const Object *ob_src, const
for (md = ob_dst->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_ParticleSystem) {
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
- if (psmd->psys == psys)
+ if (psmd->psys == psys) {
psmd->psys = npsys;
+ }
}
else if (md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
@@ -1126,8 +1137,9 @@ void BKE_object_copy_particlesystems(Object *ob_dst, const Object *ob_src, const
if (smd->type == MOD_SMOKE_TYPE_FLOW) {
if (smd->flow) {
- if (smd->flow->psys == psys)
+ if (smd->flow->psys == psys) {
smd->flow->psys = npsys;
+ }
}
}
}
@@ -1149,7 +1161,8 @@ static void copy_object_pose(Object *obn, const Object *ob, const int flag)
chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE);
- /* XXX Remapping object pointing onto itself should be handled by generic BKE_library_remap stuff, but...
+ /* XXX Remapping object pointing onto itself should be handled by generic
+ * BKE_library_remap stuff, but...
* the flush_constraint_targets callback am not sure about, so will delay that for now. */
for (con = chan->constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
@@ -1160,12 +1173,14 @@ static void copy_object_pose(Object *obn, const Object *ob, const int flag)
cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) {
- if (ct->tar == ob)
+ if (ct->tar == ob) {
ct->tar = obn;
+ }
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
}
}
@@ -1190,17 +1205,20 @@ bool BKE_object_pose_context_check(const Object *ob)
Object *BKE_object_pose_armature_get(Object *ob)
{
- if (ob == NULL)
+ if (ob == NULL) {
return NULL;
+ }
- if (BKE_object_pose_context_check(ob))
+ if (BKE_object_pose_context_check(ob)) {
return ob;
+ }
ob = modifiers_isDeformedByArmature(ob);
/* Only use selected check when non-active. */
- if (BKE_object_pose_context_check(ob))
+ if (BKE_object_pose_context_check(ob)) {
return ob;
+ }
return NULL;
}
@@ -1319,8 +1337,10 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)
}
/**
- * Only copy internal data of Object ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Object ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -1350,11 +1370,13 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
ob_dst->matbits = NULL;
}
- if (ob_src->iuser)
+ if (ob_src->iuser) {
ob_dst->iuser = MEM_dupallocN(ob_src->iuser);
+ }
- if (ob_src->runtime.bb)
+ if (ob_src->runtime.bb) {
ob_dst->runtime.bb = MEM_dupallocN(ob_src->runtime.bb);
+ }
BLI_listbase_clear(&ob_dst->modifiers);
@@ -1421,7 +1443,8 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
copy_object_lod(ob_dst, ob_src, flag_subdata);
- /* Do not copy object's preview (mostly due to the fact renderers create temp copy of objects). */
+ /* Do not copy object's preview
+ * (mostly due to the fact renderers create temp copy of objects). */
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */
BKE_previewimg_id_copy(&ob_dst->id, &ob_src->id);
}
@@ -1444,11 +1467,13 @@ Object *BKE_object_copy(Main *bmain, const Object *ob)
/** Perform deep-copy of object and its 'children' data-blocks (obdata, materials, actions, etc.).
*
- * \param dupflag Controls which sub-data are also duplicated (see #eDupli_ID_Flags in DNA_userdef_types.h).
+ * \param dupflag Controls which sub-data are also duplicated
+ * (see #eDupli_ID_Flags in DNA_userdef_types.h).
*
- * \note This function does not do any remapping to new IDs, caller must do it (\a #BKE_libblock_relink_to_newid()).
- * \note Caller MUST free \a newid pointers itself (#BKE_main_id_clear_newpoins()) and call updates of DEG too
- * (#DAG_relations_tag_update()).
+ * \note This function does not do any remapping to new IDs, caller must do it
+ * (\a #BKE_libblock_relink_to_newid()).
+ * \note Caller MUST free \a newid pointers itself (#BKE_main_id_clear_newpoins()) and call updates
+ * of DEG too (#DAG_relations_tag_update()).
*/
Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
{
@@ -1588,8 +1613,9 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
case OB_ARMATURE:
if (dupflag != 0) {
DEG_id_tag_update(&obn->id, ID_RECALC_GEOMETRY);
- if (obn->pose)
+ if (obn->pose) {
BKE_pose_tag_recalc(bmain, obn->pose);
+ }
if (dupflag & USER_DUP_ARM) {
ID_NEW_REMAP_US2(obn->data)
else
@@ -1625,7 +1651,7 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
}
break;
case OB_LIGHTPROBE:
- if (dupflag != 0) {
+ if (dupflag & USER_DUP_LIGHTPROBE) {
ID_NEW_REMAP_US2(obn->data)
else
{
@@ -1647,7 +1673,7 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag)
}
break;
case OB_GPENCIL:
- if (dupflag != 0) {
+ if (dupflag & USER_DUP_GPENCIL) {
ID_NEW_REMAP_US2(obn->data)
else
{
@@ -1713,7 +1739,8 @@ void BKE_object_make_local_ex(Main *bmain,
/* - only lib users: do nothing (unless force_local is set)
* - only local users: set flag
* - mixed: make copy
- * In case we make a whole lib's content local, we always want to localize, and we skip remapping (done later).
+ * In case we make a whole lib's content local,
+ * we always want to localize, and we skip remapping (done later).
*/
if (!ID_IS_LINKED(ob)) {
@@ -1779,8 +1806,9 @@ static void armature_set_id_extern(Object *ob)
unsigned int lay = arm->layer_protected;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (!(pchan->bone->layer & lay))
+ if (!(pchan->bone->layer & lay)) {
id_lib_extern((ID *)pchan->custom);
+ }
}
}
@@ -1790,8 +1818,9 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
FCurve *fcu;
/* add new animdata block */
- if (!ob->adt)
+ if (!ob->adt) {
ob->adt = BKE_animdata_add_id(&ob->id);
+ }
/* make a copy of all the drivers (for now), then correct any links that need fixing */
free_fcurves(&ob->adt->drivers);
@@ -1805,14 +1834,16 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
/* all drivers */
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
if (dtar->id) {
- if ((Object *)dtar->id == target)
+ if ((Object *)dtar->id == target) {
dtar->id = (ID *)ob;
+ }
else {
/* only on local objects because this causes indirect links
* 'a -> b -> c', blend to point directly to a.blend
* when a.blend has a proxy thats linked into c.blend */
- if (!ID_IS_LINKED(ob))
+ if (!ID_IS_LINKED(ob)) {
id_lib_extern((ID *)dtar->id);
+ }
}
}
}
@@ -1822,10 +1853,12 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
}
}
-/* proxy rule: lib_object->proxy_from == the one we borrow from, set temporally while object_update */
-/* local_object->proxy == pointer to library object, saved in files and read */
-/* local_object->proxy_group == pointer to collection dupli-object, saved in files and read */
-
+/**
+ * Proxy rule:
+ * - lib_object->proxy_from == the one we borrow from, set temporally while object_update.
+ * - local_object->proxy == pointer to library object, saved in files and read.
+ * - local_object->proxy_group == pointer to collection dupli-object, saved in files and read.
+ */
void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob)
{
/* paranoia checks */
@@ -1879,10 +1912,12 @@ void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob)
/* copy material and index information */
ob->actcol = ob->totcol = 0;
- if (ob->mat)
+ if (ob->mat) {
MEM_freeN(ob->mat);
- if (ob->matbits)
+ }
+ if (ob->matbits) {
MEM_freeN(ob->matbits);
+ }
ob->mat = NULL;
ob->matbits = NULL;
if ((target->totcol) && (target->mat) && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
@@ -1981,7 +2016,7 @@ void BKE_object_scale_to_mat3(Object *ob, float mat[3][3])
size_to_mat3(mat, vec);
}
-void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot)
+void BKE_object_rot_to_mat3(const Object *ob, float mat[3][3], bool use_drot)
{
float rmat[3][3], dmat[3][3];
@@ -1991,7 +2026,8 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot)
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
if (ob->rotmode > 0) {
- /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
+ /* Euler rotations
+ * (will cause gimble lock, but this can be alleviated a bit with rotation orders). */
eulO_to_mat3(rmat, ob->rot, ob->rotmode);
eulO_to_mat3(dmat, ob->drot, ob->rotmode);
}
@@ -2012,10 +2048,12 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot)
}
/* combine these rotations */
- if (use_drot)
+ if (use_drot) {
mul_m3_m3m3(mat, dmat, rmat);
- else
+ }
+ else {
copy_m3_m3(mat, rmat);
+ }
}
void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat)
@@ -2055,10 +2093,12 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat)
mul_qt_qtqt(quat, dquat, quat);
/* end drot correction */
- if (use_compat)
+ if (use_compat) {
quat_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, quat);
- else
+ }
+ else {
quat_to_eulO(ob->rot, ob->rotmode, quat);
+ }
break;
}
}
@@ -2214,11 +2254,11 @@ static bool ob_parcurve(Object *ob, Object *par, float mat[4][4])
return false;
}
- /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
- * but this will only work if it actually is animated...
+ /* ctime is now a proper var setting of Curve which gets set by Animato like any other var
+ * that's animated, but this will only work if it actually is animated.
*
- * we divide the curvetime calculated in the previous step by the length of the path, to get a time
- * factor, which then gets clamped to lie within 0.0 - 1.0 range
+ * We divide the curvetime calculated in the previous step by the length of the path,
+ * to get a time factor, which then gets clamped to lie within 0.0 - 1.0 range.
*/
if (cu->pathlen) {
ctime = cu->ctime / cu->pathlen;
@@ -2375,8 +2415,9 @@ static void give_parvert(Object *par, int nr, float vec[3])
float(*co)[3] = dl ? (float(*)[3])dl->verts : NULL;
int tot;
- if (latt->editlatt)
+ if (latt->editlatt) {
latt = latt->editlatt->latt;
+ }
tot = latt->pntsu * latt->pntsv * latt->pntsw;
@@ -2431,10 +2472,12 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4]
}
}
- if (ok)
+ if (ok) {
mul_m4_m4m4(parentmat, par->obmat, tmat);
- else
+ }
+ else {
copy_m4_m4(parentmat, par->obmat);
+ }
break;
case PARBONE:
@@ -2460,7 +2503,8 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4]
}
/**
- * \param r_originmat: Optional matrix that stores the space the object is in (without its own matrix applied)
+ * \param r_originmat: Optional matrix that stores the space the object is in
+ * (without its own matrix applied)
*/
static void solve_parenting(
Object *ob, Object *par, float obmat[4][4], float r_originmat[3][3], const bool set_origin)
@@ -2525,10 +2569,12 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph,
}
/* set negative scale flag in object */
- if (is_negative_m4(ob->obmat))
+ if (is_negative_m4(ob->obmat)) {
ob->transflag |= OB_NEG_SCALE;
- else
+ }
+ else {
ob->transflag &= ~OB_NEG_SCALE;
+ }
}
void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
@@ -2581,7 +2627,8 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o
unit_m4(workob->parentinv);
unit_m4(workob->constinv);
- /* Since this is used while calculating parenting, at this moment ob_eval->parent is still NULL. */
+ /* Since this is used while calculating parenting,
+ * at this moment ob_eval->parent is still NULL. */
workob->parent = DEG_get_evaluated_object(depsgraph, ob->parent);
workob->trackflag = ob->trackflag;
@@ -2603,8 +2650,10 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o
* Applies the global transformation \a mat to the \a ob using a relative parent space if supplied.
*
* \param mat: the global transformation mat that the object should be set object to.
- * \param parent: the parent space in which this object will be set relative to (should probably always be parent_eval).
- * \param use_compat: true to ensure that rotations are set using the min difference between the old and new orientation.
+ * \param parent: the parent space in which this object will be set relative to
+ * (should probably always be parent_eval).
+ * \param use_compat: true to ensure that rotations are set using the
+ * min difference between the old and new orientation.
*/
void BKE_object_apply_mat4_ex(
Object *ob, float mat[4][4], Object *parent, float parentinv[4][4], const bool use_compat)
@@ -2633,12 +2682,15 @@ void BKE_object_apply_mat4_ex(
sub_v3_v3(ob->loc, ob->dloc);
- if (ob->dscale[0] != 0.0f)
+ if (ob->dscale[0] != 0.0f) {
ob->scale[0] /= ob->dscale[0];
- if (ob->dscale[1] != 0.0f)
+ }
+ if (ob->dscale[1] != 0.0f) {
ob->scale[1] /= ob->dscale[1];
- if (ob->dscale[2] != 0.0f)
+ }
+ if (ob->dscale[2] != 0.0f) {
ob->scale[2] /= ob->dscale[2];
+ }
/* BKE_object_mat3_to_rot handles delta rotations */
}
@@ -2735,10 +2787,12 @@ void BKE_object_boundbox_flag(Object *ob, int flag, const bool set)
{
BoundBox *bb = BKE_object_boundbox_get(ob);
if (bb) {
- if (set)
+ if (set) {
bb->flag |= flag;
- else
+ }
+ else {
bb->flag &= ~flag;
+ }
}
}
@@ -3108,10 +3162,12 @@ void BKE_object_tfm_restore(Object *ob, void *obtfm_pt)
bool BKE_object_parent_loop_check(const Object *par, const Object *ob)
{
/* test if 'ob' is a parent somewhere in par's parents */
- if (par == NULL)
+ if (par == NULL) {
return false;
- if (ob == par)
+ }
+ if (ob == par) {
return true;
+ }
return BKE_object_parent_loop_check(par->parent, ob);
}
@@ -3137,14 +3193,19 @@ static void object_handle_update_proxy(Depsgraph *depsgraph,
}
}
-/* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */
-/* local_object->proxy == pointer to library object, saved in files and read */
-
-/* function below is polluted with proxy exceptions, cleanup will follow! */
-
-/* the main object update call, for object matrix, constraints, keys and displist (modifiers) */
-/* requires flags to be set! */
-/* Ideally we shouldn't have to pass the rigid body world, but need bigger restructuring to avoid id */
+/**
+ * Proxy rule:
+ * - lib_object->proxy_from == the one we borrow from, only set temporal and cleared here.
+ * - local_object->proxy == pointer to library object, saved in files and read.
+ *
+ * Function below is polluted with proxy exceptions, cleanup will follow!
+ *
+ * The main object update call, for object matrix, constraints, keys and displist (modifiers)
+ * requires flags to be set!
+ *
+ * Ideally we shouldn't have to pass the rigid body world,
+ * but need bigger restructuring to avoid id.
+ */
void BKE_object_handle_update_ex(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
@@ -3244,8 +3305,9 @@ void BKE_object_sculpt_modifiers_changed(Object *ob)
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
- for (n = 0; n < totnode; n++)
+ for (n = 0; n < totnode; n++) {
BKE_pbvh_node_mark_update(nodes[n]);
+ }
MEM_freeN(nodes);
}
@@ -3256,8 +3318,9 @@ int BKE_object_obdata_texspace_get(
Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot)
{
- if (ob->data == NULL)
+ if (ob->data == NULL) {
return 0;
+ }
switch (GS(((ID *)ob->data)->name)) {
case ID_ME: {
@@ -3269,26 +3332,34 @@ int BKE_object_obdata_texspace_get(
if (cu->bb == NULL || (cu->bb->flag & BOUNDBOX_DIRTY)) {
BKE_curve_texspace_calc(cu);
}
- if (r_texflag)
+ if (r_texflag) {
*r_texflag = &cu->texflag;
- if (r_loc)
+ }
+ if (r_loc) {
*r_loc = cu->loc;
- if (r_size)
+ }
+ if (r_size) {
*r_size = cu->size;
- if (r_rot)
+ }
+ if (r_rot) {
*r_rot = cu->rot;
+ }
break;
}
case ID_MB: {
MetaBall *mb = ob->data;
- if (r_texflag)
+ if (r_texflag) {
*r_texflag = &mb->texflag;
- if (r_loc)
+ }
+ if (r_loc) {
*r_loc = mb->loc;
- if (r_size)
+ }
+ if (r_size) {
*r_size = mb->size;
- if (r_rot)
+ }
+ if (r_rot) {
*r_rot = mb->rot;
+ }
break;
}
default:
@@ -3363,10 +3434,12 @@ Mesh *BKE_object_get_original_mesh(Object *object)
static int pc_cmp(const void *a, const void *b)
{
const LinkData *ad = a, *bd = b;
- if (POINTER_AS_INT(ad->data) > POINTER_AS_INT(bd->data))
+ if (POINTER_AS_INT(ad->data) > POINTER_AS_INT(bd->data)) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
int BKE_object_insert_ptcache(Object *ob)
@@ -3379,8 +3452,9 @@ int BKE_object_insert_ptcache(Object *ob)
for (link = ob->pc_ids.first, i = 0; link; link = link->next, i++) {
int index = POINTER_AS_INT(link->data);
- if (i < index)
+ if (i < index) {
break;
+ }
}
link = MEM_callocN(sizeof(LinkData), "PCLink");
@@ -3395,13 +3469,15 @@ static int pc_findindex(ListBase *listbase, int index)
LinkData *link = NULL;
int number = 0;
- if (listbase == NULL)
+ if (listbase == NULL) {
return -1;
+ }
link = listbase->first;
while (link) {
- if (POINTER_AS_INT(link->data) == index)
+ if (POINTER_AS_INT(link->data) == index) {
return number;
+ }
number++;
link = link->next;
@@ -3667,12 +3743,14 @@ int BKE_object_is_modified(Scene *scene, Object *ob)
md && (flag != (eModifierMode_Render | eModifierMode_Realtime));
md = md->next) {
if ((flag & eModifierMode_Render) == 0 &&
- modifier_isEnabled(scene, md, eModifierMode_Render))
+ modifier_isEnabled(scene, md, eModifierMode_Render)) {
flag |= eModifierMode_Render;
+ }
if ((flag & eModifierMode_Realtime) == 0 &&
- modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
flag |= eModifierMode_Realtime;
+ }
}
}
@@ -3810,12 +3888,14 @@ int BKE_object_is_deform_modified(Scene *scene, Object *ob)
}
if (can_deform) {
- if (!(flag & eModifierMode_Render) && modifier_isEnabled(scene, md, eModifierMode_Render))
+ if (!(flag & eModifierMode_Render) && modifier_isEnabled(scene, md, eModifierMode_Render)) {
flag |= eModifierMode_Render;
+ }
if (!(flag & eModifierMode_Realtime) &&
- modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
flag |= eModifierMode_Realtime;
+ }
}
}
@@ -3828,11 +3908,12 @@ bool BKE_object_is_animated(Scene *scene, Object *ob)
ModifierData *md;
VirtualModifierData virtualModifierData;
- for (md = modifiers_getVirtualModifierList(ob, &virtualModifierData); md; md = md->next)
+ for (md = modifiers_getVirtualModifierList(ob, &virtualModifierData); md; md = md->next) {
if (modifier_dependsOnTime(md) && (modifier_isEnabled(scene, md, eModifierMode_Realtime) ||
modifier_isEnabled(scene, md, eModifierMode_Render))) {
return true;
}
+ }
return false;
}
@@ -3855,8 +3936,9 @@ MovieClip *BKE_object_movieclip_get(Scene *scene, Object *ob, bool use_default)
while (con) {
if (con->type == CONSTRAINT_TYPE_CAMERASOLVER) {
- if (scon == NULL || (scon->flag & CONSTRAINT_OFF))
+ if (scon == NULL || (scon->flag & CONSTRAINT_OFF)) {
scon = con;
+ }
}
con = con->next;
@@ -3864,10 +3946,12 @@ MovieClip *BKE_object_movieclip_get(Scene *scene, Object *ob, bool use_default)
if (scon) {
bCameraSolverConstraint *solver = scon->data;
- if ((solver->flag & CAMERASOLVER_ACTIVECLIP) == 0)
+ if ((solver->flag & CAMERASOLVER_ACTIVECLIP) == 0) {
clip = solver->clip;
- else
+ }
+ else {
clip = scene->clip;
+ }
}
return clip;
@@ -3886,7 +3970,6 @@ void BKE_object_runtime_reset_on_copy(Object *object, const int UNUSED(flag))
runtime->mesh_deform_eval = NULL;
runtime->curve_cache = NULL;
runtime->gpencil_cache = NULL;
- runtime->cached_bbone_deformation = NULL;
}
/*
@@ -3954,8 +4037,9 @@ LinkNode *BKE_object_relational_superset(struct ViewLayer *view_layer,
(objectSet == OB_SET_VISIBLE && BASE_EDITABLE(((View3D *)NULL), base))) {
Object *ob = base->object;
- if (obrel_list_test(ob))
+ if (obrel_list_test(ob)) {
obrel_list_add(&links, ob);
+ }
/* parent relationship */
if (includeFilter & (OB_REL_PARENT | OB_REL_PARENT_RECURSIVE)) {
@@ -4176,8 +4260,9 @@ bool BKE_object_modifier_use_time(Object *ob, ModifierData *md)
/* action - check for F-Curves with paths containing 'modifiers[' */
if (adt->action) {
for (fcu = (FCurve *)adt->action->curves.first; fcu != NULL; fcu = (FCurve *)fcu->next) {
- if (fcu->rna_path && strstr(fcu->rna_path, pattern))
+ if (fcu->rna_path && strstr(fcu->rna_path, pattern)) {
return true;
+ }
}
}
@@ -4188,8 +4273,9 @@ bool BKE_object_modifier_use_time(Object *ob, ModifierData *md)
* by the RNA updates cache introduced in r.38649
*/
for (fcu = (FCurve *)adt->drivers.first; fcu != NULL; fcu = (FCurve *)fcu->next) {
- if (fcu->rna_path && strstr(fcu->rna_path, pattern))
+ if (fcu->rna_path && strstr(fcu->rna_path, pattern)) {
return true;
+ }
}
/* XXX: also, should check NLA strips, though for now assume that nobody uses
@@ -4252,15 +4338,17 @@ bool BKE_object_shaderfx_use_time(Object *ob, ShaderFxData *fx)
/* action - check for F-Curves with paths containing string[' */
if (adt->action) {
for (fcu = adt->action->curves.first; fcu != NULL; fcu = fcu->next) {
- if (fcu->rna_path && strstr(fcu->rna_path, pattern))
+ if (fcu->rna_path && strstr(fcu->rna_path, pattern)) {
return true;
+ }
}
}
/* This here allows properties to get driven and still update properly */
for (fcu = adt->drivers.first; fcu != NULL; fcu = fcu->next) {
- if (fcu->rna_path && strstr(fcu->rna_path, pattern))
+ if (fcu->rna_path && strstr(fcu->rna_path, pattern)) {
return true;
+ }
}
}
@@ -4276,10 +4364,12 @@ static void object_cacheIgnoreClear(Object *ob, int state)
for (pid = pidlist.first; pid; pid = pid->next) {
if (pid->cache) {
- if (state)
+ if (state) {
pid->cache->flag |= PTCACHE_IGNORE_CLEAR;
- else
+ }
+ else {
pid->cache->flag &= ~PTCACHE_IGNORE_CLEAR;
+ }
}
}
@@ -4304,31 +4394,36 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
/* if other is dynamic paint canvas, don't update */
- if (pmd && pmd->canvas)
+ if (pmd && pmd->canvas) {
return true;
+ }
}
else if (type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
- if (smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) != 0)
+ if (smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) != 0) {
return true;
+ }
}
/* if object has parents, update them too */
if (parent_recursion) {
int recursion = parent_recursion - 1;
bool no_update = false;
- if (ob->parent)
+ if (ob->parent) {
no_update |= BKE_object_modifier_update_subframe(
depsgraph, scene, ob->parent, 0, recursion, frame, type);
- if (ob->track)
+ }
+ if (ob->track) {
no_update |= BKE_object_modifier_update_subframe(
depsgraph, scene, ob->track, 0, recursion, frame, type);
+ }
/* skip subframe if object is parented
* to vertex of a dynamic paint canvas */
- if (no_update && (ob->partype == PARVERT1 || ob->partype == PARVERT3))
+ if (no_update && (ob->partype == PARVERT1 || ob->partype == PARVERT3)) {
return false;
+ }
/* also update constraint targets */
for (con = ob->constraints.first; con; con = con->next) {
@@ -4339,13 +4434,15 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
bConstraintTarget *ct;
cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) {
- if (ct->tar)
+ if (ct->tar) {
BKE_object_modifier_update_subframe(
depsgraph, scene, ct->tar, 0, recursion, frame, type);
+ }
}
/* free temp targets */
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index be3dbbb1c71..0ce6094771c 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -116,8 +116,9 @@ bDeformGroup *BKE_object_defgroup_add_name(Object *ob, const char *name)
{
bDeformGroup *defgroup;
- if (!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type))
+ if (!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type)) {
return NULL;
+ }
defgroup = BKE_defgroup_new(ob, name);
@@ -283,8 +284,9 @@ static void object_defgroup_remove_common(Object *ob, bDeformGroup *dg, const in
BLI_freelinkN(&ob->defbase, dg);
/* Update the active deform index if necessary */
- if (ob->actdef > def_nr)
+ if (ob->actdef > def_nr) {
ob->actdef--;
+ }
/* remove all dverts */
if (BLI_listbase_is_empty(&ob->defbase)) {
@@ -345,7 +347,8 @@ static void object_defgroup_remove_edit_mode(Object *ob, bDeformGroup *dg)
BLI_assert(def_nr != -1);
- /* Make sure that no verts are using this group - if none were removed, we can skip next per-vert update. */
+ /* Make sure that no verts are using this group - if none were removed,
+ * we can skip next per-vert update. */
if (!BKE_object_defgroup_clear(ob, dg, false)) {
/* Nothing to do. */
}
@@ -401,10 +404,12 @@ void BKE_object_defgroup_remove(Object *ob, bDeformGroup *defgroup)
BKE_gpencil_vgroup_remove(ob, defgroup);
}
else {
- if (BKE_object_is_in_editmode_vgroup(ob))
+ if (BKE_object_is_in_editmode_vgroup(ob)) {
object_defgroup_remove_edit_mode(ob, defgroup);
- else
+ }
+ else {
object_defgroup_remove_object_mode(ob, defgroup);
+ }
BKE_object_batch_cache_dirty_tag(ob);
}
@@ -424,10 +429,12 @@ void BKE_object_defgroup_remove_all_ex(struct Object *ob, bool only_unlocked)
bDeformGroup *next_dg = dg->next;
if (!only_unlocked || (dg->flag & DG_LOCK_WEIGHT) == 0) {
- if (edit_mode)
+ if (edit_mode) {
object_defgroup_remove_edit_mode(ob, dg);
- else
+ }
+ else {
object_defgroup_remove_object_mode(ob, dg);
+ }
}
dg = next_dg;
@@ -571,7 +578,7 @@ bool *BKE_object_defgroup_lock_flags_get(Object *ob, const int defbase_tot)
{
bool is_locked = false;
int i;
- //int defbase_tot = BLI_listbase_count(&ob->defbase);
+ // int defbase_tot = BLI_listbase_count(&ob->defbase);
bool *lock_flags = MEM_mallocN(defbase_tot * sizeof(bool), "defflags");
bDeformGroup *defgroup;
@@ -595,7 +602,7 @@ bool *BKE_object_defgroup_validmap_get(Object *ob, const int defbase_tot)
bool *defgroup_validmap;
GHash *gh;
int i, step1 = 1;
- //int defbase_tot = BLI_listbase_count(&ob->defbase);
+ // int defbase_tot = BLI_listbase_count(&ob->defbase);
VirtualModifierData virtualModifierData;
if (BLI_listbase_is_empty(&ob->defbase)) {
@@ -615,8 +622,9 @@ bool *BKE_object_defgroup_validmap_get(Object *ob, const int defbase_tot)
for (md = ob->modifiers.first; md; md = !md->next && step1 ? (step1 = 0),
modifiers_getVirtualModifierList(ob, &virtualModifierData) :
md->next) {
- if (!(md->mode & (eModifierMode_Realtime | eModifierMode_Virtual)))
+ if (!(md->mode & (eModifierMode_Realtime | eModifierMode_Virtual))) {
continue;
+ }
if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData *)md;
@@ -627,8 +635,9 @@ bool *BKE_object_defgroup_validmap_get(Object *ob, const int defbase_tot)
for (chan = pose->chanbase.first; chan; chan = chan->next) {
void **val_p;
- if (chan->bone->flag & BONE_NO_DEFORM)
+ if (chan->bone->flag & BONE_NO_DEFORM) {
continue;
+ }
val_p = BLI_ghash_lookup_p(gh, chan->name);
if (val_p) {
@@ -684,7 +693,9 @@ bool *BKE_object_defgroup_selected_get(Object *ob, int defbase_tot, int *r_dg_fl
return dg_selection;
}
-/* Marks mirror vgroups in output and counts them. Output and counter assumed to be already initialized.
+/**
+ * Marks mirror vgroups in output and counts them.
+ * Output and counter assumed to be already initialized.
* Designed to be usable after BKE_object_defgroup_selected_get to extend selection to mirror.
*/
void BKE_object_defgroup_mirror_selection(struct Object *ob,
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 2544bb6a8f0..8080834a53a 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -66,9 +66,10 @@
typedef struct DupliContext {
Depsgraph *depsgraph;
- Collection
- *collection; /* XXX child objects are selected from this group if set, could be nicer */
- Object *obedit; /* Only to check if the object is in edit-mode. */
+ /** XXX child objects are selected from this group if set, could be nicer. */
+ Collection *collection;
+ /** Only to check if the object is in edit-mode. */
+ Object *obedit;
Scene *scene;
ViewLayer *view_layer;
@@ -80,7 +81,7 @@ typedef struct DupliContext {
const struct DupliGenerator *gen;
- /* result containers */
+ /** Result containers. */
ListBase *duplilist; /* legacy doubly-linked list */
} DupliContext;
@@ -102,10 +103,12 @@ static void init_context(
r_ctx->object = ob;
r_ctx->obedit = OBEDIT_FROM_OBACT(ob);
- if (space_mat)
+ if (space_mat) {
copy_m4_m4(r_ctx->space_mat, space_mat);
- else
+ }
+ else {
unit_m4(r_ctx->space_mat);
+ }
r_ctx->level = 0;
r_ctx->gen = get_dupli_generator(r_ctx);
@@ -119,13 +122,16 @@ static void copy_dupli_context(
{
*r_ctx = *ctx;
- /* XXX annoying, previously was done by passing an ID* argument, this at least is more explicit */
- if (ctx->gen->type == OB_DUPLICOLLECTION)
+ /* XXX annoying, previously was done by passing an ID* argument,
+ * this at least is more explicit. */
+ if (ctx->gen->type == OB_DUPLICOLLECTION) {
r_ctx->collection = ctx->object->instance_collection;
+ }
r_ctx->object = ob;
- if (mat)
+ if (mat) {
mul_m4_m4m4(r_ctx->space_mat, (float(*)[4])ctx->space_mat, mat);
+ }
r_ctx->persistent_id[r_ctx->level] = index;
++r_ctx->level;
@@ -158,17 +164,20 @@ static DupliObject *make_dupli(const DupliContext *ctx, Object *ob, float mat[4]
* dupli object between frames, which is needed for motion blur. last level
* goes first in the array. */
dob->persistent_id[0] = index;
- for (i = 1; i < ctx->level + 1; i++)
+ for (i = 1; i < ctx->level + 1; i++) {
dob->persistent_id[i] = ctx->persistent_id[ctx->level - i];
+ }
/* fill rest of values with INT_MAX which index will never have as value */
- for (; i < MAX_DUPLI_RECUR; i++)
+ for (; i < MAX_DUPLI_RECUR; i++) {
dob->persistent_id[i] = INT_MAX;
+ }
/* metaballs never draw in duplis, they are instead merged into one by the basis
* mball outside of the group. this does mean that if that mball is not in the
* scene, they will not show up at all, limitation that should be solved once. */
- if (ob->type == OB_MBALL)
+ if (ob->type == OB_MBALL) {
dob->no_draw = true;
+ }
/* random number */
/* the logic here is designed to match Cycles */
@@ -216,8 +225,9 @@ static bool is_child(const Object *ob, const Object *parent)
{
const Object *ob_parent = ob->parent;
while (ob_parent) {
- if (ob_parent == parent)
+ if (ob_parent == parent) {
return true;
+ }
ob_parent = ob_parent->parent;
}
return false;
@@ -256,8 +266,9 @@ static void make_child_duplis(const DupliContext *ctx,
copy_dupli_context(&pctx, ctx, ctx->object, NULL, baseid);
/* metaballs have a different dupli handling */
- if (ob->type != OB_MBALL)
+ if (ob->type != OB_MBALL) {
ob->flag |= OB_DONE; /* doesn't render */
+ }
make_child_duplis_cb(&pctx, userdata, ob);
}
@@ -274,8 +285,9 @@ static void make_duplis_collection(const DupliContext *ctx)
Collection *collection;
float collection_mat[4][4];
- if (ob->instance_collection == NULL)
+ if (ob->instance_collection == NULL) {
return;
+ }
collection = ob->instance_collection;
/* combine collection offset and obmat */
@@ -337,8 +349,9 @@ static void get_duplivert_transform(const float co[3],
nor_f[2] = (float)-no[2];
vec_to_quat(quat, nor_f, axis, upflag);
}
- else
+ else {
unit_qt(quat);
+ }
loc_quat_size_to_mat4(mat, co, quat, size);
}
@@ -366,8 +379,9 @@ static void vertex_dupli(const VertexDupliData *vdd,
dob = make_dupli(vdd->ctx, vdd->inst_ob, obmat, index);
- if (vdd->orco)
+ if (vdd->orco) {
copy_v3_v3(dob->orco, vdd->orco[index]);
+ }
/* recursion */
make_recursive_duplis(vdd->ctx, vdd->inst_ob, space_mat, index);
@@ -482,8 +496,9 @@ static void make_duplis_font(const DupliContext *ctx)
bool text_free = false;
/* font dupliverts not supported inside collections */
- if (ctx->collection)
+ if (ctx->collection) {
return;
+ }
copy_m4_m4(pmat, par->obmat);
@@ -511,7 +526,8 @@ static void make_duplis_font(const DupliContext *ctx)
for (a = 0; a < text_len; a++, ct++) {
/* XXX That G.main is *really* ugly, but not sure what to do here...
- * Definitively don't think it would be safe to put back Main *bmain pointer in DupliContext as done in 2.7x? */
+ * Definitively don't think it would be safe to put back Main *bmain pointer
+ * in DupliContext as done in 2.7x? */
ob = find_family_object(G.main, cu->family, family_len, (unsigned int)text[a], family_gh);
if (ob) {
vec[0] = fsize * (ct->xof - xof);
@@ -584,8 +600,9 @@ static void get_dupliface_transform(
float area = BKE_mesh_calc_poly_area(mpoly, mloop, mvert);
scale = sqrtf(area) * scale_fac;
}
- else
+ else {
scale = 1.0f;
+ }
size[0] = size[1] = size[2] = scale;
loc_quat_size_to_mat4(mat, loc, quat, size);
@@ -611,8 +628,9 @@ static void make_child_duplis_faces(const DupliContext *ctx, void *userdata, Obj
MLoop *loopstart = mloop + mp->loopstart;
float space_mat[4][4], obmat[4][4];
- if (UNLIKELY(mp->totloop < 3))
+ if (UNLIKELY(mp->totloop < 3)) {
continue;
+ }
/* obmat is transform to face */
get_dupliface_transform(
@@ -726,19 +744,23 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
int no_draw_flag = PARS_UNEXIST;
- if (psys == NULL)
+ if (psys == NULL) {
return;
+ }
part = psys->part;
- if (part == NULL)
+ if (part == NULL) {
return;
+ }
- if (!psys_check_enabled(par, psys, for_render))
+ if (!psys_check_enabled(par, psys, for_render)) {
return;
+ }
- if (!for_render)
+ if (!for_render) {
no_draw_flag |= PARS_NO_DISP;
+ }
ctime = DEG_get_ctime(
ctx->depsgraph); /* NOTE: in old animsys, used parent object's timeoffset... */
@@ -759,17 +781,20 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
/* first check for loops (particle system object used as dupli object) */
if (part->ren_as == PART_DRAW_OB) {
- if (ELEM(part->instance_object, NULL, par))
+ if (ELEM(part->instance_object, NULL, par)) {
return;
+ }
}
else { /*PART_DRAW_GR */
- if (part->instance_collection == NULL)
+ if (part->instance_collection == NULL) {
return;
+ }
const ListBase dup_collection_objects = BKE_collection_object_cache_get(
part->instance_collection);
- if (BLI_listbase_is_empty(&dup_collection_objects))
+ if (BLI_listbase_is_empty(&dup_collection_objects)) {
return;
+ }
if (BLI_findptr(&dup_collection_objects, par, offsetof(Base, object))) {
return;
@@ -778,10 +803,12 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
/* if we have a hair particle system, use the path cache */
if (part->type == PART_HAIR) {
- if (psys->flag & PSYS_HAIR_DONE)
+ if (psys->flag & PSYS_HAIR_DONE) {
hair = (totchild == 0 || psys->childcache) && psys->pathcache;
- if (!hair)
+ }
+ if (!hair) {
return;
+ }
/* we use cache, update totchild according to cached data */
totchild = psys->totchildcache;
@@ -850,16 +877,19 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
ob = part->instance_object;
}
- if (totchild == 0 || part->draw & PART_DRAW_PARENT)
+ if (totchild == 0 || part->draw & PART_DRAW_PARENT) {
a = 0;
- else
+ }
+ else {
a = totpart;
+ }
for (pa = psys->particles; a < totpart + totchild; a++, pa++) {
if (a < totpart) {
/* handle parent particle */
- if (pa->flag & no_draw_flag)
+ if (pa->flag & no_draw_flag) {
continue;
+ }
/* pa_num = pa->num; */ /* UNUSED */
size = pa->size;
@@ -881,14 +911,17 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
if (part->ren_as == PART_DRAW_GR) {
/* prevent divide by zero below [#28336] */
- if (totcollection == 0)
+ if (totcollection == 0) {
continue;
+ }
/* for collections, pick the object based on settings */
- if (part->draw & PART_DRAW_RAND_GR)
+ if (part->draw & PART_DRAW_RAND_GR) {
b = BLI_rng_get_int(rng) % totcollection;
- else
+ }
+ else {
b = a % totcollection;
+ }
ob = oblist[b];
}
@@ -957,7 +990,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
copy_v3_v3(vec, obmat[3]);
zero_v3(obmat[3]);
- /* particle rotation uses x-axis as the aligned axis, so pre-rotate the object accordingly */
+ /* Particle rotation uses x-axis as the aligned axis,
+ * so pre-rotate the object accordingly. */
if ((part->draw & PART_DRAW_ROTATE_OB) == 0) {
float xvec[3], q[4], size_mat[4][4], original_size[3];
@@ -971,8 +1005,9 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
obmat[3][3] = 1.0f;
/* add scaling if requested */
- if ((part->draw & PART_DRAW_NO_SCALE_OB) == 0)
+ if ((part->draw & PART_DRAW_NO_SCALE_OB) == 0) {
mul_m4_m4m4(obmat, obmat, size_mat);
+ }
}
else if (part->draw & PART_DRAW_NO_SCALE_OB) {
/* remove scaling */
@@ -990,8 +1025,9 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
copy_m4_m4(mat, tmat);
- if (part->draw & PART_DRAW_GLOBAL_OB)
+ if (part->draw & PART_DRAW_GLOBAL_OB) {
add_v3_v3v3(mat[3], mat[3], vec);
+ }
dob = make_dupli(ctx, ob, mat, a);
dob->particle_system = psys;
@@ -1003,8 +1039,9 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
}
/* clean up */
- if (oblist)
+ if (oblist) {
MEM_freeN(oblist);
+ }
if (psys->lattice_deform_data) {
end_latt_deform(psys->lattice_deform_data);
@@ -1039,13 +1076,15 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
int transflag = ctx->object->transflag;
int restrictflag = ctx->object->restrictflag;
- if ((transflag & OB_DUPLI) == 0)
+ if ((transflag & OB_DUPLI) == 0) {
return NULL;
+ }
/* Should the dupli's be generated for this object? - Respect restrict flags */
if (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER ? (restrictflag & OB_RESTRICT_RENDER) :
- (restrictflag & OB_RESTRICT_VIEW))
+ (restrictflag & OB_RESTRICT_VIEW)) {
return NULL;
+ }
if (transflag & OB_DUPLIPARTS) {
return &gen_dupli_particles;
@@ -1059,8 +1098,9 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx)
}
}
else if (transflag & OB_DUPLIFACES) {
- if (ctx->object->type == OB_MESH)
+ if (ctx->object->type == OB_MESH) {
return &gen_dupli_faces;
+ }
}
else if (transflag & OB_DUPLICOLLECTION) {
return &gen_dupli_collection;
diff --git a/source/blender/blenkernel/intern/object_facemap.c b/source/blender/blenkernel/intern/object_facemap.c
index 4548a6d6bd1..b3ebe9b5ffa 100644
--- a/source/blender/blenkernel/intern/object_facemap.c
+++ b/source/blender/blenkernel/intern/object_facemap.c
@@ -68,8 +68,9 @@ static bFaceMap *fmap_duplicate(bFaceMap *infmap)
{
bFaceMap *outfmap;
- if (!infmap)
+ if (!infmap) {
return NULL;
+ }
outfmap = MEM_callocN(sizeof(bFaceMap), "copy facemap");
@@ -109,8 +110,9 @@ bFaceMap *BKE_object_facemap_add_name(Object *ob, const char *name)
{
bFaceMap *fmap;
- if (!ob || ob->type != OB_MESH)
+ if (!ob || ob->type != OB_MESH) {
return NULL;
+ }
fmap = MEM_callocN(sizeof(bFaceMap), __func__);
@@ -151,10 +153,12 @@ static void object_fmap_remove_edit_mode(Object *ob, bFaceMap *fmap, bool do_sel
map = BM_ELEM_CD_GET_VOID_P(efa, cd_fmap_offset);
if (map) {
- if (*map == fmap_nr)
+ if (*map == fmap_nr) {
*map = -1;
- else if (*map > fmap_nr)
+ }
+ else if (*map > fmap_nr) {
*map -= 1;
+ }
}
}
}
@@ -170,8 +174,9 @@ static void object_fmap_remove_edit_mode(Object *ob, bFaceMap *fmap, bool do_sel
}
}
- if (ob->actfmap == BLI_listbase_count(&ob->fmaps))
+ if (ob->actfmap == BLI_listbase_count(&ob->fmaps)) {
ob->actfmap--;
+ }
BLI_remlink(&ob->fmaps, fmap);
MEM_freeN(fmap);
@@ -192,16 +197,19 @@ static void object_fmap_remove_object_mode(Object *ob, bFaceMap *fmap, bool purg
if (map) {
for (i = 0; i < me->totpoly; i++) {
- if (map[i] == fmap_nr)
+ if (map[i] == fmap_nr) {
map[i] = -1;
- else if (purge && map[i] > fmap_nr)
+ }
+ else if (purge && map[i] > fmap_nr) {
map[i]--;
+ }
}
}
}
- if (ob->actfmap == BLI_listbase_count(&ob->fmaps))
+ if (ob->actfmap == BLI_listbase_count(&ob->fmaps)) {
ob->actfmap--;
+ }
BLI_remlink(&ob->fmaps, fmap);
MEM_freeN(fmap);
@@ -210,10 +218,12 @@ static void object_fmap_remove_object_mode(Object *ob, bFaceMap *fmap, bool purg
static void fmap_remove_exec(Object *ob, bFaceMap *fmap, const bool is_edit_mode, const bool purge)
{
- if (is_edit_mode)
+ if (is_edit_mode) {
object_fmap_remove_edit_mode(ob, fmap, false, purge);
- else
+ }
+ else {
object_fmap_remove_object_mode(ob, fmap, purge);
+ }
}
void BKE_object_facemap_remove(Object *ob, bFaceMap *fmap)
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 75c0b0b3dc0..183bc968897 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -142,10 +142,12 @@ void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob)
* do not need to worry about relcalculating it. */
invert_m4_m4(ob->imat, ob->obmat);
/* Set negative scale flag in object. */
- if (is_negative_m4(ob->obmat))
+ if (is_negative_m4(ob->obmat)) {
ob->transflag |= OB_NEG_SCALE;
- else
+ }
+ else {
ob->transflag &= ~OB_NEG_SCALE;
+ }
}
void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *ob)
@@ -233,8 +235,9 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o
psys_free(ob, psys);
psys = tpsys;
}
- else
+ else {
psys = psys->next;
+ }
}
}
BKE_object_eval_boundbox(depsgraph, ob);
@@ -366,14 +369,6 @@ void BKE_object_eval_transform_all(Depsgraph *depsgraph, Scene *scene, Object *o
BKE_object_eval_transform_final(depsgraph, object);
}
-void BKE_object_eval_update_shading(Depsgraph *depsgraph, Object *object)
-{
- DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
- if (object->type == OB_MESH) {
- BKE_mesh_batch_cache_dirty_tag(object->data, BKE_MESH_BATCH_DIRTY_SHADING);
- }
-}
-
void BKE_object_data_select_update(Depsgraph *depsgraph, ID *object_data)
{
DEG_debug_print_eval(depsgraph, __func__, object_data->name, object_data);
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index f84048b502f..b5df7d5fe9b 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -116,7 +116,8 @@ typedef struct Ocean {
/* two dimensional arrays of float */
double *_disp_y; /* init w sim w via plan? */
double *_N_x; /* init w sim w via plan? */
- /* all member of this array has same values, so convert this array to a float to reduce memory usage (MEM01)*/
+ /* all member of this array has same values,
+ * so convert this array to a float to reduce memory usage (MEM01). */
/*float * _N_y; */
double _N_y; /* sim w ********* can be rearranged? */
double *_N_z; /* init w sim w via plan? */
@@ -148,9 +149,9 @@ static float nextfr(RNG *rng, float min, float max)
static float gaussRand(RNG *rng)
{
- /* Note: to avoid numerical problems with very small numbers, we make these variables singe-precision floats,
- * but later we call the double-precision log() and sqrt() functions instead of logf() and sqrtf().
- */
+ /* Note: to avoid numerical problems with very small numbers, we make these variables
+ * singe-precision floats, but later we call the double-precision log() and sqrt() functions
+ * instead of logf() and sqrtf(). */
float x;
float y;
float length2;
@@ -295,10 +296,12 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u, float
u = fmodf(u, 1.0f);
v = fmodf(v, 1.0f);
- if (u < 0)
+ if (u < 0) {
u += 1.0f;
- if (v < 0)
+ }
+ if (v < 0) {
v += 1.0f;
+ }
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
@@ -365,10 +368,12 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u
u = fmod(u, 1.0f);
v = fmod(v, 1.0f);
- if (u < 0)
+ if (u < 0) {
u += 1.0f;
- if (v < 0)
+ }
+ if (v < 0) {
v += 1.0f;
+ }
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
@@ -460,9 +465,8 @@ void BKE_ocean_eval_xz_catrom(struct Ocean *oc, struct OceanResult *ocr, float x
BKE_ocean_eval_uv_catrom(oc, ocr, x / oc->_Lx, z / oc->_Lz);
}
-/* note that this doesn't wrap properly for i, j < 0, but its not really meant for that being just a way to get
- * the raw data out to save in some image format.
- */
+/* note that this doesn't wrap properly for i, j < 0, but its not really meant for that being
+ * just a way to get the raw data out to save in some image format. */
void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i, int j)
{
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
@@ -515,7 +519,8 @@ static void ocean_compute_htilda(void *__restrict userdata,
int j;
- /* note the <= _N/2 here, see the fftw doco about the mechanics of the complex->real fft storage */
+ /* note the <= _N/2 here, see the fftw doco
+ * about the mechanics of the complex->real fft storage. */
for (j = 0; j <= o->_N / 2; ++j) {
fftw_complex exp_param1;
fftw_complex exp_param2;
@@ -766,11 +771,12 @@ void BKE_ocean_simulate(struct Ocean *o, float t, float scale, float chop_amount
BLI_rw_mutex_lock(&o->oceanmutex, THREAD_LOCK_WRITE);
- /* Note about multi-threading here: we have to run a first set of computations (htilda one) before we can run
- * all others, since they all depend on it.
- * So we make a first parallelized forloop run for htilda, and then pack all other computations into
- * a set of parallel tasks.
- * This is not optimal in all cases, but remains reasonably simple and should be OK most of the time. */
+ /* Note about multi-threading here: we have to run a first set of computations (htilda one)
+ * before we can run all others, since they all depend on it.
+ * So we make a first parallelized forloop run for htilda,
+ * and then pack all other computations into a set of parallel tasks.
+ * This is not optimal in all cases,
+ * but remains reasonably simple and should be OK most of the time. */
/* compute a new htilda */
ParallelRangeSettings settings;
@@ -813,8 +819,9 @@ static void set_height_normalize_factor(struct Ocean *oc)
int i, j;
- if (!oc->_do_disp_y)
+ if (!oc->_do_disp_y) {
return;
+ }
oc->normalize_factor = 1.0;
@@ -832,8 +839,9 @@ static void set_height_normalize_factor(struct Ocean *oc)
BLI_rw_mutex_unlock(&oc->oceanmutex);
- if (max_h == 0.0f)
+ if (max_h == 0.0f) {
max_h = 0.00001f; /* just in case ... */
+ }
res = 1.0f / (max_h);
@@ -942,32 +950,40 @@ void BKE_ocean_init(struct Ocean *o,
o->_kz = (float *)MEM_mallocN(o->_N * sizeof(float), "ocean_kz");
/* make this robust in the face of erroneous usage */
- if (o->_Lx == 0.0f)
+ if (o->_Lx == 0.0f) {
o->_Lx = 0.001f;
+ }
- if (o->_Lz == 0.0f)
+ if (o->_Lz == 0.0f) {
o->_Lz = 0.001f;
+ }
/* the +ve components and DC */
- for (i = 0; i <= o->_M / 2; ++i)
+ for (i = 0; i <= o->_M / 2; ++i) {
o->_kx[i] = 2.0f * (float)M_PI * i / o->_Lx;
+ }
/* the -ve components */
- for (i = o->_M - 1, ii = 0; i > o->_M / 2; --i, ++ii)
+ for (i = o->_M - 1, ii = 0; i > o->_M / 2; --i, ++ii) {
o->_kx[i] = -2.0f * (float)M_PI * ii / o->_Lx;
+ }
/* the +ve components and DC */
- for (i = 0; i <= o->_N / 2; ++i)
+ for (i = 0; i <= o->_N / 2; ++i) {
o->_kz[i] = 2.0f * (float)M_PI * i / o->_Lz;
+ }
/* the -ve components */
- for (i = o->_N - 1, ii = 0; i > o->_N / 2; --i, ++ii)
+ for (i = o->_N - 1, ii = 0; i > o->_N / 2; --i, ++ii) {
o->_kz[i] = -2.0f * (float)M_PI * ii / o->_Lz;
+ }
/* pre-calculate the k matrix */
- for (i = 0; i < o->_M; ++i)
- for (j = 0; j <= o->_N / 2; ++j)
+ for (i = 0; i < o->_M; ++i) {
+ for (j = 0; j <= o->_N / 2; ++j) {
o->_k[i * (1 + o->_N / 2) + j] = sqrt(o->_kx[i] * o->_kx[i] + o->_kz[j] * o->_kz[j]);
+ }
+ }
/*srand(seed);*/
rng = BLI_rng_new(seed);
@@ -1052,8 +1068,9 @@ void BKE_ocean_init(struct Ocean *o,
void BKE_ocean_free_data(struct Ocean *oc)
{
- if (!oc)
+ if (!oc) {
return;
+ }
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_WRITE);
@@ -1097,8 +1114,9 @@ void BKE_ocean_free_data(struct Ocean *oc)
BLI_thread_unlock(LOCK_FFTW);
- if (oc->_fft_in)
+ if (oc->_fft_in) {
MEM_freeN(oc->_fft_in);
+ }
/* check that ocean data has been initialized */
if (oc->_htilda) {
@@ -1115,8 +1133,9 @@ void BKE_ocean_free_data(struct Ocean *oc)
void BKE_ocean_free(struct Ocean *oc)
{
- if (!oc)
+ if (!oc) {
return;
+ }
BKE_ocean_free_data(oc);
BLI_rw_mutex_end(&oc->oceanmutex);
@@ -1177,8 +1196,9 @@ void BKE_ocean_free_cache(struct OceanCache *och)
{
int i, f = 0;
- if (!och)
+ if (!och) {
return;
+ }
if (och->ibufs_disp) {
for (i = och->start, f = 0; i <= och->end; i++, f++) {
@@ -1207,8 +1227,9 @@ void BKE_ocean_free_cache(struct OceanCache *och)
MEM_freeN(och->ibufs_norm);
}
- if (och->time)
+ if (och->time) {
MEM_freeN(och->time);
+ }
MEM_freeN(och);
}
@@ -1222,10 +1243,12 @@ void BKE_ocean_cache_eval_uv(
u = fmod(u, 1.0);
v = fmod(v, 1.0);
- if (u < 0)
+ if (u < 0) {
u += 1.0f;
- if (v < 0)
+ }
+ if (v < 0) {
v += 1.0f;
+ }
if (och->ibufs_disp[f]) {
ibuf_sample(och->ibufs_disp[f], u, v, (1.0f / (float)res_x), (1.0f / (float)res_y), result);
@@ -1248,10 +1271,12 @@ void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, in
const int res_x = och->resolution_x;
const int res_y = och->resolution_y;
- if (i < 0)
+ if (i < 0) {
i = -i;
- if (j < 0)
+ }
+ if (j < 0) {
j = -j;
+ }
i = i % res_x;
j = j % res_y;
@@ -1315,10 +1340,12 @@ void BKE_ocean_simulate_cache(struct OceanCache *och, int frame)
f = frame - och->start; /* shift to 0 based */
/* if image is already loaded in mem, return */
- if (och->ibufs_disp[f] != NULL)
+ if (och->ibufs_disp[f] != NULL) {
return;
+ }
- /* use default color spaces since we know for sure cache files were saved with default settings too */
+ /* Use default color spaces since we know for sure cache
+ * files were saved with default settings too. */
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE);
och->ibufs_disp[f] = IMB_loadiffname(string, 0, NULL);
@@ -1350,17 +1377,20 @@ void BKE_ocean_bake(struct Ocean *o,
int res_x = och->resolution_x;
int res_y = och->resolution_y;
char string[FILE_MAX];
- //RNG *rng;
+ // RNG *rng;
- if (!o)
+ if (!o) {
return;
+ }
- if (o->_do_jacobian)
+ if (o->_do_jacobian) {
prev_foam = MEM_callocN(res_x * res_y * sizeof(float), "previous frame foam bake data");
- else
+ }
+ else {
prev_foam = NULL;
+ }
- //rng = BLI_rng_new(0);
+ // rng = BLI_rng_new(0);
/* setup image format */
imf.imtype = R_IMF_IMTYPE_OPENEXR;
@@ -1402,9 +1432,9 @@ void BKE_ocean_bake(struct Ocean *o,
/* pr = pr * och->foam_fade; */ /* overall fade */
- /* remember ocean coord sys is Y up!
- * break up the foam where height (Y) is low (wave valley), and X and Z displacement is greatest
- */
+ /* Remember ocean coord sys is Y up!
+ * break up the foam where height (Y) is low (wave valley),
+ * and X and Z displacement is greatest. */
neg_disp = ocr.disp[1] < 0.0f ? 1.0f + ocr.disp[1] : 1.0f;
neg_disp = neg_disp < 0.0f ? 0.0f : neg_disp;
@@ -1413,8 +1443,9 @@ void BKE_ocean_bake(struct Ocean *o,
neg_eplus = ocr.Eplus[2] < 0.0f ? 1.0f + ocr.Eplus[2] : 1.0f;
neg_eplus = neg_eplus < 0.0f ? 0.0f : neg_eplus;
- if (pr < 1.0f)
+ if (pr < 1.0f) {
pr *= pr;
+ }
pr *= och->foam_fade * (0.75f + neg_eplus * 0.25f);
@@ -1436,19 +1467,22 @@ void BKE_ocean_bake(struct Ocean *o,
/* write the images */
cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE);
- if (0 == BKE_imbuf_write(ibuf_disp, string, &imf))
+ if (0 == BKE_imbuf_write(ibuf_disp, string, &imf)) {
printf("Cannot save Displacement File Output to %s\n", string);
+ }
if (o->_do_jacobian) {
cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM);
- if (0 == BKE_imbuf_write(ibuf_foam, string, &imf))
+ if (0 == BKE_imbuf_write(ibuf_foam, string, &imf)) {
printf("Cannot save Foam File Output to %s\n", string);
+ }
}
if (o->_do_normals) {
cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL);
- if (0 == BKE_imbuf_write(ibuf_normal, string, &imf))
+ if (0 == BKE_imbuf_write(ibuf_normal, string, &imf)) {
printf("Cannot save Normal File Output to %s\n", string);
+ }
}
IMB_freeImBuf(ibuf_disp);
@@ -1460,16 +1494,18 @@ void BKE_ocean_bake(struct Ocean *o,
update_cb(update_cb_data, progress, &cancel);
if (cancel) {
- if (prev_foam)
+ if (prev_foam) {
MEM_freeN(prev_foam);
- //BLI_rng_free(rng);
+ }
+ // BLI_rng_free(rng);
return;
}
}
- //BLI_rng_free(rng);
- if (prev_foam)
+ // BLI_rng_free(rng);
+ if (prev_foam) {
MEM_freeN(prev_foam);
+ }
och->baked = 1;
}
@@ -1563,8 +1599,9 @@ void BKE_ocean_free_data(struct Ocean *UNUSED(oc))
void BKE_ocean_free(struct Ocean *oc)
{
- if (!oc)
+ if (!oc) {
return;
+ }
MEM_freeN(oc);
}
@@ -1572,8 +1609,9 @@ void BKE_ocean_free(struct Ocean *oc)
void BKE_ocean_free_cache(struct OceanCache *och)
{
- if (!och)
+ if (!och) {
return;
+ }
MEM_freeN(och);
}
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index a1b315be19a..dd91878a15b 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -117,17 +117,23 @@ int countPackedFiles(Main *bmain)
int count = 0;
/* let's check if there are packed files... */
- for (ima = bmain->images.first; ima; ima = ima->id.next)
- if (BKE_image_has_packedfile(ima))
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ if (BKE_image_has_packedfile(ima)) {
count++;
+ }
+ }
- for (vf = bmain->fonts.first; vf; vf = vf->id.next)
- if (vf->packedfile)
+ for (vf = bmain->fonts.first; vf; vf = vf->id.next) {
+ if (vf->packedfile) {
count++;
+ }
+ }
- for (sound = bmain->sounds.first; sound; sound = sound->id.next)
- if (sound->packedfile)
+ for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
+ if (sound->packedfile) {
count++;
+ }
+ }
return count;
}
@@ -138,8 +144,9 @@ void freePackedFile(PackedFile *pf)
MEM_freeN(pf->data);
MEM_freeN(pf);
}
- else
+ else {
printf("freePackedFile: Trying to free a NULL pointer\n");
+ }
}
PackedFile *dupPackedFile(const PackedFile *pf_src)
@@ -170,10 +177,11 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
/* render result has no filename and can be ignored
* any other files with no name can be ignored too */
- if (filename[0] == '\0')
+ if (filename[0] == '\0') {
return NULL;
+ }
- //XXX waitcursor(1);
+ // XXX waitcursor(1);
/* convert relative filenames to absolute filenames */
@@ -208,7 +216,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
close(file);
}
- //XXX waitcursor(0);
+ // XXX waitcursor(0);
return (pf);
}
@@ -251,10 +259,12 @@ void packAll(Main *bmain, ReportList *reports, bool verbose)
}
}
- if (tot > 0)
+ if (tot > 0) {
BKE_reportf(reports, RPT_INFO, "Packed %d files", tot);
- else if (verbose)
+ }
+ else if (verbose) {
BKE_report(reports, RPT_INFO, "No new files have been packed");
+ }
}
int writePackedFile(ReportList *reports,
@@ -271,7 +281,7 @@ int writePackedFile(ReportList *reports,
/* void *data; */
if (guimode) {
- } //XXX waitcursor(1);
+ } // XXX waitcursor(1);
BLI_strncpy(name, filename, sizeof(name));
BLI_path_abs(name, ref_file_name);
@@ -326,7 +336,7 @@ int writePackedFile(ReportList *reports,
}
if (guimode) {
- } //XXX waitcursor(0);
+ } // XXX waitcursor(0);
return (ret_value);
}
@@ -397,7 +407,8 @@ int checkPackedFile(const char *ref_file_name, const char *filename, PackedFile
* It returns a char *to the existing file name / new file name or NULL when
* there was an error or when the user decides to cancel the operation.
*
- * \warning 'abs_name' may be relative still! (use a "//" prefix) be sure to run #BLI_path_abs on it first.
+ * \warning 'abs_name' may be relative still! (use a "//" prefix)
+ * be sure to run #BLI_path_abs on it first.
*/
char *unpackFile(ReportList *reports,
const char *ref_file_name,
@@ -650,18 +661,22 @@ void packLibraries(Main *bmain, ReportList *reports)
Library *lib;
/* test for relativenss */
- for (lib = bmain->libraries.first; lib; lib = lib->id.next)
- if (!BLI_path_is_rel(lib->name))
+ for (lib = bmain->libraries.first; lib; lib = lib->id.next) {
+ if (!BLI_path_is_rel(lib->name)) {
break;
+ }
+ }
if (lib) {
BKE_reportf(reports, RPT_ERROR, "Cannot pack absolute file: '%s'", lib->name);
return;
}
- for (lib = bmain->libraries.first; lib; lib = lib->id.next)
- if (lib->packedfile == NULL)
+ for (lib = bmain->libraries.first; lib; lib = lib->id.next) {
+ if (lib->packedfile == NULL) {
lib->packedfile = newPackedFile(reports, lib->name, BKE_main_blendfile_path(bmain));
+ }
+ }
}
void unpackAll(Main *bmain, ReportList *reports, int how)
@@ -670,17 +685,23 @@ void unpackAll(Main *bmain, ReportList *reports, int how)
VFont *vf;
bSound *sound;
- for (ima = bmain->images.first; ima; ima = ima->id.next)
- if (BKE_image_has_packedfile(ima))
+ for (ima = bmain->images.first; ima; ima = ima->id.next) {
+ if (BKE_image_has_packedfile(ima)) {
unpackImage(bmain, reports, ima, how);
+ }
+ }
- for (vf = bmain->fonts.first; vf; vf = vf->id.next)
- if (vf->packedfile)
+ for (vf = bmain->fonts.first; vf; vf = vf->id.next) {
+ if (vf->packedfile) {
unpackVFont(bmain, reports, vf, how);
+ }
+ }
- for (sound = bmain->sounds.first; sound; sound = sound->id.next)
- if (sound->packedfile)
+ for (sound = bmain->sounds.first; sound; sound = sound->id.next) {
+ if (sound->packedfile) {
unpackSound(bmain, reports, sound, how);
+ }
+ }
}
/* ID should be not NULL, return 1 if there's a packed file */
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 22586c674db..c55cf18fcea 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -84,13 +84,16 @@ void BKE_paint_invalidate_overlay_tex(Scene *scene, ViewLayer *view_layer, const
Paint *p = BKE_paint_get_active(scene, view_layer);
Brush *br = p->brush;
- if (!br)
+ if (!br) {
return;
+ }
- if (br->mtex.tex == tex)
+ if (br->mtex.tex == tex) {
overlay_flags |= PAINT_OVERLAY_INVALID_TEXTURE_PRIMARY;
- if (br->mask_mtex.tex == tex)
+ }
+ if (br->mask_mtex.tex == tex) {
overlay_flags |= PAINT_OVERLAY_INVALID_TEXTURE_SECONDARY;
+ }
}
void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, CurveMapping *curve)
@@ -98,8 +101,9 @@ void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, Cu
Paint *p = BKE_paint_get_active(scene, view_layer);
Brush *br = p->brush;
- if (br && br->curve == curve)
+ if (br && br->curve == curve) {
overlay_flags |= PAINT_OVERLAY_INVALID_CURVE;
+ }
}
void BKE_paint_invalidate_overlay_all(void)
@@ -116,12 +120,15 @@ eOverlayControlFlags BKE_paint_get_overlay_flags(void)
void BKE_paint_set_overlay_override(eOverlayFlags flags)
{
if (flags & BRUSH_OVERLAY_OVERRIDE_MASK) {
- if (flags & BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE)
+ if (flags & BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE) {
overlay_flags |= PAINT_OVERLAY_OVERRIDE_CURSOR;
- if (flags & BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE)
+ }
+ if (flags & BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE) {
overlay_flags |= PAINT_OVERLAY_OVERRIDE_PRIMARY;
- if (flags & BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE)
+ }
+ if (flags & BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE) {
overlay_flags |= PAINT_OVERLAY_OVERRIDE_SECONDARY;
+ }
}
else {
overlay_flags &= ~(PAINT_OVERRIDE_MASK);
@@ -133,6 +140,40 @@ void BKE_paint_reset_overlay_invalid(eOverlayControlFlags flag)
overlay_flags &= ~(flag);
}
+bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode)
+{
+ ToolSettings *ts = sce->toolsettings;
+ Paint **paint_ptr = NULL;
+
+ switch (mode) {
+ case PAINT_MODE_SCULPT:
+ paint_ptr = (Paint **)&ts->sculpt;
+ break;
+ case PAINT_MODE_VERTEX:
+ paint_ptr = (Paint **)&ts->vpaint;
+ break;
+ case PAINT_MODE_WEIGHT:
+ paint_ptr = (Paint **)&ts->wpaint;
+ break;
+ case PAINT_MODE_TEXTURE_2D:
+ case PAINT_MODE_TEXTURE_3D:
+ break;
+ case PAINT_MODE_SCULPT_UV:
+ paint_ptr = (Paint **)&ts->uvsculpt;
+ break;
+ case PAINT_MODE_GPENCIL:
+ paint_ptr = (Paint **)&ts->gp_paint;
+ break;
+ case PAINT_MODE_INVALID:
+ break;
+ }
+ if (paint_ptr && (*paint_ptr == NULL)) {
+ BKE_paint_ensure(ts, paint_ptr);
+ return true;
+ }
+ return false;
+}
+
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
{
if (sce) {
@@ -175,6 +216,7 @@ const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
case PAINT_MODE_TEXTURE_3D:
return rna_enum_brush_image_tool_items;
case PAINT_MODE_SCULPT_UV:
+ return rna_enum_brush_uv_sculpt_tool_items;
return NULL;
case PAINT_MODE_GPENCIL:
return rna_enum_brush_gpencil_types_items;
@@ -196,6 +238,8 @@ const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
case PAINT_MODE_TEXTURE_2D:
case PAINT_MODE_TEXTURE_3D:
return "image_tool";
+ case PAINT_MODE_SCULPT_UV:
+ return "uv_sculpt_tool";
case PAINT_MODE_GPENCIL:
return "gpencil_tool";
default:
@@ -222,9 +266,7 @@ Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
case OB_MODE_PAINT_GPENCIL:
return &ts->gp_paint->paint;
case OB_MODE_EDIT:
- if (ts->use_uv_sculpt)
- return &ts->uvsculpt->paint;
- return &ts->imapaint.paint;
+ return &ts->uvsculpt->paint;
default:
break;
}
@@ -247,15 +289,18 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
ToolSettings *ts = sce->toolsettings;
Object *obact = NULL;
- if (view_layer->basact && view_layer->basact->object)
+ if (view_layer->basact && view_layer->basact->object) {
obact = view_layer->basact->object;
+ }
if ((sima = CTX_wm_space_image(C)) != NULL) {
if (obact && obact->mode == OB_MODE_EDIT) {
- if (sima->mode == SI_MODE_PAINT)
+ if (sima->mode == SI_MODE_PAINT) {
return &ts->imapaint.paint;
- else if (ts->use_uv_sculpt)
+ }
+ else if (sima->mode == SI_MODE_UV) {
return &ts->uvsculpt->paint;
+ }
}
else {
return &ts->imapaint.paint;
@@ -276,18 +321,20 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
SpaceImage *sima;
if (sce && view_layer) {
- ToolSettings *ts = sce->toolsettings;
Object *obact = NULL;
- if (view_layer->basact && view_layer->basact->object)
+ if (view_layer->basact && view_layer->basact->object) {
obact = view_layer->basact->object;
+ }
if ((sima = CTX_wm_space_image(C)) != NULL) {
if (obact && obact->mode == OB_MODE_EDIT) {
- if (sima->mode == SI_MODE_PAINT)
+ if (sima->mode == SI_MODE_PAINT) {
return PAINT_MODE_TEXTURE_2D;
- else if (ts->use_uv_sculpt)
+ }
+ else if (sima->mode == SI_MODE_UV) {
return PAINT_MODE_SCULPT_UV;
+ }
}
else {
return PAINT_MODE_TEXTURE_2D;
@@ -304,9 +351,7 @@ ePaintMode BKE_paintmode_get_active_from_context(const bContext *C)
case OB_MODE_TEXTURE_PAINT:
return PAINT_MODE_TEXTURE_3D;
case OB_MODE_EDIT:
- if (ts->use_uv_sculpt)
- return PAINT_MODE_SCULPT_UV;
- return PAINT_MODE_TEXTURE_2D;
+ return PAINT_MODE_SCULPT_UV;
default:
return PAINT_MODE_TEXTURE_2D;
}
@@ -340,6 +385,8 @@ ePaintMode BKE_paintmode_get_from_tool(const struct bToolRef *tref)
switch (tref->mode) {
case SI_MODE_PAINT:
return PAINT_MODE_TEXTURE_2D;
+ case SI_MODE_UV:
+ return PAINT_MODE_SCULPT_UV;
}
}
@@ -380,15 +427,14 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
paint->runtime.tool_offset = offsetof(Brush, weightpaint_tool);
paint->runtime.ob_mode = OB_MODE_WEIGHT_PAINT;
}
+ else if (paint == &ts->uvsculpt->paint) {
+ paint->runtime.tool_offset = offsetof(Brush, uv_sculpt_tool);
+ paint->runtime.ob_mode = OB_MODE_EDIT;
+ }
else if (paint == &ts->gp_paint->paint) {
paint->runtime.tool_offset = offsetof(Brush, gpencil_tool);
paint->runtime.ob_mode = OB_MODE_PAINT_GPENCIL;
}
- else if (paint == &ts->uvsculpt->paint) {
- /* We don't use these yet. */
- paint->runtime.tool_offset = 0;
- paint->runtime.ob_mode = 0;
- }
else {
BLI_assert(0);
}
@@ -406,9 +452,10 @@ uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
return offsetof(Brush, vertexpaint_tool);
case PAINT_MODE_WEIGHT:
return offsetof(Brush, weightpaint_tool);
+ case PAINT_MODE_SCULPT_UV:
+ return offsetof(Brush, uv_sculpt_tool);
case PAINT_MODE_GPENCIL:
return offsetof(Brush, gpencil_tool);
- case PAINT_MODE_SCULPT_UV:
case PAINT_MODE_INVALID:
break; /* We don't use these yet. */
}
@@ -432,8 +479,10 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of PaintCurve ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of PaintCurve ID from source to
+ * already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -489,7 +538,7 @@ void BKE_paint_curve_clamp_endpoint_add_index(PaintCurve *pc, const int add_inde
pc->add_index = (add_index || pc->tot_points == 1) ? (add_index + 1) : 0;
}
-/* remove colour from palette. Must be certain color is inside the palette! */
+/** Remove color from palette. Must be certain color is inside the palette! */
void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
{
if (BLI_listbase_count_at_most(&palette->colors, palette->active_color) ==
@@ -519,8 +568,10 @@ Palette *BKE_palette_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Palette ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Palette ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -599,8 +650,9 @@ void BKE_paint_cavity_curve_preset(Paint *p, int preset)
{
CurveMap *cm = NULL;
- if (!p->cavity_curve)
+ if (!p->cavity_curve) {
p->cavity_curve = curvemapping_add(1, 0, 0, 1, 1);
+ }
cm = p->cavity_curve->cm;
cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
@@ -712,8 +764,9 @@ void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const char col[3])
ups->last_stroke_valid = false;
zero_v3(ups->average_stroke_accum);
ups->average_stroke_counter = 0;
- if (!paint->cavity_curve)
+ if (!paint->cavity_curve) {
BKE_paint_cavity_curve_preset(paint, CURVE_PRESET_LINE);
+ }
}
void BKE_paint_free(Paint *paint)
@@ -805,15 +858,19 @@ float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level, unsigned x
void paint_update_brush_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, float rotation)
{
- if (brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE)
+ if (brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) {
ups->brush_rotation = rotation;
- else
+ }
+ else {
ups->brush_rotation = 0.0f;
+ }
- if (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)
+ if (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE) {
ups->brush_rotation_sec = rotation;
- else
+ }
+ else {
ups->brush_rotation_sec = 0.0f;
+ }
}
bool paint_calculate_rake_rotation(UnifiedPaintSettings *ups,
@@ -899,8 +956,9 @@ static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
BM_ITER_MESH (efa, &iter, ss->bm, BM_FACES_OF_MESH) {
BM_elem_flag_set(efa, BM_ELEM_SMOOTH, ss->bm_smooth_shading);
}
- if (reorder)
+ if (reorder) {
BM_log_mesh_elems_reorder(ss->bm, ss->bm_log);
+ }
BM_mesh_bm_to_me(NULL,
ss->bm,
ob->data,
@@ -916,7 +974,8 @@ void BKE_sculptsession_bm_to_me(Object *ob, bool reorder)
if (ob && ob->sculpt) {
sculptsession_bm_to_me_update_data_only(ob, reorder);
- /* ensure the objects evaluated mesh doesn't hold onto arrays now realloc'd in the mesh [#34473] */
+ /* Ensure the objects evaluated mesh doesn't hold onto arrays
+ * now realloc'd in the mesh T34473. */
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
@@ -958,28 +1017,36 @@ void BKE_sculptsession_free(Object *ob)
BM_mesh_free(ss->bm);
}
- if (ss->pbvh)
+ if (ss->pbvh) {
BKE_pbvh_free(ss->pbvh);
+ }
MEM_SAFE_FREE(ss->pmap);
MEM_SAFE_FREE(ss->pmap_mem);
- if (ss->bm_log)
+ if (ss->bm_log) {
BM_log_free(ss->bm_log);
+ }
- if (ss->texcache)
+ if (ss->texcache) {
MEM_freeN(ss->texcache);
+ }
- if (ss->tex_pool)
+ if (ss->tex_pool) {
BKE_image_pool_free(ss->tex_pool);
+ }
- if (ss->layer_co)
+ if (ss->layer_co) {
MEM_freeN(ss->layer_co);
+ }
- if (ss->orig_cos)
+ if (ss->orig_cos) {
MEM_freeN(ss->orig_cos);
- if (ss->deform_cos)
+ }
+ if (ss->deform_cos) {
MEM_freeN(ss->deform_cos);
- if (ss->deform_imats)
+ }
+ if (ss->deform_imats) {
MEM_freeN(ss->deform_imats);
+ }
BKE_sculptsession_free_vwpaint_data(ob->sculpt);
@@ -1011,13 +1078,16 @@ MultiresModifierData *BKE_sculpt_multires_active(Scene *scene, Object *ob)
if (md->type == eModifierType_Multires) {
MultiresModifierData *mmd = (MultiresModifierData *)md;
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
continue;
+ }
- if (mmd->sculptlvl > 0)
+ if (mmd->sculptlvl > 0) {
return mmd;
- else
+ }
+ else {
return NULL;
+ }
}
}
@@ -1032,27 +1102,33 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob);
VirtualModifierData virtualModifierData;
- if (mmd || ob->sculpt->bm)
+ if (mmd || ob->sculpt->bm) {
return false;
+ }
/* non-locked shape keys could be handled in the same way as deformed mesh */
- if ((ob->shapeflag & OB_SHAPE_LOCK) == 0 && me->key && ob->shapenr)
+ if ((ob->shapeflag & OB_SHAPE_LOCK) == 0 && me->key && ob->shapenr) {
return true;
+ }
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
/* exception for shape keys because we can edit those */
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
continue;
- if (ELEM(md->type, eModifierType_ShapeKey, eModifierType_Multires))
+ }
+ if (ELEM(md->type, eModifierType_ShapeKey, eModifierType_Multires)) {
continue;
+ }
- if (mti->type == eModifierTypeType_OnlyDeform)
+ if (mti->type == eModifierTypeType_OnlyDeform) {
return true;
- else if ((sd->flags & SCULPT_ONLY_DEFORM) == 0)
+ }
+ else if ((sd->flags & SCULPT_ONLY_DEFORM) == 0) {
return true;
+ }
}
return false;
@@ -1095,7 +1171,10 @@ void BKE_sculpt_update_mesh_elements(
if (!CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
#if 1
BKE_sculpt_mask_layers_ensure(ob, mmd);
-#else /* if we wanted to support adding mask data while multi-res painting, we would need to do this */
+#else
+ /* If we wanted to support adding mask data while multi-res painting,
+ * we would need to do this. */
+
if ((ED_sculpt_mask_layers_ensure(ob, mmd) & ED_SCULPT_MASK_LAYER_CALC_LOOP)) {
/* remake the derived mesh */
ob->recalc |= ID_RECALC_GEOMETRY;
@@ -1340,8 +1419,15 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform)
BKE_mesh_recalc_looptri(me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, looptri);
- BKE_pbvh_build_mesh(
- pbvh, me->mpoly, me->mloop, me->mvert, me->totvert, &me->vdata, looptri, looptris_num);
+ BKE_pbvh_build_mesh(pbvh,
+ me->mpoly,
+ me->mloop,
+ me->mvert,
+ me->totvert,
+ &me->vdata,
+ &me->ldata,
+ looptri,
+ looptris_num);
pbvh_show_diffuse_color_set(pbvh, ob->sculpt->show_diffuse_color);
pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c
index 942d5e758f3..fbf586e3f49 100644
--- a/source/blender/blenkernel/intern/paint_toolslots.c
+++ b/source/blender/blenkernel/intern/paint_toolslots.c
@@ -70,6 +70,7 @@ void BKE_paint_toolslots_init_from_main(struct Main *bmain)
paint_toolslots_init(bmain, &ts->sculpt->paint);
paint_toolslots_init(bmain, &ts->vpaint->paint);
paint_toolslots_init(bmain, &ts->wpaint->paint);
+ paint_toolslots_init(bmain, &ts->uvsculpt->paint);
paint_toolslots_init(bmain, &ts->gp_paint->paint);
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 9e121d279ba..c6cc72ba989 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -129,8 +129,9 @@ int count_particles(ParticleSystem *psys)
}
else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) {
}
- else
+ else {
tot++;
+ }
}
return tot;
}
@@ -146,8 +147,9 @@ int count_particles_mod(ParticleSystem *psys, int totgr, int cur)
}
else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) {
}
- else if (p % totgr == cur)
+ else if (p % totgr == cur) {
tot++;
+ }
}
return tot;
}
@@ -176,8 +178,9 @@ static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot,
buf = MEM_callocN(sizeof(LinkData), "PathCacheLinkData");
buf->data = MEM_callocN(sizeof(ParticleCacheKey) * totbufkey * totkeys, "ParticleCacheKey");
- for (i = 0; i < totbufkey; i++)
+ for (i = 0; i < totbufkey; i++) {
cache[totkey + i] = ((ParticleCacheKey *)buf->data) + i * totkeys;
+ }
totkey += totbufkey;
BLI_addtail(bufs, buf);
@@ -190,11 +193,13 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf
{
LinkData *buf;
- if (cache)
+ if (cache) {
MEM_freeN(cache);
+ }
- for (buf = bufs->first; buf; buf = buf->next)
+ for (buf = bufs->first; buf; buf = buf->next) {
MEM_freeN(buf->data);
+ }
BLI_freelistN(bufs);
}
@@ -205,12 +210,14 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf
ParticleSystem *psys_get_current(Object *ob)
{
ParticleSystem *psys;
- if (ob == NULL)
+ if (ob == NULL) {
return NULL;
+ }
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
- if (psys->flag & PSYS_CURRENT)
+ if (psys->flag & PSYS_CURRENT) {
return psys;
+ }
}
return NULL;
@@ -220,12 +227,15 @@ short psys_get_current_num(Object *ob)
ParticleSystem *psys;
short i;
- if (ob == NULL)
+ if (ob == NULL) {
return 0;
+ }
- for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++)
- if (psys->flag & PSYS_CURRENT)
+ for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++) {
+ if (psys->flag & PSYS_CURRENT) {
return i;
+ }
+ }
return i;
}
@@ -234,14 +244,17 @@ void psys_set_current_num(Object *ob, int index)
ParticleSystem *psys;
short i;
- if (ob == NULL)
+ if (ob == NULL) {
return;
+ }
for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++) {
- if (i == index)
+ if (i == index) {
psys->flag |= PSYS_CURRENT;
- else
+ }
+ else {
psys->flag &= ~PSYS_CURRENT;
+ }
}
}
@@ -266,8 +279,9 @@ struct LatticeDeformData *psys_create_lattice_deform_data(ParticleSimulationData
break;
}
}
- if (lattice)
+ if (lattice) {
lattice_deform_data = init_latt_deform(lattice, NULL);
+ }
}
return lattice_deform_data;
@@ -276,15 +290,17 @@ void psys_disable_all(Object *ob)
{
ParticleSystem *psys = ob->particlesystem.first;
- for (; psys; psys = psys->next)
+ for (; psys; psys = psys->next) {
psys->flag |= PSYS_DISABLED;
+ }
}
void psys_enable_all(Object *ob)
{
ParticleSystem *psys = ob->particlesystem.first;
- for (; psys; psys = psys->next)
+ for (; psys; psys = psys->next) {
psys->flag &= ~PSYS_DISABLED;
+ }
}
ParticleSystem *psys_orig_get(ParticleSystem *psys)
@@ -339,26 +355,31 @@ bool psys_check_enabled(Object *ob, ParticleSystem *psys, const bool use_render_
{
ParticleSystemModifierData *psmd;
- if (psys->flag & PSYS_DISABLED || psys->flag & PSYS_DELETE || !psys->part)
+ if (psys->flag & PSYS_DISABLED || psys->flag & PSYS_DELETE || !psys->part) {
return 0;
+ }
psmd = psys_get_modifier(ob, psys);
if (use_render_params) {
- if (!(psmd->modifier.mode & eModifierMode_Render))
+ if (!(psmd->modifier.mode & eModifierMode_Render)) {
return 0;
+ }
}
- else if (!(psmd->modifier.mode & eModifierMode_Realtime))
+ else if (!(psmd->modifier.mode & eModifierMode_Realtime)) {
return 0;
+ }
return 1;
}
bool psys_check_edited(ParticleSystem *psys)
{
- if (psys->part && psys->part->type == PART_HAIR)
+ if (psys->part && psys->part->type == PART_HAIR) {
return (psys->flag & PSYS_EDITED || (psys->edit && psys->edit->edited));
- else
+ }
+ else {
return (psys->pointcache->edit && psys->pointcache->edit->edited);
+ }
}
void psys_find_group_weights(ParticleSettings *part)
@@ -435,8 +456,9 @@ void psys_check_group_weights(ParticleSettings *part)
if (!current) {
dw = part->instance_weights.first;
- if (dw)
+ if (dw) {
dw->flag |= PART_DUPLIW_CURRENT;
+ }
}
}
@@ -450,11 +472,14 @@ int psys_uses_gravity(ParticleSimulationData *sim)
/************************************************/
static void fluid_free_settings(SPHFluidSettings *fluid)
{
- if (fluid)
+ if (fluid) {
MEM_freeN(fluid);
+ }
}
-/** Free (or release) any data used by this particle settings (does not free the partsett itself). */
+/**
+ * Free (or release) any data used by this particle settings (does not free the partsett itself).
+ */
void BKE_particlesettings_free(ParticleSettings *part)
{
int a;
@@ -465,12 +490,15 @@ void BKE_particlesettings_free(ParticleSettings *part)
MEM_SAFE_FREE(part->mtex[a]);
}
- if (part->clumpcurve)
+ if (part->clumpcurve) {
curvemapping_free(part->clumpcurve);
- if (part->roughcurve)
+ }
+ if (part->roughcurve) {
curvemapping_free(part->roughcurve);
- if (part->twistcurve)
+ }
+ if (part->twistcurve) {
curvemapping_free(part->twistcurve);
+ }
BKE_partdeflect_free(part->pd);
BKE_partdeflect_free(part->pd2);
@@ -489,8 +517,9 @@ void free_hair(Object *object, ParticleSystem *psys, int dynamics)
LOOP_PARTICLES
{
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = NULL;
pa->totkey = 0;
}
@@ -510,20 +539,23 @@ void free_hair(Object *object, ParticleSystem *psys, int dynamics)
}
}
- if (psys->hair_in_mesh)
+ if (psys->hair_in_mesh) {
BKE_id_free(NULL, psys->hair_in_mesh);
+ }
psys->hair_in_mesh = NULL;
- if (psys->hair_out_mesh)
+ if (psys->hair_out_mesh) {
BKE_id_free(NULL, psys->hair_out_mesh);
+ }
psys->hair_out_mesh = NULL;
}
void free_keyed_keys(ParticleSystem *psys)
{
PARTICLE_P;
- if (psys->part->type == PART_HAIR)
+ if (psys->part->type == PART_HAIR) {
return;
+ }
if (psys->particles && psys->particles->keys) {
MEM_freeN(psys->particles->keys);
@@ -573,21 +605,25 @@ void psys_free_particles(ParticleSystem *psys)
PARTICLE_P;
if (psys->particles) {
- /* Even though psys->part should never be NULL, this can happen as an exception during deletion.
+ /* Even though psys->part should never be NULL,
+ * this can happen as an exception during deletion.
* See ID_REMAP_SKIP/FORCE/FLAG_NEVER_NULL_USAGE in BKE_library_remap. */
if (psys->part && psys->part->type == PART_HAIR) {
LOOP_PARTICLES
{
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
}
}
- if (psys->particles->keys)
+ if (psys->particles->keys) {
MEM_freeN(psys->particles->keys);
+ }
- if (psys->particles->boid)
+ if (psys->particles->boid) {
MEM_freeN(psys->particles->boid);
+ }
MEM_freeN(psys->particles);
psys->particles = NULL;
@@ -597,20 +633,24 @@ void psys_free_particles(ParticleSystem *psys)
void psys_free_pdd(ParticleSystem *psys)
{
if (psys->pdd) {
- if (psys->pdd->cdata)
+ if (psys->pdd->cdata) {
MEM_freeN(psys->pdd->cdata);
+ }
psys->pdd->cdata = NULL;
- if (psys->pdd->vdata)
+ if (psys->pdd->vdata) {
MEM_freeN(psys->pdd->vdata);
+ }
psys->pdd->vdata = NULL;
- if (psys->pdd->ndata)
+ if (psys->pdd->ndata) {
MEM_freeN(psys->pdd->ndata);
+ }
psys->pdd->ndata = NULL;
- if (psys->pdd->vedata)
+ if (psys->pdd->vedata) {
MEM_freeN(psys->pdd->vedata);
+ }
psys->pdd->vedata = NULL;
psys->pdd->totpoint = 0;
@@ -645,8 +685,9 @@ void psys_free(Object *ob, ParticleSystem *psys)
psys_free_particles(psys);
- if (psys->edit && psys->free_edit)
+ if (psys->edit && psys->free_edit) {
psys->free_edit(psys->edit);
+ }
if (psys->child) {
MEM_freeN(psys->child);
@@ -664,8 +705,9 @@ void psys_free(Object *ob, ParticleSystem *psys)
}
}
/* clear do-not-draw-flag */
- if (!nr)
+ if (!nr) {
ob->transflag &= ~OB_DUPLIPARTS;
+ }
psys->part = NULL;
@@ -679,8 +721,9 @@ void psys_free(Object *ob, ParticleSystem *psys)
BLI_bvhtree_free(psys->bvhtree);
BLI_kdtree_3d_free(psys->tree);
- if (psys->fluid_springs)
+ if (psys->fluid_springs) {
MEM_freeN(psys->fluid_springs);
+ }
BKE_effectors_free(psys->effectors);
@@ -749,8 +792,9 @@ static float interpolate_particle_value(
float value;
value = w[0] * v1 + w[1] * v2 + w[2] * v3;
- if (four)
+ if (four) {
value += w[3] * v4;
+ }
CLAMP(value, 0.f, 1.f);
@@ -805,8 +849,12 @@ typedef struct ParticleInterpolationData {
float birthtime, dietime;
int bspline;
} ParticleInterpolationData;
-/* Assumes pointcache->mem_cache exists, so for disk cached particles call psys_make_temp_pointcache() before use */
-/* It uses ParticleInterpolationData->pm to store the current memory cache frame so it's thread safe. */
+/**
+ * Assumes pointcache->mem_cache exists, so for disk cached particles
+ * call #psys_make_temp_pointcache() before use.
+ * It uses #ParticleInterpolationData.pm to store the current memory cache frame
+ * so it's thread safe.
+ */
static void get_pointcache_keys_for_time(Object *UNUSED(ob),
PointCache *cache,
PTCacheMem **cur,
@@ -821,13 +869,15 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob),
if (index < 0) { /* initialize */
*cur = cache->mem_cache.first;
- if (*cur)
+ if (*cur) {
*cur = (*cur)->next;
+ }
}
else {
if (*cur) {
- while (*cur && (*cur)->next && (float)(*cur)->frame < t)
+ while (*cur && (*cur)->next && (float)(*cur)->frame < t) {
*cur = (*cur)->next;
+ }
pm = *cur;
@@ -838,10 +888,12 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob),
}
BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame);
- if (index1 < 0)
+ if (index1 < 0) {
copy_particle_key(key1, key2, 1);
- else
+ }
+ else {
BKE_ptcache_make_particle_key(key1, index1, pm->prev->data, (float)pm->prev->frame);
+ }
}
else if (cache->mem_cache.first) {
pm = cache->mem_cache.first;
@@ -887,8 +939,9 @@ float psys_get_dietime_from_cache(PointCache *cache, int index)
int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */
for (pm = cache->mem_cache.last; pm; pm = pm->prev) {
- if (BKE_ptcache_mem_index_find(pm, index) >= 0)
+ if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
return (float)pm->frame;
+ }
}
return (float)dietime;
@@ -979,14 +1032,17 @@ static void do_particle_interpolation(ParticleSystem *psys,
/* interpret timing and find keys */
if (point) {
- if (result->time < 0.0f)
+ if (result->time < 0.0f) {
real_t = -result->time;
- else
+ }
+ else {
real_t = *(pind->ekey[0]->time) +
t * (*(pind->ekey[0][point->totkey - 1].time) - *(pind->ekey[0]->time));
+ }
- while (*(pind->ekey[1]->time) < real_t)
+ while (*(pind->ekey[1]->time) < real_t) {
pind->ekey[1]++;
+ }
pind->ekey[0] = pind->ekey[1] - 1;
}
@@ -997,49 +1053,59 @@ static void do_particle_interpolation(ParticleSystem *psys,
return;
}
- if (result->time < 0.0f)
+ if (result->time < 0.0f) {
real_t = -result->time;
- else
+ }
+ else {
real_t = pind->kkey[0]->time +
t * (pind->kkey[0][pa->totkey - 1].time - pind->kkey[0]->time);
+ }
if (psys->part->phystype == PART_PHYS_KEYED && psys->flag & PSYS_KEYED_TIMING) {
ParticleTarget *pt = psys->targets.first;
pt = pt->next;
- while (pt && pa->time + pt->time < real_t)
+ while (pt && pa->time + pt->time < real_t) {
pt = pt->next;
+ }
if (pt) {
pt = pt->prev;
- if (pa->time + pt->time + pt->duration > real_t)
+ if (pa->time + pt->time + pt->duration > real_t) {
real_t = pa->time + pt->time;
+ }
}
- else
+ else {
real_t = pa->time + ((ParticleTarget *)psys->targets.last)->time;
+ }
}
CLAMP(real_t, pa->time, pa->dietime);
- while (pind->kkey[1]->time < real_t)
+ while (pind->kkey[1]->time < real_t) {
pind->kkey[1]++;
+ }
pind->kkey[0] = pind->kkey[1] - 1;
}
else if (pind->cache) {
- if (result->time < 0.0f) /* flag for time in frames */
+ if (result->time < 0.0f) { /* flag for time in frames */
real_t = -result->time;
- else
+ }
+ else {
real_t = pa->time + t * (pa->dietime - pa->time);
+ }
}
else {
- if (result->time < 0.0f)
+ if (result->time < 0.0f) {
real_t = -result->time;
- else
+ }
+ else {
real_t = pind->hkey[0]->time +
t * (pind->hkey[0][pa->totkey - 1].time - pind->hkey[0]->time);
+ }
while (pind->hkey[1]->time < real_t) {
pind->hkey[1]++;
@@ -1074,41 +1140,53 @@ static void do_particle_interpolation(ParticleSystem *psys,
/* set secondary interpolation keys for hair */
if (!pind->keyed && !pind->cache && !point_vel) {
if (point) {
- if (pind->ekey[0] != point->keys)
+ if (pind->ekey[0] != point->keys) {
edit_to_particle(keys, pind->ekey[0] - 1);
- else
+ }
+ else {
edit_to_particle(keys, pind->ekey[0]);
+ }
}
else if (pind->mesh) {
- if (pind->hkey[0] != pa->hair)
+ if (pind->hkey[0] != pa->hair) {
mvert_to_particle(keys, pind->mvert[0] - 1, pind->hkey[0] - 1);
- else
+ }
+ else {
mvert_to_particle(keys, pind->mvert[0], pind->hkey[0]);
+ }
}
else {
- if (pind->hkey[0] != pa->hair)
+ if (pind->hkey[0] != pa->hair) {
hair_to_particle(keys, pind->hkey[0] - 1);
- else
+ }
+ else {
hair_to_particle(keys, pind->hkey[0]);
+ }
}
if (point) {
- if (pind->ekey[1] != point->keys + point->totkey - 1)
+ if (pind->ekey[1] != point->keys + point->totkey - 1) {
edit_to_particle(keys + 3, pind->ekey[1] + 1);
- else
+ }
+ else {
edit_to_particle(keys + 3, pind->ekey[1]);
+ }
}
else if (pind->mesh) {
- if (pind->hkey[1] != pa->hair + pa->totkey - 1)
+ if (pind->hkey[1] != pa->hair + pa->totkey - 1) {
mvert_to_particle(keys + 3, pind->mvert[1] + 1, pind->hkey[1] + 1);
- else
+ }
+ else {
mvert_to_particle(keys + 3, pind->mvert[1], pind->hkey[1]);
+ }
}
else {
- if (pind->hkey[1] != pa->hair + pa->totkey - 1)
+ if (pind->hkey[1] != pa->hair + pa->totkey - 1) {
hair_to_particle(keys + 3, pind->hkey[1] + 1);
- else
+ }
+ else {
hair_to_particle(keys + 3, pind->hkey[1]);
+ }
}
}
@@ -1123,7 +1201,8 @@ static void do_particle_interpolation(ParticleSystem *psys,
interp_qt_qtqt(result->rot, keys[1].rot, keys[2].rot, keytime);
}
- /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0, 1]->[k2, k3] (k1 & k4 used for cardinal & bspline interpolation)*/
+ /* Now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between
+ * [0, 1]->[k2, k3] (k1 & k4 used for cardinal & bspline interpolation). */
psys_interpolate_particle((pind->keyed || pind->cache || point_vel) ?
-1 /* signal for cubic interpolation */
:
@@ -1134,8 +1213,9 @@ static void do_particle_interpolation(ParticleSystem *psys,
1);
/* the velocity needs to be converted back from cubic interpolation */
- if (pind->keyed || pind->cache || point_vel)
+ if (pind->keyed || pind->cache || point_vel) {
mul_v3_fl(result->vel, 1.f / invdt);
+ }
}
static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCacheKey *result)
@@ -1146,11 +1226,13 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach
/* scale the requested time to fit the entire path even if the path is cut early */
t *= (first + first->segments)->time;
- while (i < first->segments && cur->time < t)
+ while (i < first->segments && cur->time < t) {
cur++;
+ }
- if (cur->time == t)
+ if (cur->time == t) {
*result = *cur;
+ }
else {
float dt = (t - (cur - 1)->time) / (cur->time - (cur - 1)->time);
interp_v3_v3v3(result->co, (cur - 1)->co, cur->co, dt);
@@ -1160,10 +1242,12 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach
}
/* first is actual base rotation, others are incremental from first */
- if (cur == first || cur - 1 == first)
+ if (cur == first || cur - 1 == first) {
copy_qt_qt(result->rot, first->rot);
- else
+ }
+ else {
mul_qt_qtqt(result->rot, first->rot, result->rot);
+ }
}
/************************************************/
@@ -1203,20 +1287,24 @@ void psys_interpolate_face(MVert *mvert,
interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w);
if (nor) {
- if (mface->flag & ME_SMOOTH)
+ if (mface->flag & ME_SMOOTH) {
interp_v3_v3v3v3v3(nor, n1, n2, n3, n4, w);
- else
+ }
+ else {
normal_quad_v3(nor, v1, v2, v3, v4);
+ }
}
}
else {
interp_v3_v3v3v3(vec, v1, v2, v3, w);
if (nor) {
- if (mface->flag & ME_SMOOTH)
+ if (mface->flag & ME_SMOOTH) {
interp_v3_v3v3v3(nor, n1, n2, n3, w);
- else
+ }
+ else {
normal_tri_v3(nor, v1, v2, v3);
+ }
}
}
@@ -1236,8 +1324,9 @@ void psys_interpolate_face(MVert *mvert,
map_to_sphere(uv1, uv1 + 1, v1[0], v1[1], v1[2]);
map_to_sphere(uv2, uv2 + 1, v2[0], v2[1], v2[2]);
map_to_sphere(uv3, uv3 + 1, v3[0], v3[1], v3[2]);
- if (v4)
+ if (v4) {
map_to_sphere(uv4, uv4 + 1, v4[0], v4[1], v4[2]);
+ }
}
if (v4) {
@@ -1342,8 +1431,9 @@ void psys_interpolate_mcol(const MCol *mcol, int quad, const float w[4], MCol *m
static float psys_interpolate_value_from_verts(
Mesh *mesh, short from, int index, const float fw[4], const float *values)
{
- if (values == 0 || index == -1)
+ if (values == 0 || index == -1) {
return 0.0;
+ }
switch (from) {
case PART_FROM_VERT:
@@ -1456,7 +1546,7 @@ int psys_particle_dm_face_lookup(Mesh *mesh_final,
if (osface_final == NULL) {
/* Assume we don't need osface_final data, and we get a direct 1-1 mapping... */
if (findex_orig < totface_final) {
- //printf("\tNO CD_ORIGSPACE, assuming not needed\n");
+ // printf("\tNO CD_ORIGSPACE, assuming not needed\n");
return findex_orig;
}
else {
@@ -1492,7 +1582,8 @@ int psys_particle_dm_face_lookup(Mesh *mesh_final,
}
else { /* if we have no node, try every face */
for (int findex_dst = 0; findex_dst < totface_final; findex_dst++) {
- /* If current tessface from 'final' DM and orig tessface (given by index) map to the same orig poly... */
+ /* If current tessface from 'final' DM and orig tessface (given by index)
+ * map to the same orig poly. */
if (BKE_mesh_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, findex_dst) ==
pindex_orig) {
faceuv = osface_final[findex_dst].uv;
@@ -1523,21 +1614,24 @@ static int psys_map_index_on_dm(Mesh *mesh,
int *mapindex,
float mapfw[4])
{
- if (index < 0)
+ if (index < 0) {
return 0;
+ }
if (mesh->runtime.deformed_only || index_dmcache == DMCACHE_ISCHILD) {
/* for meshes that are either only deformed or for child particles, the
* index and fw do not require any mapping, so we can directly use it */
if (from == PART_FROM_VERT) {
- if (index >= mesh->totvert)
+ if (index >= mesh->totvert) {
return 0;
+ }
*mapindex = index;
}
else { /* FROM_FACE/FROM_VOLUME */
- if (index >= mesh->totface)
+ if (index >= mesh->totface) {
return 0;
+ }
*mapindex = index;
copy_v4_v4(mapfw, fw);
@@ -1548,8 +1642,9 @@ static int psys_map_index_on_dm(Mesh *mesh,
* to their new location, which means a different index, and for faces
* also a new face interpolation weights */
if (from == PART_FROM_VERT) {
- if (index_dmcache == DMCACHE_NOTFOUND || index_dmcache > mesh->totvert)
+ if (index_dmcache == DMCACHE_NOTFOUND || index_dmcache > mesh->totvert) {
return 0;
+ }
*mapindex = index_dmcache;
}
@@ -1561,8 +1656,9 @@ static int psys_map_index_on_dm(Mesh *mesh,
i = index_dmcache;
- if (i == DMCACHE_NOTFOUND || i >= mesh->totface)
+ if (i == DMCACHE_NOTFOUND || i >= mesh->totface) {
return 0;
+ }
*mapindex = i;
@@ -1571,10 +1667,12 @@ static int psys_map_index_on_dm(Mesh *mesh,
osface = CustomData_get_layer(&mesh->fdata, CD_ORIGSPACE);
mface = &mesh->mface[i];
- if (osface == NULL)
+ if (osface == NULL) {
mapfw[0] = mapfw[1] = mapfw[2] = mapfw[3] = 0.0f;
- else
+ }
+ else {
psys_origspace_to_w(&osface[i], mface->v4, fw, mapfw);
+ }
}
}
@@ -1653,21 +1751,24 @@ void psys_particle_on_dm(Mesh *mesh_final,
mvert = mesh_final->mvert;
mtface = mesh_final->mtface;
- if (mtface)
+ if (mtface) {
mtface += mapindex;
+ }
if (from == PART_FROM_VOLUME) {
psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, tmpnor, utan, vtan, orco);
- if (nor)
+ if (nor) {
copy_v3_v3(nor, tmpnor);
+ }
normalize_v3(
tmpnor); /* XXX Why not normalize tmpnor before copying it into nor??? -- mont29 */
mul_v3_fl(tmpnor, -foffset);
add_v3_v3(vec, tmpnor);
}
- else
+ else {
psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, nor, utan, vtan, orco);
+ }
}
}
@@ -1677,8 +1778,9 @@ float psys_particle_value_from_verts(Mesh *mesh, short from, ParticleData *pa, f
int mapindex;
if (!psys_map_index_on_dm(
- mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, &mapindex, mapfw))
+ mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, &mapindex, mapfw)) {
return 0.0f;
+ }
return psys_interpolate_value_from_verts(mesh, from, mapindex, mapfw, values);
}
@@ -1738,17 +1840,20 @@ void psys_emitter_customdata_mask(ParticleSystem *psys, CustomData_MeshMasks *r_
MTex *mtex;
int i;
- if (!psys->part)
+ if (!psys->part) {
return;
+ }
for (i = 0; i < MAX_MTEX; i++) {
mtex = psys->part->mtex[i];
- if (mtex && mtex->mapto && (mtex->texco & TEXCO_UV))
+ if (mtex && mtex->mapto && (mtex->texco & TEXCO_UV)) {
r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
}
- if (psys->part->tanfac != 0.0f)
+ if (psys->part->tanfac != 0.0f) {
r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
/* ask for vertexgroups if we need them */
for (i = 0; i < PSYS_TOT_VG; i++) {
@@ -1783,19 +1888,22 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd,
{
if (psmd && psmd->mesh_final) {
if (psmd->psys->part->distr == PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) {
- if (vec)
+ if (vec) {
copy_v3_v3(vec, fuv);
+ }
- if (orco)
+ if (orco) {
copy_v3_v3(orco, fuv);
+ }
return;
}
/* we cant use the num_dmcache */
psys_particle_on_dm(
psmd->mesh_final, from, index, index_dmcache, fuv, foffset, vec, nor, utan, vtan, orco);
}
- else
+ else {
psys_particle_on_shape(from, index, fuv, vec, nor, utan, vtan, orco);
+ }
}
/************************************************/
/* Path Cache */
@@ -1812,8 +1920,9 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
GuideEffectorData *data;
PARTICLE_P;
- if (!effectors)
+ if (!effectors) {
return;
+ }
LOOP_PARTICLES
{
@@ -1835,12 +1944,14 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
pd_point_from_particle(sim, pa, &state, &point);
for (eff = effectors->first; eff; eff = eff->next) {
- if (eff->pd->forcefield != PFIELD_GUIDE)
+ if (eff->pd->forcefield != PFIELD_GUIDE) {
continue;
+ }
- if (!eff->guide_data)
+ if (!eff->guide_data) {
eff->guide_data = MEM_callocN(sizeof(GuideEffectorData) * psys->totpart,
"GuideEffectorData");
+ }
data = eff->guide_data + p;
@@ -1875,34 +1986,39 @@ int do_guides(Depsgraph *depsgraph,
float guidetime, radius, weight, angle, totstrength = 0.0f;
float vec_to_point[3];
- if (effectors)
+ if (effectors) {
for (eff = effectors->first; eff; eff = eff->next) {
pd = eff->pd;
- if (pd->forcefield != PFIELD_GUIDE)
+ if (pd->forcefield != PFIELD_GUIDE) {
continue;
+ }
data = eff->guide_data + index;
- if (data->strength <= 0.0f)
+ if (data->strength <= 0.0f) {
continue;
+ }
guidetime = time / (1.0f - pd->free_end);
- if (guidetime > 1.0f)
+ if (guidetime > 1.0f) {
continue;
+ }
cu = (Curve *)eff->ob->data;
if (pd->flag & PFIELD_GUIDE_PATH_ADD) {
if (where_on_path(
eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight) ==
- 0)
+ 0) {
return 0;
+ }
}
else {
- if (where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight) == 0)
+ if (where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight) == 0) {
return 0;
+ }
}
mul_m4_v3(eff->ob->obmat, guidevec);
@@ -1926,24 +2042,26 @@ int do_guides(Depsgraph *depsgraph,
}
/* curve taper */
- if (cu->taperobj)
+ if (cu->taperobj) {
mul_v3_fl(vec_to_point,
BKE_displist_calc_taper(depsgraph,
eff->scene,
cu->taperobj,
(int)(data->strength * guidetime * 100.0f),
100));
-
+ }
else { /* curve size*/
if (cu->flag & CU_PATH_RADIUS) {
mul_v3_fl(vec_to_point, radius);
}
}
- if (clumpcurve)
+ if (clumpcurve) {
curvemapping_changed_all(clumpcurve);
- if (roughcurve)
+ }
+ if (roughcurve) {
curvemapping_changed_all(roughcurve);
+ }
{
ParticleKey key;
@@ -1981,20 +2099,23 @@ int do_guides(Depsgraph *depsgraph,
add_v3_v3(vec_to_point, guidevec);
- //sub_v3_v3v3(pa_loc, pa_loc, pa_zero);
+ // sub_v3_v3v3(pa_loc, pa_loc, pa_zero);
madd_v3_v3fl(effect, vec_to_point, data->strength);
madd_v3_v3fl(veffect, guidedir, data->strength);
totstrength += data->strength;
- if (pd->flag & PFIELD_GUIDE_PATH_WEIGHT)
+ if (pd->flag & PFIELD_GUIDE_PATH_WEIGHT) {
totstrength *= weight;
+ }
}
+ }
if (totstrength != 0.0f) {
- if (totstrength > 1.0f)
+ if (totstrength > 1.0f) {
mul_v3_fl(effect, 1.0f / totstrength);
+ }
CLAMP(totstrength, 0.0f, 1.0f);
- //add_v3_v3(effect, pa_zero);
+ // add_v3_v3(effect, pa_zero);
interp_v3_v3v3(state->co, state->co, effect, totstrength);
normalize_v3(veffect);
@@ -2022,8 +2143,9 @@ static void do_path_effectors(ParticleSimulationData *sim,
EffectedPoint epoint;
/* Don't apply effectors for dynamic hair, otherwise the effectors don't get applied twice. */
- if (sim->psys->flag & PSYS_HAIR_DYNAMICS)
+ if (sim->psys->flag & PSYS_HAIR_DYNAMICS) {
return;
+ }
copy_v3_v3(eff_key.co, (ca - 1)->co);
copy_v3_v3(eff_key.vel, (ca - 1)->vel);
@@ -2045,13 +2167,15 @@ static void do_path_effectors(ParticleSimulationData *sim,
normalize_v3(force);
- if (k < steps)
+ if (k < steps) {
sub_v3_v3v3(vec, (ca + 1)->co, ca->co);
+ }
madd_v3_v3v3fl(ca->co, (ca - 1)->co, force, *length);
- if (k < steps)
+ if (k < steps) {
*length = len_v3(vec);
+ }
}
static void offset_child(ChildParticle *cpa,
ParticleKey *par,
@@ -2071,8 +2195,9 @@ static void offset_child(ChildParticle *cpa,
mul_qt_v3(par_rot, child->co);
copy_qt_qt(child->rot, par_rot);
}
- else
+ else {
unit_qt(child->rot);
+ }
add_v3_v3(child->co, par->co);
}
@@ -2089,12 +2214,14 @@ float *psys_cache_vgroup(Mesh *mesh, ParticleSystem *psys, int vgroup)
int totvert = mesh->totvert, i;
vg = MEM_callocN(sizeof(float) * totvert, "vg_cache");
if (psys->vg_neg & (1 << vgroup)) {
- for (i = 0; i < totvert; i++)
+ for (i = 0; i < totvert; i++) {
vg[i] = 1.0f - defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1);
+ }
}
else {
- for (i = 0; i < totvert; i++)
+ for (i = 0; i < totvert; i++) {
vg[i] = defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1);
+ }
}
}
}
@@ -2112,8 +2239,9 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
int from = PART_FROM_FACE;
totparent = (int)(totchild * part->parents * 0.3f);
- if (use_render_params && part->child_nbr && part->ren_child_nbr)
+ if (use_render_params && part->child_nbr && part->ren_child_nbr) {
totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
+ }
/* hard limit, workaround for it being ignored above */
if (sim->psys->totpart < totparent) {
@@ -2126,7 +2254,8 @@ void psys_find_parents(ParticleSimulationData *sim, const bool use_render_params
psys_particle_on_emitter(
sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco);
- /* Check if particle doesn't exist because of texture influence. Insert only existing particles into kdtree. */
+ /* Check if particle doesn't exist because of texture influence.
+ * Insert only existing particles into kdtree. */
get_cpa_texture(sim->psmd->mesh_final,
psys,
part,
@@ -2175,8 +2304,9 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx,
ParticleEditSettings *pset = &scene->toolsettings->particle;
if ((use_render_params == 0) &&
- (psys_orig_edit_get(psys) == NULL || pset->flag & PE_DRAW_PART) == 0)
+ (psys_orig_edit_get(psys) == NULL || pset->flag & PE_DRAW_PART) == 0) {
totchild = 0;
+ }
segments = 1 << pset->draw_step;
}
@@ -2184,30 +2314,35 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx,
if (totchild && part->childtype == PART_CHILD_FACES) {
totparent = (int)(totchild * part->parents * 0.3f);
- if (use_render_params && part->child_nbr && part->ren_child_nbr)
+ if (use_render_params && part->child_nbr && part->ren_child_nbr) {
totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
+ }
/* part->parents could still be 0 so we can't test with totparent */
between = 1;
}
- if (use_render_params)
+ if (use_render_params) {
segments = 1 << part->ren_step;
+ }
else {
totchild = (int)((float)totchild * (float)part->disp / 100.0f);
totparent = MIN2(totparent, totchild);
}
- if (totchild == 0)
+ if (totchild == 0) {
return false;
+ }
/* fill context values */
ctx->between = between;
ctx->segments = segments;
- if (ELEM(part->kink, PART_KINK_SPIRAL))
+ if (ELEM(part->kink, PART_KINK_SPIRAL)) {
ctx->extra_segments = max_ii(part->kink_extra_steps, 1);
- else
+ }
+ else {
ctx->extra_segments = 0;
+ }
ctx->totchild = totchild;
ctx->totparent = totparent;
ctx->parent_pass = 0;
@@ -2224,8 +2359,9 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx,
ctx->vg_rough2 = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_ROUGH2);
ctx->vg_roughe = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_ROUGHE);
ctx->vg_twist = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_TWIST);
- if (psys->part->flag & PART_CHILD_EFFECT)
+ if (psys->part->flag & PART_CHILD_EFFECT) {
ctx->vg_effector = psys_cache_vgroup(ctx->mesh, psys, PSYS_VG_EFFECTOR);
+ }
/* prepare curvemapping tables */
if ((part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && part->clumpcurve) {
@@ -2284,8 +2420,9 @@ static void psys_thread_create_path(ParticleTask *task,
int k, cpa_num;
short cpa_from;
- if (!pcache)
+ if (!pcache) {
return;
+ }
if (ctx->between) {
ParticleData *pa = psys->particles + cpa->pa[0];
@@ -2308,10 +2445,12 @@ static void psys_thread_create_path(ParticleTask *task,
w++;
}
- if (!needupdate)
+ if (!needupdate) {
return;
- else
+ }
+ else {
memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1));
+ }
}
/* get parent paths */
@@ -2334,7 +2473,8 @@ static void psys_thread_create_path(ParticleTask *task,
const ParticleCacheKey *key_w_last = pcache_key_segment_endpoint_safe(key[w]);
float d;
if (part->flag & PART_CHILD_LONG_HAIR) {
- /* For long hair use tip distance/root distance as parting factor instead of root to tip angle. */
+ /* For long hair use tip distance/root distance as parting
+ * factor instead of root to tip angle. */
float d1 = len_v3v3(key[0]->co, key[w]->co);
float d2 = len_v3v3(key_0_last->co, key_w_last->co);
@@ -2350,20 +2490,24 @@ static void psys_thread_create_path(ParticleTask *task,
d = RAD2DEGF(saacos(dot_v3v3(v1, v2)));
}
- if (p_max > p_min)
+ if (p_max > p_min) {
d = (d - p_min) / (p_max - p_min);
- else
+ }
+ else {
d = (d - p_min) <= 0.f ? 0.f : 1.f;
+ }
CLAMP(d, 0.f, 1.f);
- if (d > 0.f)
+ if (d > 0.f) {
weight[w] *= (1.f - d);
+ }
}
wsum += weight[w];
}
- for (w = 0; w < 4; w++)
+ for (w = 0; w < 4; w++) {
weight[w] /= wsum;
+ }
interp_v4_v4v4(weight, cpa->w, weight, p_fac);
}
@@ -2380,8 +2524,9 @@ static void psys_thread_create_path(ParticleTask *task,
mul_m4_v3(ob->obmat, co);
- for (w = 0; w < 4; w++)
+ for (w = 0; w < 4; w++) {
sub_v3_v3v3(off1[w], co, key[w]->co);
+ }
psys_mat_hair_to_global(ob, ctx->sim.psmd->mesh_final, psys->part->from, pa, hairmat);
}
@@ -2389,8 +2534,9 @@ static void psys_thread_create_path(ParticleTask *task,
ParticleData *pa = psys->particles + cpa->parent;
float co[3];
if (ctx->editupdate) {
- if (!(edit->points[cpa->parent].flag & PEP_EDIT_RECALC))
+ if (!(edit->points[cpa->parent].flag & PEP_EDIT_RECALC)) {
return;
+ }
memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1));
}
@@ -2413,8 +2559,9 @@ static void psys_thread_create_path(ParticleTask *task,
pa->num_dmcache;
/* XXX hack to avoid messed up particle num and subsequent crash (#40733) */
- if (cpa_num > ctx->sim.psmd->mesh_final->totface)
+ if (cpa_num > ctx->sim.psmd->mesh_final->totface) {
cpa_num = 0;
+ }
cpa_fuv = pa->fuv;
psys_particle_on_emitter(ctx->sim.psmd,
@@ -2456,8 +2603,9 @@ static void psys_thread_create_path(ParticleTask *task,
if (part->flag & PART_CHILD_LONG_HAIR) {
/* Use parent rotation (in addition to emission location) to determine child offset. */
- if (k)
+ if (k) {
mul_qt_v3((key[w] + k)->rot, off2[w]);
+ }
/* Fade the effect of rotation for even lengths in the end */
project_v3_v3v3(dvec, off2[w], (key[w] + k)->vel);
@@ -2539,7 +2687,8 @@ static void psys_thread_create_path(ParticleTask *task,
pa = &psys->particles[cpa->parent];
par = pcache[cpa->parent];
- /* If particle is unexisting, try to pick a viable parent from particles used for interpolation. */
+ /* If particle is unexisting, try to pick a viable parent from particles
+ * used for interpolation. */
for (k = 0; k < 4 && pa && (pa->flag & PARS_UNEXIST); k++) {
if (cpa->pa[k] >= 0) {
pa = &psys->particles[cpa->pa[k]];
@@ -2547,8 +2696,9 @@ static void psys_thread_create_path(ParticleTask *task,
}
}
- if (pa->flag & PARS_UNEXIST)
+ if (pa->flag & PARS_UNEXIST) {
pa = NULL;
+ }
}
if (pa) {
@@ -2570,13 +2720,15 @@ static void psys_thread_create_path(ParticleTask *task,
psys_apply_child_modifiers(
ctx, &modifiers, cpa, &ptex, orco, hairmat, child_keys, par, par_orco);
}
- else
+ else {
zero_v3(par_orco);
+ }
}
/* Hide virtual parents */
- if (i < ctx->totparent)
+ if (i < ctx->totparent) {
child_keys->segments = -1;
+ }
}
static void exec_child_path_cache(TaskPool *__restrict UNUSED(pool),
@@ -2609,12 +2761,14 @@ void psys_cache_child_paths(ParticleSimulationData *sim,
int numtasks_parent, numtasks_child;
int i, totchild, totparent;
- if (sim->psys->flag & PSYS_GLOBAL_HAIR)
+ if (sim->psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
/* create a task pool for child path tasks */
- if (!psys_thread_context_init_path(&ctx, sim, sim->scene, cfra, editupdate, use_render_params))
+ if (!psys_thread_context_init_path(&ctx, sim, sim->scene, cfra, editupdate, use_render_params)) {
return;
+ }
task_scheduler = BLI_task_scheduler_get();
task_pool = BLI_task_pool_create(task_scheduler, &ctx);
@@ -2744,12 +2898,15 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
int keyed, baked;
/* we don't have anything valid to create paths from so let's quit here */
- if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache) == 0)
+ if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache) == 0) {
return;
+ }
- if (psys_in_edit_mode(sim->depsgraph, psys))
- if ((psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0)
+ if (psys_in_edit_mode(sim->depsgraph, psys)) {
+ if ((psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) {
return;
+ }
+ }
keyed = psys->flag & PSYS_KEYED;
baked = psys->pointcache->mem_cache.first && psys->part->type != PART_HAIR;
@@ -2761,15 +2918,18 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
psys->lattice_deform_data = psys_create_lattice_deform_data(sim);
ma = give_current_material(sim->ob, psys->part->omat);
- if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT))
+ if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT)) {
copy_v3_v3(col, &ma->r);
+ }
if ((psys->flag & PSYS_GLOBAL_HAIR) == 0) {
- if ((psys->part->flag & PART_CHILD_EFFECT) == 0)
+ if ((psys->part->flag & PART_CHILD_EFFECT) == 0) {
vg_effector = psys_cache_vgroup(psmd->mesh_final, psys, PSYS_VG_EFFECTOR);
+ }
- if (!psys->totchild)
+ if (!psys->totchild) {
vg_length = psys_cache_vgroup(psmd->mesh_final, psys, PSYS_VG_LENGTH);
+ }
}
/* ensure we have tessfaces to be used for mapping */
@@ -2783,8 +2943,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if (!psys->totchild) {
psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.f);
pa_length = ptex.length * (1.0f - part->randlength * psys_frand(psys, psys->seed + p));
- if (vg_length)
+ if (vg_length) {
pa_length *= psys_particle_value_from_verts(psmd->mesh_final, part->from, pa, vg_length);
+ }
}
pind.keyed = keyed;
@@ -2833,10 +2994,12 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
/* dynamic hair is in object space */
/* keyed and baked are already in global space */
- if (hair_mesh)
+ if (hair_mesh) {
mul_m4_v3(sim->ob->obmat, ca->co);
- else if (!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR))
+ }
+ else if (!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) {
mul_m4_v3(hairmat, ca->co);
+ }
copy_v3_v3(ca->col, col);
}
@@ -2855,21 +3018,23 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
/* apply effectors */
if ((psys->part->flag & PART_CHILD_EFFECT) == 0) {
float effector = 1.0f;
- if (vg_effector)
+ if (vg_effector) {
effector *= psys_particle_value_from_verts(
psmd->mesh_final, psys->part->from, pa, vg_effector);
+ }
sub_v3_v3v3(vec, (cache[p] + 1)->co, cache[p]->co);
length = len_v3(vec);
- for (k = 1, ca = cache[p] + 1; k <= segments; k++, ca++)
+ for (k = 1, ca = cache[p] + 1; k <= segments; k++, ca++) {
do_path_effectors(
sim, p, ca, k, segments, cache[p]->co, effector, dfra, cfra, &length, vec);
+ }
}
/* apply guide curves to path data */
if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT) == 0) {
- for (k = 0, ca = cache[p]; k <= segments; k++, ca++)
+ for (k = 0, ca = cache[p]; k <= segments; k++, ca++) {
/* ca is safe to cast, since only co and vel are used */
do_guides(sim->depsgraph,
sim->psys->part,
@@ -2877,12 +3042,14 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
(ParticleKey *)ca,
p,
(float)k / (float)segments);
+ }
}
/* lattices have to be calculated separately to avoid mixups between effector calculations */
if (psys->lattice_deform_data) {
- for (k = 0, ca = cache[p]; k <= segments; k++, ca++)
+ for (k = 0, ca = cache[p]; k <= segments; k++, ca++) {
calc_latt_deform(psys->lattice_deform_data, ca->co, psys->lattice_strength);
+ }
}
}
@@ -2890,14 +3057,16 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
for (k = 1, ca = cache[p] + 1; k <= segments; k++, ca++) {
cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k);
- if (k == segments)
+ if (k == segments) {
copy_qt_qt(ca->rot, (ca - 1)->rot);
+ }
/* set velocity */
sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co);
- if (k == 1)
+ if (k == 1) {
copy_v3_v3((ca - 1)->vel, ca->vel);
+ }
ca->time = (float)k / (float)segments;
}
@@ -2918,11 +3087,13 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
psys->lattice_deform_data = NULL;
}
- if (vg_effector)
+ if (vg_effector) {
MEM_freeN(vg_effector);
+ }
- if (vg_length)
+ if (vg_length) {
MEM_freeN(vg_length);
+ }
}
typedef struct CacheEditrPathsIterData {
@@ -3017,14 +3188,16 @@ static void psys_cache_edit_paths_iter(void *__restrict iter_data_v,
if (k) {
cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k);
- if (k == segments)
+ if (k == segments) {
copy_qt_qt(ca->rot, (ca - 1)->rot);
+ }
/* set velocity */
sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co);
- if (k == 1)
+ if (k == 1) {
copy_v3_v3((ca - 1)->vel, ca->vel);
+ }
}
}
else {
@@ -3143,7 +3316,7 @@ void psys_cache_edit_paths(Depsgraph *depsgraph,
iter_data.use_weight = use_weight;
if (use_weight) {
- ; /* use weight painting colors now... */
+ /* use weight painting colors now... */
}
else {
iter_data.sel_col[0] = (float)edit->sel_col[0] / 255.0f;
@@ -3197,14 +3370,18 @@ void copy_particle_key(ParticleKey *to, ParticleKey *from, int time)
}
void psys_get_from_key(ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time)
{
- if (loc)
+ if (loc) {
copy_v3_v3(loc, key->co);
- if (vel)
+ }
+ if (vel) {
copy_v3_v3(vel, key->vel);
- if (rot)
+ }
+ if (rot) {
copy_qt_qt(rot, key->rot);
- if (time)
+ }
+ if (time) {
*time = key->time;
+ }
}
static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat[4][4])
@@ -3236,8 +3413,9 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat
mat[1][2] = w1 * (v2[2] - v1[2]) + w2 * (v3[2] - v1[2]);
normalize_v3(mat[1]);
}
- else
+ else {
mat[1][0] = mat[1][1] = mat[1][2] = 0.0f;
+ }
}
else {
sub_v3_v3v3(mat[1], v2, v1);
@@ -3271,8 +3449,9 @@ static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4]
/* ugly hack to use non-transformed orcos, since only those
* give symmetric results for mirroring in particle mode */
- if (CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))
+ if (CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX)) {
BKE_mesh_orco_verts_transform(ob->data, v, 3, 1);
+ }
}
else {
copy_v3_v3(v[0], mesh->mvert[mface->v1].co);
@@ -3309,8 +3488,9 @@ void psys_mat_hair_to_orco(
mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, orco);
/* see psys_face_mat for why this function is called */
- if (CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))
+ if (CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX)) {
BKE_mesh_orco_verts_transform(ob->data, &orco, 1, 1);
+ }
copy_v3_v3(hairmat[3], orco);
}
@@ -3342,16 +3522,18 @@ ModifierData *object_add_particle_system(Main *bmain, Scene *scene, Object *ob,
ModifierData *md;
ParticleSystemModifierData *psmd;
- if (!ob || ob->type != OB_MESH)
+ if (!ob || ob->type != OB_MESH) {
return NULL;
+ }
if (name == NULL) {
name = DATA_("ParticleSettings");
}
psys = ob->particlesystem.first;
- for (; psys; psys = psys->next)
+ for (; psys; psys = psys->next) {
psys->flag &= ~PSYS_CURRENT;
+ }
psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
@@ -3383,22 +3565,27 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
ParticleSystemModifierData *psmd;
ModifierData *md;
- if (!psys)
+ if (!psys) {
return;
+ }
/* clear all other appearances of this pointer (like on smoke flow modifier) */
if ((md = modifiers_findByType(ob, eModifierType_Smoke))) {
SmokeModifierData *smd = (SmokeModifierData *)md;
- if ((smd->type == MOD_SMOKE_TYPE_FLOW) && smd->flow && smd->flow->psys)
- if (smd->flow->psys == psys)
+ if ((smd->type == MOD_SMOKE_TYPE_FLOW) && smd->flow && smd->flow->psys) {
+ if (smd->flow->psys == psys) {
smd->flow->psys = NULL;
+ }
+ }
}
if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint))) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- if (pmd->brush && pmd->brush->psys)
- if (pmd->brush->psys == psys)
+ if (pmd->brush && pmd->brush->psys) {
+ if (pmd->brush->psys == psys) {
pmd->brush->psys = NULL;
+ }
+ }
}
/* clear modifier */
@@ -3413,10 +3600,12 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
}
psys_free(ob, psys);
- if (ob->particlesystem.first)
+ if (ob->particlesystem.first) {
((ParticleSystem *)ob->particlesystem.first)->flag |= PSYS_CURRENT;
- else
+ }
+ else {
ob->mode &= ~OB_MODE_PARTICLE_EDIT;
+ }
DEG_relations_tag_update(bmain);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -3495,8 +3684,9 @@ static void default_particle_settings(ParticleSettings *part)
part->color_vec_max = 1.f;
part->draw_col = PART_DRAW_COL_MAT;
- if (!part->effector_weights)
+ if (!part->effector_weights) {
part->effector_weights = BKE_effector_add_weights(NULL);
+ }
part->omat = 1;
part->use_modifier_stack = false;
@@ -3563,8 +3753,10 @@ void BKE_particlesettings_twist_curve_init(ParticleSettings *part)
}
/**
- * Only copy internal data of ParticleSettings ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of ParticleSettings ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -3631,11 +3823,13 @@ static int get_particle_uv(Mesh *mesh,
tf = CustomData_get_layer_named(&mesh->fdata, CD_MTFACE, name);
- if (tf == NULL)
+ if (tf == NULL) {
tf = mesh->mtface;
+ }
- if (tf == NULL)
+ if (tf == NULL) {
return 0;
+ }
if (pa) {
i = ELEM(pa->num_dmcache, DMCACHE_NOTFOUND, DMCACHE_ISCHILD) ? pa->num : pa->num_dmcache;
@@ -3739,8 +3933,9 @@ static void get_cpa_texture(Mesh *mesh,
if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) &&
(ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 ||
- part->distr == PART_DISTR_GRID))
+ part->distr == PART_DISTR_GRID)) {
texco = TEXCO_GLOB;
+ }
switch (texco) {
case TEXCO_GLOB:
@@ -3748,8 +3943,9 @@ static void get_cpa_texture(Mesh *mesh,
break;
case TEXCO_OBJECT:
copy_v3_v3(texvec, par->state.co);
- if (mtex->object)
+ if (mtex->object) {
mul_m4_v3(mtex->object->imat, texvec);
+ }
break;
case TEXCO_UV:
if (fw && get_particle_uv(mesh,
@@ -3776,9 +3972,10 @@ static void get_cpa_texture(Mesh *mesh,
externtex(mtex, texvec, &value, rgba, rgba + 1, rgba + 2, rgba + 3, 0, NULL, false, false);
- if ((event & mtex->mapto) & PAMAP_ROUGH)
+ if ((event & mtex->mapto) & PAMAP_ROUGH) {
ptex->rough1 = ptex->rough2 = ptex->roughe = texture_value_blend(
def, ptex->rough1, value, mtex->roughfac, blend);
+ }
SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac);
SET_PARTICLE_TEXTURE(PAMAP_CLUMP, ptex->clump, mtex->clumpfac);
@@ -3824,8 +4021,9 @@ void psys_get_texture(
short texco = mtex->texco;
if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 ||
- part->distr == PART_DISTR_GRID))
+ part->distr == PART_DISTR_GRID)) {
texco = TEXCO_GLOB;
+ }
switch (texco) {
case TEXCO_GLOB:
@@ -3833,8 +4031,9 @@ void psys_get_texture(
break;
case TEXCO_OBJECT:
copy_v3_v3(texvec, pa->state.co);
- if (mtex->object)
+ if (mtex->object) {
mul_m4_v3(mtex->object->imat, texvec);
+ }
break;
case TEXCO_UV:
if (get_particle_uv(sim->psmd->mesh_final,
@@ -3865,20 +4064,25 @@ void psys_get_texture(
BKE_mesh_texspace_calc(me);
}
sub_v3_v3(texvec, me->loc);
- if (me->size[0] != 0.0f)
+ if (me->size[0] != 0.0f) {
texvec[0] /= me->size[0];
- if (me->size[1] != 0.0f)
+ }
+ if (me->size[1] != 0.0f) {
texvec[1] /= me->size[1];
- if (me->size[2] != 0.0f)
+ }
+ if (me->size[2] != 0.0f) {
texvec[2] /= me->size[2];
+ }
break;
case TEXCO_PARTICLE:
/* texture coordinates in range [-1, 1] */
texvec[0] = 2.f * (cfra - pa->time) / (pa->dietime - pa->time) - 1.f;
- if (sim->psys->totpart > 0)
+ if (sim->psys->totpart > 0) {
texvec[1] = 2.f * (float)(pa - sim->psys->particles) / (float)sim->psys->totpart - 1.f;
- else
+ }
+ else {
texvec[1] = 0.0f;
+ }
texvec[2] = 0.f;
break;
}
@@ -3894,8 +4098,9 @@ void psys_get_texture(
ptex->time += timefac * ((flip) ? 1.0f - value : value);
setvars |= MAP_PA_TIME;
}
- else
+ else {
ptex->time = texture_value_blend(def, ptex->time, value, mtex->timefac, blend);
+ }
}
SET_PARTICLE_TEXTURE(PAMAP_LIFE, ptex->life, mtex->lifefac);
SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac);
@@ -3949,10 +4154,12 @@ float psys_get_child_time(
life = pa->lifetime;
}
- if (birthtime)
+ if (birthtime) {
*birthtime = time;
- if (dietime)
+ }
+ if (dietime) {
*dietime = time + life;
+ }
return (cfra - time) / life;
}
@@ -3978,8 +4185,9 @@ float psys_get_child_size(ParticleSystem *psys,
size *= part->childsize;
- if (part->childrandsize != 0.0f)
+ if (part->childrandsize != 0.0f) {
size *= 1.0f - part->childrandsize * psys_frand(psys, cpa - psys->child + 26);
+ }
return size;
}
@@ -4007,33 +4215,42 @@ static void get_child_modifier_parameters(ParticleSettings *part,
PAMAP_DENS | PAMAP_CHILD,
psys->cfra);
- if (ptex->exist < psys_frand(psys, i + 24))
+ if (ptex->exist < psys_frand(psys, i + 24)) {
return;
+ }
- if (ctx->vg_length)
+ if (ctx->vg_length) {
ptex->length *= psys_interpolate_value_from_verts(
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_length);
- if (ctx->vg_clump)
+ }
+ if (ctx->vg_clump) {
ptex->clump *= psys_interpolate_value_from_verts(
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_clump);
- if (ctx->vg_kink)
+ }
+ if (ctx->vg_kink) {
ptex->kink_freq *= psys_interpolate_value_from_verts(
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_kink);
- if (ctx->vg_rough1)
+ }
+ if (ctx->vg_rough1) {
ptex->rough1 *= psys_interpolate_value_from_verts(
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough1);
- if (ctx->vg_rough2)
+ }
+ if (ctx->vg_rough2) {
ptex->rough2 *= psys_interpolate_value_from_verts(
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough2);
- if (ctx->vg_roughe)
+ }
+ if (ctx->vg_roughe) {
ptex->roughe *= psys_interpolate_value_from_verts(
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_roughe);
- if (ctx->vg_effector)
+ }
+ if (ctx->vg_effector) {
ptex->effector *= psys_interpolate_value_from_verts(
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_effector);
- if (ctx->vg_twist)
+ }
+ if (ctx->vg_twist) {
ptex->twist *= psys_interpolate_value_from_verts(
ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_twist);
+ }
}
/* get's hair (or keyed) particles state at the "path time" specified in state->time */
void psys_get_particle_on_path(ParticleSimulationData *sim,
@@ -4113,14 +4330,15 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
/* TODO: proper velocity handling */
}
- if (psys->lattice_deform_data && edit == 0)
+ if (psys->lattice_deform_data && edit == 0) {
calc_latt_deform(psys->lattice_deform_data, state->co, psys->lattice_strength);
+ }
}
}
}
}
else if (totchild) {
- //invert_m4_m4(imat, ob->obmat);
+ // invert_m4_m4(imat, ob->obmat);
/* interpolate childcache directly if it exists */
if (psys->childcache) {
@@ -4135,8 +4353,9 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
cpa = psys->child + p - totpart;
- if (state->time < 0.0f)
+ if (state->time < 0.0f) {
t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL);
+ }
if (totchild && part->childtype == PART_CHILD_FACES) {
/* part->parents could still be 0 so we can't test with totparent */
@@ -4163,10 +4382,11 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
psys_particle_on_emitter(
psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, 0, 0, 0, orco);
- /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
- //copy_v3_v3(cpa_1st, co);
+ /* We need to save the actual root position of the child for
+ * positioning it accurately to the surface of the emitter. */
+ // copy_v3_v3(cpa_1st, co);
- //mul_m4_v3(ob->obmat, cpa_1st);
+ // mul_m4_v3(ob->obmat, cpa_1st);
pa = psys->particles + cpa->parent;
@@ -4181,10 +4401,12 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
0,
0,
par_orco);
- if (part->type == PART_HAIR)
+ if (part->type == PART_HAIR) {
psys_mat_hair_to_global(sim->ob, sim->psmd->mesh_final, psys->part->from, pa, hairmat);
- else
+ }
+ else {
unit_m4(hairmat);
+ }
pa = 0;
}
@@ -4248,7 +4470,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
w++;
}
/* apply offset for correct positioning */
- //add_v3_v3(state->co, cpa_1st);
+ // add_v3_v3(state->co, cpa_1st);
}
else {
/* offset the child from the parent position */
@@ -4257,8 +4479,9 @@ void psys_get_particle_on_path(ParticleSimulationData *sim,
par = keys;
- if (vel)
+ if (vel) {
copy_particle_key(&tstate, state, 1);
+ }
/* apply different deformations to the child path */
ParticleChildModifierContext modifier_ctx = {NULL};
@@ -4312,12 +4535,14 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
cfra = state->time > 0 ? state->time : DEG_get_ctime(sim->depsgraph);
if (p >= totpart) {
- if (!psys->totchild)
+ if (!psys->totchild) {
return 0;
+ }
if (part->childtype == PART_CHILD_FACES) {
- if (!(psys->flag & PSYS_KEYED))
+ if (!(psys->flag & PSYS_KEYED)) {
return 0;
+ }
cpa = psys->child + p - totpart;
@@ -4388,20 +4613,24 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
do_child_modifiers(&modifier_ctx, mat, state, t);
- if (psys->lattice_deform_data)
+ if (psys->lattice_deform_data) {
calc_latt_deform(psys->lattice_deform_data, state->co, psys->lattice_strength);
+ }
}
else {
- if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED))
+ if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) {
copy_particle_key(state, &pa->state, 1);
- else if (pa->prev_state.time == cfra)
+ }
+ else if (pa->prev_state.time == cfra) {
copy_particle_key(state, &pa->prev_state, 1);
+ }
else {
float dfra, frs_sec = sim->scene->r.frs_sec;
/* let's interpolate to try to be as accurate as possible */
if (pa->state.time + 2.f >= state->time && pa->prev_state.time - 2.f <= state->time) {
if (pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.f) {
- /* prev_state is wrong so let's not use it, this can happen at frames 1, 0 or particle birth */
+ /* prev_state is wrong so let's not use it,
+ * this can happen at frames 1, 0 or particle birth. */
dfra = state->time - pa->state.time;
copy_particle_key(state, &pa->state, 1);
@@ -4442,13 +4671,15 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec);
}
else {
- /* extrapolating over big ranges is not accurate so let's just give something close to reasonable back */
+ /* Extrapolating over big ranges is not accurate
+ * so let's just give something close to reasonable back. */
copy_particle_key(state, &pa->state, 0);
}
}
- if (sim->psys->lattice_deform_data)
+ if (sim->psys->lattice_deform_data) {
calc_latt_deform(sim->psys->lattice_deform_data, state->co, psys->lattice_strength);
+ }
}
return 1;
@@ -4518,8 +4749,9 @@ void psys_get_dupli_texture(ParticleSystem *psys,
num = pa->num_dmcache;
- if (num == DMCACHE_NOTFOUND)
+ if (num == DMCACHE_NOTFOUND) {
num = pa->num;
+ }
if (num >= psmd->mesh_final->totface) {
/* happens when simplify is enabled
@@ -4554,10 +4786,11 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim,
sub_v3_v3v3(vec, (cache + cache->segments)->co, cache->co);
len = normalize_v3(vec);
- if (pa == NULL && psys->part->childflat != PART_CHILD_FACES)
+ if (pa == NULL && psys->part->childflat != PART_CHILD_FACES) {
pa = psys->particles + cpa->pa[0];
+ }
- if (pa)
+ if (pa) {
psys_particle_on_emitter(psmd,
sim->psys->part->from,
pa->num,
@@ -4569,7 +4802,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim,
0,
0,
0);
- else
+ }
+ else {
psys_particle_on_emitter(psmd,
PART_FROM_FACE,
cpa->num,
@@ -4581,6 +4815,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim,
0,
0,
0);
+ }
if (psys->part->rotmode == PART_ROT_VEL) {
transpose_m3_m4(nmat, ob->imat);
@@ -4607,8 +4842,9 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim,
if (psys->part->phasefac != 0) {
float q_phase[4];
float phasefac = psys->part->phasefac;
- if (psys->part->randphasefac != 0.0f)
+ if (psys->part->randphasefac != 0.0f) {
phasefac += psys->part->randphasefac * psys_frand(psys, (pa - psys->particles) + 20);
+ }
axis_angle_to_quat(q_phase, vec, phasefac * (float)M_PI);
mul_qt_v3(q_phase, side);
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c
index c967449248d..b74fd3ff684 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -56,10 +56,12 @@ static void psys_path_iter_get(ParticlePathIterator *iter,
if (parent) {
iter->parent_key = parent + index;
- if (index > 0)
+ if (index > 0) {
mul_qt_qtqt(iter->parent_rotation, iter->parent_key->rot, parent->rot);
- else
+ }
+ else {
copy_qt_qt(iter->parent_rotation, parent->rot);
+ }
}
else {
iter->parent_key = NULL;
@@ -110,8 +112,9 @@ static void do_kink_spiral_deform(ParticleKey *state,
float radius = amplitude * expf(b * theta);
/* a bit more intuitive than using negative frequency for this */
- if (amplitude < 0.0f)
+ if (amplitude < 0.0f) {
theta = -theta;
+ }
cross_v3_v3v3(spiral_axis, dir, kink);
normalize_v3(spiral_axis);
@@ -276,8 +279,9 @@ static void do_kink_spiral(ParticleThreadContext *ctx,
}
totlen = 0.0f;
- for (k = 0, key = keys; k < end_index - 1; k++, key++)
+ for (k = 0, key = keys; k < end_index - 1; k++, key++) {
totlen += len_v3v3((key + 1)->co, key->co);
+ }
*r_totkeys = end_index;
*r_max_length = totlen;
@@ -426,16 +430,19 @@ void do_kink(ParticleKey *state,
float kink[3] = {1.f, 0.f, 0.f}, par_vec[3], q1[4] = {1.f, 0.f, 0.f, 0.f};
float t, dt = 1.f, result[3];
- if (ELEM(type, PART_KINK_NO, PART_KINK_SPIRAL))
+ if (ELEM(type, PART_KINK_NO, PART_KINK_SPIRAL)) {
return;
+ }
CLAMP(time, 0.f, 1.f);
if (shape != 0.0f && !ELEM(type, PART_KINK_BRAID)) {
- if (shape < 0.0f)
+ if (shape < 0.0f) {
time = (float)pow(time, 1.f + shape);
- else
+ }
+ else {
time = (float)pow(time, 1.f / (1.f - shape));
+ }
}
t = time * freq * (float)M_PI;
@@ -452,8 +459,9 @@ void do_kink(ParticleKey *state,
kink[axis] = 1.f;
- if (obmat)
+ if (obmat) {
mul_mat3_m4_v3(obmat, kink);
+ }
mul_qt_v3(par_rot, kink);
@@ -569,10 +577,12 @@ void do_kink(ParticleKey *state,
}
/* blend the start of the kink */
- if (dt < 1.f)
+ if (dt < 1.f) {
interp_v3_v3v3(state->co, state->co, result, dt);
- else
+ }
+ else {
copy_v3_v3(state->co, result);
+ }
}
static float do_clump_level(float result[3],
@@ -594,15 +604,19 @@ static float do_clump_level(float result[3],
else if (clumpfac != 0.0f) {
float cpow;
- if (clumppow < 0.0f)
+ if (clumppow < 0.0f) {
cpow = 1.0f + clumppow;
- else
+ }
+ else {
cpow = 1.0f + 9.0f * clumppow;
+ }
- if (clumpfac < 0.0f) /* clump roots instead of tips */
+ if (clumpfac < 0.0f) { /* clump roots instead of tips */
clump = -clumpfac * pa_clump * (float)pow(1.0 - (double)time, (double)cpow);
- else
+ }
+ else {
clump = clumpfac * pa_clump * (float)pow((double)time, (double)cpow);
+ }
interp_v3_v3v3(result, co, par_co, clump);
}
@@ -696,8 +710,9 @@ static void do_rough_curve(const float loc[3],
float rough[3];
float rco[3];
- if (!roughcurve)
+ if (!roughcurve) {
return;
+ }
fac *= clamp_f(curvemapping_evaluateF(roughcurve, 0, time), 0.0f, 1.0f);
@@ -840,7 +855,7 @@ void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx,
do_twist(modifier_ctx, state, t);
- if (part->flag & PART_CHILD_EFFECT)
+ if (part->flag & PART_CHILD_EFFECT) {
/* state is safe to cast, since only co and vel are used */
guided = do_guides(sim->depsgraph,
sim->psys->part,
@@ -848,6 +863,7 @@ void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx,
(ParticleKey *)state,
cpa->parent,
t);
+ }
if (guided == 0) {
float orco_offset[3];
@@ -888,8 +904,9 @@ void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx,
do_rough_curve(modifier_ctx->orco, mat, t, rough1, part->rough1_size, roughcurve, state);
}
else {
- if (rough1 > 0.f)
+ if (rough1 > 0.f) {
do_rough(modifier_ctx->orco, mat, t, rough1, part->rough1_size, 0.0, state);
+ }
if (rough2 > 0.f) {
float vec[3];
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index facfc318426..8125024585c 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -64,8 +64,9 @@ static void alloc_child_particles(ParticleSystem *psys, int tot)
if (psys->part->childtype) {
psys->totchild = tot;
- if (psys->totchild)
+ if (psys->totchild) {
psys->child = MEM_callocN(psys->totchild * sizeof(ChildParticle), "child_particles");
+ }
}
}
@@ -238,31 +239,37 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
bool intersects_tri = isect_ray_tri_watertight_v3(
co1, &isect_precalc, v1, v2, v3, &lambda, NULL);
if (intersects_tri) {
- if (from == PART_FROM_FACE)
+ if (from == PART_FROM_FACE) {
(pa + (int)(lambda * size[a]) * a0mul)->flag &= ~PARS_UNEXIST;
- else /* store number of intersections */
+ }
+ else { /* store number of intersections */
(pa + (int)(lambda * size[a]) * a0mul)->hair_index++;
+ }
}
if (mface->v4 && (!intersects_tri || from == PART_FROM_VOLUME)) {
copy_v3_v3(v4, mvert[mface->v4].co);
if (isect_ray_tri_watertight_v3(co1, &isect_precalc, v1, v3, v4, &lambda, NULL)) {
- if (from == PART_FROM_FACE)
+ if (from == PART_FROM_FACE) {
(pa + (int)(lambda * size[a]) * a0mul)->flag &= ~PARS_UNEXIST;
- else
+ }
+ else {
(pa + (int)(lambda * size[a]) * a0mul)->hair_index++;
+ }
}
}
}
if (from == PART_FROM_VOLUME) {
int in = pa->hair_index % 2;
- if (in)
+ if (in) {
pa->hair_index++;
+ }
for (i = 0; i < size[0]; i++) {
- if (in || (pa + i * a0mul)->hair_index % 2)
+ if (in || (pa + i * a0mul)->hair_index % 2) {
(pa + i * a0mul)->flag &= ~PARS_UNEXIST;
+ }
/* odd intersections == in->out / out->in */
/* even intersections -> in stays same */
in = (in + (pa + i * a0mul)->hair_index) % 2;
@@ -277,8 +284,9 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
for (i = 0, p = 0, pa = psys->particles; i < res; i++) {
for (j = 0; j < res; j++) {
for (k = 0; k < res; k++, p++, pa++) {
- if (j % 2)
+ if (j % 2) {
pa->fuv[0] += d / 2.f;
+ }
if (k % 2) {
pa->fuv[0] += d / 2.f;
@@ -303,8 +311,9 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
if (psys->part->grid_rand > 0.f) {
float rfac = d * psys->part->grid_rand;
for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) {
- if (pa->flag & PARS_UNEXIST)
+ if (pa->flag & PARS_UNEXIST) {
continue;
+ }
pa->fuv[0] += rfac * (psys_frand(psys, p + 31) - 0.5f);
pa->fuv[1] += rfac * (psys_frand(psys, p + 32) - 0.5f);
@@ -340,8 +349,9 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount)
float *jit2, x, rad1, rad2, rad3;
int i, num2;
- if (num == 0)
+ if (num == 0) {
return;
+ }
rad1 = (float)(1.0f / sqrtf((float)num));
rad2 = (float)(1.0f / ((float)num));
@@ -378,10 +388,12 @@ static void psys_uv_to_w(float u, float v, int quad, float *w)
float vert[4][3], co[3];
if (!quad) {
- if (u + v > 1.0f)
+ if (u + v > 1.0f) {
v = 1.0f - v;
- else
+ }
+ else {
u = 1.0f - u;
+ }
}
vert[0][0] = 0.0f;
@@ -415,20 +427,24 @@ static int distribute_binary_search(float *sum, int n, float value)
{
int mid, low = 0, high = n - 1;
- if (high == low)
+ if (high == low) {
return low;
+ }
- if (sum[low] >= value)
+ if (sum[low] >= value) {
return low;
+ }
- if (sum[high - 1] < value)
+ if (sum[high - 1] < value) {
return high;
+ }
while (low < high) {
mid = (low + high) / 2;
- if ((sum[mid] >= value) && (sum[mid - 1] < value))
+ if ((sum[mid] >= value) && (sum[mid - 1] < value)) {
return mid;
+ }
if (sum[mid] > value) {
high = mid - 1;
@@ -521,10 +537,12 @@ static void distribute_from_faces_exec(ParticleTask *thread, ParticleData *pa, i
switch (distr) {
case PART_DISTR_JIT:
if (ctx->jitlevel == 1) {
- if (mface->v4)
+ if (mface->v4) {
psys_uv_to_w(0.5f, 0.5f, mface->v4, pa->fuv);
- else
+ }
+ else {
psys_uv_to_w(1.0f / 3.0f, 1.0f / 3.0f, mface->v4, pa->fuv);
+ }
}
else {
float offset = fmod(ctx->jitoff[i] + (float)p, (float)ctx->jitlevel);
@@ -569,10 +587,12 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
switch (distr) {
case PART_DISTR_JIT:
if (ctx->jitlevel == 1) {
- if (mface->v4)
+ if (mface->v4) {
psys_uv_to_w(0.5f, 0.5f, mface->v4, pa->fuv);
- else
+ }
+ else {
psys_uv_to_w(1.0f / 3.0f, 1.0f / 3.0f, mface->v4, pa->fuv);
+ }
}
else {
float offset = fmod(ctx->jitoff[i] + (float)p, (float)ctx->jitlevel);
@@ -604,8 +624,9 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
intersect = 0;
for (i = 0, mface = mesh->mface; i < tot; i++, mface++) {
- if (i == pa->num)
+ if (i == pa->num) {
continue;
+ }
v1 = mvert[mface->v1].co;
v2 = mvert[mface->v2].co;
@@ -630,8 +651,9 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
}
}
}
- if (intersect == 0)
+ if (intersect == 0) {
pa->foffset = 0.0;
+ }
else {
switch (distr) {
case PART_DISTR_JIT:
@@ -736,8 +758,9 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
cpa->parent = cpa->pa[0];
}
- if (rng_skip_tot > 0) /* should never be below zero */
+ if (rng_skip_tot > 0) { /* should never be below zero */
BLI_rng_skip(thread->rng, rng_skip_tot);
+ }
}
static void exec_distribute_parent(TaskPool *__restrict UNUSED(pool),
@@ -754,16 +777,19 @@ static void exec_distribute_parent(TaskPool *__restrict UNUSED(pool),
pa = psys->particles + task->begin;
switch (psys->part->from) {
case PART_FROM_FACE:
- for (p = task->begin; p < task->end; ++p, ++pa)
+ for (p = task->begin; p < task->end; ++p, ++pa) {
distribute_from_faces_exec(task, pa, p);
+ }
break;
case PART_FROM_VOLUME:
- for (p = task->begin; p < task->end; ++p, ++pa)
+ for (p = task->begin; p < task->end; ++p, ++pa) {
distribute_from_volume_exec(task, pa, p);
+ }
break;
case PART_FROM_VERT:
- for (p = task->begin; p < task->end; ++p, ++pa)
+ for (p = task->begin; p < task->end; ++p, ++pa) {
distribute_from_verts_exec(task, pa, p);
+ }
break;
}
}
@@ -794,20 +820,25 @@ static int distribute_compare_orig_index(const void *p1, const void *p2, void *u
int index1 = orig_index[*(const int *)p1];
int index2 = orig_index[*(const int *)p2];
- if (index1 < index2)
+ if (index1 < index2) {
return -1;
+ }
else if (index1 == index2) {
/* this pointer comparison appears to make qsort stable for glibc,
* and apparently on solaris too, makes the renders reproducible */
- if (p1 < p2)
+ if (p1 < p2) {
return -1;
- else if (p1 == p2)
+ }
+ else if (p1 == p2) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
- else
+ else {
return 1;
+ }
}
static void distribute_invalid(ParticleSimulationData *sim, int from)
@@ -864,26 +895,28 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
float cur, maxweight = 0.0, tweight, totweight, inv_totweight, co[3], nor[3], orco[3];
RNG *rng = NULL;
- if (ELEM(NULL, ob, psys, psys->part))
+ if (ELEM(NULL, ob, psys, psys->part)) {
return 0;
+ }
part = psys->part;
totpart = psys->totpart;
- if (totpart == 0)
+ if (totpart == 0) {
return 0;
+ }
if (!final_mesh->runtime.deformed_only &&
!CustomData_get_layer(&final_mesh->fdata, CD_ORIGINDEX)) {
printf(
"Can't create particles with the current modifier stack, disable destructive modifiers\n");
- // XXX error("Can't paint with the current modifier stack, disable destructive modifiers");
+ // XXX error("Can't paint with the current modifier stack, disable destructive modifiers");
return 0;
}
- /* XXX This distribution code is totally broken in case from == PART_FROM_CHILD, it's always using finaldm
- * even if use_modifier_stack is unset... But making things consistent here break all existing edited
- * hair systems, so better wait for complete rewrite.
- */
+ /* XXX This distribution code is totally broken in case from == PART_FROM_CHILD,
+ * it's always using finaldm even if use_modifier_stack is unset...
+ * But making things consistent here break all existing edited
+ * hair systems, so better wait for complete rewrite. */
psys_thread_context_init(ctx, sim);
@@ -949,10 +982,12 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
rng = BLI_rng_new_srandom(31415926 + psys->seed);
- if (psys->part->use_modifier_stack)
+ if (psys->part->use_modifier_stack) {
mesh = final_mesh;
- else
+ }
+ else {
BKE_id_copy_ex(NULL, ob->data, (ID **)&mesh, LIB_ID_COPY_LOCALIZE);
+ }
BKE_mesh_tessface_ensure(mesh);
@@ -976,8 +1011,9 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
copy_v3_v3(co, orcodata[p]);
BKE_mesh_orco_verts_transform(ob->data, &co, 1, 1);
}
- else
+ else {
copy_v3_v3(co, mv[p].co);
+ }
BLI_kdtree_3d_insert(tree, p, co);
}
@@ -991,11 +1027,13 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
if (totelem == 0) {
distribute_invalid(sim, children ? PART_FROM_CHILD : 0);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
fprintf(stderr, "Particle distribution error: Nothing to emit from!\n");
+ }
- if (mesh != final_mesh)
+ if (mesh != final_mesh) {
BKE_id_free(NULL, mesh);
+ }
BLI_kdtree_3d_free(tree);
BLI_rng_free(rng);
@@ -1046,22 +1084,25 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
cur = mf->v4 ? area_quad_v3(co1, co2, co3, co4) : area_tri_v3(co1, co2, co3);
- if (cur > maxweight)
+ if (cur > maxweight) {
maxweight = cur;
+ }
element_weight[i] = cur;
totarea += cur;
}
- for (i = 0; i < totelem; i++)
+ for (i = 0; i < totelem; i++) {
element_weight[i] /= totarea;
+ }
maxweight /= totarea;
}
else {
float min = 1.0f / (float)(MIN2(totelem, totpart));
- for (i = 0; i < totelem; i++)
+ for (i = 0; i < totelem; i++) {
element_weight[i] = min;
+ }
maxweight = min;
}
@@ -1070,8 +1111,9 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
if (vweight) {
if (from == PART_FROM_VERT) {
- for (i = 0; i < totelem; i++)
+ for (i = 0; i < totelem; i++) {
element_weight[i] *= vweight[i];
+ }
}
else { /* PART_FROM_FACE / PART_FROM_VOLUME */
for (i = 0; i < totelem; i++) {
@@ -1127,8 +1169,9 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
int *element_map = MEM_mallocN(sizeof(*element_map) * totmapped, __func__);
int i_mapped = 0;
- for (i = 0; i < totelem && element_weight[i] == 0.0f; i++)
+ for (i = 0; i < totelem && element_weight[i] == 0.0f; i++) {
;
+ }
element_sum[i_mapped] = element_weight[i] * inv_totweight;
element_map[i_mapped] = i;
i_mapped++;
@@ -1161,9 +1204,10 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
double step, pos;
step = (totpart < 2) ? 0.5 : 1.0 / (double)totpart;
- /* This is to address tricky issues with vertex-emitting when user tries (and expects) exact 1-1 vert/part
- * distribution (see T47983 and its two example files). It allows us to consider pos as
- * 'midpoint between v and v+1' (or 'p and p+1', depending whether we have more vertices than particles or not),
+ /* This is to address tricky issues with vertex-emitting when user tries
+ * (and expects) exact 1-1 vert/part distribution (see T47983 and its two example files).
+ * It allows us to consider pos as 'midpoint between v and v+1'
+ * (or 'p and p+1', depending whether we have more vertices than particles or not),
* and avoid stumbling over float impression in element_sum.
* Note: moved face and volume distribution to this as well (instead of starting at zero),
* for the same reasons, see T52682. */
@@ -1171,8 +1215,9 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
step * 0.5; /* We choose the smaller step. */
for (i = 0, p = 0; p < totpart; p++, pos += step) {
- for (; (i < totmapped - 1) && (pos > (double)element_sum[i]); i++)
+ for (; (i < totmapped - 1) && (pos > (double)element_sum[i]); i++) {
;
+ }
particle_element[p] = element_map[i];
@@ -1189,12 +1234,14 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
int *orig_index = NULL;
if (from == PART_FROM_VERT) {
- if (mesh->totvert)
+ if (mesh->totvert) {
orig_index = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX);
+ }
}
else {
- if (mesh->totface)
+ if (mesh->totface) {
orig_index = CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX);
+ }
}
if (orig_index) {
@@ -1209,10 +1256,12 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
if (jitlevel == 0) {
jitlevel = totpart / totelem;
- if (part->flag & PART_EDISTR)
+ if (part->flag & PART_EDISTR) {
jitlevel *= 2; /* looks better in general, not very scientific */
- if (jitlevel < 3)
+ }
+ if (jitlevel < 3) {
jitlevel = 3;
+ }
}
jit = MEM_callocN((2 + jitlevel * 2) * sizeof(float), "jit");
@@ -1220,10 +1269,12 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
/* for small amounts of particles we use regular jitter since it looks
* a bit better, for larger amounts we switch to hammersley sequence
* because it is much faster */
- if (jitlevel < 25)
+ if (jitlevel < 25) {
init_mv_jit(jit, jitlevel, psys->seed, part->jitfac);
- else
+ }
+ else {
hammersley_create(jit, jitlevel + 1, psys->seed, part->jitfac);
+ }
BLI_array_randomize(
jit, 2 * sizeof(float), jitlevel, psys->seed); /* for custom jit or even distribution */
}
@@ -1271,8 +1322,9 @@ static void distribute_particles_on_dm(ParticleSimulationData *sim, int from)
int i, totpart, numtasks;
/* create a task pool for distribution tasks */
- if (!psys_thread_context_init_distribute(&ctx, sim, from))
+ if (!psys_thread_context_init_distribute(&ctx, sim, from)) {
return;
+ }
task_scheduler = BLI_task_scheduler_get();
task_pool = BLI_task_pool_create(task_scheduler, &ctx);
@@ -1283,10 +1335,12 @@ static void distribute_particles_on_dm(ParticleSimulationData *sim, int from)
ParticleTask *task = &tasks[i];
psys_task_init_distribute(task, sim);
- if (from == PART_FROM_CHILD)
+ if (from == PART_FROM_CHILD) {
BLI_task_pool_push(task_pool, exec_distribute_child, task, false, TASK_PRIORITY_LOW);
- else
+ }
+ else {
BLI_task_pool_push(task_pool, exec_distribute_parent, task, false, TASK_PRIORITY_LOW);
+ }
}
BLI_task_pool_work_and_wait(task_pool);
@@ -1294,8 +1348,9 @@ static void distribute_particles_on_dm(ParticleSimulationData *sim, int from)
psys_calc_dmcache(sim->ob, final_mesh, sim->psmd->mesh_original, sim->psys);
- if (ctx.mesh != final_mesh)
+ if (ctx.mesh != final_mesh) {
BKE_id_free(NULL, ctx.mesh);
+ }
psys_tasks_free(tasks, numtasks);
@@ -1316,13 +1371,16 @@ void distribute_particles(ParticleSimulationData *sim, int from)
int distr_error = 0;
if (psmd) {
- if (psmd->mesh_final)
+ if (psmd->mesh_final) {
distribute_particles_on_dm(sim, from);
- else
+ }
+ else {
distr_error = 1;
+ }
}
- else
+ else {
distribute_particles_on_shape(sim, from);
+ }
if (distr_error) {
distribute_invalid(sim, from);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index bf34e98c482..cba15aed55f 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -102,13 +102,16 @@ static ThreadRWMutex psys_bvhtree_rwlock = BLI_RWLOCK_INITIALIZER;
static int particles_are_dynamic(ParticleSystem *psys)
{
- if (psys->pointcache->flag & PTCACHE_BAKED)
+ if (psys->pointcache->flag & PTCACHE_BAKED) {
return 0;
+ }
- if (psys->part->type == PART_HAIR)
+ if (psys->part->type == PART_HAIR) {
return psys->flag & PSYS_HAIR_DYNAMICS;
- else
+ }
+ else {
return ELEM(psys->part->phystype, PART_PHYS_NEWTON, PART_PHYS_BOIDS, PART_PHYS_FLUID);
+ }
}
float psys_get_current_display_percentage(ParticleSystem *psys, const bool use_render_params)
@@ -128,12 +131,15 @@ float psys_get_current_display_percentage(ParticleSystem *psys, const bool use_r
static int tot_particles(ParticleSystem *psys, PTCacheID *pid)
{
- if (pid && psys->pointcache->flag & PTCACHE_EXTERNAL)
+ if (pid && psys->pointcache->flag & PTCACHE_EXTERNAL) {
return pid->cache->totpoint;
- else if (psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT)
+ }
+ else if (psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT) {
return psys->part->grid_res * psys->part->grid_res * psys->part->grid_res - psys->totunexist;
- else
+ }
+ else {
return psys->part->totpart - psys->totunexist;
+ }
}
void psys_reset(ParticleSystem *psys, int mode)
@@ -212,11 +218,13 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
totpart = part->grid_res;
totpart *= totpart * totpart;
}
- else
+ else {
totpart = part->totpart;
+ }
}
- else
+ else {
totpart = new_totpart;
+ }
if (totpart != psys->totpart) {
if (psys->edit && psys->free_edit) {
@@ -227,16 +235,18 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
if (totpart) {
newpars = MEM_callocN(totpart * sizeof(ParticleData), "particles");
- if (newpars == NULL)
+ if (newpars == NULL) {
return;
+ }
if (psys->part->phystype == PART_PHYS_BOIDS) {
newboids = MEM_callocN(totpart * sizeof(BoidParticle), "boid particles");
if (newboids == NULL) {
/* allocation error! */
- if (newpars)
+ if (newpars) {
MEM_freeN(newpars);
+ }
return;
}
}
@@ -248,15 +258,18 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
if (totsaved) {
memcpy(newpars, psys->particles, totsaved * sizeof(ParticleData));
- if (psys->particles->boid)
+ if (psys->particles->boid) {
memcpy(newboids, psys->particles->boid, totsaved * sizeof(BoidParticle));
+ }
}
- if (psys->particles->keys)
+ if (psys->particles->keys) {
MEM_freeN(psys->particles->keys);
+ }
- if (psys->particles->boid)
+ if (psys->particles->boid) {
MEM_freeN(psys->particles->boid);
+ }
for (p = 0, pa = newpars; p < totsaved; p++, pa++) {
if (pa->keys) {
@@ -265,9 +278,11 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
}
}
- for (p = totsaved, pa = psys->particles + totsaved; p < psys->totpart; p++, pa++)
- if (pa->hair)
+ for (p = totsaved, pa = psys->particles + totsaved; p < psys->totpart; p++, pa++) {
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
+ }
MEM_freeN(psys->particles);
psys_free_pdd(psys);
@@ -295,13 +310,16 @@ int psys_get_child_number(Scene *scene, ParticleSystem *psys, const bool use_ren
{
int nbr;
- if (!psys->part->childtype)
+ if (!psys->part->childtype) {
return 0;
+ }
- if (use_render_params)
+ if (use_render_params) {
nbr = psys->part->ren_child_nbr;
- else
+ }
+ else {
nbr = psys->part->child_nbr;
+ }
return get_render_child_particle_number(&scene->r, nbr, use_render_params);
}
@@ -406,17 +424,21 @@ void psys_calc_dmcache(Object *ob, Mesh *mesh_final, Mesh *mesh_original, Partic
}
if (use_modifier_stack) {
- if (pa->num < totelem)
+ if (pa->num < totelem) {
pa->num_dmcache = DMCACHE_ISCHILD;
- else
+ }
+ else {
pa->num_dmcache = DMCACHE_NOTFOUND;
+ }
}
else {
if (psys->part->from == PART_FROM_VERT) {
- if (pa->num < totelem && nodearray[pa->num])
+ if (pa->num < totelem && nodearray[pa->num]) {
pa->num_dmcache = POINTER_AS_INT(nodearray[pa->num]->link);
- else
+ }
+ else {
pa->num_dmcache = DMCACHE_NOTFOUND;
+ }
}
else { /* FROM_FACE/FROM_VOLUME */
pa->num_dmcache = psys_particle_dm_face_lookup(
@@ -488,10 +510,12 @@ void psys_tasks_free(ParticleTask *tasks, int numtasks)
/* threads */
for (i = 0; i < numtasks; ++i) {
- if (tasks[i].rng)
+ if (tasks[i].rng) {
BLI_rng_free(tasks[i].rng);
- if (tasks[i].rng_path)
+ }
+ if (tasks[i].rng_path) {
BLI_rng_free(tasks[i].rng_path);
+ }
}
MEM_freeN(tasks);
@@ -500,20 +524,27 @@ void psys_tasks_free(ParticleTask *tasks, int numtasks)
void psys_thread_context_free(ParticleThreadContext *ctx)
{
/* path caching */
- if (ctx->vg_length)
+ if (ctx->vg_length) {
MEM_freeN(ctx->vg_length);
- if (ctx->vg_clump)
+ }
+ if (ctx->vg_clump) {
MEM_freeN(ctx->vg_clump);
- if (ctx->vg_kink)
+ }
+ if (ctx->vg_kink) {
MEM_freeN(ctx->vg_kink);
- if (ctx->vg_rough1)
+ }
+ if (ctx->vg_rough1) {
MEM_freeN(ctx->vg_rough1);
- if (ctx->vg_rough2)
+ }
+ if (ctx->vg_rough2) {
MEM_freeN(ctx->vg_rough2);
- if (ctx->vg_roughe)
+ }
+ if (ctx->vg_roughe) {
MEM_freeN(ctx->vg_roughe);
- if (ctx->vg_twist)
+ }
+ if (ctx->vg_twist) {
MEM_freeN(ctx->vg_twist);
+ }
if (ctx->sim.psys->lattice_deform_data) {
end_latt_deform(ctx->sim.psys->lattice_deform_data);
@@ -521,17 +552,22 @@ void psys_thread_context_free(ParticleThreadContext *ctx)
}
/* distribution */
- if (ctx->jit)
+ if (ctx->jit) {
MEM_freeN(ctx->jit);
- if (ctx->jitoff)
+ }
+ if (ctx->jitoff) {
MEM_freeN(ctx->jitoff);
- if (ctx->weight)
+ }
+ if (ctx->weight) {
MEM_freeN(ctx->weight);
- if (ctx->index)
+ }
+ if (ctx->index) {
MEM_freeN(ctx->index);
- if (ctx->seams)
+ }
+ if (ctx->seams) {
MEM_freeN(ctx->seams);
- //if (ctx->vertpart) MEM_freeN(ctx->vertpart);
+ }
+ // if (ctx->vertpart) MEM_freeN(ctx->vertpart);
BLI_kdtree_3d_free(ctx->tree);
if (ctx->clumpcurve != NULL) {
@@ -583,7 +619,7 @@ void initialize_particle(ParticleSimulationData *sim, ParticleData *pa)
pa->hair_index = 0;
/* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */
/* usage other than straight after distribute has to handle this index by itself - jahka*/
- //pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we don't have a derived mesh face */
+ // pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we don't have a derived mesh face */
}
static void initialize_all_particles(ParticleSimulationData *sim)
@@ -626,8 +662,9 @@ static void free_unexisting_particles(ParticleSimulationData *sim)
}
if (psys->totpart && psys->totunexist == psys->totpart) {
- if (psys->particles->boid)
+ if (psys->particles->boid) {
MEM_freeN(psys->particles->boid);
+ }
MEM_freeN(psys->particles);
psys->particles = NULL;
@@ -641,14 +678,16 @@ static void free_unexisting_particles(ParticleSimulationData *sim)
npa = newpars = MEM_callocN(newtotpart * sizeof(ParticleData), "particles");
for (p = 0, pa = psys->particles; p < newtotpart; p++, pa++, npa++) {
- while (pa->flag & PARS_UNEXIST)
+ while (pa->flag & PARS_UNEXIST) {
pa++;
+ }
memcpy(npa, pa, sizeof(ParticleData));
}
- if (psys->particles->boid)
+ if (psys->particles->boid) {
MEM_freeN(psys->particles->boid);
+ }
MEM_freeN(psys->particles);
psys->particles = newpars;
psys->totpart -= psys->totunexist;
@@ -720,7 +759,7 @@ void psys_get_birth_coords(
int p = pa - psys->particles;
/* get birth location from object */
- if (use_tangents)
+ if (use_tangents) {
psys_particle_on_emitter(sim->psmd,
part->from,
pa->num,
@@ -732,9 +771,11 @@ void psys_get_birth_coords(
utan,
vtan,
0);
- else
+ }
+ else {
psys_particle_on_emitter(
sim->psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, nor, 0, 0, 0);
+ }
/* get possible textural influence */
psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra);
@@ -750,8 +791,15 @@ void psys_get_birth_coords(
/* -tangent */
if (use_tangents) {
- //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
+#if 0
+ float phase = vg_rot ?
+ 2.0f *
+ (psys_particle_value_from_verts(sim->psmd->dm, part->from, pa, vg_rot) -
+ 0.5f) :
+ 0.0f;
+#else
float phase = 0.0f;
+#endif
mul_v3_fl(vtan, -cosf((float)M_PI * (part->tanphase + phase)));
fac = -sinf((float)M_PI * (part->tanphase + phase));
madd_v3_v3fl(vtan, utan, fac);
@@ -842,12 +890,14 @@ void psys_get_birth_coords(
}
/* *emitter normal */
- if (part->normfac != 0.f)
+ if (part->normfac != 0.f) {
madd_v3_v3fl(vel, nor, part->normfac);
+ }
/* *emitter tangent */
- if (sim->psmd && part->tanfac != 0.f)
+ if (sim->psmd && part->tanfac != 0.f) {
madd_v3_v3fl(vel, vtan, part->tanfac);
+ }
/* *emitter object orientation */
if (part->ob_vel[0] != 0.f) {
@@ -867,12 +917,14 @@ void psys_get_birth_coords(
/* TODO */
/* *random */
- if (part->randfac != 0.f)
+ if (part->randfac != 0.f) {
madd_v3_v3fl(vel, r_vel, part->randfac);
+ }
/* *particle */
- if (part->partfac != 0.f)
+ if (part->partfac != 0.f) {
madd_v3_v3fl(vel, p_vel, part->partfac);
+ }
mul_v3_v3fl(state->vel, vel, ptex.ivel);
@@ -990,8 +1042,9 @@ void psys_get_birth_coords(
/* rotation phase */
phasefac = part->phasefac;
- if (part->randphasefac != 0.0f)
+ if (part->randphasefac != 0.0f) {
phasefac += part->randphasefac * psys_frand(psys, p + 20);
+ }
axis_angle_to_quat(q_phase, x_vec, phasefac * (float)M_PI);
/* combine base rotation & phase */
@@ -1003,10 +1056,12 @@ void psys_get_birth_coords(
zero_v3(state->ave);
if (part->avemode) {
- if (part->avemode == PART_AVE_RAND)
+ if (part->avemode == PART_AVE_RAND) {
copy_v3_v3(state->ave, r_ave);
- else
+ }
+ else {
get_angular_velocity_vector(part->avemode, state, state->ave);
+ }
normalize_v3(state->ave);
mul_v3_fl(state->ave, part->avefac);
@@ -1020,8 +1075,9 @@ static void evaluate_emitter_anim(struct Depsgraph *depsgraph,
Object *ob,
float cfra)
{
- if (ob->parent)
+ if (ob->parent) {
evaluate_emitter_anim(depsgraph, scene, ob->parent, cfra);
+ }
BKE_object_where_is_calc_time(depsgraph, scene, ob, cfra);
}
@@ -1083,8 +1139,9 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
pa->lifetime = part->lifetime * ptex.life;
- if (part->randlife != 0.0f)
+ if (part->randlife != 0.0f) {
pa->lifetime *= 1.0f - part->randlife * psys_frand(psys, p + 21);
+ }
}
pa->dietime = pa->time + pa->lifetime;
@@ -1095,12 +1152,15 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
pa->dietime = MIN2(pa->dietime, dietime);
}
- if (pa->time > cfra)
+ if (pa->time > cfra) {
pa->alive = PARS_UNBORN;
- else if (pa->dietime <= cfra)
+ }
+ else if (pa->dietime <= cfra) {
pa->alive = PARS_DEAD;
- else
+ }
+ else {
pa->alive = PARS_ALIVE;
+ }
pa->state.time = cfra;
}
@@ -1109,8 +1169,9 @@ static void reset_all_particles(ParticleSimulationData *sim, float dtime, float
ParticleData *pa;
int p, totpart = sim->psys->totpart;
- for (p = from, pa = sim->psys->particles + from; p < totpart; p++, pa++)
+ for (p = from, pa = sim->psys->particles + from; p < totpart; p++, pa++) {
reset_particle(sim, pa, dtime, cfra);
+ }
}
/************************************************/
/* Particle targets */
@@ -1119,15 +1180,19 @@ ParticleSystem *psys_get_target_system(Object *ob, ParticleTarget *pt)
{
ParticleSystem *psys = NULL;
- if (pt->ob == NULL || pt->ob == ob)
+ if (pt->ob == NULL || pt->ob == ob) {
psys = BLI_findlink(&ob->particlesystem, pt->psys - 1);
- else
+ }
+ else {
psys = BLI_findlink(&pt->ob->particlesystem, pt->psys - 1);
+ }
- if (psys)
+ if (psys) {
pt->flag |= PTARGET_VALID;
- else
+ }
+ else {
pt->flag &= ~PTARGET_VALID;
+ }
return psys;
}
@@ -1147,8 +1212,9 @@ void psys_count_keyed_targets(ParticleSimulationData *sim)
if (kpsys && kpsys->totpart) {
psys->totkeyed += keys_valid;
- if (psys->flag & PSYS_KEYED_TIMING && pt->duration != 0.0f)
+ if (psys->flag & PSYS_KEYED_TIMING && pt->duration != 0.0f) {
psys->totkeyed += 1;
+ }
}
else {
keys_valid = 0;
@@ -1214,14 +1280,17 @@ static void set_keyed_keys(ParticleSimulationData *sim)
(key + 1)->time = pa->time + pt->time + pt->duration;
}
}
- else if (totkeys > 1)
+ else if (totkeys > 1) {
key->time = pa->time + (float)k / (float)(totkeys - 1) * pa->lifetime;
- else
+ }
+ else {
key->time = pa->time;
+ }
}
- if (psys->flag & PSYS_KEYED_TIMING && pt->duration != 0.0f)
+ if (psys->flag & PSYS_KEYED_TIMING && pt->duration != 0.0f) {
k++;
+ }
ksim.psys->flag |= keyed_flag;
@@ -1248,8 +1317,9 @@ void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys)
}
static void psys_clear_temp_pointcache(ParticleSystem *psys)
{
- if (psys->pointcache->flag & PTCACHE_DISK_CACHE)
+ if (psys->pointcache->flag & PTCACHE_DISK_CACHE) {
BKE_ptcache_free_mem(&psys->pointcache->mem_cache);
+ }
}
void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
{
@@ -1287,10 +1357,12 @@ static void psys_update_particle_bvhtree(ParticleSystem *psys, float cfra)
LOOP_SHOWN_PARTICLES
{
if (pa->alive == PARS_ALIVE) {
- if (pa->state.time == cfra)
+ if (pa->state.time == cfra) {
BLI_bvhtree_insert(psys->bvhtree, p, pa->prev_state.co, 1);
- else
+ }
+ else {
BLI_bvhtree_insert(psys->bvhtree, p, pa->state.co, 1);
+ }
}
}
BLI_bvhtree_balance(psys->bvhtree);
@@ -1319,10 +1391,12 @@ void psys_update_particle_tree(ParticleSystem *psys, float cfra)
LOOP_SHOWN_PARTICLES
{
if (pa->alive == PARS_ALIVE) {
- if (pa->state.time == cfra)
+ if (pa->state.time == cfra) {
BLI_kdtree_3d_insert(psys->tree, p, pa->prev_state.co);
- else
+ }
+ else {
BLI_kdtree_3d_insert(psys->tree, p, pa->state.co);
+ }
}
}
BLI_kdtree_3d_balance(psys->tree);
@@ -1367,8 +1441,9 @@ static void integrate_particle(
copy_v3_v3(oldpos, pa->state.co);
/* Verlet integration behaves strangely with moving emitters, so do first step with euler. */
- if (pa->prev_state.time < 0.f && integrator == PART_INT_VERLET)
+ if (pa->prev_state.time < 0.f && integrator == PART_INT_VERLET) {
integrator = PART_INT_EULER;
+ }
switch (integrator) {
case PART_INT_EULER:
@@ -1400,8 +1475,9 @@ static void integrate_particle(
/* force to acceleration*/
mul_v3_v3fl(acceleration, force, 1.0f / pa_mass);
- if (external_acceleration)
+ if (external_acceleration) {
add_v3_v3(acceleration, external_acceleration);
+ }
/* calculate next state */
add_v3_v3(states[i].vel, impulse);
@@ -1485,12 +1561,13 @@ static void integrate_particle(
}
}
-/*********************************************************************************************************
- * SPH fluid physics
+/* -------------------------------------------------------------------- */
+/** \name SPH fluid physics
*
* In theory, there could be unlimited implementation of SPH simulators
*
- * This code uses in some parts adapted algorithms from the pseudo code as outlined in the Research paper:
+ * This code uses in some parts adapted algorithms
+ * from the pseudo code as outlined in the Research paper:
*
* Titled: Particle-based Viscoelastic Fluid Simulation.
* Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin
@@ -1498,7 +1575,8 @@ static void integrate_particle(
*
* Presented at Siggraph, (2005)
*
- * ********************************************************************************************************/
+ * \{ */
+
#define PSYS_FLUID_SPRINGS_INITIAL_SIZE 256
static ParticleSpring *sph_spring_add(ParticleSystem *psys, ParticleSpring *spring)
{
@@ -1522,8 +1600,9 @@ static ParticleSpring *sph_spring_add(ParticleSystem *psys, ParticleSpring *spri
}
static void sph_spring_delete(ParticleSystem *psys, int j)
{
- if (j != psys->tot_fluidsprings - 1)
+ if (j != psys->tot_fluidsprings - 1) {
psys->fluid_springs[j] = psys->fluid_springs[psys->tot_fluidsprings - 1];
+ }
psys->tot_fluidsprings--;
@@ -1548,8 +1627,9 @@ static void sph_springs_modify(ParticleSystem *psys, float dtime)
/* scale things according to dtime */
float timefix = 25.f * dtime;
- if ((fluid->flag & SPH_VISCOELASTIC_SPRINGS) == 0 || fluid->spring_k == 0.f)
+ if ((fluid->flag & SPH_VISCOELASTIC_SPRINGS) == 0 || fluid->spring_k == 0.f) {
return;
+ }
/* Loop through the springs */
for (i = 0; i < psys->tot_fluidsprings; i++, spring++) {
@@ -1563,21 +1643,25 @@ static void sph_springs_modify(ParticleSystem *psys, float dtime)
Lij = spring->rest_length;
d = yield_ratio * timefix * Lij;
- if (rij > Lij + d) // Stretch
+ if (rij > Lij + d) { // Stretch
spring->rest_length += plasticity * (rij - Lij - d) * timefix;
- else if (rij < Lij - d) // Compress
+ }
+ else if (rij < Lij - d) { // Compress
spring->rest_length -= plasticity * (Lij - d - rij) * timefix;
+ }
h = 4.f * pa1->size;
- if (spring->rest_length > h)
+ if (spring->rest_length > h) {
spring->delete_flag = 1;
+ }
}
/* Loop through springs backwaqrds - for efficient delete function */
for (i = psys->tot_fluidsprings - 1; i >= 0; i--) {
- if (psys->fluid_springs[i].delete_flag)
+ if (psys->fluid_springs[i].delete_flag) {
sph_spring_delete(psys, i);
+ }
}
}
static EdgeHash *sph_springhash_build(ParticleSystem *psys)
@@ -1588,9 +1672,10 @@ static EdgeHash *sph_springhash_build(ParticleSystem *psys)
springhash = BLI_edgehash_new_ex(__func__, psys->tot_fluidsprings);
- for (i = 0, spring = psys->fluid_springs; i < psys->tot_fluidsprings; i++, spring++)
+ for (i = 0, spring = psys->fluid_springs; i < psys->tot_fluidsprings; i++, spring++) {
BLI_edgehash_insert(
springhash, spring->particle_index[0], spring->particle_index[1], POINTER_FROM_INT(i + 1));
+ }
return springhash;
}
@@ -1654,8 +1739,9 @@ static void sph_density_accum_cb(void *userdata, int index, const float co[3], f
UNUSED_VARS(co);
- if (npa == pfr->pa || squared_dist < FLT_EPSILON)
+ if (npa == pfr->pa || squared_dist < FLT_EPSILON) {
return;
+ }
/* Ugh! One particle has too many neighbors! If some aren't taken into
* account, the forces will be biased by the tree search order. This
@@ -1663,8 +1749,9 @@ static void sph_density_accum_cb(void *userdata, int index, const float co[3], f
* But, we have to stop somewhere, and it's not the end of the world.
* - jahka and z0r
*/
- if (pfr->tot_neighbors >= SPH_NEIGHBORS)
+ if (pfr->tot_neighbors >= SPH_NEIGHBORS) {
return;
+ }
pfr->neighbors[pfr->tot_neighbors].index = index;
pfr->neighbors[pfr->tot_neighbors].psys = pfr->npsys;
@@ -1673,8 +1760,9 @@ static void sph_density_accum_cb(void *userdata, int index, const float co[3], f
dist = sqrtf(squared_dist);
q = (1.f - dist / pfr->h) * pfr->massfac;
- if (pfr->use_size)
+ if (pfr->use_size) {
q *= npa->size;
+ }
pfr->data[0] += q * q;
pfr->data[1] += q * q * q;
@@ -1778,8 +1866,9 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
q = (1.f - rij / h) * pfn->psys->part->mass * inv_mass;
- if (pfn->psys->part->flag & PART_SIZEMASS)
+ if (pfn->psys->part->flag & PART_SIZEMASS) {
q *= npa->size;
+ }
copy_v3_v3(vel, npa->prev_state.vel);
@@ -1791,11 +1880,13 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
sub_v3_v3v3(dv, vel, state->vel);
u = dot_v3v3(vec, dv);
- if (u < 0.f && visc > 0.f)
+ if (u < 0.f && visc > 0.f) {
madd_v3_v3fl(force, vec, 0.5f * q * visc * u);
+ }
- if (u > 0.f && stiff_visc > 0.f)
+ if (u > 0.f && stiff_visc > 0.f) {
madd_v3_v3fl(force, vec, 0.5f * q * stiff_visc * u);
+ }
}
if (spring_constant > 0.f) {
@@ -1829,11 +1920,13 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
}
/* Artificial buoyancy force in negative gravity direction */
- if (fluid->buoyancy > 0.f && gravity)
+ if (fluid->buoyancy > 0.f && gravity) {
madd_v3_v3fl(force, gravity, fluid->buoyancy * (density - rest_density));
+ }
- if (sphdata->pass == 0 && psys[0]->part->time_flag & PART_TIME_AUTOSF)
+ if (sphdata->pass == 0 && psys[0]->part->time_flag & PART_TIME_AUTOSF) {
sph_particle_courant(sphdata, &pfr);
+ }
sphdata->pass++;
}
@@ -1855,8 +1948,9 @@ static void sphclassical_density_accum_cb(void *userdata,
sub_v3_v3v3(vec, npa->state.co, co);
rij = len_v3(vec);
rij_h = rij / pfr->h;
- if (rij_h > 2.0f)
+ if (rij_h > 2.0f) {
return;
+ }
/* Smoothing factor. Utilise the Wendland kernel. gnuplot:
* q1(x) = (2.0 - x)**4 * ( 1.0 + 2.0 * x)
@@ -1864,8 +1958,9 @@ static void sphclassical_density_accum_cb(void *userdata,
q = qfac / pow3f(pfr->h) * pow4f(2.0f - rij_h) * (1.0f + 2.0f * rij_h);
q *= pfr->npsys->part->mass;
- if (pfr->use_size)
+ if (pfr->use_size) {
q *= pfr->pa->size;
+ }
pfr->data[0] += q;
pfr->data[1] += q / npa->sphdensity;
@@ -1881,8 +1976,9 @@ static void sphclassical_neighbour_accum_cb(void *userdata,
float rij, rij_h;
float vec[3];
- if (pfr->tot_neighbors >= SPH_NEIGHBORS)
+ if (pfr->tot_neighbors >= SPH_NEIGHBORS) {
return;
+ }
/* Exclude particles that are more than 2h away. Can't use squared_dist here
* because it is not accurate enough. Use current state, i.e. the output of
@@ -1890,8 +1986,9 @@ static void sphclassical_neighbour_accum_cb(void *userdata,
sub_v3_v3v3(vec, npa->state.co, co);
rij = len_v3(vec);
rij_h = rij / pfr->h;
- if (rij_h > 2.0f)
+ if (rij_h > 2.0f) {
return;
+ }
pfr->neighbors[pfr->tot_neighbors].index = index;
pfr->neighbors[pfr->tot_neighbors].psys = pfr->npsys;
@@ -1964,8 +2061,9 @@ static void sphclassical_force_cb(void *sphdata_v,
sub_v3_v3v3(vec, co, state->co);
rij = normalize_v3(vec);
rij_h = rij / pfr.h;
- if (rij_h > 2.0f)
+ if (rij_h > 2.0f) {
continue;
+ }
npressure = stiffness * (pow7f(npa->sphdensity / rest_density) - 1.0f);
@@ -1976,8 +2074,9 @@ static void sphclassical_force_cb(void *sphdata_v,
* Particles > 2h away are excluded above. */
dq = qfac2 * (2.0f * pow4f(2.0f - rij_h) - 4.0f * pow3f(2.0f - rij_h) * (1.0f + 2.0f * rij_h));
- if (pfn->psys->part->flag & PART_SIZEMASS)
+ if (pfn->psys->part->flag & PART_SIZEMASS) {
dq *= npa->size;
+ }
pressureTerm = pressure / pow2f(pa->sphdensity) + npressure / pow2f(npa->sphdensity);
@@ -1996,11 +2095,13 @@ static void sphclassical_force_cb(void *sphdata_v,
}
/* Artificial buoyancy force in negative gravity direction */
- if (fluid->buoyancy > 0.f && gravity)
+ if (fluid->buoyancy > 0.f && gravity) {
madd_v3_v3fl(force, gravity, fluid->buoyancy * (pa->sphdensity - rest_density));
+ }
- if (sphdata->pass == 0 && psys[0]->part->time_flag & PART_TIME_AUTOSF)
+ if (sphdata->pass == 0 && psys[0]->part->time_flag & PART_TIME_AUTOSF) {
sph_particle_courant(sphdata, &pfr);
+ }
sphdata->pass++;
}
@@ -2033,13 +2134,16 @@ void psys_sph_init(ParticleSimulationData *sim, SPHData *sphdata)
// Add other coupled particle systems.
sphdata->psys[0] = sim->psys;
- for (i = 1, pt = sim->psys->targets.first; i < 10; i++, pt = (pt ? pt->next : NULL))
+ for (i = 1, pt = sim->psys->targets.first; i < 10; i++, pt = (pt ? pt->next : NULL)) {
sphdata->psys[i] = pt ? psys_get_target_system(sim->ob, pt) : NULL;
+ }
- if (psys_uses_gravity(sim))
+ if (psys_uses_gravity(sim)) {
sphdata->gravity = sim->scene->physics_settings.gravity;
- else
+ }
+ else {
sphdata->gravity = NULL;
+ }
sphdata->eh = sph_springhash_build(sim->psys);
// These per-particle values should be overridden later, but just for
@@ -2104,7 +2208,7 @@ static void sph_integrate(ParticleSimulationData *sim,
sphdata->pa = pa;
sphdata->mass = pa_mass;
sphdata->pass = 0;
- //sphdata.element_size and sphdata.flow are set in the callback.
+ // sphdata.element_size and sphdata.flow are set in the callback.
/* restore previous state and treat gravity & effectors as external acceleration*/
sub_v3_v3v3(effector_acceleration, pa->state.vel, pa->prev_state.vel);
@@ -2115,6 +2219,8 @@ static void sph_integrate(ParticleSimulationData *sim,
integrate_particle(part, pa, dtime, effector_acceleration, sphdata->force_cb, sphdata);
}
+/** \} */
+
/************************************************/
/* Basic physics */
/************************************************/
@@ -2134,16 +2240,18 @@ static void basic_force_cb(void *efdata_v, ParticleKey *state, float *force, flo
/* add effectors */
pd_point_from_particle(efdata->sim, efdata->pa, state, &epoint);
- if (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)
+ if (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR) {
BKE_effectors_apply(
sim->psys->effectors, sim->colliders, part->effector_weights, &epoint, force, impulse);
+ }
mul_v3_fl(force, efdata->ptex.field);
mul_v3_fl(impulse, efdata->ptex.field);
/* calculate air-particle interaction */
- if (part->dragfac != 0.0f)
+ if (part->dragfac != 0.0f) {
madd_v3_v3fl(force, state->vel, -part->dragfac * pa->size * pa->size * len_v3(state->vel));
+ }
/* brownian force */
if (part->brownfac != 0.0f) {
@@ -2152,8 +2260,9 @@ static void basic_force_cb(void *efdata_v, ParticleKey *state, float *force, flo
force[2] += (BLI_rng_get_float(rng) - 0.5f) * part->brownfac;
}
- if (part->flag & PART_ROT_DYN && epoint.ave)
+ if (part->flag & PART_ROT_DYN && epoint.ave) {
copy_v3_v3(pa->state.ave, epoint.ave);
+ }
}
/* gathers all forces that effect particles and calculates a new state for the particle */
static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, float cfra)
@@ -2187,10 +2296,11 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
integrate_particle(part, pa, dtime, gravity, basic_force_cb, &efdata);
/* damp affects final velocity */
- if (part->dampfac != 0.f)
+ if (part->dampfac != 0.f) {
mul_v3_fl(pa->state.vel, 1.f - part->dampfac * efdata.ptex.damp * 25.f * dtime);
+ }
- //copy_v3_v3(pa->state.ave, states->ave);
+ // copy_v3_v3(pa->state.ave, states->ave);
/* finally we do guides */
time = (cfra - pa->time) / pa->lifetime;
@@ -2292,10 +2402,12 @@ static float nr_signed_distance_to_plane(float *p,
d = dot_v3v3(p0, nor);
if (pce->inv_nor == -1) {
- if (d < 0.f)
+ if (d < 0.f) {
pce->inv_nor = 1;
- else
+ }
+ else {
pce->inv_nor = 0;
+ }
}
if (pce->inv_nor == 1) {
@@ -2334,7 +2446,8 @@ static void collision_interpolate_element(ParticleCollisionElement *pce,
{
/* t is the current time for newton rhapson */
/* fac is the starting factor for current collision iteration */
- /* the col->fac's are factors for the particle subframe step start and end during collision modifier step */
+ /* The col->fac's are factors for the particle subframe step start
+ * and end during collision modifier step. */
float f = fac + t * (1.f - fac);
float mul = col->fac1 + f * (col->fac2 - col->fac1);
if (pce->tot > 0) {
@@ -2343,8 +2456,9 @@ static void collision_interpolate_element(ParticleCollisionElement *pce,
if (pce->tot > 1) {
madd_v3_v3v3fl(pce->x1, pce->x[1], pce->v[1], mul);
- if (pce->tot > 2)
+ if (pce->tot > 2) {
madd_v3_v3v3fl(pce->x2, pce->x[2], pce->v[2], mul);
+ }
}
}
}
@@ -2367,8 +2481,9 @@ static void collision_point_velocity(ParticleCollisionElement *pce)
static float collision_point_distance_with_normal(
float p[3], ParticleCollisionElement *pce, float fac, ParticleCollision *col, float *nor)
{
- if (fac >= 0.f)
+ if (fac >= 0.f) {
collision_interpolate_element(pce, 0.f, fac, col);
+ }
switch (pce->tot) {
case 1: {
@@ -2424,8 +2539,9 @@ static void collision_point_on_surface(
cross_v3_v3v3(nor, e1, e2);
normalize_v3(nor);
- if (pce->inv_nor == 1)
+ if (pce->inv_nor == 1) {
negate_v3(nor);
+ }
madd_v3_v3v3fl(co, pce->x0, nor, col->radius);
madd_v3_v3fl(co, e1, pce->uv[0]);
@@ -2489,8 +2605,9 @@ static float collision_newton_rhapson(ParticleCollision *col,
d1 = 0.f;
continue;
}
- else
+ else {
return -1.f;
+ }
}
dd = (t1 - t0) / (d1 - d0);
@@ -2510,20 +2627,23 @@ static float collision_newton_rhapson(ParticleCollision *col,
d1 = 0.f;
continue;
}
- else if (iter == 1 && (t1 < -COLLISION_ZERO || t1 > 1.f))
+ else if (iter == 1 && (t1 < -COLLISION_ZERO || t1 > 1.f)) {
return -1.f;
+ }
if (d1 <= COLLISION_ZERO && d1 >= -COLLISION_ZERO) {
if (t1 >= -COLLISION_ZERO && t1 <= 1.f) {
- if (distance_func == nr_signed_distance_to_plane)
+ if (distance_func == nr_signed_distance_to_plane) {
copy_v3_v3(pce->nor, n);
+ }
CLAMP(t1, 0.f, 1.f);
return t1;
}
- else
+ else {
return -1.f;
+ }
}
}
return -1.0;
@@ -2603,8 +2723,9 @@ static int collision_sphere_to_edges(ParticleCollision *col,
sub_v3_v3v3(vec, cur->p, cur->x0);
u = dot_v3v3(vec, e) / dot_v3v3(e, e);
- if (u < 0.f || u > 1.f)
+ if (u < 0.f || u > 1.f) {
break;
+ }
*result = *cur;
@@ -2703,8 +2824,9 @@ static int collision_detect(ParticleData *pa,
ColliderCache *coll;
float ray_dir[3];
- if (BLI_listbase_is_empty(colliders))
+ if (BLI_listbase_is_empty(colliders)) {
return 0;
+ }
sub_v3_v3v3(ray_dir, col->co2, col->co1);
hit->index = -1;
@@ -2713,8 +2835,9 @@ static int collision_detect(ParticleData *pa,
/* even if particle is stationary we want to check for moving colliders */
/* if hit.dist is zero the bvhtree_ray_cast will just ignore everything */
- if (hit->dist == 0.0f)
+ if (hit->dist == 0.0f) {
hit->dist = col->original_ray_length = 0.000001f;
+ }
for (coll = colliders->first; coll; coll = coll->next) {
/* for boids: don't check with current ground object; also skip if permeated */
@@ -2727,12 +2850,14 @@ static int collision_detect(ParticleData *pa,
}
}
- if (skip)
+ if (skip) {
continue;
+ }
/* particles should not collide with emitter at birth */
- if (coll->ob == col->emitter && pa->time < col->cfra && pa->time >= col->old_cfra)
+ if (coll->ob == col->emitter && pa->time < col->cfra && pa->time >= col->old_cfra) {
continue;
+ }
col->current = coll->ob;
col->md = coll->collmd;
@@ -2815,7 +2940,8 @@ static int collision_response(ParticleSimulationData *sim,
/* get exact velocity right before collision */
madd_v3_v3v3fl(v0, col->ve1, col->acc, dt1);
- /* convert collider velocity from 1/framestep to 1/s TODO: here we assume 1 frame step for collision modifier */
+ /* Convert collider velocity from 1/framestep to 1/s TODO:
+ * here we assume 1 frame step for collision modifier. */
mul_v3_fl(pce->vel, col->inv_timestep);
/* calculate tangential particle velocity */
@@ -2870,12 +2996,15 @@ static int collision_response(ParticleSimulationData *sim,
}
}
- /* stickiness was possibly added before, so cancel that before calculating new normal velocity */
- /* otherwise particles go flying out of the surface because of high reversed sticky velocity */
+ /* Stickiness was possibly added before,
+ * so cancel that before calculating new normal velocity.
+ * Otherwise particles go flying out of the surface
+ * because of high reversed sticky velocity. */
if (v0_dot < 0.0f) {
v0_dot += pd->pdef_stickness;
- if (v0_dot > 0.0f)
+ if (v0_dot > 0.0f) {
v0_dot = 0.0f;
+ }
}
/* damping and flipping of velocity around normal */
@@ -2885,12 +3014,15 @@ static int collision_response(ParticleSimulationData *sim,
/* calculate normal particle velocity */
/* special case for object hitting the particle from behind */
if (through == 0 && ((vc_dot > 0.0f && v0_dot > 0.0f && vc_dot > v0_dot) ||
- (vc_dot < 0.0f && v0_dot < 0.0f && vc_dot < v0_dot)))
+ (vc_dot < 0.0f && v0_dot < 0.0f && vc_dot < v0_dot))) {
mul_v3_v3fl(v0_nor, pce->nor, vc_dot);
- else if (v0_dot > 0.f)
+ }
+ else if (v0_dot > 0.f) {
mul_v3_v3fl(v0_nor, pce->nor, vc_dot + v0_dot);
- else
+ }
+ else {
mul_v3_v3fl(v0_nor, pce->nor, vc_dot + (through ? 1.0f : -1.0f) * v0_dot);
+ }
/* combine components together again */
add_v3_v3v3(v0, v0_nor, v0_tan);
@@ -2913,21 +3045,25 @@ static int collision_response(ParticleSimulationData *sim,
if (!through) {
distance = collision_point_distance_with_normal(co, pce, -1.f, col, nor);
- if (distance < col->radius + COLLISION_MIN_DISTANCE)
+ if (distance < col->radius + COLLISION_MIN_DISTANCE) {
madd_v3_v3fl(co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
+ }
dot = dot_v3v3(nor, v0);
- if (dot < 0.f)
+ if (dot < 0.f) {
madd_v3_v3fl(v0, nor, -dot);
+ }
distance = collision_point_distance_with_normal(pa->state.co, pce, 1.f, col, nor);
- if (distance < col->radius + COLLISION_MIN_DISTANCE)
+ if (distance < col->radius + COLLISION_MIN_DISTANCE) {
madd_v3_v3fl(pa->state.co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
+ }
dot = dot_v3v3(nor, pa->state.vel);
- if (dot < 0.f)
+ if (dot < 0.f) {
madd_v3_v3fl(pa->state.vel, nor, -dot);
+ }
}
/* add stickiness to surface */
@@ -3017,15 +3153,18 @@ static void collision_check(ParticleSimulationData *sim, int p, float dfra, floa
collision_count++;
- if (collision_count == PARTICLE_COLLISION_MAX_COLLISIONS)
+ if (collision_count == PARTICLE_COLLISION_MAX_COLLISIONS) {
collision_fail(pa, &col);
+ }
else if (collision_response(
sim, pa, &col, &hit, part->flag & PART_DIE_ON_COL, part->flag & PART_ROT_DYN) ==
- 0)
+ 0) {
return;
+ }
}
- else
+ else {
return;
+ }
}
}
/************************************************/
@@ -3043,48 +3182,58 @@ static void psys_update_path_cache(ParticleSimulationData *sim,
if ((psys->part->childtype &&
psys->totchild != psys_get_tot_child(sim->scene, psys, use_render_params)) ||
- psys->recalc & ID_RECALC_PSYS_RESET)
+ psys->recalc & ID_RECALC_PSYS_RESET) {
alloc = 1;
+ }
if (alloc || psys->recalc & ID_RECALC_PSYS_CHILD ||
- (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
+ (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT))) {
distr = 1;
+ }
if (distr) {
- if (alloc)
+ if (alloc) {
realloc_particles(sim, sim->psys->totpart);
+ }
if (psys_get_tot_child(sim->scene, psys, use_render_params)) {
/* don't generate children while computing the hair keys */
if (!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) {
distribute_particles(sim, PART_FROM_CHILD);
- if (part->childtype == PART_CHILD_FACES && part->parents != 0.0f)
+ if (part->childtype == PART_CHILD_FACES && part->parents != 0.0f) {
psys_find_parents(sim, use_render_params);
+ }
}
}
- else
+ else {
psys_free_children(psys);
+ }
}
if ((part->type == PART_HAIR || psys->flag & PSYS_KEYED ||
- psys->pointcache->flag & PTCACHE_BAKED) == 0)
+ psys->pointcache->flag & PTCACHE_BAKED) == 0) {
skip = 1; /* only hair, keyed and baked stuff can have paths */
+ }
else if (part->ren_as != PART_DRAW_PATH &&
- !(part->type == PART_HAIR && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)))
+ !(part->type == PART_HAIR && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR))) {
skip = 1; /* particle visualization must be set as path */
+ }
else if (DEG_get_mode(sim->depsgraph) != DAG_EVAL_RENDER) {
- if (part->draw_as != PART_DRAW_REND)
+ if (part->draw_as != PART_DRAW_REND) {
skip = 1; /* draw visualization */
- else if (psys->pointcache->flag & PTCACHE_BAKING)
+ }
+ else if (psys->pointcache->flag & PTCACHE_BAKING) {
skip = 1; /* no need to cache paths while baking dynamics */
-
+ }
else if (psys_in_edit_mode(sim->depsgraph, psys)) {
- if ((pset->flag & PE_DRAW_PART) == 0)
+ if ((pset->flag & PE_DRAW_PART) == 0) {
skip = 1;
+ }
else if (part->childtype == 0 &&
- (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) == 0)
+ (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) == 0) {
skip = 1; /* in edit mode paths are needed for child particles and dynamic hair */
+ }
}
}
@@ -3093,17 +3242,21 @@ static void psys_update_path_cache(ParticleSimulationData *sim,
/* for render, child particle paths are computed on the fly */
if (part->childtype) {
- if (!psys->totchild)
+ if (!psys->totchild) {
skip = 1;
- else if (psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DONE) == 0)
+ }
+ else if (psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DONE) == 0) {
skip = 1;
+ }
- if (!skip)
+ if (!skip) {
psys_cache_child_paths(sim, cfra, 0, use_render_params);
+ }
}
}
- else if (psys->pathcache)
+ else if (psys->pathcache) {
psys_free_path_cache(psys, NULL);
+ }
}
static bool psys_hair_use_simulation(ParticleData *pa, float max_length)
@@ -3119,13 +3272,15 @@ static bool psys_hair_use_simulation(ParticleData *pa, float max_length)
HairKey *key;
int k;
- if (pa->totkey < 2)
+ if (pa->totkey < 2) {
return false;
+ }
for (k = 1, key = pa->hair + 1; k < pa->totkey; k++, key++) {
float length = len_v3v3(key->co, (key - 1)->co);
- if (length < min_length)
+ if (length < min_length) {
return false;
+ }
}
return true;
@@ -3187,8 +3342,9 @@ static void hair_create_input_mesh(ParticleSimulationData *sim,
if (!(pa->flag & PARS_UNEXIST)) {
for (k = 1, key = pa->hair + 1; k < pa->totkey; k++, key++) {
float length = len_v3v3(key->co, (key - 1)->co);
- if (max_length < length)
+ if (max_length < length) {
max_length = length;
+ }
}
}
}
@@ -3263,14 +3419,17 @@ static void hair_create_input_mesh(ParticleSimulationData *sim,
}
/* roots and disabled hairs should be 1.0, the rest can be anything from 0.0 to 1.0 */
- if (use_hair)
+ if (use_hair) {
dvert = hair_set_pinning(dvert, key->weight);
- else
+ }
+ else {
dvert = hair_set_pinning(dvert, 1.0f);
+ }
mvert++;
- if (k)
+ if (k) {
medge++;
+ }
}
hair_index += pa->totkey + 1;
@@ -3327,8 +3486,9 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
hair_create_input_mesh(sim, totpoint, totedge, &psys->hair_in_mesh, &psys->clmd->hairdata);
- if (psys->hair_out_mesh)
+ if (psys->hair_out_mesh) {
BKE_id_free(NULL, psys->hair_out_mesh);
+ }
psys->clmd->point_cache = psys->pointcache;
/* for hair sim we replace the internal cloth effector weights temporarily
@@ -3358,26 +3518,31 @@ static void hair_step(ParticleSimulationData *sim, float cfra, const bool use_re
LOOP_PARTICLES
{
pa->size = part->size;
- if (part->randsize > 0.0f)
+ if (part->randsize > 0.0f) {
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
+ }
- if (psys_frand(psys, p) > disp)
+ if (psys_frand(psys, p) > disp) {
pa->flag |= PARS_NO_DISP;
- else
+ }
+ else {
pa->flag &= ~PARS_NO_DISP;
+ }
}
if (psys->recalc & ID_RECALC_PSYS_RESET) {
/* need this for changing subsurf levels */
psys_calc_dmcache(sim->ob, sim->psmd->mesh_final, sim->psmd->mesh_original, psys);
- if (psys->clmd)
+ if (psys->clmd) {
cloth_free_modifier(psys->clmd);
+ }
}
/* dynamics with cloth simulation, psys->particles can be NULL with 0 particles [#25519] */
- if (psys->part->type == PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS && psys->particles)
+ if (psys->part->type == PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS && psys->particles) {
do_hair_dynamics(sim);
+ }
/* following lines were removed r29079 but cause bug [#22811], see report for details */
psys_update_effectors(sim);
@@ -3397,8 +3562,9 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
psys->lattice_deform_data = psys_create_lattice_deform_data(sim);
- if (psys->totpart == 0)
+ if (psys->totpart == 0) {
return;
+ }
/* save new keys for elements if needed */
LOOP_PARTICLES
@@ -3427,7 +3593,8 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
pa->totkey++;
- /* root is always in the origin of hair space so we set it to be so after the last key is saved*/
+ /* Root is always in the origin of hair space
+ * so we set it to be so after the last key is saved. */
if (pa->totkey == psys->part->hair_step + 1) {
zero_v3(root->co);
}
@@ -3471,34 +3638,43 @@ static float get_base_time_step(ParticleSettings *part)
static void update_timestep(ParticleSystem *psys, ParticleSimulationData *sim)
{
float dt_target;
- if (sim->courant_num == 0.0f)
+ if (sim->courant_num == 0.0f) {
dt_target = 1.0f;
- else
+ }
+ else {
dt_target = psys->dt_frac * (psys->part->courant_target / sim->courant_num);
+ }
/* Make sure the time step is reasonable. For some reason, the CLAMP macro
* doesn't work here. The time step becomes too large. - z0r */
- if (dt_target < MIN_TIMESTEP)
+ if (dt_target < MIN_TIMESTEP) {
dt_target = MIN_TIMESTEP;
- else if (dt_target > get_base_time_step(psys->part))
+ }
+ else if (dt_target > get_base_time_step(psys->part)) {
dt_target = get_base_time_step(psys->part);
+ }
/* Decrease time step instantly, but increase slowly. */
- if (dt_target > psys->dt_frac)
+ if (dt_target > psys->dt_frac) {
psys->dt_frac = interpf(dt_target, psys->dt_frac, TIMESTEP_EXPANSION_FACTOR);
- else
+ }
+ else {
psys->dt_frac = dt_target;
+ }
}
static float sync_timestep(ParticleSystem *psys, float t_frac)
{
/* Sync with frame end if it's close. */
- if (t_frac == 1.0f)
+ if (t_frac == 1.0f) {
return psys->dt_frac;
- else if (t_frac + (psys->dt_frac * TIMESTEP_EXPANSION_TOLERANCE) >= 1.0f)
+ }
+ else if (t_frac + (psys->dt_frac * TIMESTEP_EXPANSION_TOLERANCE) >= 1.0f) {
return 1.0f - t_frac;
- else
+ }
+ else {
return psys->dt_frac;
+ }
}
/************************************************/
@@ -3538,8 +3714,9 @@ static void dynamics_step_sph_ddr_task_cb_ex(void *__restrict userdata,
/* actual fluids calculations */
sph_integrate(sim, pa, pa->state.time, sphdata);
- if (sim->colliders)
+ if (sim->colliders) {
collision_check(sim, p, pa->state.time, data->cfra);
+ }
/* SPH particles are not physical particles, just interpolation
* particles, thus rotation has not a direct sense for them */
@@ -3603,8 +3780,9 @@ static void dynamics_step_sph_classical_integrate_task_cb_ex(
/* actual fluids calculations */
sph_integrate(sim, pa, pa->state.time, sphdata);
- if (sim->colliders)
+ if (sim->colliders) {
collision_check(sim, p, pa->state.time, data->cfra);
+ }
/* SPH particles are not physical particles, just interpolation
* particles, thus rotation has not a direct sense for them */
@@ -3639,8 +3817,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
{
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
pa->size = part->size * ptex.size;
- if (part->randsize > 0.0f)
+ if (part->randsize > 0.0f) {
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
+ }
reset_particle(sim, pa, dtime, cfra);
}
@@ -3652,8 +3831,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
psys_update_effectors(sim);
- if (part->type != PART_HAIR)
+ if (part->type != PART_HAIR) {
sim->colliders = BKE_collider_cache_create(sim->depsgraph, sim->ob, part->collision_group);
+ }
/* initialize physics type specific stuff */
switch (part->phystype) {
@@ -3684,8 +3864,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
for (; pt;
pt = pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */
- if (pt->ob)
+ if (pt->ob) {
psys_update_particle_bvhtree(BLI_findlink(&pt->ob->particlesystem, pt->psys - 1), cfra);
+ }
}
break;
}
@@ -3698,8 +3879,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
pa->size = part->size * ptex.size;
- if (part->randsize > 0.0f)
+ if (part->randsize > 0.0f) {
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
+ }
birthtime = pa->time;
dietime = pa->dietime;
@@ -3731,8 +3913,10 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
reset_particle(sim, pa, dtime, cfra);
}
- if (ELEM(pa->alive, PARS_ALIVE, PARS_DYING) == 0 || (pa->flag & (PARS_UNEXIST | PARS_NO_DISP)))
+ if (ELEM(pa->alive, PARS_ALIVE, PARS_DYING) == 0 ||
+ (pa->flag & (PARS_UNEXIST | PARS_NO_DISP))) {
pa->state.time = -1.f;
+ }
}
switch (part->phystype) {
@@ -3743,8 +3927,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
basic_integrate(sim, p, pa->state.time, cfra);
/* deflection */
- if (sim->colliders)
+ if (sim->colliders) {
collision_check(sim, p, pa->state.time, cfra);
+ }
/* rotations */
basic_rotate(part, pa, pa->state.time, timestep);
@@ -3762,8 +3947,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
boid_body(&bbd, pa);
/* deflection */
- if (sim->colliders)
+ if (sim->colliders) {
collision_check(sim, p, pa->state.time, cfra);
+ }
}
}
break;
@@ -3857,8 +4043,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
pa->alive = PARS_DEAD;
pa->state.time = pa->dietime;
}
- else
+ else {
pa->state.time = cfra;
+ }
}
BKE_collider_cache_free(&sim->colliders);
@@ -3868,18 +4055,21 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
static void update_children(ParticleSimulationData *sim, const bool use_render_params)
{
- if ((sim->psys->part->type == PART_HAIR) && (sim->psys->flag & PSYS_HAIR_DONE) == 0)
+ if ((sim->psys->part->type == PART_HAIR) && (sim->psys->flag & PSYS_HAIR_DONE) == 0) {
/* don't generate children while growing hair - waste of time */
psys_free_children(sim->psys);
+ }
else if (sim->psys->part->childtype) {
- if (sim->psys->totchild != psys_get_tot_child(sim->scene, sim->psys, use_render_params))
+ if (sim->psys->totchild != psys_get_tot_child(sim->scene, sim->psys, use_render_params)) {
distribute_particles(sim, PART_FROM_CHILD);
+ }
else {
/* Children are up to date, nothing to do. */
}
}
- else
+ else {
psys_free_children(sim->psys);
+ }
}
/* updates cached particles' alive & other flags etc..*/
static void cached_step(ParticleSimulationData *sim, float cfra, const bool use_render_params)
@@ -3898,8 +4088,9 @@ static void cached_step(ParticleSimulationData *sim, float cfra, const bool use_
{
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
pa->size = part->size * ptex.size;
- if (part->randsize > 0.0f)
+ if (part->randsize > 0.0f) {
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
+ }
psys->lattice_deform_data = psys_create_lattice_deform_data(sim);
@@ -3908,23 +4099,28 @@ static void cached_step(ParticleSimulationData *sim, float cfra, const bool use_
/* update alive status and push events */
if (pa->time > cfra) {
pa->alive = PARS_UNBORN;
- if (part->flag & PART_UNBORN && (psys->pointcache->flag & PTCACHE_EXTERNAL) == 0)
+ if (part->flag & PART_UNBORN && (psys->pointcache->flag & PTCACHE_EXTERNAL) == 0) {
reset_particle(sim, pa, 0.0f, cfra);
+ }
}
- else if (dietime <= cfra)
+ else if (dietime <= cfra) {
pa->alive = PARS_DEAD;
- else
+ }
+ else {
pa->alive = PARS_ALIVE;
+ }
if (psys->lattice_deform_data) {
end_latt_deform(psys->lattice_deform_data);
psys->lattice_deform_data = NULL;
}
- if (psys_frand(psys, p) > disp)
+ if (psys_frand(psys, p) > disp) {
pa->flag |= PARS_NO_DISP;
- else
+ }
+ else {
pa->flag &= ~PARS_NO_DISP;
+ }
}
}
@@ -4005,7 +4201,7 @@ static void particles_fluid_step(ParticleSimulationData *sim,
float wrf;
gzread(gzf, &wrf, sizeof(wrf));
pa->state.co[j] = wrf;
- //fprintf(stderr,"Rj%d ",j);
+ // fprintf(stderr,"Rj%d ",j);
}
for (j = 0; j < 3; j++) {
float wrf;
@@ -4020,7 +4216,18 @@ static void particles_fluid_step(ParticleSimulationData *sim,
pa->dietime = sim->scene->r.efra + 1;
pa->lifetime = sim->scene->r.efra;
pa->alive = PARS_ALIVE;
- //if (a < 25) fprintf(stderr,"FSPARTICLE debug set %s, a%d = %f,%f,%f, life=%f\n", filename, a, pa->co[0],pa->co[1],pa->co[2], pa->lifetime );
+# if 0
+ if (a < 25) {
+ fprintf(stderr,
+ "FSPARTICLE debug set %s, a%d = %f,%f,%f, life=%f\n",
+ filename,
+ a,
+ pa->co[0],
+ pa->co[1],
+ pa->co[2],
+ pa->lifetime);
+ }
+# endif
}
else {
// skip...
@@ -4057,8 +4264,9 @@ static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNU
int oldtotpart = psys->totpart;
int totpart = tot_particles(psys, pid);
- if (totpart != oldtotpart)
+ if (totpart != oldtotpart) {
realloc_particles(sim, totpart);
+ }
return totpart - oldtotpart;
}
@@ -4084,8 +4292,9 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
psys_clear_temp_pointcache(psys);
/* set suitable cache range automatically */
- if ((cache->flag & (PTCACHE_BAKING | PTCACHE_BAKED)) == 0)
+ if ((cache->flag & (PTCACHE_BAKING | PTCACHE_BAKED)) == 0) {
psys_get_pointcache_start_end(sim->scene, psys, &cache->startframe, &cache->endframe);
+ }
pid = &ptcacheid;
BKE_ptcache_id_from_particles(pid, sim->ob, psys);
@@ -4135,8 +4344,9 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
BKE_ptcache_validate(cache, (int)cache_cfra);
- if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
+ if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) {
BKE_ptcache_write(pid, (int)cache_cfra);
+ }
return;
}
@@ -4151,11 +4361,13 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
}
/* if on second frame, write cache for first frame */
- if (psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0))
+ if (psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
BKE_ptcache_write(pid, startframe);
+ }
}
- else
+ else {
BKE_ptcache_invalidate(cache);
+ }
/* 3. do dynamics */
/* set particles to be not calculated TODO: can't work with pointcache */
@@ -4163,10 +4375,12 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
LOOP_PARTICLES
{
- if (psys_frand(psys, p) > disp)
+ if (psys_frand(psys, p) > disp) {
pa->flag |= PARS_NO_DISP;
- else
+ }
+ else {
pa->flag &= ~PARS_NO_DISP;
+ }
}
if (psys->totpart) {
@@ -4175,8 +4389,9 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
/* handle negative frame start at the first frame by doing
* all the steps before the first frame */
- if ((int)cfra == startframe && part->sta < startframe)
+ if ((int)cfra == startframe && part->sta < startframe) {
totframesback = (startframe - (int)part->sta);
+ }
if (!(part->time_flag & PART_TIME_AUTOSF)) {
/* Constant time step */
@@ -4199,8 +4414,9 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
dynamics_step(sim, cfra + dframe + t_frac - 1.f);
psys->cfra = cfra + dframe + t_frac - 1.f;
- if (part->time_flag & PART_TIME_AUTOSF)
+ if (part->time_flag & PART_TIME_AUTOSF) {
update_timestep(psys, sim);
+ }
/* Even without AUTOSF dt_frac may not add up to 1.0 due to float precision. */
dt_frac = sync_timestep(psys, t_frac);
}
@@ -4210,8 +4426,9 @@ static void system_step(ParticleSimulationData *sim, float cfra, const bool use_
/* 4. only write cache starting from second frame */
if (pid) {
BKE_ptcache_validate(cache, (int)cache_cfra);
- if ((int)cache_cfra != startframe)
+ if ((int)cache_cfra != startframe) {
BKE_ptcache_write(pid, (int)cache_cfra);
+ }
}
update_children(sim, use_render_params);
@@ -4231,18 +4448,22 @@ void psys_changed_type(Object *ob, ParticleSystem *psys)
BKE_ptcache_id_from_particles(&pid, ob, psys);
- if (part->phystype != PART_PHYS_KEYED)
+ if (part->phystype != PART_PHYS_KEYED) {
psys->flag &= ~PSYS_KEYED;
+ }
if (part->type == PART_HAIR) {
- if (ELEM(part->ren_as, PART_DRAW_NOT, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR) == 0)
+ if (ELEM(part->ren_as, PART_DRAW_NOT, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR) == 0) {
part->ren_as = PART_DRAW_PATH;
+ }
- if (part->distr == PART_DISTR_GRID)
+ if (part->distr == PART_DISTR_GRID) {
part->distr = PART_DISTR_JIT;
+ }
- if (ELEM(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH) == 0)
+ if (ELEM(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH) == 0) {
part->draw_as = PART_DRAW_REND;
+ }
CLAMP(part->path_start, 0.0f, 100.0f);
CLAMP(part->path_end, 0.0f, 100.0f);
@@ -4265,8 +4486,9 @@ void psys_check_boid_data(ParticleSystem *psys)
pa = psys->particles;
- if (!pa)
+ if (!pa) {
return;
+ }
if (psys->part && psys->part->phystype == PART_PHYS_BOIDS) {
if (!pa->boid) {
@@ -4371,11 +4593,13 @@ void particle_system_update(struct Depsgraph *depsgraph,
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
/* drawdata is outdated after ANY change */
- if (psys->pdd)
+ if (psys->pdd) {
psys->pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED;
+ }
- if (!psys_check_enabled(ob, psys, use_render_params))
+ if (!psys_check_enabled(ob, psys, use_render_params)) {
return;
+ }
cfra = DEG_get_ctime(depsgraph);
@@ -4389,12 +4613,14 @@ void particle_system_update(struct Depsgraph *depsgraph,
if (sim.psmd->flag & eParticleSystemFlag_psys_updated) {
sim.psmd->flag &= ~eParticleSystemFlag_psys_updated;
/* make sure it really was updated to cfra */
- if (psys->cfra == cfra)
+ if (psys->cfra == cfra) {
return;
+ }
}
- if (!sim.psmd->mesh_final)
+ if (!sim.psmd->mesh_final) {
return;
+ }
if (part->from != PART_FROM_VERT) {
BKE_mesh_tessface_ensure(sim.psmd->mesh_final);
@@ -4403,8 +4629,9 @@ void particle_system_update(struct Depsgraph *depsgraph,
/* to verify if we need to restore object afterwards */
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
- if (psys->recalc & ID_RECALC_PSYS_RESET)
+ if (psys->recalc & ID_RECALC_PSYS_RESET) {
psys->totunexist = 0;
+ }
/* setup necessary physics type dependent additional data if it doesn't yet exist */
psys_prepare_physics(&sim);
@@ -4441,9 +4668,10 @@ void particle_system_update(struct Depsgraph *depsgraph,
for (i = 0; i <= part->hair_step; i++) {
hcfra = 100.0f * (float)i / (float)psys->part->hair_step;
- if ((part->flag & PART_HAIR_REGROW) == 0)
+ if ((part->flag & PART_HAIR_REGROW) == 0) {
BKE_animsys_evaluate_animdata(
depsgraph, scene, &part_local->id, part_local->adt, hcfra, ADT_RECALC_ANIM);
+ }
system_step(&sim, hcfra, use_render_params);
psys->cfra = hcfra;
psys->recalc = 0;
@@ -4458,11 +4686,13 @@ void particle_system_update(struct Depsgraph *depsgraph,
psys->flag |= PSYS_HAIR_DONE;
psys->recalc = recalc;
}
- else if (psys->flag & PSYS_EDITED)
+ else if (psys->flag & PSYS_EDITED) {
psys->flag |= PSYS_HAIR_DONE;
+ }
- if (psys->flag & PSYS_HAIR_DONE)
+ if (psys->flag & PSYS_HAIR_DONE) {
hair_step(&sim, cfra, use_render_params);
+ }
break;
}
case PART_FLUID: {
@@ -4478,8 +4708,9 @@ void particle_system_update(struct Depsgraph *depsgraph,
bool free_unexisting = false;
/* Particles without dynamics haven't been reset yet because they don't use pointcache */
- if (psys->recalc & ID_RECALC_PSYS_RESET)
+ if (psys->recalc & ID_RECALC_PSYS_RESET) {
psys_reset(psys, PSYS_RESET_ALL);
+ }
if (emit_particles(&sim, NULL, cfra) || (psys->recalc & ID_RECALC_PSYS_RESET)) {
free_keyed_keys(psys);
@@ -4494,20 +4725,24 @@ void particle_system_update(struct Depsgraph *depsgraph,
LOOP_EXISTING_PARTICLES
{
pa->size = part->size;
- if (part->randsize > 0.0f)
+ if (part->randsize > 0.0f) {
pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
+ }
reset_particle(&sim, pa, 0.0, cfra);
- if (psys_frand(psys, p) > disp)
+ if (psys_frand(psys, p) > disp) {
pa->flag |= PARS_NO_DISP;
- else
+ }
+ else {
pa->flag &= ~PARS_NO_DISP;
+ }
}
/* free unexisting after resetting particles */
- if (free_unexisting)
+ if (free_unexisting) {
free_unexisting_particles(&sim);
+ }
if (part->phystype == PART_PHYS_KEYED) {
psys_count_keyed_targets(&sim);
@@ -4551,7 +4786,8 @@ void particle_system_update(struct Depsgraph *depsgraph,
}
}
- /* save matrix for duplicators, at rendertime the actual dupliobject's matrix is used so don't update! */
+ /* Save matrix for duplicators,
+ * at rendertime the actual dupliobject's matrix is used so don't update! */
invert_m4_m4(psys->imat, ob->obmat);
BKE_particle_batch_cache_dirty_tag(psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 445205a513a..c186394880b 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -101,27 +101,33 @@ int BB_widest_axis(const BB *bb)
{
float dim[3];
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < 3; ++i) {
dim[i] = bb->bmax[i] - bb->bmin[i];
+ }
if (dim[0] > dim[1]) {
- if (dim[0] > dim[2])
+ if (dim[0] > dim[2]) {
return 0;
- else
+ }
+ else {
return 2;
+ }
}
else {
- if (dim[1] > dim[2])
+ if (dim[1] > dim[2]) {
return 1;
- else
+ }
+ else {
return 2;
+ }
}
}
void BBC_update_centroid(BBC *bbc)
{
- for (int i = 0; i < 3; ++i)
+ for (int i = 0; i < 3; ++i) {
bbc->bcentroid[i] = (bbc->bmin[i] + bbc->bmax[i]) * 0.5f;
+ }
}
/* Not recursive */
@@ -148,12 +154,12 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node)
node->vb = vb;
}
-//void BKE_pbvh_node_BB_reset(PBVHNode *node)
+// void BKE_pbvh_node_BB_reset(PBVHNode *node)
//{
// BB_reset(&node->vb);
//}
//
-//void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3])
+// void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3])
//{
// BB_expand(&node->vb, co);
//}
@@ -174,13 +180,16 @@ static int partition_indices(int *prim_indices, int lo, int hi, int axis, float
{
int i = lo, j = hi;
for (;;) {
- for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++)
+ for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++) {
;
- for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--)
+ }
+ for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--) {
;
+ }
- if (!(i < j))
+ if (!(i < j)) {
return i;
+ }
SWAP(int, prim_indices[i], prim_indices[j]);
i++;
@@ -197,27 +206,34 @@ static int partition_indices_material(PBVH *bvh, int lo, int hi)
const void *first;
int i = lo, j = hi;
- if (bvh->looptri)
+ if (bvh->looptri) {
first = &mpoly[looptri[bvh->prim_indices[lo]].poly];
- else
+ }
+ else {
first = &flagmats[bvh->prim_indices[lo]];
+ }
for (;;) {
if (bvh->looptri) {
- for (; face_materials_match(first, &mpoly[looptri[indices[i]].poly]); i++)
+ for (; face_materials_match(first, &mpoly[looptri[indices[i]].poly]); i++) {
;
- for (; !face_materials_match(first, &mpoly[looptri[indices[j]].poly]); j--)
+ }
+ for (; !face_materials_match(first, &mpoly[looptri[indices[j]].poly]); j--) {
;
+ }
}
else {
- for (; grid_materials_match(first, &flagmats[indices[i]]); i++)
+ for (; grid_materials_match(first, &flagmats[indices[i]]); i++) {
;
- for (; !grid_materials_match(first, &flagmats[indices[j]]); j--)
+ }
+ for (; !grid_materials_match(first, &flagmats[indices[j]]); j--) {
;
+ }
}
- if (!(i < j))
+ if (!(i < j)) {
return i;
+ }
SWAP(int, bvh->prim_indices[i], bvh->prim_indices[j]);
i++;
@@ -228,8 +244,9 @@ void pbvh_grow_nodes(PBVH *bvh, int totnode)
{
if (UNLIKELY(totnode > bvh->node_mem_count)) {
bvh->node_mem_count = bvh->node_mem_count + (bvh->node_mem_count / 3);
- if (bvh->node_mem_count < totnode)
+ if (bvh->node_mem_count < totnode) {
bvh->node_mem_count = totnode;
+ }
bvh->nodes = MEM_recallocN(bvh->nodes, sizeof(PBVHNode) * bvh->node_mem_count);
}
@@ -300,8 +317,9 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node)
void *value = BLI_ghashIterator_getValue(&gh_iter);
int ndx = POINTER_AS_INT(value);
- if (ndx < 0)
+ if (ndx < 0) {
ndx = -ndx + node->uniq_verts - 1;
+ }
vert_indices[ndx] = POINTER_AS_INT(BLI_ghashIterator_getKey(&gh_iter));
}
@@ -310,8 +328,9 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node)
const int sides = 3;
for (int j = 0; j < sides; ++j) {
- if (face_vert_indices[i][j] < 0)
+ if (face_vert_indices[i][j] < 0) {
face_vert_indices[i][j] = -face_vert_indices[i][j] + node->uniq_verts - 1;
+ }
}
}
@@ -350,13 +369,15 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
/* grid hidden are present, have to check each element */
for (int y = 0; y < gridsize - 1; y++) {
for (int x = 0; x < gridsize - 1; x++) {
- if (!paint_is_grid_face_hidden(gh, gridsize, x, y))
+ if (!paint_is_grid_face_hidden(gh, gridsize, x, y)) {
totquad++;
+ }
}
}
}
- else
+ else {
totquad += gridarea;
+ }
}
return totquad;
@@ -380,8 +401,9 @@ static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc, int offset, int
/* Still need vb for searches */
update_vb(bvh, &bvh->nodes[node_index], prim_bbc, offset, count);
- if (bvh->looptri)
+ if (bvh->looptri) {
build_mesh_leaf_node(bvh, bvh->nodes + node_index);
+ }
else {
build_grid_leaf_node(bvh, bvh->nodes + node_index);
}
@@ -391,8 +413,9 @@ static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc, int offset, int
* same material (including flat/smooth shading), non-zero otherwise */
static bool leaf_needs_material_split(PBVH *bvh, int offset, int count)
{
- if (count <= 1)
+ if (count <= 1) {
return false;
+ }
if (bvh->looptri) {
const MLoopTri *first = &bvh->looptri[bvh->prim_indices[offset]];
@@ -411,8 +434,9 @@ static bool leaf_needs_material_split(PBVH *bvh, int offset, int count)
for (int i = offset + count - 1; i > offset; --i) {
int prim = bvh->prim_indices[i];
- if (!grid_materials_match(first, &bvh->grid_flag_mats[prim]))
+ if (!grid_materials_match(first, &bvh->grid_flag_mats[prim])) {
return true;
+ }
}
}
@@ -456,8 +480,9 @@ static void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc, int offs
if (!cb) {
cb = &cb_backing;
BB_reset(cb);
- for (int i = offset + count - 1; i >= offset; --i)
+ for (int i = offset + count - 1; i >= offset; --i) {
BB_expand(cb, prim_bbc[bvh->prim_indices[i]].bcentroid);
+ }
}
const int axis = BB_widest_axis(cb);
@@ -484,13 +509,16 @@ static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim)
{
if (totprim != bvh->totprim) {
bvh->totprim = totprim;
- if (bvh->nodes)
+ if (bvh->nodes) {
MEM_freeN(bvh->nodes);
- if (bvh->prim_indices)
+ }
+ if (bvh->prim_indices) {
MEM_freeN(bvh->prim_indices);
+ }
bvh->prim_indices = MEM_mallocN(sizeof(int) * totprim, "bvh prim indices");
- for (int i = 0; i < totprim; ++i)
+ for (int i = 0; i < totprim; ++i) {
bvh->prim_indices[i] = i;
+ }
bvh->totnode = 0;
if (bvh->node_mem_count < 100) {
bvh->node_mem_count = 100;
@@ -505,8 +533,8 @@ static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim)
/**
* Do a full rebuild with on Mesh data structure.
*
- * \note Unlike mpoly/mloop/verts, looptri is **totally owned** by PBVH (which means it may rewrite it if needed,
- * see #BKE_pbvh_apply_vertCos().
+ * \note Unlike mpoly/mloop/verts, looptri is **totally owned** by PBVH
+ * (which means it may rewrite it if needed, see #BKE_pbvh_apply_vertCos().
*/
void BKE_pbvh_build_mesh(PBVH *bvh,
const MPoly *mpoly,
@@ -514,6 +542,7 @@ void BKE_pbvh_build_mesh(PBVH *bvh,
MVert *verts,
int totvert,
struct CustomData *vdata,
+ struct CustomData *ldata,
const MLoopTri *looptri,
int looptri_num)
{
@@ -529,6 +558,7 @@ void BKE_pbvh_build_mesh(PBVH *bvh,
bvh->totvert = totvert;
bvh->leaf_limit = LEAF_LIMIT;
bvh->vdata = vdata;
+ bvh->ldata = ldata;
BB_reset(&cb);
@@ -542,16 +572,18 @@ void BKE_pbvh_build_mesh(PBVH *bvh,
BB_reset((BB *)bbc);
- for (int j = 0; j < sides; ++j)
+ for (int j = 0; j < sides; ++j) {
BB_expand((BB *)bbc, verts[bvh->mloop[lt->tri[j]].v].co);
+ }
BBC_update_centroid(bbc);
BB_expand(&cb, bbc->bcentroid);
}
- if (looptri_num)
+ if (looptri_num) {
pbvh_build(bvh, &cb, prim_bbc, looptri_num);
+ }
MEM_freeN(prim_bbc);
MEM_freeN(bvh->vert_bitmap);
@@ -589,16 +621,18 @@ void BKE_pbvh_build_grids(PBVH *bvh,
BB_reset((BB *)bbc);
- for (int j = 0; j < gridsize * gridsize; ++j)
+ for (int j = 0; j < gridsize * gridsize; ++j) {
BB_expand((BB *)bbc, CCG_elem_offset_co(key, grid, j));
+ }
BBC_update_centroid(bbc);
BB_expand(&cb, bbc->bcentroid);
}
- if (totgrid)
+ if (totgrid) {
pbvh_build(bvh, &cb, prim_bbc, totgrid);
+ }
MEM_freeN(prim_bbc);
}
@@ -616,20 +650,26 @@ void BKE_pbvh_free(PBVH *bvh)
PBVHNode *node = &bvh->nodes[i];
if (node->flag & PBVH_Leaf) {
- if (node->draw_buffers)
+ if (node->draw_buffers) {
GPU_pbvh_buffers_free(node->draw_buffers);
- if (node->vert_indices)
+ }
+ if (node->vert_indices) {
MEM_freeN((void *)node->vert_indices);
- if (node->face_vert_indices)
+ }
+ if (node->face_vert_indices) {
MEM_freeN((void *)node->face_vert_indices);
+ }
BKE_pbvh_node_layer_disp_free(node);
- if (node->bm_faces)
+ if (node->bm_faces) {
BLI_gset_free(node->bm_faces, NULL);
- if (node->bm_unique_verts)
+ }
+ if (node->bm_unique_verts) {
BLI_gset_free(node->bm_unique_verts, NULL);
- if (node->bm_other_verts)
+ }
+ if (node->bm_other_verts) {
BLI_gset_free(node->bm_other_verts, NULL);
+ }
}
}
@@ -645,19 +685,22 @@ void BKE_pbvh_free(PBVH *bvh)
MEM_freeN((void *)bvh->looptri);
}
- if (bvh->nodes)
+ if (bvh->nodes) {
MEM_freeN(bvh->nodes);
+ }
- if (bvh->prim_indices)
+ if (bvh->prim_indices) {
MEM_freeN(bvh->prim_indices);
+ }
MEM_freeN(bvh);
}
void BKE_pbvh_free_layer_disp(PBVH *bvh)
{
- for (int i = 0; i < bvh->totnode; ++i)
+ for (int i = 0; i < bvh->totnode; ++i) {
BKE_pbvh_node_layer_disp_free(&bvh->nodes[i]);
+ }
}
static void pbvh_iter_begin(PBVHIter *iter,
@@ -679,8 +722,9 @@ static void pbvh_iter_begin(PBVHIter *iter,
static void pbvh_iter_end(PBVHIter *iter)
{
- if (iter->stackspace > STACK_FIXED_DEPTH)
+ if (iter->stackspace > STACK_FIXED_DEPTH) {
MEM_freeN(iter->stack);
+ }
}
static void pbvh_stack_push(PBVHIter *iter, PBVHNode *node, bool revisiting)
@@ -713,17 +757,20 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter)
/* on a mesh with no faces this can happen
* can remove this check if we know meshes have at least 1 face */
- if (node == NULL)
+ if (node == NULL) {
return NULL;
+ }
bool revisiting = iter->stack[iter->stacksize].revisiting;
/* revisiting node already checked */
- if (revisiting)
+ if (revisiting) {
return node;
+ }
- if (iter->scb && !iter->scb(node, iter->search_data))
+ if (iter->scb && !iter->scb(node, iter->search_data)) {
continue; /* don't traverse, outside of search zone */
+ }
if (node->flag & PBVH_Leaf) {
/* immediately hit leaf node */
@@ -751,11 +798,13 @@ static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter)
/* on a mesh with no faces this can happen
* can remove this check if we know meshes have at least 1 face */
- if (node == NULL)
+ if (node == NULL) {
return NULL;
+ }
- if (iter->scb && !iter->scb(node, iter->search_data))
+ if (iter->scb && !iter->scb(node, iter->search_data)) {
continue; /* don't traverse, outside of search zone */
+ }
if (node->flag & PBVH_Leaf) {
/* immediately hit leaf node */
@@ -814,9 +863,11 @@ void BKE_pbvh_search_callback(PBVH *bvh,
pbvh_iter_begin(&iter, bvh, scb, search_data);
- while ((node = pbvh_iter_next(&iter)))
- if (node->flag & PBVH_Leaf)
+ while ((node = pbvh_iter_next(&iter))) {
+ if (node->flag & PBVH_Leaf) {
hcb(node, hit_data);
+ }
+ }
pbvh_iter_end(&iter);
}
@@ -853,13 +904,15 @@ static void traverse_tree(node_tree *tree,
void *hit_data,
float *tmin)
{
- if (tree->left)
+ if (tree->left) {
traverse_tree(tree->left, hcb, hit_data, tmin);
+ }
hcb(tree->data, hit_data, tmin);
- if (tree->right)
+ if (tree->right) {
traverse_tree(tree->right, hcb, hit_data, tmin);
+ }
}
static void free_tree(node_tree *tree)
@@ -925,8 +978,9 @@ static bool update_search_cb(PBVHNode *node, void *data_v)
{
int flag = POINTER_AS_INT(data_v);
- if (node->flag & PBVH_Leaf)
+ if (node->flag & PBVH_Leaf) {
return (node->flag & flag) != 0;
+ }
return true;
}
@@ -984,9 +1038,10 @@ static void pbvh_update_normals_accum_task_cb(void *__restrict userdata,
const int v = vtri[j];
if (bvh->verts[v].flag & ME_VERT_PBVH_UPDATE) {
- /* Note: This avoids `lock, add_v3_v3, unlock` and is five to ten times quicker than a spinlock.
- * Not exact equivalent though, since atomicity is only ensured for one component
- * of the vector at a time, but here it shall not make any sensible difference. */
+ /* Note: This avoids `lock, add_v3_v3, unlock`
+ * and is five to ten times quicker than a spinlock.
+ * Not exact equivalent though, since atomicity is only ensured for one component
+ * of the vector at a time, but here it shall not make any sensible difference. */
for (int k = 3; k--;) {
atomic_add_and_fetch_fl(&vnors[v][k], fn[k]);
}
@@ -1035,8 +1090,9 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, int totnode, float
return;
}
- if (bvh->type != PBVH_FACES)
+ if (bvh->type != PBVH_FACES) {
return;
+ }
/* could be per node to save some memory, but also means
* we have to store for each vertex which node it is in */
@@ -1079,16 +1135,19 @@ static void pbvh_update_BB_redraw_task_cb(void *__restrict userdata,
PBVHNode *node = data->nodes[n];
const int flag = data->flag;
- if ((flag & PBVH_UpdateBB) && (node->flag & PBVH_UpdateBB))
+ if ((flag & PBVH_UpdateBB) && (node->flag & PBVH_UpdateBB)) {
/* don't clear flag yet, leave it for flushing later */
/* Note that bvh usage is read-only here, so no need to thread-protect it. */
update_node_vb(bvh, node);
+ }
- if ((flag & PBVH_UpdateOriginalBB) && (node->flag & PBVH_UpdateOriginalBB))
+ if ((flag & PBVH_UpdateOriginalBB) && (node->flag & PBVH_UpdateOriginalBB)) {
node->orig_vb = node->vb;
+ }
- if ((flag & PBVH_UpdateRedraw) && (node->flag & PBVH_UpdateRedraw))
+ if ((flag & PBVH_UpdateRedraw) && (node->flag & PBVH_UpdateRedraw)) {
node->flag &= ~PBVH_UpdateRedraw;
+ }
}
void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag)
@@ -1106,14 +1165,15 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag)
BLI_task_parallel_range(0, totnode, &data, pbvh_update_BB_redraw_task_cb, &settings);
}
-static int pbvh_get_buffers_update_flags(PBVH *bvh)
+static int pbvh_get_buffers_update_flags(PBVH *bvh, bool show_vcol)
{
int update_flags = 0;
update_flags |= bvh->show_mask ? GPU_PBVH_BUFFERS_SHOW_MASK : 0;
+ update_flags |= show_vcol ? GPU_PBVH_BUFFERS_SHOW_VCOL : 0;
return update_flags;
}
-static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
+static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode, bool show_vcol)
{
/* can't be done in parallel with OpenGL */
for (int n = 0; n < totnode; n++) {
@@ -1144,7 +1204,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
}
if (node->flag & PBVH_UpdateDrawBuffers) {
- const int update_flags = pbvh_get_buffers_update_flags(bvh);
+ const int update_flags = pbvh_get_buffers_update_flags(bvh, show_vcol);
switch (bvh->type) {
case PBVH_GRIDS:
GPU_pbvh_grid_buffers_update(node->draw_buffers,
@@ -1161,6 +1221,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode)
node->vert_indices,
node->uniq_verts + node->face_verts,
CustomData_get_layer(bvh->vdata, CD_PAINT_MASK),
+ CustomData_get_layer(bvh->ldata, CD_MLOOPCOL),
node->face_vert_indices,
update_flags);
break;
@@ -1201,10 +1262,12 @@ static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag)
update |= pbvh_flush_bb(bvh, bvh->nodes + node->children_offset, flag);
update |= pbvh_flush_bb(bvh, bvh->nodes + node->children_offset + 1, flag);
- if (update & PBVH_UpdateBB)
+ if (update & PBVH_UpdateBB) {
update_node_vb(bvh, node);
- if (update & PBVH_UpdateOriginalBB)
+ }
+ if (update & PBVH_UpdateOriginalBB) {
node->orig_vb = node->vb;
+ }
}
return update;
@@ -1212,25 +1275,30 @@ static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag)
void BKE_pbvh_update(PBVH *bvh, int flag, float (*fnors)[3])
{
- if (!bvh->nodes)
+ if (!bvh->nodes) {
return;
+ }
PBVHNode **nodes;
int totnode;
BKE_pbvh_search_gather(bvh, update_search_cb, POINTER_FROM_INT(flag), &nodes, &totnode);
- if (flag & PBVH_UpdateNormals)
+ if (flag & PBVH_UpdateNormals) {
pbvh_update_normals(bvh, nodes, totnode, fnors);
+ }
- if (flag & (PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw))
+ if (flag & (PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw)) {
pbvh_update_BB_redraw(bvh, nodes, totnode, flag);
+ }
- if (flag & (PBVH_UpdateBB | PBVH_UpdateOriginalBB))
+ if (flag & (PBVH_UpdateBB | PBVH_UpdateOriginalBB)) {
pbvh_flush_bb(bvh, bvh->nodes, flag);
+ }
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
void BKE_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3])
@@ -1243,9 +1311,11 @@ void BKE_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3])
pbvh_iter_begin(&iter, bvh, NULL, NULL);
- while ((node = pbvh_iter_next(&iter)))
- if (node->flag & PBVH_UpdateRedraw)
+ while ((node = pbvh_iter_next(&iter))) {
+ if (node->flag & PBVH_UpdateRedraw) {
BB_expand_with_bb(&bb, &node->vb);
+ }
+ }
pbvh_iter_end(&iter);
@@ -1268,8 +1338,9 @@ void BKE_pbvh_get_grid_updates(PBVH *bvh, bool clear, void ***r_gridfaces, int *
BLI_gset_add(face_set, face);
}
- if (clear)
+ if (clear) {
node->flag &= ~PBVH_UpdateNormals;
+ }
}
}
@@ -1287,8 +1358,7 @@ void BKE_pbvh_get_grid_updates(PBVH *bvh, bool clear, void ***r_gridfaces, int *
GSetIterator gs_iter;
int i;
- GSET_ITER_INDEX(gs_iter, face_set, i)
- {
+ GSET_ITER_INDEX (gs_iter, face_set, i) {
faces[i] = BLI_gsetIterator_getKey(&gs_iter);
}
@@ -1380,10 +1450,12 @@ void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden)
{
BLI_assert(node->flag & PBVH_Leaf);
- if (fully_hidden)
+ if (fully_hidden) {
node->flag |= PBVH_FullyHidden;
- else
+ }
+ else {
node->flag &= ~PBVH_FullyHidden;
+ }
}
void BKE_pbvh_node_get_verts(PBVH *bvh,
@@ -1407,23 +1479,29 @@ void BKE_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *r_uniquevert, int *
switch (bvh->type) {
case PBVH_GRIDS:
tot = node->totprim * bvh->gridkey.grid_area;
- if (r_totvert)
+ if (r_totvert) {
*r_totvert = tot;
- if (r_uniquevert)
+ }
+ if (r_uniquevert) {
*r_uniquevert = tot;
+ }
break;
case PBVH_FACES:
- if (r_totvert)
+ if (r_totvert) {
*r_totvert = node->uniq_verts + node->face_verts;
- if (r_uniquevert)
+ }
+ if (r_uniquevert) {
*r_uniquevert = node->uniq_verts;
+ }
break;
case PBVH_BMESH:
tot = BLI_gset_len(node->bm_unique_verts);
- if (r_totvert)
+ if (r_totvert) {
*r_totvert = tot + BLI_gset_len(node->bm_other_verts);
- if (r_uniquevert)
+ }
+ if (r_uniquevert) {
*r_uniquevert = tot;
+ }
break;
}
}
@@ -1438,29 +1516,39 @@ void BKE_pbvh_node_get_grids(PBVH *bvh,
{
switch (bvh->type) {
case PBVH_GRIDS:
- if (r_grid_indices)
+ if (r_grid_indices) {
*r_grid_indices = node->prim_indices;
- if (r_totgrid)
+ }
+ if (r_totgrid) {
*r_totgrid = node->totprim;
- if (r_maxgrid)
+ }
+ if (r_maxgrid) {
*r_maxgrid = bvh->totgrid;
- if (r_gridsize)
+ }
+ if (r_gridsize) {
*r_gridsize = bvh->gridkey.grid_size;
- if (r_griddata)
+ }
+ if (r_griddata) {
*r_griddata = bvh->grids;
+ }
break;
case PBVH_FACES:
case PBVH_BMESH:
- if (r_grid_indices)
+ if (r_grid_indices) {
*r_grid_indices = NULL;
- if (r_totgrid)
+ }
+ if (r_totgrid) {
*r_totgrid = 0;
- if (r_maxgrid)
+ }
+ if (r_maxgrid) {
*r_maxgrid = 0;
- if (r_gridsize)
+ }
+ if (r_gridsize) {
*r_gridsize = 0;
- if (r_griddata)
+ }
+ if (r_griddata) {
*r_griddata = NULL;
+ }
break;
}
}
@@ -1480,16 +1568,20 @@ void BKE_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max
void BKE_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count)
{
if (node->proxy_count > 0) {
- if (proxies)
+ if (proxies) {
*proxies = node->proxies;
- if (proxy_count)
+ }
+ if (proxy_count) {
*proxy_count = node->proxy_count;
+ }
}
else {
- if (proxies)
+ if (proxies) {
*proxies = NULL;
- if (proxy_count)
+ }
+ if (proxy_count) {
*proxy_count = 0;
+ }
}
}
@@ -1700,8 +1792,9 @@ static bool pbvh_faces_node_raycast(PBVH *bvh,
const MLoopTri *lt = &bvh->looptri[faces[i]];
const int *face_verts = node->face_vert_indices[i];
- if (paint_is_face_hidden(lt, vert, mloop))
+ if (paint_is_face_hidden(lt, vert, mloop)) {
continue;
+ }
if (origco) {
/* intersect with backuped original coordinates */
@@ -1741,8 +1834,9 @@ static bool pbvh_grids_node_raycast(PBVH *bvh,
CCGElem *grid = bvh->grids[node->prim_indices[i]];
BLI_bitmap *gh;
- if (!grid)
+ if (!grid) {
continue;
+ }
gh = bvh->grid_hidden[node->prim_indices[i]];
@@ -1750,8 +1844,9 @@ static bool pbvh_grids_node_raycast(PBVH *bvh,
for (int x = 0; x < gridsize - 1; ++x) {
/* check if grid face is hidden */
if (gh) {
- if (paint_is_grid_face_hidden(gh, gridsize, x, y))
+ if (paint_is_grid_face_hidden(gh, gridsize, x, y)) {
continue;
+ }
}
if (origco) {
@@ -1775,8 +1870,9 @@ static bool pbvh_grids_node_raycast(PBVH *bvh,
}
}
- if (origco)
+ if (origco) {
origco += gridsize * gridsize;
+ }
}
return hit;
@@ -1792,8 +1888,9 @@ bool BKE_pbvh_node_raycast(PBVH *bvh,
{
bool hit = false;
- if (node->flag & PBVH_FullyHidden)
+ if (node->flag & PBVH_FullyHidden) {
return false;
+ }
switch (bvh->type) {
case PBVH_FACES:
@@ -1821,13 +1918,15 @@ void BKE_pbvh_raycast_project_ray_root(
float offset = 1.0f + 1e-3f;
float offset_vec[3] = {1e-3f, 1e-3f, 1e-3f};
- if (original)
+ if (original) {
BKE_pbvh_node_get_original_BB(bvh->nodes, bb_min_root, bb_max_root);
- else
+ }
+ else {
BKE_pbvh_node_get_BB(bvh->nodes, bb_min_root, bb_max_root);
+ }
- /* slightly offset min and max in case we have a zero width node (due to a plane mesh for instance),
- * or faces very close to the bounding box boundary. */
+ /* Slightly offset min and max in case we have a zero width node
+ * (due to a plane mesh for instance), or faces very close to the bounding box boundary. */
mid_v3_v3v3(bb_center, bb_max_root, bb_min_root);
/* diff should be same for both min/max since it's calculated from center */
sub_v3_v3v3(bb_diff, bb_max_root, bb_center);
@@ -1838,15 +1937,17 @@ void BKE_pbvh_raycast_project_ray_root(
/* first project start ray */
isect_ray_aabb_v3_precalc(&ray, ray_start, ray_normal);
- if (!isect_ray_aabb_v3(&ray, bb_min_root, bb_max_root, &rootmin_start))
+ if (!isect_ray_aabb_v3(&ray, bb_min_root, bb_max_root, &rootmin_start)) {
return;
+ }
/* then the end ray */
mul_v3_v3fl(ray_normal_inv, ray_normal, -1.0);
isect_ray_aabb_v3_precalc(&ray, ray_end, ray_normal_inv);
/* unlikely to fail exiting if entering succeeded, still keep this here */
- if (!isect_ray_aabb_v3(&ray, bb_min_root, bb_max_root, &rootmin_end))
+ if (!isect_ray_aabb_v3(&ray, bb_min_root, bb_max_root, &rootmin_end)) {
return;
+ }
madd_v3_v3v3fl(ray_start, ray_start, ray_normal, rootmin_start);
madd_v3_v3v3fl(ray_end, ray_end, ray_normal_inv, rootmin_end);
@@ -1916,8 +2017,9 @@ static bool pbvh_faces_node_nearest_to_ray(PBVH *bvh,
const MLoopTri *lt = &bvh->looptri[faces[i]];
const int *face_verts = node->face_vert_indices[i];
- if (paint_is_face_hidden(lt, vert, mloop))
+ if (paint_is_face_hidden(lt, vert, mloop)) {
continue;
+ }
if (origco) {
/* intersect with backuped original coordinates */
@@ -1960,8 +2062,9 @@ static bool pbvh_grids_node_nearest_to_ray(PBVH *bvh,
CCGElem *grid = bvh->grids[node->prim_indices[i]];
BLI_bitmap *gh;
- if (!grid)
+ if (!grid) {
continue;
+ }
gh = bvh->grid_hidden[node->prim_indices[i]];
@@ -1969,8 +2072,9 @@ static bool pbvh_grids_node_nearest_to_ray(PBVH *bvh,
for (int x = 0; x < gridsize - 1; ++x) {
/* check if grid face is hidden */
if (gh) {
- if (paint_is_grid_face_hidden(gh, gridsize, x, y))
+ if (paint_is_grid_face_hidden(gh, gridsize, x, y)) {
continue;
+ }
}
if (origco) {
@@ -1996,8 +2100,9 @@ static bool pbvh_grids_node_nearest_to_ray(PBVH *bvh,
}
}
- if (origco)
+ if (origco) {
origco += gridsize * gridsize;
+ }
}
return hit;
@@ -2014,8 +2119,9 @@ bool BKE_pbvh_node_find_nearest_to_ray(PBVH *bvh,
{
bool hit = false;
- if (node->flag & PBVH_FullyHidden)
+ if (node->flag & PBVH_FullyHidden) {
return false;
+ }
switch (bvh->type) {
case PBVH_FACES:
@@ -2065,10 +2171,12 @@ static PlaneAABBIsect test_planes_aabb(const float bb_min[3],
}
}
- if (dot_v3v3(planes[i], vmin) + planes[i][3] > 0)
+ if (dot_v3v3(planes[i], vmin) + planes[i][3] > 0) {
return ISECT_OUTSIDE;
- else if (dot_v3v3(planes[i], vmax) + planes[i][3] >= 0)
+ }
+ else if (dot_v3v3(planes[i], vmax) + planes[i][3] >= 0) {
ret = ISECT_INTERSECT;
+ }
}
return ret;
@@ -2126,6 +2234,7 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
bool fast,
bool wires,
bool only_mask,
+ bool show_vcol,
void (*draw_fn)(void *user_data, GPUBatch *batch),
void *user_data)
{
@@ -2146,10 +2255,11 @@ void BKE_pbvh_draw_cb(PBVH *bvh,
&totnode);
pbvh_update_normals(bvh, nodes, totnode, fnors);
- pbvh_update_draw_buffers(bvh, nodes, totnode);
+ pbvh_update_draw_buffers(bvh, nodes, totnode, show_vcol);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
if (planes) {
BKE_pbvh_search_callback(
@@ -2174,8 +2284,9 @@ void BKE_pbvh_grids_update(
bvh->grid_flag_mats = flagmats;
bvh->grid_hidden = grid_hidden;
- for (int a = 0; a < bvh->totnode; ++a)
+ for (int a = 0; a < bvh->totnode; ++a) {
BKE_pbvh_node_mark_rebuild_draw(&bvh->nodes[a]);
+ }
}
}
@@ -2231,7 +2342,8 @@ void BKE_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3], const int totvert)
/* unneeded deformation -- duplicate verts/faces to avoid this */
pbvh->verts = MEM_dupallocN(pbvh->verts);
- /* No need to dupalloc pbvh->looptri, this one is 'totally owned' by pbvh, it's never some mesh data. */
+ /* No need to dupalloc pbvh->looptri, this one is 'totally owned' by pbvh,
+ * it's never some mesh data. */
pbvh->deformed = true;
}
@@ -2252,8 +2364,9 @@ void BKE_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3], const int totvert)
BKE_mesh_calc_normals_looptri(
pbvh->verts, pbvh->totvert, pbvh->mloop, pbvh->looptri, pbvh->totprim, NULL);
- for (int a = 0; a < pbvh->totnode; ++a)
+ for (int a = 0; a < pbvh->totnode; ++a) {
BKE_pbvh_node_mark_update(&pbvh->nodes[a]);
+ }
BKE_pbvh_update(pbvh, PBVH_UpdateBB, NULL);
BKE_pbvh_update(pbvh, PBVH_UpdateOriginalBB, NULL);
@@ -2274,10 +2387,12 @@ PBVHProxyNode *BKE_pbvh_node_add_proxy(PBVH *bvh, PBVHNode *node)
node->proxy_count++;
- if (node->proxies)
+ if (node->proxies) {
node->proxies = MEM_reallocN(node->proxies, node->proxy_count * sizeof(PBVHProxyNode));
- else
+ }
+ else {
node->proxies = MEM_mallocN(sizeof(PBVHProxyNode), "PBVHNodeProxy");
+ }
BKE_pbvh_node_num_verts(bvh, node, &totverts, NULL);
node->proxies[index].co = MEM_callocN(sizeof(float[3]) * totverts, "PBVHNodeProxy.co");
@@ -2350,10 +2465,12 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, PBVHVertexIter *vi, int mo
vi->totgrid = (grids) ? totgrid : 1;
vi->gridsize = gridsize;
- if (mode == PBVH_ITER_ALL)
+ if (mode == PBVH_ITER_ALL) {
vi->totvert = totvert;
- else
+ }
+ else {
vi->totvert = uniq_verts;
+ }
vi->vert_indices = vert_indices;
vi->mverts = verts;
@@ -2365,12 +2482,14 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, PBVHVertexIter *vi, int mo
}
vi->gh = NULL;
- if (vi->grids && mode == PBVH_ITER_UNIQUE)
+ if (vi->grids && mode == PBVH_ITER_UNIQUE) {
vi->grid_hidden = bvh->grid_hidden;
+ }
vi->mask = NULL;
- if (bvh->type == PBVH_FACES)
+ if (bvh->type == PBVH_FACES) {
vi->vmask = CustomData_get_layer(bvh->vdata, CD_PAINT_MASK);
+ }
}
bool pbvh_has_mask(PBVH *bvh)
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index c007d5e3df7..25f9948a835 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -240,8 +240,9 @@ static void pbvh_bmesh_node_finalize(PBVH *bvh,
BB_expand(&n->vb, v->co);
} while ((l_iter = l_iter->next) != l_first);
- if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN))
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
has_visible = true;
+ }
}
BLI_assert(n->vb.bmin[0] <= n->vb.bmax[0] && n->vb.bmin[1] <= n->vb.bmax[1] &&
@@ -304,10 +305,12 @@ static void pbvh_bmesh_node_split(PBVH *bvh, const BBC *bbc_array, int node_inde
BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
const BBC *bbc = &bbc_array[BM_elem_index_get(f)];
- if (bbc->bcentroid[axis] < mid)
+ if (bbc->bcentroid[axis] < mid) {
BLI_gset_insert(c1->bm_faces, f);
- else
+ }
+ else {
BLI_gset_insert(c2->bm_faces, f);
+ }
}
/* Enforce at least one primitive in each node */
@@ -347,11 +350,13 @@ static void pbvh_bmesh_node_split(PBVH *bvh, const BBC *bbc_array, int node_inde
}
BLI_gset_free(n->bm_faces, NULL);
- if (n->bm_other_verts)
+ if (n->bm_other_verts) {
BLI_gset_free(n->bm_other_verts, NULL);
+ }
- if (n->layer_disp)
+ if (n->layer_disp) {
MEM_freeN(n->layer_disp);
+ }
n->bm_faces = NULL;
n->bm_unique_verts = NULL;
@@ -393,8 +398,7 @@ static bool pbvh_bmesh_node_limit_ensure(PBVH *bvh, int node_index)
GSetIterator gs_iter;
int i;
- GSET_ITER_INDEX(gs_iter, bm_faces, i)
- {
+ GSET_ITER_INDEX (gs_iter, bm_faces, i) {
BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
BBC *bbc = &bbc_array[i];
@@ -431,7 +435,6 @@ static int pbvh_bmesh_node_offset_from_elem(PBVH *bvh, BMElem *ele)
BLI_assert(ele->head.htype == BM_FACE);
return bvh->cd_face_node_offset;
}
-
}
static int pbvh_bmesh_node_index_from_elem(PBVH *bvh, void *key)
@@ -543,7 +546,7 @@ static int pbvh_bmesh_node_vert_use_count(PBVH *bvh, PBVHNode *node, BMVert *v)
BMFace *f;
int count = 0;
- BM_FACES_OF_VERT_ITER_BEGIN(f, v) {
+ BM_FACES_OF_VERT_ITER_BEGIN (f, v) {
PBVHNode *f_node = pbvh_bmesh_node_from_face(bvh, f);
if (f_node == node) {
count++;
@@ -709,10 +712,12 @@ static void pbvh_bmesh_edge_loops(BLI_Buffer *buf, BMEdge *e)
static void pbvh_bmesh_node_drop_orig(PBVHNode *node)
{
- if (node->bm_orco)
+ if (node->bm_orco) {
MEM_freeN(node->bm_orco);
- if (node->bm_ortri)
+ }
+ if (node->bm_ortri) {
MEM_freeN(node->bm_ortri);
+ }
node->bm_orco = NULL;
node->bm_ortri = NULL;
node->bm_tot_ortri = 0;
@@ -1157,8 +1162,9 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
v1 = l_adj->v;
v2 = l_adj->next->v;
- if (ni != node_index && i == 0)
+ if (ni != node_index && i == 0) {
pbvh_bmesh_vert_ownership_transfer(bvh, &bvh->nodes[ni], v_new);
+ }
/**
* The 2 new faces created and assigned to ``f_new`` have their
@@ -1250,8 +1256,9 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx,
/* At the moment edges never get shorter (subdiv will make new edges)
* unlike collapse where edges can become longer. */
#if 0
- if (len_squared_v3v3(v1->co, v2->co) <= eq_ctx->q->limit_len_squared)
+ if (len_squared_v3v3(v1->co, v2->co) <= eq_ctx->q->limit_len_squared) {
continue;
+ }
#else
BLI_assert(len_squared_v3v3(v1->co, v2->co) > eq_ctx->q->limit_len_squared);
#endif
@@ -1397,8 +1404,9 @@ static void pbvh_bmesh_collapse_edge(PBVH *bvh,
/* Check if any of the face's edges are now unused by any
* face, if so delete them */
for (int j = 0; j < 3; j++) {
- if (BM_edge_is_wire(e_tri[j]))
+ if (BM_edge_is_wire(e_tri[j])) {
BM_edge_kill(bvh->bm, e_tri[j]);
+ }
}
/* Check if any of the face's vertices are now unused, if so
@@ -1473,8 +1481,9 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
EDGE_QUEUE_DISABLE(e);
#endif
- if (len_squared_v3v3(v1->co, v2->co) >= min_len_squared)
+ if (len_squared_v3v3(v1->co, v2->co) >= min_len_squared) {
continue;
+ }
/* Check that the edge's vertices are still in the PBVH. It's
* possible that an edge collapse has deleted adjacent faces
@@ -1542,8 +1551,9 @@ bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node,
float *depth,
float *r_edge_length)
{
- if (node->flag & PBVH_FullyHidden)
+ if (node->flag & PBVH_FullyHidden) {
return 0;
+ }
GSetIterator gs_iter;
bool hit = false;
@@ -1820,8 +1830,9 @@ static void pbvh_bmesh_create_nodes_fast_recursive(
/* Update node bounding box */
} while ((l_iter = l_iter->next) != l_first);
- if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN))
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
has_visible = true;
+ }
BB_expand_with_bb(&n->vb, (BB *)bbc);
}
@@ -1861,8 +1872,9 @@ void BKE_pbvh_build_bmesh(PBVH *bvh,
/* TODO: choose leaf limit better */
bvh->leaf_limit = 100;
- if (smooth_shading)
+ if (smooth_shading) {
bvh->flags |= PBVH_DYNTOPO_SMOOTH_SHADING;
+ }
/* bounding box array of all faces, no need to recalculate every time */
BBC *bbc_array = MEM_mallocN(sizeof(BBC) * bm->totface, "BBC");
@@ -1904,7 +1916,8 @@ void BKE_pbvh_build_bmesh(PBVH *bvh,
/* start recursion, assign faces to nodes accordingly */
pbvh_bmesh_node_limit_ensure_fast(bvh, nodeinfo, bbc_array, &rootnode, arena);
- /* we now have all faces assigned to a node, next we need to assign those to the gsets of the nodes */
+ /* We now have all faces assigned to a node,
+ * next we need to assign those to the gsets of the nodes. */
/* Start with all faces in the root node */
bvh->nodes = MEM_callocN(sizeof(PBVHNode), "PBVHNode");
@@ -2003,8 +2016,9 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh,
void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node)
{
/* Skip if original coords/triangles are already saved */
- if (node->bm_orco)
+ if (node->bm_orco) {
return;
+ }
const int totvert = BLI_gset_len(node->bm_unique_verts) + BLI_gset_len(node->bm_other_verts);
@@ -2034,8 +2048,9 @@ void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node)
GSET_ITER (gs_iter, node->bm_faces) {
BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
- if (BM_elem_flag_test(f, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
continue;
+ }
#if 0
BMIter bm_iter;
@@ -2105,38 +2120,32 @@ static void pbvh_bmesh_print(PBVH *bvh)
BMIter iter;
BMFace *f;
- BM_ITER_MESH(f, &iter, bvh->bm, BM_FACES_OF_MESH) {
- fprintf(stderr, " %d -> %d\n",
- BM_elem_index_get(f),
- pbvh_bmesh_node_index_from_face(bvh, f));
+ BM_ITER_MESH (f, &iter, bvh->bm, BM_FACES_OF_MESH) {
+ fprintf(stderr, " %d -> %d\n", BM_elem_index_get(f), pbvh_bmesh_node_index_from_face(bvh, f));
}
fprintf(stderr, "bm_vert_to_node:\n");
BMVert *v;
- BM_ITER_MESH(v, &iter, bvh->bm, BM_FACES_OF_MESH) {
- fprintf(stderr, " %d -> %d\n",
- BM_elem_index_get(v),
- pbvh_bmesh_node_index_from_vert(bvh, v));
+ BM_ITER_MESH (v, &iter, bvh->bm, BM_FACES_OF_MESH) {
+ fprintf(stderr, " %d -> %d\n", BM_elem_index_get(v), pbvh_bmesh_node_index_from_vert(bvh, v));
}
for (int n = 0; n < bvh->totnode; n++) {
PBVHNode *node = &bvh->nodes[n];
- if (!(node->flag & PBVH_Leaf))
+ if (!(node->flag & PBVH_Leaf)) {
continue;
+ }
GSetIterator gs_iter;
fprintf(stderr, "node %d\n faces:\n", n);
GSET_ITER (gs_iter, node->bm_faces)
- fprintf(stderr, " %d\n",
- BM_elem_index_get((BMFace *)BLI_gsetIterator_getKey(&gs_iter)));
+ fprintf(stderr, " %d\n", BM_elem_index_get((BMFace *)BLI_gsetIterator_getKey(&gs_iter)));
fprintf(stderr, " unique verts:\n");
GSET_ITER (gs_iter, node->bm_unique_verts)
- fprintf(stderr, " %d\n",
- BM_elem_index_get((BMVert *)BLI_gsetIterator_getKey(&gs_iter)));
+ fprintf(stderr, " %d\n", BM_elem_index_get((BMVert *)BLI_gsetIterator_getKey(&gs_iter)));
fprintf(stderr, " other verts:\n");
GSET_ITER (gs_iter, node->bm_other_verts)
- fprintf(stderr, " %d\n",
- BM_elem_index_get((BMVert *)BLI_gsetIterator_getKey(&gs_iter)));
+ fprintf(stderr, " %d\n", BM_elem_index_get((BMVert *)BLI_gsetIterator_getKey(&gs_iter)));
}
}
@@ -2275,8 +2284,9 @@ static void pbvh_bmesh_verify(PBVH *bvh)
bool has_unique = false;
for (int i = 0; i < bvh->totnode; i++) {
PBVHNode *n = &bvh->nodes[i];
- if ((n->bm_unique_verts != NULL) && BLI_gset_haskey(n->bm_unique_verts, vi))
+ if ((n->bm_unique_verts != NULL) && BLI_gset_haskey(n->bm_unique_verts, vi)) {
has_unique = true;
+ }
}
BLI_assert(has_unique);
vert_count++;
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index 5fc41c560b2..74d7312e6a7 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -132,6 +132,7 @@ struct PBVH {
const MLoop *mloop;
const MLoopTri *looptri;
CustomData *vdata;
+ CustomData *ldata;
/* Grid Data */
CCGKey gridkey;
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 2d3914090b1..a55d0be4f95 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -153,22 +153,26 @@ static int ptcache_basic_header_read(PTCacheFile *pf)
int error = 0;
/* Custom functions should read these basic elements too! */
- if (!error && !fread(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
+ if (!error && !fread(&pf->totpoint, sizeof(unsigned int), 1, pf->fp)) {
error = 1;
+ }
- if (!error && !fread(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
+ if (!error && !fread(&pf->data_types, sizeof(unsigned int), 1, pf->fp)) {
error = 1;
+ }
return !error;
}
static int ptcache_basic_header_write(PTCacheFile *pf)
{
/* Custom functions should write these basic elements too! */
- if (!fwrite(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
+ if (!fwrite(&pf->totpoint, sizeof(unsigned int), 1, pf->fp)) {
return 0;
+ }
- if (!fwrite(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
+ if (!fwrite(&pf->data_types, sizeof(unsigned int), 1, pf->fp)) {
return 0;
+ }
return 1;
}
@@ -206,8 +210,9 @@ static void ptcache_softbody_interpolate(
ParticleKey keys[4];
float dfra;
- if (cfra1 == cfra2)
+ if (cfra1 == cfra2) {
return;
+ }
copy_v3_v3(keys[1].co, bp->pos);
copy_v3_v3(keys[1].vel, bp->vec);
@@ -216,8 +221,9 @@ static void ptcache_softbody_interpolate(
memcpy(keys[2].co, old_data, 3 * sizeof(float));
memcpy(keys[2].vel, old_data + 3, 3 * sizeof(float));
}
- else
+ else {
BKE_ptcache_make_particle_key(keys + 2, 0, data, cfra2);
+ }
dfra = cfra2 - cfra1;
@@ -267,8 +273,9 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfra
int step = psys->pointcache->step;
/* No need to store unborn or died particles outside cache step bounds */
- if (data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step))
+ if (data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step)) {
return 0;
+ }
times[0] = pa->time;
times[1] = pa->dietime;
@@ -286,7 +293,8 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfra
PTCACHE_DATA_FROM(data, BPHYS_DATA_BOIDS, &boid->data);
}
- /* return flag 1+1=2 for newly born particles to copy exact birth location to previously cached frame */
+ /* Return flag 1+1=2 for newly born particles
+ * to copy exact birth location to previously cached frame. */
return 1 + (pa->state.time >= pa->time && pa->prev_state.time <= pa->time);
}
static void ptcache_particle_read(
@@ -297,14 +305,16 @@ static void ptcache_particle_read(
BoidParticle *boid;
float timestep = 0.04f * psys->part->timetweak;
- if (index >= psys->totpart)
+ if (index >= psys->totpart) {
return;
+ }
pa = psys->particles + index;
boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL;
- if (cfra > pa->state.time)
+ if (cfra > pa->state.time) {
memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey));
+ }
if (old_data) {
/* old format cache */
@@ -315,10 +325,12 @@ static void ptcache_particle_read(
BKE_ptcache_make_particle_key(&pa->state, 0, data, cfra);
/* set frames cached before birth to birth time */
- if (cfra < pa->time)
+ if (cfra < pa->time) {
pa->state.time = pa->time;
- else if (cfra > pa->dietime)
+ }
+ else if (cfra > pa->dietime) {
pa->state.time = pa->dietime;
+ }
if (data[BPHYS_DATA_SIZE]) {
PTCACHE_DATA_TO(data, BPHYS_DATA_SIZE, 0, &pa->size);
@@ -361,28 +373,33 @@ static void ptcache_particle_interpolate(
ParticleKey keys[4];
float dfra, timestep = 0.04f * psys->part->timetweak;
- if (index >= psys->totpart)
+ if (index >= psys->totpart) {
return;
+ }
pa = psys->particles + index;
/* particle wasn't read from first cache so can't interpolate */
if ((int)cfra1 < pa->time - psys->pointcache->step ||
- (int)cfra1 > pa->dietime + psys->pointcache->step)
+ (int)cfra1 > pa->dietime + psys->pointcache->step) {
return;
+ }
cfra = MIN2(cfra, pa->dietime);
cfra1 = MIN2(cfra1, pa->dietime);
cfra2 = MIN2(cfra2, pa->dietime);
- if (cfra1 == cfra2)
+ if (cfra1 == cfra2) {
return;
+ }
memcpy(keys + 1, &pa->state, sizeof(ParticleKey));
- if (old_data)
+ if (old_data) {
memcpy(keys + 2, old_data, sizeof(ParticleKey));
- else
+ }
+ else {
BKE_ptcache_make_particle_key(keys + 2, 0, data, cfra2);
+ }
/* determine velocity from previous location */
if (data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
@@ -401,8 +418,9 @@ static void ptcache_particle_interpolate(
unit_qt(keys[2].rot);
}
- if (cfra > pa->time)
+ if (cfra > pa->time) {
cfra1 = MAX2(cfra1, pa->time);
+ }
dfra = cfra2 - cfra1;
@@ -435,11 +453,13 @@ static int ptcache_particle_totwrite(void *psys_v, int cfra)
int p, step = psys->pointcache->step;
int totwrite = 0;
- if (cfra == 0)
+ if (cfra == 0) {
return psys->totpart;
+ }
- for (p = 0; p < psys->totpart; p++, pa++)
+ for (p = 0; p < psys->totpart; p++, pa++) {
totwrite += (cfra >= pa->time - step && cfra <= pa->dietime + step);
+ }
return totwrite;
}
@@ -473,8 +493,9 @@ static void ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUS
for (; extra; extra = extra->next) {
switch (extra->type) {
case BPHYS_EXTRA_FLUID_SPRINGS: {
- if (psys->fluid_springs)
+ if (psys->fluid_springs) {
MEM_freeN(psys->fluid_springs);
+ }
psys->fluid_springs = MEM_dupallocN(extra->data);
psys->tot_fluidsprings = psys->alloc_fluidsprings = extra->totdata;
@@ -524,8 +545,9 @@ static void ptcache_cloth_interpolate(
ParticleKey keys[4];
float dfra;
- if (cfra1 == cfra2)
+ if (cfra1 == cfra2) {
return;
+ }
copy_v3_v3(keys[1].co, vert->x);
copy_v3_v3(keys[1].vel, vert->v);
@@ -534,8 +556,9 @@ static void ptcache_cloth_interpolate(
memcpy(keys[2].co, old_data, 3 * sizeof(float));
memcpy(keys[2].vel, old_data + 6, 3 * sizeof(float));
}
- else
+ else {
BKE_ptcache_make_particle_key(keys + 2, 0, data, cfra2);
+ }
dfra = cfra2 - cfra1;
@@ -574,8 +597,9 @@ static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra))
if (sds->fluid) {
return sds->base_res[0] * sds->base_res[1] * sds->base_res[2];
}
- else
+ else {
return 0;
+ }
}
static void ptcache_smoke_error(void *smoke_v, const char *message)
@@ -607,10 +631,11 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
unsigned int in_len = sizeof(float) * (unsigned int)res;
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4,
"pointcache_lzo_buffer");
- //int mode = res >= 1000000 ? 2 : 1;
+ // int mode = res >= 1000000 ? 2 : 1;
int mode = 1; // light
- if (sds->cache_comp == SM_CACHE_HEAVY)
+ if (sds->cache_comp == SM_CACHE_HEAVY) {
mode = 2; // heavy
+ }
smoke_export(sds->fluid,
&dt,
@@ -679,10 +704,11 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
smoke_turbulence_get_res(sds->wt, res_big_array);
res_big = res_big_array[0] * res_big_array[1] * res_big_array[2];
- //mode = res_big >= 1000000 ? 2 : 1;
+ // mode = res_big >= 1000000 ? 2 : 1;
mode = 1; // light
- if (sds->cache_high_comp == SM_CACHE_HEAVY)
+ if (sds->cache_high_comp == SM_CACHE_HEAVY) {
mode = 2; // heavy
+ }
in_len_big = sizeof(float) * (unsigned int)res_big;
@@ -831,14 +857,17 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
/* check if resolution has changed */
if (sds->res[0] != ch_res[0] || sds->res[1] != ch_res[1] || sds->res[2] != ch_res[2]) {
- if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN)
+ if (sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
reallocate = 1;
- else
+ }
+ else {
return 0;
+ }
}
/* check if active fields have changed */
- if (fluid_fields != cache_fields || active_fields != sds->active_fields)
+ if (fluid_fields != cache_fields || active_fields != sds->active_fields) {
reallocate = 1;
+ }
/* reallocate fluid if needed*/
if (reallocate) {
@@ -1323,10 +1352,12 @@ static int ptcache_dynamicpaint_totpoint(void *sd, int UNUSED(cfra))
{
DynamicPaintSurface *surface = (DynamicPaintSurface *)sd;
- if (!surface->data)
+ if (!surface->data) {
return 0;
- else
+ }
+ else {
return surface->data->total_points;
+ }
}
static void ptcache_dynamicpaint_error(void *UNUSED(sd), const char *UNUSED(message))
@@ -1393,8 +1424,9 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
/* cache type */
ptcache_file_read(pf, &surface_type, 1, sizeof(int));
- if (surface_type != surface->type)
+ if (surface_type != surface->type) {
return 0;
+ }
/* read surface data */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
@@ -1423,8 +1455,9 @@ static int ptcache_rigidbody_write(int index, void *rb_v, void **data, int UNUSE
RigidBodyWorld *rbw = rb_v;
Object *ob = NULL;
- if (rbw->objects)
+ if (rbw->objects) {
ob = rbw->objects[index];
+ }
if (ob && ob->rigidbody_object) {
RigidBodyOb *rbo = ob->rigidbody_object;
@@ -1447,8 +1480,9 @@ static void ptcache_rigidbody_read(
RigidBodyWorld *rbw = rb_v;
Object *ob = NULL;
- if (rbw->objects)
+ if (rbw->objects) {
ob = rbw->objects[index];
+ }
if (ob && ob->rigidbody_object) {
RigidBodyOb *rbo = ob->rigidbody_object;
@@ -1472,8 +1506,9 @@ static void ptcache_rigidbody_interpolate(
RigidBodyWorld *rbw = rb_v;
Object *ob = NULL;
- if (rbw->objects)
+ if (rbw->objects) {
ob = rbw->objects[index];
+ }
if (ob && ob->rigidbody_object) {
RigidBodyOb *rbo = ob->rigidbody_object;
@@ -1571,8 +1606,9 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
pid->cache_ptr = &psys->pointcache;
pid->ptcaches = &psys->ptcaches;
- if (psys->part->type != PART_HAIR)
+ if (psys->part->type != PART_HAIR) {
pid->flag |= PTCACHE_VEL_PER_SEC;
+ }
pid->totpoint = ptcache_particle_totpoint;
pid->totwrite = ptcache_particle_totwrite;
@@ -1598,9 +1634,10 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
pid->data_types = (1 << BPHYS_DATA_LOCATION) | (1 << BPHYS_DATA_VELOCITY) |
(1 << BPHYS_DATA_INDEX);
- if (psys->part->phystype == PART_PHYS_BOIDS)
+ if (psys->part->phystype == PART_PHYS_BOIDS) {
pid->data_types |= (1 << BPHYS_DATA_AVELOCITY) | (1 << BPHYS_DATA_ROTATION) |
(1 << BPHYS_DATA_BOIDS);
+ }
else if (psys->part->phystype == PART_PHYS_FLUID && psys->part->fluid &&
psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS) {
pid->write_extra_data = ptcache_particle_extra_write;
@@ -1700,10 +1737,12 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
pid->data_types = 0;
pid->info_types = 0;
- if (sds->fluid)
+ if (sds->fluid) {
pid->data_types |= (1 << BPHYS_DATA_SMOKE_LOW);
- if (sds->wt)
+ }
+ if (sds->wt) {
pid->data_types |= (1 << BPHYS_DATA_SMOKE_HIGH);
+ }
pid->default_step = 1;
pid->max_step = 1;
@@ -1838,9 +1877,7 @@ static bool foreach_object_particle_ptcache(Object *object,
}
/* Hair needs to be included in id-list for cache edit mode to work. */
#if 0
- if ((psys->part->type == PART_HAIR) &&
- (psys->flag & PSYS_HAIR_DYNAMICS) == 0)
- {
+ if ((psys->part->type == PART_HAIR) && (psys->flag & PSYS_HAIR_DYNAMICS) == 0) {
continue;
}
#endif
@@ -2032,8 +2069,9 @@ static int ptcache_path(PTCacheID *pid, char *filename)
i = strlen(file);
/* remove .blend */
- if (i > 6)
+ if (i > 6) {
file[i - 6] = '\0';
+ }
BLI_snprintf(filename,
MAX_PTCACHE_PATH,
@@ -2058,8 +2096,9 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
filename[0] = '\0';
newname = filename;
- if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL) == 0)
+ if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL) == 0) {
return 0; /* save blend file before using disk pointcache */
+ }
/* start with temp dir */
if (do_path) {
@@ -2083,21 +2122,24 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
}
if (do_ext) {
- if (pid->cache->index < 0)
+ if (pid->cache->index < 0) {
pid->cache->index = pid->stack_index = BKE_object_insert_ptcache(pid->ob);
+ }
const char *ext = ptcache_file_extension(pid);
if (pid->cache->flag & PTCACHE_EXTERNAL) {
- if (pid->cache->index >= 0)
+ if (pid->cache->index >= 0) {
BLI_snprintf(newname,
MAX_PTCACHE_FILE,
"_%06d_%02u%s",
cfra,
pid->stack_index,
ext); /* always 6 chars */
- else
+ }
+ else {
BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d%s", cfra, ext); /* always 6 chars */
+ }
}
else {
BLI_snprintf(newname,
@@ -2122,11 +2164,13 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
#ifndef DURIAN_POINTCACHE_LIB_OK
/* don't allow writing for linked objects */
- if (pid->ob->id.lib && mode == PTCACHE_FILE_WRITE)
+ if (pid->ob->id.lib && mode == PTCACHE_FILE_WRITE) {
return NULL;
+ }
#endif
- if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL) == 0)
+ if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL) == 0) {
return NULL; /* save blend file before using disk pointcache */
+ }
ptcache_filename(pid, filename, cfra, 1, 1);
@@ -2143,8 +2187,9 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
fp = BLI_fopen(filename, "rb+");
}
- if (!fp)
+ if (!fp) {
return NULL;
+ }
pf = MEM_mallocN(sizeof(PTCacheFile), "PTCacheFile");
pf->fp = fp;
@@ -2185,8 +2230,9 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result,
"pointcache_compressed_buffer");
ptcache_file_read(pf, in, in_len, sizeof(unsigned char));
#ifdef WITH_LZO
- if (compressed == 1)
+ if (compressed == 1) {
r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
+ }
#endif
#ifdef WITH_LZMA
if (compressed == 2) {
@@ -2226,10 +2272,12 @@ static int ptcache_file_compressed_write(
LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);
- if (!(r == LZO_E_OK) || (out_len >= in_len))
+ if (!(r == LZO_E_OK) || (out_len >= in_len)) {
compressed = 0;
- else
+ }
+ else {
compressed = 1;
+ }
}
#endif
#ifdef WITH_LZMA
@@ -2238,7 +2286,7 @@ static int ptcache_file_compressed_write(
r = LzmaCompress(out,
&out_len,
in,
- in_len, //assume sizeof(char)==1....
+ in_len, // assume sizeof(char)==1....
props,
&sizeOfIt,
5,
@@ -2249,10 +2297,12 @@ static int ptcache_file_compressed_write(
32,
2);
- if (!(r == SZ_OK) || (out_len >= in_len))
+ if (!(r == SZ_OK) || (out_len >= in_len)) {
compressed = 0;
- else
+ }
+ else {
compressed = 2;
+ }
}
#endif
@@ -2262,8 +2312,9 @@ static int ptcache_file_compressed_write(
ptcache_file_write(pf, &size, 1, sizeof(unsigned int));
ptcache_file_write(pf, out, out_len, sizeof(unsigned char));
}
- else
+ else {
ptcache_file_write(pf, in, in_len, sizeof(unsigned char));
+ }
if (compressed == 2) {
unsigned int size = sizeOfIt;
@@ -2288,8 +2339,10 @@ static int ptcache_file_data_read(PTCacheFile *pf)
int i;
for (i = 0; i < BPHYS_TOT_DATA; i++) {
- if ((pf->data_types & (1 << i)) && !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i]))
+ if ((pf->data_types & (1 << i)) &&
+ !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i])) {
return 0;
+ }
}
return 1;
@@ -2300,8 +2353,9 @@ static int ptcache_file_data_write(PTCacheFile *pf)
for (i = 0; i < BPHYS_TOT_DATA; i++) {
if ((pf->data_types & (1 << i)) &&
- !ptcache_file_write(pf, pf->cur[i], 1, ptcache_data_size[i]))
+ !ptcache_file_write(pf, pf->cur[i], 1, ptcache_data_size[i])) {
return 0;
+ }
}
return 1;
@@ -2314,21 +2368,25 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf)
pf->data_types = 0;
- if (fread(bphysics, sizeof(char), 8, pf->fp) != 8)
+ if (fread(bphysics, sizeof(char), 8, pf->fp) != 8) {
error = 1;
+ }
- if (!error && !STREQLEN(bphysics, "BPHYSICS", 8))
+ if (!error && !STREQLEN(bphysics, "BPHYSICS", 8)) {
error = 1;
+ }
- if (!error && !fread(&typeflag, sizeof(unsigned int), 1, pf->fp))
+ if (!error && !fread(&typeflag, sizeof(unsigned int), 1, pf->fp)) {
error = 1;
+ }
pf->type = (typeflag & PTCACHE_TYPEFLAG_TYPEMASK);
pf->flag = (typeflag & PTCACHE_TYPEFLAG_FLAGMASK);
/* if there was an error set file as it was */
- if (error)
+ if (error) {
fseek(pf->fp, 0, SEEK_SET);
+ }
return !error;
}
@@ -2337,11 +2395,13 @@ static int ptcache_file_header_begin_write(PTCacheFile *pf)
const char *bphysics = "BPHYSICS";
unsigned int typeflag = pf->type + pf->flag;
- if (fwrite(bphysics, sizeof(char), 8, pf->fp) != 8)
+ if (fwrite(bphysics, sizeof(char), 8, pf->fp) != 8) {
return 0;
+ }
- if (!fwrite(&typeflag, sizeof(unsigned int), 1, pf->fp))
+ if (!fwrite(&typeflag, sizeof(unsigned int), 1, pf->fp)) {
return 0;
+ }
return 1;
}
@@ -2374,22 +2434,27 @@ int BKE_ptcache_mem_index_find(PTCacheMem *pm, unsigned int index)
unsigned int *data = pm->data[BPHYS_DATA_INDEX];
unsigned int mid, low = 0, high = pm->totpoint - 1;
- if (index < *data || index > *(data + high))
+ if (index < *data || index > *(data + high)) {
return -1;
+ }
/* check simple case for continuous indexes first */
- if (index - *data < high && data[index - *data] == index)
+ if (index - *data < high && data[index - *data] == index) {
return index - *data;
+ }
while (low <= high) {
mid = (low + high) / 2;
- if (data[mid] > index)
+ if (data[mid] > index) {
high = mid - 1;
- else if (data[mid] < index)
+ }
+ else if (data[mid] < index) {
low = mid + 1;
- else
+ }
+ else {
return mid;
+ }
}
return -1;
@@ -2404,8 +2469,9 @@ void BKE_ptcache_mem_pointers_init(PTCacheMem *pm)
int data_types = pm->data_types;
int i;
- for (i = 0; i < BPHYS_TOT_DATA; i++)
+ for (i = 0; i < BPHYS_TOT_DATA; i++) {
pm->cur[i] = ((data_types & (1 << i)) ? pm->data[i] : NULL);
+ }
}
void BKE_ptcache_mem_pointers_incr(PTCacheMem *pm)
@@ -2413,8 +2479,9 @@ void BKE_ptcache_mem_pointers_incr(PTCacheMem *pm)
int i;
for (i = 0; i < BPHYS_TOT_DATA; i++) {
- if (pm->cur[i])
+ if (pm->cur[i]) {
pm->cur[i] = (char *)pm->cur[i] + ptcache_data_size[i];
+ }
}
}
int BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm)
@@ -2431,8 +2498,9 @@ int BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm)
return 0;
}
- for (i = 0; i < BPHYS_TOT_DATA; i++)
+ for (i = 0; i < BPHYS_TOT_DATA; i++) {
pm->cur[i] = data_types & (1 << i) ? (char *)pm->data[i] + index * ptcache_data_size[i] : NULL;
+ }
return 1;
}
@@ -2443,8 +2511,9 @@ static void ptcache_data_alloc(PTCacheMem *pm)
int i;
for (i = 0; i < BPHYS_TOT_DATA; i++) {
- if (data_types & (1 << i))
+ if (data_types & (1 << i)) {
pm->data[i] = MEM_callocN(totpoint * ptcache_data_size[i], "PTCache Data");
+ }
}
}
static void ptcache_data_free(PTCacheMem *pm)
@@ -2453,8 +2522,9 @@ static void ptcache_data_free(PTCacheMem *pm)
int i;
for (i = 0; i < BPHYS_TOT_DATA; i++) {
- if (data[i])
+ if (data[i]) {
MEM_freeN(data[i]);
+ }
}
}
static void ptcache_data_copy(void *from[], void *to[])
@@ -2463,8 +2533,9 @@ static void ptcache_data_copy(void *from[], void *to[])
for (i = 0; i < BPHYS_TOT_DATA; i++) {
/* note, durian file 03.4b_comp crashes if to[i] is not tested
* its NULL, not sure if this should be fixed elsewhere but for now its needed */
- if (from[i] && to[i])
+ if (from[i] && to[i]) {
memcpy(to[i], from[i], ptcache_data_size[i]);
+ }
}
}
@@ -2474,8 +2545,9 @@ static void ptcache_extra_free(PTCacheMem *pm)
if (extra) {
for (; extra; extra = extra->next) {
- if (extra->data)
+ if (extra->data) {
MEM_freeN(extra->data);
+ }
}
BLI_freelistN(&pm->extradata);
@@ -2483,12 +2555,15 @@ static void ptcache_extra_free(PTCacheMem *pm)
}
static int ptcache_old_elemsize(PTCacheID *pid)
{
- if (pid->type == PTCACHE_TYPE_SOFTBODY)
+ if (pid->type == PTCACHE_TYPE_SOFTBODY) {
return 6 * sizeof(float);
- else if (pid->type == PTCACHE_TYPE_PARTICLES)
+ }
+ else if (pid->type == PTCACHE_TYPE_PARTICLES) {
return sizeof(ParticleKey);
- else if (pid->type == PTCACHE_TYPE_CLOTH)
+ }
+ else if (pid->type == PTCACHE_TYPE_CLOTH) {
return 9 * sizeof(float);
+ }
return 0;
}
@@ -2498,17 +2573,21 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
int cfra1 = frame, cfra2 = frame + 1;
- while (cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1))
+ while (cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1)) {
cfra1--;
+ }
- if (cfra1 < pid->cache->startframe)
+ if (cfra1 < pid->cache->startframe) {
cfra1 = 0;
+ }
- while (cfra2 <= pid->cache->endframe && !BKE_ptcache_id_exist(pid, cfra2))
+ while (cfra2 <= pid->cache->endframe && !BKE_ptcache_id_exist(pid, cfra2)) {
cfra2++;
+ }
- if (cfra2 > pid->cache->endframe)
+ if (cfra2 > pid->cache->endframe) {
cfra2 = 0;
+ }
if (cfra1 && !cfra2) {
*fra1 = 0;
@@ -2523,8 +2602,9 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *
PTCacheMem *pm = pid->cache->mem_cache.first;
PTCacheMem *pm2 = pid->cache->mem_cache.last;
- while (pm->next && pm->next->frame <= frame)
+ while (pm->next && pm->next->frame <= frame) {
pm = pm->next;
+ }
if (pm2->frame < frame) {
pm2 = NULL;
@@ -2552,14 +2632,17 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
PTCacheMem *pm = NULL;
unsigned int i, error = 0;
- if (pf == NULL)
+ if (pf == NULL) {
return NULL;
+ }
- if (!ptcache_file_header_begin_read(pf))
+ if (!ptcache_file_header_begin_read(pf)) {
error = 1;
+ }
- if (!error && (pf->type != pid->type || !pid->read_header(pf)))
+ if (!error && (pf->type != pid->type || !pid->read_header(pf))) {
error = 1;
+ }
if (!error) {
pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem");
@@ -2573,8 +2656,9 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS) {
for (i = 0; i < BPHYS_TOT_DATA; i++) {
unsigned int out_len = pm->totpoint * ptcache_data_size[i];
- if (pf->data_types & (1 << i))
+ if (pf->data_types & (1 << i)) {
ptcache_file_compressed_read(pf, (unsigned char *)(pm->data[i]), out_len);
+ }
}
}
else {
@@ -2605,12 +2689,14 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
extra->data = MEM_callocN(extra->totdata * ptcache_extra_datasize[extra->type],
"Pointcache extradata->data");
- if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS)
+ if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS) {
ptcache_file_compressed_read(pf,
(unsigned char *)(extra->data),
extra->totdata * ptcache_extra_datasize[extra->type]);
- else
+ }
+ else {
ptcache_file_read(pf, extra->data, extra->totdata, ptcache_extra_datasize[extra->type]);
+ }
BLI_addtail(&pm->extradata, extra);
}
@@ -2625,8 +2711,9 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
ptcache_file_close(pf);
- if (error && G.debug & G_DEBUG)
+ if (error && G.debug & G_DEBUG) {
printf("Error reading from disk cache\n");
+ }
return pm;
}
@@ -2640,8 +2727,9 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame);
if (pf == NULL) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error opening disk cache file for writing\n");
+ }
return 0;
}
@@ -2650,14 +2738,17 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
pf->type = pid->type;
pf->flag = 0;
- if (pm->extradata.first)
+ if (pm->extradata.first) {
pf->flag |= PTCACHE_TYPEFLAG_EXTRADATA;
+ }
- if (pid->cache->compression)
+ if (pid->cache->compression) {
pf->flag |= PTCACHE_TYPEFLAG_COMPRESS;
+ }
- if (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf))
+ if (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)) {
error = 1;
+ }
if (!error) {
if (pid->cache->compression) {
@@ -2691,8 +2782,9 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
PTCacheExtra *extra = pm->extradata.first;
for (; extra; extra = extra->next) {
- if (extra->data == NULL || extra->totdata == 0)
+ if (extra->data == NULL || extra->totdata == 0) {
continue;
+ }
ptcache_file_write(pf, &extra->type, 1, sizeof(unsigned int));
ptcache_file_write(pf, &extra->totdata, 1, sizeof(unsigned int));
@@ -2713,8 +2805,9 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
ptcache_file_close(pf);
- if (error && G.debug & G_DEBUG)
+ if (error && G.debug & G_DEBUG) {
printf("Error writing to disk cache\n");
+ }
return error == 0;
}
@@ -2724,12 +2817,14 @@ static int ptcache_read_stream(PTCacheID *pid, int cfra)
PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra);
int error = 0;
- if (pid->read_stream == NULL)
+ if (pid->read_stream == NULL) {
return 0;
+ }
if (pf == NULL) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error opening disk cache file for reading\n");
+ }
return 0;
}
@@ -2771,8 +2866,9 @@ static int ptcache_read_openvdb_stream(PTCacheID *pid, int cfra)
char filename[FILE_MAX * 2];
/* save blend file before using disk pointcache */
- if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL) == 0)
+ if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL) == 0) {
return 0;
+ }
ptcache_filename(pid, filename, cfra, 1, 1);
@@ -2807,8 +2903,9 @@ static int ptcache_read(PTCacheID *pid, int cfra)
else {
pm = pid->cache->mem_cache.first;
- while (pm && pm->frame != cfra)
+ while (pm && pm->frame != cfra) {
pm = pm->next;
+ }
}
/* read the cache */
@@ -2827,16 +2924,18 @@ static int ptcache_read(PTCacheID *pid, int cfra)
BKE_ptcache_mem_pointers_init(pm);
for (i = 0; i < totpoint; i++) {
- if (pm->data_types & (1 << BPHYS_DATA_INDEX))
+ if (pm->data_types & (1 << BPHYS_DATA_INDEX)) {
index = pm->cur[BPHYS_DATA_INDEX];
+ }
pid->read_point(*index, pid->calldata, pm->cur, (float)pm->frame, NULL);
BKE_ptcache_mem_pointers_incr(pm);
}
- if (pid->read_extra_data && pm->extradata.first)
+ if (pid->read_extra_data && pm->extradata.first) {
pid->read_extra_data(pid->calldata, pm, (float)pm->frame);
+ }
/* clean up temporary memory cache */
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
@@ -2861,8 +2960,9 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
else {
pm = pid->cache->mem_cache.first;
- while (pm && pm->frame != cfra2)
+ while (pm && pm->frame != cfra2) {
pm = pm->next;
+ }
}
/* read the cache */
@@ -2881,16 +2981,18 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
BKE_ptcache_mem_pointers_init(pm);
for (i = 0; i < totpoint; i++) {
- if (pm->data_types & (1 << BPHYS_DATA_INDEX))
+ if (pm->data_types & (1 << BPHYS_DATA_INDEX)) {
index = pm->cur[BPHYS_DATA_INDEX];
+ }
pid->interpolate_point(
*index, pid->calldata, pm->cur, cfra, (float)cfra1, (float)cfra2, NULL);
BKE_ptcache_mem_pointers_incr(pm);
}
- if (pid->interpolate_extra_data && pm->extradata.first)
+ if (pid->interpolate_extra_data && pm->extradata.first) {
pid->interpolate_extra_data(pid->calldata, pm, cfra, (float)cfra1, (float)cfra2);
+ }
/* clean up temporary memory cache */
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
@@ -2910,8 +3012,9 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
int ret = 0;
/* nothing to read to */
- if (pid->totpoint(pid->calldata, cfrai) == 0)
+ if (pid->totpoint(pid->calldata, cfrai) == 0) {
return 0;
+ }
if (pid->cache->flag & PTCACHE_READ_INFO) {
pid->cache->flag &= ~PTCACHE_READ_INFO;
@@ -2919,27 +3022,33 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
}
/* first check if we have the actual frame cached */
- if (cfra == (float)cfrai && BKE_ptcache_id_exist(pid, cfrai))
+ if (cfra == (float)cfrai && BKE_ptcache_id_exist(pid, cfrai)) {
cfra1 = cfrai;
+ }
/* no exact cache frame found so try to find cached frames around cfra */
- if (cfra1 == 0)
+ if (cfra1 == 0) {
ptcache_find_frames_around(pid, cfrai, &cfra1, &cfra2);
+ }
- if (cfra1 == 0 && cfra2 == 0)
+ if (cfra1 == 0 && cfra2 == 0) {
return 0;
+ }
/* don't read old cache if already simulated past cached frame */
if (no_extrapolate_old) {
- if (cfra1 == 0 && cfra2 && cfra2 <= pid->cache->simframe)
+ if (cfra1 == 0 && cfra2 && cfra2 <= pid->cache->simframe) {
return 0;
- if (cfra1 && cfra1 == cfra2)
+ }
+ if (cfra1 && cfra1 == cfra2) {
return 0;
+ }
}
else {
/* avoid calling interpolate between the same frame values */
- if (cfra1 && cfra1 == cfra2)
+ if (cfra1 && cfra1 == cfra2) {
cfra1 = 0;
+ }
}
if (cfra1) {
@@ -2949,11 +3058,13 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
}
}
else if (pid->read_stream) {
- if (!ptcache_read_stream(pid, cfra1))
+ if (!ptcache_read_stream(pid, cfra1)) {
return 0;
+ }
}
- else if (pid->read_point)
+ else if (pid->read_point) {
ptcache_read(pid, cfra1);
+ }
}
if (cfra2) {
@@ -2963,19 +3074,23 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
}
}
else if (pid->read_stream) {
- if (!ptcache_read_stream(pid, cfra2))
+ if (!ptcache_read_stream(pid, cfra2)) {
return 0;
+ }
}
else if (pid->read_point) {
- if (cfra1 && cfra2 && pid->interpolate_point)
+ if (cfra1 && cfra2 && pid->interpolate_point) {
ptcache_interpolate(pid, cfra, cfra1, cfra2);
- else
+ }
+ else {
ptcache_read(pid, cfra2);
+ }
}
}
- if (cfra1)
+ if (cfra1) {
ret = (cfra2 ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT);
+ }
else if (cfra2) {
ret = PTCACHE_READ_OLD;
pid->cache->simframe = cfra2;
@@ -2987,8 +3102,9 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai);
}
else if (pid->cache->flag & PTCACHE_FRAMES_SKIPPED) {
- if (cfra <= pid->cache->last_exact)
+ if (cfra <= pid->cache->last_exact) {
pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
+ }
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact));
}
@@ -3005,8 +3121,9 @@ static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint)
pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra);
if (pf == NULL) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error opening disk cache file for writing\n");
+ }
return 0;
}
@@ -3015,16 +3132,19 @@ static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint)
pf->type = pid->type;
pf->flag = 0;
- if (!error && (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)))
+ if (!error && (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf))) {
error = 1;
+ }
- if (!error && pid->write_stream)
+ if (!error && pid->write_stream) {
pid->write_stream(pf, pid->calldata);
+ }
ptcache_file_close(pf);
- if (error && G.debug & G_DEBUG)
+ if (error && G.debug & G_DEBUG) {
printf("Error writing to disk cache\n");
+ }
return error == 0;
}
@@ -3069,13 +3189,15 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
if (cache->flag & PTCACHE_DISK_CACHE) {
int fra = cfra - 1;
- while (fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra))
+ while (fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra)) {
fra--;
+ }
pm2 = ptcache_disk_frame_to_mem(pid, fra);
}
- else
+ else {
pm2 = cache->mem_cache.last;
+ }
}
if (pid->write_point) {
@@ -3085,14 +3207,16 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
BKE_ptcache_mem_pointers_incr(pm);
/* newly born particles have to be copied to previous cached frame */
- if (overwrite && write == 2 && pm2 && BKE_ptcache_mem_pointers_seek(i, pm2))
+ if (overwrite && write == 2 && pm2 && BKE_ptcache_mem_pointers_seek(i, pm2)) {
pid->write_point(i, pid->calldata, pm2->cur, cfra);
+ }
}
}
}
- if (pid->write_extra_data)
+ if (pid->write_extra_data) {
pid->write_extra_data(pid->calldata, pm, cfra);
+ }
pm->frame = cfra;
@@ -3132,26 +3256,31 @@ static int ptcache_write_needed(PTCacheID *pid, int cfra, int *overwrite)
}
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
- if (cfra == 0 && cache->startframe > 0)
+ if (cfra == 0 && cache->startframe > 0) {
return 1;
+ }
/* find last cached frame */
- while (efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra))
+ while (efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra)) {
efra--;
+ }
/* find second last cached frame */
ofra = efra - 1;
- while (ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra))
+ while (ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra)) {
ofra--;
+ }
}
else {
PTCacheMem *pm = cache->mem_cache.last;
/* don't write info file in memory */
- if (cfra == 0)
+ if (cfra == 0) {
return 0;
+ }
- if (pm == NULL)
+ if (pm == NULL) {
return 1;
+ }
efra = pm->frame;
ofra = (pm->prev ? pm->prev->frame : efra - cache->step);
@@ -3175,11 +3304,13 @@ int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra)
int totpoint = pid->totpoint(pid->calldata, cfra);
int overwrite = 0, error = 0;
- if (totpoint == 0 || (cfra ? pid->data_types == 0 : pid->info_types == 0))
+ if (totpoint == 0 || (cfra ? pid->data_types == 0 : pid->info_types == 0)) {
return 0;
+ }
- if (ptcache_write_needed(pid, cfra, &overwrite) == 0)
+ if (ptcache_write_needed(pid, cfra, &overwrite) == 0) {
return 0;
+ }
if (pid->file_type == PTCACHE_FILE_OPENVDB && pid->write_openvdb_stream) {
ptcache_write_openvdb_stream(pid, cfra);
@@ -3197,12 +3328,14 @@ int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra)
cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
}
/* Don't mark skipped when writing info file (frame 0) */
- else if (cfra)
+ else if (cfra) {
cache->flag |= PTCACHE_FRAMES_SKIPPED;
+ }
/* Update timeline cache display */
- if (cfra && cache->cached_frames)
+ if (cfra && cache->cached_frames) {
cache->cached_frames[cfra - cache->startframe] = 1;
+ }
BKE_ptcache_update_info(pid);
@@ -3226,19 +3359,22 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
char path_full[MAX_PTCACHE_FILE];
char ext[MAX_PTCACHE_PATH];
- if (!pid || !pid->cache || pid->cache->flag & PTCACHE_BAKED)
+ if (!pid || !pid->cache || pid->cache->flag & PTCACHE_BAKED) {
return;
+ }
- if (pid->cache->flag & PTCACHE_IGNORE_CLEAR)
+ if (pid->cache->flag & PTCACHE_IGNORE_CLEAR) {
return;
+ }
sta = pid->cache->startframe;
end = pid->cache->endframe;
#ifndef DURIAN_POINTCACHE_LIB_OK
/* don't allow clearing for linked objects */
- if (pid->ob->id.lib)
+ if (pid->ob->id.lib) {
return;
+ }
#endif
/*if (!G.relbase_valid) return; */ /* save blend file before using pointcache */
@@ -3254,8 +3390,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
ptcache_path(pid, path);
dir = opendir(path);
- if (dir == NULL)
+ if (dir == NULL) {
return;
+ }
len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */
/* append underscore terminator to ensure we don't match similar names
@@ -3285,8 +3422,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
(mode == PTCACHE_CLEAR_AFTER && frame > cfra)) {
BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
BLI_delete(path_full, false, false);
- if (pid->cache->cached_frames && frame >= sta && frame <= end)
+ if (pid->cache->cached_frames && frame >= sta && frame <= end) {
pid->cache->cached_frames[frame - sta] = 0;
+ }
}
}
}
@@ -3295,8 +3433,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
closedir(dir);
- if (mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames)
+ if (mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames) {
memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
+ }
}
else {
PTCacheMem *pm = pid->cache->mem_cache.first;
@@ -3311,23 +3450,26 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
BLI_freelistN(&pid->cache->mem_cache);
- if (pid->cache->cached_frames)
+ if (pid->cache->cached_frames) {
memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
+ }
}
else {
while (pm) {
if ((mode == PTCACHE_CLEAR_BEFORE && pm->frame < cfra) ||
(mode == PTCACHE_CLEAR_AFTER && pm->frame > cfra)) {
link = pm;
- if (pid->cache->cached_frames && pm->frame >= sta && pm->frame <= end)
+ if (pid->cache->cached_frames && pm->frame >= sta && pm->frame <= end) {
pid->cache->cached_frames[pm->frame - sta] = 0;
+ }
ptcache_data_free(pm);
ptcache_extra_free(pm);
pm = pm->next;
BLI_freelinkN(&pid->cache->mem_cache, link);
}
- else
+ else {
pm = pm->next;
+ }
}
}
}
@@ -3352,8 +3494,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
}
}
- if (pid->cache->cached_frames && cfra >= sta && cfra <= end)
+ if (pid->cache->cached_frames && cfra >= sta && cfra <= end) {
pid->cache->cached_frames[cfra - sta] = 0;
+ }
break;
}
@@ -3361,14 +3504,17 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
{
- if (!pid->cache)
+ if (!pid->cache) {
return 0;
+ }
- if (cfra < pid->cache->startframe || cfra > pid->cache->endframe)
+ if (cfra < pid->cache->startframe || cfra > pid->cache->endframe) {
return 0;
+ }
- if (pid->cache->cached_frames && pid->cache->cached_frames[cfra - pid->cache->startframe] == 0)
+ if (pid->cache->cached_frames && pid->cache->cached_frames[cfra - pid->cache->startframe] == 0) {
return 0;
+ }
if (pid->cache->flag & PTCACHE_DISK_CACHE) {
char filename[MAX_PTCACHE_FILE];
@@ -3381,8 +3527,9 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
PTCacheMem *pm = pid->cache->mem_cache.first;
for (; pm; pm = pm->next) {
- if (pm->frame == cfra)
+ if (pm->frame == cfra) {
return 1;
+ }
}
return 0;
}
@@ -3453,8 +3600,9 @@ void BKE_ptcache_id_time(
len = ptcache_filename(pid, filename, (int)cfra, 0, 0); /* no path */
dir = opendir(path);
- if (dir == NULL)
+ if (dir == NULL) {
return;
+ }
const char *fext = ptcache_file_extension(pid);
@@ -3478,8 +3626,9 @@ void BKE_ptcache_id_time(
PTCacheMem *pm = pid->cache->mem_cache.first;
while (pm) {
- if (pm->frame >= sta && pm->frame <= end)
+ if (pm->frame >= sta && pm->frame <= end) {
cache->cached_frames[pm->frame - sta] = 1;
+ }
pm = pm->next;
}
}
@@ -3490,8 +3639,9 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
PointCache *cache;
int reset, clear, after;
- if (!pid->cache)
+ if (!pid->cache) {
return 0;
+ }
cache = pid->cache;
reset = 0;
@@ -3522,19 +3672,25 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
BKE_ptcache_invalidate(cache);
cache->flag &= ~PTCACHE_REDO_NEEDED;
- if (pid->type == PTCACHE_TYPE_CLOTH)
+ if (pid->type == PTCACHE_TYPE_CLOTH) {
cloth_free_modifier(pid->calldata);
- else if (pid->type == PTCACHE_TYPE_SOFTBODY)
+ }
+ else if (pid->type == PTCACHE_TYPE_SOFTBODY) {
sbFreeSimulation(pid->calldata);
- else if (pid->type == PTCACHE_TYPE_PARTICLES)
+ }
+ else if (pid->type == PTCACHE_TYPE_PARTICLES) {
psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH);
- else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT)
+ }
+ else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT) {
dynamicPaint_clearSurface(scene, (DynamicPaintSurface *)pid->calldata);
+ }
}
- if (clear)
+ if (clear) {
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
- else if (after)
+ }
+ else if (after) {
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, CFRA);
+ }
return (reset || clear || after);
}
@@ -3555,17 +3711,20 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
/* children or just redo can be calculated without resetting anything */
- if (psys->recalc & ID_RECALC_PSYS_REDO || psys->recalc & ID_RECALC_PSYS_CHILD)
+ if (psys->recalc & ID_RECALC_PSYS_REDO || psys->recalc & ID_RECALC_PSYS_CHILD) {
skip = 1;
- /* Baked cloth hair has to be checked too, because we don't want to reset */
- /* particles or cloth in that case -jahka */
+ /* Baked cloth hair has to be checked too, because we don't want to reset */
+ /* particles or cloth in that case -jahka */
+ }
else if (psys->clmd) {
BKE_ptcache_id_from_cloth(&pid, ob, psys->clmd);
if (mode == PSYS_RESET_ALL ||
- !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED)))
+ !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) {
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
- else
+ }
+ else {
skip = 1;
+ }
}
if (skip == 0 && psys->part) {
@@ -3600,15 +3759,17 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
}
if (scene->rigidbody_world && (ob->rigidbody_object || ob->rigidbody_constraint)) {
- if (ob->rigidbody_object)
+ if (ob->rigidbody_object) {
ob->rigidbody_object->flag |= RBO_FLAG_NEEDS_RESHAPE;
+ }
BKE_ptcache_id_from_rigidbody(&pid, ob, scene->rigidbody_world);
/* only flag as outdated, resetting should happen on start frame */
pid.cache->flag |= PTCACHE_OUTDATED;
}
- if (ob->type == OB_ARMATURE)
+ if (ob->type == OB_ARMATURE) {
BIK_clear_cache(ob->pose);
+ }
return reset;
}
@@ -3629,8 +3790,9 @@ void BKE_ptcache_remove(void)
struct dirent *de;
dir = opendir(path);
- if (dir == NULL)
+ if (dir == NULL) {
return;
+ }
while ((de = readdir(dir)) != NULL) {
if (FILENAME_IS_CURRPAR(de->d_name)) {
@@ -3689,10 +3851,12 @@ void BKE_ptcache_free_mem(ListBase *mem_cache)
void BKE_ptcache_free(PointCache *cache)
{
BKE_ptcache_free_mem(&cache->mem_cache);
- if (cache->edit && cache->free_edit)
+ if (cache->edit && cache->free_edit) {
cache->free_edit(cache->edit);
- if (cache->cached_frames)
+ }
+ if (cache->cached_frames) {
MEM_freeN(cache->cached_frames);
+ }
MEM_freeN(cache);
}
void BKE_ptcache_free_list(ListBase *ptcaches)
@@ -3728,8 +3892,9 @@ static PointCache *ptcache_copy(PointCache *cache, const bool copy_data)
int i;
for (i = 0; i < BPHYS_TOT_DATA; i++) {
- if (pmn->data[i])
+ if (pmn->data[i]) {
pmn->data[i] = MEM_dupallocN(pm->data[i]);
+ }
}
BKE_ptcache_mem_pointers_init(pm);
@@ -3737,8 +3902,9 @@ static PointCache *ptcache_copy(PointCache *cache, const bool copy_data)
BLI_addtail(&ncache->mem_cache, pmn);
}
- if (ncache->cached_frames)
+ if (ncache->cached_frames) {
ncache->cached_frames = MEM_dupallocN(cache->cached_frames);
+ }
}
/* hmm, should these be copied over instead? */
@@ -3786,14 +3952,17 @@ void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene, ViewLayer *view_laye
static void ptcache_dt_to_str(char *str, double dtime)
{
if (dtime > 60.0) {
- if (dtime > 3600.0)
+ if (dtime > 3600.0) {
sprintf(
str, "%ih %im %is", (int)(dtime / 3600), ((int)(dtime / 60)) % 60, ((int)dtime) % 60);
- else
+ }
+ else {
sprintf(str, "%im %is", ((int)(dtime / 60)) % 60, ((int)dtime) % 60);
+ }
}
- else
+ else {
sprintf(str, "%is", ((int)dtime) % 60);
+ }
}
/* if bake is not given run simulations to current frame */
@@ -3825,9 +3994,10 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
ParticleSystem *psys = pid->calldata;
/* a bit confusing, could make this work better in the UI */
- if (psys->part->type == PART_EMITTER)
+ if (psys->part->type == PART_EMITTER) {
psys_get_pointcache_start_end(
scene, pid->calldata, &cache->startframe, &cache->endframe);
+ }
}
else if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES) {
/* get all pids from the object and search for smoke low res */
@@ -3837,8 +4007,9 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
for (pid2 = pidlist2.first; pid2; pid2 = pid2->next) {
if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
if (pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) {
- if (bake || pid2->cache->flag & PTCACHE_REDO_NEEDED)
+ if (bake || pid2->cache->flag & PTCACHE_REDO_NEEDED) {
BKE_ptcache_id_clear(pid2, PTCACHE_CLEAR_ALL, 0);
+ }
if (bake) {
pid2->cache->flag |= PTCACHE_BAKING;
pid2->cache->flag &= ~PTCACHE_BAKED;
@@ -3849,8 +4020,9 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
BLI_freelistN(&pidlist2);
}
- if (bake || cache->flag & PTCACHE_REDO_NEEDED)
+ if (bake || cache->flag & PTCACHE_REDO_NEEDED) {
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+ }
startframe = MAX2(cache->last_exact, cache->startframe);
@@ -3876,8 +4048,9 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
if (pid->type == PTCACHE_TYPE_PARTICLES) {
ParticleSystem *psys = (ParticleSystem *)pid->calldata;
/* skip hair & keyed particles */
- if (psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED)
+ if (psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED) {
continue;
+ }
psys_get_pointcache_start_end(
scene, pid->calldata, &cache->startframe, &cache->endframe);
@@ -3900,8 +4073,9 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
if (bake || render) {
cache->flag |= PTCACHE_BAKING;
- if (bake)
+ if (bake) {
endframe = MAX2(endframe, cache->endframe);
+ }
}
cache->flag &= ~PTCACHE_BAKED;
@@ -3981,8 +4155,9 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
if (bake) {
cache->flag |= PTCACHE_BAKED;
/* write info file */
- if (cache->flag & PTCACHE_DISK_CACHE)
+ if (cache->flag & PTCACHE_DISK_CACHE) {
BKE_ptcache_write(pid, 0);
+ }
}
}
else {
@@ -3992,22 +4167,26 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
for (pid = pidlist.first; pid; pid = pid->next) {
/* skip hair particles */
if (pid->type == PTCACHE_TYPE_PARTICLES &&
- ((ParticleSystem *)pid->calldata)->part->type == PART_HAIR)
+ ((ParticleSystem *)pid->calldata)->part->type == PART_HAIR) {
continue;
+ }
cache = pid->cache;
- if (baker->quick_step > 1)
+ if (baker->quick_step > 1) {
cache->flag &= ~(PTCACHE_BAKING | PTCACHE_OUTDATED);
- else
+ }
+ else {
cache->flag &= ~(PTCACHE_BAKING | PTCACHE_REDO_NEEDED);
+ }
cache->flag |= PTCACHE_SIMULATION_VALID;
if (bake) {
cache->flag |= PTCACHE_BAKED;
- if (cache->flag & PTCACHE_DISK_CACHE)
+ if (cache->flag & PTCACHE_DISK_CACHE) {
BKE_ptcache_write(pid, 0);
+ }
}
}
BLI_freelistN(&pidlist);
@@ -4043,8 +4222,9 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid)
for (cfra = sfra; cfra <= efra; cfra++) {
pm = ptcache_disk_frame_to_mem(pid, cfra);
- if (pm)
+ if (pm) {
BLI_addtail(&pid->cache->mem_cache, pm);
+ }
}
}
void BKE_ptcache_mem_to_disk(PTCacheID *pid)
@@ -4070,8 +4250,9 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid)
}
/* write info file */
- if (cache->flag & PTCACHE_BAKED)
+ if (cache->flag & PTCACHE_BAKED) {
BKE_ptcache_write(pid, 0);
+ }
}
void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
{
@@ -4080,8 +4261,9 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
if (!G.relbase_valid) {
cache->flag &= ~PTCACHE_DISK_CACHE;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("File must be saved before using disk cache!\n");
+ }
return;
}
@@ -4091,10 +4273,12 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
cache->cached_frames_len = 0;
}
- if (cache->flag & PTCACHE_DISK_CACHE)
+ if (cache->flag & PTCACHE_DISK_CACHE) {
BKE_ptcache_mem_to_disk(pid);
- else
+ }
+ else {
BKE_ptcache_disk_to_mem(pid);
+ }
cache->flag ^= PTCACHE_DISK_CACHE;
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
@@ -4184,23 +4368,27 @@ void BKE_ptcache_load_external(PTCacheID *pid)
char filename[MAX_PTCACHE_FILE];
char ext[MAX_PTCACHE_PATH];
- if (!cache)
+ if (!cache) {
return;
+ }
ptcache_path(pid, path);
len = ptcache_filename(pid, filename, 1, 0, 0); /* no path */
dir = opendir(path);
- if (dir == NULL)
+ if (dir == NULL) {
return;
+ }
const char *fext = ptcache_file_extension(pid);
- if (cache->index >= 0)
+ if (cache->index >= 0) {
BLI_snprintf(ext, sizeof(ext), "_%02d%s", cache->index, fext);
- else
+ }
+ else {
BLI_strncpy(ext, fext, sizeof(ext));
+ }
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
@@ -4213,8 +4401,9 @@ void BKE_ptcache_load_external(PTCacheID *pid)
start = MIN2(start, frame);
end = MAX2(end, frame);
}
- else
+ else {
info = 1;
+ }
}
}
}
@@ -4255,8 +4444,9 @@ void BKE_ptcache_load_external(PTCacheID *pid)
pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cache->startframe);
if (pf) {
- while (ptcache_file_read(pf, old_data, 1, elemsize))
+ while (ptcache_file_read(pf, old_data, 1, elemsize)) {
cache->totpoint++;
+ }
ptcache_file_close(pf);
}
@@ -4285,17 +4475,21 @@ void BKE_ptcache_update_info(PTCacheID *pid)
int cfra = cache->startframe;
for (; cfra <= cache->endframe; cfra++) {
- if (BKE_ptcache_id_exist(pid, cfra))
+ if (BKE_ptcache_id_exist(pid, cfra)) {
totframes++;
+ }
}
/* smoke doesn't use frame 0 as info frame so can't check based on totpoint */
- if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes)
+ if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes) {
BLI_snprintf(cache->info, sizeof(cache->info), IFACE_("%i frames found!"), totframes);
- else if (totframes && cache->totpoint)
+ }
+ else if (totframes && cache->totpoint) {
BLI_snprintf(cache->info, sizeof(cache->info), IFACE_("%i points found!"), cache->totpoint);
- else
+ }
+ else {
BLI_strncpy(cache->info, IFACE_("No valid data to read!"), sizeof(cache->info));
+ }
return;
}
@@ -4303,18 +4497,21 @@ void BKE_ptcache_update_info(PTCacheID *pid)
if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
int totpoint = pid->totpoint(pid->calldata, 0);
- if (cache->totpoint > totpoint)
+ if (cache->totpoint > totpoint) {
BLI_snprintf(
mem_info, sizeof(mem_info), IFACE_("%i cells + High Resolution cached"), totpoint);
- else
+ }
+ else {
BLI_snprintf(mem_info, sizeof(mem_info), IFACE_("%i cells cached"), totpoint);
+ }
}
else {
int cfra = cache->startframe;
for (; cfra <= cache->endframe; cfra++) {
- if (BKE_ptcache_id_exist(pid, cfra))
+ if (BKE_ptcache_id_exist(pid, cfra)) {
totframes++;
+ }
}
BLI_snprintf(mem_info, sizeof(mem_info), IFACE_("%i frames on disk"), totframes);
@@ -4328,8 +4525,9 @@ void BKE_ptcache_update_info(PTCacheID *pid)
int i;
for (; pm; pm = pm->next) {
- for (i = 0; i < BPHYS_TOT_DATA; i++)
+ for (i = 0; i < BPHYS_TOT_DATA; i++) {
bytes += MEM_allocN_len(pm->data[i]);
+ }
for (extra = pm->extradata.first; extra; extra = extra->next) {
bytes += MEM_allocN_len(extra->data);
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index 1319c6de835..5db091e6a43 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -65,8 +65,9 @@ const char *BKE_report_type_str(ReportType type)
void BKE_reports_init(ReportList *reports, int flag)
{
- if (!reports)
+ if (!reports) {
return;
+ }
memset(reports, 0, sizeof(ReportList));
@@ -79,8 +80,9 @@ void BKE_reports_clear(ReportList *reports)
{
Report *report, *report_next;
- if (!reports)
+ if (!reports) {
return;
+ }
report = reports->list.first;
@@ -163,8 +165,9 @@ void BKE_reports_prepend(ReportList *reports, const char *_prepend)
DynStr *ds;
const char *prepend = TIP_(_prepend);
- if (!reports)
+ if (!reports) {
return;
+ }
for (report = reports->list.first; report; report = report->next) {
ds = BLI_dynstr_new();
@@ -187,8 +190,9 @@ void BKE_reports_prependf(ReportList *reports, const char *_prepend, ...)
va_list args;
const char *prepend = TIP_(_prepend);
- if (!reports)
+ if (!reports) {
return;
+ }
for (report = reports->list.first; report; report = report->next) {
ds = BLI_dynstr_new();
@@ -208,32 +212,36 @@ void BKE_reports_prependf(ReportList *reports, const char *_prepend, ...)
ReportType BKE_report_print_level(ReportList *reports)
{
- if (!reports)
+ if (!reports) {
return RPT_ERROR;
+ }
return reports->printlevel;
}
void BKE_report_print_level_set(ReportList *reports, ReportType level)
{
- if (!reports)
+ if (!reports) {
return;
+ }
reports->printlevel = level;
}
ReportType BKE_report_store_level(ReportList *reports)
{
- if (!reports)
+ if (!reports) {
return RPT_ERROR;
+ }
return reports->storelevel;
}
void BKE_report_store_level_set(ReportList *reports, ReportType level)
{
- if (!reports)
+ if (!reports) {
return;
+ }
reports->storelevel = level;
}
@@ -244,18 +252,23 @@ char *BKE_reports_string(ReportList *reports, ReportType level)
DynStr *ds;
char *cstring;
- if (!reports || !reports->list.first)
+ if (!reports || !reports->list.first) {
return NULL;
+ }
ds = BLI_dynstr_new();
- for (report = reports->list.first; report; report = report->next)
- if (report->type >= level)
+ for (report = reports->list.first; report; report = report->next) {
+ if (report->type >= level) {
BLI_dynstr_appendf(ds, "%s: %s\n", report->typestr, report->message);
+ }
+ }
- if (BLI_dynstr_get_len(ds))
+ if (BLI_dynstr_get_len(ds)) {
cstring = BLI_dynstr_get_cstring(ds);
- else
+ }
+ else {
cstring = NULL;
+ }
BLI_dynstr_free(ds);
return cstring;
@@ -265,8 +278,9 @@ void BKE_reports_print(ReportList *reports, ReportType level)
{
char *cstring = BKE_reports_string(reports, level);
- if (cstring == NULL)
+ if (cstring == NULL) {
return;
+ }
puts(cstring);
fflush(stdout);
@@ -278,8 +292,9 @@ Report *BKE_reports_last_displayable(ReportList *reports)
Report *report;
for (report = reports->list.last; report; report = report->prev) {
- if (ELEM(report->type, RPT_ERROR, RPT_WARNING, RPT_INFO))
+ if (ELEM(report->type, RPT_ERROR, RPT_WARNING, RPT_INFO)) {
return report;
+ }
}
return NULL;
@@ -289,9 +304,11 @@ bool BKE_reports_contain(ReportList *reports, ReportType level)
{
Report *report;
if (reports != NULL) {
- for (report = reports->list.first; report; report = report->next)
- if (report->type >= level)
+ for (report = reports->list.first; report; report = report->next) {
+ if (report->type >= level) {
return true;
+ }
+ }
}
return false;
}
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 78639b4ddb9..ad15214c3b8 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -109,11 +109,13 @@ void BKE_rigidbody_free_world(Scene *scene)
scene->rigidbody_world = NULL;
/* sanity check */
- if (!rbw)
+ if (!rbw) {
return;
+ }
if (is_orig && rbw->shared->physics_world) {
- /* free physics references, we assume that all physics objects in will have been added to the world */
+ /* Free physics references,
+ * we assume that all physics objects in will have been added to the world. */
if (rbw->constraints) {
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->constraints, object) {
if (object->rigidbody_constraint) {
@@ -135,8 +137,9 @@ void BKE_rigidbody_free_world(Scene *scene)
/* free dynamics world */
RB_dworld_delete(rbw->shared->physics_world);
}
- if (rbw->objects)
+ if (rbw->objects) {
free(rbw->objects);
+ }
if (is_orig) {
/* free cache */
@@ -147,8 +150,9 @@ void BKE_rigidbody_free_world(Scene *scene)
}
/* free effector weights */
- if (rbw->effector_weights)
+ if (rbw->effector_weights) {
MEM_freeN(rbw->effector_weights);
+ }
/* free rigidbody world itself */
MEM_freeN(rbw);
@@ -161,8 +165,9 @@ void BKE_rigidbody_free_object(Object *ob, RigidBodyWorld *rbw)
RigidBodyOb *rbo = ob->rigidbody_object;
/* sanity check */
- if (rbo == NULL)
+ if (rbo == NULL) {
return;
+ }
/* free physics references */
if (is_orig) {
@@ -198,8 +203,9 @@ void BKE_rigidbody_free_constraint(Object *ob)
RigidBodyCon *rbc = (ob) ? ob->rigidbody_constraint : NULL;
/* sanity check */
- if (rbc == NULL)
+ if (rbc == NULL) {
return;
+ }
/* free physics reference */
if (rbc->physics_constraint) {
@@ -332,8 +338,9 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
mesh = rigidbody_get_mesh(ob);
/* ensure mesh validity, then grab data */
- if (mesh == NULL)
+ if (mesh == NULL) {
return NULL;
+ }
mvert = mesh->mvert;
totvert = mesh->totvert;
@@ -415,12 +422,14 @@ static void rigidbody_validate_sim_shape(Object *ob, bool rebuild)
bool has_volume;
/* sanity check */
- if (rbo == NULL)
+ if (rbo == NULL) {
return;
+ }
/* don't create a new shape if we already have one and don't want to rebuild it */
- if (rbo->shared->physics_shape && !rebuild)
+ if (rbo->shared->physics_shape && !rebuild) {
return;
+ }
/* if automatically determining dimensions, use the Object's boundbox
* - assume that all quadrics are standing upright on local z-axis
@@ -472,13 +481,15 @@ static void rigidbody_validate_sim_shape(Object *ob, bool rebuild)
/* try to emged collision margin */
has_volume = (MIN3(size[0], size[1], size[2]) > 0.0f);
- if (!(rbo->flag & RBO_FLAG_USE_MARGIN) && has_volume)
+ if (!(rbo->flag & RBO_FLAG_USE_MARGIN) && has_volume) {
hull_margin = 0.04f;
+ }
new_shape = rigidbody_get_shape_convexhull_from_mesh(ob, hull_margin, &can_embed);
- if (!(rbo->flag & RBO_FLAG_USE_MARGIN))
+ if (!(rbo->flag & RBO_FLAG_USE_MARGIN)) {
rbo->margin = (can_embed && has_volume) ?
0.04f :
0.0f; /* RB_TODO ideally we shouldn't directly change the margin here */
+ }
break;
case RB_SHAPE_TRIMESH:
new_shape = rigidbody_get_shape_trimesh_from_mesh(ob);
@@ -561,8 +572,9 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol)
const MLoop *mloop = NULL;
/* ensure mesh validity, then grab data */
- if (mesh == NULL)
+ if (mesh == NULL) {
return;
+ }
mvert = mesh->mvert;
totvert = mesh->totvert;
@@ -584,8 +596,9 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol)
}
/* return the volume calculated */
- if (r_vol)
+ if (r_vol) {
*r_vol = volume;
+ }
}
void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3])
@@ -633,8 +646,9 @@ void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3])
const MLoop *mloop;
/* ensure mesh validity, then grab data */
- if (mesh == NULL)
+ if (mesh == NULL) {
return;
+ }
mvert = mesh->mvert;
totvert = mesh->totvert;
@@ -667,13 +681,16 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
/* sanity checks:
* - object doesn't have RigidBody info already: then why is it here?
*/
- if (rbo == NULL)
+ if (rbo == NULL) {
return;
+ }
/* make sure collision shape exists */
- /* FIXME we shouldn't always have to rebuild collision shapes when rebuilding objects, but it's needed for constraints to update correctly */
- if (rbo->shared->physics_shape == NULL || rebuild)
+ /* FIXME we shouldn't always have to rebuild collision shapes when rebuilding objects,
+ * but it's needed for constraints to update correctly. */
+ if (rbo->shared->physics_shape == NULL || rebuild) {
rigidbody_validate_sim_shape(ob, true);
+ }
if (rbo->shared->physics_object) {
RB_dworld_remove_body(rbw->shared->physics_world, rbo->shared->physics_object);
@@ -697,8 +714,9 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
RB_body_set_activation_state(rbo->shared->physics_object,
rbo->flag & RBO_FLAG_USE_DEACTIVATION);
- if (rbo->type == RBO_TYPE_PASSIVE || rbo->flag & RBO_FLAG_START_DEACTIVATED)
+ if (rbo->type == RBO_TYPE_PASSIVE || rbo->flag & RBO_FLAG_START_DEACTIVATED) {
RB_body_deactivate(rbo->shared->physics_object);
+ }
RB_body_set_linear_factor(rbo->shared->physics_object,
(ob->protectflag & OB_LOCK_LOCX) == 0,
@@ -714,8 +732,9 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
}
- if (rbw && rbw->shared->physics_world)
+ if (rbw && rbw->shared->physics_world) {
RB_dworld_add_body(rbw->shared->physics_world, rbo->shared->physics_object, rbo->col_groups);
+ }
}
/* --------------------- */
@@ -753,41 +772,53 @@ static void rigidbody_constraint_init_spring(RigidBodyCon *rbc,
static void rigidbody_constraint_set_limits(RigidBodyCon *rbc,
void (*set_limits)(rbConstraint *, int, float, float))
{
- if (rbc->flag & RBC_FLAG_USE_LIMIT_LIN_X)
+ if (rbc->flag & RBC_FLAG_USE_LIMIT_LIN_X) {
set_limits(
rbc->physics_constraint, RB_LIMIT_LIN_X, rbc->limit_lin_x_lower, rbc->limit_lin_x_upper);
- else
+ }
+ else {
set_limits(rbc->physics_constraint, RB_LIMIT_LIN_X, 0.0f, -1.0f);
+ }
- if (rbc->flag & RBC_FLAG_USE_LIMIT_LIN_Y)
+ if (rbc->flag & RBC_FLAG_USE_LIMIT_LIN_Y) {
set_limits(
rbc->physics_constraint, RB_LIMIT_LIN_Y, rbc->limit_lin_y_lower, rbc->limit_lin_y_upper);
- else
+ }
+ else {
set_limits(rbc->physics_constraint, RB_LIMIT_LIN_Y, 0.0f, -1.0f);
+ }
- if (rbc->flag & RBC_FLAG_USE_LIMIT_LIN_Z)
+ if (rbc->flag & RBC_FLAG_USE_LIMIT_LIN_Z) {
set_limits(
rbc->physics_constraint, RB_LIMIT_LIN_Z, rbc->limit_lin_z_lower, rbc->limit_lin_z_upper);
- else
+ }
+ else {
set_limits(rbc->physics_constraint, RB_LIMIT_LIN_Z, 0.0f, -1.0f);
+ }
- if (rbc->flag & RBC_FLAG_USE_LIMIT_ANG_X)
+ if (rbc->flag & RBC_FLAG_USE_LIMIT_ANG_X) {
set_limits(
rbc->physics_constraint, RB_LIMIT_ANG_X, rbc->limit_ang_x_lower, rbc->limit_ang_x_upper);
- else
+ }
+ else {
set_limits(rbc->physics_constraint, RB_LIMIT_ANG_X, 0.0f, -1.0f);
+ }
- if (rbc->flag & RBC_FLAG_USE_LIMIT_ANG_Y)
+ if (rbc->flag & RBC_FLAG_USE_LIMIT_ANG_Y) {
set_limits(
rbc->physics_constraint, RB_LIMIT_ANG_Y, rbc->limit_ang_y_lower, rbc->limit_ang_y_upper);
- else
+ }
+ else {
set_limits(rbc->physics_constraint, RB_LIMIT_ANG_Y, 0.0f, -1.0f);
+ }
- if (rbc->flag & RBC_FLAG_USE_LIMIT_ANG_Z)
+ if (rbc->flag & RBC_FLAG_USE_LIMIT_ANG_Z) {
set_limits(
rbc->physics_constraint, RB_LIMIT_ANG_Z, rbc->limit_ang_z_lower, rbc->limit_ang_z_upper);
- else
+ }
+ else {
set_limits(rbc->physics_constraint, RB_LIMIT_ANG_Z, 0.0f, -1.0f);
+ }
}
/**
@@ -851,16 +882,19 @@ static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, b
RB_constraint_set_limits_hinge(
rbc->physics_constraint, rbc->limit_ang_z_lower, rbc->limit_ang_z_upper);
}
- else
+ else {
RB_constraint_set_limits_hinge(rbc->physics_constraint, 0.0f, -1.0f);
+ }
break;
case RBC_TYPE_SLIDER:
rbc->physics_constraint = RB_constraint_new_slider(loc, rot, rb1, rb2);
- if (rbc->flag & RBC_FLAG_USE_LIMIT_LIN_X)
+ if (rbc->flag & RBC_FLAG_USE_LIMIT_LIN_X) {
RB_constraint_set_limits_slider(
rbc->physics_constraint, rbc->limit_lin_x_lower, rbc->limit_lin_x_upper);
- else
+ }
+ else {
RB_constraint_set_limits_slider(rbc->physics_constraint, 0.0f, -1.0f);
+ }
break;
case RBC_TYPE_PISTON:
rbc->physics_constraint = RB_constraint_new_piston(loc, rot, rb1, rb2);
@@ -934,15 +968,19 @@ static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, b
RB_constraint_set_enabled(rbc->physics_constraint, rbc->flag & RBC_FLAG_ENABLED);
- if (rbc->flag & RBC_FLAG_USE_BREAKING)
+ if (rbc->flag & RBC_FLAG_USE_BREAKING) {
RB_constraint_set_breaking_threshold(rbc->physics_constraint, rbc->breaking_threshold);
- else
+ }
+ else {
RB_constraint_set_breaking_threshold(rbc->physics_constraint, FLT_MAX);
+ }
- if (rbc->flag & RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS)
+ if (rbc->flag & RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS) {
RB_constraint_set_solver_iterations(rbc->physics_constraint, rbc->num_solver_iterations);
- else
+ }
+ else {
RB_constraint_set_solver_iterations(rbc->physics_constraint, -1);
+ }
}
if (rbw && rbw->shared->physics_world && rbc->physics_constraint) {
@@ -954,18 +992,24 @@ static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, b
/* --------------------- */
-/* Create physics sim world given RigidBody world settings */
-// NOTE: this does NOT update object references that the scene uses, in case those aren't ready yet!
+/**
+ * Create physics sim world given RigidBody world settings
+ *
+ * \note this does NOT update object references that the scene uses,
+ * in case those aren't ready yet!
+ */
void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, bool rebuild)
{
/* sanity checks */
- if (rbw == NULL)
+ if (rbw == NULL) {
return;
+ }
/* create new sim world */
if (rebuild || rbw->shared->physics_world == NULL) {
- if (rbw->shared->physics_world)
+ if (rbw->shared->physics_world) {
RB_dworld_delete(rbw->shared->physics_world);
+ }
rbw->shared->physics_world = RB_dworld_new(scene->physics_settings.gravity);
}
@@ -986,8 +1030,9 @@ RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene)
* - there must be a valid scene to add world to
* - there mustn't be a sim world using this group already
*/
- if (scene == NULL)
+ if (scene == NULL) {
return NULL;
+ }
/* create a new sim world */
rbw = MEM_callocN(sizeof(RigidBodyWorld), "RigidBodyWorld");
@@ -1068,8 +1113,9 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
* - object must exist
* - cannot add rigid body if it already exists
*/
- if (ob == NULL || (ob->rigidbody_object != NULL))
+ if (ob == NULL || (ob->rigidbody_object != NULL)) {
return NULL;
+ }
/* create new settings data, and link it up */
rbo = MEM_callocN(sizeof(RigidBodyOb), "RigidBodyOb");
@@ -1096,10 +1142,12 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type)
/* use triangle meshes for passive objects
* use convex hulls for active objects since dynamic triangle meshes are very unstable
*/
- if (type == RBO_TYPE_ACTIVE)
+ if (type == RBO_TYPE_ACTIVE) {
rbo->shape = RB_SHAPE_CONVEXH;
- else
+ }
+ else {
rbo->shape = RB_SHAPE_TRIMESH;
+ }
rbo->mesh_source = RBO_MESH_DEFORM;
@@ -1125,8 +1173,9 @@ RigidBodyCon *BKE_rigidbody_create_constraint(Scene *scene, Object *ob, short ty
* - object must exist
* - cannot add constraint if it already exists
*/
- if (ob == NULL || (ob->rigidbody_constraint != NULL))
+ if (ob == NULL || (ob->rigidbody_constraint != NULL)) {
return NULL;
+ }
/* create new settings data, and link it up */
rbc = MEM_callocN(sizeof(RigidBodyCon), "RigidBodyCon");
@@ -1240,8 +1289,9 @@ void BKE_rigidbody_main_collection_object_add(Main *bmain, Collection *collectio
RigidBodyWorld *BKE_rigidbody_get_world(Scene *scene)
{
/* sanity check */
- if (scene == NULL)
+ if (scene == NULL) {
return NULL;
+ }
return scene->rigidbody_world;
}
@@ -1363,8 +1413,13 @@ static void rigidbody_update_sim_ob(
float scale[3];
/* only update if rigid body exists */
- if (rbo->shared->physics_object == NULL)
+ if (rbo->shared->physics_object == NULL) {
return;
+ }
+
+ ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+ const bool is_selected = base ? (base->flag & BASE_SELECTED) != 0 : false;
if (rbo->shape == RB_SHAPE_TRIMESH && rbo->flag & RBO_FLAG_USE_DEFORM) {
Mesh *mesh = ob->runtime.mesh_deform_eval;
@@ -1387,18 +1442,20 @@ static void rigidbody_update_sim_ob(
/* update scale for all objects */
RB_body_set_scale(rbo->shared->physics_object, scale);
/* compensate for embedded convex hull collision margin */
- if (!(rbo->flag & RBO_FLAG_USE_MARGIN) && rbo->shape == RB_SHAPE_CONVEXH)
+ if (!(rbo->flag & RBO_FLAG_USE_MARGIN) && rbo->shape == RB_SHAPE_CONVEXH) {
RB_shape_set_margin(rbo->shared->physics_shape,
RBO_GET_MARGIN(rbo) * MIN3(scale[0], scale[1], scale[2]));
+ }
- /* make transformed objects temporarily kinmatic so that they can be moved by the user during simulation */
- if (ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ) {
+ /* Make transformed objects temporarily kinmatic
+ * so that they can be moved by the user during simulation. */
+ if (is_selected && (G.moving & G_TRANSFORM_OBJ)) {
RB_body_set_kinematic_state(rbo->shared->physics_object, true);
RB_body_set_mass(rbo->shared->physics_object, 0.0f);
}
/* update rigid body location and rotation for kinematic bodies */
- if (rbo->flag & RBO_FLAG_KINEMATIC || (ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ)) {
+ if (rbo->flag & RBO_FLAG_KINEMATIC || (is_selected && (G.moving & G_TRANSFORM_OBJ))) {
RB_body_activate(rbo->shared->physics_object);
RB_body_set_loc_rot(rbo->shared->physics_object, loc, rot);
}
@@ -1417,29 +1474,33 @@ static void rigidbody_update_sim_ob(
float eff_loc[3], eff_vel[3];
/* create dummy 'point' which represents last known position of object as result of sim */
- // XXX: this can create some inaccuracies with sim position, but is probably better than using unsimulated vals?
+ /* XXX: this can create some inaccuracies with sim position,
+ * but is probably better than using unsimulated vals? */
RB_body_get_position(rbo->shared->physics_object, eff_loc);
RB_body_get_linear_velocity(rbo->shared->physics_object, eff_vel);
pd_point_from_loc(scene, eff_loc, eff_vel, 0, &epoint);
- /* calculate net force of effectors, and apply to sim object
- * - we use 'central force' since apply force requires a "relative position" which we don't have...
- */
+ /* Calculate net force of effectors, and apply to sim object:
+ * - we use 'central force' since apply force requires a "relative position"
+ * which we don't have... */
BKE_effectors_apply(effectors, NULL, effector_weights, &epoint, eff_force, NULL);
- if (G.f & G_DEBUG)
+ if (G.f & G_DEBUG) {
printf("\tapplying force (%f,%f,%f) to '%s'\n",
eff_force[0],
eff_force[1],
eff_force[2],
ob->id.name + 2);
+ }
/* activate object in case it is deactivated */
- if (!is_zero_v3(eff_force))
+ if (!is_zero_v3(eff_force)) {
RB_body_activate(rbo->shared->physics_object);
+ }
RB_body_apply_central_force(rbo->shared->physics_object, eff_force);
}
- else if (G.f & G_DEBUG)
+ else if (G.f & G_DEBUG) {
printf("\tno forces to apply to '%s'\n", ob->id.name + 2);
+ }
/* cleanup */
BKE_effectors_free(effectors);
@@ -1464,8 +1525,9 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
float ctime = DEG_get_ctime(depsgraph);
/* update world */
- if (rebuild)
+ if (rebuild) {
BKE_rigidbody_validate_sim_world(scene, rbw, true);
+ }
rigidbody_update_sim_world(scene, rbw);
/* XXX TODO For rebuild: remove all constraints first.
@@ -1491,13 +1553,15 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
if (ob->type == OB_MESH) {
/* validate that we've got valid object set up here... */
RigidBodyOb *rbo = ob->rigidbody_object;
- /* update transformation matrix of the object so we don't get a frame of lag for simple animations */
+ /* Update transformation matrix of the object
+ * so we don't get a frame of lag for simple animations. */
BKE_object_where_is_calc_time(depsgraph, scene, ob, ctime);
/* TODO remove this whole block once we are sure we never get NULL rbo here anymore. */
/* This cannot be done in CoW evaluation context anymore... */
if (rbo == NULL) {
- BLI_assert(!"CoW object part of RBW object collection without RB object data, should not happen.\n");
+ BLI_assert(!"CoW object part of RBW object collection without RB object data, "
+ "should not happen.\n");
/* Since this object is included in the sim group but doesn't have
* rigid body settings (perhaps it was added manually), add!
* - assume object to be active? That is the default for newly added settings...
@@ -1513,7 +1577,8 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
if (rebuild) {
/* World has been rebuilt so rebuild object */
/* TODO(Sybren): rigidbody_validate_sim_object() can call rigidbody_validate_sim_shape(),
- * but neither resets the RBO_FLAG_NEEDS_RESHAPE flag nor calls RB_body_set_collision_shape().
+ * but neither resets the RBO_FLAG_NEEDS_RESHAPE flag nor
+ * calls RB_body_set_collision_shape().
* This results in the collision shape being created twice, which is unnecessary. */
rigidbody_validate_sim_object(rbw, ob, true);
}
@@ -1525,7 +1590,8 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
/* mesh/shape data changed, so force shape refresh */
rigidbody_validate_sim_shape(ob, true);
/* now tell RB sim about it */
- // XXX: we assume that this can only get applied for active/passive shapes that will be included as rigidbodies
+ /* XXX: we assume that this can only get applied for active/passive shapes
+ * that will be included as rigidbodies. */
RB_body_set_collision_shape(rbo->shared->physics_object, rbo->shared->physics_shape);
}
}
@@ -1538,19 +1604,22 @@ static void rigidbody_update_simulation(Depsgraph *depsgraph,
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
/* update constraints */
- if (rbw->constraints == NULL) /* no constraints, move on */
+ if (rbw->constraints == NULL) { /* no constraints, move on */
return;
+ }
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->constraints, ob) {
/* validate that we've got valid object set up here... */
RigidBodyCon *rbc = ob->rigidbody_constraint;
- /* update transformation matrix of the object so we don't get a frame of lag for simple animations */
+ /* Update transformation matrix of the object
+ * so we don't get a frame of lag for simple animations. */
BKE_object_where_is_calc_time(depsgraph, scene, ob, ctime);
/* TODO remove this whole block once we are sure we never get NULL rbo here anymore. */
/* This cannot be done in CoW evaluation context anymore... */
if (rbc == NULL) {
- BLI_assert(!"CoW object part of RBW constraints collection without RB constraint data, should not happen.\n");
+ BLI_assert(!"CoW object part of RBW constraints collection without RB constraint data, "
+ "should not happen.\n");
/* Since this object is included in the group but doesn't have
* constraint settings (perhaps it was added manually), add!
*/
@@ -1587,8 +1656,9 @@ static void rigidbody_update_simulation_post_step(Depsgraph *depsgraph, RigidBod
rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
RB_body_set_mass(rbo->shared->physics_object, RBO_GET_MASS(rbo));
/* Deactivate passive objects so they don't interfere with deactivation of active objects. */
- if (rbo->type == RBO_TYPE_PASSIVE)
+ if (rbo->type == RBO_TYPE_PASSIVE) {
RB_body_deactivate(rbo->shared->physics_object);
+ }
}
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
@@ -1605,12 +1675,13 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime)
RigidBodyOb *rbo = ob->rigidbody_object;
/* keep original transform for kinematic and passive objects */
- if (ELEM(NULL, rbw, rbo) || rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE)
+ if (ELEM(NULL, rbw, rbo) || rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE) {
return;
+ }
/* use rigid body transform after cache start frame if objects is not being transformed */
if (BKE_rigidbody_check_sim_running(rbw, ctime) &&
- !(ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ)) {
+ !(ob->base_flag & BASE_SELECTED && G.moving & G_TRANSFORM_OBJ)) {
float mat[4][4], size_mat[4][4], size[3];
normalize_qt(rbo->orn); // RB_TODO investigate why quaternion isn't normalized at this point
@@ -1690,11 +1761,13 @@ void BKE_rigidbody_aftertrans_update(
if (rbo->shared->physics_object) {
/* allow passive objects to return to original transform */
- if (rbo->type == RBO_TYPE_PASSIVE)
+ if (rbo->type == RBO_TYPE_PASSIVE) {
RB_body_set_kinematic_state(rbo->shared->physics_object, true);
+ }
RB_body_set_loc_rot(rbo->shared->physics_object, rbo->pos, rbo->orn);
}
- // RB_TODO update rigid body physics object's loc/rot for dynamic objects here as well (needs to be done outside bullet's update loop)
+ /* RB_TODO update rigid body physics object's loc/rot for dynamic objects here as well
+ * (needs to be done outside bullet's update loop). */
}
void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw)
@@ -1719,7 +1792,8 @@ void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime
BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
cache = rbw->shared->pointcache;
- /* flag cache as outdated if we don't have a world or number of objects in the simulation has changed */
+ /* Flag cache as outdated if we don't have a world or number of objects
+ * in the simulation has changed. */
int n = 0;
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, object) {
(void)object;
@@ -1765,10 +1839,12 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
}
/* don't try to run the simulation if we don't have a world yet but allow reading baked cache */
- if (rbw->shared->physics_world == NULL && !(cache->flag & PTCACHE_BAKED))
+ if (rbw->shared->physics_world == NULL && !(cache->flag & PTCACHE_BAKED)) {
return;
- else if (rbw->objects == NULL)
+ }
+ else if (rbw->objects == NULL) {
rigidbody_update_ob_array(rbw);
+ }
/* try to read from cache */
// RB_TODO deal with interpolated, old and baked results
@@ -1798,7 +1874,8 @@ void BKE_rigidbody_do_simulation(Depsgraph *depsgraph, Scene *scene, float ctime
/* calculate how much time elapsed since last step in seconds */
timestep = 1.0f / (float)FPS * (ctime - rbw->ltime) * rbw->time_scale;
- /* step simulation by the requested timestep, steps per second are adjusted to take time scale into account */
+ /* Step simulation by the requested timestep,
+ * steps per second are adjusted to take time scale into account. */
RB_dworld_step_simulation(rbw->shared->physics_world,
timestep,
INT_MAX,
@@ -1836,8 +1913,9 @@ void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, bool re
}
void BKE_rigidbody_calc_volume(Object *ob, float *r_vol)
{
- if (r_vol)
+ if (r_vol) {
*r_vol = 0.0f;
+ }
}
void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3])
{
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 5fad95c54e2..58b36aed24f 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -225,8 +225,10 @@ void BKE_toolsettings_free(ToolSettings *toolsettings)
}
/**
- * Only copy internal data of Scene ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Scene ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -355,8 +357,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
sce_copy->eevee.light_cache = NULL;
sce_copy->eevee.light_cache_info[0] = '\0';
- if (sce->id.properties)
+ if (sce->id.properties) {
sce_copy->id.properties = IDP_CopyProperty(sce->id.properties);
+ }
MEM_freeN(sce_copy->toolsettings);
BKE_sound_destroy_scene(sce_copy);
@@ -411,7 +414,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
id_us_min(&sce_copy->id);
id_us_ensure_real(&sce_copy->id);
- /* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks... */
+ /* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks. */
if (type == SCE_COPY_FULL) {
/* Copy Freestyle LineStyle datablocks. */
@@ -455,8 +458,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
void BKE_scene_groups_relink(Scene *sce)
{
- if (sce->rigidbody_world)
+ if (sce->rigidbody_world) {
BKE_rigidbody_world_groups_relink(sce->rigidbody_world);
+ }
}
void BKE_scene_make_local(Main *bmain, Scene *sce, const bool lib_local)
@@ -765,7 +769,8 @@ void BKE_scene_init(Scene *sce)
BLI_rctf_init(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
sce->r.osa = 8;
- /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */
+ /* Note; in header_info.c the scene copy happens...,
+ * if you add more to renderdata it has to be checked there. */
/* multiview - stereo */
BKE_scene_add_render_view(sce, STEREO_LEFT_NAME);
@@ -1004,7 +1009,8 @@ Object *BKE_scene_object_find_by_name(Scene *scene, const char *name)
}
/**
- * Sets the active scene, mainly used when running in background mode (``--scene`` command line argument).
+ * Sets the active scene, mainly used when running in background mode
+ * (``--scene`` command line argument).
* This is also called to set the scene directly, bypassing windowing code.
* Otherwise #WM_window_set_active_scene is used when changing scenes by the user.
*/
@@ -1016,8 +1022,9 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
BKE_scene_validate_setscene(bmain, scene);
/* deselect objects (for dataselect) */
- for (ob = bmain->objects.first; ob; ob = ob->id.next)
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
ob->flag &= ~SELECT;
+ }
/* copy layers and flags from bases to objects */
for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
@@ -1028,7 +1035,8 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
BKE_scene_object_base_flag_sync_from_base(base);
}
}
- /* no full animation update, this to enable render code to work (render code calls own animation updates) */
+ /* No full animation update, this to enable render code to work
+ * (render code calls own animation updates). */
}
/* called from creator_args.c */
@@ -1045,7 +1053,8 @@ Scene *BKE_scene_set_name(Main *bmain, const char *name)
return NULL;
}
-/* Used by metaballs, return *all* objects (including duplis) existing in the scene (including scene's sets) */
+/* Used by metaballs, return *all* objects (including duplis)
+ * existing in the scene (including scene's sets). */
int BKE_scene_base_iter_next(
Depsgraph *depsgraph, SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob)
{
@@ -1204,8 +1213,9 @@ Object *BKE_scene_camera_switch_find(Scene *scene)
camera = m->camera;
frame = m->frame;
- if (frame == cfra)
+ if (frame == cfra) {
break;
+ }
}
if (m->frame < min_frame) {
@@ -1249,14 +1259,17 @@ char *BKE_scene_find_marker_name(Scene *scene, int frame)
/* search through markers for match */
for (m1 = markers->first, m2 = markers->last; m1 && m2; m1 = m1->next, m2 = m2->prev) {
- if (m1->frame == frame)
+ if (m1->frame == frame) {
return m1->name;
+ }
- if (m1 == m2)
+ if (m1 == m2) {
break;
+ }
- if (m2->frame == frame)
+ if (m2->frame == frame) {
return m2->name;
+ }
}
return NULL;
@@ -1295,11 +1308,13 @@ int BKE_scene_frame_snap_by_seconds(Scene *scene, double interval_in_seconds, in
void BKE_scene_remove_rigidbody_object(struct Main *bmain, Scene *scene, Object *ob)
{
/* remove rigid body constraint from world before removing object */
- if (ob->rigidbody_constraint)
+ if (ob->rigidbody_constraint) {
BKE_rigidbody_remove_constraint(scene, ob);
+ }
/* remove rigid body object from world before removing object */
- if (ob->rigidbody_object)
+ if (ob->rigidbody_object) {
BKE_rigidbody_remove_object(bmain, scene, ob);
+ }
}
/* checks for cycle, returns 1 if it's all OK */
@@ -1308,8 +1323,9 @@ bool BKE_scene_validate_setscene(Main *bmain, Scene *sce)
Scene *sce_iter;
int a, totscene;
- if (sce->set == NULL)
+ if (sce->set == NULL) {
return true;
+ }
totscene = BLI_listbase_count(&bmain->scenes);
for (a = 0, sce_iter = sce; sce_iter->set; sce_iter = sce_iter->set, a++) {
@@ -1324,8 +1340,10 @@ bool BKE_scene_validate_setscene(Main *bmain, Scene *sce)
return true;
}
-/* This function is needed to cope with fractional frames - including two Blender rendering features
- * mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering.
+/**
+ * This function is needed to cope with fractional frames - including two Blender rendering
+ * features mblur (motion blur that renders 'subframes' and blurs them together),
+ * and fields rendering.
*/
float BKE_scene_frame_get(const Scene *scene)
{
@@ -1547,15 +1565,6 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
BKE_image_editors_update_frame(bmain, scene->r.cfra);
BKE_sound_set_cfra(scene->r.cfra);
DEG_graph_relations_update(depsgraph, bmain, scene, view_layer);
- /* Update animated cache files for modifiers.
- *
- * TODO(sergey): Make this a depsgraph node?
- */
- BKE_cachefile_update_frame(bmain,
- depsgraph,
- scene,
- ctime,
- (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base));
#ifdef POSE_ANIMATION_WORKAROUND
scene_armature_depsgraph_workaround(bmain, depsgraph);
#endif
@@ -1575,8 +1584,8 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
/** Ensures given scene/view_layer pair has a valid, up-to-date depsgraph.
*
- * \warning Sets matching depsgraph as active, so should only be called from the active editing context
- * (usually, from operators).
+ * \warning Sets matching depsgraph as active,
+ * so should only be called from the active editing context (usually, from operators).
*/
void BKE_scene_view_layer_graph_evaluated_ensure(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
@@ -1590,8 +1599,9 @@ SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name)
{
SceneRenderView *srv;
- if (!name)
+ if (!name) {
name = DATA_("RenderView");
+ }
srv = MEM_callocN(sizeof(SceneRenderView), "new render view");
BLI_strncpy(srv->name, name, sizeof(srv->name));
@@ -1631,10 +1641,12 @@ bool BKE_scene_remove_render_view(Scene *scene, SceneRenderView *srv)
int get_render_subsurf_level(const RenderData *r, int lvl, bool for_render)
{
if (r->mode & R_SIMPLIFY) {
- if (for_render)
+ if (for_render) {
return min_ii(r->simplify_subsurf_render, lvl);
- else
+ }
+ else {
return min_ii(r->simplify_subsurf, lvl);
+ }
}
else {
return lvl;
@@ -1644,10 +1656,12 @@ int get_render_subsurf_level(const RenderData *r, int lvl, bool for_render)
int get_render_child_particle_number(const RenderData *r, int num, bool for_render)
{
if (r->mode & R_SIMPLIFY) {
- if (for_render)
+ if (for_render) {
return (int)(r->simplify_particles_render * num);
- else
+ }
+ else {
return (int)(r->simplify_particles * num);
+ }
}
else {
return num;
@@ -1728,31 +1742,20 @@ void BKE_scene_base_flag_to_objects(ViewLayer *view_layer)
}
}
+/**
+ * Synchronize object base flags
+ *
+ * This is usually handled by the depsgraph.
+ * However, in rare occasions we need to use the latest object flags
+ * before depsgraph is fully updated.
+ *
+ * It should (ideally) only run for copy-on-written objects since this is
+ * runtime data generated per-viewlayer.
+ */
void BKE_scene_object_base_flag_sync_from_base(Base *base)
{
Object *ob = base->object;
-
- ob->flag = base->flag;
-
- if ((base->flag & BASE_SELECTED) != 0) {
- ob->flag |= SELECT;
- }
- else {
- ob->flag &= ~SELECT;
- }
-}
-
-void BKE_scene_object_base_flag_sync_from_object(Base *base)
-{
- Object *ob = base->object;
- base->flag = ob->flag;
-
- if ((ob->flag & SELECT) != 0 && (base->flag & BASE_SELECTABLE) != 0) {
- base->flag |= BASE_SELECTED;
- }
- else {
- base->flag &= ~BASE_SELECTED;
- }
+ ob->base_flag = base->flag;
}
void BKE_scene_disable_color_management(Scene *scene)
@@ -1793,14 +1796,17 @@ int BKE_render_num_threads(const RenderData *rd)
/* override set from command line? */
threads = BLI_system_num_threads_override_get();
- if (threads > 0)
+ if (threads > 0) {
return threads;
+ }
/* fixed number of threads specified in scene? */
- if (rd->mode & R_FIXED_THREADS)
+ if (rd->mode & R_FIXED_THREADS) {
threads = rd->threads;
- else
+ }
+ else {
threads = BLI_system_thread_count();
+ }
return max_ii(threads, 1);
}
@@ -1818,8 +1824,9 @@ int BKE_render_preview_pixel_size(const RenderData *r)
return r->preview_pixel_size;
}
-/* Apply the needed correction factor to value, based on unit_type (only length-related are affected currently)
- * and unit->scale_length.
+/**
+ * Apply the needed correction factor to value, based on unit_type
+ * (only length-related are affected currently) and unit->scale_length.
*/
double BKE_scene_unit_scale(const UnitSettings *unit, const int unit_type, double value)
{
@@ -1851,8 +1858,9 @@ int BKE_scene_multiview_num_views_get(const RenderData *rd)
SceneRenderView *srv;
int totviews = 0;
- if ((rd->scemode & R_MULTIVIEW) == 0)
+ if ((rd->scemode & R_MULTIVIEW) == 0) {
return 1;
+ }
if (rd->views_format == SCE_VIEWS_FORMAT_STEREO_3D) {
srv = BLI_findstring(&rd->views, STEREO_LEFT_NAME, offsetof(SceneRenderView, name));
@@ -1879,8 +1887,9 @@ bool BKE_scene_multiview_is_stereo3d(const RenderData *rd)
{
SceneRenderView *srv[2];
- if ((rd->scemode & R_MULTIVIEW) == 0)
+ if ((rd->scemode & R_MULTIVIEW) == 0) {
return false;
+ }
srv[0] = (SceneRenderView *)BLI_findstring(
&rd->views, STEREO_LEFT_NAME, offsetof(SceneRenderView, name));
@@ -1894,17 +1903,21 @@ bool BKE_scene_multiview_is_stereo3d(const RenderData *rd)
/* return whether to render this SceneRenderView */
bool BKE_scene_multiview_is_render_view_active(const RenderData *rd, const SceneRenderView *srv)
{
- if (srv == NULL)
+ if (srv == NULL) {
return false;
+ }
- if ((rd->scemode & R_MULTIVIEW) == 0)
+ if ((rd->scemode & R_MULTIVIEW) == 0) {
return false;
+ }
- if ((srv->viewflag & SCE_VIEW_DISABLE))
+ if ((srv->viewflag & SCE_VIEW_DISABLE)) {
return false;
+ }
- if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW)
+ if (rd->views_format == SCE_VIEWS_FORMAT_MULTIVIEW) {
return true;
+ }
/* SCE_VIEWS_SETUP_BASIC */
if (STREQ(srv->name, STEREO_LEFT_NAME) || STREQ(srv->name, STEREO_RIGHT_NAME)) {
@@ -1919,11 +1932,13 @@ bool BKE_scene_multiview_is_render_view_first(const RenderData *rd, const char *
{
SceneRenderView *srv;
- if ((rd->scemode & R_MULTIVIEW) == 0)
+ if ((rd->scemode & R_MULTIVIEW) == 0) {
return true;
+ }
- if ((!viewname) || (!viewname[0]))
+ if ((!viewname) || (!viewname[0])) {
return true;
+ }
for (srv = rd->views.first; srv; srv = srv->next) {
if (BKE_scene_multiview_is_render_view_active(rd, srv)) {
@@ -1939,11 +1954,13 @@ bool BKE_scene_multiview_is_render_view_last(const RenderData *rd, const char *v
{
SceneRenderView *srv;
- if ((rd->scemode & R_MULTIVIEW) == 0)
+ if ((rd->scemode & R_MULTIVIEW) == 0) {
return true;
+ }
- if ((!viewname) || (!viewname[0]))
+ if ((!viewname) || (!viewname[0])) {
return true;
+ }
for (srv = rd->views.last; srv; srv = srv->prev) {
if (BKE_scene_multiview_is_render_view_active(rd, srv)) {
@@ -1959,13 +1976,15 @@ SceneRenderView *BKE_scene_multiview_render_view_findindex(const RenderData *rd,
SceneRenderView *srv;
size_t nr;
- if ((rd->scemode & R_MULTIVIEW) == 0)
+ if ((rd->scemode & R_MULTIVIEW) == 0) {
return NULL;
+ }
for (srv = rd->views.first, nr = 0; srv; srv = srv->next) {
if (BKE_scene_multiview_is_render_view_active(rd, srv)) {
- if (nr++ == view_id)
+ if (nr++ == view_id) {
return srv;
+ }
}
}
return srv;
@@ -1975,10 +1994,12 @@ const char *BKE_scene_multiview_render_view_name_get(const RenderData *rd, const
{
SceneRenderView *srv = BKE_scene_multiview_render_view_findindex(rd, view_id);
- if (srv)
+ if (srv) {
return srv->name;
- else
+ }
+ else {
return "";
+ }
}
int BKE_scene_multiview_view_id_get(const RenderData *rd, const char *viewname)
@@ -1986,11 +2007,13 @@ int BKE_scene_multiview_view_id_get(const RenderData *rd, const char *viewname)
SceneRenderView *srv;
size_t nr;
- if ((!rd) || ((rd->scemode & R_MULTIVIEW) == 0))
+ if ((!rd) || ((rd->scemode & R_MULTIVIEW) == 0)) {
return 0;
+ }
- if ((!viewname) || (!viewname[0]))
+ if ((!viewname) || (!viewname[0])) {
return 0;
+ }
for (srv = rd->views.first, nr = 0; srv; srv = srv->next) {
if (BKE_scene_multiview_is_render_view_active(rd, srv)) {
@@ -2027,10 +2050,12 @@ void BKE_scene_multiview_view_filepath_get(const RenderData *rd,
char suffix[FILE_MAX];
srv = BLI_findstring(&rd->views, viewname, offsetof(SceneRenderView, name));
- if (srv)
+ if (srv) {
BLI_strncpy(suffix, srv->suffix, sizeof(suffix));
- else
+ }
+ else {
BLI_strncpy(suffix, viewname, sizeof(suffix));
+ }
BLI_strncpy(r_filepath, filepath, FILE_MAX);
BLI_path_suffix(r_filepath, FILE_MAX, suffix, "");
@@ -2040,14 +2065,17 @@ const char *BKE_scene_multiview_view_suffix_get(const RenderData *rd, const char
{
SceneRenderView *srv;
- if ((viewname == NULL) || (viewname[0] == '\0'))
+ if ((viewname == NULL) || (viewname[0] == '\0')) {
return viewname;
+ }
srv = BLI_findstring(&rd->views, viewname, offsetof(SceneRenderView, name));
- if (srv)
+ if (srv) {
return srv->suffix;
- else
+ }
+ else {
return viewname;
+ }
}
const char *BKE_scene_multiview_view_id_suffix_get(const RenderData *rd, const int view_id)
@@ -2075,8 +2103,9 @@ void BKE_scene_multiview_view_prefix_get(Scene *scene,
/* begin of extension */
index_act = BLI_str_rpartition(name, delims, rext, &suf_act);
- if (*rext == NULL)
+ if (*rext == NULL) {
return;
+ }
BLI_assert(index_act > 0);
UNUSED_VARS_NDEBUG(index_act);
@@ -2113,11 +2142,13 @@ void BKE_scene_multiview_videos_dimensions_get(const RenderData *rd,
int BKE_scene_multiview_num_videos_get(const RenderData *rd)
{
- if (BKE_imtype_is_movie(rd->im_format.imtype) == false)
+ if (BKE_imtype_is_movie(rd->im_format.imtype) == false) {
return 0;
+ }
- if ((rd->scemode & R_MULTIVIEW) == 0)
+ if ((rd->scemode & R_MULTIVIEW) == 0) {
return 1;
+ }
if (rd->im_format.views_format == R_IMF_VIEWS_STEREO_3D) {
return 1;
@@ -2256,7 +2287,8 @@ TransformOrientation *BKE_scene_transform_orientation_find(const Scene *scene, c
}
/**
- * \return the index that \a orientation has within \a scene's transform-orientation list or -1 if not found.
+ * \return the index that \a orientation has within \a scene's transform-orientation list
+ * or -1 if not found.
*/
int BKE_scene_transform_orientation_get_index(const Scene *scene,
const TransformOrientation *orientation)
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 9fa70d38574..9799f7c2943 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -99,8 +99,9 @@ SpaceType *BKE_spacetype_from_id(int spaceid)
SpaceType *st;
for (st = spacetypes.first; st; st = st->next) {
- if (st->spaceid == spaceid)
+ if (st->spaceid == spaceid) {
return st;
+ }
}
return NULL;
}
@@ -109,9 +110,11 @@ ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid)
{
ARegionType *art;
- for (art = st->regiontypes.first; art; art = art->next)
- if (art->regionid == regionid)
+ for (art = st->regiontypes.first; art; art = art->next) {
+ if (art->regionid == regionid) {
return art;
+ }
+ }
printf(
"Error, region type %d missing in - name:\"%s\", id:%d\n", regionid, st->name, st->spaceid);
@@ -166,13 +169,15 @@ void BKE_spacedata_freelist(ListBase *lb)
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
/* free regions for pushed spaces */
- for (ar = sl->regionbase.first; ar; ar = ar->next)
+ for (ar = sl->regionbase.first; ar; ar = ar->next) {
BKE_area_region_free(st, ar);
+ }
BLI_freelistN(&sl->regionbase);
- if (st && st->free)
+ if (st && st->free) {
st->free(sl);
+ }
}
BLI_freelistN(lb);
@@ -235,8 +240,9 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
}
}
- if (ar->v2d.tab_offset)
+ if (ar->v2d.tab_offset) {
newar->v2d.tab_offset = MEM_dupallocN(ar->v2d.tab_offset);
+ }
panel_list_copy(&newar->panels, &ar->panels);
@@ -291,16 +297,19 @@ void BKE_spacedata_draw_locks(int set)
ARegionType *art;
for (art = st->regiontypes.first; art; art = art->next) {
- if (set)
+ if (set) {
art->do_lock = art->lock;
- else
+ }
+ else {
art->do_lock = false;
+ }
}
}
}
/**
- * Version of #BKE_area_find_region_type that also works if \a slink is not the active space of \a sa.
+ * Version of #BKE_area_find_region_type that also works if \a slink
+ * is not the active space of \a sa.
*/
ARegion *BKE_spacedata_find_region_type(const SpaceLink *slink, const ScrArea *sa, int region_type)
{
@@ -398,14 +407,17 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
if (st) {
ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
- if (art && art->free)
+ if (art && art->free) {
art->free(ar);
+ }
- if (ar->regiondata)
+ if (ar->regiondata) {
printf("regiondata free error\n");
+ }
}
- else if (ar->type && ar->type->free)
+ else if (ar->type && ar->type->free) {
ar->type->free(ar);
+ }
if (ar->v2d.tab_offset) {
MEM_freeN(ar->v2d.tab_offset);
@@ -447,8 +459,9 @@ void BKE_screen_area_free(ScrArea *sa)
SpaceType *st = BKE_spacetype_from_id(sa->spacetype);
ARegion *ar;
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
BKE_area_region_free(st, ar);
+ }
MEM_SAFE_FREE(sa->global);
BLI_freelistN(&sa->regionbase);
@@ -477,8 +490,9 @@ void BKE_screen_free(bScreen *sc)
/* No animdata here. */
- for (ar = sc->regionbase.first; ar; ar = ar->next)
+ for (ar = sc->regionbase.first; ar; ar = ar->next) {
BKE_area_region_free(NULL, ar);
+ }
BLI_freelistN(&sc->regionbase);
@@ -543,24 +557,30 @@ void BKE_screen_remove_double_scrverts(bScreen *sc)
/* replace pointers in edges and faces */
se = sc->edgebase.first;
while (se) {
- if (se->v1->newv)
+ if (se->v1->newv) {
se->v1 = se->v1->newv;
- if (se->v2->newv)
+ }
+ if (se->v2->newv) {
se->v2 = se->v2->newv;
+ }
/* edges changed: so.... */
BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
se = se->next;
}
sa = sc->areabase.first;
while (sa) {
- if (sa->v1->newv)
+ if (sa->v1->newv) {
sa->v1 = sa->v1->newv;
- if (sa->v2->newv)
+ }
+ if (sa->v2->newv) {
sa->v2 = sa->v2->newv;
- if (sa->v3->newv)
+ }
+ if (sa->v3->newv) {
sa->v3 = sa->v3->newv;
- if (sa->v4->newv)
+ }
+ if (sa->v4->newv) {
sa->v4 = sa->v4->newv;
+ }
sa = sa->next;
}
@@ -606,25 +626,33 @@ void BKE_screen_remove_unused_scredges(bScreen *sc)
sa = sc->areabase.first;
while (sa) {
se = BKE_screen_find_edge(sc, sa->v1, sa->v2);
- if (se == NULL)
+ if (se == NULL) {
printf("error: area %d edge 1 doesn't exist\n", a);
- else
+ }
+ else {
se->flag = 1;
+ }
se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
- if (se == NULL)
+ if (se == NULL) {
printf("error: area %d edge 2 doesn't exist\n", a);
- else
+ }
+ else {
se->flag = 1;
+ }
se = BKE_screen_find_edge(sc, sa->v3, sa->v4);
- if (se == NULL)
+ if (se == NULL) {
printf("error: area %d edge 3 doesn't exist\n", a);
- else
+ }
+ else {
se->flag = 1;
+ }
se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
- if (se == NULL)
+ if (se == NULL) {
printf("error: area %d edge 4 doesn't exist\n", a);
- else
+ }
+ else {
se->flag = 1;
+ }
sa = sa->next;
a++;
}
@@ -682,8 +710,9 @@ ARegion *BKE_area_find_region_type(const ScrArea *sa, int region_type)
{
if (sa) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == region_type)
+ if (ar->regiontype == region_type) {
return ar;
+ }
}
}
@@ -793,8 +822,9 @@ void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene)
for (ar = v3d->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = ar->regiondata;
- if (rv3d->persp == RV3D_CAMOB)
+ if (rv3d->persp == RV3D_CAMOB) {
rv3d->persp = RV3D_PERSP;
+ }
}
}
}
@@ -868,7 +898,7 @@ void BKE_screen_header_alignment_reset(bScreen *screen)
int alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_HEADER) {
+ if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
if (ELEM(sa->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) {
ar->alignment = RGN_ALIGN_TOP;
continue;
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c
index 7024bafd988..1c0aa63f590 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -21,49 +21,84 @@
*/
#include <stddef.h>
-
-#include "BLI_sys_types.h" /* for intptr_t */
+#include <memory.h>
#include "MEM_guardedalloc.h"
#include "DNA_sequence_types.h"
#include "DNA_scene_types.h"
-#include "IMB_moviecache.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "BLI_mempool.h"
+#include "BLI_threads.h"
#include "BLI_listbase.h"
+#include "BLI_ghash.h"
#include "BKE_sequencer.h"
#include "BKE_scene.h"
+#include "BKE_main.h"
+
+/* ***************************** Sequencer cache design notes ******************************
+ *
+ * Cache key members:
+ * is_temp_cache - this cache entry will be freed before rendering next frame
+ * creator_id - ID of thread that created entry
+ * cost - In short: render time divided by playback frame rate
+ * link_prev/next - link to another entry created during rendering of the frame
+ *
+ * Linking: We use links to reduce number of iterations needed to manage cache.
+ * Entries are linked in order as they are put into cache.
+ * Only pernament (is_temp_cache = 0) cache entries are linked.
+ * Putting SEQ_CACHE_STORE_FINAL_OUT will reset linking
+ *
+ * Function:
+ * All images created during rendering are added to cache, even if the cache is already full.
+ * This is because:
+ * - one image may be needed multiple times during rendering.
+ * - keeping the last rendered frame allows us for faster re-render when user edits strip in stack
+ * - we can decide if we keep frame only when it's completely rendered. Otherwise we risk having
+ * "holes" in the cache, which can be annoying
+ * If the cache is full all entries for pending frame will have is_temp_cache set.
+ *
+ * Only entire frame can be freed to release resources for new entries (recycling).
+ * Once again, this is to reduce number of iterations, but also more controllable than removing
+ * entries one by one in reverse order to their creation.
+ *
+ * User can exclude caching of some images. Such entries will have is_temp_cache set.
+ */
+
+typedef struct SeqCache {
+ struct GHash *hash;
+ ThreadMutex iterator_mutex;
+ struct BLI_mempool *keys_pool;
+ struct BLI_mempool *items_pool;
+ struct SeqCacheKey *last_key;
+ size_t memory_used;
+} SeqCache;
+
+typedef struct SeqCacheItem {
+ struct SeqCache *cache_owner;
+ struct ImBuf *ibuf;
+} SeqCacheItem;
typedef struct SeqCacheKey {
+ struct SeqCache *cache_owner;
+ void *userkey;
+ struct SeqCacheKey *link_prev; /* Used for linking intermediate items to final frame */
+ struct SeqCacheKey *link_next; /* Used for linking intermediate items to final frame */
struct Sequence *seq;
SeqRenderData context;
float cfra;
- eSeqStripElemIBuf type;
+ float nfra;
+ float cost;
+ bool is_temp_cache;
+ short creator_id;
+ int type;
} SeqCacheKey;
-typedef struct SeqPreprocessCacheElem {
- struct SeqPreprocessCacheElem *next, *prev;
-
- struct Sequence *seq;
- SeqRenderData context;
- eSeqStripElemIBuf type;
-
- ImBuf *ibuf;
-} SeqPreprocessCacheElem;
-
-typedef struct SeqPreprocessCache {
- int cfra;
- ListBase elems;
-} SeqPreprocessCache;
-
-static struct MovieCache *moviecache = NULL;
-static struct SeqPreprocessCache *preprocess_cache = NULL;
-
-static void preprocessed_cache_destruct(void);
+static ThreadMutex cache_create_lock = BLI_MUTEX_INITIALIZER;
static bool seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b)
{
@@ -88,198 +123,536 @@ static unsigned int seq_hash_render_data(const SeqRenderData *a)
return rval;
}
-static unsigned int seqcache_hashhash(const void *key_)
+static unsigned int seq_cache_hashhash(const void *key_)
{
const SeqCacheKey *key = key_;
unsigned int rval = seq_hash_render_data(&key->context);
- rval ^= *(const unsigned int *)&key->cfra;
+ rval ^= *(const unsigned int *)&key->nfra;
rval += key->type;
rval ^= ((intptr_t)key->seq) << 6;
return rval;
}
-static bool seqcache_hashcmp(const void *a_, const void *b_)
+static bool seq_cache_hashcmp(const void *a_, const void *b_)
{
const SeqCacheKey *a = a_;
const SeqCacheKey *b = b_;
- return ((a->seq != b->seq) || (a->cfra != b->cfra) || (a->type != b->type) ||
+ return ((a->seq != b->seq) || (a->nfra != b->nfra) || (a->type != b->type) ||
seq_cmp_render_data(&a->context, &b->context));
}
-void BKE_sequencer_cache_destruct(void)
+static SeqCache *seq_cache_get_from_scene(Scene *scene)
{
- if (moviecache)
- IMB_moviecache_free(moviecache);
+ if (scene && scene->ed && scene->ed->cache) {
+ return scene->ed->cache;
+ }
- preprocessed_cache_destruct();
+ return NULL;
}
-void BKE_sequencer_cache_cleanup(void)
+static void seq_cache_lock(Scene *scene)
{
- if (moviecache) {
- IMB_moviecache_free(moviecache);
- moviecache = IMB_moviecache_create(
- "seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp);
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+
+ if (cache) {
+ BLI_mutex_lock(&cache->iterator_mutex);
}
+}
- BKE_sequencer_preprocessed_cache_cleanup();
+static void seq_cache_unlock(Scene *scene)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+
+ if (cache) {
+ BLI_mutex_unlock(&cache->iterator_mutex);
+ }
+}
+
+static void seq_cache_keyfree(void *val)
+{
+ SeqCacheKey *key = val;
+ BLI_mempool_free(key->cache_owner->keys_pool, key);
}
-static bool seqcache_key_check_seq(ImBuf *UNUSED(ibuf), void *userkey, void *userdata)
+static void seq_cache_valfree(void *val)
{
- SeqCacheKey *key = (SeqCacheKey *)userkey;
- Sequence *seq = (Sequence *)userdata;
+ SeqCacheItem *item = (SeqCacheItem *)val;
+ SeqCache *cache = item->cache_owner;
+
+ if (item->ibuf) {
+ cache->memory_used -= IMB_get_size_in_memory(item->ibuf);
+ IMB_freeImBuf(item->ibuf);
+ }
- return key->seq == seq;
+ BLI_mempool_free(item->cache_owner->items_pool, item);
}
-void BKE_sequencer_cache_cleanup_sequence(Sequence *seq)
+static void seq_cache_put(SeqCache *cache, SeqCacheKey *key, ImBuf *ibuf)
{
- if (moviecache)
- IMB_moviecache_cleanup(moviecache, seqcache_key_check_seq, seq);
+ SeqCacheItem *item;
+ item = BLI_mempool_alloc(cache->items_pool);
+ item->cache_owner = cache;
+ item->ibuf = ibuf;
+
+ if (BLI_ghash_reinsert(cache->hash, key, item, seq_cache_keyfree, seq_cache_valfree)) {
+ IMB_refImBuf(ibuf);
+ cache->last_key = key;
+ cache->memory_used += IMB_get_size_in_memory(ibuf);
+ }
}
-struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
- Sequence *seq,
- float cfra,
- eSeqStripElemIBuf type)
+static ImBuf *seq_cache_get(SeqCache *cache, void *key)
{
- if (moviecache && seq) {
- SeqCacheKey key;
+ SeqCacheItem *item = BLI_ghash_lookup(cache->hash, key);
- key.seq = seq;
- key.context = *context;
- key.cfra = cfra - seq->start;
- key.type = type;
+ if (item && item->ibuf) {
+ IMB_refImBuf(item->ibuf);
- return IMB_moviecache_get(moviecache, &key);
+ return item->ibuf;
}
return NULL;
}
-void BKE_sequencer_cache_put(
- const SeqRenderData *context, Sequence *seq, float cfra, eSeqStripElemIBuf type, ImBuf *i)
+static void seq_cache_relink_keys(SeqCacheKey *link_next, SeqCacheKey *link_prev)
{
- SeqCacheKey key;
+ if (link_next) {
+ link_next->link_prev = link_prev;
+ }
+ if (link_prev) {
+ link_prev->link_next = link_next;
+ }
+}
- if (i == NULL || context->skip_cache) {
+static SeqCacheKey *seq_cache_choose_key(Scene *scene, SeqCacheKey *lkey, SeqCacheKey *rkey)
+{
+ SeqCacheKey *finalkey = NULL;
+
+ if (rkey && lkey) {
+ if (lkey->cfra > rkey->cfra) {
+ SeqCacheKey *swapkey = lkey;
+ lkey = rkey;
+ rkey = swapkey;
+ }
+
+ int l_diff = scene->r.cfra - lkey->cfra;
+ int r_diff = rkey->cfra - scene->r.cfra;
+
+ if (l_diff > r_diff) {
+ finalkey = lkey;
+ }
+ else {
+ finalkey = rkey;
+ }
+ }
+ else {
+ if (lkey) {
+ finalkey = lkey;
+ }
+ else {
+ finalkey = rkey;
+ }
+ }
+ return finalkey;
+}
+
+static void seq_cache_recycle_linked(Scene *scene, SeqCacheKey *base)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
return;
}
- if (!moviecache) {
- moviecache = IMB_moviecache_create(
- "seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp);
+ SeqCacheKey *next = base->link_next;
+
+ while (base) {
+ SeqCacheKey *prev = base->link_prev;
+ BLI_ghash_remove(cache->hash, base, seq_cache_keyfree, seq_cache_valfree);
+ base = prev;
+ }
+
+ base = next;
+ while (base) {
+ next = base->link_next;
+ BLI_ghash_remove(cache->hash, base, seq_cache_keyfree, seq_cache_valfree);
+ base = next;
+ }
+}
+
+static SeqCacheKey *seq_cache_get_item_for_removal(Scene *scene)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ SeqCacheKey *finalkey = NULL;
+ /*leftmost key*/
+ SeqCacheKey *lkey = NULL;
+ /*rightmost key*/
+ SeqCacheKey *rkey = NULL;
+ SeqCacheKey *key = NULL;
+
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ int total_count = 0;
+ int cheap_count = 0;
+
+ while (!BLI_ghashIterator_done(&gh_iter)) {
+ key = BLI_ghashIterator_getKey(&gh_iter);
+ SeqCacheItem *item = BLI_ghashIterator_getValue(&gh_iter);
+ BLI_ghashIterator_step(&gh_iter);
+
+ /* this shouldn't happen, but better be safe than sorry */
+ if (!item->ibuf) {
+ seq_cache_recycle_linked(scene, key);
+ /* can not continue iterating after linked remove */
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ continue;
+ }
+
+ if (key->is_temp_cache || key->link_next != NULL) {
+ continue;
+ }
+
+ total_count++;
+
+ if (key->cost <= scene->ed->recycle_max_cost) {
+ cheap_count++;
+ if (lkey) {
+ if (key->cfra < lkey->cfra) {
+ lkey = key;
+ }
+ }
+ else {
+ lkey = key;
+ }
+ if (rkey) {
+ if (key->cfra > rkey->cfra) {
+ rkey = key;
+ }
+ }
+ else {
+ rkey = key;
+ }
+ }
+ }
+
+ finalkey = seq_cache_choose_key(scene, lkey, rkey);
+ return finalkey;
+}
+
+/* Find only "base" keys
+ * Sources(other types) for a frame must be freed all at once
+ */
+static bool seq_cache_recycle_item(Scene *scene)
+{
+ size_t memory_total = ((size_t)U.memcachelimit) * 1024 * 1024;
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
+ return false;
+ }
+
+ seq_cache_lock(scene);
+
+ while (cache->memory_used > memory_total) {
+ SeqCacheKey *finalkey = seq_cache_get_item_for_removal(scene);
+
+ if (finalkey) {
+ seq_cache_recycle_linked(scene, finalkey);
+ }
+ else {
+ seq_cache_unlock(scene);
+ return false;
+ }
+ }
+ seq_cache_unlock(scene);
+ return true;
+}
+
+static void seq_cache_set_temp_cache_linked(Scene *scene, SeqCacheKey *base)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+
+ if (!cache || !base) {
+ return;
}
- key.seq = seq;
- key.context = *context;
- key.cfra = cfra - seq->start;
- key.type = type;
+ SeqCacheKey *next = base->link_next;
+
+ while (base) {
+ SeqCacheKey *prev = base->link_prev;
+ base->is_temp_cache = true;
+ base = prev;
+ }
- IMB_moviecache_put(moviecache, &key, i);
+ base = next;
+ while (base) {
+ next = base->link_next;
+ base->is_temp_cache = true;
+ base = next;
+ }
}
-void BKE_sequencer_preprocessed_cache_cleanup(void)
+static void BKE_sequencer_cache_create(Scene *scene)
{
- SeqPreprocessCacheElem *elem;
+ BLI_mutex_lock(&cache_create_lock);
+ if (scene->ed->cache == NULL) {
+ SeqCache *cache = MEM_callocN(sizeof(SeqCache), "SeqCache");
+ cache->keys_pool = BLI_mempool_create(sizeof(SeqCacheKey), 0, 64, BLI_MEMPOOL_NOP);
+ cache->items_pool = BLI_mempool_create(sizeof(SeqCacheItem), 0, 64, BLI_MEMPOOL_NOP);
+ cache->hash = BLI_ghash_new(seq_cache_hashhash, seq_cache_hashcmp, "SeqCache hash");
+ cache->last_key = NULL;
+ BLI_mutex_init(&cache->iterator_mutex);
+ scene->ed->cache = cache;
+ }
+ BLI_mutex_unlock(&cache_create_lock);
+}
+
+/* ***************************** API ****************************** */
- if (!preprocess_cache)
+void BKE_sequencer_cache_free_temp_cache(Scene *scene, short id, int cfra)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
return;
+ }
+
+ seq_cache_lock(scene);
- for (elem = preprocess_cache->elems.first; elem; elem = elem->next) {
- IMB_freeImBuf(elem->ibuf);
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ while (!BLI_ghashIterator_done(&gh_iter)) {
+ SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
+ BLI_ghashIterator_step(&gh_iter);
+
+ if (key->is_temp_cache && key->creator_id == id && key->cfra != cfra) {
+ BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
+ }
}
- BLI_freelistN(&preprocess_cache->elems);
+ seq_cache_unlock(scene);
+}
- BLI_listbase_clear(&preprocess_cache->elems);
+void BKE_sequencer_cache_destruct(Scene *scene)
+{
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
+ return;
+ }
+
+ BLI_ghash_free(cache->hash, seq_cache_keyfree, seq_cache_valfree);
+ BLI_mempool_destroy(cache->keys_pool);
+ BLI_mempool_destroy(cache->items_pool);
+ BLI_mutex_end(&cache->iterator_mutex);
+ MEM_freeN(cache);
+ scene->ed->cache = NULL;
}
-static void preprocessed_cache_destruct(void)
+void BKE_sequencer_cache_cleanup_all(Main *bmain)
+{
+ for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
+ BKE_sequencer_cache_cleanup(scene);
+ }
+}
+void BKE_sequencer_cache_cleanup(Scene *scene)
{
- if (!preprocess_cache)
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
return;
+ }
+
+ seq_cache_lock(scene);
- BKE_sequencer_preprocessed_cache_cleanup();
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ while (!BLI_ghashIterator_done(&gh_iter)) {
+ SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
- MEM_freeN(preprocess_cache);
- preprocess_cache = NULL;
+ BLI_ghashIterator_step(&gh_iter);
+ BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
+ }
+ cache->last_key = NULL;
+ seq_cache_unlock(scene);
}
-ImBuf *BKE_sequencer_preprocessed_cache_get(const SeqRenderData *context,
- Sequence *seq,
- float cfra,
- eSeqStripElemIBuf type)
+void BKE_sequencer_cache_cleanup_sequence(Scene *scene, Sequence *seq)
{
- SeqPreprocessCacheElem *elem;
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
+ return;
+ }
- if (!preprocess_cache)
- return NULL;
+ seq_cache_lock(scene);
+
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ while (!BLI_ghashIterator_done(&gh_iter)) {
+ SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
+ BLI_ghashIterator_step(&gh_iter);
+
+ if (key->seq == seq) {
+ /* Relink keys, so we don't end up with orphaned keys */
+ if (key->link_next || key->link_prev) {
+ seq_cache_relink_keys(key->link_next, key->link_prev);
+ }
+
+ BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree);
+ }
+ }
+ cache->last_key = NULL;
+ seq_cache_unlock(scene);
+}
- if (preprocess_cache->cfra != cfra)
+struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context,
+ Sequence *seq,
+ float cfra,
+ int type)
+{
+ Scene *scene = context->scene;
+
+ if (!scene->ed->cache) {
+ BKE_sequencer_cache_create(scene);
return NULL;
+ }
- for (elem = preprocess_cache->elems.first; elem; elem = elem->next) {
- if (elem->seq != seq)
- continue;
+ seq_cache_lock(scene);
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ ImBuf *ibuf = NULL;
- if (elem->type != type)
- continue;
+ if (cache && seq) {
+ SeqCacheKey key;
- if (seq_cmp_render_data(&elem->context, context) != 0)
- continue;
+ key.seq = seq;
+ key.context = *context;
+ key.nfra = cfra - seq->start;
+ key.type = type;
- IMB_refImBuf(elem->ibuf);
- return elem->ibuf;
+ ibuf = seq_cache_get(cache, &key);
}
+ seq_cache_unlock(scene);
- return NULL;
+ return ibuf;
+}
+
+bool BKE_sequencer_cache_put_if_possible(
+ const SeqRenderData *context, Sequence *seq, float cfra, int type, ImBuf *ibuf, float cost)
+{
+ Scene *scene = context->scene;
+
+ if (seq_cache_recycle_item(scene)) {
+ BKE_sequencer_cache_put(context, seq, cfra, type, ibuf, cost);
+ return true;
+ }
+ else {
+ seq_cache_set_temp_cache_linked(scene, scene->ed->cache->last_key);
+ scene->ed->cache->last_key = NULL;
+ return false;
+ }
}
-void BKE_sequencer_preprocessed_cache_put(
- const SeqRenderData *context, Sequence *seq, float cfra, eSeqStripElemIBuf type, ImBuf *ibuf)
+void BKE_sequencer_cache_put(
+ const SeqRenderData *context, Sequence *seq, float cfra, int type, ImBuf *i, float cost)
{
- SeqPreprocessCacheElem *elem;
+ Scene *scene = context->scene;
+ short creator_id = 0;
+
+ if (i == NULL || context->skip_cache || context->is_proxy_render || !seq) {
+ return;
+ }
+
+ /* Prevent reinserting, it breaks cache key linking */
+ ImBuf *test = BKE_sequencer_cache_get(context, seq, cfra, type);
+ if (test) {
+ IMB_freeImBuf(test);
+ return;
+ }
- if (!preprocess_cache) {
- preprocess_cache = MEM_callocN(sizeof(SeqPreprocessCache), "sequencer preprocessed cache");
+ if (!scene->ed->cache) {
+ BKE_sequencer_cache_create(scene);
+ }
+
+ seq_cache_lock(scene);
+
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ int flag;
+
+ if (seq->cache_flag & SEQ_CACHE_OVERRIDE) {
+ flag = seq->cache_flag;
+ flag |= scene->ed->cache_flag & SEQ_CACHE_STORE_FINAL_OUT;
}
else {
- if (preprocess_cache->cfra != cfra)
- BKE_sequencer_preprocessed_cache_cleanup();
+ flag = scene->ed->cache_flag;
+ }
+
+ if (cost > SEQ_CACHE_COST_MAX) {
+ cost = SEQ_CACHE_COST_MAX;
}
- elem = MEM_callocN(sizeof(SeqPreprocessCacheElem), "sequencer preprocessed cache element");
+ SeqCacheKey *key;
+ key = BLI_mempool_alloc(cache->keys_pool);
+ key->cache_owner = cache;
+ key->seq = seq;
+ key->context = *context;
+ key->cfra = cfra;
+ key->nfra = cfra - seq->start;
+ key->type = type;
+ key->cost = cost;
+ key->cache_owner = cache;
+ key->link_prev = NULL;
+ key->link_next = NULL;
+ key->is_temp_cache = true;
+ key->creator_id = creator_id;
+
+ /* Item stored for later use */
+ if (flag & type) {
+ key->is_temp_cache = false;
+ key->link_prev = cache->last_key;
+ }
- elem->seq = seq;
- elem->type = type;
- elem->context = *context;
- elem->ibuf = ibuf;
+ SeqCacheKey *temp_last_key = cache->last_key;
+ seq_cache_put(cache, key, i);
- preprocess_cache->cfra = cfra;
+ /* Restore pointer to previous item as this one will be freed when stack is rendered */
+ if (key->is_temp_cache) {
+ cache->last_key = temp_last_key;
+ }
+
+ /* Set last_key's reference to this key so we can look up chain backwards
+ * Item is already put in cache, so cache->last_key points to current key;
+ */
+ if (flag & type && temp_last_key) {
+ temp_last_key->link_next = cache->last_key;
+ }
- IMB_refImBuf(ibuf);
+ /* Reset linking */
+ if (key->type == SEQ_CACHE_STORE_FINAL_OUT) {
+ cache->last_key = NULL;
+ }
- BLI_addtail(&preprocess_cache->elems, elem);
+ seq_cache_unlock(scene);
}
-void BKE_sequencer_preprocessed_cache_cleanup_sequence(Sequence *seq)
+void BKE_sequencer_cache_iterate(
+ struct Scene *scene,
+ void *userdata,
+ bool callback(void *userdata, struct Sequence *seq, int cfra, int cache_type, float cost))
{
- SeqPreprocessCacheElem *elem, *elem_next;
-
- if (!preprocess_cache)
+ SeqCache *cache = seq_cache_get_from_scene(scene);
+ if (!cache) {
return;
+ }
- for (elem = preprocess_cache->elems.first; elem; elem = elem_next) {
- elem_next = elem->next;
+ seq_cache_lock(scene);
+ GHashIterator gh_iter;
+ BLI_ghashIterator_init(&gh_iter, cache->hash);
+ bool interrupt = false;
- if (elem->seq == seq) {
- IMB_freeImBuf(elem->ibuf);
+ while (!BLI_ghashIterator_done(&gh_iter) && !interrupt) {
+ SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
+ BLI_ghashIterator_step(&gh_iter);
- BLI_freelinkN(&preprocess_cache->elems, elem);
- }
+ interrupt = callback(userdata, key->seq, key->cfra, key->type, key->cost);
}
+
+ cache->last_key = NULL;
+ seq_cache_unlock(scene);
}
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index fa596c875a8..b151bc7f092 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -76,11 +76,13 @@ static void slice_get_byte_buffers(const SeqRenderData *context,
*rect1 = (unsigned char *)ibuf1->rect + offset;
*rect_out = (unsigned char *)out->rect + offset;
- if (ibuf2)
+ if (ibuf2) {
*rect2 = (unsigned char *)ibuf2->rect + offset;
+ }
- if (ibuf3)
+ if (ibuf3) {
*rect3 = (unsigned char *)ibuf3->rect + offset;
+ }
}
static void slice_get_float_buffers(const SeqRenderData *context,
@@ -99,11 +101,13 @@ static void slice_get_float_buffers(const SeqRenderData *context,
*rect1 = ibuf1->rect_float + offset;
*rect_out = out->rect_float + offset;
- if (ibuf2)
+ if (ibuf2) {
*rect2 = ibuf2->rect_float + offset;
+ }
- if (ibuf3)
+ if (ibuf3) {
*rect3 = ibuf3->rect_float + offset;
+ }
}
/*********************** Glow effect *************************/
@@ -219,10 +223,12 @@ static void do_alphaover_effect_byte(float facf0,
fac = fac2;
mfac = 1.0f - fac2 * rt1[3];
- if (fac <= 0.0f)
+ if (fac <= 0.0f) {
*((unsigned int *)rt) = *((unsigned int *)cp2);
- else if (mfac <= 0.0f)
+ }
+ else if (mfac <= 0.0f) {
*((unsigned int *)rt) = *((unsigned int *)cp1);
+ }
else {
tempc[0] = fac * rt1[0] + mfac * rt2[0];
tempc[1] = fac * rt1[1] + mfac * rt2[1];
@@ -236,8 +242,9 @@ static void do_alphaover_effect_byte(float facf0,
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -248,10 +255,12 @@ static void do_alphaover_effect_byte(float facf0,
fac = fac4;
mfac = 1.0f - (fac4 * rt1[3]);
- if (fac <= 0.0f)
+ if (fac <= 0.0f) {
*((unsigned int *)rt) = *((unsigned int *)cp2);
- else if (mfac <= 0.0f)
+ }
+ else if (mfac <= 0.0f) {
*((unsigned int *)rt) = *((unsigned int *)cp1);
+ }
else {
tempc[0] = fac * rt1[0] + mfac * rt2[0];
tempc[1] = fac * rt1[1] + mfac * rt2[1];
@@ -307,8 +316,9 @@ static void do_alphaover_effect_float(
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -398,15 +408,18 @@ static void do_alphaunder_effect_byte(float facf0,
/* this complex optimization is because the
* 'skybuf' can be crossed in
*/
- if (rt2[3] <= 0.0f && fac2 >= 1.0f)
+ if (rt2[3] <= 0.0f && fac2 >= 1.0f) {
*((unsigned int *)rt) = *((unsigned int *)cp1);
- else if (rt2[3] >= 1.0f)
+ }
+ else if (rt2[3] >= 1.0f) {
*((unsigned int *)rt) = *((unsigned int *)cp2);
+ }
else {
fac = (fac2 * (1.0f - rt2[3]));
- if (fac <= 0)
+ if (fac <= 0) {
*((unsigned int *)rt) = *((unsigned int *)cp2);
+ }
else {
tempc[0] = (fac * rt1[0] + rt2[0]);
tempc[1] = (fac * rt1[1] + rt2[1]);
@@ -421,8 +434,9 @@ static void do_alphaunder_effect_byte(float facf0,
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -430,15 +444,18 @@ static void do_alphaunder_effect_byte(float facf0,
straight_uchar_to_premul_float(rt1, cp1);
straight_uchar_to_premul_float(rt2, cp2);
- if (rt2[3] <= 0.0f && fac4 >= 1.0f)
+ if (rt2[3] <= 0.0f && fac4 >= 1.0f) {
*((unsigned int *)rt) = *((unsigned int *)cp1);
- else if (rt2[3] >= 1.0f)
+ }
+ else if (rt2[3] >= 1.0f) {
*((unsigned int *)rt) = *((unsigned int *)cp2);
+ }
else {
fac = (fac4 * (1.0f - rt2[3]));
- if (fac <= 0)
+ if (fac <= 0) {
*((unsigned int *)rt) = *((unsigned int *)cp2);
+ }
else {
tempc[0] = (fac * rt1[0] + rt2[0]);
tempc[1] = (fac * rt1[1] + rt2[1]);
@@ -502,8 +519,9 @@ static void do_alphaunder_effect_float(
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -601,8 +619,9 @@ static void do_cross_effect_byte(float facf0,
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -649,8 +668,9 @@ static void do_cross_effect_float(
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -763,12 +783,15 @@ static float gammaCorrect(float c)
* may help solve that, by exchanging LUT size for the interpolation.
* Negative colors are explicitly handled.
*/
- if (UNLIKELY(i < 0))
+ if (UNLIKELY(i < 0)) {
res = -powf(-c, valid_gamma);
- else if (i >= RE_GAMMA_TABLE_SIZE)
+ }
+ else if (i >= RE_GAMMA_TABLE_SIZE) {
res = powf(c, valid_gamma);
- else
+ }
+ else {
res = gamma_range_table[i] + ((c - color_domain_table[i]) * gamfactor_table[i]);
+ }
return res;
}
@@ -782,12 +805,15 @@ static float invGammaCorrect(float c)
i = floorf(c * inv_color_step);
/* Negative colors are explicitly handled */
- if (UNLIKELY(i < 0))
+ if (UNLIKELY(i < 0)) {
res = -powf(-c, valid_inv_gamma);
- else if (i >= RE_GAMMA_TABLE_SIZE)
+ }
+ else if (i >= RE_GAMMA_TABLE_SIZE) {
res = powf(c, valid_inv_gamma);
- else
+ }
+ else {
res = inv_gamma_range_table[i] + ((c - color_domain_table[i]) * inv_gamfactor_table[i]);
+ }
return res;
}
@@ -802,19 +828,23 @@ static void gamtabs(float gamma)
val = a;
val /= 65535.0f;
- if (gamma == 2.0f)
+ if (gamma == 2.0f) {
val = sqrtf(val);
- else if (gamma != 1.0f)
+ }
+ else if (gamma != 1.0f) {
val = powf(val, igamma);
+ }
gamtab[a] = (65535.99f * val);
}
/* inverse gamtab1 : in byte, out short */
for (a = 1; a <= 256; a++) {
- if (gamma == 2.0f)
+ if (gamma == 2.0f) {
igamtab1[a - 1] = a * a - 1;
- else if (gamma == 1.0f)
+ }
+ else if (gamma == 1.0f) {
igamtab1[a - 1] = 256 * a - 1;
+ }
else {
val = a / 256.0f;
igamtab1[a - 1] = (65535.0 * pow(val, gamma)) - 1;
@@ -881,8 +911,9 @@ static void do_gammacross_effect_byte(float facf0,
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -927,8 +958,9 @@ static void do_gammacross_effect_float(
rt++;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo * 4;
@@ -1019,8 +1051,9 @@ static void do_add_effect_byte(float facf0,
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -1067,8 +1100,9 @@ static void do_add_effect_float(
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -1151,8 +1185,9 @@ static void do_sub_effect_byte(float facf0,
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -1200,8 +1235,9 @@ static void do_sub_effect_float(
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -1279,10 +1315,12 @@ static void do_drop_effect_byte(float facf0,
rt1 = rect1i;
out = outi;
for (y = 0; y < height - yoff; y++) {
- if (field)
+ if (field) {
fac = fac1;
- else
+ }
+ else {
fac = fac2;
+ }
field = !field;
memcpy(out, rt1, sizeof(*out) * xoff * 4);
@@ -1326,10 +1364,12 @@ static void do_drop_effect_float(
rt1 = rect1i;
out = outi;
for (y = 0; y < height - yoff; y++) {
- if (field)
+ if (field) {
fac = fac1;
- else
+ }
+ else {
fac = fac2;
+ }
field = !field;
memcpy(out, rt1, sizeof(*out) * xoff * 4);
@@ -1395,8 +1435,9 @@ static void do_mul_effect_byte(float facf0,
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -1446,8 +1487,9 @@ static void do_mul_effect_float(
rt += 4;
}
- if (y == 0)
+ if (y == 0) {
break;
+ }
y--;
x = xo;
@@ -1853,19 +1895,24 @@ static float in_band(float width, float dist, int side, int dir)
{
float alpha;
- if (width == 0)
+ if (width == 0) {
return (float)side;
+ }
- if (width < dist)
+ if (width < dist) {
return (float)side;
+ }
- if (side == 1)
+ if (side == 1) {
alpha = (dist + 0.5f * width) / (width);
- else
+ }
+ else {
alpha = (0.5f * width - dist) / (width);
+ }
- if (dir == 0)
+ if (dir == 0) {
alpha = 1 - alpha;
+ }
return alpha;
}
@@ -1884,8 +1931,9 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
WipeVars *wipe = (WipeVars *)seq->effectdata;
int width;
- if (wipezone->flip)
+ if (wipezone->flip) {
x = xo - x;
+ }
angle = wipezone->angle;
if (wipe->forward) {
@@ -1920,22 +1968,27 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
}
if (wipe->forward) {
- if (b1 < b2)
+ if (b1 < b2) {
output = in_band(width, hyp, 1, 1);
- else
+ }
+ else {
output = in_band(width, hyp, 0, 1);
+ }
}
else {
- if (b1 < b2)
+ if (b1 < b2) {
output = in_band(width, hyp, 0, 1);
- else
+ }
+ else {
output = in_band(width, hyp, 1, 1);
+ }
}
break;
case DO_DOUBLE_WIPE:
- if (!wipe->forward)
+ if (!wipe->forward) {
facf0 = 1.0f - facf0; /* Go the other direction */
+ }
width = wipezone->width; /* calculate the blur width */
hwidth = width * 0.5f;
@@ -1966,15 +2019,19 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
output = in_band(hwidth, hyp2, 0, 1);
}
else {
- if (hyp < hwidth && hyp2 > hwidth)
+ if (hyp < hwidth && hyp2 > hwidth) {
output = in_band(hwidth, hyp, 1, 1);
- else if (hyp > hwidth && hyp2 < hwidth)
+ }
+ else if (hyp > hwidth && hyp2 < hwidth) {
output = in_band(hwidth, hyp2, 1, 1);
- else
+ }
+ else {
output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1);
+ }
}
- if (!wipe->forward)
+ if (!wipe->forward) {
output = 1 - output;
+ }
break;
case DO_CLOCK_WIPE:
/*
@@ -1995,12 +2052,15 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
y = y - halfy;
temp2 = asin(abs(y) / hypot(x, y));
- if (x <= 0 && y >= 0)
+ if (x <= 0 && y >= 0) {
temp2 = (float)M_PI - temp2;
- else if (x <= 0 && y <= 0)
+ }
+ else if (x <= 0 && y <= 0) {
temp2 += (float)M_PI;
- else if (x >= 0 && y <= 0)
+ }
+ else if (x >= 0 && y <= 0) {
temp2 = 2.0f * (float)M_PI - temp2;
+ }
if (wipe->forward) {
temp3 = temp1 - (widthf * 0.5f) * facf0;
@@ -2010,32 +2070,43 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
temp3 = temp1 - (widthf * 0.5f) * (1 - facf0);
temp4 = temp1 + (widthf * 0.5f) * facf0;
}
- if (temp3 < 0)
+ if (temp3 < 0) {
temp3 = 0;
- if (temp4 > 2.0f * (float)M_PI)
+ }
+ if (temp4 > 2.0f * (float)M_PI) {
temp4 = 2.0f * (float)M_PI;
+ }
- if (temp2 < temp3)
+ if (temp2 < temp3) {
output = 0;
- else if (temp2 > temp4)
+ }
+ else if (temp2 > temp4) {
output = 1;
- else
+ }
+ else {
output = (temp2 - temp3) / (temp4 - temp3);
- if (x == 0 && y == 0)
+ }
+ if (x == 0 && y == 0) {
output = 1;
- if (output != output)
+ }
+ if (output != output) {
output = 1;
- if (wipe->forward)
+ }
+ if (wipe->forward) {
output = 1 - output;
+ }
break;
case DO_IRIS_WIPE:
- if (xo > yo)
+ if (xo > yo) {
yo = xo;
- else
+ }
+ else {
xo = yo;
+ }
- if (!wipe->forward)
+ if (!wipe->forward) {
facf0 = 1 - facf0;
+ }
width = wipezone->width;
hwidth = width * 0.5f;
@@ -2044,27 +2115,33 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
pointdist = hypotf(temp1, temp1);
temp2 = hypotf(halfx - x, halfy - y);
- if (temp2 > pointdist)
+ if (temp2 > pointdist) {
output = in_band(hwidth, fabsf(temp2 - pointdist), 0, 1);
- else
+ }
+ else {
output = in_band(hwidth, fabsf(temp2 - pointdist), 1, 1);
+ }
- if (!wipe->forward)
+ if (!wipe->forward) {
output = 1 - output;
+ }
break;
}
- if (output < 0)
+ if (output < 0) {
output = 0;
- else if (output > 1)
+ }
+ else if (output > 1) {
output = 1;
+ }
return output;
}
static void init_wipe_effect(Sequence *seq)
{
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = MEM_callocN(sizeof(WipeVars), "wipevars");
}
@@ -2076,8 +2153,9 @@ static int num_inputs_wipe(void)
static void free_wipe_effect(Sequence *seq, const bool UNUSED(do_id_user))
{
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = NULL;
}
@@ -2265,8 +2343,9 @@ static void init_transform_effect(Sequence *seq)
{
TransformVars *transform;
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = MEM_callocN(sizeof(TransformVars), "transformvars");
@@ -2292,8 +2371,9 @@ static int num_inputs_transform(void)
static void free_transform_effect(Sequence *seq, const bool UNUSED(do_id_user))
{
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = NULL;
}
@@ -2435,13 +2515,15 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i
float fval, k, curColor[4], curColor2[4], weight = 0;
/* If we're not really blurring, bail out */
- if (blur <= 0)
+ if (blur <= 0) {
return;
+ }
/* Allocate memory for the tempmap and the blur filter matrix */
temp = MEM_mallocN((width * height * 4 * sizeof(float)), "blurbitmaptemp");
- if (!temp)
+ if (!temp) {
return;
+ }
/* Allocate memory for the filter elements */
halfWidth = ((quality + 1) * blur);
@@ -2467,11 +2549,13 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i
/* Normalize the array */
fval = 0;
- for (ix = 0; ix < halfWidth * 2; ix++)
+ for (ix = 0; ix < halfWidth * 2; ix++) {
fval += filter[ix];
+ }
- for (ix = 0; ix < halfWidth * 2; ix++)
+ for (ix = 0; ix < halfWidth * 2; ix++) {
filter[ix] /= fval;
+ }
/* Blur the rows */
for (y = 0; y < height; y++) {
@@ -2613,8 +2697,9 @@ static void init_glow_effect(Sequence *seq)
{
GlowVars *glow;
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = MEM_callocN(sizeof(GlowVars), "glowvars");
@@ -2634,8 +2719,9 @@ static int num_inputs_glow(void)
static void free_glow_effect(Sequence *seq, const bool UNUSED(do_id_user))
{
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = NULL;
}
@@ -2667,8 +2753,9 @@ static void do_glow_effect_byte(Sequence *seq,
RVIsolateHighlights_float(
inbuf, outbuf, x, y, glow->fMini * 3.0f, glow->fBoost * facf0, glow->fClamp);
RVBlurBitmap2_float(outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality);
- if (!glow->bNoComp)
+ if (!glow->bNoComp) {
RVAddBitmaps_float(inbuf, outbuf, outbuf, x, y);
+ }
IMB_buffer_float_unpremultiply(outbuf, x, y);
IMB_buffer_byte_from_float(
@@ -2695,8 +2782,9 @@ static void do_glow_effect_float(Sequence *seq,
RVIsolateHighlights_float(
inbuf, outbuf, x, y, glow->fMini * 3.0f, glow->fBoost * facf0, glow->fClamp);
RVBlurBitmap2_float(outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality);
- if (!glow->bNoComp)
+ if (!glow->bNoComp) {
RVAddBitmaps_float(inbuf, outbuf, outbuf, x, y);
+ }
}
static ImBuf *do_glow_effect(const SeqRenderData *context,
@@ -2744,8 +2832,9 @@ static void init_solid_color(Sequence *seq)
{
SolidColorVars *cv;
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = MEM_callocN(sizeof(SolidColorVars), "solidcolor");
@@ -2760,8 +2849,9 @@ static int num_inputs_color(void)
static void free_solid_color(Sequence *seq, const bool UNUSED(do_id_user))
{
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = NULL;
}
@@ -3003,8 +3093,9 @@ static void init_speed_effect(Sequence *seq)
{
SpeedControlVars *v;
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = MEM_callocN(sizeof(SpeedControlVars), "speedcontrolvars");
@@ -3031,10 +3122,12 @@ static int num_inputs_speed(void)
static void free_speed_effect(Sequence *seq, const bool UNUSED(do_id_user))
{
SpeedControlVars *v = (SpeedControlVars *)seq->effectdata;
- if (v->frameMap)
+ if (v->frameMap) {
MEM_freeN(v->frameMap);
- if (seq->effectdata)
+ }
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = NULL;
}
@@ -3099,8 +3192,9 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL);
if (!v->frameMap || v->length != seq->len) {
- if (v->frameMap)
+ if (v->frameMap) {
MEM_freeN(v->frameMap);
+ }
v->length = seq->len;
@@ -3260,8 +3354,9 @@ static void do_overdrop_effect(const SeqRenderData *context,
static void init_gaussian_blur_effect(Sequence *seq)
{
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = MEM_callocN(sizeof(WipeVars), "wipevars");
}
@@ -3273,8 +3368,9 @@ static int num_inputs_gaussian_blur(void)
static void free_gaussian_blur_effect(Sequence *seq, const bool UNUSED(do_id_user))
{
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = NULL;
}
@@ -3313,8 +3409,9 @@ static float *make_gaussian_blur_kernel(float rad, int size)
}
sum = 1.0f / sum;
- for (i = 0; i < n; i++)
+ for (i = 0; i < n; i++) {
gausstab[i] *= sum;
+ }
return gausstab;
}
@@ -3680,8 +3777,9 @@ static void init_text_effect(Sequence *seq)
{
TextVars *data;
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
data = seq->effectdata = MEM_callocN(sizeof(TextVars), "textvars");
data->text_font = NULL;
@@ -3914,8 +4012,9 @@ static void copy_effect_default(Sequence *dst, Sequence *src, const int UNUSED(f
static void free_effect_default(Sequence *seq, const bool UNUSED(do_id_user))
{
- if (seq->effectdata)
+ if (seq->effectdata) {
MEM_freeN(seq->effectdata);
+ }
seq->effectdata = NULL;
}
diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c
index 29a5d556aef..cc44cd66f23 100644
--- a/source/blender/blenkernel/intern/seqmodifier.c
+++ b/source/blender/blenkernel/intern/seqmodifier.c
@@ -107,18 +107,22 @@ static void modifier_init_handle(void *handle_v, int start_line, int tot_line, v
handle->apply_callback = init_data->apply_callback;
handle->user_data = init_data->user_data;
- if (ibuf->rect)
+ if (ibuf->rect) {
handle->rect = (unsigned char *)ibuf->rect + offset;
+ }
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
handle->rect_float = ibuf->rect_float + offset;
+ }
if (mask) {
- if (mask->rect)
+ if (mask->rect) {
handle->mask_rect = (unsigned char *)mask->rect + offset;
+ }
- if (mask->rect_float)
+ if (mask->rect_float) {
handle->mask_rect_float = mask->rect_float + offset;
+ }
}
else {
handle->mask_rect = NULL;
@@ -450,10 +454,12 @@ static void hue_correct_apply_threaded(int width,
float pixel[3], result[3], mask[3] = {1.0f, 1.0f, 1.0f};
float hsv[3], f;
- if (rect_float)
+ if (rect_float) {
copy_v3_v3(pixel, rect_float + pixel_index);
- else
+ }
+ else {
rgb_uchar_to_float(pixel, rect + pixel_index);
+ }
rgb_to_hsv(pixel[0], pixel[1], pixel[2], hsv, hsv + 1, hsv + 2);
@@ -475,19 +481,23 @@ static void hue_correct_apply_threaded(int width,
/* convert back to rgb */
hsv_to_rgb(hsv[0], hsv[1], hsv[2], result, result + 1, result + 2);
- if (mask_rect_float)
+ if (mask_rect_float) {
copy_v3_v3(mask, mask_rect_float + pixel_index);
- else if (mask_rect)
+ }
+ else if (mask_rect) {
rgb_uchar_to_float(mask, mask_rect + pixel_index);
+ }
result[0] = pixel[0] * (1.0f - mask[0]) + result[0] * mask[0];
result[1] = pixel[1] * (1.0f - mask[1]) + result[1] * mask[1];
result[2] = pixel[2] * (1.0f - mask[2]) + result[2] * mask[2];
- if (rect_float)
+ if (rect_float) {
copy_v3_v3(rect_float + pixel_index, result);
- else
+ }
+ else {
rgb_float_to_uchar(rect + pixel_index, result);
+ }
}
}
}
@@ -584,8 +594,9 @@ static void brightcontrast_apply_threaded(int width,
pixel[c] = pixel[c] * (1.0f - m[c]) + v * m[c];
}
- else
+ else {
pixel[c] = v;
+ }
}
}
}
@@ -625,11 +636,13 @@ static void maskmodifier_apply_threaded(int width,
{
int x, y;
- if (rect && !mask_rect)
+ if (rect && !mask_rect) {
return;
+ }
- if (rect_float && !mask_rect_float)
+ if (rect_float && !mask_rect_float) {
return;
+ }
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
@@ -655,8 +668,9 @@ static void maskmodifier_apply_threaded(int width,
/* float buffers are premultiplied, so need to premul color
* as well to make it easy to alpha-over masted strip.
*/
- for (c = 0; c < 4; c++)
+ for (c = 0; c < 4; c++) {
pixel[c] = pixel[c] * mask;
+ }
}
}
}
@@ -928,25 +942,29 @@ SequenceModifierData *BKE_sequence_modifier_new(Sequence *seq, const char *name,
smd->type = type;
smd->flag |= SEQUENCE_MODIFIER_EXPANDED;
- if (!name || !name[0])
+ if (!name || !name[0]) {
BLI_strncpy(smd->name, smti->name, sizeof(smd->name));
- else
+ }
+ else {
BLI_strncpy(smd->name, name, sizeof(smd->name));
+ }
BLI_addtail(&seq->modifiers, smd);
BKE_sequence_modifier_unique_name(seq, smd);
- if (smti->init_data)
+ if (smti->init_data) {
smti->init_data(smd);
+ }
return smd;
}
bool BKE_sequence_modifier_remove(Sequence *seq, SequenceModifierData *smd)
{
- if (BLI_findindex(&seq->modifiers, smd) == -1)
+ if (BLI_findindex(&seq->modifiers, smd) == -1) {
return false;
+ }
BLI_remlink(&seq->modifiers, smd);
BKE_sequence_modifier_free(smd);
@@ -1011,12 +1029,14 @@ ImBuf *BKE_sequence_modifier_apply_stack(const SeqRenderData *context,
const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);
/* could happen if modifier is being removed or not exists in current version of blender */
- if (!smti)
+ if (!smti) {
continue;
+ }
/* modifier is muted, do nothing */
- if (smd->flag & SEQUENCE_MODIFIER_MUTE)
+ if (smd->flag & SEQUENCE_MODIFIER_MUTE) {
continue;
+ }
if (smti->apply) {
int frame_offset;
@@ -1029,13 +1049,15 @@ ImBuf *BKE_sequence_modifier_apply_stack(const SeqRenderData *context,
ImBuf *mask = modifier_mask_get(smd, context, cfra, frame_offset, ibuf->rect_float != NULL);
- if (processed_ibuf == ibuf)
+ if (processed_ibuf == ibuf) {
processed_ibuf = IMB_dupImBuf(ibuf);
+ }
smti->apply(smd, processed_ibuf, mask);
- if (mask)
+ if (mask) {
IMB_freeImBuf(mask);
+ }
}
}
@@ -1056,8 +1078,9 @@ void BKE_sequence_modifier_list_copy(Sequence *seqn, Sequence *seq)
smdn = MEM_dupallocN(smd);
- if (smti && smti->copy_data)
+ if (smti && smti->copy_data) {
smti->copy_data(smdn, smd);
+ }
smdn->next = smdn->prev = NULL;
BLI_addtail(&seqn->modifiers, smdn);
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 4af06606ef0..b1a32552878 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -27,7 +27,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <math.h>
+#include <time.h>
#include "MEM_guardedalloc.h"
@@ -121,12 +121,23 @@ SequencerDrawView sequencer_view3d_cb = NULL; /* NULL in background mode */
#if 0 /* unused function */
static void printf_strip(Sequence *seq)
{
- fprintf(stderr, "name: '%s', len:%d, start:%d, (startofs:%d, endofs:%d), "
+ fprintf(stderr,
+ "name: '%s', len:%d, start:%d, (startofs:%d, endofs:%d), "
"(startstill:%d, endstill:%d), machine:%d, (startdisp:%d, enddisp:%d)\n",
- seq->name, seq->len, seq->start, seq->startofs, seq->endofs, seq->startstill, seq->endstill, seq->machine,
- seq->startdisp, seq->enddisp);
-
- fprintf(stderr, "\tseq_tx_set_final_left: %d %d\n\n", seq_tx_get_final_left(seq, 0),
+ seq->name,
+ seq->len,
+ seq->start,
+ seq->startofs,
+ seq->endofs,
+ seq->startstill,
+ seq->endstill,
+ seq->machine,
+ seq->startdisp,
+ seq->enddisp);
+
+ fprintf(stderr,
+ "\tseq_tx_set_final_left: %d %d\n\n",
+ seq_tx_get_final_left(seq, 0),
seq_tx_get_final_right(seq, 0));
}
#endif
@@ -142,8 +153,9 @@ int BKE_sequencer_base_recursive_apply(ListBase *seqbase,
{
Sequence *iseq;
for (iseq = seqbase->first; iseq; iseq = iseq->next) {
- if (BKE_sequencer_recursive_apply(iseq, apply_func, arg) == -1)
+ if (BKE_sequencer_recursive_apply(iseq, apply_func, arg) == -1) {
return -1; /* bail out */
+ }
}
return 1;
}
@@ -152,11 +164,13 @@ int BKE_sequencer_recursive_apply(Sequence *seq, int (*apply_func)(Sequence *, v
{
int ret = apply_func(seq, arg);
- if (ret == -1)
+ if (ret == -1) {
return -1; /* bail out */
+ }
- if (ret && seq->seqbase.first)
+ if (ret && seq->seqbase.first) {
ret = BKE_sequencer_base_recursive_apply(&seq->seqbase, apply_func, arg);
+ }
return ret;
}
@@ -176,8 +190,9 @@ static void free_proxy_seq(Sequence *seq)
static void seq_free_strip(Strip *strip)
{
strip->us--;
- if (strip->us > 0)
+ if (strip->us > 0) {
return;
+ }
if (strip->us < 0) {
printf("error: negative users in strip\n");
return;
@@ -210,8 +225,9 @@ static void BKE_sequence_free_ex(Scene *scene,
const bool do_cache,
const bool do_id_user)
{
- if (seq->strip)
+ if (seq->strip) {
seq_free_strip(seq->strip);
+ }
BKE_sequence_free_anim(seq);
@@ -234,11 +250,13 @@ static void BKE_sequence_free_ex(Scene *scene,
if (scene) {
Editing *ed = scene->ed;
- if (ed->act_seq == seq)
+ if (ed->act_seq == seq) {
ed->act_seq = NULL;
+ }
- if (seq->scene_sound && ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE))
+ if (seq->scene_sound && ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) {
BKE_sound_remove_scene_sound(scene, seq->scene_sound);
+ }
seq_free_animdata(scene, seq);
}
@@ -255,7 +273,8 @@ static void BKE_sequence_free_ex(Scene *scene,
* also invalidate cache for all dependent sequences
*
* be _very_ careful here, invalidating cache loops over the scene sequences and
- * assumes the listbase is valid for all strips, this may not be the case if lists are being freed.
+ * assumes the listbase is valid for all strips,
+ * this may not be the case if lists are being freed.
* this is optional BKE_sequence_invalidate_cache
*/
if (do_cache) {
@@ -445,6 +464,11 @@ Editing *BKE_sequencer_editing_ensure(Scene *scene)
ed = scene->ed = MEM_callocN(sizeof(Editing), "addseq");
ed->seqbasep = &ed->seqbase;
+ ed->cache = NULL;
+ ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
+ ed->cache_flag |= SEQ_CACHE_VIEW_FINAL_OUT;
+ ed->cache_flag |= SEQ_CACHE_VIEW_ENABLE;
+ ed->recycle_max_cost = 10.0f;
}
return scene->ed;
@@ -455,11 +479,11 @@ void BKE_sequencer_editing_free(Scene *scene, const bool do_id_user)
Editing *ed = scene->ed;
Sequence *seq;
- if (ed == NULL)
+ if (ed == NULL) {
return;
+ }
- /* this may not be the active scene!, could be smarter about this */
- BKE_sequencer_cache_cleanup();
+ BKE_sequencer_cache_destruct(scene);
SEQ_BEGIN (ed, seq) {
/* handle cache freeing above */
@@ -561,8 +585,9 @@ void BKE_sequencer_imbuf_from_sequencer_space(Scene *scene, ImBuf *ibuf)
const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(
COLOR_ROLE_SCENE_LINEAR);
- if (!ibuf->rect_float)
+ if (!ibuf->rect_float) {
return;
+ }
if (to_colorspace && to_colorspace[0] != '\0') {
IMB_colormanagement_transform_threaded(
@@ -629,8 +654,9 @@ static void seq_count(ListBase *seqbase, int *tot)
for (seq = seqbase->first; seq; seq = seq->next) {
(*tot)++;
- if (seq->seqbase.first)
+ if (seq->seqbase.first) {
seq_count(&seq->seqbase, tot);
+ }
}
}
@@ -641,8 +667,9 @@ static void seq_build_array(ListBase *seqbase, Sequence ***array, int depth)
for (seq = seqbase->first; seq; seq = seq->next) {
seq->depth = depth;
- if (seq->seqbase.first)
+ if (seq->seqbase.first) {
seq_build_array(&seq->seqbase, array, depth + 1);
+ }
**array = seq;
(*array)++;
@@ -656,22 +683,28 @@ static void seq_array(Editing *ed, Sequence ***seqarray, int *tot, bool use_poin
*seqarray = NULL;
*tot = 0;
- if (ed == NULL)
+ if (ed == NULL) {
return;
+ }
- if (use_pointer)
+ if (use_pointer) {
seq_count(ed->seqbasep, tot);
- else
+ }
+ else {
seq_count(&ed->seqbase, tot);
+ }
- if (*tot == 0)
+ if (*tot == 0) {
return;
+ }
*seqarray = array = MEM_mallocN(sizeof(Sequence *) * (*tot), "SeqArray");
- if (use_pointer)
+ if (use_pointer) {
seq_build_array(ed->seqbasep, &array, 0);
- else
+ }
+ else {
seq_build_array(&ed->seqbase, &array, 0);
+ }
}
void BKE_sequence_iterator_begin(Editing *ed, SeqIterator *iter, bool use_pointer)
@@ -688,16 +721,19 @@ void BKE_sequence_iterator_begin(Editing *ed, SeqIterator *iter, bool use_pointe
void BKE_sequence_iterator_next(SeqIterator *iter)
{
- if (++iter->cur < iter->tot)
+ if (++iter->cur < iter->tot) {
iter->seq = iter->array[iter->cur];
- else
+ }
+ else {
iter->valid = 0;
+ }
}
void BKE_sequence_iterator_end(SeqIterator *iter)
{
- if (iter->array)
+ if (iter->array) {
MEM_freeN(iter->array);
+ }
iter->valid = 0;
}
@@ -730,11 +766,13 @@ static void seq_update_sound_bounds_recursive_rec(Scene *scene,
if (seq->scene_sound) {
int startofs = seq->startofs;
int endofs = seq->endofs;
- if (seq->startofs + seq->start < start)
+ if (seq->startofs + seq->start < start) {
startofs = start - seq->start;
+ }
- if (seq->start + seq->len - seq->endofs > end)
+ if (seq->start + seq->len - seq->endofs > end) {
endofs = seq->start + seq->len - end;
+ }
BKE_sound_move_scene_sound(scene,
seq->scene_sound,
@@ -754,10 +792,12 @@ static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
void BKE_sequence_calc_disp(Scene *scene, Sequence *seq)
{
- if (seq->startofs && seq->startstill)
+ if (seq->startofs && seq->startstill) {
seq->startstill = 0;
- if (seq->endofs && seq->endstill)
+ }
+ if (seq->endofs && seq->endstill) {
seq->endstill = 0;
+ }
seq->startdisp = seq->start + seq->startofs - seq->startstill;
seq->enddisp = seq->start + seq->len - seq->endofs + seq->endstill;
@@ -786,8 +826,9 @@ void BKE_sequence_calc(Scene *scene, Sequence *seq)
/* check all metas recursively */
seqm = seq->seqbase.first;
while (seqm) {
- if (seqm->seqbase.first)
+ if (seqm->seqbase.first) {
BKE_sequence_calc(scene, seqm);
+ }
seqm = seqm->next;
}
@@ -795,10 +836,12 @@ void BKE_sequence_calc(Scene *scene, Sequence *seq)
if (seq->type & SEQ_TYPE_EFFECT) {
/* pointers */
- if (seq->seq2 == NULL)
+ if (seq->seq2 == NULL) {
seq->seq2 = seq->seq1;
- if (seq->seq3 == NULL)
+ }
+ if (seq->seq3 == NULL) {
seq->seq3 = seq->seq1;
+ }
/* effecten go from seq1 -> seq2: test */
@@ -840,10 +883,12 @@ void BKE_sequence_calc(Scene *scene, Sequence *seq)
min = MAXFRAME * 2;
max = -MAXFRAME * 2;
while (seqm) {
- if (seqm->startdisp < min)
+ if (seqm->startdisp < min) {
min = seqm->startdisp;
- if (seqm->enddisp > max)
+ }
+ if (seqm->enddisp > max) {
max = seqm->enddisp;
+ }
seqm = seqm->next;
}
seq->start = min + seq->anim_startofs;
@@ -982,8 +1027,9 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r
break;
}
case SEQ_TYPE_MOVIECLIP:
- if (seq->clip == NULL)
+ if (seq->clip == NULL) {
return;
+ }
seq->len = BKE_movieclip_get_duration(seq->clip);
@@ -994,8 +1040,9 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r
}
break;
case SEQ_TYPE_MASK:
- if (seq->mask == NULL)
+ if (seq->mask == NULL) {
return;
+ }
seq->len = BKE_mask_get_duration(seq->mask);
seq->len -= seq->anim_startofs;
seq->len -= seq->anim_endofs;
@@ -1005,8 +1052,9 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r
break;
case SEQ_TYPE_SOUND_RAM:
#ifdef WITH_AUDASPACE
- if (!seq->sound)
+ if (!seq->sound) {
return;
+ }
seq->len = ceil((double)AUD_getInfo(seq->sound->playback_handle).length * FPS);
seq->len -= seq->anim_startofs;
seq->len -= seq->anim_endofs;
@@ -1046,8 +1094,9 @@ void BKE_sequencer_sort(Scene *scene)
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq, *seqt;
- if (ed == NULL)
+ if (ed == NULL) {
return;
+ }
BLI_listbase_clear(&seqbase);
BLI_listbase_clear(&effbase);
@@ -1063,8 +1112,9 @@ void BKE_sequencer_sort(Scene *scene)
}
seqt = seqt->next;
}
- if (seqt == NULL)
+ if (seqt == NULL) {
BLI_addtail(&effbase, seq);
+ }
}
else {
seqt = seqbase.first;
@@ -1075,8 +1125,9 @@ void BKE_sequencer_sort(Scene *scene)
}
seqt = seqt->next;
}
- if (seqt == NULL)
+ if (seqt == NULL) {
BLI_addtail(&seqbase, seq);
+ }
}
}
@@ -1095,8 +1146,9 @@ int BKE_sequencer_cmp_time_startdisp(const void *a, const void *b)
static int clear_scene_in_allseqs_cb(Sequence *seq, void *arg_pt)
{
- if (seq->scene == (Scene *)arg_pt)
+ if (seq->scene == (Scene *)arg_pt) {
seq->scene = NULL;
+ }
return 1;
}
@@ -1140,8 +1192,9 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui)
static int seqbase_unique_name_recursive_cb(Sequence *seq, void *arg_pt)
{
- if (seq->seqbase.first)
+ if (seq->seqbase.first) {
seqbase_unique_name(&seq->seqbase, (SeqUniqueInfo *)arg_pt);
+ }
return 1;
}
@@ -1161,8 +1214,9 @@ void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq)
*dot = '\0';
dot++;
- if (*dot)
+ if (*dot) {
sui.count = atoi(dot) + 1;
+ }
}
while (sui.match) {
@@ -1258,7 +1312,7 @@ ListBase *BKE_sequence_seqbase_get(Sequence *seq, int *r_offset)
break;
}
case SEQ_TYPE_SCENE: {
- if (seq->flag & SEQ_SCENE_STRIPS) {
+ if (seq->flag & SEQ_SCENE_STRIPS && seq->scene) {
Editing *ed = BKE_sequencer_editing_get(seq->scene, false);
if (ed) {
seqbase = &ed->seqbase;
@@ -1349,24 +1403,31 @@ static float give_stripelem_index(Sequence *seq, float cfra)
if (seq->flag & SEQ_REVERSE_FRAMES) {
/*reverse frame in this sequence */
- if (cfra <= sta)
+ if (cfra <= sta) {
nr = end - sta;
- else if (cfra >= end)
+ }
+ else if (cfra >= end) {
nr = 0;
- else
+ }
+ else {
nr = end - cfra;
+ }
}
else {
- if (cfra <= sta)
+ if (cfra <= sta) {
nr = 0;
- else if (cfra >= end)
+ }
+ else if (cfra >= end) {
nr = end - sta;
- else
+ }
+ else {
nr = cfra - sta;
+ }
}
- if (seq->strobe < 1.0f)
+ if (seq->strobe < 1.0f) {
seq->strobe = 1.0f;
+ }
if (seq->strobe > 1.0f) {
nr -= fmodf((double)nr, (double)seq->strobe);
@@ -1386,8 +1447,9 @@ StripElem *BKE_sequencer_give_stripelem(Sequence *seq, int cfra)
int nr = (int)give_stripelem_index(seq, cfra);
- if (nr == -1 || se == NULL)
+ if (nr == -1 || se == NULL) {
return NULL;
+ }
se += nr + seq->anim_startofs;
}
@@ -1454,8 +1516,9 @@ int BKE_sequencer_evaluate_frame(Scene *scene, int cfra)
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq_arr[MAXSEQ + 1];
- if (ed == NULL)
+ if (ed == NULL) {
return 0;
+ }
return evaluate_seq_frame_gen(seq_arr, ed->seqbasep, cfra, 0);
}
@@ -1609,10 +1672,12 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
if (use_proxy) {
if (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE) {
- if (ed->proxy_dir[0] == 0)
+ if (ed->proxy_dir[0] == 0) {
BLI_strncpy(dir, "//BL_proxy", sizeof(dir));
- else
+ }
+ else {
BLI_strncpy(dir, ed->proxy_dir, sizeof(dir));
+ }
}
else {
BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
@@ -1733,10 +1798,12 @@ static bool seq_proxy_get_fname(
if (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE) {
char fname[FILE_MAXFILE];
- if (ed->proxy_dir[0] == 0)
+ if (ed->proxy_dir[0] == 0) {
BLI_strncpy(dir, "//BL_proxy", sizeof(dir));
- else
+ }
+ else {
BLI_strncpy(dir, ed->proxy_dir, sizeof(dir));
+ }
if (sanim && sanim->anim) {
IMB_anim_get_fname(sanim->anim, fname, FILE_MAXFILE);
@@ -1766,17 +1833,20 @@ static bool seq_proxy_get_fname(
BLI_path_append(dir, sizeof(dir), fname);
}
else if (seq->type == SEQ_TYPE_IMAGE) {
- if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR)
+ if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) {
BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
- else
+ }
+ else {
BLI_snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir);
+ }
}
else {
return false;
}
- if (view_id > 0)
+ if (view_id > 0) {
BLI_snprintf(suffix, sizeof(suffix), "_%d", view_id);
+ }
if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE &&
ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE) {
@@ -1876,8 +1946,9 @@ static ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int c
if (BLI_exists(name)) {
ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL);
- if (ibuf)
+ if (ibuf) {
sequencer_imbuf_assign_spaces(context->scene, ibuf);
+ }
return ibuf;
}
@@ -1930,8 +2001,9 @@ static void seq_proxy_build_frame(const SeqRenderData *context,
ibuf->foptions.quality = quality;
/* unsupported feature only confuses other s/w */
- if (ibuf->planes == 32)
+ if (ibuf->planes == 32) {
ibuf->planes = 24;
+ }
BLI_make_existing_file(name);
@@ -1949,8 +2021,9 @@ static void seq_proxy_build_frame(const SeqRenderData *context,
*/
static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, const int view_id)
{
- if ((scene->r.scemode & R_MULTIVIEW) == 0)
+ if ((scene->r.scemode & R_MULTIVIEW) == 0) {
return false;
+ }
if ((seq->type == SEQ_TYPE_IMAGE) && (seq->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
static char prefix[FILE_MAX];
@@ -1967,15 +2040,18 @@ static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, con
prefix[0] = '\0';
}
- if (prefix[0] == '\0')
+ if (prefix[0] == '\0') {
return view_id != 0;
+ }
seq_multiview_name(scene, view_id, prefix, ext, str, FILE_MAX);
- if (BLI_access(str, R_OK) == 0)
+ if (BLI_access(str, R_OK) == 0) {
return false;
- else
+ }
+ else {
return view_id != 0;
+ }
}
return false;
}
@@ -1987,8 +2063,9 @@ static int seq_proxy_context_count(Sequence *seq, Scene *scene)
{
int num_views = 1;
- if ((scene->r.scemode & R_MULTIVIEW) == 0)
+ if ((scene->r.scemode & R_MULTIVIEW) == 0) {
return 1;
+ }
switch (seq->type) {
case SEQ_TYPE_MOVIE: {
@@ -2040,8 +2117,9 @@ void BKE_sequencer_proxy_rebuild_context(Main *bmain,
num_files = seq_proxy_context_count(seq, scene);
for (i = 0; i < num_files; i++) {
- if (seq_proxy_multiview_context_invalid(seq, scene, i))
+ if (seq_proxy_multiview_context_invalid(seq, scene, i)) {
continue;
+ }
context = MEM_callocN(sizeof(SeqIndexBuildContext), "seq proxy rebuild context");
@@ -2146,8 +2224,9 @@ void BKE_sequencer_proxy_rebuild(SeqIndexBuildContext *context,
(seq->enddisp - seq->endstill - seq->startdisp - seq->startstill);
*do_update = true;
- if (*stop || G.is_break)
+ if (*stop || G.is_break) {
break;
+ }
}
}
@@ -2156,11 +2235,13 @@ void BKE_sequencer_proxy_rebuild_finish(SeqIndexBuildContext *context, bool stop
if (context->index_context) {
StripAnim *sanim;
- for (sanim = context->seq->anims.first; sanim; sanim = sanim->next)
+ for (sanim = context->seq->anims.first; sanim; sanim = sanim->next) {
IMB_close_anim_proxies(sanim->anim);
+ }
- for (sanim = context->orig_seq->anims.first; sanim; sanim = sanim->next)
+ for (sanim = context->orig_seq->anims.first; sanim; sanim = sanim->next) {
IMB_close_anim_proxies(sanim->anim);
+ }
IMB_anim_index_rebuild_finish(context->index_context, stop);
}
@@ -2201,8 +2282,9 @@ static StripColorBalance calc_cb(StripColorBalance *cb_)
for (c = 0; c < 3; c++) {
/* tweak to give more subtle results
* values above 1.0 are scaled */
- if (cb.lift[c] > 1.0f)
+ if (cb.lift[c] > 1.0f) {
cb.lift[c] = pow(cb.lift[c] - 1.0f, 2.0) + 1.0;
+ }
cb.lift[c] = 2.0f - cb.lift[c];
}
@@ -2240,8 +2322,9 @@ MINLINE float color_balance_fl(
float x = (((in - 1.0f) * lift) + 1.0f) * gain;
/* prevent NaN */
- if (x < 0.f)
+ if (x < 0.f) {
x = 0.f;
+ }
return powf(x, gamma) * mul;
}
@@ -2264,7 +2347,7 @@ static void color_balance_byte_byte(StripColorBalance *cb_,
int height,
float mul)
{
- //unsigned char cb_tab[3][256];
+ // unsigned char cb_tab[3][256];
unsigned char *cp = rect;
unsigned char *e = cp + width * 4 * height;
unsigned char *m = mask_rect;
@@ -2285,15 +2368,17 @@ static void color_balance_byte_byte(StripColorBalance *cb_,
p[c] = p[c] * (1.0f - m_normal) + t * m_normal;
}
- else
+ else {
p[c] = t;
+ }
}
premul_float_to_straight_uchar(cp, p);
cp += 4;
- if (m)
+ if (m) {
m += 4;
+ }
}
}
@@ -2365,15 +2450,18 @@ static void color_balance_float_float(StripColorBalance *cb_,
for (c = 0; c < 3; c++) {
float t = color_balance_fl(p[c], cb.lift[c], cb.gain[c], cb.gamma[c], mul);
- if (m)
+ if (m) {
p[c] = p[c] * (1.0f - m[c]) + t * m[c];
- else
+ }
+ else {
p[c] = t;
+ }
}
p += 4;
- if (m)
+ if (m) {
m += 4;
+ }
}
}
@@ -2417,18 +2505,22 @@ static void color_balance_init_handle(void *handle_v,
handle->height = tot_line;
handle->make_float = init_data->make_float;
- if (ibuf->rect)
+ if (ibuf->rect) {
handle->rect = (unsigned char *)ibuf->rect + offset;
+ }
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
handle->rect_float = ibuf->rect_float + offset;
+ }
if (mask) {
- if (mask->rect)
+ if (mask->rect) {
handle->mask_rect = (unsigned char *)mask->rect + offset;
+ }
- if (mask->rect_float)
+ if (mask->rect_float) {
handle->mask_rect_float = mask->rect_float + offset;
+ }
}
else {
handle->mask_rect = NULL;
@@ -2479,12 +2571,14 @@ ImBuf *BKE_sequencer_render_mask_input(const SeqRenderData *context,
mask_input = seq_render_strip(context, &state, mask_sequence, cfra);
if (make_float) {
- if (!mask_input->rect_float)
+ if (!mask_input->rect_float) {
IMB_float_from_rect(mask_input);
+ }
}
else {
- if (!mask_input->rect)
+ if (!mask_input->rect) {
IMB_rect_from_float(mask_input);
+ }
}
}
}
@@ -2500,8 +2594,9 @@ void BKE_sequencer_color_balance_apply(
{
ColorBalanceInitData init_data;
- if (!ibuf->rect_float && make_float)
+ if (!ibuf->rect_float && make_float) {
imb_addrectfloatImBuf(ibuf);
+ }
init_data.cb = cb;
init_data.ibuf = ibuf;
@@ -2519,8 +2614,9 @@ void BKE_sequencer_color_balance_apply(
* free byte buffer if there's float buffer since float buffer would be used for
* color balance in favor of byte buffer
*/
- if (ibuf->rect_float && ibuf->rect)
+ if (ibuf->rect_float && ibuf->rect) {
imb_freerectImBuf(ibuf);
+ }
}
/*
@@ -2547,7 +2643,7 @@ bool BKE_sequencer_input_have_to_preprocess(const SeqRenderData *context,
{
float mul;
- if (context->is_proxy_render) {
+ if (context && context->is_proxy_render) {
return false;
}
@@ -2717,54 +2813,6 @@ static ImBuf *input_preprocess(const SeqRenderData *context,
return ibuf;
}
-static ImBuf *copy_from_ibuf_still(const SeqRenderData *context, Sequence *seq, float nr)
-{
- ImBuf *rval = NULL;
- ImBuf *ibuf = NULL;
-
- if (nr == 0) {
- ibuf = BKE_sequencer_cache_get(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL);
- }
- else if (nr == seq->len - 1) {
- ibuf = BKE_sequencer_cache_get(context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL);
- }
-
- if (ibuf) {
- rval = IMB_dupImBuf(ibuf);
- IMB_metadata_copy(rval, ibuf);
- IMB_freeImBuf(ibuf);
- }
-
- return rval;
-}
-
-static void copy_to_ibuf_still(const SeqRenderData *context, Sequence *seq, float nr, ImBuf *ibuf)
-{
- /* warning: ibuf may be NULL if the video fails to load */
- if (nr == 0 || nr == seq->len - 1) {
- /* we have to store a copy, since the passed ibuf
- * could be preprocessed afterwards (thereby silently
- * changing the cached image... */
- ImBuf *oibuf = ibuf;
- ibuf = IMB_dupImBuf(oibuf);
-
- if (ibuf) {
- IMB_metadata_copy(ibuf, oibuf);
- sequencer_imbuf_assign_spaces(context->scene, ibuf);
- }
-
- if (nr == 0) {
- BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf);
- }
-
- if (nr == seq->len - 1) {
- BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL, ibuf);
- }
-
- IMB_freeImBuf(ibuf);
- }
-}
-
/*********************** strip rendering functions *************************/
typedef struct RenderEffectInitData {
@@ -2912,16 +2960,19 @@ static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context,
break;
case EARLY_DO_EFFECT:
for (i = 0; i < 3; i++) {
- if (input[i])
+ if (input[i]) {
ibuf[i] = seq_render_strip(context, state, input[i], cfra);
+ }
}
if (ibuf[0] && ibuf[1]) {
- if (sh.multithreaded)
+ if (sh.multithreaded) {
out = seq_render_effect_execute_threaded(
&sh, context, seq, cfra, fac, facf, ibuf[0], ibuf[1], ibuf[2]);
- else
+ }
+ else {
out = sh.execute(context, seq, cfra, fac, facf, ibuf[0], ibuf[1], ibuf[2]);
+ }
}
break;
case EARLY_USE_INPUT_1:
@@ -2967,7 +3018,7 @@ static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context,
static ImBuf *seq_render_image_strip(const SeqRenderData *context,
Sequence *seq,
- float nr,
+ float UNUSED(nr),
float cfra)
{
ImBuf *ibuf = NULL;
@@ -2983,8 +3034,9 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context,
}
flag = IB_rect | IB_metadata;
- if (seq->alpha_mode == SEQ_ALPHA_PREMUL)
+ if (seq->alpha_mode == SEQ_ALPHA_PREMUL) {
flag |= IB_alphamode_premul;
+ }
if (!s_elem) {
/* don't do anything */
@@ -3023,13 +3075,15 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context,
if (ibufs_arr[i]) {
/* we don't need both (speed reasons)! */
- if (ibufs_arr[i]->rect_float && ibufs_arr[i]->rect)
+ if (ibufs_arr[i]->rect_float && ibufs_arr[i]->rect) {
imb_freerectImBuf(ibufs_arr[i]);
+ }
}
}
- if (seq->views_format == R_IMF_VIEWS_STEREO_3D && ibufs_arr[0])
+ if (seq->views_format == R_IMF_VIEWS_STEREO_3D && ibufs_arr[0]) {
IMB_ImBufFromStereo3d(seq->stereo3d_format, ibufs_arr[0], &ibufs_arr[0], &ibufs_arr[1]);
+ }
for (i = 0; i < totviews; i++) {
if (ibufs_arr[i]) {
@@ -3040,8 +3094,8 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context,
BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibufs_arr[i], false);
if (i != context->view_id) {
- copy_to_ibuf_still(&localcontext, seq, nr, ibufs_arr[i]);
- BKE_sequencer_cache_put(&localcontext, seq, cfra, SEQ_STRIPELEM_IBUF, ibufs_arr[i]);
+ BKE_sequencer_cache_put(
+ &localcontext, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED, ibufs_arr[i], 0);
}
}
}
@@ -3066,8 +3120,9 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context,
monoview_image:
if ((ibuf = IMB_loadiffname(name, flag, seq->strip->colorspace_settings.name))) {
/* we don't need both (speed reasons)! */
- if (ibuf->rect_float && ibuf->rect)
+ if (ibuf->rect_float && ibuf->rect) {
imb_freerectImBuf(ibuf);
+ }
/* all sequencer color is done in SRGB space, linear gives odd crossfades */
BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf, false);
@@ -3099,8 +3154,9 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context,
int totviews;
int i;
- if (totfiles != BLI_listbase_count_at_most(&seq->anims, totfiles + 1))
+ if (totfiles != BLI_listbase_count_at_most(&seq->anims, totfiles + 1)) {
goto monoview_movie;
+ }
totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs");
@@ -3126,8 +3182,9 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context,
}
if (ibuf_arr[i]) {
/* we don't need both (speed reasons)! */
- if (ibuf_arr[i]->rect_float && ibuf_arr[i]->rect)
+ if (ibuf_arr[i]->rect_float && ibuf_arr[i]->rect) {
imb_freerectImBuf(ibuf_arr[i]);
+ }
}
}
}
@@ -3152,8 +3209,8 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context,
BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf_arr[i], false);
}
if (i != context->view_id) {
- copy_to_ibuf_still(&localcontext, seq, nr, ibuf_arr[i]);
- BKE_sequencer_cache_put(&localcontext, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf_arr[i]);
+ BKE_sequencer_cache_put(
+ &localcontext, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED, ibuf_arr[i], 0);
}
}
@@ -3397,9 +3454,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
const bool is_rendering = G.is_rendering;
const bool is_background = G.background;
- const bool do_seq_gl = is_rendering ? 0 /* (context->scene->r.seq_flag & R_SEQ_GL_REND) */ :
- (context->scene->r.seq_prev_type) != OB_RENDER;
- // bool have_seq = false; /* UNUSED */
+ const bool do_seq_gl = is_rendering ? 0 : (context->scene->r.seq_prev_type) != OB_RENDER;
bool have_comp = false;
bool use_gpencil = true;
/* do we need to re-evaluate the frame after rendering? */
@@ -3415,7 +3470,9 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
scene = seq->scene;
frame = (double)scene->r.sfra + (double)nr + (double)seq->anim_startofs;
- // have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first); /* UNUSED */
+#if 0 /* UNUSED */
+ have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first);
+#endif
have_comp = (scene->r.scemode & R_DOCOMP) && scene->use_nodes && scene->nodetree;
/* Get view layer for the strip. */
@@ -3462,20 +3519,20 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
char err_out[256] = "unknown";
const int width = (scene->r.xsch * scene->r.size) / 100;
const int height = (scene->r.ysch * scene->r.size) / 100;
- const bool use_background = (scene->r.alphamode == R_ADDSKY);
const char *viewname = BKE_scene_multiview_render_view_name_get(&scene->r, context->view_id);
- unsigned int draw_flags = SEQ_OFSDRAW_NONE;
- draw_flags |= (use_gpencil) ? SEQ_OFSDRAW_USE_GPENCIL : 0;
- draw_flags |= (use_background) ? SEQ_OFSDRAW_USE_BACKGROUND : 0;
- draw_flags |= (context->gpu_full_samples) ? SEQ_OFSDRAW_USE_FULL_SAMPLE : 0;
- draw_flags |= (context->scene->r.seq_flag & R_SEQ_SOLID_TEX) ? SEQ_OFSDRAW_USE_SOLID_TEX : 0;
- draw_flags |= (context->scene->r.seq_flag & R_SEQ_CAMERA_DOF) ? SEQ_OFSDRAW_USE_CAMERA_DOF : 0;
+ unsigned int draw_flags = V3D_OFSDRAW_NONE;
+ draw_flags |= (use_gpencil) ? V3D_OFSDRAW_SHOW_ANNOTATION : 0;
+ draw_flags |= (context->gpu_full_samples) ? V3D_OFSDRAW_USE_FULL_SAMPLE : 0;
+ draw_flags |= (context->scene->r.seq_flag & R_SEQ_OVERRIDE_SCENE_SETTINGS) ?
+ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS :
+ 0;
/* for old scene this can be uninitialized,
* should probably be added to do_versions at some point if the functionality stays */
- if (context->scene->r.seq_prev_type == 0)
+ if (context->scene->r.seq_prev_type == 0) {
context->scene->r.seq_prev_type = 3 /* == OB_SOLID */;
+ }
/* opengl offscreen render */
depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
@@ -3484,6 +3541,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
/* set for OpenGL render (NULL when scrubbing) */
depsgraph,
scene,
+ &context->scene->display.shading,
context->scene->r.seq_prev_type,
camera,
width,
@@ -3516,8 +3574,9 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
* case it's always safe to render scene here
*/
if (!is_thread_main || is_rendering == false || is_background || context->for_render) {
- if (re == NULL)
+ if (re == NULL) {
re = RE_NewSceneRender(scene);
+ }
RE_BlenderFrame(re, context->bmain, scene, view_layer, camera, frame, false);
@@ -3551,8 +3610,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
}
if (i != context->view_id) {
- copy_to_ibuf_still(&localcontext, seq, nr, ibufs_arr[i]);
- BKE_sequencer_cache_put(&localcontext, seq, cfra, SEQ_STRIPELEM_IBUF, ibufs_arr[i]);
+ BKE_sequencer_cache_put(&localcontext, seq, cfra, SEQ_CACHE_STORE_RAW, ibufs_arr[i], 0);
}
RE_ReleaseResultImage(re);
@@ -3582,7 +3640,7 @@ finally:
#ifdef DURIAN_CAMERA_SWITCH
/* stooping to new low's in hackyness :( */
- scene->r.mode &= ~(orig_data.mode & R_NO_CAMERA_SWITCH);
+ scene->r.mode &= orig_data.mode | ~R_NO_CAMERA_SWITCH;
#endif
return ibuf;
@@ -3604,6 +3662,12 @@ static ImBuf *do_render_strip_seqbase(const SeqRenderData *context,
seqbase = BKE_sequence_seqbase_get(seq, &offset);
if (seqbase && !BLI_listbase_is_empty(seqbase)) {
+
+ if (seq->flag & SEQ_SCENE_STRIPS && seq->scene) {
+ BKE_animsys_evaluate_all_animation(
+ context->bmain, context->depsgraph, seq->scene, nr + offset);
+ }
+
meta_ibuf = seq_render_strip_stack(context,
state,
seqbase,
@@ -3662,6 +3726,7 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
*/
SeqRenderData local_context = *context;
local_context.scene = seq->scene;
+ local_context.skip_cache = true;
ibuf = do_render_strip_seqbase(&local_context, state, seq, nr, use_preprocess);
@@ -3672,13 +3737,11 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
else {
/* scene can be NULL after deletions */
ibuf = seq_render_scene_strip(context, seq, nr, cfra);
+ }
- /* Scene strips update all animation, so we need to restore original state.*/
- BKE_animsys_evaluate_all_animation(
- context->bmain, context->depsgraph, context->scene, cfra);
+ /* Scene strips update all animation, so we need to restore original state.*/
+ BKE_animsys_evaluate_all_animation(context->bmain, context->depsgraph, context->scene, cfra);
- copy_to_ibuf_still(context, seq, nr, ibuf);
- }
break;
}
@@ -3715,13 +3778,11 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
case SEQ_TYPE_IMAGE: {
ibuf = seq_render_image_strip(context, seq, nr, cfra);
- copy_to_ibuf_still(context, seq, nr, ibuf);
break;
}
case SEQ_TYPE_MOVIE: {
ibuf = seq_render_movie_strip(context, seq, nr, cfra);
- copy_to_ibuf_still(context, seq, nr, ibuf);
break;
}
@@ -3734,10 +3795,9 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
IMB_freeImBuf(ibuf);
ibuf = i;
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
BKE_sequencer_imbuf_to_sequencer_space(context->scene, ibuf, false);
-
- copy_to_ibuf_still(context, seq, nr, ibuf);
+ }
}
break;
@@ -3746,18 +3806,37 @@ static ImBuf *do_render_strip_uncached(const SeqRenderData *context,
case SEQ_TYPE_MASK: {
/* ibuf is always new */
ibuf = seq_render_mask_strip(context, seq, nr);
-
- copy_to_ibuf_still(context, seq, nr, ibuf);
break;
}
}
- if (ibuf)
+ if (ibuf) {
sequencer_imbuf_assign_spaces(context->scene, ibuf);
+ }
return ibuf;
}
+/* Estimate time spent by the program rendering the strip */
+static clock_t seq_estimate_render_cost_begin(void)
+{
+ return clock();
+}
+
+static float seq_estimate_render_cost_end(Scene *scene, clock_t begin)
+{
+ clock_t end = clock();
+ float time_spent = (float)(end - begin);
+ float time_max = (1.0f / scene->r.frs_sec) * CLOCKS_PER_SEC;
+
+ if (time_max != 0) {
+ return time_spent / time_max;
+ }
+ else {
+ return 1;
+ }
+}
+
static ImBuf *seq_render_strip(const SeqRenderData *context,
SeqRenderState *state,
Sequence *seq,
@@ -3766,65 +3845,62 @@ static ImBuf *seq_render_strip(const SeqRenderData *context,
ImBuf *ibuf = NULL;
bool use_preprocess = false;
bool is_proxy_image = false;
- float nr = give_stripelem_index(seq, cfra);
/* all effects are handled similarly with the exception of speed effect */
int type = (seq->type & SEQ_TYPE_EFFECT && seq->type != SEQ_TYPE_SPEED) ? SEQ_TYPE_EFFECT :
seq->type;
bool is_preprocessed = !ELEM(
type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_SCENE, SEQ_TYPE_MOVIECLIP);
- ibuf = BKE_sequencer_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF);
+ clock_t begin = seq_estimate_render_cost_begin();
- if (ibuf == NULL) {
- ibuf = copy_from_ibuf_still(context, seq, nr);
+ ibuf = BKE_sequencer_cache_get(context, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED);
+ if (ibuf == NULL) {
+ ibuf = BKE_sequencer_cache_get(context, seq, cfra, SEQ_CACHE_STORE_RAW);
if (ibuf == NULL) {
- ibuf = BKE_sequencer_preprocessed_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF);
+ /* MOVIECLIPs have their own proxy management */
+ if (seq->type != SEQ_TYPE_MOVIECLIP) {
+ ibuf = seq_proxy_fetch(context, seq, cfra);
+ is_proxy_image = (ibuf != NULL);
+ }
if (ibuf == NULL) {
- /* MOVIECLIPs have their own proxy management */
- if (seq->type != SEQ_TYPE_MOVIECLIP) {
- ibuf = seq_proxy_fetch(context, seq, cfra);
- is_proxy_image = (ibuf != NULL);
- }
-
- if (ibuf == NULL)
- ibuf = do_render_strip_uncached(context, state, seq, cfra);
+ ibuf = do_render_strip_uncached(context, state, seq, cfra);
+ }
- if (ibuf) {
- if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) {
- is_proxy_image = (context->preview_render_size != 100);
- }
- BKE_sequencer_preprocessed_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf);
+ if (ibuf) {
+ if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) {
+ is_proxy_image = (context->preview_render_size != 100);
}
}
}
- if (ibuf)
+ if (ibuf) {
use_preprocess = BKE_sequencer_input_have_to_preprocess(context, seq, cfra);
- }
- else {
- /* currently, we cache preprocessed images in SEQ_STRIPELEM_IBUF,
- * but not(!) on SEQ_STRIPELEM_IBUF_ENDSTILL and ..._STARTSTILL
- * so, no need in check for preprocess here
- */
- }
+ }
- if (ibuf == NULL) {
- ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
- sequencer_imbuf_assign_spaces(context->scene, ibuf);
- }
+ if (ibuf == NULL) {
+ ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
+ sequencer_imbuf_assign_spaces(context->scene, ibuf);
+ }
- if (context->is_proxy_render == false &&
- (ibuf->x != context->rectx || ibuf->y != context->recty)) {
- use_preprocess = true;
- }
+ if (context->is_proxy_render == false &&
+ (ibuf->x != context->rectx || ibuf->y != context->recty)) {
+ use_preprocess = true;
+ }
- if (use_preprocess)
- ibuf = input_preprocess(context, seq, cfra, ibuf, is_proxy_image, is_preprocessed);
+ if (use_preprocess) {
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(context, seq, cfra, SEQ_CACHE_STORE_RAW, ibuf, cost);
- BKE_sequencer_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf);
+ /* reset timer so we can get partial render time */
+ begin = seq_estimate_render_cost_begin();
+ ibuf = input_preprocess(context, seq, cfra, ibuf, is_proxy_image, is_preprocessed);
+ }
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(context, seq, cfra, SEQ_CACHE_STORE_PREPROCESSED, ibuf, cost);
+ }
return ibuf;
}
@@ -3874,18 +3950,22 @@ static ImBuf *seq_render_strip_stack_apply_effect(
int swap_input = seq_must_swap_input_in_blend_mode(seq);
if (swap_input) {
- if (sh.multithreaded)
+ if (sh.multithreaded) {
out = seq_render_effect_execute_threaded(
&sh, context, seq, cfra, facf, facf, ibuf2, ibuf1, NULL);
- else
+ }
+ else {
out = sh.execute(context, seq, cfra, facf, facf, ibuf2, ibuf1, NULL);
+ }
}
else {
- if (sh.multithreaded)
+ if (sh.multithreaded) {
out = seq_render_effect_execute_threaded(
&sh, context, seq, cfra, facf, facf, ibuf1, ibuf2, NULL);
- else
+ }
+ else {
out = sh.execute(context, seq, cfra, facf, facf, ibuf1, ibuf2, NULL);
+ }
}
return out;
@@ -3901,6 +3981,7 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
int count;
int i;
ImBuf *out = NULL;
+ clock_t begin;
count = get_shown_sequences(seqbasep, cfra, chanshown, (Sequence **)&seq_arr);
@@ -3908,73 +3989,11 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
return NULL;
}
-#if 0 /* commentind since this breaks keyframing, since it resets the value on draw */
- if (scene->r.cfra != cfra) {
- /* XXX for prefetch and overlay offset!..., very bad!!! */
- AnimData *adt = BKE_animdata_from_id(&scene->id);
- BKE_animsys_evaluate_animdata(scene, &scene->id, adt, cfra, ADT_RECALC_ANIM);
- }
-#endif
-
- out = BKE_sequencer_cache_get(context, seq_arr[count - 1], cfra, SEQ_STRIPELEM_IBUF_COMP);
-
- if (out) {
- return out;
- }
-
- if (count == 1) {
- Sequence *seq = seq_arr[0];
-
- /* Some of the blend modes are unclear how to apply with only single input,
- * or some of them will just produce an empty result..
- */
- if (ELEM(seq->blend_mode, SEQ_BLEND_REPLACE, SEQ_TYPE_CROSS, SEQ_TYPE_ALPHAOVER)) {
- int early_out;
- if (seq->blend_mode == SEQ_BLEND_REPLACE) {
- early_out = EARLY_NO_INPUT;
- }
- else {
- early_out = seq_get_early_out_for_blend_mode(seq);
- }
-
- if (ELEM(early_out, EARLY_NO_INPUT, EARLY_USE_INPUT_2)) {
- out = seq_render_strip(context, state, seq, cfra);
- }
- else if (early_out == EARLY_USE_INPUT_1) {
- out = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
- }
- else {
- out = seq_render_strip(context, state, seq, cfra);
-
- if (early_out == EARLY_DO_EFFECT) {
- ImBuf *ibuf1 = IMB_allocImBuf(
- context->rectx, context->recty, 32, out->rect_float ? IB_rectfloat : IB_rect);
- ImBuf *ibuf2 = out;
-
- out = seq_render_strip_stack_apply_effect(context, seq, cfra, ibuf1, ibuf2);
- if (out) {
- IMB_metadata_copy(out, ibuf2);
- }
-
- IMB_freeImBuf(ibuf1);
- IMB_freeImBuf(ibuf2);
- }
- }
- }
- else {
- out = seq_render_strip(context, state, seq, cfra);
- }
-
- BKE_sequencer_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF_COMP, out);
-
- return out;
- }
-
for (i = count - 1; i >= 0; i--) {
int early_out;
Sequence *seq = seq_arr[i];
- out = BKE_sequencer_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF_COMP);
+ out = BKE_sequencer_cache_get(context, seq, cfra, SEQ_CACHE_STORE_COMPOSITE);
if (out) {
break;
@@ -3998,15 +4017,19 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
break;
case EARLY_DO_EFFECT:
if (i == 0) {
+ begin = seq_estimate_render_cost_begin();
+
ImBuf *ibuf1 = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect);
ImBuf *ibuf2 = seq_render_strip(context, state, seq, cfra);
out = seq_render_strip_stack_apply_effect(context, seq, cfra, ibuf1, ibuf2);
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(context, seq_arr[i], cfra, SEQ_CACHE_STORE_COMPOSITE, out, cost);
+
IMB_freeImBuf(ibuf1);
IMB_freeImBuf(ibuf2);
}
-
break;
}
if (out) {
@@ -4014,11 +4037,9 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
}
}
- BKE_sequencer_cache_put(context, seq_arr[i], cfra, SEQ_STRIPELEM_IBUF_COMP, out);
-
i++;
-
for (; i < count; i++) {
+ begin = seq_estimate_render_cost_begin();
Sequence *seq = seq_arr[i];
if (seq_get_early_out_for_blend_mode(seq) == EARLY_DO_EFFECT) {
@@ -4031,7 +4052,8 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
IMB_freeImBuf(ibuf2);
}
- BKE_sequencer_cache_put(context, seq_arr[i], cfra, SEQ_STRIPELEM_IBUF_COMP, out);
+ float cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put(context, seq_arr[i], cfra, SEQ_CACHE_STORE_COMPOSITE, out, cost);
}
return out;
@@ -4044,11 +4066,13 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
ImBuf *BKE_sequencer_give_ibuf(const SeqRenderData *context, float cfra, int chanshown)
{
- Editing *ed = BKE_sequencer_editing_get(context->scene, false);
+ Scene *scene = context->scene;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
ListBase *seqbasep;
- if (ed == NULL)
+ if (ed == NULL) {
return NULL;
+ }
if ((chanshown < 0) && !BLI_listbase_is_empty(&ed->metastack)) {
int count = BLI_listbase_count(&ed->metastack);
@@ -4061,8 +4085,29 @@ ImBuf *BKE_sequencer_give_ibuf(const SeqRenderData *context, float cfra, int cha
SeqRenderState state;
sequencer_state_init(&state);
+ ImBuf *out = NULL;
+ Sequence *seq_arr[MAXSEQ + 1];
+ int count;
- return seq_render_strip_stack(context, &state, seqbasep, cfra, chanshown);
+ count = get_shown_sequences(seqbasep, cfra, chanshown, seq_arr);
+
+ if (count) {
+ out = BKE_sequencer_cache_get(context, seq_arr[count - 1], cfra, SEQ_CACHE_STORE_FINAL_OUT);
+ }
+
+ BKE_sequencer_cache_free_temp_cache(context->scene, 0, cfra);
+
+ clock_t begin = seq_estimate_render_cost_begin();
+ float cost = 0;
+
+ if (count && !out) {
+ out = seq_render_strip_stack(context, &state, seqbasep, cfra, chanshown);
+ cost = seq_estimate_render_cost_end(context->scene, begin);
+ BKE_sequencer_cache_put_if_possible(
+ context, seq_arr[count - 1], cfra, SEQ_CACHE_STORE_FINAL_OUT, out, cost);
+ }
+
+ return out;
}
ImBuf *BKE_sequencer_give_ibuf_seqbase(const SeqRenderData *context,
@@ -4081,7 +4126,9 @@ ImBuf *BKE_sequencer_give_ibuf_direct(const SeqRenderData *context, float cfra,
SeqRenderState state;
sequencer_state_init(&state);
- return seq_render_strip(context, &state, seq, cfra);
+ ImBuf *ibuf = seq_render_strip(context, &state, seq, cfra);
+
+ return ibuf;
}
/* *********************** threading api ******************* */
@@ -4094,8 +4141,8 @@ static pthread_mutex_t queue_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t wakeup_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t wakeup_cond = PTHREAD_COND_INITIALIZER;
-//static pthread_mutex_t prefetch_ready_lock = PTHREAD_MUTEX_INITIALIZER;
-//static pthread_cond_t prefetch_ready_cond = PTHREAD_COND_INITIALIZER;
+// static pthread_mutex_t prefetch_ready_lock = PTHREAD_MUTEX_INITIALIZER;
+// static pthread_cond_t prefetch_ready_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t frame_done_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t frame_done_cond = PTHREAD_COND_INITIALIZER;
@@ -4227,16 +4274,19 @@ ImBuf *BKE_sequencer_give_ibuf_threaded(const SeqRenderData *context, float cfra
/* check whether sequence cur depends on seq */
bool BKE_sequence_check_depend(Sequence *seq, Sequence *cur)
{
- if (cur->seq1 == seq || cur->seq2 == seq || cur->seq3 == seq)
+ if (cur->seq1 == seq || cur->seq2 == seq || cur->seq3 == seq) {
return true;
+ }
/* sequences are not intersecting in time, assume no dependency exists between them */
- if (cur->enddisp < seq->startdisp || cur->startdisp > seq->enddisp)
+ if (cur->enddisp < seq->startdisp || cur->startdisp > seq->enddisp) {
return false;
+ }
/* checking sequence is below reference one, not dependent on it */
- if (cur->machine < seq->machine)
+ if (cur->machine < seq->machine) {
return false;
+ }
/* sequence is not blending with lower machines, no dependency here occurs
* check for non-effects only since effect could use lower machines as input
@@ -4250,28 +4300,29 @@ bool BKE_sequence_check_depend(Sequence *seq, Sequence *cur)
return true;
}
-static void sequence_do_invalidate_dependent(Sequence *seq, ListBase *seqbase)
+static void sequence_do_invalidate_dependent(Scene *scene, Sequence *seq, ListBase *seqbase)
{
Sequence *cur;
for (cur = seqbase->first; cur; cur = cur->next) {
- if (cur == seq)
+ if (cur == seq) {
continue;
+ }
if (BKE_sequence_check_depend(seq, cur)) {
- BKE_sequencer_cache_cleanup_sequence(cur);
- BKE_sequencer_preprocessed_cache_cleanup_sequence(cur);
+ BKE_sequencer_cache_cleanup_sequence(scene, cur);
}
- if (cur->seqbase.first)
- sequence_do_invalidate_dependent(seq, &cur->seqbase);
+ if (cur->seqbase.first) {
+ sequence_do_invalidate_dependent(scene, seq, &cur->seqbase);
+ }
}
}
static void sequence_invalidate_cache(Scene *scene,
Sequence *seq,
bool invalidate_self,
- bool invalidate_preprocess)
+ bool UNUSED(invalidate_preprocess))
{
Editing *ed = scene->ed;
@@ -4282,22 +4333,20 @@ static void sequence_invalidate_cache(Scene *scene,
* re-open the animation.
*/
BKE_sequence_free_anim(seq);
- BKE_sequencer_cache_cleanup_sequence(seq);
+ BKE_sequencer_cache_cleanup_sequence(scene, seq);
}
/* if invalidation is invoked from sequence free routine, effectdata would be NULL here */
- if (seq->effectdata && seq->type == SEQ_TYPE_SPEED)
+ if (seq->effectdata && seq->type == SEQ_TYPE_SPEED) {
BKE_sequence_effect_speed_rebuild_map(scene, seq, true);
-
- if (invalidate_preprocess)
- BKE_sequencer_preprocessed_cache_cleanup_sequence(seq);
+ }
/* invalidate cache for all dependent sequences */
/* NOTE: can not use SEQ_BEGIN/SEQ_END here because that macro will change sequence's depth,
* which makes transformation routines work incorrect
*/
- sequence_do_invalidate_dependent(seq, &ed->seqbase);
+ sequence_do_invalidate_dependent(scene, seq, &ed->seqbase);
}
void BKE_sequence_invalidate_cache(Scene *scene, Sequence *seq)
@@ -4319,7 +4368,7 @@ void BKE_sequencer_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
{
Sequence *seq;
- BKE_sequencer_cache_cleanup();
+ BKE_sequencer_cache_cleanup(scene);
for (seq = seqbase->first; seq; seq = seq->next) {
if (for_render && CFRA >= seq->startdisp && CFRA <= seq->enddisp) {
@@ -4352,25 +4401,35 @@ static bool update_changed_seq_recurs(
/* recurs downwards to see if this seq depends on the changed seq */
- if (seq == NULL)
+ if (seq == NULL) {
return false;
+ }
- if (seq == changed_seq)
+ if (seq == changed_seq) {
free_imbuf = true;
+ }
- for (subseq = seq->seqbase.first; subseq; subseq = subseq->next)
- if (update_changed_seq_recurs(scene, subseq, changed_seq, len_change, ibuf_change))
+ for (subseq = seq->seqbase.first; subseq; subseq = subseq->next) {
+ if (update_changed_seq_recurs(scene, subseq, changed_seq, len_change, ibuf_change)) {
free_imbuf = true;
+ }
+ }
- if (seq->seq1)
- if (update_changed_seq_recurs(scene, seq->seq1, changed_seq, len_change, ibuf_change))
+ if (seq->seq1) {
+ if (update_changed_seq_recurs(scene, seq->seq1, changed_seq, len_change, ibuf_change)) {
free_imbuf = true;
- if (seq->seq2 && (seq->seq2 != seq->seq1))
- if (update_changed_seq_recurs(scene, seq->seq2, changed_seq, len_change, ibuf_change))
+ }
+ }
+ if (seq->seq2 && (seq->seq2 != seq->seq1)) {
+ if (update_changed_seq_recurs(scene, seq->seq2, changed_seq, len_change, ibuf_change)) {
free_imbuf = true;
- if (seq->seq3 && (seq->seq3 != seq->seq1) && (seq->seq3 != seq->seq2))
- if (update_changed_seq_recurs(scene, seq->seq3, changed_seq, len_change, ibuf_change))
+ }
+ }
+ if (seq->seq3 && (seq->seq3 != seq->seq1) && (seq->seq3 != seq->seq2)) {
+ if (update_changed_seq_recurs(scene, seq->seq3, changed_seq, len_change, ibuf_change)) {
free_imbuf = true;
+ }
+ }
if (free_imbuf) {
if (ibuf_change) {
@@ -4382,8 +4441,9 @@ static bool update_changed_seq_recurs(
}
}
- if (len_change)
+ if (len_change) {
BKE_sequence_calc(scene, seq);
+ }
}
return free_imbuf;
@@ -4397,11 +4457,13 @@ void BKE_sequencer_update_changed_seq_and_deps(Scene *scene,
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
- if (ed == NULL)
+ if (ed == NULL) {
return;
+ }
- for (seq = ed->seqbase.first; seq; seq = seq->next)
+ for (seq = ed->seqbase.first; seq; seq = seq->next) {
update_changed_seq_recurs(scene, seq, changed_seq, len_change, ibuf_change);
+ }
}
/* seq funcs's for transforming internally
@@ -4489,13 +4551,15 @@ bool BKE_sequence_base_isolated_sel_check(ListBase *seqbase)
}
}
- if (ok == false)
+ if (ok == false) {
return false;
+ }
/* test relationships */
for (seq = seqbase->first; seq; seq = seq->next) {
- if ((seq->type & SEQ_TYPE_EFFECT) == 0)
+ if ((seq->type & SEQ_TYPE_EFFECT) == 0) {
continue;
+ }
if (seq->flag & SELECT) {
if ((seq->seq1 && (seq->seq1->flag & SELECT) == 0) ||
@@ -4565,8 +4629,9 @@ void BKE_sequence_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
void BKE_sequence_single_fix(Sequence *seq)
{
int left, start, offset;
- if (!BKE_sequence_single_check(seq))
+ if (!BKE_sequence_single_check(seq)) {
return;
+ }
/* make sure the image is always at the start since there is only one,
* adjusting its start should be ok */
@@ -4588,8 +4653,8 @@ bool BKE_sequence_tx_test(Sequence *seq)
/**
* Return \a true if given \a seq needs a complete cleanup of its cache when it is transformed.
*
- * Some (effect) strip types need a complete recache of themselves when they are transformed, because
- * they do not 'contain' anything and do not have any explicit relations to other strips.
+ * Some (effect) strip types need a complete recache of themselves when they are transformed,
+ * because they do not 'contain' anything and do not have any explicit relations to other strips.
*/
bool BKE_sequence_tx_fullupdate_test(Sequence *seq)
{
@@ -4608,8 +4673,9 @@ bool BKE_sequence_test_overlap(ListBase *seqbasep, Sequence *test)
seq = seqbasep->first;
while (seq) {
- if (seq_overlap(test, seq))
+ if (seq_overlap(test, seq)) {
return true;
+ }
seq = seq->next;
}
@@ -4655,12 +4721,14 @@ Sequence *BKE_sequencer_foreground_frame_get(Scene *scene, int frame)
Sequence *seq, *best_seq = NULL;
int best_machine = -1;
- if (!ed)
+ if (!ed) {
return NULL;
+ }
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame)
+ if (seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) {
continue;
+ }
/* Only use strips that generate an image, not ones that combine
* other strips or apply some effect. */
if (ELEM(seq->type,
@@ -4709,8 +4777,9 @@ bool BKE_sequence_base_shuffle_ex(ListBase *seqbasep,
int new_frame = test->enddisp;
for (seq = seqbasep->first; seq; seq = seq->next) {
- if (seq->machine == orig_machine)
+ if (seq->machine == orig_machine) {
new_frame = max_ii(new_frame, seq->enddisp);
+ }
}
test->machine = orig_machine;
@@ -4770,8 +4839,9 @@ static int shuffle_seq_time_offset(Scene *scene, ListBase *seqbasep, char dir)
}
for (seq = seqbasep->first; seq; seq = seq->next) {
- if (seq->tmp)
+ if (seq->tmp) {
BKE_sequence_calc_disp(scene, seq); /* corrects dummy startdisp/enddisp values */
+ }
}
return tot_ofs;
@@ -4891,8 +4961,9 @@ static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, i
if (seq->type == SEQ_TYPE_META) {
/* if this is the current meta sequence, unmute because
* all sequences above this were set to mute */
- if (seq == metaseq)
+ if (seq == metaseq) {
seqmute = 0;
+ }
seq_update_muting_recursive(&seq->seqbase, metaseq, seqmute);
}
@@ -4910,10 +4981,12 @@ void BKE_sequencer_update_muting(Editing *ed)
/* mute all sounds up to current metastack list */
MetaStack *ms = ed->metastack.last;
- if (ms)
+ if (ms) {
seq_update_muting_recursive(&ed->seqbase, ms->parseq, 1);
- else
+ }
+ else {
seq_update_muting_recursive(&ed->seqbase, NULL, 0);
+ }
}
}
@@ -5051,8 +5124,9 @@ void BKE_sequencer_offset_animdata(Scene *scene, Sequence *seq, int ofs)
size_t str_len;
FCurve *fcu;
- if (scene->adt == NULL || ofs == 0 || scene->adt->action == NULL)
+ if (scene->adt == NULL || ofs == 0 || scene->adt->action == NULL) {
return;
+ }
str_len = sequencer_rna_path_prefix(str, seq->name + 2);
@@ -5086,8 +5160,9 @@ void BKE_sequencer_dupe_animdata(Scene *scene, const char *name_src, const char
FCurve *fcu_cpy;
ListBase lb = {NULL, NULL};
- if (scene->adt == NULL || scene->adt->action == NULL)
+ if (scene->adt == NULL || scene->adt->action == NULL) {
return;
+ }
str_from_len = sequencer_rna_path_prefix(str_from, name_src);
@@ -5115,8 +5190,9 @@ static void seq_free_animdata(Scene *scene, Sequence *seq)
size_t str_len;
FCurve *fcu;
- if (scene->adt == NULL || scene->adt->action == NULL)
+ if (scene->adt == NULL || scene->adt->action == NULL) {
return;
+ }
str_len = sequencer_rna_path_prefix(str, seq->name + 2);
@@ -5145,8 +5221,9 @@ Sequence *BKE_sequence_get_by_name(ListBase *seqbase, const char *name, bool rec
Sequence *rseq = NULL;
for (iseq = seqbase->first; iseq; iseq = iseq->next) {
- if (STREQ(name, iseq->name + 2))
+ if (STREQ(name, iseq->name + 2)) {
return iseq;
+ }
else if (recursive && (iseq->seqbase.first) &&
(rseq = BKE_sequence_get_by_name(&iseq->seqbase, name, 1))) {
return rseq;
@@ -5183,8 +5260,9 @@ Sequence *BKE_sequencer_active_get(Scene *scene)
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL)
+ if (ed == NULL) {
return NULL;
+ }
return ed->act_seq;
}
@@ -5193,8 +5271,9 @@ void BKE_sequencer_active_set(Scene *scene, Sequence *seq)
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL)
+ if (ed == NULL) {
return;
+ }
ed->act_seq = seq;
}
@@ -5264,8 +5343,9 @@ static void seq_load_apply(Main *bmain, Scene *scene, Sequence *seq, SeqLoadInfo
}
if (seq_load->flag & SEQ_LOAD_SOUND_CACHE) {
- if (seq->sound)
+ if (seq->sound) {
BKE_sound_cache(seq->sound);
+ }
}
seq_load->tot_success++;
@@ -5296,6 +5376,7 @@ Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine)
seq->scene_sound = NULL;
seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Sequence Stereo Format");
+ seq->cache_flag = SEQ_CACHE_ALL_TYPES;
return seq;
}
@@ -5327,8 +5408,9 @@ void BKE_sequence_init_colorspace(Sequence *seq)
*/
seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
if (ibuf) {
- if (ibuf->flags & IB_alphamode_premul)
+ if (ibuf->flags & IB_alphamode_premul) {
seq->alpha_mode = IMA_ALPHA_PREMUL;
+ }
IMB_freeImBuf(ibuf);
}
@@ -5378,7 +5460,7 @@ Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq = BKE_sequence_alloc(seqbasep, seq_load->start_frame, seq_load->channel);
seq->type = SEQ_TYPE_IMAGE;
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
@@ -5388,8 +5470,9 @@ Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoad
strip->stripdata = MEM_callocN(seq->len * sizeof(StripElem), "stripelem");
BLI_strncpy(strip->dir, seq_load->path, sizeof(strip->dir));
- if (seq_load->stereo3d_format)
+ if (seq_load->stereo3d_format) {
*seq->stereo3d_format = *seq_load->stereo3d_format;
+ }
seq->views_format = seq_load->views_format;
seq->flag |= seq_load->flag & SEQ_USE_VIEWS;
@@ -5436,7 +5519,8 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad
/* basic defaults */
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
- /* We add a very small negative offset here, because ceil(132.0) == 133.0, not nice with videos, see T47135. */
+ /* We add a very small negative offset here, because
+ * ceil(132.0) == 133.0, not nice with videos, see T47135. */
seq->len = (int)ceil((double)info.length * FPS - 1e-4);
strip->us = 1;
@@ -5541,7 +5625,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
seq->flag |= seq_load->flag & SEQ_USE_VIEWS;
seq->type = SEQ_TYPE_MOVIE;
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
for (i = 0; i < totfiles; i++) {
if (anim_arr[i]) {
@@ -5581,8 +5665,9 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
BKE_sequence_calc_disp(scene, seq);
- if (seq_load->name[0] == '\0')
+ if (seq_load->name[0] == '\0') {
BLI_strncpy(seq_load->name, se->name, sizeof(seq_load->name));
+ }
if (seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
int start_frame_back = seq_load->start_frame;
@@ -5649,8 +5734,9 @@ static Sequence *seq_dupli(const Scene *scene_src,
}
else if (seq->type == SEQ_TYPE_SCENE) {
seqn->strip->stripdata = NULL;
- if (seq->scene_sound)
+ if (seq->scene_sound) {
seqn->scene_sound = BKE_sound_scene_add_scene_sound_defaults(scene_dst, seqn);
+ }
}
else if (seq->type == SEQ_TYPE_MOVIECLIP) {
/* avoid assert */
@@ -5664,8 +5750,9 @@ static Sequence *seq_dupli(const Scene *scene_src,
}
else if (seq->type == SEQ_TYPE_SOUND_RAM) {
seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata);
- if (seq->scene_sound)
+ if (seq->scene_sound) {
seqn->scene_sound = BKE_sound_add_scene_sound_defaults(scene_dst, seqn);
+ }
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
id_us_plus((ID *)seqn->sound);
@@ -5677,8 +5764,9 @@ static Sequence *seq_dupli(const Scene *scene_src,
else if (seq->type & SEQ_TYPE_EFFECT) {
struct SeqEffectHandle sh;
sh = BKE_sequence_get_effect(seq);
- if (sh.copy)
+ if (sh.copy) {
sh.copy(seq, seqn, flag);
+ }
seqn->strip->stripdata = NULL;
}
@@ -5690,9 +5778,9 @@ static Sequence *seq_dupli(const Scene *scene_src,
/* When using SEQ_DUPE_UNIQUE_NAME, it is mandatory to add new sequences in relevant container
* (scene or meta's one), *before* checking for unique names. Otherwise the meta's list is empty
* and hence we miss all seqs in that meta that have already been duplicated (see T55668).
- * Note that unique name check itslef could be done at a later step in calling code, once all seqs
- * have bee duplicated (that was first, simpler solution), but then handling of animation data will
- * be broken (see T60194). */
+ * Note that unique name check itslef could be done at a later step in calling code, once all
+ * seqs have bee duplicated (that was first, simpler solution), but then handling of animation
+ * data will be broken (see T60194). */
if (new_seq_list != NULL) {
BLI_addtail(new_seq_list, seqn);
}
@@ -5715,12 +5803,15 @@ static void seq_new_fix_links_recursive(Sequence *seq)
SequenceModifierData *smd;
if (seq->type & SEQ_TYPE_EFFECT) {
- if (seq->seq1 && seq->seq1->tmp)
+ if (seq->seq1 && seq->seq1->tmp) {
seq->seq1 = seq->seq1->tmp;
- if (seq->seq2 && seq->seq2->tmp)
+ }
+ if (seq->seq2 && seq->seq2->tmp) {
seq->seq2 = seq->seq2->tmp;
- if (seq->seq3 && seq->seq3->tmp)
+ }
+ if (seq->seq3 && seq->seq3->tmp) {
seq->seq3 = seq->seq3->tmp;
+ }
}
else if (seq->type == SEQ_TYPE_META) {
Sequence *seqn;
@@ -5730,8 +5821,9 @@ static void seq_new_fix_links_recursive(Sequence *seq)
}
for (smd = seq->modifiers.first; smd; smd = smd->next) {
- if (smd->mask_sequence && smd->mask_sequence->tmp)
+ if (smd->mask_sequence && smd->mask_sequence->tmp) {
smd->mask_sequence = smd->mask_sequence->tmp;
+ }
}
}
@@ -5840,12 +5932,14 @@ int BKE_sequencer_find_next_prev_edit(Scene *scene,
int dist, best_dist, best_frame = cfra;
int seq_frames[2], seq_frames_tot;
- /* in case where both is passed, frame just finds the nearest end while frame_left the nearest start */
+ /* In case where both is passed,
+ * frame just finds the nearest end while frame_left the nearest start. */
best_dist = MAXFRAME * 2;
- if (ed == NULL)
+ if (ed == NULL) {
return cfra;
+ }
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
int i;
@@ -5854,8 +5948,9 @@ int BKE_sequencer_find_next_prev_edit(Scene *scene,
continue;
}
- if (do_unselected && (seq->flag & SELECT))
+ if (do_unselected && (seq->flag & SELECT)) {
continue;
+ }
if (do_center) {
seq_frames[0] = (seq->startdisp + seq->enddisp) / 2;
@@ -5911,15 +6006,12 @@ static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int cfra)
}
}
-void BKE_sequencer_all_free_anim_ibufs(Main *bmain, int cfra)
+void BKE_sequencer_all_free_anim_ibufs(Scene *scene, int cfra)
{
- BKE_sequencer_cache_cleanup();
- for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL) {
- /* Ignore scenes without sequencer. */
- continue;
- }
- sequencer_all_free_anim_ibufs(&ed->seqbase, cfra);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ if (ed == NULL) {
+ return;
}
+ sequencer_all_free_anim_ibufs(&ed->seqbase, cfra);
+ BKE_sequencer_cache_cleanup(scene);
}
diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c
index 98dbc3fc989..75503b8ca10 100644
--- a/source/blender/blenkernel/intern/shader_fx.c
+++ b/source/blender/blenkernel/intern/shader_fx.c
@@ -85,11 +85,13 @@ ShaderFxData *BKE_shaderfx_new(int type)
fx->mode = eShaderFxMode_Realtime | eShaderFxMode_Render | eShaderFxMode_Expanded;
fx->flag = eShaderFxFlag_StaticOverride_Local;
- if (fxi->flags & eShaderFxTypeFlag_EnableInEditmode)
+ if (fxi->flags & eShaderFxTypeFlag_EnableInEditmode) {
fx->mode |= eShaderFxMode_Editmode;
+ }
- if (fxi->initData)
+ if (fxi->initData) {
fxi->initData(fx);
+ }
return fx;
}
@@ -118,10 +120,12 @@ void BKE_shaderfx_free_ex(ShaderFxData *fx, const int flag)
}
}
- if (fxi->freeData)
+ if (fxi->freeData) {
fxi->freeData(fx);
- if (fx->error)
+ }
+ if (fx->error) {
MEM_freeN(fx->error);
+ }
MEM_freeN(fx);
}
@@ -219,9 +223,11 @@ ShaderFxData *BKE_shaderfx_findByType(Object *ob, ShaderFxType type)
{
ShaderFxData *fx = ob->shader_fx.first;
- for (; fx; fx = fx->next)
- if (fx->type == type)
+ for (; fx; fx = fx->next) {
+ if (fx->type == type) {
break;
+ }
+ }
return fx;
}
@@ -233,8 +239,9 @@ void BKE_shaderfx_foreachIDLink(Object *ob, ShaderFxIDWalkFunc walk, void *userD
for (; fx; fx = fx->next) {
const ShaderFxTypeInfo *fxi = BKE_shaderfxType_getInfo(fx->type);
- if (fxi->foreachIDLink)
+ if (fxi->foreachIDLink) {
fxi->foreachIDLink(fx, ob, walk, userData);
+ }
else if (fxi->foreachObjectLink) {
/* each Object can masquerade as an ID, so this should be OK */
ShaderFxObjectWalkFunc fp = (ShaderFxObjectWalkFunc)walk;
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 7a9ccc66824..6a72b46a8f2 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -69,25 +69,25 @@
#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
typedef struct ShrinkwrapCalcData {
- ShrinkwrapModifierData *smd; //shrinkwrap modifier data
+ ShrinkwrapModifierData *smd; // shrinkwrap modifier data
- struct Object *ob; //object we are applying shrinkwrap to
+ struct Object *ob; // object we are applying shrinkwrap to
- struct MVert *vert; //Array of verts being projected (to fetch normals or other data)
- float (*vertexCos)[3]; //vertexs being shrinkwraped
+ struct MVert *vert; // Array of verts being projected (to fetch normals or other data)
+ float (*vertexCos)[3]; // vertexs being shrinkwraped
int numVerts;
- struct MDeformVert *dvert; //Pointer to mdeform array
- int vgroup; //Vertex group num
+ struct MDeformVert *dvert; // Pointer to mdeform array
+ int vgroup; // Vertex group num
bool invert_vgroup; /* invert vertex group influence */
- struct Mesh *target; //mesh we are shrinking to
- struct SpaceTransform local2target; //transform to move between local and target space
+ struct Mesh *target; // mesh we are shrinking to
+ struct SpaceTransform local2target; // transform to move between local and target space
struct ShrinkwrapTreeData *tree; // mesh BVH tree data
struct Object *aux_target;
- float keepDist; //Distance to keep above target surface (units are in local space)
+ float keepDist; // Distance to keep above target surface (units are in local space)
} ShrinkwrapCalcData;
typedef struct ShrinkwrapCalcCBData {
@@ -375,13 +375,15 @@ static void shrinkwrap_calc_nearest_vertex_cb_ex(void *__restrict userdata,
/* Use local proximity heuristics (to reduce the nearest search)
*
- * If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
- * so we can initiate the "nearest.dist" with the expected value to that last hit.
+ * If we already had an hit before.. we assume this vertex is going to have a close hit to that
+ * other vertex so we can initiate the "nearest.dist" with the expected value to that last hit.
* This will lead in pruning of the search tree. */
- if (nearest->index != -1)
+ if (nearest->index != -1) {
nearest->dist_sq = len_squared_v3v3(tmp_co, nearest->co);
- else
+ }
+ else {
nearest->dist_sq = FLT_MAX;
+ }
BLI_bvhtree_find_nearest(treeData->tree, tmp_co, nearest, treeData->nearest_callback, treeData);
@@ -536,8 +538,9 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
if (calc->vert != NULL && calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
/* calc->vert contains verts from evaluated mesh. */
- /* These coordinates are deformed by vertexCos only for normal projection (to get correct normals) */
- /* for other cases calc->verts contains undeformed coordinates and vertexCos should be used */
+ /* These coordinates are deformed by vertexCos only for normal projection
+ * (to get correct normals) for other cases calc->verts contains undeformed coordinates and
+ * vertexCos should be used */
copy_v3_v3(tmp_co, calc->vert[i].co);
normal_short_to_float_v3(tmp_no, calc->vert[i].no);
}
@@ -547,8 +550,9 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata,
}
hit->index = -1;
- hit->dist =
- BVH_RAYCAST_DIST_MAX; /* TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that */
+
+ /* TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that */
+ hit->dist = BVH_RAYCAST_DIST_MAX;
bool is_aux = false;
@@ -647,23 +651,28 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
/* If the user doesn't allows to project in any direction of projection axis
* then there's nothing todo. */
if ((calc->smd->shrinkOpts &
- (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0)
+ (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0) {
return;
+ }
/* Prepare data to retrieve the direction in which we should project each vertex */
if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
- if (calc->vert == NULL)
+ if (calc->vert == NULL) {
return;
+ }
}
else {
/* The code supports any axis that is a combination of X,Y,Z
* although currently UI only allows to set the 3 different axis */
- if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS)
+ if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) {
proj_axis[0] = 1.0f;
- if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS)
+ }
+ if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) {
proj_axis[1] = 1.0f;
- if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS)
+ }
+ if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) {
proj_axis[2] = 1.0f;
+ }
normalize_v3(proj_axis);
@@ -675,8 +684,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
if (calc->aux_target) {
auxMesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(calc->aux_target, false);
- if (!auxMesh)
+ if (!auxMesh) {
return;
+ }
BLI_SPACE_TRANSFORM_SETUP(&local2aux, calc->ob, calc->aux_target);
}
@@ -930,7 +940,8 @@ static bool update_hit(BVHTreeNearest *nearest,
return false;
}
-/* Target projection on a non-manifold boundary edge - treats it like an infinitely thin cylinder. */
+/* Target projection on a non-manifold boundary edge -
+ * treats it like an infinitely thin cylinder. */
static void target_project_edge(const ShrinkwrapTreeData *tree,
int index,
const float co[3],
@@ -1036,8 +1047,9 @@ static void mesh_looptri_target_project(void *userdata,
nearest->dist_sq);
#endif
- if (dist_sq >= nearest->dist_sq)
+ if (dist_sq >= nearest->dist_sq) {
return;
+ }
/* Decode normals */
normal_short_to_float_v3(vtri_no[0], vtri[0]->no);
@@ -1133,8 +1145,8 @@ static void shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdat
/* Use local proximity heuristics (to reduce the nearest search)
*
- * If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
- * so we can initiate the "nearest.dist" with the expected value to that last hit.
+ * If we already had an hit before.. we assume this vertex is going to have a close hit to that
+ * other vertex so we can initiate the "nearest.dist" with the expected value to that last hit.
* This will lead in pruning of the search tree. */
if (nearest->index != -1) {
if (calc->smd->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
@@ -1146,8 +1158,9 @@ static void shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdat
nearest->dist_sq = len_squared_v3v3(tmp_co, nearest->co);
}
}
- else
+ else {
nearest->dist_sq = FLT_MAX;
+ }
BKE_shrinkwrap_find_nearest_surface(data->tree, nearest, tmp_co, calc->smd->shrinkType);
@@ -1375,10 +1388,12 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData;
/* remove loop dependencies on derived meshes (TODO should this be done elsewhere?) */
- if (smd->target == ob)
+ if (smd->target == ob) {
smd->target = NULL;
- if (smd->auxTarget == ob)
+ }
+ if (smd->auxTarget == ob) {
smd->auxTarget = NULL;
+ }
/* Configure Shrinkwrap calc data */
calc.smd = smd;
@@ -1461,6 +1476,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd,
}
/* free memory */
- if (ss_mesh)
+ if (ss_mesh) {
ss_mesh->release(ss_mesh);
+ }
}
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 23cdf802c81..d6858e2d4d2 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -82,14 +82,13 @@
//#define DEBUG_TIME
+#include "smoke_API.h"
+
#ifdef DEBUG_TIME
# include "PIL_time.h"
#endif
#ifdef WITH_SMOKE
-
-# include "smoke_API.h"
-
# include "BLI_task.h"
# include "BLI_kdtree.h"
# include "BLI_voxel.h"
@@ -120,7 +119,7 @@ struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res),
{
return NULL;
}
-//struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(dx), float *UNUSED(dtdef), int UNUSED(use_heat), int UNUSED(use_fire), int UNUSED(use_colors)) { return NULL; }
+
void smoke_free(struct FLUID_3D *UNUSED(fluid))
{
}
@@ -173,8 +172,9 @@ void BKE_smoke_reallocate_fluid(SmokeDomainSettings *sds, float dx, int res[3],
int use_fire = (sds->active_fields & SM_ACTIVE_FIRE);
int use_colors = (sds->active_fields & SM_ACTIVE_COLORS);
- if (free_old && sds->fluid)
+ if (free_old && sds->fluid) {
smoke_free(sds->fluid);
+ }
if (!min_iii(res[0], res[1], res[2])) {
sds->fluid = NULL;
return;
@@ -194,8 +194,9 @@ void BKE_smoke_reallocate_fluid(SmokeDomainSettings *sds, float dx, int res[3],
&(sds->flame_max_temp));
/* reallocate shadow buffer */
- if (sds->shadow)
+ if (sds->shadow) {
MEM_freeN(sds->shadow);
+ }
sds->shadow = MEM_callocN(sizeof(float) * res[0] * res[1] * res[2], "SmokeDomainShadow");
}
@@ -207,8 +208,9 @@ void BKE_smoke_reallocate_highres_fluid(SmokeDomainSettings *sds,
int use_fire = (sds->active_fields & (SM_ACTIVE_HEAT | SM_ACTIVE_FIRE));
int use_colors = (sds->active_fields & SM_ACTIVE_COLORS);
- if (free_old && sds->wt)
+ if (free_old && sds->wt) {
smoke_turbulence_free(sds->wt);
+ }
if (!min_iii(res[0], res[1], res[2])) {
sds->wt = NULL;
return;
@@ -289,8 +291,9 @@ static void smoke_set_domain_from_mesh(SmokeDomainSettings *sds,
// prevent crash when initializing a plane as domain
if (!init_resolution || (size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) ||
- (size[2] < FLT_EPSILON))
+ (size[2] < FLT_EPSILON)) {
return;
+ }
/* define grid resolutions from longest domain side */
if (size[0] >= MAX2(size[1], size[2])) {
@@ -358,10 +361,10 @@ static int smokeModifier_init(SmokeModifierData *smd, Object *ob, int scene_fram
BKE_smoke_reallocate_highres_fluid(sds, sds->dx, sds->res, 0);
}
/* allocate shadow buffer */
- if (!sds->shadow)
+ if (!sds->shadow) {
sds->shadow = MEM_callocN(sizeof(float) * sds->res[0] * sds->res[1] * sds->res[2],
"SmokeDomainShadow");
-
+ }
return 1;
}
else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
@@ -387,21 +390,26 @@ static int smokeModifier_init(SmokeModifierData *smd, Object *ob, int scene_fram
static void smokeModifier_freeDomain(SmokeModifierData *smd)
{
if (smd->domain) {
- if (smd->domain->shadow)
+ if (smd->domain->shadow) {
MEM_freeN(smd->domain->shadow);
+ }
smd->domain->shadow = NULL;
- if (smd->domain->fluid)
+ if (smd->domain->fluid) {
smoke_free(smd->domain->fluid);
+ }
- if (smd->domain->fluid_mutex)
+ if (smd->domain->fluid_mutex) {
BLI_rw_mutex_free(smd->domain->fluid_mutex);
+ }
- if (smd->domain->wt)
+ if (smd->domain->wt) {
smoke_turbulence_free(smd->domain->wt);
+ }
- if (smd->domain->effector_weights)
+ if (smd->domain->effector_weights) {
MEM_freeN(smd->domain->effector_weights);
+ }
smd->domain->effector_weights = NULL;
if (!(smd->modifier.flag & eModifierFlag_SharedCaches)) {
@@ -421,10 +429,12 @@ static void smokeModifier_freeDomain(SmokeModifierData *smd)
static void smokeModifier_freeFlow(SmokeModifierData *smd)
{
if (smd->flow) {
- if (smd->flow->mesh)
+ if (smd->flow->mesh) {
BKE_id_free(NULL, smd->flow->mesh);
- if (smd->flow->verts_old)
+ }
+ if (smd->flow->verts_old) {
MEM_freeN(smd->flow->verts_old);
+ }
MEM_freeN(smd->flow);
smd->flow = NULL;
}
@@ -442,8 +452,9 @@ static void smokeModifier_freeCollision(SmokeModifierData *smd)
}
}
- if (smd->coll->mesh)
+ if (smd->coll->mesh) {
BKE_id_free(NULL, smd->coll->mesh);
+ }
smd->coll->mesh = NULL;
MEM_freeN(smd->coll);
@@ -463,19 +474,22 @@ static void smokeModifier_reset_ex(struct SmokeModifierData *smd, bool need_lock
{
if (smd) {
if (smd->domain) {
- if (smd->domain->shadow)
+ if (smd->domain->shadow) {
MEM_freeN(smd->domain->shadow);
+ }
smd->domain->shadow = NULL;
if (smd->domain->fluid) {
- if (need_lock)
+ if (need_lock) {
BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE);
+ }
smoke_free(smd->domain->fluid);
smd->domain->fluid = NULL;
- if (need_lock)
+ if (need_lock) {
BLI_rw_mutex_unlock(smd->domain->fluid_mutex);
+ }
}
smokeModifier_reset_turbulence(smd);
@@ -485,8 +499,9 @@ static void smokeModifier_reset_ex(struct SmokeModifierData *smd, bool need_lock
smd->domain->active_fields = 0;
}
else if (smd->flow) {
- if (smd->flow->verts_old)
+ if (smd->flow->verts_old) {
MEM_freeN(smd->flow->verts_old);
+ }
smd->flow->verts_old = NULL;
smd->flow->numverts = 0;
}
@@ -519,8 +534,9 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
{
if (smd) {
if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
- if (smd->domain)
+ if (smd->domain) {
smokeModifier_freeDomain(smd);
+ }
smd->domain = MEM_callocN(sizeof(SmokeDomainSettings), "SmokeDomain");
@@ -593,8 +609,9 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->clipping = 1e-3f;
}
else if (smd->type & MOD_SMOKE_TYPE_FLOW) {
- if (smd->flow)
+ if (smd->flow) {
smokeModifier_freeFlow(smd);
+ }
smd->flow = MEM_callocN(sizeof(SmokeFlowSettings), "SmokeFlow");
@@ -621,8 +638,9 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->flow->psys = NULL;
}
else if (smd->type & MOD_SMOKE_TYPE_COLL) {
- if (smd->coll)
+ if (smd->coll) {
smokeModifier_freeCollision(smd);
+ }
smd->coll = MEM_callocN(sizeof(SmokeCollSettings), "SmokeColl");
@@ -873,8 +891,9 @@ static void obstacles_from_mesh(Object *coll_ob,
int *num_obstacles,
float dt)
{
- if (!scs->mesh)
+ if (!scs->mesh) {
return;
+ }
{
Mesh *me = NULL;
MVert *mvert = NULL;
@@ -895,14 +914,16 @@ static void obstacles_from_mesh(Object *coll_ob,
// DG TODO
// if (scs->type > SM_COLL_STATIC)
- // if line above is used, the code is in trouble if the object moves but is declared as "does not move"
+ // if line above is used, the code is in trouble if the object moves
+ // but is declared as "does not move".
{
vert_vel = MEM_callocN(sizeof(float) * numverts * 3, "smoke_obs_velocity");
if (scs->numverts != numverts || !scs->verts_old) {
- if (scs->verts_old)
+ if (scs->verts_old) {
MEM_freeN(scs->verts_old);
+ }
scs->verts_old = MEM_callocN(sizeof(float) * numverts * 3, "smoke_obs_verts_old");
scs->numverts = numverts;
@@ -963,8 +984,9 @@ static void obstacles_from_mesh(Object *coll_ob,
free_bvhtree_from_mesh(&treeData);
BKE_id_free(NULL, me);
- if (vert_vel)
+ if (vert_vel) {
MEM_freeN(vert_vel);
+ }
}
}
@@ -1084,10 +1106,12 @@ static void em_boundInsert(EmissionMap *em, float point[3])
}
else {
for (; i < 3; i++) {
- if (point[i] < em->min[i])
+ if (point[i] < em->min[i]) {
em->min[i] = (int)floor(point[i]);
- if (point[i] > em->max[i])
+ }
+ if (point[i] > em->max[i]) {
em->max[i] = (int)ceil(point[i]);
+ }
}
}
}
@@ -1127,15 +1151,17 @@ static void em_allocateData(EmissionMap *em, bool use_velocity, int hires_mul)
for (i = 0; i < 3; i++) {
res[i] = em->max[i] - em->min[i];
- if (res[i] <= 0)
+ if (res[i] <= 0) {
return;
+ }
}
em->total_cells = res[0] * res[1] * res[2];
copy_v3_v3_int(em->res, res);
em->influence = MEM_callocN(sizeof(float) * em->total_cells, "smoke_flow_influence");
- if (use_velocity)
+ if (use_velocity) {
em->velocity = MEM_callocN(sizeof(float) * em->total_cells * 3, "smoke_flow_velocity");
+ }
/* allocate high resolution map if required */
if (hires_mul > 1) {
@@ -1155,12 +1181,15 @@ static void em_allocateData(EmissionMap *em, bool use_velocity, int hires_mul)
static void em_freeData(EmissionMap *em)
{
- if (em->influence)
+ if (em->influence) {
MEM_freeN(em->influence);
- if (em->influence_high)
+ }
+ if (em->influence_high) {
MEM_freeN(em->influence_high);
- if (em->velocity)
+ }
+ if (em->velocity) {
MEM_freeN(em->velocity);
+ }
}
static void em_combineMaps(
@@ -1187,8 +1216,8 @@ static void em_combineMaps(
em_allocateData(output, (em1.velocity || em2->velocity), hires_multiplier);
/* base resolution inputs */
- for (x = output->min[0]; x < output->max[0]; x++)
- for (y = output->min[1]; y < output->max[1]; y++)
+ for (x = output->min[0]; x < output->max[0]; x++) {
+ for (y = output->min[1]; y < output->max[1]; y++) {
for (z = output->min[2]; z < output->max[2]; z++) {
int index_out = smoke_get_index(x - output->min[0],
output->res[0],
@@ -1234,11 +1263,13 @@ static void em_combineMaps(
}
}
} // low res loop
+ }
+ }
/* initialize high resolution input if available */
if (output->influence_high) {
- for (x = output->hmin[0]; x < output->hmax[0]; x++)
- for (y = output->hmin[1]; y < output->hmax[1]; y++)
+ for (x = output->hmin[0]; x < output->hmax[0]; x++) {
+ for (y = output->hmin[1]; y < output->hmax[1]; y++) {
for (z = output->hmin[2]; z < output->hmax[2]; z++) {
int index_out = smoke_get_index(x - output->hmin[0],
output->hres[0],
@@ -1271,6 +1302,8 @@ static void em_combineMaps(
}
}
} // high res loop
+ }
+ }
}
/* free original data */
@@ -1394,12 +1427,15 @@ static void emit_from_particles(Object *flow_ob,
sim.psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
/* prepare curvemapping tables */
- if ((psys->part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && psys->part->clumpcurve)
+ if ((psys->part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && psys->part->clumpcurve) {
curvemapping_changed_all(psys->part->clumpcurve);
- if ((psys->part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && psys->part->roughcurve)
+ }
+ if ((psys->part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && psys->part->roughcurve) {
curvemapping_changed_all(psys->part->roughcurve);
- if ((psys->part->child_flag & PART_CHILD_USE_TWIST_CURVE) && psys->part->twistcurve)
+ }
+ if ((psys->part->child_flag & PART_CHILD_USE_TWIST_CURVE) && psys->part->twistcurve) {
curvemapping_changed_all(psys->part->twistcurve);
+ }
/* initialize particle cache */
if (psys->part->type == PART_HAIR) {
@@ -1430,19 +1466,22 @@ static void emit_from_particles(Object *flow_ob,
ParticleKey state;
float *pos;
if (p < totpart) {
- if (psys->particles[p].flag & (PARS_NO_DISP | PARS_UNEXIST))
+ if (psys->particles[p].flag & (PARS_NO_DISP | PARS_UNEXIST)) {
continue;
+ }
}
else {
/* handle child particle */
ChildParticle *cpa = &psys->child[p - totpart];
- if (psys->particles[cpa->parent].flag & (PARS_NO_DISP | PARS_UNEXIST))
+ if (psys->particles[cpa->parent].flag & (PARS_NO_DISP | PARS_UNEXIST)) {
continue;
+ }
}
state.time = DEG_get_ctime(depsgraph); /* use depsgraph time */
- if (psys_get_particle_state(&sim, p, &state, 0) == 0)
+ if (psys_get_particle_state(&sim, p, &state, 0) == 0) {
continue;
+ }
/* location */
pos = &particle_pos[valid_particles * 3];
@@ -1484,8 +1523,9 @@ static void emit_from_particles(Object *flow_ob,
break;
}
}
- if (badcell)
+ if (badcell) {
continue;
+ }
/* get cell index */
index = smoke_get_index(cell[0], em->res[0], cell[1], em->res[1], cell[2]);
/* Add influence to emission map */
@@ -1538,10 +1578,12 @@ static void emit_from_particles(Object *flow_ob,
}
/* free data */
- if (particle_pos)
+ if (particle_pos) {
MEM_freeN(particle_pos);
- if (particle_vel)
+ }
+ if (particle_vel) {
MEM_freeN(particle_vel);
+ }
}
}
@@ -1619,8 +1661,9 @@ static void sample_mesh(SmokeFlowSettings *sfs,
CLAMP(sample_str, 0.0f, 1.0f);
sample_str = pow(1.0f - sample_str, 0.5f);
}
- else
+ else {
sample_str = 0.0f;
+ }
/* calculate barycentric weights for nearest point */
v1 = mloop[mlooptri[f_index].tri[0]].v;
@@ -1638,7 +1681,8 @@ static void sample_mesh(SmokeFlowSettings *sfs,
interp_v3_v3v3v3(hit_normal, n1, n2, n3, weights);
normalize_v3(hit_normal);
/* apply normal directional and random velocity
- * - TODO: random disabled for now since it doesn't really work well as pressure calc smoothens it out... */
+ * - TODO: random disabled for now since it doesn't really work well
+ * as pressure calc smoothens it out. */
velocity_map[index * 3] += hit_normal[0] * sfs->vel_normal * 0.25f;
velocity_map[index * 3 + 1] += hit_normal[1] * sfs->vel_normal * 0.25f;
velocity_map[index * 3 + 2] += hit_normal[2] * sfs->vel_normal * 0.25f;
@@ -1777,7 +1821,10 @@ static void emit_from_mesh_task_cb(void *__restrict userdata,
const int index = smoke_get_index(
x - data->min[0], data->res[0], y - data->min[1], data->res[1], z - data->min[2]);
const float ray_start[3] = {
- lx + 0.5f * data->hr, ly + 0.5f * data->hr, lz + 0.5f * data->hr};
+ lx + 0.5f * data->hr,
+ ly + 0.5f * data->hr,
+ lz + 0.5f * data->hr,
+ };
sample_mesh(data->sfs,
data->mvert,
@@ -1847,8 +1894,9 @@ static void emit_from_mesh(
vert_vel = MEM_callocN(sizeof(float) * numOfVerts * 3, "smoke_flow_velocity");
if (sfs->numverts != numOfVerts || !sfs->verts_old) {
- if (sfs->verts_old)
+ if (sfs->verts_old) {
MEM_freeN(sfs->verts_old);
+ }
sfs->verts_old = MEM_callocN(sizeof(float) * numOfVerts * 3, "smoke_flow_verts_old");
sfs->numverts = numOfVerts;
}
@@ -1977,8 +2025,8 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
INIT_MINMAX(min_vel, max_vel);
/* Calculate bounds for current domain content */
- for (x = sds->res_min[0]; x < sds->res_max[0]; x++)
- for (y = sds->res_min[1]; y < sds->res_max[1]; y++)
+ for (x = sds->res_min[0]; x < sds->res_max[0]; x++) {
+ for (y = sds->res_min[1]; y < sds->res_max[1]; y++) {
for (z = sds->res_min[2]; z < sds->res_max[2]; z++) {
int xn = x - new_shift[0];
int yn = y - new_shift[1];
@@ -1988,8 +2036,9 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
/* skip if cell already belongs to new area */
if (xn >= min[0] && xn <= max[0] && yn >= min[1] && yn <= max[1] && zn >= min[2] &&
- zn <= max[2])
+ zn <= max[2]) {
continue;
+ }
index = smoke_get_index(x - sds->res_min[0],
sds->res[0],
@@ -2006,8 +2055,8 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
int yy = (y - sds->res_min[1]) * block_size;
int zz = (z - sds->res_min[2]) * block_size;
- for (i = 0; i < block_size; i++)
- for (j = 0; j < block_size; j++)
+ for (i = 0; i < block_size; i++) {
+ for (j = 0; j < block_size; j++) {
for (k = 0; k < block_size; k++) {
int big_index = smoke_get_index(xx + i, wt_res[0], yy + j, wt_res[1], zz + k);
float den = (bigfuel) ? MAX2(bigdensity[big_index], bigfuel[big_index]) :
@@ -2016,45 +2065,61 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
max_den = den;
}
}
+ }
+ }
}
/* content bounds (use shifted coordinates) */
if (max_den >= sds->adapt_threshold) {
- if (min[0] > xn)
+ if (min[0] > xn) {
min[0] = xn;
- if (min[1] > yn)
+ }
+ if (min[1] > yn) {
min[1] = yn;
- if (min[2] > zn)
+ }
+ if (min[2] > zn) {
min[2] = zn;
- if (max[0] < xn)
+ }
+ if (max[0] < xn) {
max[0] = xn;
- if (max[1] < yn)
+ }
+ if (max[1] < yn) {
max[1] = yn;
- if (max[2] < zn)
+ }
+ if (max[2] < zn) {
max[2] = zn;
+ }
}
/* velocity bounds */
- if (min_vel[0] > vx[index])
+ if (min_vel[0] > vx[index]) {
min_vel[0] = vx[index];
- if (min_vel[1] > vy[index])
+ }
+ if (min_vel[1] > vy[index]) {
min_vel[1] = vy[index];
- if (min_vel[2] > vz[index])
+ }
+ if (min_vel[2] > vz[index]) {
min_vel[2] = vz[index];
- if (max_vel[0] < vx[index])
+ }
+ if (max_vel[0] < vx[index]) {
max_vel[0] = vx[index];
- if (max_vel[1] < vy[index])
+ }
+ if (max_vel[1] < vy[index]) {
max_vel[1] = vy[index];
- if (max_vel[2] < vz[index])
+ }
+ if (max_vel[2] < vz[index]) {
max_vel[2] = vz[index];
+ }
}
+ }
+ }
/* also apply emission maps */
for (int i = 0; i < numflowobj; i++) {
EmissionMap *em = &emaps[i];
- for (x = em->min[0]; x < em->max[0]; x++)
- for (y = em->min[1]; y < em->max[1]; y++)
+ for (x = em->min[0]; x < em->max[0]; x++) {
+ for (y = em->min[1]; y < em->max[1]; y++) {
for (z = em->min[2]; z < em->max[2]; z++) {
int index = smoke_get_index(
x - em->min[0], em->res[0], y - em->min[1], em->res[1], z - em->min[2]);
@@ -2062,20 +2127,28 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
/* density bounds */
if (max_den >= sds->adapt_threshold) {
- if (min[0] > x)
+ if (min[0] > x) {
min[0] = x;
- if (min[1] > y)
+ }
+ if (min[1] > y) {
min[1] = y;
- if (min[2] > z)
+ }
+ if (min[2] > z) {
min[2] = z;
- if (max[0] < x)
+ }
+ if (max[0] < x) {
max[0] = x;
- if (max[1] < y)
+ }
+ if (max[1] < y) {
max[1] = y;
- if (max[2] < z)
+ }
+ if (max[2] < z) {
max[2] = z;
+ }
}
}
+ }
+ }
}
/* calculate new bounds based on these values */
@@ -2088,8 +2161,9 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
res[i] = max[i] - min[i];
total_cells *= res[i];
- if (new_shift[i])
+ if (new_shift[i]) {
shift_changed = 1;
+ }
/* if no content set minimum dimensions */
if (res[i] <= 0) {
@@ -2103,8 +2177,9 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
total_cells = 1;
break;
}
- if (min[i] != sds->res_min[i] || max[i] != sds->res_max[i])
+ if (min[i] != sds->res_min[i] || max[i] != sds->res_max[i]) {
res_changed = 1;
+ }
}
if (res_changed || shift_changed) {
@@ -2191,8 +2266,8 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
&n_wt_tcw);
}
- for (x = sds->res_min[0]; x < sds->res_max[0]; x++)
- for (y = sds->res_min[1]; y < sds->res_max[1]; y++)
+ for (x = sds->res_min[0]; x < sds->res_max[0]; x++) {
+ for (y = sds->res_min[1]; y < sds->res_max[1]; y++) {
for (z = sds->res_min[2]; z < sds->res_max[2]; z++) {
/* old grid index */
int xo = x - sds->res_min[0];
@@ -2206,8 +2281,9 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
int index_new = smoke_get_index(xn, res[0], yn, res[1], zn);
/* skip if outside new domain */
- if (xn < 0 || xn >= res[0] || yn < 0 || yn >= res[1] || zn < 0 || zn >= res[2])
+ if (xn < 0 || xn >= res[0] || yn < 0 || yn >= res[1] || zn < 0 || zn >= res[2]) {
continue;
+ }
/* copy data */
n_dens[index_new] = o_dens[index_old];
@@ -2247,8 +2323,8 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
n_wt_tcv[index_new] = o_wt_tcv[index_old];
n_wt_tcw[index_new] = o_wt_tcw[index_old];
- for (i = 0; i < block_size; i++)
- for (j = 0; j < block_size; j++)
+ for (i = 0; i < block_size; i++) {
+ for (j = 0; j < block_size; j++) {
for (k = 0; k < block_size; k++) {
int big_index_old = smoke_get_index(
xx_o + i, wt_res_old[0], yy_o + j, wt_res_old[1], zz_o + k);
@@ -2267,12 +2343,17 @@ static void adjustDomainResolution(SmokeDomainSettings *sds,
n_wt_b[big_index_new] = o_wt_b[big_index_old];
}
}
+ }
+ }
}
}
+ }
+ }
}
smoke_free(fluid_old);
- if (turb_old)
+ if (turb_old) {
smoke_turbulence_free(turb_old);
+ }
/* set new domain dimensions */
copy_v3_v3_int(sds->res_min, min);
@@ -2329,12 +2410,14 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs,
/* absolute */
if (absolute_flow) {
if (sfs->type != MOD_SMOKE_FLOW_TYPE_FIRE) {
- if (dens_flow > density[index])
+ if (dens_flow > density[index]) {
density[index] = dens_flow;
+ }
}
if (sfs->type != MOD_SMOKE_FLOW_TYPE_SMOKE && fuel && fuel_flow) {
- if (fuel_flow > fuel[index])
+ if (fuel_flow > fuel[index]) {
fuel[index] = fuel_flow;
+ }
}
}
/* additive */
@@ -2453,7 +2536,7 @@ static void update_flowsfluids(
EmissionMap em_temp = {NULL};
float sample_size = 1.0f / (float)(subframes + 1);
# if 0
- float prev_frame_pos = sample_size * (float)(subframe+1);
+ float prev_frame_pos = sample_size * (float)(subframe + 1);
# endif
float sdt = dt * sample_size;
int hires_multiplier = 1;
@@ -2593,7 +2676,7 @@ static void update_flowsfluids(
float *velocity_x = smoke_get_velocity_x(sds->fluid);
float *velocity_y = smoke_get_velocity_y(sds->fluid);
float *velocity_z = smoke_get_velocity_z(sds->fluid);
- //unsigned char *obstacle = smoke_get_obstacle(sds->fluid);
+ // unsigned char *obstacle = smoke_get_obstacle(sds->fluid);
// DG TODO UNUSED unsigned char *obstacleAnim = smoke_get_obstacle_anim(sds->fluid);
int bigres[3];
float *velocity_map = em->velocity;
@@ -2604,8 +2687,8 @@ static void update_flowsfluids(
size_t e_index, d_index, index_big;
// loop through every emission map cell
- for (gx = em->min[0]; gx < em->max[0]; gx++)
- for (gy = em->min[1]; gy < em->max[1]; gy++)
+ for (gx = em->min[0]; gx < em->max[0]; gx++) {
+ for (gy = em->min[1]; gy < em->max[1]; gy++) {
for (gz = em->min[2]; gz < em->max[2]; gz++) {
/* get emission map index */
ex = gx - em->min[0];
@@ -2620,8 +2703,9 @@ static void update_flowsfluids(
d_index = smoke_get_index(dx, sds->res[0], dy, sds->res[1], dz);
/* make sure emission cell is inside the new domain boundary */
if (dx < 0 || dy < 0 || dz < 0 || dx >= sds->res[0] || dy >= sds->res[1] ||
- dz >= sds->res[2])
+ dz >= sds->res[2]) {
continue;
+ }
if (sfs->type == MOD_SMOKE_FLOW_TYPE_OUTFLOW) { // outflow
apply_outflow_fields(
@@ -2652,7 +2736,8 @@ static void update_flowsfluids(
/* loop through high res blocks if high res enabled */
if (bigdensity) {
- // neighbor cell emission densities (for high resolution smoke smooth interpolation)
+ /* Neighbor cell emission densities
+ * (for high resolution smoke smooth interpolation). */
float c000, c001, c010, c011, c100, c101, c110, c111;
smoke_turbulence_get_res(sds->wt, bigres);
@@ -2687,8 +2772,8 @@ static void update_flowsfluids(
c111 = emission_map[smoke_get_index(
ex, em->res[0], ey, em->res[1], ez)]; // this cell
- for (ii = 0; ii < block_size; ii++)
- for (jj = 0; jj < block_size; jj++)
+ for (ii = 0; ii < block_size; ii++) {
+ for (jj = 0; jj < block_size; jj++) {
for (kk = 0; kk < block_size; kk++) {
float fx, fy, fz, interpolated_value;
@@ -2770,8 +2855,12 @@ static void update_flowsfluids(
bigcolor_b);
}
} // hires loop
- } // bigdensity
- } // low res loop
+ }
+ }
+ } // bigdensity
+ } // low res loop
+ }
+ }
// free emission maps
em_freeData(em);
@@ -2781,8 +2870,9 @@ static void update_flowsfluids(
}
BKE_collision_objects_free(flowobjs);
- if (emaps)
+ if (emaps) {
MEM_freeN(emaps);
+ }
}
typedef struct UpdateEffectorsData {
@@ -2947,12 +3037,9 @@ static void step(Depsgraph *depsgraph,
update_obstacles(depsgraph, ob, sds, dtSubdiv, substep, totalSubsteps);
if (sds->total_cells > 1) {
- update_effectors(
- depsgraph,
- scene,
- ob,
- sds,
- dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt
+ // DG TODO? problem --> uses forces instead of velocity,
+ // need to check how they need to be changed with variable dt.
+ update_effectors(depsgraph, scene, ob, sds, dtSubdiv);
smoke_step(sds->fluid, gravity, dtSubdiv);
}
}
@@ -3109,11 +3196,13 @@ static void smokeModifier_process(
const int scene_framenr = (int)DEG_get_ctime(depsgraph);
if ((smd->type & MOD_SMOKE_TYPE_FLOW)) {
- if (scene_framenr >= smd->time)
+ if (scene_framenr >= smd->time) {
smokeModifier_init(smd, ob, scene_framenr, me);
+ }
- if (smd->flow->mesh)
+ if (smd->flow->mesh) {
BKE_id_free(NULL, smd->flow->mesh);
+ }
smd->flow->mesh = BKE_mesh_copy_for_eval(me, false);
if (scene_framenr > smd->time) {
@@ -3125,12 +3214,14 @@ static void smokeModifier_process(
}
}
else if (smd->type & MOD_SMOKE_TYPE_COLL) {
- if (scene_framenr >= smd->time)
+ if (scene_framenr >= smd->time) {
smokeModifier_init(smd, ob, scene_framenr, me);
+ }
if (smd->coll) {
- if (smd->coll->mesh)
+ if (smd->coll->mesh) {
BKE_id_free(NULL, smd->coll->mesh);
+ }
smd->coll->mesh = BKE_mesh_copy_for_eval(me, false);
}
@@ -3161,15 +3252,17 @@ static void smokeModifier_process(
}
if (!smd->domain->fluid && (framenr != startframe) &&
- (smd->domain->flags & MOD_SMOKE_FILE_LOAD) == 0 && (cache->flag & PTCACHE_BAKED) == 0)
+ (smd->domain->flags & MOD_SMOKE_FILE_LOAD) == 0 && (cache->flag & PTCACHE_BAKED) == 0) {
return;
+ }
smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD;
CLAMP(framenr, startframe, endframe);
/* If already viewing a pre/after frame, no need to reload */
- if ((smd->time == framenr) && (framenr != scene_framenr))
+ if ((smd->time == framenr) && (framenr != scene_framenr)) {
return;
+ }
if (smokeModifier_init(smd, ob, scene_framenr, me) == 0) {
printf("bad smokeModifier_init\n");
@@ -3187,8 +3280,9 @@ static void smokeModifier_process(
return;
}
- if (!can_simulate)
+ if (!can_simulate) {
return;
+ }
# ifdef DEBUG_TIME
double start = PIL_check_seconds_timer();
@@ -3228,8 +3322,9 @@ static void smokeModifier_process(
}
BKE_ptcache_validate(cache, framenr);
- if (framenr != startframe)
+ if (framenr != startframe) {
BKE_ptcache_write(&pid, framenr);
+ }
# ifdef DEBUG_TIME
double end = PIL_check_seconds_timer();
@@ -3242,13 +3337,15 @@ struct Mesh *smokeModifier_do(
SmokeModifierData *smd, Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *me)
{
/* lock so preview render does not read smoke data while it gets modified */
- if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE);
+ }
smokeModifier_process(smd, depsgraph, scene, ob, me);
- if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
BLI_rw_mutex_unlock(smd->domain->fluid_mutex);
+ }
/* return generated geometry for adaptive domain */
Mesh *result;
@@ -3319,8 +3416,9 @@ static void bresenham_linie_3D(int x1,
err_1 = dy2 - l;
err_2 = dz2 - l;
for (i = 0; i < l; i++) {
- if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
+ if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) {
break;
+ }
if (err_1 > 0) {
pixel[1] += y_inc;
err_1 -= dx2;
@@ -3338,8 +3436,9 @@ static void bresenham_linie_3D(int x1,
err_1 = dx2 - m;
err_2 = dz2 - m;
for (i = 0; i < m; i++) {
- if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
+ if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) {
break;
+ }
if (err_1 > 0) {
pixel[0] += x_inc;
err_1 -= dy2;
@@ -3357,8 +3456,9 @@ static void bresenham_linie_3D(int x1,
err_1 = dy2 - n;
err_2 = dx2 - n;
for (i = 0; i < n; i++) {
- if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
+ if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) {
break;
+ }
if (err_1 > 0) {
pixel[1] += y_inc;
err_1 -= dz2;
@@ -3383,8 +3483,9 @@ static void smoke_calc_transparency(SmokeDomainSettings *sds, ViewLayer *view_la
float *density = smoke_get_density(sds->fluid);
float correct = -7.0f * sds->dx;
- if (!get_light(view_layer, light))
+ if (!get_light(view_layer, light)) {
return;
+ }
/* convert light pos to sim cell space */
mul_m4_v3(sds->imat, light);
@@ -3392,8 +3493,9 @@ static void smoke_calc_transparency(SmokeDomainSettings *sds, ViewLayer *view_la
light[1] = (light[1] - sds->p0[1]) / sds->cell_size[1] - 0.5f - (float)sds->res_min[1];
light[2] = (light[2] - sds->p0[2]) / sds->cell_size[2] - 0.5f - (float)sds->res_min[2];
- for (a = 0; a < size; a++)
+ for (a = 0; a < size; a++) {
sds->shadow[a] = -1.0f;
+ }
/* calculate domain bounds in sim cell space */
// 0,2,4 = 0.0f
@@ -3405,15 +3507,16 @@ static void smoke_calc_transparency(SmokeDomainSettings *sds, ViewLayer *view_la
size_t index = z * slabsize;
int x, y;
- for (y = 0; y < sds->res[1]; y++)
+ for (y = 0; y < sds->res[1]; y++) {
for (x = 0; x < sds->res[0]; x++, index++) {
float voxelCenter[3];
float pos[3];
int cell[3];
float tRay = 1.0;
- if (sds->shadow[index] >= 0.0f)
+ if (sds->shadow[index] >= 0.0f) {
continue;
+ }
voxelCenter[0] = (float)x;
voxelCenter[1] = (float)y;
voxelCenter[2] = (float)z;
@@ -3452,6 +3555,7 @@ static void smoke_calc_transparency(SmokeDomainSettings *sds, ViewLayer *view_la
// convention -> from a RGBA float array, use G value for tRay
sds->shadow[index] = tRay;
}
+ }
}
}
@@ -3475,10 +3579,12 @@ float BKE_smoke_get_velocity_at(struct Object *ob, float position[3], float velo
smoke_pos_to_cell(sds, pos);
/* check if point is outside domain max bounds */
- if (pos[0] < sds->res_min[0] || pos[1] < sds->res_min[1] || pos[2] < sds->res_min[2])
+ if (pos[0] < sds->res_min[0] || pos[1] < sds->res_min[1] || pos[2] < sds->res_min[2]) {
return -1.0f;
- if (pos[0] > sds->res_max[0] || pos[1] > sds->res_max[1] || pos[2] > sds->res_max[2])
+ }
+ if (pos[0] > sds->res_max[0] || pos[1] > sds->res_max[1] || pos[2] > sds->res_max[2]) {
return -1.0f;
+ }
/* map pos between 0.0 - 1.0 */
pos[0] = (pos[0] - sds->res_min[0]) / ((float)sds->res[0]);
@@ -3487,10 +3593,12 @@ float BKE_smoke_get_velocity_at(struct Object *ob, float position[3], float velo
/* check if point is outside active area */
if (smd->domain->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) {
- if (pos[0] < 0.0f || pos[1] < 0.0f || pos[2] < 0.0f)
+ if (pos[0] < 0.0f || pos[1] < 0.0f || pos[2] < 0.0f) {
return 0.0f;
- if (pos[0] > 1.0f || pos[1] > 1.0f || pos[2] > 1.0f)
+ }
+ if (pos[0] > 1.0f || pos[1] > 1.0f || pos[2] > 1.0f) {
return 0.0f;
+ }
}
/* get interpolated velocity */
@@ -3522,12 +3630,15 @@ int BKE_smoke_get_data_flags(SmokeDomainSettings *sds)
int flags = 0;
if (sds->fluid) {
- if (smoke_has_heat(sds->fluid))
+ if (smoke_has_heat(sds->fluid)) {
flags |= SM_ACTIVE_HEAT;
- if (smoke_has_fuel(sds->fluid))
+ }
+ if (smoke_has_fuel(sds->fluid)) {
flags |= SM_ACTIVE_FIRE;
- if (smoke_has_colors(sds->fluid))
+ }
+ if (smoke_has_colors(sds->fluid)) {
flags |= SM_ACTIVE_COLORS;
+ }
}
return flags;
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index ba7e26e817a..2a3145bee6c 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -190,8 +190,8 @@ static float sb_time_scale(Object *ob)
/* hrms .. this could be IPO as well :)
* estimated range [0.001 sluggish slug - 100.0 very fast (i hope ODE solver can handle that)]
* 1 approx = a unit 1 pendulum at g = 9.8 [earth conditions] has period 65 frames
- * theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM)
- */
+ * theory would give a 50 frames period .. so there must be something inaccurate ..
+ * looking for that (BM). */
}
return (1.0f);
/*
@@ -217,11 +217,13 @@ static float _final_goal(Object *ob, BodyPoint *bp) /*jow_go_for2_5 */
float f = -1999.99f;
if (ob) {
SoftBody *sb = ob->soft; /* is supposed to be there */
- if (!(ob->softflag & OB_SB_GOAL))
+ if (!(ob->softflag & OB_SB_GOAL)) {
return (0.0f);
+ }
if (sb && bp) {
- if (bp->goal < 0.0f)
+ if (bp->goal < 0.0f) {
return (0.0f);
+ }
f = sb->mingoal + bp->goal * fabsf(sb->maxgoal - sb->mingoal);
f = pow(f, 4.0f);
return (f);
@@ -286,10 +288,12 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
cmd = (CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
/* first some paranoia checks */
- if (!cmd)
+ if (!cmd) {
return NULL;
- if (!cmd->mvert_num || !cmd->tri_num)
+ }
+ if (!cmd->mvert_num || !cmd->tri_num) {
return NULL;
+ }
pccd_M = MEM_mallocN(sizeof(ccd_Mesh), "ccd_Mesh");
pccd_M->mvert_num = cmd->mvert_num;
@@ -370,10 +374,12 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
cmd = (CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
/* first some paranoia checks */
- if (!cmd)
+ if (!cmd) {
return;
- if (!cmd->mvert_num || !cmd->tri_num)
+ }
+ if (!cmd->mvert_num || !cmd->tri_num) {
return;
+ }
if ((pccd_M->mvert_num != cmd->mvert_num) || (pccd_M->tri_num != cmd->tri_num)) {
return;
@@ -386,8 +392,9 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
/* rotate current to previous */
- if (pccd_M->mprevvert)
+ if (pccd_M->mprevvert) {
MEM_freeN((void *)pccd_M->mprevvert);
+ }
pccd_M->mprevvert = pccd_M->mvert;
/* alloc and copy verts*/
pccd_M->mvert = MEM_dupallocN(cmd->xnew);
@@ -482,8 +489,9 @@ static void ccd_mesh_free(ccd_Mesh *ccdm)
if (ccdm && (ccdm->savety == CCD_SAVETY)) { /*make sure we're not nuking objects we don't know*/
MEM_freeN((void *)ccdm->mvert);
MEM_freeN((void *)ccdm->tri);
- if (ccdm->mprevvert)
+ if (ccdm->mprevvert) {
MEM_freeN((void *)ccdm->mprevvert);
+ }
MEM_freeN(ccdm->mima);
MEM_freeN(ccdm);
ccdm = NULL;
@@ -510,8 +518,9 @@ static void ccd_build_deflector_hash(Depsgraph *depsgraph,
Object *vertexowner,
GHash *hash)
{
- if (!hash)
+ if (!hash) {
return;
+ }
unsigned int numobjects;
Object **objects = BKE_collision_objects_create(
@@ -546,8 +555,9 @@ static void ccd_update_deflector_hash(Depsgraph *depsgraph,
Object *vertexowner,
GHash *hash)
{
- if ((!hash) || (!vertexowner))
+ if ((!hash) || (!vertexowner)) {
return;
+ }
unsigned int numobjects;
Object **objects = BKE_collision_objects_create(
@@ -589,7 +599,7 @@ static void add_mesh_quad_diag_springs(Object *ob)
if (ob->soft) {
int nofquads;
- //float s_shear = ob->soft->shearstiff*ob->soft->shearstiff;
+ // float s_shear = ob->soft->shearstiff*ob->soft->shearstiff;
nofquads = count_mesh_quads(me);
if (nofquads) {
@@ -636,16 +646,17 @@ static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *count
} /* we are 2nd order here so 1rst should have been build :) */
/* first run counting second run adding */
*counter = 0;
- if (addsprings)
+ if (addsprings) {
bs3 = ob->soft->bspring + ob->soft->totspring;
+ }
for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
/*scan for neighborhood*/
bpo = NULL;
v0 = (sb->totpoint - a);
for (b = bp->nofsprings; b > 0; b--) {
bs = sb->bspring + bp->springs[b - 1];
- /*nasty thing here that springs have two ends
- so here we have to make sure we examine the other */
+ /* Nasty thing here that springs have two ends
+ * so here we have to make sure we examine the other */
if (v0 == bs->v1) {
bpo = sb->bpoint + bs->v2;
notthis = bs->v2;
@@ -699,8 +710,9 @@ static void add_2nd_order_springs(Object *ob, float stiffness)
bs_new = MEM_callocN((ob->soft->totspring + counter) * sizeof(BodySpring), "bodyspring");
memcpy(bs_new, ob->soft->bspring, (ob->soft->totspring) * sizeof(BodySpring));
- if (ob->soft->bspring)
+ if (ob->soft->bspring) {
MEM_freeN(ob->soft->bspring);
+ }
ob->soft->bspring = bs_new;
add_2nd_order_roller(ob, stiffness, &counter, 1); /* adding */
@@ -738,8 +750,9 @@ static void build_bps_springlist(Object *ob)
BodySpring *bs;
int a, b;
- if (sb == NULL)
+ if (sb == NULL) {
return; /* paranoya check */
+ }
for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
/* throw away old list */
@@ -767,8 +780,9 @@ static void calculate_collision_balls(Object *ob)
int a, b, akku_count;
float min, max, akku;
- if (sb == NULL)
+ if (sb == NULL) {
return; /* paranoya check */
+ }
for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
bp->colball = 0;
@@ -804,8 +818,9 @@ static void calculate_collision_balls(Object *ob)
bp->colball = (min + max) / 2.0f * sb->colball;
}
}
- else
+ else {
bp->colball = 0;
+ }
} /*for bp*/
}
@@ -815,10 +830,12 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring
SoftBody *sb;
int i;
short softflag;
- if (ob->soft == NULL)
+ if (ob->soft == NULL) {
ob->soft = sbNew(scene);
- else
+ }
+ else {
free_softbody_intern(ob->soft);
+ }
sb = ob->soft;
softflag = ob->softflag;
@@ -827,8 +844,9 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring
sb->totspring = totspring;
sb->bpoint = MEM_mallocN(totpoint * sizeof(BodyPoint), "bodypoint");
- if (totspring)
+ if (totspring) {
sb->bspring = MEM_mallocN(totspring * sizeof(BodySpring), "bodyspring");
+ }
/* initialize BodyPoint array */
for (i = 0; i < totpoint; i++) {
@@ -865,11 +883,13 @@ static void free_softbody_baked(SoftBody *sb)
for (k = 0; k < sb->totkey; k++) {
key = *(sb->keys + k);
- if (key)
+ if (key) {
MEM_freeN(key);
+ }
}
- if (sb->keys)
+ if (sb->keys) {
MEM_freeN(sb->keys);
+ }
sb->keys = NULL;
sb->totkey = 0;
@@ -912,8 +932,9 @@ static void free_softbody_intern(SoftBody *sb)
MEM_freeN(sb->bpoint);
}
- if (sb->bspring)
+ if (sb->bspring) {
MEM_freeN(sb->bspring);
+ }
sb->totpoint = sb->totspring = 0;
sb->bpoint = NULL;
@@ -982,8 +1003,9 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]),
int a;
#endif
- if ((sb == NULL) || (sb->scratch == NULL))
+ if ((sb == NULL) || (sb->scratch == NULL)) {
return 0;
+ }
copy_v3_v3(aabbmin, sb->scratch->aabbmin);
copy_v3_v3(aabbmax, sb->scratch->aabbmax);
@@ -1437,7 +1459,7 @@ static void _scan_for_ext_spring_forces(
sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos, &damp, feedback, ob, timenow)) {
add_v3_v3(bs->ext_force, feedback);
bs->flag |= BSF_INTERSECT;
- //bs->cf=damp;
+ // bs->cf=damp;
bs->cf = sb->choke * 0.01f;
}
}
@@ -1506,8 +1528,10 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph,
ListBase threads;
SB_thread_context *sb_threads;
int i, totthread, left, dec;
- int lowsprings =
- 100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
+
+ /* wild guess .. may increase with better thread management 'above'
+ * or even be UI option sb->spawn_cf_threads_nopts */
+ int lowsprings = 100;
ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, ob->soft->effector_weights);
@@ -1532,8 +1556,9 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph,
if (left > 0) {
sb_threads[i].ifirst = left;
}
- else
+ else {
sb_threads[i].ifirst = 0;
+ }
sb_threads[i].effectors = effectors;
sb_threads[i].do_deflector = false; // not used here
sb_threads[i].fieldfactor = 0.0f; // not used here
@@ -1544,13 +1569,15 @@ static void sb_sfesf_threads_run(struct Depsgraph *depsgraph,
if (totthread > 1) {
BLI_threadpool_init(&threads, exec_scan_for_ext_spring_forces, totthread);
- for (i = 0; i < totthread; i++)
+ for (i = 0; i < totthread; i++) {
BLI_threadpool_insert(&threads, &sb_threads[i]);
+ }
BLI_threadpool_end(&threads);
}
- else
+ else {
exec_scan_for_ext_spring_forces(&sb_threads[0]);
+ }
/* clean up */
MEM_freeN(sb_threads);
@@ -1716,9 +1743,10 @@ static int sb_detect_vertex_collisionCached(float opco[3],
if ((facedist > innerfacethickness) && (facedist < outerfacethickness)) {
if (isect_point_tri_prism_v3(opco, nv1, nv2, nv3)) {
force_mag_norm = (float)exp(-ee * facedist);
- if (facedist > outerfacethickness * ff)
+ if (facedist > outerfacethickness * ff) {
force_mag_norm = (float)force_mag_norm * fa * (facedist - outerfacethickness) *
(facedist - outerfacethickness);
+ }
*damp = ob->pd->pdef_sbdamp;
if (facedist > 0.0f) {
*damp *= (1.0f - facedist / outerfacethickness);
@@ -1727,8 +1755,9 @@ static int sb_detect_vertex_collisionCached(float opco[3],
}
else {
madd_v3_v3fl(innerforceaccu, d_nvect, force_mag_norm);
- if (deflected < 2)
+ if (deflected < 2) {
deflected = 2;
+ }
}
if ((mprevvert) && (*damp > 0.0f)) {
choose_winner(ve, opco, nv1, nv2, nv3, vv1, vv2, vv3);
@@ -1750,9 +1779,10 @@ static int sb_detect_vertex_collisionCached(float opco[3],
if (deflected == 1) { // no face but 'outer' edge cylinder sees vert
force_mag_norm = (float)exp(-ee * mindistedge);
- if (mindistedge > outerfacethickness * ff)
+ if (mindistedge > outerfacethickness * ff) {
force_mag_norm = (float)force_mag_norm * fa * (mindistedge - outerfacethickness) *
(mindistedge - outerfacethickness);
+ }
madd_v3_v3fl(force, coledge, force_mag_norm);
*damp = ob->pd->pdef_sbdamp;
if (mindistedge > 0.0f) {
@@ -1767,11 +1797,13 @@ static int sb_detect_vertex_collisionCached(float opco[3],
}
BLI_ghashIterator_free(ihash);
- if (cavel)
+ if (cavel) {
mul_v3_fl(avel, 1.0f / (float)cavel);
+ }
copy_v3_v3(vel, avel);
- if (ci)
+ if (ci) {
*intrusion /= ci;
+ }
if (deflected) {
normalize_v3_v3(facenormal, force);
}
@@ -1793,7 +1825,10 @@ static int sb_deflect_face(Object *ob,
copy_v3_v3(s_actpos, actpos);
deflected = sb_detect_vertex_collisionCached(
s_actpos, facenormal, cf, force, ob, time, vel, intrusion);
- //deflected= sb_detect_vertex_collisionCachedEx(s_actpos, facenormal, cf, force, ob, time, vel, intrusion);
+#if 0
+ deflected = sb_detect_vertex_collisionCachedEx(
+ s_actpos, facenormal, cf, force, ob, time, vel, intrusion);
+#endif
return (deflected);
}
@@ -1804,35 +1839,36 @@ static void dfdx_spring(int ia, int ic, int op, float dir[3], float L, float len
float m, delta_ij;
int i, j;
if (L < len) {
- for (i=0;i<3;i++) {
- for (j=0;j<3;j++) {
- delta_ij = (i==j ? (1.0f): (0.0f));
- m=factor*(dir[i]*dir[j] + (1-L/len)*(delta_ij - dir[i]*dir[j]));
- EIG_linear_solver_matrix_add(ia+i, op+ic+j, m);
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
+ delta_ij = (i == j ? (1.0f) : (0.0f));
+ m = factor * (dir[i] * dir[j] + (1 - L / len) * (delta_ij - dir[i] * dir[j]));
+ EIG_linear_solver_matrix_add(ia + i, op + ic + j, m);
}
}
}
else {
- for (i=0;i<3;i++) {
- for (j=0;j<3;j++) {
- m=factor*dir[i]*dir[j];
- EIG_linear_solver_matrix_add(ia+i, op+ic+j, m);
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
+ m = factor * dir[i] * dir[j];
+ EIG_linear_solver_matrix_add(ia + i, op + ic + j, m);
}
}
}
}
-
static void dfdx_goal(int ia, int ic, int op, float factor)
{
int i;
- for (i=0;i<3;i++) EIG_linear_solver_matrix_add(ia+i, op+ic+i, factor);
+ for (i = 0; i < 3; i++)
+ EIG_linear_solver_matrix_add(ia + i, op + ic + i, factor);
}
static void dfdv_goal(int ia, int ic, float factor)
{
int i;
- for (i=0;i<3;i++) EIG_linear_solver_matrix_add(ia+i, ic+i, factor);
+ for (i = 0; i < 3; i++)
+ EIG_linear_solver_matrix_add(ia + i, ic + i, factor);
}
#endif /* if 0 */
@@ -1852,16 +1888,16 @@ static void sb_spring_force(
bp1 = &sb->bpoint[bs->v1];
bp2 = &sb->bpoint[bs->v2];
#if 0 /* UNUSED */
- ia =3*bs->v1;
- ic =3*bs->v2;
+ ia = 3 * bs->v1;
+ ic = 3 * bs->v2;
#endif
}
else if (bpi == bs->v2) {
bp1 = &sb->bpoint[bs->v2];
bp2 = &sb->bpoint[bs->v1];
#if 0 /* UNUSED */
- ia =3*bs->v2;
- ic =3*bs->v1;
+ ia = 3 * bs->v2;
+ ic = 3 * bs->v1;
#endif
}
else {
@@ -1873,15 +1909,19 @@ static void sb_spring_force(
/* do bp1 <--> bp2 elastic */
sub_v3_v3v3(dir, bp1->pos, bp2->pos);
distance = normalize_v3(dir);
- if (bs->len < distance)
+ if (bs->len < distance) {
iks = 1.0f / (1.0f - sb->inspring) - 1.0f; /* inner spring constants function */
- else
+ }
+ else {
iks = 1.0f / (1.0f - sb->inpush) - 1.0f; /* inner spring constants function */
+ }
- if (bs->len > 0.0f) /* check for degenerated springs */
+ if (bs->len > 0.0f) { /* check for degenerated springs */
forcefactor = iks / bs->len;
- else
+ }
+ else {
forcefactor = iks;
+ }
kw = (bp1->springweight + bp2->springweight) / 2.0f;
kw = kw * kw;
kw = kw * kw;
@@ -1971,14 +2011,16 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
float compare;
float bstune = sb->ballstiff;
- /* running in a slice we must not assume anything done with obp neither alter the data of obp */
+ /* Running in a slice we must not assume anything done with obp
+ * neither alter the data of obp. */
for (c = sb->totpoint, obp = sb->bpoint; c > 0; c--, obp++) {
compare = (obp->colball + bp->colball);
sub_v3_v3v3(def, bp->pos, obp->pos);
/* rather check the AABBoxes before ever calculating the real distance */
/* mathematically it is completely nuts, but performance is pretty much (3) times faster */
- if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare))
+ if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) {
continue;
+ }
distance = normalize_v3(def);
if (distance < compare) {
/* exclude body points attached with a spring */
@@ -2114,8 +2156,9 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene,
bs = sb->bspring + bp->springs[b - 1];
if (do_springcollision || do_aero) {
add_v3_v3(bp->force, bs->ext_force);
- if (bs->flag & BSF_INTERSECT)
+ if (bs->flag & BSF_INTERSECT) {
bp->choke = bs->cf;
+ }
}
// sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float forcetime)
sb_spring_force(ob, ilast - bb, bs, iks, forcetime);
@@ -2159,8 +2202,10 @@ static void sb_cf_threads_run(Scene *scene,
ListBase threads;
SB_thread_context *sb_threads;
int i, totthread, left, dec;
- int lowpoints =
- 100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
+
+ /* wild guess .. may increase with better thread management 'above'
+ * or even be UI option sb->spawn_cf_threads_nopts. */
+ int lowpoints = 100;
/* figure the number of threads while preventing pretty pointless threading overhead */
totthread = BKE_scene_num_threads(scene);
@@ -2185,8 +2230,9 @@ static void sb_cf_threads_run(Scene *scene,
if (left > 0) {
sb_threads[i].ifirst = left;
}
- else
+ else {
sb_threads[i].ifirst = 0;
+ }
sb_threads[i].effectors = effectors;
sb_threads[i].do_deflector = do_deflector;
sb_threads[i].fieldfactor = fieldfactor;
@@ -2198,13 +2244,15 @@ static void sb_cf_threads_run(Scene *scene,
if (totthread > 1) {
BLI_threadpool_init(&threads, exec_softbody_calc_forces, totthread);
- for (i = 0; i < totthread; i++)
+ for (i = 0; i < totthread; i++) {
BLI_threadpool_insert(&threads, &sb_threads[i]);
+ }
BLI_threadpool_end(&threads);
}
- else
+ else {
exec_softbody_calc_forces(&sb_threads[0]);
+ }
/* clean up */
MEM_freeN(sb_threads);
}
@@ -2226,7 +2274,9 @@ static void softbody_calc_forces(
/* check conditions for various options */
do_deflector = query_external_colliders(depsgraph, sb->collision_group);
- /* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */
+#if 0
+ do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
+#endif
do_springcollision = do_deflector && (ob->softflag & OB_SB_EDGES) &&
(ob->softflag & OB_SB_EDGECOLL);
do_aero = ((sb->aeroedge) && (ob->softflag & OB_SB_EDGES));
@@ -2234,8 +2284,9 @@ static void softbody_calc_forces(
/* iks = 1.0f/(1.0f-sb->inspring)-1.0f; */ /* inner spring constants function */ /* UNUSED */
/* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
- if (do_springcollision || do_aero)
+ if (do_springcollision || do_aero) {
sb_sfesf_threads_run(depsgraph, scene, ob, timenow, sb->totspring, NULL);
+ }
/* after spring scan because it uses Effoctors too */
ListBase *effectors = BKE_effectors_create(depsgraph, ob, NULL, sb->effector_weights);
@@ -2257,8 +2308,9 @@ static void softbody_calc_forces(
windfactor);
/* finally add forces caused by face collision */
- if (ob->softflag & OB_SB_FACECOLL)
+ if (ob->softflag & OB_SB_FACECOLL) {
scan_for_ext_face_forces(ob, timenow);
+ }
/* finish matrix and solve */
BKE_effectors_free(effectors);
@@ -2284,27 +2336,42 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
/* old one with homogeneous masses */
/* claim a minimum mass for vertex */
#if 0
- if (sb->nodemass > 0.009999f) timeovermass = forcetime / sb->nodemass;
- else timeovermass = forcetime / 0.009999f;
+ if (sb->nodemass > 0.009999f)
+ timeovermass = forcetime / sb->nodemass;
+ else
+ timeovermass = forcetime / 0.009999f;
#endif
for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
- /* now we have individual masses */
+ /* Now we have individual masses. */
/* claim a minimum mass for vertex */
- if (_final_mass(ob, bp) > 0.009999f)
+ if (_final_mass(ob, bp) > 0.009999f) {
timeovermass = forcetime / _final_mass(ob, bp);
- else
+ }
+ else {
timeovermass = forcetime / 0.009999f;
+ }
if (_final_goal(ob, bp) < SOFTGOALSNAP) {
/* this makes t~ = t */
- if (mid_flags & MID_PRESERVE)
+ if (mid_flags & MID_PRESERVE) {
copy_v3_v3(dx, bp->vec);
+ }
- /* so here is (v)' = a(cceleration) = sum(F_springs)/m + gravitation + some friction forces + more forces*/
- /* the ( ... )' operator denotes derivate respective time */
- /* the euler step for velocity then becomes */
- /* v(t + dt) = v(t) + a(t) * dt */
+ /**
+ * So here is:
+ * <pre>
+ * (v)' = a(cceleration) =
+ * sum(F_springs)/m + gravitation + some friction forces + more forces.
+ * </pre>
+ *
+ * The ( ... )' operator denotes derivate respective time.
+ *
+ * The euler step for velocity then becomes:
+ * <pre>
+ * v(t + dt) = v(t) + a(t) * dt
+ * </pre>
+ */
mul_v3_fl(bp->force, timeovermass); /* individual mass of node here */
/* some nasty if's to have heun in here too */
copy_v3_v3(dv, bp->force);
@@ -2329,8 +2396,9 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
}
/* this makes t~ = t+dt */
- if (!(mid_flags & MID_PRESERVE))
+ if (!(mid_flags & MID_PRESERVE)) {
copy_v3_v3(dx, bp->vec);
+ }
/* so here is (x)'= v(elocity) */
/* the euler step for location then becomes */
@@ -2339,11 +2407,11 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
/* the freezer coming sooner or later */
#if 0
- if ((dot_v3v3(dx, dx)<freezeloc )&&(dot_v3v3(bp->force, bp->force)<freezeforce )) {
- bp->frozen /=2;
+ if ((dot_v3v3(dx, dx) < freezeloc) && (dot_v3v3(bp->force, bp->force) < freezeforce)) {
+ bp->frozen /= 2;
}
else {
- bp->frozen = min_ff(bp->frozen*1.05f, 1.0f);
+ bp->frozen = min_ff(bp->frozen * 1.05f, 1.0f);
}
mul_v3_fl(dx, bp->frozen);
#endif
@@ -2378,23 +2446,27 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
} /*snap*/
/* so while we are looping BPs anyway do statistics on the fly */
minmax_v3v3_v3(aabbmin, aabbmax, bp->pos);
- if (bp->loc_flag & SBF_DOFUZZY)
+ if (bp->loc_flag & SBF_DOFUZZY) {
fuzzy = 1;
+ }
} /*for*/
- if (sb->totpoint)
+ if (sb->totpoint) {
mul_v3_fl(cm, 1.0f / sb->totpoint);
+ }
if (sb->scratch) {
copy_v3_v3(sb->scratch->aabbmin, aabbmin);
copy_v3_v3(sb->scratch->aabbmax, aabbmax);
}
if (err) { /* so step size will be controlled by biggest difference in slope */
- if (sb->solverflags & SBSO_OLDERR)
+ if (sb->solverflags & SBSO_OLDERR) {
*err = max_ff(maxerrpos, maxerrvel);
- else
+ }
+ else {
*err = maxerrpos;
- //printf("EP %f EV %f\n", maxerrpos, maxerrvel);
+ }
+ // printf("EP %f EV %f\n", maxerrpos, maxerrvel);
if (fuzzy) {
*err /= sb->fuzzyness;
}
@@ -2417,73 +2489,72 @@ static void softbody_restore_prev_step(Object *ob)
#if 0
static void softbody_store_step(Object *ob)
{
- SoftBody *sb= ob->soft; /* is supposed to be there*/
+ SoftBody *sb = ob->soft; /* is supposed to be there*/
BodyPoint *bp;
int a;
- for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
copy_v3_v3(bp->prevvec, bp->vec);
copy_v3_v3(bp->prevpos, bp->pos);
}
}
-
/* used by predictors and correctors */
static void softbody_store_state(Object *ob, float *ppos, float *pvel)
{
- SoftBody *sb= ob->soft; /* is supposed to be there*/
+ SoftBody *sb = ob->soft; /* is supposed to be there*/
BodyPoint *bp;
int a;
- float *pp=ppos, *pv=pvel;
+ float *pp = ppos, *pv = pvel;
- for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
copy_v3_v3(pv, bp->vec);
- pv+=3;
+ pv += 3;
copy_v3_v3(pp, bp->pos);
- pp+=3;
+ pp += 3;
}
}
/* used by predictors and correctors */
static void softbody_retrieve_state(Object *ob, float *ppos, float *pvel)
{
- SoftBody *sb= ob->soft; /* is supposed to be there*/
+ SoftBody *sb = ob->soft; /* is supposed to be there*/
BodyPoint *bp;
int a;
- float *pp=ppos, *pv=pvel;
+ float *pp = ppos, *pv = pvel;
- for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
copy_v3_v3(bp->vec, pv);
- pv+=3;
+ pv += 3;
copy_v3_v3(bp->pos, pp);
- pp+=3;
+ pp += 3;
}
}
/* used by predictors and correctors */
static void softbody_swap_state(Object *ob, float *ppos, float *pvel)
{
- SoftBody *sb= ob->soft; /* is supposed to be there*/
+ SoftBody *sb = ob->soft; /* is supposed to be there*/
BodyPoint *bp;
int a;
- float *pp=ppos, *pv=pvel;
+ float *pp = ppos, *pv = pvel;
float temp[3];
- for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
+ for (a = sb->totpoint, bp = sb->bpoint; a > 0; a--, bp++) {
copy_v3_v3(temp, bp->vec);
copy_v3_v3(bp->vec, pv);
copy_v3_v3(pv, temp);
- pv+=3;
+ pv += 3;
copy_v3_v3(temp, bp->pos);
copy_v3_v3(bp->pos, pp);
copy_v3_v3(pp, temp);
- pp+=3;
+ pp += 3;
}
}
#endif
@@ -2605,10 +2676,12 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
int a, totedge;
int defgroup_index, defgroup_index_mass, defgroup_index_spring;
- if (ob->softflag & OB_SB_EDGES)
+ if (ob->softflag & OB_SB_EDGES) {
totedge = me->totedge;
- else
+ }
+ else {
totedge = 0;
+ }
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
renew_softbody(scene, ob, me->totvert, totedge);
@@ -2911,15 +2984,21 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
/* weights from bpoints, same code used as for mesh vertices */
/* if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack*/
/* new! take the weights from curve vertex anyhow */
- if (ob->softflag & OB_SB_GOAL)
+ if (ob->softflag & OB_SB_GOAL) {
setgoal = 1;
+ }
for (nu = cu->nurb.first; nu; nu = nu->next) {
if (nu->bezt) {
- /* bezier case ; this is nicly said naive; who ever wrote this part, it was not me (JOW) :) */
- /* a: never ever make tangent handles (sub) and or (ob)ject to collision */
- /* b: rather calculate them using some C2 (C2= continuous in second derivate -> no jump in bending ) condition */
- /* not too hard to do, but needs some more code to care for; some one may want look at it JOW 2010/06/12*/
+ /* Bezier case; this is nicly said naive; who ever wrote this part,
+ * it was not me (JOW) :).
+ *
+ * a: never ever make tangent handles (sub) and or (ob)ject to collision.
+ * b: rather calculate them using some C2
+ * (C2= continuous in second derivate -> no jump in bending ) condition.
+ *
+ * Not too hard to do, but needs some more code to care for;
+ * some one may want look at it JOW 2010/06/12. */
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++, bp += 3, curindex += 3) {
if (setgoal) {
bp->goal *= bezt->weight;
@@ -2993,8 +3072,9 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts,
for (a = 0; a < numVerts; a++, bp++) {
copy_v3_v3(vertexCos[a], bp->pos);
- if (local == 0)
+ if (local == 0) {
mul_m4_v3(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */
+ }
}
}
}
@@ -3002,8 +3082,9 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts,
/* +++ ************ maintaining scratch *************** */
static void sb_new_scratch(SoftBody *sb)
{
- if (!sb)
+ if (!sb) {
return;
+ }
sb->scratch = MEM_callocN(sizeof(SBScratch), "SBScratch");
sb->scratch->colliderhash = BLI_ghash_ptr_new("sb_new_scratch gh");
sb->scratch->bodyface = NULL;
@@ -3061,8 +3142,9 @@ SoftBody *sbNew(Scene *scene)
sb->shared = MEM_callocN(sizeof(*sb->shared), "SoftBody_Shared");
sb->shared->pointcache = BKE_ptcache_add(&sb->shared->ptcaches);
- if (!sb->effector_weights)
+ if (!sb->effector_weights) {
sb->effector_weights = BKE_effector_add_weights(NULL);
+ }
sb->last_frame = MINFRAME - 1;
@@ -3085,8 +3167,9 @@ void sbFree(Object *ob)
sb->shared->pointcache = NULL;
MEM_freeN(sb->shared);
}
- if (sb->effector_weights)
+ if (sb->effector_weights) {
MEM_freeN(sb->effector_weights);
+ }
MEM_freeN(sb);
ob->soft = NULL;
@@ -3100,7 +3183,7 @@ void sbFreeSimulation(SoftBody *sb)
/* makes totally fresh start situation */
void sbObjectToSoftbody(Object *ob)
{
- //ob->softflag |= OB_SB_REDO;
+ // ob->softflag |= OB_SB_REDO;
free_softbody_intern(ob->soft);
}
@@ -3132,8 +3215,9 @@ static void softbody_update_positions(Object *ob,
BodyPoint *bp;
int a;
- if (!sb || !sb->bpoint)
+ if (!sb || !sb->bpoint) {
return;
+ }
for (a = 0, bp = sb->bpoint; a < numVerts; a++, bp++) {
/* store where goals are now */
@@ -3154,10 +3238,9 @@ static void softbody_update_positions(Object *ob,
* that is:
* a precise position vector denoting the motion of the center of mass
* give a rotation/scale matrix using averaging method, that's why estimate and not calculate
- * see: this is kind of reverse engineering: having to states of a point cloud and recover what happened
- * our advantage here we know the identity of the vertex
- * there are others methods giving other results.
- * lloc, lrot, lscale are allowed to be NULL, just in case you don't need it.
+ * see: this is kind of reverse engineering: having to states of a point cloud and recover what
+ * happened our advantage here we know the identity of the vertex there are others methods giving
+ * other results. lloc, lrot, lscale are allowed to be NULL, just in case you don't need it.
* should be pretty useful for pythoneers :)
* not! velocity .. 2nd order stuff
* vcloud_estimate_transform_v3 see
@@ -3173,11 +3256,13 @@ void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float ls
float com[3], rcom[3];
int a;
- if (!ob || !ob->soft)
+ if (!ob || !ob->soft) {
return; /* why did we get here ? */
+ }
sb = ob->soft;
- if (!sb || !sb->bpoint)
+ if (!sb || !sb->bpoint) {
return;
+ }
opos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_OPOS");
rpos = MEM_callocN((sb->totpoint) * 3 * sizeof(float), "SB_RPOS");
/* might filter vertex selection with a vertex group */
@@ -3187,14 +3272,17 @@ void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float ls
}
vcloud_estimate_transform_v3(sb->totpoint, opos, NULL, rpos, NULL, com, rcom, lrot, lscale);
- //sub_v3_v3(com, rcom);
- if (lloc)
+ // sub_v3_v3(com, rcom);
+ if (lloc) {
copy_v3_v3(lloc, com);
+ }
copy_v3_v3(sb->lcom, com);
- if (lscale)
+ if (lscale) {
copy_m3_m3(sb->lscale, lscale);
- if (lrot)
+ }
+ if (lrot) {
copy_m3_m3(sb->lrot, lrot);
+ }
MEM_freeN(opos);
MEM_freeN(rpos);
@@ -3248,8 +3336,9 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
}
switch (ob->type) {
case OB_MESH:
- if (ob->softflag & OB_SB_FACECOLL)
+ if (ob->softflag & OB_SB_FACECOLL) {
mesh_faces_to_scratch(ob);
+ }
break;
case OB_LATTICE:
break;
@@ -3273,8 +3362,9 @@ static void softbody_step(
* So we refuse to do so. Since we do not know anything about 'outside' changes
* especially colliders we refuse to go more than 10 frames.
*/
- if (dtime < 0 || dtime > 10.5f)
+ if (dtime < 0 || dtime > 10.5f) {
return;
+ }
ccd_update_deflector_hash(depsgraph, sb->collision_group, ob, sb->scratch->colliderhash);
@@ -3287,22 +3377,27 @@ static void softbody_step(
/* special case of 2nd order Runge-Kutta type AKA Heun */
int mid_flags = 0;
float err = 0;
- float forcetimemax = 1.0f; /* set defaults guess we shall do one frame */
- float forcetimemin = 0.01f; /* set defaults guess 1/100 is tight enough */
- float timedone = 0.0; /* how far did we get without violating error condition */
- /* loops = counter for emergency brake
- * we don't want to lock up the system if physics fail */
+ /* Set defaults guess we shall do one frame */
+ float forcetimemax = 1.0f;
+ /* Set defaults guess 1/100 is tight enough */
+ float forcetimemin = 0.01f;
+ /* How far did we get without violating error condition. */
+ float timedone = 0.0;
+ /* Loops = counter for emergency brake we don't want to lock up the system if physics fail. */
int loops = 0;
SoftHeunTol = sb->rklimit; /* humm .. this should be calculated from sb parameters and sizes */
/* adjust loop limits */
- if (sb->minloops > 0)
+ if (sb->minloops > 0) {
forcetimemax = dtime / sb->minloops;
- if (sb->maxloops > 0)
+ }
+ if (sb->maxloops > 0) {
forcetimemin = dtime / sb->maxloops;
+ }
- if (sb->solver_ID > 0)
+ if (sb->solver_ID > 0) {
mid_flags |= MID_PRESERVE;
+ }
forcetime = forcetimemax; /* hope for integrating in one step */
while ((ABS(timedone) < ABS(dtime)) && (loops < 2000)) {
@@ -3326,7 +3421,7 @@ static void softbody_step(
if (forcetime > forcetimemin) {
forcetime = max_ff(forcetime / 2.0f, forcetimemin);
softbody_restore_prev_step(ob);
- //printf("down, ");
+ // printf("down, ");
}
else {
timedone += forcetime;
@@ -3336,7 +3431,8 @@ static void softbody_step(
float newtime = forcetime * 1.1f; /* hope for 1.1 times better conditions in next step */
if (sb->scratch->flag & SBF_DOFUZZY) {
- //if (err > SoftHeunTol/(2.0f*sb->fuzzyness)) { /* stay with this stepsize unless err really small */
+ ///* stay with this stepsize unless err really small */
+ // if (err > SoftHeunTol/(2.0f*sb->fuzzyness)) {
newtime = forcetime;
//}
}
@@ -3347,21 +3443,25 @@ static void softbody_step(
}
timedone += forcetime;
newtime = min_ff(forcetimemax, max_ff(newtime, forcetimemin));
- //if (newtime > forcetime) printf("up, ");
- if (forcetime > 0.0f)
+ // if (newtime > forcetime) printf("up, ");
+ if (forcetime > 0.0f) {
forcetime = min_ff(dtime - timedone, newtime);
- else
+ }
+ else {
forcetime = max_ff(dtime - timedone, newtime);
+ }
}
loops++;
if (sb->solverflags & SBSO_MONITOR) {
sct = PIL_check_seconds_timer();
- if (sct - sst > 0.5)
+ if (sct - sst > 0.5) {
printf("%3.0f%% \r", 100.0f * timedone / dtime);
+ }
}
/* ask for user break */
- if (SB_localInterruptCallBack && SB_localInterruptCallBack())
+ if (SB_localInterruptCallBack && SB_localInterruptCallBack()) {
break;
+ }
}
/* move snapped to final position */
interpolate_exciter(ob, 2, 2);
@@ -3369,20 +3469,21 @@ static void softbody_step(
// if (G.debug & G_DEBUG) {
if (sb->solverflags & SBSO_MONITOR) {
- if (loops > HEUNWARNLIMIT) /* monitor high loop counts */
+ if (loops > HEUNWARNLIMIT) { /* monitor high loop counts */
printf("\r needed %d steps/frame", loops);
+ }
}
}
else if (sb->solver_ID == 2) {
/* do semi "fake" implicit euler */
- //removed
+ // removed
} /*SOLVER SELECT*/
else if (sb->solver_ID == 4) {
/* do semi "fake" implicit euler */
} /*SOLVER SELECT*/
else if (sb->solver_ID == 3) {
/* do "stupid" semi "fake" implicit euler */
- //removed
+ // removed
} /*SOLVER SELECT*/
else {
@@ -3394,8 +3495,9 @@ static void softbody_step(
if (sb->solverflags & SBSO_MONITOR) {
sct = PIL_check_seconds_timer();
- if ((sct - sst > 0.5) || (G.debug & G_DEBUG))
+ if ((sct - sst > 0.5) || (G.debug & G_DEBUG)) {
printf(" solver time %f sec %s\n", sct - sst, ob->id.name);
+ }
}
}
@@ -3503,19 +3605,20 @@ void sbObjectStep(struct Depsgraph *depsgraph,
BKE_ptcache_validate(cache, framenr);
if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED &&
- can_write_cache)
+ can_write_cache) {
BKE_ptcache_write(&pid, framenr);
+ }
sbStoreLastFrame(depsgraph, ob, framenr);
return;
}
else if (cache_result == PTCACHE_READ_OLD) {
- ; /* do nothing */
+ /* pass */
}
- else if (/*ob->id.lib || */ (
- cache->flag &
- PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */
+ else if (/*ob->id.lib || */
+ /* "library linking & pointcaches" has to be solved properly at some point */
+ (cache->flag & PTCACHE_BAKED)) {
/* if baked and nothing in cache, do nothing */
if (can_write_cache) {
BKE_ptcache_invalidate(cache);
@@ -3523,12 +3626,15 @@ void sbObjectStep(struct Depsgraph *depsgraph,
return;
}
- if (!can_simulate)
+ if (!can_simulate) {
return;
+ }
/* if on second frame, write cache for first frame */
- if (cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0))
+ if (cache->simframe == startframe &&
+ (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
BKE_ptcache_write(&pid, startframe);
+ }
softbody_update_positions(ob, sb, vertexCos, numVerts);
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 383542fa335..c97baf8f7dd 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -61,7 +61,7 @@ static int sound_cfra;
static char **audio_device_names = NULL;
#endif
-bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath)
+bSound *BKE_sound_new_file(Main *bmain, const char *filepath)
{
bSound *sound;
const char *path;
@@ -82,7 +82,7 @@ bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath)
return sound;
}
-bSound *BKE_sound_new_file_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists)
+bSound *BKE_sound_new_file_exists_ex(Main *bmain, const char *filepath, bool *r_exists)
{
bSound *sound;
char str[FILE_MAX], strtest[FILE_MAX];
@@ -97,18 +97,20 @@ bSound *BKE_sound_new_file_exists_ex(struct Main *bmain, const char *filepath, b
if (BLI_path_cmp(strtest, str) == 0) {
id_us_plus(&sound->id); /* officially should not, it doesn't link here! */
- if (r_exists)
+ if (r_exists) {
*r_exists = true;
+ }
return sound;
}
}
- if (r_exists)
+ if (r_exists) {
*r_exists = false;
+ }
return BKE_sound_new_file(bmain, filepath);
}
-bSound *BKE_sound_new_file_exists(struct Main *bmain, const char *filepath)
+bSound *BKE_sound_new_file_exists(Main *bmain, const char *filepath)
{
return BKE_sound_new_file_exists_ex(bmain, filepath, NULL);
}
@@ -146,8 +148,10 @@ void BKE_sound_free(bSound *sound)
}
/**
- * Only copy internal data of Sound ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Sound ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -190,21 +194,25 @@ static const char *force_device = NULL;
static void sound_sync_callback(void *data, int mode, float time)
{
// Ugly: Blender doesn't like it when the animation is played back during rendering
- if (G.is_rendering)
+ if (G.is_rendering) {
return;
+ }
- struct Main *bmain = (struct Main *)data;
- struct Scene *scene;
+ Main *bmain = (Main *)data;
+ Scene *scene;
scene = bmain->scenes.first;
while (scene) {
if (scene->audio.flag & AUDIO_SYNC) {
- if (mode)
+ if (mode) {
BKE_sound_play_scene(scene);
- else
+ }
+ else {
BKE_sound_stop_scene(scene);
- if (scene->playback_handle)
+ }
+ if (scene->playback_handle) {
AUD_Handle_setPosition(scene->playback_handle, time);
+ }
}
scene = scene->id.next;
}
@@ -229,7 +237,7 @@ void *BKE_sound_get_device(void)
return sound_device;
}
-void BKE_sound_init(struct Main *bmain)
+void BKE_sound_init(Main *bmain)
{
/* Make sure no instance of the sound system is running, otherwise we get leaks. */
BKE_sound_exit();
@@ -256,32 +264,39 @@ void BKE_sound_init(struct Main *bmain)
}
}
}
- else
+ else {
device_name = force_device;
+ }
- if (buffersize < 128)
+ if (buffersize < 128) {
buffersize = 1024;
+ }
- if (specs.rate < AUD_RATE_8000)
+ if (specs.rate < AUD_RATE_8000) {
specs.rate = AUD_RATE_48000;
+ }
- if (specs.format <= AUD_FORMAT_INVALID)
+ if (specs.format <= AUD_FORMAT_INVALID) {
specs.format = AUD_FORMAT_S16;
+ }
- if (specs.channels <= AUD_CHANNELS_INVALID)
+ if (specs.channels <= AUD_CHANNELS_INVALID) {
specs.channels = AUD_CHANNELS_STEREO;
+ }
- if (!(sound_device = AUD_init(device_name, specs, buffersize, "Blender")))
+ if (!(sound_device = AUD_init(device_name, specs, buffersize, "Blender"))) {
sound_device = AUD_init("Null", specs, buffersize, "Blender");
+ }
BKE_sound_init_main(bmain);
}
-void BKE_sound_init_main(struct Main *bmain)
+void BKE_sound_init_main(Main *bmain)
{
# ifdef WITH_JACK
- if (sound_device)
+ if (sound_device) {
AUD_setSynchronizerCallback(sound_sync_callback, bmain);
+ }
# else
(void)bmain; /* unused */
# endif
@@ -311,7 +326,7 @@ void BKE_sound_exit_once(void)
/* XXX unused currently */
# if 0
-bSound *BKE_sound_new_buffer(struct Main *bmain, bSound *source)
+bSound *BKE_sound_new_buffer(Main *bmain, bSound *source)
{
bSound *sound = NULL;
@@ -329,7 +344,7 @@ bSound *BKE_sound_new_buffer(struct Main *bmain, bSound *source)
return sound;
}
-bSound *BKE_sound_new_limiter(struct Main *bmain, bSound *source, float start, float end)
+bSound *BKE_sound_new_limiter(Main *bmain, bSound *source, float start, float end)
{
bSound *sound = NULL;
@@ -353,14 +368,17 @@ bSound *BKE_sound_new_limiter(struct Main *bmain, bSound *source, float start, f
void BKE_sound_cache(bSound *sound)
{
sound->flags |= SOUND_FLAGS_CACHING;
- if (sound->cache)
+ if (sound->cache) {
AUD_Sound_free(sound->cache);
+ }
sound->cache = AUD_Sound_cache(sound->handle);
- if (sound->cache)
+ if (sound->cache) {
sound->playback_handle = sound->cache;
- else
+ }
+ else {
sound->playback_handle = sound->handle;
+ }
}
void BKE_sound_delete_cache(bSound *sound)
@@ -373,7 +391,7 @@ void BKE_sound_delete_cache(bSound *sound)
}
}
-void BKE_sound_load(struct Main *bmain, bSound *sound)
+void BKE_sound_load(Main *bmain, bSound *sound)
{
if (sound) {
if (sound->cache) {
@@ -391,8 +409,7 @@ void BKE_sound_load(struct Main *bmain, bSound *sound)
/* XXX unused currently */
# if 0
- switch (sound->type)
- {
+ switch (sound->type) {
case SOUND_TYPE_FILE:
# endif
{
@@ -406,23 +423,27 @@ void BKE_sound_load(struct Main *bmain, bSound *sound)
BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id));
/* but we need a packed file then */
- if (pf)
+ if (pf) {
sound->handle = AUD_Sound_bufferFile((unsigned char *)pf->data, pf->size);
- /* or else load it from disk */
- else
+ }
+ else {
+ /* or else load it from disk */
sound->handle = AUD_Sound_file(fullpath);
+ }
}
/* XXX unused currently */
# if 0
break;
}
case SOUND_TYPE_BUFFER:
- if (sound->child_sound && sound->child_sound->handle)
+ if (sound->child_sound && sound->child_sound->handle) {
sound->handle = AUD_bufferSound(sound->child_sound->handle);
+ }
break;
case SOUND_TYPE_LIMITER:
- if (sound->child_sound && sound->child_sound->handle)
+ if (sound->child_sound && sound->child_sound->handle) {
sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end);
+ }
break;
}
# endif
@@ -436,25 +457,28 @@ void BKE_sound_load(struct Main *bmain, bSound *sound)
sound->cache = AUD_Sound_cache(sound->handle);
}
- if (sound->cache)
+ if (sound->cache) {
sound->playback_handle = sound->cache;
- else
+ }
+ else {
sound->playback_handle = sound->handle;
+ }
BKE_sound_update_sequencer(bmain, sound);
}
}
-AUD_Device *BKE_sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
+AUD_Device *BKE_sound_mixdown(Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
{
return AUD_openMixdownDevice(specs, scene->sound_scene, volume, start / FPS);
}
-void BKE_sound_create_scene(struct Scene *scene)
+void BKE_sound_create_scene(Scene *scene)
{
/* should be done in version patch, but this gets called before */
- if (scene->r.frs_sec_base == 0)
+ if (scene->r.frs_sec_base == 0) {
scene->r.frs_sec_base = 1;
+ }
scene->sound_scene = AUD_Sequence_create(FPS, scene->audio.flag & AUDIO_MUTE);
AUD_Sequence_setSpeedOfSound(scene->sound_scene, scene->audio.speed_of_sound);
@@ -465,19 +489,23 @@ void BKE_sound_create_scene(struct Scene *scene)
scene->speaker_handles = NULL;
}
-void BKE_sound_destroy_scene(struct Scene *scene)
+void BKE_sound_destroy_scene(Scene *scene)
{
- if (scene->playback_handle)
+ if (scene->playback_handle) {
AUD_Handle_stop(scene->playback_handle);
- if (scene->sound_scrub_handle)
+ }
+ if (scene->sound_scrub_handle) {
AUD_Handle_stop(scene->sound_scrub_handle);
- if (scene->sound_scene)
+ }
+ if (scene->sound_scene) {
AUD_Sequence_free(scene->sound_scene);
- if (scene->speaker_handles)
+ }
+ if (scene->speaker_handles) {
AUD_destroySet(scene->speaker_handles);
+ }
}
-void BKE_sound_reset_scene_specs(struct Scene *scene)
+void BKE_sound_reset_scene_specs(Scene *scene)
{
AUD_Specs specs;
@@ -487,21 +515,23 @@ void BKE_sound_reset_scene_specs(struct Scene *scene)
AUD_Sequence_setSpecs(scene->sound_scene, specs);
}
-void BKE_sound_mute_scene(struct Scene *scene, int muted)
+void BKE_sound_mute_scene(Scene *scene, int muted)
{
- if (scene->sound_scene)
+ if (scene->sound_scene) {
AUD_Sequence_setMuted(scene->sound_scene, muted);
+ }
}
-void BKE_sound_update_fps(struct Scene *scene)
+void BKE_sound_update_fps(Scene *scene)
{
- if (scene->sound_scene)
+ if (scene->sound_scene) {
AUD_Sequence_setFPS(scene->sound_scene, FPS);
+ }
BKE_sequencer_refresh_sound_length(scene);
}
-void BKE_sound_update_scene_listener(struct Scene *scene)
+void BKE_sound_update_scene_listener(Scene *scene)
{
AUD_Sequence_setSpeedOfSound(scene->sound_scene, scene->audio.speed_of_sound);
AUD_Sequence_setDopplerFactor(scene->sound_scene, scene->audio.doppler_factor);
@@ -509,7 +539,7 @@ void BKE_sound_update_scene_listener(struct Scene *scene)
}
void *BKE_sound_scene_add_scene_sound(
- struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
+ Scene *scene, Sequence *sequence, int startframe, int endframe, int frameskip)
{
if (sequence->scene && scene != sequence->scene) {
const double fps = FPS;
@@ -522,7 +552,7 @@ void *BKE_sound_scene_add_scene_sound(
return NULL;
}
-void *BKE_sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
+void *BKE_sound_scene_add_scene_sound_defaults(Scene *scene, Sequence *sequence)
{
return BKE_sound_scene_add_scene_sound(scene,
sequence,
@@ -532,7 +562,7 @@ void *BKE_sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Seque
}
void *BKE_sound_add_scene_sound(
- struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip)
+ Scene *scene, Sequence *sequence, int startframe, int endframe, int frameskip)
{
/* Happens when sequence's sound datablock was removed. */
if (sequence->sound == NULL) {
@@ -551,7 +581,7 @@ void *BKE_sound_add_scene_sound(
return handle;
}
-void *BKE_sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
+void *BKE_sound_add_scene_sound_defaults(Scene *scene, Sequence *sequence)
{
return BKE_sound_add_scene_sound(scene,
sequence,
@@ -560,7 +590,7 @@ void *BKE_sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence *s
sequence->startofs + sequence->anim_startofs);
}
-void BKE_sound_remove_scene_sound(struct Scene *scene, void *handle)
+void BKE_sound_remove_scene_sound(Scene *scene, void *handle)
{
AUD_Sequence_remove(scene->sound_scene, handle);
}
@@ -571,13 +601,13 @@ void BKE_sound_mute_scene_sound(void *handle, char mute)
}
void BKE_sound_move_scene_sound(
- struct Scene *scene, void *handle, int startframe, int endframe, int frameskip)
+ Scene *scene, void *handle, int startframe, int endframe, int frameskip)
{
const double fps = FPS;
AUD_SequenceEntry_move(handle, startframe / fps, endframe / fps, frameskip / fps);
}
-void BKE_sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence)
+void BKE_sound_move_scene_sound_defaults(Scene *scene, Sequence *sequence)
{
if (sequence->scene_sound) {
BKE_sound_move_scene_sound(scene,
@@ -598,7 +628,7 @@ void BKE_sound_set_cfra(int cfra)
sound_cfra = cfra;
}
-void BKE_sound_set_scene_volume(struct Scene *scene, float volume)
+void BKE_sound_set_scene_volume(Scene *scene, float volume)
{
AUD_Sequence_setAnimationData(scene->sound_scene,
AUD_AP_VOLUME,
@@ -623,27 +653,29 @@ void BKE_sound_set_scene_sound_pan(void *handle, float pan, char animated)
AUD_SequenceEntry_setAnimationData(handle, AUD_AP_PANNING, sound_cfra, &pan, animated);
}
-void BKE_sound_update_sequencer(struct Main *main, bSound *sound)
+void BKE_sound_update_sequencer(Main *main, bSound *sound)
{
- struct Scene *scene;
+ Scene *scene;
for (scene = main->scenes.first; scene; scene = scene->id.next) {
BKE_sequencer_update_sound(scene, sound);
}
}
-static void sound_start_play_scene(struct Scene *scene)
+static void sound_start_play_scene(Scene *scene)
{
- if (scene->playback_handle)
+ if (scene->playback_handle) {
AUD_Handle_stop(scene->playback_handle);
+ }
BKE_sound_reset_scene_specs(scene);
- if ((scene->playback_handle = AUD_Device_play(sound_device, scene->sound_scene, 1)))
+ if ((scene->playback_handle = AUD_Device_play(sound_device, scene->sound_scene, 1))) {
AUD_Handle_setLoopCount(scene->playback_handle, -1);
+ }
}
-void BKE_sound_play_scene(struct Scene *scene)
+void BKE_sound_play_scene(Scene *scene)
{
AUD_Status status;
const float cur_time = (float)((double)CFRA / FPS);
@@ -667,23 +699,25 @@ void BKE_sound_play_scene(struct Scene *scene)
AUD_Handle_resume(scene->playback_handle);
}
- if (scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC) {
AUD_playSynchronizer();
+ }
AUD_Device_unlock(sound_device);
}
-void BKE_sound_stop_scene(struct Scene *scene)
+void BKE_sound_stop_scene(Scene *scene)
{
if (scene->playback_handle) {
AUD_Handle_pause(scene->playback_handle);
- if (scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC) {
AUD_stopSynchronizer();
+ }
}
}
-void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
+void BKE_sound_seek_scene(Main *bmain, Scene *scene)
{
AUD_Status status;
bScreen *screen;
@@ -747,31 +781,37 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene)
AUD_Device_unlock(sound_device);
}
-float BKE_sound_sync_scene(struct Scene *scene)
+float BKE_sound_sync_scene(Scene *scene)
{
// Ugly: Blender doesn't like it when the animation is played back during rendering
- if (G.is_rendering)
+ if (G.is_rendering) {
return NAN_FLT;
+ }
if (scene->playback_handle) {
- if (scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC) {
return AUD_getSynchronizerPosition(scene->playback_handle);
- else
+ }
+ else {
return AUD_Handle_getPosition(scene->playback_handle);
+ }
}
return NAN_FLT;
}
-int BKE_sound_scene_playing(struct Scene *scene)
+int BKE_sound_scene_playing(Scene *scene)
{
// Ugly: Blender doesn't like it when the animation is played back during rendering
- if (G.is_rendering)
+ if (G.is_rendering) {
return -1;
+ }
- if (scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC) {
return AUD_isSynchronizerPlaying();
- else
+ }
+ else {
return -1;
+ }
}
void BKE_sound_free_waveform(bSound *sound)
@@ -976,7 +1016,7 @@ void BKE_sound_force_device(const char *UNUSED(device))
void BKE_sound_init_once(void)
{
}
-void BKE_sound_init(struct Main *UNUSED(bmain))
+void BKE_sound_init(Main *UNUSED(bmain))
{
}
void BKE_sound_exit(void)
@@ -985,110 +1025,107 @@ void BKE_sound_exit(void)
void BKE_sound_exit_once(void)
{
}
-void BKE_sound_cache(struct bSound *UNUSED(sound))
+void BKE_sound_cache(bSound *UNUSED(sound))
{
}
-void BKE_sound_delete_cache(struct bSound *UNUSED(sound))
+void BKE_sound_delete_cache(bSound *UNUSED(sound))
{
}
-void BKE_sound_load(struct Main *UNUSED(bmain), struct bSound *UNUSED(sound))
+void BKE_sound_load(Main *UNUSED(bmain), bSound *UNUSED(sound))
{
}
-void BKE_sound_create_scene(struct Scene *UNUSED(scene))
+void BKE_sound_create_scene(Scene *UNUSED(scene))
{
}
-void BKE_sound_destroy_scene(struct Scene *UNUSED(scene))
+void BKE_sound_destroy_scene(Scene *UNUSED(scene))
{
}
-void BKE_sound_reset_scene_specs(struct Scene *UNUSED(scene))
+void BKE_sound_reset_scene_specs(Scene *UNUSED(scene))
{
}
-void BKE_sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted))
+void BKE_sound_mute_scene(Scene *UNUSED(scene), int UNUSED(muted))
{
}
-void *BKE_sound_scene_add_scene_sound(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence),
+void *BKE_sound_scene_add_scene_sound(Scene *UNUSED(scene),
+ Sequence *UNUSED(sequence),
int UNUSED(startframe),
int UNUSED(endframe),
int UNUSED(frameskip))
{
return NULL;
}
-void *BKE_sound_scene_add_scene_sound_defaults(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence))
+void *BKE_sound_scene_add_scene_sound_defaults(Scene *UNUSED(scene), Sequence *UNUSED(sequence))
{
return NULL;
}
-void *BKE_sound_add_scene_sound(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence),
+void *BKE_sound_add_scene_sound(Scene *UNUSED(scene),
+ Sequence *UNUSED(sequence),
int UNUSED(startframe),
int UNUSED(endframe),
int UNUSED(frameskip))
{
return NULL;
}
-void *BKE_sound_add_scene_sound_defaults(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence))
+void *BKE_sound_add_scene_sound_defaults(Scene *UNUSED(scene), Sequence *UNUSED(sequence))
{
return NULL;
}
-void BKE_sound_remove_scene_sound(struct Scene *UNUSED(scene), void *UNUSED(handle))
+void BKE_sound_remove_scene_sound(Scene *UNUSED(scene), void *UNUSED(handle))
{
}
void BKE_sound_mute_scene_sound(void *UNUSED(handle), char UNUSED(mute))
{
}
-void BKE_sound_move_scene_sound(struct Scene *UNUSED(scene),
+void BKE_sound_move_scene_sound(Scene *UNUSED(scene),
void *UNUSED(handle),
int UNUSED(startframe),
int UNUSED(endframe),
int UNUSED(frameskip))
{
}
-void BKE_sound_move_scene_sound_defaults(struct Scene *UNUSED(scene),
- struct Sequence *UNUSED(sequence))
+void BKE_sound_move_scene_sound_defaults(Scene *UNUSED(scene), Sequence *UNUSED(sequence))
{
}
-void BKE_sound_play_scene(struct Scene *UNUSED(scene))
+void BKE_sound_play_scene(Scene *UNUSED(scene))
{
}
-void BKE_sound_stop_scene(struct Scene *UNUSED(scene))
+void BKE_sound_stop_scene(Scene *UNUSED(scene))
{
}
-void BKE_sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene))
+void BKE_sound_seek_scene(Main *UNUSED(bmain), Scene *UNUSED(scene))
{
}
-float BKE_sound_sync_scene(struct Scene *UNUSED(scene))
+float BKE_sound_sync_scene(Scene *UNUSED(scene))
{
return NAN_FLT;
}
-int BKE_sound_scene_playing(struct Scene *UNUSED(scene))
+int BKE_sound_scene_playing(Scene *UNUSED(scene))
{
return -1;
}
-void BKE_sound_read_waveform(struct bSound *sound, short *stop)
+void BKE_sound_read_waveform(bSound *sound, short *stop)
{
UNUSED_VARS(sound, stop);
}
-void BKE_sound_init_main(struct Main *UNUSED(bmain))
+void BKE_sound_init_main(Main *UNUSED(bmain))
{
}
void BKE_sound_set_cfra(int UNUSED(cfra))
{
}
-void BKE_sound_update_sequencer(struct Main *UNUSED(main), struct bSound *UNUSED(sound))
+void BKE_sound_update_sequencer(Main *UNUSED(main), bSound *UNUSED(sound))
{
}
-void BKE_sound_update_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene))
+void BKE_sound_update_scene(Main *UNUSED(bmain), Scene *UNUSED(scene))
{
}
-void BKE_sound_update_scene_sound(void *UNUSED(handle), struct bSound *UNUSED(sound))
+void BKE_sound_update_scene_sound(void *UNUSED(handle), bSound *UNUSED(sound))
{
}
-void BKE_sound_update_scene_listener(struct Scene *UNUSED(scene))
+void BKE_sound_update_scene_listener(Scene *UNUSED(scene))
{
}
-void BKE_sound_update_fps(struct Scene *UNUSED(scene))
+void BKE_sound_update_fps(Scene *UNUSED(scene))
{
}
void BKE_sound_set_scene_sound_volume(void *UNUSED(handle),
@@ -1099,7 +1136,7 @@ void BKE_sound_set_scene_sound_volume(void *UNUSED(handle),
void BKE_sound_set_scene_sound_pan(void *UNUSED(handle), float UNUSED(pan), char UNUSED(animated))
{
}
-void BKE_sound_set_scene_volume(struct Scene *UNUSED(scene), float UNUSED(volume))
+void BKE_sound_set_scene_volume(Scene *UNUSED(scene), float UNUSED(volume))
{
}
void BKE_sound_set_scene_sound_pitch(void *UNUSED(handle),
@@ -1107,7 +1144,7 @@ void BKE_sound_set_scene_sound_pitch(void *UNUSED(handle),
char UNUSED(animated))
{
}
-float BKE_sound_get_length(struct bSound *UNUSED(sound))
+float BKE_sound_get_length(bSound *UNUSED(sound))
{
return 0;
}
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index 8565fde4565..c7a0d65a2a9 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -60,8 +60,10 @@ void *BKE_speaker_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of Speaker ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Speaker ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index 7a95ec3055e..e0ff5fcccca 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -129,12 +129,13 @@ static const char *STUDIOLIGHT_MATCAP_DEFAULT = "basic_1.exr";
static void studiolight_free(struct StudioLight *sl)
{
#define STUDIOLIGHT_DELETE_ICON(s) \
- { \
+ do { \
if (s != 0) { \
BKE_icon_delete(s); \
s = 0; \
} \
- }
+ } while (0)
+
if (sl->free_function) {
sl->free_function(sl, sl->free_function_data);
}
@@ -432,9 +433,8 @@ static void studiolight_calculate_radiance_buffer(ImBuf *ibuf,
const float ysign,
const float zsign)
{
- ITER_PIXELS(
- float, colbuf, 4, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE)
- {
+ ITER_PIXELS (
+ float, colbuf, 4, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) {
float direction[3];
direction[index_x] = xsign * (x - 0.5f);
direction[index_y] = ysign * (y - 0.5f);
@@ -485,12 +485,24 @@ static void studiolight_calculate_radiance_cubemap_buffers(StudioLight *sl)
NULL, colbuf, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE);
#if 0
- IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_X_POS], "/tmp/studiolight_radiance_left.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_X_NEG], "/tmp/studiolight_radiance_right.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_POS], "/tmp/studiolight_radiance_front.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_NEG], "/tmp/studiolight_radiance_back.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_POS], "/tmp/studiolight_radiance_bottom.png", IB_rectfloat);
- IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_NEG], "/tmp/studiolight_radiance_top.png", IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_X_POS],
+ "/tmp/studiolight_radiance_left.png",
+ IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_X_NEG],
+ "/tmp/studiolight_radiance_right.png",
+ IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_POS],
+ "/tmp/studiolight_radiance_front.png",
+ IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Y_NEG],
+ "/tmp/studiolight_radiance_back.png",
+ IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_POS],
+ "/tmp/studiolight_radiance_bottom.png",
+ IB_rectfloat);
+ IMB_saveiff(sl->radiance_cubemap_buffers[STUDIOLIGHT_Z_NEG],
+ "/tmp/studiolight_radiance_top.png",
+ IB_rectfloat);
#endif
MEM_freeN(colbuf);
}
@@ -531,12 +543,11 @@ static void studiolight_spherical_harmonics_calculate_coefficients(StudioLight *
memset(sh, 0, sizeof(float) * 3 * STUDIOLIGHT_SH_COEFS_LEN);
for (int face = 0; face < 6; face++) {
- ITER_PIXELS(float,
- sl->radiance_cubemap_buffers[face]->rect_float,
- 4,
- STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE,
- STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE)
- {
+ ITER_PIXELS (float,
+ sl->radiance_cubemap_buffers[face]->rect_float,
+ 4,
+ STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE,
+ STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) {
float color[3], cubevec[3], weight;
studiolight_calculate_cubemap_vector_weight(cubevec, &weight, face, x, y);
mul_v3_v3fl(color, pixel, weight);
@@ -647,8 +658,9 @@ static float studiolight_spherical_harmonics_lambda_get(float *sh, float max_lap
static void studiolight_spherical_harmonics_apply_windowing(float (*sh)[3], float max_laplacian)
{
- if (max_laplacian <= 0.0f)
+ if (max_laplacian <= 0.0f) {
return;
+ }
float sh_r[STUDIOLIGHT_SH_COEFS_LEN];
float sh_g[STUDIOLIGHT_SH_COEFS_LEN];
@@ -680,7 +692,8 @@ static float studiolight_spherical_harmonics_geomerics_eval(
const float normal[3], float sh0, float sh1, float sh2, float sh3)
{
/* Use Geomerics non-linear SH. */
- /* http://www.geomerics.com/wp-content/uploads/2015/08/CEDEC_Geomerics_ReconstructingDiffuseLighting1.pdf */
+ /* http://www.geomerics.com/wp-content/uploads/2015/08/CEDEC_Geomerics_ReconstructingDiffuseLighting1.pdf
+ */
float R0 = sh0 * M_1_PI;
float R1[3] = {-sh3, sh2, -sh1};
@@ -822,12 +835,11 @@ BLI_INLINE void studiolight_evaluate_specular_radiance_buffer(ImBuf *radiance_bu
float accum[3] = {0.0f, 0.0f, 0.0f};
float accum_weight = 0.00001f;
- ITER_PIXELS(float,
- radiance_buffer->rect_float,
- 4,
- STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE,
- STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE)
- {
+ ITER_PIXELS (float,
+ radiance_buffer->rect_float,
+ 4,
+ STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE,
+ STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) {
float direction[3];
direction[zoffset] = zsign * 0.5f;
direction[xoffset] = x - 0.5f;
@@ -1014,12 +1026,11 @@ static void studiolight_calculate_irradiance_equirect_image(StudioLight *sl)
STUDIOLIGHT_IRRADIANCE_EQUIRECT_HEIGHT * sizeof(float[4]),
__func__);
- ITER_PIXELS(float,
- colbuf,
- 4,
- STUDIOLIGHT_IRRADIANCE_EQUIRECT_WIDTH,
- STUDIOLIGHT_IRRADIANCE_EQUIRECT_HEIGHT)
- {
+ ITER_PIXELS (float,
+ colbuf,
+ 4,
+ STUDIOLIGHT_IRRADIANCE_EQUIRECT_WIDTH,
+ STUDIOLIGHT_IRRADIANCE_EQUIRECT_HEIGHT) {
float dir[3];
equirect_to_direction(dir, x, y);
#ifdef STUDIOLIGHT_IRRADIANCE_METHOD_RADIANCE
@@ -1153,8 +1164,7 @@ static void studiolight_radiance_preview(uint *icon_buffer, StudioLight *sl)
{
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED);
- ITER_PIXELS(uint, icon_buffer, 1, STUDIOLIGHT_ICON_SIZE, STUDIOLIGHT_ICON_SIZE)
- {
+ ITER_PIXELS (uint, icon_buffer, 1, STUDIOLIGHT_ICON_SIZE, STUDIOLIGHT_ICON_SIZE) {
float dy = RESCALE_COORD(y);
float dx = RESCALE_COORD(x);
@@ -1188,8 +1198,7 @@ static void studiolight_matcap_preview(uint *icon_buffer, StudioLight *sl, bool
ImBuf *ibuf = sl->equirect_radiance_buffer;
- ITER_PIXELS(uint, icon_buffer, 1, STUDIOLIGHT_ICON_SIZE, STUDIOLIGHT_ICON_SIZE)
- {
+ ITER_PIXELS (uint, icon_buffer, 1, STUDIOLIGHT_ICON_SIZE, STUDIOLIGHT_ICON_SIZE) {
float dy = RESCALE_COORD(y);
float dx = RESCALE_COORD(x);
if (flipped) {
@@ -1211,8 +1220,7 @@ static void studiolight_matcap_preview(uint *icon_buffer, StudioLight *sl, bool
static void studiolight_irradiance_preview(uint *icon_buffer, StudioLight *sl)
{
- ITER_PIXELS(uint, icon_buffer, 1, STUDIOLIGHT_ICON_SIZE, STUDIOLIGHT_ICON_SIZE)
- {
+ ITER_PIXELS (uint, icon_buffer, 1, STUDIOLIGHT_ICON_SIZE, STUDIOLIGHT_ICON_SIZE) {
float dy = RESCALE_COORD(y);
float dx = RESCALE_COORD(x);
@@ -1276,7 +1284,8 @@ void BKE_studiolight_init(void)
BLI_addtail(&studiolights, sl);
/* go over the preset folder and add a studiolight for every image with its path */
- /* for portable installs (where USER and SYSTEM paths are the same), only go over LOCAL datafiles once */
+ /* for portable installs (where USER and SYSTEM paths are the same),
+ * only go over LOCAL datafiles once */
/* Also reserve icon space for it. */
if (!BKE_appdir_app_is_portable_install()) {
studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES,
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c
index d461394bc02..885898d9a57 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -267,8 +267,10 @@ static void vertex_interpolation_from_corner(const SubdivMeshContext *ctx,
coarse_mloop[coarse_poly->loopstart +
(first_loop_index - coarse_poly->loopstart + 1) % coarse_poly->totloop]
.v};
- const int last_indices[2] = {coarse_mloop[first_loop_index].v,
- coarse_mloop[last_loop_index].v};
+ const int last_indices[2] = {
+ coarse_mloop[first_loop_index].v,
+ coarse_mloop[last_loop_index].v,
+ };
CustomData_interp(vertex_data,
&vertex_interpolation->vertex_data_storage,
first_indices,
@@ -393,8 +395,10 @@ static void loop_interpolation_from_corner(const SubdivMeshContext *ctx,
const int second_loop_index = base_loop_index +
(first_loop_index - base_loop_index + 1) % coarse_poly->totloop;
const int first_indices[2] = {first_loop_index, second_loop_index};
- const int last_indices[2] = {loops_of_ptex.last_loop - coarse_mloop,
- loops_of_ptex.first_loop - coarse_mloop};
+ const int last_indices[2] = {
+ loops_of_ptex.last_loop - coarse_mloop,
+ loops_of_ptex.first_loop - coarse_mloop,
+ };
CustomData_interp(
loop_data, &loop_interpolation->loop_data_storage, first_indices, weights, NULL, 2, 1);
CustomData_interp(
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index cba391a90a8..ad81fc49b19 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -156,10 +156,12 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int numLaye
ifc.numLayers = numLayers;
ifc.vertDataSize = sizeof(float) * numLayers;
normalOffset += sizeof(float) * numLayers;
- if (flags & CCG_CALC_NORMALS)
+ if (flags & CCG_CALC_NORMALS) {
ifc.vertDataSize += sizeof(float) * 3;
- if (flags & CCG_ALLOC_MASK)
+ }
+ if (flags & CCG_ALLOC_MASK) {
ifc.vertDataSize += sizeof(float);
+ }
ifc.simpleSubdiv = !!(flags & CCG_SIMPLE_SUBDIV);
if (useArena) {
@@ -187,10 +189,12 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int numLaye
ccgSubSurf_setAllocMask(ccgSS, 1, sizeof(float) * numLayers);
}
- if (flags & CCG_CALC_NORMALS)
+ if (flags & CCG_CALC_NORMALS) {
ccgSubSurf_setCalcVertexNormals(ccgSS, 1, normalOffset);
- else
+ }
+ else {
ccgSubSurf_setCalcVertexNormals(ccgSS, 0, 0);
+ }
return ccgSS;
}
@@ -270,10 +274,12 @@ static void get_face_uv_map_vert(
for (j = 0; j < nverts; j++) {
for (nv = v = BKE_mesh_uv_vert_map_get_vert(vmap, ml[j].v); v; v = v->next) {
- if (v->separate)
+ if (v->separate) {
nv = v;
- if (v->poly_index == fi)
+ }
+ if (v->poly_index == fi) {
break;
+ }
}
fverts[j] = POINTER_FROM_UINT(mpoly[nv->poly_index].loopstart + nv->loop_of_poly_index);
@@ -299,23 +305,27 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm,
limit[0] = limit[1] = STD_UV_CONNECT_LIMIT;
/* previous behavior here is without accounting for winding, however this causes stretching in
- * UV map in really simple cases with mirror + subsurf, see second part of T44530. Also, initially
- * intention is to treat merged vertices from mirror modifier as seams.
+ * UV map in really simple cases with mirror + subsurf, see second part of T44530.
+ * Also, initially intention is to treat merged vertices from mirror modifier as seams.
* This fixes a very old regression (2.49 was correct here) */
vmap = BKE_mesh_uv_vert_map_create(mpoly, mloop, mloopuv, totface, totvert, limit, false, true);
- if (!vmap)
+ if (!vmap) {
return 0;
+ }
ccgSubSurf_initFullSync(ss);
/* create vertices */
for (i = 0; i < totvert; i++) {
- if (!BKE_mesh_uv_vert_map_get_vert(vmap, i))
+ if (!BKE_mesh_uv_vert_map_get_vert(vmap, i)) {
continue;
+ }
- for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i)->next; v; v = v->next)
- if (v->separate)
+ for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i)->next; v; v = v->next) {
+ if (v->separate) {
break;
+ }
+ }
seam = (v != NULL);
@@ -486,8 +496,9 @@ static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *
MTFace *tface = CustomData_get_layer_n(&result->faceData, CD_MTFACE, n);
MLoopUV *mloopuv = CustomData_get_layer_n(&result->loopData, CD_MLOOPUV, n);
- if (!dmloopuv || (!tface && !mloopuv))
+ if (!dmloopuv || (!tface && !mloopuv)) {
return;
+ }
/* create a CCGSubSurf from uv's */
uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), 2, CCG_USE_ARENA);
@@ -643,12 +654,14 @@ static void free_ss_weights(WeightTable *wtable)
int i;
for (i = 0; i < wtable->len; i++) {
- if (wtable->weight_table[i].valid)
+ if (wtable->weight_table[i].valid) {
MEM_freeN(wtable->weight_table[i].w);
+ }
}
- if (wtable->weight_table)
+ if (wtable->weight_table) {
MEM_freeN(wtable->weight_table);
+ }
}
static void ss_sync_ccg_from_derivedmesh(CCGSubSurf *ss,
@@ -733,7 +746,7 @@ static void ss_sync_ccg_from_derivedmesh(CCGSubSurf *ss,
static int hasGivenError = 0;
if (!hasGivenError) {
- //XXX error("Unrecoverable error in SubSurf calculation,"
+ // XXX error("Unrecoverable error in SubSurf calculation,"
// " mesh is inconsistent.");
hasGivenError = 1;
@@ -807,18 +820,24 @@ static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f)
static void minmax_v3_v3v3(const float vec[3], float min[3], float max[3])
{
- if (min[0] > vec[0])
+ if (min[0] > vec[0]) {
min[0] = vec[0];
- if (min[1] > vec[1])
+ }
+ if (min[1] > vec[1]) {
min[1] = vec[1];
- if (min[2] > vec[2])
+ }
+ if (min[2] > vec[2]) {
min[2] = vec[2];
- if (max[0] < vec[0])
+ }
+ if (max[0] < vec[0]) {
max[0] = vec[0];
- if (max[1] < vec[1])
+ }
+ if (max[1] < vec[1]) {
max[1] = vec[1];
- if (max[2] < vec[2])
+ }
+ if (max[2] < vec[2]) {
max[2] = vec[2];
+ }
}
static void ccgDM_getMinMax(DerivedMesh *dm, float r_min[3], float r_max[3])
@@ -841,8 +860,9 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float r_min[3], float r_max[3])
CCG_key_top_level(&key, ss);
- if (!ccgSubSurf_getNumVerts(ss))
+ if (!ccgSubSurf_getNumVerts(ss)) {
r_min[0] = r_min[1] = r_min[2] = r_max[0] = r_max[1] = r_max[2] = 0.0;
+ }
for (ccgSubSurf_initVertIterator(ss, &vi); !ccgVertIterator_isStopped(&vi);
ccgVertIterator_next(&vi)) {
@@ -857,8 +877,9 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float r_min[3], float r_max[3])
CCGEdge *e = ccgEdgeIterator_getCurrent(&ei);
CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
- for (i = 0; i < edgeSize; i++)
+ for (i = 0; i < edgeSize; i++) {
minmax_v3_v3v3(CCG_elem_offset_co(&key, edgeData, i), r_min, r_max);
+ }
}
for (ccgSubSurf_initFaceIterator(ss, &fi); !ccgFaceIterator_isStopped(&fi);
@@ -869,9 +890,11 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float r_min[3], float r_max[3])
for (S = 0; S < numVerts; S++) {
CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
- for (y = 0; y < gridSize; y++)
- for (x = 0; x < gridSize; x++)
+ for (y = 0; y < gridSize; y++) {
+ for (x = 0; x < gridSize; x++) {
minmax_v3_v3v3(CCG_grid_elem_co(&key, faceGridData, x, y), r_min, r_max);
+ }
+ }
}
}
}
@@ -1083,8 +1106,9 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
e = ccgdm->edgeMap[i].edge;
- if (!ccgSubSurf_getEdgeNumFaces(e))
+ if (!ccgSubSurf_getEdgeNumFaces(e)) {
flags |= ME_LOOSEEDGE;
+ }
x = edgeNum - ccgdm->edgeMap[i].startEdge;
@@ -1092,10 +1116,12 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
med->v2 = getEdgeIndex(ss, e, x + 1, edgeSize);
edgeFlag = (ccgdm->edgeFlags) ? &ccgdm->edgeFlags[i] : NULL;
- if (edgeFlag)
+ if (edgeFlag) {
flags |= (*edgeFlag & (ME_SEAM | ME_SHARP)) | ME_EDGEDRAW | ME_EDGERENDER;
- else
+ }
+ else {
flags |= ME_EDGEDRAW | ME_EDGERENDER;
+ }
med->flag = flags;
}
@@ -1119,8 +1145,9 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
DMFlagMat *faceFlags = ccgdm->faceFlags;
memset(mf, 0, sizeof(*mf));
- if (faceNum >= ccgdm->dm.numTessFaceData)
+ if (faceNum >= ccgdm->dm.numTessFaceData) {
return;
+ }
i = ccgdm->reverseFaceMap[faceNum];
@@ -1173,8 +1200,9 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm,
int factor = BKE_ccg_factor(level, md->level);
BLI_bitmap *hidden = md->hidden;
- if (!hidden)
+ if (!hidden) {
continue;
+ }
for (y = 0; y < gridSize; y++) {
for (x = 0; x < gridSize; x++) {
@@ -1182,8 +1210,9 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm,
vndx = getFaceIndex(ss, f, j, x, y, edgeSize, gridSize);
offset = (y * factor) * hidden_gridsize + (x * factor);
- if (BLI_BITMAP_TEST(hidden, offset))
+ if (BLI_BITMAP_TEST(hidden, offset)) {
mvert[vndx].flag |= ME_HIDE;
+ }
}
}
}
@@ -1211,8 +1240,9 @@ void subsurf_copy_grid_paint_mask(DerivedMesh *dm,
for (j = 0; j < p->totloop; j++) {
const GridPaintMask *gpm = &grid_paint_mask[p->loopstart + j];
- if (!gpm->data)
+ if (!gpm->data) {
continue;
+ }
factor = BKE_ccg_factor(level, gpm->level);
gpm_gridsize = BKE_ccg_gridsize(gpm->level);
@@ -1699,8 +1729,8 @@ static void ccgDM_foreachMappedLoop(DerivedMesh *dm,
void *userData,
DMForeachFlag flag)
{
- /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
- * return loop data from bmesh itself. */
+ /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData,
+ * EditDerivedBMesh would return loop data from bmesh itself. */
const float(*lnors)[3] = (flag & DM_FOREACH_USE_NORMAL) ? DM_get_loop_data_layer(dm, CD_NORMAL) :
NULL;
@@ -1779,26 +1809,34 @@ static void ccgDM_release(DerivedMesh *dm)
}
if (ccgdm->multires.mmd) {
- if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED)
+ if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED) {
multires_modifier_update_mdisps(dm, NULL);
- if (ccgdm->multires.modified_flags & MULTIRES_HIDDEN_MODIFIED)
+ }
+ if (ccgdm->multires.modified_flags & MULTIRES_HIDDEN_MODIFIED) {
multires_modifier_update_hidden(dm);
+ }
}
}
- if (ccgdm->ehash)
+ if (ccgdm->ehash) {
BLI_edgehash_free(ccgdm->ehash, NULL);
+ }
- if (ccgdm->reverseFaceMap)
+ if (ccgdm->reverseFaceMap) {
MEM_freeN(ccgdm->reverseFaceMap);
- if (ccgdm->gridFaces)
+ }
+ if (ccgdm->gridFaces) {
MEM_freeN(ccgdm->gridFaces);
- if (ccgdm->gridData)
+ }
+ if (ccgdm->gridData) {
MEM_freeN(ccgdm->gridData);
- if (ccgdm->gridOffset)
+ }
+ if (ccgdm->gridOffset) {
MEM_freeN(ccgdm->gridOffset);
- if (ccgdm->gridFlagMats)
+ }
+ if (ccgdm->gridFlagMats) {
MEM_freeN(ccgdm->gridFlagMats);
+ }
if (ccgdm->gridHidden) {
/* Using dm->getNumGrids(dm) accesses freed memory */
uint numGrids = ccgdm->numGrid;
@@ -1809,12 +1847,15 @@ static void ccgDM_release(DerivedMesh *dm)
}
MEM_freeN(ccgdm->gridHidden);
}
- if (ccgdm->freeSS)
+ if (ccgdm->freeSS) {
ccgSubSurf_free(ccgdm->ss);
- if (ccgdm->pmap)
+ }
+ if (ccgdm->pmap) {
MEM_freeN(ccgdm->pmap);
- if (ccgdm->pmap_mem)
+ }
+ if (ccgdm->pmap_mem) {
MEM_freeN(ccgdm->pmap_mem);
+ }
MEM_freeN(ccgdm->edgeFlags);
MEM_freeN(ccgdm->faceFlags);
if (ccgdm->useGpuBackend == false) {
@@ -1855,8 +1896,9 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
totnone = dm->numVertData - totorig;
/* original vertices are at the end */
- for (a = 0; a < totnone; a++)
+ for (a = 0; a < totnone; a++) {
origindex[a] = ORIGINDEX_NONE;
+ }
for (index = 0; index < totorig; index++, a++) {
CCGVert *v = ccgdm->vertMap[index].vert;
@@ -1894,15 +1936,17 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
totnone = dm->numEdgeData - totorig;
/* original edges are at the end */
- for (a = 0; a < totnone; a++)
+ for (a = 0; a < totnone; a++) {
origindex[a] = ORIGINDEX_NONE;
+ }
for (index = 0; index < totedge; index++) {
CCGEdge *e = ccgdm->edgeMap[index].edge;
int mapIndex = ccgDM_getEdgeMapIndex(ss, e);
- for (i = 0; i < edgeSize - 1; i++, a++)
+ for (i = 0; i < edgeSize - 1; i++, a++) {
origindex[a] = mapIndex;
+ }
}
return origindex;
@@ -1934,10 +1978,9 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
if (type == CD_TESSLOOPNORMAL) {
/* Create tessloopnormal on demand to save memory. */
- /* Note that since tessellated face corners are the same a loops in CCGDM, and since all faces have four
- * loops/corners, we can simplify the code here by converting tessloopnormals from 'short (*)[4][3]'
- * to 'short (*)[3]'.
- */
+ /* Note that since tessellated face corners are the same a loops in CCGDM,
+ * and since all faces have four loops/corners, we can simplify the code
+ * here by converting tessloopnormals from 'short (*)[4][3]' to 'short (*)[3]'. */
short(*tlnors)[3];
/* Avoid re-creation if the layer exists already */
@@ -1956,7 +1999,8 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
DM_add_tessface_layer(dm, CD_TESSLOOPNORMAL, CD_CALLOC, NULL);
tlnors = tlnors_it = (short(*)[3])DM_get_tessface_data_layer(dm, CD_TESSLOOPNORMAL);
- /* With ccgdm, we have a simple one to one mapping between loops and tessellated face corners. */
+ /* With ccgdm, we have a simple one to one mapping between loops
+ * and tessellated face corners. */
for (i = 0; i < numLoops; ++i, ++tlnors_it, ++lnors) {
normal_float_to_short_v3(*tlnors_it, *lnors);
}
@@ -1994,8 +2038,9 @@ static void *ccgDM_get_poly_data_layer(DerivedMesh *dm, int type)
int numVerts = ccgSubSurf_getFaceNumVerts(f);
int mapIndex = ccgDM_getFaceMapIndex(ss, f);
- for (i = 0; i < gridFaces * gridFaces * numVerts; i++, a++)
+ for (i = 0; i < gridFaces * gridFaces * numVerts; i++, a++) {
origindex[a] = mapIndex;
+ }
}
return origindex;
@@ -2076,8 +2121,9 @@ static void ccgdm_create_grids(DerivedMesh *dm)
int *gridOffset;
int index, numFaces, numGrids, S, gIndex /*, gridSize*/;
- if (ccgdm->gridData)
+ if (ccgdm->gridData) {
return;
+ }
numGrids = ccgDM_getNumGrids(dm);
numFaces = ccgSubSurf_getNumFaces(ss);
@@ -2182,8 +2228,9 @@ static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm)
/* both of multires and subsurf modifiers are CCG, but
* grids should only be used when sculpting on multires */
- if (!mmd)
+ if (!mmd) {
return 0;
+ }
return 1;
}
@@ -2201,14 +2248,15 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
return NULL;
}
- if (!ob->sculpt)
+ if (!ob->sculpt) {
return NULL;
+ }
bool grid_pbvh = ccgDM_use_grid_pbvh(ccgdm);
if ((ob->mode & OB_MODE_SCULPT) == 0) {
/* In vwpaint, we may use a grid_pbvh for multires/subsurf, under certain conditions.
- * More complex cases break 'history' trail back to original vertices, in that case we fall back to
- * deformed cage only (i.e. original deformed mesh). */
+ * More complex cases break 'history' trail back to original vertices,
+ * in that case we fall back to deformed cage only (i.e. original deformed mesh). */
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -2246,8 +2294,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
}
if (ob->sculpt->pbvh) {
- /* Note that we have to clean up exisitng pbvh instead of updating it in case it does not match current
- * grid_pbvh status. */
+ /* Note that we have to clean up exisitng pbvh instead of updating it in case it does not
+ * match current grid_pbvh status. */
const PBVHType pbvh_type = BKE_pbvh_type(ob->sculpt->pbvh);
if (grid_pbvh) {
if (pbvh_type == PBVH_GRIDS) {
@@ -2313,6 +2361,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
me->mvert,
me->totvert,
&me->vdata,
+ &me->ldata,
looptri,
looptris_num);
@@ -2389,7 +2438,8 @@ static void set_default_ccgdm_callbacks(CCGDerivedMesh *ccgdm)
ccgdm->dm.getNumVerts = ccgDM_getNumVerts;
ccgdm->dm.getNumEdges = ccgDM_getNumEdges;
ccgdm->dm.getNumLoops = ccgDM_getNumLoops;
- /* reuse of ccgDM_getNumTessFaces is intentional here: subsurf polys are just created from tessfaces */
+ /* reuse of ccgDM_getNumTessFaces is intentional here:
+ * subsurf polys are just created from tessfaces */
ccgdm->dm.getNumPolys = ccgDM_getNumPolys;
ccgdm->dm.getNumTessFaces = ccgDM_getNumTessFaces;
@@ -2692,8 +2742,9 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm,
ccgdm->edgeMap[index].startVert = vertNum;
ccgdm->edgeMap[index].startEdge = edgeNum;
- if (edgeIdx >= 0 && edgeFlags)
+ if (edgeIdx >= 0 && edgeFlags) {
edgeFlags[edgeIdx] = medge[edgeIdx].flag;
+ }
/* set the edge base vert */
*((int *)ccgSubSurf_getEdgeUserData(ss, e)) = vertNum;
@@ -2732,8 +2783,9 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm,
int numlayer = CustomData_number_of_layers(ldata, CD_MLOOPUV);
int dmnumlayer = CustomData_number_of_layers(dmldata, CD_MLOOPUV);
- for (i = 0; i < numlayer && i < dmnumlayer; i++)
+ for (i = 0; i < numlayer && i < dmnumlayer; i++) {
set_subsurf_uv(ss, dm, &ccgdm->dm, i);
+ }
}
for (index = 0; index < totvert; ++index) {
@@ -2911,8 +2963,9 @@ struct DerivedMesh *subsurf_make_derived_from_derived(struct DerivedMesh *dm,
get_render_subsurf_level(&scene->r, smd->renderLevels, true) :
smd->renderLevels;
- if (levels == 0)
+ if (levels == 0) {
return dm;
+ }
ss = _getSubSurf(NULL, levels, 3, useSimple | CCG_USE_ARENA | CCG_CALC_NORMALS);
@@ -2979,8 +3032,9 @@ struct DerivedMesh *subsurf_make_derived_from_derived(struct DerivedMesh *dm,
}
}
- if (flags & SUBSURF_ALLOC_PAINT_MASK)
+ if (flags & SUBSURF_ALLOC_PAINT_MASK) {
ccg_flags |= CCG_ALLOC_MASK;
+ }
ss = _getSubSurf(prevSS, levels, 3, ccg_flags);
#ifdef WITH_OPENSUBDIV
@@ -2990,13 +3044,16 @@ struct DerivedMesh *subsurf_make_derived_from_derived(struct DerivedMesh *dm,
result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm, use_gpu_backend);
- if (flags & SUBSURF_IS_FINAL_CALC)
+ if (flags & SUBSURF_IS_FINAL_CALC) {
smd->mCache = ss;
- else
+ }
+ else {
result->freeSS = 1;
+ }
- if (flags & SUBSURF_ALLOC_PAINT_MASK)
+ if (flags & SUBSURF_ALLOC_PAINT_MASK) {
ccgSubSurf_setNumLayers(ss, 4);
+ }
}
}
@@ -3040,8 +3097,9 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*r_positions)[3])
/* ad-hoc correction for boundary vertices, to at least avoid them
* moving completely out of place (brecht) */
- if (numFaces && numFaces != N)
+ if (numFaces && numFaces != N) {
mul_v3_fl(face_sum, (float)N / (float)numFaces);
+ }
co = ccgSubSurf_getVertData(ss, v);
r_positions[idx][0] = (co[0] * N * N + edge_sum[0] * 4 + face_sum[0]) / (N * (N + 5));
diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c
index 7631afaa680..47d536f4f4f 100644
--- a/source/blender/blenkernel/intern/suggestions.c
+++ b/source/blender/blenkernel/intern/suggestions.c
@@ -39,7 +39,7 @@
static Text *activeToolText = NULL;
static SuggList suggestions = {NULL, NULL, NULL, NULL, NULL};
static char *documentation = NULL;
-//static int doc_lines = 0;
+// static int doc_lines = 0;
static void txttl_free_suggest(void)
{
@@ -74,8 +74,9 @@ void free_texttools(void)
void texttool_text_set_active(Text *text)
{
- if (activeToolText == text)
+ if (activeToolText == text) {
return;
+ }
texttool_text_clear();
activeToolText = text;
}
@@ -123,14 +124,16 @@ void texttool_suggest_add(const char *name, char type)
/* Newitem comes after this item, insert here */
if (cmp >= 0) {
newitem->prev = item;
- if (item->next)
+ if (item->next) {
item->next->prev = newitem;
+ }
newitem->next = item->next;
item->next = newitem;
/* At last item, set last pointer here */
- if (item == suggestions.last)
+ if (item == suggestions.last) {
suggestions.last = newitem;
+ }
break;
}
}
@@ -150,8 +153,9 @@ void texttool_suggest_prefix(const char *prefix, const int prefix_len)
SuggItem *match, *first, *last;
int cmp, top = 0;
- if (!suggestions.first)
+ if (!suggestions.first) {
return;
+ }
if (prefix_len == 0) {
suggestions.selected = suggestions.firstmatch = suggestions.first;
suggestions.lastmatch = suggestions.last;
@@ -176,8 +180,9 @@ void texttool_suggest_prefix(const char *prefix, const int prefix_len)
top++;
}
if (first) {
- if (!last)
+ if (!last) {
last = suggestions.last;
+ }
suggestions.firstmatch = first;
suggestions.lastmatch = last;
suggestions.selected = first;
@@ -228,8 +233,9 @@ void texttool_docs_show(const char *docs)
{
int len;
- if (!docs)
+ if (!docs) {
return;
+ }
len = strlen(docs);
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index ef4b9d95324..f07751e349f 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -209,8 +209,9 @@ void BKE_text_init(Text *ta)
ta->nlines = 1;
ta->flags = TXT_ISDIRTY | TXT_ISMEM;
- if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0)
+ if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0) {
ta->flags |= TXT_TABSTOSPACES;
+ }
BLI_listbase_clear(&ta->lines);
@@ -252,8 +253,9 @@ int txt_extended_ascii_as_utf8(char **str)
int added = 0;
while ((*str)[i]) {
- if ((bad_char = BLI_utf8_invalid_byte(*str + i, length - i)) == -1)
+ if ((bad_char = BLI_utf8_invalid_byte(*str + i, length - i)) == -1) {
break;
+ }
added++;
i += bad_char + 1;
@@ -321,8 +323,9 @@ static void text_from_buf(Text *text, const unsigned char *buffer, const int len
tmp->line = (char *)MEM_mallocN(llen + 1, "textline_string");
tmp->format = NULL;
- if (llen)
+ if (llen) {
memcpy(tmp->line, &buffer[i - llen], llen);
+ }
tmp->line[llen] = 0;
tmp->len = llen;
@@ -350,8 +353,9 @@ static void text_from_buf(Text *text, const unsigned char *buffer, const int len
tmp->line = (char *)MEM_mallocN(llen + 1, "textline_string");
tmp->format = NULL;
- if (llen)
+ if (llen) {
memcpy(tmp->line, &buffer[i - llen], llen);
+ }
tmp->line[llen] = 0;
tmp->len = llen;
@@ -412,8 +416,9 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const
BLI_stat_t st;
BLI_strncpy(filepath_abs, file, FILE_MAX);
- if (relpath) /* can be NULL (bg mode) */
+ if (relpath) { /* can be NULL (bg mode) */
BLI_path_abs(filepath_abs, relpath);
+ }
buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len);
if (buffer == NULL) {
@@ -426,8 +431,9 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const
BLI_listbase_clear(&ta->lines);
ta->curl = ta->sell = NULL;
- if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0)
+ if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0) {
ta->flags = TXT_TABSTOSPACES;
+ }
if (is_internal == false) {
ta->name = MEM_mallocN(strlen(file) + 1, "text_name");
@@ -458,8 +464,10 @@ Text *BKE_text_load(Main *bmain, const char *file, const char *relpath)
}
/**
- * Only copy internal data of Text ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Text ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -545,25 +553,30 @@ int BKE_text_file_modified_check(Text *text)
int result;
char file[FILE_MAX];
- if (!text->name)
+ if (!text->name) {
return 0;
+ }
BLI_strncpy(file, text->name, FILE_MAX);
BLI_path_abs(file, BKE_main_blendfile_path_from_global());
- if (!BLI_exists(file))
+ if (!BLI_exists(file)) {
return 2;
+ }
result = BLI_stat(file, &st);
- if (result == -1)
+ if (result == -1) {
return -1;
+ }
- if ((st.st_mode & S_IFMT) != S_IFREG)
+ if ((st.st_mode & S_IFMT) != S_IFREG) {
return -1;
+ }
- if (st.st_mtime > text->mtime)
+ if (st.st_mtime > text->mtime) {
return 1;
+ }
return 0;
}
@@ -574,19 +587,22 @@ void BKE_text_file_modified_ignore(Text *text)
int result;
char file[FILE_MAX];
- if (!text->name)
+ if (!text->name) {
return;
+ }
BLI_strncpy(file, text->name, FILE_MAX);
BLI_path_abs(file, BKE_main_blendfile_path_from_global());
- if (!BLI_exists(file))
+ if (!BLI_exists(file)) {
return;
+ }
result = BLI_stat(file, &st);
- if (result == -1 || (st.st_mode & S_IFMT) != S_IFREG)
+ if (result == -1 || (st.st_mode & S_IFMT) != S_IFREG) {
return;
+ }
text->mtime = st.st_mtime;
}
@@ -597,10 +613,12 @@ void BKE_text_file_modified_ignore(Text *text)
static void make_new_line(TextLine *line, char *newline)
{
- if (line->line)
+ if (line->line) {
MEM_freeN(line->line);
- if (line->format)
+ }
+ if (line->format) {
MEM_freeN(line->format);
+ }
line->line = newline;
line->len = strlen(newline);
@@ -611,8 +629,9 @@ static TextLine *txt_new_line(const char *str)
{
TextLine *tmp;
- if (!str)
+ if (!str) {
str = "";
+ }
tmp = (TextLine *)MEM_mallocN(sizeof(TextLine), "textline");
tmp->line = MEM_mallocN(strlen(str) + 1, "textline_string");
@@ -647,28 +666,35 @@ void txt_clean_text(Text *text)
TextLine **top, **bot;
if (!text->lines.first) {
- if (text->lines.last)
+ if (text->lines.last) {
text->lines.first = text->lines.last;
- else
+ }
+ else {
text->lines.first = text->lines.last = txt_new_line(NULL);
+ }
}
- if (!text->lines.last)
+ if (!text->lines.last) {
text->lines.last = text->lines.first;
+ }
top = (TextLine **)&text->lines.first;
bot = (TextLine **)&text->lines.last;
- while ((*top)->prev)
+ while ((*top)->prev) {
*top = (*top)->prev;
- while ((*bot)->next)
+ }
+ while ((*bot)->next) {
*bot = (*bot)->next;
+ }
if (!text->curl) {
- if (text->sell)
+ if (text->sell) {
text->curl = text->sell;
- else
+ }
+ else {
text->curl = text->lines.first;
+ }
text->curc = 0;
}
@@ -683,15 +709,18 @@ int txt_get_span(TextLine *from, TextLine *to)
int ret = 0;
TextLine *tmp = from;
- if (!to || !from)
+ if (!to || !from) {
return 0;
- if (from == to)
+ }
+ if (from == to) {
return 0;
+ }
/* Look forwards */
while (tmp) {
- if (tmp == to)
+ if (tmp == to) {
return ret;
+ }
ret++;
tmp = tmp->next;
}
@@ -701,13 +730,15 @@ int txt_get_span(TextLine *from, TextLine *to)
tmp = from;
ret = 0;
while (tmp) {
- if (tmp == to)
+ if (tmp == to) {
break;
+ }
ret--;
tmp = tmp->prev;
}
- if (!tmp)
+ if (!tmp) {
ret = 0;
+ }
}
return ret;
@@ -717,8 +748,9 @@ static void txt_make_dirty(Text *text)
{
text->flags |= TXT_ISDIRTY;
#ifdef WITH_PYTHON
- if (text->compiled)
+ if (text->compiled) {
BPY_text_free_code(text);
+ }
#endif
}
@@ -787,8 +819,9 @@ int txt_utf8_column_to_offset(const char *str, int column)
int offset = 0, pos = 0, col;
while (*(str + offset) && pos < column) {
col = BLI_str_utf8_char_width_safe(str + offset);
- if (pos + col > column)
+ if (pos + col > column) {
break;
+ }
offset += BLI_str_utf8_size_safe(str + offset);
pos += col;
}
@@ -800,14 +833,16 @@ void txt_move_up(Text *text, const bool sel)
TextLine **linep;
int *charp;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
+ }
else {
txt_pop_first(text);
txt_curs_cur(text, &linep, &charp);
}
- if (!*linep)
+ if (!*linep) {
return;
+ }
if ((*linep)->prev) {
int column = txt_utf8_offset_to_column((*linep)->line, *charp);
@@ -818,8 +853,9 @@ void txt_move_up(Text *text, const bool sel)
txt_move_bol(text, sel);
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
void txt_move_down(Text *text, const bool sel)
@@ -827,14 +863,16 @@ void txt_move_down(Text *text, const bool sel)
TextLine **linep;
int *charp;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
+ }
else {
txt_pop_last(text);
txt_curs_cur(text, &linep, &charp);
}
- if (!*linep)
+ if (!*linep) {
return;
+ }
if ((*linep)->next) {
int column = txt_utf8_offset_to_column((*linep)->line, *charp);
@@ -845,8 +883,9 @@ void txt_move_down(Text *text, const bool sel)
txt_move_eol(text, sel);
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
int txt_calc_tab_left(TextLine *tl, int ch)
@@ -855,15 +894,17 @@ int txt_calc_tab_left(TextLine *tl, int ch)
int tabsize = (ch < TXT_TABSIZE) ? ch : TXT_TABSIZE;
- for (int i = 0; i < ch; i++)
+ for (int i = 0; i < ch; i++) {
if (tl->line[i] != ' ') {
tabsize = 0;
break;
}
+ }
/* if in the middle of the space-tab */
- if (tabsize && ch % TXT_TABSIZE != 0)
+ if (tabsize && ch % TXT_TABSIZE != 0) {
tabsize = (ch % TXT_TABSIZE);
+ }
return tabsize;
}
@@ -895,14 +936,16 @@ void txt_move_left(Text *text, const bool sel)
int *charp;
int tabsize = 0;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
+ }
else {
txt_pop_first(text);
txt_curs_cur(text, &linep, &charp);
}
- if (!*linep)
+ if (!*linep) {
return;
+ }
if (*charp == 0) {
if ((*linep)->prev) {
@@ -926,8 +969,9 @@ void txt_move_left(Text *text, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
void txt_move_right(Text *text, const bool sel)
@@ -935,14 +979,16 @@ void txt_move_right(Text *text, const bool sel)
TextLine **linep;
int *charp;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
+ }
else {
txt_pop_last(text);
txt_curs_cur(text, &linep, &charp);
}
- if (!*linep)
+ if (!*linep) {
return;
+ }
if (*charp == (*linep)->len) {
if ((*linep)->next) {
@@ -967,8 +1013,9 @@ void txt_move_right(Text *text, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
void txt_jump_left(Text *text, const bool sel, const bool use_init_step)
@@ -976,20 +1023,23 @@ void txt_jump_left(Text *text, const bool sel, const bool use_init_step)
TextLine **linep;
int *charp;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
+ }
else {
txt_pop_first(text);
txt_curs_cur(text, &linep, &charp);
}
- if (!*linep)
+ if (!*linep) {
return;
+ }
BLI_str_cursor_step_utf8(
(*linep)->line, (*linep)->len, charp, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM, use_init_step);
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
void txt_jump_right(Text *text, const bool sel, const bool use_init_step)
@@ -997,20 +1047,23 @@ void txt_jump_right(Text *text, const bool sel, const bool use_init_step)
TextLine **linep;
int *charp;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
+ }
else {
txt_pop_last(text);
txt_curs_cur(text, &linep, &charp);
}
- if (!*linep)
+ if (!*linep) {
return;
+ }
BLI_str_cursor_step_utf8(
(*linep)->line, (*linep)->len, charp, STRCUR_DIR_NEXT, STRCUR_JUMP_DELIM, use_init_step);
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
void txt_move_bol(Text *text, const bool sel)
@@ -1018,17 +1071,21 @@ void txt_move_bol(Text *text, const bool sel)
TextLine **linep;
int *charp;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
- else
+ }
+ else {
txt_curs_cur(text, &linep, &charp);
- if (!*linep)
+ }
+ if (!*linep) {
return;
+ }
*charp = 0;
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
void txt_move_eol(Text *text, const bool sel)
@@ -1036,17 +1093,21 @@ void txt_move_eol(Text *text, const bool sel)
TextLine **linep;
int *charp;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
- else
+ }
+ else {
txt_curs_cur(text, &linep, &charp);
- if (!*linep)
+ }
+ if (!*linep) {
return;
+ }
*charp = (*linep)->len;
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
void txt_move_bof(Text *text, const bool sel)
@@ -1054,18 +1115,22 @@ void txt_move_bof(Text *text, const bool sel)
TextLine **linep;
int *charp;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
- else
+ }
+ else {
txt_curs_cur(text, &linep, &charp);
- if (!*linep)
+ }
+ if (!*linep) {
return;
+ }
*linep = text->lines.first;
*charp = 0;
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
void txt_move_eof(Text *text, const bool sel)
@@ -1073,18 +1138,22 @@ void txt_move_eof(Text *text, const bool sel)
TextLine **linep;
int *charp;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
- else
+ }
+ else {
txt_curs_cur(text, &linep, &charp);
- if (!*linep)
+ }
+ if (!*linep) {
return;
+ }
*linep = text->lines.last;
*charp = (*linep)->len;
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
void txt_move_toline(Text *text, unsigned int line, const bool sel)
@@ -1099,26 +1168,33 @@ void txt_move_to(Text *text, unsigned int line, unsigned int ch, const bool sel)
int *charp;
unsigned int i;
- if (sel)
+ if (sel) {
txt_curs_sel(text, &linep, &charp);
- else
+ }
+ else {
txt_curs_cur(text, &linep, &charp);
- if (!*linep)
+ }
+ if (!*linep) {
return;
+ }
*linep = text->lines.first;
for (i = 0; i < line; i++) {
- if ((*linep)->next)
+ if ((*linep)->next) {
*linep = (*linep)->next;
- else
+ }
+ else {
break;
+ }
}
- if (ch > (unsigned int)((*linep)->len))
+ if (ch > (unsigned int)((*linep)->len)) {
ch = (unsigned int)((*linep)->len);
+ }
*charp = ch;
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
/****************************/
@@ -1167,10 +1243,12 @@ void txt_pop_sel(Text *text)
void txt_order_cursors(Text *text, const bool reverse)
{
- if (!text->curl)
+ if (!text->curl) {
return;
- if (!text->sell)
+ }
+ if (!text->sell) {
return;
+ }
/* Flip so text->curl is before/after text->sell */
if (reverse == false) {
@@ -1197,13 +1275,16 @@ static void txt_delete_sel(Text *text, TextUndoBuf *utxt)
TextLine *tmpl;
char *buf;
- if (!text->curl)
+ if (!text->curl) {
return;
- if (!text->sell)
+ }
+ if (!text->sell) {
return;
+ }
- if (!txt_has_sel(text))
+ if (!txt_has_sel(text)) {
return;
+ }
txt_order_cursors(text, false);
@@ -1224,8 +1305,9 @@ static void txt_delete_sel(Text *text, TextUndoBuf *utxt)
tmpl = text->sell;
while (tmpl != text->curl) {
tmpl = tmpl->prev;
- if (!tmpl)
+ if (!tmpl) {
break;
+ }
txt_delete_line(text, tmpl->next);
}
@@ -1258,8 +1340,9 @@ void txt_sel_clear(Text *text)
void txt_sel_line(Text *text)
{
- if (!text->curl)
+ if (!text->curl) {
return;
+ }
text->curc = 0;
text->sell = text->curl;
@@ -1277,12 +1360,15 @@ char *txt_to_buf(Text *text)
int charf, charl;
char *buf;
- if (!text->curl)
+ if (!text->curl) {
return NULL;
- if (!text->sell)
+ }
+ if (!text->sell) {
return NULL;
- if (!text->lines.first)
+ }
+ if (!text->lines.first) {
return NULL;
+ }
linef = text->lines.first;
charf = 0;
@@ -1341,32 +1427,40 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
TextLine *tl, *startl;
const char *s = NULL;
- if (!text->curl || !text->sell)
+ if (!text->curl || !text->sell) {
return 0;
+ }
txt_order_cursors(text, false);
tl = startl = text->sell;
- if (match_case)
+ if (match_case) {
s = strstr(&tl->line[text->selc], findstr);
- else
+ }
+ else {
s = BLI_strcasestr(&tl->line[text->selc], findstr);
+ }
while (!s) {
tl = tl->next;
if (!tl) {
- if (wrap)
+ if (wrap) {
tl = text->lines.first;
- else
+ }
+ else {
break;
+ }
}
- if (match_case)
+ if (match_case) {
s = strstr(tl->line, findstr);
- else
+ }
+ else {
s = BLI_strcasestr(tl->line, findstr);
- if (tl == startl)
+ }
+ if (tl == startl) {
break;
+ }
}
if (s) {
@@ -1376,8 +1470,9 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
txt_move_to(text, newl, newc + strlen(findstr), 1);
return 1;
}
- else
+ else {
return 0;
+ }
}
char *txt_sel_to_buf(Text *text)
@@ -1387,10 +1482,12 @@ char *txt_sel_to_buf(Text *text)
TextLine *tmp, *linef, *linel;
int charf, charl;
- if (!text->curl)
+ if (!text->curl) {
return NULL;
- if (!text->sell)
+ }
+ if (!text->sell) {
return NULL;
+ }
if (text->curl == text->sell) {
linef = linel = text->curl;
@@ -1470,8 +1567,9 @@ void txt_insert_buf(Text *text, TextUndoBuf *utxt, const char *in_buffer)
TextLine *add;
char *buffer;
- if (!in_buffer)
+ if (!in_buffer) {
return;
+ }
txt_delete_sel(text, utxt);
@@ -1563,7 +1661,8 @@ static void dump_buffer(TextUndoBuf *utxt)
{
int i = 0;
- while (i++ < utxt->undo_pos) printf("%d: %d %c\n", i, utxt->buf[i], utxt->buf[i]);
+ while (i++ < utxt->undo_pos)
+ printf("%d: %d %c\n", i, utxt->buf[i], utxt->buf[i]);
}
/* Note: this function is outdated and must be updated if needed for future use */
@@ -1646,27 +1745,38 @@ void txt_print_undo(Text *text)
i++;
printf(" - Char is ");
switch (op) {
- case UNDO_INSERT_1: case UNDO_BS_1: case UNDO_DEL_1:
+ case UNDO_INSERT_1:
+ case UNDO_BS_1:
+ case UNDO_DEL_1:
printf("%c", utxt->buf[i]);
i++;
break;
- case UNDO_INSERT_2: case UNDO_BS_2: case UNDO_DEL_2:
+ case UNDO_INSERT_2:
+ case UNDO_BS_2:
+ case UNDO_DEL_2:
printf("%c%c", utxt->buf[i], utxt->buf[i + 1]);
i += 2;
break;
- case UNDO_INSERT_3: case UNDO_BS_3: case UNDO_DEL_3:
+ case UNDO_INSERT_3:
+ case UNDO_BS_3:
+ case UNDO_DEL_3:
printf("%c%c%c", utxt->buf[i], utxt->buf[i + 1], utxt->buf[i + 2]);
i += 3;
break;
- case UNDO_INSERT_4: case UNDO_BS_4: case UNDO_DEL_4:
- {
+ case UNDO_INSERT_4:
+ case UNDO_BS_4:
+ case UNDO_DEL_4: {
unsigned int uc;
char c[BLI_UTF8_MAX + 1];
size_t c_len;
- uc = utxt->buf[i]; i++;
- uc = uc + (utxt->buf[i] << 8); i++;
- uc = uc + (utxt->buf[i] << 16); i++;
- uc = uc + (utxt->buf[i] << 24); i++;
+ uc = utxt->buf[i];
+ i++;
+ uc = uc + (utxt->buf[i] << 8);
+ i++;
+ uc = uc + (utxt->buf[i] << 16);
+ i++;
+ uc = uc + (utxt->buf[i] << 24);
+ i++;
c_len = BLI_str_utf8_from_unicode(uc, c);
c[c_len] = '\0';
puts(c);
@@ -1677,49 +1787,70 @@ void txt_print_undo(Text *text)
else if (op == UNDO_DBLOCK || op == UNDO_IBLOCK) {
i++;
- linep = utxt->buf[i]; i++;
- linep = linep + (utxt->buf[i] << 8); i++;
- linep = linep + (utxt->buf[i] << 16); i++;
- linep = linep + (utxt->buf[i] << 24); i++;
+ linep = utxt->buf[i];
+ i++;
+ linep = linep + (utxt->buf[i] << 8);
+ i++;
+ linep = linep + (utxt->buf[i] << 16);
+ i++;
+ linep = linep + (utxt->buf[i] << 24);
+ i++;
printf(" (length %d) <", linep);
while (linep > 0) {
putchar(utxt->buf[i]);
- linep--; i++;
+ linep--;
+ i++;
}
- linep = utxt->buf[i]; i++;
- linep = linep + (utxt->buf[i] << 8); i++;
- linep = linep + (utxt->buf[i] << 16); i++;
- linep = linep + (utxt->buf[i] << 24); i++;
+ linep = utxt->buf[i];
+ i++;
+ linep = linep + (utxt->buf[i] << 8);
+ i++;
+ linep = linep + (utxt->buf[i] << 16);
+ i++;
+ linep = linep + (utxt->buf[i] << 24);
+ i++;
printf("> (%d)", linep);
}
else if (op == UNDO_INDENT || op == UNDO_UNINDENT) {
i++;
- charp = utxt->buf[i]; i++;
- charp = charp + (utxt->buf[i] << 8); i++;
+ charp = utxt->buf[i];
+ i++;
+ charp = charp + (utxt->buf[i] << 8);
+ i++;
- linep = utxt->buf[i]; i++;
- linep = linep + (utxt->buf[i] << 8); i++;
- linep = linep + (utxt->buf[i] << 16); i++;
- linep = linep + (utxt->buf[i] << 24); i++;
+ linep = utxt->buf[i];
+ i++;
+ linep = linep + (utxt->buf[i] << 8);
+ i++;
+ linep = linep + (utxt->buf[i] << 16);
+ i++;
+ linep = linep + (utxt->buf[i] << 24);
+ i++;
printf("to <%d, %d> ", linep, charp);
- charp = utxt->buf[i]; i++;
- charp = charp + (utxt->buf[i] << 8); i++;
+ charp = utxt->buf[i];
+ i++;
+ charp = charp + (utxt->buf[i] << 8);
+ i++;
- linep = utxt->buf[i]; i++;
- linep = linep + (utxt->buf[i] << 8); i++;
- linep = linep + (utxt->buf[i] << 16); i++;
- linep = linep + (utxt->buf[i] << 24); i++;
+ linep = utxt->buf[i];
+ i++;
+ linep = linep + (utxt->buf[i] << 8);
+ i++;
+ linep = linep + (utxt->buf[i] << 16);
+ i++;
+ linep = linep + (utxt->buf[i] << 24);
+ i++;
printf("from <%d, %d>", linep, charp);
}
- printf(" %d\n", i);
+ printf(" %d\n", i);
i++;
}
}
@@ -1875,7 +2006,7 @@ static void txt_undo_add_unprefix_op(Text *text,
BLI_assert(BLI_listbase_count(line_index_mask) == line_index_mask_len);
- /* OP byte + UInt32 count + counted UInt32 line numbers + UInt32 count + 12-bytes selection + OP byte */
+ /* OP byte + u32 count + counted u32 line numbers + u32 count + 12-bytes selection + OP byte. */
if (!max_undo_test(utxt, 2 + 4 + (line_index_mask_len * 4) + 4 + 12 + 1)) {
return;
}
@@ -2234,8 +2365,9 @@ void txt_do_undo(Text *text, TextUndoBuf *utxt)
prev_flags = text->flags;
text->flags &= ~TXT_TABSTOSPACES;
- for (i = 0; i < linep; i++)
+ for (i = 0; i < linep; i++) {
txt_move_right(text, 1);
+ }
text->flags = prev_flags;
}
@@ -2316,7 +2448,7 @@ void txt_do_undo(Text *text, TextUndoBuf *utxt)
break;
}
default:
- //XXX error("Undo buffer error - resetting");
+ // XXX error("Undo buffer error - resetting");
utxt->pos = -1;
break;
@@ -2508,7 +2640,7 @@ void txt_do_redo(Text *text, TextUndoBuf *utxt)
break;
}
default:
- //XXX error("Undo buffer error - resetting");
+ // XXX error("Undo buffer error - resetting");
utxt->pos = -1;
break;
@@ -2526,27 +2658,31 @@ void txt_split_curline(Text *text, TextUndoBuf *utxt)
TextLine *ins;
char *left, *right;
- if (!text->curl)
+ if (!text->curl) {
return;
+ }
txt_delete_sel(text, utxt);
- if (!undoing)
+ if (!undoing) {
txt_undo_add_charop(text, utxt, UNDO_INSERT_1, '\n');
+ }
/* Make the two half strings */
left = MEM_mallocN(text->curc + 1, "textline_string");
- if (text->curc)
+ if (text->curc) {
memcpy(left, text->curl->line, text->curc);
+ }
left[text->curc] = 0;
right = MEM_mallocN(text->curl->len - text->curc + 1, "textline_string");
memcpy(right, text->curl->line + text->curc, text->curl->len - text->curc + 1);
MEM_freeN(text->curl->line);
- if (text->curl->format)
+ if (text->curl->format) {
MEM_freeN(text->curl->format);
+ }
/* Make the new TextLine */
@@ -2571,15 +2707,18 @@ void txt_split_curline(Text *text, TextUndoBuf *utxt)
static void txt_delete_line(Text *text, TextLine *line)
{
- if (!text->curl)
+ if (!text->curl) {
return;
+ }
BLI_remlink(&text->lines, line);
- if (line->line)
+ if (line->line) {
MEM_freeN(line->line);
- if (line->format)
+ }
+ if (line->format) {
MEM_freeN(line->format);
+ }
MEM_freeN(line);
@@ -2591,8 +2730,9 @@ static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb)
{
char *tmp, *s;
- if (!linea || !lineb)
+ if (!linea || !lineb) {
return;
+ }
tmp = MEM_mallocN(linea->len + lineb->len + 1, "textline_string");
@@ -2613,8 +2753,9 @@ void txt_duplicate_line(Text *text, TextUndoBuf *utxt)
{
TextLine *textline;
- if (!text->curl)
+ if (!text->curl) {
return;
+ }
if (text->curl == text->sell) {
textline = txt_new_line(text->curl->line);
@@ -2623,8 +2764,9 @@ void txt_duplicate_line(Text *text, TextUndoBuf *utxt)
txt_make_dirty(text);
txt_clean_text(text);
- if (!undoing)
+ if (!undoing) {
txt_undo_add_op(text, utxt, UNDO_DUPLICATE);
+ }
}
}
@@ -2632,8 +2774,9 @@ void txt_delete_char(Text *text, TextUndoBuf *utxt)
{
unsigned int c = '\n';
- if (!text->curl)
+ if (!text->curl) {
return;
+ }
if (txt_has_sel(text)) { /* deleting a selection */
txt_delete_sel(text, utxt);
@@ -2645,8 +2788,9 @@ void txt_delete_char(Text *text, TextUndoBuf *utxt)
txt_combine_lines(text, text->curl, text->curl->next);
txt_pop_sel(text);
}
- else
+ else {
return;
+ }
}
else { /* Just deleting a char */
size_t c_len = 0;
@@ -2664,8 +2808,9 @@ void txt_delete_char(Text *text, TextUndoBuf *utxt)
txt_make_dirty(text);
txt_clean_text(text);
- if (!undoing)
+ if (!undoing) {
txt_undo_add_charop(text, utxt, UNDO_DEL_1, c);
+ }
}
void txt_delete_word(Text *text, TextUndoBuf *utxt)
@@ -2679,8 +2824,9 @@ void txt_backspace_char(Text *text, TextUndoBuf *utxt)
{
unsigned int c = '\n';
- if (!text->curl)
+ if (!text->curl) {
return;
+ }
if (txt_has_sel(text)) { /* deleting a selection */
txt_delete_sel(text, utxt);
@@ -2688,8 +2834,9 @@ void txt_backspace_char(Text *text, TextUndoBuf *utxt)
return;
}
else if (text->curc == 0) { /* Appending two lines */
- if (!text->curl->prev)
+ if (!text->curl->prev) {
return;
+ }
text->curl = text->curl->prev;
text->curc = text->curl->len;
@@ -2716,8 +2863,9 @@ void txt_backspace_char(Text *text, TextUndoBuf *utxt)
txt_make_dirty(text);
txt_clean_text(text);
- if (!undoing)
+ if (!undoing) {
txt_undo_add_charop(text, utxt, UNDO_BS_1, c);
+ }
}
void txt_backspace_word(Text *text, TextUndoBuf *utxt)
@@ -2747,8 +2895,9 @@ static bool txt_add_char_intern(Text *text, TextUndoBuf *utxt, unsigned int add,
char *tmp, ch[BLI_UTF8_MAX];
size_t add_len;
- if (!text->curl)
+ if (!text->curl) {
return 0;
+ }
if (add == '\n') {
txt_split_curline(text, utxt);
@@ -2763,8 +2912,9 @@ static bool txt_add_char_intern(Text *text, TextUndoBuf *utxt, unsigned int add,
txt_delete_sel(text, utxt);
- if (!undoing)
+ if (!undoing) {
txt_undo_add_charop(text, utxt, UNDO_INSERT_1, add);
+ }
add_len = BLI_str_utf8_from_unicode(add, ch);
@@ -2809,8 +2959,9 @@ bool txt_replace_char(Text *text, TextUndoBuf *utxt, unsigned int add)
size_t del_size = 0, add_size;
char ch[BLI_UTF8_MAX];
- if (!text->curl)
+ if (!text->curl) {
return false;
+ }
/* If text is selected or we're at the end of the line just use txt_add_char */
if (text->curc == text->curl->len || txt_has_sel(text) || add == '\n') {
@@ -2880,13 +3031,15 @@ static void txt_select_prefix(Text *text, const char *add)
tmp = MEM_mallocN(text->curl->len + indentlen + 1, "textline_string");
text->curc = 0;
- if (text->curc)
+ if (text->curc) {
memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */
+ }
memcpy(tmp + text->curc, add, indentlen);
len = text->curl->len - text->curc;
- if (len > 0)
+ if (len > 0) {
memcpy(tmp + text->curc + indentlen, text->curl->line + text->curc, len);
+ }
tmp[text->curl->len + indentlen] = 0;
make_new_line(text->curl, tmp);
@@ -2906,10 +3059,12 @@ static void txt_select_prefix(Text *text, const char *add)
num++;
}
}
- if (!curc_old)
+ if (!curc_old) {
text->curc = 0;
- else
+ }
+ else {
text->curc = curc_old + indentlen;
+ }
while (num > 0) {
text->curl = text->curl->prev;
@@ -2950,8 +3105,9 @@ static void txt_select_unprefix(Text *text,
while (true) {
bool changed = false;
if (STREQLEN(text->curl->line, remove, indentlen)) {
- if (num == 0)
+ if (num == 0) {
unindented_first = true;
+ }
text->curl->len -= indentlen;
memmove(text->curl->line, text->curl->line + indentlen, text->curl->len + 1);
changed = true;
@@ -2971,8 +3127,9 @@ static void txt_select_unprefix(Text *text,
txt_clean_text(text);
if (text->curl == text->sell) {
- if (changed)
+ if (changed) {
text->selc = MAX2(text->selc - indentlen, 0);
+ }
break;
}
else {
@@ -2981,8 +3138,9 @@ static void txt_select_unprefix(Text *text,
}
}
- if (unindented_first)
+ if (unindented_first) {
text->curc = MAX2(text->curc - indentlen, 0);
+ }
while (num > 0) {
text->curl = text->curl->prev;
@@ -3066,15 +3224,17 @@ void txt_move_lines(struct Text *text, TextUndoBuf *utxt, const int direction)
BLI_assert(ELEM(direction, TXT_MOVE_LINE_UP, TXT_MOVE_LINE_DOWN));
- if (!text->curl || !text->sell)
+ if (!text->curl || !text->sell) {
return;
+ }
txt_order_cursors(text, false);
line_other = (direction == TXT_MOVE_LINE_DOWN) ? text->sell->next : text->curl->prev;
- if (!line_other)
+ if (!line_other) {
return;
+ }
BLI_remlink(&text->lines, line_other);
@@ -3103,11 +3263,12 @@ int txt_setcurr_tab_spaces(Text *text, int space)
const char indent = (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t';
static const char *back_words[] = {"return", "break", "continue", "pass", "yield", NULL};
- if (!text->curl)
+ if (!text->curl) {
return 0;
+ }
while (text->curl->line[i] == indent) {
- //we only count those tabs/spaces that are before any text or before the curs;
+ // we only count those tabs/spaces that are before any text or before the curs;
if (i == text->curc) {
return i;
}
@@ -3162,65 +3323,82 @@ int text_check_bracket(const char ch)
char close[] = ")]}";
for (a = 0; a < (sizeof(opens) - 1); a++) {
- if (ch == opens[a])
+ if (ch == opens[a]) {
return a + 1;
- else if (ch == close[a])
+ }
+ else if (ch == close[a]) {
return -(a + 1);
+ }
}
return 0;
}
-/* TODO, have a function for operators - http://docs.python.org/py3k/reference/lexical_analysis.html#operators */
+/* TODO, have a function for operators -
+ * http://docs.python.org/py3k/reference/lexical_analysis.html#operators */
bool text_check_delim(const char ch)
{
int a;
char delims[] = "():\"\' ~!%^&*-+=[]{};/<>|.#\t,@";
for (a = 0; a < (sizeof(delims) - 1); a++) {
- if (ch == delims[a])
+ if (ch == delims[a]) {
return true;
+ }
}
return false;
}
bool text_check_digit(const char ch)
{
- if (ch < '0')
+ if (ch < '0') {
return false;
- if (ch <= '9')
+ }
+ if (ch <= '9') {
return true;
+ }
return false;
}
bool text_check_identifier(const char ch)
{
- if (ch < '0')
+ if (ch < '0') {
return false;
- if (ch <= '9')
+ }
+ if (ch <= '9') {
return true;
- if (ch < 'A')
+ }
+ if (ch < 'A') {
return false;
- if (ch <= 'Z' || ch == '_')
+ }
+ if (ch <= 'Z' || ch == '_') {
return true;
- if (ch < 'a')
+ }
+ if (ch < 'a') {
return false;
- if (ch <= 'z')
+ }
+ if (ch <= 'z') {
return true;
+ }
return false;
}
bool text_check_identifier_nodigit(const char ch)
{
- if (ch <= '9')
+ if (ch <= '9') {
return false;
- if (ch < 'A')
+ }
+ if (ch < 'A') {
return false;
- if (ch <= 'Z' || ch == '_')
+ }
+ if (ch <= 'Z' || ch == '_') {
return true;
- if (ch < 'a')
+ }
+ if (ch < 'a') {
return false;
- if (ch <= 'z')
+ }
+ if (ch <= 'z') {
return true;
+ }
return false;
}
@@ -3238,8 +3416,9 @@ int text_check_identifier_nodigit_unicode(const unsigned int ch)
bool text_check_whitespace(const char ch)
{
- if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')
+ if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') {
return true;
+ }
return false;
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index dbbb231a18b..9baa8bd20e1 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -101,24 +101,30 @@ void BKE_texture_mapping_init(TexMapping *texmap)
zero_m4(proj);
proj[3][3] = 1.0f;
- if (texmap->projx != PROJ_N)
+ if (texmap->projx != PROJ_N) {
proj[texmap->projx - 1][0] = 1.0f;
- if (texmap->projy != PROJ_N)
+ }
+ if (texmap->projy != PROJ_N) {
proj[texmap->projy - 1][1] = 1.0f;
- if (texmap->projz != PROJ_N)
+ }
+ if (texmap->projz != PROJ_N) {
proj[texmap->projz - 1][2] = 1.0f;
+ }
/* scale */
copy_v3_v3(size, texmap->size);
if (ELEM(texmap->type, TEXMAP_TYPE_TEXTURE, TEXMAP_TYPE_NORMAL)) {
/* keep matrix invertible */
- if (fabsf(size[0]) < 1e-5f)
+ if (fabsf(size[0]) < 1e-5f) {
size[0] = signf(size[0]) * 1e-5f;
- if (fabsf(size[1]) < 1e-5f)
+ }
+ if (fabsf(size[1]) < 1e-5f) {
size[1] = signf(size[1]) * 1e-5f;
- if (fabsf(size[2]) < 1e-5f)
+ }
+ if (fabsf(size[2]) < 1e-5f) {
size[2] = signf(size[2]) * 1e-5f;
+ }
}
size_to_mat4(smat, texmap->size);
@@ -208,7 +214,8 @@ void BKE_texture_free(Tex *tex)
void BKE_texture_default(Tex *tex)
{
- /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); */ /* Not here, can be called with some pointers set. :/ */
+ /* Not here, can be called with some pointers set. :/ */
+ /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); */
tex->type = TEX_IMAGE;
tex->ima = NULL;
@@ -254,9 +261,7 @@ void BKE_texture_default(Tex *tex)
tex->vn_distm = 0;
tex->vn_coltype = 0;
- tex->iuser.ok = 1;
- tex->iuser.frames = 100;
- tex->iuser.sfra = 1;
+ BKE_imageuser_default(&tex->iuser);
tex->preview = NULL;
}
@@ -407,8 +412,10 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot)
/* ------------------------------------------------------------------------- */
/**
- * Only copy internal data of Texture ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Texture ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -466,8 +473,9 @@ Tex *BKE_texture_localize(Tex *tex)
/* image texture: BKE_texture_free also doesn't decrease */
- if (texn->coba)
+ if (texn->coba) {
texn->coba = MEM_dupallocN(texn->coba);
+ }
texn->preview = NULL;
@@ -494,8 +502,9 @@ Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle)
if (linestyle) {
mtex = linestyle->mtex[(int)(linestyle->texact)];
- if (mtex)
+ if (mtex) {
tex = mtex->tex;
+ }
}
return tex;
@@ -505,8 +514,9 @@ void set_current_linestyle_texture(FreestyleLineStyle *linestyle, Tex *newtex)
{
int act = linestyle->texact;
- if (linestyle->mtex[act] && linestyle->mtex[act]->tex)
+ if (linestyle->mtex[act] && linestyle->mtex[act]->tex) {
id_us_min(&linestyle->mtex[act]->tex->id);
+ }
if (newtex) {
if (!linestyle->mtex[act]) {
@@ -528,18 +538,21 @@ bool give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
switch (GS(id->name)) {
case ID_LS:
*mtex_ar = ((FreestyleLineStyle *)id)->mtex;
- if (act)
+ if (act) {
*act = (((FreestyleLineStyle *)id)->texact);
+ }
break;
case ID_PA:
*mtex_ar = ((ParticleSettings *)id)->mtex;
- if (act)
+ if (act) {
*act = (((ParticleSettings *)id)->texact);
+ }
break;
default:
*mtex_ar = NULL;
- if (act)
+ if (act) {
*act = 0;
+ }
return false;
}
@@ -548,10 +561,12 @@ bool give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
void set_active_mtex(ID *id, short act)
{
- if (act < 0)
+ if (act < 0) {
act = 0;
- else if (act >= MAX_MTEX)
+ }
+ else if (act >= MAX_MTEX) {
act = MAX_MTEX - 1;
+ }
switch (GS(id->name)) {
case ID_LS:
@@ -572,8 +587,9 @@ Tex *give_current_brush_texture(Brush *br)
void set_current_brush_texture(Brush *br, Tex *newtex)
{
- if (br->mtex.tex)
+ if (br->mtex.tex) {
id_us_min(&br->mtex.tex->id);
+ }
if (newtex) {
br->mtex.tex = newtex;
@@ -586,12 +602,14 @@ Tex *give_current_particle_texture(ParticleSettings *part)
MTex *mtex = NULL;
Tex *tex = NULL;
- if (!part)
+ if (!part) {
return NULL;
+ }
mtex = part->mtex[(int)(part->texact)];
- if (mtex)
+ if (mtex) {
tex = mtex->tex;
+ }
return tex;
}
@@ -600,8 +618,9 @@ void set_current_particle_texture(ParticleSettings *part, Tex *newtex)
{
int act = part->texact;
- if (part->mtex[act] && part->mtex[act]->tex)
+ if (part->mtex[act] && part->mtex[act]->tex) {
id_us_min(&part->mtex[act]->tex->id);
+ }
if (newtex) {
if (!part->mtex[act]) {
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index c478ce274b8..a5445be7ce5 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -108,8 +108,9 @@ static void tracking_plane_tracks_free(ListBase *plane_tracks)
*/
static void tracking_reconstruction_free(MovieTrackingReconstruction *reconstruction)
{
- if (reconstruction->cameras)
+ if (reconstruction->cameras) {
MEM_freeN(reconstruction->cameras);
+ }
}
/* Free memory used by tracking object, only frees contents of the structure,
@@ -130,8 +131,9 @@ static void tracking_objects_free(ListBase *objects)
MovieTrackingObject *object;
/* Free objects contents. */
- for (object = objects->first; object; object = object->next)
+ for (object = objects->first; object; object = object->next) {
tracking_object_free(object);
+ }
/* Free objects themselves. */
BLI_freelistN(objects);
@@ -176,8 +178,9 @@ void BKE_tracking_free(MovieTracking *tracking)
tracking_reconstruction_free(&tracking->reconstruction);
tracking_objects_free(&tracking->objects);
- if (tracking->camera.intrinsics)
+ if (tracking->camera.intrinsics) {
BKE_tracking_distortion_free(tracking->camera.intrinsics);
+ }
tracking_dopesheet_free(&tracking->dopesheet);
}
@@ -206,7 +209,8 @@ static void tracking_tracks_copy(ListBase *tracks_dst,
}
}
-/* copy the whole list of plane tracks (need whole MovieTracking structures due to embedded pointers to tracks).
+/* Copy the whole list of plane tracks
+ * (need whole MovieTracking structures due to embedded pointers to tracks).
* WARNING: implies tracking_[dst/src] and their tracks have already been copied. */
static void tracking_plane_tracks_copy(ListBase *plane_tracks_list_dst,
const ListBase *plane_tracks_list_src,
@@ -318,7 +322,8 @@ void BKE_tracking_copy(MovieTracking *tracking_dst,
/* Warning! Will override tracks_mapping. */
tracking_objects_copy(&tracking_dst->objects, &tracking_src->objects, tracks_mapping, flag);
- /* Those remaining are runtime data, they will be reconstructed as needed, do not bother copying them. */
+ /* Those remaining are runtime data, they will be reconstructed as needed,
+ * do not bother copying them. */
tracking_dst->dopesheet.ok = false;
BLI_listbase_clear(&tracking_dst->dopesheet.channels);
BLI_listbase_clear(&tracking_dst->dopesheet.coverage_segments);
@@ -406,16 +411,20 @@ MovieTrackingReconstruction *BKE_tracking_get_active_reconstruction(MovieTrackin
void BKE_tracking_get_camera_object_matrix(Scene *scene, Object *ob, float mat[4][4])
{
if (!ob) {
- if (scene->camera)
+ if (scene->camera) {
ob = scene->camera;
- else
+ }
+ else {
ob = BKE_view_layer_camera_find(BKE_view_layer_context_active_PLACEHOLDER(scene));
+ }
}
- if (ob)
+ if (ob) {
BKE_object_where_is_calc_mat4(ob, mat);
- else
+ }
+ else {
unit_m4(mat);
+ }
}
/* Get projection matrix for camera specified by given tracking object
@@ -442,10 +451,12 @@ void BKE_tracking_get_projection_matrix(MovieTracking *tracking,
clipsta = 0.1f;
clipend = 1000.0f;
- if (winx >= winy)
+ if (winx >= winy) {
viewfac = (lens * winx) / tracking->camera.sensor_width;
- else
+ }
+ else {
viewfac = (ycor * lens * winy) / tracking->camera.sensor_width;
+ }
pixsize = clipsta / viewfac;
@@ -656,8 +667,9 @@ void BKE_tracking_track_unique_name(ListBase *tracksbase, MovieTrackingTrack *tr
*/
void BKE_tracking_track_free(MovieTrackingTrack *track)
{
- if (track->markers)
+ if (track->markers) {
MEM_freeN(track->markers);
+ }
}
/* Set flag for all specified track's areas.
@@ -667,15 +679,19 @@ void BKE_tracking_track_free(MovieTrackingTrack *track)
*/
void BKE_tracking_track_flag_set(MovieTrackingTrack *track, int area, int flag)
{
- if (area == TRACK_AREA_NONE)
+ if (area == TRACK_AREA_NONE) {
return;
+ }
- if (area & TRACK_AREA_POINT)
+ if (area & TRACK_AREA_POINT) {
track->flag |= flag;
- if (area & TRACK_AREA_PAT)
+ }
+ if (area & TRACK_AREA_PAT) {
track->pat_flag |= flag;
- if (area & TRACK_AREA_SEARCH)
+ }
+ if (area & TRACK_AREA_SEARCH) {
track->search_flag |= flag;
+ }
}
/* Clear flag from all specified track's areas.
@@ -685,15 +701,19 @@ void BKE_tracking_track_flag_set(MovieTrackingTrack *track, int area, int flag)
*/
void BKE_tracking_track_flag_clear(MovieTrackingTrack *track, int area, int flag)
{
- if (area == TRACK_AREA_NONE)
+ if (area == TRACK_AREA_NONE) {
return;
+ }
- if (area & TRACK_AREA_POINT)
+ if (area & TRACK_AREA_POINT) {
track->flag &= ~flag;
- if (area & TRACK_AREA_PAT)
+ }
+ if (area & TRACK_AREA_PAT) {
track->pat_flag &= ~flag;
- if (area & TRACK_AREA_SEARCH)
+ }
+ if (area & TRACK_AREA_SEARCH) {
track->search_flag &= ~flag;
+ }
}
/* Check whether track has got marker at specified frame.
@@ -747,8 +767,9 @@ void BKE_tracking_track_path_clear(MovieTrackingTrack *track, int ref_frame, int
a++;
}
- if (track->markersnr)
+ if (track->markersnr) {
tracking_marker_insert_disabled(track, &track->markers[track->markersnr - 1], false, true);
+ }
}
else if (action == TRACK_CLEAR_UPTO) {
a = track->markersnr - 1;
@@ -769,8 +790,9 @@ void BKE_tracking_track_path_clear(MovieTrackingTrack *track, int ref_frame, int
a--;
}
- if (track->markersnr)
+ if (track->markersnr) {
tracking_marker_insert_disabled(track, &track->markers[0], true, true);
+ }
}
else if (action == TRACK_CLEAR_ALL) {
MovieTrackingMarker *marker, marker_new;
@@ -832,11 +854,13 @@ void BKE_tracking_tracks_join(MovieTracking *tracking,
marker_a = &src_track->markers[a];
marker_b = &dst_track->markers[b];
- if (marker_a->flag & MARKER_DISABLED || marker_b->flag & MARKER_DISABLED)
+ if (marker_a->flag & MARKER_DISABLED || marker_b->flag & MARKER_DISABLED) {
break;
+ }
- if (marker_a->framenr != frame || marker_b->framenr != frame)
+ if (marker_a->framenr != frame || marker_b->framenr != frame) {
break;
+ }
frame++;
len++;
@@ -851,11 +875,13 @@ void BKE_tracking_tracks_join(MovieTracking *tracking,
for (j = 0; j < len; j++) {
float fac = 0.5f;
- if (len > 1)
+ if (len > 1) {
fac = 1.0f / (len - 1) * j;
+ }
- if (inverse)
+ if (inverse) {
fac = 1.0f - fac;
+ }
marker_a = &src_track->markers[a];
marker_b = &dst_track->markers[b];
@@ -907,8 +933,9 @@ MovieTrackingTrack *BKE_tracking_track_get_named(MovieTracking *tracking,
MovieTrackingTrack *track = tracksbase->first;
while (track) {
- if (STREQ(track->name, name))
+ if (STREQ(track->name, name)) {
return track;
+ }
track = track->next;
}
@@ -953,14 +980,16 @@ MovieTrackingTrack *BKE_tracking_track_get_active(MovieTracking *tracking)
{
ListBase *tracksbase;
- if (!tracking->act_track)
+ if (!tracking->act_track) {
return NULL;
+ }
tracksbase = BKE_tracking_get_active_tracks(tracking);
/* check that active track is in current tracks list */
- if (BLI_findindex(tracksbase, tracking->act_track) != -1)
+ if (BLI_findindex(tracksbase, tracking->act_track) != -1) {
return tracking->act_track;
+ }
return NULL;
}
@@ -969,8 +998,9 @@ static bGPDlayer *track_mask_gpencil_layer_get(MovieTrackingTrack *track)
{
bGPDlayer *layer;
- if (!track->gpd)
+ if (!track->gpd) {
return NULL;
+ }
layer = track->gpd->layers.first;
@@ -988,8 +1018,9 @@ static bGPDlayer *track_mask_gpencil_layer_get(MovieTrackingTrack *track)
frame = frame->next;
}
- if (ok)
+ if (ok) {
return layer;
+ }
}
layer = layer->next;
@@ -1084,10 +1115,14 @@ float *BKE_tracking_track_get_mask(int frame_width,
MovieTrackingMarker *marker)
{
/* Convert normalized space marker's search area to pixel-space region. */
- const float region_min[2] = {marker->search_min[0] * frame_width,
- marker->search_min[1] * frame_height};
- const float region_max[2] = {marker->search_max[0] * frame_width,
- marker->search_max[1] * frame_height};
+ const float region_min[2] = {
+ marker->search_min[0] * frame_width,
+ marker->search_min[1] * frame_height,
+ };
+ const float region_max[2] = {
+ marker->search_max[0] * frame_width,
+ marker->search_max[1] * frame_height,
+ };
return tracking_track_get_mask_for_region(
frame_width, frame_height, region_min, region_max, track);
}
@@ -1161,8 +1196,9 @@ MovieTrackingMarker *BKE_tracking_marker_insert(MovieTrackingTrack *track,
{
MovieTrackingMarker *old_marker = NULL;
- if (track->markersnr)
+ if (track->markersnr) {
old_marker = BKE_tracking_marker_get_exact(track, marker->framenr);
+ }
if (old_marker) {
/* simply replace settings for already allocated marker */
@@ -1175,17 +1211,20 @@ MovieTrackingMarker *BKE_tracking_marker_insert(MovieTrackingTrack *track,
/* find position in array where to add new marker */
while (a--) {
- if (track->markers[a].framenr < marker->framenr)
+ if (track->markers[a].framenr < marker->framenr) {
break;
+ }
}
track->markersnr++;
- if (track->markers)
+ if (track->markers) {
track->markers = MEM_reallocN(track->markers,
sizeof(MovieTrackingMarker) * track->markersnr);
- else
+ }
+ else {
track->markers = MEM_callocN(sizeof(MovieTrackingMarker), "MovieTracking markers");
+ }
/* shift array to "free" space for new marker */
memmove(track->markers + a + 2,
@@ -1251,12 +1290,14 @@ void BKE_tracking_marker_clamp(MovieTrackingMarker *marker, int event)
int b;
/* pattern shouldn't be moved outside of search */
if (pat_min[a] < marker->search_min[a]) {
- for (b = 0; b < 4; b++)
+ for (b = 0; b < 4; b++) {
marker->pattern_corners[b][a] += marker->search_min[a] - pat_min[a];
+ }
}
if (pat_max[a] > marker->search_max[a]) {
- for (b = 0; b < 4; b++)
+ for (b = 0; b < 4; b++) {
marker->pattern_corners[b][a] -= pat_max[a] - marker->search_max[a];
+ }
}
}
}
@@ -1290,15 +1331,18 @@ MovieTrackingMarker *BKE_tracking_marker_get(MovieTrackingTrack *track, int fram
{
int a = track->markersnr - 1;
- if (!track->markersnr)
+ if (!track->markersnr) {
return NULL;
+ }
/* approximate pre-first framenr marker with first marker */
- if (framenr < track->markers[0].framenr)
+ if (framenr < track->markers[0].framenr) {
return &track->markers[0];
+ }
- if (track->last_marker < track->markersnr)
+ if (track->last_marker < track->markersnr) {
a = track->last_marker;
+ }
if (track->markers[a].framenr <= framenr) {
while (a < track->markersnr && track->markers[a].framenr <= framenr) {
@@ -1335,8 +1379,9 @@ MovieTrackingMarker *BKE_tracking_marker_get_exact(MovieTrackingTrack *track, in
{
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
- if (marker->framenr != framenr)
+ if (marker->framenr != framenr) {
return NULL;
+ }
return marker;
}
@@ -1633,8 +1678,9 @@ MovieTrackingPlaneMarker *BKE_tracking_plane_marker_insert(MovieTrackingPlaneTra
{
MovieTrackingPlaneMarker *old_plane_marker = NULL;
- if (plane_track->markersnr)
+ if (plane_track->markersnr) {
old_plane_marker = BKE_tracking_plane_marker_get_exact(plane_track, plane_marker->framenr);
+ }
if (old_plane_marker) {
/* Simply replace settings in existing marker. */
@@ -1709,8 +1755,9 @@ MovieTrackingPlaneMarker *BKE_tracking_plane_marker_get(MovieTrackingPlaneTrack
{
int a = plane_track->markersnr - 1;
- if (!plane_track->markersnr)
+ if (!plane_track->markersnr) {
return NULL;
+ }
/* Approximate pre-first framenr marker with first marker. */
if (framenr < plane_track->markers[0].framenr) {
@@ -1849,8 +1896,9 @@ bool BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *ob
MovieTrackingTrack *track;
int index = BLI_findindex(&tracking->objects, object);
- if (index == -1)
+ if (index == -1) {
return false;
+ }
if (object->flag & TRACKING_OBJECT_CAMERA) {
/* object used for camera solving can't be deleted */
@@ -1859,8 +1907,9 @@ bool BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *ob
track = object->tracks.first;
while (track) {
- if (track == tracking->act_track)
+ if (track == tracking->act_track) {
tracking->act_track = NULL;
+ }
track = track->next;
}
@@ -1870,10 +1919,12 @@ bool BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *ob
tracking->tot_object--;
- if (index != 0)
+ if (index != 0) {
tracking->objectnr = index - 1;
- else
+ }
+ else {
tracking->objectnr = 0;
+ }
BKE_tracking_dopesheet_tag_update(tracking);
@@ -1895,8 +1946,9 @@ MovieTrackingObject *BKE_tracking_object_get_named(MovieTracking *tracking, cons
MovieTrackingObject *object = tracking->objects.first;
while (object) {
- if (STREQ(object->name, name))
+ if (STREQ(object->name, name)) {
return object;
+ }
object = object->next;
}
@@ -1914,8 +1966,9 @@ MovieTrackingObject *BKE_tracking_object_get_camera(MovieTracking *tracking)
MovieTrackingObject *object = tracking->objects.first;
while (object) {
- if (object->flag & TRACKING_OBJECT_CAMERA)
+ if (object->flag & TRACKING_OBJECT_CAMERA) {
return object;
+ }
object = object->next;
}
@@ -1961,28 +2014,35 @@ static int reconstructed_camera_index_get(MovieTrackingReconstruction *reconstru
MovieReconstructedCamera *cameras = reconstruction->cameras;
int a = 0, d = 1;
- if (!reconstruction->camnr)
+ if (!reconstruction->camnr) {
return -1;
+ }
if (framenr < cameras[0].framenr) {
- if (nearest)
+ if (nearest) {
return 0;
- else
+ }
+ else {
return -1;
+ }
}
if (framenr > cameras[reconstruction->camnr - 1].framenr) {
- if (nearest)
+ if (nearest) {
return reconstruction->camnr - 1;
- else
+ }
+ else {
return -1;
+ }
}
- if (reconstruction->last_camera < reconstruction->camnr)
+ if (reconstruction->last_camera < reconstruction->camnr) {
a = reconstruction->last_camera;
+ }
- if (cameras[a].framenr >= framenr)
+ if (cameras[a].framenr >= framenr) {
d = -1;
+ }
while (a >= 0 && a < reconstruction->camnr) {
int cfra = cameras[a].framenr;
@@ -1991,18 +2051,22 @@ static int reconstructed_camera_index_get(MovieTrackingReconstruction *reconstru
if (d > 0 && cfra > framenr) {
/* interpolate with previous position */
- if (nearest)
+ if (nearest) {
return a - 1;
- else
+ }
+ else {
break;
+ }
}
if (d < 0 && cfra < framenr) {
/* interpolate with next position */
- if (nearest)
+ if (nearest) {
return a;
- else
+ }
+ else {
break;
+ }
}
if (cfra == framenr) {
@@ -2031,7 +2095,8 @@ static void reconstructed_camera_scale_set(MovieTrackingObject *object, float ma
void BKE_tracking_camera_shift_get(
MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty)
{
- /* indeed in both of cases it should be winx -- it's just how camera shift works for blender's camera */
+ /* Indeed in both of cases it should be winx -
+ * it's just how camera shift works for blender's camera. */
*shiftx = (0.5f * winx - tracking->camera.principal[0]) / winx;
*shifty = (0.5f * winy - tracking->camera.principal[1]) / winx;
}
@@ -2064,8 +2129,9 @@ MovieReconstructedCamera *BKE_tracking_camera_get_reconstructed(MovieTracking *t
reconstruction = BKE_tracking_object_get_reconstruction(tracking, object);
a = reconstructed_camera_index_get(reconstruction, framenr, false);
- if (a == -1)
+ if (a == -1) {
return NULL;
+ }
return &reconstruction->cameras[a];
}
@@ -2191,8 +2257,9 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion,
resibuf->rect_float);
}
- if (ibuf->rect)
+ if (ibuf->rect) {
imb_freerectImBuf(ibuf);
+ }
}
else {
if (undistort) {
@@ -2347,8 +2414,9 @@ void BKE_tracking_max_distortion_delta_across_bound(MovieTracking *tracking,
delta[0] = delta[1] = -FLT_MAX;
for (a = rect->xmin; a <= rect->xmax + coord_delta; a += coord_delta) {
- if (a > rect->xmax)
+ if (a > rect->xmax) {
a = rect->xmax;
+ }
/* bottom edge */
pos[0] = a;
@@ -2368,13 +2436,15 @@ void BKE_tracking_max_distortion_delta_across_bound(MovieTracking *tracking,
delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
- if (a >= rect->xmax)
+ if (a >= rect->xmax) {
break;
+ }
}
for (a = rect->ymin; a <= rect->ymax + coord_delta; a += coord_delta) {
- if (a > rect->ymax)
+ if (a > rect->ymax) {
a = rect->ymax;
+ }
/* left edge */
pos[0] = rect->xmin;
@@ -2394,8 +2464,9 @@ void BKE_tracking_max_distortion_delta_across_bound(MovieTracking *tracking,
delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
- if (a >= rect->ymax)
+ if (a >= rect->ymax) {
break;
+ }
}
}
@@ -2426,8 +2497,9 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width,
double warped_position_x, warped_position_y;
float *mask = NULL;
- if (num_samples_x <= 0 || num_samples_y <= 0)
+ if (num_samples_x <= 0 || num_samples_y <= 0) {
return NULL;
+ }
pattern_ibuf = IMB_allocImBuf(
num_samples_x, num_samples_y, 32, search_ibuf->rect_float ? IB_rectfloat : IB_rect);
@@ -2452,10 +2524,12 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width,
((int)(track->offset[1] * frame_height)));
/* when offset is negative, rounding happens in opposite direction */
- if (track->offset[0] < 0.0f)
+ if (track->offset[0] < 0.0f) {
src_pixel_x[a] += 1.0;
- if (track->offset[1] < 0.0f)
+ }
+ if (track->offset[1] < 0.0f) {
src_pixel_y[a] += 1.0;
+ }
}
}
@@ -2565,8 +2639,9 @@ ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf,
w = (marker->search_max[0] - marker->search_min[0]) * ibuf->x;
h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y;
- if (w <= 0 || h <= 0)
+ if (w <= 0 || h <= 0) {
return NULL;
+ }
searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
@@ -2592,8 +2667,9 @@ void BKE_tracking_disable_channels(
int x, y;
float scale;
- if (!disable_red && !disable_green && !disable_blue && !grayscale)
+ if (!disable_red && !disable_green && !disable_blue && !grayscale) {
return;
+ }
/* if only some components are selected, it's important to rescale the result
* appropriately so that e.g. if only blue is selected, it's not zeroed out.
@@ -2642,8 +2718,9 @@ void BKE_tracking_disable_channels(
}
}
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
ibuf->userflags |= IB_RECT_INVALID;
+ }
}
/*********************** Dopesheet functions *************************/
@@ -2655,10 +2732,12 @@ static int channels_alpha_sort(const void *a, const void *b)
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
- if (BLI_strcasecmp(channel_a->track->name, channel_b->track->name) > 0)
+ if (BLI_strcasecmp(channel_a->track->name, channel_b->track->name) > 0) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static int channels_total_track_sort(const void *a, const void *b)
@@ -2666,10 +2745,12 @@ static int channels_total_track_sort(const void *a, const void *b)
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
- if (channel_a->total_frames > channel_b->total_frames)
+ if (channel_a->total_frames > channel_b->total_frames) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static int channels_longest_segment_sort(const void *a, const void *b)
@@ -2677,10 +2758,12 @@ static int channels_longest_segment_sort(const void *a, const void *b)
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
- if (channel_a->max_segment > channel_b->max_segment)
+ if (channel_a->max_segment > channel_b->max_segment) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static int channels_average_error_sort(const void *a, const void *b)
@@ -2688,34 +2771,42 @@ static int channels_average_error_sort(const void *a, const void *b)
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
- if (channel_a->track->error > channel_b->track->error)
+ if (channel_a->track->error > channel_b->track->error) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static int channels_alpha_inverse_sort(const void *a, const void *b)
{
- if (channels_alpha_sort(a, b))
+ if (channels_alpha_sort(a, b)) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
static int channels_total_track_inverse_sort(const void *a, const void *b)
{
- if (channels_total_track_sort(a, b))
+ if (channels_total_track_sort(a, b)) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
static int channels_longest_segment_inverse_sort(const void *a, const void *b)
{
- if (channels_longest_segment_sort(a, b))
+ if (channels_longest_segment_sort(a, b)) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
static int channels_average_error_inverse_sort(const void *a, const void *b)
@@ -2723,10 +2814,12 @@ static int channels_average_error_inverse_sort(const void *a, const void *b)
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
- if (channel_a->track->error < channel_b->track->error)
+ if (channel_a->track->error < channel_b->track->error) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
/* Calculate frames segments at which track is tracked continuously. */
@@ -2755,10 +2848,12 @@ static void tracking_dopesheet_channels_segments_calc(MovieTrackingDopesheetChan
while (i < track->markersnr) {
marker = &track->markers[i];
- if (marker->framenr != prev_fra + 1)
+ if (marker->framenr != prev_fra + 1) {
break;
- if (marker->flag & MARKER_DISABLED)
+ }
+ if (marker->flag & MARKER_DISABLED) {
break;
+ }
prev_fra = marker->framenr;
len++;
@@ -2771,8 +2866,9 @@ static void tracking_dopesheet_channels_segments_calc(MovieTrackingDopesheetChan
i++;
}
- if (!channel->tot_segment)
+ if (!channel->tot_segment) {
return;
+ }
channel->segments = MEM_callocN(2 * sizeof(int) * channel->tot_segment,
"tracking channel segments");
@@ -2791,10 +2887,12 @@ static void tracking_dopesheet_channels_segments_calc(MovieTrackingDopesheetChan
while (i < track->markersnr) {
marker = &track->markers[i];
- if (marker->framenr != prev_fra + 1)
+ if (marker->framenr != prev_fra + 1) {
break;
- if (marker->flag & MARKER_DISABLED)
+ }
+ if (marker->flag & MARKER_DISABLED) {
break;
+ }
prev_fra = marker->framenr;
channel->total_frames++;
@@ -2829,11 +2927,13 @@ static void tracking_dopesheet_channels_calc(MovieTracking *tracking)
for (track = tracksbase->first; track; track = track->next) {
MovieTrackingDopesheetChannel *channel;
- if (!show_hidden && (track->flag & TRACK_HIDDEN) != 0)
+ if (!show_hidden && (track->flag & TRACK_HIDDEN) != 0) {
continue;
+ }
- if (sel_only && !TRACK_SELECTED(track))
+ if (sel_only && !TRACK_SELECTED(track)) {
continue;
+ }
channel = MEM_callocN(sizeof(MovieTrackingDopesheetChannel), "tracking dopesheet channel");
channel->track = track;
@@ -2894,10 +2994,12 @@ static void tracking_dopesheet_channels_sort(MovieTracking *tracking,
static int coverage_from_count(int count)
{
/* Values are actually arbitrary here, probably need to be tweaked. */
- if (count < 8)
+ if (count < 8) {
return TRACKING_COVERAGE_BAD;
- else if (count < 16)
+ }
+ else if (count < 16) {
return TRACKING_COVERAGE_ACCEPTABLE;
+ }
return TRACKING_COVERAGE_OK;
}
@@ -2932,8 +3034,9 @@ static void tracking_dopesheet_calc_coverage(MovieTracking *tracking)
MovieTrackingMarker *marker = &track->markers[i];
/* TODO: perhaps we need to add check for non-single-frame track here */
- if ((marker->flag & MARKER_DISABLED) == 0)
+ if ((marker->flag & MARKER_DISABLED) == 0) {
per_frame_counter[marker->framenr - start_frame]++;
+ }
}
}
@@ -2942,22 +3045,25 @@ static void tracking_dopesheet_calc_coverage(MovieTracking *tracking)
last_segment_frame = start_frame;
/* means only disabled tracks in the beginning, could be ignored */
- if (!per_frame_counter[0])
+ if (!per_frame_counter[0]) {
prev_coverage = TRACKING_COVERAGE_OK;
+ }
for (int i = 1; i < frames; i++) {
int coverage = coverage_from_count(per_frame_counter[i]);
/* means only disabled tracks in the end, could be ignored */
- if (i == frames - 1 && !per_frame_counter[i])
+ if (i == frames - 1 && !per_frame_counter[i]) {
coverage = TRACKING_COVERAGE_OK;
+ }
if (coverage != prev_coverage || i == frames - 1) {
MovieTrackingDopesheetCoverageSegment *coverage_segment;
int end_segment_frame = i - 1 + start_frame;
- if (end_segment_frame == last_segment_frame)
+ if (end_segment_frame == last_segment_frame) {
end_segment_frame++;
+ }
coverage_segment = MEM_callocN(sizeof(MovieTrackingDopesheetCoverageSegment),
"tracking coverage segment");
@@ -2994,8 +3100,9 @@ void BKE_tracking_dopesheet_update(MovieTracking *tracking)
short sort_method = dopesheet->sort_method;
bool inverse = (dopesheet->flag & TRACKING_DOPE_SORT_INVERSE) != 0;
- if (dopesheet->ok)
+ if (dopesheet->ok) {
return;
+ }
tracking_dopesheet_free(dopesheet);
diff --git a/source/blender/blenkernel/intern/tracking_auto.c b/source/blender/blenkernel/intern/tracking_auto.c
index e93a5780b81..8a474725b0c 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -45,8 +45,7 @@ typedef struct AutoTrackOptions {
int clip_index; /** Index of the clip this track belogs to. */
int track_index; /* Index of the track in AutoTrack tracks structure. */
MovieTrackingTrack *track; /* Pointer to an original track/ */
- libmv_TrackRegionOptions track_region_options; /* Options for the region
- tracker. */
+ libmv_TrackRegionOptions track_region_options; /* Options for the region tracker. */
bool use_keyframe_match; /* Keyframe pattern matching. */
/* TODO(sergey): A bit awkward to keep it in here, only used to
diff --git a/source/blender/blenkernel/intern/tracking_detect.c b/source/blender/blenkernel/intern/tracking_detect.c
index 36d44f8fa5d..ec044f14fa8 100644
--- a/source/blender/blenkernel/intern/tracking_detect.c
+++ b/source/blender/blenkernel/intern/tracking_detect.c
@@ -56,8 +56,9 @@ static bool check_point_in_stroke(bGPDstroke *stroke, float x, float y)
if ((points[i].y < y && points[prev].y >= y) || (points[prev].y < y && points[i].y >= y)) {
float fac = (y - points[i].y) / (points[prev].y - points[i].y);
- if (points[i].x + fac * (points[prev].x - points[i].x) < x)
+ if (points[i].x + fac * (points[prev].x - points[i].x) < x) {
count++;
+ }
}
prev = i;
@@ -75,8 +76,9 @@ static bool check_point_in_layer(bGPDlayer *layer, float x, float y)
bGPDstroke *stroke = frame->strokes.first;
while (stroke) {
- if (check_point_in_stroke(stroke, x, y))
+ if (check_point_in_stroke(stroke, x, y)) {
return true;
+ }
stroke = stroke->next;
}
@@ -113,8 +115,9 @@ static void detect_retrieve_libmv_features(MovieTracking *tracking,
xu = (x + 0.5) / width;
yu = (y + 0.5) / height;
- if (layer)
+ if (layer) {
ok = check_point_in_layer(layer, xu, yu) != place_outside_layer;
+ }
if (ok) {
track = BKE_tracking_track_add(tracking, tracksbase, xu, yu, framenr, width, height);
diff --git a/source/blender/blenkernel/intern/tracking_region_tracker.c b/source/blender/blenkernel/intern/tracking_region_tracker.c
index a66a521783b..1d6bb88c3f4 100644
--- a/source/blender/blenkernel/intern/tracking_region_tracker.c
+++ b/source/blender/blenkernel/intern/tracking_region_tracker.c
@@ -200,10 +200,12 @@ void tracking_configure_tracker(const MovieTrackingTrack *track,
options->minimum_correlation = track->minimum_correlation;
options->sigma = 0.9;
- if ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_MASK) != 0)
+ if ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_MASK) != 0) {
options->image1_mask = mask;
- else
+ }
+ else {
options->image1_mask = NULL;
+ }
}
/* Perform tracking from a reference_marker to destination_ibuf.
@@ -250,14 +252,16 @@ static bool configure_and_run_tracker(ImBuf *destination_ibuf,
/* configure the tracker */
tracking_configure_tracker(track, mask, &options);
- /* convert the marker corners and center into pixel coordinates in the search/destination images. */
+ /* Convert the marker corners and center into pixel coordinates in the
+ * search/destination images. */
tracking_get_marker_coords_for_tracking(
frame_width, frame_height, reference_marker, src_pixel_x, src_pixel_y);
tracking_get_marker_coords_for_tracking(
frame_width, frame_height, marker, dst_pixel_x, dst_pixel_y);
- if (patch_new == NULL || reference_search_area == NULL)
+ if (patch_new == NULL || reference_search_area == NULL) {
return false;
+ }
/* run the tracker! */
tracked = libmv_trackRegion(&options,
@@ -289,10 +293,12 @@ static bool refine_marker_reference_frame_get(MovieTrackingTrack *track,
while (reference >= first_marker && reference <= last_marker &&
(reference->flag & MARKER_DISABLED) != 0) {
- if (backwards)
+ if (backwards) {
reference++;
- else
+ }
+ else {
reference--;
+ }
}
if (reference < first_marker || reference > last_marker) {
@@ -357,8 +363,9 @@ void BKE_tracking_refine_marker(MovieClip *clip,
reference_ibuf, track, reference_marker, &search_area_width, &search_area_height);
/* If needed, compute track's mask. */
- if ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_MASK) != 0)
+ if ((track->algorithm_flag & TRACK_ALGORITHM_FLAG_USE_MASK) != 0) {
mask = BKE_tracking_track_get_mask(frame_width, frame_height, track, marker);
+ }
/* Run the tracker from reference frame to current one. */
tracked = configure_and_run_tracker(destination_ibuf,
@@ -381,8 +388,9 @@ void BKE_tracking_refine_marker(MovieClip *clip,
/* Free memory used for refining */
MEM_freeN(search_area);
- if (mask)
+ if (mask) {
MEM_freeN(mask);
+ }
IMB_freeImBuf(reference_ibuf);
IMB_freeImBuf(destination_ibuf);
}
diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c
index c3759fd01bb..cfa41cb7d92 100644
--- a/source/blender/blenkernel/intern/tracking_solver.c
+++ b/source/blender/blenkernel/intern/tracking_solver.c
@@ -188,8 +188,9 @@ static bool reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context,
tracknr++;
}
- if (reconstruction->cameras)
+ if (reconstruction->cameras) {
MEM_freeN(reconstruction->cameras);
+ }
reconstruction->camnr = 0;
reconstruction->cameras = NULL;
@@ -205,8 +206,9 @@ static bool reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context,
float error = libmv_reprojectionErrorForImage(libmv_reconstruction, a);
for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++)
+ for (j = 0; j < 4; j++) {
mat[i][j] = matd[i][j];
+ }
}
/* Ensure first camera has got zero rotation and transform.
@@ -248,8 +250,9 @@ static bool reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context,
if (origin_set) {
track = tracksbase->first;
while (track) {
- if (track->flag & TRACK_HAS_BUNDLE)
+ if (track->flag & TRACK_HAS_BUNDLE) {
mul_v3_m4v3(track->bundle_pos, imat, track->bundle_pos);
+ }
track = track->next;
}
@@ -276,20 +279,25 @@ static int reconstruct_refine_intrinsics_get_flags(MovieTracking *tracking,
int refine = tracking->settings.refine_camera_intrinsics;
int flags = 0;
- if ((object->flag & TRACKING_OBJECT_CAMERA) == 0)
+ if ((object->flag & TRACKING_OBJECT_CAMERA) == 0) {
return 0;
+ }
- if (refine & REFINE_FOCAL_LENGTH)
+ if (refine & REFINE_FOCAL_LENGTH) {
flags |= LIBMV_REFINE_FOCAL_LENGTH;
+ }
- if (refine & REFINE_PRINCIPAL_POINT)
+ if (refine & REFINE_PRINCIPAL_POINT) {
flags |= LIBMV_REFINE_PRINCIPAL_POINT;
+ }
- if (refine & REFINE_RADIAL_DISTORTION_K1)
+ if (refine & REFINE_RADIAL_DISTORTION_K1) {
flags |= LIBMV_REFINE_RADIAL_DISTORTION_K1;
+ }
- if (refine & REFINE_RADIAL_DISTORTION_K2)
+ if (refine & REFINE_RADIAL_DISTORTION_K2) {
flags |= LIBMV_REFINE_RADIAL_DISTORTION_K2;
+ }
return flags;
}
@@ -397,11 +405,13 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieClip *clip
last_marker--;
}
- if (first <= track->markersnr - 1)
+ if (first <= track->markersnr - 1) {
sfra = min_ii(sfra, first_marker->framenr);
+ }
- if (last >= 0)
+ if (last >= 0) {
efra = max_ii(efra, last_marker->framenr);
+ }
tracks_map_insert(context->tracks_map, track, NULL);
@@ -422,8 +432,9 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieClip *clip
/* Free memory used by a reconstruction process. */
void BKE_tracking_reconstruction_context_free(MovieReconstructContext *context)
{
- if (context->reconstruction)
+ if (context->reconstruction) {
libmv_reconstructionDestroy(context->reconstruction);
+ }
libmv_tracksDestroy(context->tracks);
@@ -532,10 +543,12 @@ bool BKE_tracking_reconstruction_finish(MovieReconstructContext *context, MovieT
object = BKE_tracking_object_get_named(tracking, context->object_name);
- if (context->is_camera)
+ if (context->is_camera) {
reconstruction = &tracking->reconstruction;
- else
+ }
+ else {
reconstruction = &object->reconstruction;
+ }
/* update keyframe in the interface */
if (context->select_keyframes) {
@@ -546,8 +559,9 @@ bool BKE_tracking_reconstruction_finish(MovieReconstructContext *context, MovieT
reconstruction->error = context->reprojection_error;
reconstruction->flag |= TRACKING_RECONSTRUCTED;
- if (!reconstruct_retrieve_libmv(context, tracking))
+ if (!reconstruct_retrieve_libmv(context, tracking)) {
return false;
+ }
return true;
}
diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c
index c98ee116df7..1fe63e21e78 100644
--- a/source/blender/blenkernel/intern/tracking_stabilize.c
+++ b/source/blender/blenkernel/intern/tracking_stabilize.c
@@ -274,10 +274,12 @@ static int search_closest_marker_index(MovieTrackingTrack *track, int ref_frame)
i = MAX2(0, i);
i = MIN2(i, end - 1);
- for (; i < end - 1 && markers[i].framenr <= ref_frame; ++i)
+ for (; i < end - 1 && markers[i].framenr <= ref_frame; ++i) {
;
- for (; 0 < i && markers[i].framenr > ref_frame; --i)
+ }
+ for (; 0 < i && markers[i].framenr > ref_frame; --i) {
;
+ }
track->last_marker = i;
return i;
@@ -1374,32 +1376,39 @@ ImBuf *BKE_tracking_stabilize_frame(
interpolation_func interpolation = NULL;
int ibuf_flags;
- if (translation)
+ if (translation) {
copy_v2_v2(tloc, translation);
+ }
- if (scale)
+ if (scale) {
tscale = *scale;
+ }
/* Perform early output if no stabilization is used. */
if ((stab->flag & TRACKING_2D_STABILIZATION) == 0) {
- if (translation)
+ if (translation) {
zero_v2(translation);
+ }
- if (scale)
+ if (scale) {
*scale = 1.0f;
+ }
- if (angle)
+ if (angle) {
*angle = 0.0f;
+ }
return ibuf;
}
/* Allocate frame for stabilization result. */
ibuf_flags = 0;
- if (ibuf->rect)
+ if (ibuf->rect) {
ibuf_flags |= IB_rect;
- if (ibuf->rect_float)
+ }
+ if (ibuf->rect_float) {
ibuf_flags |= IB_rectfloat;
+ }
tmpibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, ibuf_flags);
@@ -1413,15 +1422,19 @@ ImBuf *BKE_tracking_stabilize_frame(
* thus we need the inverse of the transformation to apply. */
invert_m4(mat);
- if (filter == TRACKING_FILTER_NEAREST)
+ if (filter == TRACKING_FILTER_NEAREST) {
interpolation = nearest_interpolation;
- else if (filter == TRACKING_FILTER_BILINEAR)
+ }
+ else if (filter == TRACKING_FILTER_BILINEAR) {
interpolation = bilinear_interpolation;
- else if (filter == TRACKING_FILTER_BICUBIC)
+ }
+ else if (filter == TRACKING_FILTER_BICUBIC) {
interpolation = bicubic_interpolation;
- else
+ }
+ else {
/* fallback to default interpolation method */
interpolation = nearest_interpolation;
+ }
TrackingStabilizeFrameInterpolationData data = {
.ibuf = ibuf,
@@ -1436,17 +1449,21 @@ ImBuf *BKE_tracking_stabilize_frame(
BLI_task_parallel_range(
0, tmpibuf->y, &data, tracking_stabilize_frame_interpolation_cb, &settings);
- if (tmpibuf->rect_float)
+ if (tmpibuf->rect_float) {
tmpibuf->userflags |= IB_RECT_INVALID;
+ }
- if (translation)
+ if (translation) {
copy_v2_v2(translation, tloc);
+ }
- if (scale)
+ if (scale) {
*scale = tscale;
+ }
- if (angle)
+ if (angle) {
*angle = tangle;
+ }
return tmpibuf;
}
diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c
index 4de10aca0ec..358d8fa0a3e 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -76,8 +76,9 @@ TracksMap *tracks_map_new(const char *object_name,
map->tracks = MEM_callocN(sizeof(MovieTrackingTrack) * num_tracks, "TrackingsMap tracks");
- if (customdata_size)
+ if (customdata_size) {
map->customdata = MEM_callocN(customdata_size * num_tracks, "TracksMap customdata");
+ }
map->hash = BLI_ghash_ptr_new("TracksMap hash");
@@ -98,8 +99,9 @@ void tracks_map_get_indexed_element(TracksMap *map,
{
*track = &map->tracks[index];
- if (map->customdata)
+ if (map->customdata) {
*customdata = &map->customdata[index * map->customdata_size];
+ }
}
void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *customdata)
@@ -110,8 +112,9 @@ void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *customda
map->tracks[map->ptr] = new_track;
- if (customdata)
+ if (customdata) {
memcpy(&map->customdata[map->ptr * map->customdata_size], customdata, map->customdata_size);
+ }
BLI_ghash_insert(map->hash, &map->tracks[map->ptr], track);
@@ -223,14 +226,16 @@ void tracks_map_free(TracksMap *map, void (*customdata_free)(void *customdata))
BLI_ghash_free(map->hash, NULL, NULL);
for (i = 0; i < map->num_tracks; i++) {
- if (map->customdata && customdata_free)
+ if (map->customdata && customdata_free) {
customdata_free(&map->customdata[i * map->customdata_size]);
+ }
BKE_tracking_track_free(&map->tracks[i]);
}
- if (map->customdata)
+ if (map->customdata) {
MEM_freeN(map->customdata);
+ }
MEM_freeN(map->tracks);
@@ -420,13 +425,16 @@ void tracking_marker_insert_disabled(MovieTrackingTrack *track,
marker_new.flag &= ~MARKER_TRACKED;
marker_new.flag |= MARKER_DISABLED;
- if (before)
+ if (before) {
marker_new.framenr--;
- else
+ }
+ else {
marker_new.framenr++;
+ }
- if (overwrite || !BKE_tracking_track_has_marker_at_frame(track, marker_new.framenr))
+ if (overwrite || !BKE_tracking_track_has_marker_at_frame(track, marker_new.framenr)) {
BKE_tracking_marker_insert(track, &marker_new);
+ }
}
/* Fill in Libmv C-API camera intrinsics options from tracking structure. */
@@ -511,8 +519,9 @@ MovieTrackingMarker *tracking_get_keyframed_marker(MovieTrackingTrack *track,
MovieTrackingMarker *cur_marker = &track->markers[a];
MovieTrackingMarker *next_marker = NULL;
- if (next >= 0 && next < track->markersnr)
+ if (next >= 0 && next < track->markersnr) {
next_marker = &track->markers[next];
+ }
if ((cur_marker->flag & MARKER_DISABLED) == 0) {
/* If it'll happen so we didn't find a real keyframe marker,
@@ -531,8 +540,9 @@ MovieTrackingMarker *tracking_get_keyframed_marker(MovieTrackingTrack *track,
}
}
else if (next_marker->flag & MARKER_DISABLED) {
- if (marker_keyed_fallback == NULL)
+ if (marker_keyed_fallback == NULL) {
marker_keyed_fallback = cur_marker;
+ }
}
is_keyframed |= (cur_marker->flag & MARKER_TRACKED) == 0;
@@ -547,8 +557,9 @@ MovieTrackingMarker *tracking_get_keyframed_marker(MovieTrackingTrack *track,
a = next;
}
- if (marker_keyed == NULL)
+ if (marker_keyed == NULL) {
marker_keyed = marker_keyed_fallback;
+ }
return marker_keyed;
}
@@ -927,10 +938,14 @@ static libmv_CacheKey accessor_get_mask_for_track_callback(libmv_FrameAccessorUs
BKE_movieclip_get_size(clip, &user, &frame_width, &frame_height);
/* Actual mask sampling. */
MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, frame);
- const float region_min[2] = {region->min[0] - marker->pos[0] * frame_width,
- region->min[1] - marker->pos[1] * frame_height};
- const float region_max[2] = {region->max[0] - marker->pos[0] * frame_width,
- region->max[1] - marker->pos[1] * frame_height};
+ const float region_min[2] = {
+ region->min[0] - marker->pos[0] * frame_width,
+ region->min[1] - marker->pos[1] * frame_height,
+ };
+ const float region_max[2] = {
+ region->max[0] - marker->pos[0] * frame_width,
+ region->max[1] - marker->pos[1] * frame_height,
+ };
*r_destination = tracking_track_get_mask_for_region(
frame_width, frame_height, region_min, region_max, track);
*r_width = region->max[0] - region->min[0];
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index d32bc7c6054..d3e0ff56977 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -135,7 +135,8 @@ static void undosys_id_ref_store(void *UNUSED(user_data), UndoRefID *id_ref)
static void undosys_id_ref_resolve(void *user_data, UndoRefID *id_ref)
{
- /* Note: we could optimize this, for now it's not too bad since it only runs when we access undo! */
+ /* Note: we could optimize this,
+ * for now it's not too bad since it only runs when we access undo! */
Main *bmain = user_data;
ListBase *lb = which_libbase(bmain, GS(id_ref->name));
for (ID *id = lb->first; id; id = id->next) {
@@ -154,7 +155,8 @@ static bool undosys_step_encode(bContext *C, Main *bmain, UndoStack *ustack, Und
UNDO_NESTED_CHECK_END;
if (ok) {
if (us->type->step_foreach_ID_ref != NULL) {
- /* Don't use from context yet because sometimes context is fake and not all members are filled in. */
+ /* Don't use from context yet because sometimes context is fake and
+ * not all members are filled in. */
us->type->step_foreach_ID_ref(us, undosys_id_ref_store, bmain);
}
#ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER
@@ -193,7 +195,8 @@ static void undosys_step_decode(bContext *C, Main *bmain, UndoStack *ustack, Und
}
}
#endif
- /* Don't use from context yet because sometimes context is fake and not all members are filled in. */
+ /* Don't use from context yet because sometimes context is fake and
+ * not all members are filled in. */
us->type->step_foreach_ID_ref(us, undosys_id_ref_resolve, bmain);
}
@@ -429,7 +432,8 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size
}
}
#endif
- /* Free from first to last, free functions may update de-duplication info (see #MemFileUndoStep). */
+ /* Free from first to last, free functions may update de-duplication info
+ * (see #MemFileUndoStep). */
undosys_stack_clear_all_first(ustack, us->prev);
#ifdef WITH_GLOBAL_UNDO_KEEP_ONE
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index ac8e35cd781..293eed8cfe3 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -356,8 +356,9 @@ static const bUnitDef *unit_best_fit(double value,
for (unit = unit_start ? unit_start : usys->units; unit->name; unit++) {
- if (suppress && (unit->flag & B_UNIT_DEF_SUPPRESS))
+ if (suppress && (unit->flag & B_UNIT_DEF_SUPPRESS)) {
continue;
+ }
/* scale down scalar so 1cm doesn't convert to 10mm because of float error */
if (UNLIKELY(unit->flag & B_UNIT_DEF_TENTH)) {
@@ -385,10 +386,12 @@ static void unit_dual_convert(double value,
const bUnitDef *main_unit)
{
const bUnitDef *unit;
- if (main_unit)
+ if (main_unit) {
unit = main_unit;
- else
+ }
+ else {
unit = unit_best_fit(value, usys, NULL, 1);
+ }
*r_value_a = (value < 0.0 ? ceil : floor)(value / unit->scalar) * unit->scalar;
*r_value_b = value - (*r_value_a);
@@ -423,8 +426,8 @@ static size_t unit_as_string(char *str,
value_conv = value / unit->scalar;
/* Adjust precision to expected number of significant digits.
- * Note that here, we shall not have to worry about very big/small numbers, units are expected to replace
- * 'scientific notation' in those cases. */
+ * Note that here, we shall not have to worry about very big/small numbers, units are expected to
+ * replace 'scientific notation' in those cases. */
prec -= integer_digits_d(value_conv);
CLAMP(prec, 0, 6);
@@ -458,8 +461,9 @@ static size_t unit_as_string(char *str,
}
/* terminate no matter what's done with padding above */
- if (i >= len_max)
+ if (i >= len_max) {
i = len_max - 1;
+ }
str[i] = '\0';
return i;
@@ -532,8 +536,9 @@ static bool is_valid_unit_collection(const bUnitCollection *usys)
static const bUnitDef *get_preferred_display_unit_if_used(int type, PreferredUnits units)
{
const bUnitCollection *usys = unit_get_system(units.system, type);
- if (!is_valid_unit_collection(usys))
+ if (!is_valid_unit_collection(usys)) {
return NULL;
+ }
int max_offset = usys->length - 1;
@@ -541,22 +546,27 @@ static const bUnitDef *get_preferred_display_unit_if_used(int type, PreferredUni
case B_UNIT_LENGTH:
case B_UNIT_AREA:
case B_UNIT_VOLUME:
- if (units.length == USER_UNIT_ADAPTIVE)
+ if (units.length == USER_UNIT_ADAPTIVE) {
return NULL;
+ }
return usys->units + MIN2(units.length, max_offset);
case B_UNIT_MASS:
- if (units.mass == USER_UNIT_ADAPTIVE)
+ if (units.mass == USER_UNIT_ADAPTIVE) {
return NULL;
+ }
return usys->units + MIN2(units.mass, max_offset);
case B_UNIT_TIME:
- if (units.time == USER_UNIT_ADAPTIVE)
+ if (units.time == USER_UNIT_ADAPTIVE) {
return NULL;
+ }
return usys->units + MIN2(units.time, max_offset);
case B_UNIT_ROTATION:
- if (units.rotation == 0)
+ if (units.rotation == 0) {
return usys->units + 0;
- else if (units.rotation == USER_UNIT_ROT_RADIANS)
+ }
+ else if (units.rotation == USER_UNIT_ROT_RADIANS) {
return usys->units + 3;
+ }
break;
default:
break;
@@ -587,8 +597,9 @@ static size_t unit_as_string_main(char *str,
if (split && unit_should_be_split(type)) {
int length = unit_as_string_splitted(str, len_max, value, prec, usys, main_unit);
/* failed when length is negative, fallback to no split */
- if (length >= 0)
+ if (length >= 0) {
return length;
+ }
}
return unit_as_string(str, len_max, value, prec, usys, main_unit, pad ? ' ' : '\0');
@@ -630,10 +641,12 @@ static const char *unit_find_str(const char *str, const char *substr, bool case_
while (true) {
/* Unit detection is case insensitive. */
const char *str_found;
- if (case_sensitive)
+ if (case_sensitive) {
str_found = strstr(str, substr);
- else
+ }
+ else {
str_found = BLI_strcasestr(str, substr);
+ }
if (str_found) {
/* Previous char cannot be a letter. */
@@ -649,8 +662,9 @@ static const char *unit_find_str(const char *str, const char *substr, bool case_
}
}
/* If str_found is not a valid unit, we have to check further in the string... */
- for (str_found++; isalpha_or_utf8(*str_found); str_found++)
+ for (str_found++; isalpha_or_utf8(*str_found); str_found++) {
;
+ }
str = str_found;
}
else {
@@ -716,8 +730,9 @@ static int unit_scale_str(char *str,
len_num = BLI_snprintf(
str_tmp, TEMP_STR_SIZE, "*%.9g" SEP_STR, unit->scalar / scale_pref); /* # removed later */
- if (len_num > len_max)
+ if (len_num > len_max) {
len_num = len_max;
+ }
if (found_ofs + len_num + len_move > len_max) {
/* can't move the whole string, move just as much as will fit */
@@ -766,14 +781,18 @@ static int unit_replace(
static bool unit_find(const char *str, const bUnitDef *unit)
{
const bool case_sensitive = (unit->flag & B_UNIT_DEF_CASE_SENSITIVE) != 0;
- if (unit_find_str(str, unit->name_short, case_sensitive))
+ if (unit_find_str(str, unit->name_short, case_sensitive)) {
return true;
- if (unit_find_str(str, unit->name_plural, false))
+ }
+ if (unit_find_str(str, unit->name_plural, false)) {
return true;
- if (unit_find_str(str, unit->name_alt, case_sensitive))
+ }
+ if (unit_find_str(str, unit->name_alt, case_sensitive)) {
return true;
- if (unit_find_str(str, unit->name, false))
+ }
+ if (unit_find_str(str, unit->name, false)) {
return true;
+ }
return false;
}
@@ -784,20 +803,23 @@ static const bUnitDef *unit_detect_from_str(const bUnitCollection *usys,
{
/* Try to find a default unit from current or previous string.
* This allows us to handle cases like 2 + 2mm, people would expect to get 4mm, not 2.002m!
- * Note this does not handle corner cases like 2 + 2cm + 1 + 2.5mm... We can't support everything. */
+ * Note this does not handle corner cases like 2 + 2cm + 1 + 2.5mm... We can't support
+ * everything. */
const bUnitDef *unit = NULL;
/* see which units the new value has */
for (unit = usys->units; unit->name; unit++) {
- if (unit_find(str, unit))
+ if (unit_find(str, unit)) {
break;
+ }
}
/* Else, try to infer the default unit from the previous string. */
if (str_prev && (unit == NULL || unit->name == NULL)) {
/* see which units the original value had */
for (unit = usys->units; unit->name; unit++) {
- if (unit_find(str_prev, unit))
+ if (unit_find(str_prev, unit)) {
break;
+ }
}
}
/* Else, fall back to default unit. */
@@ -812,8 +834,9 @@ bool bUnit_ContainsUnit(const char *str, int type)
{
for (int system = 0; system < UNIT_SYSTEM_TOT; system++) {
const bUnitCollection *usys = unit_get_system(system, type);
- if (!is_valid_unit_collection(usys))
+ if (!is_valid_unit_collection(usys)) {
continue;
+ }
for (int i = 0; i < usys->length; i++) {
if (unit_find(str, usys->units + i)) {
@@ -828,10 +851,12 @@ double bUnit_PreferredInputUnitScalar(const struct UnitSettings *settings, int t
{
PreferredUnits units = preferred_units_from_UnitSettings(settings);
const bUnitDef *unit = get_preferred_display_unit_if_used(type, units);
- if (unit)
+ if (unit) {
return unit->scalar;
- else
+ }
+ else {
return bUnit_BaseScalar(units.system, type);
+ }
}
/* make a copy of the string that replaces the units with numbers
@@ -853,8 +878,9 @@ bool bUnit_ReplaceString(
char *str, int len_max, const char *str_prev, double scale_pref, int system, int type)
{
const bUnitCollection *usys = unit_get_system(system, type);
- if (!is_valid_unit_collection(usys))
+ if (!is_valid_unit_collection(usys)) {
return false;
+ }
const bUnitDef *unit = NULL, *default_unit;
double scale_pref_base = scale_pref;
@@ -864,10 +890,12 @@ bool bUnit_ReplaceString(
/* Try to find a default unit from current or previous string. */
default_unit = unit_detect_from_str(usys, str, str_prev);
- /* We apply the default unit to the whole expression (default unit is now the reference '1.0' one). */
+ /* We apply the default unit to the whole expression (default unit is now the reference '1.0'
+ * one). */
scale_pref_base *= default_unit->scalar;
- /* Apply the default unit on the whole expression, this allows to handle nasty cases like '2+2in'. */
+ /* Apply the default unit on the whole expression, this allows to handle nasty cases like
+ * '2+2in'. */
if (BLI_snprintf(str_tmp, sizeof(str_tmp), "(%s)*%.9g", str, default_unit->scalar) <
sizeof(str_tmp)) {
strncpy(str, str_tmp, len_max);
@@ -880,16 +908,17 @@ bool bUnit_ReplaceString(
for (unit = usys->units; unit->name; unit++) {
/* in case there are multiple instances */
- while (unit_replace(str, len_max, str_tmp, scale_pref_base, unit))
+ while (unit_replace(str, len_max, str_tmp, scale_pref_base, unit)) {
changed = true;
+ }
}
unit = NULL;
{
/* try other unit systems now, so we can evaluate imperial when metric is set for eg. */
- /* Note that checking other systems at that point means we do not support their units as 'default' one.
- * In other words, when in metrics, typing '2+2in' will give 2 meters 2 inches, not 4 inches.
- * I do think this is the desired behavior!
+ /* Note that checking other systems at that point means we do not support their units as
+ * 'default' one. In other words, when in metrics, typing '2+2in' will give 2 meters 2 inches,
+ * not 4 inches. I do think this is the desired behavior!
*/
const bUnitCollection *usys_iter;
int system_iter;
@@ -901,8 +930,10 @@ bool bUnit_ReplaceString(
for (unit = usys_iter->units; unit->name; unit++) {
int ofs = 0;
/* in case there are multiple instances */
- while ((ofs = unit_replace(str + ofs, len_max - ofs, str_tmp, scale_pref_base, unit)))
+ while (
+ (ofs = unit_replace(str + ofs, len_max - ofs, str_tmp, scale_pref_base, unit))) {
changed = true;
+ }
}
}
}
@@ -964,10 +995,12 @@ void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int syste
len_max -= offset;
/* print the alt_name */
- if (unit->name_alt)
+ if (unit->name_alt) {
len_name = BLI_strncpy_rlen(str, unit->name_alt, len_max);
- else
+ }
+ else {
len_name = 0;
+ }
len_name = (len_name < len_max ? len_name : len_max);
str += len_name;
@@ -985,12 +1018,14 @@ double bUnit_ClosestScalar(double value, int system, int type)
const bUnitCollection *usys = unit_get_system(system, type);
const bUnitDef *unit;
- if (usys == NULL)
+ if (usys == NULL) {
return -1;
+ }
unit = unit_best_fit(value, usys, NULL, 1);
- if (unit == NULL)
+ if (unit == NULL) {
return -1;
+ }
return unit->scalar;
}
@@ -998,10 +1033,12 @@ double bUnit_ClosestScalar(double value, int system, int type)
double bUnit_BaseScalar(int system, int type)
{
const bUnitCollection *usys = unit_get_system(system, type);
- if (usys)
+ if (usys) {
return unit_default(usys)->scalar;
- else
+ }
+ else {
return 1.0;
+ }
}
/* external access */
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 2e9591a99c7..f9584adc6e0 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -113,8 +113,9 @@ static void *workspace_relation_get_data_matching_parent(const ListBase *relatio
}
/**
- * Checks if \a screen is already used within any workspace. A screen should never be assigned to multiple
- * WorkSpaceLayouts, but that should be ensured outside of the BKE_workspace module and without such checks.
+ * Checks if \a screen is already used within any workspace. A screen should never be assigned to
+ * multiple WorkSpaceLayouts, but that should be ensured outside of the BKE_workspace module
+ * and without such checks.
* Hence, this should only be used as assert check before assigining a screen to a workspace.
*/
#ifndef NDEBUG
@@ -143,8 +144,9 @@ WorkSpace *BKE_workspace_add(Main *bmain, const char *name)
}
/**
- * The function that actually frees the workspace data (not workspace itself). It shouldn't be called
- * directly, instead #BKE_workspace_remove should be, which calls this through #BKE_id_free then.
+ * The function that actually frees the workspace data (not workspace itself).
+ * It shouldn't be called directly, instead #BKE_workspace_remove should be,
+ * which calls this through #BKE_id_free then.
*
* Should something like a bke_internal.h be added, this should go there!
*/
@@ -275,7 +277,8 @@ WorkSpaceLayout *BKE_workspace_layout_find(const WorkSpace *workspace, const bSc
* Find the layout for \a screen without knowing which workspace to look in.
* Can also be used to find the workspace that contains \a screen.
*
- * \param r_workspace: Optionally return the workspace that contains the looked up layout (if found).
+ * \param r_workspace: Optionally return the workspace that contains the
+ * looked up layout (if found).
*/
WorkSpaceLayout *BKE_workspace_layout_find_global(const Main *bmain,
const bScreen *screen,
@@ -303,7 +306,8 @@ WorkSpaceLayout *BKE_workspace_layout_find_global(const Main *bmain,
/**
* Circular workspace layout iterator.
*
- * \param callback: Custom function which gets executed for each layout. Can return false to stop iterating.
+ * \param callback: Custom function which gets executed for each layout.
+ * Can return false to stop iterating.
* \param arg: Custom data passed to each \a callback call.
*
* \return the layout at which \a callback returned false.
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 8dcd31a13c9..109d615ae83 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -95,8 +95,10 @@ World *BKE_world_add(Main *bmain, const char *name)
}
/**
- * Only copy internal data of World ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of World ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
*
* WARNING! This function will not handle ID user count!
*
@@ -144,8 +146,9 @@ World *BKE_world_localize(World *wrld)
wrldn = BKE_libblock_copy_for_localize(&wrld->id);
- if (wrld->nodetree)
+ if (wrld->nodetree) {
wrldn->nodetree = ntreeLocalize(wrld->nodetree);
+ }
wrldn->preview = NULL;
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index 9f76f1022d1..b72b99e514d 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -163,8 +163,9 @@ static void filepath_avi(char *string, RenderData *rd, bool preview, const char
{
int sfra, efra;
- if (string == NULL)
+ if (string == NULL) {
return;
+ }
if (preview) {
sfra = rd->psfra;
@@ -219,10 +220,12 @@ static int start_avi(void *context_v,
quality = rd->im_format.quality;
framerate = (double)rd->frs_sec / (double)rd->frs_sec_base;
- if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG)
+ if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG) {
format = AVI_FORMAT_AVI_RGB;
- else
+ }
+ else {
format = AVI_FORMAT_MJPEG;
+ }
if (AVI_open_compress(name, avi, 1, format) != AVI_ERROR_NONE) {
BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file");
@@ -256,8 +259,9 @@ static int append_avi(void *context_v,
char *cp, rt;
AviMovie *avi = context_v;
- if (avi == NULL)
+ if (avi == NULL) {
return 0;
+ }
/* note that libavi free's the buffer... stupid interface - zr */
rectot = MEM_mallocN(rectx * recty * sizeof(int), "rectot");
@@ -289,8 +293,9 @@ static void end_avi(void *context_v)
{
AviMovie *avi = context_v;
- if (avi == NULL)
+ if (avi == NULL) {
return;
+ }
AVI_close_compress(avi);
}
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 6bf8186e02f..a74d5b241ed 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -115,8 +115,9 @@ static void ffmpeg_filepath_get(
static void delete_picture(AVFrame *f)
{
if (f) {
- if (f->data[0])
+ if (f->data[0]) {
MEM_freeN(f->data[0]);
+ }
av_free(f);
}
}
@@ -207,12 +208,15 @@ static int write_audio_frame(FFMpegContext *context)
# endif
if (got_output) {
- if (pkt.pts != AV_NOPTS_VALUE)
+ if (pkt.pts != AV_NOPTS_VALUE) {
pkt.pts = av_rescale_q(pkt.pts, c->time_base, context->audio_stream->time_base);
- if (pkt.dts != AV_NOPTS_VALUE)
+ }
+ if (pkt.dts != AV_NOPTS_VALUE) {
pkt.dts = av_rescale_q(pkt.dts, c->time_base, context->audio_stream->time_base);
- if (pkt.duration > 0)
+ }
+ if (pkt.duration > 0) {
pkt.duration = av_rescale_q(pkt.duration, c->time_base, context->audio_stream->time_base);
+ }
pkt.stream_index = context->audio_stream->index;
@@ -220,16 +224,18 @@ static int write_audio_frame(FFMpegContext *context)
if (av_interleaved_write_frame(context->outfile, &pkt) != 0) {
fprintf(stderr, "Error writing audio packet!\n");
- if (frame)
+ if (frame) {
av_frame_free(&frame);
+ }
return -1;
}
av_free_packet(&pkt);
}
- if (frame)
+ if (frame) {
av_frame_free(&frame);
+ }
return 0;
}
@@ -244,8 +250,9 @@ static AVFrame *alloc_picture(int pix_fmt, int width, int height)
/* allocate space for the struct */
f = av_frame_alloc();
- if (!f)
+ if (!f) {
return NULL;
+ }
size = avpicture_get_size(pix_fmt, width, height);
/* allocate the actual picture buffer */
buf = MEM_mallocN(size, "AVFrame buffer");
@@ -353,8 +360,9 @@ static int write_video_frame(
success = 0;
}
- if (!success)
+ if (!success) {
BKE_report(reports, RPT_ERROR, "Error writing frame");
+ }
return success;
}
@@ -527,8 +535,9 @@ static void set_ffmpeg_properties(RenderData *rd,
}
for (curr = prop->data.group.first; curr; curr = curr->next) {
- if (ffmpeg_proprty_valid(c, prop_name, curr))
+ if (ffmpeg_proprty_valid(c, prop_name, curr)) {
set_ffmpeg_property_option(c, curr, dictionary);
+ }
}
}
@@ -551,8 +560,9 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
error[0] = '\0';
st = avformat_new_stream(of, NULL);
- if (!st)
+ if (!st) {
return NULL;
+ }
st->id = 0;
/* Set up the codec context */
@@ -627,11 +637,12 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
}
/* Deprecated and not doing anything since July 2015, deleted in recent ffmpeg */
- //c->me_method = ME_EPZS;
+ // c->me_method = ME_EPZS;
codec = avcodec_find_encoder(c->codec_id);
- if (!codec)
+ if (!codec) {
return NULL;
+ }
/* Be sure to use the correct pixel format(e.g. RGB, YUV) */
@@ -731,8 +742,9 @@ static AVStream *alloc_audio_stream(FFMpegContext *context,
error[0] = '\0';
st = avformat_new_stream(of, NULL);
- if (!st)
+ if (!st) {
return NULL;
+ }
st->id = 1;
c = st->codec;
@@ -775,19 +787,21 @@ static AVStream *alloc_audio_stream(FFMpegContext *context,
codec = avcodec_find_encoder(c->codec_id);
if (!codec) {
- //XXX error("Couldn't find a valid audio codec");
+ // XXX error("Couldn't find a valid audio codec");
return NULL;
}
if (codec->sample_fmts) {
- /* check if the preferred sample format for this codec is supported.
- * this is because, depending on the version of libav, and with the whole ffmpeg/libav fork situation,
- * you have various implementations around. float samples in particular are not always supported.
- */
+ /* Check if the preferred sample format for this codec is supported.
+ * this is because, depending on the version of libav,
+ * and with the whole ffmpeg/libav fork situation,
+ * you have various implementations around.
+ * Float samples in particular are not always supported. */
const enum AVSampleFormat *p = codec->sample_fmts;
for (; *p != -1; p++) {
- if (*p == st->codec->sample_fmt)
+ if (*p == st->codec->sample_fmt) {
break;
+ }
}
if (*p == -1) {
/* sample format incompatible with codec. Defaulting to a format known to work */
@@ -817,7 +831,7 @@ static AVStream *alloc_audio_stream(FFMpegContext *context,
set_ffmpeg_properties(rd, c, "audio", &opts);
if (avcodec_open2(c, codec, &opts) < 0) {
- //XXX error("Couldn't initialize audio codec");
+ // XXX error("Couldn't initialize audio codec");
BLI_strncpy(error, IMB_ffmpeg_last_error(), error_size);
av_dict_free(&opts);
return NULL;
@@ -833,16 +847,18 @@ static AVStream *alloc_audio_stream(FFMpegContext *context,
context->audio_outbuf_size = FF_MIN_BUFFER_SIZE;
# endif
- if (c->frame_size == 0)
+ if (c->frame_size == 0) {
// used to be if ((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD))
// not sure if that is needed anymore, so let's try out if there are any
// complaints regarding some ffmpeg versions users might have
context->audio_input_samples = FF_MIN_BUFFER_SIZE * 8 / c->bits_per_coded_sample / c->channels;
+ }
else {
context->audio_input_samples = c->frame_size;
# ifndef FFMPEG_HAVE_ENCODE_AUDIO2
- if (c->frame_size * c->channels * sizeof(int16_t) * 4 > context->audio_outbuf_size)
+ if (c->frame_size * c->channels * sizeof(int16_t) * 4 > context->audio_outbuf_size) {
context->audio_outbuf_size = c->frame_size * c->channels * sizeof(int16_t) * 4;
+ }
# endif
}
@@ -856,9 +872,10 @@ static AVStream *alloc_audio_stream(FFMpegContext *context,
context->audio_output_buffer = (uint8_t *)av_malloc(context->audio_outbuf_size);
# endif
- if (context->audio_deinterleave)
+ if (context->audio_deinterleave) {
context->audio_deinterleave_buffer = (uint8_t *)av_malloc(
context->audio_input_samples * c->channels * context->audio_sample_size);
+ }
context->audio_time = 0.0f;
@@ -1041,10 +1058,12 @@ static int start_ffmpeg_impl(FFMpegContext *context,
context, rd, fmt->video_codec, of, rectx, recty, error, sizeof(error));
PRINT("alloc video stream %p\n", context->video_stream);
if (!context->video_stream) {
- if (error[0])
+ if (error[0]) {
BKE_report(reports, RPT_ERROR, error);
- else
+ }
+ else {
BKE_report(reports, RPT_ERROR, "Error initializing video stream");
+ }
goto fail;
}
}
@@ -1053,10 +1072,12 @@ static int start_ffmpeg_impl(FFMpegContext *context,
context->audio_stream = alloc_audio_stream(
context, rd, fmt->audio_codec, of, error, sizeof(error));
if (!context->audio_stream) {
- if (error[0])
+ if (error[0]) {
BKE_report(reports, RPT_ERROR, error);
- else
+ }
+ else {
BKE_report(reports, RPT_ERROR, "Error initializing audio stream");
+ }
goto fail;
}
}
@@ -1180,8 +1201,9 @@ static void ffmpeg_filepath_get(
const char **fe = exts;
int sfra, efra;
- if (!string || !exts)
+ if (!string || !exts) {
return;
+ }
if (preview) {
sfra = rd->psfra;
@@ -1501,7 +1523,6 @@ static IDProperty *BKE_ffmpeg_property_add(RenderData *rd,
(char
*)" ";
val.string.len = 80;
- /* val.str = (char *)" ";*/
idp_type = IDP_STRING;
break;
case AV_OPT_TYPE_CONST:
@@ -1533,8 +1554,9 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char
BLI_strncpy(name_, str, sizeof(name_));
name = name_;
- while (*name == ' ')
+ while (*name == ' ') {
name++;
+ }
param = strchr(name, ':');
@@ -1543,8 +1565,9 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char
}
if (param) {
*param++ = '\0';
- while (*param == ' ')
+ while (*param == ' ') {
param++;
+ }
}
o = av_opt_find(&c, name, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
@@ -1592,8 +1615,9 @@ static void ffmpeg_set_expert_options(RenderData *rd)
{
int codec_id = rd->ffcodecdata.codec;
- if (rd->ffcodecdata.properties)
+ if (rd->ffcodecdata.properties) {
IDP_FreeProperty(rd->ffcodecdata.properties);
+ }
if (codec_id == AV_CODEC_ID_H264) {
/*
@@ -1612,7 +1636,9 @@ static void ffmpeg_set_expert_options(RenderData *rd)
* The other options were taken from the libx264-default.preset
* included in the ffmpeg distribution.
*/
- // ffmpeg_property_add_string(rd, "video", "flags:loop"); // this breaks compatibility for QT
+
+ /* This breaks compatibility for QT. */
+ // BKE_ffmpeg_property_add_string(rd, "video", "flags:loop");
BKE_ffmpeg_property_add_string(rd, "video", "cmp:chroma");
BKE_ffmpeg_property_add_string(rd, "video", "partitions:parti4x4"); // Deprecated.
BKE_ffmpeg_property_add_string(rd, "video", "partitions:partp8x8"); // Deprecated.
@@ -1643,8 +1669,9 @@ static void ffmpeg_set_expert_options(RenderData *rd)
# endif
}
else if (codec_id == AV_CODEC_ID_DNXHD) {
- if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
+ if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) {
BKE_ffmpeg_property_add_string(rd, "video", "mbd:rd");
+ }
}
}
@@ -1652,8 +1679,9 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset)
{
int isntsc = (rd->frs_sec != 25);
- if (rd->ffcodecdata.properties)
+ if (rd->ffcodecdata.properties) {
IDP_FreeProperty(rd->ffcodecdata.properties);
+ }
switch (preset) {
case FFMPEG_PRESET_VCD:
@@ -1793,18 +1821,22 @@ bool BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd)
{
int codec = rd->ffcodecdata.codec;
- if (codec == AV_CODEC_ID_QTRLE)
+ if (codec == AV_CODEC_ID_QTRLE) {
return true;
+ }
- if (codec == AV_CODEC_ID_PNG)
+ if (codec == AV_CODEC_ID_PNG) {
return true;
+ }
- if (codec == AV_CODEC_ID_HUFFYUV)
+ if (codec == AV_CODEC_ID_HUFFYUV) {
return true;
+ }
# ifdef FFMPEG_FFV1_ALPHA_SUPPORTED
- if (codec == AV_CODEC_ID_FFV1)
+ if (codec == AV_CODEC_ID_FFV1) {
return true;
+ }
# endif
return false;
diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h
index 59c9b4e7d33..dc086987e21 100644
--- a/source/blender/blenkernel/nla_private.h
+++ b/source/blender/blenkernel/nla_private.h
@@ -163,7 +163,8 @@ typedef struct NlaKeyframingContext {
float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode);
/* --------------- NLA Evaluation (very-private stuff) ----------------------- */
-/* these functions are only defined here to avoid problems with the order in which they get defined... */
+/* these functions are only defined here to avoid problems with the order
+ * in which they get defined. */
NlaEvalStrip *nlastrips_ctime_get_strip(
struct Depsgraph *depsgraph, ListBase *list, ListBase *strips, short index, float ctime);
diff --git a/source/blender/blenlib/BLI_assert.h b/source/blender/blenlib/BLI_assert.h
index 44dc4324328..3d3c84d6370 100644
--- a/source/blender/blenlib/BLI_assert.h
+++ b/source/blender/blenlib/BLI_assert.h
@@ -94,13 +94,13 @@ extern "C" {
#else /* older gcc, clang... */
/* Code adapted from http://www.pixelbeat.org/programming/gcc/static_assert.html */
/* Note we need the two concats below because arguments to ## are not expanded, so we need to
- * expand __LINE__ with one indirection before doing the actual concatenation. */
+ * expand __LINE__ with one indirection before doing the actual concatenation. */
# define _BLI_ASSERT_CONCAT_(a, b) a##b
# define _BLI_ASSERT_CONCAT(a, b) _BLI_ASSERT_CONCAT_(a, b)
/* This can't be used twice on the same line so ensure if using in headers
- * that the headers are not included twice (by wrapping in #ifndef...#endif)
- * Note it doesn't cause an issue when used on same line of separate modules
- * compiled with gcc -combine -fwhole-program. */
+ * that the headers are not included twice (by wrapping in #ifndef...#endif)
+ * Note it doesn't cause an issue when used on same line of separate modules
+ * compiled with gcc -combine -fwhole-program. */
# define BLI_STATIC_ASSERT(a, msg) \
; \
enum { _BLI_ASSERT_CONCAT(assert_line_, __LINE__) = 1 / (int)(!!(a)) };
diff --git a/source/blender/blenlib/BLI_astar.h b/source/blender/blenlib/BLI_astar.h
index 320c450a78a..3fe37d7886b 100644
--- a/source/blender/blenlib/BLI_astar.h
+++ b/source/blender/blenlib/BLI_astar.h
@@ -88,8 +88,10 @@ void BLI_astar_solution_clear(BLI_AStarSolution *as_solution);
void BLI_astar_solution_free(BLI_AStarSolution *as_solution);
/**
- * Callback computing the current cost (distance) to next node, and the estimated overall cost to destination node
- * (A* expects this estimation to always be less or equal than actual shortest path from next node to destination one).
+ * Callback computing the current cost (distance) to next node,
+ * and the estimated overall cost to destination node
+ * (A* expects this estimation to always be less or equal than actual shortest path
+ * from next node to destination one).
*
* \param link: the graph link between current node and next one.
* \param node_idx_curr: current node index.
diff --git a/source/blender/blenlib/BLI_compiler_compat.h b/source/blender/blenlib/BLI_compiler_compat.h
index 80c564a70c7..bd1cd327d3c 100644
--- a/source/blender/blenlib/BLI_compiler_compat.h
+++ b/source/blender/blenlib/BLI_compiler_compat.h
@@ -45,4 +45,10 @@ template<typename T> static inline T decltype_helper(T x)
# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
# endif
+# if defined(__GNUC__)
+# define BLI_NOINLINE __attribute__((noinline))
+# else
+# define BLI_NOINLINE
+# endif
+
#endif /* __BLI_COMPILER_COMPAT_H__ */
diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h
index 222cdea10cc..11e5e2c70e9 100644
--- a/source/blender/blenlib/BLI_dlrbTree.h
+++ b/source/blender/blenlib/BLI_dlrbTree.h
@@ -68,20 +68,23 @@ typedef struct DLRBT_Tree {
/* Callback Types --------------------------------- */
-/* return -1, 0, 1 for whether the given data is less than, equal to, or greater than the given node
+/* Return -1, 0, 1 for whether the given data is less than,
+ * equal to, or greater than the given node.
* - node: <DLRBT_Node> the node to compare to
- * - data: pointer to the relevant data or values stored in the bitpattern dependent on the function
+ * - data: pointer to the relevant data or values stored in the bitpattern
+ * dependent on the function.
*/
typedef short (*DLRBT_Comparator_FP)(void *node, void *data);
-/* return a new node instance wrapping the given data
- * - data: pointer to the relevant data to create a subclass of node from
+/* Return a new node instance wrapping the given data
+ * - data: Pointer to the relevant data to create a subclass of node from
*/
typedef DLRBT_Node *(*DLRBT_NAlloc_FP)(void *data);
-/* update an existing node instance accordingly to be in sync with the given data *
- * - node: <DLRBT_Node> the node to update
- * - data: pointer to the relevant data or values stored in the bitpattern dependent on the function
+/* Update an existing node instance accordingly to be in sync with the given data *
+ * - node: <DLRBT_Node> the node to update.
+ * - data: Pointer to the relevant data or values stored in the bitpattern
+ * dependent on the function.
*/
typedef void (*DLRBT_NUpdate_FP)(void *node, void *data);
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index 7787ca4cdb5..d8daa81b58d 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -51,8 +51,8 @@ int BLI_copy(const char *path, const char *to) ATTR_NONNULL();
int BLI_rename(const char *from, const char *to) ATTR_NONNULL();
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL();
#if 0 /* Unused */
-int BLI_move(const char *path, const char *to) ATTR_NONNULL();
-int BLI_create_symlink(const char *path, const char *to) ATTR_NONNULL();
+int BLI_move(const char *path, const char *to) ATTR_NONNULL();
+int BLI_create_symlink(const char *path, const char *to) ATTR_NONNULL();
#endif
/* keep in sync with the definition of struct direntry in BLI_fileops_types.h */
@@ -113,7 +113,7 @@ bool BLI_file_is_writable(const char *file) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL
bool BLI_file_touch(const char *file) ATTR_NONNULL();
#if 0 /* UNUSED */
-int BLI_file_gzip(const char *from, const char *to) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+int BLI_file_gzip(const char *from, const char *to) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
#endif
char *BLI_file_ungzip_to_mem(const char *from_file, int *r_size) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index 5d7fc5eeee3..aa3d7520506 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -27,8 +27,8 @@
#include "BLI_compiler_attrs.h"
#include "BLI_utildefines.h"
#include "DNA_listBase.h"
-//struct ListBase;
-//struct LinkData;
+// struct ListBase;
+// struct LinkData;
#ifdef __cplusplus
extern "C" {
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index aff01622f35..177a1a84b16 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -200,8 +200,9 @@ double double_round(double x, int ndigits);
/** \note 0.0001 is too small becaues normals may be converted from short's: see T34322. */
# define BLI_ASSERT_UNIT_EPSILON 0.0002f
/**
- * \note Checks are flipped so NAN doesn't assert. This is done because we're making sure the value was normalized
- * and in the case we don't want NAN to be raising asserts since there is nothing to be done in that case.
+ * \note Checks are flipped so NAN doesn't assert.
+ * This is done because we're making sure the value was normalized and in the case we
+ * don't want NAN to be raising asserts since there is nothing to be done in that case.
*/
# define BLI_ASSERT_UNIT_V3(v) \
{ \
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index cde3f282427..7a4ac14970f 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -27,6 +27,8 @@
* \ingroup bli
*/
+#include "DNA_vec_types.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -215,14 +217,6 @@ void rotate_eulO(float eul[3], const short order, char axis, float angle);
/******************************* Dual Quaternions ****************************/
-typedef struct DualQuat {
- float quat[4];
- float trans[4];
-
- float scale[4][4];
- float scale_weight;
-} DualQuat;
-
void copy_dq_dq(DualQuat *r, const DualQuat *dq);
void normalize_dq(DualQuat *dq, float totw);
void add_weighted_dq_dq(DualQuat *r, const DualQuat *dq, float weight);
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h
index fca3d268981..67851a63f8f 100644
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@ -77,8 +77,10 @@ enum {
BLI_MEMPOOL_NOP = 0,
/** allow iterating on this mempool.
*
- * \note this requires that the first four bytes of the elements never begin with 'free' (FREEWORD).
- * \note order of iteration is only assured to be the order of allocation when no chunks have been freed.
+ * \note this requires that the first four bytes of the elements
+ * never begin with 'free' (#FREEWORD).
+ * \note order of iteration is only assured to be the
+ * order of allocation when no chunks have been freed.
*/
BLI_MEMPOOL_ALLOW_ITER = (1 << 0),
};
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h
index f73f2e6706e..f23580916b1 100644
--- a/source/blender/blenlib/BLI_rect.h
+++ b/source/blender/blenlib/BLI_rect.h
@@ -66,7 +66,7 @@ void BLI_rctf_interp(struct rctf *rect,
const struct rctf *rect_a,
const struct rctf *rect_b,
const float fac);
-//void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac);
+// void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac);
bool BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]);
bool BLI_rcti_clamp_pt_v(const struct rcti *rect, int xy[2]);
bool BLI_rctf_clamp(struct rctf *rect, const struct rctf *rect_bounds, float r_xy[2]);
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 47ff0a15b01..70ffb46e952 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -160,33 +160,42 @@ int BLI_string_find_split_words(const char *str,
* Follows #ELEM macro convention.
* \{ */
+/* Manual line breaks for readability. */
+/* clang-format off */
/* STR_ELEM#(v, ...): is the first arg equal any others? */
/* Internal helpers. */
#define _VA_STR_ELEM2(v, a) (strcmp(v, a) == 0)
-#define _VA_STR_ELEM3(v, a, b) (_VA_STR_ELEM2(v, a) || ((v) == (b)))
-#define _VA_STR_ELEM4(v, a, b, c) (_VA_STR_ELEM3(v, a, b) || ((v) == (c)))
-#define _VA_STR_ELEM5(v, a, b, c, d) (_VA_STR_ELEM4(v, a, b, c) || ((v) == (d)))
-#define _VA_STR_ELEM6(v, a, b, c, d, e) (_VA_STR_ELEM5(v, a, b, c, d) || ((v) == (e)))
-#define _VA_STR_ELEM7(v, a, b, c, d, e, f) (_VA_STR_ELEM6(v, a, b, c, d, e) || ((v) == (f)))
-#define _VA_STR_ELEM8(v, a, b, c, d, e, f, g) (_VA_STR_ELEM7(v, a, b, c, d, e, f) || ((v) == (g)))
+#define _VA_STR_ELEM3(v, a, b) \
+ (_VA_STR_ELEM2(v, a) || (_VA_STR_ELEM2(v, b)))
+#define _VA_STR_ELEM4(v, a, b, c) \
+ (_VA_STR_ELEM3(v, a, b) || (_VA_STR_ELEM2(v, c)))
+#define _VA_STR_ELEM5(v, a, b, c, d) \
+ (_VA_STR_ELEM4(v, a, b, c) || (_VA_STR_ELEM2(v, d)))
+#define _VA_STR_ELEM6(v, a, b, c, d, e) \
+ (_VA_STR_ELEM5(v, a, b, c, d) || (_VA_STR_ELEM2(v, e)))
+#define _VA_STR_ELEM7(v, a, b, c, d, e, f) \
+ (_VA_STR_ELEM6(v, a, b, c, d, e) || (_VA_STR_ELEM2(v, f)))
+#define _VA_STR_ELEM8(v, a, b, c, d, e, f, g) \
+ (_VA_STR_ELEM7(v, a, b, c, d, e, f) || (_VA_STR_ELEM2(v, g)))
#define _VA_STR_ELEM9(v, a, b, c, d, e, f, g, h) \
- (_VA_STR_ELEM8(v, a, b, c, d, e, f, g) || ((v) == (h)))
+ (_VA_STR_ELEM8(v, a, b, c, d, e, f, g) || (_VA_STR_ELEM2(v, h)))
#define _VA_STR_ELEM10(v, a, b, c, d, e, f, g, h, i) \
- (_VA_STR_ELEM9(v, a, b, c, d, e, f, g, h) || ((v) == (i)))
+ (_VA_STR_ELEM9(v, a, b, c, d, e, f, g, h) || (_VA_STR_ELEM2(v, i)))
#define _VA_STR_ELEM11(v, a, b, c, d, e, f, g, h, i, j) \
- (_VA_STR_ELEM10(v, a, b, c, d, e, f, g, h, i) || ((v) == (j)))
+ (_VA_STR_ELEM10(v, a, b, c, d, e, f, g, h, i) || (_VA_STR_ELEM2(v, j)))
#define _VA_STR_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) \
- (_VA_STR_ELEM11(v, a, b, c, d, e, f, g, h, i, j) || ((v) == (k)))
+ (_VA_STR_ELEM11(v, a, b, c, d, e, f, g, h, i, j) || (_VA_STR_ELEM2(v, k)))
#define _VA_STR_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) \
- (_VA_STR_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) || ((v) == (l)))
+ (_VA_STR_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) || (_VA_STR_ELEM2(v, l)))
#define _VA_STR_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) \
- (_VA_STR_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) || ((v) == (m)))
+ (_VA_STR_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) || (_VA_STR_ELEM2(v, m)))
#define _VA_STR_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) \
- (_VA_STR_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) || ((v) == (n)))
+ (_VA_STR_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) || (_VA_STR_ELEM2(v, n)))
#define _VA_STR_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) \
- (_VA_STR_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) || ((v) == (o)))
+ (_VA_STR_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) || (_VA_STR_ELEM2(v, o)))
#define _VA_STR_ELEM17(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
- (_VA_STR_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) || ((v) == (p)))
+ (_VA_STR_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) || (_VA_STR_ELEM2(v, p)))
+/* clang-format on */
/* reusable STR_ELEM macro */
#define STR_ELEM(...) VA_NARGS_CALL_OVERLOAD(_VA_STR_ELEM, __VA_ARGS__)
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index f2f30265ea0..216e409aee6 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -246,32 +246,43 @@ extern "C" {
/** \name Equal to Any Element (ELEM) Macro
* \{ */
+/* Manual line breaks for readability. */
+/* clang-format off */
+
/* ELEM#(v, ...): is the first arg equal any others? */
-/* internal helpers*/
+/* internal helpers. */
#define _VA_ELEM2(v, a) ((v) == (a))
-#define _VA_ELEM3(v, a, b) (_VA_ELEM2(v, a) || ((v) == (b)))
-#define _VA_ELEM4(v, a, b, c) (_VA_ELEM3(v, a, b) || ((v) == (c)))
-#define _VA_ELEM5(v, a, b, c, d) (_VA_ELEM4(v, a, b, c) || ((v) == (d)))
-#define _VA_ELEM6(v, a, b, c, d, e) (_VA_ELEM5(v, a, b, c, d) || ((v) == (e)))
-#define _VA_ELEM7(v, a, b, c, d, e, f) (_VA_ELEM6(v, a, b, c, d, e) || ((v) == (f)))
-#define _VA_ELEM8(v, a, b, c, d, e, f, g) (_VA_ELEM7(v, a, b, c, d, e, f) || ((v) == (g)))
-#define _VA_ELEM9(v, a, b, c, d, e, f, g, h) (_VA_ELEM8(v, a, b, c, d, e, f, g) || ((v) == (h)))
+#define _VA_ELEM3(v, a, b) \
+ (_VA_ELEM2(v, a) || _VA_ELEM2(v, b))
+#define _VA_ELEM4(v, a, b, c) \
+ (_VA_ELEM3(v, a, b) || _VA_ELEM2(v, c))
+#define _VA_ELEM5(v, a, b, c, d) \
+ (_VA_ELEM4(v, a, b, c) || _VA_ELEM2(v, d))
+#define _VA_ELEM6(v, a, b, c, d, e) \
+ (_VA_ELEM5(v, a, b, c, d) || _VA_ELEM2(v, e))
+#define _VA_ELEM7(v, a, b, c, d, e, f) \
+ (_VA_ELEM6(v, a, b, c, d, e) || _VA_ELEM2(v, f))
+#define _VA_ELEM8(v, a, b, c, d, e, f, g) \
+ (_VA_ELEM7(v, a, b, c, d, e, f) || _VA_ELEM2(v, g))
+#define _VA_ELEM9(v, a, b, c, d, e, f, g, h) \
+ (_VA_ELEM8(v, a, b, c, d, e, f, g) || _VA_ELEM2(v, h))
#define _VA_ELEM10(v, a, b, c, d, e, f, g, h, i) \
- (_VA_ELEM9(v, a, b, c, d, e, f, g, h) || ((v) == (i)))
+ (_VA_ELEM9(v, a, b, c, d, e, f, g, h) || _VA_ELEM2(v, i))
#define _VA_ELEM11(v, a, b, c, d, e, f, g, h, i, j) \
- (_VA_ELEM10(v, a, b, c, d, e, f, g, h, i) || ((v) == (j)))
+ (_VA_ELEM10(v, a, b, c, d, e, f, g, h, i) || _VA_ELEM2(v, j))
#define _VA_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) \
- (_VA_ELEM11(v, a, b, c, d, e, f, g, h, i, j) || ((v) == (k)))
+ (_VA_ELEM11(v, a, b, c, d, e, f, g, h, i, j) || _VA_ELEM2(v, k))
#define _VA_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) \
- (_VA_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) || ((v) == (l)))
+ (_VA_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) || _VA_ELEM2(v, l))
#define _VA_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) \
- (_VA_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) || ((v) == (m)))
+ (_VA_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) || _VA_ELEM2(v, m))
#define _VA_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) \
- (_VA_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) || ((v) == (n)))
+ (_VA_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) || _VA_ELEM2(v, n))
#define _VA_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) \
- (_VA_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) || ((v) == (o)))
+ (_VA_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) || _VA_ELEM2(v, o))
#define _VA_ELEM17(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
- (_VA_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) || ((v) == (p)))
+ (_VA_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) || _VA_ELEM2(v, p))
+/* clang-format on */
/* reusable ELEM macro */
#define ELEM(...) VA_NARGS_CALL_OVERLOAD(_VA_ELEM, __VA_ARGS__)
@@ -692,7 +703,8 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
* args = [(chr(ord('a') + (c % 26)) + (chr(ord('0') + (c // 26)))) for c in range(i + 1)]
* print("#define _VA_UNUSED_VARS_%d(%s) \\" % (i + 1, ", ".join(args)))
* print("\t((void)(%s)%s)" %
- * (args[0], ((", _VA_UNUSED_VARS_" + str(i) + "(%s)") if i else "%s") % ", ".join((args[1:]))))
+ * (args[0], ((", _VA_UNUSED_VARS_" + str(i) + "(%s)") if i else "%s") %
+ * ", ".join((args[1:]))))
* \endcode
*/
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index f4b951dc8a3..dbc72ff1213 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -22,9 +22,9 @@ set(INC
.
# ../blenkernel # dont add this back!
../makesdna
- ../../../intern/guardedalloc
../../../intern/atomic
../../../intern/eigen
+ ../../../intern/guardedalloc
../../../intern/numaapi/include
../../../extern/wcwidth
)
diff --git a/source/blender/blenlib/PIL_time.h b/source/blender/blenlib/PIL_time.h
index 7d8983dea57..21ebc9d4b90 100644
--- a/source/blender/blenlib/PIL_time.h
+++ b/source/blender/blenlib/PIL_time.h
@@ -31,17 +31,14 @@ extern "C" {
extern
/** Return an indication of time, expressed as
- * seconds since some fixed point. Successive calls
- * are guaranteed to generate values greater than or
- * equal to the last call.
- */
+ * seconds since some fixed point. Successive calls
+ * are guaranteed to generate values greater than or
+ * equal to the last call. */
double
PIL_check_seconds_timer(void);
extern
- /**
- * int version of #PIL_check_seconds_timer
- */
+ /** `int` version of #PIL_check_seconds_timer. */
long int
PIL_check_seconds_timer_i(void);
diff --git a/source/blender/blenlib/PIL_time_utildefines.h b/source/blender/blenlib/PIL_time_utildefines.h
index cfdea54bf37..198b6d1bb21 100644
--- a/source/blender/blenlib/PIL_time_utildefines.h
+++ b/source/blender/blenlib/PIL_time_utildefines.h
@@ -62,8 +62,9 @@
(void)0
/**
- * _AVERAGED variants do same thing as their basic counterpart, but additionally add elapsed time to an averaged
- * static value, useful to get sensible timing of code running fast and often.
+ * _AVERAGED variants do same thing as their basic counterpart,
+ * but additionally add elapsed time to an averaged static value,
+ * useful to get sensible timing of code running fast and often.
*/
#define TIMEIT_START_AVERAGED(var) \
{ \
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index c0ec1eba9c0..769bb02e2b9 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -73,7 +73,8 @@ BLI_STATIC_ASSERT(ARRAY_SIZE(hashsizes) == GHASH_MAX_SIZE, "Invalid 'hashsizes'
/**
* \note Max load #GHASH_LIMIT_GROW used to be 3. (pre 2.74).
* Python uses 0.6666, tommyhashlib even goes down to 0.5.
- * Reducing our from 3 to 0.75 gives huge speedup (about twice quicker pure GHash insertions/lookup,
+ * Reducing our from 3 to 0.75 gives huge speedup
+ * (about twice quicker pure GHash insertions/lookup,
* about 25% - 30% quicker 'dynamic-topology' stroke drawing e.g.).
* Min load #GHASH_LIMIT_SHRINK is a quarter of max load, to avoid resizing to quickly.
*/
@@ -379,7 +380,8 @@ BLI_INLINE void ghash_buckets_reset(GHash *gh, const uint nentries)
/**
* Internal lookup function.
- * Takes hash and bucket_index arguments to avoid calling #ghash_keyhash and #ghash_bucket_index multiple times.
+ * Takes hash and bucket_index arguments to avoid calling #ghash_keyhash and #ghash_bucket_index
+ * multiple times.
*/
BLI_INLINE Entry *ghash_lookup_entry_ex(GHash *gh, const void *key, const uint bucket_index)
{
@@ -397,7 +399,8 @@ BLI_INLINE Entry *ghash_lookup_entry_ex(GHash *gh, const void *key, const uint b
/**
* Internal lookup function, returns previous entry of target one too.
- * Takes bucket_index argument to avoid calling #ghash_keyhash and #ghash_bucket_index multiple times.
+ * Takes bucket_index argument to avoid calling #ghash_keyhash and #ghash_bucket_index
+ * multiple times.
* Useful when modifying buckets somehow (like removing an entry...).
*/
BLI_INLINE Entry *ghash_lookup_entry_prev_ex(GHash *gh,
@@ -451,7 +454,8 @@ static GHash *ghash_new(GHashHashFP hashfp,
/**
* Internal insert function.
- * Takes hash and bucket_index arguments to avoid calling #ghash_keyhash and #ghash_bucket_index multiple times.
+ * Takes hash and bucket_index arguments to avoid calling #ghash_keyhash and #ghash_bucket_index
+ * multiple times.
*/
BLI_INLINE void ghash_insert_ex(GHash *gh, void *key, void *val, const uint bucket_index)
{
@@ -723,7 +727,8 @@ GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info)
}
/**
- * Copy given GHash. Keys and values are also copied if relevant callback is provided, else pointers remain the same.
+ * Copy given GHash. Keys and values are also copied if relevant callback is provided,
+ * else pointers remain the same.
*/
GHash *BLI_ghash_copy(GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP valcopyfp)
{
@@ -951,7 +956,8 @@ bool BLI_ghash_haskey(GHash *gh, const void *key)
}
/**
- * Remove a random entry from \a gh, returning true if a key/value pair could be removed, false otherwise.
+ * Remove a random entry from \a gh, returning true
+ * if a key/value pair could be removed, false otherwise.
*
* \param r_key: The removed key.
* \param r_val: The removed value.
@@ -1332,7 +1338,8 @@ int BLI_gset_buckets_len(GSet *gs)
/**
* Measure how well the hash function performs (1.0 is approx as good as random distribution),
- * and return a few other stats like load, variance of the distribution of the entries in the buckets, etc.
+ * and return a few other stats like load,
+ * variance of the distribution of the entries in the buckets, etc.
*
* Smaller is better!
*/
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 22e64d6717b..98e8a5ee425 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -622,9 +622,12 @@ static int implicit_leafs_index(const BVHBuildHelper *data, const int depth, con
/**
* Generalized implicit tree build
*
- * An implicit tree is a tree where its structure is implied, thus there is no need to store child pointers or indexs.
- * Its possible to find the position of the child or the parent with simple maths (multiplication and adittion).
- * This type of tree is for example used on heaps.. where node N has its childs at indexs N*2 and N*2+1.
+ * An implicit tree is a tree where its structure is implied,
+ * thus there is no need to store child pointers or indexs.
+ * Its possible to find the position of the child or the parent with simple maths
+ * (multiplication and adittion).
+ * This type of tree is for example used on heaps..
+ * where node N has its childs at indexs N*2 and N*2+1.
*
* Although in this case the tree type is general.. and not know until runtime.
* tree_type stands for the maximum number of childs that a tree node can have.
@@ -766,14 +769,16 @@ static void non_recursive_bvh_div_nodes_task_cb(void *__restrict userdata,
* - At most only one branch will have NULL childs;
* - All leafs will be stored at level N or N+1.
*
- * This function creates an implicit tree on branches_array, the leafs are given on the leafs_array.
+ * This function creates an implicit tree on branches_array,
+ * the leafs are given on the leafs_array.
*
* The tree is built per depth levels. First branches at depth 1.. then branches at depth 2.. etc..
- * The reason is that we can build level N+1 from level N without any data dependencies.. thus it allows
- * to use multithread building.
+ * The reason is that we can build level N+1 from level N without any data dependencies..
+ * thus it allows to use multithread building.
*
- * To archive this is necessary to find how much leafs are accessible from a certain branch, BVHBuildHelper
- * #implicit_needed_branches and #implicit_leafs_index are auxiliary functions to solve that "optimal-split".
+ * To archive this is necessary to find how much leafs are accessible from a certain branch,
+ * #BVHBuildHelper, #implicit_needed_branches and #implicit_leafs_index
+ * are auxiliary functions to solve that "optimal-split".
*/
static void non_recursive_bvh_div_nodes(const BVHTree *tree,
BVHNode *branches_array,
@@ -1731,9 +1736,10 @@ float BLI_bvhtree_bb_raycast(const float bv[6],
* Calls the callback for every ray intersection
*
* \note Using a \a callback which resets or never sets the #BVHTreeRayHit index & dist works too,
- * however using this function means existing generic callbacks can be used from custom callbacks without
- * having to handle resetting the hit beforehand.
- * It also avoid redundant argument and return value which aren't meaningful when collecting multiple hits.
+ * however using this function means existing generic callbacks can be used from custom callbacks
+ * without having to handle resetting the hit beforehand.
+ * It also avoid redundant argument and return value which aren't meaningful
+ * when collecting multiple hits.
*/
void BLI_bvhtree_ray_cast_all_ex(BVHTree *tree,
const float co[3],
@@ -1786,7 +1792,8 @@ void BLI_bvhtree_ray_cast_all(BVHTree *tree,
/* -------------------------------------------------------------------- */
/** \name BLI_bvhtree_range_query
*
- * Allocs and fills an array with the indexs of node that are on the given spherical range (center, radius).
+ * Allocs and fills an array with the indexs of node that are on the given spherical range
+ * (center, radius).
* Returns the size of the array.
*
* \{ */
@@ -2063,7 +2070,8 @@ typedef struct BVHTree_WalkData {
} BVHTree_WalkData;
/**
- * Runs first among nodes children of the first node before going to the next node in the same layer.
+ * Runs first among nodes children of the first node before going
+ * to the next node in the same layer.
*
* \return false to break out of the search early.
*/
diff --git a/source/blender/blenlib/intern/BLI_linklist_lockfree.c b/source/blender/blenlib/intern/BLI_linklist_lockfree.c
index d27e65af778..795e5ba3140 100644
--- a/source/blender/blenlib/intern/BLI_linklist_lockfree.c
+++ b/source/blender/blenlib/intern/BLI_linklist_lockfree.c
@@ -57,10 +57,10 @@ void BLI_linklist_lockfree_insert(LockfreeLinkList *list, LockfreeLinkNode *node
{
/* Based on:
*
- * John D. Valois
- * Implementing Lock-Free Queues
+ * John D. Valois
+ * Implementing Lock-Free Queues
*
- * http://people.csail.mit.edu/bushl2/rpi/portfolio/lockfree-grape/documents/lock-free-linked-lists.pdf
+ * http://people.csail.mit.edu/bushl2/rpi/portfolio/lockfree-grape/documents/lock-free-linked-lists.pdf
*/
bool keep_working;
LockfreeLinkNode *tail_node;
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 0f65f8ecbf0..5765540a8f1 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -63,7 +63,8 @@
/**
* Important that this value is an is _not_ aligned with ``sizeof(void *)``.
- * So having a pointer to 2/4/8... aligned memory is enough to ensure the freeword will never be used.
+ * So having a pointer to 2/4/8... aligned memory is enough to ensure
+ * the freeword will never be used.
* To be safe, use a word thats the same in both directions.
*/
#define FREEWORD \
@@ -547,8 +548,10 @@ void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter)
/**
* Initialize an array of mempool iterators, #BLI_MEMPOOL_ALLOW_ITER flag must be set.
*
- * This is used in threaded code, to generate as much iterators as needed (each task should have its own),
- * such that each iterator goes over its own single chunk, and only getting the next chunk to iterate over has to be
+ * This is used in threaded code, to generate as much iterators as needed
+ * (each task should have its own),
+ * such that each iterator goes over its own single chunk,
+ * and only getting the next chunk to iterate over has to be
* protected against concurrency (which can be done in a lockless way).
*
* To be used when creating a task for each single item in the pool is totally overkill.
@@ -608,11 +611,9 @@ static void *bli_mempool_iternext(BLI_mempool_iter *iter)
if (iter->curchunk == NULL) {
return ret;
}
- if (atomic_cas_ptr(
- (void **)iter->curchunk_threaded_shared,
- iter->curchunk,
- iter->curchunk->next) == iter->curchunk)
- {
+ if (atomic_cas_ptr((void **)iter->curchunk_threaded_shared,
+ iter->curchunk,
+ iter->curchunk->next) == iter->curchunk) {
break;
}
}
diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c
index 59d80b45a84..7917730cd6a 100644
--- a/source/blender/blenlib/intern/DLRB_tree.c
+++ b/source/blender/blenlib/intern/DLRB_tree.c
@@ -515,7 +515,7 @@ static void insert_check_3(DLRBT_Tree *tree, DLRBT_Node *node)
if ((node == node->parent->left) && (node->parent == gp->left)) {
rotate_right(tree, gp);
}
- else { //if ((node == node->parent->right) && (node->parent == gp->right))
+ else { // if ((node == node->parent->right) && (node->parent == gp->right))
rotate_left(tree, gp);
}
}
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index 0e7b9a29ee5..825f2e36c6e 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -32,8 +32,10 @@
*
* - BArrayStore: The whole array store.
* - BArrayState: Represents a single state (array) of data.
- * These can be add using a reference state, while this could be considered the previous or parent state.
- * no relationship is kept, so the caller is free to add any state from the same BArrayStore as a reference.
+ * These can be add using a reference state,
+ * while this could be considered the previous or parent state.
+ * no relationship is kept,
+ * so the caller is free to add any state from the same BArrayStore as a reference.
*
* <pre>
* <+> BArrayStore: root data-structure,
@@ -136,7 +138,8 @@
/* For arrays of matching length, test that *enough* of the chunks are aligned,
* and simply step over both arrays, using matching chunks.
- * This avoids overhead of using a lookup table for cases when we can assume they're mostly aligned.
+ * This avoids overhead of using a lookup table for cases
+ * when we can assume they're mostly aligned.
*/
#define USE_ALIGN_CHUNKS_TEST
@@ -1411,7 +1414,8 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info,
* but adds overhead by increasing the number of chunks to look-up when searching for duplicates,
* as well as some overhead constructing the original array again, with more calls to ``memcpy``.
* - Larger values reduce the *book keeping* overhead,
- * but increase the chance a small, isolated change will cause a larger amount of data to be duplicated.
+ * but increase the chance a small,
+ * isolated change will cause a larger amount of data to be duplicated.
*
* \return A new array store, to be freed with #BLI_array_store_destroy.
*/
@@ -1542,7 +1546,8 @@ size_t BLI_array_store_calc_size_compacted_get(const BArrayStore *bs)
* typically this is the previous state,
* however it can be any previously created state from this \a bs.
*
- * \return The new state, which is used by the caller as a handle to get back the contents of \a data.
+ * \return The new state,
+ * which is used by the caller as a handle to get back the contents of \a data.
* This may be removed using #BLI_array_store_state_remove,
* otherwise it will be removed with #BLI_array_store_destroy.
*/
diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c
index f941c05e570..25bcf7136f7 100644
--- a/source/blender/blenlib/intern/array_utils.c
+++ b/source/blender/blenlib/intern/array_utils.c
@@ -185,7 +185,8 @@ void _bli_array_binary_or(
* \param use_wrap: Detect contiguous ranges across the first/last points.
* In this case the second index of \a span_step may be lower than the first,
* which indicates the values are wrapped.
- * \param use_delimit_bounds: When false, ranges that defined by the start/end indices are excluded.
+ * \param use_delimit_bounds: When false,
+ * ranges that defined by the start/end indices are excluded.
* This option has no effect when \a use_wrap is enabled.
* \param test_fn: Function to test if the item should be included in the range.
* \param user_data: User data for \a test_fn.
diff --git a/source/blender/blenlib/intern/astar.c b/source/blender/blenlib/intern/astar.c
index c275f679dc6..c8f2160f0b6 100644
--- a/source/blender/blenlib/intern/astar.c
+++ b/source/blender/blenlib/intern/astar.c
@@ -27,13 +27,16 @@
* in addition to distance already walked. This heuristic allows more efficiency
* in finding optimal path.
*
- * Implementation based on Wikipedia A* page [https://en.wikipedia.org/wiki/A*_search_algorithm].
+ * Implementation based on Wikipedia A* page:
+ * https://en.wikipedia.org/wiki/A*_search_algorithm
*
- * Note that most memory handling here is done through two different MemArena's. Those should also be used to allocate
+ * Note that most memory handling here is done through two different MemArena's.
+ * Those should also be used to allocate
* custom data needed to a specific use of A*.
- * The first one, owned by BLI_AStarGraph, is for 'static' data that will live as long as the graph.
- * The second one, owned by BLI_AStarSolution, is for data used during a single path solve. It will be cleared
- * much more often than graph's one.
+ * The first one, owned by BLI_AStarGraph,
+ * is for 'static' data that will live as long as the graph.
+ * The second one, owned by BLI_AStarSolution, is for data used during a single path solve.
+ * It will be cleared much more often than graph's one.
*/
#include <limits.h>
@@ -53,7 +56,8 @@
/**
* Init a node in A* graph.
*
- * \param custom_data: an opaque pointer attached to this link, available e.g. to cost callback function.
+ * \param custom_data: an opaque pointer attached to this link,
+ * available e.g. to cost callback function.
*/
void BLI_astar_node_init(BLI_AStarGraph *as_graph, const int node_index, void *custom_data)
{
@@ -63,8 +67,10 @@ void BLI_astar_node_init(BLI_AStarGraph *as_graph, const int node_index, void *c
/**
* Add a link between two nodes of our A* graph.
*
- * \param cost: the 'length' of the link (actual distance between two vertices or face centers e.g.).
- * \param custom_data: an opaque pointer attached to this link, available e.g. to cost callback function.
+ * \param cost: the 'length' of the link
+ * (actual distance between two vertices or face centers e.g.).
+ * \param custom_data: an opaque pointer attached to this link,
+ * available e.g. to cost callback function.
*/
void BLI_astar_node_link_add(BLI_AStarGraph *as_graph,
const int node1_index,
@@ -98,7 +104,8 @@ int BLI_astar_node_link_other_node(BLI_AStarGNLink *lnk, const int idx)
/**
* Initialize a solution data for given A* graph. Does not compute anything!
*
- * \param custom_data: an opaque pointer attached to this link, available e.g. to cost callback function.
+ * \param custom_data: an opaque pointer attached to this link, available e.g
+ * . to cost callback function.
*
* \note BLI_AStarSolution stores nearly all data needed during solution compute.
*/
@@ -165,7 +172,8 @@ void BLI_astar_solution_free(BLI_AStarSolution *as_solution)
*
* Nodes might be e.g. vertices, faces, ...
*
- * \param custom_data: an opaque pointer attached to this link, available e.g. to cost callback function.
+ * \param custom_data: an opaque pointer attached to this link,
+ * available e.g. to cost callback function.
*/
void BLI_astar_graph_init(BLI_AStarGraph *as_graph, const int node_num, void *custom_data)
{
@@ -194,8 +202,9 @@ void BLI_astar_graph_free(BLI_AStarGraph *as_graph)
/**
* Solve a path in given graph, using given 'cost' callback function.
*
- * \param max_steps: maximum number of nodes the found path may have. Useful in performance-critical usages.
- * If no path is found within given steps, returns false too.
+ * \param max_steps: maximum number of nodes the found path may have.
+ * Useful in performance-critical usages.
+ * If no path is found within given steps, returns false too.
* \return true if a path was found, false otherwise.
*/
bool BLI_astar_graph_solve(BLI_AStarGraph *as_graph,
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index 528f206c02e..9b846dfa08d 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -144,8 +144,7 @@ static void edgehash_free_values(EdgeHash *eh, EdgeHashFreeFP free_value)
BLI_INLINE void edgehash_insert_index(EdgeHash *eh, Edge edge, uint entry_index)
{
- ITER_SLOTS(eh, edge, slot, index)
- {
+ ITER_SLOTS (eh, edge, slot, index) {
if (index == SLOT_EMPTY) {
eh->map[slot] = (int32_t)entry_index;
break;
@@ -182,8 +181,7 @@ BLI_INLINE bool edgehash_ensure_can_insert(EdgeHash *eh)
BLI_INLINE EdgeHashEntry *edgehash_insert(EdgeHash *eh, Edge edge, void *value)
{
- ITER_SLOTS(eh, edge, slot, index)
- {
+ ITER_SLOTS (eh, edge, slot, index) {
if (index == SLOT_EMPTY) {
return edgehash_insert_at_slot(eh, slot, edge, value);
}
@@ -198,8 +196,7 @@ BLI_INLINE EdgeHashEntry *edgehash_lookup_entry(EdgeHash *eh, uint v0, uint v1)
{
Edge edge = init_edge(v0, v1);
- ITER_SLOTS(eh, edge, slot, index)
- {
+ ITER_SLOTS (eh, edge, slot, index) {
if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
return &eh->entries[index];
}
@@ -211,8 +208,7 @@ BLI_INLINE EdgeHashEntry *edgehash_lookup_entry(EdgeHash *eh, uint v0, uint v1)
BLI_INLINE void edgehash_change_index(EdgeHash *eh, Edge edge, int new_index)
{
- ITER_SLOTS(eh, edge, slot, index)
- {
+ ITER_SLOTS (eh, edge, slot, index) {
if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
eh->map[slot] = new_index;
break;
@@ -293,8 +289,7 @@ bool BLI_edgehash_reinsert(EdgeHash *eh, uint v0, uint v1, void *value)
{
Edge edge = init_edge(v0, v1);
- ITER_SLOTS(eh, edge, slot, index)
- {
+ ITER_SLOTS (eh, edge, slot, index) {
if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
eh->entries[index].value = value;
return false;
@@ -360,8 +355,7 @@ bool BLI_edgehash_ensure_p(EdgeHash *eh, uint v0, uint v1, void ***r_value)
{
Edge edge = init_edge(v0, v1);
- ITER_SLOTS(eh, edge, slot, index)
- {
+ ITER_SLOTS (eh, edge, slot, index) {
if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
*r_value = &eh->entries[index].value;
return true;
@@ -407,8 +401,7 @@ void *BLI_edgehash_popkey(EdgeHash *eh, uint v0, uint v1)
{
Edge edge = init_edge(v0, v1);
- ITER_SLOTS(eh, edge, slot, index)
- {
+ ITER_SLOTS (eh, edge, slot, index) {
if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
void *value = eh->entries[index].value;
eh->length--;
@@ -546,8 +539,7 @@ int BLI_edgeset_len(EdgeSet *es)
static void edgeset_insert_index(EdgeSet *es, Edge edge, uint entry_index)
{
- ITER_SLOTS(es, edge, slot, index)
- {
+ ITER_SLOTS (es, edge, slot, index) {
if (index == SLOT_EMPTY) {
es->map[slot] = (int)entry_index;
break;
@@ -587,8 +579,7 @@ bool BLI_edgeset_add(EdgeSet *es, uint v0, uint v1)
edgeset_ensure_can_insert(es);
Edge edge = init_edge(v0, v1);
- ITER_SLOTS(es, edge, slot, index)
- {
+ ITER_SLOTS (es, edge, slot, index) {
if (ES_INDEX_HAS_EDGE(es, index, edge)) {
return false;
}
@@ -608,8 +599,7 @@ void BLI_edgeset_insert(EdgeSet *es, uint v0, uint v1)
edgeset_ensure_can_insert(es);
Edge edge = init_edge(v0, v1);
- ITER_SLOTS(es, edge, slot, index)
- {
+ ITER_SLOTS (es, edge, slot, index) {
if (index == SLOT_EMPTY) {
edgeset_insert_at_slot(es, slot, edge);
return;
@@ -621,8 +611,7 @@ bool BLI_edgeset_haskey(EdgeSet *es, uint v0, uint v1)
{
Edge edge = init_edge(v0, v1);
- ITER_SLOTS(es, edge, slot, index)
- {
+ ITER_SLOTS (es, edge, slot, index) {
if (ES_INDEX_HAS_EDGE(es, index, edge)) {
return true;
}
diff --git a/source/blender/blenlib/intern/expr_pylike_eval.c b/source/blender/blenlib/intern/expr_pylike_eval.c
index 40df9711ef1..6dc0203ead2 100644
--- a/source/blender/blenlib/intern/expr_pylike_eval.c
+++ b/source/blender/blenlib/intern/expr_pylike_eval.c
@@ -356,27 +356,29 @@ typedef struct BuiltinOpDef {
void *funcptr;
} BuiltinOpDef;
-static BuiltinOpDef builtin_ops[] = {{"radians", OPCODE_FUNC1, op_radians},
- {"degrees", OPCODE_FUNC1, op_degrees},
- {"abs", OPCODE_FUNC1, fabs},
- {"fabs", OPCODE_FUNC1, fabs},
- {"floor", OPCODE_FUNC1, floor},
- {"ceil", OPCODE_FUNC1, ceil},
- {"trunc", OPCODE_FUNC1, trunc},
- {"int", OPCODE_FUNC1, trunc},
- {"sin", OPCODE_FUNC1, sin},
- {"cos", OPCODE_FUNC1, cos},
- {"tan", OPCODE_FUNC1, tan},
- {"asin", OPCODE_FUNC1, asin},
- {"acos", OPCODE_FUNC1, acos},
- {"atan", OPCODE_FUNC1, atan},
- {"atan2", OPCODE_FUNC2, atan2},
- {"exp", OPCODE_FUNC1, exp},
- {"log", OPCODE_FUNC1, log},
- {"sqrt", OPCODE_FUNC1, sqrt},
- {"pow", OPCODE_FUNC2, pow},
- {"fmod", OPCODE_FUNC2, fmod},
- {NULL, OPCODE_CONST, NULL}};
+static BuiltinOpDef builtin_ops[] = {
+ {"radians", OPCODE_FUNC1, op_radians},
+ {"degrees", OPCODE_FUNC1, op_degrees},
+ {"abs", OPCODE_FUNC1, fabs},
+ {"fabs", OPCODE_FUNC1, fabs},
+ {"floor", OPCODE_FUNC1, floor},
+ {"ceil", OPCODE_FUNC1, ceil},
+ {"trunc", OPCODE_FUNC1, trunc},
+ {"int", OPCODE_FUNC1, trunc},
+ {"sin", OPCODE_FUNC1, sin},
+ {"cos", OPCODE_FUNC1, cos},
+ {"tan", OPCODE_FUNC1, tan},
+ {"asin", OPCODE_FUNC1, asin},
+ {"acos", OPCODE_FUNC1, acos},
+ {"atan", OPCODE_FUNC1, atan},
+ {"atan2", OPCODE_FUNC2, atan2},
+ {"exp", OPCODE_FUNC1, exp},
+ {"log", OPCODE_FUNC1, log},
+ {"sqrt", OPCODE_FUNC1, sqrt},
+ {"pow", OPCODE_FUNC2, pow},
+ {"fmod", OPCODE_FUNC2, fmod},
+ {NULL, OPCODE_CONST, NULL},
+};
/** \} */
@@ -413,12 +415,14 @@ typedef struct KeywordTokenDef {
short token;
} KeywordTokenDef;
-static KeywordTokenDef keyword_list[] = {{"and", TOKEN_AND},
- {"or", TOKEN_OR},
- {"not", TOKEN_NOT},
- {"if", TOKEN_IF},
- {"else", TOKEN_ELSE},
- {NULL, TOKEN_ID}};
+static KeywordTokenDef keyword_list[] = {
+ {"and", TOKEN_AND},
+ {"or", TOKEN_OR},
+ {"not", TOKEN_NOT},
+ {"if", TOKEN_IF},
+ {"else", TOKEN_ELSE},
+ {NULL, TOKEN_ID},
+};
typedef struct ExprParseState {
int param_names_len;
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 9e07b4d2836..8fff9603a88 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -70,11 +70,13 @@ int BLI_file_gzip(const char *from, const char *to)
/* level 1 is very close to 3 (the default) in terms of file size,
* but about twice as fast, best use for speedy saving - campbell */
gzfile = BLI_gzopen(to, "wb1");
- if (gzfile == NULL)
+ if (gzfile == NULL) {
return -1;
+ }
file = BLI_open(from, O_BINARY | O_RDONLY, 0);
- if (file == -1)
+ if (file == -1) {
return -2;
+ }
while (1) {
readsize = read(file, buffer, sizeof(buffer));
@@ -84,8 +86,9 @@ int BLI_file_gzip(const char *from, const char *to)
fprintf(stderr, "Error reading file %s: %s.\n", from, strerror(errno));
break;
}
- else if (readsize == 0)
- break; /* done reading */
+ else if (readsize == 0) {
+ break; /* done reading */
+ }
if (gzwrite(gzfile, buffer, readsize) <= 0) {
rval = -1; /* error happened in writing */
@@ -946,8 +949,9 @@ static int move_callback_pre(const char *from, const char *to)
{
int ret = rename(from, to);
- if (ret)
+ if (ret) {
return copy_callback_pre(from, to);
+ }
return RecursiveOp_Callback_StopRecurs;
}
@@ -956,8 +960,9 @@ static int move_single_file(const char *from, const char *to)
{
int ret = rename(from, to);
- if (ret)
+ if (ret) {
return copy_single_file(from, to);
+ }
return RecursiveOp_Callback_OK;
}
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index a8b8f01fa22..7be7674069c 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -386,7 +386,7 @@ static int check_freetypefont(PackedFile *pf)
err = FT_New_Memory_Face(library, pf->data, pf->size, 0, &face);
if (err) {
success = 0;
- //XXX error("This is not a valid font");
+ // XXX error("This is not a valid font");
}
else {
glyph_index = FT_Get_Char_Index(face, 'A');
@@ -400,7 +400,7 @@ static int check_freetypefont(PackedFile *pf)
success = 1;
}
else {
- //XXX error("Selected Font has no outline data");
+ // XXX error("Selected Font has no outline data");
success = 0;
}
}
@@ -497,7 +497,7 @@ VChar *BLI_vfontchar_copy(const VChar *vchar_src, const int UNUSED(flag))
return vchar_dst;
}
-/*
+/**
* from: http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-1
*
* Vectorial representation of Freetype glyphs
@@ -508,27 +508,30 @@ VChar *BLI_vfontchar_copy(const VChar *vchar_src, const int UNUSED(flag))
* they come from the TrueType format. The latter are called cubic arcs and mostly come from the
* Type1 format.
*
- * Each arc is described through a series of start, end and control points. Each point of the outline
- * has a specific tag which indicates whether it is used to describe a line segment or an arc.
+ * Each arc is described through a series of start, end and control points.
+ * Each point of the outline has a specific tag which indicates whether it is
+ * used to describe a line segment or an arc.
* The following rules are applied to decompose the contour's points into segments and arcs :
*
* # two successive "on" points indicate a line segment joining them.
*
- * # one conic "off" point amidst two "on" points indicates a conic bezier arc, the "off" point being
- * the control point, and the "on" ones the start and end points.
+ * # one conic "off" point amidst two "on" points indicates a conic bezier arc,
+ * the "off" point being the control point, and the "on" ones the start and end points.
*
- * # Two successive cubic "off" points amidst two "on" points indicate a cubic bezier arc. There must
- * be exactly two cubic control points and two on points for each cubic arc (using a single cubic
- * "off" point between two "on" points is forbidden, for example).
+ * # Two successive cubic "off" points amidst two "on" points indicate a cubic bezier arc.
+ * There must be exactly two cubic control points and two on points for each cubic arc
+ * (using a single cubic "off" point between two "on" points is forbidden, for example).
*
- * # finally, two successive conic "off" points forces the rasterizer to create (during the scan-line
- * conversion process exclusively) a virtual "on" point amidst them, at their exact middle. This
- * greatly facilitates the definition of successive conic bezier arcs. Moreover, it's the way
- * outlines are described in the TrueType specification.
+ * # finally, two successive conic "off" points forces the rasterizer to create
+ * (during the scan-line conversion process exclusively) a virtual "on" point amidst them,
+ * at their exact middle.
+ * This greatly facilitates the definition of successive conic bezier arcs.
+ * Moreover, it's the way outlines are described in the TrueType specification.
*
* Note that it is possible to mix conic and cubic arcs in a single contour, even though no current
* font driver produces such outlines.
*
+ * <pre>
* * # on
* * off
* __---__
@@ -560,9 +563,11 @@ VChar *BLI_vfontchar_copy(const VChar *vchar_src, const int UNUSED(flag))
* Two "on" points
* and two "cubic" point
* between them
- * Each glyph's original outline points are located on a grid of indivisible units. The points are stored
- * in the font file as 16-bit integer grid coordinates, with the grid origin's being at (0, 0); they thus
- * range from -16384 to 16383.
+ * </pre>
+ *
+ * Each glyph's original outline points are located on a grid of indivisible units.
+ * The points are stored in the font file as 16-bit integer grid coordinates,
+ * with the grid origin's being at (0, 0); they thus range from -16384 to 16383.
*
* Convert conic to bezier arcs:
* Conic P0 P1 P2
diff --git a/source/blender/blenlib/intern/hash_md5.c b/source/blender/blenlib/intern/hash_md5.c
index d3ba5ee1a3b..44a9348c5d3 100644
--- a/source/blender/blenlib/intern/hash_md5.c
+++ b/source/blender/blenlib/intern/hash_md5.c
@@ -49,8 +49,9 @@
#endif
/* If UINT_MAX isn't defined, assume it's a 32-bit type.
- * This should be valid for all systems GNU cares about because that doesn't include 16-bit systems,
- * and only modern systems (that certainly have <limits.h>) have 64+-bit integral types.
+ * This should be valid for all systems GNU cares about
+ * because that doesn't include 16-bit systems, and only modern systems
+ * (that certainly have <limits.h>) have 64+-bit integral types.
*/
#ifndef UINT_MAX
@@ -359,9 +360,10 @@ int BLI_hash_md5_stream(FILE *stream, void *resblock)
return 0;
}
-/** Compute MD5 message digest for 'len' bytes beginning at 'buffer'.
- * The result is always in little endian byte order, so that a byte-wise output yields to the wanted
- * ASCII representation of the message digest.
+/**
+ * Compute MD5 message digest for 'len' bytes beginning at 'buffer'.
+ * The result is always in little endian byte order,
+ * so that a byte-wise output yields to the wanted ASCII representation of the message digest.
*/
void *BLI_hash_md5_buffer(const char *buffer, size_t len, void *resblock)
{
diff --git a/source/blender/blenlib/intern/hash_mm2a.c b/source/blender/blenlib/intern/hash_mm2a.c
index ee4a6329f64..0899491cd0d 100644
--- a/source/blender/blenlib/intern/hash_mm2a.c
+++ b/source/blender/blenlib/intern/hash_mm2a.c
@@ -23,11 +23,12 @@
* A very fast hash generating int32 result, with few collisions and good repartition.
*
* See also:
- * reference implementation: https://smhasher.googlecode.com/svn-history/r130/trunk/MurmurHash2.cpp
- * and http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed
+ * reference implementation:
+ * - https://smhasher.googlecode.com/svn-history/r130/trunk/MurmurHash2.cpp
+ * - http://programmers.stackexchange.com/questions/49550
*
- * \warning Do not store that hash in files or such, it is not endian-agnostic, so you should only use it
- * for temporary data.
+ * \warning Do not store that hash in files or such, it is not endian-agnostic,
+ * so you should only use it for temporary data.
*/
#include "BLI_compiler_attrs.h"
diff --git a/source/blender/blenlib/intern/kdtree_impl.h b/source/blender/blenlib/intern/kdtree_impl.h
index a4b1833e657..32e8a4e90f5 100644
--- a/source/blender/blenlib/intern/kdtree_impl.h
+++ b/source/blender/blenlib/intern/kdtree_impl.h
@@ -58,7 +58,8 @@ struct KDTree {
#define KD_NODE_UNSET ((uint)-1)
-/** When set we know all values are unbalanced, otherwise clear them when re-balancing: see T62210. */
+/** When set we know all values are unbalanced,
+ * otherwise clear them when re-balancing: see T62210. */
#define KD_NODE_ROOT_IS_INIT ((uint)-2)
/* -------------------------------------------------------------------- */
@@ -732,7 +733,8 @@ int BLI_kdtree_nd_(range_search)(const KDTree *tree,
* A version of #BLI_kdtree_3d_range_search which runs a callback
* instead of allocating an array.
*
- * \param search_cb: Called for every node found in \a range, false return value performs an early exit.
+ * \param search_cb: Called for every node found in \a range,
+ * false return value performs an early exit.
*
* \note the order of calls isn't sorted based on distance.
*/
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index ff9e21319da..31d372945c6 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -224,7 +224,8 @@ void BLI_listbase_swaplinks(ListBase *listbase, void *vlinka, void *vlinkb)
}
/**
- * Swaps \a vlinka and \a vlinkb from their respective lists. Assumes they are both already in their lista!
+ * Swaps \a vlinka and \a vlinkb from their respective lists.
+ * Assumes they are both already in their lista!
*/
void BLI_listbases_swaplinks(ListBase *listbasea, ListBase *listbaseb, void *vlinka, void *vlinkb)
{
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index f1ceaca4eb1..221a27f69ed 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -428,11 +428,13 @@ MINLINE int compare_ff(float a, float b, const float max_diff)
}
/**
- * Almost-equal for IEEE floats, using their integer representation (mixing ULP and absolute difference methods).
+ * Almost-equal for IEEE floats, using their integer representation
+ * (mixing ULP and absolute difference methods).
*
* \param max_diff: is the maximum absolute difference (allows to take care of the near-zero area,
- * where relative difference methods cannot really work).
- * \param max_ulps: is the 'maximum number of floats + 1' allowed between \a a and \a b to consider them equal.
+ * where relative difference methods cannot really work).
+ * \param max_ulps: is the 'maximum number of floats + 1'
+ * allowed between \a a and \a b to consider them equal.
*
* \see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
*/
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index bc1699451f3..f07c2ec159e 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -355,11 +355,11 @@ void hsv_clamp_v(float hsv[3], float v_max)
}
/**
- * We define a 'cpack' here as a (3 byte color code) number that can be expressed like 0xFFAA66 or so.
- * for that reason it is sensitive for endianness... with this function it works correctly.
+ * We define a 'cpack' here as a (3 byte color code)
+ * number that can be expressed like 0xFFAA66 or so.
+ * For that reason it is sensitive for endianness... with this function it works correctly.
* \see #imm_cpack
*/
-
unsigned int hsv_to_cpack(float h, float s, float v)
{
unsigned int r, g, b;
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 1309eb12e4d..d7a2d681f33 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -265,8 +265,8 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack)
*
* \warning
* These are only an approximation,
- * in almost _all_ cases, #IMB_colormanagement_get_luminance should be used instead.
- * however for screen-only colors which don't depend on the currently loaded profile - this is preferred.
+ * in almost _all_ cases, #IMB_colormanagement_get_luminance should be used instead. However for
+ * screen-only colors which don't depend on the currently loaded profile - this is preferred.
* Checking theme colors for contrast, etc. Basically anything outside the render pipeline.
*
* \{ */
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 7d7ff3f450f..898e97613c1 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -599,7 +599,8 @@ float dist_squared_to_ray_v3_normalized(const float ray_origin[3],
/**
* Find the closest point in a seg to a ray and return the distance squared.
- * \param r_point: Is the point on segment closest to ray (or to ray_origin if the ray and the segment are parallel).
+ * \param r_point: Is the point on segment closest to ray
+ * (or to ray_origin if the ray and the segment are parallel).
* \param r_depth: the distance of r_point projection on ray to the ray_origin.
*/
float dist_squared_ray_to_seg_v3(const float ray_origin[3],
@@ -828,14 +829,9 @@ void dist_squared_to_projected_aabb_precalc(struct DistProjectedAABBPrecalc *pre
float projmat_trans[4][4];
transpose_m4_m4(projmat_trans, projmat);
if (!isect_plane_plane_plane_v3(
- projmat_trans[0], projmat_trans[1], projmat_trans[3],
- precalc->ray_origin))
- {
+ projmat_trans[0], projmat_trans[1], projmat_trans[3], precalc->ray_origin)) {
/* Orthographic projection. */
- isect_plane_plane_v3(
- px, py,
- precalc->ray_origin,
- precalc->ray_direction);
+ isect_plane_plane_v3(px, py, precalc->ray_origin, precalc->ray_direction);
}
else {
/* Perspective projection. */
@@ -1904,12 +1900,11 @@ bool isect_ray_tri_watertight_v3(const float ray_origin[3],
const float t = (u * a_kz + v * b_kz + w * c_kz) * sz;
const float sign_t = xor_fl(t, sign_det);
if ((sign_t < 0.0f)
- /* differ from Cycles, don't read r_lambda's original value
- * otherwise we won't match any of the other intersect functions here...
- * which would be confusing */
+ /* Differ from Cycles, don't read r_lambda's original value
+ * otherwise we won't match any of the other intersect functions here...
+ * which would be confusing. */
#if 0
- ||
- (sign_T > *r_lambda * xor_signmask(det, sign_mask))
+ || (sign_T > *r_lambda * xor_signmask(det, sign_mask))
#endif
) {
return false;
@@ -1945,10 +1940,14 @@ bool isect_ray_tri_watertight_v3_simple(const float ray_origin[3],
* A version of #isect_ray_tri_v3 which takes a threshold argument
* so rays slightly outside the triangle to be considered as intersecting.
*/
-bool isect_ray_tri_threshold_v3(
- const float ray_origin[3], const float ray_direction[3],
- const float v0[3], const float v1[3], const float v2[3],
- float *r_lambda, float r_uv[2], const float threshold)
+bool isect_ray_tri_threshold_v3(const float ray_origin[3],
+ const float ray_direction[3],
+ const float v0[3],
+ const float v1[3],
+ const float v2[3],
+ float *r_lambda,
+ float r_uv[2],
+ const float threshold)
{
const float epsilon = 0.00000001f;
float p[3], s[3], e1[3], e2[3], q[3];
@@ -1960,14 +1959,16 @@ bool isect_ray_tri_threshold_v3(
cross_v3_v3v3(p, ray_direction, e2);
a = dot_v3v3(e1, p);
- if ((a > -epsilon) && (a < epsilon)) return false;
+ if ((a > -epsilon) && (a < epsilon))
+ return false;
f = 1.0f / a;
sub_v3_v3v3(s, ray_origin, v0);
cross_v3_v3v3(q, s, e1);
*r_lambda = f * dot_v3v3(e2, q);
- if ((*r_lambda < 0.0f)) return false;
+ if ((*r_lambda < 0.0f))
+ return false;
u = f * dot_v3v3(s, p);
v = f * dot_v3v3(ray_direction, q);
@@ -1978,13 +1979,19 @@ bool isect_ray_tri_threshold_v3(
dv = v - t;
}
else {
- if (u < 0) du = u;
- else if (u > 1) du = u - 1;
- else du = 0.0f;
+ if (u < 0)
+ du = u;
+ else if (u > 1)
+ du = u - 1;
+ else
+ du = 0.0f;
- if (v < 0) dv = v;
- else if (v > 1) dv = v - 1;
- else dv = 0.0f;
+ if (v < 0)
+ dv = v;
+ else if (v > 1)
+ dv = v - 1;
+ else
+ dv = 0.0f;
}
mul_v3_fl(e1, du);
@@ -2849,7 +2856,7 @@ bool isect_ray_aabb_v3(const struct IsectRayAABB_Precalc *data,
/* Note: tmax does not need to be updated since we don't use it
* keeping this here for future reference - jwilkins */
- //if (tzmax < tmax) tmax = tzmax;
+ // if (tzmax < tmax) tmax = tzmax;
if (tmin_out) {
(*tmin_out) = tmin;
@@ -2862,7 +2869,8 @@ bool isect_ray_aabb_v3(const struct IsectRayAABB_Precalc *data,
* Test a bounding box (AABB) for ray intersection.
* Assumes the ray is already local to the boundbox space.
*
- * \note: \a direction should be normalized if you intend to use the \a tmin or \a tmax distance results!
+ * \note: \a direction should be normalized
+ * if you intend to use the \a tmin or \a tmax distance results!
*/
bool isect_ray_aabb_v3_simple(const float orig[3],
const float dir[3],
@@ -3125,7 +3133,8 @@ bool isect_point_tri_prism_v3(const float p[3],
/**
* \param r_isect_co: The point \a p projected onto the triangle.
* \return True when \a p is inside the triangle.
- * \note Its up to the caller to check the distance between \a p and \a r_vi against an error margin.
+ * \note Its up to the caller to check the distance between \a p and \a r_vi
+ * against an error margin.
*/
bool isect_point_tri_v3(
const float p[3], const float v1[3], const float v2[3], const float v3[3], float r_isect_co[3])
@@ -3402,7 +3411,12 @@ void interp_weights_quad_v3(float w[4],
}
}
-/* return 1 of point is inside triangle, 2 if it's on the edge, 0 if point is outside of triangle */
+/**
+ * \return
+ * - 0 if the point is outside of triangle.
+ * - 1 if the point is inside triangle.
+ * - 2 if it's on the edge.
+ * */
int barycentric_inside_triangle_v2(const float w[3])
{
if (IN_RANGE(w[0], 0.0f, 1.0f) && IN_RANGE(w[1], 0.0f, 1.0f) && IN_RANGE(w[2], 0.0f, 1.0f)) {
@@ -3463,7 +3477,8 @@ void barycentric_weights_v2(
/**
* A version of #barycentric_weights_v2 that doesn't allow negative weights.
- * Useful when negative values cause problems and points are only ever slightly outside of the triangle.
+ * Useful when negative values cause problems and points are only
+ * ever slightly outside of the triangle.
*/
void barycentric_weights_v2_clamped(
const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
@@ -3518,9 +3533,9 @@ void barycentric_weights_v2_quad(const float v1[2],
float w[4])
{
/* note: fabsf() here is not needed for convex quads (and not used in interp_weights_poly_v2).
- * but in the case of concave/bow-tie quads for the mask rasterizer it gives unreliable results
- * without adding absf(). If this becomes an issue for more general usage we could have
- * this optional or use a different function - Campbell */
+ * but in the case of concave/bow-tie quads for the mask rasterizer it gives unreliable results
+ * without adding absf(). If this becomes an issue for more general usage we could have
+ * this optional or use a different function - Campbell */
#define MEAN_VALUE_HALF_TAN_V2(_area, i1, i2) \
((_area = cross_v2v2(dirs[i1], dirs[i2])) != 0.0f ? \
fabsf(((lens[i1] * lens[i2]) - dot_v2v2(dirs[i1], dirs[i2])) / _area) : \
@@ -4332,7 +4347,8 @@ void window_translate_m4(float winmat[4][4], float perspmat[4][4], const float x
}
/**
- * Frustum planes extraction from a projection matrix (homogeneous 4d vector representations of planes).
+ * Frustum planes extraction from a projection matrix
+ * (homogeneous 4d vector representations of planes).
*
* plane parameters can be NULL if you do not need them.
*/
@@ -4808,7 +4824,8 @@ void tangent_from_uv_v3(const float uv1[2],
* \param pos: current pos array of 'new' positions
* \param weight: current weight array of 'new'weights (may be NULL pointer if you have no weights)
* \param rpos: Reference rpos array of 'old' positions
- * \param rweight: Reference rweight array of 'old'weights (may be NULL pointer if you have no weights).
+ * \param rweight: Reference rweight array of 'old'weights
+ * (may be NULL pointer if you have no weights).
*
* output
*
@@ -5212,20 +5229,20 @@ typedef union {
static vFloat vec_splat_float(float val)
{
- return (vFloat) {val, val, val, val};
+ return (vFloat){val, val, val, val};
}
static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3)
{
vFloat vcos, rlen, vrx, vry, vrz, vsrx, vsry, vsrz, gx, gy, gz, vangle;
- vUInt8 rotate = (vUInt8) {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3};
+ vUInt8 rotate = (vUInt8){4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3};
vFloatResult vresult;
float result;
/* compute r* */
- vrx = (vFloat) {q0[0], q1[0], q2[0], q3[0]} -vec_splat_float(p[0]);
- vry = (vFloat) {q0[1], q1[1], q2[1], q3[1]} -vec_splat_float(p[1]);
- vrz = (vFloat) {q0[2], q1[2], q2[2], q3[2]} -vec_splat_float(p[2]);
+ vrx = (vFloat){q0[0], q1[0], q2[0], q3[0]} - vec_splat_float(p[0]);
+ vry = (vFloat){q0[1], q1[1], q2[1], q3[1]} - vec_splat_float(p[1]);
+ vrz = (vFloat){q0[2], q1[2], q2[2], q3[2]} - vec_splat_float(p[2]);
/* normalize r* */
rlen = vec_rsqrte(vrx * vrx + vry * vry + vrz * vrz + vec_splat_float(1e-16f));
@@ -5255,9 +5272,9 @@ static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float
vangle = vacosf(vcos);
/* dot */
- vresult.v = (vec_splat_float(n[0]) * gx +
- vec_splat_float(n[1]) * gy +
- vec_splat_float(n[2]) * gz) * vangle;
+ vresult.v = (vec_splat_float(n[0]) * gx + vec_splat_float(n[1]) * gy +
+ vec_splat_float(n[2]) * gz) *
+ vangle;
result = (vresult.f[0] + vresult.f[1] + vresult.f[2] + vresult.f[3]) * (0.5f / (float)M_PI);
result = MAX2(result, 0.0f);
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c
index 6acfb538036..14fde18aa52 100644
--- a/source/blender/blenlib/intern/math_interp.c
+++ b/source/blender/blenlib/intern/math_interp.c
@@ -54,10 +54,8 @@ static float P(float k)
static float P(float k)
{
return (float)(1.0f / 6.0f) *
- (pow(MAX2(k + 2.0f, 0), 3.0f) - 4.0f *
- pow(MAX2(k + 1.0f, 0), 3.0f) + 6.0f *
- pow(MAX2(k, 0), 3.0f) - 4.0f *
- pow(MAX2(k - 1.0f, 0), 3.0f));
+ (pow(MAX2(k + 2.0f, 0), 3.0f) - 4.0f * pow(MAX2(k + 1.0f, 0), 3.0f) +
+ 6.0f * pow(MAX2(k, 0), 3.0f) - 4.0f * pow(MAX2(k - 1.0f, 0), 3.0f));
}
#endif
@@ -514,8 +512,9 @@ void BLI_bilinear_interpolation_wrap_char(const unsigned char *buffer,
* by Ned Greene and Paul S. Heckbert (1986)
***************************************************************************/
-/* table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2
- * used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible */
+/* Table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2
+ * used instead of actual gaussian,
+ * otherwise at high texture magnifications circular artifacts are visible. */
#define EWA_MAXIDX 255
const float EWA_WTS[EWA_MAXIDX + 1] = {
1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f,
@@ -623,9 +622,10 @@ void BLI_ewa_filter(const int width,
* so the ellipse always covers at least some texels. But since the filter is now always larger,
* it also means that everywhere else it's also more blurry then ideally should be the case.
* So instead here the ellipse radii are modified instead whenever either is too low.
- * Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off,
- * and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on
- * (minimum values: const float rmin = intpol ? 1.f : 0.5f;) */
+ * Use a different radius based on interpolation switch,
+ * just enough to anti-alias when interpolation is off,
+ * and slightly larger to make result a bit smoother than bilinear interpolation when
+ * interpolation is on (minimum values: const float rmin = intpol ? 1.f : 0.5f;) */
const float rmin = (intpol ? 1.5625f : 0.765625f) / ff2;
BLI_ewa_imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
if ((b2 = b * b) < rmin) {
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 71ea1ce1bc9..e09fae7d140 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -1897,8 +1897,10 @@ void blend_m4_m4m4(float out[4][4],
* A polar-decomposition-based interpolation between matrix A and matrix B.
*
* \note This code is about five times slower as the 'naive' interpolation done by #blend_m3_m3m3
- * (it typically remains below 2 usec on an average i74700, while #blend_m3_m3m3 remains below 0.4 usec).
- * However, it gives expected results even with non-uniformly scaled matrices, see T46418 for an example.
+ * (it typically remains below 2 usec on an average i74700,
+ * while #blend_m3_m3m3 remains below 0.4 usec).
+ * However, it gives expected results even with non-uniformly scaled matrices,
+ * see T46418 for an example.
*
* Based on "Matrix Animation and Polar Decomposition", by Ken Shoemake & Tom Duff
*
@@ -1937,7 +1939,8 @@ void interp_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3], con
}
/**
- * Complete transform matrix interpolation, based on polar-decomposition-based interpolation from #interp_m3_m3m3.
+ * Complete transform matrix interpolation,
+ * based on polar-decomposition-based interpolation from #interp_m3_m3m3.
*
* \param R: Resulting interpolated matrix.
* \param A: Input matrix which is totally effective with `t = 0.0`.
@@ -2626,11 +2629,13 @@ void invert_m4_m4_safe(float Ainv[4][4], const float A[4][4])
* - #BLI_SPACE_TRANSFORM_SETUP(&data, ob1, ob2)
*
* After that the following calls can be used:
- * - #BLI_space_transform_apply(&data, co); // converts a coordinate in ob1 space to the corresponding ob2 space.
- * - #BLI_space_transform_invert(&data, co); // converts a coordinate in ob2 space to the corresponding ob1 space.
+ * - Converts a coordinate in ob1 space to the corresponding ob2 space:
+ * #BLI_space_transform_apply(&data, co);
+ * - Converts a coordinate in ob2 space to the corresponding ob1 space:
+ * #BLI_space_transform_invert(&data, co);
*
- * Same concept as #BLI_space_transform_apply and #BLI_space_transform_invert, but no is normalized after conversion
- * (and not translated at all!):
+ * Same concept as #BLI_space_transform_apply and #BLI_space_transform_invert,
+ * but no is normalized after conversion (and not translated at all!):
* - #BLI_space_transform_apply_normal(&data, no);
* - #BLI_space_transform_invert_normal(&data, no);
*/
@@ -2638,12 +2643,14 @@ void invert_m4_m4_safe(float Ainv[4][4], const float A[4][4])
/**
* Global-invariant transform.
*
- * This defines a matrix transforming a point in local space to a point in target space such that its global
- * coordinates remain unchanged.
+ * This defines a matrix transforming a point in local space to a point in target space
+ * such that its global coordinates remain unchanged.
*
- * In other words, if we have a global point P with local coordinates (x, y, z) and global coordinates (X, Y, Z),
+ * In other words, if we have a global point P with local coordinates (x, y, z)
+ * and global coordinates (X, Y, Z),
* this defines a transform matrix TM such that (x', y', z') = TM * (x, y, z)
- * where (x', y', z') are the coordinates of P' in target space such that it keeps (X, Y, Z) coordinates in global space.
+ * where (x', y', z') are the coordinates of P' in target space
+ * such that it keeps (X, Y, Z) coordinates in global space.
*/
void BLI_space_transform_from_matrices(SpaceTransform *data,
const float local[4][4],
@@ -2658,12 +2665,14 @@ void BLI_space_transform_from_matrices(SpaceTransform *data,
/**
* Local-invariant transform.
*
- * This defines a matrix transforming a point in global space such that its local coordinates
- * (from local space to target space) remain unchanged.
+ * This defines a matrix transforming a point in global space
+ * such that its local coordinates (from local space to target space) remain unchanged.
*
- * In other words, if we have a local point p with local coordinates (x, y, z) and global coordinates (X, Y, Z),
+ * In other words, if we have a local point p with local coordinates (x, y, z)
+ * and global coordinates (X, Y, Z),
* this defines a transform matrix TM such that (X', Y', Z') = TM * (X, Y, Z)
- * where (X', Y', Z') are the coordinates of p' in global space such that it keeps (x, y, z) coordinates in target space.
+ * where (X', Y', Z') are the coordinates of p' in global space
+ * such that it keeps (x, y, z) coordinates in target space.
*/
void BLI_space_transform_global_from_matrices(SpaceTransform *data,
const float local[4][4],
diff --git a/source/blender/blenlib/intern/math_solvers.c b/source/blender/blenlib/intern/math_solvers.c
index a6331aaadd8..a1c3d16a404 100644
--- a/source/blender/blenlib/intern/math_solvers.c
+++ b/source/blender/blenlib/intern/math_solvers.c
@@ -184,7 +184,8 @@ bool BLI_tridiagonal_solve_cyclic(
*
* \param func_delta: Callback computing the value of f(x).
* \param func_jacobian: Callback computing the Jacobian matrix of the function at x.
- * \param func_correction: Callback for forcing the search into an arbitrary custom domain. May be NULL.
+ * \param func_correction: Callback for forcing the search into an arbitrary custom domain.
+ * May be NULL.
* \param userdata: Data for the callbacks.
* \param epsilon: Desired precision.
* \param max_iterations: Limit on the iterations.
diff --git a/source/blender/blenlib/intern/math_statistics.c b/source/blender/blenlib/intern/math_statistics.c
index dbfc68adb9b..7c461120520 100644
--- a/source/blender/blenlib/intern/math_statistics.c
+++ b/source/blender/blenlib/intern/math_statistics.c
@@ -93,7 +93,8 @@ static void covariance_m_vn_ex_task_cb(void *__restrict userdata,
* \param n: the dimension of the vectors (and hence, of the covariance matrix to compute).
* \param cos_vn: the nD points to compute covariance from.
* \param nbr_cos_vn: the number of nD coordinates in cos_vn.
- * \param center: the center (or mean point) of cos_vn. If NULL, it is assumed cos_vn is already centered.
+ * \param center: the center (or mean point) of cos_vn. If NULL,
+ * it is assumed cos_vn is already centered.
* \param use_sample_correction: whether to apply sample correction
* (i.e. get 'sample varince' instead of 'population variance').
* \return r_covmat the computed covariance matrix.
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 2fbf64e1200..e388cc06295 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -27,8 +27,8 @@
/* local */
static float noise3_perlin(float vec[3]);
-//static float turbulence_perlin(const float point[3], float lofreq, float hifreq);
-//static float turbulencep(float noisesize, float x, float y, float z, int nr);
+// static float turbulence_perlin(const float point[3], float lofreq, float hifreq);
+// static float turbulencep(float noisesize, float x, float y, float z, int nr);
/* UNUSED */
// #define HASHVEC(x, y, z) hashvectf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255]
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 64872e881f5..3bb60a20fc8 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -57,7 +57,8 @@
#ifdef WIN32
-/* return true if the path is absolute ie starts with a drive specifier (eg A:\) or is a UNC path */
+/** Return true if the path is absolute ie starts with a drive specifier
+ * (eg A:\) or is a UNC path. */
static bool BLI_path_is_abs(const char *name);
#endif /* WIN32 */
@@ -71,8 +72,10 @@ static bool BLI_path_is_abs(const char *name);
* returning the integer value if found, or 0 if not.
*
* \param string: String to scan.
- * \param head: Optional area to return copy of part of string prior to digits, or before dot if no digits.
- * \param tail: Optional area to return copy of part of string following digits, or from dot if no digits.
+ * \param head: Optional area to return copy of part of string prior to digits,
+ * or before dot if no digits.
+ * \param tail: Optional area to return copy of part of string following digits,
+ * or from dot if no digits.
* \param r_num_len: Optional to return number of digits found.
*/
int BLI_stringdec(const char *string, char *head, char *tail, ushort *r_num_len)
@@ -282,15 +285,18 @@ void BLI_cleanup_file(const char *relabase, char *path)
* https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words )
* by underscores ('_').
*
- * \note Space case ' ' is a bit of an edge case here - in theory it is allowed, but again can be an issue
- * in some cases, so we simply replace it by an underscore too (good practice anyway).
- * REMOVED based on popular demand (see T45900).
- * Percent '%' char is a bit same case - not recommended to use it, but supported by all decent FS/OS around...
+ * \note Space case ' ' is a bit of an edge case here - in theory it is allowed,
+ * but again can be an issue in some cases, so we simply replace it by an underscore too
+ * (good practice anyway).
+ * REMOVED based on popular demand (see T45900).
+ * Percent '%' char is a bit same case - not recommended to use it,
+ * but supported by all decent FS/OS around.
*
- * \note On Windows, it also ensures there is no '.' (dot char) at the end of the file, this can lead to issues...
+ * \note On Windows, it also ensures there is no '.' (dot char) at the end of the file,
+ * this can lead to issues.
*
* \note On Windows, it also checks for forbidden names
- * (see https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx ).
+ * (see https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx ).
*/
bool BLI_filename_make_safe(char *fname)
{
@@ -438,7 +444,8 @@ static int BLI_path_unc_prefix_len(const char *path)
#if defined(WIN32)
-/* return true if the path is absolute ie starts with a drive specifier (eg A:\) or is a UNC path */
+/** Return true if the path is absolute ie starts with a drive specifier
+ * (eg A:\) or is a UNC path. */
static bool BLI_path_is_abs(const char *name)
{
return (name[1] == ':' && (name[2] == '\\' || name[2] == '/')) || BLI_path_is_unc(name);
@@ -1302,8 +1309,8 @@ const char *BLI_getenv(const char *env)
}
/**
- * Strips off nonexistent (or non-accessible) subdirectories from the end of *dir, leaving the path of
- * the lowest-level directory that does exist and we can read.
+ * Strips off nonexistent (or non-accessible) subdirectories from the end of *dir,
+ * leaving the path of the lowest-level directory that does exist and we can read.
*/
void BLI_make_exist(char *dir)
{
diff --git a/source/blender/blenlib/intern/polyfill_2d_beautify.c b/source/blender/blenlib/intern/polyfill_2d_beautify.c
index 2ca19d173c2..3e94ae8de1f 100644
--- a/source/blender/blenlib/intern/polyfill_2d_beautify.c
+++ b/source/blender/blenlib/intern/polyfill_2d_beautify.c
@@ -96,8 +96,9 @@ BLI_INLINE bool is_boundary_edge(uint i_a, uint i_b, const uint coord_last)
* Assuming we have 2 triangles sharing an edge (2 - 4),
* check if the edge running from (1 - 3) gives better results.
*
- * \param lock_degenerate: Use to avoid rotating out of a degenerate state.
- * - When true, an existing zero area face on either side of the (2 - 4) split will return a positive value.
+ * \param lock_degenerate: Use to avoid rotating out of a degenerate state:
+ * - When true, an existing zero area face on either side of the (2 - 4
+ * split will return a positive value.
* - When false, the check must be non-biased towards either split direction.
*
* \return (negative number means the edge can be rotated, lager == better).
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index 2723e1708cb..5000b3df92b 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -553,7 +553,8 @@ void BLI_rctf_transform_pt_v(const rctf *dst,
/**
* Calculate a 4x4 matrix representing the transformation between two rectangles.
*
- * \note Multiplying a vector by this matrix does *not* give the same value as #BLI_rctf_transform_pt_v.
+ * \note Multiplying a vector by this matrix does *not*
+ * give the same value as #BLI_rctf_transform_pt_v.
*/
void BLI_rctf_transform_calc_m4_pivot_min_ex(
const rctf *dst, const rctf *src, float matrix[4][4], uint x, uint y)
@@ -700,6 +701,9 @@ bool BLI_rcti_clamp_pt_v(const rcti *rect, int xy[2])
/**
* Clamp \a rect within \a rect_bounds, setting \a r_xy to the offset.
*
+ * Keeps the top left corner within the bounds, which for user interface
+ * elements is typically where the most important information is.
+ *
* \return true if a change is made.
*/
bool BLI_rctf_clamp(rctf *rect, const rctf *rect_bounds, float r_xy[2])
@@ -709,16 +713,16 @@ bool BLI_rctf_clamp(rctf *rect, const rctf *rect_bounds, float r_xy[2])
r_xy[0] = 0.0f;
r_xy[1] = 0.0f;
- if (rect->xmin < rect_bounds->xmin) {
- float ofs = rect_bounds->xmin - rect->xmin;
+ if (rect->xmax > rect_bounds->xmax) {
+ float ofs = rect_bounds->xmax - rect->xmax;
rect->xmin += ofs;
rect->xmax += ofs;
r_xy[0] += ofs;
changed = true;
}
- if (rect->xmax > rect_bounds->xmax) {
- float ofs = rect_bounds->xmax - rect->xmax;
+ if (rect->xmin < rect_bounds->xmin) {
+ float ofs = rect_bounds->xmin - rect->xmin;
rect->xmin += ofs;
rect->xmax += ofs;
r_xy[0] += ofs;
@@ -751,16 +755,16 @@ bool BLI_rcti_clamp(rcti *rect, const rcti *rect_bounds, int r_xy[2])
r_xy[0] = 0;
r_xy[1] = 0;
- if (rect->xmin < rect_bounds->xmin) {
- int ofs = rect_bounds->xmin - rect->xmin;
+ if (rect->xmax > rect_bounds->xmax) {
+ int ofs = rect_bounds->xmax - rect->xmax;
rect->xmin += ofs;
rect->xmax += ofs;
r_xy[0] += ofs;
changed = true;
}
- if (rect->xmax > rect_bounds->xmax) {
- int ofs = rect_bounds->xmax - rect->xmax;
+ if (rect->xmin < rect_bounds->xmin) {
+ int ofs = rect_bounds->xmin - rect->xmin;
rect->xmin += ofs;
rect->xmax += ofs;
r_xy[0] += ofs;
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index 4060ad15fe3..ea15c14d3d2 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -20,15 +20,17 @@
/** \file
* \ingroup bli
*
- * A light stack-friendly hash library, it uses stack space for relatively small, fixed size hash tables
- * but falls back to heap memory once the stack limits reached (#SMSTACKSIZE).
+ * A light stack-friendly hash library, it uses stack space for relatively small,
+ * fixed size hash tables but falls back to heap memory once the stack limits reached
+ * (#SMSTACKSIZE).
*
* based on a doubling hashing approach (non-chaining) which uses more buckets then entries
* stepping over buckets when two keys share the same hash so any key can find a free bucket.
*
* See: https://en.wikipedia.org/wiki/Double_hashing
*
- * \warning This should _only_ be used for small hashes where allocating a hash every time is unacceptable.
+ * \warning This should _only_ be used for small hashes
+ * where allocating a hash every time is unacceptable.
* Otherwise #GHash should be used instead.
*
* #SmallHashEntry.key
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 64b8ff40bcf..b34a9c0a44e 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -52,7 +52,9 @@
#ifdef WIN32
# include <io.h>
# include <direct.h>
+# include <stdbool.h>
# include "BLI_winstuff.h"
+# include "BLI_string_utf8.h"
# include "utfconv.h"
#else
# include <sys/ioctl.h>
@@ -77,6 +79,15 @@
*/
char *BLI_current_working_dir(char *dir, const size_t maxncpy)
{
+#if defined(WIN32)
+ wchar_t path[MAX_PATH];
+ if (_wgetcwd(path, MAX_PATH)) {
+ if (BLI_strncpy_wchar_as_utf8(dir, path, maxncpy) != maxncpy) {
+ return dir;
+ }
+ }
+ return NULL;
+#else
const char *pwd = BLI_getenv("PWD");
if (pwd) {
size_t srclen = BLI_strnlen(pwd, maxncpy);
@@ -88,8 +99,8 @@ char *BLI_current_working_dir(char *dir, const size_t maxncpy)
return NULL;
}
}
-
return getcwd(dir, maxncpy);
+#endif
}
/**
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 01cb635b044..3b69e257f45 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -118,7 +118,8 @@ char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t
}
/**
- * Like BLI_strncpy but ensures dst is always padded by given char, on both sides (unless src is empty).
+ * Like BLI_strncpy but ensures dst is always padded by given char,
+ * on both sides (unless src is empty).
*
* \param dst: Destination for copy
* \param src: Source string to copy
@@ -927,7 +928,8 @@ bool BLI_str_endswith(const char *__restrict str, const char *__restrict end)
* \param str: The string to search within.
* \param delim: The set of delimiters to search for, as unicode values.
* \param sep: Return value, set to the first delimiter found (or NULL if none found).
- * \param suf: Return value, set to next char after the first delimiter found (or NULL if none found).
+ * \param suf: Return value, set to next char after the first delimiter found
+ * (or NULL if none found).
* \return The length of the prefix (i.e. *sep - str).
*/
size_t BLI_str_partition(const char *str, const char delim[], const char **sep, const char **suf)
@@ -941,7 +943,8 @@ size_t BLI_str_partition(const char *str, const char delim[], const char **sep,
* \param str: The string to search within.
* \param delim: The set of delimiters to search for, as unicode values.
* \param sep: Return value, set to the first delimiter found (or NULL if none found).
- * \param suf: Return value, set to next char after the first delimiter found (or NULL if none found).
+ * \param suf: Return value, set to next char after the first delimiter found
+ * (or NULL if none found).
* \return The length of the prefix (i.e. *sep - str).
*/
size_t BLI_str_rpartition(const char *str, const char delim[], const char **sep, const char **suf)
@@ -956,7 +959,8 @@ size_t BLI_str_rpartition(const char *str, const char delim[], const char **sep,
* \param end: If non-NULL, the right delimiter of the string.
* \param delim: The set of delimiters to search for, as unicode values.
* \param sep: Return value, set to the first delimiter found (or NULL if none found).
- * \param suf: Return value, set to next char after the first delimiter found (or NULL if none found).
+ * \param suf: Return value, set to next char after the first delimiter found
+ * (or NULL if none found).
* \param from_right: If %true, search from the right of \a str, else, search from its left.
* \return The length of the prefix (i.e. *sep - str).
*/
@@ -1073,9 +1077,10 @@ size_t BLI_str_format_uint64_grouped(char dst[16], uint64_t num)
* 1000 -> 1 KB
* Number of decimal places grows with the used unit (e.g. 1.5 MB, 1.55 GB, 1.545 TB).
*
- * \param dst: The resulting string. Dimension of 14 to support largest possible value for \a bytes (LLONG_MAX).
- * \param bytes: Number to format
- * \param base_10: Calculate using base 10 (GB, MB, ...) or 2 (GiB, MiB, ...)
+ * \param dst: The resulting string.
+ * Dimension of 14 to support largest possible value for \a bytes (#LLONG_MAX).
+ * \param bytes: Number to format.
+ * \param base_10: Calculate using base 10 (GB, MB, ...) or 2 (GiB, MiB, ...).
*/
void BLI_str_format_byte_unit(char dst[15], long long int bytes, const bool base_10)
{
diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c
index 9b6ffd85341..fa12b4b3a37 100644
--- a/source/blender/blenlib/intern/string_utils.c
+++ b/source/blender/blenlib/intern/string_utils.c
@@ -132,10 +132,13 @@ void BLI_string_split_prefix(const char *string, char *r_pre, char *r_body, cons
}
/**
- * Finds the best possible flipped (left/right) name. For renaming; check for unique names afterwards.
+ * Finds the best possible flipped (left/right) name.
+ * For renaming; check for unique names afterwards.
*
- * \param r_name: flipped name, assumed to be a pointer to a string of at least \a name_len size.
- * \param from_name: original name, assumed to be a pointer to a string of at least \a name_len size.
+ * \param r_name: flipped name,
+ * assumed to be a pointer to a string of at least \a name_len size.
+ * \param from_name: original name,
+ * assumed to be a pointer to a string of at least \a name_len size.
* \param strip_number: If set, remove number extensions.
*/
void BLI_string_flip_side_name(char *r_name,
@@ -326,7 +329,8 @@ bool BLI_uniquename_cb(UniquenameCheckCallback unique_check,
*
* For places where this is used, see constraint.c for example...
*
- * \param name_offs: should be calculated using offsetof(structname, membername) macro from stddef.h
+ * \param name_offs: should be calculated using offsetof(structname, membername)
+ * macro from stddef.h
*/
static bool uniquename_find_dupe(ListBase *list, void *vlink, const char *name, int name_offs)
{
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index 57ce4f16b1a..6f9ff02ce17 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -714,13 +714,15 @@ TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata)
/**
* Create a background task pool.
- * In multi-threaded context, there is no differences with \a BLI_task_pool_create(), but in single-threaded case
- * it is ensured to have at least one worker thread to run on (i.e. you do not have to call
- * \a BLI_task_pool_work_and_wait() on it to be sure it will be processed).
+ * In multi-threaded context, there is no differences with #BLI_task_pool_create(),
+ * but in single-threaded case it is ensured to have at least one worker thread to run on
+ * (i.e. you don't have to call #BLI_task_pool_work_and_wait
+ * on it to be sure it will be processed).
*
- * \note Background pools are non-recursive (that is, you should not create other background pools in tasks assigned
- * to a background pool, they could end never being executed, since the 'fallback' background thread is already
- * busy with parent task in single-threaded context).
+ * \note Background pools are non-recursive
+ * (that is, you should not create other background pools in tasks assigned to a background pool,
+ * they could end never being executed, since the 'fallback' background thread is already
+ * busy with parent task in single-threaded context).
*/
TaskPool *BLI_task_pool_create_background(TaskScheduler *scheduler, void *userdata)
{
@@ -1078,7 +1080,8 @@ static void parallel_range_single_thread(const int start,
}
/**
- * This function allows to parallelized for loops in a similar way to OpenMP's 'parallel for' statement.
+ * This function allows to parallelized for loops in a similar way to OpenMP's
+ * 'parallel for' statement.
*
* See public API doc of ParallelRangeSettings for description of all settings.
*/
@@ -1264,10 +1267,12 @@ BLI_INLINE int task_parallel_listbasecalc_chunk_size(const int num_threads)
* \param listbase: The double linked list to loop over.
* \param userdata: Common userdata passed to all instances of \a func.
* \param func: Callback function.
- * \param use_threading: If \a true, actually split-execute loop in threads, else just do a sequential forloop
- * (allows caller to use any kind of test to switch on parallelization or not).
+ * \param use_threading: If \a true, actually split-execute loop in threads,
+ * else just do a sequential forloop
+ * (allows caller to use any kind of test to switch on parallelization or not).
*
- * \note There is no static scheduling here, since it would need another full loop over items to count them...
+ * \note There is no static scheduling here,
+ * since it would need another full loop over items to count them.
*/
void BLI_task_parallel_listbase(struct ListBase *listbase,
void *userdata,
@@ -1336,7 +1341,8 @@ static void parallel_mempool_func(TaskPool *__restrict pool, void *taskdata, int
* \param mempool: The iterable BLI_mempool to loop over.
* \param userdata: Common userdata passed to all instances of \a func.
* \param func: Callback function.
- * \param use_threading: If \a true, actually split-execute loop in threads, else just do a sequential for loop
+ * \param use_threading: If \a true, actually split-execute loop in threads,
+ * else just do a sequential for loop
* (allows caller to use any kind of test to switch on parallelization or not).
*
* \note There is no static scheduling here.
diff --git a/source/blender/blenloader/BLO_blend_validate.h b/source/blender/blenloader/BLO_blend_validate.h
index c0c2ceabb7f..1ffaddef02f 100644
--- a/source/blender/blenloader/BLO_blend_validate.h
+++ b/source/blender/blenloader/BLO_blend_validate.h
@@ -22,7 +22,8 @@
/** \file
* \ingroup blenloader
- * \brief Utils ensuring .blend file (i.e. Main) is in valid state during write and/or read process.
+ * \brief Utils ensuring .blend file (i.e. Main)
+ * is in valid state during write and/or read process.
*/
struct Main;
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index 5b6c91ee1fe..8ab93ba382c 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -53,6 +53,7 @@ set(SRC
intern/versioning_260.c
intern/versioning_270.c
intern/versioning_280.c
+ intern/versioning_cycles.c
intern/versioning_defaults.c
intern/versioning_dna.c
intern/versioning_legacy.c
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index 1ca274dd68a..323ecedb971 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -17,7 +17,8 @@
/** \file
* \ingroup blenloader
*
- * Utils to check/validate a Main is in sane state, only checks relations between datablocks and libraries for now.
+ * Utils to check/validate a Main is in sane state,
+ * only checks relations between datablocks and libraries for now.
*
* \note Does not *fix* anything, only reports found errors.
*/
@@ -45,7 +46,10 @@
#include "readfile.h"
-/** Check (but do *not* fix) that all linked data-blocks are still valid (i.e. pointing to the right library). */
+/**
+ * Check (but do *not* fix) that all linked data-blocks are still valid
+ * (i.e. pointing to the right library).
+ */
bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
{
ListBase mainlist;
@@ -168,10 +172,8 @@ bool BLO_main_validate_shapekeys(Main *bmain, ReportList *reports)
BKE_main_lock(bmain);
- FOREACH_MAIN_LISTBASE_BEGIN(bmain, lb)
- {
- FOREACH_MAIN_LISTBASE_ID_BEGIN(lb, id)
- {
+ FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb) {
+ FOREACH_MAIN_LISTBASE_ID_BEGIN (lb, id) {
if (!BKE_key_idtype_support(GS(id->name))) {
break;
}
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 6441c6d7a39..4b22a59a155 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -99,8 +99,9 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
fprintf(fp, "[\n");
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == ENDB)
+ if (bhead->code == ENDB) {
break;
+ }
else {
const short *sp = fd->filesdna->structs[bhead->SDNAnr];
const char *name = fd->filesdna->types[sp[0]];
@@ -128,7 +129,8 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
}
/**
- * Gets the names of all the datablocks in a file of a certain type (e.g. all the scene names in a file).
+ * Gets the names of all the datablocks in a file of a certain type
+ * (e.g. all the scene names in a file).
*
* \param bh: The blendhandle to access.
* \param ofblocktype: The type of names to get.
@@ -149,8 +151,9 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
BLI_linklist_prepend(&names, strdup(idname + 2));
tot++;
}
- else if (bhead->code == ENDB)
+ else if (bhead->code == ENDB) {
break;
+ }
}
*tot_names = tot;
@@ -158,7 +161,8 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
}
/**
- * Gets the previews of all the datablocks in a file of a certain type (e.g. all the scene previews in a file).
+ * Gets the previews of all the datablocks in a file of a certain type
+ * (e.g. all the scene previews in a file).
*
* \param bh: The blendhandle to access.
* \param ofblocktype: The type of names to get.
@@ -247,7 +251,8 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
}
/**
- * Gets the names of all the linkable datablock types available in a file. (e.g. "Scene", "Mesh", "Light", etc.).
+ * Gets the names of all the linkable datablock types available in a file.
+ * (e.g. "Scene", "Mesh", "Light", etc.).
*
* \param bh: The blendhandle to access.
* \return A BLI_linklist of strings. The string links should be freed with malloc.
@@ -348,9 +353,11 @@ BlendFileData *BLO_read_from_memory(const void *mem,
}
/**
- * Used for undo/redo, skips part of libraries reading (assuming their data are already loaded & valid).
+ * Used for undo/redo, skips part of libraries reading
+ * (assuming their data are already loaded & valid).
*
- * \param oldmain: old main, from which we will keep libraries and other datablocks that should not have changed.
+ * \param oldmain: old main,
+ * from which we will keep libraries and other datablocks that should not have changed.
* \param filename: current file, only for retrieving library data.
*/
BlendFileData *BLO_read_from_memfile(Main *oldmain,
@@ -410,17 +417,18 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
BLI_assert(old_mainlist.first == oldmain);
if (bfd && old_mainlist.first != old_mainlist.last) {
- /* Even though directly used libs have been already moved to new main, indirect ones have not.
- * This is a bit annoying, but we have no choice but to keep them all for now - means some now unused
- * data may remain in memory, but think we'll have to live with it. */
+ /* Even though directly used libs have been already moved to new main,
+ * indirect ones have not.
+ * This is a bit annoying, but we have no choice but to keep them all for now -
+ * means some now unused data may remain in memory, but think we'll have to live with it. */
Main *libmain, *libmain_next;
Main *newmain = bfd->main;
ListBase new_mainlist = {newmain, newmain};
for (libmain = oldmain->next; libmain; libmain = libmain_next) {
libmain_next = libmain->next;
- /* Note that LIB_INDIRECT does not work with libraries themselves, so we use non-NULL parent
- * to detect indirect-linked ones... */
+ /* Note that LIB_INDIRECT does not work with libraries themselves, so we use non-NULL
+ * parent to detect indirect-linked ones. */
if (libmain->curlib && (libmain->curlib->parent != NULL)) {
BLI_remlink(&old_mainlist, libmain);
BLI_addtail(&new_mainlist, libmain);
@@ -431,14 +439,17 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
#endif
}
}
- /* In any case, we need to move all lib datablocks themselves - those are 'first level data',
- * getting rid of them would imply updating spaces & co to prevent invalid pointers access. */
+ /* In any case, we need to move all lib datablocks themselves - those are
+ * 'first level data', getting rid of them would imply updating spaces & co
+ * to prevent invalid pointers access. */
BLI_movelisttolist(&newmain->libraries, &oldmain->libraries);
blo_join_main(&new_mainlist);
}
- /* printf("Remaining mains/libs in oldmain: %d\n", BLI_listbase_count(&fd->old_mainlist) - 1); */
+#if 0
+ printf("Remaining mains/libs in oldmain: %d\n", BLI_listbase_count(&fd->old_mainlist) - 1);
+#endif
/* That way, libs (aka mains) we did not reuse in new undone/redone state
* will be cleared together with oldmain... */
@@ -451,7 +462,8 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
}
/**
- * Frees a BlendFileData structure and *all* the data associated with it (the userdef data, and the main libblock data).
+ * Frees a BlendFileData structure and *all* the data associated with it
+ * (the userdef data, and the main libblock data).
*
* \param bfd: The structure to free.
*/
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e05edfdd44e..7f62369647a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -154,7 +154,6 @@
#include "DEG_depsgraph.h"
-#include "NOD_common.h"
#include "NOD_socket.h"
#include "BLO_blend_defs.h"
@@ -344,8 +343,7 @@ typedef struct OldNewMap {
static void oldnewmap_insert_index_in_map(OldNewMap *onm, const void *ptr, int index)
{
- ITER_SLOTS(onm, ptr, slot, stored_index)
- {
+ ITER_SLOTS (onm, ptr, slot, stored_index) {
if (stored_index == -1) {
onm->map[slot] = index;
break;
@@ -355,8 +353,7 @@ static void oldnewmap_insert_index_in_map(OldNewMap *onm, const void *ptr, int i
static void oldnewmap_insert_or_replace(OldNewMap *onm, OldNew entry)
{
- ITER_SLOTS(onm, entry.oldp, slot, index)
- {
+ ITER_SLOTS (onm, entry.oldp, slot, index) {
if (index == -1) {
onm->entries[onm->nentries] = entry;
onm->map[slot] = onm->nentries;
@@ -372,8 +369,7 @@ static void oldnewmap_insert_or_replace(OldNewMap *onm, OldNew entry)
static OldNew *oldnewmap_lookup_entry(const OldNewMap *onm, const void *addr)
{
- ITER_SLOTS(onm, addr, slot, index)
- {
+ ITER_SLOTS (onm, addr, slot, index) {
if (index >= 0) {
OldNew *entry = &onm->entries[index];
if (entry->oldp == addr) {
@@ -419,8 +415,9 @@ static OldNewMap *oldnewmap_new(void)
static void oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
{
- if (oldaddr == NULL || newaddr == NULL)
+ if (oldaddr == NULL || newaddr == NULL) {
return;
+ }
if (UNLIKELY(onm->nentries == ENTRIES_CAPACITY(onm))) {
oldnewmap_increase_size(onm);
@@ -441,24 +438,29 @@ void blo_do_versions_oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void
static void *oldnewmap_lookup_and_inc(OldNewMap *onm, const void *addr, bool increase_users)
{
OldNew *entry = oldnewmap_lookup_entry(onm, addr);
- if (entry == NULL)
+ if (entry == NULL) {
return NULL;
- if (increase_users)
+ }
+ if (increase_users) {
entry->nr++;
+ }
return entry->newp;
}
/* for libdata, OldNew.nr has ID code, no increment */
static void *oldnewmap_liblookup(OldNewMap *onm, const void *addr, const void *lib)
{
- if (addr == NULL)
+ if (addr == NULL) {
return NULL;
+ }
ID *id = oldnewmap_lookup_and_inc(onm, addr, false);
- if (id == NULL)
+ if (id == NULL) {
return NULL;
- if (!lib || id->lib)
+ }
+ if (!lib || id->lib) {
return id;
+ }
return NULL;
}
@@ -551,8 +553,9 @@ void blo_split_main(ListBase *mainlist, Main *main)
mainlist->first = mainlist->last = main;
main->next = NULL;
- if (BLI_listbase_is_empty(&main->libraries))
+ if (BLI_listbase_is_empty(&main->libraries)) {
return;
+ }
/* (Library.temp_index -> Main), lookup table */
const uint lib_main_array_len = BLI_listbase_count(&main->libraries);
@@ -574,7 +577,8 @@ void blo_split_main(ListBase *mainlist, Main *main)
while (i--) {
ID *id = lbarray[i]->first;
if (id == NULL || GS(id->name) == ID_LI) {
- continue; /* no ID_LI datablock should ever be linked anyway, but just in case, better be explicit. */
+ /* No ID_LI datablock should ever be linked anyway, but just in case, better be explicit. */
+ continue;
}
split_libdata(lbarray[i], lib_main_array, lib_main_array_len);
}
@@ -595,8 +599,9 @@ static void read_file_version(FileData *fd, Main *main)
main->minsubversionfile = fg->minsubversion;
MEM_freeN(fg);
}
- else if (bhead->code == ENDB)
+ else if (bhead->code == ENDB) {
break;
+ }
}
}
if (main->curlib) {
@@ -661,8 +666,9 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
const char *libname = (m->curlib) ? m->curlib->filepath : m->name;
if (BLI_path_cmp(name1, libname) == 0) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("blo_find_main: found library %s\n", libname);
+ }
return m;
}
}
@@ -682,8 +688,9 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
read_file_version(fd, m);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("blo_find_main: added new lib %s\n", filepath);
+ }
return m;
}
@@ -696,8 +703,9 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
static void switch_endian_bh4(BHead4 *bhead)
{
/* the ID_.. codes */
- if ((bhead->code & 0xFFFF) == 0)
+ if ((bhead->code & 0xFFFF) == 0) {
bhead->code >>= 16;
+ }
if (bhead->code != ENDB) {
BLI_endian_switch_int32(&bhead->len);
@@ -709,8 +717,9 @@ static void switch_endian_bh4(BHead4 *bhead)
static void switch_endian_bh8(BHead8 *bhead)
{
/* the ID_.. codes */
- if ((bhead->code & 0xFFFF) == 0)
+ if ((bhead->code & 0xFFFF) == 0) {
bhead->code >>= 16;
+ }
if (bhead->code != ENDB) {
BLI_endian_switch_int32(&bhead->len);
@@ -1048,7 +1057,7 @@ static bool read_file_dna(FileData *fd, const char **r_error_message)
/* We can't use read_global because this needs 'DNA1' to be decoded,
* however the first 4 chars are _always_ the subversion. */
FileGlobal *fg = (void *)&bhead[1];
- BLI_STATIC_ASSERT(offsetof(FileGlobal, subvstr) == 0, "Must be first: subvstr");
+ BLI_STATIC_ASSERT(offsetof(FileGlobal, subvstr) == 0, "Must be first: subvstr")
char num[5];
memcpy(num, fg->subvstr, 4);
num[4] = 0;
@@ -1071,8 +1080,9 @@ static bool read_file_dna(FileData *fd, const char **r_error_message)
return false;
}
}
- else if (bhead->code == ENDB)
+ else if (bhead->code == ENDB) {
break;
+ }
}
*r_error_message = "Missing DNA block";
@@ -1185,8 +1195,9 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, uint size)
static MemFileChunk *chunk = NULL;
size_t chunkoffset, readsize, totread;
- if (size == 0)
+ if (size == 0) {
return 0;
+ }
if (seek != (size_t)filedata->file_offset) {
chunk = filedata->memfile->chunks.first;
@@ -1225,8 +1236,9 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, uint size)
/* data can be spread over multiple chunks, so clamp size
* to within this chunk, and then it will read further in
* the next chunk */
- if (chunkoffset + readsize > chunk->size)
+ if (chunkoffset + readsize > chunk->size) {
readsize = chunk->size - chunkoffset;
+ }
memcpy(POINTER_OFFSET(buffer, totread), chunk->buf + chunkoffset, readsize);
totread += readsize;
@@ -1382,8 +1394,8 @@ FileData *blo_filedata_from_file(const char *filepath, ReportList *reports)
}
/**
- * Same as blo_filedata_from_file(), but does not reads DNA data, only header. Use it for light access
- * (e.g. thumbnail reading).
+ * Same as blo_filedata_from_file(), but does not reads DNA data, only header.
+ * Use it for light access (e.g. thumbnail reading).
*/
static FileData *blo_filedata_from_file_minimal(const char *filepath)
{
@@ -1430,8 +1442,9 @@ static int fd_read_gzip_from_memory_init(FileData *fd)
fd->strm.zalloc = Z_NULL;
fd->strm.zfree = Z_NULL;
- if (inflateInit2(&fd->strm, (16 + MAX_WBITS)) != Z_OK)
+ if (inflateInit2(&fd->strm, (16 + MAX_WBITS)) != Z_OK) {
return 0;
+ }
fd->read = fd_read_gzip_from_memory;
@@ -1458,8 +1471,9 @@ FileData *blo_filedata_from_memory(const void *mem, int memsize, ReportList *rep
return NULL;
}
}
- else
+ else {
fd->read = fd_read_from_memory;
+ }
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
@@ -1511,8 +1525,7 @@ void blo_filedata_free(FileData *fd)
BLI_freelistN(&fd->bhead_list);
#else
/* Sanity check we're not keeping memory we don't need. */
- LISTBASE_FOREACH_MUTABLE(BHeadN *, new_bhead, &fd->bhead_list)
- {
+ LISTBASE_FOREACH_MUTABLE (BHeadN *, new_bhead, &fd->bhead_list) {
if (fd->seek != NULL && BHEAD_USE_READ_ON_DEMAND(&new_bhead->bhead)) {
BLI_assert(new_bhead->has_data == 0);
}
@@ -1520,29 +1533,40 @@ void blo_filedata_free(FileData *fd)
}
#endif
- if (fd->filesdna)
+ if (fd->filesdna) {
DNA_sdna_free(fd->filesdna);
- if (fd->compflags)
+ }
+ if (fd->compflags) {
MEM_freeN((void *)fd->compflags);
+ }
- if (fd->datamap)
+ if (fd->datamap) {
oldnewmap_free(fd->datamap);
- if (fd->globmap)
+ }
+ if (fd->globmap) {
oldnewmap_free(fd->globmap);
- if (fd->imamap)
+ }
+ if (fd->imamap) {
oldnewmap_free(fd->imamap);
- if (fd->movieclipmap)
+ }
+ if (fd->movieclipmap) {
oldnewmap_free(fd->movieclipmap);
- if (fd->scenemap)
+ }
+ if (fd->scenemap) {
oldnewmap_free(fd->scenemap);
- if (fd->soundmap)
+ }
+ if (fd->soundmap) {
oldnewmap_free(fd->soundmap);
- if (fd->packedmap)
+ }
+ if (fd->packedmap) {
oldnewmap_free(fd->packedmap);
- if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP))
+ }
+ if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP)) {
oldnewmap_free(fd->libmap);
- if (fd->bheadmap)
+ }
+ if (fd->bheadmap) {
MEM_freeN(fd->bheadmap);
+ }
#ifdef USE_GHASH_BHEAD
if (fd->bhead_idname_hash) {
@@ -1586,7 +1610,8 @@ bool BLO_has_bfile_extension(const char *str)
*/
bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
{
- /* We might get some data names with slashes, so we have to go up in path until we find blend file itself,
+ /* We might get some data names with slashes,
+ * so we have to go up in path until we find blend file itself,
* then we now next path item is group, and everything else is data name. */
char *slash = NULL, *prev_slash = NULL, c = '\0';
@@ -1648,7 +1673,8 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
*
* \param filepath: The path of the file to extract thumbnail from.
* \return The raw thumbnail
- * (MEM-allocated, as stored in file, use #BKE_main_thumbnail_to_imbuf() to convert it to ImBuf image).
+ * (MEM-allocated, as stored in file, use #BKE_main_thumbnail_to_imbuf()
+ * to convert it to ImBuf image).
*/
BlendThumbnail *BLO_thumbnail_from_file(const char *filepath)
{
@@ -1703,38 +1729,43 @@ static void *newglobadr(FileData *fd, const void *adr) /* direct datablocks with
static void *newimaadr(FileData *fd, const void *adr) /* used to restore image data after undo */
{
- if (fd->imamap && adr)
+ if (fd->imamap && adr) {
return oldnewmap_lookup_and_inc(fd->imamap, adr, true);
+ }
return NULL;
}
static void *newsceadr(FileData *fd, const void *adr) /* used to restore scene data after undo */
{
- if (fd->scenemap && adr)
+ if (fd->scenemap && adr) {
return oldnewmap_lookup_and_inc(fd->scenemap, adr, true);
+ }
return NULL;
}
static void *newmclipadr(FileData *fd,
const void *adr) /* used to restore movie clip data after undo */
{
- if (fd->movieclipmap && adr)
+ if (fd->movieclipmap && adr) {
return oldnewmap_lookup_and_inc(fd->movieclipmap, adr, true);
+ }
return NULL;
}
static void *newsoundadr(FileData *fd, const void *adr) /* used to restore sound data after undo */
{
- if (fd->soundmap && adr)
+ if (fd->soundmap && adr) {
return oldnewmap_lookup_and_inc(fd->soundmap, adr, true);
+ }
return NULL;
}
static void *newpackedadr(FileData *fd,
const void *adr) /* used to restore packed data after undo */
{
- if (fd->packedmap && adr)
+ if (fd->packedmap && adr) {
return oldnewmap_lookup_and_inc(fd->packedmap, adr, true);
+ }
return oldnewmap_lookup_and_inc(fd->datamap, adr, true);
}
@@ -1785,8 +1816,9 @@ static void change_link_placeholder_to_real_ID_pointer_fd(FileData *fd, const vo
if (old == entry->newp && entry->nr == ID_LINK_PLACEHOLDER) {
entry->newp = new;
- if (new)
+ if (new) {
entry->nr = GS(((ID *)new)->name);
+ }
}
}
}
@@ -1801,10 +1833,12 @@ static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist,
for (mainptr = mainlist->first; mainptr; mainptr = mainptr->next) {
FileData *fd;
- if (mainptr->curlib)
+ if (mainptr->curlib) {
fd = mainptr->curlib->filedata;
- else
+ }
+ else {
fd = basefd;
+ }
if (fd) {
change_link_placeholder_to_real_ID_pointer_fd(fd, old, new);
@@ -1851,8 +1885,9 @@ void blo_end_scene_pointer_map(FileData *fd, Main *oldmain)
/* used entries were restored, so we put them to zero */
for (i = 0; i < fd->scenemap->nentries; i++, entry++) {
- if (entry->nr > 0)
+ if (entry->nr > 0) {
entry->newp = NULL;
+ }
}
for (; sce; sce = sce->id.next) {
@@ -1889,8 +1924,7 @@ void blo_make_image_pointer_map(FileData *fd, Main *oldmain)
for (; sce; sce = sce->id.next) {
if (sce->nodetree && sce->nodetree->previews) {
bNodeInstanceHashIterator iter;
- NODE_INSTANCE_HASH_ITER(iter, sce->nodetree->previews)
- {
+ NODE_INSTANCE_HASH_ITER (iter, sce->nodetree->previews) {
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
oldnewmap_insert(fd->imamap, preview, preview, 0);
}
@@ -1909,8 +1943,9 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
/* used entries were restored, so we put them to zero */
for (i = 0; i < fd->imamap->nentries; i++, entry++) {
- if (entry->nr > 0)
+ if (entry->nr > 0) {
entry->newp = NULL;
+ }
}
for (; ima; ima = ima->id.next) {
@@ -1926,8 +1961,9 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
slot->render = newimaadr(fd, slot->render);
}
- for (i = 0; i < TEXTARGET_COUNT; i++)
+ for (i = 0; i < TEXTARGET_COUNT; i++) {
ima->gputexture[i] = newimaadr(fd, ima->gputexture[i]);
+ }
ima->rr = newimaadr(fd, ima->rr);
}
for (; sce; sce = sce->id.next) {
@@ -1936,8 +1972,7 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
bNodeInstanceHashIterator iter;
/* reconstruct the preview hash, only using remaining pointers */
- NODE_INSTANCE_HASH_ITER(iter, sce->nodetree->previews)
- {
+ NODE_INSTANCE_HASH_ITER (iter, sce->nodetree->previews) {
bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter);
if (preview) {
bNodePreview *new_preview = newimaadr(fd, preview);
@@ -1961,20 +1996,24 @@ void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain)
fd->movieclipmap = oldnewmap_new();
for (; clip; clip = clip->id.next) {
- if (clip->cache)
+ if (clip->cache) {
oldnewmap_insert(fd->movieclipmap, clip->cache, clip->cache, 0);
+ }
- if (clip->tracking.camera.intrinsics)
+ if (clip->tracking.camera.intrinsics) {
oldnewmap_insert(
fd->movieclipmap, clip->tracking.camera.intrinsics, clip->tracking.camera.intrinsics, 0);
+ }
}
for (; sce; sce = sce->id.next) {
if (sce->nodetree) {
bNode *node;
- for (node = sce->nodetree->nodes.first; node; node = node->next)
- if (node->type == CMP_NODE_MOVIEDISTORTION)
+ for (node = sce->nodetree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_MOVIEDISTORTION) {
oldnewmap_insert(fd->movieclipmap, node->storage, node->storage, 0);
+ }
+ }
}
}
}
@@ -1990,8 +2029,9 @@ void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain)
/* used entries were restored, so we put them to zero */
for (i = 0; i < fd->movieclipmap->nentries; i++, entry++) {
- if (entry->nr > 0)
+ if (entry->nr > 0) {
entry->newp = NULL;
+ }
}
for (; clip; clip = clip->id.next) {
@@ -2002,9 +2042,11 @@ void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain)
for (; sce; sce = sce->id.next) {
if (sce->nodetree) {
bNode *node;
- for (node = sce->nodetree->nodes.first; node; node = node->next)
- if (node->type == CMP_NODE_MOVIEDISTORTION)
+ for (node = sce->nodetree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_MOVIEDISTORTION) {
node->storage = newmclipadr(fd, node->storage);
+ }
+ }
}
}
}
@@ -2016,8 +2058,9 @@ void blo_make_sound_pointer_map(FileData *fd, Main *oldmain)
fd->soundmap = oldnewmap_new();
for (; sound; sound = sound->id.next) {
- if (sound->waveform)
+ if (sound->waveform) {
oldnewmap_insert(fd->soundmap, sound->waveform, sound->waveform, 0);
+ }
}
}
@@ -2031,8 +2074,9 @@ void blo_end_sound_pointer_map(FileData *fd, Main *oldmain)
/* used entries were restored, so we put them to zero */
for (i = 0; i < fd->soundmap->nentries; i++, entry++) {
- if (entry->nr > 0)
+ if (entry->nr > 0) {
entry->newp = NULL;
+ }
}
for (; sound; sound = sound->id.next) {
@@ -2040,7 +2084,8 @@ void blo_end_sound_pointer_map(FileData *fd, Main *oldmain)
}
}
-/* XXX disabled this feature - packed files also belong in temp saves and quit.blend, to make restore work */
+/* XXX disabled this feature - packed files also belong in temp saves and quit.blend,
+ * to make restore work. */
static void insert_packedmap(FileData *fd, PackedFile *pf)
{
@@ -2060,25 +2105,34 @@ void blo_make_packed_pointer_map(FileData *fd, Main *oldmain)
for (ima = oldmain->images.first; ima; ima = ima->id.next) {
ImagePackedFile *imapf;
- if (ima->packedfile)
+ if (ima->packedfile) {
insert_packedmap(fd, ima->packedfile);
+ }
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next)
- if (imapf->packedfile)
+ for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
+ if (imapf->packedfile) {
insert_packedmap(fd, imapf->packedfile);
+ }
+ }
}
- for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next)
- if (vfont->packedfile)
+ for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next) {
+ if (vfont->packedfile) {
insert_packedmap(fd, vfont->packedfile);
+ }
+ }
- for (sound = oldmain->sounds.first; sound; sound = sound->id.next)
- if (sound->packedfile)
+ for (sound = oldmain->sounds.first; sound; sound = sound->id.next) {
+ if (sound->packedfile) {
insert_packedmap(fd, sound->packedfile);
+ }
+ }
- for (lib = oldmain->libraries.first; lib; lib = lib->id.next)
- if (lib->packedfile)
+ for (lib = oldmain->libraries.first; lib; lib = lib->id.next) {
+ if (lib->packedfile) {
insert_packedmap(fd, lib->packedfile);
+ }
+ }
}
/* set old main packed data to zero if it has been restored */
@@ -2094,8 +2148,9 @@ void blo_end_packed_pointer_map(FileData *fd, Main *oldmain)
/* used entries were restored, so we put them to zero */
for (i = 0; i < fd->packedmap->nentries; i++, entry++) {
- if (entry->nr > 0)
+ if (entry->nr > 0) {
entry->newp = NULL;
+ }
}
for (ima = oldmain->images.first; ima; ima = ima->id.next) {
@@ -2103,18 +2158,22 @@ void blo_end_packed_pointer_map(FileData *fd, Main *oldmain)
ima->packedfile = newpackedadr(fd, ima->packedfile);
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next)
+ for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
imapf->packedfile = newpackedadr(fd, imapf->packedfile);
+ }
}
- for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next)
+ for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next) {
vfont->packedfile = newpackedadr(fd, vfont->packedfile);
+ }
- for (sound = oldmain->sounds.first; sound; sound = sound->id.next)
+ for (sound = oldmain->sounds.first; sound; sound = sound->id.next) {
sound->packedfile = newpackedadr(fd, sound->packedfile);
+ }
- for (lib = oldmain->libraries.first; lib; lib = lib->id.next)
+ for (lib = oldmain->libraries.first; lib; lib = lib->id.next) {
lib->packedfile = newpackedadr(fd, lib->packedfile);
+ }
}
/* undo file support: add all library pointers in lookup */
@@ -2127,8 +2186,9 @@ void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd)
int i = set_listbasepointers(ptr, lbarray);
while (i--) {
ID *id;
- for (id = lbarray[i]->first; id; id = id->next)
+ for (id = lbarray[i]->first; id; id = id->next) {
oldnewmap_insert(fd->libmap, id, id, GS(id->name));
+ }
}
}
@@ -2231,8 +2291,9 @@ static void link_list_ex(FileData *fd, ListBase *lb, link_list_cb callback) /* o
{
Link *ln, *prev;
- if (BLI_listbase_is_empty(lb))
+ if (BLI_listbase_is_empty(lb)) {
return;
+ }
lb->first = newdataadr(fd, lb->first);
if (callback != NULL) {
@@ -2262,8 +2323,9 @@ static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
Link *ln, *prev;
void *poin;
- if (BLI_listbase_is_empty(lb))
+ if (BLI_listbase_is_empty(lb)) {
return;
+ }
poin = newdataadr(fd, lb->first);
if (lb->first) {
oldnewmap_insert(fd->globmap, lb->first, poin, 0);
@@ -2303,8 +2365,9 @@ static void test_pointer_array(FileData *fd, void **mat)
lpoin = *mat;
while (len-- > 0) {
- if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN))
+ if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
BLI_endian_switch_int64(lpoin);
+ }
*ipoin = (int)((*lpoin) >> 3);
ipoin++;
lpoin++;
@@ -2355,8 +2418,9 @@ static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData
prop->totallen = 0;
}
- for (i = 0; i < prop->len; i++)
+ for (i = 0; i < prop->len; i++) {
IDP_DirectLinkProperty(&array[i], switch_endian, fd);
+ }
}
static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *fd)
@@ -2372,8 +2436,9 @@ static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *f
test_pointer_array(fd, prop->data.pointer);
array = prop->data.pointer;
- for (i = 0; i < prop->len; i++)
+ for (i = 0; i < prop->len; i++) {
IDP_DirectLinkProperty(array[i], switch_endian, fd);
+ }
}
else if (prop->subtype == IDP_DOUBLE) {
if (switch_endian) {
@@ -2480,8 +2545,9 @@ static void _IDP_DirectLinkGroup_OrFree(IDProperty **prop,
static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd)
{
- if (!prop)
+ if (!prop) {
return;
+ }
switch (prop->type) {
case IDP_ID: /* PointerProperty */
@@ -2590,7 +2656,8 @@ static void direct_link_id(FileData *fd, ID *id)
}
id->py_instance = NULL;
- /* That way datablock reading not going through main read_libblock() function are still in a clear tag state.
+ /* That way datablock reading not going through main read_libblock()
+ * function are still in a clear tag state.
* (glowering at certain nodetree fake datablock here...). */
id->tag = 0;
@@ -2677,10 +2744,12 @@ static void direct_link_brush(FileData *fd, Brush *brush)
brush->gradient = newdataadr(fd, brush->gradient);
- if (brush->curve)
+ if (brush->curve) {
direct_link_curvemapping(fd, brush->curve);
- else
+ }
+ else {
BKE_brush_curve_preset(brush, CURVE_PRESET_SHARP);
+ }
/* grease pencil */
brush->gpencil_settings = newdataadr(fd, brush->gpencil_settings);
@@ -2691,14 +2760,17 @@ static void direct_link_brush(FileData *fd, Brush *brush)
brush->gpencil_settings->curve_strength);
brush->gpencil_settings->curve_jitter = newdataadr(fd, brush->gpencil_settings->curve_jitter);
- if (brush->gpencil_settings->curve_sensitivity)
+ if (brush->gpencil_settings->curve_sensitivity) {
direct_link_curvemapping(fd, brush->gpencil_settings->curve_sensitivity);
+ }
- if (brush->gpencil_settings->curve_strength)
+ if (brush->gpencil_settings->curve_strength) {
direct_link_curvemapping(fd, brush->gpencil_settings->curve_strength);
+ }
- if (brush->gpencil_settings->curve_jitter)
+ if (brush->gpencil_settings->curve_jitter) {
direct_link_curvemapping(fd, brush->gpencil_settings->curve_jitter);
+ }
}
brush->preview = NULL;
@@ -2779,8 +2851,9 @@ static void lib_link_ipo(FileData *fd, Main *main)
if (ipo->id.tag & LIB_TAG_NEED_LINK) {
IpoCurve *icu;
for (icu = ipo->curve.first; icu; icu = icu->next) {
- if (icu->driver)
+ if (icu->driver) {
icu->driver->ob = newlibadr(fd, ipo->id.lib, icu->driver->ob);
+ }
}
ipo->id.tag &= ~LIB_TAG_NEED_LINK;
}
@@ -2811,8 +2884,9 @@ static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist)
strip->object = newlibadr(fd, id->lib, strip->object);
strip->act = newlibadr_us(fd, id->lib, strip->act);
strip->ipo = newlibadr(fd, id->lib, strip->ipo);
- for (amod = strip->modifiers.first; amod; amod = amod->next)
+ for (amod = strip->modifiers.first; amod; amod = amod->next) {
amod->ob = newlibadr(fd, id->lib, amod->ob);
+ }
}
}
@@ -2823,8 +2897,9 @@ static void direct_link_nlastrips(FileData *fd, ListBase *strips)
link_list(fd, strips);
- for (strip = strips->first; strip; strip = strip->next)
+ for (strip = strips->first; strip; strip = strip->next) {
link_list(fd, &strip->modifiers);
+ }
}
// XXX deprecated - old animation system
@@ -2864,8 +2939,9 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
{
FCurve *fcu;
- if (list == NULL)
+ if (list == NULL) {
return;
+ }
/* relink ID-block references... */
for (fcu = list->first; fcu; fcu = fcu->next) {
@@ -2877,10 +2953,12 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* only relink if still used */
- if (tarIndex < dvar->num_targets)
+ if (tarIndex < dvar->num_targets) {
dtar->id = newlibadr(fd, id->lib, dtar->id);
- else
+ }
+ else {
dtar->id = NULL;
+ }
}
DRIVER_TARGETS_LOOPER_END;
}
@@ -2961,7 +3039,8 @@ static void direct_link_fcurves(FileData *fd, ListBase *list)
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
- /* compiled expression data will need to be regenerated (old pointer may still be set here) */
+ /* Compiled expression data will need to be regenerated
+ * (old pointer may still be set here). */
driver->expr_comp = NULL;
driver->expr_simple = NULL;
@@ -2975,10 +3054,12 @@ static void direct_link_fcurves(FileData *fd, ListBase *list)
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* only relink the targets being used */
- if (tarIndex < dvar->num_targets)
+ if (tarIndex < dvar->num_targets) {
dtar->rna_path = newdataadr(fd, dtar->rna_path);
- else
+ }
+ else {
dtar->rna_path = NULL;
+ }
}
DRIVER_TARGETS_LOOPER_END;
}
@@ -3057,8 +3138,9 @@ static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list)
strip->act = newlibadr_us(fd, id->lib, strip->act);
/* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */
- if ((strip->act) && (strip->act->idroot == 0))
+ if ((strip->act) && (strip->act->idroot == 0)) {
strip->act->idroot = GS(id->name);
+ }
}
}
@@ -3145,18 +3227,21 @@ static void direct_link_keyingsets(FileData *fd, ListBase *list)
static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
{
- if (adt == NULL)
+ if (adt == NULL) {
return;
+ }
/* link action data */
adt->action = newlibadr_us(fd, id->lib, adt->action);
adt->tmpact = newlibadr_us(fd, id->lib, adt->tmpact);
/* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */
- if ((adt->action) && (adt->action->idroot == 0))
+ if ((adt->action) && (adt->action->idroot == 0)) {
adt->action->idroot = GS(id->name);
- if ((adt->tmpact) && (adt->tmpact->idroot == 0))
+ }
+ if ((adt->tmpact) && (adt->tmpact->idroot == 0)) {
adt->tmpact->idroot = GS(id->name);
+ }
/* link drivers */
lib_link_fcurves(fd, id, &adt->drivers);
@@ -3170,8 +3255,9 @@ static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
static void direct_link_animdata(FileData *fd, AnimData *adt)
{
/* NOTE: must have called newdataadr already before doing this... */
- if (adt == NULL)
+ if (adt == NULL) {
return;
+ }
/* link drivers */
link_list(fd, &adt->drivers);
@@ -3219,7 +3305,8 @@ static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
{
BLI_listbase_clear(&cache_file->object_paths);
cache_file->handle = NULL;
- cache_file->handle_mutex = NULL;
+ cache_file->handle_filepath[0] = '\0';
+ cache_file->handle_readers = NULL;
/* relink animdata */
cache_file->adt = newdataadr(fd, cache_file->adt);
@@ -3313,35 +3400,46 @@ static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook
/* Single node tree (also used for material/scene trees), ntree is not NULL */
static void lib_link_ntree(FileData *fd, ID *id, bNodeTree *ntree)
{
- bNode *node;
- bNodeSocket *sock;
-
IDP_LibLinkProperty(ntree->id.properties, fd);
lib_link_animdata(fd, &ntree->id, ntree->adt);
ntree->gpd = newlibadr_us(fd, id->lib, ntree->gpd);
- for (node = ntree->nodes.first; node; node = node->next) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
IDP_LibLinkProperty(node->prop, fd);
node->id = newlibadr_us(fd, id->lib, node->id);
- for (sock = node->inputs.first; sock; sock = sock->next) {
+ for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
IDP_LibLinkProperty(sock->prop, fd);
}
- for (sock = node->outputs.first; sock; sock = sock->next) {
+ for (bNodeSocket *sock = node->outputs.first; sock; sock = sock->next) {
IDP_LibLinkProperty(sock->prop, fd);
}
}
- for (sock = ntree->inputs.first; sock; sock = sock->next) {
+ for (bNodeSocket *sock = ntree->inputs.first; sock; sock = sock->next) {
IDP_LibLinkProperty(sock->prop, fd);
}
- for (sock = ntree->outputs.first; sock; sock = sock->next) {
+ for (bNodeSocket *sock = ntree->outputs.first; sock; sock = sock->next) {
IDP_LibLinkProperty(sock->prop, fd);
}
+
+ /* Set node->typeinfo pointers. This is done in lib linking, after the
+ * first versioning that can change types still without functions that
+ * update the typeinfo pointers. Versioning after lib linking needs
+ * these top be valid. */
+ ntreeSetTypes(NULL, ntree);
+
+ /* For nodes with static socket layout, add/remove sockets as needed
+ * to match the static layout. */
+ if (fd->memfile == NULL) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ node_verify_socket_templates(ntree, node);
+ }
+ }
}
/* library ntree linking after fileread */
@@ -3357,222 +3455,6 @@ static void lib_link_nodetree(FileData *fd, Main *main)
}
}
-/* updates group node socket identifier so that
- * external links to/from the group node are preserved.
- */
-static void lib_node_do_versions_group_indices(bNode *gnode)
-{
- bNodeTree *ngroup = (bNodeTree *)gnode->id;
- bNodeSocket *sock;
- bNodeLink *link;
-
- for (sock = gnode->outputs.first; sock; sock = sock->next) {
- int old_index = sock->to_index;
-
- for (link = ngroup->links.first; link; link = link->next) {
- if (link->tonode == NULL && link->fromsock->own_index == old_index) {
- strcpy(sock->identifier, link->fromsock->identifier);
- /* deprecated */
- sock->own_index = link->fromsock->own_index;
- sock->to_index = 0;
- sock->groupsock = NULL;
- }
- }
- }
- for (sock = gnode->inputs.first; sock; sock = sock->next) {
- int old_index = sock->to_index;
-
- for (link = ngroup->links.first; link; link = link->next) {
- if (link->fromnode == NULL && link->tosock->own_index == old_index) {
- strcpy(sock->identifier, link->tosock->identifier);
- /* deprecated */
- sock->own_index = link->tosock->own_index;
- sock->to_index = 0;
- sock->groupsock = NULL;
- }
- }
- }
-}
-
-/* verify types for nodes and groups, all data has to be read */
-/* open = 0: appending/linking, open = 1: open new file (need to clean out dynamic
- * typedefs */
-static void lib_verify_nodetree(Main *main, int UNUSED(open))
-{
- /* this crashes blender on undo/redo */
-#if 0
- if (open == 1) {
- reinit_nodesystem();
- }
-#endif
-
- /* set node->typeinfo pointers */
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- ntreeSetTypes(NULL, ntree);
- }
- FOREACH_NODETREE_END;
-
- /* verify static socket templates */
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next)
- node_verify_socket_templates(ntree, node);
- }
- FOREACH_NODETREE_END;
-
- {
- bool has_old_groups = false;
- /* XXX this should actually be part of do_versions, but since we need
- * finished library linking, it is not possible there. Instead in do_versions
- * we have set the NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2 flag, so at this point we can do the
- * actual group node updates.
- */
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- if (ntree->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2) {
- has_old_groups = 1;
- }
- }
-
- if (has_old_groups) {
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- /* updates external links for all group nodes in a tree */
- bNode *node;
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == NODE_GROUP) {
- bNodeTree *ngroup = (bNodeTree *)node->id;
- if (ngroup && (ngroup->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2))
- lib_node_do_versions_group_indices(node);
- }
- }
- }
- FOREACH_NODETREE_END;
- }
-
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- ntree->flag &= ~NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2;
- }
- }
-
- {
- /* Convert the previously used ntree->inputs/ntree->outputs lists to interface nodes.
- * Pre 2.56.2 node trees automatically have all unlinked sockets exposed already
- * (see NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2).
- *
- * XXX this should actually be part of do_versions,
- * but needs valid typeinfo pointers to create interface nodes.
- *
- * Note: theoretically only needed in node groups (main->nodetree),
- * but due to a temporary bug such links could have been added in all trees,
- * so have to clean up all of them ...
- */
-
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- if (ntree->flag & NTREE_DO_VERSIONS_CUSTOMNODES_GROUP) {
- bNode *input_node = NULL, *output_node = NULL;
- int num_inputs = 0, num_outputs = 0;
- bNodeLink *link, *next_link;
- /* Only create new interface nodes for actual older files.
- * New file versions already have input/output nodes with duplicate links,
- * in that case just remove the invalid links.
- */
- const bool create_io_nodes = (ntree->flag &
- NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE) != 0;
-
- float input_locx = 1000000.0f, input_locy = 0.0f;
- float output_locx = -1000000.0f, output_locy = 0.0f;
- /* rough guess, not nice but we don't have access to UI constants here ... */
- static const float offsetx = 42 + 3 * 20 + 20;
- /*static const float offsety = 0.0f;*/
-
- if (create_io_nodes) {
- if (ntree->inputs.first)
- input_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_INPUT);
-
- if (ntree->outputs.first)
- output_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_OUTPUT);
- }
-
- /* Redirect links from/to the node tree interface to input/output node.
- * If the fromnode/tonode pointers are NULL, this means a link from/to
- * the ntree interface sockets, which need to be redirected to new interface nodes.
- */
- for (link = ntree->links.first; link; link = next_link) {
- bool free_link = false;
- next_link = link->next;
-
- if (link->fromnode == NULL) {
- if (input_node) {
- link->fromnode = input_node;
- link->fromsock = node_group_input_find_socket(input_node,
- link->fromsock->identifier);
- ++num_inputs;
-
- if (link->tonode) {
- if (input_locx > link->tonode->locx - offsetx)
- input_locx = link->tonode->locx - offsetx;
- input_locy += link->tonode->locy;
- }
- }
- else {
- free_link = true;
- }
- }
-
- if (link->tonode == NULL) {
- if (output_node) {
- link->tonode = output_node;
- link->tosock = node_group_output_find_socket(output_node, link->tosock->identifier);
- ++num_outputs;
-
- if (link->fromnode) {
- if (output_locx < link->fromnode->locx + offsetx)
- output_locx = link->fromnode->locx + offsetx;
- output_locy += link->fromnode->locy;
- }
- }
- else {
- free_link = true;
- }
- }
-
- if (free_link)
- nodeRemLink(ntree, link);
- }
-
- if (num_inputs > 0) {
- input_locy /= num_inputs;
- input_node->locx = input_locx;
- input_node->locy = input_locy;
- }
- if (num_outputs > 0) {
- output_locy /= num_outputs;
- output_node->locx = output_locx;
- output_node->locy = output_locy;
- }
-
- /* clear do_versions flags */
- ntree->flag &= ~(NTREE_DO_VERSIONS_CUSTOMNODES_GROUP |
- NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE);
- }
- }
- FOREACH_NODETREE_END;
- }
-
- /* verify all group user nodes */
- for (bNodeTree *ntree = main->nodetrees.first; ntree; ntree = ntree->id.next) {
- ntreeVerifyNodes(main, &ntree->id);
- }
-
- /* make update calls where necessary */
- {
- FOREACH_NODETREE_BEGIN (main, ntree, id) {
- /* make an update call for the tree */
- ntreeUpdateTree(main, ntree);
- }
- FOREACH_NODETREE_END;
- }
-}
-
static void direct_link_node_socket(FileData *fd, bNodeSocket *sock)
{
sock->prop = newdataadr(fd, sock->prop);
@@ -3698,19 +3580,23 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
node->parent = newdataadr(fd, node->parent);
node->lasty = 0;
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
direct_link_node_socket(fd, sock);
- for (sock = node->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
direct_link_node_socket(fd, sock);
+ }
}
/* interface socket lists */
link_list(fd, &ntree->inputs);
link_list(fd, &ntree->outputs);
- for (sock = ntree->inputs.first; sock; sock = sock->next)
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
direct_link_node_socket(fd, sock);
- for (sock = ntree->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
direct_link_node_socket(fd, sock);
+ }
for (link = ntree->links.first; link; link = link->next) {
link->fromnode = newdataadr(fd, link->fromnode);
@@ -3846,13 +3732,15 @@ static void direct_link_constraints(FileData *fd, ListBase *lb)
}
case CONSTRAINT_TYPE_CHILDOF: {
/* XXX version patch, in older code this flag wasn't always set, and is inherent to type */
- if (con->ownspace == CONSTRAINT_SPACE_POSE)
+ if (con->ownspace == CONSTRAINT_SPACE_POSE) {
con->flag |= CONSTRAINT_SPACEONCE;
+ }
break;
}
case CONSTRAINT_TYPE_TRANSFORM_CACHE: {
bTransformCacheConstraint *data = con->data;
data->reader = NULL;
+ data->reader_object_path[0] = '\0';
}
}
}
@@ -3862,8 +3750,9 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
{
bArmature *arm = ob->data;
- if (!pose || !arm)
+ if (!pose || !arm) {
return;
+ }
/* always rebuild to match proxy or lib changes, but on Undo */
bool rebuild = false;
@@ -3879,8 +3768,9 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
if (ob->proxy) {
/* sync proxy layer */
- if (pose->proxy_layer)
+ if (pose->proxy_layer) {
arm->layer = pose->proxy_layer;
+ }
/* sync proxy active bone */
if (pose->proxy_act_bone[0]) {
@@ -3958,8 +3848,9 @@ static void direct_link_bones(FileData *fd, Bone *bone)
link_list(fd, &bone->childbase);
- for (child = bone->childbase.first; child; child = child->next)
+ for (child = bone->childbase.first; child; child = child->next) {
direct_link_bones(fd, child);
+ }
}
static void direct_link_armature(FileData *fd, bArmature *arm)
@@ -4051,8 +3942,9 @@ static void direct_link_light(FileData *fd, Light *la)
direct_link_animdata(fd, la->adt);
la->curfalloff = newdataadr(fd, la->curfalloff);
- if (la->curfalloff)
+ if (la->curfalloff) {
direct_link_curvemapping(fd, la->curfalloff);
+ }
la->nodetree = newdataadr(fd, la->nodetree);
if (la->nodetree) {
@@ -4139,8 +4031,9 @@ static void direct_link_key(FileData *fd, Key *key)
for (kb = key->block.first; kb; kb = kb->next) {
kb->data = newdataadr(fd, kb->data);
- if (fd->flags & FD_FLAGS_SWITCH_ENDIAN)
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
switch_endian_keyblock(key, kb);
+ }
}
}
@@ -4326,10 +4219,12 @@ static void direct_link_image(FileData *fd, Image *ima)
ImagePackedFile *imapf;
/* for undo system, pointers could be restored */
- if (fd->imamap)
+ if (fd->imamap) {
ima->cache = newimaadr(fd, ima->cache);
- else
+ }
+ else {
ima->cache = NULL;
+ }
/* if not restored, we keep the binded opengl index */
if (!ima->cache) {
@@ -4457,8 +4352,9 @@ static void direct_link_curve(FileData *fd, Curve *cu)
cu->tb = tb;
cu->tb[0].w = cu->linewidth;
}
- if (cu->wordspace == 0.0f)
+ if (cu->wordspace == 0.0f) {
cu->wordspace = 1.0f;
+ }
}
cu->editnurb = NULL;
@@ -4470,8 +4366,9 @@ static void direct_link_curve(FileData *fd, Curve *cu)
nu->bp = newdataadr(fd, nu->bp);
nu->knotsu = newdataadr(fd, nu->knotsu);
nu->knotsv = newdataadr(fd, nu->knotsv);
- if (cu->vfont == NULL)
+ if (cu->vfont == NULL) {
nu->charidx = 0;
+ }
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
switch_endian_knots(nu);
@@ -4618,8 +4515,9 @@ static void direct_link_pointcache_cb(FileData *fd, void *data)
link_list(fd, &pm->extradata);
- for (extra = pm->extradata.first; extra; extra = extra->next)
+ for (extra = pm->extradata.first; extra; extra = extra->next) {
extra->data = newdataadr(fd, extra->data);
+ }
}
static void direct_link_pointcache(FileData *fd, PointCache *cache)
@@ -4627,8 +4525,9 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache)
if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
link_list_ex(fd, &cache->mem_cache, direct_link_pointcache_cb);
}
- else
+ else {
BLI_listbase_clear(&cache->mem_cache);
+ }
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe = 0;
@@ -4671,10 +4570,12 @@ static void direct_link_pointcache_list(FileData *fd,
static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
{
- if (pd && pd->tex)
+ if (pd && pd->tex) {
pd->tex = newlibadr_us(fd, id->lib, pd->tex);
- if (pd && pd->f_source)
+ }
+ if (pd && pd->f_source) {
pd->f_source = newlibadr(fd, id->lib, pd->f_source);
+ }
}
static void lib_link_particlesettings(FileData *fd, Main *main)
@@ -4750,8 +4651,9 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
static void direct_link_partdeflect(PartDeflect *pd)
{
- if (pd)
+ if (pd) {
pd->rng = NULL;
+ }
}
static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
@@ -4767,18 +4669,22 @@ static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
direct_link_partdeflect(part->pd2);
part->clumpcurve = newdataadr(fd, part->clumpcurve);
- if (part->clumpcurve)
+ if (part->clumpcurve) {
direct_link_curvemapping(fd, part->clumpcurve);
+ }
part->roughcurve = newdataadr(fd, part->roughcurve);
- if (part->roughcurve)
+ if (part->roughcurve) {
direct_link_curvemapping(fd, part->roughcurve);
+ }
part->twistcurve = newdataadr(fd, part->twistcurve);
- if (part->twistcurve)
+ if (part->twistcurve) {
direct_link_curvemapping(fd, part->twistcurve);
+ }
part->effector_weights = newdataadr(fd, part->effector_weights);
- if (!part->effector_weights)
+ if (!part->effector_weights) {
part->effector_weights = BKE_effector_add_weights(part->eff_group);
+ }
link_list(fd, &part->instance_weights);
@@ -4814,8 +4720,9 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
if (psys->part) {
ParticleTarget *pt = psys->targets.first;
- for (; pt; pt = pt->next)
+ for (; pt; pt = pt->next) {
pt->ob = newlibadr(fd, id->lib, pt->ob);
+ }
psys->parent = newlibadr(fd, id->lib, psys->parent);
psys->target_ob = newlibadr(fd, id->lib, psys->target_ob);
@@ -4850,8 +4757,9 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
psys->particles = newdataadr(fd, psys->particles);
if (psys->particles && psys->particles->hair) {
- for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++)
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
pa->hair = newdataadr(fd, pa->hair);
+ }
}
if (psys->particles && psys->particles->keys) {
@@ -4874,8 +4782,9 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
}
}
else if (psys->particles) {
- for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++)
+ for (a = 0, pa = psys->particles; a < psys->totpart; a++, pa++) {
pa->boid = NULL;
+ }
}
psys->fluid_springs = newdataadr(fd, psys->fluid_springs);
@@ -4903,8 +4812,9 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
if (psys->clmd->sim_parms) {
psys->clmd->sim_parms->effector_weights = NULL;
- if (psys->clmd->sim_parms->presets > 10)
+ if (psys->clmd->sim_parms->presets > 10) {
psys->clmd->sim_parms->presets = 0;
+ }
}
psys->hair_in_mesh = psys->hair_out_mesh = NULL;
@@ -5043,8 +4953,9 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte
/* this does swap for data written at write_mdisps() - readfile.c */
BLI_endian_switch_float_array(*mdisps[i].disps, mdisps[i].totdisp * 3);
}
- if (!external && !mdisps[i].disps)
+ if (!external && !mdisps[i].disps) {
mdisps[i].totdisp = 0;
+ }
}
}
}
@@ -5056,8 +4967,9 @@ static void direct_link_grid_paint_mask(FileData *fd, int count, GridPaintMask *
for (i = 0; i < count; ++i) {
GridPaintMask *gpm = &grid_paint_mask[i];
- if (gpm->data)
+ if (gpm->data) {
gpm->data = newdataadr(fd, gpm->data);
+ }
}
}
}
@@ -5081,17 +4993,20 @@ static void direct_link_customdata(FileData *fd, CustomData *data, int count)
while (i < data->totlayer) {
CustomDataLayer *layer = &data->layers[i];
- if (layer->flag & CD_FLAG_EXTERNAL)
+ if (layer->flag & CD_FLAG_EXTERNAL) {
layer->flag &= ~CD_FLAG_IN_MEMORY;
+ }
layer->flag &= ~CD_FLAG_NOFREE;
if (CustomData_verify_versions(data, i)) {
layer->data = newdataadr(fd, layer->data);
- if (layer->type == CD_MDISPS)
+ if (layer->type == CD_MDISPS) {
direct_link_mdisps(fd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
- else if (layer->type == CD_GRID_PAINT_MASK)
+ }
+ else if (layer->type == CD_GRID_PAINT_MASK) {
direct_link_grid_paint_mask(fd, count, layer->data);
+ }
i++;
}
}
@@ -5164,8 +5079,9 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
* array, or the verts array contains out-of-date
* data. */
if (mesh->totvert == ((MultiresLevel *)mesh->mr->levels.last)->totvert) {
- if (mesh->mr->verts)
+ if (mesh->mr->verts) {
MEM_freeN(mesh->mr->verts);
+ }
mesh->mr->verts = MEM_dupallocN(mesh->mvert);
}
@@ -5318,10 +5234,12 @@ static void lib_link_object(FileData *fd, Main *main)
ob->proxy->proxy_from = NULL;
ob->proxy = NULL;
- if (ob->id.lib)
+ if (ob->id.lib) {
printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->name);
- else
+ }
+ else {
printf("Proxy lost from object %s lib <NONE>\n", ob->id.name + 2);
+ }
}
else {
/* this triggers object_update to always use a copy */
@@ -5334,10 +5252,12 @@ static void lib_link_object(FileData *fd, Main *main)
ob->data = newlibadr_us(fd, ob->id.lib, ob->data);
if (ob->data == NULL && poin != NULL) {
- if (ob->id.lib)
+ if (ob->id.lib) {
printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->name);
- else
+ }
+ else {
printf("Object %s lost data.\n", ob->id.name + 2);
+ }
ob->type = OB_EMPTY;
warn = true;
@@ -5357,8 +5277,9 @@ static void lib_link_object(FileData *fd, Main *main)
ob->mode &= ~OB_MODE_POSE;
}
}
- for (a = 0; a < ob->totcol; a++)
+ for (a = 0; a < ob->totcol; a++) {
ob->mat[a] = newlibadr_us(fd, ob->id.lib, ob->mat[a]);
+ }
/* When the object is local and the data is library its possible
* the material list size gets out of sync. [#22663] */
@@ -5395,9 +5316,10 @@ static void lib_link_object(FileData *fd, Main *main)
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(
ob, eModifierType_Fluidsim);
- if (fluidmd && fluidmd->fss)
+ if (fluidmd && fluidmd->fss) {
fluidmd->fss->ipo = newlibadr_us(
fd, ob->id.lib, fluidmd->fss->ipo); // XXX deprecated - old animation system
+ }
}
{
@@ -5411,8 +5333,9 @@ static void lib_link_object(FileData *fd, Main *main)
}
/* texture field */
- if (ob->pd)
+ if (ob->pd) {
lib_link_partdeflect(fd, &ob->id, ob->pd);
+ }
if (ob->soft) {
ob->soft->collision_group = newlibadr(fd, ob->id.lib, ob->soft->collision_group);
@@ -5436,8 +5359,9 @@ static void lib_link_object(FileData *fd, Main *main)
for (level = ob->lodlevels.first; level; level = level->next) {
level->source = newlibadr(fd, ob->id.lib, level->source);
- if (!level->source && level == ob->lodlevels.first)
+ if (!level->source && level == ob->lodlevels.first) {
level->source = ob;
+ }
}
}
}
@@ -5452,8 +5376,9 @@ static void lib_link_object(FileData *fd, Main *main)
static void direct_link_motionpath(FileData *fd, bMotionPath *mpath)
{
/* sanity check */
- if (mpath == NULL)
+ if (mpath == NULL) {
return;
+ }
/* relink points cache */
mpath->points = newdataadr(fd, mpath->points);
@@ -5467,8 +5392,9 @@ static void direct_link_pose(FileData *fd, bPose *pose)
{
bPoseChannel *pchan;
- if (!pose)
+ if (!pose) {
return;
+ }
link_list(fd, &pose->chanbase);
link_list(fd, &pose->agroups);
@@ -5491,8 +5417,9 @@ static void direct_link_pose(FileData *fd, bPose *pose)
IDP_DirectLinkGroup_OrFree(&pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
pchan->mpath = newdataadr(fd, pchan->mpath);
- if (pchan->mpath)
+ if (pchan->mpath) {
direct_link_motionpath(fd, pchan->mpath);
+ }
BLI_listbase_clear(&pchan->iktree);
BLI_listbase_clear(&pchan->siktree);
@@ -5501,7 +5428,7 @@ static void direct_link_pose(FileData *fd, bPose *pose)
CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
pchan->draw_data = NULL;
- memset(&pchan->runtime, 0, sizeof(pchan->runtime));
+ BKE_pose_channel_runtime_reset(&pchan->runtime);
}
pose->ikdata = NULL;
if (pose->ikparam != NULL) {
@@ -5520,8 +5447,9 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
md->runtime = NULL;
/* if modifiers disappear, or for upward compatibility */
- if (NULL == modifierType_getInfo(md->type))
+ if (NULL == modifierType_getInfo(md->type)) {
md->type = eModifierType_None;
+ }
if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
@@ -5545,8 +5473,9 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache, 0);
if (clmd->sim_parms) {
- if (clmd->sim_parms->presets > 10)
+ if (clmd->sim_parms->presets > 10) {
clmd->sim_parms->presets = 0;
+ }
clmd->sim_parms->reset = 0;
@@ -5594,8 +5523,9 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->domain->coba = newdataadr(fd, smd->domain->coba);
smd->domain->effector_weights = newdataadr(fd, smd->domain->effector_weights);
- if (!smd->domain->effector_weights)
+ if (!smd->domain->effector_weights) {
smd->domain->effector_weights = BKE_effector_add_weights(NULL);
+ }
direct_link_pointcache_list(
fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0]), 1);
@@ -5663,8 +5593,9 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
surface->data = NULL;
direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
- if (!(surface->effector_weights = newdataadr(fd, surface->effector_weights)))
+ if (!(surface->effector_weights = newdataadr(fd, surface->effector_weights))) {
surface->effector_weights = BKE_effector_add_weights(NULL);
+ }
}
}
}
@@ -5752,16 +5683,21 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
mmd->bindcos = newdataadr(fd, mmd->bindcos);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- if (mmd->bindoffsets)
+ if (mmd->bindoffsets) {
BLI_endian_switch_int32_array(mmd->bindoffsets, mmd->totvert + 1);
- if (mmd->bindcagecos)
+ }
+ if (mmd->bindcagecos) {
BLI_endian_switch_float_array(mmd->bindcagecos, mmd->totcagevert * 3);
- if (mmd->dynverts)
+ }
+ if (mmd->dynverts) {
BLI_endian_switch_int32_array(mmd->dynverts, mmd->totvert);
- if (mmd->bindweights)
+ }
+ if (mmd->bindweights) {
BLI_endian_switch_float_array(mmd->bindweights, mmd->totvert);
- if (mmd->bindcos)
+ }
+ if (mmd->bindcos) {
BLI_endian_switch_float_array(mmd->bindcos, mmd->totcagevert * 3);
+ }
}
}
else if (md->type == eModifierType_Ocean) {
@@ -5773,15 +5709,17 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
WarpModifierData *tmd = (WarpModifierData *)md;
tmd->curfalloff = newdataadr(fd, tmd->curfalloff);
- if (tmd->curfalloff)
+ if (tmd->curfalloff) {
direct_link_curvemapping(fd, tmd->curfalloff);
+ }
}
else if (md->type == eModifierType_WeightVGEdit) {
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
wmd->cmap_curve = newdataadr(fd, wmd->cmap_curve);
- if (wmd->cmap_curve)
+ if (wmd->cmap_curve) {
direct_link_curvemapping(fd, wmd->cmap_curve);
+ }
}
else if (md->type == eModifierType_LaplacianDeform) {
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
@@ -5809,6 +5747,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
else if (md->type == eModifierType_MeshSequenceCache) {
MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md;
msmcd->reader = NULL;
+ msmcd->reader_object_path[0] = '\0';
}
else if (md->type == eModifierType_SurfaceDeform) {
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
@@ -5826,9 +5765,10 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
fd, smd->verts[i].binds[j].vert_weights);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- if (smd->verts[i].binds[j].vert_inds)
+ if (smd->verts[i].binds[j].vert_inds) {
BLI_endian_switch_uint32_array(smd->verts[i].binds[j].vert_inds,
smd->verts[i].binds[j].numverts);
+ }
if (smd->verts[i].binds[j].vert_weights) {
if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
@@ -5859,8 +5799,9 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
md->error = NULL;
/* if modifiers disappear, or for upward compatibility */
- if (NULL == BKE_gpencil_modifierType_getInfo(md->type))
+ if (NULL == BKE_gpencil_modifierType_getInfo(md->type)) {
md->type = eModifierType_None;
+ }
if (md->type == eGpencilModifierType_Lattice) {
LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData *)md;
@@ -5897,8 +5838,9 @@ static void direct_link_shaderfxs(FileData *fd, ListBase *lb)
fx->error = NULL;
/* if shader disappear, or for upward compatibility */
- if (NULL == BKE_shaderfxType_getInfo(fx->type))
+ if (NULL == BKE_shaderfxType_getInfo(fx->type)) {
fx->type = eShaderFxType_None;
+ }
}
}
@@ -5906,7 +5848,8 @@ static void direct_link_object(FileData *fd, Object *ob)
{
PartEff *paf;
- /* XXX This should not be needed - but seems like it can happen in some cases, so for now play safe... */
+ /* XXX This should not be needed - but seems like it can happen in some cases,
+ * so for now play safe. */
ob->proxy_from = NULL;
/* loading saved files with editmode enabled works, but for undo we like
@@ -5929,8 +5872,9 @@ static void direct_link_object(FileData *fd, Object *ob)
direct_link_pose(fd, ob->pose);
ob->mpath = newdataadr(fd, ob->mpath);
- if (ob->mpath)
+ if (ob->mpath) {
direct_link_motionpath(fd, ob->mpath);
+ }
link_list(fd, &ob->defbase);
link_list(fd, &ob->fmaps);
@@ -6020,8 +5964,9 @@ static void direct_link_object(FileData *fd, Object *ob)
}
sb->effector_weights = newdataadr(fd, sb->effector_weights);
- if (!sb->effector_weights)
+ if (!sb->effector_weights) {
sb->effector_weights = BKE_effector_add_weights(NULL);
+ }
sb->shared = newdataadr(fd, sb->shared);
if (sb->shared == NULL) {
@@ -6045,8 +5990,9 @@ static void direct_link_object(FileData *fd, Object *ob)
rbo->shared = MEM_callocN(sizeof(*rbo->shared), "RigidBodyObShared");
}
ob->rigidbody_constraint = newdataadr(fd, ob->rigidbody_constraint);
- if (ob->rigidbody_constraint)
+ if (ob->rigidbody_constraint) {
ob->rigidbody_constraint->physics_constraint = NULL;
+ }
link_list(fd, &ob->particlesystem);
direct_link_particlesystems(fd, &ob->particlesystem);
@@ -6114,8 +6060,9 @@ static void direct_link_view_settings(FileData *fd, ColorManagedViewSettings *vi
{
view_settings->curve_mapping = newdataadr(fd, view_settings->curve_mapping);
- if (view_settings->curve_mapping)
+ if (view_settings->curve_mapping) {
direct_link_curvemapping(fd, view_settings->curve_mapping);
+ }
}
/** \} */
@@ -6333,8 +6280,9 @@ static void composite_patch(bNodeTree *ntree, Scene *scene)
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->id == NULL && node->type == CMP_NODE_R_LAYERS)
+ if (node->id == NULL && node->type == CMP_NODE_R_LAYERS) {
node->id = &scene->id;
+ }
}
}
@@ -6359,8 +6307,9 @@ static void lib_link_sequence_modifiers(FileData *fd, Scene *scene, ListBase *lb
SequenceModifierData *smd;
for (smd = lb->first; smd; smd = smd->next) {
- if (smd->mask_id)
+ if (smd->mask_id) {
smd->mask_id = newlibadr_us(fd, scene->id.lib, smd->mask_id);
+ }
}
}
@@ -6413,8 +6362,9 @@ static bool scene_validate_setscene__liblink(Scene *sce, const int totscene)
Scene *sce_iter;
int a;
- if (sce->set == NULL)
+ if (sce->set == NULL) {
return 1;
+ }
for (a = 0, sce_iter = sce; sce_iter->set; sce_iter = sce_iter->set, a++) {
if (sce_iter->id.tag & LIB_TAG_NEED_LINK) {
@@ -6459,21 +6409,25 @@ static void lib_link_scene(FileData *fd, Main *main)
link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint);
link_paint(fd, sce, &sce->toolsettings->gp_paint->paint);
- if (sce->toolsettings->sculpt)
+ if (sce->toolsettings->sculpt) {
sce->toolsettings->sculpt->gravity_object = newlibadr(
fd, sce->id.lib, sce->toolsettings->sculpt->gravity_object);
+ }
- if (sce->toolsettings->imapaint.stencil)
+ if (sce->toolsettings->imapaint.stencil) {
sce->toolsettings->imapaint.stencil = newlibadr_us(
fd, sce->id.lib, sce->toolsettings->imapaint.stencil);
+ }
- if (sce->toolsettings->imapaint.clone)
+ if (sce->toolsettings->imapaint.clone) {
sce->toolsettings->imapaint.clone = newlibadr_us(
fd, sce->id.lib, sce->toolsettings->imapaint.clone);
+ }
- if (sce->toolsettings->imapaint.canvas)
+ if (sce->toolsettings->imapaint.canvas) {
sce->toolsettings->imapaint.canvas = newlibadr_us(
fd, sce->id.lib, sce->toolsettings->imapaint.canvas);
+ }
sce->toolsettings->particle.shape_object = newlibadr(
fd, sce->id.lib, sce->toolsettings->particle.shape_object);
@@ -6493,8 +6447,9 @@ static void lib_link_scene(FileData *fd, Main *main)
TIP_("LIB: object lost from scene: '%s'"),
sce->id.name + 2);
BLI_remlink(&sce->base, base_legacy);
- if (base_legacy == sce->basact)
+ if (base_legacy == sce->basact) {
sce->basact = NULL;
+ }
MEM_freeN(base_legacy);
}
}
@@ -6503,9 +6458,10 @@ static void lib_link_scene(FileData *fd, Main *main)
SEQ_BEGIN (sce->ed, seq) {
IDP_LibLinkProperty(seq->prop, fd);
- if (seq->ipo)
+ if (seq->ipo) {
seq->ipo = newlibadr_us(
fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system
+ }
seq->scene_sound = NULL;
if (seq->scene) {
seq->scene = newlibadr(fd, sce->id.lib, seq->scene);
@@ -6557,12 +6513,15 @@ static void lib_link_scene(FileData *fd, Main *main)
/* rigidbody world relies on it's linked collections */
if (sce->rigidbody_world) {
RigidBodyWorld *rbw = sce->rigidbody_world;
- if (rbw->group)
+ if (rbw->group) {
rbw->group = newlibadr(fd, sce->id.lib, rbw->group);
- if (rbw->constraints)
+ }
+ if (rbw->constraints) {
rbw->constraints = newlibadr(fd, sce->id.lib, rbw->constraints);
- if (rbw->effector_weights)
+ }
+ if (rbw->effector_weights) {
rbw->effector_weights->group = newlibadr(fd, sce->id.lib, rbw->effector_weights->group);
+ }
}
if (sce->nodetree) {
@@ -6648,21 +6607,25 @@ static void link_recurs_seq(FileData *fd, ListBase *lb)
link_list(fd, lb);
for (seq = lb->first; seq; seq = seq->next) {
- if (seq->seqbase.first)
+ if (seq->seqbase.first) {
link_recurs_seq(fd, &seq->seqbase);
+ }
}
}
static void direct_link_paint(FileData *fd, const Scene *scene, Paint *p)
{
- if (p->num_input_samples < 1)
+ if (p->num_input_samples < 1) {
p->num_input_samples = 1;
+ }
p->cavity_curve = newdataadr(fd, p->cavity_curve);
- if (p->cavity_curve)
+ if (p->cavity_curve) {
direct_link_curvemapping(fd, p->cavity_curve);
- else
+ }
+ else {
BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE);
+ }
p->tool_slots = newdataadr(fd, p->tool_slots);
@@ -6686,8 +6649,9 @@ static void direct_link_sequence_modifiers(FileData *fd, ListBase *lb)
link_list(fd, lb);
for (smd = lb->first; smd; smd = smd->next) {
- if (smd->mask_sequence)
+ if (smd->mask_sequence) {
smd->mask_sequence = newdataadr(fd, smd->mask_sequence);
+ }
if (smd->type == seqModifierType_Curves) {
CurvesModifierData *cmd = (CurvesModifierData *)smd;
@@ -6774,6 +6738,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
ed = sce->ed = newdataadr(fd, sce->ed);
ed->act_seq = newdataadr(fd, ed->act_seq);
+ ed->cache = NULL;
/* recursive link sequences, lb will be correctly initialized */
link_recurs_seq(fd, &ed->seqbase);
@@ -6784,14 +6749,16 @@ static void direct_link_scene(FileData *fd, Scene *sce)
seq->seq3 = newdataadr(fd, seq->seq3);
/* a patch: after introduction of effects with 3 input strips */
- if (seq->seq3 == NULL)
+ if (seq->seq3 == NULL) {
seq->seq3 = seq->seq2;
+ }
seq->effectdata = newdataadr(fd, seq->effectdata);
seq->stereo3d_format = newdataadr(fd, seq->stereo3d_format);
- if (seq->type & SEQ_TYPE_EFFECT)
+ if (seq->type & SEQ_TYPE_EFFECT) {
seq->flag |= SEQ_EFFECT_NOT_LOADED;
+ }
if (seq->type == SEQ_TYPE_SPEED) {
SpeedControlVars *s = seq->effectdata;
@@ -6853,7 +6820,8 @@ static void direct_link_scene(FileData *fd, Scene *sce)
}
SEQ_END;
- /* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */
+ /* link metastack, slight abuse of structs here,
+ * have to restore pointer to internal part in struct */
{
Sequence temp;
void *poin;
@@ -6869,10 +6837,12 @@ static void direct_link_scene(FileData *fd, Scene *sce)
poin = POINTER_OFFSET(ed->seqbasep, -offset);
poin = newdataadr(fd, poin);
- if (poin)
+ if (poin) {
ed->seqbasep = (ListBase *)POINTER_OFFSET(poin, offset);
- else
+ }
+ else {
ed->seqbasep = &ed->seqbase;
+ }
}
/* stack */
link_list(fd, &(ed->metastack));
@@ -6880,20 +6850,28 @@ static void direct_link_scene(FileData *fd, Scene *sce)
for (ms = ed->metastack.first; ms; ms = ms->next) {
ms->parseq = newdataadr(fd, ms->parseq);
- if (ms->oldbasep == old_seqbasep)
+ if (ms->oldbasep == old_seqbasep) {
ms->oldbasep = &ed->seqbase;
+ }
else {
poin = POINTER_OFFSET(ms->oldbasep, -offset);
poin = newdataadr(fd, poin);
- if (poin)
+ if (poin) {
ms->oldbasep = (ListBase *)POINTER_OFFSET(poin, offset);
- else
+ }
+ else {
ms->oldbasep = &ed->seqbase;
+ }
}
}
}
}
+#ifdef DURIAN_CAMERA_SWITCH
+ /* Runtime */
+ sce->r.mode &= ~R_NO_CAMERA_SWITCH;
+#endif
+
sce->r.avicodecdata = newdataadr(fd, sce->r.avicodecdata);
if (sce->r.avicodecdata) {
sce->r.avicodecdata->lpFormat = newdataadr(fd, sce->r.avicodecdata->lpFormat);
@@ -6961,8 +6939,9 @@ static void direct_link_scene(FileData *fd, Scene *sce)
/* set effector weights */
rbw->effector_weights = newdataadr(fd, rbw->effector_weights);
- if (!rbw->effector_weights)
+ if (!rbw->effector_weights) {
rbw->effector_weights = BKE_effector_add_weights(NULL);
+ }
}
sce->preview = direct_link_preview_image(fd, sce->preview);
@@ -6992,10 +6971,12 @@ static void direct_link_scene(FileData *fd, Scene *sce)
if (fd->memfile) {
/* If it's undo try to recover the cache. */
- if (fd->scenemap)
+ if (fd->scenemap) {
sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache);
- else
+ }
+ else {
sce->eevee.light_cache = NULL;
+ }
}
else {
/* else try to read the cache from file. */
@@ -7050,8 +7031,9 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
bGPDpalette *palette;
/* we must firstly have some grease-pencil data to link! */
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* relink animdata */
gpd->adt = newdataadr(fd, gpd->adt);
@@ -7236,11 +7218,13 @@ static void direct_link_area(FileData *fd, ScrArea *area)
/* if we do not have the spacetype registered we cannot
* free it, so don't allocate any new memory for such spacetypes. */
- if (!BKE_spacetype_exists(sl->spacetype))
+ if (!BKE_spacetype_exists(sl->spacetype)) {
sl->spacetype = SPACE_EMPTY;
+ }
- for (ar = sl->regionbase.first; ar; ar = ar->next)
+ for (ar = sl->regionbase.first; ar; ar = ar->next) {
direct_link_region(fd, ar, sl->spacetype);
+ }
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
@@ -7260,10 +7244,12 @@ static void direct_link_area(FileData *fd, ScrArea *area)
}
v3d->shading.prev_type = OB_SOLID;
- if (v3d->fx_settings.dof)
+ if (v3d->fx_settings.dof) {
v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof);
- if (v3d->fx_settings.ssao)
+ }
+ if (v3d->fx_settings.ssao) {
v3d->fx_settings.ssao = newdataadr(fd, v3d->fx_settings.ssao);
+ }
blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
}
@@ -7384,7 +7370,7 @@ static void direct_link_area(FileData *fd, ScrArea *area)
link_list(fd, &sconsole->scrollback);
link_list(fd, &sconsole->history);
- //for (cl= sconsole->scrollback.first; cl; cl= cl->next)
+ // for (cl= sconsole->scrollback.first; cl; cl= cl->next)
// cl->line= newdataadr(fd, cl->line);
/* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
@@ -7568,11 +7554,13 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
/* first nodetree in path is same as snode->nodetree */
path->nodetree = snode->nodetree;
}
- else
+ else {
path->nodetree = newlibadr_us(fd, parent_id->lib, path->nodetree);
+ }
- if (!path->nodetree)
+ if (!path->nodetree) {
break;
+ }
}
/* remaining path entries are invalid, remove */
@@ -7653,7 +7641,8 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
WorkSpaceInstanceHook *hook = win->workspace_hook;
win->workspace_hook = newdataadr(fd, hook);
- /* we need to restore a pointer to this later when reading workspaces, so store in global oldnew-map */
+ /* we need to restore a pointer to this later when reading workspaces,
+ * so store in global oldnew-map. */
oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0);
direct_link_area_map(fd, &win->global_areas);
@@ -7883,7 +7872,8 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View
v3d->localvd->camera = scene->camera;
- /* Localview can become invalid during undo/redo steps, so we exit it when no could be found. */
+ /* Localview can become invalid during undo/redo steps,
+ * so we exit it when no could be found. */
for (base = view_layer->object_bases.first; base; base = base->next) {
if (base->local_view_bits & v3d->local_view_uuid) {
break;
@@ -7949,9 +7939,10 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
if (ads) {
ads->source = restore_pointer_by_name(id_map, (ID *)ads->source, USER_REAL);
- if (ads->filter_grp)
+ if (ads->filter_grp) {
ads->filter_grp = restore_pointer_by_name(
id_map, (ID *)ads->filter_grp, USER_IGNORE);
+ }
}
/* force recalc of list of channels (i.e. includes calculating F-Curve colors)
@@ -7982,9 +7973,10 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
saction->ads.source = restore_pointer_by_name(
id_map, (ID *)saction->ads.source, USER_REAL);
- if (saction->ads.filter_grp)
+ if (saction->ads.filter_grp) {
saction->ads.filter_grp = restore_pointer_by_name(
id_map, (ID *)saction->ads.filter_grp, USER_IGNORE);
+ }
/* force recalc of list of channels, potentially updating the active action
* while we're at it (as it can only be updated that way) [#28962]
@@ -8031,17 +8023,19 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
if (ads) {
ads->source = restore_pointer_by_name(id_map, (ID *)ads->source, USER_REAL);
- if (ads->filter_grp)
+ if (ads->filter_grp) {
ads->filter_grp = restore_pointer_by_name(
id_map, (ID *)ads->filter_grp, USER_IGNORE);
+ }
}
}
else if (sl->spacetype == SPACE_TEXT) {
SpaceText *st = (SpaceText *)sl;
st->text = restore_pointer_by_name(id_map, (ID *)st->text, USER_REAL);
- if (st->text == NULL)
+ if (st->text == NULL) {
st->text = newmain->texts.first;
+ }
}
else if (sl->spacetype == SPACE_SCRIPT) {
SpaceScript *scpt = (SpaceScript *)sl;
@@ -8064,7 +8058,8 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
BLI_mempool_iternew(so->treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
- /* Do not try to restore pointers to drivers/sequence/etc., can crash in undo case! */
+ /* Do not try to restore pointers to drivers/sequence/etc.,
+ * can crash in undo case! */
if (TSE_IS_REAL_ID(tselem)) {
tselem->id = restore_pointer_by_name(id_map, tselem->id, USER_IGNORE);
}
@@ -8097,11 +8092,13 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
/* first nodetree in path is same as snode->nodetree */
path->nodetree = snode->nodetree;
}
- else
+ else {
path->nodetree = restore_pointer_by_name(id_map, (ID *)path->nodetree, USER_REAL);
+ }
- if (!path->nodetree)
+ if (!path->nodetree) {
break;
+ }
}
/* remaining path entries are invalid, remove */
@@ -8118,8 +8115,9 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
path = snode->treepath.last;
snode->edittree = path->nodetree;
}
- else
+ else {
snode->edittree = NULL;
+ }
}
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
@@ -8206,8 +8204,9 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
}
/* this was not initialized correct always */
- if (v3d->gridsubdiv == 0)
+ if (v3d->gridsubdiv == 0) {
v3d->gridsubdiv = 10;
+ }
}
static bool direct_link_screen(FileData *fd, bScreen *sc)
@@ -8254,8 +8253,9 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
BLI_remlink(&main->libraries, lib);
MEM_freeN(lib);
- /* Now, since Blender always expect **latest** Main pointer from fd->mainlist to be the active library
- * Main pointer, where to add all non-library data-blocks found in file next, we have to switch that
+ /* Now, since Blender always expect **latest** Main pointer from fd->mainlist
+ * to be the active library Main pointer,
+ * where to add all non-library data-blocks found in file next, we have to switch that
* 'dupli' found Main to latest position in the list!
* Otherwise, you get weird disappearing linked data on a rather inconsistent basis.
* See also T53977 for reproducible case. */
@@ -8292,7 +8292,8 @@ static void lib_link_library(FileData *UNUSED(fd), Main *main)
}
}
-/* Always call this once you have loaded new library data to set the relative paths correctly in relation to the blend file */
+/* Always call this once you have loaded new library data to set the relative paths correctly
+ * in relation to the blend file. */
static void fix_relpaths_library(const char *basepath, Main *main)
{
Library *lib;
@@ -8312,7 +8313,8 @@ static void fix_relpaths_library(const char *basepath, Main *main)
else {
for (lib = main->libraries.first; lib; lib = lib->id.next) {
/* Libraries store both relative and abs paths, recreate relative paths,
- * relative to the blend file since indirectly linked libs will be relative to their direct linked library */
+ * relative to the blend file since indirectly linked libs will be
+ * relative to their direct linked library. */
if (BLI_path_is_rel(lib->name)) { /* if this is relative to begin with? */
BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
BLI_path_rel(lib->name, basepath);
@@ -8480,15 +8482,19 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip)
clip->adt = newdataadr(fd, clip->adt);
- if (fd->movieclipmap)
+ if (fd->movieclipmap) {
clip->cache = newmclipadr(fd, clip->cache);
- else
+ }
+ else {
clip->cache = NULL;
+ }
- if (fd->movieclipmap)
+ if (fd->movieclipmap) {
clip->tracking.camera.intrinsics = newmclipadr(fd, clip->tracking.camera.intrinsics);
- else
+ }
+ else {
clip->tracking.camera.intrinsics = NULL;
+ }
direct_link_movieTracks(fd, &tracking->tracks);
direct_link_moviePlaneTracks(fd, &tracking->plane_tracks);
@@ -8591,8 +8597,9 @@ static void direct_link_mask(FileData *fd, Mask *mask)
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
- if (point->tot_uw)
+ if (point->tot_uw) {
point->uw = newdataadr(fd, point->uw);
+ }
}
/* detect active point */
@@ -8893,17 +8900,21 @@ static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
linestyle->adt = newdataadr(fd, linestyle->adt);
direct_link_animdata(fd, linestyle->adt);
link_list(fd, &linestyle->color_modifiers);
- for (modifier = linestyle->color_modifiers.first; modifier; modifier = modifier->next)
+ for (modifier = linestyle->color_modifiers.first; modifier; modifier = modifier->next) {
direct_link_linestyle_color_modifier(fd, modifier);
+ }
link_list(fd, &linestyle->alpha_modifiers);
- for (modifier = linestyle->alpha_modifiers.first; modifier; modifier = modifier->next)
+ for (modifier = linestyle->alpha_modifiers.first; modifier; modifier = modifier->next) {
direct_link_linestyle_alpha_modifier(fd, modifier);
+ }
link_list(fd, &linestyle->thickness_modifiers);
- for (modifier = linestyle->thickness_modifiers.first; modifier; modifier = modifier->next)
+ for (modifier = linestyle->thickness_modifiers.first; modifier; modifier = modifier->next) {
direct_link_linestyle_thickness_modifier(fd, modifier);
+ }
link_list(fd, &linestyle->geometry_modifiers);
- for (modifier = linestyle->geometry_modifiers.first; modifier; modifier = modifier->next)
+ for (modifier = linestyle->geometry_modifiers.first; modifier; modifier = modifier->next) {
direct_link_linestyle_geometry_modifier(fd, modifier);
+ }
for (a = 0; a < MAX_MTEX; a++) {
linestyle->mtex[a] = newdataadr(fd, linestyle->mtex[a]);
}
@@ -9037,11 +9048,14 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta
const char *allocname;
bool wrong_id = false;
- /* In undo case, most libs and linked data should be kept as is from previous state (see BLO_read_from_memfile).
- * However, some needed by the snapshot being read may have been removed in previous one, and would go missing.
+ /* In undo case, most libs and linked data should be kept as is from previous state
+ * (see BLO_read_from_memfile).
+ * However, some needed by the snapshot being read may have been removed in previous one,
+ * and would go missing.
* This leads e.g. to disappearing objects in some undo/redo case, see T34446.
- * That means we have to carefully check whether current lib or libdata already exits in old main, if it does
- * we merely copy it over into new main area, otherwise we have to do a full read of that bhead... */
+ * That means we have to carefully check whether current lib or
+ * libdata already exits in old main, if it does we merely copy it over into new main area,
+ * otherwise we have to do a full read of that bhead... */
if (fd->memfile && ELEM(bhead->code, ID_LI, ID_LINK_PLACEHOLDER)) {
const char *idname = blo_bhead_id_name(fd, bhead);
@@ -9055,9 +9069,11 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta
if (libmain->curlib && STREQ(idname, libmain->curlib->id.name)) {
Main *oldmain = fd->old_mainlist->first;
DEBUG_PRINTF("FOUND!\n");
- /* In case of a library, we need to re-add its main to fd->mainlist, because if we have later
- * a missing ID_LINK_PLACEHOLDER, we need to get the correct lib it is linked to!
- * Order is crucial, we cannot bulk-add it in BLO_read_from_memfile() like it used to be... */
+ /* In case of a library, we need to re-add its main to fd->mainlist,
+ * because if we have later a missing ID_LINK_PLACEHOLDER,
+ * we need to get the correct lib it is linked to!
+ * Order is crucial, we cannot bulk-add it in BLO_read_from_memfile()
+ * like it used to be. */
BLI_remlink(fd->old_mainlist, libmain);
BLI_remlink_safe(&oldmain->libraries, libmain->curlib);
BLI_addtail(fd->mainlist, libmain);
@@ -9077,12 +9093,14 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta
main->curlib ? main->curlib->name : "<NULL>");
if ((id = BKE_libblock_find_name(main, GS(idname), idname + 2))) {
DEBUG_PRINTF("FOUND!\n");
- /* Even though we found our linked ID, there is no guarantee its address is still the same... */
+ /* Even though we found our linked ID,
+ * there is no guarantee its address is still the same. */
if (id != bhead->old) {
oldnewmap_insert(fd->libmap, bhead->old, id, GS(id->name));
}
- /* No need to do anything else for ID_LINK_PLACEHOLDER, it's assumed already present in its lib's main... */
+ /* No need to do anything else for ID_LINK_PLACEHOLDER,
+ * it's assumed already present in its lib's main. */
if (r_id) {
*r_id = NULL; /* Just in case... */
}
@@ -9112,10 +9130,12 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta
}
}
- if (r_id)
+ if (r_id) {
*r_id = id;
- if (!id)
+ }
+ if (!id) {
return blo_bhead_next(fd, bhead);
+ }
id->lib = main->curlib;
id->us = ID_FAKE_USERS(id);
@@ -9289,19 +9309,24 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
bfd->globalf = fg->globalf;
BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename));
- /* error in 2.65 and older: main->name was not set if you save from startup (not after loading file) */
+ /* Error in 2.65 and older: main->name was not set if you save from startup
+ * (not after loading file). */
if (bfd->filename[0] == 0) {
- if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1))
- if ((G.fileflags & G_FILE_RECOVER) == 0)
+ if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1)) {
+ if ((G.fileflags & G_FILE_RECOVER) == 0) {
BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
+ }
+ }
/* early 2.50 version patch - filename not in FileGlobal struct at all */
- if (fd->fileversion <= 250)
+ if (fd->fileversion <= 250) {
BLI_strncpy(bfd->filename, BKE_main_blendfile_path(bfd->main), sizeof(bfd->filename));
+ }
}
- if (G.fileflags & G_FILE_RECOVER)
+ if (G.fileflags & G_FILE_RECOVER) {
BLI_strncpy(fd->relabase, fg->filename, sizeof(fd->relabase));
+ }
bfd->curscreen = fg->curscreen;
bfd->curscene = fg->curscene;
@@ -9323,8 +9348,9 @@ static void link_global(FileData *fd, BlendFileData *bfd)
bfd->curscene = newlibadr(fd, NULL, bfd->curscene);
// this happens in files older than 2.35
if (bfd->curscene == NULL) {
- if (bfd->curscreen)
+ if (bfd->curscreen) {
bfd->curscene = bfd->curscreen->scene;
+ }
}
}
@@ -9341,13 +9367,15 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd)
Main *bmain = bfd->main;
UserDef *user = bfd->user;
- if (user == NULL)
+ if (user == NULL) {
return;
+ }
if (MAIN_VERSION_OLDER(bmain, 266, 4)) {
bTheme *btheme;
- /* themes for Node and Sequence editor were not using grid color, but back. we copy this over then */
+ /* Themes for Node and Sequence editor were not using grid color,
+ * but back. we copy this over then. */
for (btheme = user->themes.first; btheme; btheme = btheme->next) {
copy_v4_v4_char(btheme->space_node.grid, btheme->space_node.back);
copy_v4_v4_char(btheme->space_sequencer.grid, btheme->space_sequencer.back);
@@ -9402,6 +9430,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
blo_do_versions_260(fd, lib, main);
blo_do_versions_270(fd, lib, main);
blo_do_versions_280(fd, lib, main);
+ blo_do_versions_cycles(fd, lib, main);
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */
@@ -9414,8 +9443,11 @@ static void do_versions_after_linking(Main *main)
// printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->name : main->name,
// main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile);
+ do_versions_after_linking_250(main);
+ do_versions_after_linking_260(main);
do_versions_after_linking_270(main);
do_versions_after_linking_280(main);
+ do_versions_after_linking_cycles(main);
}
/** \} */
@@ -9432,7 +9464,8 @@ static void lib_link_all(FileData *fd, Main *main)
if (fd->memfile == NULL) {
lib_link_windowmanager(fd, main);
}
- /* DO NOT skip screens here, 3Dview may contains pointers to other ID data (like bgpic)! See T41411. */
+ /* DO NOT skip screens here,
+ * 3D viewport may contains pointers to other ID data (like bgpic)! See T41411. */
lib_link_screen(fd, main);
lib_link_scene(fd, main);
lib_link_object(fd, main);
@@ -9527,14 +9560,17 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
kmdi->remove_item = newdataadr(fd, kmdi->remove_item);
kmdi->add_item = newdataadr(fd, kmdi->add_item);
- if (kmdi->remove_item)
+ if (kmdi->remove_item) {
direct_link_keymapitem(fd, kmdi->remove_item);
- if (kmdi->add_item)
+ }
+ if (kmdi->add_item) {
direct_link_keymapitem(fd, kmdi->add_item);
+ }
}
- for (kmi = keymap->items.first; kmi; kmi = kmi->next)
+ for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
direct_link_keymapitem(fd, kmi);
+ }
}
for (wmKeyConfigPref *kpt = user->user_keyconfig_prefs.first; kpt; kpt = kpt->next) {
@@ -9690,14 +9726,15 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
do_versions_after_linking(mainvar);
}
blo_join_main(&mainlist);
+
+ /* After all data has been read and versioned, uses LIB_TAG_NEW. */
+ ntreeUpdateAllNew(bfd->main);
}
BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false);
- /* Before static overrides, which needs typeinfo. */
- lib_verify_nodetree(bfd->main, true);
-
- /* Now that all our data-blocks are loaded, we can re-generate overrides from their references. */
+ /* Now that all our data-blocks are loaded,
+ * we can re-generate overrides from their references. */
if (fd->memfile == NULL) {
/* Do not apply in undo case! */
BKE_main_override_static_update(bfd->main);
@@ -9732,10 +9769,12 @@ static int verg_bheadsort(const void *v1, const void *v2)
{
const struct BHeadSort *x1 = v1, *x2 = v2;
- if (x1->old > x2->old)
+ if (x1->old > x2->old) {
return 1;
- else if (x1->old < x2->old)
+ }
+ else if (x1->old < x2->old) {
return -1;
+ }
return 0;
}
@@ -9745,12 +9784,14 @@ static void sort_bhead_old_map(FileData *fd)
struct BHeadSort *bhs;
int tot = 0;
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead))
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
tot++;
+ }
fd->tot_bheadmap = tot;
- if (tot == 0)
+ if (tot == 0) {
return;
+ }
bhs = fd->bheadmap = MEM_malloc_arrayN(tot, sizeof(struct BHeadSort), "BHeadSort");
@@ -9765,12 +9806,14 @@ static void sort_bhead_old_map(FileData *fd)
static BHead *find_previous_lib(FileData *fd, BHead *bhead)
{
/* skip library datablocks in undo, see comment in read_libblock */
- if (fd->memfile)
+ if (fd->memfile) {
return NULL;
+ }
for (; bhead; bhead = blo_bhead_prev(fd, bhead)) {
- if (bhead->code == ID_LI)
+ if (bhead->code == ID_LI) {
break;
+ }
}
return bhead;
@@ -9783,17 +9826,20 @@ static BHead *find_bhead(FileData *fd, void *old)
#endif
struct BHeadSort *bhs, bhs_s;
- if (!old)
+ if (!old) {
return NULL;
+ }
- if (fd->bheadmap == NULL)
+ if (fd->bheadmap == NULL) {
sort_bhead_old_map(fd);
+ }
bhs_s.old = old;
bhs = bsearch(&bhs_s, fd->bheadmap, fd->tot_bheadmap, sizeof(struct BHeadSort), verg_bheadsort);
- if (bhs)
+ if (bhs) {
return bhs->bhead;
+ }
#if 0
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
@@ -9922,8 +9968,12 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
* read yet at that point. */
change_link_placeholder_to_real_ID_pointer_fd(fd, bhead->old, id);
- // commented because this can print way too much
- // if (G.debug & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name);
+ /* Commented because this can print way too much. */
+#if 0
+ if (G.debug & G_DEBUG) {
+ printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name);
+ }
+#endif
}
MEM_freeN(lib);
@@ -9940,8 +9990,9 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
read_libblock(fd, mainvar, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, NULL);
}
else {
- /* this is actually only needed on UI call? when ID was already read before, and another append
- * happens which invokes same ID... in that case the lookup table needs this entry */
+ /* this is actually only needed on UI call? when ID was already read before,
+ * and another append happens which invokes same ID...
+ * in that case the lookup table needs this entry */
oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
// commented because this can print way too much
// if (G.debug & G_DEBUG) printf("expand: already read %s\n", id->name);
@@ -9956,8 +10007,9 @@ static void expand_ipo(FileData *fd, Main *mainvar, Ipo *ipo)
{
IpoCurve *icu;
for (icu = ipo->curve.first; icu; icu = icu->next) {
- if (icu->driver)
+ if (icu->driver) {
expand_doit(fd, mainvar, icu->driver->ob);
+ }
}
}
@@ -9980,8 +10032,9 @@ static void expand_id(FileData *fd, Main *mainvar, ID *id)
static void expand_idprops(FileData *fd, Main *mainvar, IDProperty *prop)
{
- if (!prop)
+ if (!prop) {
return;
+ }
switch (prop->type) {
case IDP_ID:
@@ -10109,8 +10162,9 @@ static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt)
expand_fcurves(fd, mainvar, &adt->drivers);
/* nla-data - referenced actions */
- for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next)
+ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
expand_animdata_nlastrips(fd, mainvar, &nlt->strips);
+ }
}
static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part)
@@ -10123,8 +10177,9 @@ static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSetting
expand_doit(fd, mainvar, part->bb_ob);
expand_doit(fd, mainvar, part->collision_group);
- if (part->adt)
+ if (part->adt) {
expand_animdata(fd, mainvar, part->adt);
+ }
for (a = 0; a < MAX_MTEX; a++) {
if (part->mtex[a]) {
@@ -10190,8 +10245,9 @@ static void expand_key(FileData *fd, Main *mainvar, Key *key)
{
expand_doit(fd, mainvar, key->ipo); // XXX deprecated - old animation system
- if (key->adt)
+ if (key->adt) {
expand_animdata(fd, mainvar, key->adt);
+ }
}
static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
@@ -10199,11 +10255,13 @@ static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
bNode *node;
bNodeSocket *sock;
- if (ntree->adt)
+ if (ntree->adt) {
expand_animdata(fd, mainvar, ntree->adt);
+ }
- if (ntree->gpd)
+ if (ntree->gpd) {
expand_doit(fd, mainvar, ntree->gpd);
+ }
for (node = ntree->nodes.first; node; node = node->next) {
if (node->id && node->type != CMP_NODE_R_LAYERS) {
@@ -10212,16 +10270,20 @@ static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
expand_idprops(fd, mainvar, node->prop);
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
expand_idprops(fd, mainvar, sock->prop);
- for (sock = node->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
expand_idprops(fd, mainvar, sock->prop);
+ }
}
- for (sock = ntree->inputs.first; sock; sock = sock->next)
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
expand_idprops(fd, mainvar, sock->prop);
- for (sock = ntree->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
expand_idprops(fd, mainvar, sock->prop);
+ }
}
static void expand_texture(FileData *fd, Main *mainvar, Tex *tex)
@@ -10229,11 +10291,13 @@ static void expand_texture(FileData *fd, Main *mainvar, Tex *tex)
expand_doit(fd, mainvar, tex->ima);
expand_doit(fd, mainvar, tex->ipo); // XXX deprecated - old animation system
- if (tex->adt)
+ if (tex->adt) {
expand_animdata(fd, mainvar, tex->adt);
+ }
- if (tex->nodetree)
+ if (tex->nodetree) {
expand_nodetree(fd, mainvar, tex->nodetree);
+ }
}
static void expand_brush(FileData *fd, Main *mainvar, Brush *brush)
@@ -10251,11 +10315,13 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma)
{
expand_doit(fd, mainvar, ma->ipo); // XXX deprecated - old animation system
- if (ma->adt)
+ if (ma->adt) {
expand_animdata(fd, mainvar, ma->adt);
+ }
- if (ma->nodetree)
+ if (ma->nodetree) {
expand_nodetree(fd, mainvar, ma->nodetree);
+ }
if (ma->gp_style) {
MaterialGPencilStyle *gp_style = ma->gp_style;
@@ -10268,11 +10334,13 @@ static void expand_light(FileData *fd, Main *mainvar, Light *la)
{
expand_doit(fd, mainvar, la->ipo); // XXX deprecated - old animation system
- if (la->adt)
+ if (la->adt) {
expand_animdata(fd, mainvar, la->adt);
+ }
- if (la->nodetree)
+ if (la->nodetree) {
expand_nodetree(fd, mainvar, la->nodetree);
+ }
}
static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt)
@@ -10280,19 +10348,22 @@ static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt)
expand_doit(fd, mainvar, lt->ipo); // XXX deprecated - old animation system
expand_doit(fd, mainvar, lt->key);
- if (lt->adt)
+ if (lt->adt) {
expand_animdata(fd, mainvar, lt->adt);
+ }
}
static void expand_world(FileData *fd, Main *mainvar, World *wrld)
{
expand_doit(fd, mainvar, wrld->ipo); // XXX deprecated - old animation system
- if (wrld->adt)
+ if (wrld->adt) {
expand_animdata(fd, mainvar, wrld->adt);
+ }
- if (wrld->nodetree)
+ if (wrld->nodetree) {
expand_nodetree(fd, mainvar, wrld->nodetree);
+ }
}
static void expand_mball(FileData *fd, Main *mainvar, MetaBall *mb)
@@ -10303,8 +10374,9 @@ static void expand_mball(FileData *fd, Main *mainvar, MetaBall *mb)
expand_doit(fd, mainvar, mb->mat[a]);
}
- if (mb->adt)
+ if (mb->adt) {
expand_animdata(fd, mainvar, mb->adt);
+ }
}
static void expand_curve(FileData *fd, Main *mainvar, Curve *cu)
@@ -10325,16 +10397,18 @@ static void expand_curve(FileData *fd, Main *mainvar, Curve *cu)
expand_doit(fd, mainvar, cu->taperobj);
expand_doit(fd, mainvar, cu->textoncurve);
- if (cu->adt)
+ if (cu->adt) {
expand_animdata(fd, mainvar, cu->adt);
+ }
}
static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me)
{
int a;
- if (me->adt)
+ if (me->adt) {
expand_animdata(fd, mainvar, me->adt);
+ }
for (a = 0; a < me->totcol; a++) {
expand_doit(fd, mainvar, me->mat[a]);
@@ -10372,8 +10446,9 @@ static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb)
/* deprecated manual expansion stuff */
for (curcon = lb->first; curcon; curcon = curcon->next) {
- if (curcon->ipo)
+ if (curcon->ipo) {
expand_doit(fd, mainvar, curcon->ipo); // XXX deprecated - old animation system
+ }
}
}
@@ -10381,8 +10456,9 @@ static void expand_pose(FileData *fd, Main *mainvar, bPose *pose)
{
bPoseChannel *chan;
- if (!pose)
+ if (!pose) {
return;
+ }
for (chan = pose->chanbase.first; chan; chan = chan->next) {
expand_constraints(fd, mainvar, &chan->constraints);
@@ -10402,8 +10478,9 @@ static void expand_bones(FileData *fd, Main *mainvar, Bone *bone)
static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm)
{
- if (arm->adt)
+ if (arm->adt) {
expand_animdata(fd, mainvar, arm->adt);
+ }
for (Bone *curBone = arm->bonebase.first; curBone; curBone = curBone->next) {
expand_bones(fd, mainvar, curBone);
@@ -10490,27 +10567,33 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
}
// XXX deprecated - old animation system (for version patching only)
- if (ob->adt)
+ if (ob->adt) {
expand_animdata(fd, mainvar, ob->adt);
+ }
for (a = 0; a < ob->totcol; a++) {
expand_doit(fd, mainvar, ob->mat[a]);
}
paf = blo_do_version_give_parteff_245(ob);
- if (paf && paf->group)
+ if (paf && paf->group) {
expand_doit(fd, mainvar, paf->group);
+ }
- if (ob->instance_collection)
+ if (ob->instance_collection) {
expand_doit(fd, mainvar, ob->instance_collection);
+ }
- if (ob->proxy)
+ if (ob->proxy) {
expand_doit(fd, mainvar, ob->proxy);
- if (ob->proxy_group)
+ }
+ if (ob->proxy_group) {
expand_doit(fd, mainvar, ob->proxy_group);
+ }
- for (psys = ob->particlesystem.first; psys; psys = psys->next)
+ for (psys = ob->particlesystem.first; psys; psys = psys->next) {
expand_doit(fd, mainvar, psys->part);
+ }
if (ob->pd) {
expand_doit(fd, mainvar, ob->pd->tex);
@@ -10563,25 +10646,30 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
expand_doit(fd, mainvar, sce->camera);
expand_doit(fd, mainvar, sce->world);
- if (sce->adt)
+ if (sce->adt) {
expand_animdata(fd, mainvar, sce->adt);
+ }
expand_keyingsets(fd, mainvar, &sce->keyingsets);
- if (sce->set)
+ if (sce->set) {
expand_doit(fd, mainvar, sce->set);
+ }
- if (sce->nodetree)
+ if (sce->nodetree) {
expand_nodetree(fd, mainvar, sce->nodetree);
+ }
for (srl = sce->r.layers.first; srl; srl = srl->next) {
expand_doit(fd, mainvar, srl->mat_override);
for (module = srl->freestyleConfig.modules.first; module; module = module->next) {
- if (module->script)
+ if (module->script) {
expand_doit(fd, mainvar, module->script);
+ }
}
for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
- if (lineset->group)
+ if (lineset->group) {
expand_doit(fd, mainvar, lineset->group);
+ }
expand_doit(fd, mainvar, lineset->linestyle);
}
}
@@ -10603,8 +10691,9 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
}
}
- if (sce->gpd)
+ if (sce->gpd) {
expand_doit(fd, mainvar, sce->gpd);
+ }
if (sce->ed) {
Sequence *seq;
@@ -10612,16 +10701,21 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
SEQ_BEGIN (sce->ed, seq) {
expand_idprops(fd, mainvar, seq->prop);
- if (seq->scene)
+ if (seq->scene) {
expand_doit(fd, mainvar, seq->scene);
- if (seq->scene_camera)
+ }
+ if (seq->scene_camera) {
expand_doit(fd, mainvar, seq->scene_camera);
- if (seq->clip)
+ }
+ if (seq->clip) {
expand_doit(fd, mainvar, seq->clip);
- if (seq->mask)
+ }
+ if (seq->mask) {
expand_doit(fd, mainvar, seq->mask);
- if (seq->sound)
+ }
+ if (seq->sound) {
expand_doit(fd, mainvar, seq->sound);
+ }
if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
TextVars *data = seq->effectdata;
@@ -10663,8 +10757,9 @@ static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
{
expand_doit(fd, mainvar, ca->ipo); // XXX deprecated - old animation system
- if (ca->adt)
+ if (ca->adt) {
expand_animdata(fd, mainvar, ca->adt);
+ }
}
static void expand_cachefile(FileData *fd, Main *mainvar, CacheFile *cache_file)
@@ -10678,8 +10773,9 @@ static void expand_speaker(FileData *fd, Main *mainvar, Speaker *spk)
{
expand_doit(fd, mainvar, spk->sound);
- if (spk->adt)
+ if (spk->adt) {
expand_animdata(fd, mainvar, spk->adt);
+ }
}
static void expand_sound(FileData *fd, Main *mainvar, bSound *snd)
@@ -10689,14 +10785,16 @@ static void expand_sound(FileData *fd, Main *mainvar, bSound *snd)
static void expand_lightprobe(FileData *fd, Main *mainvar, LightProbe *prb)
{
- if (prb->adt)
+ if (prb->adt) {
expand_animdata(fd, mainvar, prb->adt);
+ }
}
static void expand_movieclip(FileData *fd, Main *mainvar, MovieClip *clip)
{
- if (clip->adt)
+ if (clip->adt) {
expand_animdata(fd, mainvar, clip->adt);
+ }
}
static void expand_mask_parent(FileData *fd, Main *mainvar, MaskParent *parent)
@@ -10710,8 +10808,9 @@ static void expand_mask(FileData *fd, Main *mainvar, Mask *mask)
{
MaskLayer *mask_layer;
- if (mask->adt)
+ if (mask->adt) {
expand_animdata(fd, mainvar, mask->adt);
+ }
for (mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
MaskSpline *spline;
@@ -10741,22 +10840,27 @@ static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *li
expand_doit(fd, mainvar, linestyle->mtex[a]->object);
}
}
- if (linestyle->nodetree)
+ if (linestyle->nodetree) {
expand_nodetree(fd, mainvar, linestyle->nodetree);
+ }
- if (linestyle->adt)
+ if (linestyle->adt) {
expand_animdata(fd, mainvar, linestyle->adt);
+ }
for (m = linestyle->color_modifiers.first; m; m = m->next) {
- if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
+ if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
expand_doit(fd, mainvar, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
+ }
}
for (m = linestyle->alpha_modifiers.first; m; m = m->next) {
- if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
+ if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
expand_doit(fd, mainvar, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target);
+ }
}
for (m = linestyle->thickness_modifiers.first; m; m = m->next) {
- if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT)
+ if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
expand_doit(fd, mainvar, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target);
+ }
}
}
@@ -10950,7 +11054,8 @@ static void add_loose_objects_to_scene(Main *mainvar,
BLI_assert(scene);
- /* Give all objects which are LIB_TAG_INDIRECT a base, or for a collection when *lib has been set. */
+ /* Give all objects which are LIB_TAG_INDIRECT a base,
+ * or for a collection when *lib has been set. */
for (Object *ob = mainvar->objects.first; ob; ob = ob->id.next) {
bool do_it = (ob->id.tag & LIB_TAG_DOIT) != 0;
if (do_it || ((ob->id.tag & LIB_TAG_INDIRECT) && (ob->id.tag & LIB_TAG_PRE_EXISTING) == 0)) {
@@ -10959,7 +11064,8 @@ static void add_loose_objects_to_scene(Main *mainvar,
do_it = true;
}
else if ((ob->id.lib == lib) && (object_in_any_scene(bmain, ob) == 0)) {
- /* When appending, make sure any indirectly loaded objects get a base, else they cant be accessed at all
+ /* When appending, make sure any indirectly loaded objects get a base,
+ * else they cant be accessed at all
* (see T27437). */
do_it = true;
}
@@ -10989,7 +11095,8 @@ static void add_loose_objects_to_scene(Main *mainvar,
if (flag & FILE_AUTOSELECT) {
base->flag |= BASE_SELECTED;
- /* Do NOT make base active here! screws up GUI stuff, if you want it do it on src/ level. */
+ /* Do NOT make base active here! screws up GUI stuff,
+ * if you want it do it on src/ level. */
}
BKE_scene_object_base_flag_sync_from_base(base);
@@ -11052,14 +11159,16 @@ static void add_collections_to_scene(Main *mainvar,
/* We do not want to force instantiation of indirectly linked collections...
* Except when we are appending (since in that case, we'll end up instantiating all objects,
* it's better to do it via their own collections if possible).
- * Reports showing that desired difference in behaviors between link and append: T62570, T61796. */
+ * Reports showing that desired difference in behaviors between link and append:
+ * See T62570, T61796. */
else if (do_append || (collection->id.tag & LIB_TAG_INDIRECT) == 0) {
bool do_add_collection = (collection->id.tag & LIB_TAG_DOIT) != 0;
if (!do_add_collection) {
/* We need to check that objects in that collections are already instantiated in a scene.
* Otherwise, it's better to add the collection to the scene's active collection, than to
* instantiate its objects in active scene's collection directly. See T61141.
- * Note that we only check object directly into that collection, not recursively into its children.
+ * Note that we only check object directly into that collection,
+ * not recursively into its children.
*/
for (CollectionObject *coll_ob = collection->gobject.first; coll_ob != NULL;
coll_ob = coll_ob->next) {
@@ -11142,8 +11251,9 @@ static ID *link_named_part(
}
else {
/* already linked */
- if (G.debug)
+ if (G.debug) {
printf("append: already linked\n");
+ }
oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
if (!force_indirect && (id->tag & LIB_TAG_INDIRECT)) {
id->tag &= ~LIB_TAG_INDIRECT;
@@ -11178,8 +11288,9 @@ int BLO_library_link_copypaste(Main *mainl, BlendHandle *bh, const unsigned int
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
ID *id = NULL;
- if (bhead->code == ENDB)
+ if (bhead->code == ENDB) {
break;
+ }
if (BKE_idcode_is_valid(bhead->code) && BKE_idcode_is_linkable(bhead->code) &&
(id_types_mask == 0 ||
@@ -11251,8 +11362,10 @@ ID *BLO_library_link_named_part(Main *mainl,
* \param idcode: The kind of data-block to link.
* \param name: The name of the data-block (without the 2 char ID prefix).
* \param flag: Options for linking, used for instantiating.
- * \param scene: The scene in which to instantiate objects/collections (if NULL, no instantiation is done).
- * \param v3d: The active View3D (only to define active layers for instantiated objects & collections, can be NULL).
+ * \param scene: The scene in which to instantiate objects/collections
+ * (if NULL, no instantiation is done).
+ * \param v3d: The active 3D viewport.
+ * (only to define active layers for instantiated objects & collections, can be NULL).
* \return the linked ID when found.
*/
ID *BLO_library_link_named_part_ex(
@@ -11293,10 +11406,11 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa
/**
* Initialize the BlendHandle for linking library data.
*
- * \param mainvar: The current main database, e.g. G_MAIN or CTX_data_main(C).
- * \param bh: A blender file handle as returned by \a BLO_blendhandle_from_file or \a BLO_blendhandle_from_memory.
+ * \param mainvar: The current main database, e.g. #G_MAIN or #CTX_data_main(C).
+ * \param bh: A blender file handle as returned by
+ * #BLO_blendhandle_from_file or #BLO_blendhandle_from_memory.
* \param filepath: Used for relative linking, copied to the \a lib->name.
- * \return the library Main, to be passed to \a BLO_library_append_named_part as \a mainl.
+ * \return the library Main, to be passed to #BLO_library_append_named_part as \a mainl.
*/
Main *BLO_library_link_begin(Main *mainvar, BlendHandle **bh, const char *filepath)
{
@@ -11374,7 +11488,8 @@ static void library_link_end(Main *mainl,
Main *main_newid = BKE_main_new();
for (mainvar = ((Main *)(*fd)->mainlist->first)->next; mainvar; mainvar = mainvar->next) {
BLI_assert(mainvar->versionfile != 0);
- /* We need to split out IDs already existing, or they will go again through do_versions - bad, very bad! */
+ /* We need to split out IDs already existing,
+ * or they will go again through do_versions - bad, very bad! */
split_main_newid(mainvar, main_newid);
do_versions_after_linking(main_newid);
@@ -11386,14 +11501,17 @@ static void library_link_end(Main *mainl,
mainvar = (*fd)->mainlist->first;
MEM_freeN((*fd)->mainlist);
+ /* After all data has been read and versioned, uses LIB_TAG_NEW. */
+ ntreeUpdateAllNew(mainvar);
+
BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false);
- lib_verify_nodetree(mainvar, false);
fix_relpaths_library(BKE_main_blendfile_path(mainvar),
mainvar); /* make all relative paths, relative to the open blend file */
/* Give a base to loose objects and collections.
- * Only directly linked objects & collections are instantiated by `BLO_library_link_named_part_ex()` & co,
+ * Only directly linked objects & collections are instantiated by
+ * `BLO_library_link_named_part_ex()` & co,
* here we handle indirect ones and other possible edge-cases. */
if (scene) {
add_collections_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag);
@@ -11423,9 +11541,12 @@ static void library_link_end(Main *mainl,
* \param bh: The blender file handle (WARNING! may be freed by this function!).
* \param flag: Options for linking, used for instantiating.
* \param bmain: The main database in which to instantiate objects/collections
- * \param scene: The scene in which to instantiate objects/collections (if NULL, no instantiation is done).
- * \param view_layer: The scene layer in which to instantiate objects/collections (if NULL, no instantiation is done).
- * \param v3d: The active View3D (only to define local-view for instantiated objects & groups, can be NULL).
+ * \param scene: The scene in which to instantiate objects/collections
+ * (if NULL, no instantiation is done).
+ * \param view_layer: The scene layer in which to instantiate objects/collections
+ * (if NULL, no instantiation is done).
+ * \param v3d: The active 3D viewport
+ * (only to define local-view for instantiated objects & groups, can be NULL).
*/
void BLO_library_link_end(Main *mainl,
BlendHandle **bh,
@@ -11609,8 +11730,9 @@ static FileData *read_library_file_data(FileData *basefd,
fd->reports = basefd->reports;
- if (fd->libmap)
+ if (fd->libmap) {
oldnewmap_free(fd->libmap);
+ }
fd->libmap = oldnewmap_new();
@@ -11662,7 +11784,11 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
/* Does this library have any more linked datablocks we need to read? */
if (has_linked_ids_to_read(mainptr)) {
- // printf("Reading linked datablocks from %s (%s)\n", mainptr->curlib->id.name, mainptr->curlib->name);
+#if 0
+ printf("Reading linked datablocks from %s (%s)\n",
+ mainptr->curlib->id.name,
+ mainptr->curlib->name);
+#endif
/* Open file if it has not been done yet. */
FileData *fd = read_library_file_data(basefd, mainlist, mainl, mainptr);
@@ -11693,21 +11819,25 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
split_main_newid(mainptr, main_newid);
/* File data can be zero with link/append. */
- if (mainptr->curlib->filedata)
+ if (mainptr->curlib->filedata) {
do_versions(mainptr->curlib->filedata, mainptr->curlib, main_newid);
- else
+ }
+ else {
do_versions(basefd, NULL, main_newid);
+ }
add_main_to_main(mainptr, main_newid);
}
/* Lib linking. */
- if (mainptr->curlib->filedata)
+ if (mainptr->curlib->filedata) {
lib_link_all(mainptr->curlib->filedata, mainptr);
+ }
/* Free file data we no longer need. */
- if (mainptr->curlib->filedata)
+ if (mainptr->curlib->filedata) {
blo_filedata_free(mainptr->curlib->filedata);
+ }
mainptr->curlib->filedata = NULL;
}
BKE_main_free(main_newid);
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 55824e17c32..7cd5bb7ac93 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -53,7 +53,7 @@ enum eFileDataFlag {
# pragma GCC poison off_t
#endif
-#if defined(_MSC_VER) || defined(__APPLE__)
+#if defined(_MSC_VER) || defined(__APPLE__) || defined(__HAIKU__)
typedef int64_t off64_t;
#endif
@@ -182,8 +182,12 @@ void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *
void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *bmain);
void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *bmain);
void blo_do_versions_280(struct FileData *fd, struct Library *lib, struct Main *bmain);
+void blo_do_versions_cycles(struct FileData *fd, struct Library *lib, struct Main *bmain);
+void do_versions_after_linking_250(struct Main *bmain);
+void do_versions_after_linking_260(struct Main *bmain);
void do_versions_after_linking_270(struct Main *bmain);
void do_versions_after_linking_280(struct Main *bmain);
+void do_versions_after_linking_cycles(struct Main *bmain);
#endif
diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c
index 0c09aa34a8b..95a4771b313 100644
--- a/source/blender/blenloader/intern/undofile.c
+++ b/source/blender/blenloader/intern/undofile.c
@@ -81,10 +81,12 @@ void BLO_memfile_merge(MemFile *first, MemFile *second)
fc->is_identical = true;
}
}
- if (fc)
+ if (fc) {
fc = fc->next;
- if (sc)
+ }
+ if (sc) {
sc = sc->next;
+ }
}
BLO_memfile_free(first);
@@ -149,8 +151,10 @@ bool BLO_memfile_write_file(struct MemFile *memfile, const char *filename)
MemFileChunk *chunk;
int file, oflags;
- /* note: This is currently used for autosave and 'quit.blend', where _not_ following symlinks is OK,
- * however if this is ever executed explicitly by the user, we may want to allow writing to symlinks.
+ /* note: This is currently used for autosave and 'quit.blend',
+ * where _not_ following symlinks is OK,
+ * however if this is ever executed explicitly by the user,
+ * we may want to allow writing to symlinks.
*/
oflags = O_BINARY | O_WRONLY | O_CREAT | O_TRUNC;
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 723701da113..face4b61d1e 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -92,10 +92,12 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb)
BLI_addtail(lb, ar);
ar->regiontype = RGN_TYPE_HEADER;
- if (sa->headertype == 1)
+ if (sa->headertype == 1) {
ar->alignment = RGN_ALIGN_BOTTOM;
- else
+ }
+ else {
ar->alignment = RGN_ALIGN_TOP;
+ }
/* initialize view2d data for header region, to allow panning */
/* is copy from ui_view2d.c */
@@ -203,8 +205,9 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
case SPACE_SEQ:
ar_main = (ARegion *)lb->first;
for (; ar_main; ar_main = ar_main->next) {
- if (ar_main->regiontype == RGN_TYPE_WINDOW)
+ if (ar_main->regiontype == RGN_TYPE_WINDOW) {
break;
+ }
}
ar = MEM_callocN(sizeof(ARegion), "preview area for sequencer");
BLI_insertlinkbefore(lb, ar_main, ar);
@@ -274,7 +277,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
ar->v2d.keepzoom |= (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_KEEPASPECT);
ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
- //ar->v2d.flag |= V2D_IS_INITIALISED;
+ // ar->v2d.flag |= V2D_IS_INITIALISED;
break;
}
case SPACE_GRAPH: {
@@ -291,7 +294,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
ar->v2d.max[0] = MAXFRAMEF;
ar->v2d.max[1] = FLT_MAX;
- //ar->v2d.flag |= V2D_IS_INITIALISED;
+ // ar->v2d.flag |= V2D_IS_INITIALISED;
break;
}
case SPACE_NLA: {
@@ -310,7 +313,8 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
case SPACE_ACTION: {
SpaceAction *saction = (SpaceAction *)sl;
- /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */
+ /* We totally reinit the view for the Action Editor,
+ * as some old instances had some weird cruft set. */
ar->v2d.tot.xmin = -20.0f;
ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
ar->v2d.tot.xmax = (float)((sa->winx > 120) ? (sa->winx) : 120);
@@ -336,8 +340,9 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
* it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit
* only shows ShapeKey-rooted actions only)
*/
- if (saction->mode == SACTCONT_SHAPEKEY)
+ if (saction->mode == SACTCONT_SHAPEKEY) {
saction->action = NULL;
+ }
break;
}
case SPACE_SEQ: {
@@ -381,7 +386,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
SpaceText *st = (SpaceText *)sl;
st->flags |= ST_FIND_WRAP;
}
- //case SPACE_XXX: // FIXME... add other ones
+ // case SPACE_XXX: // FIXME... add other ones
// memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
// break;
}
@@ -396,29 +401,33 @@ static void do_versions_windowmanager_2_50(bScreen *screen)
/* add regions */
for (sa = screen->areabase.first; sa; sa = sa->next) {
/* we keep headertype variable to convert old files only */
- if (sa->headertype)
+ if (sa->headertype) {
area_add_header_region(sa, &sa->regionbase);
+ }
area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase);
/* space imageselect is deprecated */
for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMASEL)
+ if (sl->spacetype == SPACE_IMASEL) {
sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
+ }
}
/* space sound is deprecated */
for (sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_SOUND)
+ if (sl->spacetype == SPACE_SOUND) {
sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
+ }
}
/* pushed back spaces also need regions! */
if (sa->spacedata.first) {
sl = sa->spacedata.first;
for (sl = sl->next; sl; sl = sl->next) {
- if (sa->headertype)
+ if (sa->headertype) {
area_add_header_region(sa, &sl->regionbase);
+ }
area_add_window_regions(sa, sl, &sl->regionbase);
}
}
@@ -435,8 +444,9 @@ static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name)
BKE_id_new_name_validate(lb, id, name);
/* alphabetic insertion: is in BKE_id_new_name_validate */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Converted GPencil to ID: %s\n", id->name + 2);
+ }
}
static void do_versions_gpencil_2_50(Main *main, bScreen *screen)
@@ -537,8 +547,9 @@ static void do_version_bone_roll_256(Bone *bone)
copy_m3_m4(submat, bone->arm_mat);
mat3_to_vec_roll(submat, NULL, &bone->arm_roll);
- for (child = bone->childbase.first; child; child = child->next)
+ for (child = bone->childbase.first; child; child = child->next) {
do_version_bone_roll_256(child);
+ }
}
/* deprecated, only keep this for readfile.c */
@@ -577,9 +588,10 @@ static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup,
}
/* Create default_value structs for node sockets from the internal bNodeStack value.
- * These structs were used from 2.59.2 on, but are replaced in the subsequent do_versions for custom nodes
- * by generic ID property values. This conversion happened _after_ do_versions originally due to messy type initialization
- * for node sockets. Now created here intermediately for convenience and to keep do_versions consistent.
+ * These structs were used from 2.59.2 on, but are replaced in the subsequent do_versions for
+ * custom nodes by generic ID property values. This conversion happened _after_ do_versions
+ * originally due to messy type initialization for node sockets.
+ * Now created here intermediately for convenience and to keep do_versions consistent.
*
* Node compatibility code is gross ...
*/
@@ -589,8 +601,9 @@ static void do_versions_socket_default_value_259(bNodeSocket *sock)
bNodeSocketValueVector *valvector;
bNodeSocketValueRGBA *valrgba;
- if (sock->default_value)
+ if (sock->default_value) {
return;
+ }
switch (sock->type) {
case SOCK_FLOAT:
@@ -632,8 +645,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
Tex *tx;
ParticleSettings *part;
Object *ob;
- //PTCacheID *pid;
- //ListBase pidlist;
+ // PTCacheID *pid;
+ // ListBase pidlist;
bSound *sound;
Sequence *seq;
@@ -676,15 +689,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
* to have them show in RNA viewer and accessible otherwise.
*/
for (ma = bmain->materials.first; ma; ma = ma->id.next) {
- if (ma->nodetree && ma->nodetree->id.name[0] == '\0')
+ if (ma->nodetree && ma->nodetree->id.name[0] == '\0') {
strcpy(ma->nodetree->id.name, "NTShader Nodetree");
+ }
}
/* and composite trees */
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
enum { R_PANORAMA = (1 << 10) };
- if (sce->nodetree && sce->nodetree->id.name[0] == '\0')
+ if (sce->nodetree && sce->nodetree->id.name[0] == '\0') {
strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
+ }
/* move to cameras */
if (sce->r.mode & R_PANORAMA) {
@@ -706,13 +721,16 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
bNode *node;
if (tx->nodetree) {
- if (tx->nodetree->id.name[0] == '\0')
+ if (tx->nodetree->id.name[0] == '\0') {
strcpy(tx->nodetree->id.name, "NTTexture Nodetree");
+ }
/* which_output 0 is now "not specified" */
- for (node = tx->nodetree->nodes.first; node; node = node->next)
- if (node->type == TEX_NODE_OUTPUT)
+ for (node = tx->nodetree->nodes.first; node; node = node->next) {
+ if (node->type == TEX_NODE_OUTPUT) {
node->custom1++;
+ }
+ }
}
}
@@ -738,12 +756,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* set old pointcaches to have disk cache flag */
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- //BKE_ptcache_ids_from_object(&pidlist, ob);
+ // BKE_ptcache_ids_from_object(&pidlist, ob);
- //for (pid = pidlist.first; pid; pid = pid->next)
+ // for (pid = pidlist.first; pid; pid = pid->next)
// pid->cache->flag |= PTCACHE_DISK_CACHE;
- //BLI_freelistN(&pidlist);
+ // BLI_freelistN(&pidlist);
}
/* type was a mixed flag & enum. move the 2d flag elsewhere */
@@ -762,18 +780,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
Tex *tex;
Scene *sce;
ToolSettings *ts;
- //PTCacheID *pid;
- //ListBase pidlist;
+ // PTCacheID *pid;
+ // ListBase pidlist;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- //BKE_ptcache_ids_from_object(&pidlist, ob);
+ // BKE_ptcache_ids_from_object(&pidlist, ob);
- //for (pid = pidlist.first; pid; pid = pid->next) {
+ // for (pid = pidlist.first; pid; pid = pid->next) {
// if (BLI_listbase_is_empty(pid->ptcaches))
// pid->ptcaches->first = pid->ptcaches->last = pid->cache;
//}
- //BLI_freelistN(&pidlist);
+ // BLI_freelistN(&pidlist);
if (ob->type == OB_MESH) {
Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data);
@@ -793,15 +811,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
int a;
ob->matbits = MEM_calloc_arrayN(ob->totcol, sizeof(char), "ob->matbits");
- for (a = 0; a < ob->totcol; a++)
+ for (a = 0; a < ob->totcol; a++) {
ob->matbits[a] = (ob->colbits & (1 << a)) != 0;
+ }
}
}
/* texture filter */
for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- if (tex->afmax == 0)
+ if (tex->afmax == 0) {
tex->afmax = 8;
+ }
}
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
@@ -814,8 +834,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
* (i.e. will result in blank box when enabled)
*/
ts->autokey_mode = U.autokey_mode;
- if (ts->autokey_mode == 0)
+ if (ts->autokey_mode == 0) {
ts->autokey_mode = 2; /* 'add/replace' but not on */
+ }
ts->uv_selectmode = UV_SELECT_VERTEX;
ts->vgroup_weight = 1.0f;
}
@@ -826,8 +847,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->flag & 8192) // OB_POSEMODE = 8192
+ if (ob->flag & 8192) { // OB_POSEMODE = 8192
ob->mode |= OB_MODE_POSE;
+ }
}
}
@@ -837,24 +859,29 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ParticleSettings *part;
bool do_gravity = false;
- for (sce = bmain->scenes.first; sce; sce = sce->id.next)
- if (sce->unit.scale_length == 0.0f)
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->unit.scale_length == 0.0f) {
sce->unit.scale_length = 1.0f;
+ }
+ }
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
/* fluid-sim stuff */
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(
ob, eModifierType_Fluidsim);
- if (fluidmd)
+ if (fluidmd) {
fluidmd->fss->fmd = fluidmd;
+ }
- /* rotation modes were added, but old objects would now default to being 'quaternion based' */
+ /* rotation modes were added,
+ * but old objects would now default to being 'quaternion based' */
ob->rotmode = ROT_MODE_EUL;
}
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->audio.main == 0.0f)
+ if (sce->audio.main == 0.0f) {
sce->audio.main = 1.0f;
+ }
sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate;
sce->r.ffcodecdata.audio_volume = sce->audio.main;
@@ -874,10 +901,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */
+ /* Assign proper global gravity weights for dynamics
+ * (only z-coordinate is taken into account) */
if (do_gravity) {
- for (part = bmain->particles.first; part; part = part->id.next)
+ for (part = bmain->particles.first; part; part = part->id.next) {
part->effector_weights->global_gravity = part->acc[2] / -9.81f;
+ }
}
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -887,24 +916,29 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (md = ob->modifiers.first; md; md = md->next) {
ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob,
eModifierType_Cloth);
- if (clmd)
+ if (clmd) {
clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2] /
-9.81f;
+ }
}
- if (ob->soft)
+ if (ob->soft) {
ob->soft->effector_weights->global_gravity = ob->soft->grav / 9.81f;
+ }
}
/* Normal wind shape is plane */
if (ob->pd) {
- if (ob->pd->forcefield == PFIELD_WIND)
+ if (ob->pd->forcefield == PFIELD_WIND) {
ob->pd->shape = PFIELD_SHAPE_PLANE;
+ }
- if (ob->pd->flag & PFIELD_PLANAR)
+ if (ob->pd->flag & PFIELD_PLANAR) {
ob->pd->shape = PFIELD_SHAPE_PLANE;
- else if (ob->pd->flag & PFIELD_SURFACE)
+ }
+ else if (ob->pd->flag & PFIELD_SURFACE) {
ob->pd->shape = PFIELD_SHAPE_SURFACE;
+ }
ob->pd->flag |= PFIELD_DO_LOCATION;
}
@@ -914,7 +948,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 6)) {
Object *ob;
- /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */
+ /* New variables for axis-angle rotations and/or quaternion rotations were added,
+ * and need proper initialization */
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
/* new variables for all objects */
ob->quat[0] = 1.0f;
@@ -949,8 +984,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
data = key->refkey->data;
tot = MIN2(me->totvert, key->refkey->totelem);
- for (a = 0; a < tot; a++, data += 3)
+ for (a = 0; a < tot; a++, data += 3) {
copy_v3_v3(me->mvert[a].co, data);
+ }
}
}
@@ -959,8 +995,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
data = key->refkey->data;
tot = MIN2(lt->pntsu * lt->pntsv * lt->pntsw, key->refkey->totelem);
- for (a = 0; a < tot; a++, data += 3)
+ for (a = 0; a < tot; a++, data += 3) {
copy_v3_v3(lt->def[a].vec, data);
+ }
}
}
@@ -1002,8 +1039,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
{
Scene *sce = bmain->scenes.first;
while (sce) {
- if (sce->r.frame_step == 0)
+ if (sce->r.frame_step == 0) {
sce->r.frame_step = 1;
+ }
sce = sce->id.next;
}
@@ -1028,8 +1066,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
Object *ob = bmain->objects.first;
while (ob) {
/* shaded mode disabled for now */
- if (ob->dt == OB_MATERIAL)
+ if (ob->dt == OB_MATERIAL) {
ob->dt = OB_TEXTURE;
+ }
ob = ob->id.next;
}
}
@@ -1044,8 +1083,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- if (v3d->drawtype == OB_MATERIAL)
+ if (v3d->drawtype == OB_MATERIAL) {
v3d->drawtype = OB_SOLID;
+ }
}
}
}
@@ -1066,8 +1106,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* don't know what scene is active, so we'll convert if any scene has it enabled... */
while (sce) {
- if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT) {
convert = 1;
+ }
sce = sce->id.next;
}
@@ -1097,13 +1138,16 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
Mesh *me;
Object *ob;
- for (sce = bmain->scenes.first; sce; sce = sce->id.next)
- if (!sce->toolsettings->particle.selectmode)
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (!sce->toolsettings->particle.selectmode) {
sce->toolsettings->particle.selectmode = SCE_SELECT_PATH;
+ }
+ }
if (bmain->versionfile == 250 && bmain->subversionfile > 1) {
- for (me = bmain->meshes.first; me; me = me->id.next)
+ for (me = bmain->meshes.first; me; me = me->id.next) {
multires_load_old_250(me);
+ }
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(
@@ -1128,8 +1172,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
- if (clmd->sim_parms->velocity_smooth < 0.01f)
+ if (clmd->sim_parms->velocity_smooth < 0.01f) {
clmd->sim_parms->velocity_smooth = 0.f;
+ }
}
}
}
@@ -1158,8 +1203,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
for (ar = regionbase->first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_PREVIEW)
+ if (ar->regiontype == RGN_TYPE_PREVIEW) {
break;
+ }
}
if (ar && (ar->regiontype == RGN_TYPE_PREVIEW)) {
@@ -1196,15 +1242,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
regionbase = &sl->regionbase;
}
- if (sseq->view == 0)
+ if (sseq->view == 0) {
sseq->view = SEQ_VIEW_SEQUENCE;
- if (sseq->mainb == 0)
+ }
+ if (sseq->mainb == 0) {
sseq->mainb = SEQ_DRAW_IMG_IMBUF;
+ }
ar_main = (ARegion *)regionbase->first;
for (; ar_main; ar_main = ar_main->next) {
- if (ar_main->regiontype == RGN_TYPE_WINDOW)
+ if (ar_main->regiontype == RGN_TYPE_WINDOW) {
break;
+ }
}
ar = MEM_callocN(sizeof(ARegion), "preview area for sequencer");
BLI_insertlinkbefore(regionbase, ar_main, ar);
@@ -1242,26 +1291,32 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
avs->path_ef = 250;
/* flags */
- if (arm->pathflag & ARM_PATH_FNUMS)
+ if (arm->pathflag & ARM_PATH_FNUMS) {
avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS;
- if (arm->pathflag & ARM_PATH_KFRAS)
+ }
+ if (arm->pathflag & ARM_PATH_KFRAS) {
avs->path_viewflag |= MOTIONPATH_VIEW_KFRAS;
- if (arm->pathflag & ARM_PATH_KFNOS)
+ }
+ if (arm->pathflag & ARM_PATH_KFNOS) {
avs->path_viewflag |= MOTIONPATH_VIEW_KFNOS;
+ }
/* bake flags */
- if (arm->pathflag & ARM_PATH_HEADS)
+ if (arm->pathflag & ARM_PATH_HEADS) {
avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS;
+ }
/* type */
- if (arm->pathflag & ARM_PATH_ACFRA)
+ if (arm->pathflag & ARM_PATH_ACFRA) {
avs->path_type = MOTIONPATH_TYPE_ACFRA;
+ }
/* stepsize */
avs->path_step = 1;
}
- else
+ else {
animviz_settings_init(&ob->pose->avs);
+ }
}
}
@@ -1310,10 +1365,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ListBase *regionbase;
ARegion *ar;
- if (sl == sa->spacedata.first)
+ if (sl == sa->spacedata.first) {
regionbase = &sa->regionbase;
- else
+ }
+ else {
regionbase = &sl->regionbase;
+ }
if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) {
for (ar = (ARegion *)regionbase->first; ar; ar = ar->next) {
@@ -1342,8 +1399,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
sce->r.border.ymax = 1.0f;
}
- if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0)
+ if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0) {
sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
+ }
SEQ_BEGIN (sce->ed, seq) {
seq->volume = 1.0f;
@@ -1356,8 +1414,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ParticleEditSettings *pset = &sce->toolsettings->particle;
int a;
- for (a = 0; a < ARRAY_SIZE(pset->brush); a++)
+ for (a = 0; a < ARRAY_SIZE(pset->brush); a++) {
pset->brush[a].strength /= 100.0f;
+ }
}
/* sequencer changes */
@@ -1382,8 +1441,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ar_preview = (ARegion *)regionbase->first;
for (; ar_preview; ar_preview = ar_preview->next) {
- if (ar_preview->regiontype == RGN_TYPE_PREVIEW)
+ if (ar_preview->regiontype == RGN_TYPE_PREVIEW) {
break;
+ }
}
if (ar_preview && (ar_preview->regiontype == RGN_TYPE_PREVIEW)) {
sequencer_init_preview_region(ar_preview);
@@ -1423,8 +1483,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
bNodeTree *ntree;
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->curve)
+ if (brush->curve) {
brush->curve->preset = CURVE_PRESET_SMOOTH;
+ }
}
/* properly initialize active flag for fluidsim modifiers */
@@ -1476,8 +1537,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 2)) {
Object *ob;
- for (ob = bmain->objects.first; ob; ob = ob->id.next)
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
blo_do_version_old_trackto_to_constraints(ob);
+ }
}
if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
@@ -1518,22 +1580,28 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ListBase *regionbase;
ARegion *ar;
- if (sl == sa->spacedata.first)
+ if (sl == sa->spacedata.first) {
regionbase = &sa->regionbase;
- else
+ }
+ else {
regionbase = &sl->regionbase;
+ }
- if (snode->v2d.minzoom > 0.09f)
+ if (snode->v2d.minzoom > 0.09f) {
snode->v2d.minzoom = 0.09f;
- if (snode->v2d.maxzoom < 2.31f)
+ }
+ if (snode->v2d.maxzoom < 2.31f) {
snode->v2d.maxzoom = 2.31f;
+ }
for (ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.minzoom > 0.09f)
+ if (ar->v2d.minzoom > 0.09f) {
ar->v2d.minzoom = 0.09f;
- if (ar->v2d.maxzoom < 2.31f)
+ }
+ if (ar->v2d.maxzoom < 2.31f) {
ar->v2d.maxzoom = 2.31f;
+ }
}
}
}
@@ -1593,8 +1661,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (tex = bmain->textures.first; tex; tex = tex->id.next) {
/* if youre picky, this isn't correct until we do a version bump
* since you could set saturation to be 0.0*/
- if (tex->saturation == 0.0f)
+ if (tex->saturation == 0.0f) {
tex->saturation = 1.0f;
+ }
}
{
@@ -1622,44 +1691,54 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* Sanity Check */
/* infinite number of dabs */
- if (brush->spacing == 0)
+ if (brush->spacing == 0) {
brush->spacing = 10;
+ }
/* will have no effect */
- if (brush->alpha == 0)
+ if (brush->alpha == 0) {
brush->alpha = 0.5f;
+ }
/* bad radius */
- if (brush->unprojected_radius == 0)
+ if (brush->unprojected_radius == 0) {
brush->unprojected_radius = 0.125f;
+ }
/* unusable size */
- if (brush->size == 0)
+ if (brush->size == 0) {
brush->size = 35;
+ }
/* can't see overlay */
- if (brush->texture_overlay_alpha == 0)
+ if (brush->texture_overlay_alpha == 0) {
brush->texture_overlay_alpha = 33;
+ }
/* same as draw brush */
- if (brush->crease_pinch_factor == 0)
+ if (brush->crease_pinch_factor == 0) {
brush->crease_pinch_factor = 0.5f;
+ }
/* will sculpt no vertexes */
- if (brush->plane_trim == 0)
+ if (brush->plane_trim == 0) {
brush->plane_trim = 0.5f;
+ }
/* same as smooth stroke off */
- if (brush->smooth_stroke_radius == 0)
+ if (brush->smooth_stroke_radius == 0) {
brush->smooth_stroke_radius = 75;
+ }
/* will keep cursor in one spot */
- if (brush->smooth_stroke_radius == 1)
+ if (brush->smooth_stroke_radius == 1) {
brush->smooth_stroke_factor = 0.9f;
+ }
/* same as dots */
- if (brush->rate == 0)
+ if (brush->rate == 0) {
brush->rate = 0.1f;
+ }
/* New Settings */
if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
@@ -1689,14 +1768,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile < 253) {
Scene *sce;
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->toolsettings->sculpt_paint_unified_alpha == 0)
+ if (sce->toolsettings->sculpt_paint_unified_alpha == 0) {
sce->toolsettings->sculpt_paint_unified_alpha = 0.5f;
+ }
- if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0)
+ if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0) {
sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f;
+ }
- if (sce->toolsettings->sculpt_paint_unified_size == 0)
+ if (sce->toolsettings->sculpt_paint_unified_size == 0) {
sce->toolsettings->sculpt_paint_unified_size = 35;
+ }
}
}
@@ -1714,8 +1796,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
smd->domain->vorticity = 2.0f;
smd->domain->time_scale = 1.0f;
- if (!(smd->domain->flags & (1 << 4)))
+ if (!(smd->domain->flags & (1 << 4))) {
continue;
+ }
/* delete old MOD_SMOKE_INITVELOCITY flag */
smd->domain->flags &= ~(1 << 4);
@@ -1751,13 +1834,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
bScreen *sc;
for (br = bmain->brushes.first; br; br = br->id.next) {
- if (br->ob_mode == 0)
+ if (br->ob_mode == 0) {
br->ob_mode = OB_MODE_ALL_PAINT;
+ }
}
for (part = bmain->particles.first; part; part = part->id.next) {
- if (part->boids)
+ if (part->boids) {
part->boids->pitch = 1.0f;
+ }
part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */
part->kink_amp_clump = 1.f; /* keep old files looking similar */
@@ -1820,8 +1905,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
- if (sima->sample_line_hist.height == 0)
+ if (sima->sample_line_hist.height == 0) {
sima->sample_line_hist.height = 100;
+ }
}
}
sa = sa->next;
@@ -1836,8 +1922,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
KeyBlock *kb;
for (kb = key->block.first; kb; kb = kb->next) {
- if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQF(kb->slidermax, 0.0f))
+ if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQF(kb->slidermax, 0.0f)) {
kb->slidermax = kb->slidermin + 1.0f;
+ }
}
}
}
@@ -1848,9 +1935,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
Bone *bone;
Object *ob;
- for (arm = bmain->armatures.first; arm; arm = arm->id.next)
- for (bone = arm->bonebase.first; bone; bone = bone->next)
+ for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
+ for (bone = arm->bonebase.first; bone; bone = bone->next) {
do_version_bone_roll_256(bone);
+ }
+ }
/* fix for objects which have zero dquat's
* since this is multiplied with the quat rather than added */
@@ -1878,12 +1967,16 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* first make sure the own_index for new sockets is valid */
for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next)
- if (sock->own_index >= ntree->cur_index)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (sock->own_index >= ntree->cur_index) {
ntree->cur_index = sock->own_index + 1;
- for (sock = node->outputs.first; sock; sock = sock->next)
- if (sock->own_index >= ntree->cur_index)
+ }
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ if (sock->own_index >= ntree->cur_index) {
ntree->cur_index = sock->own_index + 1;
+ }
+ }
}
/* add ntree->inputs/ntree->outputs sockets for all unlinked sockets in the group tree. */
@@ -1898,7 +1991,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
copy_v4_v4(gsock->ns.vec, sock->ns.vec);
/* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer,
- * have to create these directly here. These links are updated again in subsequent do_version!
+ * have to create these directly here.
+ * These links are updated again in subsequent do_version!
*/
link = MEM_callocN(sizeof(bNodeLink), "link");
BLI_addtail(&ntree->links, link);
@@ -1920,7 +2014,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
copy_v4_v4(gsock->ns.vec, sock->ns.vec);
/* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer,
- * have to create these directly here. These links are updated again in subsequent do_version!
+ * have to create these directly here.
+ * These links are updated again in subsequent do_version!
*/
link = MEM_callocN(sizeof(bNodeLink), "link");
BLI_addtail(&ntree->links, link);
@@ -1935,12 +2030,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
- /* XXX The external group node sockets needs to adjust their own_index to point at
- * associated ntree inputs/outputs internal sockets. However, this can only happen
- * after lib-linking (needs access to internal node group tree)!
- * Setting a temporary flag here, actual do_versions happens in lib_verify_nodetree.
- */
- ntree->flag |= NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2;
+ /* Externl group node socket need to adjust their own_index to point at
+ * associated ntree inputs/outputs internal sockets. This happens in
+ * do_versions_after_linking_250, after lib linking. */
}
}
@@ -1954,14 +2046,16 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
for (sc = bmain->screens.first; sc; sc = sc->id.next) {
if (sc->redraws_flag == 0) {
/* just initialize to default? */
- /* XXX: we could also have iterated through areas, and taken them from the first timeline available... */
+ /* XXX: we could also have iterated through areas,
+ * and taken them from the first timeline available... */
sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
}
}
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->height == 0)
+ if (brush->height == 0) {
brush->height = 0.4f;
+ }
}
/* replace 'rim material' option for in offset*/
@@ -1980,36 +2074,42 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* particle draw color from material */
for (part = bmain->particles.first; part; part = part->id.next) {
- if (part->draw & PART_DRAW_MAT_COL)
+ if (part->draw & PART_DRAW_MAT_COL) {
part->draw_col = PART_DRAW_COL_MAT;
+ }
}
}
if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 6)) {
Mesh *me;
- for (me = bmain->meshes.first; me; me = me->id.next)
+ for (me = bmain->meshes.first; me; me = me->id.next) {
BKE_mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL);
+ }
}
if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
/* update blur area sizes from 0..1 range to 0..100 percentage */
Scene *scene;
bNode *node;
- for (scene = bmain->scenes.first; scene; scene = scene->id.next)
- if (scene->nodetree)
- for (node = scene->nodetree->nodes.first; node; node = node->next)
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ if (scene->nodetree) {
+ for (node = scene->nodetree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_BLUR) {
NodeBlurData *nbd = node->storage;
nbd->percentx *= 100.0f;
nbd->percenty *= 100.0f;
}
+ }
+ }
+ }
}
if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
- /* screen view2d settings were not properly initialized [#27164]
- * v2d->scroll caused the bug but best reset other values too which are in old blend files only.
- * need to make less ugly - possibly an iterator? */
+ /* screen view2d settings were not properly initialized T27164.
+ * v2d->scroll caused the bug but best reset other values too
+ * which are in old blend files only.
+ * Need to make less ugly - possibly an iterator? */
bScreen *screen;
for (screen = bmain->screens.first; screen; screen = screen->id.next) {
@@ -2079,8 +2179,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ARegion *ar;
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.min[1] == 4.0f)
+ if (ar->v2d.min[1] == 4.0f) {
ar->v2d.min[1] = 0.5f;
+ }
}
}
}
@@ -2089,8 +2190,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
ARegion *ar;
for (ar = sl->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (ar->v2d.min[1] == 4.0f)
+ if (ar->v2d.min[1] == 4.0f) {
ar->v2d.min[1] = 0.5f;
+ }
}
}
}
@@ -2116,17 +2218,21 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
uint i = 0;
/* only need to touch curves that had this flag set */
- if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0)
+ if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0) {
continue;
- if ((fcu->totvert == 0) || (fcu->bezt == NULL))
+ }
+ if ((fcu->totvert == 0) || (fcu->bezt == NULL)) {
continue;
+ }
/* only change auto-handles to auto-clamped */
for (bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
- if (bezt->h1 == HD_AUTO)
+ if (bezt->h1 == HD_AUTO) {
bezt->h1 = HD_AUTO_ANIM;
- if (bezt->h2 == HD_AUTO)
+ }
+ if (bezt->h2 == HD_AUTO) {
bezt->h2 = HD_AUTO_ANIM;
+ }
}
fcu->flag &= ~FCURVE_AUTO_HANDLES;
@@ -2143,16 +2249,20 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
bNodeSocket *sock;
for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
do_versions_socket_default_value_259(sock);
- for (sock = node->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
do_versions_socket_default_value_259(sock);
+ }
}
- for (sock = ntree->inputs.first; sock; sock = sock->next)
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
do_versions_socket_default_value_259(sock);
- for (sock = ntree->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
do_versions_socket_default_value_259(sock);
+ }
ntree->update |= NTREE_UPDATE;
}
@@ -2166,8 +2276,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
*/
bNodeTree *ntree;
/* all node trees in bmain->nodetree are considered groups */
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
ntree->nodetype = NODE_GROUP;
+ }
}
}
@@ -2182,3 +2293,59 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
}
}
}
+
+/* updates group node socket identifier so that
+ * external links to/from the group node are preserved.
+ */
+static void lib_node_do_versions_group_indices(bNode *gnode)
+{
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
+ bNodeSocket *sock;
+ bNodeLink *link;
+
+ for (sock = gnode->outputs.first; sock; sock = sock->next) {
+ int old_index = sock->to_index;
+
+ for (link = ngroup->links.first; link; link = link->next) {
+ if (link->tonode == NULL && link->fromsock->own_index == old_index) {
+ strcpy(sock->identifier, link->fromsock->identifier);
+ /* deprecated */
+ sock->own_index = link->fromsock->own_index;
+ sock->to_index = 0;
+ sock->groupsock = NULL;
+ }
+ }
+ }
+ for (sock = gnode->inputs.first; sock; sock = sock->next) {
+ int old_index = sock->to_index;
+
+ for (link = ngroup->links.first; link; link = link->next) {
+ if (link->fromnode == NULL && link->tosock->own_index == old_index) {
+ strcpy(sock->identifier, link->tosock->identifier);
+ /* deprecated */
+ sock->own_index = link->tosock->own_index;
+ sock->to_index = 0;
+ sock->groupsock = NULL;
+ }
+ }
+ }
+}
+
+void do_versions_after_linking_250(Main *bmain)
+{
+ if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 2)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ /* updates external links for all group nodes in a tree */
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == NODE_GROUP) {
+ bNodeTree *ngroup = (bNodeTree *)node->id;
+ if (ngroup) {
+ lib_node_do_versions_group_indices(node);
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 42d0edbcc0c..77ef27182f2 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -67,6 +67,7 @@
#include "IMB_imbuf.h" // for proxy / timecode versioning stuff
+#include "NOD_common.h"
#include "NOD_texture.h"
#include "BLO_readfile.h"
@@ -106,7 +107,8 @@ static void do_versions_nodetree_convert_angle(bNodeTree *ntree)
else if (node->type == CMP_NODE_DEFOCUS) {
/* Convert degrees to radians. */
NodeDefocus *nqd = node->storage;
- /* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */
+ /* XXX DNA char to float conversion seems to map the char value
+ * into the [0.0f, 1.0f] range. */
nqd->rotation = DEG2RADF(nqd->rotation * 255.0f);
}
else if (node->type == CMP_NODE_CHROMA_MATTE) {
@@ -118,7 +120,8 @@ static void do_versions_nodetree_convert_angle(bNodeTree *ntree)
else if (node->type == CMP_NODE_GLARE) {
/* Convert degrees to radians. */
NodeGlare *ndg = node->storage;
- /* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */
+ /* XXX DNA char to float conversion seems to map the char value
+ * into the [0.0f, 1.0f] range. */
ndg->angle_ofs = DEG2RADF(ndg->angle_ofs * 255.0f);
}
/* XXX TexMapping struct is used by other nodes too (at least node_composite_mapValue),
@@ -203,15 +206,19 @@ static void do_versions_nodetree_socket_use_flags_2_62(bNodeTree *ntree)
bNodeLink *link;
for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_IN_USE;
- for (sock = node->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_IN_USE;
+ }
}
- for (sock = ntree->inputs.first; sock; sock = sock->next)
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_IN_USE;
- for (sock = ntree->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_IN_USE;
+ }
for (link = ntree->links.first; link; link = link->next) {
link->fromsock->flag |= SOCK_IN_USE;
@@ -233,7 +240,8 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo
bNodeSocket *sock;
char filename[FILE_MAXFILE];
- /* ugly, need to remove the old inputs list to avoid bad pointer checks when adding new sockets.
+ /* ugly, need to remove the old inputs list to avoid bad pointer
+ * checks when adding new sockets.
* sock->storage is expected to contain path info in ntreeCompositOutputFileAddSocket.
*/
BLI_listbase_clear(&node->inputs);
@@ -293,8 +301,9 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo
nodeRemoveSocket(ntree, node, old_image);
nodeRemoveSocket(ntree, node, old_z);
- if (old_data)
+ if (old_data) {
MEM_freeN(old_data);
+ }
}
else if (node->type == CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED) {
NodeImageMultiFile *nimf = node->storage;
@@ -304,8 +313,9 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo
node->type = CMP_NODE_OUTPUT_FILE;
/* initialize the node-wide image format from render data, if available */
- if (sce)
+ if (sce) {
nimf->format = sce->r.im_format;
+ }
/* transfer render format toggle to node format toggle */
for (sock = node->inputs.first; sock; sock = sock->next) {
@@ -457,7 +467,8 @@ static const char *node_get_static_idname(int type, int treetype)
case ID: \
return #Category #StructName;
- /* XXX hack, group types share a single static integer identifier, but are registered as separate types */
+ /* XXX hack, group types share a single static integer identifier,
+ * but are registered as separate types */
if (type == NODE_GROUP) {
switch (treetype) {
case NTREE_COMPOSIT:
@@ -539,16 +550,20 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro
node->flag |= NODE_INIT;
/* sockets idname */
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
- for (sock = node->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
+ }
}
/* tree sockets idname */
- for (sock = ntree->inputs.first; sock; sock = sock->next)
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
- for (sock = ntree->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
+ }
}
/* initialize socket in_out values */
@@ -557,15 +572,19 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro
bNodeSocket *sock;
for (node = ntree->nodes.first; node; node = node->next) {
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
sock->in_out = SOCK_IN;
- for (sock = node->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = node->outputs.first; sock; sock = sock->next) {
sock->in_out = SOCK_OUT;
+ }
}
- for (sock = ntree->inputs.first; sock; sock = sock->next)
+ for (sock = ntree->inputs.first; sock; sock = sock->next) {
sock->in_out = SOCK_IN;
- for (sock = ntree->outputs.first; sock; sock = sock->next)
+ }
+ for (sock = ntree->outputs.first; sock; sock = sock->next) {
sock->in_out = SOCK_OUT;
+ }
}
/* initialize socket identifier strings */
@@ -625,15 +644,18 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
/* there are files with invalid audio_channels value, the real cause
* is unknown, but we fix it here anyway to avoid crashes */
- if (sce->r.ffcodecdata.audio_channels == 0)
+ if (sce->r.ffcodecdata.audio_channels == 0) {
sce->r.ffcodecdata.audio_channels = 2;
+ }
- if (sce->nodetree)
+ if (sce->nodetree) {
do_versions_nodetree_image_default_alpha_output(sce->nodetree);
+ }
}
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
do_versions_nodetree_image_default_alpha_output(ntree);
+ }
}
{
@@ -644,8 +666,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
part->draw |= PART_DRAW_ROTATE_OB;
- if (part->rotmode == 0)
+ if (part->rotmode == 0) {
part->rotmode = PART_ROT_VEL;
+ }
}
}
}
@@ -661,11 +684,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
Camera *cam;
for (cam = bmain->cameras.first; cam; cam = cam->id.next) {
- if (cam->sensor_x < 0.01f)
+ if (cam->sensor_x < 0.01f) {
cam->sensor_x = DEFAULT_SENSOR_WIDTH;
+ }
- if (cam->sensor_y < 0.01f)
+ if (cam->sensor_y < 0.01f) {
cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
+ }
}
}
}
@@ -697,17 +722,20 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
bNodeTree *ntree;
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
+ if (sce->nodetree) {
do_versions_nodetree_convert_angle(sce->nodetree);
+ }
}
for (mat = bmain->materials.first; mat; mat = mat->id.next) {
- if (mat->nodetree)
+ if (mat->nodetree) {
do_versions_nodetree_convert_angle(mat->nodetree);
+ }
}
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
do_versions_nodetree_convert_angle(ntree);
+ }
}
{
@@ -727,13 +755,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
v3d->flag2 |= V3D_SHOW_RECONSTRUCTION;
}
- if (v3d->bundle_drawtype == 0)
+ if (v3d->bundle_drawtype == 0) {
v3d->bundle_drawtype = OB_PLAINAXES;
+ }
}
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
- if (sclip->scopes.track_preview_height == 0)
+ if (sclip->scopes.track_preview_height == 0) {
sclip->scopes.track_preview_height = 120;
+ }
}
}
}
@@ -750,19 +780,23 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN | IMB_TC_FREE_RUN |
IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN;
- if (clip->proxy.build_size_flag == 0)
+ if (clip->proxy.build_size_flag == 0) {
clip->proxy.build_size_flag = IMB_PROXY_25;
+ }
- if (clip->proxy.quality == 0)
+ if (clip->proxy.quality == 0) {
clip->proxy.quality = 90;
+ }
- if (clip->tracking.camera.pixel_aspect < 0.01f)
+ if (clip->tracking.camera.pixel_aspect < 0.01f) {
clip->tracking.camera.pixel_aspect = 1.0f;
+ }
track = clip->tracking.tracks.first;
while (track) {
- if (track->minimum_correlation == 0.0f)
+ if (track->minimum_correlation == 0.0f) {
track->minimum_correlation = 0.75f;
+ }
track = track->next;
}
@@ -797,7 +831,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (i = 0; i < 3; i++) {
if ((ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */
(ob->scale[i] == 0.0f)) /* cant scale the dsize to give a non zero result,
- * so fallback to 1.0f */
+ * so fallback to 1.0f */
{
ob->dscale[i] = 1.0f;
}
@@ -824,8 +858,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
Brush *brush;
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
- if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
+ if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) {
brush->alpha = 1.0f;
+ }
}
}
@@ -839,28 +874,33 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
bNodeTree *ntree;
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
+ if (sce->nodetree) {
do_versions_nodetree_socket_use_flags_2_62(sce->nodetree);
+ }
}
for (mat = bmain->materials.first; mat; mat = mat->id.next) {
- if (mat->nodetree)
+ if (mat->nodetree) {
do_versions_nodetree_socket_use_flags_2_62(mat->nodetree);
+ }
}
for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- if (tex->nodetree)
+ if (tex->nodetree) {
do_versions_nodetree_socket_use_flags_2_62(tex->nodetree);
+ }
}
for (Light *la = bmain->lights.first; la; la = la->id.next) {
- if (la->nodetree)
+ if (la->nodetree) {
do_versions_nodetree_socket_use_flags_2_62(la->nodetree);
+ }
}
for (world = bmain->worlds.first; world; world = world->id.next) {
- if (world->nodetree)
+ if (world->nodetree) {
do_versions_nodetree_socket_use_flags_2_62(world->nodetree);
+ }
}
for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
@@ -877,15 +917,18 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
clip->proxy.build_tc_flag |= IMB_TC_RECORD_RUN_NO_GAPS;
- if (!tracking->settings.object_distance)
+ if (!tracking->settings.object_distance) {
tracking->settings.object_distance = 1.0f;
+ }
- if (BLI_listbase_is_empty(&tracking->objects))
+ if (BLI_listbase_is_empty(&tracking->objects)) {
BKE_tracking_object_add(tracking, "Camera");
+ }
while (tracking_object) {
- if (!tracking_object->scale)
+ if (!tracking_object->scale) {
tracking_object->scale = 1.0f;
+ }
tracking_object = tracking_object->next;
}
@@ -897,8 +940,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
- if (data->invmat[3][3] == 0.0f)
+ if (data->invmat[3][3] == 0.0f) {
unit_m4(data->invmat);
+ }
}
}
}
@@ -934,8 +978,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
tl->len += added;
/* reset cursor position if line was changed */
- if (added && tl == text->curl)
+ if (added && tl == text->curl) {
text->curc = 0;
+ }
}
}
}
@@ -971,8 +1016,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
- if (clmd->sim_parms)
+ if (clmd->sim_parms) {
clmd->sim_parms->vel_damping = 1.0f;
+ }
}
}
}
@@ -988,8 +1034,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Fluidsim) {
FluidsimModifierData *fmd = (FluidsimModifierData *)md;
- if (fmd->fss->animRate == 0.0f)
+ if (fmd->fss->animRate == 0.0f) {
fmd->fss->animRate = 1.0f;
+ }
}
}
}
@@ -1001,13 +1048,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
bNodeTree *ntree;
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
+ if (sce->nodetree) {
do_versions_nodetree_multi_file_output_format_2_62_1(sce, sce->nodetree);
+ }
}
/* XXX can't associate with scene for group nodes, image format will stay uninitialized */
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree);
+ }
}
/* only swap for pre-release bmesh merge which had MLoopCol red/blue swap */
@@ -1026,8 +1075,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
KeyingSet *ks;
for (ks = scene->keyingsets.first; ks; ks = ks->next) {
- if (!ks->idname[0])
+ if (!ks->idname[0]) {
BLI_strncpy(ks->idname, ks->name, sizeof(ks->idname));
+ }
}
}
}
@@ -1081,11 +1131,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
Scene *sce;
bNodeTree *ntree;
- for (sce = bmain->scenes.first; sce; sce = sce->id.next)
- if (sce->nodetree)
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->nodetree) {
do_versions_nodetree_multi_file_output_path_2_63_1(sce->nodetree);
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ }
+ }
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
do_versions_nodetree_multi_file_output_path_2_63_1(ntree);
+ }
}
if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 3)) {
@@ -1190,28 +1243,39 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
World *world;
bNodeTree *ntree;
- for (sce = bmain->scenes.first; sce; sce = sce->id.next)
- if (sce->nodetree)
+ for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
+ if (sce->nodetree) {
do_versions_nodetree_frame_2_64_6(sce->nodetree);
+ }
+ }
- for (mat = bmain->materials.first; mat; mat = mat->id.next)
- if (mat->nodetree)
+ for (mat = bmain->materials.first; mat; mat = mat->id.next) {
+ if (mat->nodetree) {
do_versions_nodetree_frame_2_64_6(mat->nodetree);
+ }
+ }
- for (tex = bmain->textures.first; tex; tex = tex->id.next)
- if (tex->nodetree)
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ if (tex->nodetree) {
do_versions_nodetree_frame_2_64_6(tex->nodetree);
+ }
+ }
- for (Light *la = bmain->lights.first; la; la = la->id.next)
- if (la->nodetree)
+ for (Light *la = bmain->lights.first; la; la = la->id.next) {
+ if (la->nodetree) {
do_versions_nodetree_frame_2_64_6(la->nodetree);
+ }
+ }
- for (world = bmain->worlds.first; world; world = world->id.next)
- if (world->nodetree)
+ for (world = bmain->worlds.first; world; world = world->id.next) {
+ if (world->nodetree) {
do_versions_nodetree_frame_2_64_6(world->nodetree);
+ }
+ }
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
do_versions_nodetree_frame_2_64_6(ntree);
+ }
}
if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) {
@@ -1362,10 +1426,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
/* keep compatibility for dupliobject particle size */
- for (part = bmain->particles.first; part; part = part->id.next)
- if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR))
- if ((part->draw & PART_DRAW_ROTATE_OB) == 0)
+ for (part = bmain->particles.first; part; part = part->id.next) {
+ if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
+ if ((part->draw & PART_DRAW_ROTATE_OB) == 0) {
part->draw |= PART_DRAW_NO_SCALE_OB;
+ }
+ }
+ }
}
if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 17)) {
@@ -1450,13 +1517,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
ima->flag |= IMA_VIEW_AS_RENDER;
}
else if (colormanagement_disabled) {
- /* if colormanagement not used, set image's color space to raw, so no sRGB->linear conversion
- * would happen on display and render
- * there's no clear way to check whether color management is enabled or not in render engine
- * so set all images to raw if there's at least one scene with color management disabled
- * this would still behave incorrect in cases when color management was used for only some
- * of scenes, but such a setup is crazy anyway and think it's fair enough to break compatibility
- * in that cases
+ /* if color-management not used, set image's color space to raw, so no sRGB->linear
+ * conversion would happen on display and render there's no clear way to check whether
+ * color management is enabled or not in render engine so set all images to raw if there's
+ * at least one scene with color management disabled this would still behave incorrect in
+ * cases when color management was used for only some of scenes, but such a setup is
+ * crazy anyway and think it's fair enough to break compatibility in that cases.
*/
BLI_strncpy(ima->colorspace_settings.name, "Raw", sizeof(ima->colorspace_settings.name));
@@ -1501,9 +1567,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
bNode *node;
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->type == SH_NODE_TEX_COORD)
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == SH_NODE_TEX_COORD) {
node->flag |= NODE_OPTIONS;
+ }
+ }
}
}
FOREACH_NODETREE_END;
@@ -1721,8 +1789,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
SEQ_END;
- if (scene->r.bake_samples == 0)
+ if (scene->r.bake_samples == 0) {
scene->r.bake_samples = 256;
+ }
}
for (Image *image = bmain->images.first; image; image = image->id.next) {
@@ -1738,8 +1807,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (tex->type == TEX_IMAGE && (tex->imaflag & TEX_USEALPHA) == 0) {
Image *image = blo_do_versions_newlibadr(fd, tex->id.lib, tex->ima);
- if (image && (image->flag & IMA_DO_PREMUL) == 0)
+ if (image && (image->flag & IMA_DO_PREMUL) == 0) {
image->flag |= IMA_IGNORE_ALPHA;
+ }
}
}
@@ -1751,8 +1821,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
Image *image = blo_do_versions_newlibadr(fd, ntree->id.lib, node->id);
if (image) {
- if ((image->flag & IMA_DO_PREMUL) == 0 && image->alpha_mode == IMA_ALPHA_STRAIGHT)
+ if ((image->flag & IMA_DO_PREMUL) == 0 && image->alpha_mode == IMA_ALPHA_STRAIGHT) {
node->custom1 |= CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT;
+ }
}
}
}
@@ -1765,9 +1836,11 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
* for compatibility all textures assumed it to be enabled */
Tex *tex;
- for (tex = bmain->textures.first; tex; tex = tex->id.next)
- if (tex->type == TEX_IMAGE)
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ if (tex->type == TEX_IMAGE) {
tex->imaflag |= TEX_USEALPHA;
+ }
+ }
}
if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 7)) {
@@ -1877,26 +1950,6 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- /* Set flag for delayed do_versions in lib_verify_nodetree. It needs valid typeinfo pointers ... */
- {
- FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
- /* XXX This should be kept without version check for now!
- * As long as USE_NODE_COMPAT_CUSTOMNODES is active, files will write links
- * to tree interface sockets for forward compatibility. These links need to be removed again
- * on file load in new versions.
- * Once forward compatibility is not required any longer, make a subversion bump
- * and only execute this for older versions.
- */
- ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP;
-
- /* Only add interface nodes once.
- * In old Blender versions they will be removed automatically due to undefined type */
- if (MAIN_VERSION_OLDER(bmain, 266, 2))
- ntree->flag |= NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE;
- }
- FOREACH_NODETREE_END;
- }
-
if (MAIN_VERSION_OLDER(bmain, 266, 3)) {
{
/* Fix for a very old issue:
@@ -1907,11 +1960,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
bNode *node;
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
- if (id == &ntree->id)
+ if (id == &ntree->id) {
continue; /* already fixed for node groups */
+ }
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
nodeUniqueName(ntree, node);
+ }
}
FOREACH_NODETREE_END;
}
@@ -1934,14 +1989,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
brush->overlay_flags = 0;
- if (brush->flag & BRUSH_TEXTURE_OVERLAY)
+ if (brush->flag & BRUSH_TEXTURE_OVERLAY) {
brush->overlay_flags |= (BRUSH_OVERLAY_PRIMARY | BRUSH_OVERLAY_CURSOR);
+ }
}
#undef BRUSH_TEXTURE_OVERLAY
}
if (bmain->versionfile < 267) {
- //if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
+ // if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
Brush *brush;
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
@@ -1979,8 +2035,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
sce->r.unit_line_thickness = 1.0f;
}
for (srl = sce->r.layers.first; srl; srl = srl->next) {
- if (srl->freestyleConfig.mode == 0)
+ if (srl->freestyleConfig.mode == 0) {
srl->freestyleConfig.mode = FREESTYLE_CONTROL_EDITOR_MODE;
+ }
if (srl->freestyleConfig.raycasting_algorithm ==
FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE ||
srl->freestyleConfig.raycasting_algorithm ==
@@ -2020,10 +2077,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
linestyle->thickness_position = LS_THICKNESS_CENTER;
linestyle->thickness_ratio = 0.5f;
}
- if (linestyle->chaining == 0)
+ if (linestyle->chaining == 0) {
linestyle->chaining = LS_CHAINING_PLAIN;
- if (linestyle->rounds == 0)
+ }
+ if (linestyle->rounds == 0) {
linestyle->rounds = 3;
+ }
}
}
@@ -2041,24 +2100,28 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (sl->spacetype == SPACE_NODE) {
SpaceNode *snode = (SpaceNode *)sl;
bNodeTreePath *path = snode->treepath.last;
- if (!path)
+ if (!path) {
continue;
+ }
active_viewer_key = path->parent_key;
break;
}
}
- if (active_viewer_key.value != 0)
+ if (active_viewer_key.value != 0) {
break;
+ }
}
- if (active_viewer_key.value != 0)
+ if (active_viewer_key.value != 0) {
break;
+ }
}
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
/* NB: scene->nodetree is a local ID block, has been direct_link'ed */
- if (scene->nodetree)
+ if (scene->nodetree) {
scene->nodetree->active_viewer_key = active_viewer_key;
+ }
}
}
@@ -2096,12 +2159,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
brush->flag &= ~BRUSH_FIXED;
- if (brush->cursor_overlay_alpha < 2)
+ if (brush->cursor_overlay_alpha < 2) {
brush->cursor_overlay_alpha = 33;
- if (brush->texture_overlay_alpha < 2)
+ }
+ if (brush->texture_overlay_alpha < 2) {
brush->texture_overlay_alpha = 33;
- if (brush->mask_overlay_alpha < 2)
+ }
+ if (brush->mask_overlay_alpha < 2) {
brush->mask_overlay_alpha = 33;
+ }
}
#undef BRUSH_FIXED
}
@@ -2115,12 +2181,15 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (con = ob->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
bShrinkwrapConstraint *data = (bShrinkwrapConstraint *)con->data;
- if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS)
+ if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) {
data->projAxis = OB_POSX;
- else if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS)
+ }
+ else if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) {
data->projAxis = OB_POSY;
- else
+ }
+ else {
data->projAxis = OB_POSZ;
+ }
data->projAxisSpace = CONSTRAINT_SPACE_LOCAL;
}
}
@@ -2173,15 +2242,17 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (sa->spacetype == SPACE_NODE) {
ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
- if (ar)
+ if (ar) {
continue;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
continue;
+ }
arnew = MEM_callocN(sizeof(ARegion), "node tools");
@@ -2300,12 +2371,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
/* this can now be turned off */
ToolSettings *ts = scene->toolsettings;
- if (ts->sculpt)
+ if (ts->sculpt) {
ts->sculpt->flags |= SCULPT_DYNTOPO_SUBDIVIDE;
+ }
/* 'Increment' mode disabled for nodes, use true grid snapping instead */
- if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT)
+ if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT) {
scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
+ }
#ifdef WITH_FFMPEG
/* Update for removed "sound-only" option in FFMPEG export settings. */
@@ -2400,14 +2473,18 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
};
int symmetry_flags = sd->flags & 7;
- if (symmetry_flags & SCULPT_SYMM_X)
+ if (symmetry_flags & SCULPT_SYMM_X) {
sd->paint.symmetry_flags |= PAINT_SYMM_X;
- if (symmetry_flags & SCULPT_SYMM_Y)
+ }
+ if (symmetry_flags & SCULPT_SYMM_Y) {
sd->paint.symmetry_flags |= PAINT_SYMM_Y;
- if (symmetry_flags & SCULPT_SYMM_Z)
+ }
+ if (symmetry_flags & SCULPT_SYMM_Z) {
sd->paint.symmetry_flags |= PAINT_SYMM_Z;
- if (symmetry_flags & SCULPT_SYMMETRY_FEATHER)
+ }
+ if (symmetry_flags & SCULPT_SYMMETRY_FEATHER) {
sd->paint.symmetry_flags |= PAINT_SYMMETRY_FEATHER;
+ }
}
}
}
@@ -2473,3 +2550,126 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+void do_versions_after_linking_260(Main *bmain)
+{
+ /* Convert the previously used ntree->inputs/ntree->outputs lists to interface nodes.
+ * Pre 2.56.2 node trees automatically have all unlinked sockets exposed already,
+ * see do_versions_after_linking_250.
+ *
+ * This assumes valid typeinfo pointers, as set in lib_link_ntree.
+ *
+ * Note: theoretically only needed in node groups (main->nodetree),
+ * but due to a temporary bug such links could have been added in all trees,
+ * so have to clean up all of them ...
+ *
+ * Note: this always runs, without it links with NULL fromnode and tonode remain
+ * which causes problems.
+ */
+ if (!MAIN_VERSION_ATLEAST(bmain, 266, 3)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ bNode *input_node = NULL, *output_node = NULL;
+ int num_inputs = 0, num_outputs = 0;
+ bNodeLink *link, *next_link;
+ /* Only create new interface nodes for actual older files.
+ * New file versions already have input/output nodes with duplicate links,
+ * in that case just remove the invalid links.
+ */
+ const bool create_io_nodes = MAIN_VERSION_OLDER(bmain, 266, 2);
+
+ float input_locx = 1000000.0f, input_locy = 0.0f;
+ float output_locx = -1000000.0f, output_locy = 0.0f;
+ /* rough guess, not nice but we don't have access to UI constants here ... */
+ static const float offsetx = 42 + 3 * 20 + 20;
+ /*static const float offsety = 0.0f;*/
+
+ if (create_io_nodes) {
+ if (ntree->inputs.first) {
+ input_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_INPUT);
+ }
+
+ if (ntree->outputs.first) {
+ output_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_OUTPUT);
+ }
+ }
+
+ /* Redirect links from/to the node tree interface to input/output node.
+ * If the fromnode/tonode pointers are NULL, this means a link from/to
+ * the ntree interface sockets, which need to be redirected to new interface nodes.
+ */
+ for (link = ntree->links.first; link; link = next_link) {
+ bool free_link = false;
+ next_link = link->next;
+
+ if (link->fromnode == NULL) {
+ if (input_node) {
+ link->fromnode = input_node;
+ link->fromsock = node_group_input_find_socket(input_node, link->fromsock->identifier);
+ ++num_inputs;
+
+ if (link->tonode) {
+ if (input_locx > link->tonode->locx - offsetx) {
+ input_locx = link->tonode->locx - offsetx;
+ }
+ input_locy += link->tonode->locy;
+ }
+ }
+ else {
+ free_link = true;
+ }
+ }
+
+ if (link->tonode == NULL) {
+ if (output_node) {
+ link->tonode = output_node;
+ link->tosock = node_group_output_find_socket(output_node, link->tosock->identifier);
+ ++num_outputs;
+
+ if (link->fromnode) {
+ if (output_locx < link->fromnode->locx + offsetx) {
+ output_locx = link->fromnode->locx + offsetx;
+ }
+ output_locy += link->fromnode->locy;
+ }
+ }
+ else {
+ free_link = true;
+ }
+ }
+
+ if (free_link) {
+ nodeRemLink(ntree, link);
+ }
+ }
+
+ if (num_inputs > 0) {
+ input_locy /= num_inputs;
+ input_node->locx = input_locx;
+ input_node->locy = input_locy;
+ }
+ if (num_outputs > 0) {
+ output_locy /= num_outputs;
+ output_node->locx = output_locx;
+ output_node->locy = output_locy;
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 60)) {
+ /* From this point we no longer write incomplete links for forward
+ * compatibility with 2.66, we have to clean them up for all previous
+ * versions. */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ bNodeLink *link, *next_link;
+
+ for (link = ntree->links.first; link; link = next_link) {
+ next_link = link->next;
+ if (link->fromnode == NULL || link->tonode == NULL) {
+ nodeRemLink(ntree, link);
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index df56809869f..20b2bfd95c8 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -256,8 +256,8 @@ static void do_version_action_editor_properties_region(ListBase *regionbase)
static void do_version_bones_super_bbone(ListBase *lb)
{
for (Bone *bone = lb->first; bone; bone = bone->next) {
- bone->scaleIn = 1.0f;
- bone->scaleOut = 1.0f;
+ bone->scale_in_x = bone->scale_in_y = 1.0f;
+ bone->scale_out_x = bone->scale_out_y = 1.0f;
do_version_bones_super_bbone(&bone->childbase);
}
@@ -324,12 +324,15 @@ static void do_versions_compositor_render_passes_storage(bNode *node)
node_cmp_rlayers_sock_to_pass(pass_index),
sizeof(sockdata->pass_name));
- if (pass_index == 0)
+ if (pass_index == 0) {
sockname = "Image";
- else if (pass_index == 1)
+ }
+ else if (pass_index == 1) {
sockname = "Alpha";
- else
+ }
+ else {
sockname = node_cmp_rlayers_sock_to_pass(pass_index);
+ }
BLI_strncpy(sock->name, sockname, sizeof(sock->name));
}
}
@@ -359,10 +362,12 @@ static char *replace_bbone_easing_rnapath(char *old_path)
/* NOTE: This will break paths for any bones/custom-properties
* which happen be named after the bbone property id's
*/
- if (strstr(old_path, "bbone_in"))
+ if (strstr(old_path, "bbone_in")) {
new_path = BLI_str_replaceN(old_path, "bbone_in", "bbone_easein");
- else if (strstr(old_path, "bbone_out"))
+ }
+ else if (strstr(old_path, "bbone_out")) {
new_path = BLI_str_replaceN(old_path, "bbone_out", "bbone_easeout");
+ }
if (new_path) {
MEM_freeN(old_path);
@@ -508,7 +513,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!MAIN_VERSION_ATLEAST(bmain, 270, 4)) {
- /* ui_previews were not handled correctly when copying areas, leading to corrupted files (see T39847).
+ /* ui_previews were not handled correctly when copying areas,
+ * leading to corrupted files (see T39847).
* This will always reset situation to a valid state.
*/
bScreen *sc;
@@ -657,8 +663,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
Brush *br;
for (br = bmain->brushes.first; br; br = br->id.next) {
if ((br->ob_mode & OB_MODE_SCULPT) &&
- ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
+ ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK)) {
br->alpha = 1.0f;
+ }
}
}
@@ -728,10 +735,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 273, 3)) {
ParticleSettings *part;
for (part = bmain->particles.first; part; part = part->id.next) {
- if (part->clumpcurve)
+ if (part->clumpcurve) {
part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
- if (part->roughcurve)
+ }
+ if (part->roughcurve) {
part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
+ }
}
}
@@ -917,10 +926,12 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
if (seq->strip && seq->strip->proxy && !seq->strip->proxy->storage) {
- if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)
+ if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) {
seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR;
- if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)
+ }
+ if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE;
+ }
}
#undef SEQ_USE_PROXY_CUSTOM_DIR
#undef SEQ_USE_PROXY_CUSTOM_FILE
@@ -1153,12 +1164,16 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (scene->gpd) {
bGPdata *gpd = scene->gpd;
- /* Copy over the settings stored in the GP datablock linked to the scene, for minimal disruption */
+ /* Copy over the settings stored in the GP data-block linked to the scene,
+ * for minimal disruption. */
ts->gpencil_v3d_align = 0;
- if (gpd->flag & GP_DATA_VIEWALIGN) ts->gpencil_v3d_align |= GP_PROJECT_VIEWSPACE;
- if (gpd->flag & GP_DATA_DEPTH_VIEW) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_VIEW;
- if (gpd->flag & GP_DATA_DEPTH_STROKE) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE;
+ if (gpd->flag & GP_DATA_VIEWALIGN)
+ ts->gpencil_v3d_align |= GP_PROJECT_VIEWSPACE;
+ if (gpd->flag & GP_DATA_DEPTH_VIEW)
+ ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_VIEW;
+ if (gpd->flag & GP_DATA_DEPTH_STROKE)
+ ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE;
if (gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS)
ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE_ENDPOINTS;
@@ -1188,18 +1203,20 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
- if (enabled)
+ if (enabled) {
gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
- else
+ }
+ else {
gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
+ }
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 276, 5)) {
ListBase *lbarray[MAX_LIBARRAY];
int a;
- /* Important to clear all non-persistent flags from older versions here, otherwise they could collide
- * with any new persistent flag we may add in the future. */
+ /* Important to clear all non-persistent flags from older versions here,
+ * otherwise they could collide with any new persistent flag we may add in the future. */
a = set_listbasepointers(bmain, lbarray);
while (a--) {
for (ID *id = lbarray[a]->first; id; id = id->next) {
@@ -1321,8 +1338,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (ob->pose) {
for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* see do_version_bones_super_bbone()... */
- pchan->scaleIn = 1.0f;
- pchan->scaleOut = 1.0f;
+ pchan->scale_in_x = pchan->scale_in_y = 1.0f;
+ pchan->scale_out_x = pchan->scale_out_y = 1.0f;
/* also make sure some legacy (unused for over a decade) flags are unset,
* so that we can reuse them for stuff that matters now...
@@ -1432,14 +1449,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
copy_v4_v4(palcolor->color, gpl->color);
copy_v4_v4(palcolor->fill, gpl->fill);
- if (gpl->flag & GP_LAYER_HIDE)
+ if (gpl->flag & GP_LAYER_HIDE) {
palcolor->flag |= PC_COLOR_HIDE;
- if (gpl->flag & GP_LAYER_LOCKED)
+ }
+ if (gpl->flag & GP_LAYER_LOCKED) {
palcolor->flag |= PC_COLOR_LOCKED;
- if (gpl->flag & GP_LAYER_ONIONSKIN)
+ }
+ if (gpl->flag & GP_LAYER_ONIONSKIN) {
palcolor->flag |= PC_COLOR_ONIONSKIN;
- if (gpl->flag & GP_LAYER_VOLUMETRIC)
+ }
+ if (gpl->flag & GP_LAYER_VOLUMETRIC) {
palcolor->flag |= PC_COLOR_VOLUMETRIC;
+ }
/* set layer opacity to 1 */
gpl->opacity = 1.0f;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 0582bf05c25..f9f87731197 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -30,6 +30,7 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
+#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
@@ -56,11 +57,13 @@
#include "DNA_text_types.h"
#include "BKE_action.h"
+#include "BKE_animsys.h"
#include "BKE_cloth.h"
#include "BKE_collection.h"
#include "BKE_constraint.h"
#include "BKE_colortools.h"
#include "BKE_customdata.h"
+#include "BKE_fcurve.h"
#include "BKE_freestyle.h"
#include "BKE_gpencil.h"
#include "BKE_idprop.h"
@@ -98,7 +101,8 @@
static bScreen *screen_parent_find(const bScreen *screen)
{
- /* can avoid lookup if screen state isn't maximized/full (parent and child store the same state) */
+ /* Can avoid lookup if screen state isn't maximized/full
+ * (parent and child store the same state). */
if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) {
for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->full && sa->full != screen) {
@@ -173,7 +177,8 @@ static void do_version_area_change_space_to_space_action(ScrArea *area, const Sc
* - Active scene isn't stored in screen anymore, but in window.
* - Create workspace instance hook for each window.
*
- * \note Some of the created workspaces might be deleted again in case of reading the default startup.blend.
+ * \note Some of the created workspaces might be deleted again
+ * in case of reading the default `startup.blend`.
*/
static void do_version_workspaces_after_lib_link(Main *bmain)
{
@@ -187,7 +192,8 @@ static void do_version_workspaces_after_lib_link(Main *bmain)
bScreen *screen = screen_parent ? screen_parent : win->screen;
if (screen->temp) {
- /* We do not generate a new workspace for those screens... still need to set some data in win. */
+ /* We do not generate a new workspace for those screens...
+ * still need to set some data in win. */
win->workspace_hook = BKE_workspace_instance_hook_create(bmain);
win->scene = screen->scene;
/* Deprecated from now on! */
@@ -509,7 +515,8 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
if (have_override || need_default_renderlayer) {
ViewLayer *view_layer = BKE_view_layer_add(scene, "Viewport");
- /* If we ported all the original render layers, we don't need to make the viewport layer renderable. */
+ /* If we ported all the original render layers,
+ * we don't need to make the viewport layer renderable. */
if (!BLI_listbase_is_single(&scene->view_layers)) {
view_layer->flag &= ~VIEW_LAYER_RENDER;
}
@@ -580,6 +587,111 @@ static void do_versions_fix_annotations(bGPdata *gpd)
}
}
+static void do_versions_remove_region(ListBase *regionbase, int regiontype)
+{
+ ARegion *ar, *ar_next;
+ for (ar = regionbase->first; ar; ar = ar_next) {
+ ar_next = ar->next;
+ if (ar->regiontype == regiontype) {
+ BLI_freelinkN(regionbase, ar);
+ }
+ }
+}
+
+static ARegion *do_versions_find_region_or_null(ListBase *regionbase, int regiontype)
+{
+ for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == regiontype) {
+ return ar;
+ }
+ }
+ return NULL;
+}
+
+static ARegion *do_versions_find_region(ListBase *regionbase, int regiontype)
+{
+ ARegion *ar = do_versions_find_region_or_null(regionbase, regiontype);
+ if (ar == NULL) {
+ BLI_assert(!"Did not find expected region in versioning");
+ }
+ return ar;
+}
+
+static ARegion *do_versions_add_region(int regiontype, const char *name)
+{
+ ARegion *ar = MEM_callocN(sizeof(ARegion), name);
+ ar->regiontype = regiontype;
+ return ar;
+}
+
+static void do_version_bones_split_bbone_scale(ListBase *lb)
+{
+ for (Bone *bone = lb->first; bone; bone = bone->next) {
+ bone->scale_in_y = bone->scale_in_x;
+ bone->scale_out_y = bone->scale_out_x;
+
+ do_version_bones_split_bbone_scale(&bone->childbase);
+ }
+}
+
+static bool replace_bbone_scale_rnapath(char **p_old_path)
+{
+ char *old_path = *p_old_path;
+
+ if (old_path == NULL) {
+ return false;
+ }
+
+ if (BLI_str_endswith(old_path, "bbone_scalein") ||
+ BLI_str_endswith(old_path, "bbone_scaleout")) {
+ *p_old_path = BLI_strdupcat(old_path, "x");
+
+ MEM_freeN(old_path);
+ return true;
+ }
+
+ return false;
+}
+
+static void do_version_bbone_scale_fcurve_fix(ListBase *curves, FCurve *fcu)
+{
+ /* Update driver variable paths. */
+ if (fcu->driver) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &fcu->driver->variables) {
+ DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
+ replace_bbone_scale_rnapath(&dtar->rna_path);
+ }
+ DRIVER_TARGETS_LOOPER_END;
+ }
+ }
+
+ /* Update F-Curve's path. */
+ if (replace_bbone_scale_rnapath(&fcu->rna_path)) {
+ /* If matched, duplicate the curve and tweak name. */
+ FCurve *second = copy_fcurve(fcu);
+
+ second->rna_path[strlen(second->rna_path) - 1] = 'y';
+
+ BLI_insertlinkafter(curves, fcu, second);
+
+ /* Add to the curve group. */
+ second->grp = fcu->grp;
+
+ if (fcu->grp != NULL && fcu->grp->channels.last == fcu) {
+ fcu->grp->channels.last = second;
+ }
+ }
+}
+
+static void do_version_bbone_scale_animdata_cb(ID *UNUSED(id),
+ AnimData *adt,
+ void *UNUSED(wrapper_data))
+{
+ LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &adt->drivers) {
+ do_version_bbone_scale_fcurve_fix(&adt->drivers, fcu);
+ }
+}
+
void do_versions_after_linking_280(Main *bmain)
{
bool use_collection_compat_28 = true;
@@ -628,9 +740,11 @@ void do_versions_after_linking_280(Main *bmain)
}
}
- /* We need to assign lib pointer to generated hidden collections *after* all have been created, otherwise we'll
- * end up with several datablocks sharing same name/library, which is FORBIDDEN!
- * Note: we need this to be recursive, since a child collection may be sorted before its parent in bmain... */
+ /* We need to assign lib pointer to generated hidden collections *after* all have been created,
+ * otherwise we'll end up with several datablocks sharing same name/library,
+ * which is FORBIDDEN!
+ * Note: we need this to be recursive,
+ * since a child collection may be sorted before its parent in bmain. */
for (Collection *collection = bmain->collections.first; collection != NULL;
collection = collection->id.next) {
do_version_collection_propagate_lib_to_children(collection);
@@ -721,8 +835,9 @@ void do_versions_after_linking_280(Main *bmain)
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) {
- /* Due to several changes to particle RNA and draw code particles from older files may no longer
- * be visible. Here we correct this by setting a default draw size for those files. */
+ /* Due to several changes to particle RNA and draw code particles from older files may
+ * no longer be visible.
+ * Here we correct this by setting a default draw size for those files. */
for (Object *object = bmain->objects.first; object; object = object->id.next) {
for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
if (psys->part->draw_size == 0.0f) {
@@ -809,8 +924,9 @@ void do_versions_after_linking_280(Main *bmain)
/* Update Curve object Shape Key data layout to include the Radius property */
if (!MAIN_VERSION_ATLEAST(bmain, 280, 23)) {
for (Curve *cu = bmain->curves.first; cu; cu = cu->id.next) {
- if (!cu->key || cu->key->elemsize != sizeof(float[4]))
+ if (!cu->key || cu->key->elemsize != sizeof(float[4])) {
continue;
+ }
cu->key->elemstr[0] = 3; /*KEYELEM_ELEM_SIZE_CURVE*/
cu->key->elemsize = sizeof(float[3]);
@@ -821,8 +937,9 @@ void do_versions_after_linking_280(Main *bmain)
int old_count = block->totelem;
void *old_data = block->data;
- if (!old_data || old_count <= 0)
+ if (!old_data || old_count <= 0) {
continue;
+ }
block->totelem = new_count;
block->data = MEM_callocN(sizeof(float[3]) * new_count, __func__);
@@ -946,8 +1063,10 @@ void do_versions_after_linking_280(Main *bmain)
}
}
-/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already.
- * But in 2.79 another case generating non-unique names was discovered (see T55668, involving Meta strips)... */
+/* NOTE: This version patch is intended for versions < 2.52.2,
+ * but was initially introduced in 2.27 already.
+ * But in 2.79 another case generating non-unique names was discovered
+ * (see T55668, involving Meta strips). */
static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbasep)
{
for (Sequence *seq = seqbasep->first; seq != NULL; seq = seq->next) {
@@ -958,6 +1077,14 @@ static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbase
}
}
+static void do_versions_seq_set_cache_defaults(Editing *ed)
+{
+ ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
+ ed->cache_flag |= SEQ_CACHE_VIEW_FINAL_OUT;
+ ed->cache_flag |= SEQ_CACHE_VIEW_ENABLE;
+ ed->recycle_max_cost = 10.0f;
+}
+
void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
bool use_collection_compat_28 = true;
@@ -1774,7 +1901,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sl;
- /* "Dopesheet" should be default here, unless it looks like the Action Editor was active instead */
+ /* "Dopesheet" should be default here,
+ * unless it looks like the Action Editor was active instead. */
if ((saction->mode_prev == 0) && (saction->action == NULL)) {
saction->mode_prev = SACTCONT_DOPESHEET;
}
@@ -3013,31 +3141,16 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_TEXT) {
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
- ARegion *ar = MEM_callocN(sizeof(ARegion), "footer for text");
/* Remove multiple footers that were added by mistake. */
- ARegion *ar_footer, *ar_next;
- for (ar_footer = regionbase->first; ar_footer; ar_footer = ar_next) {
- ar_next = ar_footer->next;
- if (ar_footer->regiontype == RGN_TYPE_FOOTER) {
- BLI_freelinkN(regionbase, ar_footer);
- }
- }
+ do_versions_remove_region(regionbase, RGN_TYPE_FOOTER);
/* Add footer. */
- ARegion *ar_header = NULL;
-
- for (ar_header = regionbase->first; ar_header; ar_header = ar_header->next) {
- if (ar_header->regiontype == RGN_TYPE_HEADER) {
- break;
- }
- }
- BLI_assert(ar_header);
+ ARegion *ar = do_versions_add_region(RGN_TYPE_FOOTER, "footer for text");
+ ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
+ ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
BLI_insertlinkafter(regionbase, ar_header, ar);
-
- ar->regiontype = RGN_TYPE_FOOTER;
- ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
}
}
}
@@ -3102,9 +3215,48 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* enable the axis aligned ortho grid by default */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->gridflag |= V3D_SHOW_ORTHO_GRID;
+ }
+ }
+ }
+ }
}
+ /* Keep un-versioned until we're finished adding space types. */
{
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ /* All spaces that use tools must be eventually added. */
+ ARegion *ar = NULL;
+ if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_IMAGE) &&
+ ((ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER)) == NULL)) {
+ /* Add tool header. */
+ ar = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header");
+ ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+
+ ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER);
+ BLI_insertlinkbefore(regionbase, ar_header, ar);
+ /* Hide by default, enable for painting workspaces (startup only). */
+ ar->flag |= RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
+ }
+ if (ar != NULL) {
+ SET_FLAG_FROM_TEST(ar->flag, ar->flag & RGN_FLAG_HIDDEN_BY_USER, RGN_FLAG_HIDDEN);
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 60)) {
if (!DNA_struct_elem_find(fd->filesdna, "bSplineIKConstraint", "short", "yScaleMode")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->pose) {
@@ -3122,6 +3274,54 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity")) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->overlay.sculpt_mode_mask_opacity = 0.75f;
+ }
+ }
+ }
+ }
+ }
+
+ /* Split bbone_scalein/bbone_scaleout into x and y fields. */
+ if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scale_out_y")) {
+ /* Update armature data and pose channels. */
+ LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
+ do_version_bones_split_bbone_scale(&arm->bonebase);
+ }
+
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+ if (ob->pose) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
+ pchan->scale_in_y = pchan->scale_in_x;
+ pchan->scale_out_y = pchan->scale_out_x;
+ }
+ }
+ }
+
+ /* Update action curves and drivers. */
+ LISTBASE_FOREACH (bAction *, act, &bmain->actions) {
+ LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &act->curves) {
+ do_version_bbone_scale_fcurve_fix(&act->curves, fcu);
+ }
+ }
+
+ BKE_animdata_main_cb(bmain, do_version_bbone_scale_animdata_cb, NULL);
+ }
+
+ for (Scene *sce = bmain->scenes.first; sce != NULL; sce = sce->id.next) {
+ if (sce->ed != NULL) {
+ do_versions_seq_set_cache_defaults(sce->ed);
+ }
+ }
+ }
+
+ {
/* Versioning code until next subversion bump goes here. */
}
}
diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c
new file mode 100644
index 00000000000..023bd685352
--- /dev/null
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -0,0 +1,332 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup blenloader
+ */
+
+/* allow readfile to use deprecated functionality */
+#define DNA_DEPRECATED_ALLOW
+
+#include <float.h>
+#include <string.h>
+
+#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_color_types.h"
+#include "DNA_light_types.h"
+#include "DNA_node_types.h"
+#include "DNA_particle_types.h"
+
+#include "BKE_colortools.h"
+#include "BKE_idprop.h"
+#include "BKE_main.h"
+#include "BKE_node.h"
+
+#include "BLO_readfile.h"
+#include "readfile.h"
+
+static float *cycles_node_socket_float_value(bNodeSocket *socket)
+{
+ bNodeSocketValueFloat *socket_data = socket->default_value;
+ return &socket_data->value;
+}
+
+static IDProperty *cycles_properties_from_ID(ID *id)
+{
+ IDProperty *idprop = IDP_GetProperties(id, false);
+ return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles", IDP_GROUP) : NULL;
+}
+
+static float cycles_property_float(IDProperty *idprop, const char *name, float default_value)
+{
+ IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_FLOAT);
+ return (prop) ? IDP_Float(prop) : default_value;
+}
+
+static bool cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
+{
+ IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT);
+ return (prop) ? IDP_Int(prop) : default_value;
+}
+
+static void displacement_node_insert(bNodeTree *ntree)
+{
+ bool need_update = false;
+
+ /* Iterate backwards from end so we don't encounter newly added links. */
+ bNodeLink *prevlink;
+ for (bNodeLink *link = ntree->links.last; link; link = prevlink) {
+ prevlink = link->prev;
+
+ /* Detect link to replace. */
+ bNode *fromnode = link->fromnode;
+ bNodeSocket *fromsock = link->fromsock;
+ bNode *tonode = link->tonode;
+ bNodeSocket *tosock = link->tosock;
+
+ if (!(tonode->type == SH_NODE_OUTPUT_MATERIAL && fromnode->type != SH_NODE_DISPLACEMENT &&
+ STREQ(tosock->identifier, "Displacement"))) {
+ continue;
+ }
+
+ /* Replace link with displacement node. */
+ nodeRemLink(ntree, link);
+
+ /* Add displacement node. */
+ bNode *node = nodeAddStaticNode(NULL, ntree, SH_NODE_DISPLACEMENT);
+ node->locx = 0.5f * (fromnode->locx + tonode->locx);
+ node->locy = 0.5f * (fromnode->locy + tonode->locy);
+
+ bNodeSocket *scale_socket = nodeFindSocket(node, SOCK_IN, "Scale");
+ bNodeSocket *midlevel_socket = nodeFindSocket(node, SOCK_IN, "Midlevel");
+ bNodeSocket *height_socket = nodeFindSocket(node, SOCK_IN, "Height");
+ bNodeSocket *displacement_socket = nodeFindSocket(node, SOCK_OUT, "Displacement");
+
+ /* Set default values for compatibility. */
+ *cycles_node_socket_float_value(scale_socket) = 0.1f;
+ *cycles_node_socket_float_value(midlevel_socket) = 0.0f;
+
+ /* Link to input and material output node. */
+ nodeAddLink(ntree, fromnode, fromsock, node, height_socket);
+ nodeAddLink(ntree, node, displacement_socket, tonode, tosock);
+
+ need_update = true;
+ }
+
+ if (need_update) {
+ ntreeUpdateTree(NULL, ntree);
+ }
+}
+
+static void displacement_principled_nodes(bNode *node)
+{
+ if (node->type == SH_NODE_DISPLACEMENT) {
+ if (node->custom1 != SHD_SPACE_WORLD) {
+ node->custom1 = SHD_SPACE_OBJECT;
+ }
+ }
+ else if (node->type == SH_NODE_BSDF_PRINCIPLED) {
+ if (node->custom2 != SHD_SUBSURFACE_RANDOM_WALK) {
+ node->custom2 = SHD_SUBSURFACE_BURLEY;
+ }
+ }
+}
+
+static bool node_has_roughness(bNode *node)
+{
+ return ELEM(node->type,
+ SH_NODE_BSDF_ANISOTROPIC,
+ SH_NODE_BSDF_GLASS,
+ SH_NODE_BSDF_GLOSSY,
+ SH_NODE_BSDF_REFRACTION);
+}
+
+static void square_roughness_node_insert(bNodeTree *ntree)
+{
+ bool need_update = false;
+
+ /* Update default values */
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node_has_roughness(node)) {
+ bNodeSocket *roughness_input = nodeFindSocket(node, SOCK_IN, "Roughness");
+ float *roughness_value = cycles_node_socket_float_value(roughness_input);
+ *roughness_value = sqrtf(max_ff(*roughness_value, 0.0f));
+ }
+ }
+
+ /* Iterate backwards from end so we don't encounter newly added links. */
+ bNodeLink *prevlink;
+ for (bNodeLink *link = ntree->links.last; link; link = prevlink) {
+ prevlink = link->prev;
+
+ /* Detect link to replace. */
+ bNode *fromnode = link->fromnode;
+ bNodeSocket *fromsock = link->fromsock;
+ bNode *tonode = link->tonode;
+ bNodeSocket *tosock = link->tosock;
+
+ if (!(node_has_roughness(tonode) && STREQ(tosock->identifier, "Roughness"))) {
+ continue;
+ }
+
+ /* Replace links with sqrt node */
+ nodeRemLink(ntree, link);
+
+ /* Add sqrt node. */
+ bNode *node = nodeAddStaticNode(NULL, ntree, SH_NODE_MATH);
+ node->custom1 = NODE_MATH_POW;
+ node->locx = 0.5f * (fromnode->locx + tonode->locx);
+ node->locy = 0.5f * (fromnode->locy + tonode->locy);
+
+ /* Link to input and material output node. */
+ *cycles_node_socket_float_value(node->inputs.last) = 0.5f;
+ nodeAddLink(ntree, fromnode, fromsock, node, node->inputs.first);
+ nodeAddLink(ntree, node, node->outputs.first, tonode, tosock);
+
+ need_update = true;
+ }
+
+ if (need_update) {
+ ntreeUpdateTree(NULL, ntree);
+ }
+}
+
+static void mapping_node_order_flip(bNode *node)
+{
+ /* Flip euler order of mapping shader node */
+ if (node->type == SH_NODE_MAPPING) {
+ TexMapping *texmap = node->storage;
+
+ float quat[4];
+ eulO_to_quat(quat, texmap->rot, EULER_ORDER_ZYX);
+ quat_to_eulO(texmap->rot, EULER_ORDER_XYZ, quat);
+ }
+}
+
+static void vector_curve_node_remap(bNode *node)
+{
+ /* Remap values of vector curve node from normalized to absolute values */
+ if (node->type == SH_NODE_CURVE_VEC) {
+ CurveMapping *mapping = node->storage;
+ mapping->flag &= ~CUMA_DO_CLIP;
+
+ for (int curve_index = 0; curve_index < CM_TOT; curve_index++) {
+ CurveMap *cm = &mapping->cm[curve_index];
+ if (cm->curve) {
+ for (int i = 0; i < mapping->cm->totpoint; i++) {
+ cm->curve[i].x = (cm->curve[i].x * 2.0f) - 1.0f;
+ cm->curve[i].y = (cm->curve[i].y - 0.5f) * 2.0f;
+ }
+ }
+ }
+
+ curvemapping_changed_all(mapping);
+ }
+}
+
+static void ambient_occlusion_node_relink(bNodeTree *ntree)
+{
+ bool need_update = false;
+
+ /* Set default values. */
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == SH_NODE_AMBIENT_OCCLUSION) {
+ node->custom1 = 1; /* samples */
+ node->custom2 &= ~SHD_AO_LOCAL;
+
+ bNodeSocket *distance_socket = nodeFindSocket(node, SOCK_IN, "Distance");
+ *cycles_node_socket_float_value(distance_socket) = 0.0f;
+ }
+ }
+
+ /* Iterate backwards from end so we don't encounter newly added links. */
+ bNodeLink *prevlink;
+ for (bNodeLink *link = ntree->links.last; link; link = prevlink) {
+ prevlink = link->prev;
+
+ /* Detect link to replace. */
+ bNode *fromnode = link->fromnode;
+ bNode *tonode = link->tonode;
+ bNodeSocket *tosock = link->tosock;
+
+ if (!(fromnode->type == SH_NODE_AMBIENT_OCCLUSION)) {
+ continue;
+ }
+
+ /* Replace links with color socket. */
+ nodeRemLink(ntree, link);
+ bNodeSocket *color_socket = nodeFindSocket(fromnode, SOCK_OUT, "Color");
+ nodeAddLink(ntree, fromnode, color_socket, tonode, tosock);
+
+ need_update = true;
+ }
+
+ if (need_update) {
+ ntreeUpdateTree(NULL, ntree);
+ }
+}
+
+void blo_do_versions_cycles(FileData *UNUSED(fd), Library *UNUSED(lib), Main *bmain)
+{
+ /* Particle shape shared with Eevee. */
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 16)) {
+ for (ParticleSettings *part = bmain->particles.first; part; part = part->id.next) {
+ IDProperty *cpart = cycles_properties_from_ID(&part->id);
+
+ if (cpart) {
+ part->shape = cycles_property_float(cpart, "shape", 0.0);
+ part->rad_root = cycles_property_float(cpart, "root_width", 1.0);
+ part->rad_tip = cycles_property_float(cpart, "tip_width", 0.0);
+ part->rad_scale = cycles_property_float(cpart, "radius_scale", 0.01);
+ if (cycles_property_boolean(cpart, "use_closetip", true)) {
+ part->shape_flag |= PART_SHAPE_CLOSE_TIP;
+ }
+ }
+ }
+ }
+}
+
+void do_versions_after_linking_cycles(Main *bmain)
+{
+ if (!MAIN_VERSION_ATLEAST(bmain, 280, 5)) {
+ /* Shader node tree changes. After lib linking so we have all the typeinfo
+ * pointers and updated sockets and we can use the high level node API to
+ * manipulate nodes. */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type != NTREE_SHADER) {
+ continue;
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 273, 5)) {
+ /* Euler order was ZYX in previous versions. */
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ mapping_node_order_flip(node);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 276, 6)) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ vector_curve_node_remap(node);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 2) ||
+ (MAIN_VERSION_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_ATLEAST(bmain, 280, 4))) {
+ displacement_node_insert(ntree);
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 3)) {
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ displacement_principled_nodes(node);
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 4) ||
+ (MAIN_VERSION_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_ATLEAST(bmain, 280, 5))) {
+ /* Switch to squared roughness convention */
+ square_roughness_node_insert(ntree);
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 279, 5)) {
+ ambient_occlusion_node_relink(ntree);
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
+}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 25bd738ce45..45c2a50cc3f 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -92,7 +92,8 @@ void BLO_update_defaults_userpref_blend(void)
/* Leave temp directory empty, will then get appropriate value per OS. */
U.tempdir[0] = '\0';
- /* Only enable tooltips translation by default, without actually enabling translation itself, for now. */
+ /* Only enable tooltips translation by default,
+ * without actually enabling translation itself, for now. */
U.transopts = USER_TR_TOOLTIPS;
U.memcachelimit = 4096;
@@ -143,11 +144,17 @@ static ID *rename_id_for_versioning(Main *bmain,
* This function can be emptied each time the startup.blend is updated. */
void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
{
+ /* For all builtin templates shipped with Blender. */
+ const bool builtin_template =
+ (!app_template ||
+ STR_ELEM(app_template, "2D_Animation", "Sculpting", "VFX", "Video_Editing"));
+
/* For all startup.blend files. */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- /* Remove all stored panels, we want to use defaults (order, open/closed) as defined by UI code here! */
+ /* Remove all stored panels, we want to use defaults
+ * (order, open/closed) as defined by UI code here! */
BKE_area_region_panels_free(&ar->panels);
/* some toolbars have been saved as initialized,
@@ -189,31 +196,29 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
}
}
- if (app_template == NULL) {
+ if (builtin_template) {
/* Name all screens by their workspaces (avoids 'Default.###' names). */
- {
- /* Default only has one window. */
- wmWindow *win = ((wmWindowManager *)bmain->wm.first)->windows.first;
- for (WorkSpace *workspace = bmain->workspaces.first; workspace;
- workspace = workspace->id.next) {
- WorkSpaceLayout *layout = BKE_workspace_hook_layout_for_workspace_get(win->workspace_hook,
- workspace);
- bScreen *screen = layout->screen;
- BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2);
- BLI_libblock_ensure_unique_name(bmain, screen->id.name);
- }
+ /* Default only has one window. */
+ wmWindow *win = ((wmWindowManager *)bmain->wm.first)->windows.first;
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace;
+ workspace = workspace->id.next) {
+ WorkSpaceLayout *layout = BKE_workspace_hook_layout_for_workspace_get(win->workspace_hook,
+ workspace);
+ bScreen *screen = layout->screen;
+ BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2);
+ BLI_libblock_ensure_unique_name(bmain, screen->id.name);
}
+ }
- {
- /* 'UV Editing' should use UV mode. */
- bScreen *screen = BLI_findstring(&bmain->screens, "UV Editing", offsetof(ID, name) + 2);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_IMAGE) {
- SpaceImage *sima = (SpaceImage *)sl;
- if (sima->mode == SI_MODE_VIEW) {
- sima->mode = SI_MODE_UV;
- }
+ if (app_template == NULL) {
+ /* 'UV Editing' should use UV mode. */
+ bScreen *screen = BLI_findstring(&bmain->screens, "UV Editing", offsetof(ID, name) + 2);
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+ if (sima->mode == SI_MODE_VIEW) {
+ sima->mode = SI_MODE_UV;
}
}
}
@@ -264,11 +269,6 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
}
}
- /* For all builtin templates shipped with Blender. */
- bool builtin_template = (!app_template || STREQ(app_template, "2D_Animation") ||
- STREQ(app_template, "Sculpting") || STREQ(app_template, "VFX") ||
- STREQ(app_template, "Video_Editing"));
-
if (builtin_template) {
/* Clear all tools to use default options instead, ignore the tool saved in the file. */
for (WorkSpace *workspace = bmain->workspaces.first; workspace;
@@ -293,6 +293,39 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
}
}
+ /* Show toopbar for sculpt/paint modes. */
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ bool show_tool_header = false;
+ if (app_template == NULL) {
+ if (STR_ELEM(screen->id.name + 2, "Sculpting", "Texture Paint")) {
+ show_tool_header = true;
+ }
+ }
+ else if (STREQ(app_template, "2D_Animation")) {
+ if (STR_ELEM(screen->id.name + 2, "2D Animation", "2D Full Canvas")) {
+ show_tool_header = true;
+ }
+ }
+ else if (STREQ(app_template, "Sculpting")) {
+ if (STR_ELEM(screen->id.name + 2, "Sculpting")) {
+ show_tool_header = true;
+ }
+ }
+
+ if (show_tool_header) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_TOOL_HEADER) {
+ ar->flag &= ~(RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER);
+ }
+ }
+ }
+ }
+ }
+ }
+
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine));
@@ -328,8 +361,8 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
}
/* Rename light objects. */
- rename_id_for_versioning(bmain, ID_OB, "Light", "Light");
- rename_id_for_versioning(bmain, ID_LA, "Light", "Light");
+ rename_id_for_versioning(bmain, ID_OB, "Lamp", "Light");
+ rename_id_for_versioning(bmain, ID_LA, "Lamp", "Light");
for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
/* Match default for new meshes. */
@@ -353,4 +386,15 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
copy_v2_fl2(scene->safe_areas.title, 0.1f, 0.05f);
copy_v2_fl2(scene->safe_areas.action, 0.035f, 0.035f);
}
+
+ if (app_template == NULL) {
+ /* Enable for UV sculpt (other brush types will be created as needed),
+ * without this the grab brush will be active but not selectable from the list. */
+ Brush *brush = BLI_findstring(&bmain->brushes, "Grab", offsetof(ID, name) + 2);
+ brush->ob_mode |= OB_MODE_EDIT;
+ }
+
+ for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
+ brush->blur_kernel_radius = 2;
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 7fea9dffece..df26ca37826 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -97,8 +97,9 @@ static void vcol_to_fcol(Mesh *me)
uint *mcol, *mcoln, *mcolmain;
int a;
- if (me->totface == 0 || me->mcol == NULL)
+ if (me->totface == 0 || me->mcol == NULL) {
return;
+ }
mcoln = mcolmain = MEM_malloc_arrayN(me->totface, 4 * sizeof(int), "mcoln");
mcol = (uint *)me->mcol;
@@ -128,8 +129,9 @@ static void do_version_bone_head_tail_237(Bone *bone)
mul_v3_fl(vec, bone->length);
add_v3_v3v3(bone->arm_tail, bone->arm_head, vec);
- for (child = bone->childbase.first; child; child = child->next)
+ for (child = bone->childbase.first; child; child = child->next) {
do_version_bone_head_tail_237(child);
+ }
}
static void bone_version_238(ListBase *lb)
@@ -142,8 +144,9 @@ static void bone_version_238(ListBase *lb)
bone->rad_tail = 0.1f * bone->length;
bone->dist -= bone->rad_head;
- if (bone->dist <= 0.0f)
+ if (bone->dist <= 0.0f) {
bone->dist = 0.0f;
+ }
}
bone_version_238(&bone->childbase);
}
@@ -154,8 +157,9 @@ static void bone_version_239(ListBase *lb)
Bone *bone;
for (bone = lb->first; bone; bone = bone->next) {
- if (bone->layer == 0)
+ if (bone->layer == 0) {
bone->layer = 1;
+ }
bone_version_239(&bone->childbase);
}
}
@@ -197,8 +201,9 @@ static void ntree_version_242(bNodeTree *ntree)
if (node->type == CMP_NODE_HUE_SAT) {
if (node->storage) {
NodeHueSat *nhs = node->storage;
- if (nhs->val == 0.0f)
+ if (nhs->val == 0.0f) {
nhs->val = 1.0f;
+ }
}
}
}
@@ -219,8 +224,9 @@ static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree)
if (!node->storage) {
ntf = MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats");
node->storage = ntf;
- if (node->custom1)
+ if (node->custom1) {
ntf->x = 1.0f;
+ }
}
}
@@ -247,8 +253,9 @@ static void idproperties_fix_groups_lengths_recurse(IDProperty *prop)
int i;
for (loop = prop->data.group.first, i = 0; loop; loop = loop->next, i++) {
- if (loop->type == IDP_GROUP)
+ if (loop->type == IDP_GROUP) {
idproperties_fix_groups_lengths_recurse(loop);
+ }
}
if (prop->len != i) {
@@ -279,19 +286,22 @@ static void customdata_version_242(Mesh *me)
if (!me->vdata.totlayer) {
CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert);
- if (me->dvert)
+ if (me->dvert) {
CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert);
+ }
}
- if (!me->edata.totlayer)
+ if (!me->edata.totlayer) {
CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->medge, me->totedge);
+ }
if (!me->fdata.totlayer) {
CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->mface, me->totface);
if (me->tface) {
- if (me->mcol)
+ if (me->mcol) {
MEM_freeN(me->mcol);
+ }
me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface);
me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface);
@@ -323,19 +333,23 @@ static void customdata_version_242(Mesh *me)
if (layer->type == CD_MTFACE) {
if (layer->name[0] == 0) {
- if (mtfacen == 0)
+ if (mtfacen == 0) {
strcpy(layer->name, "UVMap");
- else
+ }
+ else {
BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen);
+ }
}
mtfacen++;
}
else if (layer->type == CD_MCOL) {
if (layer->name[0] == 0) {
- if (mcoln == 0)
+ if (mcoln == 0) {
strcpy(layer->name, "Col");
- else
+ }
+ else {
BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln);
+ }
}
mcoln++;
}
@@ -394,8 +408,9 @@ static void do_version_free_effect_245(Effect *eff)
if (eff->type == EFF_PARTICLE) {
paf = (PartEff *)eff;
- if (paf->keys)
+ if (paf->keys) {
MEM_freeN(paf->keys);
+ }
}
MEM_freeN(eff);
}
@@ -437,8 +452,9 @@ static void do_version_constraints_245(ListBase *lb)
bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data;
/* new headtail functionality makes Bone-Tip function obsolete */
- if (data->flag & LOCLIKE_TIP)
+ if (data->flag & LOCLIKE_TIP) {
con->headtail = 1.0f;
+ }
}
}
}
@@ -449,14 +465,16 @@ PartEff *blo_do_version_give_parteff_245(Object *ob)
paf = ob->effect.first;
while (paf) {
- if (paf->type == EFF_PARTICLE)
+ if (paf->type == EFF_PARTICLE) {
return paf;
+ }
paf = paf->next;
}
return NULL;
}
-/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */
+/* NOTE: this version patch is intended for versions < 2.52.2,
+ * but was initially introduced in 2.27 already. */
void blo_do_version_old_trackto_to_constraints(Object *ob)
{
/* create new trackto constraint from the relationship */
@@ -517,8 +535,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
ob->colbits = 0;
if (ob->totcol) {
for (a = 0; a < ob->totcol; a++) {
- if (ob->mat[a])
+ if (ob->mat[a]) {
ob->colbits |= (1 << a);
+ }
}
}
ob = ob->id.next;
@@ -540,8 +559,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* mcol changed */
Mesh *me = bmain->meshes.first;
while (me) {
- if (me->mcol)
+ if (me->mcol) {
vcol_to_fcol(me);
+ }
me = me->id.next;
}
}
@@ -550,8 +570,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Object *ob;
ob = bmain->objects.first;
while (ob) {
- if (ob->dt == 0)
+ if (ob->dt == 0) {
ob->dt = OB_SOLID;
+ }
ob = ob->id.next;
}
}
@@ -567,8 +588,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- if (v3d->gridlines == 0)
+ if (v3d->gridlines == 0) {
v3d->gridlines = 20;
+ }
}
sl = sl->next;
}
@@ -608,8 +630,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile <= 153) {
Scene *sce = bmain->scenes.first;
while (sce) {
- if (sce->r.blurfac == 0.0f)
+ if (sce->r.blurfac == 0.0f) {
sce->r.blurfac = 1.0f;
+ }
sce = sce->id.next;
}
}
@@ -617,8 +640,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile <= 163) {
Scene *sce = bmain->scenes.first;
while (sce) {
- if (sce->r.frs_sec == 0)
+ if (sce->r.frs_sec == 0) {
sce->r.frs_sec = 25;
+ }
sce = sce->id.next;
}
}
@@ -661,8 +685,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile <= 169) {
Mesh *me = bmain->meshes.first;
while (me) {
- if (me->subdiv == 0)
+ if (me->subdiv == 0) {
me->subdiv = 1;
+ }
me = me->id.next;
}
}
@@ -758,10 +783,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
sound->min_gain = 0.0;
sound->distance = 1.0;
- if (sound->attenuation > 0.0f)
+ if (sound->attenuation > 0.0f) {
sound->flags |= SOUND_FLAGS_3D;
- else
+ }
+ else {
sound->flags &= ~SOUND_FLAGS_3D;
+ }
sound = sound->id.next;
}
@@ -783,10 +810,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
me->subdiv = 1;
}
else {
- if (me->subdiv < 2)
+ if (me->subdiv < 2) {
me->subdiv = 1;
- else
+ }
+ else {
me->subdiv--;
+ }
}
}
}
@@ -1013,33 +1042,33 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (sbuts->mainb == BUTS_LAMP) {
sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_LAMP;
+ // sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_LAMP;
}
else if (sbuts->mainb == BUTS_MAT) {
sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_MAT;
+ // sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_MAT;
}
else if (sbuts->mainb == BUTS_TEX) {
sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_TEX;
+ // sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_TEX;
}
else if (sbuts->mainb == BUTS_ANIM) {
sbuts->mainb = CONTEXT_OBJECT;
}
else if (sbuts->mainb == BUTS_WORLD) {
sbuts->mainb = CONTEXT_SCENE;
- //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_WORLD;
+ // sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_WORLD;
}
else if (sbuts->mainb == BUTS_RENDER) {
sbuts->mainb = CONTEXT_SCENE;
- //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_RENDER;
+ // sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_RENDER;
}
else if (sbuts->mainb == BUTS_FPAINT) {
sbuts->mainb = CONTEXT_EDITING;
}
else if (sbuts->mainb == BUTS_RADIO) {
sbuts->mainb = CONTEXT_SHADING;
- //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_RAD;
+ // sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_RAD;
}
else if (sbuts->mainb == BUTS_CONSTRAINT) {
sbuts->mainb = CONTEXT_OBJECT;
@@ -1145,8 +1174,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (wrld->aodist == 0.0f) {
wrld->aodist = 10.0f;
}
- if (wrld->aoenergy == 0.0f)
+ if (wrld->aoenergy == 0.0f) {
wrld->aoenergy = 1.0f;
+ }
wrld = wrld->id.next;
}
@@ -1195,8 +1225,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_TEXT) {
SpaceText *st = (SpaceText *)sl;
- if (st->tabnumber == 0)
+ if (st->tabnumber == 0) {
st->tabnumber = 2;
+ }
}
}
}
@@ -1210,16 +1241,18 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Editing *ed;
while (tex) {
- if (tex->nabla == 0.0f)
+ if (tex->nabla == 0.0f) {
tex->nabla = 0.025f;
+ }
tex = tex->id.next;
}
while (sce) {
ed = sce->ed;
if (ed) {
SEQ_BEGIN (sce->ed, seq) {
- if (seq->type == SEQ_TYPE_IMAGE || seq->type == SEQ_TYPE_MOVIE)
+ if (seq->type == SEQ_TYPE_IMAGE || seq->type == SEQ_TYPE_MOVIE) {
seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
+ }
}
SEQ_END;
}
@@ -1235,8 +1268,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
while (cam) {
if (cam->ortho_scale == 0.0f) {
cam->ortho_scale = 256.0f / cam->lens;
- if (cam->type == CAM_ORTHO)
+ if (cam->type == CAM_ORTHO) {
printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n");
+ }
}
cam = cam->id.next;
}
@@ -1246,10 +1280,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* softbody init new vars */
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->soft) {
- if (ob->soft->defgoal == 0.0f)
+ if (ob->soft->defgoal == 0.0f) {
ob->soft->defgoal = 0.7f;
- if (ob->soft->physics_speed == 0.0f)
+ }
+ if (ob->soft->physics_speed == 0.0f) {
ob->soft->physics_speed = 1.0f;
+ }
if (ob->soft->interval == 0) {
ob->soft->interval = 2;
@@ -1277,20 +1313,23 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
BKE_armature_where_is(arm);
- for (bone = arm->bonebase.first; bone; bone = bone->next)
+ for (bone = arm->bonebase.first; bone; bone = bone->next) {
do_version_bone_head_tail_237(bone);
+ }
}
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->parent) {
Object *parent = blo_do_versions_newlibadr(fd, lib, ob->parent);
- if (parent && parent->type == OB_LATTICE)
+ if (parent && parent->type == OB_LATTICE) {
ob->partype = PARSKEL;
+ }
}
/* btw. armature_rebuild_pose is further only called on leave editmode */
if (ob->type == OB_ARMATURE) {
- if (ob->pose)
+ if (ob->pose) {
BKE_pose_tag_recalc(bmain, ob->pose);
+ }
/* cannot call stuff now (pointers!), done in setup_app_data */
ob->id.recalc |= ID_RECALC_ALL;
@@ -1318,13 +1357,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
smd->subdivType = me->subsurftype;
smd->modifier.mode = 0;
- if (me->subdiv != 0)
+ if (me->subdiv != 0) {
smd->modifier.mode |= 1;
- if (me->subdivr != 0)
+ }
+ if (me->subdivr != 0) {
smd->modifier.mode |= 2;
+ }
- if (me->flag & ME_OPT_EDGES)
+ if (me->flag & ME_OPT_EDGES) {
smd->flags |= eSubsurfModifierFlag_ControlEdges;
+ }
BLI_addtail(&ob->modifiers, smd);
@@ -1340,8 +1382,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (obc && obc->type == OB_CURVE) {
Curve *cu = blo_do_versions_newlibadr(fd, lib, obc->data);
- if (cu)
+ if (cu) {
cu->flag |= CU_PATH;
+ }
}
}
}
@@ -1430,12 +1473,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
paf = blo_do_version_give_parteff_245(ob);
if (paf) {
- if (paf->disp == 0)
+ if (paf->disp == 0) {
paf->disp = 100;
- if (paf->speedtex == 0)
+ }
+ if (paf->speedtex == 0) {
paf->speedtex = 8;
- if (paf->omat == 0)
+ }
+ if (paf->omat == 0) {
paf->omat = 1;
+ }
}
}
@@ -1459,8 +1505,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (kb = key->block.first; kb; kb = kb->next) {
if (kb == key->refkey) {
- if (kb->name[0] == 0)
+ if (kb->name[0] == 0) {
strcpy(kb->name, "Basis");
+ }
}
else {
if (kb->name[0] == 0) {
@@ -1498,8 +1545,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* updating stepsize for ghost drawing */
for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
bone_version_239(&arm->bonebase);
- if (arm->layer == 0)
+ if (arm->layer == 0) {
arm->layer = 1;
+ }
}
for (; sce; sce = sce->id.next) {
@@ -1510,16 +1558,19 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
for (; cam; cam = cam->id.next) {
- if (set_passepartout)
+ if (set_passepartout) {
cam->flag |= CAM_SHOWPASSEPARTOUT;
+ }
/* make sure old cameras have title safe on */
- if (!(cam->flag & CAM_SHOW_SAFE_MARGINS))
+ if (!(cam->flag & CAM_SHOW_SAFE_MARGINS)) {
cam->flag |= CAM_SHOW_SAFE_MARGINS;
+ }
/* set an appropriate camera passepartout alpha */
- if (!(cam->passepartalpha))
+ if (!(cam->passepartalpha)) {
cam->passepartalpha = 0.2f;
+ }
}
}
@@ -1533,12 +1584,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* updating layers still */
for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
bone_version_239(&arm->bonebase);
- if (arm->layer == 0)
+ if (arm->layer == 0) {
arm->layer = 1;
+ }
}
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->audio.mixrate == 0)
+ if (sce->audio.mixrate == 0) {
sce->audio.mixrate = 48000;
+ }
/* We don't add default layer since blender2.8 because the layers
* are now in Scene->view_layers and a default layer is created in
@@ -1547,14 +1600,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
SceneRenderLayer *srl;
/* new layer flag for sky, was default for solid */
for (srl = sce->r.layers.first; srl; srl = srl->next) {
- if (srl->layflag & SCE_LAY_SOLID)
+ if (srl->layflag & SCE_LAY_SOLID) {
srl->layflag |= SCE_LAY_SKY;
+ }
srl->passflag &= (SCE_PASS_COMBINED | SCE_PASS_Z | SCE_PASS_NORMAL | SCE_PASS_VECTOR);
}
/* node version changes */
- if (sce->nodetree)
+ if (sce->nodetree) {
ntree_version_241(sce->nodetree);
+ }
/* uv calculation options moved to toolsettings */
if (sce->toolsettings->unwrapper == 0) {
@@ -1563,12 +1618,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
ntree_version_241(ntree);
+ }
- for (la = bmain->lights.first; la; la = la->id.next)
- if (la->buffers == 0)
+ for (la = bmain->lights.first; la; la = la->id.next) {
+ if (la->buffers == 0) {
la->buffers = 1;
+ }
+ }
/* for empty drawsize and drawtype */
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
@@ -1613,8 +1671,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- if (v3d->gridsubdiv == 0)
+ if (v3d->gridsubdiv == 0) {
v3d->gridsubdiv = 10;
+ }
}
}
sa = sa->next;
@@ -1625,20 +1684,25 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
enum {
R_THREADS = (1 << 19),
};
- if (sce->toolsettings->select_thresh == 0.0f)
+ if (sce->toolsettings->select_thresh == 0.0f) {
sce->toolsettings->select_thresh = 0.01f;
+ }
if (sce->r.threads == 0) {
- if (sce->r.mode & R_THREADS)
+ if (sce->r.mode & R_THREADS) {
sce->r.threads = 2;
- else
+ }
+ else {
sce->r.threads = 1;
+ }
}
- if (sce->nodetree)
+ if (sce->nodetree) {
ntree_version_242(sce->nodetree);
+ }
}
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
ntree_version_242(ntree);
+ }
/* add default radius values to old curve points */
for (cu = bmain->curves.first; cu; cu = cu->id.next) {
@@ -1646,14 +1710,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (nu) {
if (nu->bezt) {
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
- if (!bezt->radius)
+ if (!bezt->radius) {
bezt->radius = 1.0;
+ }
}
}
else if (nu->bp) {
for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
- if (!bp->radius)
+ if (!bp->radius) {
bp->radius = 1.0;
+ }
}
}
}
@@ -1674,10 +1740,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
switch (curcon->type) {
case CONSTRAINT_TYPE_MINMAX: {
bMinMaxConstraint *data = curcon->data;
- if (data->sticky == 1)
+ if (data->sticky == 1) {
data->flag |= MINMAX_STICKY;
- else
+ }
+ else {
data->flag &= ~MINMAX_STICKY;
+ }
break;
}
@@ -1685,8 +1753,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
bRotateLikeConstraint *data = curcon->data;
/* version patch from buttons_object.c */
- if (data->flag == 0)
+ if (data->flag == 0) {
data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
+ }
break;
}
@@ -1703,10 +1772,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
switch (curcon->type) {
case CONSTRAINT_TYPE_MINMAX: {
bMinMaxConstraint *data = curcon->data;
- if (data->sticky == 1)
+ if (data->sticky == 1) {
data->flag |= MINMAX_STICKY;
- else
+ }
+ else {
data->flag &= ~MINMAX_STICKY;
+ }
break;
}
case CONSTRAINT_TYPE_KINEMATIC: {
@@ -1721,8 +1792,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
bRotateLikeConstraint *data = curcon->data;
/* version patch from buttons_object.c */
- if (data->flag == 0)
+ if (data->flag == 0) {
data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
+ }
break;
}
}
@@ -1736,23 +1808,28 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (md->type == eModifierType_Curve) {
CurveModifierData *cmd = (CurveModifierData *)md;
- if (cmd->defaxis == 0)
+ if (cmd->defaxis == 0) {
cmd->defaxis = ob->trackflag + 1;
+ }
}
}
}
for (ma = bmain->materials.first; ma; ma = ma->id.next) {
- if (ma->nodetree)
+ if (ma->nodetree) {
ntree_version_242(ma->nodetree);
+ }
}
- for (me = bmain->meshes.first; me; me = me->id.next)
+ for (me = bmain->meshes.first; me; me = me->id.next) {
customdata_version_242(me);
+ }
- for (collection = bmain->collections.first; collection; collection = collection->id.next)
- if (collection->layer == 0)
+ for (collection = bmain->collections.first; collection; collection = collection->id.next) {
+ if (collection->layer == 0) {
collection->layer = (1 << 20) - 1;
+ }
+ }
/* now, subversion control! */
if (bmain->subversionfile < 3) {
@@ -1795,14 +1872,18 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC) != 0;
}
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
+ if (sce->nodetree) {
do_version_ntree_242_2(sce->nodetree);
+ }
}
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
do_version_ntree_242_2(ntree);
- for (ma = bmain->materials.first; ma; ma = ma->id.next)
- if (ma->nodetree)
+ }
+ for (ma = bmain->materials.first; ma; ma = ma->id.next) {
+ if (ma->nodetree) {
do_version_ntree_242_2(ma->nodetree);
+ }
+ }
}
if (bmain->subversionfile < 4) {
@@ -1856,8 +1937,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* render layer added, this is not the active layer */
if (bmain->versionfile <= 243 || bmain->subversionfile < 2) {
Mesh *me;
- for (me = bmain->meshes.first; me; me = me->id.next)
+ for (me = bmain->meshes.first; me; me = me->id.next) {
customdata_version_243(me);
+ }
}
}
@@ -1925,8 +2007,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
bLocLimitConstraint *data = (bLocLimitConstraint *)curcon->data;
/* old limit without parent option for objects */
- if (data->flag2)
+ if (data->flag2) {
curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
+ }
break;
}
}
@@ -1955,8 +2038,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
bActionConstraint *data = (bActionConstraint *)curcon->data;
/* 'data->local' used to mean that target was in local-space */
- if (data->local)
+ if (data->local) {
curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
+ }
break;
}
}
@@ -1981,8 +2065,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
/* add point caches */
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->soft && !ob->soft->pointcache)
+ if (ob->soft && !ob->soft->pointcache) {
ob->soft->pointcache = BKE_ptcache_add(&ob->soft->ptcaches);
+ }
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
if (psys->pointcache) {
@@ -1992,8 +2077,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
psys->pointcache->flag &= ~PTCACHE_BAKED;
}
}
- else
+ else {
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
+ }
}
for (md = ob->modifiers.first; md; md = md->next) {
@@ -2042,13 +2128,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
for (part = bmain->particles.first; part; part = part->id.next) {
- if (part->ren_child_nbr == 0)
+ if (part->ren_child_nbr == 0) {
part->ren_child_nbr = part->child_nbr;
+ }
}
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
- if (sce->nodetree)
+ if (sce->nodetree) {
ntree_version_245(fd, lib, sce->nodetree);
+ }
if (sce->r.simplify_subsurf == 0) {
sce->r.simplify_subsurf = 6;
@@ -2056,8 +2144,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
}
}
- for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next)
+ for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
ntree_version_245(fd, lib, ntree);
+ }
/* fix for temporary flag changes during 245 cycle */
for (ima = bmain->images.first; ima; ima = ima->id.next) {
@@ -2094,13 +2183,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
ModifierData *md;
Object *ob;
- for (arm = bmain->armatures.first; arm; arm = arm->id.next)
+ for (arm = bmain->armatures.first; arm; arm = arm->id.next) {
arm->deformflag |= ARM_DEF_B_BONE_REST;
+ }
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Armature)
+ if (md->type == eModifierType_Armature) {
((ArmatureModifierData *)md)->deformflag |= ARM_DEF_B_BONE_REST;
+ }
}
}
}
@@ -2142,8 +2233,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
int k;
for (k = 0; k < sb->totkey; k++) {
- if (sb->keys[k])
+ if (sb->keys[k]) {
MEM_freeN(sb->keys[k]);
+ }
}
MEM_freeN(sb->keys);
@@ -2165,8 +2257,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
int k;
for (k = 0; k < sb->totkey; k++) {
- if (sb->keys[k])
+ if (sb->keys[k]) {
MEM_freeN(sb->keys[k]);
+ }
}
MEM_freeN(sb->keys);
@@ -2288,8 +2381,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(
ob, eModifierType_Fluidsim);
- if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE)
+ if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE) {
part->type = PART_FLUID;
+ }
}
do_version_free_effects_245(&ob->effect);
@@ -2323,8 +2417,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Object *ob;
/* dupliface scale */
- for (ob = bmain->objects.first; ob; ob = ob->id.next)
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
ob->instance_faces_scale = 1.0f;
+ }
}
if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
@@ -2336,19 +2431,23 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (strip = ob->nlastrips.first; strip; strip = strip->next) {
float length, actlength, repeat;
- if (strip->flag & ACTSTRIP_USESTRIDE)
+ if (strip->flag & ACTSTRIP_USESTRIDE) {
repeat = 1.0f;
- else
+ }
+ else {
repeat = strip->repeat;
+ }
length = strip->end - strip->start;
- if (length == 0.0f)
+ if (length == 0.0f) {
length = 1.0f;
+ }
actlength = strip->actend - strip->actstart;
strip->scale = length / (repeat * actlength);
- if (strip->scale == 0.0f)
+ if (strip->scale == 0.0f) {
strip->scale = 1.0f;
+ }
}
if (ob->soft) {
ob->soft->inpush = ob->soft->inspring;
@@ -2363,8 +2462,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
SEQ_BEGIN (sce->ed, seq) {
- if (seq->blend_mode == 0)
+ if (seq->blend_mode == 0) {
seq->blend_opacity = 100.0f;
+ }
}
SEQ_END;
}
@@ -2425,8 +2525,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile < 246 || (bmain->versionfile == 246 && bmain->subversionfile < 1)) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pd && (ob->pd->forcefield == PFIELD_WIND))
+ if (ob->pd && (ob->pd->forcefield == PFIELD_WIND)) {
ob->pd->f_noise = 0.0f;
+ }
}
}
@@ -2502,8 +2603,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile < 249 && bmain->subversionfile < 1) {
Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->pd)
+ if (ob->pd) {
ob->pd->seed = ((uint)(ceil(PIL_check_seconds_timer())) + 1) % 128;
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index bf88eddc145..91611fe8c74 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -113,6 +113,15 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme)
FROM_DEFAULT_V4_UCHAR(space_info.info_info);
}
+ /**
+ * Include next version bump.
+ */
+ {
+ if (btheme->space_view3d.obcenter_dia == 0) {
+ btheme->space_view3d.obcenter_dia = U_theme_default.space_view3d.obcenter_dia;
+ }
+ }
+
#undef FROM_DEFAULT_V4_UCHAR
#undef USER_VERSION_ATLEAST
@@ -157,14 +166,16 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(bmain, ver, subver)
/* the UserDef struct is not corrected with do_versions() .... ugh! */
- if (userdef->wheellinescroll == 0)
+ if (userdef->wheellinescroll == 0) {
userdef->wheellinescroll = 3;
+ }
if (userdef->menuthreshold1 == 0) {
userdef->menuthreshold1 = 5;
userdef->menuthreshold2 = 2;
}
- if (userdef->mixbufsize == 0)
+ if (userdef->mixbufsize == 0) {
userdef->mixbufsize = 2048;
+ }
if (userdef->autokey_mode == 0) {
/* 'add/replace' but not on */
userdef->autokey_mode = 2;
@@ -177,8 +188,9 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
userdef->gizmo_size = 75;
userdef->gizmo_flag |= USER_GIZMO_DRAW;
}
- if (userdef->pad_rot_angle == 0.0f)
+ if (userdef->pad_rot_angle == 0.0f) {
userdef->pad_rot_angle = 15.0f;
+ }
/* graph editor - unselected F-Curve visibility */
if (userdef->fcu_inactive_alpha == 0) {
@@ -197,18 +209,18 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
/* added seam, normal color, undo */
if (!USER_VERSION_ATLEAST(235, 0)) {
userdef->uiflag |= USER_GLOBALUNDO;
- if (userdef->undosteps == 0)
+ if (userdef->undosteps == 0) {
userdef->undosteps = 32;
+ }
}
if (!USER_VERSION_ATLEAST(236, 0)) {
/* illegal combo... */
- if (userdef->flag & USER_LMOUSESELECT)
+ if (userdef->flag & USER_LMOUSESELECT) {
userdef->flag &= ~USER_TWOBUTTONMOUSE;
+ }
}
if (!USER_VERSION_ATLEAST(240, 0)) {
userdef->uiflag |= USER_PLAINMENUS;
- if (userdef->obcenter_dia == 0)
- userdef->obcenter_dia = 6;
}
if (!USER_VERSION_ATLEAST(242, 0)) {
/* set defaults for 3D View rotating axis indicator */
@@ -221,12 +233,14 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
}
if (!USER_VERSION_ATLEAST(244, 0)) {
/* set default number of recently-used files (if not set) */
- if (userdef->recent_files == 0)
+ if (userdef->recent_files == 0) {
userdef->recent_files = 10;
+ }
}
if (!USER_VERSION_ATLEAST(245, 3)) {
- if (userdef->coba_weight.tot == 0)
+ if (userdef->coba_weight.tot == 0) {
BKE_colorband_init(&userdef->coba_weight, true);
+ }
}
if (!USER_VERSION_ATLEAST(245, 3)) {
userdef->flag |= USER_ADD_VIEWALIGNED | USER_ADD_EDITMODE;
@@ -242,56 +256,76 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
if (!USER_VERSION_ATLEAST(250, 3)) {
/* new audio system */
- if (userdef->audiochannels == 0)
+ if (userdef->audiochannels == 0) {
userdef->audiochannels = 2;
- if (userdef->audioformat == 0)
+ }
+ if (userdef->audioformat == 0) {
userdef->audioformat = 0x24;
- if (userdef->audiorate == 0)
+ }
+ if (userdef->audiorate == 0) {
userdef->audiorate = 48000;
+ }
}
if (!USER_VERSION_ATLEAST(250, 8)) {
wmKeyMap *km;
for (km = userdef->user_keymaps.first; km; km = km->next) {
- if (STREQ(km->idname, "Armature_Sketch"))
+ if (STREQ(km->idname, "Armature_Sketch")) {
strcpy(km->idname, "Armature Sketch");
- else if (STREQ(km->idname, "View3D"))
+ }
+ else if (STREQ(km->idname, "View3D")) {
strcpy(km->idname, "3D View");
- else if (STREQ(km->idname, "View3D Generic"))
+ }
+ else if (STREQ(km->idname, "View3D Generic")) {
strcpy(km->idname, "3D View Generic");
- else if (STREQ(km->idname, "EditMesh"))
+ }
+ else if (STREQ(km->idname, "EditMesh")) {
strcpy(km->idname, "Mesh");
- else if (STREQ(km->idname, "UVEdit"))
+ }
+ else if (STREQ(km->idname, "UVEdit")) {
strcpy(km->idname, "UV Editor");
- else if (STREQ(km->idname, "Animation_Channels"))
+ }
+ else if (STREQ(km->idname, "Animation_Channels")) {
strcpy(km->idname, "Animation Channels");
- else if (STREQ(km->idname, "GraphEdit Keys"))
+ }
+ else if (STREQ(km->idname, "GraphEdit Keys")) {
strcpy(km->idname, "Graph Editor");
- else if (STREQ(km->idname, "GraphEdit Generic"))
+ }
+ else if (STREQ(km->idname, "GraphEdit Generic")) {
strcpy(km->idname, "Graph Editor Generic");
- else if (STREQ(km->idname, "Action_Keys"))
+ }
+ else if (STREQ(km->idname, "Action_Keys")) {
strcpy(km->idname, "Dopesheet");
- else if (STREQ(km->idname, "NLA Data"))
+ }
+ else if (STREQ(km->idname, "NLA Data")) {
strcpy(km->idname, "NLA Editor");
- else if (STREQ(km->idname, "Node Generic"))
+ }
+ else if (STREQ(km->idname, "Node Generic")) {
strcpy(km->idname, "Node Editor");
- else if (STREQ(km->idname, "Logic Generic"))
+ }
+ else if (STREQ(km->idname, "Logic Generic")) {
strcpy(km->idname, "Logic Editor");
- else if (STREQ(km->idname, "File"))
+ }
+ else if (STREQ(km->idname, "File")) {
strcpy(km->idname, "File Browser");
- else if (STREQ(km->idname, "FileMain"))
+ }
+ else if (STREQ(km->idname, "FileMain")) {
strcpy(km->idname, "File Browser Main");
- else if (STREQ(km->idname, "FileButtons"))
+ }
+ else if (STREQ(km->idname, "FileButtons")) {
strcpy(km->idname, "File Browser Buttons");
- else if (STREQ(km->idname, "Buttons Generic"))
+ }
+ else if (STREQ(km->idname, "Buttons Generic")) {
strcpy(km->idname, "Property Editor");
+ }
}
}
if (!USER_VERSION_ATLEAST(252, 3)) {
- if (userdef->flag & USER_LMOUSESELECT)
+ if (userdef->flag & USER_LMOUSESELECT) {
userdef->flag &= ~USER_TWOBUTTONMOUSE;
+ }
}
if (!USER_VERSION_ATLEAST(252, 4)) {
/* default new handle type is auto handles */
@@ -308,8 +342,9 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
/* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead
* was changed in 260 as part of GSoC11, but version patch was wrong
*/
- if (userdef->keyhandles_new == HD_AUTO)
+ if (userdef->keyhandles_new == HD_AUTO) {
userdef->keyhandles_new = HD_AUTO_ANIM;
+ }
/* enable (Cycles) addon by default */
BKE_addon_ensure(&userdef->addons, "cycles");
@@ -331,10 +366,12 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
if (userdef->v2d_min_gridsize == 0) {
userdef->v2d_min_gridsize = 35;
}
- if (userdef->widget_unit == 0)
+ if (userdef->widget_unit == 0) {
userdef->widget_unit = 20;
- if (userdef->anisotropic_filter <= 0)
+ }
+ if (userdef->anisotropic_filter <= 0) {
userdef->anisotropic_filter = 1;
+ }
if (userdef->ndof_sensitivity == 0.0f) {
userdef->ndof_sensitivity = 1.0f;
@@ -345,11 +382,13 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
if (userdef->ndof_orbit_sensitivity == 0.0f) {
userdef->ndof_orbit_sensitivity = userdef->ndof_sensitivity;
- if (!(userdef->flag & USER_TRACKBALL))
+ if (!(userdef->flag & USER_TRACKBALL)) {
userdef->ndof_flag |= NDOF_TURNTABLE;
+ }
}
- if (userdef->tweak_threshold == 0)
+ if (userdef->tweak_threshold == 0) {
userdef->tweak_threshold = 10;
+ }
}
/* NOTE!! from now on use userdef->versionfile and userdef->subversionfile */
@@ -491,18 +530,32 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
userdef->move_threshold = 2;
}
+ if (!USER_VERSION_ATLEAST(280, 58)) {
+ if (userdef->image_draw_method != IMAGE_DRAW_METHOD_GLSL) {
+ userdef->image_draw_method = IMAGE_DRAW_METHOD_AUTO;
+ }
+ }
+
+ /* patch to set Dupli Lightprobes and Grease Pencil */
+ if (!USER_VERSION_ATLEAST(280, 58)) {
+ userdef->dupflag |= USER_DUP_LIGHTPROBE;
+ userdef->dupflag |= USER_DUP_GPENCIL;
+ }
+
/**
* Include next version bump.
*/
{
/* (keep this block even if it becomes empty). */
+ if (userdef->vbotimeout == 0) {
+ userdef->vbocollectrate = 60;
+ userdef->vbotimeout = 120;
+ }
}
- if (userdef->pixelsize == 0.0f)
+ if (userdef->pixelsize == 0.0f) {
userdef->pixelsize = 1.0f;
-
- if (userdef->image_draw_method == 0)
- userdef->image_draw_method = IMAGE_DRAW_METHOD_2DTEXTURE;
+ }
for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
do_versions_theme(userdef, btheme);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 79cd7678f90..9a4e2adc0e3 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -167,10 +167,6 @@
#include "BKE_subsurf.h"
#include "BKE_workspace.h"
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-# include "NOD_socket.h" /* for sock->default_value data */
-#endif
-
#include "BLO_blend_defs.h"
#include "BLO_blend_validate.h"
#include "BLO_readfile.h"
@@ -958,32 +954,8 @@ static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
write_curvemapping_curves(wd, cumap);
}
-static void write_node_socket(WriteData *wd,
- bNodeTree *UNUSED(ntree),
- bNode *node,
- bNodeSocket *sock)
+static void write_node_socket(WriteData *wd, bNodeSocket *sock)
{
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* forward compatibility code, so older blenders still open (not for undo) */
- if (wd->use_memfile == false) {
- sock->stack_type = 1;
-
- if (node->type == NODE_GROUP) {
- bNodeTree *ngroup = (bNodeTree *)node->id;
- if (ngroup) {
- /* for node groups: look up the deprecated groupsock pointer */
- sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier);
- BLI_assert(sock->groupsock != NULL);
-
- /* node group sockets now use the generic identifier string to verify group nodes,
- * old blender uses the own_index.
- */
- sock->own_index = sock->groupsock->own_index;
- }
- }
- }
-#endif
-
/* actual socket writing */
writestruct(wd, DATA, bNodeSocket, 1, sock);
@@ -995,18 +967,8 @@ static void write_node_socket(WriteData *wd,
writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value);
}
}
-static void write_node_socket_interface(WriteData *wd, bNodeTree *UNUSED(ntree), bNodeSocket *sock)
+static void write_node_socket_interface(WriteData *wd, bNodeSocket *sock)
{
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* forward compatibility code, so older blenders still open */
- sock->stack_type = 1;
-
- /* Reconstruct the deprecated default_value structs in socket interface DNA. */
- if (sock->default_value == NULL && sock->typeinfo) {
- node_socket_init_default_value(sock);
- }
-#endif
-
/* actual socket writing */
writestruct(wd, DATA, bNodeSocket, 1, sock);
@@ -1039,10 +1001,10 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
}
for (sock = node->inputs.first; sock; sock = sock->next) {
- write_node_socket(wd, ntree, node, sock);
+ write_node_socket(wd, sock);
}
for (sock = node->outputs.first; sock; sock = sock->next) {
- write_node_socket(wd, ntree, node, sock);
+ write_node_socket(wd, sock);
}
for (link = node->internal_links.first; link; link = link->next) {
@@ -1126,10 +1088,10 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree)
}
for (sock = ntree->inputs.first; sock; sock = sock->next) {
- write_node_socket_interface(wd, ntree, sock);
+ write_node_socket_interface(wd, sock);
}
for (sock = ntree->outputs.first; sock; sock = sock->next) {
- write_node_socket_interface(wd, ntree, sock);
+ write_node_socket_interface(wd, sock);
}
}
@@ -2175,10 +2137,10 @@ static void write_mesh(WriteData *wd, Mesh *mesh)
/**
* Those calls:
- * - Reduce mesh->xdata.totlayer to number of layers to write.
- * - Fill xlayers with those layers to be written.
- * Note that mesh->xdata is from now on invalid for Blender, but this is why the whole mesh is
- * a temp local copy!
+ * - Reduce mesh->xdata.totlayer to number of layers to write.
+ * - Fill xlayers with those layers to be written.
+ * Note that mesh->xdata is from now on invalid for Blender,
+ * but this is why the whole mesh is a temp local copy!
*/
CustomData_file_write_prepare(
&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
@@ -2776,8 +2738,9 @@ static void write_region(WriteData *wd, ARegion *ar, int spacetype)
writestruct(wd, DATA, BoundBox, 1, rv3d->clipbb);
}
}
- else
+ else {
printf("regiondata write missing!\n");
+ }
break;
default:
printf("regiondata write missing!\n");
@@ -3162,76 +3125,6 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree)
}
}
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
-static void customnodes_add_deprecated_data(Main *mainvar)
-{
- FOREACH_NODETREE_BEGIN (mainvar, ntree, id) {
- bNodeLink *link, *last_link = ntree->links.last;
-
- /* only do this for node groups */
- if (id != &ntree->id) {
- continue;
- }
-
- /* Forward compatibility for group nodes: add links to node tree interface sockets.
- * These links are invalid by new rules (missing node pointer)!
- * They will be removed again in customnodes_free_deprecated_data,
- * cannot do this directly lest bNodeLink pointer mapping becomes ambiguous.
- * When loading files with such links in a new Blender version
- * they will be removed as well.
- */
- for (link = ntree->links.first; link; link = link->next) {
- bNode *fromnode = link->fromnode, *tonode = link->tonode;
- bNodeSocket *fromsock = link->fromsock, *tosock = link->tosock;
-
- /* check both sides of the link, to handle direct input-to-output links */
- if (fromnode->type == NODE_GROUP_INPUT) {
- fromnode = NULL;
- fromsock = ntreeFindSocketInterface(ntree, SOCK_IN, fromsock->identifier);
- }
- /* only the active output node defines links */
- if (tonode->type == NODE_GROUP_OUTPUT && (tonode->flag & NODE_DO_OUTPUT)) {
- tonode = NULL;
- tosock = ntreeFindSocketInterface(ntree, SOCK_OUT, tosock->identifier);
- }
-
- if (!fromnode || !tonode) {
- /* Note: not using nodeAddLink here, it asserts existing node pointers */
- bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "group node link");
- tlink->fromnode = fromnode;
- tlink->fromsock = fromsock;
- tlink->tonode = tonode;
- tlink->tosock = tosock;
- tosock->link = tlink;
- tlink->flag |= NODE_LINK_VALID;
- BLI_addtail(&ntree->links, tlink);
- }
-
- /* don't check newly created compatibility links */
- if (link == last_link) {
- break;
- }
- }
- }
- FOREACH_NODETREE_END;
-}
-
-static void customnodes_free_deprecated_data(Main *mainvar)
-{
- FOREACH_NODETREE_BEGIN (mainvar, ntree, id) {
- bNodeLink *link, *next_link;
-
- for (link = ntree->links.first; link; link = next_link) {
- next_link = link->next;
- if (link->fromnode == NULL || link->tonode == NULL) {
- nodeRemLink(ntree, link);
- }
- }
- }
- FOREACH_NODETREE_END;
-}
-#endif
-
static void write_brush(WriteData *wd, Brush *brush)
{
if (brush->id.us > 0 || wd->use_memfile) {
@@ -3740,9 +3633,10 @@ static void write_libraries(WriteData *wd, Main *main)
}
}
- /* to be able to restore quit.blend and temp saves, the packed blend has to be in undo buffers... */
- /* XXX needs rethink, just like save UI in undo files now - would be nice to append things only for the]
- * quit.blend and temp saves */
+ /* To be able to restore 'quit.blend' and temp saves,
+ * the packed blend has to be in undo buffers... */
+ /* XXX needs rethink, just like save UI in undo files now -
+ * would be nice to append things only for the 'quit.blend' and temp saves. */
if (found_one) {
/* Not overridable. */
@@ -3865,14 +3759,6 @@ static bool write_file_handle(Main *mainvar,
wd = mywrite_begin(ww, compare, current);
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* don't write compatibility data on undo */
- if (!current) {
- /* deprecated forward compat data is freed again below */
- customnodes_add_deprecated_data(mainvar);
- }
-#endif
-
sprintf(buf,
"BLENDER%c%c%.3d",
(sizeof(void *) == 8) ? '-' : '_',
@@ -3893,7 +3779,8 @@ static bool write_file_handle(Main *mainvar,
NULL :
BKE_override_static_operations_store_initialize();
- /* This outer loop allows to save first datablocks from real mainvar, then the temp ones from override process,
+ /* This outer loop allows to save first datablocks from real mainvar,
+ * then the temp ones from override process,
* if needed, without duplicating whole code. */
Main *bmain = mainvar;
do {
@@ -3907,7 +3794,8 @@ static bool write_file_handle(Main *mainvar,
}
for (; id; id = id->next) {
- /* We should never attempt to write non-regular IDs (i.e. all kind of temp/runtime ones). */
+ /* We should never attempt to write non-regular IDs
+ * (i.e. all kind of temp/runtime ones). */
BLI_assert(
(id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0);
@@ -4063,17 +3951,6 @@ static bool write_file_handle(Main *mainvar,
* so writing each time uses the same address and doesn't cause unnecessary undo overhead. */
writedata(wd, DNA1, wd->sdna->data_len, wd->sdna->data);
-#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* compatibility data not created on undo */
- if (!current) {
- /* Ugly, forward compatibility code generates deprecated data during writing,
- * this has to be freed again. Can not be done directly after writing, otherwise
- * the data pointers could be reused and not be mapped correctly.
- */
- customnodes_free_deprecated_data(mainvar);
- }
-#endif
-
/* end of file */
memset(&bhead, 0, sizeof(BHead));
bhead.code = ENDB;
diff --git a/source/blender/blentranslation/BLT_lang.h b/source/blender/blentranslation/BLT_lang.h
index 544f2701258..6ce9a0ba71c 100644
--- a/source/blender/blentranslation/BLT_lang.h
+++ b/source/blender/blentranslation/BLT_lang.h
@@ -42,8 +42,8 @@ void BLT_lang_set(const char *);
/* Get the current locale ([partial] ISO code, e.g. es_ES). */
const char *BLT_lang_get(void);
-/* Get locale's elements (if relevant pointer is not NULL and element actually exists, e.g. if there is no variant,
- * *variant and *language_variant will always be NULL).
+/* Get locale's elements (if relevant pointer is not NULL and element actually exists, e.g.
+ * if there is no variant, *variant and *language_variant will always be NULL).
* Non-null elements are always MEM_mallocN'ed, it's the caller's responsibility to free them.
* NOTE: Always available, even in non-WITH_INTERNATIONAL builds.
*/
diff --git a/source/blender/blentranslation/BLT_translation.h b/source/blender/blentranslation/BLT_translation.h
index 5fdae83951c..c3667c364bc 100644
--- a/source/blender/blentranslation/BLT_translation.h
+++ b/source/blender/blentranslation/BLT_translation.h
@@ -86,11 +86,11 @@ bool BLT_lang_is_ime_supported(void);
/* Default, void context.
* WARNING! The "" context is not the same as no (NULL) context at mo/boost::locale level!
- * NOTE: We translate BLT_I18NCONTEXT_DEFAULT as BLT_I18NCONTEXT_DEFAULT_BPY in Python, as we can't use "natural"
- * None value in rna string properties... :/
+ * NOTE: We translate BLT_I18NCONTEXT_DEFAULT as BLT_I18NCONTEXT_DEFAULT_BPY in Python,
+ * as we can't use "natural" None value in rna string properties... :/
* The void string "" is also interpreted as BLT_I18NCONTEXT_DEFAULT.
- * For perf reason, we only use the first char to detect this context, so other contexts should never start
- * with the same char!
+ * For perf reason, we only use the first char to detect this context,
+ * so other contexts should never start with the same char!
*/
#define BLT_I18NCONTEXT_DEFAULT NULL
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA "*"
@@ -102,7 +102,8 @@ bool BLT_lang_is_ime_supported(void);
* easy to get collisions with other areas...). */
#define BLT_I18NCONTEXT_UI_EVENTS "UI_Events_KeyMaps"
-/* Mark the msgid applies to several elements (needed in some cases, as english adjectives have no plural mark :( ). */
+/* Mark the msgid applies to several elements
+ * (needed in some cases, as english adjectives have no plural mark :( ). */
#define BLT_I18NCONTEXT_PLURAL "Plural"
/* ID-types contexts. */
diff --git a/source/blender/blentranslation/intern/blt_lang.c b/source/blender/blentranslation/intern/blt_lang.c
index e8955235198..75a4681deb2 100644
--- a/source/blender/blentranslation/intern/blt_lang.c
+++ b/source/blender/blentranslation/intern/blt_lang.c
@@ -108,8 +108,9 @@ static void fill_locales(void)
continue; /* Comment or void... */
}
t = atoi(str);
- if (t >= num_locales)
+ if (t >= num_locales) {
num_locales = t + 1;
+ }
num_locales_menu++;
line = line->next;
}
@@ -118,7 +119,8 @@ static void fill_locales(void)
/* And now, build locales and locale_menu! */
locales_menu = MEM_callocN(num_locales_menu * sizeof(EnumPropertyItem), __func__);
line = lines;
- /* Do not allocate locales with zero-sized mem, as LOCALE macro uses NULL locales as invalid marker! */
+ /* Do not allocate locales with zero-sized mem,
+ * as LOCALE macro uses NULL locales as invalid marker! */
if (num_locales > 0) {
locales = MEM_callocN(num_locales * sizeof(char *), __func__);
while (line) {
@@ -155,7 +157,8 @@ static void fill_locales(void)
/* The DEFAULT/Automatic item... */
if (BLI_strnlen(loc, 2)) {
locales[id] = "";
- /* Keep this tip in sync with the one in rna_userdef (rna_enum_language_default_items). */
+ /* Keep this tip in sync with the one in rna_userdef
+ * (rna_enum_language_default_items). */
locales_menu[idx].description = BLI_strdup(
"Automatically choose system's defined language "
"if available, or fall-back to English");
@@ -259,8 +262,9 @@ void BLT_lang_set(const char *str)
const char *short_locale = str ? str : LOCALE(ulang);
const char *short_locale_utf8 = NULL;
- if ((U.transopts & USER_DOTRANSLATE) == 0)
+ if ((U.transopts & USER_DOTRANSLATE) == 0) {
return;
+ }
/* We want to avoid locales like '.UTF-8'! */
if (short_locale[0]) {
@@ -307,10 +311,12 @@ const char *BLT_lang_get(void)
#undef LOCALE
#undef ULANGUAGE
-/* Get locale's elements (if relevant pointer is not NULL and element actually exists, e.g. if there is no variant,
+/* Get locale's elements (if relevant pointer is not NULL and element actually exists, e.g.
+ * if there is no variant,
* *variant and *language_variant will always be NULL).
* Non-null elements are always MEM_mallocN'ed, it's the caller's responsibility to free them.
- * NOTE: Keep that one always available, you never know, may become useful even in no-WITH_INTERNATIONAL context...
+ * NOTE: Keep that one always available, you never know,
+ * may become useful even in no-WITH_INTERNATIONAL context...
*/
void BLT_lang_locale_explode(const char *locale,
char **language,
@@ -327,36 +333,45 @@ void BLT_lang_locale_explode(const char *locale,
if (language || language_variant) {
if (m1 || m2) {
_t = m1 ? BLI_strdupn(locale, m1 - locale) : BLI_strdupn(locale, m2 - locale);
- if (language)
+ if (language) {
*language = _t;
+ }
}
else if (language) {
*language = BLI_strdup(locale);
}
}
if (country) {
- if (m1)
+ if (m1) {
*country = m2 ? BLI_strdupn(m1 + 1, m2 - (m1 + 1)) : BLI_strdup(m1 + 1);
- else
+ }
+ else {
*country = NULL;
+ }
}
if (variant) {
- if (m2)
+ if (m2) {
*variant = BLI_strdup(m2 + 1);
- else
+ }
+ else {
*variant = NULL;
+ }
}
if (language_country) {
- if (m1)
+ if (m1) {
*language_country = m2 ? BLI_strdupn(locale, m2 - locale) : BLI_strdup(locale);
- else
+ }
+ else {
*language_country = NULL;
+ }
}
if (language_variant) {
- if (m2)
+ if (m2) {
*language_variant = m1 ? BLI_strdupcat(_t, m2) : BLI_strdup(locale);
- else
+ }
+ else {
*language_variant = NULL;
+ }
}
if (_t && !language) {
MEM_freeN(_t);
diff --git a/source/blender/blentranslation/intern/blt_translation.c b/source/blender/blentranslation/intern/blt_translation.c
index a4bac6bc01f..64e14522aca 100644
--- a/source/blender/blentranslation/intern/blt_translation.c
+++ b/source/blender/blentranslation/intern/blt_translation.c
@@ -61,8 +61,8 @@ const char *BLT_pgettext(const char *msgctxt, const char *msgid)
msgctxt = BLT_I18NCONTEXT_DEFAULT;
}
ret = bl_locale_pgettext(msgctxt, msgid);
- /* We assume if the returned string is the same (memory level) as the msgid, no translation was found,
- * and we can try py scripts' ones!
+ /* We assume if the returned string is the same (memory level) as the msgid,
+ * no translation was found, and we can try py scripts' ones!
*/
# ifdef WITH_PYTHON
if (ret == msgid) {
diff --git a/source/blender/blentranslation/msgfmt/msgfmt.c b/source/blender/blentranslation/msgfmt/msgfmt.c
index 6beaef74a9f..500ae2df4b5 100644
--- a/source/blender/blentranslation/msgfmt/msgfmt.c
+++ b/source/blender/blentranslation/msgfmt/msgfmt.c
@@ -24,8 +24,10 @@
*
* Generate binary message catalog from textual translation description.
*
- * This program converts a textual Uniforum-style message catalog (.po file) into a binary GNU catalog (.mo file).
- * This is essentially the same function as the GNU msgfmt program, however, it is a simpler implementation.
+ * This program converts a textual Uniforum-style message catalog (.po file)
+ * into a binary GNU catalog (.mo file).
+ * This is essentially the same function as the GNU msgfmt program,
+ * however, it is a simpler implementation.
*
* Usage: msgfmt input.po output.po
*/
@@ -80,12 +82,15 @@ static char *trim(char *str)
return str;
}
- for (i = 0; i < len && ELEM(str[0], ' ', '\t', '\n'); str++, i++)
- ;
+ for (i = 0; i < len && ELEM(str[0], ' ', '\t', '\n'); str++, i++) {
+ /* pass */
+ }
char *end = &str[len - 1 - i];
- for (i = len; i > 0 && ELEM(end[0], ' ', '\t', '\n'); end--, i--)
- ;
+ for (i = len; i > 0 && ELEM(end[0], ' ', '\t', '\n'); end--, i--) {
+ /* pass */
+ }
+
end[1] = '\0';
return str;
@@ -206,7 +211,8 @@ static char *generate(GHash *messages, size_t *r_output_size)
tot_vals_len += off->val_len + 1;
}
- /* The header is 7 32-bit unsigned integers. then comes the keys index table, then the values index table. */
+ /* The header is 7 32-bit unsigned integers.
+ * Then comes the keys index table, then the values index table. */
const uint32_t idx_keystart = 7 * 4;
const uint32_t idx_valstart = idx_keystart + 8 * num_keys;
/* We don't use hash tables, so the keys start right after the index tables. */
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index 4ba9d13c8a0..f5095ca2b5f 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -24,9 +24,9 @@ set(INC
../blenlib
../blentranslation
../makesdna
- ../../../intern/guardedalloc
../../../intern/atomic
../../../intern/eigen
+ ../../../intern/guardedalloc
../../../extern/rangetree
)
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h
index dce6b8b79ec..b7356a89314 100644
--- a/source/blender/bmesh/bmesh.h
+++ b/source/blender/bmesh/bmesh.h
@@ -22,7 +22,8 @@
*
* \addtogroup bmesh BMesh
*
- * \brief BMesh is a non-manifold boundary representation designed to support advanced editing operations.
+ * \brief BMesh is a non-manifold boundary representation
+ * designed to support advanced editing operations.
* \section bm_structure The Structure
*
* BMesh stores topology in four main element structures:
@@ -32,7 +33,8 @@
* - Edges - BMEdge
* - Verts - BMVert
* \subsection bm_header_flags Header Flags
- * Each element (vertex/edge/face/loop) in a mesh has an associated bit-field called "header flags".
+ * Each element (vertex/edge/face/loop)
+ * in a mesh has an associated bit-field called "header flags".
*
* BMHeader flags should **never** be read or written to by bmesh operators (see Operators below).
*
@@ -81,7 +83,8 @@
* See source/blender/bmesh/bmesh_query.h for more misc. queries.
* \section bm_api The BMesh API
*
- * One of the goals of the BMesh API is to make it easy and natural to produce highly maintainable code.
+ * One of the goals of the BMesh API is to make it easy
+ * and natural to produce highly maintainable code.
* Code duplication, etc are avoided where possible.
* \subsection bm_iter_api Iterator API
*
@@ -95,15 +98,18 @@
* though a mechanism for plugging in new walkers needs to be added at some point.
*
* Most topological queries should go through these two APIs;
- * there are additional functions you can use for topological iteration, but their meant for internal bmesh code.
+ * there are additional functions you can use for topological iteration,
+ * but their meant for internal bmesh code.
*
- * Note that the walker API supports delimiter flags, to allow the caller to flag elements not to walk past.
+ * Note that the walker API supports delimiter flags,
+ * to allow the caller to flag elements not to walk past.
* \subsection bm_ops Operators
*
* Operators are an integral part of BMesh. Unlike regular blender operators,
* BMesh operators **bmo's** are designed to be nested (e.g. call other operators).
*
- * Each operator has a number of input/output "slots" which are used to pass settings & data into/out of the operator
+ * Each operator has a number of input/output "slots"
+ * which are used to pass settings & data into/out of the operator
* (and allows for chaining operators together).
*
* These slots are identified by name, using strings.
@@ -111,7 +117,8 @@
* Access to slots is done with ``BMO_slot_***()`` functions.
* \subsection bm_tool_flags Tool Flags
*
- * The BMesh API provides a set of flags for faces, edges and vertices, which are private to an operator.
+ * The BMesh API provides a set of flags for faces, edges and vertices,
+ * which are private to an operator.
* These flags may be used by the client operator code as needed
* (a common example is flagging elements for use in another operator).
* Each call to an operator allocates it's own set of tool flags when it's executed,
@@ -140,7 +147,8 @@
* - map - BMO_OP_SLOT_MAPPING - simple hash map.
* \subsection bm_slot_iter Slot Iterators
*
- * Access to element buffers or maps must go through the slot iterator api, defined in bmesh_operators.h.
+ * Access to element buffers or maps must go through the slot iterator api,
+ * defined in bmesh_operators.h.
* Use #BMO_ITER where ever possible.
* \subsection bm_elem_buf Element Buffers
*
@@ -149,14 +157,16 @@
* Many operators take in a buffer of elements, process it,
* then spit out a new one; this allows operators to be chained together.
*
- * \note Element buffers may have elements of different types within the same buffer (this is supported by the API.
+ * \note Element buffers may have elements of different types within the same buffer
+ * (this is supported by the API.
* \section bm_fname Function Naming Conventions
*
* These conventions should be used throughout the bmesh module.
*
* - ``bmesh_kernel_*()`` - Low level API, for primitive functions that others are built ontop of.
* - ``bmesh_***()`` - Low level API function.
- * - ``bm_***()`` - 'static' functions, not apart of the API at all, but use prefix since they operate on BMesh data.
+ * - ``bm_***()`` - 'static' functions, not apart of the API at all,
+ * but use prefix since they operate on BMesh data.
* - ``BM_***()`` - High level BMesh API function for use anywhere.
* - ``BMO_***()`` - High level operator API function for use anywhere.
* - ``bmo_***()`` - Low level / internal operator API functions.
@@ -168,11 +178,14 @@
*
* \subsection bm_todo_optimize Optimizations
*
- * - skip normal calc when its not needed (when calling chain of operators & for modifiers, flag as dirty)
- * - skip BMO flag allocation, its not needed in many cases, this is fairly redundant to calc by default.
- * - ability to call BMO's with option not to create return data (will save some time)
- * - binary diff UNDO, currently this uses huge amount of ram when all shapes are stored for each undo step for eg.
- * - use two different iterator types for BMO map/buffer types.
+ * - Skip normal calc when its not needed
+ * (when calling chain of operators & for modifiers, flag as dirty)
+ * - Skip BMO flag allocation, its not needed in many cases,
+ * this is fairly redundant to calc by default.
+ * - Ability to call BMO's with option not to create return data (will save some time)
+ * - Binary diff UNDO, currently this uses huge amount of ram
+ * when all shapes are stored for each undo step for eg.
+ * - Use two different iterator types for BMO map/buffer types.
*/
#ifdef __cplusplus
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 220a5b3a5f5..8349dee06e2 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -23,7 +23,8 @@
/* bmesh data structures */
-/* dissable holes for now, these are ifdef'd because they use more memory and cant be saved in DNA currently */
+/* dissable holes for now,
+ * these are ifdef'd because they use more memory and cant be saved in DNA currently */
// #define USE_BMESH_HOLES
struct BMEdge;
@@ -58,23 +59,32 @@ struct BLI_mempool;
* 4: some elements for internal record keeping.
*/
typedef struct BMHeader {
- void *data; /* customdata layers */
- int index; /* notes:
- * - Use BM_elem_index_get/set macros for index
- * - Uninitialized to -1 so we can easily tell its not set.
- * - Used for edge/vert/face/loop, check BMesh.elem_index_dirty for valid index values,
- * this is abused by various tools which set it dirty.
- * - For loops this is used for sorting during tessellation. */
-
- char htype; /* element geometric type (verts/edges/loops/faces) */
- char hflag; /* this would be a CD layer, see below */
-
- /* internal use only!
- * note,.we are very picky about not bloating this struct
+ /** Customdata layers. */
+ void *data;
+
+ /**
+ * \note
+ * - Use BM_elem_index_get/set macros for index
+ * - Uninitialized to -1 so we can easily tell its not set.
+ * - Used for edge/vert/face/loop, check BMesh.elem_index_dirty for valid index values,
+ * this is abused by various tools which set it dirty.
+ * - For loops this is used for sorting during tessellation.
+ */
+ int index;
+
+ /** Element geometric type (verts/edges/loops/faces). */
+ char htype;
+ /** This would be a CD layer, see below. */
+ char hflag;
+
+ /**
+ * Internal use only!
+ * \note We are very picky about not bloating this struct
* but in this case its padded up to 16 bytes anyway,
- * so adding a flag here gives no increase in size */
+ * so adding a flag here gives no increase in size.
+ */
char api_flag;
- // char _pad;
+ // char _pad;
} BMHeader;
BLI_STATIC_ASSERT((sizeof(BMHeader) <= 16), "BMHeader size has grown!");
@@ -89,10 +99,12 @@ typedef struct BMVert {
float co[3]; /* vertex coordinates */
float no[3]; /* vertex normal */
- /* pointer to (any) edge using this vertex (for disk cycles)
+ /**
+ * Pointer to (any) edge using this vertex (for disk cycles).
*
- * note: some higher level functions set this to different edges that use this vertex,
- * which is a bit of an abuse of internal bmesh data but also works OK for now (use with care!).
+ * \note Some higher level functions set this to different edges that use this vertex,
+ * which is a bit of an abuse of internal bmesh data but also works OK for now
+ * (use with care!).
*/
struct BMEdge *e;
} BMVert;
@@ -116,8 +128,12 @@ typedef struct BMEdge {
* to access the other loops using the edge */
struct BMLoop *l;
- /* disk cycle pointers
- * relative data: d1 indicates indicates the next/prev edge around vertex v1 and d2 does the same for v2 */
+ /**
+ * Disk Cycle Pointers
+ *
+ * relative data: d1 indicates indicates the next/prev
+ * edge around vertex v1 and d2 does the same for v2.
+ */
BMDiskLink v1_disk_link, v2_disk_link;
} BMEdge;
@@ -272,7 +288,10 @@ typedef struct BMLoopNorEditData {
typedef struct BMLoopNorEditDataArray {
BMLoopNorEditData *lnor_editdata;
- /* This one has full amount of loops, used to map loop index to actual BMLoopNorEditData struct. */
+ /**
+ * This one has full amount of loops,
+ * used to map loop index to actual BMLoopNorEditData struct.
+ */
BMLoopNorEditData **lidx_to_lnor_editdata;
int cd_custom_normal_offset;
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 0528a550be4..224f6ad1e5c 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -124,7 +124,8 @@ BMFace *BM_face_create_quad_tri(BMesh *bm,
/**
* \brief copies face loop data from shared adjacent faces.
*
- * \param filter_fn: A function that filters the source loops before copying (don't always want to copy all)
+ * \param filter_fn: A function that filters the source loops before copying
+ * (don't always want to copy all).
*
* \note when a matching edge is found, both loops of that edge are copied
* this is done since the face may not be completely surrounded by faces,
@@ -436,12 +437,12 @@ void BM_verts_sort_radial_plane(BMVert **vert_arr, int len)
far_cross_dist = normalize_v3(far_cross_vec);
/* more of a weight then a distance */
- far_cross_dist = (/* first we want to have a value close to zero mapped to 1 */
- 1.0f - fabsf(dot_v3v3(far_vec, far_cross_vec)) *
-
- /* second we multiply by the distance
- * so points close to the center are not preferred */
- far_cross_dist);
+ far_cross_dist = (
+ /* First we want to have a value close to zero mapped to 1. */
+ 1.0f - fabsf(dot_v3v3(far_vec, far_cross_vec)) *
+ /* Second we multiply by the distance
+ * so points close to the center are not preferred. */
+ far_cross_dist);
if (far_cross_dist > far_cross_best || far_cross == NULL) {
far_cross = vert_arr[i]->co;
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 5dcf6acad57..6ece32e57e8 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -69,7 +69,7 @@ BMVert *BM_vert_create(BMesh *bm,
v->head.data = NULL;
#ifdef USE_DEBUG_INDEX_MEMCHECK
- DEBUG_MEMCHECK_INDEX_INVALIDATE(v)
+ DEBUG_MEMCHECK_INDEX_INVALIDATE(v);
#else
BM_elem_index_set(v, -1); /* set_ok_invalid */
#endif
@@ -140,7 +140,8 @@ BMVert *BM_vert_create(BMesh *bm,
* \brief Main function for creating a new edge.
*
* \note Duplicate edges are supported by the API however users should _never_ see them.
- * so unless you need a unique edge or know the edge won't exist, you should call with \a no_double = true
+ * so unless you need a unique edge or know the edge won't exist,
+ * you should call with \a no_double = true.
*/
BMEdge *BM_edge_create(
BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *e_example, const eBMCreateFlag create_flag)
@@ -162,7 +163,7 @@ BMEdge *BM_edge_create(
e->head.data = NULL;
#ifdef USE_DEBUG_INDEX_MEMCHECK
- DEBUG_MEMCHECK_INDEX_INVALIDATE(e)
+ DEBUG_MEMCHECK_INDEX_INVALIDATE(e);
#else
BM_elem_index_set(e, -1); /* set_ok_invalid */
#endif
@@ -237,7 +238,7 @@ static BMLoop *bm_loop_create(BMesh *bm,
l->head.data = NULL;
#ifdef USE_DEBUG_INDEX_MEMCHECK
- DEBUG_MEMCHECK_INDEX_INVALIDATE(l)
+ DEBUG_MEMCHECK_INDEX_INVALIDATE(l);
#else
BM_elem_index_set(l, -1); /* set_ok_invalid */
#endif
@@ -373,7 +374,7 @@ BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm)
/* --- assign all members --- */
f->head.data = NULL;
#ifdef USE_DEBUG_INDEX_MEMCHECK
- DEBUG_MEMCHECK_INDEX_INVALIDATE(f)
+ DEBUG_MEMCHECK_INDEX_INVALIDATE(f);
#else
BM_elem_index_set(f, -1); /* set_ok_invalid */
#endif
@@ -1417,8 +1418,9 @@ static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *f_example)
*
* \warning this is a low level function, most likely you want to use #BM_face_split()
*
- * Takes as input two vertices in a single face. An edge is created which divides the original face
- * into two distinct regions. One of the regions is assigned to the original face and it is closed off.
+ * Takes as input two vertices in a single face.
+ * An edge is created which divides the original face into two distinct regions.
+ * One of the regions is assigned to the original face and it is closed off.
* The second region has a new face assigned to it.
*
* \par Examples:
@@ -1573,7 +1575,7 @@ BMFace *bmesh_kernel_split_face_make_edge(BMesh *bm,
}
else {
/* this code is not significant until holes actually work */
- //printf("warning: call to split face euler without holes argument; holes will be tossed.\n");
+ // printf("warning: call to split face euler without holes argument; holes will be tossed.\n");
for (lst = f->loops.last; lst != f->loops.first; lst = lst2) {
lst2 = lst->prev;
BLI_mempool_free(bm->looplistpool, lst);
@@ -1715,7 +1717,7 @@ BMVert *bmesh_kernel_split_edge_make_vert(BMesh *bm, BMVert *tv, BMEdge *e, BMEd
/* verify loop->v and loop->next->v pointers for e */
for (i = 0, l = e->l; i < radlen; i++, l = l->radial_next) {
BMESH_ASSERT(l->e == e);
- //BMESH_ASSERT(l->radial_next == l);
+ // BMESH_ASSERT(l->radial_next == l);
BMESH_ASSERT(!(l->prev->e != e_new && l->next->e != e_new));
edok = BM_verts_in_edge(l->v, l->next->v, e);
@@ -1944,7 +1946,8 @@ BMEdge *bmesh_kernel_join_edge_kill_vert(BMesh *bm,
*
* Collapse an edge, merging surrounding data.
*
- * Unlike #BM_vert_collapse_edge & #bmesh_kernel_join_edge_kill_vert which only handle 2 valence verts,
+ * Unlike #BM_vert_collapse_edge & #bmesh_kernel_join_edge_kill_vert
+ * which only handle 2 valence verts,
* this can handle any number of connected edges/faces.
*
* <pre>
@@ -2065,8 +2068,8 @@ BMVert *bmesh_kernel_join_vert_kill_edge(BMesh *bm,
* before attempting to fuse \a f1 and \a f2.
*
* \note The order of arguments decides whether or not certain per-face attributes are present
- * in the resultant face. For instance vertex winding, material index, smooth flags, etc are inherited
- * from \a f1, not \a f2.
+ * in the resultant face. For instance vertex winding, material index, smooth flags,
+ * etc are inherited from \a f1, not \a f2.
*
* \return A BMFace pointer
*/
@@ -2413,7 +2416,8 @@ void bmesh_kernel_vert_separate(
*
* Takes a list of edges, which have been split from their original.
*
- * Any edges which failed to split off in #bmesh_kernel_vert_separate will be merged back into the original edge.
+ * Any edges which failed to split off in #bmesh_kernel_vert_separate
+ * will be merged back into the original edge.
*
* \param edges_separate:
* A list-of-lists, each list is from a single original edge (the first edge is the original),
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index a802515a3b2..2ca9c7e6340 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -264,7 +264,9 @@ static bool bm_loop_path_build_step(BLI_mempool *vs_pool,
BLI_mempool_free(vs_pool, vs);
}
- /* bm->elem_index_dirty |= BM_VERT; */ /* Commented because used in a loop, and this flag has already been set. */
+
+ /* Commented because used in a loop, and this flag has already been set. */
+ /* bm->elem_index_dirty |= BM_VERT; */
/* lb is now full of free'd items, overwrite */
*lb = lb_tmp;
@@ -750,8 +752,7 @@ void BM_edgeloop_expand(
LinkData *node_curr = el_store->verts.first;
int iter_prev = 0;
- BLI_FOREACH_SPARSE_RANGE(el_store->len, (el_store_len - el_store->len), iter)
- {
+ BLI_FOREACH_SPARSE_RANGE (el_store->len, (el_store_len - el_store->len), iter) {
while (iter_prev < iter) {
node_curr = node_curr->next;
iter_prev += 1;
diff --git a/source/blender/bmesh/intern/bmesh_iterators_inline.h b/source/blender/bmesh/intern/bmesh_iterators_inline.h
index ed3a9a5be09..4b9fbf52630 100644
--- a/source/blender/bmesh/intern/bmesh_iterators_inline.h
+++ b/source/blender/bmesh/intern/bmesh_iterators_inline.h
@@ -174,7 +174,8 @@ ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) BLI_INLINE
}
/**
- * \brief Parallel (threaded) iterator, only available for most basic itertypes (verts/edges/faces of mesh).
+ * \brief Parallel (threaded) iterator,
+ * only available for most basic itertypes (verts/edges/faces of mesh).
*
* Uses BLI_task_parallel_mempool to iterate over all items of underlying matching mempool.
*
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index 16a534b5e56..8cbbf765f66 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -307,9 +307,11 @@ static void bm_log_faces_restore(BMesh *bm, BMLog *log, GHash *faces)
GHASH_ITER (gh_iter, faces) {
void *key = BLI_ghashIterator_getKey(&gh_iter);
BMLogFace *lf = BLI_ghashIterator_getValue(&gh_iter);
- BMVert *v[3] = {bm_log_vert_from_id(log, lf->v_ids[0]),
- bm_log_vert_from_id(log, lf->v_ids[1]),
- bm_log_vert_from_id(log, lf->v_ids[2])};
+ BMVert *v[3] = {
+ bm_log_vert_from_id(log, lf->v_ids[0]),
+ bm_log_vert_from_id(log, lf->v_ids[1]),
+ bm_log_vert_from_id(log, lf->v_ids[2]),
+ };
BMFace *f;
f = BM_face_create_verts(bm, v, 3, NULL, BM_CREATE_NOP, true);
@@ -728,8 +730,8 @@ void BM_log_entry_drop(BMLogEntry *entry)
* Also, design wise, a first entry should not have any deleted vertices since it
* should not have anything to delete them -from-
*/
- //bm_log_id_ghash_release(log, entry->deleted_faces);
- //bm_log_id_ghash_release(log, entry->deleted_verts);
+ // bm_log_id_ghash_release(log, entry->deleted_faces);
+ // bm_log_id_ghash_release(log, entry->deleted_verts);
}
else if (!entry->next) {
/* Release IDs of elements that are added by this entry. Since
@@ -1125,11 +1127,9 @@ void bm_log_print(const BMLog *log, const char *description)
int i;
printf("%s:\n", description);
- printf(" % 2d: [ initial ]%s\n", 0,
- (!log->current_entry) ? current : "");
+ printf(" % 2d: [ initial ]%s\n", 0, (!log->current_entry) ? current : "");
for (entry = log->entries.first, i = 1; entry; entry = entry->next, i++) {
- printf(" % 2d: [%p]%s\n", i, entry,
- (entry == log->current_entry) ? current : "");
+ printf(" % 2d: [%p]%s\n", i, entry, (entry == log->current_entry) ? current : "");
}
}
#endif
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index f8ec69b6fe9..579fbbdc05e 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -1231,7 +1231,8 @@ void BM_mesh_elem_hflag_enable_test(BMesh *bm,
/* note, better not attempt a fast path for selection as done with de-select
* because hidden geometry and different selection modes can give different results,
- * we could of course check for no hidden faces and then use quicker method but its not worth it. */
+ * we could of course check for no hidden faces and then use
+ * quicker method but its not worth it. */
for (i = 0; i < 3; i++) {
if (htype & flag_types[i]) {
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 8d445d428b2..cb10ec9d701 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -321,7 +321,8 @@ void BM_mesh_free(BMesh *bm)
* Helpers for #BM_mesh_normals_update and #BM_verts_calc_normal_vcos
*/
-/* We use that existing internal API flag, assuming no other tool using it would run concurrently to clnors editing. */
+/* We use that existing internal API flag,
+ * assuming no other tool using it would run concurrently to clnors editing. */
#define BM_LNORSPACE_UPDATE _FLAG_MF
typedef struct BMEdgesCalcVectorsData {
@@ -433,7 +434,8 @@ static void mesh_verts_calc_normals_accum_cb(void *userdata, MempoolIterData *mp
virtual_lock += f_no[0] * fac;
v_no[1] += f_no[1] * fac;
v_no[2] += f_no[2] * fac;
- /* Second atomic operation to 'release' our lock on that vector and set its first scalar value. */
+ /* Second atomic operation to 'release'
+ * our lock on that vector and set its first scalar value. */
/* Note that we do not need to loop here, since we 'locked' v_no[0],
* nobody should have changed it in the mean time. */
virtual_lock = atomic_cas_float(&v_no[0], FLT_MAX, virtual_lock);
@@ -529,7 +531,8 @@ void BM_mesh_normals_update(BMesh *bm)
/**
* \brief BMesh Compute Normals from/to external data.
*
- * Computes the vertex normals of a mesh into vnos, using given vertex coordinates (vcos) and polygon normals (fnos).
+ * Computes the vertex normals of a mesh into vnos,
+ * using given vertex coordinates (vcos) and polygon normals (fnos).
*/
void BM_verts_calc_normal_vcos(BMesh *bm,
const float (*fnos)[3],
@@ -573,9 +576,8 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm,
BM_mesh_elem_index_ensure(bm, htype);
}
- /* This first loop checks which edges are actually smooth, and pre-populate lnos with vnos (as if they were
- * all smooth).
- */
+ /* This first loop checks which edges are actually smooth,
+ * and pre-populate lnos with vnos (as if they were all smooth). */
BM_ITER_MESH_INDEX (e, &eiter, bm, BM_EDGES_OF_MESH, i) {
BMLoop *l_a, *l_b;
@@ -613,7 +615,8 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm,
}
}
else if (do_sharp_edges_tag) {
- /* Note that we do not care about the other sharp-edge cases (sharp poly, non-manifold edge, etc.),
+ /* Note that we do not care about the other sharp-edge cases
+ * (sharp poly, non-manifold edge, etc.),
* only tag edge as sharp when it is due to angle threashold. */
BM_elem_flag_disable(e, BM_ELEM_SMOOTH);
}
@@ -626,7 +629,8 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm,
/**
* Check whether given loop is part of an unknown-so-far cyclic smooth fan, or not.
- * Needed because cyclic smooth fans have no obvious 'entry point', and yet we need to walk them once, and only once.
+ * Needed because cyclic smooth fans have no obvious 'entry point',
+ * and yet we need to walk them once, and only once.
*/
bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr)
{
@@ -647,8 +651,9 @@ bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr)
/* Smooth loop/edge... */
else if (BM_elem_flag_test(lfan_pivot_next, BM_ELEM_TAG)) {
if (lfan_pivot_next == l_curr) {
- /* We walked around a whole cyclic smooth fan without finding any already-processed loop, means we can
- * use initial l_curr/l_prev edge as start for this smooth fan. */
+ /* We walked around a whole cyclic smooth fan
+ * without finding any already-processed loop,
+ * means we can use initial l_curr/l_prev edge as start for this smooth fan. */
return true;
}
/* ... already checked in some previous looping, we can abort. */
@@ -661,8 +666,11 @@ bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr)
}
}
-/* BMesh version of BKE_mesh_normals_loop_split() in mesh_evaluate.c
- * Will use first clnors_data array, and fallback to cd_loop_clnors_offset (use NULL and -1 to not use clnors). */
+/**
+ * BMesh version of BKE_mesh_normals_loop_split() in mesh_evaluate.c
+ * Will use first clnors_data array, and fallback to cd_loop_clnors_offset
+ * (use NULL and -1 to not use clnors).
+ */
static void bm_mesh_loops_calc_normals(BMesh *bm,
const float (*vcos)[3],
const float (*fnos)[3],
@@ -718,7 +726,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP);
- /* We now know edges that can be smoothed (they are tagged), and edges that will be hard (they aren't).
+ /* We now know edges that can be smoothed (they are tagged),
+ * and edges that will be hard (they aren't).
* Now, time to generate the normals.
*/
BM_ITER_MESH (f_curr, &fiter, bm, BM_FACES_OF_MESH) {
@@ -731,12 +740,15 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
continue;
}
/* A smooth edge, we have to check for cyclic smooth fan case.
- * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge as
- * 'entry point', otherwise we can skip it. */
- /* Note: In theory, we could make bm_mesh_loop_check_cyclic_smooth_fan() store mlfan_pivot's in a stack,
- * to avoid having to fan again around the vert during actual computation of clnor & clnorspace.
- * However, this would complicate the code, add more memory usage, and BM_vert_step_fan_loop()
- * is quite cheap in term of CPU cycles, so really think it's not worth it. */
+ * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge
+ * as 'entry point', otherwise we can skip it. */
+
+ /* Note: In theory, we could make bm_mesh_loop_check_cyclic_smooth_fan() store
+ * mlfan_pivot's in a stack, to avoid having to fan again around
+ * the vert during actual computation of clnor & clnorspace. However, this would complicate
+ * the code, add more memory usage, and
+ * BM_vert_step_fan_loop() is quite cheap in term of CPU cycles,
+ * so really think it's not worth it. */
if (BM_elem_flag_test(l_curr->e, BM_ELEM_TAG) &&
(BM_elem_flag_test(l_curr, BM_ELEM_TAG) || !BM_loop_check_cyclic_smooth_fan(l_curr))) {
}
@@ -769,7 +781,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
BKE_lnor_space_define(lnor_space, r_lnos[l_curr_index], vec_curr, vec_prev, NULL);
- /* We know there is only one loop in this space, no need to create a linklist in this case... */
+ /* We know there is only one loop in this space,
+ * no need to create a linklist in this case... */
BKE_lnor_space_add_loop(r_lnors_spacearr, lnor_space, l_curr_index, l_curr, true);
if (has_clnors) {
@@ -780,20 +793,22 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
}
/* We *do not need* to check/tag loops as already computed!
- * Due to the fact a loop only links to one of its two edges, a same fan *will never be walked more than
- * once!*
- * Since we consider edges having neighbor faces with inverted (flipped) normals as sharp, we are sure that
- * no fan will be skipped, even only considering the case (sharp curr_edge, smooth prev_edge), and not the
- * alternative (smooth curr_edge, sharp prev_edge).
+ * Due to the fact a loop only links to one of its two edges,
+ * a same fan *will never be walked more than once!*
+ * Since we consider edges having neighbor faces with inverted (flipped) normals as sharp,
+ * we are sure that no fan will be skipped, even only considering the case
+ * (sharp curr_edge, smooth prev_edge), and not the alternative
+ * (smooth curr_edge, sharp prev_edge).
* All this due/thanks to link between normals and loop ordering.
*/
else {
/* We have to fan around current vertex, until we find the other non-smooth edge,
* and accumulate face normals into the vertex!
- * Note in case this vertex has only one sharp edge, this is a waste because the normal is the same as
- * the vertex normal, but I do not see any easy way to detect that (would need to count number
- * of sharp edges per vertex, I doubt the additional memory usage would be worth it, especially as
- * it should not be a common case in real-life meshes anyway).
+ * Note in case this vertex has only one sharp edge,
+ * this is a waste because the normal is the same as the vertex normal,
+ * but I do not see any easy way to detect that (would need to count number of sharp edges
+ * per vertex, I doubt the additional memory usage would be worth it, especially as it
+ * should not be a common case in real-life meshes anyway).
*/
BMVert *v_pivot = l_curr->v;
BMEdge *e_next;
@@ -820,7 +835,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
lfan_pivot_index = BM_elem_index_get(lfan_pivot);
e_next = lfan_pivot->e; /* Current edge here, actually! */
- /* Only need to compute previous edge's vector once, then we can just reuse old current one! */
+ /* Only need to compute previous edge's vector once,
+ * then we can just reuse old current one! */
{
const BMVert *v_2 = BM_edge_other_vert(e_next, v_pivot);
const float *co_2 = vcos ? vcos[BM_elem_index_get(v_2)] : v_2->co;
@@ -846,9 +862,10 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
/* Compute edge vector.
- * NOTE: We could pre-compute those into an array, in the first iteration, instead of computing them
- * twice (or more) here. However, time gained is not worth memory and time lost,
- * given the fact that this code should not be called that much in real-life meshes...
+ * NOTE: We could pre-compute those into an array, in the first iteration,
+ * instead of computing them twice (or more) here.
+ * However, time gained is not worth memory and time lost,
+ * given the fact that this code should not be called that much in real-life meshes.
*/
{
const BMVert *v_2 = BM_edge_other_vert(e_next, v_pivot);
@@ -937,11 +954,11 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
/* printf("Invalid clnors in this fan!\n"); */
while ((clnor = BLI_SMALLSTACK_POP(clnors))) {
- //print_v2("org clnor", clnor);
+ // print_v2("org clnor", clnor);
clnor[0] = (short)clnors_avg[0];
clnor[1] = (short)clnors_avg[1];
}
- //print_v2("new clnors", clnors_avg);
+ // print_v2("new clnors", clnors_avg);
}
else {
/* We still have to consume the stack! */
@@ -970,7 +987,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm,
}
}
- /* Tag related vertex as sharp, to avoid fanning around it again (in case it was a smooth one). */
+ /* Tag related vertex as sharp, to avoid fanning around it again
+ * (in case it was a smooth one). */
if (r_lnors_spacearr) {
BM_elem_flag_enable(l_curr->v, BM_ELEM_TAG);
}
@@ -1023,22 +1041,28 @@ static void bm_mesh_loops_calc_normals_no_autosmooth(BMesh *bm,
/**
* \brief BMesh Compute Loop Normals
*
- * Updates the loop normals of a mesh. Assumes vertex and face normals are valid (else call BM_mesh_normals_update()
- * first)!
+ * Updates the loop normals of a mesh.
+ * Assumes vertex and face normals are valid (else call BM_mesh_normals_update() first)!
*/
-void BM_mesh_loop_normals_update(
- BMesh *bm, const bool use_split_normals, const float split_angle, float (*r_lnos)[3],
- MLoopNorSpaceArray *r_lnors_spacearr, short (*clnors_data)[2], const int cd_loop_clnors_offset)
+void BM_mesh_loop_normals_update(BMesh *bm,
+ const bool use_split_normals,
+ const float split_angle,
+ float (*r_lnos)[3],
+ MLoopNorSpaceArray *r_lnors_spacearr,
+ short (*clnors_data)[2],
+ const int cd_loop_clnors_offset)
{
const bool has_clnors = clnors_data || (cd_loop_clnors_offset != -1);
if (use_split_normals) {
- /* Tag smooth edges and set lnos from vnos when they might be completely smooth...
- * When using custom loop normals, disable the angle feature! */
- bm_mesh_edges_sharp_tag(bm, NULL, NULL, has_clnors ? (float)M_PI : split_angle, r_lnos);
+ /* Tag smooth edges and set lnos from vnos when they might be completely smooth...
+ * When using custom loop normals, disable the angle feature! */
+ bm_mesh_edges_sharp_tag(bm, NULL, NULL, has_clnors ? (float)M_PI : split_angle, r_lnos);
- /* Finish computing lnos by accumulating face normals in each fan of faces defined by sharp edges. */
- bm_mesh_loops_calc_normals(bm, NULL, NULL, r_lnos, r_lnors_spacearr, clnors_data, cd_loop_clnors_offset);
+ /* Finish computing lnos by accumulating face normals
+ * in each fan of faces defined by sharp edges. */
+ bm_mesh_loops_calc_normals(
+ bm, NULL, NULL, r_lnos, r_lnors_spacearr, clnors_data, cd_loop_clnors_offset);
}
else {
BLI_assert(!r_lnors_spacearr);
@@ -1051,7 +1075,8 @@ void BM_mesh_loop_normals_update(
* \brief BMesh Compute Loop Normals from/to external data.
*
* Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals').
- * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges).
+ * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry
+ * (splitting edges).
*/
void BM_loops_calc_normal_vcos(BMesh *bm,
const float (*vcos)[3],
@@ -1072,7 +1097,8 @@ void BM_loops_calc_normal_vcos(BMesh *bm,
* When using custom loop normals, disable the angle feature! */
bm_mesh_edges_sharp_tag(bm, vnos, fnos, r_lnos, has_clnors ? (float)M_PI : split_angle, false);
- /* Finish computing lnos by accumulating face normals in each fan of faces defined by sharp edges. */
+ /* Finish computing lnos by accumulating face normals
+ * in each fan of faces defined by sharp edges. */
bm_mesh_loops_calc_normals(
bm, vcos, fnos, r_lnos, r_lnors_spacearr, clnors_data, cd_loop_clnors_offset, do_rebuild);
}
@@ -1084,7 +1110,8 @@ void BM_loops_calc_normal_vcos(BMesh *bm,
/** Define sharp edges as needed to mimic 'autosmooth' from angle threshold.
*
- * Used when defining an empty custom loop normals data layer, to keep same shading as with autosmooth!
+ * Used when defining an empty custom loop normals data layer,
+ * to keep same shading as with autosmooth!
*/
void BM_edges_sharp_from_angle_set(BMesh *bm, const float split_angle)
{
@@ -1139,7 +1166,8 @@ void BM_lnorspace_invalidate(BMesh *bm, const bool do_invalidate_all)
BMVert *v;
BMLoop *l;
BMIter viter, liter;
- /* Note: we could use temp tag of BMItem for that, but probably better not use it in such a low-level func?
+ /* Note: we could use temp tag of BMItem for that,
+ * but probably better not use it in such a low-level func?
* --mont29 */
BLI_bitmap *done_verts = BLI_BITMAP_NEW(bm->totvert, __func__);
@@ -1409,13 +1437,15 @@ static int bm_loop_normal_mark_indiv(BMesh *bm, BLI_bitmap *loops)
if (use_sel_face_history) {
/* Using face history allows to select a single loop from a single face...
- * Note that this is On² piece of code, but it is not designed to be used with huge selection sets,
+ * Note that this is On² piece of code,
+ * but it is not designed to be used with huge selection sets,
* rather with only a few items selected at most.*/
printf("using face history selection\n");
/* Goes from last selected to the first selected element. */
for (ese = bm->selected.last; ese; ese = ese->prev) {
if (ese->htype == BM_FACE) {
- /* If current face is selected, then any verts to be edited must have been selected before it. */
+ /* If current face is selected,
+ * then any verts to be edited must have been selected before it. */
for (ese_prev = ese->prev; ese_prev; ese_prev = ese_prev->prev) {
if (ese_prev->htype == BM_VERT) {
bm_loop_normal_mark_indiv_do_loop(
@@ -1839,8 +1869,13 @@ void BM_mesh_elem_index_validate(
/* dirty may have been incorrectly set */
fprintf(stderr,
- "Invalid Dirty: at %s, %s (%s), dirty flag was set but all index values are correct, '%s', '%s'\n",
- location, func, type_names[i], msg_a, msg_b);
+ "Invalid Dirty: at %s, %s (%s), dirty flag was set but all index values are "
+ "correct, '%s', '%s'\n",
+ location,
+ func,
+ type_names[i],
+ msg_a,
+ msg_b);
#endif
}
}
@@ -1848,9 +1883,7 @@ void BM_mesh_elem_index_validate(
#if 0 /* mostly annoying, even in debug mode */
# ifdef DEBUG
if (is_any_error == 0) {
- fprintf(stderr,
- "Valid Index Success: at %s, %s, '%s', '%s'\n",
- location, func, msg_a, msg_b);
+ fprintf(stderr, "Valid Index Success: at %s, %s, '%s', '%s'\n", location, func, msg_a, msg_b);
}
# endif
#endif
@@ -2070,11 +2103,13 @@ int BM_mesh_elem_count(BMesh *bm, const char htype)
*
* A NULL array means no changes.
*
- * Note: - Does not mess with indices, just sets elem_index_dirty flag.
- * - For verts/edges/faces only (as loops must remain "ordered" and "aligned"
- * on a per-face basis...).
+ * \note
+ * - Does not mess with indices, just sets elem_index_dirty flag.
+ * - For verts/edges/faces only (as loops must remain "ordered" and "aligned"
+ * on a per-face basis...).
*
- * WARNING: Be careful if you keep pointers to affected BM elements, or arrays, when using this func!
+ * \warning Be careful if you keep pointers to affected BM elements,
+ * or arrays, when using this func!
*/
void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx)
{
@@ -2126,7 +2161,10 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
for (i = totvert; i--; new_idx--, ve--, vep--) {
BMVert *new_vep = verts_pool[*new_idx];
*new_vep = *ve;
- /* printf("mapping vert from %d to %d (%p/%p to %p)\n", i, *new_idx, *vep, verts_pool[i], new_vep);*/
+#if 0
+ printf(
+ "mapping vert from %d to %d (%p/%p to %p)\n", i, *new_idx, *vep, verts_pool[i], new_vep);
+#endif
BLI_ghash_insert(vptr_map, *vep, new_vep);
if (cd_vert_pyptr != -1) {
void **pyptr = BM_ELEM_CD_GET_VOID_P(((BMElem *)new_vep), cd_vert_pyptr);
@@ -2175,7 +2213,10 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
BMEdge *new_edp = edges_pool[*new_idx];
*new_edp = *ed;
BLI_ghash_insert(eptr_map, *edp, new_edp);
- /* printf("mapping edge from %d to %d (%p/%p to %p)\n", i, *new_idx, *edp, edges_pool[i], new_edp);*/
+#if 0
+ printf(
+ "mapping edge from %d to %d (%p/%p to %p)\n", i, *new_idx, *edp, edges_pool[i], new_edp);
+#endif
if (cd_edge_pyptr != -1) {
void **pyptr = BM_ELEM_CD_GET_VOID_P(((BMElem *)new_edp), cd_edge_pyptr);
*pyptr = pyptrs[*new_idx];
@@ -2250,27 +2291,28 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const
}
}
- /* Edges' pointers, only vert pointers (as we don't mess with loops!), and - ack! - edge pointers,
+ /* Edges' pointers, only vert pointers (as we don't mess with loops!),
+ * and - ack! - edge pointers,
* as we have to handle disklinks... */
if (vptr_map || eptr_map) {
BM_ITER_MESH (ed, &iter, bm, BM_EDGES_OF_MESH) {
if (vptr_map) {
- /* printf("Edge v1: %p -> %p\n", ed->v1, BLI_ghash_lookup(vptr_map, ed->v1));*/
- /* printf("Edge v2: %p -> %p\n", ed->v2, BLI_ghash_lookup(vptr_map, ed->v2));*/
+ /* printf("Edge v1: %p -> %p\n", ed->v1, BLI_ghash_lookup(vptr_map, ed->v1));*/
+ /* printf("Edge v2: %p -> %p\n", ed->v2, BLI_ghash_lookup(vptr_map, ed->v2));*/
ed->v1 = BLI_ghash_lookup(vptr_map, ed->v1);
ed->v2 = BLI_ghash_lookup(vptr_map, ed->v2);
BLI_assert(ed->v1);
BLI_assert(ed->v2);
}
if (eptr_map) {
- /* printf("Edge v1_disk_link prev: %p -> %p\n", ed->v1_disk_link.prev,*/
- /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.prev));*/
- /* printf("Edge v1_disk_link next: %p -> %p\n", ed->v1_disk_link.next,*/
- /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.next));*/
- /* printf("Edge v2_disk_link prev: %p -> %p\n", ed->v2_disk_link.prev,*/
- /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.prev));*/
- /* printf("Edge v2_disk_link next: %p -> %p\n", ed->v2_disk_link.next,*/
- /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.next));*/
+ /* printf("Edge v1_disk_link prev: %p -> %p\n", ed->v1_disk_link.prev,*/
+ /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.prev));*/
+ /* printf("Edge v1_disk_link next: %p -> %p\n", ed->v1_disk_link.next,*/
+ /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.next));*/
+ /* printf("Edge v2_disk_link prev: %p -> %p\n", ed->v2_disk_link.prev,*/
+ /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.prev));*/
+ /* printf("Edge v2_disk_link next: %p -> %p\n", ed->v2_disk_link.next,*/
+ /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.next));*/
ed->v1_disk_link.prev = BLI_ghash_lookup(eptr_map, ed->v1_disk_link.prev);
ed->v1_disk_link.next = BLI_ghash_lookup(eptr_map, ed->v1_disk_link.next);
ed->v2_disk_link.prev = BLI_ghash_lookup(eptr_map, ed->v2_disk_link.prev);
@@ -2563,7 +2605,8 @@ void BM_mesh_rebuild(BMesh *bm,
#undef REMAP_EDGE
/* Cleanup, re-use local tables if the current mesh had tables allocated.
- * could use irrespective but it may use more memory then the caller wants (and not be needed). */
+ * could use irrespective but it may use more memory then the caller wants
+ * (and not be needed). */
if (remap & BM_VERT) {
if (bm->vtable) {
SWAP(BMVert **, vtable_dst, bm->vtable);
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index f2db451888a..0ea33049458 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -33,33 +33,41 @@
*
* - Editmode operations when a shape key-block is active edits only that key-block.
* - The first Basis key-block always matches the Mesh verts.
- * - Changing vertex locations of _any_ Basis will apply offsets to those shape keys using this as their Basis.
+ * - Changing vertex locations of _any_ Basis
+ * will apply offsets to those shape keys using this as their Basis.
+ *
* \subsection enter_editmode Entering EditMode - #BM_mesh_bm_from_me
*
- * - the active key-block is used for BMesh vertex locations on entering edit-mode.
- * So obviously the meshes vertex locations remain unchanged and the shape key its self is not being edited directly.
- * Simply the #BMVert.co is a initialized from active shape key (when its set).
- * - all key-blocks are added as CustomData layers (read code for details).
+ * - The active key-block is used for BMesh vertex locations on entering edit-mode.
+ * So obviously the meshes vertex locations remain unchanged and the shape key
+ * its self is not being edited directly.
+ * Simply the #BMVert.co is a initialized from active shape key (when its set).
+ * - All key-blocks are added as CustomData layers (read code for details).
+ *
* \subsection exit_editmode Exiting EditMode - #BM_mesh_bm_to_me
*
- * This is where the most confusing code is! Won't attempt to document the details here, for that read the code.
+ * This is where the most confusing code is! Won't attempt to document the details here,
+ * for that read the code.
* But basics are as follows.
*
- * - Vertex locations (possibly modified from initial active key-block) are copied directly into #MVert.co
- * (special confusing note that these may be restored later, when editing the 'Basis', read on).
- * - if the 'Key' is relative, and the active key-block is the basis for ANY other key-blocks - get an array of offsets
- * between the new vertex locations and the original shape key (before entering edit-mode),
- * these offsets get applied later on to inactive key-blocks using the active one (which we are editing) as their Basis.
+ * - Vertex locations (possibly modified from initial active key-block)
+ * are copied directly into #MVert.co
+ * (special confusing note that these may be restored later, when editing the 'Basis', read on).
+ * - if the 'Key' is relative, and the active key-block is the basis for ANY other key-blocks -
+ * get an array of offsets between the new vertex locations and the original shape key
+ * (before entering edit-mode), these offsets get applied later on to inactive key-blocks
+ * using the active one (which we are editing) as their Basis.
*
* Copying the locations back to the shape keys is quite confusing...
* One main area of confusion is that when editing a 'Basis' key-block 'me->key->refkey'
- * The coords are written into the mesh, from the users perspective the Basis coords are written into the mesh
- * when exiting edit-mode.
+ * The coords are written into the mesh, from the users perspective the Basis coords are written
+ * into the mesh when exiting edit-mode.
*
- * When _not_ editing the 'Basis', the original vertex locations (stored in the mesh and unchanged during edit-mode),
- * are copied back into the mesh.
+ * When _not_ editing the 'Basis', the original vertex locations
+ * (stored in the mesh and unchanged during edit-mode), are copied back into the mesh.
*
- * This has the effect from the users POV of leaving the mesh un-touched, and only editing the active shape key-block.
+ * This has the effect from the users POV of leaving the mesh un-touched,
+ * and only editing the active shape key-block.
*/
#include "DNA_mesh_types.h"
@@ -490,7 +498,8 @@ static BMVert **bm_to_mesh_vertex_map(BMesh *bm, int ototvert)
const int keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset);
if ((keyi != ORIGINDEX_NONE) && (keyi < ototvert) &&
/* not fool-proof, but chances are if we have many verts with the same index,
- * we will want to use the first one, since the second is more likely to be a duplicate. */
+ * we will want to use the first one,
+ * since the second is more likely to be a duplicate. */
(vertMap[keyi] == NULL)) {
vertMap[keyi] = eve;
}
@@ -944,8 +953,9 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
if (apply_offset) {
add_v3_v3(fp, *ofs_pt++);
/* Apply back new coordinates of offsetted shapekeys into BMesh.
- * Otherwise, in case we call again BM_mesh_bm_to_me on same BMesh, we'll apply diff from previous
- * call to BM_mesh_bm_to_me, to shapekey values from *original creation of the BMesh*. See T50524. */
+ * Otherwise, in case we call again BM_mesh_bm_to_me on same BMesh,
+ * we'll apply diff from previous call to BM_mesh_bm_to_me,
+ * to shapekey values from *original creation of the BMesh*. See T50524. */
copy_v3_v3(BM_ELEM_CD_GET_VOID_P(eve, cd_shape_offset), fp);
}
@@ -977,8 +987,10 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
}
/**
- * A version of #BM_mesh_bm_to_me intended for getting the mesh to pass to the modifier stack for evaluation,
- * instad of mode switching (where we make sure all data is kept and do expensive lookups to maintain shape keys).
+ * A version of #BM_mesh_bm_to_me intended for getting the mesh
+ * to pass to the modifier stack for evaluation,
+ * instad of mode switching (where we make sure all data is kept
+ * and do expensive lookups to maintain shape keys).
*
* Key differences:
*
diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.c b/source/blender/bmesh/intern/bmesh_mesh_validate.c
index 3b6f63df089..83ab29940f3 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_validate.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_validate.c
@@ -51,7 +51,8 @@
# endif
/**
- * Check of this BMesh is valid, this function can be slow since its intended to help with debugging.
+ * Check of this BMesh is valid,
+ * this function can be slow since its intended to help with debugging.
*
* \return true when the mesh is valid.
*/
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 1075b3753da..888393de47a 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -322,13 +322,14 @@ BMFace *BM_face_split(BMesh *bm,
*
* Like BM_face_split, but with an edge split by \a n intermediate points with given coordinates.
*
- * \param bm: The bmesh
- * \param f: the original face
- * \param l_a, l_b: Vertices which define the split edge, must be different
- * \param cos: Array of coordinates for intermediate points
- * \param n: Length of \a cos (must be > 0)
- * \param r_l: pointer which will receive the BMLoop for the first split edge (from \a l_a) in the new face
- * \param example: Edge used for attributes of splitting edge, if non-NULL
+ * \param bm: The bmesh.
+ * \param f: the original face.
+ * \param l_a, l_b: Vertices which define the split edge, must be different.
+ * \param cos: Array of coordinates for intermediate points.
+ * \param n: Length of \a cos (must be > 0).
+ * \param r_l: pointer which will receive the BMLoop.
+ * for the first split edge (from \a l_a) in the new face.
+ * \param example: Edge used for attributes of splitting edge, if non-NULL.
*
* \return Pointer to the newly created face representing one side of the split
* if the split is successful (and the original original face will be the
@@ -370,7 +371,8 @@ BMFace *BM_face_split_n(BMesh *bm,
#else
f_new = bmesh_kernel_split_face_make_edge(bm, f, l_a, l_b, &l_new, example, false);
#endif
- /* bmesh_kernel_split_face_make_edge returns in 'l_new' a Loop for f_new going from 'v_a' to 'v_b'.
+ /* bmesh_kernel_split_face_make_edge returns in 'l_new'
+ * a Loop for f_new going from 'v_a' to 'v_b'.
* The radial_next is for 'f' and goes from 'v_b' to 'v_a' */
if (f_new) {
@@ -378,7 +380,8 @@ BMFace *BM_face_split_n(BMesh *bm,
for (i = 0; i < n; i++) {
v_new = bmesh_kernel_split_edge_make_vert(bm, v_b, e, &e_new);
BLI_assert(v_new != NULL);
- /* bmesh_kernel_split_edge_make_vert returns in 'e_new' the edge going from 'v_new' to 'v_b' */
+ /* bmesh_kernel_split_edge_make_vert returns in 'e_new'
+ * the edge going from 'v_new' to 'v_b'. */
copy_v3_v3(v_new->co, cos[i]);
/* interpolate the loop data for the loops with (v == v_new), using orig face */
@@ -531,14 +534,15 @@ BMEdge *BM_vert_collapse_edge(
/* in this case we want to keep all faces and not join them,
* rather just get rid of the vertex - see bug [#28645] */
- BMVert *tv = BM_edge_other_vert(e_kill, v_kill);
+ BMVert *tv = BM_edge_other_vert(e_kill, v_kill);
if (tv) {
BMEdge *e2 = bmesh_disk_edge_next(e_kill, v_kill);
if (e2) {
BMVert *tv2 = BM_edge_other_vert(e2, v_kill);
if (tv2) {
/* only action, other calls here only get the edge to return */
- e_new = bmesh_kernel_join_edge_kill_vert(bm, e_kill, v_kill, do_del, true, kill_degenerate_faces);
+ e_new = bmesh_kernel_join_edge_kill_vert(
+ bm, e_kill, v_kill, do_del, true, kill_degenerate_faces);
}
}
}
@@ -752,7 +756,7 @@ bool BM_face_validate(BMFace *face, FILE *err)
verts[i] = l->v;
if (l->e->v1 == l->e->v2) {
fprintf(err, "Found bmesh edge with identical verts!\n");
- fprintf(err, " edge ptr: %p, vert: %p\n", l->e, l->e->v1);
+ fprintf(err, " edge ptr: %p, vert: %p\n", l->e, l->e->v1);
fflush(err);
ret = false;
}
diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h
index 5085eb801ce..3b543835586 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api.h
@@ -628,7 +628,7 @@ void BMO_slot_buffer_from_all(BMesh *bm,
* don't directly access. */
typedef struct BMOIter {
BMOpSlot *slot;
- int cur; //for arrays
+ int cur; // for arrays
GHashIterator giter;
void **val;
char restrictmask; /* bitwise '&' with BMHeader.htype */
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index a7783084c01..84c177a4d04 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -272,7 +272,7 @@ BMOpSlot *BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identif
int slot_code = bmo_name_to_slotcode_check(slot_args, identifier);
if (UNLIKELY(slot_code < 0)) {
- //return &BMOpEmptySlot;
+ // return &BMOpEmptySlot;
BLI_assert(0);
return NULL; /* better crash */
}
@@ -741,7 +741,8 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd)
if (slot->len >= slot->size) {
slot->size = (slot->size + 1 + totadd) * 2;
- allocsize = BMO_OPSLOT_TYPEINFO[bmo_opdefines[op->type]->slot_types[slot_code].type] * slot->size;
+ allocsize = BMO_OPSLOT_TYPEINFO[bmo_opdefines[op->type]->slot_types[slot_code].type] *
+ slot->size;
tmp = slot->data.buf;
slot->data.buf = MEM_callocN(allocsize, "opslot dynamic array");
@@ -756,7 +757,8 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd)
slot->len += totadd;
slot->size = slot->len + 2;
- allocsize = BMO_OPSLOT_TYPEINFO[bmo_opdefines[op->type]->slot_types[slot_code].type] * slot->len;
+ allocsize = BMO_OPSLOT_TYPEINFO[bmo_opdefines[op->type]->slot_types[slot_code].type] *
+ slot->len;
tmp = slot->data.buf;
slot->data.buf = MEM_callocN(allocsize, "opslot dynamic array");
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 2a734c242ba..172f7050aa0 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -121,7 +121,8 @@ static void bm_face_calc_poly_center_median_vertex_cos(const BMFace *f,
/**
* For tools that insist on using triangles, ideally we would cache this data.
*
- * \param use_fixed_quad: When true, always split quad along (0 -> 2) regardless of concave corners,
+ * \param use_fixed_quad: When true,
+ * always split quad along (0 -> 2) regardless of concave corners,
* (as done in #BM_mesh_calc_tessellation).
* \param r_loops: Store face loop pointers, (f->len)
* \param r_index: Store triangle triples, indices into \a r_loops, `((f->len - 2) * 3)`
@@ -963,8 +964,8 @@ bool BM_face_point_inside_test(const BMFace *f, const float co[3])
* with a length equal to (f->len - 3). It will be filled with the new
* triangles (not including the original triangle).
*
- * \param r_faces_double: When newly created faces are duplicates of existing faces, they're added to this list.
- * Caller must handle de-duplication.
+ * \param r_faces_double: When newly created faces are duplicates of existing faces,
+ * they're added to this list. Caller must handle de-duplication.
* This is done because its possible _all_ faces exist already,
* and in that case we would have to remove all faces including the one passed,
* which causes complications adding/removing faces while looking over them.
@@ -1068,10 +1069,10 @@ void BM_face_triangulate(BMesh *bm,
/* named confusingly, l_v1 is in fact the second vertex */
if (split_24) {
l_v1 = l_v4;
- //l_v2 = l_v2;
+ // l_v2 = l_v2;
}
else {
- //l_v1 = l_v1;
+ // l_v1 = l_v1;
l_v2 = l_v3;
}
break;
@@ -1156,8 +1157,8 @@ void BM_face_triangulate(BMesh *bm,
l_iter = l_first = l_new;
do {
BMEdge *e = l_iter->e;
- /* confusing! if its not a boundary now, we know it will be later
- * since this will be an edge of one of the new faces which we're in the middle of creating */
+ /* Confusing! if its not a boundary now, we know it will be later since this will be an
+ * edge of one of the new faces which we're in the middle of creating. */
bool is_new_edge = (l_iter == l_iter->radial_next);
if (is_new_edge) {
@@ -1432,7 +1433,7 @@ void BM_mesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptri
else if (efa->len == 3) {
# if 0
int j;
- BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) {
+ BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, j) {
looptris[i][j] = l;
}
i += 1;
@@ -1450,7 +1451,7 @@ void BM_mesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptri
BMLoop *ltmp[4];
int j;
BLI_array_grow_items(looptris, 2);
- BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) {
+ BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, j) {
ltmp[j] = l;
}
@@ -1587,7 +1588,7 @@ void BM_mesh_calc_tessellation_beauty(BMesh *bm, BMLoop *(*looptris)[3], int *r_
*/
#if 0
const bool split_13 = (BM_verts_calc_rotate_beauty(
- l_v1->v, l_v2->v, l_v3->v, l_v4->v, 0, 0) < 0.0f);
+ l_v1->v, l_v2->v, l_v3->v, l_v4->v, 0, 0) < 0.0f);
#else
float axis_mat[3][3], v_quad[4][2];
axis_dominant_v3_to_m3(axis_mat, efa->no);
diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
index e2b117536f3..14b73693b03 100644
--- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
+++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
@@ -987,8 +987,10 @@ static int bm_face_split_edgenet_find_connection(const struct EdgeGroup_FindConn
* Method for finding connection is as follows:
*
* - Cast a ray along either the positive or negative directions.
- * - Take the hit-edge, and cast rays to their vertices checking those rays don't intersect a closer edge.
- * - Keep taking the hit-edge and testing its verts until a vertex is found which isn't blocked by an edge.
+ * - Take the hit-edge, and cast rays to their vertices
+ * checking those rays don't intersect a closer edge.
+ * - Keep taking the hit-edge and testing its verts
+ * until a vertex is found which isn't blocked by an edge.
*
* \note It's possible none of the verts can be accessed (with self-intersecting lines).
* In that case theres no right answer (without subdividing edges),
@@ -1146,7 +1148,8 @@ static BMVert *bm_face_split_edgenet_partial_connect(BMesh *bm, BMVert *v_delimi
}
}
- /* Detect if this is a delimiter by checking if we didn't walk any of edges connected to 'v_delimit' */
+ /* Detect if this is a delimiter
+ * by checking if we didn't walk any of edges connected to 'v_delimit'. */
bool is_delimit = false;
FOREACH_VERT_EDGE(v_delimit, e_iter, {
BMVert *v_step = BM_edge_other_vert(e_iter, v_delimit);
@@ -1500,7 +1503,8 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm,
/* Now create bvh tree
*
- * Note that a large epsilon is used because meshes with dimensions of around 100+ need it. see T52329. */
+ * Note that a large epsilon is used because meshes with dimensions of around 100+ need it.
+ * see T52329. */
BVHTree *bvhtree = BLI_bvhtree_new(edge_arr_len, 1e-4f, 8, 8);
for (uint i = 0; i < edge_arr_len; i++) {
const float e_cos[2][3] = {
diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h
index b77243f7b26..d5cbe947293 100644
--- a/source/blender/bmesh/intern/bmesh_private.h
+++ b/source/blender/bmesh/intern/bmesh_private.h
@@ -31,8 +31,8 @@
/* returns positive nonzero on error */
#ifdef NDEBUG
-/* no error checking for release,
- * it can take most of the CPU time when running some tools */
+/* No error checking for release,
+ * it can take most of the CPU time when running some tools. */
# define BM_CHECK_ELEMENT(el) (void)(el)
#else
int bmesh_elem_check(void *element, const char htype);
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index 98ad30b6a28..a2f95a013a2 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -311,9 +311,11 @@ float BM_loop_point_side_of_edge_test(const BMLoop *l, const float co[3])
}
/**
- * Given 2 verts, find a face they share that has the lowest angle across these verts and give back both loops.
+ * Given 2 verts,
+ * find a face they share that has the lowest angle across these verts and give back both loops.
*
- * This can be better then #BM_vert_pair_share_face_by_len because concave splits are ranked lowest.
+ * This can be better then #BM_vert_pair_share_face_by_len
+ * because concave splits are ranked lowest.
*/
BMFace *BM_vert_pair_share_face_by_angle(
BMVert *v_a, BMVert *v_b, BMLoop **r_l_a, BMLoop **r_l_b, const bool allow_adjacent)
@@ -1410,7 +1412,8 @@ BMLoop *BM_face_edge_share_loop(BMFace *f, BMEdge *e)
* BM_face_create_ngon() on an arbitrary array of verts,
* though be sure to pick an edge which has a face.
*
- * \note This is in fact quite a simple check, mainly include this function so the intent is more obvious.
+ * \note This is in fact quite a simple check,
+ * mainly include this function so the intent is more obvious.
* We know these 2 verts will _always_ make up the loops edge
*/
void BM_edge_ordered_verts_ex(const BMEdge *edge,
@@ -1507,10 +1510,13 @@ float BM_loop_calc_face_angle(const BMLoop *l)
*/
float BM_loop_calc_face_normal_safe_ex(const BMLoop *l, const float epsilon_sq, float r_normal[3])
{
- /* Note: we cannot use result of normal_tri_v3 here to detect colinear vectors (vertex on a straight line)
- * from zero value, because it does not normalize both vectors before making crossproduct.
- * Instead of adding two costly normalize computations, just check ourselves for colinear case. */
- /* Note: FEPSILON might need some finer tweaking at some point? Seems to be working OK for now though. */
+ /* Note: we cannot use result of normal_tri_v3 here to detect colinear vectors
+ * (vertex on a straight line) from zero value,
+ * because it does not normalize both vectors before making crossproduct.
+ * Instead of adding two costly normalize computations,
+ * just check ourselves for colinear case. */
+ /* Note: FEPSILON might need some finer tweaking at some point?
+ * Seems to be working OK for now though. */
float v1[3], v2[3], v_tmp[3];
sub_v3_v3v3(v1, l->prev->v->co, l->v->co);
sub_v3_v3v3(v2, l->next->v->co, l->v->co);
@@ -1841,8 +1847,7 @@ float BM_vert_calc_median_tagged_edge_length(const BMVert *v)
int tot;
float length = 0.0f;
- BM_ITER_ELEM_INDEX(e, &iter, (BMVert *)v, BM_EDGES_OF_VERT, tot)
- {
+ BM_ITER_ELEM_INDEX (e, &iter, (BMVert *)v, BM_EDGES_OF_VERT, tot) {
const BMVert *v_other = BM_edge_other_vert(e, v);
if (BM_elem_flag_test(v_other, BM_ELEM_TAG)) {
length += BM_edge_calc_length(e);
@@ -1917,7 +1922,6 @@ BMEdge *BM_edge_exists(BMVert *v_a, BMVert *v_b)
BMIter iter;
BMEdge *e;
-
BLI_assert(v_a != v_b);
BLI_assert(v_a->head.htype == BM_VERT && v_b->head.htype == BM_VERT);
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index c327c10226f..20042e65287 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -209,14 +209,13 @@ static void *bmw_VertShellWalker_step(BMWalker *walker)
BMW_state_remove(walker);
-
/* find the next edge whose other vertex has not been visite */
curedge = shellWalk.curedge;
do {
if (!BLI_gset_haskey(walker->visit_set, curedge)) {
if (!walker->restrictflag ||
- (walker->restrictflag && BMO_edge_flag_test(walker->bm, curedge, walker->restrictflag)))
- {
+ (walker->restrictflag &&
+ BMO_edge_flag_test(walker->bm, curedge, walker->restrictflag))) {
BMwShellWalker *newstate;
v_old = BM_edge_other_vert(curedge, shellWalk.base);
@@ -727,9 +726,9 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
iwalk = BMW_state_add(walker);
iwalk->base = owalk.base;
- //if (!BMO_face_flag_test(walker->bm, l->f, walker->restrictflag))
+ // if (!BMO_face_flag_test(walker->bm, l->f, walker->restrictflag))
// iwalk->curloop = l->radial_next;
- iwalk->curloop = l; //else iwalk->curloop = l;
+ iwalk->curloop = l; // else iwalk->curloop = l;
iwalk->lastv = v;
return owalk.curloop;
@@ -990,8 +989,9 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker)
vert_edge_tot = BM_vert_edge_count_nonwire(v);
- /* typical loopiong over edges in the middle of a mesh */
- /* however, why use 2 here at all? I guess for internal ngon loops it can be useful. Antony R. */
+ /* Typical loopiong over edges in the middle of a mesh */
+ /* However, why use 2 here at all?
+ * I guess for internal ngon loops it can be useful. Antony R. */
if (vert_edge_tot == 4 || vert_edge_tot == 2) {
int i_opposite = vert_edge_tot / 2;
int i = 0;
diff --git a/source/blender/bmesh/operators/bmo_bridge.c b/source/blender/bmesh/operators/bmo_bridge.c
index 39ccc0c631e..7ec73412373 100644
--- a/source/blender/bmesh/operators/bmo_bridge.c
+++ b/source/blender/bmesh/operators/bmo_bridge.c
@@ -211,8 +211,11 @@ static void bridge_loop_pair(BMesh *bm,
* +--------+ +--------+
* </pre>
*
- * When loops are aligned to the direction between the loops values of 'dir_a/b' is degenerate,
- * in this case compare the original directions (before they were corrected by 'el_dir'), see: T43013
+ * When loops are aligned to the direction between
+ * the loops values of 'dir_a/b' is degenerate,
+ * in this case compare the original directions
+ * (before they were corrected by 'el_dir'),
+ * see: T43013
*/
test_a = dir_a_orig;
test_b = dir_b_orig;
diff --git a/source/blender/bmesh/operators/bmo_connect_pair.c b/source/blender/bmesh/operators/bmo_connect_pair.c
index 18568c364d6..07ead2b8a96 100644
--- a/source/blender/bmesh/operators/bmo_connect_pair.c
+++ b/source/blender/bmesh/operators/bmo_connect_pair.c
@@ -43,9 +43,11 @@
* - never step over the same element twice (tag elements as #ELE_TOUCHED).
* this avoids going into an eternal loop if there are many possible branches (see T45582).
* - when running into a branch, create a new #PathLinkState state and add to the heap.
- * - when the target is reached, finish - since none of the other paths can be shorter then the one just found.
+ * - when the target is reached,
+ * finish - since none of the other paths can be shorter then the one just found.
* - if the connection can't be found - fail.
- * - with the connection found, split all edges tagging verts (or tag verts that sit on the intersection).
+ * - with the connection found, split all edges tagging verts
+ * (or tag verts that sit on the intersection).
* - run the standard connect operator.
*/
@@ -520,7 +522,8 @@ static void bm_vert_pair_to_matrix(BMVert *v_pair[2], float r_unit_mat[3][3])
project_plane_normalized_v3_v3v3(basis_nor_a, v_pair[0]->no, basis_dir);
project_plane_normalized_v3_v3v3(basis_nor_b, v_pair[1]->no, basis_dir);
- /* don't normalize before combining so as normals approach the direction, they have less effect (T46784). */
+ /* Don't normalize before combining so as normals approach the direction,
+ * they have less effect (T46784). */
/* combine the normals */
/* for flipped faces */
diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c
index c799b177843..c6813a864a8 100644
--- a/source/blender/bmesh/operators/bmo_create.c
+++ b/source/blender/bmesh/operators/bmo_create.c
@@ -230,8 +230,8 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
*
* Rather then do nothing, when 5+ verts are selected, check if they are in our history,
* when this is so, we can make edges from them, but _not_ a face,
- * if it is the intention to make a face the user can just hit F again since there will be edges next
- * time around.
+ * if it is the intention to make a face the user can just hit F again
+ * since there will be edges next time around.
*
* if all history verts have ELE_NEW flagged and the total number of history verts == totv,
* then we know the history contains all verts here and we can continue...
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c
index 9cea982f6bd..6c662323ec1 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -161,15 +161,15 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
BLI_array_clear(faces);
faces = NULL; /* forces different allocatio */
- BMW_init(
- &regwalker,
- bm,
- BMW_ISLAND_MANIFOLD,
- BMW_MASK_NOP,
- BMW_MASK_NOP,
- FACE_MARK,
- BMW_FLAG_NOP, /* no need to check BMW_FLAG_TEST_HIDDEN, faces are already marked by the bmo */
- BMW_NIL_LAY);
+ BMW_init(&regwalker,
+ bm,
+ BMW_ISLAND_MANIFOLD,
+ BMW_MASK_NOP,
+ BMW_MASK_NOP,
+ FACE_MARK,
+ /* no need to check BMW_FLAG_TEST_HIDDEN, faces are already marked by the bmo. */
+ BMW_FLAG_NOP,
+ BMW_NIL_LAY);
for (f_iter = BMW_begin(&regwalker, f); f_iter; f_iter = BMW_step(&regwalker)) {
BLI_array_append(faces, f_iter);
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index cec7a920abb..7d557204369 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -740,8 +740,7 @@ static void solidify_add_thickness(BMesh *bm, const float dist)
/* array for receiving angles from angle_poly_v3 */
float **verts = BLI_buffer_reinit_data(&verts_buf, float *, f->len);
- BM_ITER_ELEM_INDEX(l, &loopIter, f, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &loopIter, f, BM_LOOPS_OF_FACE, i) {
verts[i] = l->v->co;
}
diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c
index b71bd482e3b..c3d19862ffb 100644
--- a/source/blender/bmesh/operators/bmo_fill_grid.c
+++ b/source/blender/bmesh/operators/bmo_fill_grid.c
@@ -485,7 +485,7 @@ static void bm_grid_fill(BMesh *bm,
const uint xtot = (uint)BM_edgeloop_length_get(estore_a);
const uint ytot = (uint)BM_edgeloop_length_get(estore_rail_a);
- //BMVert *v;
+ // BMVert *v;
uint i;
#ifdef DEBUG
uint x, y;
@@ -682,8 +682,10 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op)
/* add vertices if needed */
{
- struct BMEdgeLoopStore *estore_pairs[2][2] = {{estore_a, estore_b},
- {estore_rail_a, estore_rail_b}};
+ struct BMEdgeLoopStore *estore_pairs[2][2] = {
+ {estore_a, estore_b},
+ {estore_rail_a, estore_rail_b},
+ };
int i;
for (i = 0; i < 2; i++) {
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index 46b31ce40d3..98d4431803a 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -103,9 +103,11 @@ static void hull_output_triangles(BMesh *bm, GSet *hull_triangles)
int i;
if (!t->skip) {
- BMEdge *edges[3] = {BM_edge_create(bm, t->v[0], t->v[1], NULL, BM_CREATE_NO_DOUBLE),
- BM_edge_create(bm, t->v[1], t->v[2], NULL, BM_CREATE_NO_DOUBLE),
- BM_edge_create(bm, t->v[2], t->v[0], NULL, BM_CREATE_NO_DOUBLE)};
+ BMEdge *edges[3] = {
+ BM_edge_create(bm, t->v[0], t->v[1], NULL, BM_CREATE_NO_DOUBLE),
+ BM_edge_create(bm, t->v[1], t->v[2], NULL, BM_CREATE_NO_DOUBLE),
+ BM_edge_create(bm, t->v[2], t->v[0], NULL, BM_CREATE_NO_DOUBLE),
+ };
BMFace *f, *example = NULL;
f = BM_face_exists(t->v, 3);
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index 724b974c50f..12ec4617f0a 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -190,10 +190,9 @@ static void bm_loop_customdata_merge(BMesh *bm,
# if 0
&&
/* check if the data ends up diverged */
- (CustomData_data_equals(
- type,
- BM_ELEM_CD_GET_VOID_P(l_a_inner, offset),
- BM_ELEM_CD_GET_VOID_P(l_b_inner, offset)) == false)
+ (CustomData_data_equals(type,
+ BM_ELEM_CD_GET_VOID_P(l_a_inner, offset),
+ BM_ELEM_CD_GET_VOID_P(l_b_inner, offset)) == false)
# endif
) {
/* no need to allocate a temp block:
@@ -660,7 +659,8 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
BM_edge_calc_face_tangent(es->e_new, es->l, es->no);
if (es->e_new == es->e_old) { /* happens on boundary edges */
- /* take care here, we're creating this double edge which _must_ have its verts replaced later on */
+ /* Take care here, we're creating this double edge which _must_
+ * have its verts replaced later on. */
es->e_old = BM_edge_create(bm, es->e_new->v1, es->e_new->v2, es->e_new, BM_CREATE_NOP);
}
@@ -710,9 +710,10 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
}
#endif
- /* execute the split and position verts, it would be most obvious to loop over verts
- * here but don't do this since we will be splitting them off (iterating stuff you modify is bad juju)
- * instead loop over edges then their verts */
+ /* Execute the split and position verts, it would be most obvious to loop
+ * over verts here but don't do this since we will be splitting them off
+ * (iterating stuff you modify is bad juju)
+ * instead loop over edges then their verts. */
for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
for (int j = 0; j < 2; j++) {
v = (j == 0) ? es->e_new->v1 : es->e_new->v2;
@@ -1047,15 +1048,16 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
f = BM_face_create_verts(bm, varr, j, es->l->f, BM_CREATE_NOP, true);
BMO_face_flag_enable(bm, f, ELE_NEW);
- /* copy for loop data, otherwise UV's and vcols are no good.
+ /* Copy for loop data, otherwise UV's and vcols are no good.
* tiny speedup here we could be more clever and copy from known adjacent data
- * also - we could attempt to interpolate the loop data, this would be much slower but more useful too */
-#if 0
- /* don't use this because face boundaries have no adjacent loops and won't be filled in.
- * instead copy from the opposite side with the code below */
- BM_face_copy_shared(bm, f, NULL, NULL);
-#else
- {
+ * also - we could attempt to interpolate the loop data,
+ * this would be much slower but more useful too. */
+ if (0) {
+ /* Don't use this because face boundaries have no adjacent loops and won't be filled in.
+ * instead copy from the opposite side with the code below */
+ BM_face_copy_shared(bm, f, NULL, NULL);
+ }
+ else {
/* 2 inner loops on the edge between the new face and the original */
BMLoop *l_a;
BMLoop *l_b;
@@ -1109,7 +1111,7 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
CustomData_bmesh_copy_data(&bm->ldata, &bm->ldata, iface->blocks_l[i_a], &l_b->head.data);
CustomData_bmesh_copy_data(&bm->ldata, &bm->ldata, iface->blocks_l[i_b], &l_a->head.data);
-# ifdef USE_LOOP_CUSTOMDATA_MERGE
+#ifdef USE_LOOP_CUSTOMDATA_MERGE
if (has_math_ldata) {
BMEdge *e_connect;
@@ -1136,7 +1138,7 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
BM_edge_other_loop(e_connect, l_b->next));
}
}
-# endif /* USE_LOOP_CUSTOMDATA_MERGE */
+#endif /* USE_LOOP_CUSTOMDATA_MERGE */
}
else {
BM_elem_attrs_copy(bm, bm, l_a_other, l_b);
@@ -1144,82 +1146,81 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
}
}
}
-#endif
- if (use_interpolate) {
- for (i = 0; i < iface_array_len; i++) {
- if (iface_array[i]) {
- bm_interp_face_free(iface_array[i], bm);
- }
+ if (use_interpolate) {
+ for (i = 0; i < iface_array_len; i++) {
+ if (iface_array[i]) {
+ bm_interp_face_free(iface_array[i], bm);
}
-
- BLI_memarena_free(interp_arena);
- MEM_freeN(iface_array);
}
- /* we could flag new edges/verts too, is it useful? */
- BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, ELE_NEW);
+ BLI_memarena_free(interp_arena);
+ MEM_freeN(iface_array);
+ }
- /* cheap feature to add depth to the inset */
- if (depth != 0.0f) {
- float(*varr_co)[3];
- BMOIter oiter;
-
- /* we need to re-calculate tagged normals, but for this purpose we can copy tagged verts from the
- * faces they inset from, */
- for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
- zero_v3(es->e_new->v1->no);
- zero_v3(es->e_new->v2->no);
- }
- for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
- const float *no = es->l->f->no;
- add_v3_v3(es->e_new->v1->no, no);
- add_v3_v3(es->e_new->v2->no, no);
+ /* we could flag new edges/verts too, is it useful? */
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "faces.out", BM_FACE, ELE_NEW);
+
+ /* cheap feature to add depth to the inset */
+ if (depth != 0.0f) {
+ float(*varr_co)[3];
+ BMOIter oiter;
+
+ /* We need to re-calculate tagged normals,
+ * but for this purpose we can copy tagged verts from the faces they inset from. */
+ for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
+ zero_v3(es->e_new->v1->no);
+ zero_v3(es->e_new->v2->no);
+ }
+ for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
+ const float *no = es->l->f->no;
+ add_v3_v3(es->e_new->v1->no, no);
+ add_v3_v3(es->e_new->v2->no, no);
+ }
+ for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
+ /* annoying, avoid normalizing twice */
+ if (len_squared_v3(es->e_new->v1->no) != 1.0f) {
+ normalize_v3(es->e_new->v1->no);
}
- for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
- /* annoying, avoid normalizing twice */
- if (len_squared_v3(es->e_new->v1->no) != 1.0f) {
- normalize_v3(es->e_new->v1->no);
- }
- if (len_squared_v3(es->e_new->v2->no) != 1.0f) {
- normalize_v3(es->e_new->v2->no);
- }
+ if (len_squared_v3(es->e_new->v2->no) != 1.0f) {
+ normalize_v3(es->e_new->v2->no);
}
- /* done correcting edge verts normals */
+ }
+ /* done correcting edge verts normals */
- /* untag verts */
- BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
+ /* untag verts */
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
- /* tag face verts */
- BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
- BM_ITER_ELEM (v, &iter, f, BM_VERTS_OF_FACE) {
- BM_elem_flag_enable(v, BM_ELEM_TAG);
- }
+ /* tag face verts */
+ BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
+ BM_ITER_ELEM (v, &iter, f, BM_VERTS_OF_FACE) {
+ BM_elem_flag_enable(v, BM_ELEM_TAG);
}
+ }
- /* do in 2 passes so moving the verts doesn't feed back into face angle checks
+ /* do in 2 passes so moving the verts doesn't feed back into face angle checks
* which BM_vert_calc_shell_factor uses. */
- /* over allocate */
- varr_co = MEM_callocN(sizeof(*varr_co) * bm->totvert, __func__);
+ /* over allocate */
+ varr_co = MEM_callocN(sizeof(*varr_co) * bm->totvert, __func__);
- BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- const float fac = (depth *
- (use_relative_offset ? bm_edge_info_average_length(v, edge_info) :
- 1.0f) *
- (use_even_boundary ? BM_vert_calc_shell_factor(v) : 1.0f));
- madd_v3_v3v3fl(varr_co[i], v->co, v->no, fac);
- }
+ BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ const float fac = (depth *
+ (use_relative_offset ? bm_edge_info_average_length(v, edge_info) :
+ 1.0f) *
+ (use_even_boundary ? BM_vert_calc_shell_factor(v) : 1.0f));
+ madd_v3_v3v3fl(varr_co[i], v->co, v->no, fac);
}
+ }
- BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- copy_v3_v3(v->co, varr_co[i]);
- }
+ BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ copy_v3_v3(v->co, varr_co[i]);
}
- MEM_freeN(varr_co);
}
-
- MEM_freeN(edge_info);
+ MEM_freeN(varr_co);
}
+
+ MEM_freeN(edge_info);
+}
diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c
index 9734dab7ca4..848669301c3 100644
--- a/source/blender/bmesh/operators/bmo_join_triangles.c
+++ b/source/blender/bmesh/operators/bmo_join_triangles.c
@@ -42,7 +42,8 @@ static float quad_calc_error(const float v1[3],
const float v3[3],
const float v4[3])
{
- /* gives a 'weight' to a pair of triangles that join an edge to decide how good a join they would make */
+ /* Gives a 'weight' to a pair of triangles that join an edge
+ * to decide how good a join they would make. */
/* Note: this is more complicated than it needs to be and should be cleaned up.. */
float error = 0.0f;
diff --git a/source/blender/bmesh/operators/bmo_normals.c b/source/blender/bmesh/operators/bmo_normals.c
index ee55165244b..b24afc0f8e6 100644
--- a/source/blender/bmesh/operators/bmo_normals.c
+++ b/source/blender/bmesh/operators/bmo_normals.c
@@ -44,7 +44,8 @@ static bool bmo_recalc_normal_loop_filter_cb(const BMLoop *l, void *UNUSED(user_
* This uses a more comprehensive test to see if the furthest face from the center
* is pointing towards the center or not.
*
- * A simple test could just check the dot product of the faces-normal and the direction from the center,
+ * A simple test could just check the dot product
+ * of the faces-normal and the direction from the center,
* however this can fail for faces which make a sharp spike. eg:
*
* <pre>
@@ -67,7 +68,8 @@ static bool bmo_recalc_normal_loop_filter_cb(const BMLoop *l, void *UNUSED(user_
*/
/**
- * \return a face index in \a faces and set \a r_is_flip if the face is flipped away from the center.
+ * \return a face index in \a faces and set \a r_is_flip
+ * if the face is flipped away from the center.
*/
static int recalc_face_normals_find_index(BMesh *bm,
BMFace **faces,
@@ -83,16 +85,23 @@ static int recalc_face_normals_find_index(BMesh *bm,
int f_start_index;
int i;
- /* Search for the best loop. Members are compared in-order defined here. */
+ /** Search for the best loop. Members are compared in-order defined here. */
struct {
- /* Squared distance from the center to the loops vertex 'l->v'.
- * The normalized direction between the center and this vertex is also used for the dot-products below. */
+ /**
+ * Squared distance from the center to the loops vertex 'l->v'.
+ * The normalized direction between the center and this vertex
+ * is also used for the dot-products below.
+ */
float dist_sq;
- /* Signed dot product using the normalized edge vector,
- * (best of 'l->prev->v' or 'l->next->v'). */
+ /**
+ * Signed dot product using the normalized edge vector,
+ * (best of 'l->prev->v' or 'l->next->v').
+ */
float edge_dot;
- /* Unsigned dot product using the loop-normal
- * (sign is used to check if we need to flip) */
+ /**
+ * Unsigned dot product using the loop-normal
+ * (sign is used to check if we need to flip).
+ */
float loop_dot;
} best, test;
@@ -247,13 +256,14 @@ static void bmo_recalc_face_normals_array(BMesh *bm,
}
}
-/*
- * put normal to the outside, and set the first direction flags in edges
+/**
+ * Put normal to the outside, and set the first direction flags in edges
*
- * then check the object, and set directions / direction-flags: but only for edges with 1 or 2 faces
- * this is in fact the 'select connected'
+ * then check the object, and set directions / direction-flags:
+ * but only for edges with 1 or 2 faces this is in fact the 'select connected'
*
- * in case all faces were not done: start over with 'find the ultimate ...' */
+ * in case all faces were not done: start over with 'find the ultimate ...'.
+ */
void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op)
{
diff --git a/source/blender/bmesh/operators/bmo_planar_faces.c b/source/blender/bmesh/operators/bmo_planar_faces.c
index ca336175f19..30aa473b2c7 100644
--- a/source/blender/bmesh/operators/bmo_planar_faces.c
+++ b/source/blender/bmesh/operators/bmo_planar_faces.c
@@ -56,8 +56,7 @@ void bmo_planar_faces_exec(BMesh *bm, BMOperator *op)
faces_center = MEM_mallocN(sizeof(*faces_center) * faces_num, __func__);
shared_vert_num = 0;
- BMO_ITER_INDEX(f, &oiter, op->slots_in, "faces", BM_FACE, i)
- {
+ BMO_ITER_INDEX (f, &oiter, op->slots_in, "faces", BM_FACE, i) {
BMLoop *l_iter, *l_first;
if (f->len == 3) {
@@ -84,8 +83,7 @@ void bmo_planar_faces_exec(BMesh *bm, BMOperator *op)
GHashIterator gh_iter;
bool changed = false;
- BMO_ITER_INDEX(f, &oiter, op->slots_in, "faces", BM_FACE, i)
- {
+ BMO_ITER_INDEX (f, &oiter, op->slots_in, "faces", BM_FACE, i) {
BMLoop *l_iter, *l_first;
float plane[4];
diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index bea7c56b1d4..cf3d6b8bf56 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -819,8 +819,7 @@ void BM_mesh_calc_uvs_grid(BMesh *bm,
continue;
}
- BM_ITER_ELEM_INDEX(l, &liter, f, BM_LOOPS_OF_FACE, loop_index)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, loop_index) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
switch (loop_index) {
@@ -942,8 +941,8 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
BMLoop *l;
BMIter fiter, liter;
- /* We cannot tag faces for UVs computing above, so we have to do it now, based on all its vertices
- * being tagged. */
+ /* We cannot tag faces for UVs computing above,
+ * so we have to do it now, based on all its vertices being tagged. */
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
bool valid = true;
@@ -1022,8 +1021,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
* so it's best to set the UVs right after the face is created. */
if (calc_uvs) {
int loop_index;
- BM_ITER_ELEM_INDEX(l, &liter, f, BM_LOOPS_OF_FACE, loop_index)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, loop_index) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
luv->uv[0] = icouvs[uvi][0];
luv->uv[1] = icouvs[uvi][1];
@@ -1077,8 +1075,7 @@ static void bm_mesh_calc_uvs_sphere_face(BMFace *f, const int cd_loop_uv_offset)
/* If face has 3 vertices, it's a polar face, in which case we need to
* compute a nearby to determine its latitude. */
float avgx = 0.0f, avgy = 0.0f;
- BM_ITER_ELEM_INDEX(l, &iter, f, BM_LOOPS_OF_FACE, loop_index)
- {
+ BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, loop_index) {
if (f->len == 3) {
avgx += l->v->co[0];
avgy += l->v->co[1];
@@ -1087,8 +1084,7 @@ static void bm_mesh_calc_uvs_sphere_face(BMFace *f, const int cd_loop_uv_offset)
avgx /= 3.0f;
avgy /= 3.0f;
- BM_ITER_ELEM_INDEX(l, &iter, f, BM_LOOPS_OF_FACE, loop_index)
- {
+ BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, loop_index) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
float x = l->v->co[0];
float y = l->v->co[1];
@@ -1164,8 +1160,7 @@ void BM_mesh_calc_uvs_sphere(BMesh *bm, const short oflag, const int cd_loop_uv_
if (!BMO_face_flag_test(bm, f, oflag)) {
continue;
}
- BM_ITER_ELEM_INDEX(l, &iter2, f, BM_LOOPS_OF_FACE, loop_index)
- {
+ BM_ITER_ELEM_INDEX (l, &iter2, f, BM_LOOPS_OF_FACE, loop_index) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (luv->uv[0] < minx) {
minx = luv->uv[0];
@@ -1177,8 +1172,7 @@ void BM_mesh_calc_uvs_sphere(BMesh *bm, const short oflag, const int cd_loop_uv_
if (!BMO_face_flag_test(bm, f, oflag)) {
continue;
}
- BM_ITER_ELEM_INDEX(l, &iter2, f, BM_LOOPS_OF_FACE, loop_index)
- {
+ BM_ITER_ELEM_INDEX (l, &iter2, f, BM_LOOPS_OF_FACE, loop_index) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
luv->uv[0] -= minx;
}
@@ -1543,7 +1537,8 @@ void BM_mesh_calc_uvs_cone(BMesh *bm,
const float uv_width = 1.0f / (float)segments;
const float uv_height = cap_ends ? 0.5f : 1.0f;
- /* Note that all this allows us to handle all cases (real cone, truncated cone, with or without ends capped)
+ /* Note that all this allows us to handle all cases
+ * (real cone, truncated cone, with or without ends capped)
* with a single common code. */
const float uv_center_y = cap_ends ? 0.25f : 0.5f;
const float uv_center_x_top = cap_ends ? 0.25f : 0.5f;
@@ -1582,8 +1577,7 @@ void BM_mesh_calc_uvs_cone(BMesh *bm,
if (f->len == 4 && radius_top && radius_bottom) {
/* side face - so unwrap it in a rectangle */
- BM_ITER_ELEM_INDEX(l, &liter, f, BM_LOOPS_OF_FACE, loop_index)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, loop_index) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
switch (loop_index) {
@@ -1608,7 +1602,8 @@ void BM_mesh_calc_uvs_cone(BMesh *bm,
}
}
else {
- /* top or bottom face - so unwrap it by transforming back to a circle and using the X/Y coords */
+ /* Top or bottom face - so unwrap it by transforming
+ * back to a circle and using the X/Y coords. */
BM_face_normal_update(f);
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
@@ -1720,8 +1715,7 @@ void BM_mesh_calc_uvs_cube(BMesh *bm, const short oflag)
continue;
}
- BM_ITER_ELEM_INDEX(l, &liter, f, BM_LOOPS_OF_FACE, loop_index)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, loop_index) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
luv->uv[0] = x;
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c
index 144d944e939..616886deba1 100644
--- a/source/blender/bmesh/operators/bmo_removedoubles.c
+++ b/source/blender/bmesh/operators/bmo_removedoubles.c
@@ -182,7 +182,8 @@ finally : {
}
/**
- * \note with 'targetmap', multiple 'keys' are currently supported, though no callers should be using.
+ * \note with 'targetmap', multiple 'keys' are currently supported,
+ * though no callers should be using.
* (because slot maps currently use GHash without the GHASH_FLAG_ALLOW_DUPES flag set)
*/
void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
@@ -428,7 +429,7 @@ void bmo_pointmerge_exec(BMesh *bm, BMOperator *op)
BMO_slot_vec_get(op->slots_in, "merge_co", vec);
- //BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges");
+ // BMO_op_callf(bm, op->flag, "collapse_uvs edges=%s", op, "edges");
BMO_op_init(bm, &weldop, op->flag, "weld_verts");
slot_targetmap = BMO_slot_get(weldop.slots_in, "targetmap");
diff --git a/source/blender/bmesh/operators/bmo_rotate_edges.c b/source/blender/bmesh/operators/bmo_rotate_edges.c
index e017806df0d..56eaac03970 100644
--- a/source/blender/bmesh/operators/bmo_rotate_edges.c
+++ b/source/blender/bmesh/operators/bmo_rotate_edges.c
@@ -116,8 +116,7 @@ static void bm_rotate_edges_shared(
BMOIter siter;
BMEdge *e;
uint i;
- BMO_ITER_INDEX(e, &siter, op->slots_in, "edges", BM_EDGE, i)
- {
+ BMO_ITER_INDEX (e, &siter, op->slots_in, "edges", BM_EDGE, i) {
BM_elem_index_set(e, BM_edge_is_manifold(e) ? i : -1); /* set_dirty! */
eheap_table[i] = NULL;
}
@@ -138,8 +137,7 @@ static void bm_rotate_edges_shared(
BMOIter siter;
BMEdge *e;
uint i;
- BMO_ITER_INDEX(e, &siter, op->slots_in, "edges", BM_EDGE, i)
- {
+ BMO_ITER_INDEX (e, &siter, op->slots_in, "edges", BM_EDGE, i) {
BLI_assert(eheap_table[i] == NULL);
bool ok = (BM_elem_index_get(e) != -1) && BM_edge_rotate_check(e);
@@ -153,14 +151,17 @@ static void bm_rotate_edges_shared(
if (ok) {
float cost = bm_edge_calc_rotate_cost(e);
if (pass_type == PASS_TYPE_BOUNDARY) {
- /* Trick to ensure once started, non boundaries are handled before other boundary edges.
+ /* Trick to ensure once started,
+ * non boundaries are handled before other boundary edges.
* This means the first longest boundary defines the starting point which is rotated
- * until all its connected edges are exhausted and the next boundary is popped off the heap.
+ * until all its connected edges are exhausted
+ * and the next boundary is popped off the heap.
*
* Without this we may rotate from different starting points and meet in the middle
* with obviously uneven topology.
*
- * Move from negative to positive value, inverting so large values are still handled first.
+ * Move from negative to positive value,
+ * inverting so large values are still handled first.
*/
cost = cost != 0.0f ? -1.0f / cost : FLT_MAX;
}
@@ -192,10 +193,12 @@ static void bm_rotate_edges_shared(
/* Note: we could validate all edges which have not been rotated
* (not just previously degenerate edges).
- * However there is no real need - they can be left until they're popped off the queue. */
+ * However there is no real need -
+ * they can be left until they're popped off the queue. */
/* We don't know the exact topology after rotating the edge,
- * so loop over all faces attached to the new edge, typically this will only be two faces. */
+ * so loop over all faces attached to the new edge,
+ * typically this will only be two faces. */
BMLoop *l_radial_iter = e_rotate->l;
do {
/* Skip this edge. */
diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
index 85f62241782..01bdf5d933a 100644
--- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c
+++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c
@@ -205,8 +205,7 @@ static void init_laplacian_matrix(LaplacianSystem *sys)
BM_ITER_MESH (f, &fiter, sys->bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
- BM_ITER_ELEM_INDEX(vn, &vi, f, BM_VERTS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) {
vf[i] = vn;
}
has_4_vert = (i == 4) ? 1 : 0;
@@ -305,8 +304,7 @@ static void fill_laplacian_matrix(LaplacianSystem *sys)
BM_ITER_MESH (f, &fiter, sys->bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
- BM_ITER_ELEM_INDEX(vn, &vi, f, BM_VERTS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) {
vf[i] = vn;
}
has_4_vert = (i == 4) ? 1 : 0;
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 869c61832f9..74635be4681 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -40,7 +40,7 @@ typedef struct SubDParams {
int smooth_falloff;
float fractal;
float along_normal;
- //int beauty;
+ // int beauty;
bool use_smooth;
bool use_smooth_even;
bool use_sphere;
@@ -391,7 +391,7 @@ static BMVert *bm_subdivide_edge_addvert(BMesh *bm,
/* offset for smooth or sphere or fractal */
alter_co(v_new, e_orig, params, factor_subd, v_a, v_b);
-#if 0 //BMESH_TODO
+#if 0 // BMESH_TODO
/* clip if needed by mirror modifier */
if (edge->v1->f2) {
if (edge->v1->f2 & edge->v2->f2 & 1) {
@@ -1042,8 +1042,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
BLI_array_grow_items(verts, face->len);
totesel = 0;
- BM_ITER_ELEM_INDEX(l_new, &liter, face, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l_new, &liter, face, BM_LOOPS_OF_FACE, i) {
edges[i] = l_new->e;
verts[i] = l_new->v;
@@ -1181,8 +1180,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
/* for case of two edges, connecting them shouldn't be too hard */
BLI_array_grow_items(loops, face->len);
- BM_ITER_ELEM_INDEX(l, &liter, face, BM_LOOPS_OF_FACE, a)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, face, BM_LOOPS_OF_FACE, a) {
loops[a] = l;
}
@@ -1283,8 +1281,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
}
a = 0;
- BM_ITER_ELEM_INDEX(l_new, &liter, face, BM_LOOPS_OF_FACE, j)
- {
+ BM_ITER_ELEM_INDEX (l_new, &liter, face, BM_LOOPS_OF_FACE, j) {
if (l_new->v == fd->start) {
a = j + 1;
break;
@@ -1293,8 +1290,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
BLI_array_grow_items(verts, face->len);
- BM_ITER_ELEM_INDEX(l_new, &liter, face, BM_LOOPS_OF_FACE, j)
- {
+ BM_ITER_ELEM_INDEX (l_new, &liter, face, BM_LOOPS_OF_FACE, j) {
b = (j - a + face->len) % face->len;
verts[b] = l_new->v;
}
diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
index c6d2910d214..6baf56f1723 100644
--- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c
+++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c
@@ -1183,8 +1183,7 @@ void bmo_subdivide_edgering_exec(BMesh *bm, BMOperator *op)
lpair_arr = BLI_array_alloca(lpair_arr, BLI_gset_len(eloop_pairs_gs));
/* first cache pairs */
- GSET_ITER_INDEX(gs_iter, eloop_pairs_gs, i)
- {
+ GSET_ITER_INDEX (gs_iter, eloop_pairs_gs, i) {
GHashPair *eloop_pair = BLI_gsetIterator_getKey(&gs_iter);
struct BMEdgeLoopStore *el_store_a = (void *)eloop_pair->first;
struct BMEdgeLoopStore *el_store_b = (void *)eloop_pair->second;
@@ -1201,8 +1200,7 @@ void bmo_subdivide_edgering_exec(BMesh *bm, BMOperator *op)
BLI_assert(bm_verts_tag_count(bm) == 0);
}
- GSET_ITER_INDEX(gs_iter, eloop_pairs_gs, i)
- {
+ GSET_ITER_INDEX (gs_iter, eloop_pairs_gs, i) {
GHashPair *eloop_pair = BLI_gsetIterator_getKey(&gs_iter);
struct BMEdgeLoopStore *el_store_a = (void *)eloop_pair->first;
struct BMEdgeLoopStore *el_store_b = (void *)eloop_pair->second;
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index 6495f2b0afe..bc06d5e454b 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -503,15 +503,13 @@ static void bm_face_reverse_uvs(BMFace *f, const int cd_loop_uv_offset)
float(*uvs)[2] = BLI_array_alloca(uvs, f->len);
- BM_ITER_ELEM_INDEX(l, &iter, f, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, i) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
copy_v2_v2(uvs[i], luv->uv);
}
/* now that we have the uvs in the array, reverse! */
- BM_ITER_ELEM_INDEX(l, &iter, f, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, i) {
/* current loop uv is the previous loop uv */
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
copy_v2_v2(luv->uv, uvs[(f->len - i - 1)]);
@@ -607,15 +605,13 @@ static void bm_face_reverse_colors(BMFace *f, const int cd_loop_color_offset)
MLoopCol *cols = BLI_array_alloca(cols, f->len);
- BM_ITER_ELEM_INDEX(l, &iter, f, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, i) {
MLoopCol *lcol = BM_ELEM_CD_GET_VOID_P(l, cd_loop_color_offset);
cols[i] = *lcol;
}
/* now that we have the uvs in the array, reverse! */
- BM_ITER_ELEM_INDEX(l, &iter, f, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, i) {
/* current loop uv is the previous loop color */
MLoopCol *lcol = BM_ELEM_CD_GET_VOID_P(l, cd_loop_color_offset);
*lcol = cols[(f->len - i - 1)];
diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c
index e8a49c895ab..00368364616 100644
--- a/source/blender/bmesh/tools/bmesh_beautify.c
+++ b/source/blender/bmesh/tools/bmesh_beautify.c
@@ -66,15 +66,24 @@ static int erot_gsetutil_cmp(const void *a, const void *b)
{
const EdRotState *e_state_a = (const EdRotState *)a;
const EdRotState *e_state_b = (const EdRotState *)b;
- if (e_state_a->v1 < e_state_b->v1) return -1;
- else if (e_state_a->v1 > e_state_b->v1) return 1;
- else if (e_state_a->v2 < e_state_b->v2) return -1;
- else if (e_state_a->v2 > e_state_b->v2) return 1;
- else if (e_state_a->f1 < e_state_b->f1) return -1;
- else if (e_state_a->f1 > e_state_b->f1) return 1;
- else if (e_state_a->f2 < e_state_b->f2) return -1;
- else if (e_state_a->f2 > e_state_b->f2) return 1;
- else return 0;
+ if (e_state_a->v1 < e_state_b->v1)
+ return -1;
+ else if (e_state_a->v1 > e_state_b->v1)
+ return 1;
+ else if (e_state_a->v2 < e_state_b->v2)
+ return -1;
+ else if (e_state_a->v2 > e_state_b->v2)
+ return 1;
+ else if (e_state_a->f1 < e_state_b->f1)
+ return -1;
+ else if (e_state_a->f1 > e_state_b->f1)
+ return 1;
+ else if (e_state_a->f2 < e_state_b->f2)
+ return -1;
+ else if (e_state_a->f2 > e_state_b->f2)
+ return 1;
+ else
+ return 0;
}
#endif
static GSet *erot_gset_new(void)
@@ -178,7 +187,8 @@ static float bm_edge_calc_rotate_beauty__area(const float v1[3],
/**
* Important to lock degenerate here,
* since the triangle pars will be projected into different 2D spaces.
- * Allowing to rotate out of a degenerate state can flip the faces (when performed iteratively).
+ * Allowing to rotate out of a degenerate state can flip the faces
+ * (when performed iteratively).
*/
return BLI_polyfill_beautify_quad_rotate_calc_ex(v1_xy, v2_xy, v3_xy, v4_xy, true);
} while (false);
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 2c304d790df..af5ce4ed9ac 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -131,22 +131,36 @@ typedef struct ProfileSpacing {
/* An element in a cyclic boundary of a Vertex Mesh (VMesh) */
typedef struct BoundVert {
- struct BoundVert *next, *prev; /* in CCW order */
+ /** In CCW order. */
+ struct BoundVert *next, *prev;
NewVert nv;
- EdgeHalf *efirst; /* first of edges attached here: in CCW order */
+ /** First of edges attached here: in CCW order. */
+ EdgeHalf *efirst;
EdgeHalf *elast;
- EdgeHalf *eon; /* the "edge between" that this is on, in offset_on_edge_between case */
- EdgeHalf *ebev; /* beveled edge whose left side is attached here, if any */
- int index; /* used for vmesh indexing */
- float sinratio; /* when eon set, ratio of sines of angles to eon edge */
- struct BoundVert *adjchain; /* adjustment chain or cycle link pointer */
- Profile profile; /* edge profile between this and next BoundVert */
- bool any_seam; /* are any of the edges attached here seams? */
- bool visited; /* used during delta adjust pass */
- bool is_arc_start; /* this boundvert begins an arc profile */
- bool is_patch_start; /* this boundvert begins a patch profile */
- int seam_len; /* length of seam starting from current boundvert to next boundvert with ccw ordering */
- int sharp_len; /* Same as seam_len but defines length of sharp edges */
+ /** The "edge between" that this is on, in offset_on_edge_between case. */
+ EdgeHalf *eon;
+ /** Beveled edge whose left side is attached here, if any. */
+ EdgeHalf *ebev;
+ /** Used for vmesh indexing. */
+ int index;
+ /** When eon set, ratio of sines of angles to eon edge. */
+ float sinratio;
+ /** Adjustment chain or cycle link pointer. */
+ struct BoundVert *adjchain;
+ /** Edge profile between this and next BoundVert. */
+ Profile profile;
+ /** Are any of the edges attached here seams? */
+ bool any_seam;
+ /** Used during delta adjust pass */
+ bool visited;
+ /** This boundvert begins an arc profile */
+ bool is_arc_start;
+ /** This boundvert begins a patch profile */
+ bool is_patch_start;
+ /** Length of seam starting from current boundvert to next boundvert with ccw ordering */
+ int seam_len;
+ /** Same as seam_len but defines length of sharp edges */
+ int sharp_len;
// int _pad;
} BoundVert;
@@ -167,78 +181,122 @@ typedef struct VMesh {
/* Data for a vertex involved in a bevel */
typedef struct BevVert {
- BMVert *v; /* original mesh vertex */
- int edgecount; /* total number of edges around the vertex (excluding wire edges if edge beveling) */
- int selcount; /* number of selected edges around the vertex */
- int wirecount; /* count of wire edges */
- float offset; /* offset for this vertex, if vertex_only bevel */
- bool any_seam; /* any seams on attached edges? */
- bool visited; /* used in graph traversal */
- EdgeHalf *edges; /* array of size edgecount; CCW order from vertex normal side */
- BMEdge **wire_edges; /* array of size wirecount of wire edges */
- VMesh *vmesh; /* mesh structure for replacing vertex */
+ /** Original mesh vertex */
+ BMVert *v;
+ /** Total number of edges around the vertex (excluding wire edges if edge beveling) */
+ int edgecount;
+ /** Number of selected edges around the vertex */
+ int selcount;
+ /** Count of wire edges */
+ int wirecount;
+ /** Offset for this vertex, if vertex_only bevel */
+ float offset;
+ /** Any seams on attached edges? */
+ bool any_seam;
+ /** Used in graph traversal */
+ bool visited;
+ /** Array of size edgecount; CCW order from vertex normal side */
+ EdgeHalf *edges;
+ /** Array of size wirecount of wire edges */
+ BMEdge **wire_edges;
+ /** Mesh structure for replacing vertex */
+ VMesh *vmesh;
} BevVert;
/* face classification: note depend on F_RECON > F_EDGE > F_VERT */
typedef enum {
- F_NONE, /* used when there is no face at all */
- F_ORIG, /* original face, not touched */
- F_VERT, /* face for construction aroun a vert */
- F_EDGE, /* face for a beveled edge */
- F_RECON, /* reconstructed original face with some new verts */
+ /** Used when there is no face at all */
+ F_NONE,
+ /** Original face, not touched */
+ F_ORIG,
+ /** Face for construction aroun a vert */
+ F_VERT,
+ /** Face for a beveled edge */
+ F_EDGE,
+ /** Reconstructed original face with some new verts */
+ F_RECON,
} FKind;
-// static const char* fkind_names[] = {"F_NONE", "F_ORIG", "F_VERT", "F_EDGE", "F_RECON"}; /* DEBUG */
+#if 0
+static const char* fkind_names[] = {"F_NONE", "F_ORIG", "F_VERT", "F_EDGE", "F_RECON"}; /* DEBUG */
+#endif
/* Bevel parameters and state */
typedef struct BevelParams {
- GHash *vert_hash; /* records BevVerts made: key BMVert*, value BevVert* */
- GHash *face_hash; /* records new faces: key BMFace*, value one of {VERT/EDGE/RECON}_POLY */
- MemArena *
- mem_arena; /* use for all allocs while bevel runs, if we need to free we can switch to mempool */
- ProfileSpacing pro_spacing; /* parameter values for evenly spaced profiles */
-
- float offset; /* blender units to offset each side of a beveled edge */
- int offset_type; /* how offset is measured; enum defined in bmesh_operators.h */
- int seg; /* number of segments in beveled edge profile */
- float profile; /* user profile setting */
- float pro_super_r; /* superellipse parameter for edge profile */
- bool vertex_only; /* bevel vertices only */
- bool use_weights; /* bevel amount affected by weights on edges or verts */
- bool loop_slide; /* should bevel prefer to slide along edges rather than keep widths spec? */
- bool limit_offset; /* should offsets be limited by collisions? */
- bool offset_adjust; /* should offsets be adjusted to try to get even widths? */
- bool mark_seam; /* should we propagate seam edge markings? */
- bool mark_sharp; /* should we propagate sharp edge markings? */
- bool harden_normals; /* should we harden normals? */
- const struct MDeformVert *dvert; /* vertex group array, maybe set if vertex_only */
- int vertex_group; /* vertex group index, maybe set if vertex_only */
- int mat_nr; /* if >= 0, material number for bevel; else material comes from adjacent faces */
- int face_strength_mode; /* setting face strength if > 0 */
- int miter_outer; /* what kind of miter pattern to use on reflex angles */
- int miter_inner; /* what kind of miter pattern to use on non-reflex angles */
- float spread; /* amount to spread when doing inside miter */
- float smoothresh; /* mesh's smoothresh, used if hardening */
+ /** Records BevVerts made: key BMVert*, value BevVert* */
+ GHash *vert_hash;
+ /** Records new faces: key BMFace*, value one of {VERT/EDGE/RECON}_POLY */
+ GHash *face_hash;
+ /** Use for all allocs while bevel runs, if we need to free we can switch to mempool. */
+ MemArena *mem_arena;
+ /** Parameter values for evenly spaced profiles. */
+ ProfileSpacing pro_spacing;
+
+ /** Blender units to offset each side of a beveled edge. */
+ float offset;
+ /** How offset is measured; enum defined in bmesh_operators.h */
+ int offset_type;
+ /** Number of segments in beveled edge profile. */
+ int seg;
+ /** User profile setting. */
+ float profile;
+ /** Superellipse parameter for edge profile. */
+ float pro_super_r;
+ /** Bevel vertices only. */
+ bool vertex_only;
+ /** Bevel amount affected by weights on edges or verts. */
+ bool use_weights;
+ /** Should bevel prefer to slide along edges rather than keep widths spec? */
+ bool loop_slide;
+ /** Should offsets be limited by collisions? */
+ bool limit_offset;
+ /** Should offsets be adjusted to try to get even widths? */
+ bool offset_adjust;
+ /** Should we propagate seam edge markings? */
+ bool mark_seam;
+ /** Should we propagate sharp edge markings? */
+ bool mark_sharp;
+ /** Should we harden normals? */
+ bool harden_normals;
+ /** Vertex group array, maybe set if vertex_only. */
+ const struct MDeformVert *dvert;
+ /** Vertex group index, maybe set if vertex_only. */
+ int vertex_group;
+ /** If >= 0, material number for bevel; else material comes from adjacent faces. */
+ int mat_nr;
+ /** Setting face strength if > 0. */
+ int face_strength_mode;
+ /** What kind of miter pattern to use on reflex angles. */
+ int miter_outer;
+ /** What kind of miter pattern to use on non-reflex angles. */
+ int miter_inner;
+ /** Amount to spread when doing inside miter. */
+ float spread;
+ /** Mesh's smoothresh, used if hardening. */
+ float smoothresh;
} BevelParams;
// #pragma GCC diagnostic ignored "-Wpadded"
// #include "bevdebug.c"
-/* some flags to re-enable old behavior for a while, in case fixes broke things not caught by regression tests */
+/* Some flags to re-enable old behavior for a while,
+ * in case fixes broke things not caught by regression tests. */
static int bev_debug_flags = 0;
#define DEBUG_OLD_PLANE_SPECIAL (bev_debug_flags & 1)
#define DEBUG_OLD_PROJ_TO_PERP_PLANE (bev_debug_flags & 2)
#define DEBUG_OLD_FLAT_MID (bev_debug_flags & 4)
-/* use the unused _BM_ELEM_TAG_ALT flag to flag the 'long' loops (parallel to beveled edge) of edge-polygons */
+/* use the unused _BM_ELEM_TAG_ALT flag to flag the 'long' loops (parallel to beveled edge)
+ * of edge-polygons. */
#define BM_ELEM_LONG_TAG (1 << 6)
/* these flag values will get set on geom we want to return in 'out' slots for edges and verts */
#define EDGE_OUT 4
#define VERT_OUT 8
-/* If we're called from the modifier, tool flags aren't available, but don't need output geometry */
+/* If we're called from the modifier, tool flags aren't available,
+ * but don't need output geometry. */
static void flag_out_edge(BMesh *bm, BMEdge *bme)
{
if (bm->use_toolflags) {
@@ -622,7 +680,8 @@ static bool contig_ldata_across_loops(BMesh *bm, BMLoop *l1, BMLoop *l2, int lay
type, (char *)l1->head.data + offset, (char *)l2->head.data + offset);
}
-/* Are all loop layers with have math (e.g., UVs) contiguous from face f1 to face f2 across edge e? */
+/* Are all loop layers with have math (e.g., UVs)
+ * contiguous from face f1 to face f2 across edge e? */
static bool contig_ldata_across_edge(BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f2)
{
BMLoop *lef1, *lef2;
@@ -867,8 +926,8 @@ static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1,
* but if the offsets are not equal (allowing for this, as bevel modifier has edge weights that may
* lead to different offsets) then meeting point can be found be intersecting offset lines.
* If making the meeting point significantly changes the left or right offset from the user spec,
- * record the change in offset_l (or offset_r); later we can tell that a change has happened because
- * the offset will differ from its original value in offset_l_spec (or offset_r_spec).
+ * record the change in offset_l (or offset_r); later we can tell that a change has happened
+ * because the offset will differ from its original value in offset_l_spec (or offset_r_spec).
*/
static void offset_meet(
EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool edges_between, float meetco[3])
@@ -1024,7 +1083,8 @@ static void offset_meet(
}
}
-/* chosen so that 1/sin(BEVEL_GOOD_ANGLE) is about 4, giving that expansion factor to bevel width */
+/* Chosen so that 1/sin(BEVEL_GOOD_ANGLE) is about 4,
+ * giving that expansion factor to bevel width. */
#define BEVEL_GOOD_ANGLE 0.25f
/* Calculate the meeting point between e1 and e2 (one of which should have zero offsets),
@@ -1780,7 +1840,8 @@ static void bevel_extend_edge_data(BevVert *bv)
for (int k = 1; k < vm->seg; k++) {
v2 = mesh_vert(vm, i % vm->count, 0, k)->v;
- /* Here v1 & v2 are current and next BMverts, we find common edge and set its edge data */
+ /* Here v1 & v2 are current and next BMverts,
+ * we find common edge and set its edge data. */
e = v1->e;
while (e->v1 != v2 && e->v2 != v2) {
if (e->v1 == v1) {
@@ -1794,7 +1855,7 @@ static void bevel_extend_edge_data(BevVert *bv)
v1 = v2;
}
BMVert *v3 = mesh_vert(vm, (i + 1) % vm->count, 0, 0)->v;
- e = v1->e; //Do same as above for first and last vert
+ e = v1->e; // Do same as above for first and last vert
while (e->v1 != v3 && e->v2 != v3) {
if (e->v1 == v1) {
e = e->v1_disk_link.next;
@@ -1918,14 +1979,16 @@ static void bevel_harden_normals(BMesh *bm, BevelParams *bp)
/* If there is not already a custom split normal layer then making one (with BM_lnorspace_update)
* will not respect the autosmooth angle between smooth faces. To get that to happen, we have
- * to mark the sharpen the edges that are only sharp because of the angle test -- otherwise would be smooth.
+ * to mark the sharpen the edges that are only sharp because
+ * of the angle test -- otherwise would be smooth.
*/
if (cd_clnors_offset == -1) {
BM_edges_sharp_from_angle_set(bm, bp->smoothresh);
bevel_edges_sharp_boundary(bm, bp);
}
- /* ensure that bm->lnor_spacearr has properly stored loop normals; side effect: ensures loop indices */
+ /* Ensure that bm->lnor_spacearr has properly stored loop normals;
+ * side effect: ensures loop indices. */
BM_lnorspace_update(bm);
if (cd_clnors_offset == -1) {
@@ -2990,11 +3053,13 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm)
/* find and process chains and cycles of unvisited BoundVerts that have eon set */
/* note: for repeatability, iterate over all verts of mesh rather than over ghash'ed BMVerts */
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(bmv, BM_ELEM_TAG))
+ if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
+ }
bv = bvcur = find_bevvert(bp, bmv);
- if (!bv)
+ if (!bv) {
continue;
+ }
vanchor = bv->vmesh->boundstart;
do {
if (vanchor->visited || !vanchor->eon) {
@@ -3068,8 +3133,9 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm)
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
bv = find_bevvert(bp, bmv);
- if (bv)
+ if (bv) {
build_boundary(bp, bv, false);
+ }
}
}
}
@@ -3140,7 +3206,8 @@ static VMesh *new_adj_vmesh(MemArena *mem_arena, int count, int seg, BoundVert *
return vm;
}
-/* VMesh verts for vertex i have data for (i, 0 <= j <= ns2, 0 <= k <= ns), where ns2 = floor(nseg / 2).
+/* VMesh verts for vertex i have data for (i, 0 <= j <= ns2, 0 <= k <= ns),
+ * where ns2 = floor(nseg / 2).
* But these overlap data from previous and next i: there are some forced equivalences.
* Let's call these indices the canonical ones: we will just calculate data for these
* 0 <= j <= ns2, 0 <= k < ns2 (for odd ns2)
@@ -4145,13 +4212,15 @@ static void closer_v3_v3v3v3(float r[3], float a[3], float b[3], float v[3])
}
/* Special case of VMesh when profile == 1 and there are 3 or more beveled edges.
- * We want the effect of parallel offset lines (n/2 of them) on each side of the center, for even n.
- * Wherever they intersect with each other between two successive beveled edges, those intersections
- * are part of the vmesh rings.
+ * We want the effect of parallel offset lines (n/2 of them)
+ * on each side of the center, for even n.
+ * Wherever they intersect with each other between two successive beveled edges,
+ * those intersections are part of the vmesh rings.
* We have to move the boundary edges too -- the usual method is to make one profile plane between
- * successive BoundVerts, but for the effect we want here, there will be two planes, one on each side
- * of the original edge.
- * At the moment, this is not called for odd number of segments, though code does something if it is.
+ * successive BoundVerts, but for the effect we want here, there will be two planes,
+ * one on each side of the original edge.
+ * At the moment, this is not called for odd number of segments,
+ * though code does something if it is.
*/
static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv)
{
@@ -4571,8 +4640,9 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv)
/* If we make a poly out of verts around bv, snapping to rep frep, will uv poly have zero area?
* The uv poly is made by snapping all outside-of-frep vertices to the closest edge in frep.
* Assume that this function is called when the only inside-of-frep vertex is vm->boundstart.
- * The poly will have zero area if the distance of that first vertex to some edge e is zero, and all
- * the other vertices snap to e or snap to an edge at a point that is essentially on e too. */
+ * The poly will have zero area if the distance of that first vertex to some edge e is zero,
+ * and all the other vertices snap to e or snap to an edge
+ * at a point that is essentially on e too. */
static bool is_bad_uv_poly(BevVert *bv, BMFace *frep)
{
BoundVert *v;
@@ -4955,7 +5025,8 @@ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i)
}
/* at this point we should be back at invariant on entrance: path up to j */
if (bestj > j) {
- /* save_path should have from j + 1 to bestj inclusive edges to add to edges[] before returning */
+ /* save_path should have from j + 1 to bestj inclusive
+ * edges to add to edges[] before returning. */
for (k = j + 1; k <= bestj; k++) {
BLI_assert(save_path[k - (j + 1)] != NULL);
bv->edges[k].e = save_path[k - (j + 1)];
@@ -4975,9 +5046,10 @@ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i)
* Assume the first edge is already in bv->edges[0].e and it is tagged. */
#ifdef FASTER_FASTORDER
/* The alternative older code is O(n^2) where n = # of edges incident to bv->v.
- * This implementation is O(n * m) where m = average number of faces attached to an edge incident to bv->v,
- * which is almost certainly a small constant except in very strange cases. But this code produces different
- * choices of ordering than the legacy system, leading to differences in vertex orders etc. in user models,
+ * This implementation is O(n * m) where m = average number of faces attached to an edge incident
+ * to bv->v, which is almost certainly a small constant except in very strange cases.
+ * But this code produces different choices of ordering than the legacy system,
+ * leading to differences in vertex orders etc. in user models,
* so for now will continue to use the legacy code. */
static bool fast_bevel_edge_order(BevVert *bv)
{
@@ -5150,6 +5222,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
BMIter iter;
EdgeHalf *e;
float weight, z;
+ float vert_axis[3];
int i, ccw_test_sum;
int nsel = 0;
int ntot = 0;
@@ -5218,21 +5291,6 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
bv->vmesh = (VMesh *)BLI_memarena_alloc(bp->mem_arena, sizeof(VMesh));
bv->vmesh->seg = bp->seg;
- if (bp->vertex_only) {
- /* if weighted, modify offset by weight */
- if (bp->dvert != NULL && bp->vertex_group != -1) {
- weight = defvert_find_weight(bp->dvert + BM_elem_index_get(v), bp->vertex_group);
- if (weight <= 0.0f) {
- BM_elem_flag_disable(v, BM_ELEM_TAG);
- return NULL;
- }
- bv->offset *= weight;
- }
- else if (bp->use_weights) {
- weight = BM_elem_float_data_get(&bm->vdata, v, CD_BWEIGHT);
- bv->offset *= weight;
- }
- }
BLI_ghash_insert(bp->vert_hash, v, bv);
find_bevel_edge_order(bm, bv, first_bme);
@@ -5280,6 +5338,29 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
}
}
+ if (bp->vertex_only) {
+ /* if weighted, modify offset by weight */
+ if (bp->dvert != NULL && bp->vertex_group != -1) {
+ weight = defvert_find_weight(bp->dvert + BM_elem_index_get(v), bp->vertex_group);
+ bv->offset *= weight;
+ }
+ else if (bp->use_weights) {
+ weight = BM_elem_float_data_get(&bm->vdata, v, CD_BWEIGHT);
+ bv->offset *= weight;
+ }
+ /* Find center axis. Note: Don't use vert normal, can give unwanted results. */
+ if (ELEM(bp->offset_type, BEVEL_AMT_WIDTH, BEVEL_AMT_DEPTH)) {
+ float edge_dir[3];
+ for (i = 0, e = bv->edges; i < ntot; i++, e++) {
+ v2 = BM_edge_other_vert(e->e, bv->v);
+ sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
+ normalize_v3(edge_dir);
+ add_v3_v3v3(vert_axis, vert_axis, edge_dir);
+ }
+ mul_v3_fl(vert_axis, 1 / ntot);
+ }
+ }
+
for (i = 0, e = bv->edges; i < ntot; i++, e++) {
e->next = &bv->edges[(i + 1) % ntot];
e->prev = &bv->edges[(i + ntot - 1) % ntot];
@@ -5339,13 +5420,43 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
}
else if (bp->vertex_only) {
/* Weight has already been applied to bv->offset, if present.
- * Transfer to e->offset_[lr]_spec and treat percent as special case */
- if (bp->offset_type == BEVEL_AMT_PERCENT) {
- v2 = BM_edge_other_vert(e->e, bv->v);
- e->offset_l_spec = BM_edge_calc_length(e->e) * bv->offset / 100.0f;
- }
- else {
- e->offset_l_spec = bv->offset;
+ * Transfer to e->offset_[lr]_spec according to offset_type. */
+ float edge_dir[3];
+ switch (bp->offset_type) {
+ case BEVEL_AMT_OFFSET: {
+ e->offset_l_spec = bv->offset;
+ break;
+ }
+ case BEVEL_AMT_WIDTH: {
+ v2 = BM_edge_other_vert(e->e, bv->v);
+ sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
+ normalize_v3(edge_dir);
+ z = fabsf(2.0f * sinf(angle_normalized_v3v3(vert_axis, edge_dir)));
+ if (z < BEVEL_EPSILON) {
+ e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel. */
+ }
+ else {
+ e->offset_l_spec = bp->offset / z;
+ }
+ break;
+ }
+ case BEVEL_AMT_DEPTH: {
+ v2 = BM_edge_other_vert(e->e, bv->v);
+ sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
+ normalize_v3(edge_dir);
+ z = fabsf(cosf(angle_normalized_v3v3(vert_axis, edge_dir)));
+ if (z < BEVEL_EPSILON) {
+ e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel. */
+ }
+ else {
+ e->offset_l_spec = bp->offset / z;
+ }
+ break;
+ }
+ case BEVEL_AMT_PERCENT: {
+ e->offset_l_spec = BM_edge_calc_length(e->e) * bv->offset / 100.0f;
+ break;
+ }
}
e->offset_r_spec = e->offset_l_spec;
}
@@ -6357,11 +6468,13 @@ static void bevel_limit_offset(BevelParams *bp, BMesh *bm)
limited_offset = bp->offset;
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(bmv, BM_ELEM_TAG))
+ if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
+ }
bv = find_bevvert(bp, bmv);
- if (!bv)
+ if (!bv) {
continue;
+ }
for (i = 0; i < bv->edgecount; i++) {
eh = &bv->edges[i];
if (bp->vertex_only) {
@@ -6387,11 +6500,13 @@ static void bevel_limit_offset(BevelParams *bp, BMesh *bm)
*/
offset_factor = limited_offset / bp->offset;
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(bmv, BM_ELEM_TAG))
+ if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
+ }
bv = find_bevvert(bp, bmv);
- if (!bv)
+ if (!bv) {
continue;
+ }
for (i = 0; i < bv->edgecount; i++) {
eh = &bv->edges[i];
eh->offset_l_spec *= offset_factor;
@@ -6500,8 +6615,9 @@ void BM_mesh_bevel(BMesh *bm,
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
bv = find_bevvert(&bp, v);
- if (bv)
+ if (bv) {
build_boundary(&bp, bv, true);
+ }
}
}
}
@@ -6534,8 +6650,9 @@ void BM_mesh_bevel(BMesh *bm,
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
bv = find_bevvert(&bp, v);
- if (bv)
+ if (bv) {
bevel_extend_edge_data(bv);
+ }
}
}
diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c
index f314ae6848b..8ae0dfecf55 100644
--- a/source/blender/bmesh/tools/bmesh_bisect_plane.c
+++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c
@@ -456,8 +456,7 @@ void BM_mesh_bisect_plane(BMesh *bm,
/* check if either edge verts are aligned,
* if so - tag and push all faces that use it into the stack */
uint j;
- BM_ITER_ELEM_INDEX(v, &iter, e, BM_VERTS_OF_EDGE, j)
- {
+ BM_ITER_ELEM_INDEX (v, &iter, e, BM_VERTS_OF_EDGE, j) {
if (side[j] == 0) {
if (vert_is_center_test(v) == 0) {
BMIter itersub;
diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index 3838f199847..da525becc78 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -204,7 +204,7 @@ static bool bm_edge_collapse_is_degenerate_flip(BMEdge *e, const float optimize_
/* use a small value rather then zero so we don't flip a face in multiple steps
* (first making it zero area, then flipping again) */
if (dot_v3v3(cross_exist, cross_optim) <= FLT_EPSILON) {
- //printf("no flip\n");
+ // printf("no flip\n");
return true;
}
#endif
@@ -690,7 +690,8 @@ static void bm_decim_triangulate_end(BMesh *bm, const int edges_tri_tot)
static void bm_edge_collapse_loop_customdata(
BMesh *bm, BMLoop *l, BMVert *v_clear, BMVert *v_other, const float customdata_fac)
{
- /* disable seam check - the seam check would have to be done per layer, its not really that important */
+ /* Disable seam check - the seam check would have to be done per layer,
+ * its not really that important. */
//#define USE_SEAM
/* these don't need to be updated, since they will get removed when the edge collapses */
BMLoop *l_clear, *l_other;
diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
index 0fbb2d14766..010245fa93d 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c
@@ -350,7 +350,8 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm,
BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) {
earray[i] = e_iter;
}
- /* remove all edges/verts left behind from dissolving, NULL'ing the vertex array so we dont re-use */
+ /* Remove all edges/verts left behind from dissolving,
+ * NULL'ing the vertex array so we dont re-use. */
for (i = bm->totedge - 1; i != -1; i--) {
e_iter = earray[i];
diff --git a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
index 13ada1756de..27b4fa15f26 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c
@@ -264,7 +264,7 @@ void BM_mesh_decimate_unsubdivide_ex(BMesh *bm, const int iterations, const bool
}
else {
/* works better to allow these verts to be checked again */
- //BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */
+ // BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */
}
}
}
diff --git a/source/blender/bmesh/tools/bmesh_edgesplit.c b/source/blender/bmesh/tools/bmesh_edgesplit.c
index 332672d7c3c..388e7f41aba 100644
--- a/source/blender/bmesh/tools/bmesh_edgesplit.c
+++ b/source/blender/bmesh/tools/bmesh_edgesplit.c
@@ -78,11 +78,12 @@ void BM_mesh_edgesplit(BMesh *bm,
}
}
}
-
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
- BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
- BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
+ else {
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
+ BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
+ }
}
}
diff --git a/source/blender/bmesh/tools/bmesh_path_region.c b/source/blender/bmesh/tools/bmesh_path_region.c
index 9ec3b51f29a..8b139e6a5ff 100644
--- a/source/blender/bmesh/tools/bmesh_path_region.c
+++ b/source/blender/bmesh/tools/bmesh_path_region.c
@@ -116,7 +116,8 @@ static bool bm_vert_region_test_chain(BMVert *v, int *const depths[2], const int
*
* This is done in both directions, after that each vertices 'depth' is added to check
* if its less than the number of passes needed to complete the search.
- * When it is, we know the path is one of possible paths that have the minimum topological distance.
+ * When it is, we know the path is one of possible paths
+ * that have the minimum topological distance.
*
* \note Only verts without BM_ELEM_TAG will be walked over.
*/
@@ -201,7 +202,8 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm,
#ifdef USE_EDGE_CHAIN
/* Expand initial state to end-point vertices when they only have 2x edges,
- * this prevents odd behavior when source or destination are in the middle of a long chain of edges. */
+ * this prevents odd behavior when source or destination are in the middle
+ * of a long chain of edges. */
if (ELEM(path_htype, BM_VERT, BM_EDGE)) {
for (int i = 0; i < ele_verts_len[side]; i++) {
BMVert *v = ele_verts[side][i];
@@ -221,8 +223,8 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm,
}
#endif /* USE_EDGE_CHAIN */
- /* Keep walking over connected geometry until we find all the vertices in `ele_verts[side_other]`,
- * or exit the loop when theres no connection. */
+ /* Keep walking over connected geometry until we find all the vertices in
+ * `ele_verts[side_other]`, or exit the loop when theres no connection. */
found_all = false;
for (pass = 1; (STACK_SIZE(stack) != 0); pass++) {
while (STACK_SIZE(stack) != 0) {
@@ -321,7 +323,8 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm,
} while ((l_iter = l_iter->next) != l_first);
#else
/* Allowing a single failure on a face gives fewer 'gaps'.
- * While correct, in practice they're often part of what a user would consider the 'region'. */
+ * While correct, in practice they're often part of what
+ * a user would consider the 'region'. */
int ok_tests = f->len > 3 ? 1 : 0; /* how many times we may fail */
do {
if (!bm_vert_region_test_chain(l_iter->v, depths, pass)) {
diff --git a/source/blender/bmesh/tools/bmesh_region_match.c b/source/blender/bmesh/tools/bmesh_region_match.c
index 6ddbaa6bb2e..8b9a9de3988 100644
--- a/source/blender/bmesh/tools/bmesh_region_match.c
+++ b/source/blender/bmesh/tools/bmesh_region_match.c
@@ -854,8 +854,7 @@ static BMFace **bm_mesh_region_match_pair(
uint i;
faces_result = MEM_mallocN(sizeof(*faces_result) * (faces_result_len + 1), __func__);
- GHASH_ITER_INDEX(gh_iter, w_dst->faces_uuid, i)
- {
+ GHASH_ITER_INDEX (gh_iter, w_dst->faces_uuid, i) {
BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
faces_result[i] = f;
}
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index c9829b1f706..2c9865bcd95 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -126,7 +126,7 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
{
bool container_is_open = false;
- //Transform animations (trans, rot, scale)
+ /* Transform animations (trans, rot, scale). */
container_is_open = open_animation_container(container_is_open, ob);
/* Now take care of the Object Animations
@@ -137,8 +137,8 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
BC_TRANSFORMATION_TYPE_MATRIX;
if (export_as_matrix) {
- export_matrix_animation(
- ob, sampler); // export all transform_curves as one single matrix animation
+ /* export all transform_curves as one single matrix animation */
+ export_matrix_animation(ob, sampler);
}
export_curve_animation_set(ob, sampler, export_as_matrix);
@@ -180,11 +180,9 @@ void AnimationExporter::export_curve_animation_set(Object *ob,
for (it = curves->begin(); it != curves->end(); ++it) {
BCAnimationCurve &curve = *it->second;
if (curve.get_channel_target() == "rotation_quaternion") {
- /*
- Can not export Quaternion animation in Collada as far as i know)
- Maybe automatically convert to euler rotation?
- Discard for now.
- */
+ /* Can not export Quaternion animation in Collada as far as i know)
+ * Maybe automatically convert to euler rotation?
+ * Discard for now. */
continue;
}
@@ -249,7 +247,7 @@ BC_global_rotation_type AnimationExporter::get_global_rotation_type(Object *ob)
return (apply_global_rotation) ? BC_DATA_ROTATION : BC_OBJECT_ROTATION;
}
-//write bone animations in transform matrix sources
+/* Write bone animations in transform matrix sources. */
void AnimationExporter::export_bone_animations_recursive(Object *ob,
Bone *bone,
BCAnimationSampler &sampler)
@@ -292,7 +290,7 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob,
BCCurveKey key(BC_ANIMATION_TYPE_CAMERA, "xfov", 0);
mcurve = new BCAnimationCurve(key, ob);
- // now tricky part: transform the fcurve
+ /* now tricky part: transform the fcurve */
BCValueMap lens_values;
curve.get_value_map(lens_values);
@@ -318,7 +316,8 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob,
float value = RAD2DEGF(focallength_to_fov(lens_value, sensor_value));
mcurve->add_value(value, frame);
}
- mcurve->clean_handles(); // to reset the handles
+ /* to reset the handles */
+ mcurve->clean_handles();
}
return mcurve;
}
@@ -334,7 +333,8 @@ void AnimationExporter::export_curve_animation(Object *ob, BCAnimationCurve &cur
*/
int channel_index = curve.get_channel_index();
- std::string axis = get_axis_name(channel_target, channel_index); // RGB or XYZ or ""
+ /* RGB or XYZ or "" */
+ std::string axis = get_axis_name(channel_target, channel_index);
std::string action_name;
bAction *action = bc_getSceneObjectAction(ob);
@@ -381,19 +381,19 @@ void AnimationExporter::export_bone_animation(Object *ob,
bool AnimationExporter::is_bone_deform_group(Bone *bone)
{
bool is_def;
- //Check if current bone is deform
+ /* Check if current bone is deform */
if ((bone->flag & BONE_NO_DEFORM) == 0)
return true;
- //Check child bones
+ /* Check child bones */
else {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- //loop through all the children until deform bone is found, and then return
+ /* loop through all the children until deform bone is found, and then return */
is_def = is_bone_deform_group(child);
if (is_def)
return true;
}
}
- //no deform bone found in children also
+ /* no deform bone found in children also */
return false;
}
@@ -487,7 +487,7 @@ void AnimationExporter::export_collada_matrix_animation(
sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION,
COLLADABU::URI(EMPTY_STRING, interpolation_id));
- // Matrix animation has no tangents
+ /* Matrix animation has no tangents */
addSampler(sampler);
addChannel(COLLADABU::URI(EMPTY_STRING, sampler_id), target);
@@ -535,7 +535,8 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
else if (transform) {
param.push_back("TRANSFORM");
}
- else { //assumes if axis isn't specified all axises are added
+ else {
+ /* assumes if axis isn't specified all axises are added */
param.push_back("X");
param.push_back("Y");
param.push_back("Z");
@@ -645,7 +646,7 @@ std::string AnimationExporter::collada_source_from_values(
/*
* Create a collada matrix source for a set of samples
-*/
+ */
std::string AnimationExporter::collada_source_from_values(
BCMatrixSampleMap &samples,
const std::string &anim_id,
@@ -667,9 +668,8 @@ std::string AnimationExporter::collada_source_from_values(
source.prepareToAppendValues();
BCMatrixSampleMap::iterator it;
- int precision = (this->export_settings.get_limit_precision()) ?
- 6 :
- -1; // could be made configurable
+ /* could be made configurable */
+ int precision = (this->export_settings.get_limit_precision()) ? 6 : -1;
for (it = samples.begin(); it != samples.end(); it++) {
BCMatrix sample = BCMatrix(*it->second);
DMatrix daemat;
@@ -715,11 +715,12 @@ std::string AnimationExporter::collada_interpolation_source(const BCAnimationCur
else if (ipo == BEZT_IPO_CONST) {
source.appendValues(STEP_NAME);
}
- else { // BEZT_IPO_LIN
+ else {
+ /* BEZT_IPO_LIN */
source.appendValues(LINEAR_NAME);
}
}
- // unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS
+ /* unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS */
source.finish();
@@ -779,10 +780,10 @@ const std::string AnimationExporter::get_collada_name(std::string channel_target
{"spot_size", "falloff_angle"},
{"fall_off_exponent", "falloff_exponent"},
{"spot_blend", "falloff_exponent"},
- {"blender/blender_dist",
- "blender/blender_dist"}, // special blender profile (todo: make this more elegant)
- {"distance",
- "blender/blender_dist"}, // special blender profile (todo: make this more elegant)
+ /* Special blender profile (todo: make this more elegant). */
+ {"blender/blender_dist", "blender/blender_dist"},
+ /* Special blender profile (todo: make this more elegant). */
+ {"distance", "blender/blender_dist"},
/* Cameras */
{"lens", "xfov"},
@@ -829,8 +830,7 @@ std::string AnimationExporter::get_collada_sid(const BCAnimationCurve &curve,
#ifdef WITH_MORPH_ANIMATION
/* TODO: This function needs to be implemented similar to the material animation export
-So we have to update BCSample for this to work.
-*/
+ * So we have to update BCSample for this to work. */
void AnimationExporter::export_morph_animation(Object *ob, BCAnimationSampler &sampler)
{
FCurve *fcu;
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index f6695db1d0a..3ab859bdb00 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -48,7 +48,7 @@
#include <algorithm>
-// first try node name, if not available (since is optional), fall back to original id
+/* first try node name, if not available (since is optional), fall back to original id */
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
@@ -69,7 +69,7 @@ void AnimationImporter::add_bezt(FCurve *fcu,
float value,
eBezTriple_Interpolation ipo)
{
- //float fps = (float)FPS;
+ // float fps = (float)FPS;
BezTriple bez;
memset(&bez, 0, sizeof(BezTriple));
bez.vec[1][0] = frame;
@@ -81,7 +81,7 @@ void AnimationImporter::add_bezt(FCurve *fcu,
calchandles_fcurve(fcu);
}
-// create one or several fcurves depending on the number of parameters being animated
+/* create one or several fcurves depending on the number of parameters being animated */
void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
{
COLLADAFW::FloatOrDoubleArray &input = curve->getInputValues();
@@ -94,10 +94,10 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
std::vector<FCurve *> &fcurves = curve_map[curve->getUniqueId()];
switch (dim) {
- case 1: // X, Y, Z or angle
- case 3: // XYZ
+ case 1: /* X, Y, Z or angle */
+ case 3: /* XYZ */
case 4:
- case 16: // matrix
+ case 16: /* matrix */
{
for (i = 0; i < dim; i++) {
FCurve *fcu = (FCurve *)MEM_callocN(sizeof(FCurve), "FCurve");
@@ -110,7 +110,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
BezTriple bez;
memset(&bez, 0, sizeof(BezTriple));
- // input, output
+ /* input, output */
bez.vec[1][0] = bc_get_float_value(input, j) * fps;
bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
bez.h1 = bez.h2 = HD_AUTO;
@@ -120,11 +120,11 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
COLLADAFW::FloatOrDoubleArray &intan = curve->getInTangentValues();
COLLADAFW::FloatOrDoubleArray &outtan = curve->getOutTangentValues();
- // intangent
+ /* intangent */
bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i)) * fps;
bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i) + 1);
- // outtangent
+ /* outtangent */
bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i)) * fps;
bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i) + 1);
if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) {
@@ -138,7 +138,9 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
else {
bez.ipo = BEZT_IPO_LIN;
}
- // bez.ipo = U.ipo_new; /* use default interpolation mode here... */
+#if 0
+ bez.ipo = U.ipo_new; /* use default interpolation mode here... */
+#endif
bez.f1 = bez.f2 = bez.f3 = SELECT;
insert_bezt_fcurve(fcu, &bez, INSERTKEY_NOFLAGS);
@@ -161,7 +163,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
void AnimationImporter::fcurve_deg_to_rad(FCurve *cu)
{
for (unsigned int i = 0; i < cu->totvert; i++) {
- // TODO convert handles too
+ /* TODO convert handles too */
cu->bezt[i].vec[1][1] *= DEG2RADF(1.0f);
cu->bezt[i].vec[0][1] *= DEG2RADF(1.0f);
cu->bezt[i].vec[2][1] *= DEG2RADF(1.0f);
@@ -195,7 +197,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
char *p = strstr(rna_path, "rotation_euler");
bool is_rotation = p && *(p + strlen("rotation_euler")) == '\0';
- // convert degrees to radians for rotation
+ /* convert degrees to radians for rotation */
if (is_rotation)
fcurve_deg_to_rad(fcu);
#endif
@@ -253,7 +255,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
AnimationImporter::~AnimationImporter()
{
- // free unused FCurves
+ /* free unused FCurves */
for (std::vector<FCurve *>::iterator it = unused_curves.begin(); it != unused_curves.end(); it++)
free_fcurve(*it);
@@ -266,15 +268,15 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
if (anim->getAnimationType() == COLLADAFW::Animation::ANIMATION_CURVE) {
COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve *)anim;
- // XXX Don't know if it's necessary
- // Should we check outPhysicalDimension?
+ /* XXX Don't know if it's necessary
+ * Should we check outPhysicalDimension? */
if (curve->getInPhysicalDimension() != COLLADAFW::PHYSICAL_DIMENSION_TIME) {
fprintf(stderr, "Inputs physical dimension is not time.\n");
return true;
}
- // a curve can have mixed interpolation type,
- // in this case curve->getInterpolationTypes returns a list of interpolation types per key
+ /* a curve can have mixed interpolation type,
+ * in this case curve->getInterpolationTypes returns a list of interpolation types per key */
COLLADAFW::AnimationCurve::InterpolationType interp = curve->getInterpolationType();
if (interp != COLLADAFW::AnimationCurve::INTERPOLATION_MIXED) {
@@ -285,14 +287,14 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
animation_to_fcurves(curve);
break;
default:
- // TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types
+ /* TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types */
fprintf(stderr,
"CARDINAL, HERMITE and BSPLINE anim interpolation types not supported yet.\n");
break;
}
}
else {
- // not supported yet
+ /* not supported yet */
fprintf(stderr, "MIXED anim interpolation type is not supported yet.\n");
}
}
@@ -303,7 +305,7 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
return true;
}
-// called on post-process stage after writeVisualScenes
+/* called on post-process stage after writeVisualScenes */
bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *animlist)
{
const COLLADAFW::UniqueId &animlist_id = animlist->getUniqueId();
@@ -311,21 +313,21 @@ bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *ani
#if 0
- // should not happen
+ /* should not happen */
if (uid_animated_map.find(animlist_id) == uid_animated_map.end()) {
return true;
}
- // for bones rna_path is like: pose.bones["bone-name"].rotation
+ /* for bones rna_path is like: pose.bones["bone-name"].rotation */
#endif
return true;
}
-// \todo refactor read_node_transform to not automatically apply anything,
-// but rather return the transform matrix, so caller can do with it what is
-// necessary. Same for \ref get_node_mat
+/* \todo refactor read_node_transform to not automatically apply anything,
+ * but rather return the transform matrix, so caller can do with it what is
+ * necessary. Same for \ref get_node_mat */
void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob)
{
float mat[4][4];
@@ -351,7 +353,8 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
std::vector<FCurve *> &rot_fcurves = fcurves_actionGroup_map[grp];
- if (rot_fcurves.size() > 3) continue;
+ if (rot_fcurves.size() > 3)
+ continue;
for (i = 0; i < rot_fcurves.size(); i++)
eulcu[rot_fcurves[i]->array_index] = rot_fcurves[i];
@@ -366,7 +369,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
create_fcurve(0, rna_path),
create_fcurve(1, rna_path),
create_fcurve(2, rna_path),
- create_fcurve(3, rna_path)
+ create_fcurve(3, rna_path),
};
bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, grp->name);
@@ -379,7 +382,8 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
FCurve *cu = eulcu[i];
- if (!cu) continue;
+ if (!cu)
+ continue;
for (int j = 0; j < cu->totvert; j++) {
float frame = cu->bezt[j].vec[1][0];
@@ -387,18 +391,17 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
float eul[3] = {
eulcu[0] ? evaluate_fcurve(eulcu[0], frame) : 0.0f,
eulcu[1] ? evaluate_fcurve(eulcu[1], frame) : 0.0f,
- eulcu[2] ? evaluate_fcurve(eulcu[2], frame) : 0.0f
+ eulcu[2] ? evaluate_fcurve(eulcu[2], frame) : 0.0f,
};
- // make eul relative to bone rest pose
+ /* make eul relative to bone rest pose */
float rot[3][3], rel[3][3], quat[4];
- /*eul_to_mat3(rot, eul);
-
- mul_m3_m3m3(rel, irest, rot);
-
- mat3_to_quat(quat, rel);
- */
+# if 0
+ eul_to_mat3(rot, eul);
+ mul_m3_m3m3(rel, irest, rot);
+ mat3_to_quat(quat, rel);
+# endif
eul_to_quat(quat, eul);
@@ -407,10 +410,11 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
}
}
- // now replace old Euler curves
+ /* now replace old Euler curves */
for (i = 0; i < 3; i++) {
- if (!eulcu[i]) continue;
+ if (!eulcu[i])
+ continue;
action_groups_remove_channel(act, eulcu[i]);
free_fcurve(eulcu[i]);
@@ -429,7 +433,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
}
#endif
-//sets the rna_path and array index to curve
+/* sets the rna_path and array index to curve */
void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves,
const char *rna_path,
int array_index)
@@ -451,7 +455,7 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves,
void AnimationImporter::unused_fcurve(std::vector<FCurve *> *curves)
{
- // when an error happens and we can't actually use curve remove it from unused_curves
+ /* when an error happens and we can't actually use curve remove it from unused_curves */
std::vector<FCurve *>::iterator it;
for (it = curves->begin(); it != curves->end(); it++) {
FCurve *fcu = *it;
@@ -466,16 +470,17 @@ void AnimationImporter::find_frames(std::vector<float> *frames, std::vector<FCur
FCurve *fcu = *iter;
for (unsigned int k = 0; k < fcu->totvert; k++) {
- //get frame value from bezTriple
+ /* get frame value from bezTriple */
float fra = fcu->bezt[k].vec[1][0];
- //if frame already not added add frame to frames
+ /* if frame already not added add frame to frames */
if (std::find(frames->begin(), frames->end(), fra) == frames->end())
frames->push_back(fra);
}
}
}
-//creates the rna_paths and array indices of fcurves from animations using transformation and bound animation class of each animation.
+/* creates the rna_paths and array indices of fcurves from animations using transformation and
+ * bound animation class of each animation. */
void AnimationImporter::Assign_transform_animations(
COLLADAFW::Transformation *transform,
const COLLADAFW::AnimationList::AnimationBinding *binding,
@@ -487,7 +492,7 @@ void AnimationImporter::Assign_transform_animations(
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
- //to check if the no of curves are valid
+ /* to check if the no of curves are valid */
bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||
tm_type == COLLADAFW::Transformation::SCALE) &&
binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
@@ -540,7 +545,7 @@ void AnimationImporter::Assign_transform_animations(
for (iter = curves->begin(); iter != curves->end(); iter++) {
FCurve *fcu = *iter;
- //if transform is rotation the fcurves values must be turned in to radian.
+ /* if transform is rotation the fcurves values must be turned in to radian. */
if (is_rotation)
fcurve_deg_to_rad(fcu);
}
@@ -562,7 +567,7 @@ void AnimationImporter::Assign_transform_animations(
unused_fcurve(curves);
break;
case COLLADAFW::AnimationList::AXISANGLE:
- // TODO convert axis-angle to quat? or XYZ?
+ /* TODO convert axis-angle to quat? or XYZ? */
default:
unused_fcurve(curves);
fprintf(stderr,
@@ -574,14 +579,13 @@ void AnimationImporter::Assign_transform_animations(
case COLLADAFW::Transformation::MATRIX:
#if 0
- {
- COLLADAFW::Matrix *mat = (COLLADAFW::Matrix*)transform;
- COLLADABU::Math::Matrix4 mat4 = mat->getMatrix();
- switch (binding->animationClass) {
- case COLLADAFW::AnimationList::TRANSFORM:
-
- }
+ {
+ COLLADAFW::Matrix *mat = (COLLADAFW::Matrix *)transform;
+ COLLADABU::Math::Matrix4 mat4 = mat->getMatrix();
+ switch (binding->animationClass) {
+ case COLLADAFW::AnimationList::TRANSFORM:
}
+ }
#endif
unused_fcurve(curves);
break;
@@ -593,7 +597,8 @@ void AnimationImporter::Assign_transform_animations(
}
}
-//creates the rna_paths and array indices of fcurves from animations using color and bound animation class of each animation.
+/* creates the rna_paths and array indices of fcurves from animations using color and bound
+ * animation class of each animation. */
void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listid,
ListBase *AnimCurves,
const char *anim_type)
@@ -611,7 +616,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
}
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
- //all the curves belonging to the current binding
+ /* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -627,7 +632,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
modify_fcurve(&animcurves, rna_path, 2);
break;
case COLLADAFW::AnimationList::COLOR_RGB:
- case COLLADAFW::AnimationList::COLOR_RGBA: // to do-> set intensity
+ case COLLADAFW::AnimationList::COLOR_RGBA: /* to do-> set intensity */
modify_fcurve(&animcurves, rna_path, -1);
break;
@@ -640,7 +645,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
}
std::vector<FCurve *>::iterator iter;
- //Add the curves of the current animation to the object
+ /* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
@@ -658,10 +663,10 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi
return;
}
else {
- //anim_type has animations
+ /* anim_type has animations */
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
- //all the curves belonging to the current binding
+ /* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -669,10 +674,11 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi
BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
modify_fcurve(&animcurves, rna_path, 0);
std::vector<FCurve *>::iterator iter;
- //Add the curves of the current animation to the object
+ /* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
- /* All anim_types whose values are to be converted from Degree to Radians can be ORed here */
+ /* All anim_types whose values are to be converted from Degree to Radians can be ORed here
+ */
if (STREQ("spot_size", anim_type)) {
/* NOTE: Do NOT convert if imported file was made by blender <= 2.69.10
* Reason: old blender versions stored spot_size in radians (was a bug)
@@ -696,7 +702,7 @@ float AnimationImporter::convert_to_focal_length(float in_xfov,
float aspect,
float sensorx)
{
- // NOTE: Needs more testing (As we curretnly have no official test data for this)
+ /* NOTE: Needs more testing (As we curretnly have no official test data for this) */
float xfov = (fov_type == CAMERA_YFOV) ?
(2.0f * atanf(aspect * tanf(DEG2RADF(in_xfov) * 0.5f))) :
DEG2RADF(in_xfov);
@@ -720,10 +726,10 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId &listid
return;
}
else {
- //anim_type has animations
+ /* anim_type has animations */
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
- //all the curves belonging to the current binding
+ /* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -732,7 +738,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId &listid
modify_fcurve(&animcurves, rna_path, 0);
std::vector<FCurve *>::iterator iter;
- //Add the curves of the current animation to the object
+ /* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
@@ -784,8 +790,8 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
copy_m4_m4(rest, bone->arm_mat);
invert_m4_m4(irest, rest);
}
- // new curves to assign matrix transform animation
- FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale
+ /* new curves to assign matrix transform animation */
+ FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */
unsigned int totcu = 10;
const char *tm_str = NULL;
char rna_path[200];
@@ -821,10 +827,12 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
std::vector<float>::iterator it;
- //float qref[4];
- //unit_qt(qref);
+#if 0
+ float qref[4];
+ unit_qt(qref);
+#endif
- // sample values at each frame
+ /* sample values at each frame */
for (it = frames.begin(); it != frames.end(); it++) {
float fra = *it;
@@ -833,23 +841,26 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
unit_m4(matfra);
- // calc object-space mat
+ /* calc object-space mat */
evaluate_transform_at_frame(matfra, node, fra);
- // for joints, we need a special matrix
+ /* for joints, we need a special matrix */
if (is_joint) {
- // special matrix: iR * M * iR_dae * R
- // where R, iR are bone rest and inverse rest mats in world space (Blender bones),
- // iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE)
+ /* special matrix: iR * M * iR_dae * R
+ * where R, iR are bone rest and inverse rest mats in world space (Blender bones),
+ * iR_dae is joint inverse rest matrix (DAE)
+ * and M is an evaluated joint world-space matrix (DAE) */
float temp[4][4], par[4][4];
- // calc M
+ /* calc M */
calc_joint_parent_mat_rest(par, NULL, root, node);
mul_m4_m4m4(temp, par, matfra);
- // evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
+#if 0
+ evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
+#endif
- // calc special matrix
+ /* calc special matrix */
mul_m4_series(mat, irest, temp, irest_dae, rest);
}
else {
@@ -859,7 +870,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
float rot[4], loc[3], scale[3];
mat4_decompose(loc, rot, scale, mat);
- // add keys
+ /* add keys */
for (int i = 0; i < totcu; i++) {
if (i < 4)
add_bezt(newcu[i], fra, rot[i]);
@@ -874,13 +885,15 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
ListBase *curves = &ob->adt->action->curves;
- // add curves
+ /* add curves */
for (int i = 0; i < totcu; i++) {
if (is_joint)
add_bone_fcurve(ob, node, newcu[i]);
else
BLI_addtail(curves, newcu[i]);
- // fcurve_is_used(newcu[i]); // never added to unused
+#if 0
+ fcurve_is_used(newcu[i]); /* never added to unused */
+#endif
}
if (is_joint) {
@@ -912,7 +925,7 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera)
const double yfov = camera->getYFov().getValue();
if (yfov == 0) {
- aspect = 1; // assume yfov and xfov are equal
+ aspect = 1; /* assume yfov and xfov are equal */
}
else {
const double xfov = camera->getXFov().getValue();
@@ -975,12 +988,12 @@ void AnimationImporter::translate_Animations(
else
act = ob->adt->action;
- //Get the list of animation curves of the object
+ /* Get the list of animation curves of the object */
ListBase *AnimCurves = &(act->curves);
const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
- //for each transformation in node
+ /* for each transformation in node */
for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) {
COLLADAFW::Transformation *transform = nodeTransforms[i];
COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType();
@@ -990,16 +1003,16 @@ void AnimationImporter::translate_Animations(
const COLLADAFW::UniqueId &listid = transform->getAnimationList();
- //check if transformation has animations
+ /* check if transformation has animations */
if (animlist_map.find(listid) == animlist_map.end()) {
continue;
}
else {
- //transformation has animations
+ /* transformation has animations */
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings &bindings =
animlist->getAnimationBindings();
- //all the curves belonging to the current binding
+ /* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -1011,12 +1024,13 @@ void AnimationImporter::translate_Animations(
add_bone_animation_sampled(ob, animcurves, root, node, transform);
}
else {
- //calculate rnapaths and array index of fcurves according to transformation and animation class
+ /* calculate rnapaths and array index of fcurves according to transformation and
+ * animation class */
Assign_transform_animations(
transform, &bindings[j], &animcurves, is_joint, joint_path);
std::vector<FCurve *>::iterator iter;
- //Add the curves of the current animation to the object
+ /* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
@@ -1191,7 +1205,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
std::vector<float> frames;
find_frames(&frames, &animcurves);
- // convert degrees to radians
+ /* convert degrees to radians */
if (tm->getTransformationType() == COLLADAFW::Transformation::ROTATE) {
std::vector<FCurve *>::iterator iter;
@@ -1218,8 +1232,8 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
copy_m4_m4(rest, bone->arm_mat);
invert_m4_m4(irest, rest);
- // new curves to assign matrix transform animation
- FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale
+ /* new curves to assign matrix transform animation */
+ FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale. */
unsigned int totcu = 10;
const char *tm_str = NULL;
char rna_path[200];
@@ -1256,7 +1270,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
std::vector<float>::iterator it;
- // sample values at each frame
+ /* sample values at each frame */
for (it = frames.begin(); it != frames.end(); it++) {
float fra = *it;
@@ -1265,22 +1279,23 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
unit_m4(matfra);
- // calc object-space mat
+ /* calc object-space mat */
evaluate_transform_at_frame(matfra, node, fra);
- // for joints, we need a special matrix
- // special matrix: iR * M * iR_dae * R
- // where R, iR are bone rest and inverse rest mats in world space (Blender bones),
- // iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE)
+ /* for joints, we need a special matrix
+ * special matrix: iR * M * iR_dae * R
+ * where R, iR are bone rest and inverse rest mats in world space (Blender bones),
+ * iR_dae is joint inverse rest matrix (DAE)
+ * and M is an evaluated joint world-space matrix (DAE). */
float temp[4][4], par[4][4];
- // calc M
+ /* calc M */
calc_joint_parent_mat_rest(par, NULL, root, node);
mul_m4_m4m4(temp, par, matfra);
- // evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
+ /* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */
- // calc special matrix
+ /* calc special matrix */
mul_m4_series(mat, irest, temp, irest_dae, rest);
float rot[4], loc[3], scale[3];
@@ -1291,7 +1306,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
copy_v3_v3(loc, mat[3]);
mat4_to_size(scale, mat);
- // add keys
+ /* add keys */
for (int i = 0; i < totcu; i++) {
if (i < 4)
add_bezt(newcu[i], fra, rot[i]);
@@ -1304,17 +1319,20 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
Main *bmain = CTX_data_main(mContext);
verify_adt_action(bmain, (ID *)&ob->id, 1);
- // add curves
+ /* add curves */
for (int i = 0; i < totcu; i++) {
add_bone_fcurve(ob, node, newcu[i]);
- // fcurve_is_used(newcu[i]); // never added to unused
+#if 0
+ fcurve_is_used(newcu[i]); /* never added to unused */
+#endif
}
bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name);
chan->rotmode = ROT_MODE_QUAT;
}
-//Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
+/* Check if object is animated by checking if animlist_map
+ * holds the animlist_id of node transforms */
AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
const COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map)
@@ -1323,12 +1341,12 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
- //for each transformation in node
+ /* for each transformation in node */
for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) {
COLLADAFW::Transformation *transform = nodeTransforms[i];
const COLLADAFW::UniqueId &listid = transform->getAnimationList();
- //check if transformation has animations
+ /* check if transformation has animations */
if (animlist_map.find(listid) == animlist_map.end()) {
continue;
}
@@ -1355,7 +1373,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *)
FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
if (camera == NULL) {
- // Can happen if the node refers to an unknown camera.
+ /* Can happen if the node refers to an unknown camera. */
continue;
}
@@ -1397,7 +1415,9 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
&(efc->getSpecular().getColor()), (types->material), MATERIAL_SPEC_COLOR);
types->material = setAnimType(
&(efc->getDiffuse().getColor()), (types->material), MATERIAL_DIFF_COLOR);
- // types->material = setAnimType(&(efc->get()), (types->material), MATERIAL_TRANSPARENCY);
+#if 0
+ types->material = setAnimType(&(efc->get()), (types->material), MATERIAL_TRANSPARENCY);
+#endif
types->material = setAnimType(
&(efc->getIndexOfRefraction()), (types->material), MATERIAL_IOR);
}
@@ -1419,26 +1439,26 @@ int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types,
return anim_type;
}
-// Is not used anymore.
+/* Is not used anymore. */
void AnimationImporter::find_frames_old(std::vector<float> *frames,
COLLADAFW::Node *node,
COLLADAFW::Transformation::TransformationType tm_type)
{
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
- // for each <rotate>, <translate>, etc. there is a separate Transformation
+ /* for each <rotate>, <translate>, etc. there is a separate Transformation */
const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
unsigned int i;
- // find frames at which to sample plus convert all rotation keys to radians
+ /* find frames at which to sample plus convert all rotation keys to radians */
for (i = 0; i < nodeTransforms.getCount(); i++) {
COLLADAFW::Transformation *transform = nodeTransforms[i];
COLLADAFW::Transformation::TransformationType nodeTmType = transform->getTransformationType();
if (nodeTmType == tm_type) {
- //get animation bindings for the current transformation
+ /* get animation bindings for the current transformation */
const COLLADAFW::UniqueId &listid = transform->getAnimationList();
- //if transform is animated its animlist must exist.
+ /* if transform is animated its animlist must exist. */
if (animlist_map.find(listid) != animlist_map.end()) {
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
@@ -1446,7 +1466,7 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
animlist->getAnimationBindings();
if (bindings.getCount()) {
- //for each AnimationBinding get the fcurves which animate the transform
+ /* for each AnimationBinding get the fcurves which animate the transform */
for (unsigned int j = 0; j < bindings.getCount(); j++) {
std::vector<FCurve *> &curves = curve_map[bindings[j].animation];
bool xyz = ((nodeTmType == COLLADAFW::Transformation::TRANSLATE ||
@@ -1459,14 +1479,14 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
for (iter = curves.begin(); iter != curves.end(); iter++) {
FCurve *fcu = *iter;
- //if transform is rotation the fcurves values must be turned in to radian.
+ /* if transform is rotation the fcurves values must be turned in to radian. */
if (is_rotation)
fcurve_deg_to_rad(fcu);
for (unsigned int k = 0; k < fcu->totvert; k++) {
- //get frame value from bezTriple
+ /* get frame value from bezTriple */
float fra = fcu->bezt[k].vec[1][0];
- //if frame already not added add frame to frames
+ /* if frame already not added add frame to frames */
if (std::find(frames->begin(), frames->end(), fra) == frames->end())
frames->push_back(fra);
}
@@ -1482,9 +1502,9 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
}
}
-// prerequisites:
-// animlist_map - map animlist id -> animlist
-// curve_map - map anim id -> curve(s)
+/* prerequisites:
+ * animlist_map - map animlist id -> animlist
+ * curve_map - map anim id -> curve(s) */
Object *AnimationImporter::translate_animation_OLD(
COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, Object *> &object_map,
@@ -1508,7 +1528,7 @@ Object *AnimationImporter::translate_animation_OLD(
return NULL;
}
- // frames at which to sample
+ /* frames at which to sample */
std::vector<float> frames;
find_frames_old(&frames, node, tm_type);
@@ -1568,8 +1588,8 @@ Object *AnimationImporter::translate_animation_OLD(
if (is_joint)
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
- // new curves
- FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale
+ /* new curves */
+ FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */
unsigned int totcu = is_matrix ? 10 : (is_rotation ? 4 : 3);
for (i = 0; i < totcu; i++) {
@@ -1605,7 +1625,7 @@ Object *AnimationImporter::translate_animation_OLD(
std::vector<float>::iterator it;
- // sample values at each frame
+ /* sample values at each frame */
for (it = frames.begin(); it != frames.end(); it++) {
float fra = *it;
@@ -1614,23 +1634,24 @@ Object *AnimationImporter::translate_animation_OLD(
unit_m4(matfra);
- // calc object-space mat
+ /* calc object-space mat */
evaluate_transform_at_frame(matfra, node, fra);
- // for joints, we need a special matrix
+ /* for joints, we need a special matrix */
if (is_joint) {
- // special matrix: iR * M * iR_dae * R
- // where R, iR are bone rest and inverse rest mats in world space (Blender bones),
- // iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE)
+ /* special matrix: iR * M * iR_dae * R
+ * where R, iR are bone rest and inverse rest mats in world space (Blender bones),
+ * iR_dae is joint inverse rest matrix (DAE)
+ * and M is an evaluated joint world-space matrix (DAE). */
float temp[4][4], par[4][4];
- // calc M
+ /* calc M */
calc_joint_parent_mat_rest(par, NULL, root, node);
mul_m4_m4m4(temp, par, matfra);
- // evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
+ /* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */
- // calc special matrix
+ /* calc special matrix */
mul_m4_series(mat, irest, temp, irest_dae, rest);
}
else {
@@ -1659,7 +1680,7 @@ Object *AnimationImporter::translate_animation_OLD(
break;
}
- // add keys
+ /* add keys */
for (i = 0; i < totcu; i++) {
if (is_matrix) {
if (i < 4)
@@ -1716,7 +1737,7 @@ Object *AnimationImporter::translate_animation_OLD(
ListBase *curves = &ob->adt->action->curves;
- // add curves
+ /* add curves */
for (i = 0; i < totcu; i++) {
if (is_joint)
add_bone_fcurve(ob, node, newcu[i]);
@@ -1742,9 +1763,9 @@ Object *AnimationImporter::translate_animation_OLD(
return job;
}
-// internal, better make it private
-// warning: evaluates only rotation and only assigns matrix transforms now
-// prerequisites: animlist_map, curve_map
+/* internal, better make it private
+ * warning: evaluates only rotation and only assigns matrix transforms now
+ * prerequisites: animlist_map, curve_map */
void AnimationImporter::evaluate_transform_at_frame(float mat[4][4],
COLLADAFW::Node *node,
float fra)
@@ -1803,7 +1824,7 @@ static void report_class_type_unsupported(const char *path,
}
}
-// return true to indicate that mat contains a sane value
+/* return true to indicate that mat contains a sane value */
bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
float mat[4][4],
float fra,
@@ -1864,7 +1885,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
return false;
}
- // TODO support other animclasses
+ /* TODO support other animclasses */
if (animclass != COLLADAFW::AnimationList::ANGLE) {
report_class_type_unsupported(path, animclass, type);
return false;
@@ -1910,7 +1931,8 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
}
}
else if (type == COLLADAFW::Transformation::MATRIX) {
- // for now, of matrix animation, support only the case when all values are packed into one animation
+ /* for now, of matrix animation,
+ * support only the case when all values are packed into one animation */
if (curves.size() != 16) {
fprintf(stderr, "%s: expected 16 curves, got %d\n", path, (int)curves.size());
return false;
@@ -1944,13 +1966,13 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
return false;
}
-// gives a world-space mat of joint at rest position
+/* gives a world-space mat of joint at rest position */
void AnimationImporter::get_joint_rest_mat(float mat[4][4],
COLLADAFW::Node *root,
COLLADAFW::Node *node)
{
- // if bind mat is not available,
- // use "current" node transform, i.e. all those tms listed inside <node>
+ /* if bind mat is not available,
+ * use "current" node transform, i.e. all those tms listed inside <node> */
if (!armature_importer->get_joint_bind_mat(mat, node)) {
float par[4][4], m[4][4];
@@ -1960,7 +1982,7 @@ void AnimationImporter::get_joint_rest_mat(float mat[4][4],
}
}
-// gives a world-space mat, end's mat not included
+/* gives a world-space mat, end's mat not included */
bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4],
float par[4][4],
COLLADAFW::Node *node,
@@ -1973,7 +1995,7 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4],
return true;
}
- // use bind matrix if available or calc "current" world mat
+ /* use bind matrix if available or calc "current" world mat */
if (!armature_importer->get_joint_bind_mat(m, node)) {
if (par) {
float temp[4][4];
@@ -2032,7 +2054,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root,
BKE_object_where_is_calc(scene, job);
- // after parenting and layer change
+ /* after parenting and layer change */
DEG_relations_tag_update(CTX_data_main(C));
joint_objects[node->getUniqueId()] = job;
@@ -2043,9 +2065,10 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root,
#endif
#if 0
-// recursively evaluates joint tree until end is found, mat then is world-space matrix of end
-// mat must be identity on enter, node must be root
-bool AnimationImporter::evaluate_joint_world_transform_at_frame(float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end, float fra)
+/* recursively evaluates joint tree until end is found,
+ * mat then is world-space matrix of end mat must be identity on enter, node must be root. */
+bool AnimationImporter::evaluate_joint_world_transform_at_frame(
+ float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end, float fra)
{
float m[4][4];
if (par) {
@@ -2062,7 +2085,7 @@ bool AnimationImporter::evaluate_joint_world_transform_at_frame(float mat[4][4],
return true;
}
else {
- COLLADAFW::NodePointerArray& children = node->getChildNodes();
+ COLLADAFW::NodePointerArray &children = node->getChildNodes();
for (int i = 0; i < children.getCount(); i++) {
if (evaluate_joint_world_transform_at_frame(mat, m, children[i], end, fra))
return true;
diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h
index 65e9974aec1..f15c02183c7 100644
--- a/source/blender/collada/AnimationImporter.h
+++ b/source/blender/collada/AnimationImporter.h
@@ -238,7 +238,8 @@ class AnimationImporter : private TransformReader, public AnimationImporterBase
#if 0
// recursively evaluates joint tree until end is found, mat then is world-space matrix of end
// mat must be identity on enter, node must be root
- bool evaluate_joint_world_transform_at_frame(float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end, float fra);
+ bool evaluate_joint_world_transform_at_frame(
+ float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end, float fra);
#endif
void add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurve *fcu);
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 90fadd06217..7d3904647de 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -114,12 +114,12 @@ bool ArmatureExporter::add_instance_controller(Object *ob)
void ArmatureExporter::operator()(Object *ob)
{
Object *ob_arm = bc_get_assigned_armature(ob);
-
}
bool ArmatureExporter::already_written(Object *ob_arm)
{
- return std::find(written_armatures.begin(), written_armatures.end(), ob_arm) != written_armatures.end();
+ return std::find(written_armatures.begin(), written_armatures.end(), ob_arm) !=
+ written_armatures.end();
}
void ArmatureExporter::wrote(Object *ob_arm)
@@ -127,11 +127,13 @@ void ArmatureExporter::wrote(Object *ob_arm)
written_armatures.push_back(ob_arm);
}
-void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<Object *>& objects, Scene *sce)
+void ArmatureExporter::find_objects_using_armature(Object *ob_arm,
+ std::vector<Object *> &objects,
+ Scene *sce)
{
objects.clear();
- Base *base = (Base *) sce->base.first;
+ Base *base = (Base *)sce->base.first;
while (base) {
Object *ob = base->object;
@@ -262,7 +264,7 @@ bool ArmatureExporter::is_export_root(Bone *bone)
void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node &node)
{
- //bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
+ // bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
float mat[4][4];
float bone_rest_mat[4][4]; /* derived from bone->arm_mat */
diff --git a/source/blender/collada/ArmatureExporter.h b/source/blender/collada/ArmatureExporter.h
index 1e8b68a259e..da6d6f79ef5 100644
--- a/source/blender/collada/ArmatureExporter.h
+++ b/source/blender/collada/ArmatureExporter.h
@@ -81,7 +81,7 @@ class ArmatureExporter : public COLLADASW::LibraryControllers,
void wrote(Object *ob_arm);
- void find_objects_using_armature(Object *ob_arm, std::vector<Object *>& objects, Scene *sce);
+ void find_objects_using_armature(Object *ob_arm, std::vector<Object *> &objects, Scene *sce);
#endif
// Scene, SceneExporter and the list of child_objects
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 038dbd0c30d..1c540b6cdaa 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -39,7 +39,7 @@ extern "C" {
#include "collada_utils.h"
#include "ArmatureImporter.h"
-// use node name, or fall back to original id if not present (name is optional)
+/* use node name, or fall back to original id if not present (name is optional) */
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
@@ -65,7 +65,7 @@ ArmatureImporter::ArmatureImporter(UnitConverter *conv,
ArmatureImporter::~ArmatureImporter()
{
- // free skin controller data if we forget to do this earlier
+ /* free skin controller data if we forget to do this earlier */
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) {
it->second.free();
@@ -75,11 +75,11 @@ ArmatureImporter::~ArmatureImporter()
#if 0
JointData *ArmatureImporter::get_joint_data(COLLADAFW::Node *node);
{
- const COLLADAFW::UniqueId& joint_id = node->getUniqueId();
+ const COLLADAFW::UniqueId &joint_id = node->getUniqueId();
if (joint_id_to_joint_index_map.find(joint_id) == joint_id_to_joint_index_map.end()) {
- fprintf(stderr, "Cannot find a joint index by joint id for %s.\n",
- node->getOriginalId().c_str());
+ fprintf(
+ stderr, "Cannot find a joint index by joint id for %s.\n", node->getOriginalId().c_str());
return NULL;
}
@@ -102,7 +102,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
float joint_bind_mat[4][4];
int chain_length = 0;
- //Checking if bone is already made.
+ /* Checking if bone is already made. */
std::vector<COLLADAFW::Node *>::iterator it;
it = std::find(finished_joints.begin(), finished_joints.end(), node);
if (it != finished_joints.end())
@@ -122,10 +122,10 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
SkinInfo *b = &skin_it->second;
if (b->get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) {
- // get original world-space matrix
+ /* get original world-space matrix */
invert_m4_m4(mat, joint_inv_bind_mat);
copy_m4_m4(joint_bind_mat, mat);
- // And make local to armature
+ /* And make local to armature */
Object *ob_arm = skin->BKE_armature_from_object();
if (ob_arm) {
float invmat[4][4];
@@ -138,7 +138,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
}
}
- // create a bone even if there's no joint data for it (i.e. it has no influence)
+ /* create a bone even if there's no joint data for it (i.e. it has no influence) */
if (!bone_is_skinned) {
get_node_mat(mat, node, NULL, NULL, parent_mat);
}
@@ -185,7 +185,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
bc_set_IDPropertyMatrix(bone, "rest_mat", rest_mat);
}
- add_v3_v3v3(bone->tail, bone->head, tail); //tail must be non zero
+ add_v3_v3v3(bone->tail, bone->head, tail); /* tail must be non zero */
/* find smallest bone length in armature (used later for leaf bone length) */
if (parent) {
@@ -371,7 +371,7 @@ void ArmatureImporter::set_leaf_bone_shapes(Object *ob_arm)
std::vector<LeafBone>::iterator it;
for (it = leaf_bones.begin(); it != leaf_bones.end(); it++) {
- LeafBone& leaf = *it;
+ LeafBone &leaf = *it;
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, leaf.name);
if (pchan) {
@@ -385,7 +385,7 @@ void ArmatureImporter::set_leaf_bone_shapes(Object *ob_arm)
void ArmatureImporter::set_euler_rotmode()
{
- // just set rotmode = ROT_MODE_EUL on pose channel for each joint
+ /* just set rotmode = ROT_MODE_EUL on pose channel for each joint */
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>::iterator it;
@@ -396,7 +396,7 @@ void ArmatureImporter::set_euler_rotmode()
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator sit;
for (sit = skin_by_data_uid.begin(); sit != skin_by_data_uid.end(); sit++) {
- SkinInfo& skin = sit->second;
+ SkinInfo &skin = sit->second;
if (skin.uses_joint_or_descendant(joint)) {
bPoseChannel *pchan = skin.get_pose_channel_from_node(joint);
@@ -430,26 +430,29 @@ Object *ArmatureImporter::get_empty_for_leaves()
Object *ArmatureImporter::find_armature(COLLADAFW::Node *node)
{
JointData *jd = get_joint_data(node);
- if (jd) return jd->ob_arm;
+ if (jd)
+ return jd->ob_arm;
- COLLADAFW::NodePointerArray& children = node->getChildNodes();
+ COLLADAFW::NodePointerArray &children = node->getChildNodes();
for (int i = 0; i < children.getCount(); i++) {
Object *ob_arm = find_armature(children[i]);
- if (ob_arm) return ob_arm;
+ if (ob_arm)
+ return ob_arm;
}
return NULL;
}
-ArmatureJoints& ArmatureImporter::get_armature_joints(Object *ob_arm)
+ArmatureJoints &ArmatureImporter::get_armature_joints(Object *ob_arm)
{
- // try finding it
+ /* try finding it */
std::vector<ArmatureJoints>::iterator it;
for (it = armature_joints.begin(); it != armature_joints.end(); it++) {
- if ((*it).ob_arm == ob_arm) return *it;
+ if ((*it).ob_arm == ob_arm)
+ return *it;
}
- // not found, create one
+ /* not found, create one */
ArmatureJoints aj;
aj.ob_arm = ob_arm;
armature_joints.push_back(aj);
@@ -462,7 +465,7 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
std::vector<COLLADAFW::Node *>::iterator ri;
std::vector<std::string> layer_labels;
- //if there is an armature created for root_joint next root_joint
+ /* if there is an armature created for root_joint next root_joint */
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
if (get_armature_for_joint(*ri) != NULL)
continue;
@@ -516,12 +519,12 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
{
- // just do like so:
- // - get armature
- // - enter editmode
- // - add edit bones and head/tail properties using matrices and parent-child info
- // - exit edit mode
- // - set a sphere shape to leaf bones
+ /* just do like so:
+ * - get armature
+ * - enter editmode
+ * - add edit bones and head/tail properties using matrices and parent-child info
+ * - exit edit mode
+ * - set a sphere shape to leaf bones */
Object *ob_arm = NULL;
@@ -540,8 +543,8 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
* for each root in root_joints:
* for each joint in joints:
* if find_node_in_tree(joint, root):
- * if (std::find(root_joints.begin(), root_joints.end(), root) == root_joints.end())
- * root_joints.push_back(root);
+ * if (std::find(root_joints.begin(), root_joints.end(), root) ==
+ * root_joints.end()) root_joints.push_back(root);
*
* for (each skin B with armature) {
* find all root joints for skin B
@@ -585,13 +588,13 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
}
if (!shared && this->joint_parent_map.size() > 0) {
- // All armatures have been created while creating the Node tree.
- // The Collada exporter currently does not create a
- // strict relationship between geometries and armatures
- // So when we reimport a Blender collada file, then we have
- // to guess what is meant.
- // XXX This is not safe when we have more than one armatures
- // in the import.
+ /* All armatures have been created while creating the Node tree.
+ * The Collada exporter currently does not create a
+ * strict relationship between geometries and armatures
+ * So when we reimport a Blender collada file, then we have
+ * to guess what is meant.
+ * XXX This is not safe when we have more than one armatures
+ * in the import. */
shared = this->joint_parent_map.begin()->second;
}
@@ -599,30 +602,29 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
ob_arm = skin.set_armature(shared);
}
else {
- ob_arm = skin.create_armature(m_bmain, scene, view_layer); //once for every armature
+ ob_arm = skin.create_armature(m_bmain, scene, view_layer); // once for every armature
}
- // enter armature edit mode
+ /* enter armature edit mode */
bArmature *armature = (bArmature *)ob_arm->data;
ED_armature_to_edit(armature);
totbone = 0;
- // bone_direction_row = 1; // TODO: don't default to Y but use asset and based on it decide on default row
+ // bone_direction_row = 1; // TODO: don't default to Y but use asset and based on it decide on
+ /* default row */
- // create bones
- /*
- TODO:
- check if bones have already been created for a given joint
- */
+ /* create bones */
+ /* TODO:
+ * check if bones have already been created for a given joint */
std::vector<COLLADAFW::Node *>::iterator ri;
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
- // for shared armature check if bone tree is already created
+ /* for shared armature check if bone tree is already created */
if (shared &&
std::find(skin_root_joints.begin(), skin_root_joints.end(), *ri) != skin_root_joints.end())
continue;
- // since root_joints may contain joints for multiple controllers, we need to filter
+ /* since root_joints may contain joints for multiple controllers, we need to filter */
if (skin.uses_joint_or_descendant(*ri)) {
create_bone(
@@ -661,14 +663,14 @@ void ArmatureImporter::set_pose(Object *ob_arm,
float mat[4][4];
float obmat[4][4];
- // object-space
+ /* object-space */
get_node_mat(obmat, root_node, NULL, NULL);
- //if (*edbone)
+ // if (*edbone)
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone_name);
- //else fprintf ( "",
+ // else fprintf ( "",
- // get world-space
+ /* get world-space */
if (parentname) {
mul_m4_m4m4(mat, parent_mat, obmat);
bPoseChannel *parchan = BKE_pose_channel_find_name(ob_arm->pose, parentname);
@@ -683,9 +685,11 @@ void ArmatureImporter::set_pose(Object *ob_arm,
mul_m4_m4m4(pchan->pose_mat, invObmat, mat);
}
- //float angle = 0.0f;
- ///*mat4_to_axis_angle(ax, &angle, mat);
- //pchan->bone->roll = angle;*/
+#if 0
+ float angle = 0.0f;
+ mat4_to_axis_angle(ax, &angle, mat);
+ pchan->bone->roll = angle;
+#endif
COLLADAFW::NodePointerArray &children = root_node->getChildNodes();
for (unsigned int i = 0; i < children.getCount(); i++) {
@@ -722,7 +726,7 @@ void ArmatureImporter::add_root_joint(COLLADAFW::Node *node)
}
#endif
-// here we add bones to armatures, having armatures previously created in write_controller
+/* here we add bones to armatures, having armatures previously created in write_controller */
void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &objects_to_scale)
{
Main *bmain = CTX_data_main(C);
@@ -738,7 +742,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
Object *ob_arm = create_armature_bones(bmain, skin);
- // link armature with a mesh object
+ /* link armature with a mesh object */
const COLLADAFW::UniqueId &uid = skin.get_controller_uid();
const COLLADAFW::UniqueId *guid = get_geometry_uid(uid);
if (guid != NULL) {
@@ -769,19 +773,19 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
else
fprintf(stderr, "Cannot find geometry to link armature with.\n");
- // set armature parent if any
+ /* set armature parent if any */
Object *par = skin.get_parent();
if (par)
bc_set_parent(skin.BKE_armature_from_object(), par, C, false);
- // free memory stolen from SkinControllerData
+ /* free memory stolen from SkinControllerData */
skin.free();
}
- //for bones without skins
+ /* for bones without skins */
create_armature_bones(bmain, ob_arms);
- // Fix bone relations
+ /* Fix bone relations */
std::vector<Object *>::iterator ob_arm_it;
for (ob_arm_it = ob_arms.begin(); ob_arm_it != ob_arms.end(); ob_arm_it++) {
@@ -799,8 +803,10 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
}
#if 0
-// link with meshes, create vertex groups, assign weights
-void ArmatureImporter::link_armature(Object *ob_arm, const COLLADAFW::UniqueId& geom_id, const COLLADAFW::UniqueId& controller_data_id)
+/* link with meshes, create vertex groups, assign weights */
+void ArmatureImporter::link_armature(Object *ob_arm,
+ const COLLADAFW::UniqueId &geom_id,
+ const COLLADAFW::UniqueId &controller_data_id)
{
Object *ob = mesh_importer->get_object_by_geom_uid(geom_id);
@@ -814,27 +820,27 @@ void ArmatureImporter::link_armature(Object *ob_arm, const COLLADAFW::UniqueId&
return;
}
- SkinInfo& skin = skin_by_data_uid[conroller_data_id];
+ SkinInfo &skin = skin_by_data_uid[conroller_data_id];
- // create vertex groups
+ /* create vertex groups */
}
#endif
bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControllerData *data)
{
- // at this stage we get vertex influence info that should go into me->verts and ob->defbase
- // there's no info to which object this should be long so we associate it with skin controller data UID
+ /* at this stage we get vertex influence info that should go into me->verts and ob->defbase
+ * there's no info to which object this should be long so we associate it with
+ * skin controller data UID. */
- // don't forget to call defgroup_unique_name before we copy
+ /* don't forget to call defgroup_unique_name before we copy */
- // controller data uid -> [armature] -> joint data,
- // [mesh object]
- //
+ /* controller data uid -> [armature] -> joint data,
+ * [mesh object] */
SkinInfo skin(unit_converter);
skin.borrow_skin_controller_data(data);
- // store join inv bind matrix to use it later in armature construction
+ /* store join inv bind matrix to use it later in armature construction */
const COLLADAFW::Matrix4Array &inv_bind_mats = data->getInverseBindMatrices();
for (unsigned int i = 0; i < data->getJointsCount(); i++) {
skin.add_joint(inv_bind_mats[i]);
@@ -847,12 +853,12 @@ bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControlle
bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
{
- // - create and store armature object
+ /* - create and store armature object */
const COLLADAFW::UniqueId &con_id = controller->getUniqueId();
if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_SKIN) {
COLLADAFW::SkinController *co = (COLLADAFW::SkinController *)controller;
- // to be able to find geom id by controller id
+ /* to be able to find geom id by controller id */
geom_uid_by_controller_uid[con_id] = co->getSource();
const COLLADAFW::UniqueId &data_uid = co->getSkinControllerData();
@@ -863,12 +869,12 @@ bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
skin_by_data_uid[data_uid].set_controller(co);
}
- // morph controller
+ /* morph controller */
else if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_MORPH) {
COLLADAFW::MorphController *co = (COLLADAFW::MorphController *)controller;
- // to be able to find geom id by controller id
+ /* to be able to find geom id by controller id */
geom_uid_by_controller_uid[con_id] = co->getSource();
- //Shape keys are applied in DocumentImporter->finish()
+ /* Shape keys are applied in DocumentImporter->finish() */
morph_controllers.push_back(co);
}
@@ -882,29 +888,29 @@ void ArmatureImporter::make_shape_keys(bContext *C)
float weight;
for (mc = morph_controllers.begin(); mc != morph_controllers.end(); mc++) {
- //Controller data
+ /* Controller data */
COLLADAFW::UniqueIdArray &morphTargetIds = (*mc)->getMorphTargets();
COLLADAFW::FloatOrDoubleArray &morphWeights = (*mc)->getMorphWeights();
- //Prereq: all the geometries must be imported and mesh objects must be made
+ /* Prereq: all the geometries must be imported and mesh objects must be made */
Object *source_ob = this->mesh_importer->get_object_by_geom_uid((*mc)->getSource());
if (source_ob) {
Mesh *source_me = (Mesh *)source_ob->data;
- //insert key to source mesh
+ /* insert key to source mesh */
Key *key = source_me->key = BKE_key_add(bmain, (ID *)source_me);
key->type = KEY_RELATIVE;
KeyBlock *kb;
- //insert basis key
+ /* insert basis key */
kb = BKE_keyblock_add_ctime(key, "Basis", false);
BKE_keyblock_convert_from_mesh(source_me, key, kb);
- //insert other shape keys
+ /* insert other shape keys */
for (int i = 0; i < morphTargetIds.getCount(); i++) {
- //better to have a separate map of morph objects,
- //This'll do for now since only mesh morphing is imported
+ /* better to have a separate map of morph objects,
+ * This'll do for now since only mesh morphing is imported */
Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]);
@@ -915,7 +921,7 @@ void ArmatureImporter::make_shape_keys(bContext *C)
kb = BKE_keyblock_add_ctime(key, morph_name.c_str(), false);
BKE_keyblock_convert_from_mesh(me, key, kb);
- //apply weights
+ /* apply weights */
weight = morphWeights.getFloatValues()->getData()[i];
kb->curval = weight;
}
@@ -968,7 +974,7 @@ void ArmatureImporter::get_rna_path_for_joint(COLLADAFW::Node *node,
BLI_snprintf(joint_path, count, "pose.bones[\"%s\"]", bc_get_joint_name(node));
}
-// gives a world-space mat
+/* gives a world-space mat */
bool ArmatureImporter::get_joint_bind_mat(float m[4][4], COLLADAFW::Node *joint)
{
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h
index cfcd9501790..19f053c61fb 100644
--- a/source/blender/collada/ArmatureImporter.h
+++ b/source/blender/collada/ArmatureImporter.h
@@ -73,7 +73,7 @@ class ArmatureImporter : private TransformReader {
#if 0
struct ArmatureJoints {
Object *ob_arm;
- std::vector<COLLADAFW::Node*> root_joints;
+ std::vector<COLLADAFW::Node *> root_joints;
};
std::vector<ArmatureJoints> armature_joints;
#endif
@@ -133,7 +133,7 @@ class ArmatureImporter : private TransformReader {
#if 0
Object *find_armature(COLLADAFW::Node *node);
- ArmatureJoints& get_armature_joints(Object *ob_arm);
+ ArmatureJoints &get_armature_joints(Object *ob_arm);
#endif
Object *create_armature_bones(Main *bmain, SkinInfo &skin);
@@ -161,7 +161,9 @@ class ArmatureImporter : private TransformReader {
#if 0
// link with meshes, create vertex groups, assign weights
- void link_armature(Object *ob_arm, const COLLADAFW::UniqueId& geom_id, const COLLADAFW::UniqueId& controller_data_id);
+ void link_armature(Object *ob_arm,
+ const COLLADAFW::UniqueId &geom_id,
+ const COLLADAFW::UniqueId &controller_data_id);
#endif
bool write_skin_controller_data(const COLLADAFW::SkinControllerData *data);
diff --git a/source/blender/collada/BCAnimationCurve.cpp b/source/blender/collada/BCAnimationCurve.cpp
index 2eb30d6779c..3f46d43840c 100644
--- a/source/blender/collada/BCAnimationCurve.cpp
+++ b/source/blender/collada/BCAnimationCurve.cpp
@@ -118,7 +118,7 @@ void BCAnimationCurve::create_bezt(float frame, float output)
BCAnimationCurve::~BCAnimationCurve()
{
if (curve_is_local_copy && fcurve) {
- //fprintf(stderr, "removed fcurve %s\n", fcurve->rna_path);
+ // fprintf(stderr, "removed fcurve %s\n", fcurve->rna_path);
delete_fcurve(fcurve);
this->fcurve = NULL;
}
@@ -262,10 +262,9 @@ FCurve *BCAnimationCurve::get_edit_fcurve()
fcurve = create_fcurve(index, path.c_str());
/* Caution here:
- Replacing the pointer here is OK only because the original value
- of FCurve was a const pointer into Blender territory. We do not
- touch that! We use the local copy to prepare data for export.
- */
+ * Replacing the pointer here is OK only because the original value
+ * of FCurve was a const pointer into Blender territory. We do not
+ * touch that! We use the local copy to prepare data for export. */
curve_is_local_copy = true;
}
@@ -638,7 +637,8 @@ void BCBezTriple::get_tangent(Scene *scene, float point[2], bool as_angle, int i
{
point[0] = FRA2TIME(bezt.vec[index][0]);
if (bezt.ipo != BEZT_IPO_BEZ) {
- /* We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data */
+ /* We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain
+ * unused data */
point[0] = 0;
point[1] = 0;
}
diff --git a/source/blender/collada/BCAnimationSampler.cpp b/source/blender/collada/BCAnimationSampler.cpp
index 858e47c1068..7b0c6c41a01 100644
--- a/source/blender/collada/BCAnimationSampler.cpp
+++ b/source/blender/collada/BCAnimationSampler.cpp
@@ -279,12 +279,11 @@ void BCAnimationSampler::find_depending_animated(std::set<Object *> &animated_ob
void BCAnimationSampler::get_animated_from_export_set(std::set<Object *> &animated_objects,
LinkNode &export_set)
{
- /*
- Check if this object is animated. That is: Check if it has its own action, or
-
- - Check if it has constraints to other objects
- - at least one of the other objects is animated as well
- */
+ /* Check if this object is animated. That is: Check if it has its own action, or:
+ *
+ * - Check if it has constraints to other objects.
+ * - at least one of the other objects is animated as well.
+ */
animated_objects.clear();
std::set<Object *> static_objects;
@@ -328,22 +327,20 @@ bool BCAnimationSampler::get_object_samples(BCMatrixSampleMap &samples, Object *
}
#if 0
-/*
- Add sampled values to FCurve
- If no FCurve exists, create a temporary FCurve;
- Note: The temporary FCurve will later be removed when the
- BCAnimationSampler is removed (by its destructor)
-
- curve: The curve to whioch the data is added
- matrices: The set of matrix values from where the data is taken
- animation_type BC_ANIMATION_EXPORT_SAMPLES: Use all matrix data
- animation_type BC_ANIMATION_EXPORT_KEYS: Only take data from matrices for keyframes
-*/
-
-void BCAnimationSampler::add_value_set(
- BCAnimationCurve &curve,
- BCFrameSampleMap &samples,
- BC_export_animation_type animation_type)
+/**
+ * Add sampled values to FCurve
+ * If no FCurve exists, create a temporary FCurve;
+ * Note: The temporary FCurve will later be removed when the
+ * BCAnimationSampler is removed (by its destructor)
+ *
+ * curve: The curve to whioch the data is added
+ * matrices: The set of matrix values from where the data is taken
+ * animation_type BC_ANIMATION_EXPORT_SAMPLES: Use all matrix data
+ * animation_type BC_ANIMATION_EXPORT_KEYS: Only take data from matrices for keyframes
+ */
+void BCAnimationSampler::add_value_set(BCAnimationCurve &curve,
+ BCFrameSampleMap &samples,
+ BC_export_animation_type animation_type)
{
int array_index = curve.get_array_index();
const BC_animation_transform_type tm_type = curve.get_transform_type();
diff --git a/source/blender/collada/BCAnimationSampler.h b/source/blender/collada/BCAnimationSampler.h
index aac5dc23c8f..e8d2ab56ae7 100644
--- a/source/blender/collada/BCAnimationSampler.h
+++ b/source/blender/collada/BCAnimationSampler.h
@@ -68,11 +68,9 @@ typedef std::map<Object *, BCAnimation *> BCAnimationObjectMap;
class BCSampleFrame {
- /*
- Each frame on the timeline that needs to be sampled will have
- one BCSampleFrame where we collect sample information about all objects
- that need to be sampled for that frame.
- */
+ /* Each frame on the timeline that needs to be sampled will have
+ * one BCSampleFrame where we collect sample information about all objects
+ * that need to be sampled for that frame. */
private:
BCSampleMap sampleMap;
diff --git a/source/blender/collada/BCSampleData.cpp b/source/blender/collada/BCSampleData.cpp
index 2571f3e2566..ceb0e07b9eb 100644
--- a/source/blender/collada/BCSampleData.cpp
+++ b/source/blender/collada/BCSampleData.cpp
@@ -66,7 +66,7 @@ BCMatrix::BCMatrix(BC_global_forward_axis global_forward_axis, BC_global_up_axis
mat3_from_axis_conversion(
BC_DEFAULT_FORWARD, BC_DEFAULT_UP, global_forward_axis, global_up_axis, mrot);
- //transpose_m3(mrot); // Assume that mat3_from_axis_conversion() returns a transposed matrix
+ // transpose_m3(mrot); // Assume that mat3_from_axis_conversion() returns a transposed matrix
copy_m4_m3(mat, mrot);
set_transform(mat);
}
@@ -179,10 +179,8 @@ void BCMatrix::unit()
quat_to_eul(this->rot, this->q);
}
-/*
-We need double here because the OpenCollada API needs it.
-precision = -1 indicates to not limit the precision
-*/
+/* We need double here because the OpenCollada API needs it.
+ * precision = -1 indicates to not limit the precision. */
void BCMatrix::get_matrix(DMatrix &mat, const bool transposed, const int precision) const
{
for (int i = 0; i < 4; i++)
diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt
index d104d01af56..e54b788903d 100644
--- a/source/blender/collada/CMakeLists.txt
+++ b/source/blender/collada/CMakeLists.txt
@@ -41,10 +41,10 @@ set(INC
../blentranslation
../depsgraph
../editors/include
+ ../imbuf
../makesdna
../makesrna
../windowmanager
- ../imbuf
../../../intern/guardedalloc
../ikplugin
../../../intern/iksolver/extern
diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp
index d3d431d4cf8..4ae185ae684 100644
--- a/source/blender/collada/ControllerExporter.cpp
+++ b/source/blender/collada/ControllerExporter.cpp
@@ -82,7 +82,7 @@ bool ControllerExporter::add_instance_controller(Object *ob)
if (!me->dvert)
return false;
- // write root bone URLs
+ /* write root bone URLs */
Bone *bone;
for (bone = (Bone *)arm->bonebase.first; bone; bone = bone->next) {
write_bone_URLs(ins, ob_arm, bone);
@@ -123,7 +123,8 @@ void ControllerExporter::operator()(Object *ob)
bool ArmatureExporter::already_written(Object *ob_arm)
{
- return std::find(written_armatures.begin(), written_armatures.end(), ob_arm) != written_armatures.end();
+ return std::find(written_armatures.begin(), written_armatures.end(), ob_arm) !=
+ written_armatures.end();
}
void ArmatureExporter::wrote(Object *ob_arm)
@@ -131,11 +132,13 @@ void ArmatureExporter::wrote(Object *ob_arm)
written_armatures.push_back(ob_arm);
}
-void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<Object *>& objects, Scene *sce)
+void ArmatureExporter::find_objects_using_armature(Object *ob_arm,
+ std::vector<Object *> &objects,
+ Scene *sce)
{
objects.clear();
- Base *base = (Base *) sce->base.first;
+ Base *base = (Base *)sce->base.first;
while (base) {
Object *ob = base->object;
@@ -159,25 +162,25 @@ std::string ControllerExporter::get_controller_id(Key *key, Object *ob)
return translate_id(id_name(ob)) + MORPH_CONTROLLER_ID_SUFFIX;
}
-// ob should be of type OB_MESH
-// both args are required
+/* ob should be of type OB_MESH
+ * both args are required */
void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
{
- // joint names
- // joint inverse bind matrices
- // vertex weights
+ /* joint names
+ * joint inverse bind matrices
+ * vertex weights */
- // input:
- // joint names: ob -> vertex group names
- // vertex group weights: me->dvert -> groups -> index, weight
+ /* input:
+ * joint names: ob -> vertex group names
+ * vertex group weights: me->dvert -> groups -> index, weight */
#if 0
me->dvert :
- typedef struct MDeformVert {
+ typedef struct MDeformVert {
struct MDeformWeight *dw;
int totweight;
- int flag; // flag only in use for weightpaint now
+ int flag; // flag only in use for weightpaint now
} MDeformVert;
typedef struct MDeformWeight {
@@ -219,7 +222,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
{
int i, j;
- // def group index -> joint index
+ /* def group index -> joint index */
std::vector<int> joint_index_by_def_index;
bDeformGroup *def;
@@ -235,14 +238,14 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
MDeformVert *vert = &me->dvert[i];
std::map<int, float> jw;
- // We're normalizing the weights later
+ /* We're normalizing the weights later */
float sumw = 0.0f;
for (j = 0; j < vert->totweight; j++) {
int idx = vert->dw[j].def_nr;
if (idx >= joint_index_by_def_index.size()) {
- // XXX: Maybe better find out where and
- // why the Out Of Bound indexes get created ?
+ /* XXX: Maybe better find out where and
+ * why the Out Of Bound indexes get created ? */
oob_counter += 1;
}
else {
@@ -328,8 +331,8 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key)
BKE_id_free(NULL, me);
- //support for animations
- //can also try the base element and param alternative
+ /* support for animations
+ * can also try the base element and param alternative */
add_weight_extras(key);
closeMorph();
closeController();
@@ -351,7 +354,7 @@ std::string ControllerExporter::add_morph_targets(Key *key, Object *ob)
source.prepareToAppendValues();
KeyBlock *kb = (KeyBlock *)key->block.first;
- //skip the basis
+ /* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(kb->name);
@@ -379,7 +382,7 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob)
source.prepareToAppendValues();
KeyBlock *kb = (KeyBlock *)key->block.first;
- //skip the basis
+ /* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
float weight = kb->curval;
@@ -390,18 +393,18 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob)
return source_id;
}
-//Added to implement support for animations.
+/* Added to implement support for animations. */
void ControllerExporter::add_weight_extras(Key *key)
{
- // can also try the base element and param alternative
+ /* can also try the base element and param alternative */
COLLADASW::BaseExtraTechnique extra;
KeyBlock *kb = (KeyBlock *)key->block.first;
- //skip the basis
+ /* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
- // XXX why is the weight not used here and set to 0.0?
- // float weight = kb->curval;
+ /* XXX why is the weight not used here and set to 0.0?
+ * float weight = kb->curval; */
extra.addExtraTechniqueParameter("KHR", "morph_weights", 0.000, "MORPH_WEIGHT_TO_TARGET");
}
}
@@ -434,7 +437,7 @@ void ControllerExporter::add_bind_shape_mat(Object *ob)
bc_add_global_transform(f_obmat, export_settings.get_global_transform());
}
- //UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
+ // UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
UnitConverter::mat4_to_dae_double(bind_mat, f_obmat);
if (this->export_settings.get_limit_precision())
bc_sanitize_mat(bind_mat, LIMITTED_PRECISION);
@@ -492,7 +495,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
COLLADASW::FloatSourceF source(mSW);
source.setId(source_id);
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
- source.setAccessorCount(totjoint); //BLI_listbase_count(defbase));
+ source.setAccessorCount(totjoint); // BLI_listbase_count(defbase));
source.setAccessorStride(16);
source.setParameterTypeName(&COLLADASW::CSWC::CSW_VALUE_TYPE_FLOAT4x4);
@@ -506,7 +509,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
int flag = arm->flag;
- // put armature in rest position
+ /* put armature in rest position */
if (!(arm->flag & ARM_RESTPOS)) {
Depsgraph *depsgraph = blender_context.get_depsgraph();
Scene *scene = blender_context.get_scene();
@@ -534,20 +537,19 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
bc_create_restpose_mat(
this->export_settings, pchan->bone, bind_mat, pchan->bone->arm_mat, true);
- // SL/OPEN_SIM COMPATIBILITY
+ /* SL/OPEN_SIM COMPATIBILITY */
if (export_settings.get_open_sim()) {
-
float loc[3];
float rot[3] = {0, 0, 0};
float scale[3];
bc_decompose(bind_mat, loc, NULL, NULL, scale);
- // Only translations, no rotation vs armature
+ /* Only translations, no rotation vs armature */
loc_eulO_size_to_mat4(bind_mat, loc, rot, scale, 6);
}
}
- // make world-space matrix (bind_mat is armature-space)
+ /* make world-space matrix (bind_mat is armature-space) */
mul_m4_m4m4(world, ob_arm->obmat, bind_mat);
if (export_settings.get_apply_global_orientation()) {
@@ -568,7 +570,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
}
}
- // back from rest position
+ /* back from rest position */
if (!(flag & ARM_RESTPOS)) {
Depsgraph *depsgraph = blender_context.get_depsgraph();
Scene *scene = blender_context.get_scene();
@@ -638,7 +640,7 @@ void ControllerExporter::add_vertex_weights_element(const std::string &weights_s
weightselem.setCount(vcounts.size());
- // write number of deformers per vertex
+ /* write number of deformers per vertex */
COLLADASW::PrimitivesBase::VCountList vcountlist;
vcountlist.resize(vcounts.size());
@@ -649,7 +651,7 @@ void ControllerExporter::add_vertex_weights_element(const std::string &weights_s
weightselem.CloseVCountAndOpenVElement();
- // write deformer index - weight index pairs
+ /* write deformer index - weight index pairs */
int weight_index = 0;
for (std::list<int>::const_iterator i = joints.begin(); i != joints.end(); ++i) {
weightselem.appendValues(*i, weight_index++);
diff --git a/source/blender/collada/ControllerExporter.h b/source/blender/collada/ControllerExporter.h
index e5b608365ca..200f8431f62 100644
--- a/source/blender/collada/ControllerExporter.h
+++ b/source/blender/collada/ControllerExporter.h
@@ -86,7 +86,7 @@ class ControllerExporter : public COLLADASW::LibraryControllers,
void wrote(Object *ob_arm);
- void find_objects_using_armature(Object *ob_arm, std::vector<Object *>& objects, Scene *sce);
+ void find_objects_using_armature(Object *ob_arm, std::vector<Object *> &objects, Scene *sce);
#endif
std::string get_controller_id(Object *ob_arm, Object *ob);
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index 06e154aea04..f9232851fbb 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -198,7 +198,7 @@ int DocumentExporter::exportCurrentScene()
RNA_id_pointer_create(&(sce->id), &sceneptr);
unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
system = RNA_struct_find_property(&unit_settings, "system");
- //scale = RNA_struct_find_property(&unit_settings, "scale_length");
+ // scale = RNA_struct_find_property(&unit_settings, "scale_length");
std::string unitname = "meter";
float linearmeasure = RNA_float_get(&unit_settings, "scale_length");
@@ -339,5 +339,6 @@ void DocumentExporter::exportScenes(const char *filename)
/*
* NOTES:
*
- * AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a user
+ * AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a
+ * user
*/
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index cc17c2c1a2b..320f8379c9e 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -18,9 +18,9 @@
* \ingroup collada
*/
-// TODO:
-// * name imported objects
-// * import object rotation as euler
+/* TODO:
+ * * name imported objects
+ * * import object rotation as euler */
#include <string>
#include <map>
@@ -131,7 +131,7 @@ bool DocumentImporter::import()
loader.registerExtraDataCallbackHandler(ehandler);
- // deselect all to select new objects
+ /* deselect all to select new objects */
BKE_view_layer_base_deselect_all(view_layer);
std::string mFilename = std::string(this->import_settings->filepath);
@@ -165,12 +165,12 @@ bool DocumentImporter::import()
void DocumentImporter::cancel(const COLLADAFW::String &errorMessage)
{
- // TODO: if possible show error info
- //
- // Should we get rid of invisible Meshes that were created so far
- // or maybe create objects at coordinate space origin?
- //
- // The latter sounds better.
+ /* TODO: if possible show error info
+ *
+ * Should we get rid of invisible Meshes that were created so far
+ * or maybe create objects at coordinate space origin?
+ *
+ * The latter sounds better. */
}
void DocumentImporter::start()
@@ -183,7 +183,8 @@ void DocumentImporter::finish()
return;
Main *bmain = CTX_data_main(mContext);
- // TODO: create a new scene except the selected <visual_scene> - use current blender scene for it
+ /* TODO: create a new scene except the selected <visual_scene> -
+ * use current blender scene for it */
Scene *sce = CTX_data_scene(mContext);
unit_converter.calculate_scale(*sce);
@@ -195,7 +196,7 @@ void DocumentImporter::finish()
PointerRNA sceneptr, unit_settings;
PropertyRNA *system, *scale;
- // for scene unit settings: system, scale_length
+ /* for scene unit settings: system, scale_length */
RNA_id_pointer_create(&sce->id, &sceneptr);
unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
@@ -220,7 +221,7 @@ void DocumentImporter::finish()
fprintf(stdout, "Collada: Adjusting Blender units to Importset units: %f.\n", unit_factor);
}
- // Write nodes to scene
+ /* Write nodes to scene */
fprintf(stderr, "+-- Import Scene --------\n");
const COLLADAFW::NodePointerArray &roots = (*sit)->getRootNodes();
for (unsigned int i = 0; i < roots.getCount(); i++) {
@@ -254,7 +255,7 @@ void DocumentImporter::finish()
if (libnode_ob.size()) {
fprintf(stderr, "| Cleanup: free %d library nodes\n", (int)libnode_ob.size());
- // free all library_nodes
+ /* free all library_nodes */
std::vector<Object *>::iterator it;
for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) {
Object *ob = *it;
@@ -267,7 +268,7 @@ void DocumentImporter::finish()
delete objects_to_scale;
- // update scene
+ /* update scene */
DEG_id_tag_update(&sce->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -277,15 +278,15 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
COLLADAFW::Node *par = NULL,
Object *parob = NULL)
{
- // The split in #29246, rootmap must point at actual root when
- // calculating bones in apply_curves_as_matrix. - actual root is the root node.
- // This has to do with inverse bind poses being world space
- // (the sources for skinned bones' restposes) and the way
- // non-skinning nodes have their "restpose" recursively calculated.
- // XXX TODO: design issue, how to support unrelated joints taking
- // part in skinning.
+ /* The split in #29246, rootmap must point at actual root when
+ * calculating bones in apply_curves_as_matrix. - actual root is the root node.
+ * This has to do with inverse bind poses being world space
+ * (the sources for skinned bones' restposes) and the way
+ * non-skinning nodes have their "restpose" recursively calculated.
+ * XXX TODO: design issue, how to support unrelated joints taking
+ * part in skinning. */
if (par) { // && par->getType() == COLLADAFW::Node::JOINT) {
- // par is root if there's no corresp. key in root_map
+ /* par is root if there's no corresp. key in root_map */
if (root_map.find(par->getUniqueId()) == root_map.end())
root_map[node->getUniqueId()] = node;
else
@@ -294,10 +295,10 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
#if 0
COLLADAFW::Transformation::TransformationType types[] = {
- COLLADAFW::Transformation::ROTATE,
- COLLADAFW::Transformation::SCALE,
- COLLADAFW::Transformation::TRANSLATE,
- COLLADAFW::Transformation::MATRIX,
+ COLLADAFW::Transformation::ROTATE,
+ COLLADAFW::Transformation::SCALE,
+ COLLADAFW::Transformation::TRANSLATE,
+ COLLADAFW::Transformation::MATRIX,
};
Object *ob;
@@ -305,9 +306,9 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
unsigned int i;
if (node->getType() == COLLADAFW::Node::JOINT && par == NULL) {
- // For Skeletons without root node we have to simulate the
- // root node here and recursively enter the same function
- // XXX: maybe this can be made more elegant.
+ /* For Skeletons without root node we have to simulate the
+ * root node here and recursively enter the same function
+ * XXX: maybe this can be made more elegant. */
translate_anim_recursive(node, node, parob);
}
else {
@@ -335,7 +336,7 @@ std::string DocumentImporter::get_import_version(const COLLADAFW::FileInfo *asse
const COLLADAFW::String &value = valuePair->second;
if (key == AUTORING_TOOL) {
if (value.compare(0, BLENDER.length(), BLENDER) == 0) {
- // Was made with Blender, now get version string
+ /* Was made with Blender, now get version string */
std::string v = value.substr(BLENDER.length());
std::string::size_type n = v.find(" ");
if (n > 0) {
@@ -361,7 +362,7 @@ bool DocumentImporter::writeGlobalAsset(const COLLADAFW::FileInfo *asset)
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeScene(const COLLADAFW::Scene *scene)
{
- // XXX could store the scene id, but do nothing for now
+ /* XXX could store the scene id, but do nothing for now */
return true;
}
Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce)
@@ -404,7 +405,9 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
Scene *sce,
bool is_library_node)
{
- //fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL);
+ // fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ?
+ // instance_node->getOriginalId().c_str() : NULL, source_node ?
+ // source_node->getOriginalId().c_str() : NULL);
Main *bmain = CTX_data_main(mContext);
Object *obn = BKE_object_copy(bmain, source_ob);
@@ -413,10 +416,10 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
if (instance_node) {
anim_importer.read_node_transform(instance_node, obn);
- // if we also have a source_node (always ;), take its
- // transformation matrix and apply it to the newly instantiated
- // object to account for node hierarchy transforms in
- // .dae
+ /* if we also have a source_node (always ;), take its
+ * transformation matrix and apply it to the newly instantiated
+ * object to account for node hierarchy transforms in
+ * .dae */
if (source_node) {
COLLADABU::Math::Matrix4 mat4 = source_node->getTransformationMatrix();
COLLADABU::Math::Matrix4 bmat4 =
@@ -427,7 +430,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
mat[i][j] = bmat4[i][j];
}
}
- // calc new matrix and apply
+ /* calc new matrix and apply */
mul_m4_m4m4(obn->obmat, obn->obmat, mat);
BKE_object_apply_mat4(obn, obn->obmat, 0, 0);
}
@@ -467,8 +470,8 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
return obn;
}
-// to create constraints off node <extra> tags. Assumes only constraint data in
-// current <extra> with blender profile.
+/* to create constraints off node <extra> tags. Assumes only constraint data in
+ * current <extra> with blender profile. */
void DocumentImporter::create_constraints(ExtraTags *et, Object *ob)
{
if (et && et->isProfile("blender")) {
@@ -504,7 +507,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
std::string id = node->getOriginalId();
std::string name = node->getName();
- // if node has child nodes write them
+ /* if node has child nodes write them */
COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
std::vector<Object *> *objects_done = new std::vector<Object *>();
@@ -515,8 +518,8 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
if (is_joint) {
if (parent_node == NULL && !is_library_node) {
- // A Joint on root level is a skeleton without root node.
- // Here we add the armature "on the fly":
+ /* A Joint on root level is a skeleton without root node.
+ * Here we add the armature "on the fly": */
par = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, std::string("Armature").c_str());
objects_done->push_back(par);
root_objects->push_back(par);
@@ -528,8 +531,8 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
if (parent_node == NULL) {
- // for skeletons without root node all has been done above.
- // Skeletons with root node are handled further down.
+ /* for skeletons without root node all has been done above.
+ * Skeletons with root node are handled further down. */
goto finally;
}
}
@@ -545,9 +548,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
size_t controller_done = 0;
size_t inst_done = 0;
- // XXX linking object with the first <instance_geometry>, though a node may have more of them...
- // maybe join multiple <instance_...> meshes into 1, and link object with it? not sure...
- // <instance_geometry>
+ /* XXX linking object with the first <instance_geometry>, though a node may have more of
+ * them... maybe join multiple <instance_...> meshes into 1, and link object with it? not
+ * sure... <instance_geometry> */
while (geom_done < geom.getCount()) {
ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map);
if (ob == NULL) {
@@ -602,7 +605,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
++controller_done;
}
- // XXX instance_node is not supported yet
+ /* XXX instance_node is not supported yet */
while (inst_done < inst_node.getCount()) {
const COLLADAFW::UniqueId &node_id = inst_node[inst_done]->getInstanciatedObjectId();
if (object_map.find(node_id) == object_map.end()) {
@@ -632,10 +635,10 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
read_transform = false;
}
- // if node is empty - create empty object
- // XXX empty node may not mean it is empty object, not sure about this
+ /* if node is empty - create empty object
+ * XXX empty node may not mean it is empty object, not sure about this */
if ((geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) {
- //Check if Object is armature, by checking if immediate child is a JOINT node.
+ /* Check if Object is armature, by checking if immediate child is a JOINT node. */
if (is_armature(node)) {
ob = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, name.c_str());
}
@@ -648,7 +651,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
}
- // XXX: if there're multiple instances, only one is stored
+ /* XXX: if there're multiple instances, only one is stored */
if (!ob) {
goto finally;
@@ -666,7 +669,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
libnode_ob.push_back(ob);
}
- //create_constraints(et,ob);
+ // create_constraints(et,ob);
}
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end();
@@ -682,7 +685,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
ob->partype = PAROBJECT;
ob->parsubstr[0] = 0;
- //bc_set_parent(ob, par, mContext, false);
+ // bc_set_parent(ob, par, mContext, false);
}
}
}
@@ -715,16 +718,17 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen
if (mImportStage == Fetching_Controller_data)
return true;
- // this method called on post process after writeGeometry, writeMaterial, etc.
-
- // for each <node> in <visual_scene>:
- // create an Object
- // if Mesh (previously created in writeGeometry) to which <node> corresponds exists, link Object with that mesh
-
- // update: since we cannot link a Mesh with Object in
- // writeGeometry because <geometry> does not reference <node>,
- // we link Objects with Meshes here
-
+ /* This method called on post process after writeGeometry, writeMaterial, etc. */
+
+ /* For each <node> in <visual_scene>:
+ * create an Object
+ * if Mesh (previously created in writeGeometry) to which <node> corresponds exists,
+ * link Object with that mesh.
+ *
+ * Update: since we cannot link a Mesh with Object in
+ * writeGeometry because <geometry> does not reference <node>,
+ * we link Objects with Meshes here.
+ */
vscenes.push_back(visualScene);
return true;
@@ -819,8 +823,8 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
fprintf(stderr, "Couldn't find <profile_COMMON>.\n");
return true;
}
- // XXX TODO: Take all <profile_common>s
- // Currently only first <profile_common> is supported
+ /* XXX TODO: Take all <profile_common>s
+ * Currently only first <profile_common> is supported */
COLLADAFW::EffectCommon *ef = common_efs[0];
write_profile_COMMON(ef, ma);
this->FW_object_map[effect->getUniqueId()] = effect;
@@ -888,7 +892,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
double yfov = camera->getYFov().getValue();
double aspect = camera->getAspectRatio().getValue();
- // NOTE: Needs more testing (As we curretnly have no official test data for this)
+ /* NOTE: Needs more testing (As we curretnly have no official test data for this) */
double xfov = 2.0f * atanf(aspect * tanf(DEG2RADF(yfov) * 0.5f));
cam->lens = fov_to_focallength(xfov, cam->sensor_x);
@@ -907,7 +911,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
case CAM_PERSP:
default: {
double x = camera->getXFov().getValue();
- // x is in degrees, cam->lens is in millimiters
+ /* x is in degrees, cam->lens is in millimiters */
cam->lens = fov_to_focallength(DEG2RADF(x), cam->sensor_x);
} break;
}
@@ -920,19 +924,19 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
case CAM_PERSP:
default: {
double yfov = camera->getYFov().getValue();
- // yfov is in degrees, cam->lens is in millimiters
+ /* yfov is in degrees, cam->lens is in millimiters */
cam->lens = fov_to_focallength(DEG2RADF(yfov), cam->sensor_x);
} break;
}
} break;
case COLLADAFW::Camera::UNDEFINED:
- // read nothing, use blender defaults.
+ /* read nothing, use blender defaults. */
break;
}
this->uid_camera_map[camera->getUniqueId()] = cam;
this->FW_object_map[camera->getUniqueId()] = camera;
- // XXX import camera options
+ /* XXX import camera options */
return true;
}
@@ -955,7 +959,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
workpath = absolute_path;
}
else {
- // Maybe imagepath was already absolute ?
+ /* Maybe imagepath was already absolute ? */
if (!BLI_exists(imagepath.c_str())) {
fprintf(stderr, "|! Image not found: %s\n", imagepath.c_str());
return true;
@@ -985,11 +989,14 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
std::string la_id, la_name;
ExtraTags *et = getExtraTags(light->getUniqueId());
- /*TagsMap::iterator etit;
+#if 0
+ TagsMap::iterator etit;
ExtraTags *et = 0;
etit = uid_tags_map.find(light->getUniqueId().toAscii());
- if (etit != uid_tags_map.end())
- et = etit->second;*/
+ if (etit != uid_tags_map.end()) {
+ et = etit->second;
+ }
+#endif
la_id = light->getOriginalId();
la_name = light->getName();
@@ -1003,7 +1010,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
return true;
}
- // if we find an ExtraTags for this, use that instead.
+ /* if we find an ExtraTags for this, use that instead. */
if (et && et->isProfile("blender")) {
et->setData("type", &(lamp->type));
et->setData("flag", &(lamp->flag));
@@ -1054,7 +1061,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
att2 = quadatt;
d = sqrt(1.0f / quadatt);
}
- // linear light
+ /* linear light */
else if (IS_EQ(quadatt, 0.0f) && linatt > 0.0f) {
att1 = linatt;
d = (1.0f / linatt);
@@ -1063,7 +1070,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
att1 = 1.0f;
}
else {
- // assuming point light (const att = 1.0);
+ /* assuming point light (const att = 1.0); */
att1 = 1.0f;
}
@@ -1074,7 +1081,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
switch (light->getLightType()) {
case COLLADAFW::Light::AMBIENT_LIGHT: {
- lamp->type = LA_SUN; //TODO needs more thoughts
+ lamp->type = LA_SUN; // TODO needs more thoughts
} break;
case COLLADAFW::Light::SPOT_LIGHT: {
lamp->type = LA_SPOT;
@@ -1112,7 +1119,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
return true;
}
-// this function is called only for animations that pass COLLADAFW::validate
+/* this function is called only for animations that pass COLLADAFW::validate */
bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
{
if (mImportStage == Fetching_Controller_data)
@@ -1121,26 +1128,27 @@ bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
return anim_importer.write_animation(anim);
}
-// called on post-process stage after writeVisualScenes
+/* called on post-process stage after writeVisualScenes */
bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animationList)
{
if (mImportStage == Fetching_Controller_data)
return true;
- // return true;
+ /* return true; */
return anim_importer.write_animation_list(animationList);
}
#if WITH_OPENCOLLADA_ANIMATION_CLIP
-// Since opencollada 1.6.68
-// called on post-process stage after writeVisualScenes
+/* Since opencollada 1.6.68
+ * called on post-process stage after writeVisualScenes */
bool DocumentImporter::writeAnimationClip(const COLLADAFW::AnimationClip *animationClip)
{
if (mImportStage == Fetching_Controller_data)
return true;
return true;
- //return animation_clip_importer.write_animation_clip(animationClip); // TODO: implement import of AnimationClips
+ /* TODO: implement import of AnimationClips */
+ // return animation_clip_importer.write_animation_clip(animationClip);
}
#endif
@@ -1151,7 +1159,7 @@ bool DocumentImporter::writeSkinControllerData(const COLLADAFW::SkinControllerDa
return armature_importer.write_skin_controller_data(skin);
}
-// this is called on postprocess, before writeVisualScenes
+/* this is called on postprocess, before writeVisualScenes */
bool DocumentImporter::writeController(const COLLADAFW::Controller *controller)
{
if (mImportStage == Fetching_Controller_data)
@@ -1196,6 +1204,6 @@ bool DocumentImporter::is_armature(COLLADAFW::Node *node)
}
}
- //no child is JOINT
+ /* no child is JOINT */
return false;
}
diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h
index b48ddaaa827..e47c844f7c6 100644
--- a/source/blender/collada/DocumentImporter.h
+++ b/source/blender/collada/DocumentImporter.h
@@ -81,7 +81,8 @@ class DocumentImporter : COLLADAFW::IWriter {
/** This is the method called. The writer hast to prepare to receive data.*/
void start();
- /** This method is called after the last write* method. No other methods will be called after this.*/
+ /** This method is called after the last write* method. No other methods will be called after
+ * this.*/
void finish();
bool writeGlobalAsset(const COLLADAFW::FileInfo *);
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
index 2cdb5e96648..bbd0a2e0bd3 100644
--- a/source/blender/collada/EffectExporter.cpp
+++ b/source/blender/collada/EffectExporter.cpp
@@ -93,8 +93,8 @@ void EffectsExporter::exportEffects(bContext *C, Scene *sce)
void EffectsExporter::set_shader_type(COLLADASW::EffectProfile &ep, Material *ma)
{
- ep.setShaderType(
- COLLADASW::EffectProfile::LAMBERT); //XXX check if BLINN and PHONG can be supported as well
+ /* XXX check if BLINN and PHONG can be supported as well */
+ ep.setShaderType(COLLADASW::EffectProfile::LAMBERT);
}
void EffectsExporter::set_transparency(COLLADASW::EffectProfile &ep, Material *ma)
@@ -199,7 +199,8 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
Image *ima = t->tex->ima;
// Image not set for texture
- if (!ima) continue;
+ if (!ima)
+ continue;
std::string key(id_name(ima));
key = translate_id(key);
@@ -207,10 +208,9 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
// create only one <sampler>/<surface> pair for each unique image
if (im_samp_map.find(key) == im_samp_map.end()) {
//<newparam> <sampler> <source>
- COLLADASW::Sampler sampler(
- COLLADASW::Sampler::SAMPLER_TYPE_2D,
- key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
- key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
+ COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
+ key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
+ key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
sampler.setImageId(key);
// copy values to arrays since they will live longer
samplers[a] = sampler;
@@ -236,7 +236,8 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
key = translate_id(key);
int i = im_samp_map[key];
std::string uvname = strlen(t->uvname) ? t->uvname : active_uv;
- COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i]; // possibly uninitialised memory ...
+ COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)
+ samp_surf[i]; // possibly uninitialised memory ...
writeTextures(ep, key, sampler, t, ima, uvname);
}
#endif
@@ -268,7 +269,7 @@ COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima,
COLLADASW::Texture texture(translate_id(id_name(ima)));
texture.setTexcoord(uv_layer_name);
- //texture.setSurface(*surface);
+ // texture.setSurface(*surface);
texture.setSampler(*sampler);
COLLADASW::ColorOrTexture cot(texture);
diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp
index 5aed0050a06..8109952b4ae 100644
--- a/source/blender/collada/ExtraHandler.cpp
+++ b/source/blender/collada/ExtraHandler.cpp
@@ -35,9 +35,9 @@ ExtraHandler::~ExtraHandler()
bool ExtraHandler::elementBegin(const char *elementName, const char **attributes)
{
- // \todo attribute handling for profile tags
+ /* \todo attribute handling for profile tags */
currentElement = std::string(elementName);
- //addToSidTree(attributes[0], attributes[1]);
+ // addToSidTree(attributes[0], attributes[1]);
return true;
}
@@ -72,7 +72,11 @@ bool ExtraHandler::parseElement(const char *profileName,
COLLADAFW::Object *object)
{
if (BLI_strcaseeq(profileName, "blender")) {
- //printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
+#if 0
+ printf("In parseElement for supported profile %s for id %s\n",
+ profileName,
+ uniqueId.toAscii().c_str());
+#endif
currentUid = uniqueId;
ExtraTags *et = dimp->getExtraTags(uniqueId);
if (!et) {
@@ -82,6 +86,7 @@ bool ExtraHandler::parseElement(const char *profileName,
currentExtraTags = et;
return true;
}
- //printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
+ // printf("In parseElement for unsupported profile %s for id %s\n", profileName,
+ // uniqueId.toAscii().c_str());
return false;
}
diff --git a/source/blender/collada/ExtraHandler.h b/source/blender/collada/ExtraHandler.h
index 8203b364953..b695f5221f6 100644
--- a/source/blender/collada/ExtraHandler.h
+++ b/source/blender/collada/ExtraHandler.h
@@ -50,7 +50,8 @@ class ExtraHandler : public COLLADASaxFWL::IExtraDataCallbackHandler {
/** Receive the data in text format. */
bool textData(const char *text, size_t textLength);
- /** Method to ask, if the current callback handler want to read the data of the given extra element. */
+ /** Method to ask, if the current callback handler want to read the data of the given extra
+ * element. */
bool parseElement(const char *profileName,
const unsigned long &elementHash,
const COLLADAFW::UniqueId &uniqueId,
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index c26b70a506e..926d85e7fb2 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -67,7 +67,7 @@ void GeometryExporter::operator()(Object *ob)
std::vector<Normal> nor;
std::vector<BCPolygonNormalsIndices> norind;
- // Skip if linked geometry was already exported from another reference
+ /* Skip if linked geometry was already exported from another reference */
if (use_instantiation && exportedGeometry.find(geom_id) != exportedGeometry.end()) {
return;
}
@@ -81,18 +81,18 @@ void GeometryExporter::operator()(Object *ob)
create_normals(nor, norind, me);
- // openMesh(geoId, geoName, meshId)
+ /* openMesh(geoId, geoName, meshId) */
openMesh(geom_id, geom_name);
- // writes <source> for vertex coords
+ /* writes <source> for vertex coords */
createVertsSource(geom_id, me);
- // writes <source> for normal coords
+ /* writes <source> for normal coords */
createNormalsSource(geom_id, me, nor);
bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
- // writes <source> for uv coords if mesh has uv coords
+ /* writes <source> for uv coords if mesh has uv coords */
if (has_uvs) {
createTexcoordsSource(geom_id, me);
}
@@ -100,7 +100,7 @@ void GeometryExporter::operator()(Object *ob)
if (has_color) {
createVertexColorSource(geom_id, me);
}
- // <vertices>
+ /* <vertices> */
COLLADASW::Vertices verts(mSW);
verts.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX));
@@ -112,9 +112,9 @@ void GeometryExporter::operator()(Object *ob)
createLooseEdgeList(ob, me, geom_id);
- // Only create Polylists if number of faces > 0
+ /* Only create Polylists if number of faces > 0 */
if (me->totface > 0) {
- // XXX slow
+ /* XXX slow */
if (ob->totcol) {
for (int a = 0; a < ob->totcol; a++) {
create_mesh_primitive_list(a, has_uvs, has_color, ob, me, geom_id, norind);
@@ -138,7 +138,7 @@ void GeometryExporter::operator()(Object *ob)
Key *key = BKE_key_from_object(ob);
if (key) {
KeyBlock *kb = (KeyBlock *)key->block.first;
- //skip the basis
+ /* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
BKE_keyblock_convert_to_mesh(kb, me);
@@ -171,15 +171,15 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
// openMesh(geoId, geoName, meshId)
openMesh(geom_id, geom_name);
- // writes <source> for vertex coords
+ /* writes <source> for vertex coords */
createVertsSource(geom_id, me);
- // writes <source> for normal coords
+ /* writes <source> for normal coords */
createNormalsSource(geom_id, me, nor);
bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
- // writes <source> for uv coords if mesh has uv coords
+ /* writes <source> for uv coords if mesh has uv coords */
if (has_uvs) {
createTexcoordsSource(geom_id, me);
}
@@ -188,7 +188,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
createVertexColorSource(geom_id, me);
}
- // <vertices>
+ /* <vertices> */
COLLADASW::Vertices verts(mSW);
verts.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX));
@@ -198,9 +198,9 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
input_list.push_back(input);
verts.add();
- //createLooseEdgeList(ob, me, geom_id, norind);
+ // createLooseEdgeList(ob, me, geom_id, norind);
- // XXX slow
+ /* XXX slow */
if (ob->totcol) {
for (int a = 0; a < ob->totcol; a++) {
create_mesh_primitive_list(a, has_uvs, has_color, ob, me, geom_id, norind);
@@ -229,8 +229,8 @@ void GeometryExporter::createLooseEdgeList(Object *ob, Mesh *me, std::string &ge
std::vector<unsigned int> edge_list;
int index;
- // Find all loose edges in Mesh
- // and save vertex indices in edge_list
+ /* Find all loose edges in Mesh
+ * and save vertex indices in edge_list */
for (index = 0; index < totedges; index++) {
MEdge *edge = &medges[index];
@@ -242,14 +242,14 @@ void GeometryExporter::createLooseEdgeList(Object *ob, Mesh *me, std::string &ge
}
if (edges_in_linelist > 0) {
- // Create the list of loose edges
+ /* Create the list of loose edges */
COLLADASW::Lines lines(mSW);
lines.setCount(edges_in_linelist);
COLLADASW::InputList &til = lines.getInputList();
- // creates <input> in <lines> for vertices
+ /* creates <input> in <lines> for vertices */
COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX,
getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX),
0);
@@ -269,12 +269,12 @@ static void prepareToAppendValues(bool is_triangulated,
COLLADASW::PrimitivesBase &primitive_list,
std::vector<unsigned long> &vcount_list)
{
- // performs the actual writing
+ /* performs the actual writing */
if (is_triangulated) {
((COLLADASW::Triangles &)primitive_list).prepareToAppendValues();
}
else {
- // sets <vcount>
+ /* sets <vcount> */
primitive_list.setVCountList(vcount_list);
((COLLADASW::Polylist &)primitive_list).prepareToAppendValues();
}
@@ -315,7 +315,7 @@ static bool collect_vertex_counts_per_poly(Mesh *me,
bool is_triangulated = true;
int i;
- // Expecting that p->mat_nr is always 0 if the mesh has no materials assigned
+ /* Expecting that p->mat_nr is always 0 if the mesh has no materials assigned */
for (i = 0; i < totpolys; i++) {
MPoly *p = &mpolys[i];
if (p->mat_nr == material_index) {
@@ -335,7 +335,7 @@ std::string GeometryExporter::makeVertexColorSourceId(std::string &geom_id, char
return result;
}
-// powerful because it handles both cases when there is material and when there's not
+/* powerful because it handles both cases when there is material and when there's not */
void GeometryExporter::create_mesh_primitive_list(short material_index,
bool has_uvs,
bool has_color,
@@ -354,7 +354,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
bool is_triangulated = collect_vertex_counts_per_poly(me, material_index, vcount_list);
int polygon_count = vcount_list.size();
- // no faces using this material
+ /* no faces using this material */
if (polygon_count == 0) {
fprintf(
stderr, "%s: material with index %d is not used.\n", id_name(ob).c_str(), material_index);
@@ -364,10 +364,10 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL;
COLLADASW::PrimitivesBase *primitive_list = create_primitive_list(is_triangulated, mSW);
- // sets count attribute in <polylist>
+ /* sets count attribute in <polylist> */
primitive_list->setCount(polygon_count);
- // sets material name
+ /* sets material name */
if (ma) {
std::string material_id = get_material_id(ma);
std::ostringstream ostr;
@@ -386,7 +386,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
til.push_back(vertex_input);
til.push_back(normals_input);
- // if mesh has uv coords writes <input> for TEXCOORD
+ /* if mesh has uv coords writes <input> for TEXCOORD */
int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV);
for (int i = 0; i < num_layers; i++) {
@@ -398,7 +398,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
COLLADASW::InputSemantic::TEXCOORD,
makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings.get_active_uv_only())),
2, // this is only until we have optimized UV sets
- (this->export_settings.get_active_uv_only()) ? 0 : layer_index - 1 //set (0,1,2,...)
+ (this->export_settings.get_active_uv_only()) ? 0 : layer_index - 1 /* set (0,1,2,...) */
);
til.push_back(texcoord_input);
}
@@ -420,10 +420,10 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
}
}
- // performs the actual writing
+ /* performs the actual writing */
prepareToAppendValues(is_triangulated, *primitive_list, vcount_list);
- // <p>
+ /* <p> */
int texindex = 0;
for (int i = 0; i < totpolys; i++) {
MPoly *p = &mpolys[i];
@@ -450,7 +450,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
finish_and_delete_primitive_List(is_triangulated, primitive_list);
}
-// creates <source> for positions
+/* creates <source> for positions */
void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
{
#if 0
@@ -474,14 +474,14 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
/* main function, it creates <source id = "">, <float_array id = ""
* count = ""> */
source.prepareToAppendValues();
- //appends data to <float_array>
+ /* appends data to <float_array> */
int i = 0;
for (i = 0; i < totverts; i++) {
Vector co;
- //if (export_settings.get_apply_global_orientation()) {
+ // if (export_settings.get_apply_global_orientation()) {
bc_add_global_transform(co, verts[i].co, export_settings.get_global_transform());
//}
- //else {
+ // else {
// copy_v3_v3(co, verts[i].co);
//}
source.appendValues(co[0], co[1], co[2]);
@@ -550,7 +550,7 @@ std::string GeometryExporter::makeTexcoordSourceId(std::string &geom_id,
return getIdBySemantics(geom_id, COLLADASW::InputSemantic::TEXCOORD) + suffix;
}
-//creates <source> for texcoords
+/* creates <source> for texcoords */
void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
{
@@ -560,8 +560,8 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
- // write <source> for each layer
- // each <source> will get id like meshName + "map-channel-1"
+ /* write <source> for each layer
+ * each <source> will get id like meshName + "map-channel-1" */
int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV);
for (int a = 0; a < num_layers; a++) {
int layer_index = CustomData_get_layer_index_n(&me->ldata, CD_MLOOPUV, a);
@@ -601,7 +601,7 @@ bool operator<(const Normal &a, const Normal &b)
return a.x < b.x || (a.x == b.x && (a.y < b.y || (a.y == b.y && a.z < b.z)));
}
-//creates <source> for normals
+/* creates <source> for normals */
void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal> &nor)
{
#if 0
@@ -626,7 +626,7 @@ void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::v
Normal &n = *it;
Vector no{n.x, n.y, n.z};
- //if (export_settings.get_apply_global_orientation()) {
+ // if (export_settings.get_apply_global_orientation()) {
bc_add_global_transform(no, export_settings.get_global_transform());
//}
source.appendValues(no[0], no[1], no[2]);
@@ -658,7 +658,7 @@ void GeometryExporter::create_normals(std::vector<Normal> &normals,
bool use_vertex_normals = use_custom_normals || mpoly->flag & ME_SMOOTH;
if (!use_vertex_normals) {
- // For flat faces use face normal as vertex normal:
+ /* For flat faces use face normal as vertex normal: */
float vector[3];
BKE_mesh_calc_poly_normal(mpoly, mloops + mpoly->loopstart, verts, vector);
diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h
index 18f36135c5b..7262784db82 100644
--- a/source/blender/collada/GeometryExporter.h
+++ b/source/blender/collada/GeometryExporter.h
@@ -52,7 +52,7 @@ class Normal {
bool operator<(const Normal &, const Normal &);
-// TODO: optimize UV sets by making indexed list with duplicates removed
+/* TODO: optimize UV sets by making indexed list with duplicates removed */
class GeometryExporter : COLLADASW::LibraryGeometries {
struct Face {
unsigned int v1, v2, v3, v4;
@@ -61,7 +61,7 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
Normal n;
public:
- // TODO: optimize UV sets by making indexed list with duplicates removed
+ /* TODO: optimize UV sets by making indexed list with duplicates removed */
GeometryExporter(BlenderContext &blender_context,
COLLADASW::StreamWriter *sw,
BCExportSettings &export_settings)
@@ -77,7 +77,7 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
void createLooseEdgeList(Object *ob, Mesh *me, std::string &geom_id);
- // powerful because it handles both cases when there is material and when there's not
+ /* powerful because it handles both cases when there is material and when there's not */
void create_mesh_primitive_list(short material_index,
bool has_uvs,
bool has_color,
@@ -86,18 +86,18 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
std::string &geom_id,
std::vector<BCPolygonNormalsIndices> &norind);
- // creates <source> for positions
+ /* creates <source> for positions */
void createVertsSource(std::string geom_id, Mesh *me);
void createVertexColorSource(std::string geom_id, Mesh *me);
std::string makeTexcoordSourceId(std::string &geom_id, int layer_index, bool is_single_layer);
- //creates <source> for texcoords
+ /* creates <source> for texcoords */
void createTexcoordsSource(std::string geom_id, Mesh *me);
void createTesselatedTexcoordsSource(std::string geom_id, Mesh *me);
- //creates <source> for normals
+ /* creates <source> for normals */
void createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal> &nor);
void create_normals(std::vector<Normal> &nor,
@@ -126,8 +126,8 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
};
struct GeometryFunctor {
- // f should have
- // void operator()(Object *ob)
+ /* f should have
+ * void operator()(Object *ob) */
template<class Functor>
void forEachMeshObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp
index 34d60c6aede..f4837d3d358 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -75,27 +75,27 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
char export_dir[FILE_MAX];
char export_file[FILE_MAX];
- // Destination folder for exported assets
+ /* Destination folder for exported assets */
BLI_split_dir_part(this->export_settings.get_filepath(), export_dir, sizeof(export_dir));
if (is_generated || is_dirty || use_copies || is_packed) {
- // make absolute destination path
+ /* make absolute destination path */
BLI_strncpy(export_file, name.c_str(), sizeof(export_file));
BKE_image_path_ensure_ext_from_imformat(export_file, &imageFormat);
BLI_join_dirfile(export_path, sizeof(export_path), export_dir, export_file);
- // make dest directory if it doesn't exist
+ /* make dest directory if it doesn't exist */
BLI_make_existing_file(export_path);
}
if (is_generated || is_dirty || is_packed) {
- // This image in its current state only exists in Blender memory.
- // So we have to export it. The export will keep the image state intact,
- // so the exported file will not be associated with the image.
+ /* This image in its current state only exists in Blender memory.
+ * So we have to export it. The export will keep the image state intact,
+ * so the exported file will not be associated with the image. */
if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) {
fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path);
@@ -105,18 +105,18 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
}
else {
- // make absolute source path
+ /* make absolute source path */
BLI_strncpy(source_path, image->name, sizeof(source_path));
BLI_path_abs(source_path, BKE_main_blendfile_path_from_global());
BLI_cleanup_path(NULL, source_path);
if (use_copies) {
- // This image is already located on the file system.
- // But we want to create copies here.
- // To move images into the same export directory.
- // Note: If an image is already located in the export folder,
- // then skip the copy (as it would result in a file copy error).
+ /* This image is already located on the file system.
+ * But we want to create copies here.
+ * To move images into the same export directory.
+ * Note: If an image is already located in the export folder,
+ * then skip the copy (as it would result in a file copy error). */
if (BLI_path_cmp(source_path, export_path) != 0) {
if (BLI_copy(source_path, export_path) != 0) {
@@ -132,17 +132,18 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
}
else {
- // Do not make any copies, but use the source path directly as reference
- // to the original image
+ /* Do not make any copies, but use the source path directly as reference
+ * to the original image */
BLI_strncpy(export_path, source_path, sizeof(export_path));
}
}
- COLLADASW::Image img(
- COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)),
- translated_name,
- translated_name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */
+ /* Set name also to mNameNC.
+ * This helps other viewers import files exported from Blender better. */
+ COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)),
+ translated_name,
+ translated_name);
img.add(mSW);
fprintf(stdout, "Collada export: Added image: %s\n", export_file);
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 0c87b139c0c..00484295694 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -266,9 +266,8 @@ void MeshImporter::print_index_list(COLLADAFW::IndexList &index_list)
}
#endif
-bool MeshImporter::is_nice_mesh(
- COLLADAFW::Mesh *
- mesh) // checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans
+/* checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans */
+bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
{
COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();
diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h
index 68ab6e73732..9517587013d 100644
--- a/source/blender/collada/MeshImporter.h
+++ b/source/blender/collada/MeshImporter.h
@@ -47,7 +47,7 @@ extern "C" {
#include "DNA_scene_types.h"
}
-// only for ArmatureImporter to "see" MeshImporter::get_object_by_geom_uid
+/* only for ArmatureImporter to "see" MeshImporter::get_object_by_geom_uid */
class MeshImporterBase {
public:
virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) = 0;
@@ -86,22 +86,24 @@ class MeshImporter : public MeshImporterBase {
ArmatureImporter *armature_importer;
- std::map<std::string, std::string> mesh_geom_map; // needed for correct shape key naming
- std::map<COLLADAFW::UniqueId, Mesh *> uid_mesh_map; // geometry unique id-to-mesh map
- std::map<COLLADAFW::UniqueId, Object *> uid_object_map; // geom uid-to-object
- std::vector<Object *> imported_objects; // list of imported objects
+ std::map<std::string, std::string> mesh_geom_map; /* needed for correct shape key naming */
+ std::map<COLLADAFW::UniqueId, Mesh *> uid_mesh_map; /* geometry unique id-to-mesh map */
+ std::map<COLLADAFW::UniqueId, Object *> uid_object_map; /* geom uid-to-object */
+ std::vector<Object *> imported_objects; /* list of imported objects */
- // this structure is used to assign material indices to polygons
- // it holds a portion of Mesh faces and corresponds to a DAE primitive list (<triangles>, <polylist>, etc.)
+ /* this structure is used to assign material indices to polygons
+ * it holds a portion of Mesh faces and corresponds to a DAE primitive list
+ * (<triangles>, <polylist>, etc.) */
struct Primitive {
MPoly *mpoly;
unsigned int totpoly;
};
typedef std::map<COLLADAFW::MaterialId, std::vector<Primitive>> MaterialIdPrimitiveArrayMap;
- std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap>
- geom_uid_mat_mapping_map; // crazy name!
- std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId>
- materials_mapped_to_geom; //< materials that have already been mapped to a geometry. A pair of geom uid and mat uid, one geometry can have several materials
+ /* crazy name! */
+ std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap> geom_uid_mat_mapping_map;
+ /* < materials that have already been mapped to a geometry.
+ * A pair/of geom uid and mat uid, one geometry can have several materials */
+ std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId> materials_mapped_to_geom;
bool set_poly_indices(
MPoly *mpoly, MLoop *mloop, int loop_index, unsigned int *indices, int loop_count);
@@ -137,7 +139,7 @@ class MeshImporter : public MeshImporterBase {
void allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me);
- // TODO: import uv set names
+ /* TODO: import uv set names */
void read_polys(COLLADAFW::Mesh *mesh, Mesh *me);
void read_lines(COLLADAFW::Mesh *mesh, Mesh *me);
unsigned int get_vertex_count(COLLADAFW::Polygons *mp, int index);
@@ -172,7 +174,7 @@ class MeshImporter : public MeshImporterBase {
bool isController,
std::map<COLLADAFW::UniqueId, Material *> &uid_material_map);
- // create a mesh storing a pointer in a map so it can be retrieved later by geometry UID
+ /* create a mesh storing a pointer in a map so it can be retrieved later by geometry UID */
bool write_geometry(const COLLADAFW::Geometry *geom);
std::string *get_geometry_name(const std::string &mesh_name);
};
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index 445e20496fe..22b2eed79d3 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -34,7 +34,7 @@ void SceneExporter::exportScene()
{
Scene *scene = blender_context.get_scene();
- // <library_visual_scenes> <visual_scene>
+ /* <library_visual_scenes> <visual_scene> */
std::string name = id_name(scene);
openVisualScene(translate_id(name), encode_xml(name));
exportHierarchy();
@@ -47,13 +47,13 @@ void SceneExporter::exportHierarchy()
LinkNode *node;
ColladaBaseNodes base_objects;
- // Ensure all objects in the export_set are marked
+ /* Ensure all objects in the export_set are marked */
for (node = this->export_settings.get_export_set(); node; node = node->next) {
Object *ob = (Object *)node->link;
ob->id.tag |= LIB_TAG_DOIT;
}
- // Now find all exportable base objects (highest in export hierarchy)
+ /* Now find all exportable base objects (highest in export hierarchy) */
for (node = this->export_settings.get_export_set(); node; node = node->next) {
Object *ob = (Object *)node->link;
if (this->export_settings.is_export_root(ob)) {
@@ -70,7 +70,7 @@ void SceneExporter::exportHierarchy()
}
}
- // And now export the base objects:
+ /* And now export the base objects: */
for (int index = 0; index < base_objects.size(); index++) {
Object *ob = base_objects.get(index);
writeNode(ob);
@@ -83,12 +83,11 @@ void SceneExporter::exportHierarchy()
void SceneExporter::writeNodeList(std::vector<Object *> &child_objects, Object *parent)
{
/* TODO: Handle the case where a parent is not exported
- Actually i am not even sure if this can be done at all
- in a good way.
- I really prefer to enforce the export of hidden
- elements in an object hierarchy. When the children of
- the hidden elements are exported as well.
- */
+ * Actually i am not even sure if this can be done at all
+ * in a good way.
+ * I really prefer to enforce the export of hidden
+ * elements in an object hierarchy. When the children of
+ * the hidden elements are exported as well. */
for (int i = 0; i < child_objects.size(); ++i) {
Object *child = child_objects[i];
writeNode(child);
@@ -106,7 +105,7 @@ void SceneExporter::writeNode(Object *ob)
bc_get_children(child_objects, ob, view_layer);
bool can_export = bc_is_in_Export_set(this->export_settings.get_export_set(), ob, view_layer);
- // Add associated armature first if available
+ /* Add associated armature first if available */
bool armature_exported = false;
Object *ob_arm = bc_get_assigned_armature(ob);
@@ -128,14 +127,14 @@ void SceneExporter::writeNode(Object *ob)
colladaNode.start();
if (ob->type == OB_MESH && armature_exported) {
- // for skinned mesh we write obmat in <bind_shape_matrix>
+ /* for skinned mesh we write obmat in <bind_shape_matrix> */
TransformWriter::add_node_transform_identity(colladaNode);
}
else {
TransformWriter::add_node_transform_ob(colladaNode, ob, this->export_settings);
}
- // <instance_geometry>
+ /* <instance_geometry> */
if (ob->type == OB_MESH) {
bool instance_controller_created = false;
if (armature_exported) {
@@ -153,27 +152,27 @@ void SceneExporter::writeNode(Object *ob)
}
}
- // <instance_controller>
+ /* <instance_controller> */
else if (ob->type == OB_ARMATURE) {
arm_exporter->add_armature_bones(ob, view_layer, this, child_objects);
}
- // <instance_camera>
+ /* <instance_camera> */
else if (ob->type == OB_CAMERA) {
COLLADASW::InstanceCamera instCam(
mSW, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_camera_id(ob)));
instCam.add();
}
- // <instance_light>
+ /* <instance_light> */
else if (ob->type == OB_LAMP) {
COLLADASW::InstanceLight instLa(
mSW, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_light_id(ob)));
instLa.add();
}
- // empty object
- else if (ob->type == OB_EMPTY) { // TODO: handle groups (OB_DUPLICOLLECTION
+ /* empty object */
+ else if (ob->type == OB_EMPTY) { /* TODO: handle groups (OB_DUPLICOLLECTION */
if ((ob->transflag & OB_DUPLICOLLECTION) == OB_DUPLICOLLECTION && ob->instance_collection) {
Collection *collection = ob->instance_collection;
/* printf("group detected '%s'\n", group->id.name + 2); */
@@ -206,9 +205,9 @@ void SceneExporter::writeNode(Object *ob)
colladaNode.addExtraTechniqueChildParameter(
"blender", con_tag, "lin_error", con->lin_error);
- //not ideal: add the target object name as another parameter.
- //No real mapping in the .dae
- //Need support for multiple target objects also.
+ /* not ideal: add the target object name as another parameter.
+ * No real mapping in the .dae
+ * Need support for multiple target objects also. */
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
if (cti && cti->get_constraint_targets) {
diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp
index d0f2e2d6332..3b5ea90d459 100644
--- a/source/blender/collada/SkinInfo.cpp
+++ b/source/blender/collada/SkinInfo.cpp
@@ -45,16 +45,16 @@
#include "SkinInfo.h"
#include "collada_utils.h"
-// use name, or fall back to original id if name not present (name is optional)
+/* use name, or fall back to original id if name not present (name is optional) */
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
return id.size() ? id.c_str() : node->getOriginalId().c_str();
}
-// This is used to store data passed in write_controller_data.
-// Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
-// so that arrays don't get freed until we free them explicitly.
+/* This is used to store data passed in write_controller_data.
+ * Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
+ * so that arrays don't get freed until we free them explicitly. */
SkinInfo::SkinInfo()
{
/* pass */
@@ -79,7 +79,7 @@ SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(NULL), pa
{
}
-// nobody owns the data after this, so it should be freed manually with releaseMemory
+/* nobody owns the data after this, so it should be freed manually with releaseMemory */
template<class T> void SkinInfo::transfer_array_data(T &src, T &dest)
{
dest.setData(src.getData(), src.getCount());
@@ -87,7 +87,7 @@ template<class T> void SkinInfo::transfer_array_data(T &src, T &dest)
dest.yieldOwnerShip();
}
-// when src is const we cannot src.yieldOwnerShip, this is used by copy constructor
+/* when src is const we cannot src.yieldOwnerShip, this is used by copy constructor */
void SkinInfo::transfer_int_array_data_const(const COLLADAFW::IntValuesArray &src,
COLLADAFW::IntValuesArray &dest)
{
@@ -109,7 +109,7 @@ void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData *
transfer_array_data((COLLADAFW::IntValuesArray &)skin->getJointIndices(), joint_indices);
// transfer_array_data(skin->getWeights(), weights);
- // cannot transfer data for FloatOrDoubleArray, copy values manually
+ /* cannot transfer data for FloatOrDoubleArray, copy values manually */
const COLLADAFW::FloatOrDoubleArray &weight = skin->getWeights();
for (unsigned int i = 0; i < weight.getValuesCount(); i++)
weights.push_back(bc_get_float_value(weight, i));
@@ -125,9 +125,9 @@ void SkinInfo::free()
// weights.releaseMemory();
}
-// using inverse bind matrices to construct armature
-// it is safe to invert them to get the original matrices
-// because if they are inverse matrices, they can be inverted
+/* using inverse bind matrices to construct armature
+ * it is safe to invert them to get the original matrices
+ * because if they are inverse matrices, they can be inverted */
void SkinInfo::add_joint(const COLLADABU::Math::Matrix4 &matrix)
{
JointData jd;
@@ -139,21 +139,21 @@ void SkinInfo::set_controller(const COLLADAFW::SkinController *co)
{
controller_uid = co->getUniqueId();
- // fill in joint UIDs
+ /* fill in joint UIDs */
const COLLADAFW::UniqueIdArray &joint_uids = co->getJoints();
for (unsigned int i = 0; i < joint_uids.getCount(); i++) {
joint_data[i].joint_uid = joint_uids[i];
- // // store armature pointer
+ /* store armature pointer */
// JointData& jd = joint_index_to_joint_info_map[i];
// jd.ob_arm = ob_arm;
- // now we'll be able to get inv bind matrix from joint id
+ /* now we'll be able to get inv bind matrix from joint id */
// joint_id_to_joint_index_map[joint_ids[i]] = i;
}
}
-// called from write_controller
+/* called from write_controller */
Object *SkinInfo::create_armature(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
ob_arm = bc_add_object(bmain, scene, view_layer, OB_ARMATURE, NULL);
@@ -193,11 +193,11 @@ const COLLADAFW::UniqueId &SkinInfo::get_controller_uid()
return controller_uid;
}
-// check if this skin controller references a joint or any descendant of it
-//
-// some nodes may not be referenced by SkinController,
-// in this case to determine if the node belongs to this armature,
-// we need to search down the tree
+/* check if this skin controller references a joint or any descendant of it
+ *
+ * some nodes may not be referenced by SkinController,
+ * in this case to determine if the node belongs to this armature,
+ * we need to search down the tree */
bool SkinInfo::uses_joint_or_descendant(COLLADAFW::Node *node)
{
const COLLADAFW::UniqueId &uid = node->getUniqueId();
@@ -248,17 +248,17 @@ void SkinInfo::link_armature(bContext *C,
amd->deformflag = ARM_DEF_VGROUP;
- // create all vertex groups
+ /* create all vertex groups */
std::vector<JointData>::iterator it;
int joint_index;
for (it = joint_data.begin(), joint_index = 0; it != joint_data.end(); it++, joint_index++) {
const char *name = "Group";
- // skip joints that have invalid UID
+ /* skip joints that have invalid UID */
if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID)
continue;
- // name group by joint node name
+ /* name group by joint node name */
if (joint_by_uid.find((*it).joint_uid) != joint_by_uid.end()) {
name = bc_get_joint_name(joint_by_uid[(*it).joint_uid]);
@@ -267,16 +267,16 @@ void SkinInfo::link_armature(bContext *C,
BKE_object_defgroup_add_name(ob, name);
}
- // <vcount> - number of joints per vertex - joints_per_vertex
- // <v> - [[bone index, weight index] * joints per vertex] * vertices - weight indices
- // ^ bone index can be -1 meaning weight toward bind shape, how to express this in Blender?
-
- // for each vertex in weight indices
- // for each bone index in vertex
- // add vertex to group at group index
- // treat group index -1 specially
-
- // get def group by index with BLI_findlink
+ /* <vcount> - number of joints per vertex - joints_per_vertex
+ * <v> - [[bone index, weight index] * joints per vertex] * vertices - weight indices
+ * ^ bone index can be -1 meaning weight toward bind shape, how to express this in Blender?
+ *
+ * for each vertex in weight indices
+ * for each bone index in vertex
+ * add vertex to group at group index
+ * treat group index -1 specially
+ *
+ * get def group by index with BLI_findlink */
for (unsigned int vertex = 0, weight = 0; vertex < joints_per_vertex.getCount(); vertex++) {
@@ -284,7 +284,7 @@ void SkinInfo::link_armature(bContext *C,
for (; weight < limit; weight++) {
int joint = joint_indices[weight], joint_weight = weight_indices[weight];
- // -1 means "weight towards the bind shape", we just don't assign it to any group
+ /* -1 means "weight towards the bind shape", we just don't assign it to any group */
if (joint != -1) {
bDeformGroup *def = (bDeformGroup *)BLI_findlink(&ob->defbase, joint);
@@ -314,17 +314,17 @@ void SkinInfo::find_root_joints(const std::vector<COLLADAFW::Node *> &root_joint
std::vector<COLLADAFW::Node *> &result)
{
std::vector<COLLADAFW::Node *>::const_iterator it;
- // for each root_joint
+ /* for each root_joint */
for (it = root_joints.begin(); it != root_joints.end(); it++) {
COLLADAFW::Node *root = *it;
std::vector<JointData>::iterator ji;
- //for each joint_data in this skin
+ /* for each joint_data in this skin */
for (ji = joint_data.begin(); ji != joint_data.end(); ji++) {
if (joint_by_uid.find((*ji).joint_uid) != joint_by_uid.end()) {
- //get joint node from joint map
+ /* get joint node from joint map */
COLLADAFW::Node *joint = joint_by_uid[(*ji).joint_uid];
- //find if joint node is in the tree belonging to the root_joint
+ /* find if joint node is in the tree belonging to the root_joint */
if (find_node_in_tree(joint, root)) {
if (std::find(result.begin(), result.end(), root) == result.end())
result.push_back(root);
diff --git a/source/blender/collada/TransformReader.h b/source/blender/collada/TransformReader.h
index 6add2950c06..2cf3ee795ae 100644
--- a/source/blender/collada/TransformReader.h
+++ b/source/blender/collada/TransformReader.h
@@ -35,7 +35,7 @@
#include "collada_internal.h"
-//struct Object;
+// struct Object;
class TransformReader {
protected:
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index 8a253c3f7ac..dfe4add8e7f 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -29,7 +29,7 @@ void TransformWriter::add_node_transform(COLLADASW::Node &node,
float mat[4][4],
float parent_mat[4][4])
{
- //bool limit_precision = export_settings.limit_precision;
+ // bool limit_precision = export_settings.limit_precision;
float loc[3], rot[3], scale[3];
float local[4][4];
@@ -66,11 +66,12 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node &node,
export_settings.get_export_transformation_type();
bool limit_precision = export_settings.get_limit_precision();
- /* Export the local Matrix (relative to the object parent, be it an object, bone or vertex(-tices)) */
+ /* Export the local Matrix (relative to the object parent,
+ * be it an object, bone or vertex(-tices)). */
Matrix f_obmat;
BKE_object_matrix_local_get(ob, f_obmat);
- //if (export_settings.is_export_root(ob)) {
+ // if (export_settings.is_export_root(ob)) {
// if (export_settings.get_apply_global_orientation()) {
// // do nothing. The rotation happens in the object data
// }
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 19234a0c7ca..4b85500008b 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -64,7 +64,7 @@ extern "C" {
#include "MEM_guardedalloc.h"
-#include "WM_api.h" // XXX hrm, see if we can do without this
+#include "WM_api.h" /* XXX hrm, see if we can do without this */
#include "WM_types.h"
#include "bmesh.h"
@@ -92,7 +92,7 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, unsigned in
return array.getDoubleValues()->getData()[index];
}
-// copied from /editors/object/object_relations.c
+/* copied from /editors/object/object_relations.c */
int bc_test_parent_loop(Object *par, Object *ob)
{
/* test if 'ob' is a parent somewhere in par's parents */
@@ -152,8 +152,7 @@ std::vector<bAction *> bc_getSceneActions(const bContext *C, Object *ob, bool al
for (id = (ID *)bmain->actions.first; id; id = (ID *)(id->next)) {
bAction *act = (bAction *)id;
/* XXX This currently creates too many actions.
- TODO Need to check if the action is compatible to the given object
- */
+ * TODO Need to check if the action is compatible to the given object. */
actions.push_back(act);
}
}
@@ -185,10 +184,8 @@ void bc_update_scene(BlenderContext &blender_context, float ctime)
Scene *scene = blender_context.get_scene();
Depsgraph *depsgraph = blender_context.get_depsgraph();
- /*
- * See remark in physics_fluid.c lines 395...)
- * BKE_scene_update_for_newframe(ev_context, bmain, scene, scene->lay);
- */
+ /* See remark in physics_fluid.c lines 395...) */
+ // BKE_scene_update_for_newframe(ev_context, bmain, scene, scene->lay);
BKE_scene_frame_set(scene, ctime);
ED_update_for_newframe(bmain, depsgraph);
}
@@ -221,13 +218,11 @@ Mesh *bc_get_mesh_copy(BlenderContext &blender_context,
if (apply_modifiers) {
#if 0 /* Not supported by new system currently... */
switch (export_mesh_type) {
- case BC_MESH_TYPE_VIEW:
- {
+ case BC_MESH_TYPE_VIEW: {
dm = mesh_create_derived_view(depsgraph, scene, ob, &mask);
break;
}
- case BC_MESH_TYPE_RENDER:
- {
+ case BC_MESH_TYPE_RENDER: {
dm = mesh_create_derived_render(depsgraph, scene, ob, &mask);
break;
}
@@ -285,7 +280,7 @@ bool bc_has_object_type(LinkNode *export_set, short obtype)
return false;
}
-// Use bubble sort algorithm for sorting the export set
+/* Use bubble sort algorithm for sorting the export set */
void bc_bubble_sort_by_Object_name(LinkNode *export_set)
{
bool sorted = false;
@@ -424,21 +419,22 @@ void bc_rotate_from_reference_quat(float quat_to[4], float quat_from[4], float m
float mat_from[4][4];
quat_to_mat4(mat_from, quat_from);
- // Calculate the difference matrix matd between mat_from and mat_to
+ /* Calculate the difference matrix matd between mat_from and mat_to */
invert_m4_m4(mati, mat_from);
mul_m4_m4m4(matd, mati, mat_to);
mat4_to_quat(qd, matd);
- mul_qt_qtqt(quat_to, qd, quat_from); // rot is the final rotation corresponding to mat_to
+ mul_qt_qtqt(quat_to, qd, quat_from); /* rot is the final rotation corresponding to mat_to */
}
void bc_triangulate_mesh(Mesh *me)
{
bool use_beauty = false;
bool tag_only = false;
- int quad_method =
- MOD_TRIANGULATE_QUAD_SHORTEDGE; /* XXX: The triangulation method selection could be offered in the UI */
+
+ /* XXX: The triangulation method selection could be offered in the UI. */
+ int quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE;
const struct BMeshCreateParams bm_create_params = {0};
BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default, &bm_create_params);
@@ -678,8 +674,8 @@ std::string BoneExtended::get_bone_layers(int bitfield)
int BoneExtended::get_bone_layers()
{
- return (bone_layers == 0) ? 1 :
- bone_layers; // ensure that the bone is in at least one bone layer!
+ /* ensure that the bone is in at least one bone layer! */
+ return (bone_layers == 0) ? 1 : bone_layers;
}
void BoneExtended::set_use_connect(int use_connect)
@@ -725,18 +721,16 @@ void bc_set_IDPropertyMatrix(EditBone *ebone, const char *key, float mat[4][4])
*/
static void bc_set_IDProperty(EditBone *ebone, const char *key, float value)
{
- if (ebone->prop == NULL)
- {
- IDPropertyTemplate val = { 0 };
+ if (ebone->prop == NULL) {
+ IDPropertyTemplate val = {0};
ebone->prop = IDP_New(IDP_GROUP, &val, "RNA_EditBone ID properties");
}
IDProperty *pgroup = (IDProperty *)ebone->prop;
- IDPropertyTemplate val = { 0 };
+ IDPropertyTemplate val = {0};
IDProperty *prop = IDP_New(IDP_FLOAT, &val, key);
IDP_Float(prop) = value;
IDP_AddToGroup(pgroup, prop);
-
}
#endif
@@ -889,7 +883,7 @@ bool bc_is_animated(BCMatrixSampleMap &values)
static float MIN_DISTANCE = 0.00001;
if (values.size() < 2)
- return false; // need at least 2 entries to be not flat
+ return false; /* need at least 2 entries to be not flat */
BCMatrixSampleMap::iterator it;
const BCMatrix *refmat = NULL;
@@ -915,7 +909,7 @@ bool bc_has_animations(Object *ob)
(bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first))
return true;
- //Check Material Effect parameter animations.
+ /* Check Material Effect parameter animations. */
for (int a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a + 1);
if (!ma)
@@ -1192,8 +1186,11 @@ bNode *bc_add_node(bContext *C, bNodeTree *ntree, int node_type, int locx, int l
}
#if 0
-// experimental, probably not used
-static bNodeSocket *bc_group_add_input_socket(bNodeTree *ntree, bNode *to_node, int to_index, std::string label)
+/* experimental, probably not used */
+static bNodeSocket *bc_group_add_input_socket(bNodeTree *ntree,
+ bNode *to_node,
+ int to_index,
+ std::string label)
{
bNodeSocket *to_socket = (bNodeSocket *)BLI_findlink(&to_node->inputs, to_index);
@@ -1209,7 +1206,10 @@ static bNodeSocket *bc_group_add_input_socket(bNodeTree *ntree, bNode *to_node,
return newsock;
}
-static bNodeSocket *bc_group_add_output_socket(bNodeTree *ntree, bNode *from_node, int from_index, std::string label)
+static bNodeSocket *bc_group_add_output_socket(bNodeTree *ntree,
+ bNode *from_node,
+ int from_index,
+ std::string label)
{
bNodeSocket *from_socket = (bNodeSocket *)BLI_findlink(&from_node->outputs, from_index);
@@ -1225,7 +1225,6 @@ static bNodeSocket *bc_group_add_output_socket(bNodeTree *ntree, bNode *from_nod
return newsock;
}
-
void bc_make_group(bContext *C, bNodeTree *ntree, std::map<std::string, bNode *> nmap)
{
bNode *gnode = node_group_make_from_selected(C, ntree, "ShaderNodeGroup", "ShaderNodeTree");
@@ -1270,7 +1269,7 @@ void bc_add_default_shader(bContext *C, Material *ma)
bc_node_add_link(ntree, nmap["transparent"], 0, nmap["mix"], 2);
bc_node_add_link(ntree, nmap["mix"], 0, nmap["out"], 0);
- // experimental, probably not used.
+ /* experimental, probably not used. */
bc_make_group(C, ntree, nmap);
#else
nmap["main"] = bc_add_node(C, ntree, SH_NODE_BSDF_PRINCIPLED, 0, 300);
@@ -1299,7 +1298,7 @@ COLLADASW::ColorOrTexture bc_get_base_color(bNode *shader)
return bc_get_cot(col[0], col[1], col[2], col[3]);
}
else {
- return bc_get_cot(0.8, 0.8, 0.8, 1.0); //default white
+ return bc_get_cot(0.8, 0.8, 0.8, 1.0); /* default white */
}
}
@@ -1316,7 +1315,7 @@ bool bc_get_reflectivity(bNode *shader, double &reflectivity)
double bc_get_reflectivity(Material *ma)
{
- double reflectivity = ma->spec; // fallback if no socket found
+ double reflectivity = ma->spec; /* fallback if no socket found */
bNode *master_shader = bc_get_master_shader(ma);
if (ma->use_nodes && master_shader) {
bc_get_reflectivity(master_shader, reflectivity);
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index be3d70b4340..8fe64a19401 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -173,9 +173,10 @@ inline bool bc_startswith(std::string const &value, std::string const &starting)
}
#if 0 /* UNUSED */
-inline bool bc_endswith(std::string const & value, std::string const & ending)
+inline bool bc_endswith(std::string const &value, std::string const &ending)
{
- if (ending.size() > value.size()) return false;
+ if (ending.size() > value.size())
+ return false;
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
}
#endif
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 49aee93c8a4..308a95c0e0c 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -30,15 +30,15 @@ set(INC
../imbuf
../makesdna
../makesrna
- ../windowmanager
../nodes
+ ../windowmanager
../nodes/composite
../nodes/intern
../render/extern/include
../render/intern/include
../../../extern/clew/include
- ../../../intern/guardedalloc
../../../intern/atomic
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index 9046a5e5dc3..55f68f2b5c1 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -26,6 +26,8 @@ extern "C" {
#include "DNA_color_types.h"
#include "DNA_node_types.h"
+/* Keep ascii art. */
+/* clang-format off */
/**
* \defgroup Model The data model of the compositor
* \defgroup Memory The memory management stuff
@@ -37,7 +39,8 @@ extern "C" {
* \page Introduction of the Blender Compositor
*
* \section bcomp Blender compositor
- * This project redesigns the internals of Blender's compositor. The project has been executed in 2011 by At Mind.
+ * This project redesigns the internals of Blender's compositor.
+ * The project has been executed in 2011 by At Mind.
* At Mind is a technology company located in Amsterdam, The Netherlands.
* The project has been crowd-funded. This code has been released under GPL2 to be used in Blender.
*
@@ -47,21 +50,24 @@ extern "C" {
* - Make the compositor work faster for you (workflow)
*
* \section speed Faster compositor
- * The speedup has been done by making better use of the hardware Blenders is working on. The previous compositor only
- * used a single threaded model to calculate a node. The only exception to this is the Defocus node.
+ * The speedup has been done by making better use of the hardware Blenders is working on.
+ * The previous compositor only used a single threaded model to calculate a node.
+ * The only exception to this is the Defocus node.
* Only when it is possible to calculate two full nodes in parallel a second thread was used.
* Current workstations have 8-16 threads available, and most of the time these are idle.
*
- * In the new compositor we want to use as much of threads as possible. Even new OpenCL capable GPU-hardware can be
- * used for calculation.
+ * In the new compositor we want to use as much of threads as possible.
+ * Even new OpenCL capable GPU-hardware can be used for calculation.
*
* \section workflow Work faster
- * The previous compositor only showed the final image. The compositor could wait a long time before seeing the result
- * of his work. The new compositor will work in a way that it will focus on getting information back to the user.
- * It will prioritize its work to get earlier user feedback.
+ * The previous compositor only showed the final image.
+ * The compositor could wait a long time before seeing the result of his work.
+ * The new compositor will work in a way that it will focus on
+ * getting information back to the user. It will prioritize its work to get earlier user feedback.
*
* \page memory Memory model
- * The main issue is the type of memory model to use. Blender is used by consumers and professionals.
+ * The main issue is the type of memory model to use.
+ * Blender is used by consumers and professionals.
* Ranging from low-end machines to very high-end machines.
* The system should work on high-end machines and on low-end machines.
* \page executing Executing
@@ -74,11 +80,15 @@ extern "C" {
* this all is controlled from \see ExecutionSystem.execute
*
* \section priority Render priority
- * Render priority is an priority of an output node. A user has a different need of Render priorities of output nodes
+ * Render priority is an priority of an output node.
+ * A user has a different need of Render priorities of output nodes
* than during editing.
- * for example. the Active ViewerNode has top priority during editing, but during rendering a CompositeNode has.
- * All NodeOperation has a setting for their render-priority, but only for output NodeOperation these have effect.
- * In ExecutionSystem.execute all priorities are checked. For every priority the ExecutionGroup's are check if the
+ * for example. the Active ViewerNode has top priority during editing,
+ * but during rendering a CompositeNode has.
+ * All NodeOperation has a setting for their render-priority,
+ * but only for output NodeOperation these have effect.
+ * In ExecutionSystem.execute all priorities are checked.
+ * For every priority the ExecutionGroup's are check if the
* priority do match.
* When match the ExecutionGroup will be executed (this happens in serial)
*
@@ -89,27 +99,35 @@ extern "C" {
* \section order Chunk order
*
* When a ExecutionGroup is executed, first the order of chunks are determined.
- * The settings are stored in the ViewerNode inside the ExecutionGroup. ExecutionGroups that have no viewer-node,
+ * The settings are stored in the ViewerNode inside the ExecutionGroup.
+ * ExecutionGroups that have no viewer-node,
* will use a default one.
* There are several possible chunk orders
- * - [@ref OrderOfChunks.COM_TO_CENTER_OUT]: Start calculating from a configurable point and order by nearest chunk
- * - [@ref OrderOfChunks.COM_TO_RANDOM]: Randomize all chunks.
- * - [@ref OrderOfChunks.COM_TO_TOP_DOWN]: Start calculation from the bottom to the top of the image
- * - [@ref OrderOfChunks.COM_TO_RULE_OF_THIRDS]: Experimental order based on 9 hot-spots in the image
+ * - [@ref OrderOfChunks.COM_TO_CENTER_OUT]:
+ * Start calculating from a configurable point and order by nearest chunk.
+ * - [@ref OrderOfChunks.COM_TO_RANDOM]:
+ * Randomize all chunks.
+ * - [@ref OrderOfChunks.COM_TO_TOP_DOWN]:
+ * Start calculation from the bottom to the top of the image.
+ * - [@ref OrderOfChunks.COM_TO_RULE_OF_THIRDS]:
+ * Experimental order based on 9 hot-spots in the image.
*
* When the chunk-order is determined, the first few chunks will be checked if they can be scheduled.
* Chunks can have three states:
- * - [@ref ChunkExecutionState.COM_ES_NOT_SCHEDULED]: Chunk is not yet scheduled, or dependencies are not met
- * - [@ref ChunkExecutionState.COM_ES_SCHEDULED]: All dependencies are met, chunk is scheduled, but not finished
- * - [@ref ChunkExecutionState.COM_ES_EXECUTED]: Chunk is finished
+ * - [@ref ChunkExecutionState.COM_ES_NOT_SCHEDULED]:
+ * Chunk is not yet scheduled, or dependencies are not met.
+ * - [@ref ChunkExecutionState.COM_ES_SCHEDULED]:
+ * All dependencies are met, chunk is scheduled, but not finished.
+ * - [@ref ChunkExecutionState.COM_ES_EXECUTED]:
+ * Chunk is finished.
*
* \see ExecutionGroup.execute
* \see ViewerOperation.getChunkOrder
* \see OrderOfChunks
*
* \section interest Area of interest
- * An ExecutionGroup can have dependencies to other ExecutionGroup's. Data passing from one ExecutionGroup to another
- * one are stored in 'chunks'.
+ * An ExecutionGroup can have dependencies to other ExecutionGroup's.
+ * Data passing from one ExecutionGroup to another one are stored in 'chunks'.
* If not all input chunks are available the chunk execution will not be scheduled.
* <pre>
* +-------------------------------------+ +--------------------------------------+
@@ -133,10 +151,12 @@ extern "C" {
* +---------------------------+
* </pre>
*
- * In the above example ExecutionGroup B has an outputoperation (ViewerOperation) and is being executed.
+ * In the above example ExecutionGroup B has an outputoperation (ViewerOperation)
+ * and is being executed.
* The first chunk is evaluated [@ref ExecutionGroup.scheduleChunkWhenPossible],
- * but not all input chunks are available. The relevant ExecutionGroup (that can calculate the missing chunks;
- * ExecutionGroup A) is asked to calculate the area ExecutionGroup B is missing.
+ * but not all input chunks are available.
+ * The relevant ExecutionGroup (that can calculate the missing chunks; ExecutionGroup A)
+ * is asked to calculate the area ExecutionGroup B is missing.
* [@ref ExecutionGroup.scheduleAreaWhenPossible]
* ExecutionGroup B checks what chunks the area spans, and tries to schedule these chunks.
* If all input data is available these chunks are scheduled [@ref ExecutionGroup.scheduleChunk]
@@ -200,47 +220,56 @@ extern "C" {
*
* </pre>
*
- * \see ExecutionGroup.execute Execute a complete ExecutionGroup. Halts until finished or breaked by user
+ * \see ExecutionGroup.execute Execute a complete ExecutionGroup.
+ * Halts until finished or breaked by user
* \see ExecutionGroup.scheduleChunkWhenPossible Tries to schedule a single chunk,
* checks if all input data is available. Can trigger dependent chunks to be calculated
- * \see ExecutionGroup.scheduleAreaWhenPossible Tries to schedule an area. This can be multiple chunks
+ * \see ExecutionGroup.scheduleAreaWhenPossible
+ * Tries to schedule an area. This can be multiple chunks
* (is called from [@ref ExecutionGroup.scheduleChunkWhenPossible])
* \see ExecutionGroup.scheduleChunk Schedule a chunk on the WorkScheduler
* \see NodeOperation.determineDependingAreaOfInterest Influence the area of interest of a chunk.
* \see WriteBufferOperation Operation to write to a MemoryProxy/MemoryBuffer
* \see ReadBufferOperation Operation to read from a MemoryProxy/MemoryBuffer
- * \see MemoryProxy proxy for information about memory image (a image consist out of multiple chunks)
+ * \see MemoryProxy proxy for information about memory image
+ * (a image consist out of multiple chunks)
* \see MemoryBuffer Allocated memory for a single chunk
*
* \section workscheduler WorkScheduler
- * the WorkScheduler is implemented as a static class. the responsibility of the WorkScheduler is to balance
- * WorkPackages to the available and free devices.
- * the work-scheduler can work in 2 states. For witching these between the state you need to recompile blender
+ * the WorkScheduler is implemented as a static class. the responsibility of the WorkScheduler
+ * is to balance WorkPackages to the available and free devices.
+ * the work-scheduler can work in 2 states.
+ * For witching these between the state you need to recompile blender
*
* \subsection multithread Multi threaded
* Default the work-scheduler will place all work as WorkPackage in a queue.
- * For every CPUcore a working thread is created. These working threads will ask the WorkScheduler if there is work
+ * For every CPUcore a working thread is created.
+ * These working threads will ask the WorkScheduler if there is work
* for a specific Device.
- * the work-scheduler will find work for the device and the device will be asked to execute the WorkPackage
+ * the work-scheduler will find work for the device and the device
+ * will be asked to execute the WorkPackage.
*
* \subsection singlethread Single threaded
- * For debugging reasons the multi-threading can be disabled. This is done by changing the COM_CURRENT_THREADING_MODEL
+ * For debugging reasons the multi-threading can be disabled.
+ * This is done by changing the COM_CURRENT_THREADING_MODEL
* to COM_TM_NOTHREAD. When compiling the work-scheduler
* will be changes to support no threading and run everything on the CPU.
*
* \section devices Devices
* A Device within the compositor context is a Hardware component that can used to calculate chunks.
* This chunk is encapsulated in a WorkPackage.
- * the WorkScheduler controls the devices and selects the device where a WorkPackage will be calculated.
+ * the WorkScheduler controls the devices and selects the device where a
+ * WorkPackage will be calculated.
*
* \subsection WS_Devices Workscheduler
- * The WorkScheduler controls all Devices. When initializing the compositor the WorkScheduler selects
- * all devices that will be used during compositor.
+ * The WorkScheduler controls all Devices.
+ * When initializing the compositor the WorkScheduler selects all
+ * devices that will be used during compositor.
* There are two types of Devices, CPUDevice and OpenCLDevice.
* When an ExecutionGroup schedules a Chunk the schedule method of the WorkScheduler
* The Workscheduler determines if the chunk can be run on an OpenCLDevice
- * (and that there are available OpenCLDevice). If this is the case the chunk will be added to the worklist for
- * OpenCLDevice's
+ * (and that there are available OpenCLDevice).
+ * If this is the case the chunk will be added to the worklist for OpenCLDevice's
* otherwise the chunk will be added to the worklist of CPUDevices.
*
* A thread will read the work-list and sends a workpackage to its device.
@@ -249,8 +278,8 @@ extern "C" {
* \see Device.execute method called to execute a chunk
*
* \subsection CPUDevice CPUDevice
- * When a CPUDevice gets a WorkPackage the Device will get the inputbuffer that is needed to calculate the chunk.
- * Allocation is already done by the ExecutionGroup.
+ * When a CPUDevice gets a WorkPackage the Device will get the inputbuffer that is needed to
+ * calculate the chunk. Allocation is already done by the ExecutionGroup.
* The outputbuffer of the chunk is being created.
* The OutputOperation of the ExecutionGroup is called to execute the area of the outputbuffer.
*
@@ -282,7 +311,8 @@ extern "C" {
* reference to the compositor editing tree
*
* \param rendering: [true false]
- * This parameter determines whether the function is called from rendering (true) or editing (false).
+ * This parameter determines whether the function is called from rendering
+ * (true) or editing (false).
* based on this setting the system will work differently:
* - during rendering only Composite & the File output node will be calculated
* \see NodeOperation.isOutputProgram(int rendering) of the specific operations
@@ -290,7 +320,8 @@ extern "C" {
* - during editing all output nodes will be calculated
* \see NodeOperation.isOutputProgram(int rendering) of the specific operations
*
- * - another quality setting can be used bNodeTree. The quality is determined by the bNodeTree fields.
+ * - another quality setting can be used bNodeTree.
+ * The quality is determined by the bNodeTree fields.
* quality can be modified by the user from within the node panels.
* \see bNodeTree.edit_quality
* \see bNodeTree.render_quality
@@ -309,6 +340,8 @@ extern "C" {
* should be checked further, probably it'll be also needed for preview
* generation in display space
*/
+/* clang-format off */
+
void COM_execute(RenderData *rd,
Scene *scene,
bNodeTree *editingtree,
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index de731b8e0da..7a38ad721bc 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -68,12 +68,14 @@ typedef enum CompositorPriority {
// workscheduler threading models
/**
- * COM_TM_QUEUE is a multithreaded model, which uses the BLI_thread_queue pattern. This is the default option.
+ * COM_TM_QUEUE is a multithreaded model, which uses the BLI_thread_queue pattern.
+ * This is the default option.
*/
#define COM_TM_QUEUE 1
/**
- * COM_TM_NOTHREAD is a single threading model, everything is executed in the caller thread. easy for debugging
+ * COM_TM_NOTHREAD is a single threading model, everything is executed in the caller thread.
+ * easy for debugging
*/
#define COM_TM_NOTHREAD 0
diff --git a/source/blender/compositor/intern/COM_CPUDevice.h b/source/blender/compositor/intern/COM_CPUDevice.h
index d82046a729f..1d411569146 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.h
+++ b/source/blender/compositor/intern/COM_CPUDevice.h
@@ -23,7 +23,8 @@
/**
* \brief class representing a CPU device.
- * \note for every hardware thread in the system a CPUDevice instance will exist in the workscheduler
+ * \note for every hardware thread in the system a CPUDevice instance
+ * will exist in the workscheduler.
*/
class CPUDevice : public Device {
public:
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index 466779ec9bd..f4cd60e3ee0 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -33,8 +33,8 @@
class CompositorContext {
private:
/**
- * \brief The rendering field describes if we are rendering (F12) or if we are editing (Node editor)
- * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * \brief The rendering field describes if we are rendering (F12) or if we are editing (Node
+ * editor) This field is initialized in ExecutionSystem and must only be read from that point on.
* \see ExecutionSystem
*/
bool m_rendering;
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index d7fac8bb5b4..9dc55527f0d 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -130,8 +130,9 @@ Node *Converter::convert(bNode *b_node)
Node *node = NULL;
/* ignore undefined nodes with missing or invalid node data */
- if (!nodeIsRegistered(b_node))
+ if (!nodeIsRegistered(b_node)) {
return NULL;
+ }
switch (b_node->type) {
case CMP_NODE_COMPOSITE:
@@ -514,8 +515,9 @@ void Converter::convertResolution(NodeOperationBuilder &builder,
TranslateOperation *translateOperation = new TranslateOperation();
translateOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
translateOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
- if (!first)
+ if (!first) {
first = translateOperation;
+ }
SetValueOperation *xop = new SetValueOperation();
xop->setValue(addX);
builder.addLink(xop->getOutputSocket(), translateOperation->getInputSocket(1));
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index 0d7fc40de17..1213246b9c9 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -41,7 +41,8 @@ class Converter {
*
* For all nodetypes a wrapper class is created.
*
- * \note When adding a new node to blender, this method needs to be changed to return the correct Node instance.
+ * \note When adding a new node to blender, this method needs to be changed to return the correct
+ * Node instance.
*
* \see Node
*/
@@ -55,7 +56,8 @@ class Converter {
static bool is_fast_node(bNode *b_node);
/**
- * \brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
+ * \brief This method will add a datetype conversion rule when the to-socket does not support the
+ * from-socket actual data type.
*
* \note this method is called when conversion is needed.
*
diff --git a/source/blender/compositor/intern/COM_Debug.cpp b/source/blender/compositor/intern/COM_Debug.cpp
index 67ac350de83..72c1e0cf316 100644
--- a/source/blender/compositor/intern/COM_Debug.cpp
+++ b/source/blender/compositor/intern/COM_Debug.cpp
@@ -53,19 +53,23 @@ DebugInfo::GroupStateMap DebugInfo::m_group_states;
std::string DebugInfo::node_name(const Node *node)
{
NodeNameMap::const_iterator it = m_node_names.find(node);
- if (it != m_node_names.end())
+ if (it != m_node_names.end()) {
return it->second;
- else
+ }
+ else {
return "";
+ }
}
std::string DebugInfo::operation_name(const NodeOperation *op)
{
OpNameMap::const_iterator it = m_op_names.find(op);
- if (it != m_op_names.end())
+ if (it != m_op_names.end()) {
return it->second;
- else
+ }
+ else {
return "";
+ }
}
void DebugInfo::convert_started()
@@ -79,8 +83,9 @@ void DebugInfo::execute_started(const ExecutionSystem *system)
m_group_states.clear();
for (ExecutionSystem::Groups::const_iterator it = system->m_groups.begin();
it != system->m_groups.end();
- ++it)
+ ++it) {
m_group_states[*it] = EG_WAIT;
+ }
}
void DebugInfo::node_added(const Node *node)
@@ -145,10 +150,12 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
}
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %p\r\n", operation);
- if (group)
+ if (group) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p_%p\"", operation, group);
- else
+ }
+ else {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p\"", operation);
+ }
len += snprintf(str + len,
maxlen > len ? maxlen - len : 0,
" [fillcolor=%s,style=filled,shape=record,label=\"{",
@@ -315,10 +322,13 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
# if 0
for (ExecutionSystem::Operations::const_iterator it = system->m_operations.begin();
- it != system->m_operations.end(); ++it)
- {
+ it != system->m_operations.end();
+ ++it) {
NodeOperation *op = *it;
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %s\r\n", node->getbNode()->typeinfo->ui_name);
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ "// OPERATION: %s\r\n",
+ node->getbNode()->typeinfo->ui_name);
}
# endif
@@ -357,16 +367,21 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
system, operation, group, str + len, maxlen > len ? maxlen - len : 0);
}
- // len += snprintf(str+len, maxlen>len ? maxlen-len : 0, "// OUTPUTOPERATION: %p\r\n", group->getOutputOperation());
- // len += snprintf(str+len, maxlen>len ? maxlen-len : 0, " O_%p\r\n", group->getOutputOperation());
+ // len += snprintf(str+len,
+ // maxlen>len ? maxlen-len : 0,
+ // "// OUTPUTOPERATION: %p\r\n", group->getOutputOperation());
+ // len += snprintf(
+ // str+len, maxlen>len ? maxlen-len : 0,
+ // " O_%p\r\n", group->getOutputOperation());
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
}
/* operations not included in any group */
for (int j = 0; j < totops; ++j) {
NodeOperation *operation = system->m_operations[j];
- if (op_groups.find(operation) != op_groups.end())
+ if (op_groups.find(operation) != op_groups.end()) {
continue;
+ }
op_groups[operation].push_back(std::string(""));
@@ -404,8 +419,9 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
NodeOperationInput *to = *it;
NodeOperationOutput *from = to->getLink();
- if (!from)
+ if (!from) {
continue;
+ }
std::string color;
switch (from->getDataType()) {
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index 50caf51cf48..1718722e860 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -86,7 +86,8 @@ bool ExecutionGroup::canContainOperation(NodeOperation *operation)
if (m_complex) {
return false;
}
- /* complex ops can't be added to other groups (except their own, which they initialize, see above) */
+ /* complex ops can't be added to other groups (except their own, which they initialize, see
+ * above) */
if (operation->isComplex()) {
return false;
}
@@ -96,8 +97,9 @@ bool ExecutionGroup::canContainOperation(NodeOperation *operation)
bool ExecutionGroup::addOperation(NodeOperation *operation)
{
- if (!canContainOperation(operation))
+ if (!canContainOperation(operation)) {
return false;
+ }
if (!operation->isReadBufferOperation() && !operation->isWriteBufferOperation()) {
m_complex = operation->isComplex();
@@ -187,7 +189,8 @@ void ExecutionGroup::determineNumberOfChunks()
}
/**
- * this method is called for the top execution groups. containing the compositor node or the preview node or the viewer node)
+ * this method is called for the top execution groups. containing the compositor node or the
+ * preview node or the viewer node)
*/
void ExecutionGroup::execute(ExecutionSystem *graph)
{
@@ -342,8 +345,9 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
startEvaluated = true;
numberEvaluated++;
- if (bTree->update_draw)
+ if (bTree->update_draw) {
bTree->update_draw(bTree->udh);
+ }
}
else if (state == COM_ES_SCHEDULED) {
finished = false;
@@ -401,8 +405,9 @@ MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *mem
void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers)
{
- if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED)
+ if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) {
this->m_chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED;
+ }
atomic_add_and_fetch_u(&this->m_chunksFinished, 1);
if (memoryBuffers) {
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index ff9ac5d0582..41ae6f1c5b2 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -55,7 +55,8 @@ typedef enum ChunkExecutionState {
/**
* \brief Class ExecutionGroup is a group of Operations that are executed as one.
- * This grouping is used to combine Operations that can be executed as one whole when multi-processing.
+ * This grouping is used to combine Operations that can be executed as one whole when
+ * multi-processing.
* \ingroup Execution
*/
class ExecutionGroup {
@@ -72,7 +73,8 @@ class ExecutionGroup {
/**
* \brief is this ExecutionGroup an input ExecutionGroup
- * an input execution group is a group that is at the end of the calculation (the output is important for the user)
+ * an input execution group is a group that is at the end of the calculation
+ * (the output is important for the user).
*/
int m_isOutput;
@@ -134,8 +136,9 @@ class ExecutionGroup {
Operations m_cachedReadOperations;
/**
- * \brief reference to the original bNodeTree, this field is only set for the 'top' execution group.
- * \note can only be used to call the callbacks for progress, status and break
+ * \brief reference to the original bNodeTree,
+ * this field is only set for the 'top' execution group.
+ * \note can only be used to call the callbacks for progress, status and break.
*/
const bNodeTree *m_bTree;
@@ -154,7 +157,8 @@ class ExecutionGroup {
/**
* \brief indicator when this ExecutionGroup has valid Operations in its vector for Execution
- * \note When building the ExecutionGroup Operations are added via recursion. First a WriteBufferOperations is added, then the
+ * \note When building the ExecutionGroup Operations are added via recursion.
+ * First a WriteBufferOperations is added, then the.
* \note Operation containing the settings that is important for the ExecutiongGroup is added,
* \note When this occurs, these settings are copied over from the node to the ExecutionGroup
* \note and the Initialized flag is set to true.
@@ -204,7 +208,8 @@ class ExecutionGroup {
/**
* \brief try to schedule a specific chunk.
- * \note scheduling succeeds when all input requirements are met and the chunks hasn't been scheduled yet.
+ * \note scheduling succeeds when all input requirements are met and the chunks hasn't been
+ * scheduled yet.
* \param graph:
* \param xChunk:
* \param yChunk:
@@ -375,9 +380,11 @@ class ExecutionGroup {
/**
* \brief schedule an ExecutionGroup
- * \note this method will return when all chunks have been calculated, or the execution has breaked (by user)
+ * \note this method will return when all chunks have been calculated, or the execution has
+ * breaked (by user)
*
- * first the order of the chunks will be determined. This is determined by finding the ViewerOperation and get the relevant information from it.
+ * first the order of the chunks will be determined. This is determined by finding the
+ * ViewerOperation and get the relevant information from it.
* - ChunkOrdering
* - CenterX
* - CenterY
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 55c2ed6c22b..009b1fb28cd 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -30,12 +30,13 @@ class ExecutionGroup;
/**
* \page execution Execution model
- * In order to get to an efficient model for execution, several steps are being done. these steps are explained below.
+ * In order to get to an efficient model for execution, several steps are being done. these steps
+ * are explained below.
*
* \section EM_Step1 Step 1: translating blender node system to the new compsitor system
- * Blenders node structure is based on C structs (DNA). These structs are not efficient in the new architecture.
- * We want to use classes in order to simplify the system.
- * during this step the blender node_tree is evaluated and converted to a CPP node system.
+ * Blenders node structure is based on C structs (DNA). These structs are not efficient in the new
+ * architecture. We want to use classes in order to simplify the system. during this step the
+ * blender node_tree is evaluated and converted to a CPP node system.
*
* \see ExecutionSystem
* \see Converter.convert
@@ -43,35 +44,41 @@ class ExecutionGroup;
*
* \section EM_Step2 Step2: translating nodes to operations
* Ungrouping the GroupNodes. Group nodes are node_tree's in node_tree's.
- * The new system only supports a single level of node_tree. We will 'flatten' the system in a single level.
+ * The new system only supports a single level of node_tree.
+ * We will 'flatten' the system in a single level.
* \see GroupNode
* \see ExecutionSystemHelper.ungroup
*
- * Every node has the ability to convert itself to operations. The node itself is responsible to create a correct
- * NodeOperation setup based on its internal settings.
- * Most Node only need to convert it to its NodeOperation. Like a ColorToBWNode doesn't check anything,
- * but replaces itself with a ConvertColorToBWOperation.
- * More complex nodes can use different NodeOperation based on settings; like MixNode.
- * based on the selected Mixtype a different operation will be used.
- * for more information see the page about creating new Nodes. [@subpage newnode]
+ * Every node has the ability to convert itself to operations. The node itself is responsible to
+ * create a correct NodeOperation setup based on its internal settings. Most Node only need to
+ * convert it to its NodeOperation. Like a ColorToBWNode doesn't check anything, but replaces
+ * itself with a ConvertColorToBWOperation. More complex nodes can use different NodeOperation
+ * based on settings; like MixNode. based on the selected Mixtype a different operation will be
+ * used. for more information see the page about creating new Nodes. [@subpage newnode]
*
* \see ExecutionSystem.convertToOperations
* \see Node.convertToOperations
* \see NodeOperation base class for all operations in the system
*
* \section EM_Step3 Step3: add additional conversions to the operation system
- * - Data type conversions: the system has 3 data types COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR.
- * The user can connect a Value socket to a color socket.
- * As values are ordered differently than colors a conversion happens.
+ * - Data type conversions: the system has 3 data types COM_DT_VALUE, COM_DT_VECTOR,
+ * COM_DT_COLOR. The user can connect a Value socket to a color socket. As values are ordered
+ * differently than colors a conversion happens.
*
* - Image size conversions: the system can automatically convert when resolutions do not match.
* An NodeInput has a resize mode. This can be any of the following settings.
- * - [@ref InputSocketResizeMode.COM_SC_CENTER]: The center of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_FIT_WIDTH]: The width of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_FIT_HEIGHT]: the height of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_FIT]: The width, or the height of both images are aligned to make sure that it fits.
- * - [@ref InputSocketResizeMode.COM_SC_STRETCH]: The width and the height of both images are aligned
- * - [@ref InputSocketResizeMode.COM_SC_NO_RESIZE]: bottom left of the images are aligned.
+ * - [@ref InputSocketResizeMode.COM_SC_CENTER]:
+ * The center of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_FIT_WIDTH]:
+ * The width of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_FIT_HEIGHT]:
+ * The height of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_FIT]:
+ * The width, or the height of both images are aligned to make sure that it fits.
+ * - [@ref InputSocketResizeMode.COM_SC_STRETCH]:
+ * The width and the height of both images are aligned.
+ * - [@ref InputSocketResizeMode.COM_SC_NO_RESIZE]:
+ * Bottom left of the images are aligned.
*
* \see Converter.convertDataType Datatype conversions
* \see Converter.convertResolution Image size conversions
@@ -79,8 +86,8 @@ class ExecutionGroup;
* \section EM_Step4 Step4: group operations in executions groups
* ExecutionGroup are groups of operations that are calculated as being one bigger operation.
* All operations will be part of an ExecutionGroup.
- * Complex nodes will be added to separate groups. Between ExecutionGroup's the data will be stored in MemoryBuffers.
- * ReadBufferOperations and WriteBufferOperations are added where needed.
+ * Complex nodes will be added to separate groups. Between ExecutionGroup's the data will be stored
+ * in MemoryBuffers. ReadBufferOperations and WriteBufferOperations are added where needed.
*
* <pre>
*
@@ -127,7 +134,7 @@ class ExecutionSystem {
*/
Groups m_groups;
- private: //methods
+ private: // methods
/**
* find all execution group with output nodes
*/
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 12cd55c95a3..df936818f33 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -35,7 +35,8 @@ extern "C" {
* \ingroup Memory
*/
typedef enum MemoryBufferState {
- /** \brief memory has been allocated on creator device and CPU machine, but kernel has not been executed */
+ /** \brief memory has been allocated on creator device and CPU machine,
+ * but kernel has not been executed */
COM_MB_ALLOCATED = 1,
/** \brief memory is available for use, content has been created */
COM_MB_AVAILABLE = 2,
@@ -158,10 +159,12 @@ class MemoryBuffer {
case COM_MB_CLIP:
break;
case COM_MB_EXTEND:
- if (x < 0)
+ if (x < 0) {
x = 0;
- if (x >= w)
+ }
+ if (x >= w) {
x = w;
+ }
break;
case COM_MB_REPEAT:
x = (x >= 0.0f ? (x % w) : (x % w) + w);
@@ -172,10 +175,12 @@ class MemoryBuffer {
case COM_MB_CLIP:
break;
case COM_MB_EXTEND:
- if (y < 0)
+ if (y < 0) {
y = 0;
- if (y >= h)
+ }
+ if (y >= h) {
y = h;
+ }
break;
case COM_MB_REPEAT:
y = (y >= 0.0f ? (y % h) : (y % h) + h);
@@ -197,10 +202,12 @@ class MemoryBuffer {
case COM_MB_CLIP:
break;
case COM_MB_EXTEND:
- if (x < 0)
+ if (x < 0) {
x = 0.0f;
- if (x >= w)
+ }
+ if (x >= w) {
x = w;
+ }
break;
case COM_MB_REPEAT:
x = fmodf(x, w);
@@ -211,10 +218,12 @@ class MemoryBuffer {
case COM_MB_CLIP:
break;
case COM_MB_EXTEND:
- if (y < 0)
+ if (y < 0) {
y = 0.0f;
- if (y >= h)
+ }
+ if (y >= h) {
y = h;
+ }
break;
case COM_MB_REPEAT:
y = fmodf(y, h);
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
index b38493e19f2..df5a8e690d3 100644
--- a/source/blender/compositor/intern/COM_Node.cpp
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -48,10 +48,12 @@ Node::Node(bNode *editorNode, bool create_sockets)
bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
while (input != NULL) {
DataType dt = COM_DT_VALUE;
- if (input->type == SOCK_RGBA)
+ if (input->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
- if (input->type == SOCK_VECTOR)
+ }
+ if (input->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
+ }
this->addInputSocket(dt, input);
input = input->next;
@@ -59,10 +61,12 @@ Node::Node(bNode *editorNode, bool create_sockets)
bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
while (output != NULL) {
DataType dt = COM_DT_VALUE;
- if (output->type == SOCK_RGBA)
+ if (output->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
- if (output->type == SOCK_VECTOR)
+ }
+ if (output->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
+ }
this->addOutputSocket(dt, output);
output = output->next;
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index 9bacf271283..c26f6cdfb8b 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -112,7 +112,8 @@ class Node {
/**
* \brief set the reference to the bNode
- * \note used in Node instances to receive the storage/settings and complex node for highlight during execution
+ * \note used in Node instances to receive the storage/settings and complex
+ * node for highlight during execution.
* \param bNode:
*/
void setbNode(bNode *node)
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp
index 89f4542d42f..b4d6cc0ff60 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.cpp
+++ b/source/blender/compositor/intern/COM_NodeGraph.cpp
@@ -60,8 +60,9 @@ bNodeSocket *NodeGraph::find_b_node_input(bNode *b_group_node, const char *ident
{
for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->inputs.first; b_sock;
b_sock = b_sock->next) {
- if (STREQ(b_sock->identifier, identifier))
+ if (STREQ(b_sock->identifier, identifier)) {
return b_sock;
+ }
}
return NULL;
}
@@ -70,8 +71,9 @@ bNodeSocket *NodeGraph::find_b_node_output(bNode *b_group_node, const char *iden
{
for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->outputs.first; b_sock;
b_sock = b_sock->next) {
- if (STREQ(b_sock->identifier, identifier))
+ if (STREQ(b_sock->identifier, identifier)) {
return b_sock;
+ }
}
return NULL;
}
@@ -149,8 +151,9 @@ void NodeGraph::add_bNode(const CompositorContext &context,
else {
/* regular nodes, handled in Converter */
Node *node = Converter::convert(b_node);
- if (node)
+ if (node) {
add_node(node, b_ntree, key, is_active_group);
+ }
}
}
@@ -186,24 +189,28 @@ NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket *b_s
void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink)
{
/// \note: ignore invalid links
- if (!(b_nodelink->flag & NODE_LINK_VALID))
+ if (!(b_nodelink->flag & NODE_LINK_VALID)) {
return;
- if ((b_nodelink->fromsock->flag & SOCK_UNAVAIL) || (b_nodelink->tosock->flag & SOCK_UNAVAIL))
+ }
+ if ((b_nodelink->fromsock->flag & SOCK_UNAVAIL) || (b_nodelink->tosock->flag & SOCK_UNAVAIL)) {
return;
+ }
/* Note: a DNA input socket can have multiple NodeInput in the compositor tree! (proxies)
* The output then gets linked to each one of them.
*/
NodeOutput *output = find_output(node_range, b_nodelink->fromsock);
- if (!output)
+ if (!output) {
return;
+ }
NodeInputs inputs = find_inputs(node_range, b_nodelink->tosock);
for (NodeInputs::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
NodeInput *input = *it;
- if (input->isLinked())
+ if (input->isLinked()) {
continue;
+ }
add_link(output, input);
}
}
@@ -232,8 +239,9 @@ void NodeGraph::add_proxies_skip(bNodeTree *b_ntree,
/* look for first input with matching datatype for each output */
for (input = (bNodeSocket *)b_node->inputs.first; input; input = input->next) {
- if (input->type == output->type)
+ if (input->type == output->type) {
break;
+ }
}
if (input) {
@@ -295,7 +303,8 @@ void NodeGraph::add_proxies_group(const CompositorContext &context,
/* missing node group datablock can happen with library linking */
if (!b_group_tree) {
- /* this error case its handled in convertToOperations() so we don't get un-convertred sockets */
+ /* This error case its handled in convertToOperations()
+ * so we don't get un-converted sockets. */
return;
}
@@ -305,11 +314,13 @@ void NodeGraph::add_proxies_group(const CompositorContext &context,
/* create proxy nodes for group input/output nodes */
for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io;
b_node_io = b_node_io->next) {
- if (b_node_io->type == NODE_GROUP_INPUT)
+ if (b_node_io->type == NODE_GROUP_INPUT) {
add_proxies_group_inputs(b_node, b_node_io);
+ }
- if (b_node_io->type == NODE_GROUP_OUTPUT && (b_node_io->flag & NODE_DO_OUTPUT))
+ if (b_node_io->type == NODE_GROUP_OUTPUT && (b_node_io->flag & NODE_DO_OUTPUT)) {
add_proxies_group_outputs(b_node, b_node_io, context.isGroupnodeBufferEnabled());
+ }
}
add_bNodeTree(context, nodes_start, b_group_tree, key);
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
index b0f7bf746fa..80243c10760 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -142,10 +142,12 @@ SocketReader *NodeOperation::getInputSocketReader(unsigned int inputSocketIndex)
NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
{
NodeOperationInput *input = getInputSocket(inputSocketIndex);
- if (input && input->isConnected())
+ if (input && input->isConnected()) {
return &input->getLink()->getOperation();
- else
+ }
+ else {
return NULL;
+ }
}
void NodeOperation::getConnectedInputSockets(Inputs *sockets)
@@ -216,8 +218,9 @@ SocketReader *NodeOperationInput::getReader()
void NodeOperationInput::determineResolution(unsigned int resolution[2],
unsigned int preferredResolution[2])
{
- if (m_link)
+ if (m_link) {
m_link->determineResolution(resolution, preferredResolution);
+ }
}
/******************
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 939d3e1f8a7..af9ed2648c9 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -53,17 +53,21 @@ class NodeOperationOutput;
* \ingroup Model
*/
typedef enum InputResizeMode {
- /** \brief Center the input image to the center of the working area of the node, no resizing occurs */
+ /** \brief Center the input image to the center of the working area of the node, no resizing
+ occurs */
COM_SC_CENTER = NS_CR_CENTER,
- /** \brief The bottom left of the input image is the bottom left of the working area of the node, no resizing occurs */
+ /** \brief The bottom left of the input image is the bottom left of the working area of the node,
+ no resizing occurs */
COM_SC_NO_RESIZE = NS_CR_NONE,
/** \brief Fit the width of the input image to the width of the working area of the node */
COM_SC_FIT_WIDTH = NS_CR_FIT_WIDTH,
/** \brief Fit the height of the input image to the height of the working area of the node */
COM_SC_FIT_HEIGHT = NS_CR_FIT_HEIGHT,
- /** \brief Fit the width or the height of the input image to the width or height of the working area of the node, image will be larger than the working area */
+ /** \brief Fit the width or the height of the input image to the width or height of the working
+ area of the node, image will be larger than the working area */
COM_SC_FIT = NS_CR_FIT,
- /** \brief Fit the width and the height of the input image to the width and height of the working area of the node, image will be equally larger than the working area */
+ /** \brief Fit the width and the height of the input image to the width and height of the working
+ area of the node, image will be equally larger than the working area */
COM_SC_STRETCH = NS_CR_STRETCH,
} InputResizeMode;
@@ -158,9 +162,11 @@ class NodeOperation : public SocketReader {
unsigned int preferredResolution[2]);
/**
- * \brief isOutputOperation determines whether this operation is an output of the ExecutionSystem during rendering or editing.
+ * \brief isOutputOperation determines whether this operation is an output of the ExecutionSystem
+ * during rendering or editing.
*
- * Default behavior if not overridden, this operation will not be evaluated as being an output of the ExecutionSystem.
+ * Default behavior if not overridden, this operation will not be evaluated as being an output of
+ * the ExecutionSystem.
*
* \see ExecutionSystem
* \group check
@@ -218,7 +224,8 @@ class NodeOperation : public SocketReader {
}
/**
- * \brief custom handle to add new tasks to the OpenCL command queue in order to execute a chunk on an GPUDevice
+ * \brief custom handle to add new tasks to the OpenCL command queue
+ * in order to execute a chunk on an GPUDevice.
* \ingroup execution
* \param context: the OpenCL context
* \param program: the OpenCL program containing all compositor kernels
@@ -226,8 +233,10 @@ class NodeOperation : public SocketReader {
* \param outputMemoryBuffer: the allocated memory buffer in main CPU memory
* \param clOutputBuffer: the allocated memory buffer in OpenCLDevice memory
* \param inputMemoryBuffers: all input MemoryBuffer's needed
- * \param clMemToCleanUp: all created cl_mem references must be added to this list. Framework will clean this after execution
- * \param clKernelsToCleanUp: all created cl_kernel references must be added to this list. Framework will clean this after execution
+ * \param clMemToCleanUp: all created cl_mem references must be added to this list.
+ * Framework will clean this after execution
+ * \param clKernelsToCleanUp: all created cl_kernel references must be added to this list.
+ * Framework will clean this after execution
*/
virtual void executeOpenCL(OpenCLDevice * /*device*/,
MemoryBuffer * /*outputMemoryBuffer*/,
@@ -297,7 +306,8 @@ class NodeOperation : public SocketReader {
/**
* \brief is this operation the active viewer output
- * user can select an ViewerNode to be active (the result of this node will be drawn on the backdrop)
+ * user can select an ViewerNode to be active
+ * (the result of this node will be drawn on the backdrop).
* \return [true:false]
* \see BaseViewerOperation
*/
@@ -365,8 +375,9 @@ class NodeOperation : public SocketReader {
inline void updateDraw()
{
- if (this->m_btree->update_draw)
+ if (this->m_btree->update_draw) {
this->m_btree->update_draw(this->m_btree->udh);
+ }
}
protected:
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
index 0f331a25ed9..2b17fc0e5f7 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
@@ -70,8 +70,9 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
* so multiple operations can use the same node input.
*/
OpInputInverseMap inverse_input_map;
- for (InputSocketMap::const_iterator it = m_input_map.begin(); it != m_input_map.end(); ++it)
+ for (InputSocketMap::const_iterator it = m_input_map.begin(); it != m_input_map.end(); ++it) {
inverse_input_map[it->second].push_back(it->first);
+ }
for (NodeGraph::Links::const_iterator it = m_graph.links().begin(); it != m_graph.links().end();
++it) {
@@ -83,7 +84,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
const OpInputs &op_to_list = find_operation_inputs(inverse_input_map, to);
if (!op_from || op_to_list.empty()) {
/* XXX allow this? error/debug message? */
- //BLI_assert(false);
+ // BLI_assert(false);
/* XXX note: this can happen with certain nodes (e.g. OutputFile)
* which only generate operations in certain circumstances (rendering)
* just let this pass silently for now ...
@@ -153,8 +154,9 @@ void NodeOperationBuilder::mapOutputSocket(NodeOutput *node_socket,
void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput *to)
{
- if (to->isConnected())
+ if (to->isConnected()) {
return;
+ }
m_links.push_back(Link(from, to));
@@ -202,14 +204,17 @@ PreviewOperation *NodeOperationBuilder::make_preview_operation() const
{
BLI_assert(m_current_node);
- if (!(m_current_node->getbNode()->flag & NODE_PREVIEW))
+ if (!(m_current_node->getbNode()->flag & NODE_PREVIEW)) {
return NULL;
+ }
/* previews only in the active group */
- if (!m_current_node->isInActiveGroup())
+ if (!m_current_node->isInActiveGroup()) {
return NULL;
+ }
/* do not calculate previews of hidden nodes */
- if (m_current_node->getbNode()->flag & NODE_HIDDEN)
+ if (m_current_node->getbNode()->flag & NODE_HIDDEN) {
return NULL;
+ }
bNodeInstanceHash *previews = m_context->getPreviewHash();
if (previews) {
@@ -275,11 +280,13 @@ void NodeOperationBuilder::add_datatype_conversions()
/* proxy operations can skip data type conversion */
NodeOperation *from_op = &link.from()->getOperation();
NodeOperation *to_op = &link.to()->getOperation();
- if (!(from_op->useDatatypeConversion() || to_op->useDatatypeConversion()))
+ if (!(from_op->useDatatypeConversion() || to_op->useDatatypeConversion())) {
continue;
+ }
- if (link.from()->getDataType() != link.to()->getDataType())
+ if (link.from()->getDataType() != link.to()->getDataType()) {
convert_links.push_back(link);
+ }
}
for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
const Link &link = *it;
@@ -305,8 +312,9 @@ void NodeOperationBuilder::add_operation_input_constants()
NodeOperation *op = *it;
for (int k = 0; k < op->getNumberOfInputSockets(); ++k) {
NodeOperationInput *input = op->getInputSocket(k);
- if (!input->isConnected())
+ if (!input->isConnected()) {
pending_inputs.push_back(input);
+ }
}
}
for (Inputs::const_iterator it = pending_inputs.begin(); it != pending_inputs.end(); ++it) {
@@ -321,10 +329,12 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
switch (input->getDataType()) {
case COM_DT_VALUE: {
float value;
- if (node_input && node_input->getbNodeSocket())
+ if (node_input && node_input->getbNodeSocket()) {
value = node_input->getEditorValueFloat();
- else
+ }
+ else {
value = 0.0f;
+ }
SetValueOperation *op = new SetValueOperation();
op->setValue(value);
@@ -334,10 +344,12 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
}
case COM_DT_COLOR: {
float value[4];
- if (node_input && node_input->getbNodeSocket())
+ if (node_input && node_input->getbNodeSocket()) {
node_input->getEditorValueColor(value);
- else
+ }
+ else {
zero_v4(value);
+ }
SetColorOperation *op = new SetColorOperation();
op->setChannels(value);
@@ -347,10 +359,12 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
}
case COM_DT_VECTOR: {
float value[3];
- if (node_input && node_input->getbNodeSocket())
+ if (node_input && node_input->getbNodeSocket()) {
node_input->getEditorValueVector(value);
- else
+ }
+ else {
zero_v3(value);
+ }
SetVectorOperation *op = new SetVectorOperation();
op->setVector(value);
@@ -387,8 +401,9 @@ void NodeOperationBuilder::resolve_proxies()
/* we may not have a final proxy input link,
* in that case it just gets dropped
*/
- if (from)
+ if (from) {
addLink(from, to);
+ }
}
}
@@ -426,8 +441,9 @@ void NodeOperationBuilder::determineResolutions()
if (link.to()->getResizeMode() != COM_SC_NO_RESIZE) {
NodeOperation &from_op = link.from()->getOperation();
NodeOperation &to_op = link.to()->getOperation();
- if (from_op.getWidth() != to_op.getWidth() || from_op.getHeight() != to_op.getHeight())
+ if (from_op.getWidth() != to_op.getWidth() || from_op.getHeight() != to_op.getHeight()) {
convert_links.push_back(link);
+ }
}
}
for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
@@ -443,8 +459,9 @@ NodeOperationBuilder::OpInputs NodeOperationBuilder::cache_output_links(
OpInputs inputs;
for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
const Link &link = *it;
- if (link.from() == output)
+ if (link.from() == output) {
inputs.push_back(link.to());
+ }
}
return inputs;
}
@@ -456,8 +473,9 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation
const Link &link = *it;
if (link.from() == output) {
NodeOperation &op = link.to()->getOperation();
- if (op.isWriteBufferOperation())
+ if (op.isWriteBufferOperation()) {
return (WriteBufferOperation *)(&op);
+ }
}
}
return NULL;
@@ -466,8 +484,9 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation
void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/,
NodeOperationInput *input)
{
- if (!input->isConnected())
+ if (!input->isConnected()) {
return;
+ }
NodeOperationOutput *output = input->getLink();
if (output->getOperation().isReadBufferOperation()) {
@@ -505,8 +524,9 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
{
/* cache connected sockets, so we can safely remove links first before replacing them */
OpInputs targets = cache_output_links(output);
- if (targets.empty())
+ if (targets.empty()) {
return;
+ }
WriteBufferOperation *writeOperation = NULL;
for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
@@ -537,8 +557,9 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
/* add readbuffer op for every former connected input */
for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
NodeOperationInput *target = *it;
- if (&target->getOperation() == writeOperation)
+ if (&target->getOperation() == writeOperation) {
continue; /* skip existing write op links */
+ }
ReadBufferOperation *readoperation = new ReadBufferOperation(
operation->getOutputSocket()->getDataType());
@@ -557,20 +578,24 @@ void NodeOperationBuilder::add_complex_operation_buffers()
* will invalidate iterators over the main m_operations
*/
Operations complex_ops;
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
- if ((*it)->isComplex())
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ if ((*it)->isComplex()) {
complex_ops.push_back(*it);
+ }
+ }
for (Operations::const_iterator it = complex_ops.begin(); it != complex_ops.end(); ++it) {
NodeOperation *op = *it;
DebugInfo::operation_read_write_buffer(op);
- for (int index = 0; index < op->getNumberOfInputSockets(); index++)
+ for (int index = 0; index < op->getNumberOfInputSockets(); index++) {
add_input_buffers(op, op->getInputSocket(index));
+ }
- for (int index = 0; index < op->getNumberOfOutputSockets(); index++)
+ for (int index = 0; index < op->getNumberOfOutputSockets(); index++) {
add_output_buffers(op, op->getOutputSocket(index));
+ }
}
}
@@ -578,14 +603,16 @@ typedef std::set<NodeOperation *> Tags;
static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *op)
{
- if (reachable.find(op) != reachable.end())
+ if (reachable.find(op) != reachable.end()) {
return;
+ }
reachable.insert(op);
for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
NodeOperationInput *input = op->getInputSocket(i);
- if (input->isConnected())
+ if (input->isConnected()) {
find_reachable_operations_recursive(reachable, &input->getLink()->getOperation());
+ }
}
/* associated write-buffer operations are executed as well */
@@ -603,8 +630,9 @@ void NodeOperationBuilder::prune_operations()
NodeOperation *op = *it;
/* output operations are primary executed operations */
- if (op->isOutputOperation(m_context->isRendering()))
+ if (op->isOutputOperation(m_context->isRendering())) {
find_reachable_operations_recursive(reachable, op);
+ }
}
/* delete unreachable operations */
@@ -612,10 +640,12 @@ void NodeOperationBuilder::prune_operations()
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
NodeOperation *op = *it;
- if (reachable.find(op) != reachable.end())
+ if (reachable.find(op) != reachable.end()) {
reachable_ops.push_back(op);
- else
+ }
+ else {
delete op;
+ }
}
/* finally replace the operations list with the pruned list */
m_operations = reachable_ops;
@@ -626,14 +656,16 @@ static void sort_operations_recursive(NodeOperationBuilder::Operations &sorted,
Tags &visited,
NodeOperation *op)
{
- if (visited.find(op) != visited.end())
+ if (visited.find(op) != visited.end()) {
return;
+ }
visited.insert(op);
for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
NodeOperationInput *input = op->getInputSocket(i);
- if (input->isConnected())
+ if (input->isConnected()) {
sort_operations_recursive(sorted, visited, &input->getLink()->getOperation());
+ }
}
sorted.push_back(op);
@@ -645,26 +677,30 @@ void NodeOperationBuilder::sort_operations()
sorted.reserve(m_operations.size());
Tags visited;
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
sort_operations_recursive(sorted, visited, *it);
+ }
m_operations = sorted;
}
static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group)
{
- if (visited.find(op) != visited.end())
+ if (visited.find(op) != visited.end()) {
return;
+ }
visited.insert(op);
- if (!group->addOperation(op))
+ if (!group->addOperation(op)) {
return;
+ }
/* add all eligible input ops to the group */
for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
NodeOperationInput *input = op->getInputSocket(i);
- if (input->isConnected())
+ if (input->isConnected()) {
add_group_operations_recursive(visited, &input->getLink()->getOperation(), group);
+ }
}
}
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
index 12e072b9b12..0aa054b8c77 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
@@ -133,8 +133,9 @@ cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
- if (error == CL_SUCCESS)
+ if (error == CL_SUCCESS) {
cleanup->push_back(clBuffer);
+ }
error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer);
if (error != CL_SUCCESS) {
@@ -190,8 +191,10 @@ void OpenCLDevice::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel ker
void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer)
{
cl_int error;
- const size_t size[] = {(size_t)outputMemoryBuffer->getWidth(),
- (size_t)outputMemoryBuffer->getHeight()};
+ const size_t size[] = {
+ (size_t)outputMemoryBuffer->getWidth(),
+ (size_t)outputMemoryBuffer->getHeight(),
+ };
error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL);
if (error != CL_SUCCESS) {
@@ -261,8 +264,9 @@ cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname,
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
else {
- if (clKernelsToCleanUp)
+ if (clKernelsToCleanUp) {
clKernelsToCleanUp->push_back(kernel);
+ }
}
return kernel;
}
diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
index e6b018eeb94..029be6d44b1 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
@@ -44,8 +44,9 @@ void SingleThreadedOperation::deinitExecution()
}
void *SingleThreadedOperation::initializeTileData(rcti *rect)
{
- if (this->m_cachedInstance)
+ if (this->m_cachedInstance) {
return this->m_cachedInstance;
+ }
lockMutex();
if (this->m_cachedInstance == NULL) {
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index e03a0aa6269..48af823f8f5 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -58,7 +58,8 @@ static ThreadQueue *g_gpuqueue;
# ifdef COM_OPENCL_ENABLED
static cl_context g_context;
static cl_program g_program;
-/// \brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is created
+/// \brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is
+/// created
static vector<OpenCLDevice *> g_gpudevices;
/// \brief list of all thread for every GPUDevice in cpudevices a thread exists
static ListBase g_gputhreads;
@@ -239,8 +240,9 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
g_program = NULL;
if (clewInit() !=
- CLEW_SUCCESS) /* this will check for errors and skip if already initialized */
+ CLEW_SUCCESS) { /* this will check for errors and skip if already initialized */
return;
+ }
if (clCreateContextFromType) {
cl_uint numberOfPlatforms = 0;
@@ -251,8 +253,9 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
else if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
- if (G.f & G_DEBUG)
+ if (G.f & G_DEBUG) {
printf("%u number of platforms\n", numberOfPlatforms);
+ }
cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN(
sizeof(cl_platform_id) * numberOfPlatforms, __func__);
error = clGetPlatformIDs(numberOfPlatforms, platforms, 0);
@@ -261,8 +264,9 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
cl_platform_id platform = platforms[indexPlatform];
cl_uint numberOfDevices = 0;
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices);
- if (numberOfDevices <= 0)
+ if (numberOfDevices <= 0) {
continue;
+ }
cl_device_id *cldevices = (cl_device_id *)MEM_mallocN(
sizeof(cl_device_id) * numberOfDevices, __func__);
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h
index 2b523272123..390fde82b61 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.h
+++ b/source/blender/compositor/intern/COM_WorkScheduler.h
@@ -67,9 +67,10 @@ class WorkScheduler {
*
* during initialization the mutexes are initialized.
* there are two mutexes (for every device type one)
- * After mutex initialization the system is queried in order to count the number of CPUDevices and GPUDevices to be created.
- * For every hardware thread a CPUDevice and for every OpenCL GPU device a OpenCLDevice is created.
- * these devices are stored in a separate list (cpudevices & gpudevices)
+ * After mutex initialization the system is queried in order to count the number of CPUDevices
+ * and GPUDevices to be created. For every hardware thread a CPUDevice and for every OpenCL GPU
+ * device a OpenCLDevice is created. these devices are stored in a separate list (cpudevices &
+ * gpudevices)
*
* This function can be called multiple times to lazily initialize OpenCL.
*/
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp
index 30072d6a5a7..32ac1fccec9 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp
@@ -49,10 +49,12 @@ void CompositorNode::convertToOperations(NodeConverter &converter,
converter.addOperation(compositorOperation);
converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0));
/* only use alpha link if "use alpha" is enabled */
- if (ignore_alpha)
+ if (ignore_alpha) {
converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f);
- else
+ }
+ else {
converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1));
+ }
converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2));
converter.addNodeInputPreview(imageSocket);
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index 5e83372a70a..8d64b629e40 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -109,10 +109,12 @@ void DefocusNode::convertToOperations(NodeConverter &converter,
#endif
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
- if (data->preview)
+ if (data->preview) {
operation->setQuality(COM_QUALITY_LOW);
- else
+ }
+ else {
operation->setQuality(context.getQuality());
+ }
operation->setMaxBlur(data->maxblur);
operation->setThreshold(data->bthresh);
converter.addOperation(operation);
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
index cde94b23ed8..50fbe983c91 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
@@ -92,7 +92,8 @@ void DilateErodeNode::convertToOperations(NodeConverter &converter,
converter.addOperation(operationx);
converter.mapInputSocket(getInputSocket(0), operationx->getInputSocket(0));
- // converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); // no size input yet
+ // converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); // no size input
+ // yet
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
operationy->setData(&m_alpha_blur);
@@ -101,7 +102,8 @@ void DilateErodeNode::convertToOperations(NodeConverter &converter,
converter.addOperation(operationy);
converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
- // converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); // no size input yet
+ // converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); // no size input
+ // yet
converter.mapOutputSocket(getOutputSocket(0), operationy->getOutputSocket());
converter.addPreview(operationy->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h
index 0093d78ca5b..d5b2863a4bb 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.h
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h
@@ -26,8 +26,9 @@
* \ingroup Node
*/
class DilateErodeNode : public Node {
- NodeBlurData
- m_alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesn't have this */
+ /** only used for blurring alpha, since the dilate/erode node doesn't have this. */
+ NodeBlurData m_alpha_blur;
+
public:
DilateErodeNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.cpp b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
index 6ff273b14b7..0c0c3aad646 100644
--- a/source/blender/compositor/nodes/COM_DisplaceNode.cpp
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
@@ -30,10 +30,12 @@ void DisplaceNode::convertToOperations(NodeConverter &converter,
const CompositorContext &context) const
{
NodeOperation *operation;
- if (context.getQuality() == COM_QUALITY_LOW)
+ if (context.getQuality() == COM_QUALITY_LOW) {
operation = new DisplaceSimpleOperation();
- else
+ }
+ else {
operation = new DisplaceOperation();
+ }
converter.addOperation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
diff --git a/source/blender/compositor/nodes/COM_FlipNode.cpp b/source/blender/compositor/nodes/COM_FlipNode.cpp
index 59b881bfcf7..4dfff9c8e49 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.cpp
+++ b/source/blender/compositor/nodes/COM_FlipNode.cpp
@@ -33,7 +33,8 @@ void FlipNode::convertToOperations(NodeConverter &converter,
NodeOutput *outputSocket = this->getOutputSocket(0);
FlipOperation *operation = new FlipOperation();
switch (this->getbNode()->custom1) {
- case 0: /// \TODO: I didn't find any constants in the old implementation, should I introduce them.
+ case 0: /// \TODO: I didn't find any constants in the old implementation, should I introduce
+ /// them.
operation->setFlipX(true);
operation->setFlipY(false);
break;
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
index cf25e9f26ae..31de6c6867e 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -118,8 +118,9 @@ void ImageNode::convertToOperations(NodeConverter &converter,
* check if the view name exists in the image */
view = BLI_findstringindex(
&image->rr->views, context.getViewName(), offsetof(RenderView, name));
- if (view == -1)
+ if (view == -1) {
view = 0;
+ }
}
else {
view = view_image - 1;
@@ -195,8 +196,9 @@ void ImageNode::convertToOperations(NodeConverter &converter,
}
/* incase we can't load the layer */
- if (operation == NULL)
+ if (operation == NULL) {
converter.setInvalidOutput(getOutputSocket(index));
+ }
}
}
}
@@ -204,8 +206,9 @@ void ImageNode::convertToOperations(NodeConverter &converter,
/* without this, multilayer that fail to load will crash blender [#32490] */
if (is_multilayer_ok == false) {
- for (int i = 0; i < getNumberOfOutputSockets(); ++i)
+ for (int i = 0; i < getNumberOfOutputSockets(); ++i) {
converter.setInvalidOutput(getOutputSocket(i));
+ }
}
}
else {
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp
index 1bb9b9aa057..b2ce7e1988c 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp
@@ -302,8 +302,9 @@ void KeyingNode::convertToOperations(NodeConverter &converter,
}
/* apply blur on matte if needed */
- if (keying_data->blur_post)
+ if (keying_data->blur_post) {
postprocessedMatte = setupPostBlur(converter, postprocessedMatte, keying_data->blur_post);
+ }
/* matte dilate/erode */
if (keying_data->dilate_distance != 0) {
@@ -342,6 +343,7 @@ void KeyingNode::convertToOperations(NodeConverter &converter,
converter.mapOutputSocket(outputImage, postprocessedImage);
converter.mapOutputSocket(outputMatte, postprocessedMatte);
- if (edgesMatte)
+ if (edgesMatte) {
converter.mapOutputSocket(outputEdges, edgesMatte);
+ }
}
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
index a4e638e20e6..34d2fba6433 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
@@ -44,10 +44,12 @@ void LensDistortionNode::convertToOperations(NodeConverter &converter,
operation->setFit(data->fit);
operation->setJitter(data->jit);
- if (!getInputSocket(1)->isLinked())
+ if (!getInputSocket(1)->isLinked()) {
operation->setDistortion(getInputSocket(1)->getEditorValueFloat());
- if (!getInputSocket(2)->isLinked())
+ }
+ if (!getInputSocket(2)->isLinked()) {
operation->setDispersion(getInputSocket(2)->getEditorValueFloat());
+ }
converter.addOperation(operation);
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
index 342f0a9f88a..f5ea6b2653a 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
@@ -51,11 +51,13 @@ void MovieClipNode::convertToOperations(NodeConverter &converter,
ImBuf *ibuf = NULL;
if (movieClip) {
- if (cacheFrame)
+ if (cacheFrame) {
ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser);
- else
+ }
+ else {
ibuf = BKE_movieclip_get_ibuf_flag(
movieClip, movieClipUser, movieClip->flag, MOVIECLIP_CACHE_SKIP);
+ }
}
// always connect the output image
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
index 26f21713a77..a361c57a2c2 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -46,8 +46,9 @@ void RenderLayersNode::testSocketLink(NodeConverter &converter,
converter.mapOutputSocket(output, operation->getOutputSocket());
converter.addOperation(operation);
- if (is_preview) /* only for image socket */
+ if (is_preview) { /* only for image socket */
converter.addPreview(operation->getOutputSocket());
+ }
}
void RenderLayersNode::testRenderLink(NodeConverter &converter,
diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
index 499b2fa96f9..712ba1e1f2d 100644
--- a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
@@ -45,10 +45,12 @@ void SeparateColorNode::convertToOperations(NodeConverter &converter,
operation->setChannel(0);
converter.addOperation(operation);
- if (color_conv)
+ if (color_conv) {
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
- else
+ }
+ else {
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
+ }
converter.mapOutputSocket(outputRSocket, operation->getOutputSocket(0));
}
@@ -57,10 +59,12 @@ void SeparateColorNode::convertToOperations(NodeConverter &converter,
operation->setChannel(1);
converter.addOperation(operation);
- if (color_conv)
+ if (color_conv) {
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
- else
+ }
+ else {
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
+ }
converter.mapOutputSocket(outputGSocket, operation->getOutputSocket(0));
}
@@ -69,10 +73,12 @@ void SeparateColorNode::convertToOperations(NodeConverter &converter,
operation->setChannel(2);
converter.addOperation(operation);
- if (color_conv)
+ if (color_conv) {
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
- else
+ }
+ else {
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
+ }
converter.mapOutputSocket(outputBSocket, operation->getOutputSocket(0));
}
@@ -81,10 +87,12 @@ void SeparateColorNode::convertToOperations(NodeConverter &converter,
operation->setChannel(3);
converter.addOperation(operation);
- if (color_conv)
+ if (color_conv) {
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
- else
+ }
+ else {
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
+ }
converter.mapOutputSocket(outputASocket, operation->getOutputSocket(0));
}
}
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
index d924d2ce9f8..5476a21d2a5 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
@@ -34,17 +34,21 @@ SocketProxyNode::SocketProxyNode(bNode *editorNode,
DataType dt;
dt = COM_DT_VALUE;
- if (editorInput->type == SOCK_RGBA)
+ if (editorInput->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
- if (editorInput->type == SOCK_VECTOR)
+ }
+ if (editorInput->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
+ }
this->addInputSocket(dt, editorInput);
dt = COM_DT_VALUE;
- if (editorOutput->type == SOCK_RGBA)
+ if (editorOutput->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
- if (editorOutput->type == SOCK_VECTOR)
+ }
+ if (editorOutput->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
+ }
this->addOutputSocket(dt, editorOutput);
}
@@ -63,17 +67,21 @@ SocketBufferNode::SocketBufferNode(bNode *editorNode,
DataType dt;
dt = COM_DT_VALUE;
- if (editorInput->type == SOCK_RGBA)
+ if (editorInput->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
- if (editorInput->type == SOCK_VECTOR)
+ }
+ if (editorInput->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
+ }
this->addInputSocket(dt, editorInput);
dt = COM_DT_VALUE;
- if (editorOutput->type == SOCK_RGBA)
+ if (editorOutput->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
- if (editorOutput->type == SOCK_VECTOR)
+ }
+ if (editorOutput->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
+ }
this->addOutputSocket(dt, editorOutput);
}
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
index b44f82f71d0..f73e3d08a74 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
@@ -69,6 +69,7 @@ void SplitViewerNode::convertToOperations(NodeConverter &converter,
converter.addPreview(splitViewerOperation->getOutputSocket());
- if (do_output)
+ if (do_output) {
converter.registerViewer(viewerOperation);
+ }
}
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp
index 342f6bc159c..947774e98ae 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.cpp
+++ b/source/blender/compositor/nodes/COM_SwitchNode.cpp
@@ -29,10 +29,12 @@ void SwitchNode::convertToOperations(NodeConverter &converter,
bool condition = this->getbNode()->custom1;
NodeOperationOutput *result;
- if (!condition)
+ if (!condition) {
result = converter.addInputProxy(getInputSocket(0), false);
- else
+ }
+ else {
result = converter.addInputProxy(getInputSocket(1), false);
+ }
converter.mapOutputSocket(getOutputSocket(0), result);
}
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp
index 08f3be27c55..6170fafcb2c 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp
@@ -68,14 +68,17 @@ void ViewerNode::convertToOperations(NodeConverter &converter,
converter.addOperation(viewerOperation);
converter.mapInputSocket(imageSocket, viewerOperation->getInputSocket(0));
/* only use alpha link if "use alpha" is enabled */
- if (ignore_alpha)
+ if (ignore_alpha) {
converter.addInputValue(viewerOperation->getInputSocket(1), 1.0f);
- else
+ }
+ else {
converter.mapInputSocket(alphaSocket, viewerOperation->getInputSocket(1));
+ }
converter.mapInputSocket(depthSocket, viewerOperation->getInputSocket(2));
converter.addNodeInputPreview(imageSocket);
- if (do_output)
+ if (do_output) {
converter.registerViewer(viewerOperation);
+ }
}
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
index 94514c64e08..de7c43a8751 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
@@ -56,39 +56,55 @@ static int extrapolate9(float *E0,
*DST = *SRC; \
} while (0)
if ((!PEQ(B, H)) && (!PEQ(D, F))) {
- if (PEQ(D, B))
+ if (PEQ(D, B)) {
PCPY(E0, D);
- else
+ }
+ else {
PCPY(E0, E);
- if ((PEQ(D, B) && !PEQ(E, C)) || (PEQ(B, F) && !PEQ(E, A)))
+ }
+ if ((PEQ(D, B) && !PEQ(E, C)) || (PEQ(B, F) && !PEQ(E, A))) {
PCPY(E1, B);
- else
+ }
+ else {
PCPY(E1, E);
- if (PEQ(B, F))
+ }
+ if (PEQ(B, F)) {
PCPY(E2, F);
- else
+ }
+ else {
PCPY(E2, E);
- if ((PEQ(D, B) && !PEQ(E, G)) || (PEQ(D, H) && !PEQ(E, A)))
+ }
+ if ((PEQ(D, B) && !PEQ(E, G)) || (PEQ(D, H) && !PEQ(E, A))) {
PCPY(E3, D);
- else
+ }
+ else {
PCPY(E3, E);
+ }
PCPY(E4, E);
- if ((PEQ(B, F) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, C)))
+ if ((PEQ(B, F) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, C))) {
PCPY(E5, F);
- else
+ }
+ else {
PCPY(E5, E);
- if (PEQ(D, H))
+ }
+ if (PEQ(D, H)) {
PCPY(E6, D);
- else
+ }
+ else {
PCPY(E6, E);
- if ((PEQ(D, H) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, G)))
+ }
+ if ((PEQ(D, H) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, G))) {
PCPY(E7, H);
- else
+ }
+ else {
PCPY(E7, E);
- if (PEQ(H, F))
+ }
+ if (PEQ(H, F)) {
PCPY(E8, F);
- else
+ }
+ else {
PCPY(E8, E);
+ }
return 1;
}
else {
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
index 5628c575b70..44cb4056c99 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
@@ -44,7 +44,8 @@ void BilateralBlurOperation::initExecution()
void BilateralBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- // read the determinator color at x, y, this will be used as the reference color for the determinator
+ // read the determinator color at x, y, this will be used as the reference color for the
+ // determinator
float determinatorReferenceColor[4];
float determinator[4];
float tempColor[4];
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index aca98085a3e..f3b090287ad 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -81,8 +81,9 @@ float *BlurBaseOperation::make_gausstab(float rad, int size)
}
sum = 1.0f / sum;
- for (i = 0; i < n; i++)
+ for (i = 0; i < n; i++) {
gausstab[i] *= sum;
+ }
return gausstab;
}
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h
index 58a1e2f85d8..2bb3e5bc1ab 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.h
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.h
@@ -21,8 +21,8 @@
#include "COM_NodeOperation.h"
/**
- * \brief The BokehImageOperation class is an operation that creates an image useful to mimic the internals
- *of a camera.
+ * \brief The BokehImageOperation class is an operation that creates an image useful to mimic the
+ *internals of a camera.
*
* features:
* - number of flaps
@@ -31,20 +31,21 @@
* - simulate catadioptric
* - simulate lensshift
*
- * Per pixel the algorithm determines the edge of the bokeh on the same line as the center of the image and the pixel
- * is evaluating.
+ * Per pixel the algorithm determines the edge of the bokeh on the same line as the center of the
+ *image and the pixel is evaluating.
*
- * The edge is detected by finding the closest point on the direct line between the two nearest flap-corners.
- * this edge is interpolated with a full circle.
- * Result of this edge detection is stored as the distance between the center of the image and the edge.
+ * The edge is detected by finding the closest point on the direct line between the two nearest
+ *flap-corners. this edge is interpolated with a full circle. Result of this edge detection is
+ *stored as the distance between the center of the image and the edge.
*
- * catadioptric lenses are simulated to interpolate between the center of the image and the distance of the edge.
- * We now have three distances:
+ * catadioptric lenses are simulated to interpolate between the center of the image and the
+ *distance of the edge. We now have three distances:
* - distance between the center of the image and the pixel to be evaluated
* - distance between the center of the image and the outer-edge
* - distance between the center of the image and the inner-edge
*
- * With a simple compare it can be detected if the evaluated pixel is between the outer and inner edge.
+ * With a simple compare it can be detected if the evaluated pixel is between the outer and inner
+ *edge.
*/
class BokehImageOperation : public NodeOperation {
private:
@@ -95,7 +96,8 @@ class BokehImageOperation : public NodeOperation {
/**
* \brief Determine if a coordinate is inside the bokeh image
*
- * \param distance: the distance that will be used. This parameter is modified a bit to mimic lens shifts
+ * \param distance: the distance that will be used.
+ * This parameter is modified a bit to mimic lens shifts.
* \param x: the x coordinate of the pixel to evaluate
* \param y: the y coordinate of the pixel to evaluate
* \return float range 0..1 0 is completely outside
@@ -121,9 +123,8 @@ class BokehImageOperation : public NodeOperation {
void deinitExecution();
/**
- * \brief determine the resolution of this operation. currently fixed at [COM_BLUR_BOKEH_PIXELS, COM_BLUR_BOKEH_PIXELS]
- * \param resolution:
- * \param preferredResolution:
+ * \brief determine the resolution of this operation. currently fixed at [COM_BLUR_BOKEH_PIXELS,
+ * COM_BLUR_BOKEH_PIXELS] \param resolution: \param preferredResolution:
*/
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
index 3f5c0896221..7fb9d839d2d 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
@@ -22,7 +22,8 @@
#include "DNA_node_types.h"
#include "COM_CalculateMeanOperation.h"
/**
- * \brief base class of CalculateStandardDeviation, implementing the simple CalculateStandardDeviation
+ * \brief base class of CalculateStandardDeviation,
+ * implementing the simple CalculateStandardDeviation.
* \ingroup operation
*/
class CalculateStandardDeviationOperation : public CalculateMeanOperation {
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
index a2554cd60de..ddbc400777f 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
@@ -58,10 +58,12 @@ void ChangeHSVOperation::executePixelSampled(float output[4],
this->m_valueOperation->readSampled(value, x, y, sampler);
output[0] = inputColor1[0] + (hue[0] - 0.5f);
- if (output[0] > 1.0f)
+ if (output[0] > 1.0f) {
output[0] -= 1.0f;
- else if (output[0] < 0.0f)
+ }
+ else if (output[0] < 0.0f) {
output[0] += 1.0f;
+ }
output[1] = inputColor1[1] * saturation[0];
output[2] = inputColor1[2] * value[0];
output[3] = inputColor1[3];
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
index f957186a652..a515b9a6a67 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
@@ -24,8 +24,9 @@ inline float colorbalance_cdl(float in, float offset, float power, float slope)
float x = in * slope + offset;
/* prevent NaN */
- if (x < 0.0f)
+ if (x < 0.0f) {
x = 0.0f;
+ }
return powf(x, power);
}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
index 48807e9218d..68b5af3089a 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -24,12 +24,14 @@ inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float g
/* 1:1 match with the sequencer with linear/srgb conversions, the conversion isnt pretty
* but best keep it this way, sice testing for durian shows a similar calculation
* without lin/srgb conversions gives bad results (over-saturated shadows) with colors
- * slightly below 1.0. some correction can be done but it ends up looking bad for shadows or lighter tones - campbell */
+ * slightly below 1.0. some correction can be done but it ends up looking bad for shadows or
+ * lighter tones - campbell */
float x = (((linearrgb_to_srgb(in) - 1.0f) * lift_lgg) + 1.0f) * gain;
/* prevent NaN */
- if (x < 0.0f)
+ if (x < 0.0f) {
x = 0.0f;
+ }
return powf(srgb_to_linearrgb(x), gamma_inv);
}
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 018b1662e0f..40315d217ce 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -54,8 +54,9 @@ CompositorOperation::CompositorOperation() : NodeOperation()
void CompositorOperation::initExecution()
{
- if (!this->m_active)
+ if (!this->m_active) {
return;
+ }
// When initializing the tree during initial load the width and height can be zero.
this->m_imageInput = getInputSocketReader(0);
@@ -73,8 +74,9 @@ void CompositorOperation::initExecution()
void CompositorOperation::deinitExecution()
{
- if (!this->m_active)
+ if (!this->m_active) {
return;
+ }
if (!isBreaked()) {
Render *re = RE_GetSceneRender(this->m_scene);
@@ -136,8 +138,9 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
float *buffer = this->m_outputBuffer;
float *zbuffer = this->m_depthBuffer;
- if (!buffer)
+ if (!buffer) {
return;
+ }
int x1 = rect->xmin;
int y1 = rect->ymin;
int x2 = rect->xmax;
@@ -181,7 +184,7 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
* Full frame
*/
- int full_width = rd->xsch * rd->size / 100;
+ int full_width = rd->xsch * rd->size / 100;
int full_height = rd->ysch * rd->size / 100;
dx = rd->border.xmin * full_width - (full_width - this->getWidth()) / 2.0f;
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index 7b63d3ef3cb..704f7cfad39 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -56,8 +56,9 @@ void ConvertDepthToRadiusOperation::initExecution()
this->m_inputOperation = this->getInputSocketReader(0);
float focalDistance = determineFocalDistance();
- if (focalDistance == 0.0f)
+ if (focalDistance == 0.0f) {
focalDistance = 1e10f; /* if the dof is 0.0 then set it to be far away */
+ }
this->m_inverseFocalDistance = 1.0f / focalDistance;
this->m_aspect = (this->getWidth() > this->getHeight()) ?
(this->getHeight() / (float)this->getWidth()) :
@@ -94,9 +95,11 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
#endif
radius = 0.5f * fabsf(this->m_aperture *
(this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.0f));
- // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem
- if (radius < 0.0f)
+ // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates
+ // the problem
+ if (radius < 0.0f) {
radius = 0.0f;
+ }
if (radius > this->m_maxRadius) {
radius = this->m_maxRadius;
}
diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp
index fbbe8706e11..625490dd3ab 100644
--- a/source/blender/compositor/operations/COM_CropOperation.cpp
+++ b/source/blender/compositor/operations/COM_CropOperation.cpp
@@ -41,14 +41,18 @@ void CropBaseOperation::updateArea()
local_settings.y1 = height * local_settings.fac_y1;
local_settings.y2 = height * local_settings.fac_y2;
}
- if (width <= local_settings.x1 + 1)
+ if (width <= local_settings.x1 + 1) {
local_settings.x1 = width - 1;
- if (height <= local_settings.y1 + 1)
+ }
+ if (height <= local_settings.y1 + 1) {
local_settings.y1 = height - 1;
- if (width <= local_settings.x2 + 1)
+ }
+ if (width <= local_settings.x2 + 1) {
local_settings.x2 = width - 1;
- if (height <= local_settings.y2 + 1)
+ }
+ if (height <= local_settings.y2 + 1) {
local_settings.y2 = height - 1;
+ }
this->m_xmax = max(local_settings.x1, local_settings.x2) + 1;
this->m_xmin = min(local_settings.x1, local_settings.x2);
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
index 807450040de..9b8d72da26d 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
@@ -70,7 +70,7 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
CLAMP(y3, 0, getHeight() - 1);
float value[4];
this->m_inputValueOperation->read(value, x2, y2, NULL);
- //const float mval = 1.0f - value[0];
+ // const float mval = 1.0f - value[0];
this->m_inputOperation->read(color_org, x2, y2, NULL);
@@ -115,7 +115,7 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*da
COLOR_ADD(TOT_DIV_CNR)
mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
- //mul_v4_fl(color_mid, 1.0f / w);
+ // mul_v4_fl(color_mid, 1.0f / w);
if ((w != 0.0f) && ((w / WTOT) > (this->m_threshold_neighbor)) &&
color_diff(color_mid, color_org, this->m_threshold)) {
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index 34f0d2cb760..f872388e3c7 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -950,12 +950,16 @@ static void do_createEdgeLocationBuffer(unsigned int t,
unsigned int rsl; // long used for finding fast 1.0/sqrt
unsigned int gradientFillOffset;
- unsigned int innerAccum =
- 0; // for looping inner edge pixel indexes, represents current position from offset
- unsigned int outerAccum =
- 0; // for looping outer edge pixel indexes, represents current position from offset
- unsigned int gradientAccum =
- 0; // for looping gradient pixel indexes, represents current position from offset
+
+ /* For looping inner edge pixel indexes, represents current position from offset. */
+ unsigned int innerAccum = 0;
+ /* For looping outer edge pixel indexes, represents current position from offset. */
+ unsigned int outerAccum = 0;
+ /* For looping gradient pixel indexes, represents current position from offset. */
+ unsigned int gradientAccum = 0;
+
+ /* */
+ /* clang-format off */
/*
* Here we compute the size of buffer needed to hold (row,col) coordinates
* for each pixel previously determined to be either gradient, inner edge,
@@ -1017,6 +1021,7 @@ static void do_createEdgeLocationBuffer(unsigned int t,
* each iteration of the final gradient calculation than it is to deconstruct
* a memory location into x,y pairs each round.
*/
+ /* clang-format on */
gradientFillOffset = 0; // since there are likely "more" of these, put it first. :)
*innerEdgeOffset = gradientFillOffset + gsz; // set start of inner edge indexes
@@ -1025,7 +1030,7 @@ static void do_createEdgeLocationBuffer(unsigned int t,
gradientAccum = gradientFillOffset; // each accumulator variable starts at its respective
innerAccum = *innerEdgeOffset; // section's offset so when we start filling, each
outerAccum = *outerEdgeOffset; // section fills up it's allocated space in gbuf
- //uses dmin=row, rsl=col
+ // uses dmin=row, rsl=col
for (x = 0, dmin = 0; x < t; x += rw, dmin++) {
for (rsl = 0; rsl < rw; rsl++) {
a = x + rsl;
@@ -1187,7 +1192,7 @@ static void do_fillGradientBuffer(unsigned int rw,
* Pixel Index = Pixel Column + ( Pixel Row * Row Width )
*/
res[gbuf[gradientFillOffset + 1] + (gbuf[gradientFillOffset] * rw)] =
- (idist / (idist + odist)); //set intensity
+ (idist / (idist + odist)); // set intensity
}
}
@@ -1340,8 +1345,9 @@ void DoubleEdgeMaskOperation::initExecution()
void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect)
{
- if (this->m_cachedInstance)
+ if (this->m_cachedInstance) {
return this->m_cachedInstance;
+ }
lockMutex();
if (this->m_cachedInstance == NULL) {
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index e375b2fe45b..2c12091c458 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -89,17 +89,20 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
this->m_sy = this->m_data.sizey * this->m_size / 2.0f;
if ((this->m_sx == this->m_sy) && (this->m_sx > 0.0f)) {
- for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
+ for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c) {
IIR_gauss(copy, this->m_sx, c, 3);
+ }
}
else {
if (this->m_sx > 0.0f) {
- for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
+ for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c) {
IIR_gauss(copy, this->m_sx, c, 1);
+ }
}
if (this->m_sy > 0.0f) {
- for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
+ for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c) {
IIR_gauss(copy, this->m_sy, c, 2);
+ }
}
}
this->m_iirgaus = copy;
@@ -123,27 +126,35 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
const unsigned int num_channels = src->get_num_channels();
// <0.5 not valid, though can have a possibly useful sort of sharpening effect
- if (sigma < 0.5f)
+ if (sigma < 0.5f) {
return;
+ }
- if ((xy < 1) || (xy > 3))
+ if ((xy < 1) || (xy > 3)) {
xy = 3;
+ }
// XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
// so just skipping blur along faulty direction if src's def is below that limit!
- if (src_width < 3)
+ if (src_width < 3) {
xy &= ~1;
- if (src_height < 3)
+ }
+ if (src_height < 3) {
xy &= ~2;
- if (xy < 1)
+ }
+ if (xy < 1) {
return;
+ }
// see "Recursive Gabor Filtering" by Young/VanVliet
- // all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200
- if (sigma >= 3.556f)
+ // all factors here in double.prec.
+ // Required, because for single.prec it seems to blow up if sigma > ~200
+ if (sigma >= 3.556f) {
q = 0.9804f * (sigma - 3.556f) + 2.5091f;
- else // sigma >= 0.5
+ }
+ else { // sigma >= 0.5
q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f;
+ }
q2 = q * q;
sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q);
// no gabor filtering here, so no complex multiplies, just the regular coefs.
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index 88c4ff7d935..318c182fdff 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -98,8 +98,9 @@ void GaussianBokehBlurOperation::updateGauss()
if (sum > 0.0f) {
/* normalize */
float norm = 1.0f / sum;
- for (j = n - 1; j >= 0; j--)
+ for (j = n - 1; j >= 0; j--) {
ddgauss[j] *= norm;
+ }
}
else {
int center = m_rady * ddwidth + m_radx;
@@ -233,19 +234,23 @@ void GaussianBlurReferenceOperation::initExecution()
/* horizontal */
m_filtersizex = (float)this->m_data.sizex;
int imgx = getWidth() / 2;
- if (m_filtersizex > imgx)
+ if (m_filtersizex > imgx) {
m_filtersizex = imgx;
- else if (m_filtersizex < 1)
+ }
+ else if (m_filtersizex < 1) {
m_filtersizex = 1;
+ }
m_radx = (float)m_filtersizex;
/* vertical */
m_filtersizey = (float)this->m_data.sizey;
int imgy = getHeight() / 2;
- if (m_filtersizey > imgy)
+ if (m_filtersizey > imgy) {
m_filtersizey = imgy;
- else if (m_filtersizey < 1)
+ }
+ else if (m_filtersizey < 1) {
m_filtersizey = 1;
+ }
m_rady = (float)m_filtersizey;
updateGauss();
}
@@ -277,14 +282,18 @@ void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y,
float refSize = tempSize[0];
int refradx = (int)(refSize * m_radx);
int refrady = (int)(refSize * m_rady);
- if (refradx > m_filtersizex)
+ if (refradx > m_filtersizex) {
refradx = m_filtersizex;
- else if (refradx < 1)
+ }
+ else if (refradx < 1) {
refradx = 1;
- if (refrady > m_filtersizey)
+ }
+ if (refrady > m_filtersizey) {
refrady = m_filtersizey;
- else if (refrady < 1)
+ }
+ else if (refrady < 1) {
refrady = 1;
+ }
if (refradx == 1 && refrady == 1) {
memorybuffer->readNoCheck(output, x, y);
diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
index e0a2790b318..1f5749d782c 100644
--- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
@@ -30,8 +30,9 @@ static unsigned int nextPow2(unsigned int x, unsigned int *L2)
{
unsigned int pw, x_notpow2 = x & (x - 1);
*L2 = 0;
- while (x >>= 1)
+ while (x >>= 1) {
++(*L2);
+ }
pw = 1 << (*L2);
if (x_notpow2) {
(*L2)++;
@@ -46,8 +47,9 @@ static unsigned int nextPow2(unsigned int x, unsigned int *L2)
// use: r = revbin_upd(r, h) where h = N>>1
static unsigned int revbin_upd(unsigned int r, unsigned int h)
{
- while (!((r ^= h) & h))
+ while (!((r ^= h) & h)) {
h >>= 1;
+ }
return r;
}
//------------------------------------------------------------------------------
@@ -81,7 +83,7 @@ static void FHT(fREAL *data, unsigned int M, unsigned int inverse)
n2 = n >> 1;
if (n > 2) {
fc = dc = cos(a);
- fs = ds = sqrt(1.0 - fc * fc); //sin(a);
+ fs = ds = sqrt(1.0 - fc * fc); // sin(a);
bd = n - 2;
for (bl = 1; bl < n2; bl++) {
fREAL *data_nbd = &data_n[bd];
@@ -115,8 +117,9 @@ static void FHT(fREAL *data, unsigned int M, unsigned int inverse)
if (inverse) {
fREAL sc = (fREAL)1 / (fREAL)len;
- for (k = 0; k < len; ++k)
+ for (k = 0; k < len; ++k) {
data[k] *= sc;
+ }
}
}
//------------------------------------------------------------------------------
@@ -133,25 +136,29 @@ static void FHT2D(
// rows (forward transform skips 0 pad data)
maxy = inverse ? Ny : nzp;
- for (j = 0; j < maxy; ++j)
+ for (j = 0; j < maxy; ++j) {
FHT(&data[Nx * j], Mx, inverse);
+ }
// transpose data
if (Nx == Ny) { // square
- for (j = 0; j < Ny; ++j)
+ for (j = 0; j < Ny; ++j) {
for (i = j + 1; i < Nx; ++i) {
unsigned int op = i + (j << Mx), np = j + (i << My);
SWAP(fREAL, data[op], data[np]);
}
+ }
}
else { // rectangular
unsigned int k, Nym = Ny - 1, stm = 1 << (Mx + My);
for (i = 0; stm > 0; i++) {
#define PRED(k) (((k & Nym) << Mx) + (k >> My))
- for (j = PRED(i); j > i; j = PRED(j))
+ for (j = PRED(i); j > i; j = PRED(j)) {
;
- if (j < i)
+ }
+ if (j < i) {
continue;
+ }
for (k = i, j = PRED(i); j != i; k = j, j = PRED(j), stm--) {
SWAP(fREAL, data[j], data[k]);
}
@@ -164,8 +171,9 @@ static void FHT2D(
SWAP(unsigned int, Mx, My);
// now columns == transposed rows
- for (j = 0; j < Ny; ++j)
+ for (j = 0; j < Ny; ++j) {
FHT(&data[Nx * j], Mx, inverse);
+ }
// finalize
for (j = 0; j <= (Ny >> 1); j++) {
@@ -280,19 +288,24 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
wt[0] = wt[1] = wt[2] = 0.0f;
for (y = 0; y < kernelHeight; y++) {
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
- for (x = 0; x < kernelWidth; x++)
+ for (x = 0; x < kernelWidth; x++) {
add_v3_v3(wt, colp[x]);
+ }
}
- if (wt[0] != 0.0f)
+ if (wt[0] != 0.0f) {
wt[0] = 1.0f / wt[0];
- if (wt[1] != 0.0f)
+ }
+ if (wt[1] != 0.0f) {
wt[1] = 1.0f / wt[1];
- if (wt[2] != 0.0f)
+ }
+ if (wt[2] != 0.0f) {
wt[2] = 1.0f / wt[2];
+ }
for (y = 0; y < kernelHeight; y++) {
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
- for (x = 0; x < kernelWidth; x++)
+ for (x = 0; x < kernelWidth; x++) {
mul_v3_v3(colp[x], wt);
+ }
}
// copy image data, unpacking interleaved RGBA into separate channels
@@ -304,11 +317,13 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
xbsz = (w2 + 1) - kernelWidth;
ybsz = (h2 + 1) - kernelHeight;
nxb = imageWidth / xbsz;
- if (imageWidth % xbsz)
+ if (imageWidth % xbsz) {
nxb++;
+ }
nyb = imageHeight / ybsz;
- if (imageHeight % ybsz)
+ if (imageHeight % ybsz) {
nyb++;
+ }
for (ybl = 0; ybl < nyb; ybl++) {
for (xbl = 0; xbl < nxb; xbl++) {
@@ -322,8 +337,9 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
for (y = 0; y < kernelHeight; y++) {
fp = &data1ch[y * w2];
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
- for (x = 0; x < kernelWidth; x++)
+ for (x = 0; x < kernelWidth; x++) {
fp[x] = colp[x][ch];
+ }
}
}
@@ -331,22 +347,25 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
memset(data2, 0, w2 * h2 * sizeof(fREAL));
for (y = 0; y < ybsz; y++) {
int yy = ybl * ybsz + y;
- if (yy >= imageHeight)
+ if (yy >= imageHeight) {
continue;
+ }
fp = &data2[y * w2];
colp = (fRGB *)&imageBuffer[yy * imageWidth * COM_NUM_CHANNELS_COLOR];
for (x = 0; x < xbsz; x++) {
int xx = xbl * xbsz + x;
- if (xx >= imageWidth)
+ if (xx >= imageWidth) {
continue;
+ }
fp[x] = colp[xx][ch];
}
}
// forward FHT
// zero pad data start is different for each == height+1
- if (!in2done)
+ if (!in2done) {
FHT2D(data1ch, log2_w, log2_h, kernelHeight + 1, 0);
+ }
FHT2D(data2, log2_w, log2_h, kernelHeight + 1, 0);
// FHT2D transposed data, row/col now swapped
@@ -358,14 +377,16 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
// overlap-add result
for (y = 0; y < (int)h2; y++) {
const int yy = ybl * ybsz + y - hh;
- if ((yy < 0) || (yy >= imageHeight))
+ if ((yy < 0) || (yy >= imageHeight)) {
continue;
+ }
fp = &data2[y * w2];
colp = (fRGB *)&rdst->getBuffer()[yy * imageWidth * COM_NUM_CHANNELS_COLOR];
for (x = 0; x < (int)w2; x++) {
const int xx = xbl * xbsz + x - hw;
- if ((xx < 0) || (xx >= imageWidth))
+ if ((xx < 0) || (xx >= imageWidth)) {
continue;
+ }
colp[xx][ch] += fp[x];
}
}
@@ -410,7 +431,7 @@ void GlareFogGlowOperation::generateGlare(float *data,
fcol[1] = expf(d * cs_g);
fcol[2] = expf(d * cs_b);
// linear window good enough here, visual result counts, not scientific analysis
- //w = (1.0f-fabs(u))*(1.0f-fabs(v));
+ // w = (1.0f-fabs(u))*(1.0f-fabs(v));
// actually, Hanning window is ok, cos^2 for some reason is slower
w = (0.5f + 0.5f * cosf(u * (float)M_PI)) * (0.5f + 0.5f * cosf(v * (float)M_PI));
mul_v3_fl(fcol, w);
diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
index f2bf25327af..944a1d9c5dc 100644
--- a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
@@ -48,41 +48,54 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
bool breaked = false;
FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 0, 3);
- if (!breaked)
+ if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 1, 3);
- if (isBreaked())
+ }
+ if (isBreaked()) {
breaked = true;
- if (!breaked)
+ }
+ if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 2, 3);
+ }
MemoryBuffer *tbuf2 = tbuf1->duplicate();
- if (isBreaked())
+ if (isBreaked()) {
breaked = true;
- if (!breaked)
+ }
+ if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 0, 3);
- if (isBreaked())
+ }
+ if (isBreaked()) {
breaked = true;
- if (!breaked)
+ }
+ if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 1, 3);
- if (isBreaked())
+ }
+ if (isBreaked()) {
breaked = true;
- if (!breaked)
+ }
+ if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
+ }
ofs = (settings->iter & 1) ? 0.5f : 0.0f;
for (x = 0; x < (settings->iter * 4); x++) {
y = x & 3;
cm[x][0] = cm[x][1] = cm[x][2] = 1;
- if (y == 1)
+ if (y == 1) {
fRGB_rgbmult(cm[x], 1.0f, cmo, cmo);
- if (y == 2)
+ }
+ if (y == 2) {
fRGB_rgbmult(cm[x], cmo, cmo, 1.0f);
- if (y == 3)
+ }
+ if (y == 3) {
fRGB_rgbmult(cm[x], cmo, 1.0f, cmo);
+ }
scalef[x] = 2.1f * (1.0f - (x + ofs) / (float)(settings->iter * 4));
- if (x & 1)
+ if (x & 1) {
scalef[x] = -0.99f / scalef[x];
+ }
}
sc = 2.13;
@@ -104,8 +117,9 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
gbuf->writePixel(x, y, c);
}
- if (isBreaked())
+ if (isBreaked()) {
breaked = true;
+ }
}
memset(tbuf1->getBuffer(),
@@ -128,8 +142,9 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
}
tbuf1->addPixel(x, y, tc);
}
- if (isBreaked())
+ if (isBreaked()) {
breaked = true;
+ }
}
memcpy(gbuf->getBuffer(),
tbuf1->getBuffer(),
diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
index cf60a1378b4..78ca373faaf 100644
--- a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
@@ -54,10 +54,12 @@ void GlareStreaksOperation::generateGlare(float *data,
for (x = 0; x < tsrc->getWidth(); ++x, tdstcol += 4) {
// first pass no offset, always same for every pass, exact copy,
// otherwise results in uneven brightness, only need once
- if (n == 0)
+ if (n == 0) {
tsrc->read(c1, x, y);
- else
+ }
+ else {
c1[0] = c1[1] = c1[2] = 0;
+ }
tsrc->readBilinear(c2, x + vxp, y + vyp);
tsrc->readBilinear(c3, x + vxp * 2.0f, y + vyp * 2.0f);
tsrc->readBilinear(c4, x + vxp * 3.0f, y + vyp * 3.0f);
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
index bf9ad441803..3a60b1c84a3 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -66,12 +66,14 @@ ImBuf *BaseImageOperation::getImBuf()
ImBuf *ibuf;
ImageUser iuser = *this->m_imageUser;
- if (this->m_image == NULL)
+ if (this->m_image == NULL) {
return NULL;
+ }
/* local changes to the original ImageUser */
- if (BKE_image_is_multilayer(this->m_image) == false)
+ if (BKE_image_is_multilayer(this->m_image) == false) {
iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
+ }
ibuf = BKE_image_acquire_ibuf(this->m_image, &iuser, NULL);
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
@@ -194,8 +196,9 @@ void ImageDepthOperation::executePixelSampled(float output[4],
output[0] = 0.0f;
}
else {
- if (x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight())
+ if (x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight()) {
output[0] = 0.0f;
+ }
else {
int offset = y * this->m_width + x;
output[0] = this->m_depthBuffer[offset];
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
index 86d566834e6..0967984899d 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cpp
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp
@@ -125,10 +125,12 @@ void InpaintSimpleOperation::calc_manhatten_distance()
/* no need to clamp here */
if (this->get_pixel(i, j)[3] < 1.0f) {
r = width + height;
- if (i > 0)
+ if (i > 0) {
r = min_ii(r, m[j * width + i - 1] + 1);
- if (j > 0)
+ }
+ if (j > 0) {
r = min_ii(r, m[(j - 1) * width + i] + 1);
+ }
}
m[j * width + i] = r;
}
@@ -138,10 +140,12 @@ void InpaintSimpleOperation::calc_manhatten_distance()
for (int i = width - 1; i >= 0; i--) {
int r = m[j * width + i];
- if (i + 1 < width)
+ if (i + 1 < width) {
r = min_ii(r, m[j * width + i + 1] + 1);
- if (j + 1 < height)
+ }
+ if (j + 1 < height) {
r = min_ii(r, m[(j + 1) * width + i] + 1);
+ }
m[j * width + i] = r;
diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp
index 632dbdbfa4e..bfd9d14a1ef 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_InvertOperation.cpp
@@ -54,10 +54,12 @@ void InvertOperation::executePixelSampled(float output[4], float x, float y, Pix
copy_v3_v3(output, inputColor);
}
- if (this->m_alpha)
+ if (this->m_alpha) {
output[3] = (1.0f - inputColor[3]) * value + inputColor[3] * invertedValue;
- else
+ }
+ else {
output[3] = inputColor[3];
+ }
}
void InvertOperation::deinitExecution()
diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
index 89fa8a8d303..b11bd54a190 100644
--- a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
@@ -90,21 +90,26 @@ void KeyingClipOperation::executePixel(float output[4], int x, int y, void *data
}
if (this->m_isEdgeMatte) {
- if (ok)
+ if (ok) {
output[0] = 0.0f;
- else
+ }
+ else {
output[0] = 1.0f;
+ }
}
else {
output[0] = value;
if (ok) {
- if (output[0] < this->m_clipBlack)
+ if (output[0] < this->m_clipBlack) {
output[0] = 0.0f;
- else if (output[0] >= this->m_clipWhite)
+ }
+ else if (output[0] >= this->m_clipWhite) {
output[0] = 1.0f;
- else
+ }
+ else {
output[0] = (output[0] - this->m_clipBlack) / (this->m_clipWhite - this->m_clipBlack);
+ }
}
}
}
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
index 03a6bf6a7dd..ab9ef0335e0 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
@@ -52,14 +52,17 @@ void KeyingScreenOperation::deinitExecution()
if (this->m_cachedTriangulation) {
TriangulationData *triangulation = this->m_cachedTriangulation;
- if (triangulation->triangulated_points)
+ if (triangulation->triangulated_points) {
MEM_freeN(triangulation->triangulated_points);
+ }
- if (triangulation->triangles)
+ if (triangulation->triangles) {
MEM_freeN(triangulation->triangles);
+ }
- if (triangulation->triangles_AABB)
+ if (triangulation->triangles_AABB) {
MEM_freeN(triangulation->triangles_AABB);
+ }
MEM_freeN(this->m_cachedTriangulation);
@@ -86,13 +89,15 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
if (this->m_trackingObject[0]) {
MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->m_trackingObject);
- if (!object)
+ if (!object) {
return NULL;
+ }
tracksbase = BKE_tracking_object_get_tracks(tracking, object);
}
- else
+ else {
tracksbase = BKE_tracking_get_active_tracks(tracking);
+ }
/* count sites */
for (track = (MovieTrackingTrack *)tracksbase->first, sites_total = 0; track;
@@ -100,8 +105,9 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame);
float pos[2];
- if (marker->flag & MARKER_DISABLED)
+ if (marker->flag & MARKER_DISABLED) {
continue;
+ }
add_v2_v2v2(pos, marker->pos, track->offset);
@@ -112,14 +118,16 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
sites_total++;
}
- if (!sites_total)
+ if (!sites_total) {
return NULL;
+ }
BKE_movieclip_user_set_frame(&user, clip_frame);
ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, &user);
- if (!ibuf)
+ if (!ibuf) {
return NULL;
+ }
triangulation = (TriangulationData *)MEM_callocN(sizeof(TriangulationData),
"keying screen triangulation data");
@@ -133,8 +141,9 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
int j;
float pos[2];
- if (marker->flag & MARKER_DISABLED)
+ if (marker->flag & MARKER_DISABLED) {
continue;
+ }
add_v2_v2v2(pos, marker->pos, track->offset);
@@ -225,8 +234,9 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect)
int chunk_size = 20;
int i;
- if (this->m_movieClip == NULL)
+ if (this->m_movieClip == NULL) {
return NULL;
+ }
if (!this->m_cachedTriangulation) {
lockMutex();
@@ -238,8 +248,9 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect)
triangulation = this->m_cachedTriangulation;
- if (!triangulation)
+ if (!triangulation) {
return NULL;
+ }
tile_data = (TileData *)MEM_callocN(sizeof(TileData), "keying screen tile data");
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
index 489f0dabdaf..ff5804a63a4 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
@@ -39,7 +39,8 @@ void MapRangeOperation::initExecution()
this->m_destMaxOperation = this->getInputSocketReader(4);
}
-/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
+/* The code below assumes all data is inside range +- this, and that input buffer is single channel
+ */
#define BLENDER_ZMAX 10000.0f
void MapRangeOperation::executePixelSampled(float output[4],
@@ -73,10 +74,12 @@ void MapRangeOperation::executePixelSampled(float output[4],
value = (value - source_min) / (source_max - source_min);
value = dest_min + value * (dest_max - dest_min);
}
- else if (value > BLENDER_ZMAX)
+ else if (value > BLENDER_ZMAX) {
value = dest_max;
- else
+ }
+ else {
value = dest_min;
+ }
if (this->m_useClamp) {
if (dest_max > dest_min) {
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp
index 98b5b650cb9..21d432b9222 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp
@@ -64,10 +64,12 @@ void MapUVOperation::executePixelSampled(float output[4],
float dv = len_v2(deriv[1]);
float factor = 1.0f - threshold * (du / m_inputColorProgram->getWidth() +
dv / m_inputColorProgram->getHeight());
- if (factor < 0.0f)
+ if (factor < 0.0f) {
alpha = 0.0f;
- else
+ }
+ else {
alpha *= factor;
+ }
/* "premul" */
if (alpha < 1.0f) {
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp
index d99a68a5e00..45104d11210 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp
@@ -39,12 +39,16 @@ void MapValueOperation::executePixelSampled(float output[4],
this->m_inputOperation->readSampled(src, x, y, sampler);
TexMapping *texmap = this->m_settings;
float value = (src[0] + texmap->loc[0]) * texmap->size[0];
- if (texmap->flag & TEXMAP_CLIP_MIN)
- if (value < texmap->min[0])
+ if (texmap->flag & TEXMAP_CLIP_MIN) {
+ if (value < texmap->min[0]) {
value = texmap->min[0];
- if (texmap->flag & TEXMAP_CLIP_MAX)
- if (value > texmap->max[0])
+ }
+ }
+ if (texmap->flag & TEXMAP_CLIP_MAX) {
+ if (value > texmap->max[0]) {
value = texmap->max[0];
+ }
+ }
output[0] = value;
}
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp
index 6f146d9e1e6..0c9208fb6bb 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_MaskOperation.cpp
@@ -134,8 +134,10 @@ void MaskOperation::executePixelSampled(float output[4],
float y,
PixelSampler /*sampler*/)
{
- const float xy[2] = {(x * this->m_maskWidthInv) + this->m_mask_px_ofs[0],
- (y * this->m_maskHeightInv) + this->m_mask_px_ofs[1]};
+ const float xy[2] = {
+ (x * this->m_maskWidthInv) + this->m_mask_px_ofs[0],
+ (y * this->m_maskHeightInv) + this->m_mask_px_ofs[1],
+ };
if (this->m_rasterMaskHandleTot == 1) {
if (this->m_rasterMaskHandles[0]) {
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index b3251d32005..15dbd4e2ac9 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -124,10 +124,12 @@ void MathDivideOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue2[0] == 0) /* We don't want to divide by zero. */
+ if (inputValue2[0] == 0) { /* We don't want to divide by zero. */
output[0] = 0.0;
- else
+ }
+ else {
output[0] = inputValue1[0] / inputValue2[0];
+ }
clampIfNeeded(output);
}
@@ -191,10 +193,12 @@ void MathArcSineOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
+ if (inputValue1[0] <= 1 && inputValue1[0] >= -1) {
output[0] = asin(inputValue1[0]);
- else
+ }
+ else {
output[0] = 0.0;
+ }
clampIfNeeded(output);
}
@@ -210,10 +214,12 @@ void MathArcCosineOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
+ if (inputValue1[0] <= 1 && inputValue1[0] >= -1) {
output[0] = acos(inputValue1[0]);
- else
+ }
+ else {
output[0] = 0.0;
+ }
clampIfNeeded(output);
}
@@ -273,10 +279,12 @@ void MathLogarithmOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue1[0] > 0 && inputValue2[0] > 0)
+ if (inputValue1[0] > 0 && inputValue2[0] > 0) {
output[0] = log(inputValue1[0]) / log(inputValue2[0]);
- else
+ }
+ else {
output[0] = 0.0;
+ }
clampIfNeeded(output);
}
@@ -372,10 +380,12 @@ void MathModuloOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue2[0] == 0)
+ if (inputValue2[0] == 0) {
output[0] = 0.0;
- else
+ }
+ else {
output[0] = fmod(inputValue1[0], inputValue2[0]);
+ }
clampIfNeeded(output);
}
@@ -461,10 +471,12 @@ void MathSqrtOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- if (inputValue1[0] > 0)
+ if (inputValue1[0] > 0) {
output[0] = sqrt(inputValue1[0]);
- else
+ }
+ else {
output[0] = 0.0f;
+ }
clampIfNeeded(output);
}
diff --git a/source/blender/compositor/operations/COM_MixOperation.cpp b/source/blender/compositor/operations/COM_MixOperation.cpp
index 8e09586aaa8..a610cb0d1e8 100644
--- a/source/blender/compositor/operations/COM_MixOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixOperation.cpp
@@ -185,42 +185,54 @@ void MixBurnOperation::executePixelSampled(float output[4], float x, float y, Pi
float valuem = 1.0f - value;
tmp = valuem + value * inputColor2[0];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
output[0] = 0.0f;
+ }
else {
tmp = 1.0f - (1.0f - inputColor1[0]) / tmp;
- if (tmp < 0.0f)
+ if (tmp < 0.0f) {
output[0] = 0.0f;
- else if (tmp > 1.0f)
+ }
+ else if (tmp > 1.0f) {
output[0] = 1.0f;
- else
+ }
+ else {
output[0] = tmp;
+ }
}
tmp = valuem + value * inputColor2[1];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
output[1] = 0.0f;
+ }
else {
tmp = 1.0f - (1.0f - inputColor1[1]) / tmp;
- if (tmp < 0.0f)
+ if (tmp < 0.0f) {
output[1] = 0.0f;
- else if (tmp > 1.0f)
+ }
+ else if (tmp > 1.0f) {
output[1] = 1.0f;
- else
+ }
+ else {
output[1] = tmp;
+ }
}
tmp = valuem + value * inputColor2[2];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
output[2] = 0.0f;
+ }
else {
tmp = 1.0f - (1.0f - inputColor1[2]) / tmp;
- if (tmp < 0.0f)
+ if (tmp < 0.0f) {
output[2] = 0.0f;
- else if (tmp > 1.0f)
+ }
+ else if (tmp > 1.0f) {
output[2] = 1.0f;
- else
+ }
+ else {
output[2] = tmp;
+ }
}
output[3] = inputColor1[3];
@@ -365,18 +377,24 @@ void MixDivideOperation::executePixelSampled(float output[4],
}
float valuem = 1.0f - value;
- if (inputColor2[0] != 0.0f)
+ if (inputColor2[0] != 0.0f) {
output[0] = valuem * (inputColor1[0]) + value * (inputColor1[0]) / inputColor2[0];
- else
+ }
+ else {
output[0] = 0.0f;
- if (inputColor2[1] != 0.0f)
+ }
+ if (inputColor2[1] != 0.0f) {
output[1] = valuem * (inputColor1[1]) + value * (inputColor1[1]) / inputColor2[1];
- else
+ }
+ else {
output[1] = 0.0f;
- if (inputColor2[2] != 0.0f)
+ }
+ if (inputColor2[2] != 0.0f) {
output[2] = valuem * (inputColor1[2]) + value * (inputColor1[2]) / inputColor2[2];
- else
+ }
+ else {
output[2] = 0.0f;
+ }
output[3] = inputColor1[3];
@@ -411,48 +429,60 @@ void MixDodgeOperation::executePixelSampled(float output[4],
if (inputColor1[0] != 0.0f) {
tmp = 1.0f - value * inputColor2[0];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
output[0] = 1.0f;
+ }
else {
tmp = inputColor1[0] / tmp;
- if (tmp > 1.0f)
+ if (tmp > 1.0f) {
output[0] = 1.0f;
- else
+ }
+ else {
output[0] = tmp;
+ }
}
}
- else
+ else {
output[0] = 0.0f;
+ }
if (inputColor1[1] != 0.0f) {
tmp = 1.0f - value * inputColor2[1];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
output[1] = 1.0f;
+ }
else {
tmp = inputColor1[1] / tmp;
- if (tmp > 1.0f)
+ if (tmp > 1.0f) {
output[1] = 1.0f;
- else
+ }
+ else {
output[1] = tmp;
+ }
}
}
- else
+ else {
output[1] = 0.0f;
+ }
if (inputColor1[2] != 0.0f) {
tmp = 1.0f - value * inputColor2[2];
- if (tmp <= 0.0f)
+ if (tmp <= 0.0f) {
output[2] = 1.0f;
+ }
else {
tmp = inputColor1[2] / tmp;
- if (tmp > 1.0f)
+ if (tmp > 1.0f) {
output[2] = 1.0f;
- else
+ }
+ else {
output[2] = tmp;
+ }
}
}
- else
+ else {
output[2] = 0.0f;
+ }
output[3] = inputColor1[3];
@@ -482,12 +512,15 @@ void MixGlareOperation::executePixelSampled(float output[4],
value = inputValue[0];
float mf = 2.0f - 2.0f * fabsf(value - 0.5f);
- if (inputColor1[0] < 0.0f)
+ if (inputColor1[0] < 0.0f) {
inputColor1[0] = 0.0f;
- if (inputColor1[1] < 0.0f)
+ }
+ if (inputColor1[1] < 0.0f) {
inputColor1[1] = 0.0f;
- if (inputColor1[2] < 0.0f)
+ }
+ if (inputColor1[2] < 0.0f) {
inputColor1[2] = 0.0f;
+ }
output[0] = mf * max(inputColor1[0] + value * (inputColor2[0] - inputColor1[0]), 0.0f);
output[1] = mf * max(inputColor1[1] + value * (inputColor2[1] - inputColor1[1]), 0.0f);
@@ -565,20 +598,26 @@ void MixLightenOperation::executePixelSampled(float output[4],
}
float tmp;
tmp = value * inputColor2[0];
- if (tmp > inputColor1[0])
+ if (tmp > inputColor1[0]) {
output[0] = tmp;
- else
+ }
+ else {
output[0] = inputColor1[0];
+ }
tmp = value * inputColor2[1];
- if (tmp > inputColor1[1])
+ if (tmp > inputColor1[1]) {
output[1] = tmp;
- else
+ }
+ else {
output[1] = inputColor1[1];
+ }
tmp = value * inputColor2[2];
- if (tmp > inputColor1[2])
+ if (tmp > inputColor1[2]) {
output[2] = tmp;
- else
+ }
+ else {
output[2] = inputColor1[2];
+ }
output[3] = inputColor1[3];
clampIfNeeded(output);
@@ -608,18 +647,24 @@ void MixLinearLightOperation::executePixelSampled(float output[4],
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}
- if (inputColor2[0] > 0.5f)
+ if (inputColor2[0] > 0.5f) {
output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0] - 0.5f));
- else
+ }
+ else {
output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0]) - 1.0f);
- if (inputColor2[1] > 0.5f)
+ }
+ if (inputColor2[1] > 0.5f) {
output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1] - 0.5f));
- else
+ }
+ else {
output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1]) - 1.0f);
- if (inputColor2[2] > 0.5f)
+ }
+ if (inputColor2[2] > 0.5f) {
output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2] - 0.5f));
- else
+ }
+ else {
output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2]) - 1.0f);
+ }
output[3] = inputColor1[3];
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
index ce7973fdc99..c5757274143 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
@@ -42,11 +42,13 @@ void MovieClipBaseOperation::initExecution()
BKE_movieclip_user_set_frame(this->m_movieClipUser, this->m_framenumber);
ImBuf *ibuf;
- if (this->m_cacheFrame)
+ if (this->m_cacheFrame) {
ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, this->m_movieClipUser);
- else
+ }
+ else {
ibuf = BKE_movieclip_get_ibuf_flag(
this->m_movieClip, this->m_movieClipUser, this->m_movieClip->flag, MOVIECLIP_CACHE_SKIP);
+ }
if (ibuf) {
this->m_movieClipBuffer = ibuf;
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
index 14542f1e65a..9876c319944 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
@@ -72,8 +72,9 @@ void MultilayerColorOperation::executePixelSampled(float output[4],
int yi = y;
int xi = x;
if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() ||
- (unsigned int)yi >= this->getHeight())
+ (unsigned int)yi >= this->getHeight()) {
zero_v4(output);
+ }
else {
int offset = (yi * this->getWidth() + xi) * 3;
copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
@@ -94,8 +95,9 @@ void MultilayerValueOperation::executePixelSampled(float output[4],
int yi = y;
int xi = x;
if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() ||
- (unsigned int)yi >= this->getHeight())
+ (unsigned int)yi >= this->getHeight()) {
output[0] = 0.0f;
+ }
else {
float result = this->m_imageFloatBuffer[yi * this->getWidth() + xi];
output[0] = result;
@@ -115,8 +117,9 @@ void MultilayerVectorOperation::executePixelSampled(float output[4],
int yi = y;
int xi = x;
if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() ||
- (unsigned int)yi >= this->getHeight())
+ (unsigned int)yi >= this->getHeight()) {
output[0] = 0.0f;
+ }
else {
int offset = (yi * this->getWidth() + xi) * 3;
copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
index 703ffbe3999..f7e689fa008 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.cpp
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
@@ -42,10 +42,12 @@ void NormalizeOperation::executePixel(float output[4], int x, int y, void *data)
output[0] = (output[0] - minmult->x) * minmult->y;
/* clamp infinities */
- if (output[0] > 1.0f)
+ if (output[0] > 1.0f) {
output[0] = 1.0f;
- else if (output[0] < 0.0f)
+ }
+ else if (output[0] < 0.0f) {
output[0] = 0.0f;
+ }
}
void NormalizeOperation::deinitExecution()
@@ -62,8 +64,9 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/,
rcti *output)
{
rcti imageInput;
- if (this->m_cachedInstance)
+ if (this->m_cachedInstance) {
return false;
+ }
NodeOperation *operation = getInputOperation(0);
imageInput.xmax = operation->getWidth();
@@ -77,7 +80,8 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/,
return false;
}
-/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
+/* The code below assumes all data is inside range +- this, and that input buffer is single channel
+ */
#define BLENDER_ZMAX 10000.0f
void *NormalizeOperation::initializeTileData(rcti *rect)
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl
index ebe8a6d08ec..4dfca1777f1 100644
--- a/source/blender/compositor/operations/COM_OpenCLKernels.cl
+++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl
@@ -26,22 +26,22 @@
const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
const sampler_t SAMPLER_NEAREST_CLAMP = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
-__constant const int2 zero = {0,0};
+__constant const int zero = {0,0};
// KERNEL --- BOKEH BLUR ---
__kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only image2d_t inputImage,
__read_only image2d_t bokehImage, __write_only image2d_t output,
- int2 offsetInput, int2 offsetOutput, int radius, int step, int2 dimension, int2 offset)
+ int offsetInput, int offsetOutput, int radius, int step, int dimension, int offset)
{
- int2 coords = {get_global_id(0), get_global_id(1)};
+ int coords = {get_global_id(0), get_global_id(1)};
coords += offset;
float tempBoundingBox;
- float4 color = {0.0f,0.0f,0.0f,0.0f};
- float4 multiplyer = {0.0f,0.0f,0.0f,0.0f};
- float4 bokeh;
+ float color = {0.0f,0.0f,0.0f,0.0f};
+ float multiplyer = {0.0f,0.0f,0.0f,0.0f};
+ float bokeh;
const float radius2 = radius*2.0f;
- const int2 realCoordinate = coords + offsetOutput;
- int2 imageCoordinates = realCoordinate - offsetInput;
+ const int realCoordinate = coords + offsetOutput;
+ int imageCoordinates = realCoordinate - offsetInput;
tempBoundingBox = read_imagef(boundingBox, SAMPLER_NEAREST, coords).s0;
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
index 62ba896f38e..9d1be09de0e 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
@@ -39,7 +39,7 @@ extern "C" {
#include "IMB_imbuf_types.h"
}
-/************************************ OpenEXR Singlelayer Multiview *****************************************/
+/************************************ OpenEXR Singlelayer Multiview ******************************/
OutputOpenExrSingleLayerMultiViewOperation::OutputOpenExrSingleLayerMultiViewOperation(
const RenderData *rd,
@@ -66,14 +66,16 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam
exrhandle = IMB_exr_get_handle_name(filename);
- if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
+ if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
return exrhandle;
+ }
IMB_exr_clear_channels(exrhandle);
for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
- if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
+ if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false) {
continue;
+ }
IMB_exr_add_view(exrhandle, srv->name);
add_exr_channels(exrhandle, NULL, this->m_datatype, srv->name, width, false, NULL);
@@ -140,7 +142,7 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
}
}
-/************************************ OpenEXR Multilayer Multiview *****************************************/
+/************************************ OpenEXR Multilayer Multiview *******************************/
OutputOpenExrMultiLayerMultiViewOperation::OutputOpenExrMultiLayerMultiViewOperation(
const RenderData *rd,
@@ -166,20 +168,22 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename
/* get a new global handle */
exrhandle = IMB_exr_get_handle_name(filename);
- if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
+ if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
return exrhandle;
+ }
IMB_exr_clear_channels(exrhandle);
/* check renderdata for amount of views */
for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
- if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
+ if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false) {
continue;
+ }
IMB_exr_add_view(exrhandle, srv->name);
- for (unsigned int i = 0; i < this->m_layers.size(); ++i)
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
add_exr_channels(exrhandle,
this->m_layers[i].name,
this->m_layers[i].datatype,
@@ -187,6 +191,7 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename
width,
this->m_exr_half_float,
NULL);
+ }
}
BLI_make_existing_file(filename);
@@ -224,7 +229,7 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
exrhandle = this->get_handle(filename);
- for (unsigned int i = 0; i < this->m_layers.size(); ++i)
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
add_exr_channels(exrhandle,
this->m_layers[i].name,
this->m_layers[i].datatype,
@@ -232,6 +237,7 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
width,
this->m_exr_half_float,
this->m_layers[i].outputBuffer);
+ }
for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
/* memory can only be freed after we write all views to the file */
@@ -284,13 +290,15 @@ void *OutputStereoOperation::get_handle(const char *filename)
exrhandle = IMB_exr_get_handle_name(filename);
- if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
+ if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
return exrhandle;
+ }
IMB_exr_clear_channels(exrhandle);
- for (i = 0; i < 2; i++)
+ for (i = 0; i < 2; i++) {
IMB_exr_add_view(exrhandle, names[i]);
+ }
return exrhandle;
}
@@ -359,8 +367,9 @@ void OutputStereoOperation::deinitExecution()
BKE_imbuf_write(ibuf[2], filename, this->m_format);
/* imbuf knows which rects are not part of ibuf */
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++) {
IMB_freeImBuf(ibuf[i]);
+ }
IMB_exr_close(exrhandle);
}
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index f83ce478bd5..79e3b2f1108 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -86,8 +86,9 @@ void free_exr_channels(void *exrhandle,
for (srv = (SceneRenderView *)rd->views.first; srv; srv = srv->next) {
float *rect = NULL;
- if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
+ if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
continue;
+ }
/* the pointer is stored in the first channel of each datatype */
switch (datatype) {
@@ -103,8 +104,9 @@ void free_exr_channels(void *exrhandle,
default:
break;
}
- if (rect)
+ if (rect) {
MEM_freeN(rect);
+ }
}
}
@@ -129,8 +131,9 @@ static float *init_buffer(unsigned int width, unsigned int height, DataType data
int size = get_datatype_size(datatype);
return (float *)MEM_callocN(width * height * size * sizeof(float), "OutputFile buffer");
}
- else
+ else {
return NULL;
+ }
}
static void write_buffer_rect(rcti *rect,
@@ -143,8 +146,9 @@ static void write_buffer_rect(rcti *rect,
float color[4];
int i, size = get_datatype_size(datatype);
- if (!buffer)
+ if (!buffer) {
return;
+ }
int x1 = rect->xmin;
int y1 = rect->ymin;
int x2 = rect->xmax;
@@ -158,12 +162,14 @@ static void write_buffer_rect(rcti *rect,
for (x = x1; x < x2 && (!breaked); x++) {
reader->readSampled(color, x, y, COM_PS_NEAREST);
- for (i = 0; i < size; ++i)
+ for (i = 0; i < size; ++i) {
buffer[offset + i] = color[i];
+ }
offset += size;
- if (tree->test_break && tree->test_break(tree->tbh))
+ if (tree->test_break && tree->test_break(tree->tbh)) {
breaked = true;
+ }
}
offset += (width - (x2 - x1)) * size;
}
@@ -240,10 +246,12 @@ void OutputSingleLayerOperation::deinitExecution()
true,
suffix);
- if (0 == BKE_imbuf_write(ibuf, filename, this->m_format))
+ if (0 == BKE_imbuf_write(ibuf, filename, this->m_format)) {
printf("Cannot save Node File Output to %s\n", filename);
- else
+ }
+ else {
printf("Saved: %s\n", filename);
+ }
IMB_freeImBuf(ibuf);
}
@@ -304,13 +312,14 @@ void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int /*
{
for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
OutputOpenExrLayer &layer = this->m_layers[i];
- if (layer.imageInput)
+ if (layer.imageInput) {
write_buffer_rect(rect,
this->m_tree,
layer.imageInput,
layer.outputBuffer,
this->getWidth(),
layer.datatype);
+ }
}
}
@@ -336,8 +345,9 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
OutputOpenExrLayer &layer = this->m_layers[i];
- if (!layer.imageInput)
+ if (!layer.imageInput) {
continue; /* skip unconnected sockets */
+ }
add_exr_channels(exrhandle,
this->m_layers[i].name,
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
index 54d5d6e97a5..313be2f5ecf 100644
--- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
@@ -43,13 +43,16 @@ static bool check_corners(float corners[4][2])
sub_v2_v2v2(v2, corners[next], corners[i]);
cur_cross = cross_v2v2(v1, v2);
- if (fabsf(cur_cross) <= FLT_EPSILON)
+ if (fabsf(cur_cross) <= FLT_EPSILON) {
return false;
+ }
- if (cross == 0.0f)
+ if (cross == 0.0f) {
cross = cur_cross;
- else if (cross * cur_cross < 0.0f)
+ }
+ else if (cross * cur_cross < 0.0f) {
return false;
+ }
}
return true;
@@ -125,10 +128,12 @@ void *PlaneCornerPinMaskOperation::initializeTileData(rcti *rect)
*/
lockMutex();
if (!m_corners_ready) {
- SocketReader *readers[4] = {getInputSocketReader(0),
- getInputSocketReader(1),
- getInputSocketReader(2),
- getInputSocketReader(3)};
+ SocketReader *readers[4] = {
+ getInputSocketReader(0),
+ getInputSocketReader(1),
+ getInputSocketReader(2),
+ getInputSocketReader(3),
+ };
float corners[4][2];
readCornersFromSockets(rect, readers, corners);
calculateCorners(corners, true, 0);
@@ -183,10 +188,12 @@ void *PlaneCornerPinWarpImageOperation::initializeTileData(rcti *rect)
lockMutex();
if (!m_corners_ready) {
/* corner sockets start at index 1 */
- SocketReader *readers[4] = {getInputSocketReader(1),
- getInputSocketReader(2),
- getInputSocketReader(3),
- getInputSocketReader(4)};
+ SocketReader *readers[4] = {
+ getInputSocketReader(1),
+ getInputSocketReader(2),
+ getInputSocketReader(3),
+ getInputSocketReader(4),
+ };
float corners[4][2];
readCornersFromSockets(rect, readers, corners);
calculateCorners(corners, true, 0);
@@ -201,9 +208,11 @@ void *PlaneCornerPinWarpImageOperation::initializeTileData(rcti *rect)
bool PlaneCornerPinWarpImageOperation::determineDependingAreaOfInterest(
rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- for (int i = 0; i < 4; ++i)
- if (getInputOperation(i + 1)->determineDependingAreaOfInterest(input, readOperation, output))
+ for (int i = 0; i < 4; ++i) {
+ if (getInputOperation(i + 1)->determineDependingAreaOfInterest(input, readOperation, output)) {
return true;
+ }
+ }
/* XXX this is bad, but unavoidable with the current design:
* we don't know the actual corners and matrix at this point,
@@ -214,5 +223,8 @@ bool PlaneCornerPinWarpImageOperation::determineDependingAreaOfInterest(
output->xmax = getInputOperation(0)->getWidth();
output->ymax = getInputOperation(0)->getHeight();
return true;
- // return PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(input, readOperation, output);
+#if 0
+ return PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(
+ input, readOperation, output);
+#endif
}
diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
index 76ecabb8c8b..c2fe41eea1d 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
@@ -46,8 +46,9 @@ void PlaneTrackCommon::readCornersFromTrack(float corners[4][2], float frame)
MovieTracking *tracking;
MovieTrackingObject *object;
- if (!this->m_movieClip)
+ if (!this->m_movieClip) {
return;
+ }
tracking = &this->m_movieClip->tracking;
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
index 40299d33306..32933f1b966 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -97,8 +97,9 @@ bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(
void ProjectorLensDistortionOperation::updateDispersion()
{
- if (this->m_dispersionAvailable)
+ if (this->m_dispersionAvailable) {
return;
+ }
this->lockMutex();
if (!this->m_dispersionAvailable) {
float result[4];
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index 0ebb60cff18..3c0b01874aa 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -47,8 +47,9 @@ void RenderLayersProg::initExecution()
Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
RenderResult *rr = NULL;
- if (re)
+ if (re) {
rr = RE_AcquireResultRead(re);
+ }
if (rr) {
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, getLayerId());
@@ -74,12 +75,15 @@ void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelS
int ix = x, iy = y;
if (ix < 0 || iy < 0 || ix >= width || iy >= height) {
- if (this->m_elementsize == 1)
+ if (this->m_elementsize == 1) {
output[0] = 0.0f;
- else if (this->m_elementsize == 3)
+ }
+ else if (this->m_elementsize == 3) {
zero_v3(output);
- else
+ }
+ else {
zero_v4(output);
+ }
return;
}
@@ -87,12 +91,15 @@ void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelS
case COM_PS_NEAREST: {
offset = (iy * width + ix) * this->m_elementsize;
- if (this->m_elementsize == 1)
+ if (this->m_elementsize == 1) {
output[0] = this->m_inputBuffer[offset];
- else if (this->m_elementsize == 3)
+ }
+ else if (this->m_elementsize == 3) {
copy_v3_v3(output, &this->m_inputBuffer[offset]);
- else
+ }
+ else {
copy_v4_v4(output, &this->m_inputBuffer[offset]);
+ }
break;
}
@@ -119,7 +126,7 @@ void RenderLayersProg::executePixelSampled(float output[4], float x, float y, Pi
/* see comment in executeRegion describing coordinate mapping,
* here it simply goes other way around
*/
- int full_width = rd->xsch * rd->size / 100;
+ int full_width = rd->xsch * rd->size / 100;
int full_height = rd->ysch * rd->size / 100;
dx = rd->border.xmin * full_width - (full_width - this->getWidth()) / 2.0f;
@@ -185,8 +192,9 @@ void RenderLayersProg::determineResolution(unsigned int resolution[2],
resolution[0] = 0;
resolution[1] = 0;
- if (re)
+ if (re) {
rr = RE_AcquireResultRead(re);
+ }
if (rr) {
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&sce->view_layers, getLayerId());
@@ -199,8 +207,9 @@ void RenderLayersProg::determineResolution(unsigned int resolution[2],
}
}
- if (re)
+ if (re) {
RE_ReleaseResult(re);
+ }
}
/* ******** Render Layers AO Operation ******** */
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index 3663d56dc87..1c5b2a71859 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -155,7 +155,7 @@ void ScaleAbsoluteOperation::executePixelSampled(float output[4],
const float width = this->getWidth();
const float height = this->getHeight();
- //div
+ // div
float relativeXScale = scx / width;
float relativeYScale = scy / height;
@@ -181,7 +181,7 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input,
const float scy = scaleY[0];
const float width = this->getWidth();
const float height = this->getHeight();
- //div
+ // div
float relateveXScale = scx / width;
float relateveYScale = scy / height;
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index eeefb2a9f3b..738f7ed31ba 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -125,8 +125,9 @@ bool ScreenLensDistortionOperation::get_delta(float r_sq,
distort_uv(uv, t, delta);
return true;
}
- else
+ else {
return false;
+ }
}
void ScreenLensDistortionOperation::accumulate(MemoryBuffer *buffer,
@@ -182,12 +183,15 @@ void ScreenLensDistortionOperation::executePixel(float output[4], int x, int y,
accumulate(buffer, 0, 1, uv_dot, uv, delta, sum, count);
accumulate(buffer, 1, 2, uv_dot, uv, delta, sum, count);
- if (count[0])
+ if (count[0]) {
output[0] = 2.0f * sum[0] / (float)count[0];
- if (count[1])
+ }
+ if (count[1]) {
output[1] = 2.0f * sum[1] / (float)count[1];
- if (count[2])
+ }
+ if (count[2]) {
output[2] = 2.0f * sum[2] / (float)count[2];
+ }
/* set alpha */
output[3] = 1.0f;
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
index 80b1c1f798a..6f47e0e190b 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
@@ -146,8 +146,8 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
* Perform the actual accumulation along a ray segment from source to pt.
* Only pixels within dist_min..dist_max contribute.
*
- * The loop runs backwards(!) over the primary sector space axis u, i.e. increasing distance to pt.
- * After each step it decrements v by dv < 1, adding a buffer shift when necessary.
+ * The loop runs backwards(!) over the primary sector space axis u, i.e. increasing distance to
+ * pt. After each step it decrements v by dv < 1, adding a buffer shift when necessary.
*/
static void eval(MemoryBuffer *input,
float output[4],
@@ -229,11 +229,12 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
};
/**
- * Dispatch function which selects an appropriate accumulator based on the sector of the target point,
- * relative to the source.
+ * Dispatch function which selects an appropriate accumulator based on the sector of the target
+ * point, relative to the source.
*
* The BufferLineAccumulator defines the actual loop over the buffer, with an efficient inner loop
- * due to using compile time constants instead of a local matrix variable defining the sector space.
+ * due to using compile time constants instead of a local matrix variable defining the sector
+ * space.
*/
static void accumulate_line(MemoryBuffer *input,
float output[4],
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index f23057bbe8e..f2d78845b6c 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -29,8 +29,8 @@ extern "C" {
TextureBaseOperation::TextureBaseOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VECTOR); //offset
- this->addInputSocket(COM_DT_VECTOR); //size
+ this->addInputSocket(COM_DT_VECTOR); // offset
+ this->addInputSocket(COM_DT_VECTOR); // size
this->m_texture = NULL;
this->m_inputSize = NULL;
this->m_inputOffset = NULL;
@@ -132,10 +132,12 @@ void TextureBaseOperation::executePixelSampled(float output[4],
retval = multitex_ext(
this->m_texture, vec, NULL, NULL, 0, &texres, thread_id, m_pool, m_sceneColorManage, false);
- if (texres.talpha)
+ if (texres.talpha) {
output[3] = texres.ta;
- else
+ }
+ else {
output[3] = texres.tin;
+ }
if ((retval & TEX_RGB)) {
output[0] = texres.tr;
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
index 178a9b57cba..e497d58732b 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
@@ -52,8 +52,9 @@ void TrackPositionOperation::initExecution()
zero_v2(this->m_markerPos);
zero_v2(this->m_relativePos);
- if (!this->m_movieClip)
+ if (!this->m_movieClip) {
return;
+ }
tracking = &this->m_movieClip->tracking;
@@ -121,10 +122,12 @@ void TrackPositionOperation::executePixelSampled(float output[4],
{
output[0] = this->m_markerPos[this->m_axis] - this->m_relativePos[this->m_axis];
- if (this->m_axis == 0)
+ if (this->m_axis == 0) {
output[0] *= this->m_width;
- else
+ }
+ else {
output[0] *= this->m_height;
+ }
}
void TrackPositionOperation::determineResolution(unsigned int resolution[2],
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 8b0335754aa..02f13effc8f 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -151,10 +151,12 @@ void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y,
if (size > this->m_threshold) {
float dx = nx - x;
if (size > fabsf(dx) && size > fabsf(dy)) {
- float uv[2] = {(float)(COM_BLUR_BOKEH_PIXELS / 2) +
- (dx / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1),
- (float)(COM_BLUR_BOKEH_PIXELS / 2) +
- (dy / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1)};
+ float uv[2] = {
+ (float)(COM_BLUR_BOKEH_PIXELS / 2) +
+ (dx / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1),
+ (float)(COM_BLUR_BOKEH_PIXELS / 2) +
+ (dy / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1),
+ };
inputBokehBuffer->read(bokeh, uv[0], uv[1]);
madd_v4_v4v4(color_accum, bokeh, &inputProgramFloatBuffer[offsetColorNxNy]);
add_v4_v4(multiplier_accum, bokeh);
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index 26e688e1c97..8e67b8ac786 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -46,7 +46,7 @@ VectorBlurOperation::VectorBlurOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE); // ZBUF
- this->addInputSocket(COM_DT_COLOR); //SPEED
+ this->addInputSocket(COM_DT_COLOR); // SPEED
this->addOutputSocket(COM_DT_COLOR);
this->m_settings = NULL;
this->m_cachedInstance = NULL;
@@ -178,10 +178,12 @@ void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop)
void zbuf_free_span(ZSpan *zspan)
{
if (zspan) {
- if (zspan->span1)
+ if (zspan->span1) {
MEM_freeN(zspan->span1);
- if (zspan->span2)
+ }
+ if (zspan->span2) {
MEM_freeN(zspan->span2);
+ }
zspan->span1 = zspan->span2 = NULL;
}
}
@@ -213,18 +215,22 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
my0 = ceil(minv[1]);
my2 = floor(maxv[1]);
- if (my2 < 0 || my0 >= zspan->recty)
+ if (my2 < 0 || my0 >= zspan->recty) {
return;
+ }
/* clip top */
- if (my2 >= zspan->recty)
+ if (my2 >= zspan->recty) {
my2 = zspan->recty - 1;
+ }
/* clip bottom */
- if (my0 < 0)
+ if (my0 < 0) {
my0 = 0;
+ }
- if (my0 > my2)
+ if (my0 > my2) {
return;
+ }
/* if (my0>my2) should still fill in, that way we get spans that skip nicely */
xx1 = maxv[1] - minv[1];
@@ -258,10 +264,12 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) {
zspan->maxp1 = maxv;
}
- if (my0 < zspan->miny1)
+ if (my0 < zspan->miny1) {
zspan->miny1 = my0;
- if (my2 > zspan->maxy1)
+ }
+ if (my2 > zspan->maxy1) {
zspan->maxy1 = my2;
+ }
}
else {
// printf("right span my0 %d my2 %d\n", my0, my2);
@@ -271,10 +279,12 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) {
zspan->maxp2 = maxv;
}
- if (my0 < zspan->miny2)
+ if (my0 < zspan->miny2) {
zspan->miny2 = my0;
- if (my2 > zspan->maxy2)
+ }
+ if (my2 > zspan->maxy2) {
zspan->maxy2 = my2;
+ }
}
for (y = my2; y >= my0; y--, xs0 += dx0) {
@@ -312,15 +322,17 @@ static void zbuf_fill_in_rgba(
zbuf_add_to_span(zspan, v4, v1);
/* clipped */
- if (zspan->minp2 == NULL || zspan->maxp2 == NULL)
+ if (zspan->minp2 == NULL || zspan->maxp2 == NULL) {
return;
+ }
my0 = max_ii(zspan->miny1, zspan->miny2);
my2 = min_ii(zspan->maxy1, zspan->maxy2);
// printf("my %d %d\n", my0, my2);
- if (my2 < my0)
+ if (my2 < my0) {
return;
+ }
/* ZBUF DX DY, in floats still */
x1 = v1[0] - v2[0];
@@ -333,8 +345,9 @@ static void zbuf_fill_in_rgba(
y0 = z1 * x2 - x1 * z2;
z0 = x1 * y2 - y1 * x2;
- if (z0 == 0.0f)
+ if (z0 == 0.0f) {
return;
+ }
xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + v1[2];
@@ -364,10 +377,12 @@ static void zbuf_fill_in_rgba(
sn2 = floor(*span2);
sn1++;
- if (sn2 >= rectx)
+ if (sn2 >= rectx) {
sn2 = rectx - 1;
- if (sn1 < 0)
+ }
+ if (sn1 < 0) {
sn1 = 0;
+ }
if (sn2 >= sn1) {
zverg = (double)sn1 * zxd + zy0;
@@ -394,7 +409,8 @@ static void zbuf_fill_in_rgba(
}
/* char value==255 is filled in, rest should be zero */
-/* returns alpha values, but sets alpha to 1 for zero alpha pixels that have an alpha value as neighbor */
+/* returns alpha values,
+ * but sets alpha to 1 for zero alpha pixels that have an alpha value as neighbor. */
void antialias_tagbuf(int xsize, int ysize, char *rectmove)
{
char *row1, *row2, *row3;
@@ -409,8 +425,9 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
row3 = row2 + xsize;
for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
if (row2[1]) {
- if (row2[0] == 0 || row2[2] == 0 || row1[1] == 0 || row3[1] == 0)
+ if (row2[0] == 0 || row2[2] == 0 || row1[1] == 0 || row3[1] == 0) {
row2[1] = 128;
+ }
}
}
}
@@ -424,8 +441,9 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
/* find previous color and next color and amount of steps to blend */
prev = row1[-1];
step = 1;
- while (x + step < xsize && row1[step] == 128)
+ while (x + step < xsize && row1[step] == 128) {
step++;
+ }
if (x + step != xsize) {
/* now we can blend values */
@@ -455,8 +473,9 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
/* find previous color and next color and amount of steps to blend */
prev = row1[-xsize];
step = 1;
- while (y + step < ysize && row1[step * xsize] == 128)
+ while (y + step < ysize && row1[step * xsize] == 128) {
step++;
+ }
if (y + step != ysize) {
/* now we can blend values */
@@ -483,8 +502,9 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
row3 = row2 + xsize;
for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
if (row2[1] == 0) {
- if (row2[0] > 1 || row2[2] > 1 || row1[1] > 1 || row3[1] > 1)
+ if (row2[0] > 1 || row2[2] > 1 || row1[1] > 1 || row3[1] > 1) {
row2[1] = 1;
+ }
}
}
}
@@ -567,8 +587,9 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
tsktsk = 1;
}
}
- if (tsktsk)
+ if (tsktsk) {
printf("Found uninitialized speed in vector buffer... fixed.\n");
+ }
/* min speed? then copy speedbuffer to recalculate speed vectors */
if (nbd->minspeed) {
@@ -605,15 +626,19 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
dvz = rectvz;
for (y = 0; y <= ysize; y++) {
- if (y == 0)
+ if (y == 0) {
dvec1 = vecbufrect + 4 * y * xsize;
- else
+ }
+ else {
dvec1 = vecbufrect + 4 * (y - 1) * xsize;
+ }
- if (y == ysize)
+ if (y == ysize) {
dvec2 = vecbufrect + 4 * (y - 1) * xsize;
- else
+ }
+ else {
dvec2 = vecbufrect + 4 * y * xsize;
+ }
for (x = 0; x <= xsize; x++) {
@@ -698,8 +723,9 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
dm = rectmove;
dvec1 = vecbufrect;
for (x = xsize * ysize; x > 0; x--, dm++, dvec1 += 4) {
- if ((dvec1[0] != 0.0f || dvec1[1] != 0.0f || dvec1[2] != 0.0f || dvec1[3] != 0.0f))
+ if ((dvec1[0] != 0.0f || dvec1[1] != 0.0f || dvec1[2] != 0.0f || dvec1[3] != 0.0f)) {
*dm = 255;
+ }
}
antialias_tagbuf(xsize, ysize, rectmove);
@@ -722,20 +748,26 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
float blendfac, ipodata[4];
/* clear zbuf, if we draw future we fill in not moving pixels */
- if (0)
- for (x = xsize * ysize - 1; x >= 0; x--)
+ if (0) {
+ for (x = xsize * ysize - 1; x >= 0; x--) {
rectz[x] = 10e16;
- else
+ }
+ }
+ else {
for (x = xsize * ysize - 1; x >= 0; x--) {
- if (rectmove[x] == 0)
+ if (rectmove[x] == 0) {
rectz[x] = zbufrect[x];
- else
+ }
+ else {
rectz[x] = 10e16;
+ }
}
+ }
/* clear drawing buffer */
- for (x = xsize * ysize - 1; x >= 0; x--)
+ for (x = xsize * ysize - 1; x >= 0; x--) {
rectdraw[x].colpoin = NULL;
+ }
dimg = imgrect;
dm = rectmove;
@@ -790,12 +822,15 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
v3, speedfac * dz2[4] + jfx + 1.0f, speedfac * dz2[5] + jfy + 1.0f, *dz);
ARRAY_SET_ITEMS(v4, speedfac * dz2[0] + jfx, speedfac * dz2[1] + jfy + 1.0f, *dz);
}
- if (*dm == 255)
+ if (*dm == 255) {
col.alpha = 1.0f;
- else if (*dm < 2)
+ }
+ else if (*dm < 2) {
col.alpha = 0.0f;
- else
+ }
+ else {
col.alpha = ((float)*dm) / 255.0f;
+ }
col.colpoin = dimg;
zbuf_fill_in_rgba(&zspan, &col, v1, v2, v3, v4);
@@ -858,7 +893,8 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
MEM_freeN(rectvz);
MEM_freeN(rectweight);
MEM_freeN(rectmax);
- if (minvecbufrect)
+ if (minvecbufrect) {
MEM_freeN(vecbufrect); /* rects were swapped! */
+ }
zbuf_free_span(&zspan);
}
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index fcf6a2a731d..5c82fe7db2f 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -82,8 +82,9 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
{
float *buffer = this->m_outputBuffer;
float *depthbuffer = this->m_depthBuffer;
- if (!buffer)
+ if (!buffer) {
return;
+ }
const int x1 = rect->xmin;
const int y1 = rect->ymin;
const int x2 = rect->xmax;
@@ -149,8 +150,9 @@ void ViewerOperation::initImage()
ibuf->x = getWidth();
ibuf->y = getHeight();
/* zero size can happen if no image buffers exist to define a sensible resolution */
- if (ibuf->x > 0 && ibuf->y > 0)
+ if (ibuf->x > 0 && ibuf->y > 0) {
imb_addrectfloatImBuf(ibuf);
+ }
ima->ok = IMA_OK_LOADED;
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index 29c3b6d8075..9a6239ca32e 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -53,8 +53,9 @@ class ViewerOperation : public NodeOperation {
void executeRegion(rcti *rect, unsigned int tileNumber);
bool isOutputOperation(bool /*rendering*/) const
{
- if (G.background)
+ if (G.background) {
return false;
+ }
return isActiveViewerOutput();
}
void setImage(Image *image)
diff --git a/source/blender/compositor/operations/COM_WrapOperation.cpp b/source/blender/compositor/operations/COM_WrapOperation.cpp
index e55f63f7d73..c25e8ba897c 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.cpp
+++ b/source/blender/compositor/operations/COM_WrapOperation.cpp
@@ -25,19 +25,23 @@ WrapOperation::WrapOperation(DataType datatype) : ReadBufferOperation(datatype)
inline float WrapOperation::getWrappedOriginalXPos(float x)
{
- if (this->getWidth() == 0)
+ if (this->getWidth() == 0) {
return 0;
- while (x < 0)
+ }
+ while (x < 0) {
x += this->m_width;
+ }
return fmodf(x, this->getWidth());
}
inline float WrapOperation::getWrappedOriginalYPos(float y)
{
- if (this->getHeight() == 0)
+ if (this->getHeight() == 0) {
return 0;
- while (y < 0)
+ }
+ while (y < 0) {
y += this->m_height;
+ }
return fmodf(y, this->getHeight());
}
@@ -49,7 +53,7 @@ void WrapOperation::executePixelSampled(float output[4], float x, float y, Pixel
MemoryBufferExtend extend_x = COM_MB_CLIP, extend_y = COM_MB_CLIP;
switch (m_wrappingType) {
case CMP_NODE_WRAP_NONE:
- //Intentionally empty, originalXPos and originalYPos have been set before
+ // Intentionally empty, originalXPos and originalYPos have been set before
break;
case CMP_NODE_WRAP_X:
// wrap only on the x-axis
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
index 222f42e8241..767280e2cd2 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
@@ -97,7 +97,7 @@ void ZCombineOperation::deinitExecution()
// MASK combine
ZCombineMaskOperation::ZCombineMaskOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE); //mask
+ this->addInputSocket(COM_DT_VALUE); // mask
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
diff --git a/source/blender/datatoc/datatoc.c b/source/blender/datatoc/datatoc.c
index 7a180b0912d..6fe2650d66c 100644
--- a/source/blender/datatoc/datatoc.c
+++ b/source/blender/datatoc/datatoc.c
@@ -80,8 +80,9 @@ int main(int argc, char **argv)
argv_len = (int)strlen(argv[1]);
for (i = 0; i < argv_len; i++) {
- if (argv[1][i] == '.')
+ if (argv[1][i] == '.') {
argv[1][i] = '_';
+ }
}
fpout = fopen(argv[2], "w");
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index e30b77ea742..aee925ad8f8 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -37,6 +37,7 @@ set(INC_SYS
set(SRC
intern/builder/deg_builder.cc
+ intern/builder/deg_builder_cache.cc
intern/builder/deg_builder_cycle.cc
intern/builder/deg_builder_map.cc
intern/builder/deg_builder_nodes.cc
@@ -82,6 +83,7 @@ set(SRC
DEG_depsgraph_query.h
intern/builder/deg_builder.h
+ intern/builder/deg_builder_cache.h
intern/builder/deg_builder_cycle.h
intern/builder/deg_builder_map.h
intern/builder/deg_builder_nodes.h
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index ef36dec6f34..b8e0ba51019 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -26,6 +26,7 @@
#include <cstring>
#include "DNA_anim_types.h"
+#include "DNA_armature_types.h"
#include "DNA_layer_types.h"
#include "DNA_ID.h"
#include "DNA_object_types.h"
@@ -34,6 +35,8 @@
#include "BLI_ghash.h"
#include "BLI_stack.h"
+#include "BKE_action.h"
+
extern "C" {
#include "BKE_animsys.h"
}
@@ -41,6 +44,7 @@ extern "C" {
#include "intern/depsgraph.h"
#include "intern/depsgraph_tag.h"
#include "intern/depsgraph_type.h"
+#include "intern/builder/deg_builder_cache.h"
#include "intern/eval/deg_eval_copy_on_write.h"
#include "intern/node/deg_node.h"
#include "intern/node/deg_node_id.h"
@@ -51,70 +55,81 @@ extern "C" {
namespace DEG {
+bool deg_check_base_in_depsgraph(const Depsgraph *graph, Base *base)
+{
+ Object *object_orig = base->base_orig->object;
+ IDNode *id_node = graph->find_id_node(&object_orig->id);
+ if (id_node == NULL) {
+ return false;
+ }
+ return id_node->has_base;
+}
+
/*******************************************************************************
* Base class for builders.
*/
-namespace {
-
-struct VisibilityCheckData {
- eEvaluationMode eval_mode;
- bool is_visibility_animated;
-};
+DepsgraphBuilder::DepsgraphBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache)
+ : bmain_(bmain), graph_(graph), cache_(cache)
+{
+}
-void visibility_animated_check_cb(ID * /*id*/, FCurve *fcu, void *user_data)
+bool DepsgraphBuilder::need_pull_base_into_graph(Base *base)
{
- VisibilityCheckData *data = reinterpret_cast<VisibilityCheckData *>(user_data);
- if (data->is_visibility_animated) {
- return;
+ /* Simple check: enabled bases are always part of dependency graph. */
+ const int base_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT :
+ BASE_ENABLED_RENDER;
+ if (base->flag & base_flag) {
+ return true;
}
- if (data->eval_mode == DAG_EVAL_VIEWPORT) {
- if (STREQ(fcu->rna_path, "hide_viewport")) {
- data->is_visibility_animated = true;
- }
+ /* More involved check: since we don't support dynamic changes in dependency graph topology and
+ * all visible objects are to be part of dependency graph, we pull all objects which has animated
+ * visibility. */
+ Object *object = base->object;
+ AnimatedPropertyID property_id;
+ if (graph_->mode == DAG_EVAL_VIEWPORT) {
+ property_id = AnimatedPropertyID(&object->id, &RNA_Object, "hide_viewport");
}
- else if (data->eval_mode == DAG_EVAL_RENDER) {
- if (STREQ(fcu->rna_path, "hide_render")) {
- data->is_visibility_animated = true;
- }
+ else if (graph_->mode == DAG_EVAL_RENDER) {
+ property_id = AnimatedPropertyID(&object->id, &RNA_Object, "hide_render");
}
-}
-
-bool is_object_visibility_animated(const Depsgraph *graph, Object *object)
-{
- AnimData *anim_data = BKE_animdata_from_id(&object->id);
- if (anim_data == NULL) {
+ else {
+ BLI_assert(!"Unknown evaluation mode.");
return false;
}
- VisibilityCheckData data;
- data.eval_mode = graph->mode;
- data.is_visibility_animated = false;
- BKE_fcurves_id_cb(&object->id, visibility_animated_check_cb, &data);
- return data.is_visibility_animated;
+ return cache_->isPropertyAnimated(&object->id, property_id);
}
-} // namespace
-
-bool deg_check_base_available_for_build(const Depsgraph *graph, Base *base)
+bool DepsgraphBuilder::check_pchan_has_bbone(Object *object, const bPoseChannel *pchan)
{
- const int base_flag = (graph->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT :
- BASE_ENABLED_RENDER;
- if (base->flag & base_flag) {
- return true;
+ BLI_assert(object->type == OB_ARMATURE);
+ if (pchan->bone == NULL) {
+ return false;
}
- if (is_object_visibility_animated(graph, base->object)) {
+ /* We don't really care whether segments are higher than 1 due to static user input (as in,
+ * rigger entered value like 3 manually), or due to animation. In either way we need to create
+ * special evaluation. */
+ if (pchan->bone->segments > 1) {
return true;
}
- return false;
+ bArmature *armature = static_cast<bArmature *>(object->data);
+ AnimatedPropertyID property_id(&armature->id, &RNA_Bone, pchan->bone, "bbone_segments");
+ return cache_->isPropertyAnimated(&armature->id, property_id);
}
-DepsgraphBuilder::DepsgraphBuilder(Main *bmain, Depsgraph *graph) : bmain_(bmain), graph_(graph)
+bool DepsgraphBuilder::check_pchan_has_bbone_segments(Object *object, const bPoseChannel *pchan)
{
+ /* Proxies don't have BONE_SEGMENTS */
+ if (ID_IS_LINKED(object) && object->proxy_from != NULL) {
+ return false;
+ }
+ return check_pchan_has_bbone(object, pchan);
}
-bool DepsgraphBuilder::need_pull_base_into_graph(Base *base)
+bool DepsgraphBuilder::check_pchan_has_bbone_segments(Object *object, const char *bone_name)
{
- return deg_check_base_available_for_build(graph_, base);
+ const bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
+ return check_pchan_has_bbone_segments(object, pchan);
}
/*******************************************************************************
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.h b/source/blender/depsgraph/intern/builder/deg_builder.h
index 310944f2f28..224e3212d57 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder.h
@@ -23,26 +23,35 @@
#pragma once
+struct bPoseChannel;
struct Base;
struct Main;
+struct Object;
namespace DEG {
struct Depsgraph;
+class DepsgraphBuilderCache;
class DepsgraphBuilder {
public:
- bool need_pull_base_into_graph(struct Base *base);
+ bool need_pull_base_into_graph(Base *base);
+
+ bool check_pchan_has_bbone(Object *object, const bPoseChannel *pchan);
+ bool check_pchan_has_bbone_segments(Object *object, const bPoseChannel *pchan);
+ bool check_pchan_has_bbone_segments(Object *object, const char *bone_name);
protected:
- DepsgraphBuilder(Main *bmain, Depsgraph *graph);
+ /* NOTE: The builder does NOT take ownership over any of those resources. */
+ DepsgraphBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache);
/* State which never changes, same for the whole builder time. */
Main *bmain_;
Depsgraph *graph_;
+ DepsgraphBuilderCache *cache_;
};
-bool deg_check_base_available_for_build(const Depsgraph *graph, Base *base);
-void deg_graph_build_finalize(struct Main *bmain, struct Depsgraph *graph);
+bool deg_check_base_in_depsgraph(const Depsgraph *graph, Base *base);
+void deg_graph_build_finalize(Main *bmain, Depsgraph *graph);
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
new file mode 100644
index 00000000000..3df707e92c1
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc
@@ -0,0 +1,186 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#include "intern/builder/deg_builder_cache.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_anim_types.h"
+
+#include "BLI_utildefines.h"
+
+extern "C" {
+#include "BKE_animsys.h"
+}
+
+namespace DEG {
+
+/* Animated property storage. */
+
+AnimatedPropertyID::AnimatedPropertyID() : data(NULL), property_rna(NULL)
+{
+}
+
+AnimatedPropertyID::AnimatedPropertyID(const PointerRNA *pointer_rna,
+ const PropertyRNA *property_rna)
+ : AnimatedPropertyID(*pointer_rna, property_rna)
+{
+}
+
+AnimatedPropertyID::AnimatedPropertyID(const PointerRNA &pointer_rna,
+ const PropertyRNA *property_rna)
+ : data(pointer_rna.data), property_rna(property_rna)
+{
+}
+
+AnimatedPropertyID::AnimatedPropertyID(ID *id, StructRNA *type, const char *property_name)
+ : data(id)
+{
+ property_rna = RNA_struct_type_find_property(type, property_name);
+}
+
+AnimatedPropertyID::AnimatedPropertyID(ID * /*id*/,
+ StructRNA *type,
+ void *data,
+ const char *property_name)
+ : data(data)
+{
+ property_rna = RNA_struct_type_find_property(type, property_name);
+}
+
+bool AnimatedPropertyID::operator<(const AnimatedPropertyID &other) const
+{
+ if (data < other.data) {
+ return true;
+ }
+ else if (data == other.data) {
+ return property_rna < other.property_rna;
+ }
+ return false;
+}
+
+namespace {
+
+struct AnimatedPropertyCallbackData {
+ PointerRNA pointer_rna;
+ AnimatedPropertyStorage *animated_property_storage;
+ DepsgraphBuilderCache *builder_cache;
+};
+
+void animated_property_cb(ID * /*id*/, FCurve *fcurve, void *data_v)
+{
+ if (fcurve->rna_path == NULL || fcurve->rna_path[0] == '\0') {
+ return;
+ }
+ AnimatedPropertyCallbackData *data = static_cast<AnimatedPropertyCallbackData *>(data_v);
+ /* Resolve property. */
+ PointerRNA pointer_rna;
+ PropertyRNA *property_rna = NULL;
+ if (!RNA_path_resolve_property(
+ &data->pointer_rna, fcurve->rna_path, &pointer_rna, &property_rna)) {
+ return;
+ }
+ /* Get storage for the ID.
+ * This is needed to deal with cases when nested datablock is animated by its parent. */
+ AnimatedPropertyStorage *animated_property_storage = data->animated_property_storage;
+ if (pointer_rna.id.data != data->pointer_rna.id.data) {
+ animated_property_storage = data->builder_cache->ensureAnimatedPropertyStorage(
+ reinterpret_cast<ID *>(pointer_rna.id.data));
+ }
+ /* Set the property as animated. */
+ animated_property_storage->tagPropertyAsAnimated(&pointer_rna, property_rna);
+}
+
+} // namespace
+
+AnimatedPropertyStorage::AnimatedPropertyStorage() : is_fully_initialized(false)
+{
+}
+
+void AnimatedPropertyStorage::initializeFromID(DepsgraphBuilderCache *builder_cache, ID *id)
+{
+ AnimatedPropertyCallbackData data;
+ RNA_id_pointer_create(id, &data.pointer_rna);
+ data.animated_property_storage = this;
+ data.builder_cache = builder_cache;
+ BKE_fcurves_id_cb(id, animated_property_cb, &data);
+}
+
+void AnimatedPropertyStorage::tagPropertyAsAnimated(const AnimatedPropertyID &property_id)
+{
+ animated_properties_set.insert(property_id);
+}
+
+void AnimatedPropertyStorage::tagPropertyAsAnimated(const PointerRNA *pointer_rna,
+ const PropertyRNA *property_rna)
+{
+ tagPropertyAsAnimated(AnimatedPropertyID(pointer_rna, property_rna));
+}
+
+bool AnimatedPropertyStorage::isPropertyAnimated(const AnimatedPropertyID &property_id)
+{
+ return animated_properties_set.find(property_id) != animated_properties_set.end();
+}
+
+bool AnimatedPropertyStorage::isPropertyAnimated(const PointerRNA *pointer_rna,
+ const PropertyRNA *property_rna)
+{
+ return isPropertyAnimated(AnimatedPropertyID(pointer_rna, property_rna));
+}
+
+/* Builder cache itself. */
+
+DepsgraphBuilderCache::DepsgraphBuilderCache()
+{
+}
+
+DepsgraphBuilderCache::~DepsgraphBuilderCache()
+{
+ for (AnimatedPropertyStorageMap::value_type &iter : animated_property_storage_map_) {
+ AnimatedPropertyStorage *animated_property_storage = iter.second;
+ OBJECT_GUARDED_DELETE(animated_property_storage, AnimatedPropertyStorage);
+ }
+}
+
+AnimatedPropertyStorage *DepsgraphBuilderCache::ensureAnimatedPropertyStorage(ID *id)
+{
+ AnimatedPropertyStorageMap::iterator it = animated_property_storage_map_.find(id);
+ if (it != animated_property_storage_map_.end()) {
+ return it->second;
+ }
+ AnimatedPropertyStorage *animated_property_storage = OBJECT_GUARDED_NEW(AnimatedPropertyStorage);
+ animated_property_storage_map_.insert(make_pair(id, animated_property_storage));
+ return animated_property_storage;
+}
+
+AnimatedPropertyStorage *DepsgraphBuilderCache::ensureInitializedAnimatedPropertyStorage(ID *id)
+{
+ AnimatedPropertyStorage *animated_property_storage = ensureAnimatedPropertyStorage(id);
+ if (!animated_property_storage->is_fully_initialized) {
+ animated_property_storage->initializeFromID(this, id);
+ animated_property_storage->is_fully_initialized = true;
+ }
+ return animated_property_storage;
+}
+
+} // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.h b/source/blender/depsgraph/intern/builder/deg_builder_cache.h
new file mode 100644
index 00000000000..949020e3a81
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.h
@@ -0,0 +1,103 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2018 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "intern/depsgraph_type.h"
+
+#include "RNA_access.h"
+
+struct ID;
+struct PointerRNA;
+struct PropertyRNA;
+
+namespace DEG {
+
+class DepsgraphBuilderCache;
+
+/* Identifier for animated property. */
+class AnimatedPropertyID {
+ public:
+ AnimatedPropertyID();
+ AnimatedPropertyID(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
+ AnimatedPropertyID(const PointerRNA &pointer_rna, const PropertyRNA *property_rna);
+ AnimatedPropertyID(ID *id, StructRNA *type, const char *property_name);
+ AnimatedPropertyID(ID *id, StructRNA *type, void *data, const char *property_name);
+
+ bool operator<(const AnimatedPropertyID &other) const;
+
+ /* Corresponds to PointerRNA.data. */
+ void *data;
+ const PropertyRNA *property_rna;
+};
+
+class AnimatedPropertyStorage {
+ public:
+ AnimatedPropertyStorage();
+
+ void initializeFromID(DepsgraphBuilderCache *builder_cache, ID *id);
+
+ void tagPropertyAsAnimated(const AnimatedPropertyID &property_id);
+ void tagPropertyAsAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
+
+ bool isPropertyAnimated(const AnimatedPropertyID &property_id);
+ bool isPropertyAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
+
+ /* The storage is fully initialized from all F-Curves from corresponding ID. */
+ bool is_fully_initialized;
+
+ /* indexed by PointerRNA.data. */
+ set<AnimatedPropertyID> animated_properties_set;
+};
+
+typedef map<ID *, AnimatedPropertyStorage *> AnimatedPropertyStorageMap;
+
+/* Cached data which can be re-used by multiple builders. */
+class DepsgraphBuilderCache {
+ public:
+ DepsgraphBuilderCache();
+ ~DepsgraphBuilderCache();
+
+ /* Makes sure storage for animated properties exists and initialized for the given ID. */
+ AnimatedPropertyStorage *ensureAnimatedPropertyStorage(ID *id);
+ AnimatedPropertyStorage *ensureInitializedAnimatedPropertyStorage(ID *id);
+
+ /* Shortcuts to go through ensureInitializedAnimatedPropertyStorage and its
+ * isPropertyAnimated.
+ *
+ * NOTE: Avoid using for multiple subsequent lookups, query for the storage once, and then query
+ * the storage.
+ *
+ * TODO(sergey): Technically, this makes this class something else than just a cache, but what is
+ * the better name? */
+ template<typename... Args> bool isPropertyAnimated(ID *id, Args... args)
+ {
+ AnimatedPropertyStorage *animated_property_storage = ensureInitializedAnimatedPropertyStorage(
+ id);
+ return animated_property_storage->isPropertyAnimated(args...);
+ }
+
+ AnimatedPropertyStorageMap animated_property_storage_map_;
+};
+
+} // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
index af5c4e7130b..d11a60b77dd 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
@@ -182,20 +182,16 @@ void solve_cycles(CyclesSolverState *state)
OperationNode *to = (OperationNode *)rel->to;
eCyclicCheckVisitedState to_state = get_node_visited_state(to);
if (to_state == NODE_IN_STACK) {
- printf("Dependency cycle detected:\n");
- printf(" '%s' depends on '%s' through '%s'\n",
- to->full_identifier().c_str(),
- node->full_identifier().c_str(),
- rel->name);
+ string cycle_str = " " + to->full_identifier() + " depends on\n " +
+ node->full_identifier() + " via '" + rel->name + "'\n";
StackEntry *current = entry;
while (current->node != to) {
BLI_assert(current != NULL);
- printf(" '%s' depends on '%s' through '%s'\n",
- current->node->full_identifier().c_str(),
- current->from->node->full_identifier().c_str(),
- current->via_relation->name);
+ cycle_str += " " + current->from->node->full_identifier() + " via '" +
+ current->via_relation->name + "'\n";
current = current->from;
}
+ printf("Dependency cycle detected:\n%s", cycle_str.c_str());
Relation *sacrificial_relation = select_relation_to_murder(rel, entry);
sacrificial_relation->flag |= RELATION_FLAG_CYCLIC;
++state->num_cycles;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index b37ecb45ac8..b6822a89093 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -65,6 +65,7 @@ extern "C" {
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_animsys.h"
+#include "BKE_cachefile.h"
#include "BKE_collection.h"
#include "BKE_constraint.h"
#include "BKE_curve.h"
@@ -129,8 +130,10 @@ void free_copy_on_write_datablock(void *id_info_v)
/* **** General purpose functions **** */
-DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph)
- : DepsgraphBuilder(bmain, graph),
+DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain,
+ Depsgraph *graph,
+ DepsgraphBuilderCache *cache)
+ : DepsgraphBuilder(bmain, graph, cache),
scene_(NULL),
view_layer_(NULL),
view_layer_index_(-1),
@@ -335,7 +338,7 @@ void DepsgraphNodeBuilder::begin_build()
entry_tag.name = op_node->name;
entry_tag.name_tag = op_node->name_tag;
saved_entry_tags_.push_back(entry_tag);
- };
+ }
GSET_FOREACH_END();
/* Make sure graph has no nodes left from previous state. */
@@ -526,6 +529,7 @@ void DepsgraphNodeBuilder::build_object(int base_index,
if (id_node->linked_state == DEG_ID_LINKED_DIRECTLY) {
id_node->is_directly_visible |= is_visible;
}
+ id_node->has_base |= (base_index != -1);
return;
}
/* Create ID node for object and begin init. */
@@ -538,6 +542,7 @@ void DepsgraphNodeBuilder::build_object(int base_index,
else {
id_node->is_directly_visible = is_visible;
}
+ id_node->has_base |= (base_index != -1);
/* Various flags, flushing from bases/collections. */
build_object_flags(base_index, object, linked_state);
/* Transform. */
@@ -1177,12 +1182,6 @@ void DepsgraphNodeBuilder::build_object_data_geometry(Object *object, bool is_ob
op_node->set_as_exit();
/* Materials. */
if (object->totcol != 0) {
- if (object->type == OB_MESH) {
- add_operation_node(&object->id,
- NodeType::SHADING,
- OperationCode::SHADING,
- function_bind(BKE_object_eval_update_shading, _1, object_cow));
- }
for (int a = 1; a <= object->totcol; a++) {
Material *ma = give_current_material(object, a);
if (ma != NULL) {
@@ -1441,7 +1440,7 @@ void DepsgraphNodeBuilder::build_compositor(Scene *scene)
/* For now, just a plain wrapper? */
// TODO: create compositing component?
// XXX: component type undefined!
- //graph->get_node(&scene->id, NULL, NodeType::COMPOSITING, NULL);
+ // graph->get_node(&scene->id, NULL, NodeType::COMPOSITING, NULL);
/* for now, nodetrees are just parameters; compositing occurs in internals
* of renderer... */
@@ -1471,11 +1470,16 @@ void DepsgraphNodeBuilder::build_cachefile(CacheFile *cache_file)
return;
}
ID *cache_file_id = &cache_file->id;
+ add_id_node(cache_file_id);
+ CacheFile *cache_file_cow = get_cow_datablock(cache_file);
/* Animation, */
build_animdata(cache_file_id);
build_parameters(cache_file_id);
/* Cache evaluation itself. */
- add_operation_node(cache_file_id, NodeType::CACHE, OperationCode::FILE_CACHE_UPDATE);
+ add_operation_node(cache_file_id,
+ NodeType::CACHE,
+ OperationCode::FILE_CACHE_UPDATE,
+ function_bind(BKE_cachefile_eval, bmain_, _1, cache_file_cow));
}
void DepsgraphNodeBuilder::build_mask(Mask *mask)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index d88f5a792e0..cf7cf1a62d8 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -69,6 +69,7 @@ namespace DEG {
struct ComponentNode;
struct Depsgraph;
+class DepsgraphBuilderCache;
struct IDNode;
struct Node;
struct OperationNode;
@@ -76,7 +77,7 @@ struct TimeSourceNode;
class DepsgraphNodeBuilder : public DepsgraphBuilder {
public:
- DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph);
+ DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache);
~DepsgraphNodeBuilder();
/* For given original ID get ID which is created by CoW system. */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
index 6f141bd7222..979e1a02e71 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
@@ -231,7 +231,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible)
function_bind(BKE_pose_bone_done, _1, object_cow, pchan_index));
/* B-Bone shape computation - the real last step if present. */
- if (pchan->bone != NULL && pchan->bone->segments > 1) {
+ if (check_pchan_has_bbone(object, pchan)) {
op_node = add_operation_node(
&object->id,
NodeType::BONE,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
index 6d979724e7e..95c50c4f44e 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
@@ -95,14 +95,14 @@ bool RootPChanMap::has_common_root(const char *bone1, const char *bone2)
{
/* Ensure that both are in the map... */
if (BLI_ghash_haskey(map_, bone1) == false) {
- //fprintf("RootPChanMap: bone1 '%s' not found (%s => %s)\n", bone1, bone1, bone2);
- //print_debug();
+ // fprintf("RootPChanMap: bone1 '%s' not found (%s => %s)\n", bone1, bone1, bone2);
+ // print_debug();
return false;
}
if (BLI_ghash_haskey(map_, bone2) == false) {
- //fprintf("RootPChanMap: bone2 '%s' not found (%s => %s)\n", bone2, bone1, bone2);
- //print_debug();
+ // fprintf("RootPChanMap: bone2 '%s' not found (%s => %s)\n", bone2, bone1, bone2);
+ // print_debug();
return false;
}
@@ -116,13 +116,13 @@ bool RootPChanMap::has_common_root(const char *bone1, const char *bone2)
const char *v2 = (const char *)BLI_gsetIterator_getKey(&it2);
if (strcmp(v1, v2) == 0) {
- //fprintf("RootPchanMap: %s in common for %s => %s\n", v1, bone1, bone2);
+ // fprintf("RootPchanMap: %s in common for %s => %s\n", v1, bone1, bone2);
return true;
}
}
}
- //fprintf("RootPChanMap: No common root found (%s => %s)\n", bone1, bone2);
+ // fprintf("RootPChanMap: No common root found (%s => %s)\n", bone1, bone2);
return false;
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 87a8875f819..d3fd16d889f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -196,21 +196,12 @@ static OperationCode bone_target_opcode(ID *target,
return OperationCode::BONE_DONE;
}
-static bool bone_has_segments(Object *object, const char *bone_name)
-{
- /* Proxies don't have BONE_SEGMENTS */
- if (ID_IS_LINKED(object) && object->proxy_from != NULL) {
- return false;
- }
- /* Only B-Bones have segments. */
- bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
- return pchan && pchan->bone && pchan->bone->segments > 1;
-}
-
/* **** General purpose functions **** */
-DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph)
- : DepsgraphBuilder(bmain, graph), scene_(NULL), rna_node_query_(graph)
+DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain,
+ Depsgraph *graph,
+ DepsgraphBuilderCache *cache)
+ : DepsgraphBuilder(bmain, graph, cache), scene_(NULL), rna_node_query_(graph, this)
{
}
@@ -1017,7 +1008,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
}
/* if needs bbone shape, reference the segment computation */
if (BKE_constraint_target_uses_bbone(con, ct) &&
- bone_has_segments(ct->tar, ct->subtarget)) {
+ check_pchan_has_bbone_segments(ct->tar, ct->subtarget)) {
opcode = OperationCode::BONE_SEGMENTS;
}
OperationKey target_key(&ct->tar->id, NodeType::BONE, ct->subtarget, opcode);
@@ -1336,25 +1327,24 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu)
fcu->rna_path ? fcu->rna_path : "",
fcu->array_index);
const char *rna_path = fcu->rna_path ? fcu->rna_path : "";
- if (GS(id->name) == ID_AR && strstr(rna_path, "bones[")) {
+ if (GS(id->name) == ID_AR && STRPREFIX(rna_path, "bones[")) {
/* Drivers on armature-level bone settings (i.e. bbone stuff),
* which will affect the evaluation of corresponding pose bones. */
- IDNode *arm_node = graph_->find_id_node(id);
char *bone_name = BLI_str_quoted_substrN(rna_path, "bones[");
- if (arm_node != NULL && bone_name != NULL) {
+ if (bone_name != NULL) {
/* Find objects which use this, and make their eval callbacks
* depend on this. */
- for (Relation *rel : arm_node->outlinks) {
- IDNode *to_node = (IDNode *)rel->to;
- /* We only care about objects with pose data which use this. */
+ for (IDNode *to_node : graph_->id_nodes) {
if (GS(to_node->id_orig->name) == ID_OB) {
Object *object = (Object *)to_node->id_orig;
- // NOTE: object->pose may be NULL
- bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
- if (pchan != NULL) {
- OperationKey bone_key(
- &object->id, NodeType::BONE, pchan->name, OperationCode::BONE_LOCAL);
- add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
+ /* We only care about objects with pose data which use this. */
+ if (object->data == id && object->pose != NULL) {
+ bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
+ if (pchan != NULL) {
+ OperationKey bone_key(
+ &object->id, NodeType::BONE, pchan->name, OperationCode::BONE_LOCAL);
+ add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
+ }
}
}
}
@@ -1411,27 +1401,34 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
/* Only used targets. */
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
- if (dtar->id == NULL) {
+ ID *target_id = dtar->id;
+ if (target_id == NULL) {
continue;
}
- build_id(dtar->id);
- build_driver_id_property(dtar->id, dtar->rna_path);
- /* Initialize relations coming to proxy_from. */
- Object *proxy_from = NULL;
- if ((GS(dtar->id->name) == ID_OB) && (((Object *)dtar->id)->proxy_from != NULL)) {
- proxy_from = ((Object *)dtar->id)->proxy_from;
- build_id(&proxy_from->id);
+ build_id(target_id);
+ build_driver_id_property(target_id, dtar->rna_path);
+ /* Look up the proxy - matches dtar_id_ensure_proxy_from during evaluation. */
+ Object *object = NULL;
+ if (GS(target_id->name) == ID_OB) {
+ object = (Object *)target_id;
+ if (object->proxy_from != NULL) {
+ /* Redirect the target to the proxy, like in evaluation. */
+ object = object->proxy_from;
+ target_id = &object->id;
+ /* Prepare the redirected target. */
+ build_id(target_id);
+ build_driver_id_property(target_id, dtar->rna_path);
+ }
}
/* Special handling for directly-named bones. */
- if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (((Object *)dtar->id)->type == OB_ARMATURE) &&
+ if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (object && object->type == OB_ARMATURE) &&
(dtar->pchan_name[0])) {
- Object *object = (Object *)dtar->id;
bPoseChannel *target_pchan = BKE_pose_channel_find_name(object->pose, dtar->pchan_name);
if (target_pchan == NULL) {
continue;
}
OperationKey variable_key(
- dtar->id, NodeType::BONE, target_pchan->name, OperationCode::BONE_DONE);
+ target_id, NodeType::BONE, target_pchan->name, OperationCode::BONE_DONE);
if (is_same_bone_dependency(variable_key, self_key)) {
continue;
}
@@ -1439,17 +1436,17 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
}
else if (dtar->flag & DTAR_FLAG_STRUCT_REF) {
/* Get node associated with the object's transforms. */
- if (dtar->id == id) {
+ if (target_id == id) {
/* Ignore input dependency if we're driving properties of
* the same ID, otherwise we'll be ending up in a cyclic
* dependency here. */
continue;
}
- OperationKey target_key(dtar->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL);
+ OperationKey target_key(target_id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL);
add_relation(target_key, driver_key, "Target -> Driver");
}
else if (dtar->rna_path != NULL && dtar->rna_path[0] != '\0') {
- RNAPathKey variable_exit_key(dtar->id, dtar->rna_path, RNAPointerSource::EXIT);
+ RNAPathKey variable_exit_key(target_id, dtar->rna_path, RNAPointerSource::EXIT);
if (RNA_pointer_is_null(&variable_exit_key.ptr)) {
continue;
}
@@ -1458,12 +1455,6 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
continue;
}
add_relation(variable_exit_key, driver_key, "RNA Target -> Driver");
- if (proxy_from != NULL) {
- RNAPathKey proxy_from_variable_key(
- &proxy_from->id, dtar->rna_path, RNAPointerSource::EXIT);
- RNAPathKey variable_entry_key(dtar->id, dtar->rna_path, RNAPointerSource::ENTRY);
- add_relation(proxy_from_variable_key, variable_entry_key, "Proxy From -> Variable");
- }
}
else {
/* If rna_path is NULL, and DTAR_FLAG_STRUCT_REF isn't set, this
@@ -1904,12 +1895,6 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
Material *ma = give_current_material(object, a);
if (ma != NULL) {
build_material(ma);
-
- if (object->type == OB_MESH) {
- OperationKey material_key(&ma->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE);
- OperationKey shading_key(&object->id, NodeType::SHADING, OperationCode::SHADING);
- add_relation(material_key, shading_key, "Material Update");
- }
}
}
}
@@ -1923,12 +1908,6 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
OperationKey obdata_ubereval_key(
&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
add_relation(geom_init_key, obdata_ubereval_key, "Object Geometry UberEval");
- if (object->totcol != 0 && object->type == OB_MESH) {
- ComponentKey object_shading_key(&object->id, NodeType::SHADING);
- Relation *rel = add_relation(
- obdata_ubereval_key, object_shading_key, "Object Geometry batch Update");
- rel->flag |= RELATION_FLAG_NO_FLUSH;
- }
}
if (object->type == OB_MBALL) {
Object *mom = BKE_mball_basis_find(scene_, object);
@@ -2243,6 +2222,14 @@ void DepsgraphRelationBuilder::build_cachefile(CacheFile *cache_file)
ComponentKey datablock_key(&cache_file->id, NodeType::CACHE);
add_relation(animation_key, datablock_key, "Datablock Animation");
}
+
+ /* Cache file updates */
+ if (cache_file->is_sequence) {
+ OperationKey cache_update_key(
+ &cache_file->id, NodeType::CACHE, OperationCode::FILE_CACHE_UPDATE);
+ TimeSourceKey time_src_key;
+ add_relation(time_src_key, cache_update_key, "TimeSrc -> Cache File Eval");
+ }
}
void DepsgraphRelationBuilder::build_mask(Mask *mask)
@@ -2350,7 +2337,8 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node)
continue;
}
int rel_flag = (RELATION_FLAG_NO_FLUSH | RELATION_FLAG_GODMODE);
- if (id_type == ID_ME && comp_node->type == NodeType::GEOMETRY) {
+ if ((id_type == ID_ME && comp_node->type == NodeType::GEOMETRY) ||
+ (id_type == ID_CF && comp_node->type == NodeType::CACHE)) {
rel_flag &= ~RELATION_FLAG_NO_FLUSH;
}
/* Notes on exceptions:
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index 5b2d34a270c..90bdb9bae65 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -86,6 +86,7 @@ namespace DEG {
struct ComponentNode;
struct DepsNodeHandle;
struct Depsgraph;
+class DepsgraphBuilderCache;
struct IDNode;
struct Node;
struct OperationNode;
@@ -155,7 +156,7 @@ struct RNAPathKey {
class DepsgraphRelationBuilder : public DepsgraphBuilder {
public:
- DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph);
+ DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache);
void begin_build();
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index 1d222258449..fadce685d31 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -83,46 +83,34 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
add_relation(init_ik_key, solver_key, "Init IK -> IK Solver");
/* Never cleanup before solver is run. */
add_relation(solver_key, pose_cleanup_key, "IK Solver -> Cleanup", RELATION_FLAG_GODMODE);
+ /* The ITASC solver currently accesses the target transforms in init tree :(
+ * TODO: Fix ITASC and remove this.
+ */
+ bool is_itasc = (object->pose->iksolver == IKSOLVER_ITASC);
+ OperationKey target_dependent_key = is_itasc ? init_ik_key : solver_key;
/* IK target */
/* TODO(sergey): This should get handled as part of the constraint code. */
if (data->tar != NULL) {
- /* TODO(sergey): For until we'll store partial matrices in the
- * depsgraph, we create dependency between target object and pose eval
- * component.
- *
- * This way we ensuring the whole subtree is updated from scratch
- * without need of intermediate matrices. This is an overkill, but good
- * enough for testing IK solver. */
- ComponentKey pose_key(&object->id, NodeType::EVAL_POSE);
+ /* Different object - requires its transform. */
+ if (data->tar != object) {
+ ComponentKey target_key(&data->tar->id, NodeType::TRANSFORM);
+ add_relation(target_key, target_dependent_key, con->name);
+ }
+ /* Subtarget references: */
if ((data->tar->type == OB_ARMATURE) && (data->subtarget[0])) {
- /* TODO(sergey): This is only for until granular update stores
- * intermediate result. */
- if (data->tar != object) {
- /* Different armature - can just read the results. */
- ComponentKey target_key(&data->tar->id, NodeType::BONE, data->subtarget);
- add_relation(target_key, pose_key, con->name);
- }
- else {
- /* Same armature - we'll use the ready state only, just in case
- * this bone is in the chain we're solving. */
- OperationKey target_key(
- &data->tar->id, NodeType::BONE, data->subtarget, OperationCode::BONE_DONE);
- add_relation(target_key, solver_key, con->name);
- }
+ /* Bone - use the final transformation. */
+ OperationKey target_key(
+ &data->tar->id, NodeType::BONE, data->subtarget, OperationCode::BONE_DONE);
+ add_relation(target_key, target_dependent_key, con->name);
}
else if (data->subtarget[0] && ELEM(data->tar->type, OB_MESH, OB_LATTICE)) {
/* Vertex group target. */
/* NOTE: for now, we don't need to represent vertex groups
* separately. */
ComponentKey target_key(&data->tar->id, NodeType::GEOMETRY);
- add_relation(target_key, solver_key, con->name);
+ add_relation(target_key, target_dependent_key, con->name);
add_customdata_mask(data->tar, DEGCustomDataMeshMasks::MaskVert(CD_MASK_MDEFORMVERT));
}
- else {
- /* Standard Object Target. */
- ComponentKey target_key(&data->tar->id, NodeType::TRANSFORM);
- add_relation(target_key, pose_key, con->name);
- }
if (data->tar == object && data->subtarget[0]) {
/* Prevent target's constraints from linking to anything from same
* chain that it controls. */
@@ -132,22 +120,26 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
/* Pole Target. */
/* TODO(sergey): This should get handled as part of the constraint code. */
if (data->poletar != NULL) {
+ /* Different object - requires its transform. */
+ if (data->poletar != object) {
+ ComponentKey target_key(&data->poletar->id, NodeType::TRANSFORM);
+ add_relation(target_key, target_dependent_key, con->name);
+ }
+ /* Subtarget references: */
if ((data->poletar->type == OB_ARMATURE) && (data->polesubtarget[0])) {
- ComponentKey target_key(&data->poletar->id, NodeType::BONE, data->polesubtarget);
- add_relation(target_key, solver_key, con->name);
+ /* Bone - use the final transformation. */
+ OperationKey target_key(
+ &data->poletar->id, NodeType::BONE, data->polesubtarget, OperationCode::BONE_DONE);
+ add_relation(target_key, target_dependent_key, con->name);
}
else if (data->polesubtarget[0] && ELEM(data->poletar->type, OB_MESH, OB_LATTICE)) {
/* Vertex group target. */
/* NOTE: for now, we don't need to represent vertex groups
* separately. */
ComponentKey target_key(&data->poletar->id, NodeType::GEOMETRY);
- add_relation(target_key, solver_key, con->name);
+ add_relation(target_key, target_dependent_key, con->name);
add_customdata_mask(data->poletar, DEGCustomDataMeshMasks::MaskVert(CD_MASK_MDEFORMVERT));
}
- else {
- ComponentKey target_key(&data->poletar->id, NodeType::TRANSFORM);
- add_relation(target_key, solver_key, con->name);
- }
}
DEG_DEBUG_PRINTF((::Depsgraph *)graph_,
BUILD,
@@ -382,7 +374,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
* to done, with transitive reduction removing this one. */
add_relation(bone_ready_key, bone_done_key, "Ready -> Done");
/* B-Bone shape is the real final step after Done if present. */
- if (pchan->bone != NULL && pchan->bone->segments > 1) {
+ if (check_pchan_has_bbone(object, pchan)) {
OperationKey bone_segments_key(
&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_SEGMENTS);
/* B-Bone shape depends on the final position of the bone. */
@@ -442,7 +434,7 @@ void DepsgraphRelationBuilder::build_proxy_rig(Object *object)
add_relation(bone_done_key, pose_cleanup_key, "Bone Done -> Pose Cleanup");
add_relation(bone_done_key, pose_done_key, "Bone Done -> Pose Done", RELATION_FLAG_GODMODE);
/* Make sure bone in the proxy is not done before it's FROM is done. */
- if (pchan->bone && pchan->bone->segments > 1) {
+ if (check_pchan_has_bbone(object, pchan)) {
OperationKey from_bone_segments_key(
&proxy_from->id, NodeType::BONE, pchan->name, OperationCode::BONE_SEGMENTS);
add_relation(from_bone_segments_key,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index 810d3ee3f66..1238cdc70c6 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -45,6 +45,7 @@ extern "C" {
#include "RNA_access.h"
#include "intern/depsgraph.h"
+#include "intern/builder/deg_builder.h"
#include "intern/node/deg_node.h"
#include "intern/node/deg_node_component.h"
#include "intern/node/deg_node_id.h"
@@ -130,8 +131,10 @@ void ghash_id_data_free_func(void *value)
} // namespace
-RNANodeQuery::RNANodeQuery(Depsgraph *depsgraph)
- : depsgraph_(depsgraph), id_data_map_(BLI_ghash_ptr_new("rna node query id data hash"))
+RNANodeQuery::RNANodeQuery(Depsgraph *depsgraph, DepsgraphBuilder *builder)
+ : depsgraph_(depsgraph),
+ builder_(builder),
+ id_data_map_(BLI_ghash_ptr_new("rna node query id data hash"))
{
}
@@ -194,20 +197,20 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
node_identifier.type = NodeType::BONE;
node_identifier.component_name = pchan->name;
/* But B-Bone properties should connect to the actual operation. */
- if (!ELEM(NULL, pchan->bone, prop) && pchan->bone->segments > 1 &&
- STRPREFIX(RNA_property_identifier(prop), "bbone_")) {
+ Object *object = reinterpret_cast<Object *>(node_identifier.id);
+ if (!ELEM(NULL, pchan->bone, prop) && STRPREFIX(RNA_property_identifier(prop), "bbone_") &&
+ builder_->check_pchan_has_bbone_segments(object, pchan)) {
node_identifier.operation_code = OperationCode::BONE_SEGMENTS;
}
}
return node_identifier;
}
else if (ptr->type == &RNA_Bone) {
- const Bone *bone = static_cast<const Bone *>(ptr->data);
- /* Armature-level bone, but it ends up going to bone component
- * anyway. */
- // NOTE: the ID in this case will end up being bArmature.
- node_identifier.type = NodeType::BONE;
- node_identifier.component_name = bone->name;
+ /* Armature-level bone mapped to Armature Eval, and thus Pose Init.
+ * Drivers have special code elsewhere that links them to the pose
+ * bone components, instead of using this generic code. */
+ node_identifier.type = NodeType::PARAMETERS;
+ node_identifier.operation_code = OperationCode::ARMATURE_EVAL;
return node_identifier;
}
else if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.h b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
index e8dbd7fb523..26d7963e0a8 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.h
@@ -36,6 +36,7 @@ namespace DEG {
struct Depsgraph;
struct Node;
class RNANodeQueryIDData;
+class DepsgraphBuilder;
/* For queries which gives operation node or key defines whether we are
* interested in a result of the given property or whether we are linking some
@@ -72,13 +73,14 @@ class RNANodeIdentifier {
* dependency graph which satisfies given RNA pointer or RAN path. */
class RNANodeQuery {
public:
- RNANodeQuery(Depsgraph *depsgraph);
+ RNANodeQuery(Depsgraph *depsgraph, DepsgraphBuilder *builder);
~RNANodeQuery();
Node *find_node(const PointerRNA *ptr, const PropertyRNA *prop, RNAPointerSource source);
protected:
Depsgraph *depsgraph_;
+ DepsgraphBuilder *builder_;
/* Indexed by an ID, returns RNANodeQueryIDData associated with that ID. */
GHash *id_data_map_;
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
index abd3b398cb7..068a04943e6 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -122,8 +122,9 @@ static int deg_debug_node_color_index(const Node *node)
return 5;
case NodeType::OPERATION: {
OperationNode *op_node = (OperationNode *)node;
- if (op_node->is_noop())
+ if (op_node->is_noop()) {
return 8;
+ }
break;
}
@@ -485,16 +486,19 @@ static bool deg_debug_graphviz_is_owner(const Node *node, const Node *other)
switch (node->get_class()) {
case NodeClass::COMPONENT: {
ComponentNode *comp_node = (ComponentNode *)node;
- if (comp_node->owner == other)
+ if (comp_node->owner == other) {
return true;
+ }
break;
}
case NodeClass::OPERATION: {
OperationNode *op_node = (OperationNode *)node;
- if (op_node->owner == other)
+ if (op_node->owner == other) {
return true;
- else if (op_node->owner->owner == other)
+ }
+ else if (op_node->owner->owner == other) {
return true;
+ }
break;
}
default:
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index e4c84264960..dd2979160cd 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -46,6 +46,7 @@ extern "C" {
#include "DEG_depsgraph_build.h"
#include "builder/deg_builder.h"
+#include "builder/deg_builder_cache.h"
#include "builder/deg_builder_cycle.h"
#include "builder/deg_builder_nodes.h"
#include "builder/deg_builder_relations.h"
@@ -238,14 +239,15 @@ void DEG_graph_build_from_view_layer(Depsgraph *graph,
BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1);
BLI_assert(deg_graph->scene == scene);
BLI_assert(deg_graph->view_layer == view_layer);
+ DEG::DepsgraphBuilderCache builder_cache;
/* Generate all the nodes in the graph first */
- DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph);
+ DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache);
node_builder.begin_build();
node_builder.build_view_layer(scene, view_layer, DEG::DEG_ID_LINKED_DIRECTLY);
node_builder.end_build();
/* Hook up relationships between operations - to determine evaluation
* order. */
- DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph);
+ DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache);
relation_builder.begin_build();
relation_builder.build_view_layer(scene, view_layer);
relation_builder.build_copy_on_write_relations();
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc
index e795bed144d..6253d31b8aa 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -237,10 +237,12 @@ void DEG_stats_simple(const Depsgraph *graph,
tot_rels += time_source->inlinks.size();
}
- if (r_relations)
+ if (r_relations) {
*r_relations = tot_rels;
- if (r_outer)
+ }
+ if (r_outer) {
*r_outer = tot_outer;
+ }
}
}
diff --git a/source/blender/depsgraph/intern/depsgraph_query_filter.cc b/source/blender/depsgraph/intern/depsgraph_query_filter.cc
index 987e9330d35..a02ced286eb 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_filter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_filter.cc
@@ -162,7 +162,7 @@ static void deg_filter_remove_unwanted_ids(Depsgraph *graph, GSet *retained_ids)
}
}
-} //namespace DEG
+} // namespace DEG
/* *************************************************** */
/* Graph Filtering API */
diff --git a/source/blender/depsgraph/intern/depsgraph_type.h b/source/blender/depsgraph/intern/depsgraph_type.h
index 51ed31b8e25..cce64116907 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.h
+++ b/source/blender/depsgraph/intern/depsgraph_type.h
@@ -37,6 +37,7 @@
#include <vector>
#include <algorithm>
#include <map>
+#include <set>
#include <unordered_map>
struct Depsgraph;
@@ -48,6 +49,7 @@ namespace DEG {
/* Commonly used types. */
using std::map;
using std::pair;
+using std::set;
using std::string;
using std::unordered_map;
using std::vector;
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 01b712fcd87..2f153e585d3 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -368,8 +368,7 @@ void scene_remove_unused_view_layers(const Depsgraph *depsgraph,
void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *view_layer)
{
ListBase enabled_bases = {NULL, NULL};
- LISTBASE_FOREACH_MUTABLE(Base *, base, &view_layer->object_bases)
- {
+ LISTBASE_FOREACH_MUTABLE (Base *, base, &view_layer->object_bases) {
/* TODO(sergey): Would be cool to optimize this somehow, or make it so
* builder tags bases.
*
@@ -381,7 +380,7 @@ void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *vie
* points to is not yet copied. This is dangerous access from evaluated
* domain to original one, but this is how the entire copy-on-write works:
* it does need to access original for an initial copy. */
- const bool is_object_enabled = deg_check_base_available_for_build(depsgraph, base->base_orig);
+ const bool is_object_enabled = deg_check_base_in_depsgraph(depsgraph, base);
if (is_object_enabled) {
BLI_addtail(&enabled_bases, base);
}
@@ -634,6 +633,40 @@ void update_modifiers_orig_pointers(const Object *object_orig, Object *object_co
&object_orig->modifiers, &object_cow->modifiers, &ModifierData::orig_modifier_data);
}
+void update_nla_strips_orig_pointers(const ListBase *strips_orig, ListBase *strips_cow)
+{
+ NlaStrip *strip_orig = reinterpret_cast<NlaStrip *>(strips_orig->first);
+ NlaStrip *strip_cow = reinterpret_cast<NlaStrip *>(strips_cow->first);
+ while (strip_orig != NULL) {
+ strip_cow->orig_strip = strip_orig;
+ update_nla_strips_orig_pointers(&strip_orig->strips, &strip_cow->strips);
+ strip_cow = strip_cow->next;
+ strip_orig = strip_orig->next;
+ }
+}
+
+void update_nla_tracks_orig_pointers(const ListBase *tracks_orig, ListBase *tracks_cow)
+{
+ NlaTrack *track_orig = reinterpret_cast<NlaTrack *>(tracks_orig->first);
+ NlaTrack *track_cow = reinterpret_cast<NlaTrack *>(tracks_cow->first);
+ while (track_orig != NULL) {
+ update_nla_strips_orig_pointers(&track_orig->strips, &track_cow->strips);
+ track_cow = track_cow->next;
+ track_orig = track_orig->next;
+ }
+}
+
+void update_animation_data_after_copy(const ID *id_orig, ID *id_cow)
+{
+ const AnimData *anim_data_orig = BKE_animdata_from_id(const_cast<ID *>(id_orig));
+ if (anim_data_orig == NULL) {
+ return;
+ }
+ AnimData *anim_data_cow = BKE_animdata_from_id(id_cow);
+ BLI_assert(anim_data_cow != NULL);
+ update_nla_tracks_orig_pointers(&anim_data_orig->nla_tracks, &anim_data_cow->nla_tracks);
+}
+
/* Do some special treatment of data transfer from original ID to it's
* CoW complementary part.
*
@@ -644,6 +677,7 @@ void update_id_after_copy(const Depsgraph *depsgraph,
ID *id_cow)
{
const ID_Type type = GS(id_orig->name);
+ update_animation_data_after_copy(id_orig, id_cow);
switch (type) {
case ID_OB: {
/* Ensure we don't drag someone's else derived mesh to the
@@ -841,6 +875,9 @@ class ModifierDataBackupID {
/* Storage for backed up runtime modifier data. */
typedef map<ModifierDataBackupID, void *> ModifierRuntimeDataBackup;
+/* Storage for backed up pose channel runtime data. */
+typedef map<bPoseChannel *, bPoseChannel_Runtime> PoseChannelRuntimeDataBackup;
+
struct ObjectRuntimeBackup {
ObjectRuntimeBackup() : base_flag(0), base_local_view_bits(0)
{
@@ -853,16 +890,19 @@ struct ObjectRuntimeBackup {
* pointers. */
void init_from_object(Object *object);
void backup_modifier_runtime_data(Object *object);
+ void backup_pose_channel_runtime_data(Object *object);
/* Restore all fields to the given object. */
void restore_to_object(Object *object);
/* NOTE: Will free all runtime data which has not been restored. */
void restore_modifier_runtime_data(Object *object);
+ void restore_pose_channel_runtime_data(Object *object);
Object_Runtime runtime;
short base_flag;
unsigned short base_local_view_bits;
ModifierRuntimeDataBackup modifier_runtime_data;
+ PoseChannelRuntimeDataBackup pose_channel_runtime_data;
};
void ObjectRuntimeBackup::init_from_object(Object *object)
@@ -884,6 +924,8 @@ void ObjectRuntimeBackup::init_from_object(Object *object)
base_local_view_bits = object->base_local_view_bits;
/* Backup tuntime data of all modifiers. */
backup_modifier_runtime_data(object);
+ /* Backup runtime data of all pose channels. */
+ backup_pose_channel_runtime_data(object);
}
inline ModifierDataBackupID create_modifier_data_id(const ModifierData *modifier_data)
@@ -905,6 +947,19 @@ void ObjectRuntimeBackup::backup_modifier_runtime_data(Object *object)
}
}
+void ObjectRuntimeBackup::backup_pose_channel_runtime_data(Object *object)
+{
+ if (object->pose != NULL) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
+ /* This is NULL in Edit mode. */
+ if (pchan->orig_pchan != NULL) {
+ pose_channel_runtime_data[pchan->orig_pchan] = pchan->runtime;
+ BKE_pose_channel_runtime_reset(&pchan->runtime);
+ }
+ }
+ }
+}
+
void ObjectRuntimeBackup::restore_to_object(Object *object)
{
Mesh *mesh_orig = object->runtime.mesh_orig;
@@ -941,6 +996,7 @@ void ObjectRuntimeBackup::restore_to_object(Object *object)
/* Restore modifier's runtime data.
* NOTE: Data of unused modifiers will be freed there. */
restore_modifier_runtime_data(object);
+ restore_pose_channel_runtime_data(object);
}
void ObjectRuntimeBackup::restore_modifier_runtime_data(Object *object)
@@ -967,6 +1023,26 @@ void ObjectRuntimeBackup::restore_modifier_runtime_data(Object *object)
}
}
+void ObjectRuntimeBackup::restore_pose_channel_runtime_data(Object *object)
+{
+ if (object->pose != NULL) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
+ /* This is NULL in Edit mode. */
+ if (pchan->orig_pchan != NULL) {
+ PoseChannelRuntimeDataBackup::iterator runtime_data_iterator =
+ pose_channel_runtime_data.find(pchan->orig_pchan);
+ if (runtime_data_iterator != pose_channel_runtime_data.end()) {
+ pchan->runtime = runtime_data_iterator->second;
+ pose_channel_runtime_data.erase(runtime_data_iterator);
+ }
+ }
+ }
+ }
+ for (PoseChannelRuntimeDataBackup::value_type &value : pose_channel_runtime_data) {
+ BKE_pose_channel_runtime_free(&value.second);
+ }
+}
+
class RuntimeBackup {
public:
RuntimeBackup() : drawdata_ptr(NULL)
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
index c913bb0f3f2..b174941e3bb 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
@@ -74,8 +74,7 @@ void deg_free_copy_on_write_datablock(struct ID *id_cow);
void deg_evaluate_copy_on_write(struct ::Depsgraph *depsgraph, const struct IDNode *id_node);
/* Check that given ID is properly expanded and does not have any shallow
- * copies inside.
- */
+ * copies inside. */
bool deg_validate_copy_on_write_datablock(ID *id_cow);
/* Tag given ID block as being copy-on-wtritten. */
diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc
index dc7ca371de3..ceec62e278b 100644
--- a/source/blender/depsgraph/intern/node/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_component.cc
@@ -335,7 +335,7 @@ void BoneComponentNode::init(const ID *id, const char *subdata)
/* name of component comes is bone name */
/* TODO(sergey): This sets name to an empty string because subdata is
* empty. Is it a bug? */
- //this->name = subdata;
+ // this->name = subdata;
/* bone-specific node data */
Object *object = (Object *)id;
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc
index 77e8f4f37e0..c5b9c56bcf0 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_id.cc
@@ -111,6 +111,7 @@ void IDNode::init(const ID *id, const char *UNUSED(subdata))
linked_state = DEG_ID_LINKED_INDIRECTLY;
is_directly_visible = true;
is_collection_fully_expanded = false;
+ has_base = false;
visible_components_mask = 0;
previously_visible_components_mask = 0;
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.h b/source/blender/depsgraph/intern/node/deg_node_id.h
index 34d78e29060..b4351ec988c 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.h
+++ b/source/blender/depsgraph/intern/node/deg_node_id.h
@@ -96,6 +96,9 @@ struct IDNode : public Node {
* recursed into. */
bool is_collection_fully_expanded;
+ /* Is used to figure out whether object came to the dependency graph via a base. */
+ bool has_base;
+
IDComponentsMask visible_components_mask;
IDComponentsMask previously_visible_components_mask;
diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc
index 54a5ecef35c..154563303ad 100644
--- a/source/blender/depsgraph/intern/node/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc
@@ -208,14 +208,11 @@ string OperationNode::identifier() const
* used for logging and debug prints. */
string OperationNode::full_identifier() const
{
- string owner_str = "";
- if (owner->type == NodeType::BONE) {
- owner_str = string(owner->owner->name) + "." + owner->name;
+ string owner_str = owner->owner->name;
+ if (owner->type == NodeType::BONE || !owner->name.empty()) {
+ owner_str += "/" + owner->name;
}
- else {
- owner_str = owner->owner->name;
- }
- return owner_str + "." + identifier();
+ return owner_str + "/" + identifier();
}
void OperationNode::tag_update(Depsgraph *graph, eUpdateSource source)
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 0d1752af4dc..abbf8a2b47b 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -39,9 +39,9 @@ set(INC
../render/intern/include
../windowmanager
+ ../../../intern/atomic
../../../intern/glew-mx
../../../intern/guardedalloc
- ../../../intern/atomic
)
set(INC_SYS
@@ -277,6 +277,8 @@ data_to_c_simple(modes/shaders/edit_mesh_overlay_geom.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_mix_frag.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facefill_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_mesh_overlay_facefill_frag.glsl SRC)
+data_to_c_simple(modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl SRC)
+data_to_c_simple(modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_curve_overlay_handle_vert.glsl SRC)
data_to_c_simple(modes/shaders/edit_curve_overlay_handle_geom.glsl SRC)
data_to_c_simple(modes/shaders/edit_curve_overlay_loosevert_vert.glsl SRC)
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index 161e28db2d3..da1f5c7863a 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -132,6 +132,9 @@ void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
struct ARegion *ar,
struct View3D *v3d,
struct GPUViewport *viewport);
+void DRW_draw_depth_object(struct ARegion *ar,
+ struct GPUViewport *viewport,
+ struct Object *object);
void DRW_framebuffer_select_id_setup(struct ARegion *ar, const bool clear);
void DRW_framebuffer_select_id_release(struct ARegion *ar);
@@ -152,6 +155,9 @@ void DRW_opengl_context_destroy(void);
void DRW_opengl_context_enable(void);
void DRW_opengl_context_disable(void);
+/* For garbage collection */
+void DRW_cache_free_old_batches(struct Main *bmain);
+
/* Never use this. Only for closing blender. */
void DRW_opengl_context_enable_ex(bool restore);
void DRW_opengl_context_disable_ex(bool restore);
diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index 16788c10680..05ee485e053 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -169,8 +169,8 @@ static void basic_cache_populate(void *vedata, Object *ob)
const bool do_cull = (draw_ctx->v3d &&
(draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
/* Depth Prepass */
- DRW_shgroup_call_add(
- (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
+ DRW_shgroup_call_object_add(
+ (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob);
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_bloom.c b/source/blender/draw/engines/eevee/eevee_bloom.c
index e5d33daa0d0..b0013151a70 100644
--- a/source/blender/draw/engines/eevee/eevee_bloom.c
+++ b/source/blender/draw/engines/eevee/eevee_bloom.c
@@ -206,31 +206,32 @@ void EEVEE_bloom_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *ved
if ((effects->enabled_effects & EFFECT_BLOOM) != 0) {
/** Bloom algorithm
*
- * Overview :
+ * Overview:
* - Downsample the color buffer doing a small blur during each step.
* - Accumulate bloom color using previously downsampled color buffers
* and do an upsample blur for each new accumulated layer.
* - Finally add accumulation buffer onto the source color buffer.
*
* [1/1] is original copy resolution (can be half or quarter res for performance)
+ * <pre>
+ * [DOWNSAMPLE CHAIN] [UPSAMPLE CHAIN]
*
- * [DOWNSAMPLE CHAIN] [UPSAMPLE CHAIN]
- *
- * Source Color ── [Blit] ──> Bright Color Extract [1/1] Final Color
- * | Λ
- * [Downsample First] Source Color ─> + [Resolve]
- * v |
- * Color Downsampled [1/2] ────────────> + Accumulation Buffer [1/2]
- * | Λ
- * ─── ───
- * Repeat Repeat
- * ─── ───
- * v |
- * Color Downsampled [1/N-1] ──────────> + Accumulation Buffer [1/N-1]
- * | Λ
- * [Downsample] [Upsample]
- * v |
- * Color Downsampled [1/N] ─────────────────────────┘
+ * Source Color ─ [Blit] ─> Bright Color Extract [1/1] Final Color
+ * | Λ
+ * [Downsample First] Source Color ─> + [Resolve]
+ * v |
+ * Color Downsampled [1/2] ────────────> + Accumulation Buffer [1/2]
+ * | Λ
+ * ─── ───
+ * Repeat Repeat
+ * ─── ───
+ * v |
+ * Color Downsampled [1/N-1] ──────────> + Accumulation Buffer [1/N-1]
+ * | Λ
+ * [Downsample] [Upsample]
+ * v |
+ * Color Downsampled [1/N] ─────────────────────────┘
+ * </pre>
*/
DRWShadingGroup *grp;
const bool use_highres = true;
diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index 62ccf30e12c..8fb73bd605f 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -141,10 +141,12 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata),
float focus_dist = BKE_camera_object_dof_distance(camera);
float focal_len = cam->lens;
- /* this is factor that converts to the scene scale. focal length and sensor are expressed in mm
- * unit.scale_length is how many meters per blender unit we have. We want to convert to blender units though
- * because the shader reads coordinates in world space, which is in blender units.
- * Note however that focus_distance is already in blender units and shall not be scaled here (see T48157). */
+ /* this is factor that converts to the scene scale. focal length and sensor are expressed in
+ * mm unit.scale_length is how many meters per blender unit we have. We want to convert to
+ * blender units though because the shader reads coordinates in world space, which is in
+ * blender units.
+ * Note however that focus_distance is already in blender units and shall not be scaled here
+ * (see T48157). */
float scale = (scene_eval->unit.system) ? scene_eval->unit.scale_length : 1.0f;
float scale_camera = 0.001f / scale;
/* we want radius here for the aperture number */
@@ -239,6 +241,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
if (use_alpha) {
DRW_shgroup_uniform_texture_ref(grp, "scatterAlphaBuffer", &effects->dof_blur_alpha);
+ DRW_shgroup_uniform_bool_copy(grp, "unpremult", DRW_state_is_image_render());
}
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index e77d7b16c78..a8b4159e030 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -168,6 +168,11 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata,
effects->enabled_effects |= EFFECT_NORMAL_BUFFER;
}
+ /* Alpha checker if background is not drawn in viewport. */
+ if (!DRW_state_is_image_render() && !DRW_state_draw_background()) {
+ effects->enabled_effects |= EFFECT_ALPHA_CHECKER;
+ }
+
/**
* Ping Pong buffer
*/
@@ -361,6 +366,23 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_shgroup_uniform_mat4(grp, "pastPersmat", effects->velocity_past_persmat);
DRW_shgroup_call_add(grp, quad, NULL);
}
+
+ if ((effects->enabled_effects & EFFECT_ALPHA_CHECKER) != 0) {
+ psl->alpha_checker = DRW_pass_create("Alpha Checker",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_PREMUL_UNDER);
+
+ GPUShader *checker_sh = GPU_shader_get_builtin_shader(GPU_SHADER_2D_CHECKER);
+
+ DRWShadingGroup *grp = DRW_shgroup_create(checker_sh, psl->alpha_checker);
+
+ copy_v4_fl4(effects->color_checker_dark, 0.15f, 0.15f, 0.15f, 1.0f);
+ copy_v4_fl4(effects->color_checker_light, 0.2f, 0.2f, 0.2f, 1.0f);
+
+ DRW_shgroup_uniform_vec4(grp, "color1", effects->color_checker_dark, 1);
+ DRW_shgroup_uniform_vec4(grp, "color2", effects->color_checker_light, 1);
+ DRW_shgroup_uniform_int_copy(grp, "size", 8);
+ DRW_shgroup_call_add(grp, quad, NULL);
+ }
}
#if 0 /* Not required for now */
@@ -413,7 +435,8 @@ void EEVEE_create_minmax_buffer(EEVEE_Data *vedata, GPUTexture *depth_src, int l
GPU_framebuffer_texture_detach(stl->g_data->minzbuffer);
/* Create lower levels */
- GPU_framebuffer_recursive_downsample(fbl->downsample_fb, stl->g_data->minzbuffer, 8, &min_downsample_cb, vedata);
+ GPU_framebuffer_recursive_downsample(
+ fbl->downsample_fb, stl->g_data->minzbuffer, 8, &min_downsample_cb, vedata);
DRW_stats_group_end();
#endif
int minmax_size[3], depth_size[3];
@@ -490,22 +513,50 @@ void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, GPUTexture *texture_src, i
DRW_stats_group_end();
}
-void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
+void EEVEE_draw_alpha_checker(EEVEE_Data *vedata)
+{
+ EEVEE_PassList *psl = vedata->psl;
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_EffectsInfo *effects = stl->effects;
+
+ if ((effects->enabled_effects & EFFECT_ALPHA_CHECKER) != 0) {
+ float mat[4][4];
+ unit_m4(mat);
+
+ /* Fragile, rely on the fact that GPU_SHADER_2D_CHECKER
+ * only use the persmat. */
+ DRW_viewport_matrix_override_set(mat, DRW_MAT_PERS);
+
+ DRW_draw_pass(psl->alpha_checker);
+
+ DRW_viewport_matrix_override_unset(DRW_MAT_PERS);
+ }
+}
+
+static void EEVEE_velocity_resolve(EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
- EEVEE_TextureList *txl = vedata->txl;
EEVEE_FramebufferList *fbl = vedata->fbl;
EEVEE_StorageList *stl = vedata->stl;
EEVEE_EffectsInfo *effects = stl->effects;
- /* First resolve the velocity. */
if ((effects->enabled_effects & EFFECT_VELOCITY_BUFFER) != 0) {
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+ e_data.depth_src = dtxl->depth;
DRW_viewport_matrix_get(effects->velocity_curr_persinv, DRW_MAT_PERSINV);
GPU_framebuffer_bind(fbl->velocity_resolve_fb);
DRW_draw_pass(psl->velocity_resolve);
}
DRW_viewport_matrix_get(effects->velocity_past_persmat, DRW_MAT_PERS);
+}
+
+void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
+{
+ EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_EffectsInfo *effects = stl->effects;
/* only once per frame after the first post process */
effects->swap_double_buffer = ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0);
@@ -517,6 +568,14 @@ void EEVEE_draw_effects(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
/* Post process stack (order matters) */
EEVEE_motion_blur_draw(vedata);
EEVEE_depth_of_field_draw(vedata);
+
+ /* NOTE: Lookdev drawing happens before TAA but after
+ * motion blur and dof to avoid distortions.
+ * Velocity resolve use a hack to exclude lookdev
+ * balls from creating shimering reprojection vectors. */
+ EEVEE_lookdev_draw(vedata);
+ EEVEE_velocity_resolve(vedata);
+
EEVEE_temporal_sampling_draw(vedata);
EEVEE_bloom_draw(vedata);
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 6232640aac8..962bc8e5efb 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -301,16 +301,15 @@ static void eevee_draw_background(void *vedata)
}
}
- /* LookDev */
- EEVEE_lookdev_draw_background(vedata);
- /* END */
-
/* Tonemapping and transfer result to default framebuffer. */
bool use_render_settings = stl->g_data->use_color_render_settings;
GPU_framebuffer_bind(dfbl->default_fb);
DRW_transform_to_display(stl->effects->final_tx, true, use_render_settings);
+ /* Draw checkerboard with alpha under. */
+ EEVEE_draw_alpha_checker(vedata);
+
/* Debug : Output buffer to view. */
switch (G.debug_value) {
case 1:
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 9ebd9542ef5..33cb2e87dc7 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -92,38 +92,64 @@ typedef struct EEVEE_LightBake {
struct Main *bmain;
EEVEE_ViewLayerData *sldata;
- LightProbe **probe; /* Current probe being rendered. */
- GPUTexture *rt_color; /* Target cube color texture. */
- GPUTexture *rt_depth; /* Target cube depth texture. */
- GPUFrameBuffer *rt_fb[6]; /* Target cube framebuffers. */
- GPUFrameBuffer *store_fb; /* Storage framebuffer. */
- int rt_res; /* Cube render target resolution. */
+ /** Current probe being rendered. */
+ LightProbe **probe;
+ /** Target cube color texture. */
+ GPUTexture *rt_color;
+ /** Target cube depth texture. */
+ GPUTexture *rt_depth;
+ /** Target cube framebuffers. */
+ GPUFrameBuffer *rt_fb[6];
+ /** Storage framebuffer. */
+ GPUFrameBuffer *store_fb;
+ /** Cube render target resolution. */
+ int rt_res;
/* Shared */
- int layer; /* Target layer to store the data to. */
- float samples_ct, invsamples_ct; /* Sample count for the convolution. */
- float lod_factor; /* Sampling bias during convolution step. */
- float lod_max; /* Max cubemap LOD to sample when convolving. */
- int cube_len, grid_len; /* Number of probes to render + world probe. */
+ /** Target layer to store the data to. */
+ int layer;
+ /** Sample count for the convolution. */
+ float samples_ct, invsamples_ct;
+ /** Sampling bias during convolution step. */
+ float lod_factor;
+ /** Max cubemap LOD to sample when convolving. */
+ float lod_max;
+ /** Number of probes to render + world probe. */
+ int cube_len, grid_len;
/* Irradiance grid */
- EEVEE_LightGrid *grid; /* Current probe being rendered (UBO data). */
- int irr_cube_res; /* Target cubemap at MIP 0. */
- int irr_size[3]; /* Size of the irradiance texture. */
- int total_irr_samples; /* Total for all grids */
- int grid_sample; /* Nth sample of the current grid being rendered. */
- int grid_sample_len; /* Total number of samples for the current grid. */
- int grid_curr; /* Nth grid in the cache being rendered. */
- int bounce_curr, bounce_len; /* The current light bounce being evaluated. */
- float vis_res; /* Resolution of the Visibility shadowmap. */
- GPUTexture *grid_prev; /* Result of previous light bounce. */
- LightProbe **grid_prb; /* Pointer to the id.data of the probe object. */
+ /** Current probe being rendered (UBO data). */
+ EEVEE_LightGrid *grid;
+ /** Target cubemap at MIP 0. */
+ int irr_cube_res;
+ /** Size of the irradiance texture. */
+ int irr_size[3];
+ /** Total for all grids */
+ int total_irr_samples;
+ /** Nth sample of the current grid being rendered. */
+ int grid_sample;
+ /** Total number of samples for the current grid. */
+ int grid_sample_len;
+ /** Nth grid in the cache being rendered. */
+ int grid_curr;
+ /** The current light bounce being evaluated. */
+ int bounce_curr, bounce_len;
+ /** Resolution of the Visibility shadowmap. */
+ float vis_res;
+ /** Result of previous light bounce. */
+ GPUTexture *grid_prev;
+ /** Pointer to the id.data of the probe object. */
+ LightProbe **grid_prb;
/* Reflection probe */
- EEVEE_LightProbe *cube; /* Current probe being rendered (UBO data). */
- int ref_cube_res; /* Target cubemap at MIP 0. */
- int cube_offset; /* Index of the current cube. */
- LightProbe **cube_prb; /* Pointer to the id.data of the probe object. */
+ /** Current probe being rendered (UBO data). */
+ EEVEE_LightProbe *cube;
+ /** Target cubemap at MIP 0. */
+ int ref_cube_res;
+ /** Index of the current cube. */
+ int cube_offset;
+ /** Pointer to the id.data of the probe object. */
+ LightProbe **cube_prb;
/* Dummy Textures */
struct GPUTexture *dummy_color, *dummy_depth;
@@ -133,15 +159,18 @@ typedef struct EEVEE_LightBake {
short *stop, *do_update;
float *progress;
- bool resource_only; /* For only handling the resources. */
+ /** For only handling the resources. */
+ bool resource_only;
bool own_resources;
- bool
- own_light_cache; /* If the lightcache was created for baking, it's first owned by the baker. */
- int delay; /* ms. delay the start of the baking to not slowdown interactions (TODO remove) */
- int frame; /* Scene frame to bake. */
-
- void *gl_context,
- *gpu_context; /* If running in parallel (in a separate thread), use this context. */
+ /** If the lightcache was created for baking, it's first owned by the baker. */
+ bool own_light_cache;
+ /** ms. delay the start of the baking to not slowdown interactions (TODO remove) */
+ int delay;
+ /** Scene frame to bake. */
+ int frame;
+
+ /** If running in parallel (in a separate thread), use this context. */
+ void *gl_context, *gpu_context;
ThreadMutex *mutex;
} EEVEE_LightBake;
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 550821ee92a..a4a17de7a57 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -145,7 +145,8 @@ static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref)
width, height, max_ii(1, num_planar_ref), GPU_DEPTH_COMPONENT24, 0, NULL);
}
else if (num_planar_ref == 0) {
- /* Makes Opengl Happy : Create a placeholder texture that will never be sampled but still bound to shader. */
+ /* Makes Opengl Happy : Create a placeholder texture that will never be sampled but still
+ * bound to shader. */
txl->planar_pool = DRW_texture_create_2d_array(
1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
txl->planar_depth = DRW_texture_create_2d_array(1, 1, 1, GPU_DEPTH_COMPONENT24, 0, NULL);
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index b118d7be3d0..270defb039b 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -680,7 +680,8 @@ static float light_shape_power_get(const Light *la, const EEVEE_Light *evli)
power = 1.0f / (evli->sizex * evli->sizey * 4.0f * M_PI) * /* 1/(w*h*Pi) */
80.0f; /* XXX : Empirical, Fit cycles power */
if (ELEM(la->area_shape, LA_AREA_DISK, LA_AREA_ELLIPSE)) {
- /* Scale power to account for the lower area of the ellipse compared to the surrounding rectangle. */
+ /* Scale power to account for the lower area of the ellipse compared to the surrounding
+ * rectangle. */
power *= 4.0f / M_PI;
}
}
@@ -693,8 +694,9 @@ static float light_shape_power_get(const Light *la, const EEVEE_Light *evli)
}
else {
power = 1.0f / (evli->radius * evli->radius * M_PI); /* 1/(r²*Pi) */
- /* Make illumation power closer to cycles for bigger radii. Cycles uses a cos^3 term that we cannot reproduce
- * so we account for that by scaling the light power. This function is the result of a rough manual fitting. */
+ /* Make illumation power closer to cycles for bigger radii. Cycles uses a cos^3 term that we
+ * cannot reproduce so we account for that by scaling the light power. This function is the
+ * result of a rough manual fitting. */
power += 1.0f / (2.0f * M_PI); /* power *= 1 + r²/2 */
}
return power;
@@ -952,7 +954,7 @@ static void frustum_min_bounding_sphere(const float corners[8][3],
}
/* TODO try to reduce the radius further by moving the center.
- * Remember we need a __stable__ solution! */
+ * Remember we need a __stable__ solution! */
/* Try to reduce float imprecision leading to shimmering. */
*r_radius = (float)round_to_digits(sqrtf(*r_radius), 3);
@@ -1383,7 +1385,8 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_draw_pass(psl->shadow_pass);
}
- /* 0.001f is arbitrary, but it should be relatively small so that filter size is not too big. */
+ /* 0.001f is arbitrary, but it should be relatively small so that filter size is not too big.
+ */
float filter_texture_size = la->soft * 0.001f;
float filter_pixel_size = ceil(filter_texture_size / srd->cube_texel_size);
linfo->filter_size = srd->cube_texel_size * ((filter_pixel_size > 1.0f) ? 1.5f : 0.0f);
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index b000eebb92e..4be87bf1a5e 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -24,6 +24,9 @@
#include "BKE_camera.h"
#include "BKE_studiolight.h"
+#include "BLI_rect.h"
+#include "BLI_rand.h"
+
#include "DNA_screen_types.h"
#include "DNA_world_types.h"
@@ -62,11 +65,30 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
{
EEVEE_StorageList *stl = vedata->stl;
EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_EffectsInfo *effects = stl->effects;
EEVEE_PrivateData *g_data = stl->g_data;
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
Scene *scene = draw_ctx->scene;
+ if (LOOK_DEV_OVERLAY_ENABLED(v3d)) {
+ /* Viewport / Ball size. */
+ rcti rect;
+ ED_region_visible_rect(draw_ctx->ar, &rect);
+
+ const int ball_size = max_ii(BLI_rcti_size_x(&rect) * 0.1f, 100.0f) * U.dpi_fac;
+
+ if (ball_size != effects->ball_size || rect.xmax != effects->anchor[0] ||
+ rect.ymin != effects->anchor[1]) {
+ /* If ball size or anchor point moves, reset TAA to avoid ghosting issue.
+ * This needs to happen early because we are changing taa_current_sample. */
+ effects->ball_size = ball_size;
+ effects->anchor[0] = rect.xmax;
+ effects->anchor[1] = rect.ymin;
+ EEVEE_temporal_sampling_reset(vedata);
+ }
+ }
+
if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) {
StudioLight *sl = BKE_studiolight_find(v3d->shading.lookdev_light,
STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE);
@@ -157,56 +179,35 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
}
}
-void EEVEE_lookdev_draw_background(EEVEE_Data *vedata)
+static void eevee_lookdev_apply_taa(const EEVEE_EffectsInfo *effects,
+ int ball_size,
+ float winmat[4][4])
+{
+ if (DRW_state_is_image_render() || ((effects->enabled_effects & EFFECT_TAA) != 0)) {
+ double ht_point[2];
+ double ht_offset[2] = {0.0, 0.0};
+ uint ht_primes[2] = {2, 3};
+ float ofs[2];
+
+ BLI_halton_2d(ht_primes, ht_offset, effects->taa_current_sample, ht_point);
+ EEVEE_temporal_sampling_offset_calc(ht_point, 1.5f, ofs);
+ winmat[3][0] += ofs[0] / ball_size;
+ winmat[3][1] += ofs[1] / ball_size;
+ }
+}
+
+void EEVEE_lookdev_draw(EEVEE_Data *vedata)
{
EEVEE_PassList *psl = vedata->psl;
+ EEVEE_FramebufferList *fbl = vedata->fbl;
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
EEVEE_EffectsInfo *effects = stl->effects;
EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
- DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
const DRWContextState *draw_ctx = DRW_context_state_get();
- if (psl->lookdev_pass && LOOK_DEV_OVERLAY_ENABLED(draw_ctx->v3d)) {
- DRW_stats_group_start("Look Dev");
- CameraParams params;
- BKE_camera_params_init(&params);
- View3D *v3d = draw_ctx->v3d;
- RegionView3D *rv3d = draw_ctx->rv3d;
- ARegion *ar = draw_ctx->ar;
-
- const float *viewport_size = DRW_viewport_size_get();
- rcti rect;
- ED_region_visible_rect(draw_ctx->ar, &rect);
-
- const float viewport_size_target[2] = {
- viewport_size[0] / 4,
- viewport_size[1] / 4,
- };
- const int viewport_inset[2] = {
- max_ii(viewport_size_target[0], 300),
- max_ii(viewport_size_target[0], 300) / 2, /* intentionally use 'x' here for 'y' value. */
- };
-
- /* minimum size for preview spheres viewport */
- const float aspect[2] = {
- viewport_inset[0] / viewport_size_target[0],
- viewport_inset[1] / viewport_size_target[1],
- };
-
- BKE_camera_params_from_view3d(&params, draw_ctx->depsgraph, v3d, rv3d);
- params.is_ortho = true;
- params.ortho_scale = 3.0f;
- params.zoom = CAMERA_PARAM_ZOOM_INIT_PERSP;
- params.offsetx = 0.0f;
- params.offsety = 0.0f;
- params.shiftx = 0.0f;
- params.shifty = 0.0f;
- params.clip_start = 0.001f;
- params.clip_end = 20.0f;
- BKE_camera_params_compute_viewplane(&params, ar->winx, ar->winy, aspect[0], aspect[1]);
- BKE_camera_params_compute_matrix(&params);
-
+ if (psl->lookdev_diffuse_pass && LOOK_DEV_OVERLAY_ENABLED(draw_ctx->v3d)) {
+ /* Config renderer. */
EEVEE_CommonUniformBuffer *common = &sldata->common_data;
common->la_num_light = 0;
common->prb_num_planar = 0;
@@ -218,34 +219,53 @@ void EEVEE_lookdev_draw_background(EEVEE_Data *vedata)
DRW_uniformbuffer_update(sldata->common_ubo, common);
/* override matrices */
- float winmat[4][4];
- float winmat_inv[4][4];
- copy_m4_m4(winmat, params.winmat);
- invert_m4_m4(winmat_inv, winmat);
- DRW_viewport_matrix_override_set(winmat, DRW_MAT_WIN);
- DRW_viewport_matrix_override_set(winmat_inv, DRW_MAT_WININV);
- float viewmat[4][4];
- DRW_viewport_matrix_get(viewmat, DRW_MAT_VIEW);
- float persmat[4][4];
- float persmat_inv[4][4];
- mul_m4_m4m4(persmat, winmat, viewmat);
- invert_m4_m4(persmat_inv, persmat);
- DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS);
- DRW_viewport_matrix_override_set(persmat_inv, DRW_MAT_PERSINV);
-
- GPUFrameBuffer *fb = effects->final_fb;
- GPU_framebuffer_bind(fb);
- GPU_framebuffer_viewport_set(
- fb, rect.xmax - viewport_inset[0], rect.ymin, viewport_inset[0], viewport_inset[1]);
- DRW_draw_pass(psl->lookdev_pass);
+ DRWMatrixState matstate;
+ unit_m4(matstate.winmat);
+
+ eevee_lookdev_apply_taa(effects, effects->ball_size, matstate.winmat);
+
+ /* "Remove" view matrix location. Leaving only rotation. */
+ DRW_viewport_matrix_get(matstate.viewmat, DRW_MAT_VIEW);
+ zero_v3(matstate.viewmat[3]);
+ mul_m4_m4m4(matstate.persmat, matstate.winmat, matstate.viewmat);
+ invert_m4_m4(matstate.wininv, matstate.winmat);
+ invert_m4_m4(matstate.viewinv, matstate.viewmat);
+ invert_m4_m4(matstate.persinv, matstate.persmat);
+
+ DRW_viewport_matrix_override_set_all(&matstate);
+
+ /* Find the right framebuffers to render to. */
+ GPUFrameBuffer *fb = (effects->target_buffer == fbl->effect_color_fb) ? fbl->main_fb :
+ fbl->effect_fb;
+
+ DRW_stats_group_start("Look Dev");
- fb = dfbl->depth_only_fb;
GPU_framebuffer_bind(fb);
- GPU_framebuffer_viewport_set(
- fb, rect.xmax - viewport_inset[0], rect.ymin, viewport_inset[0], viewport_inset[1]);
- DRW_draw_pass(psl->lookdev_pass);
- DRW_viewport_matrix_override_unset_all();
+ const int ball_margin = effects->ball_size / 6.0f;
+ float offset[2] = {0.0f, ball_margin};
+
+ offset[0] = effects->ball_size + ball_margin;
+ GPU_framebuffer_viewport_set(fb,
+ effects->anchor[0] - offset[0],
+ effects->anchor[1] + offset[1],
+ effects->ball_size,
+ effects->ball_size);
+
+ DRW_draw_pass(psl->lookdev_diffuse_pass);
+
+ offset[0] = (effects->ball_size + ball_margin) +
+ (ball_margin + effects->ball_size + ball_margin);
+ GPU_framebuffer_viewport_set(fb,
+ effects->anchor[0] - offset[0],
+ effects->anchor[1] + offset[1],
+ effects->ball_size,
+ effects->ball_size);
+
+ DRW_draw_pass(psl->lookdev_glossy_pass);
+
DRW_stats_group_end();
+
+ DRW_viewport_matrix_override_unset_all();
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 9268f2e8a46..456f4bdb5f1 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -115,15 +115,15 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
static float samples_len = 8192.0f;
static float inv_samples_len = 1.0f / 8192.0f;
- char *lib_str = BLI_string_joinN(
- datatoc_bsdf_common_lib_glsl,
- datatoc_bsdf_sampling_lib_glsl);
+ char *lib_str = BLI_string_joinN(datatoc_bsdf_common_lib_glsl, datatoc_bsdf_sampling_lib_glsl);
- struct GPUShader *sh = DRW_shader_create_with_lib(
- datatoc_lightprobe_vert_glsl, datatoc_lightprobe_geom_glsl, datatoc_bsdf_lut_frag_glsl, lib_str,
- "#define HAMMERSLEY_SIZE 8192\n"
- "#define BRDF_LUT_SIZE 64\n"
- "#define NOISE_SIZE 64\n");
+ struct GPUShader *sh = DRW_shader_create_with_lib(datatoc_lightprobe_vert_glsl,
+ datatoc_lightprobe_geom_glsl,
+ datatoc_bsdf_lut_frag_glsl,
+ lib_str,
+ "#define HAMMERSLEY_SIZE 8192\n"
+ "#define BRDF_LUT_SIZE 64\n"
+ "#define NOISE_SIZE 64\n");
DRWPass *pass = DRW_pass_create("LightProbe Filtering", DRW_STATE_WRITE_COLOR);
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
@@ -150,11 +150,14 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
glReadPixels(0, 0, w, h, GL_RGB, GL_FLOAT, data);
printf("{");
- for (int i = 0; i < w*h * 3; i+=3) {
- printf("%ff, %ff, ", data[i], data[i+1]); i+=3;
- printf("%ff, %ff, ", data[i], data[i+1]); i+=3;
- printf("%ff, %ff, ", data[i], data[i+1]); i+=3;
- printf("%ff, %ff, \n", data[i], data[i+1]);
+ for (int i = 0; i < w * h * 3; i += 3) {
+ printf("%ff, %ff, ", data[i], data[i + 1]);
+ i += 3;
+ printf("%ff, %ff, ", data[i], data[i + 1]);
+ i += 3;
+ printf("%ff, %ff, ", data[i], data[i + 1]);
+ i += 3;
+ printf("%ff, %ff, \n", data[i], data[i + 1]);
}
printf("}");
@@ -174,15 +177,13 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
static float inv_samples_len = 1.0f / 8192.0f;
char *frag_str = BLI_string_joinN(
- datatoc_bsdf_common_lib_glsl,
- datatoc_bsdf_sampling_lib_glsl,
- datatoc_btdf_lut_frag_glsl);
+ datatoc_bsdf_common_lib_glsl, datatoc_bsdf_sampling_lib_glsl, datatoc_btdf_lut_frag_glsl);
struct GPUShader *sh = DRW_shader_create_fullscreen(frag_str,
- "#define HAMMERSLEY_SIZE 8192\n"
- "#define BRDF_LUT_SIZE 64\n"
- "#define NOISE_SIZE 64\n"
- "#define LUT_SIZE 64\n");
+ "#define HAMMERSLEY_SIZE 8192\n"
+ "#define BRDF_LUT_SIZE 64\n"
+ "#define NOISE_SIZE 64\n"
+ "#define LUT_SIZE 64\n");
MEM_freeN(frag_str);
@@ -222,20 +223,28 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
# if 1
fprintf(f, "\t{\n\t\t");
- for (int i = 0; i < w*h * 3; i+=3) {
+ for (int i = 0; i < w * h * 3; i += 3) {
fprintf(f, "%ff,", data[i]);
- if (((i/3)+1) % 12 == 0) fprintf(f, "\n\t\t");
- else fprintf(f, " ");
+ if (((i / 3) + 1) % 12 == 0)
+ fprintf(f, "\n\t\t");
+ else
+ fprintf(f, " ");
}
fprintf(f, "\n\t},\n");
# else
- for (int i = 0; i < w*h * 3; i+=3) {
- if (data[i] < 0.01) printf(" ");
- else if (data[i] < 0.3) printf(".");
- else if (data[i] < 0.6) printf("+");
- else if (data[i] < 0.9) printf("%%");
- else printf("#");
- if ((i/3+1) % 64 == 0) printf("\n");
+ for (int i = 0; i < w * h * 3; i += 3) {
+ if (data[i] < 0.01)
+ printf(" ");
+ else if (data[i] < 0.3)
+ printf(".");
+ else if (data[i] < 0.6)
+ printf("+");
+ else if (data[i] < 0.9)
+ printf("%%");
+ else
+ printf("#");
+ if ((i / 3 + 1) % 64 == 0)
+ printf("\n");
}
# endif
@@ -327,7 +336,10 @@ static char *eevee_get_defines(int options)
BLI_dynstr_append(ds, "#define USE_ALPHA_BLEND_VOLUMETRICS\n");
}
if ((options & VAR_MAT_LOOKDEV) != 0) {
+ /* Auto config shadow method. Avoid more permutation. */
+ BLI_assert((options & (VAR_MAT_VSM | VAR_MAT_ESM)) == 0);
BLI_dynstr_append(ds, "#define LOOKDEV\n");
+ BLI_dynstr_append(ds, "#define SHADOW_ESM\n");
}
str = BLI_dynstr_get_cstring(ds);
@@ -457,7 +469,7 @@ static void eevee_init_util_texture(void)
texels_layer += 64 * 64;
/* Copy bsdf_split_sum_ggx into 2nd layer red and green channels.
- Copy ltc_mag_ggx into 2nd layer blue and alpha channel. */
+ * Copy ltc_mag_ggx into 2nd layer blue and alpha channel. */
for (int i = 0; i < 64 * 64; i++) {
texels_layer[i][0] = bsdf_split_sum_ggx[i * 2 + 0];
texels_layer[i][1] = bsdf_split_sum_ggx[i * 2 + 1];
@@ -582,6 +594,7 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata,
datatoc_lit_surface_frag_glsl,
datatoc_lit_surface_frag_glsl,
datatoc_lit_surface_frag_glsl,
+ datatoc_lit_surface_frag_glsl,
datatoc_volumetric_lib_glsl);
e_data.volume_shader_lib = BLI_string_joinN(datatoc_common_view_lib_glsl,
@@ -985,42 +998,11 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(EEVEE_ViewLayerDa
}
}
-/**
- * Create a default shading group inside the lookdev pass without standard uniforms.
- */
-static struct DRWShadingGroup *EEVEE_lookdev_shading_group_get(EEVEE_ViewLayerData *sldata,
- EEVEE_Data *vedata,
- bool use_ssr,
- int shadow_method)
-{
- static int ssr_id;
- ssr_id = (use_ssr) ? 1 : -1;
- int options = VAR_MAT_MESH | VAR_MAT_LOOKDEV;
-
- options |= eevee_material_shadow_option(shadow_method);
-
- if (e_data.default_lit[options] == NULL) {
- create_default_shader(options);
- }
-
- if (vedata->psl->lookdev_pass == NULL) {
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS |
- DRW_STATE_CULL_BACK;
- vedata->psl->lookdev_pass = DRW_pass_create("LookDev Pass", state);
-
- DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options],
- vedata->psl->lookdev_pass);
- /* XXX / WATCH: This creates non persistent binds for the ubos and textures.
- * But it's currently OK because the following shgroups does not add any bind. */
- add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, false);
- }
-
- return DRW_shgroup_create(e_data.default_lit[options], vedata->psl->lookdev_pass);
-}
void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
{
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
/* Create Material Ghash */
{
@@ -1034,16 +1016,13 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = NULL;
- const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
World *wo = scene->world;
const float *col = G_draw.block.colorBackground;
- /* LookDev */
EEVEE_lookdev_cache_init(
vedata, &grp, psl->background_pass, stl->g_data->background_alpha, wo, NULL);
- /* END */
if (!grp && wo) {
col = &wo->horr;
@@ -1174,6 +1153,39 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
DRW_shgroup_uniform_vec3(grp, "offsets", e_data.noise_offsets, 1);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
}
+
+ if (LOOK_DEV_OVERLAY_ENABLED(draw_ctx->v3d)) {
+ DRWShadingGroup *shgrp;
+
+ struct GPUBatch *sphere = DRW_cache_sphere_get();
+ static float color_chrome[3] = {1.0f, 1.0f, 1.0f};
+ static float color_diffuse[3] = {0.8f, 0.8f, 0.8f};
+ int options = VAR_MAT_MESH | VAR_MAT_LOOKDEV;
+
+ if (e_data.default_lit[options] == NULL) {
+ create_default_shader(options);
+ }
+
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS |
+ DRW_STATE_CULL_BACK;
+
+ psl->lookdev_diffuse_pass = DRW_pass_create("LookDev Diffuse Pass", state);
+ shgrp = DRW_shgroup_create(e_data.default_lit[options], psl->lookdev_diffuse_pass);
+ add_standard_uniforms(shgrp, sldata, vedata, NULL, NULL, true, true, false, false, false);
+ DRW_shgroup_uniform_vec3(shgrp, "basecol", color_diffuse, 1);
+ DRW_shgroup_uniform_float_copy(shgrp, "metallic", 0.0f);
+ DRW_shgroup_uniform_float_copy(shgrp, "specular", 0.5f);
+ DRW_shgroup_uniform_float_copy(shgrp, "roughness", 1.0f);
+ DRW_shgroup_call_add(shgrp, sphere, NULL);
+
+ psl->lookdev_glossy_pass = DRW_pass_create("LookDev Glossy Pass", state);
+ shgrp = DRW_shgroup_create(e_data.default_lit[options], psl->lookdev_glossy_pass);
+ add_standard_uniforms(shgrp, sldata, vedata, NULL, NULL, true, true, false, false, false);
+ DRW_shgroup_uniform_vec3(shgrp, "basecol", color_chrome, 1);
+ DRW_shgroup_uniform_float_copy(shgrp, "metallic", 1.0f);
+ DRW_shgroup_uniform_float_copy(shgrp, "roughness", 0.0f);
+ DRW_shgroup_call_add(shgrp, sphere, NULL);
+ }
}
#define ADD_SHGROUP_CALL(shgrp, ob, ma, geom, oedata) \
@@ -1399,9 +1411,9 @@ static void material_opaque(Material *ma,
}
else {
if (use_translucency) {
- /* NOTE: This is a nasty workaround, because the sss profile might not have been generated
- * but the UBO is still declared in this case even if not used. But rendering without a
- * bound UBO might result in crashes on certain platform. */
+ /* NOTE: This is a nasty workaround, because the sss profile might not have been
+ * generated but the UBO is still declared in this case even if not used.
+ * But rendering without a bound UBO might result in crashes on certain platform. */
DRW_shgroup_uniform_block(*shgrp, "sssProfile", e_data.dummy_sss_profile);
}
}
@@ -1605,12 +1617,10 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
const bool do_cull = (draw_ctx->v3d &&
(draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
- const bool is_active = (ob == draw_ctx->obact);
- const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
+ const bool is_sculpt_mode = (ob->sculpt != NULL);
/* For now just force fully shaded with eevee when supported. */
- const bool is_sculpt_mode_draw = is_sculpt_mode &&
- ((ob->sculpt && ob->sculpt->pbvh) &&
- (BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES));
+ const bool is_sculpt_mode_draw = ob->sculpt && ob->sculpt->pbvh &&
+ BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES;
const bool is_default_mode_shader = is_sculpt_mode;
/* First get materials for this mesh. */
@@ -1871,6 +1881,13 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata,
shgrp = DRW_shgroup_material_hair_create(ob, psys, md, psl->material_pass, gpumat);
+ if (!use_diffuse && !use_glossy && !use_refract) {
+ /* FIXME: Small hack to avoid issue when utilTex is needed for
+ * world_normals_get and none of the bsdfs that need it are present.
+ * This can try to bind utilTex even if not needed. */
+ DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
+ }
+
add_standard_uniforms(shgrp,
sldata,
vedata,
@@ -1918,46 +1935,6 @@ void EEVEE_materials_cache_finish(EEVEE_Data *vedata)
{
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
- /* Look-Dev */
- const DRWContextState *draw_ctx = DRW_context_state_get();
- const View3D *v3d = draw_ctx->v3d;
- if (LOOK_DEV_OVERLAY_ENABLED(v3d)) {
- EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
- EEVEE_LightsInfo *linfo = sldata->lights;
- struct GPUBatch *sphere = DRW_cache_sphere_get();
- static float mat1[4][4];
- static float color[3] = {0.8f, 0.8f, 0.8f};
- static float metallic_on = 1.0f;
- static float metallic_off = 0.00f;
- static float specular_off = 0.5f;
- static float specular_on = 1.0f;
- static float roughness_off = 0.05f;
- static float roughness_on = 1.00f;
-
- float view_mat[4][4];
- DRW_viewport_matrix_get(view_mat, DRW_MAT_VIEWINV);
-
- DRWShadingGroup *shgrp = EEVEE_lookdev_shading_group_get(
- sldata, vedata, false, linfo->shadow_method);
- DRW_shgroup_uniform_vec3(shgrp, "basecol", color, 1);
- DRW_shgroup_uniform_float(shgrp, "metallic", &metallic_on, 1);
- DRW_shgroup_uniform_float(shgrp, "specular", &specular_on, 1);
- DRW_shgroup_uniform_float(shgrp, "roughness", &roughness_off, 1);
- unit_m4(mat1);
- mul_m4_m4m4(mat1, mat1, view_mat);
- translate_m4(mat1, -1.5f, 0.0f, -5.0f);
- DRW_shgroup_call_add(shgrp, sphere, mat1);
-
- shgrp = EEVEE_lookdev_shading_group_get(sldata, vedata, false, linfo->shadow_method);
- DRW_shgroup_uniform_vec3(shgrp, "basecol", color, 1);
- DRW_shgroup_uniform_float(shgrp, "metallic", &metallic_off, 1);
- DRW_shgroup_uniform_float(shgrp, "specular", &specular_off, 1);
- DRW_shgroup_uniform_float(shgrp, "roughness", &roughness_on, 1);
- translate_m4(mat1, 3.0f, 0.0f, 0.0f);
- DRW_shgroup_call_add(shgrp, sphere, mat1);
- }
- /* END */
-
BLI_ghash_free(stl->g_data->material_hash, NULL, MEM_freeN);
}
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index f2863d572c4..f8795a7ff0e 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -165,11 +165,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
#if 0 /* for future high quality blur */
/* Future matrix */
eevee_motion_blur_camera_get_matrix_at_time(
- scene,
- ar, rv3d, v3d,
- ob_camera_eval,
- ctime + delta,
- effects->future_world_to_ndc);
+ scene, ar, rv3d, v3d, ob_camera_eval, ctime + delta, effects->future_world_to_ndc);
#endif
invert_m4_m4(effects->current_ndc_to_world, effects->current_world_to_ndc);
}
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 8e21c7f389c..c3cd25923b2 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -246,6 +246,7 @@ typedef struct EEVEE_PassList {
struct DRWPass *color_downsample_cube_ps;
struct DRWPass *velocity_resolve;
struct DRWPass *taa_resolve;
+ struct DRWPass *alpha_checker;
/* HiZ */
struct DRWPass *minz_downlevel_ps;
@@ -275,7 +276,8 @@ typedef struct EEVEE_PassList {
struct DRWPass *transparent_pass;
struct DRWPass *background_pass;
struct DRWPass *update_noise_pass;
- struct DRWPass *lookdev_pass;
+ struct DRWPass *lookdev_glossy_pass;
+ struct DRWPass *lookdev_diffuse_pass;
} EEVEE_PassList;
typedef struct EEVEE_FramebufferList {
@@ -537,6 +539,7 @@ typedef enum EEVEE_EffectsFlag {
EFFECT_VELOCITY_BUFFER = (1 << 12), /* Not really an effect but a feature */
EFFECT_TAA_REPROJECT = (1 << 13), /* should be mutually exclusive with EFFECT_TAA */
EFFECT_DEPTH_DOUBLE_BUFFER = (1 << 14), /* Not really an effect but a feature */
+ EFFECT_ALPHA_CHECKER = (1 << 15), /* Not really an effect but a feature */
} EEVEE_EffectsFlag;
typedef struct EEVEE_EffectsInfo {
@@ -598,8 +601,14 @@ typedef struct EEVEE_EffectsInfo {
struct GPUTexture *dof_coc;
struct GPUTexture *dof_blur;
struct GPUTexture *dof_blur_alpha;
+ /* Alpha Checker */
+ float color_checker_dark[4];
+ float color_checker_light[4];
/* Other */
float prev_persmat[4][4];
+ /* Lookdev */
+ int ball_size;
+ int anchor[2];
/* Bloom */
int bloom_iteration_len;
float source_texel_size[2];
@@ -1044,6 +1053,9 @@ void EEVEE_mist_free(void);
/* eevee_temporal_sampling.c */
void EEVEE_temporal_sampling_reset(EEVEE_Data *vedata);
int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
+void EEVEE_temporal_sampling_offset_calc(const double ht_point[2],
+ const float filter_size,
+ float r_offset[2]);
void EEVEE_temporal_sampling_matrices_calc(EEVEE_EffectsInfo *effects,
float viewmat[4][4],
float persmat[4][4],
@@ -1073,6 +1085,7 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_create_minmax_buffer(EEVEE_Data *vedata, struct GPUTexture *depth_src, int layer);
void EEVEE_downsample_buffer(EEVEE_Data *vedata, struct GPUTexture *texture_src, int level);
void EEVEE_downsample_cube_buffer(EEVEE_Data *vedata, struct GPUTexture *texture_src, int level);
+void EEVEE_draw_alpha_checker(EEVEE_Data *vedata);
void EEVEE_draw_effects(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
void EEVEE_effects_free(void);
@@ -1099,7 +1112,7 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
float background_alpha,
struct World *world,
EEVEE_LightProbesInfo *pinfo);
-void EEVEE_lookdev_draw_background(EEVEE_Data *vedata);
+void EEVEE_lookdev_draw(EEVEE_Data *vedata);
/** eevee_engine.c */
void EEVEE_cache_populate(void *vedata, Object *ob);
diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
index a3603fc3d64..22c7dd00b97 100644
--- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
+++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c
@@ -296,8 +296,9 @@ void EEVEE_reflection_compute(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
/* Resolve at fullres */
int sample = (DRW_state_is_image_render()) ? effects->taa_render_sample :
effects->taa_current_sample;
- /* Doing a neighbor shift only after a few iteration. We wait for a prime number of cycles to avoid
- * noise correlation. This reduces variance faster. */
+ /* Doing a neighbor shift only after a few iteration.
+ * We wait for a prime number of cycles to avoid noise correlation.
+ * This reduces variance faster. */
effects->ssr_neighbor_ofs = ((sample / 5) % 8) * 4;
switch ((sample / 11) % 4) {
case 0:
diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
index 54ceb1a167a..194fff9b93c 100644
--- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
@@ -131,6 +131,14 @@ static void eevee_create_cdf_table_temporal_sampling(void)
e_data.inited = true;
}
+void EEVEE_temporal_sampling_offset_calc(const double ht_point[2],
+ const float filter_size,
+ float r_offset[2])
+{
+ r_offset[0] = eval_table(e_data.inverted_cdf, (float)(ht_point[0])) * filter_size;
+ r_offset[1] = eval_table(e_data.inverted_cdf, (float)(ht_point[1])) * filter_size;
+}
+
void EEVEE_temporal_sampling_matrices_calc(EEVEE_EffectsInfo *effects,
float viewmat[4][4],
float persmat[4][4],
@@ -141,13 +149,11 @@ void EEVEE_temporal_sampling_matrices_calc(EEVEE_EffectsInfo *effects,
Scene *scene = draw_ctx->scene;
RenderData *rd = &scene->r;
- float filter_size = rd->gauss; /* Sigh.. Stupid legacy naming. */
-
- float ofs_x = eval_table(e_data.inverted_cdf, (float)(ht_point[0])) * filter_size;
- float ofs_y = eval_table(e_data.inverted_cdf, (float)(ht_point[1])) * filter_size;
+ float ofs[2];
+ EEVEE_temporal_sampling_offset_calc(ht_point, rd->gauss, ofs);
window_translate_m4(
- effects->overide_winmat, persmat, ofs_x / viewport_size[0], ofs_y / viewport_size[1]);
+ effects->overide_winmat, persmat, ofs[0] / viewport_size[0], ofs[1] / viewport_size[1]);
mul_m4_m4m4(effects->overide_persmat, effects->overide_winmat, viewmat);
invert_m4_m4(effects->overide_persinv, effects->overide_persmat);
@@ -157,6 +163,7 @@ void EEVEE_temporal_sampling_matrices_calc(EEVEE_EffectsInfo *effects,
void EEVEE_temporal_sampling_reset(EEVEE_Data *vedata)
{
vedata->stl->effects->taa_render_sample = 1;
+ vedata->stl->effects->taa_current_sample = 1;
}
int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
index f23303c5b93..32076b47d8c 100644
--- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
@@ -1,7 +1,8 @@
/* Based on Practical Realtime Strategies for Accurate Indirect Occlusion
* http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pdf
- * http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pptx */
+ * http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pptx
+ */
#if defined(MESH_SHADER)
# if !defined(USE_ALPHA_HASH)
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index fdaec58977f..3a5f20b952e 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -319,7 +319,8 @@ float line_unit_sphere_intersect_dist(vec3 lineorigin, vec3 linedirection)
float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection)
{
- /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ */
+ /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
+ */
vec3 firstplane = (vec3(1.0) - lineorigin) / linedirection;
vec3 secondplane = (vec3(-1.0) - lineorigin) / linedirection;
vec3 furthestplane = max(firstplane, secondplane);
@@ -837,9 +838,16 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac)
# ifdef USE_SSS
cl.sss_data.rgb = mix(cl1.sss_data.rgb, cl2.sss_data.rgb, fac);
cl.sss_data.a = (cl1.sss_data.a > 0.0) ? cl1.sss_data.a : cl2.sss_data.a;
+
# ifdef USE_SSS_ALBEDO
/* TODO Find a solution to this. Dither? */
cl.sss_albedo = (cl1.sss_data.a > 0.0) ? cl1.sss_albedo : cl2.sss_albedo;
+ /* Add radiance that was supposed to be filtered but was rejected. */
+ cl.radiance += (cl1.sss_data.a > 0.0) ? cl2.sss_data.rgb * cl2.sss_albedo :
+ cl1.sss_data.rgb * cl1.sss_albedo;
+# else
+ /* Add radiance that was supposed to be filtered but was rejected. */
+ cl.radiance += (cl1.sss_data.a > 0.0) ? cl2.sss_data.rgb : cl1.sss_data.rgb;
# endif
# endif
@@ -870,8 +878,10 @@ Closure closure_emission(vec3 rgb)
return cl;
}
-# if defined(MESH_SHADER) && !defined(USE_ALPHA_HASH) && !defined(USE_ALPHA_CLIP) && \
- !defined(SHADOW_SHADER) && !defined(USE_MULTIPLY)
+/* Breaking this across multiple lines causes issues for some older GLSL compilers. */
+/* clang-format off */
+# if defined(MESH_SHADER) && !defined(USE_ALPHA_HASH) && !defined(USE_ALPHA_CLIP) && !defined(SHADOW_SHADER) && !defined(USE_MULTIPLY)
+/* clang-format on */
layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec4 ssrNormals;
layout(location = 2) out vec4 ssrData;
@@ -918,10 +928,19 @@ void main()
/* For Probe capture */
# ifdef USE_SSS
+ float fac = float(!sssToggle);
+
+# ifdef USE_REFRACTION
+ /* SSRefraction pass is done after the SSS pass.
+ * In order to not loose the diffuse light totally we
+ * need to merge the SSS radiance to the main radiance. */
+ fac = 1.0;
+# endif
+
# ifdef USE_SSS_ALBEDO
- fragColor.rgb += cl.sss_data.rgb * cl.sss_albedo.rgb * float(!sssToggle);
+ fragColor.rgb += cl.sss_data.rgb * cl.sss_albedo.rgb * fac;
# else
- fragColor.rgb += cl.sss_data.rgb * float(!sssToggle);
+ fragColor.rgb += cl.sss_data.rgb * fac;
# endif
# endif
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
index 8a10962c6ef..d8cec17af58 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
@@ -5,6 +5,7 @@ uniform sampler2D colorBuffer;
uniform sampler2D depthBuffer;
uniform vec2 dofParams;
+uniform bool unpremult;
#define dof_mul dofParams.x /* distance * aperturesize * invsensorsize */
#define dof_bias dofParams.y /* aperturesize * invsensorsize */
@@ -241,8 +242,12 @@ void main(void)
fragColor = (far_col + near_col + focus_col) * inv_weight_sum;
# ifdef USE_ALPHA_DOF
- /* Unpremult */
- fragColor.rgb /= (fragColor.a > 0.0) ? fragColor.a : 1.0;
+ /* Sigh... viewport expect premult output but
+ * the final render output needs to be with
+ * associated alpha. */
+ if (unpremult) {
+ fragColor.rgb /= (fragColor.a > 0.0) ? fragColor.a : 1.0;
+ }
# endif
}
diff --git a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
index 3ec695fcdbc..ac6751fb5fb 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
@@ -14,7 +14,8 @@ vec4 safe_color(vec4 c)
/**
* Adapted from https://casual-effects.com/g3d/G3D10/data-files/shader/Film/Film_temporalAA.pix
- * which is adapted from https://github.com/gokselgoktas/temporal-anti-aliasing/blob/master/Assets/Resources/Shaders/TemporalAntiAliasing.cginc
+ * which is adapted from
+ * https://github.com/gokselgoktas/temporal-anti-aliasing/blob/master/Assets/Resources/Shaders/TemporalAntiAliasing.cginc
* which is adapted from https://github.com/playdeadgames/temporal
* Optimization by Stubbesaurus and epsilon adjustment to avoid division by zero.
*
@@ -38,7 +39,6 @@ vec3 clip_to_aabb(vec3 color, vec3 minimum, vec3 maximum, vec3 average)
void main()
{
ivec2 texel = ivec2(gl_FragCoord.xy);
- float depth = texelFetch(depthBuffer, texel, 0).r;
vec2 motion = texelFetch(velocityBuffer, texel, 0).rg;
/* Decode from unsigned normalized 16bit texture. */
@@ -95,6 +95,9 @@ void main()
color_history = (out_of_view) ? color : color_history;
FragColor = safe_color(color_history);
+ /* There is some ghost issue if we use the alpha
+ * in the viewport. Overwritting alpha fixes it. */
+ FragColor.a = color.a;
}
#else
diff --git a/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
index b9e038ceeaf..7d701bce5cb 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_velocity_resolve_frag.glsl
@@ -17,6 +17,9 @@ void main()
outData = uv - uv_history;
+ /* HACK: Reject lookdev spheres from TAA reprojection. */
+ outData = (depth > 0.0) ? outData : vec2(0.0);
+
/* Encode to unsigned normalized 16bit texture. */
outData = outData * 0.5 + 0.5;
}
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
index 0c7be71d914..a70ac686efd 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
@@ -161,7 +161,8 @@ vec3 probe_evaluate_cube(int pd_id, vec3 W, vec3 R, float roughness)
/* From Frostbite PBR Course
* Distance based roughness
- * http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf */
+ * http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
+ */
float original_roughness = roughness;
float linear_roughness = sqrt(roughness);
float distance_roughness = saturate(dist * linear_roughness / length(intersection));
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index 7dba3738c12..37b0ebb33cf 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -44,6 +44,14 @@ uniform int hairThicknessRes = 1;
#define CLOSURE_GLOSSY
#endif /* SURFACE_DEFAULT */
+#if !defined(SURFACE_DEFAULT_CLEARCOAT) && !defined(CLOSURE_NAME)
+#define SURFACE_DEFAULT_CLEARCOAT
+#define CLOSURE_NAME eevee_closure_default_clearcoat
+#define CLOSURE_DIFFUSE
+#define CLOSURE_GLOSSY
+#define CLOSURE_CLEARCOAT
+#endif /* SURFACE_DEFAULT_CLEARCOAT */
+
#if !defined(SURFACE_PRINCIPLED) && !defined(CLOSURE_NAME)
#define SURFACE_PRINCIPLED
#define CLOSURE_NAME eevee_closure_principled
@@ -274,7 +282,8 @@ void CLOSURE_NAME(vec3 N
/* ---------------- SPECULAR ENVIRONMENT LIGHTING ----------------- */
/* ---------------------------------------------------------------- */
- /* Accumulate incoming light from all sources until accumulator is full. Then apply Occlusion and BRDF. */
+ /* Accumulate incoming light from all sources until accumulator is full. Then apply Occlusion and
+ * BRDF. */
#ifdef CLOSURE_GLOSSY
vec4 spec_accum = vec4(0.0);
#endif
diff --git a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
index 88dd9f46b55..2cf8501de9b 100644
--- a/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
@@ -164,8 +164,8 @@ void ltc_transform_quad(vec3 N, vec3 V, mat3 Minv, inout vec3 corners[4])
corners[3] = normalize(Minv * corners[3]);
}
-/* If corners have already pass through ltc_transform_quad(), then N **MUST** be vec3(0.0, 0.0, 1.0),
- * corresponding to the Up axis of the shading basis. */
+/* If corners have already pass through ltc_transform_quad(),
+ * then N **MUST** be vec3(0.0, 0.0, 1.0), corresponding to the Up axis of the shading basis. */
float ltc_evaluate_quad(vec3 corners[4], vec3 N)
{
/* Approximation using a sphere of the same solid angle than the quad.
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index 49c4569f585..82581f2327b 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -84,8 +84,8 @@ void prepare_raycast(vec3 ray_origin,
ss_end.w = project_point(ProjectionMatrix, ray_end).z;
/* XXX This is a hack a better method is welcome ! */
- /* We take the delta between the offseted depth and the depth and substract it from the ray depth.
- * This will change the world space thickness appearance a bit but we can have negative
+ /* We take the delta between the offseted depth and the depth and substract it from the ray
+ * depth. This will change the world space thickness appearance a bit but we can have negative
* values without worries. We cannot do this in viewspace because of the perspective division. */
ss_start.w = 2.0 * ss_start.z - ss_start.w;
ss_end.w = 2.0 * ss_end.z - ss_end.w;
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
index 5c0f5adda27..f24032c4360 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl
@@ -36,7 +36,8 @@ vec3 octahedral_to_cubemap_proj(vec2 co)
}
/* Marco Salvi's GDC 2008 presentation about shadow maps pre-filtering techniques slide 24 */
-/* http://advances.realtimerendering.com/s2009/SIGGRAPH%202009%20-%20Lighting%20Research%20at%20Bungie.pdf Slide 55*/
+/* http://advances.realtimerendering.com/s2009/SIGGRAPH%202009%20-%20Lighting%20Research%20at%20Bungie.pdf
+ * Slide 55. */
#define ln_space_prefilter_step(ref, sample) exp(sample - ref)
#define ln_space_prefilter_finalize(ref, sum) (ref + log(shadowInvSampleCount * sum))
diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c
index 29749ce6712..ed8c609c01f 100644
--- a/source/blender/draw/engines/external/external_engine.c
+++ b/source/blender/draw/engines/external/external_engine.c
@@ -54,12 +54,12 @@ typedef struct EXTERNAL_StorageList {
} EXTERNAL_StorageList;
typedef struct EXTERNAL_FramebufferList {
- struct GPUFrameBuffer *default_fb;
+ struct GPUFrameBuffer *depth_buffer_fb;
} EXTERNAL_FramebufferList;
typedef struct EXTERNAL_TextureList {
/* default */
- struct GPUTexture *depth;
+ struct GPUTexture *depth_buffer_tx;
} EXTERNAL_TextureList;
typedef struct EXTERNAL_PassList {
@@ -80,30 +80,77 @@ typedef struct EXTERNAL_Data {
static struct {
/* Depth Pre Pass */
struct GPUShader *depth_sh;
+ bool draw_depth;
} e_data = {NULL}; /* Engine data */
typedef struct EXTERNAL_PrivateData {
DRWShadingGroup *depth_shgrp;
+
+ /* Do we need to update the depth or can we reuse the last calculated texture. */
+ bool update_depth;
+ bool view_updated;
+
+ float last_mat[4][4];
+ float curr_mat[4][4];
} EXTERNAL_PrivateData; /* Transient data */
/* Functions */
-static void external_engine_init(void *UNUSED(vedata))
+static void external_engine_init(void *vedata)
{
+ EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ RegionView3D *rv3d = draw_ctx->rv3d;
+
/* Depth prepass */
if (!e_data.depth_sh) {
e_data.depth_sh = DRW_shader_create_3d_depth_only(GPU_SHADER_CFG_DEFAULT);
}
+
+ if (!stl->g_data) {
+ /* Alloc transient pointers */
+ stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
+ stl->g_data->update_depth = true;
+ stl->g_data->view_updated = false;
+ }
+
+ if (stl->g_data->update_depth == false) {
+ if (rv3d && rv3d->rflag & RV3D_NAVIGATING) {
+ stl->g_data->update_depth = true;
+ }
+ }
+
+ if (stl->g_data->view_updated) {
+ stl->g_data->update_depth = true;
+ stl->g_data->view_updated = false;
+ }
+
+ {
+ float view[4][4];
+ float win[4][4];
+ DRW_viewport_matrix_get(view, DRW_MAT_VIEW);
+ DRW_viewport_matrix_get(win, DRW_MAT_WIN);
+ mul_m4_m4m4(stl->g_data->curr_mat, view, win);
+ if (!equals_m4m4(stl->g_data->curr_mat, stl->g_data->last_mat)) {
+ stl->g_data->update_depth = true;
+ }
+ }
}
static void external_cache_init(void *vedata)
{
EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl;
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
+ EXTERNAL_TextureList *txl = ((EXTERNAL_Data *)vedata)->txl;
+ EXTERNAL_FramebufferList *fbl = ((EXTERNAL_Data *)vedata)->fbl;
- if (!stl->g_data) {
- /* Alloc transient pointers */
- stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
+ {
+ DRW_texture_ensure_fullscreen_2d(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0);
+
+ GPU_framebuffer_ensure_config(&fbl->depth_buffer_fb,
+ {
+ GPU_ATTACHMENT_TEXTURE(txl->depth_buffer_tx),
+ });
}
/* Depth Pass */
@@ -112,6 +159,16 @@ static void external_cache_init(void *vedata)
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL);
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
}
+
+ /* Do not draw depth pass when overlays are turned off. */
+ e_data.draw_depth = false;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const View3D *v3d = draw_ctx->v3d;
+ if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
+ /* mark `update_depth` for when overlays are turned on again. */
+ stl->g_data->update_depth = true;
+ return;
+ }
}
static void external_cache_populate(void *vedata, Object *ob)
@@ -122,10 +179,20 @@ static void external_cache_populate(void *vedata, Object *ob)
return;
}
- struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
- if (geom) {
- /* Depth Prepass */
- DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
+ /* Do not draw depth pass when overlays are turned off. */
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const View3D *v3d = draw_ctx->v3d;
+ if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
+ return;
+ }
+
+ if (stl->g_data->update_depth) {
+ e_data.draw_depth = true;
+ struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
+ if (geom) {
+ /* Depth Prepass */
+ DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
+ }
}
}
@@ -181,7 +248,10 @@ static void external_draw_scene_do(void *vedata)
static void external_draw_scene(void *vedata)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
+ EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl;
+ EXTERNAL_FramebufferList *fbl = ((EXTERNAL_Data *)vedata)->fbl;
+ const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
/* Will be NULL during OpenGL render.
* OpenGL render is used for quick preview (thumbnails or sequencer preview)
@@ -189,7 +259,28 @@ static void external_draw_scene(void *vedata)
if (draw_ctx->evil_C) {
external_draw_scene_do(vedata);
}
- DRW_draw_pass(psl->depth_pass);
+
+ if (e_data.draw_depth) {
+ DRW_draw_pass(psl->depth_pass);
+ // copy result to tmp buffer
+ GPU_framebuffer_blit(dfbl->depth_only_fb, 0, fbl->depth_buffer_fb, 0, GPU_DEPTH_BIT);
+ stl->g_data->update_depth = false;
+ }
+ else {
+ // copy tmp buffer to default
+ GPU_framebuffer_blit(fbl->depth_buffer_fb, 0, dfbl->depth_only_fb, 0, GPU_DEPTH_BIT);
+ }
+
+ copy_m4_m4(stl->g_data->last_mat, stl->g_data->curr_mat);
+}
+
+static void external_view_update(void *vedata)
+{
+ EXTERNAL_Data *data = vedata;
+ EXTERNAL_StorageList *stl = data->stl;
+ if (stl && stl->g_data) {
+ stl->g_data->view_updated = true;
+ }
}
static void external_engine_free(void)
@@ -211,12 +302,13 @@ static DrawEngineType draw_engine_external_type = {
&external_cache_finish,
NULL,
&external_draw_scene,
- NULL,
+ &external_view_update,
NULL,
NULL,
};
-/* Note: currently unused, we should not register unless we want to see this when debugging the view. */
+/* Note: currently unused,
+ * we should not register unless we want to see this when debugging the view. */
RenderEngineType DRW_engine_viewport_external_type = {
NULL,
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 76ec0a61b8c..67ffe62f3c6 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -78,8 +78,8 @@ tGPencilObjectCache *gpencil_object_cache_add(tGPencilObjectCache *cache_array,
tGPencilObjectCache *p = NULL;
/* By default a cache is created with one block with a predefined number of free slots,
- if the size is not enough, the cache is reallocated adding a new block of free slots.
- This is done in order to keep cache small */
+ * if the size is not enough, the cache is reallocated adding a new block of free slots.
+ * This is done in order to keep cache small. */
if (*gp_cache_used + 1 > *gp_cache_size) {
if ((*gp_cache_size == 0) || (cache_array == NULL)) {
p = MEM_callocN(sizeof(struct tGPencilObjectCache) * GP_CACHE_BLOCK_SIZE,
@@ -187,8 +187,8 @@ GpencilBatchGroup *gpencil_group_cache_add(GpencilBatchGroup *cache_array,
GpencilBatchGroup *p = NULL;
/* By default a cache is created with one block with a predefined number of free slots,
- if the size is not enough, the cache is reallocated adding a new block of free slots.
- This is done in order to keep cache small */
+ * if the size is not enough, the cache is reallocated adding a new block of free slots.
+ * This is done in order to keep cache small. */
if (*grp_used + 1 > *grp_size) {
if ((*grp_size == 0) || (cache_array == NULL)) {
p = MEM_callocN(sizeof(struct GpencilBatchGroup) * GPENCIL_GROUPS_BLOCK_SIZE,
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 9e71791fbf3..7dabbcf4c41 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -71,6 +71,40 @@ static void gpencil_set_stroke_point(GPUVertBuf *vbo,
GPU_vertbuf_attr_set(vbo, pos_id, idx, &pt->x);
}
+/* Helper to add buffer_stroke point to vbo */
+static void gpencil_set_buffer_stroke_point(GPUVertBuf *vbo,
+ const bGPDspoint *pt,
+ int idx,
+ uint pos_id,
+ uint color_id,
+ uint thickness_id,
+ uint uvdata_id,
+ uint prev_pos_id,
+ float ref_pt[3],
+ short thickness,
+ const float ink[4])
+{
+
+ float alpha = ink[3] * pt->strength;
+ CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
+ float col[4];
+ ARRAY_SET_ITEMS(col, ink[0], ink[1], ink[2], alpha);
+
+ GPU_vertbuf_attr_set(vbo, color_id, idx, col);
+
+ /* transfer both values using the same shader variable */
+ float uvdata[2] = {pt->uv_fac, pt->uv_rot};
+ GPU_vertbuf_attr_set(vbo, uvdata_id, idx, uvdata);
+
+ /* the thickness of the stroke must be affected by zoom, so a pixel scale is calculated */
+ float thick = max_ff(pt->pressure * thickness, 1.0f);
+ GPU_vertbuf_attr_set(vbo, thickness_id, idx, &thick);
+
+ GPU_vertbuf_attr_set(vbo, pos_id, idx, &pt->x);
+ /* reference point to follow drawing path */
+ GPU_vertbuf_attr_set(vbo, prev_pos_id, idx, ref_pt);
+}
+
/* Helper to add a new fill point and texture coordinates to vertex buffer */
static void gpencil_set_fill_point(GPUVertBuf *vbo,
int idx,
@@ -142,16 +176,20 @@ void DRW_gpencil_get_point_geom(GpencilBatchCacheElem *be,
/* use previous point to determine stroke direction */
bGPDspoint *pt2 = NULL;
+ float fpt[3];
if (i == 0) {
if (gps->totpoints > 1) {
/* extrapolate a point before first point */
- float fpt[3];
pt2 = &gps->points[1];
interp_v3_v3v3(fpt, &pt2->x, &pt->x, 1.5f);
GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt);
}
else {
- GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, &pt->x);
+ /* add small offset to get a vector */
+ copy_v3_v3(fpt, &pt->x);
+ fpt[0] += 0.00001f;
+ fpt[1] += 0.00001f;
+ GPU_vertbuf_attr_set(be->vbo, be->prev_pos_id, be->vbo_len, fpt);
}
}
else {
@@ -433,12 +471,13 @@ GPUBatch *DRW_gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
int totpoints = gpd->runtime.sbuffer_size;
static GPUVertFormat format = {0};
- static uint pos_id, color_id, thickness_id, uvdata_id;
+ static uint pos_id, color_id, thickness_id, uvdata_id, prev_pos_id;
if (format.attr_len == 0) {
pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
thickness_id = GPU_vertformat_attr_add(&format, "thickness", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
uvdata_id = GPU_vertformat_attr_add(&format, "uvdata", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ prev_pos_id = GPU_vertformat_attr_add(&format, "prev_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
@@ -458,9 +497,43 @@ GPUBatch *DRW_gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt);
+ /* use previous point to determine stroke direction (drawing path) */
+ bGPDspoint pt2;
+ float ref_pt[3];
+
+ if (i == 0) {
+ if (totpoints > 1) {
+ /* extrapolate a point before first point */
+ tGPspoint *tpt2 = &points[1];
+ ED_gpencil_tpoint_to_point(ar, origin, tpt2, &pt2);
+ ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt2);
+
+ interp_v3_v3v3(ref_pt, &pt2.x, &pt.x, 1.5f);
+ }
+ else {
+ copy_v3_v3(ref_pt, &pt.x);
+ }
+ }
+ else {
+ tGPspoint *tpt2 = &points[i - 1];
+ ED_gpencil_tpoint_to_point(ar, origin, tpt2, &pt2);
+ ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt2);
+
+ copy_v3_v3(ref_pt, &pt2.x);
+ }
+
/* set point */
- gpencil_set_stroke_point(
- vbo, &pt, idx, pos_id, color_id, thickness_id, uvdata_id, thickness, gpd->runtime.scolor);
+ gpencil_set_buffer_stroke_point(vbo,
+ &pt,
+ idx,
+ pos_id,
+ color_id,
+ thickness_id,
+ uvdata_id,
+ prev_pos_id,
+ ref_pt,
+ thickness,
+ gpd->runtime.scolor);
idx++;
}
@@ -561,8 +634,9 @@ GPUBatch *DRW_gpencil_get_buffer_fill_geom(bGPdata *gpd)
float(*points2d)[2] = MEM_mallocN(sizeof(*points2d) * totpoints, __func__);
/* Convert points to array and triangulate
- * Here a cache is not used because while drawing the information changes all the time, so the cache
- * would be recalculated constantly, so it is better to do direct calculation for each function call
+ * Here a cache is not used because while drawing the information changes all the time, so the
+ * cache would be recalculated constantly, so it is better to do direct calculation for each
+ * function call
*/
for (int i = 0; i < totpoints; i++) {
const tGPspoint *pt = &points[i];
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 320b621f903..4b6c913785d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -421,7 +421,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(GPENCIL_e_data *e_data,
DRW_shgroup_uniform_float(grp, "texture_opacity", &gp_style->texture_opacity, 1);
DRW_shgroup_uniform_float(grp, "layer_opacity", &gpl->opacity, 1);
- stl->shgroups[id].texture_mix = gp_style->flag & GP_STYLE_COLOR_TEX_MIX ? 1 : 0;
+ stl->shgroups[id].texture_mix = gp_style->flag & GP_STYLE_FILL_TEX_MIX ? 1 : 0;
DRW_shgroup_uniform_int(grp, "texture_mix", &stl->shgroups[id].texture_mix, 1);
stl->shgroups[id].texture_flip = gp_style->flag & GP_STYLE_COLOR_FLIP_FILL ? 1 : 0;
@@ -450,7 +450,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(GPENCIL_e_data *e_data,
DRW_shgroup_uniform_vec4(grp, "wire_color", stl->shgroups[id].wire_color, 1);
/* image texture */
- if ((gp_style->flag & GP_STYLE_COLOR_TEX_MIX) ||
+ if ((gp_style->flag & GP_STYLE_FILL_TEX_MIX) ||
(gp_style->fill_style & GP_STYLE_FILL_STYLE_TEXTURE)) {
ImBuf *ibuf;
Image *image = gp_style->ima;
@@ -569,6 +569,12 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(GPENCIL_e_data *e_data,
/* wire color */
set_wireframe_color(ob, gpl, v3d, stl, gp_style, id, false);
DRW_shgroup_uniform_vec4(grp, "wire_color", stl->shgroups[id].wire_color, 1);
+
+ /* mix stroke factor */
+ stl->shgroups[id].mix_stroke_factor = (gp_style->flag & GP_STYLE_STROKE_TEX_MIX) ?
+ gp_style->mix_stroke_factor :
+ 0.0f;
+ DRW_shgroup_uniform_float(grp, "mix_stroke_factor", &stl->shgroups[id].mix_stroke_factor, 1);
}
else {
stl->storage->obj_scale = 1.0f;
@@ -591,8 +597,16 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(GPENCIL_e_data *e_data,
/* viewport x-ray */
DRW_shgroup_uniform_int(grp, "viewport_xray", &stl->storage->is_xray, 1);
DRW_shgroup_uniform_int(grp, "shading_type", (const int *)&stl->storage->shade_render, 2);
+
+ /* mix stroke factor */
+ stl->storage->mix_stroke_factor = (gp_style->flag & GP_STYLE_STROKE_TEX_MIX) ?
+ gp_style->mix_stroke_factor :
+ 0.0f;
+ DRW_shgroup_uniform_float(grp, "mix_stroke_factor", &stl->storage->mix_stroke_factor, 1);
}
+ DRW_shgroup_uniform_vec4(grp, "colormix", gp_style->stroke_rgba, 1);
+
if ((gpd) && (id > -1)) {
stl->shgroups[id].xray_mode = (ob->dtx & OB_DRAWXRAY) ? GP_XRAY_FRONT : GP_XRAY_3DSPACE;
DRW_shgroup_uniform_int(grp, "xraymode", &stl->shgroups[id].xray_mode, 1);
@@ -703,6 +717,16 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(GPENCIL_e_data *e_data,
/* wire color */
set_wireframe_color(ob, gpl, v3d, stl, gp_style, id, false);
DRW_shgroup_uniform_vec4(grp, "wire_color", stl->shgroups[id].wire_color, 1);
+
+ /* mix stroke factor */
+ stl->shgroups[id].mix_stroke_factor = (gp_style->flag & GP_STYLE_STROKE_TEX_MIX) ?
+ gp_style->mix_stroke_factor :
+ 0.0f;
+ DRW_shgroup_uniform_float(grp, "mix_stroke_factor", &stl->shgroups[id].mix_stroke_factor, 1);
+
+ /* lock rotation of dots and boxes */
+ stl->shgroups[id].use_follow_path = (gp_style->flag & GP_STYLE_COLOR_LOCK_DOTS) ? 0 : 1;
+ DRW_shgroup_uniform_int(grp, "use_follow_path", &stl->shgroups[id].use_follow_path, 1);
}
else {
stl->storage->obj_scale = 1.0f;
@@ -724,25 +748,28 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(GPENCIL_e_data *e_data,
DRW_shgroup_uniform_vec2(grp, "gradient_s", stl->storage->gradient_s, 1);
/* viewport x-ray */
- stl->shgroups[id].is_xray = ((ob) && (ob->dt == OB_WIRE)) ? 1 : stl->storage->is_xray;
- DRW_shgroup_uniform_int(grp, "viewport_xray", (const int *)&stl->shgroups[id].is_xray, 1);
+ DRW_shgroup_uniform_int(grp, "viewport_xray", &stl->storage->is_xray, 1);
DRW_shgroup_uniform_int(grp, "shading_type", (const int *)&stl->storage->shade_render, 2);
+
+ /* mix stroke factor */
+ stl->storage->mix_stroke_factor = (gp_style->flag & GP_STYLE_STROKE_TEX_MIX) ?
+ gp_style->mix_stroke_factor :
+ 0.0f;
+ DRW_shgroup_uniform_float(grp, "mix_stroke_factor", &stl->storage->mix_stroke_factor, 1);
+
+ /* lock rotation of dots and boxes */
+ DRW_shgroup_uniform_int(grp, "use_follow_path", &stl->storage->use_follow_path, 1);
}
+ DRW_shgroup_uniform_vec4(grp, "colormix", gp_style->stroke_rgba, 1);
+
if ((gpd) && (id > -1)) {
stl->shgroups[id].xray_mode = (ob->dtx & OB_DRAWXRAY) ? GP_XRAY_FRONT : GP_XRAY_3DSPACE;
DRW_shgroup_uniform_int(grp, "xraymode", (const int *)&stl->shgroups[id].xray_mode, 1);
-
- /* lock rotation of dots and boxes */
- stl->shgroups[id].use_follow_path = (gp_style->flag & GP_STYLE_COLOR_LOCK_DOTS) ? 0 : 1;
- DRW_shgroup_uniform_int(grp, "use_follow_path", &stl->shgroups[id].use_follow_path, 1);
}
else {
/* for drawing always on predefined z-depth */
DRW_shgroup_uniform_int(grp, "xraymode", &stl->storage->xray, 1);
-
- /* lock rotation of dots and boxes */
- DRW_shgroup_uniform_int(grp, "use_follow_path", &stl->storage->use_follow_path, 1);
}
/* image texture */
@@ -1045,7 +1072,8 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache,
DRW_gpencil_recalc_geometry_caches(ob, gpl, gp_style, src_gps);
}
- /* if the fill has any value, it's considered a fill and is not drawn if simplify fill is enabled */
+ /* if the fill has any value, it's considered a fill and is not drawn if simplify fill is
+ * enabled */
if ((stl->storage->simplify_fill) &&
(scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_REMOVE_FILL_LINE)) {
if ((gp_style->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) ||
@@ -1340,7 +1368,8 @@ static void gpencil_copy_frame(bGPDframe *gpf, bGPDframe *derived_gpf)
}
}
-/* Triangulate stroke for high quality fill (this is done only if cache is null or stroke was modified) */
+/* Triangulate stroke for high quality fill (this is done only if cache is null or stroke was
+ * modified) */
void DRW_gpencil_triangulate_stroke_fill(Object *ob, bGPDstroke *gps)
{
BLI_assert(gps->totpoints >= 3);
@@ -1429,6 +1458,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
View3D *v3d = draw_ctx->v3d;
const bool overlay = v3d != NULL ? (bool)((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : true;
Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
+ const bool is_paint_tool = (bool)((brush) && (brush->gpencil_tool == GPAINT_TOOL_DRAW));
bGPdata *gpd_eval = ob->data;
/* need the original to avoid cow overhead while drawing */
bGPdata *gpd = (bGPdata *)DEG_get_original_id(&gpd_eval->id);
@@ -1554,7 +1584,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
const bool is_show_gizmo = (((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) &&
((v3d->gizmo_flag & V3D_GIZMO_HIDE_TOOL) == 0));
- if ((overlay) && (is_cppoint || is_speed_guide) && (is_show_gizmo) &&
+ if ((overlay) && (is_paint_tool) && (is_cppoint || is_speed_guide) && (is_show_gizmo) &&
((gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0)) {
DRWShadingGroup *shgrp = DRW_shgroup_create(e_data->gpencil_edit_point_sh, psl->drawing_pass);
const float *viewport_size = DRW_viewport_size_get();
@@ -1621,6 +1651,16 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
int idx = 0;
bool tag_first = false;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const View3D *v3d = draw_ctx->v3d;
+
+ const bool overlay = draw_ctx->v3d != NULL ?
+ (bool)((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) :
+ true;
+ const bool main_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true;
+ const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && main_onion &&
+ DRW_gpencil_onion_active(gpd) && overlay;
+
int start_stroke = 0;
int start_point = 0;
int start_fill = 0;
@@ -1680,14 +1720,14 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
elm->onion,
scale,
cache_ob->shading_type);
-
- DRW_shgroup_call_range_add(shgrp,
- cache->b_stroke.batch,
- (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix :
- cache_ob->obmat,
- start_stroke,
- len);
-
+ if ((do_onion) || (elm->onion == false)) {
+ DRW_shgroup_call_range_add(shgrp,
+ cache->b_stroke.batch,
+ (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix :
+ cache_ob->obmat,
+ start_stroke,
+ len);
+ }
stl->storage->shgroup_id++;
start_stroke = elm->vertex_idx;
break;
@@ -1709,13 +1749,14 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
scale,
cache_ob->shading_type);
- DRW_shgroup_call_range_add(shgrp,
- cache->b_point.batch,
- (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix :
- cache_ob->obmat,
- start_point,
- len);
-
+ if ((do_onion) || (elm->onion == false)) {
+ DRW_shgroup_call_range_add(shgrp,
+ cache->b_point.batch,
+ (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix :
+ cache_ob->obmat,
+ start_point,
+ len);
+ }
stl->storage->shgroup_id++;
start_point = elm->vertex_idx;
break;
@@ -1734,13 +1775,14 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
stl->storage->shgroup_id,
cache_ob->shading_type);
- DRW_shgroup_call_range_add(shgrp,
- cache->b_fill.batch,
- (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix :
- cache_ob->obmat,
- start_fill,
- len);
-
+ if ((do_onion) || (elm->onion == false)) {
+ DRW_shgroup_call_range_add(shgrp,
+ cache->b_fill.batch,
+ (!cache_ob->is_dup_ob) ? gpf->runtime.viewmatrix :
+ cache_ob->obmat,
+ start_fill,
+ len);
+ }
stl->storage->shgroup_id++;
start_fill = elm->vertex_idx;
break;
@@ -1870,6 +1912,28 @@ void DRW_gpencil_populate_multiedit(GPENCIL_e_data *e_data,
cache->is_dirty = false;
}
+/* ensure there is a derived frame */
+static void gpencil_ensure_derived_frame(bGPdata *gpd,
+ bGPDlayer *gpl,
+ bGPDframe *gpf,
+ GpencilBatchCache *cache,
+ bGPDframe **derived_gpf)
+{
+ /* create derived frames array data or expand */
+ int derived_idx = BLI_findindex(&gpd->layers, gpl);
+ *derived_gpf = &cache->derived_array[derived_idx];
+
+ /* if no derived frame or dirty cache, create a new one */
+ if ((*derived_gpf == NULL) || (cache->is_dirty)) {
+ if (*derived_gpf != NULL) {
+ /* first clear temp data */
+ BKE_gpencil_free_frame_runtime_data(*derived_gpf);
+ }
+ /* create new data (do not assign new memory)*/
+ gpencil_copy_frame(gpf, *derived_gpf);
+ }
+}
+
/* helper for populate a complete grease pencil datablock */
void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data,
void *vedata,
@@ -1887,9 +1951,6 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data,
int cfra_eval = (int)DEG_get_ctime(draw_ctx->depsgraph);
bGPDframe *derived_gpf = NULL;
- const bool main_onion = v3d != NULL ? (v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) : true;
- const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && main_onion &&
- DRW_gpencil_onion_active(gpd);
const bool overlay = v3d != NULL ? (bool)((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) : true;
const bool time_remap = BKE_gpencil_has_time_modifiers(ob);
@@ -1965,25 +2026,14 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data,
}
/* create derived frames array data or expand */
- int derived_idx = BLI_findindex(&gpd->layers, gpl);
- derived_gpf = &cache->derived_array[derived_idx];
-
- /* if no derived frame or dirty cache, create a new one */
- if ((derived_gpf == NULL) || (cache->is_dirty)) {
- if (derived_gpf != NULL) {
- /* first clear temp data */
- BKE_gpencil_free_frame_runtime_data(derived_gpf);
- }
- /* create new data (do not assign new memory)*/
- gpencil_copy_frame(gpf, derived_gpf);
- }
+ gpencil_ensure_derived_frame(gpd, gpl, gpf, cache, &derived_gpf);
/* draw onion skins */
if (!ID_IS_LINKED(&gpd->id)) {
- if ((do_onion) && (gpl->onion_flag & GP_LAYER_ONIONSKIN) &&
+ if ((gpl->onion_flag & GP_LAYER_ONIONSKIN) &&
((!playing) || (gpd->onion_flag & GP_ONION_GHOST_ALWAYS)) && (!cache_ob->is_dup_ob) &&
(gpd->id.us <= 1)) {
- if (((!stl->storage->is_render) && (overlay)) ||
+ if ((!stl->storage->is_render) ||
((stl->storage->is_render) && (gpd->onion_flag & GP_ONION_GHOST_ALWAYS))) {
gpencil_draw_onionskins(cache, vedata, ob, gpd, gpl, gpf);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 6fa07245396..ea578187765 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -328,7 +328,8 @@ void GPENCIL_cache_init(void *vedata)
stl->g_data->shgrps_edit_point = NULL;
if (!stl->shgroups) {
- /* Alloc maximum size because count strokes is very slow and can be very complex due onion skinning.
+ /* Alloc maximum size because count strokes is very slow and can be very complex due onion
+ * skinning.
*/
stl->shgroups = MEM_mallocN(sizeof(GPENCIL_shgroup) * GPENCIL_MAX_SHGROUPS, "GPENCIL_shgroup");
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 3add2cb0f1b..2ac1dc3211c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -134,6 +134,8 @@ typedef struct GPENCIL_shgroup {
float gradient_f;
float gradient_s[2];
+ float mix_stroke_factor;
+
/* color of the wireframe */
float wire_color[4];
/* shading type and mode */
@@ -182,6 +184,8 @@ typedef struct GPENCIL_Storage {
float gradient_s[2];
int use_follow_path;
+ float mix_stroke_factor;
+
/* Render Matrices and data */
float persmat[4][4], persinv[4][4];
float viewmat[4][4], viewinv[4][4];
diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c
index 282c4ca3a77..e6a3f45d60d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_render.c
+++ b/source/blender/draw/engines/gpencil/gpencil_render.c
@@ -18,7 +18,7 @@
/** \file
* \ingroup draw
- */
+ */
#include "BLI_rect.h"
#include "DRW_render.h"
@@ -36,9 +36,9 @@
#include "gpencil_engine.h"
/* Get pixel size for render
- * This function uses the same calculation used for viewport, because if use
- * camera pixelsize, the result is not correct.
- */
+ * This function uses the same calculation used for viewport, because if use
+ * camera pixelsize, the result is not correct.
+ */
static float get_render_pixelsize(float persmat[4][4], int winx, int winy)
{
float v1[3], v2[3];
@@ -138,10 +138,12 @@ static void GPENCIL_render_update_viewvecs(float invproj[4][4],
{
/* view vectors for the corners of the view frustum.
* Can be used to recreate the world space position easily */
- float view_vecs[4][4] = {{-1.0f, -1.0f, -1.0f, 1.0f},
- {1.0f, -1.0f, -1.0f, 1.0f},
- {-1.0f, 1.0f, -1.0f, 1.0f},
- {-1.0f, -1.0f, 1.0f, 1.0f}};
+ float view_vecs[4][4] = {
+ {-1.0f, -1.0f, -1.0f, 1.0f},
+ {1.0f, -1.0f, -1.0f, 1.0f},
+ {-1.0f, 1.0f, -1.0f, 1.0f},
+ {-1.0f, -1.0f, 1.0f, 1.0f},
+ };
/* convert the view vectors to view space */
const bool is_persp = (winmat[3][3] == 0.0f);
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index b133d9310b0..355235618f6 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -119,10 +119,11 @@ static void GPENCIL_dof_nearfar(Object *camera, float coc, float nearfar[2])
float focus_dist = BKE_camera_object_dof_distance(camera);
float focal_len = cam->lens;
- /* this is factor that converts to the scene scale. focal length and sensor are expressed in mm
- * unit.scale_length is how many meters per blender unit we have. We want to convert to blender units though
- * because the shader reads coordinates in world space, which is in blender units.
- * Note however that focus_distance is already in blender units and shall not be scaled here (see T48157). */
+ /* This is factor that converts to the scene scale. focal length and sensor are expressed in mm
+ * unit.scale_length is how many meters per blender unit we have. We want to convert to blender
+ * units though because the shader reads coordinates in world space, which is in blender units.
+ * Note however that focus_distance is already in blender units and shall not be scaled here
+ * (see T48157). */
float scale = (scene->unit.system) ? scene->unit.scale_length : 1.0f;
float scale_camera = 0.001f / scale;
/* we want radius here for the aperture number */
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl
index b5d0a5bce71..8c3fd022004 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl
@@ -16,6 +16,12 @@ vec2 toScreenSpace(vec4 vertex)
return vec2(vertex.xy / vertex.w) * Viewport;
}
+/* get zdepth value */
+float getZdepth(vec4 point)
+{
+ return min(-0.05, (point.z / point.w));
+}
+
void main(void)
{
vec4 P0 = gl_in[0].gl_Position;
@@ -26,22 +32,22 @@ void main(void)
/* generate the triangle strip */
mTexCoord = vec2(0, 1);
mColor = finalColor[0];
- gl_Position = vec4(vec2(sp0.x - size, sp0.y + size) / Viewport, 0, 1.0);
+ gl_Position = vec4(vec2(sp0.x - size, sp0.y + size) / Viewport, getZdepth(P0), 1.0);
EmitVertex();
mTexCoord = vec2(0, 0);
mColor = finalColor[0];
- gl_Position = vec4(vec2(sp0.x - size, sp0.y - size) / Viewport, 0, 1.0);
+ gl_Position = vec4(vec2(sp0.x - size, sp0.y - size) / Viewport, getZdepth(P0), 1.0);
EmitVertex();
mTexCoord = vec2(1, 1);
mColor = finalColor[0];
- gl_Position = vec4(vec2(sp0.x + size, sp0.y + size) / Viewport, 0, 1.0);
+ gl_Position = vec4(vec2(sp0.x + size, sp0.y + size) / Viewport, getZdepth(P0), 1.0);
EmitVertex();
mTexCoord = vec2(1, 0);
mColor = finalColor[0];
- gl_Position = vec4(vec2(sp0.x + size, sp0.y - size) / Viewport, 0, 1.0);
+ gl_Position = vec4(vec2(sp0.x + size, sp0.y - size) / Viewport, getZdepth(P0), 1.0);
EmitVertex();
EndPrimitive();
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
index 632c63a39aa..acf60fc2d59 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
@@ -177,10 +177,11 @@ void main()
/* set zdepth */
if (xraymode == GP_XRAY_FRONT) {
- gl_FragDepth = 0.000001;
+ gl_FragDepth = min(-0.05, (gl_FragCoord.z / gl_FragCoord.w));
}
else if (xraymode == GP_XRAY_3DSPACE) {
- /* if 3D mode, move slightly the fill to avoid z-fighting between stroke and fill on same stroke */
+ /* if 3D mode, move slightly the fill to avoid z-fighting between stroke and fill on same
+ * stroke */
if (drawmode == GP_DRAWMODE_3D) {
gl_FragDepth = gl_FragCoord.z * 1.0001;
}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
index c8af822bc9e..cc47e12b303 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
@@ -5,6 +5,10 @@ uniform sampler2D myTexture;
uniform float gradient_f;
uniform vec2 gradient_s;
+uniform vec4 colormix;
+uniform float mix_stroke_factor;
+uniform int shading_type[2];
+
in vec4 mColor;
in vec2 mTexCoord;
out vec4 fragColor;
@@ -20,50 +24,82 @@ out vec4 fragColor;
#define GPENCIL_COLOR_TEXTURE 1
#define GPENCIL_COLOR_PATTERN 2
+#define OB_SOLID 3
+#define V3D_SHADING_TEXTURE_COLOR 3
+
+bool no_texture = (shading_type[0] == OB_SOLID) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR);
+
/* Function to check the point inside ellipse */
-float checkpoint(vec2 pt, vec2 radius)
+float check_ellipse_point(vec2 pt, vec2 radius)
{
float p = (pow(pt.x, 2) / pow(radius.x, 2)) + (pow(pt.y, 2) / pow(radius.y, 2));
return p;
}
+/* Function to check the point inside box */
+vec2 check_box_point(vec2 pt, vec2 radius)
+{
+ vec2 rtn;
+ rtn.x = abs(pt.x) / radius.x;
+ rtn.y = abs(pt.y) / radius.y;
+
+ return rtn;
+}
+
void main()
{
vec2 centered = mTexCoord - vec2(0.5);
- float ellip = checkpoint(centered, vec2(gradient_s / 2.0));
+ float ellip = check_ellipse_point(centered, vec2(gradient_s / 2.0));
+ vec2 box;
if (mode != GPENCIL_MODE_BOX) {
if (ellip > 1.0) {
discard;
}
}
+ else {
+ box = check_box_point(centered, vec2(gradient_s / 2.0));
+ if ((box.x > 1.0) || (box.y > 1.0)) {
+ discard;
+ }
+ }
vec4 tmp_color = texture2D(myTexture, mTexCoord);
/* Solid */
- if (color_type == GPENCIL_COLOR_SOLID) {
+ if ((color_type == GPENCIL_COLOR_SOLID) || (no_texture)) {
fragColor = mColor;
}
/* texture */
- if (color_type == GPENCIL_COLOR_TEXTURE) {
- fragColor = texture2D(myTexture, mTexCoord);
+ if ((color_type == GPENCIL_COLOR_TEXTURE) && (!no_texture)) {
+ vec4 text_color = texture2D(myTexture, mTexCoord);
+ if (mix_stroke_factor > 0.0) {
+ fragColor.rgb = mix(text_color.rgb, colormix.rgb, mix_stroke_factor);
+ fragColor.a = text_color.a;
+ }
+ else {
+ fragColor = text_color;
+ }
+
/* mult both alpha factor to use strength factor with texture */
fragColor.a = min(fragColor.a * mColor.a, fragColor.a);
}
/* pattern */
- if (color_type == GPENCIL_COLOR_PATTERN) {
+ if ((color_type == GPENCIL_COLOR_PATTERN) && (!no_texture)) {
vec4 text_color = texture2D(myTexture, mTexCoord);
fragColor = mColor;
/* mult both alpha factor to use strength factor with color alpha limit */
fragColor.a = min(text_color.a * mColor.a, mColor.a);
}
- if ((mode == GPENCIL_MODE_DOTS) && (gradient_f < 1.0)) {
- float dist = length(centered) * 2;
+ if (gradient_f < 1.0) {
+ float dist = length(centered) * 2.0;
float decay = dist * (1.0 - gradient_f) * fragColor.a;
fragColor.a = clamp(fragColor.a - decay, 0.0, 1.0);
- fragColor.a = fragColor.a * (1.0 - ellip);
+ if (mode == GPENCIL_MODE_DOTS) {
+ fragColor.a = fragColor.a * (1.0 - ellip);
+ }
}
if (fragColor.a < 0.0035) {
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
index 2fb48ac5147..a64a7ecb9be 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
@@ -31,7 +31,7 @@ vec2 toScreenSpace(vec4 vertex)
float getZdepth(vec4 point)
{
if (xraymode == GP_XRAY_FRONT) {
- return 0.000001;
+ return min(-0.05, (point.z / point.w));
}
if (xraymode == GP_XRAY_3DSPACE) {
return (point.z / point.w);
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
index 92c9acf1f2a..9cef7601770 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
@@ -42,7 +42,7 @@ void main()
else {
float size = (ProjectionMatrix[3][3] == 0.0) ? (thickness / (gl_Position.z * defaultpixsize)) :
(thickness / defaultpixsize);
- finalThickness = max(size * objscale, 4.0); /* minimum 4 pixels */
+ finalThickness = max(size * objscale, 0.5); /* set a minimum size */
}
/* for wireframe override size and color */
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
index 35d07306361..6b7cee888ea 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
@@ -3,6 +3,10 @@ uniform sampler2D myTexture;
uniform float gradient_f;
+uniform vec4 colormix;
+uniform float mix_stroke_factor;
+uniform int shading_type[2];
+
in vec4 mColor;
in vec2 mTexCoord;
in vec2 uvfac;
@@ -18,6 +22,11 @@ out vec4 fragColor;
#define ENDCAP 1.0
+#define OB_SOLID 3
+#define V3D_SHADING_TEXTURE_COLOR 3
+
+bool no_texture = (shading_type[0] == OB_SOLID) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR);
+
void main()
{
@@ -30,8 +39,8 @@ void main()
discard;
}
}
- /* Solid */
- if (color_type == GPENCIL_COLOR_SOLID) {
+
+ if ((color_type == GPENCIL_COLOR_SOLID) || (no_texture)) {
fragColor = tColor;
}
@@ -45,13 +54,20 @@ void main()
}
/* texture */
- if (color_type == GPENCIL_COLOR_TEXTURE) {
- fragColor = text_color;
+ if ((color_type == GPENCIL_COLOR_TEXTURE) && (!no_texture)) {
+ if (mix_stroke_factor > 0.0) {
+ fragColor.rgb = mix(text_color.rgb, colormix.rgb, mix_stroke_factor);
+ fragColor.a = text_color.a;
+ }
+ else {
+ fragColor = text_color;
+ }
+
/* mult both alpha factor to use strength factor */
fragColor.a = min(fragColor.a * tColor.a, fragColor.a);
}
/* pattern */
- if (color_type == GPENCIL_COLOR_PATTERN) {
+ if ((color_type == GPENCIL_COLOR_PATTERN) && (!no_texture)) {
fragColor = tColor;
/* mult both alpha factor to use strength factor with color alpha limit */
fragColor.a = min(text_color.a * tColor.a, tColor.a);
@@ -63,7 +79,7 @@ void main()
float d = abs(mTexCoord.y - 0.5) * (1.1 - gradient_f);
float alpha = 1.0 - clamp((fragColor.a - (d * 2.0)), 0.03, 1.0);
fragColor.a = smoothstep(fragColor.a, 0.0, alpha);
-
+
}
*/
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
index 7e62d6f0d64..b90f5b33a57 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl
@@ -35,7 +35,7 @@ vec2 toScreenSpace(vec4 vertex)
float getZdepth(vec4 point)
{
if (xraymode == GP_XRAY_FRONT) {
- return 0.000001;
+ return min(-0.05, (point.z / point.w));
}
if (xraymode == GP_XRAY_3DSPACE) {
return (point.z / point.w);
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
index 54440f7b120..0428b0d408c 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl
@@ -362,9 +362,9 @@ void main()
for (int dX = -1; dX <= 1; ++dX) {
for (int dY = -1; dY <= 1; ++dY) {
vec2 offset = vec2(float(dX), float(dY));
- /* If a pixel in the window is located at (x+dX, y+dY), put it at index (dX + R)(2R + 1) + (dY + R) of the
- * pixel array. This will fill the pixel array, with the top left pixel of the window at pixel[0] and the
- * bottom right pixel of the window at pixel[N-1]. */
+ /* If a pixel in the window is located at (x+dX, y+dY), put it at index (dX + R)(2R + 1) +
+ * (dY + R) of the pixel array. This will fill the pixel array, with the top left pixel of
+ * the window at pixel[0] and the bottom right pixel of the window at pixel[N-1]. */
v[(dX + 1) * 3 + (dY + 1)] = toVec(texture(blurTex, uv + offset * pixel_size * rad));
}
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
index e654141df5c..5eff0b41e20 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
@@ -25,6 +25,9 @@ in vec3 normal_viewport;
#ifdef V3D_SHADING_TEXTURE_COLOR
in vec2 uv_interp;
#endif
+#ifdef V3D_SHADING_VERTEX_COLOR
+in vec3 vertexColor;
+#endif
#ifdef V3D_LIGHTING_MATCAP
uniform sampler2D matcapImage;
#endif
@@ -42,11 +45,13 @@ void main()
{
vec4 diffuse_color;
-#ifdef V3D_SHADING_TEXTURE_COLOR
+#if defined(V3D_SHADING_TEXTURE_COLOR)
diffuse_color = workbench_sample_texture(image, uv_interp, imageSrgb, imageNearest);
if (diffuse_color.a < ImageTransparencyCutoff) {
discard;
}
+#elif defined(V3D_SHADING_VERTEX_COLOR)
+ diffuse_color = vec4(vertexColor, 1.0);
#else
diffuse_color = vec4(materialDiffuseColor, 1.0);
#endif /* V3D_SHADING_TEXTURE_COLOR */
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
index 6b2962a66da..2596fc4cf88 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
@@ -16,6 +16,9 @@ in vec3 normal_viewport;
#ifdef V3D_SHADING_TEXTURE_COLOR
in vec2 uv_interp;
#endif
+#ifdef V3D_SHADING_VERTEX_COLOR
+in vec3 vertexColor;
+#endif
#ifdef HAIR_SHADER
flat in float hair_rand;
@@ -37,11 +40,13 @@ void main()
float metallic, roughness;
vec4 color;
-# ifdef V3D_SHADING_TEXTURE_COLOR
+# if defined(V3D_SHADING_TEXTURE_COLOR)
color = workbench_sample_texture(image, uv_interp, imageSrgb, imageNearest);
if (color.a < ImageTransparencyCutoff) {
discard;
}
+# elif defined(V3D_SHADING_VERTEX_COLOR)
+ color.rgb = vertexColor;
# else
color.rgb = materialDiffuseColor;
# endif
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
index dd737063f61..f2c684cdb6a 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
@@ -10,6 +10,9 @@ uniform mat3 NormalMatrix;
in vec3 pos;
in vec3 nor;
in vec2 u; /* active texture layer */
+# ifdef V3D_SHADING_VERTEX_COLOR
+in vec3 c; /* active color */
+# endif
# define uv u
#else /* HAIR_SHADER */
# ifdef V3D_SHADING_TEXTURE_COLOR
@@ -25,6 +28,9 @@ out vec3 normal_viewport;
#ifdef V3D_SHADING_TEXTURE_COLOR
out vec2 uv_interp;
#endif
+#ifdef V3D_SHADING_VERTEX_COLOR
+out vec3 vertexColor;
+#endif
/* From http://libnoise.sourceforge.net/noisegen/index.html */
float integer_noise(int n)
@@ -34,6 +40,16 @@ float integer_noise(int n)
return (float(nn) / 1073741824.0);
}
+#ifdef V3D_SHADING_VERTEX_COLOR
+vec3 srgb_to_linear_attr(vec3 c)
+{
+ c = max(c, vec3(0.0));
+ vec3 c1 = c * (1.0 / 12.92);
+ vec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4));
+ return mix(c1, c2, step(vec3(0.04045), c));
+}
+#endif
+
void main()
{
#ifdef HAIR_SHADER
@@ -68,6 +84,12 @@ void main()
uv_interp = uv;
#endif
+#ifdef V3D_SHADING_VERTEX_COLOR
+# ifndef HAIR_SHADER
+ vertexColor = srgb_to_linear_attr(c);
+# endif
+#endif
+
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
normal_viewport = NormalMatrix * nor;
# ifndef HAIR_SHADER
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
index 26ebe7a4553..a1c269d5a65 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
@@ -64,7 +64,8 @@ float max_v3(vec3 v)
float line_unit_box_intersect_dist(vec3 lineorigin, vec3 linedirection)
{
- /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ */
+ /* https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
+ */
vec3 firstplane = (vec3(1.0) - lineorigin) / linedirection;
vec3 secondplane = (vec3(-1.0) - lineorigin) / linedirection;
vec3 furthestplane = min(firstplane, secondplane);
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index 91f4f351c7b..5d7bdc72546 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -209,15 +209,15 @@ static GPUShader *workbench_cavity_shader_get(bool cavity, bool curvature)
}
static GPUShader *ensure_deferred_prepass_shader(WORKBENCH_PrivateData *wpd,
- bool use_textures,
+ bool is_uniform_color,
bool is_hair,
eGPUShaderConfig sh_cfg)
{
WORKBENCH_DEFERRED_Shaders *sh_data = &e_data.sh_data[sh_cfg];
- int index = workbench_material_get_prepass_shader_index(wpd, use_textures, is_hair);
+ int index = workbench_material_get_prepass_shader_index(wpd, is_uniform_color, is_hair);
if (sh_data->prepass_sh_cache[index] == NULL) {
const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
- char *defines = workbench_material_build_defines(wpd, use_textures, is_hair);
+ char *defines = workbench_material_build_defines(wpd, is_uniform_color, is_hair);
char *prepass_vert = workbench_build_prepass_vert(is_hair);
char *prepass_frag = workbench_build_prepass_frag();
sh_data->prepass_sh_cache[index] = GPU_shader_create_from_arrays({
@@ -263,10 +263,10 @@ static GPUShader *ensure_background_shader(WORKBENCH_PrivateData *wpd)
static void select_deferred_shaders(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg)
{
- wpd->prepass_solid_sh = ensure_deferred_prepass_shader(wpd, false, false, sh_cfg);
- wpd->prepass_solid_hair_sh = ensure_deferred_prepass_shader(wpd, false, true, sh_cfg);
- wpd->prepass_texture_sh = ensure_deferred_prepass_shader(wpd, true, false, sh_cfg);
- wpd->prepass_texture_hair_sh = ensure_deferred_prepass_shader(wpd, true, true, sh_cfg);
+ wpd->prepass_sh = ensure_deferred_prepass_shader(wpd, false, false, sh_cfg);
+ wpd->prepass_hair_sh = ensure_deferred_prepass_shader(wpd, false, true, sh_cfg);
+ wpd->prepass_uniform_sh = ensure_deferred_prepass_shader(wpd, true, false, sh_cfg);
+ wpd->prepass_uniform_hair_sh = ensure_deferred_prepass_shader(wpd, true, true, sh_cfg);
wpd->composite_sh = ensure_deferred_composite_shader(wpd);
wpd->background_sh = ensure_background_shader(wpd);
}
@@ -846,8 +846,7 @@ static WORKBENCH_MaterialData *get_or_create_material_data(WORKBENCH_Data *vedat
if (material == NULL) {
material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), __func__);
material->shgrp = DRW_shgroup_create(
- (color_type == V3D_SHADING_TEXTURE_COLOR) ? wpd->prepass_texture_sh :
- wpd->prepass_solid_sh,
+ (wpd->shading.color_type == color_type) ? wpd->prepass_sh : wpd->prepass_uniform_sh,
(ob->dtx & OB_DRAWXRAY) ? psl->ghost_prepass_pass : psl->prepass_pass);
workbench_material_copy(material, &material_template);
DRW_shgroup_stencil_mask(material->shgrp, (ob->dtx & OB_DRAWXRAY) ? 0x00 : 0xFF);
@@ -881,13 +880,13 @@ static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *o
ImageUser *iuser;
int interp;
workbench_material_get_image_and_mat(ob, part->omat, &image, &iuser, &interp, &mat);
- int color_type = workbench_material_determine_color_type(wpd, image, ob);
+ int color_type = workbench_material_determine_color_type(wpd, image, ob, false);
WORKBENCH_MaterialData *material = get_or_create_material_data(
vedata, ob, mat, image, iuser, color_type, interp);
- struct GPUShader *shader = (color_type != V3D_SHADING_TEXTURE_COLOR) ?
- wpd->prepass_solid_hair_sh :
- wpd->prepass_texture_hair_sh;
+ struct GPUShader *shader = (wpd->shading.color_type == color_type) ?
+ wpd->prepass_hair_sh :
+ wpd->prepass_uniform_hair_sh;
DRWShadingGroup *shgrp = DRW_shgroup_hair_create(
ob,
psys,
@@ -936,7 +935,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
WORKBENCH_MaterialData *material;
if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
const bool is_active = (ob == draw_ctx->obact);
- const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
+ const bool is_sculpt_mode = (ob->sculpt != NULL);
const bool use_hide = is_active && DRW_object_use_hide_faces(ob);
const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
@@ -952,10 +951,10 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
ImageUser *iuser;
int interp;
workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat);
- int color_type = workbench_material_determine_color_type(wpd, image, ob);
+ int color_type = workbench_material_determine_color_type(wpd, image, ob, is_sculpt_mode);
if (color_type == V3D_SHADING_MATERIAL_COLOR && mat && mat->a < 1.0) {
material = workbench_forward_get_or_create_material_data(
- vedata, ob, mat, image, iuser, color_type, 0);
+ vedata, ob, mat, image, iuser, color_type, 0, is_sculpt_mode);
has_transp_mat = true;
}
else {
@@ -969,24 +968,33 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
else if (ELEM(wpd->shading.color_type,
V3D_SHADING_SINGLE_COLOR,
V3D_SHADING_OBJECT_COLOR,
- V3D_SHADING_RANDOM_COLOR)) {
- if ((ob->color[3] < 1.0f) && (wpd->shading.color_type == V3D_SHADING_OBJECT_COLOR)) {
+ V3D_SHADING_RANDOM_COLOR,
+ V3D_SHADING_VERTEX_COLOR)) {
+ int color_type = workbench_material_determine_color_type(wpd, NULL, ob, is_sculpt_mode);
+
+ if ((ob->color[3] < 1.0f) && (color_type == V3D_SHADING_OBJECT_COLOR)) {
/* Hack */
wpd->shading.xray_alpha = ob->color[3];
material = workbench_forward_get_or_create_material_data(
- vedata, ob, NULL, NULL, NULL, wpd->shading.color_type, 0);
+ vedata, ob, NULL, NULL, NULL, color_type, 0, is_sculpt_mode);
has_transp_mat = true;
}
else {
/* Draw solid color */
- material = get_or_create_material_data(
- vedata, ob, NULL, NULL, NULL, wpd->shading.color_type, 0);
+ material = get_or_create_material_data(vedata, ob, NULL, NULL, NULL, color_type, 0);
}
if (is_sculpt_mode) {
DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat);
}
else {
- struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
+ struct GPUBatch *geom;
+ if (color_type == V3D_SHADING_VERTEX_COLOR) {
+ geom = DRW_cache_mesh_surface_vertpaint_get(ob);
+ }
+ else {
+ geom = DRW_cache_object_surface_get(ob);
+ }
+
if (geom) {
DRW_shgroup_call_object_add(material->shgrp, geom, ob);
}
@@ -1015,7 +1023,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
/* Hack */
wpd->shading.xray_alpha = mat->a;
material = workbench_forward_get_or_create_material_data(
- vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
+ vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode);
has_transp_mat = true;
}
else {
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c
index 3e35f8120d7..3dea99a76cf 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c
@@ -185,9 +185,12 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera)
wpd->dof_blur_tx = DRW_texture_pool_query_2d(
size[0], size[1], GPU_R11F_G11F_B10F, &draw_engine_workbench_solid);
#if 0
- wpd->coc_temp_tx = DRW_texture_pool_query_2d(shrink_h_size[0], shrink_h_size[1], GPU_RG8, &draw_engine_workbench_solid);
- wpd->coc_tiles_tx[0] = DRW_texture_pool_query_2d(shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench_solid);
- wpd->coc_tiles_tx[1] = DRW_texture_pool_query_2d(shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench_solid);
+ wpd->coc_temp_tx = DRW_texture_pool_query_2d(
+ shrink_h_size[0], shrink_h_size[1], GPU_RG8, &draw_engine_workbench_solid);
+ wpd->coc_tiles_tx[0] = DRW_texture_pool_query_2d(
+ shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench_solid);
+ wpd->coc_tiles_tx[1] = DRW_texture_pool_query_2d(
+ shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench_solid);
#endif
GPU_framebuffer_ensure_config(&fbl->dof_downsample_fb,
@@ -197,18 +200,21 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera)
GPU_ATTACHMENT_TEXTURE(txl->coc_halfres_tx),
});
#if 0
- GPU_framebuffer_ensure_config(&fbl->dof_coc_tile_h_fb, {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_TEXTURE(wpd->coc_temp_tx),
- });
- GPU_framebuffer_ensure_config(&fbl->dof_coc_tile_v_fb, {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_TEXTURE(wpd->coc_tiles_tx[0]),
- });
- GPU_framebuffer_ensure_config(&fbl->dof_coc_dilate_fb, {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_TEXTURE(wpd->coc_tiles_tx[1]),
- });
+ GPU_framebuffer_ensure_config(&fbl->dof_coc_tile_h_fb,
+ {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE(wpd->coc_temp_tx),
+ });
+ GPU_framebuffer_ensure_config(&fbl->dof_coc_tile_v_fb,
+ {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE(wpd->coc_tiles_tx[0]),
+ });
+ GPU_framebuffer_ensure_config(&fbl->dof_coc_dilate_fb,
+ {
+ GPU_ATTACHMENT_NONE,
+ GPU_ATTACHMENT_TEXTURE(wpd->coc_tiles_tx[1]),
+ });
#endif
GPU_framebuffer_ensure_config(&fbl->dof_blur1_fb,
{
@@ -237,9 +243,10 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera)
/* TODO(fclem) deduplicate with eevee */
/* this is factor that converts to the scene scale. focal length and sensor are expressed in mm
- * unit.scale_length is how many meters per blender unit we have. We want to convert to blender units though
- * because the shader reads coordinates in world space, which is in blender units.
- * Note however that focus_distance is already in blender units and shall not be scaled here (see T48157). */
+ * unit.scale_length is how many meters per blender unit we have. We want to convert to blender
+ * units though because the shader reads coordinates in world space, which is in blender units.
+ * Note however that focus_distance is already in blender units and shall not be scaled here
+ * (see T48157). */
float scale = (scene_eval->unit.system) ? scene_eval->unit.scale_length : 1.0f;
float scale_camera = 0.001f / scale;
/* we want radius here for the aperture number */
@@ -318,12 +325,14 @@ void workbench_dof_create_pass(WORKBENCH_Data *vedata,
}
#if 0
{
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.effect_dof_flatten_h_sh, psl->dof_flatten_h_ps);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.effect_dof_flatten_h_sh,
+ psl->dof_flatten_h_ps);
DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx);
DRW_shgroup_call_add(grp, quad, NULL);
}
{
- DRWShadingGroup *grp = DRW_shgroup_create(e_data.effect_dof_flatten_v_sh, psl->dof_flatten_v_ps);
+ DRWShadingGroup *grp = DRW_shgroup_create(e_data.effect_dof_flatten_v_sh,
+ psl->dof_flatten_v_ps);
DRW_shgroup_uniform_texture(grp, "inputCocTex", wpd->coc_temp_tx);
DRW_shgroup_call_add(grp, quad, NULL);
}
diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c
index 782e85597d7..00590940ac3 100644
--- a/source/blender/draw/engines/workbench/workbench_forward.c
+++ b/source/blender/draw/engines/workbench/workbench_forward.c
@@ -137,7 +137,8 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_
Image *ima,
ImageUser *iuser,
int color_type,
- int interp)
+ int interp,
+ bool is_sculpt_mode)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
WORKBENCH_FORWARD_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
@@ -168,9 +169,9 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_
material = MEM_mallocN(sizeof(WORKBENCH_MaterialData), __func__);
/* transparent accum */
- grp = DRW_shgroup_create(color_type == V3D_SHADING_TEXTURE_COLOR ?
- wpd->transparent_accum_texture_sh :
- wpd->transparent_accum_sh,
+ grp = DRW_shgroup_create(wpd->shading.color_type == color_type ?
+ wpd->transparent_accum_sh :
+ wpd->transparent_accum_uniform_sh,
psl->transparent_accum_pass);
DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo);
DRW_shgroup_uniform_float_copy(grp, "alpha", wpd->shading.xray_alpha);
@@ -194,7 +195,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_
material->shgrp = grp;
/* Depth */
- if (workbench_material_determine_color_type(wpd, material->ima, ob) ==
+ if (workbench_material_determine_color_type(wpd, material->ima, ob, is_sculpt_mode) ==
V3D_SHADING_TEXTURE_COLOR) {
material->shgrp_object_outline = DRW_shgroup_create(sh_data->object_outline_texture_sh,
psl->object_outline_pass);
@@ -217,15 +218,15 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_
}
static GPUShader *ensure_forward_accum_shaders(WORKBENCH_PrivateData *wpd,
- bool use_textures,
+ bool is_uniform_color,
bool is_hair,
eGPUShaderConfig sh_cfg)
{
WORKBENCH_FORWARD_Shaders *sh_data = &e_data.sh_data[sh_cfg];
- int index = workbench_material_get_accum_shader_index(wpd, use_textures, is_hair);
+ int index = workbench_material_get_accum_shader_index(wpd, is_uniform_color, is_hair);
if (sh_data->transparent_accum_sh_cache[index] == NULL) {
const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
- char *defines = workbench_material_build_defines(wpd, use_textures, is_hair);
+ char *defines = workbench_material_build_defines(wpd, is_uniform_color, is_hair);
char *transparent_accum_vert = workbench_build_forward_vert(is_hair);
char *transparent_accum_frag = workbench_build_forward_transparent_accum_frag();
sh_data->transparent_accum_sh_cache[index] = GPU_shader_create_from_arrays({
@@ -258,8 +259,8 @@ void workbench_forward_choose_shaders(WORKBENCH_PrivateData *wpd, eGPUShaderConf
wpd->composite_sh = ensure_forward_composite_shaders(wpd);
wpd->transparent_accum_sh = ensure_forward_accum_shaders(wpd, false, false, sh_cfg);
wpd->transparent_accum_hair_sh = ensure_forward_accum_shaders(wpd, false, true, sh_cfg);
- wpd->transparent_accum_texture_sh = ensure_forward_accum_shaders(wpd, true, false, sh_cfg);
- wpd->transparent_accum_texture_hair_sh = ensure_forward_accum_shaders(wpd, true, true, sh_cfg);
+ wpd->transparent_accum_uniform_sh = ensure_forward_accum_shaders(wpd, true, false, sh_cfg);
+ wpd->transparent_accum_uniform_hair_sh = ensure_forward_accum_shaders(wpd, true, true, sh_cfg);
}
void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg)
@@ -497,13 +498,13 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O
ImageUser *iuser;
int interp;
workbench_material_get_image_and_mat(ob, part->omat, &image, &iuser, &interp, &mat);
- int color_type = workbench_material_determine_color_type(wpd, image, ob);
+ int color_type = workbench_material_determine_color_type(wpd, image, ob, false);
WORKBENCH_MaterialData *material = workbench_forward_get_or_create_material_data(
- vedata, ob, mat, image, iuser, color_type, interp);
+ vedata, ob, mat, image, iuser, color_type, interp, false);
- struct GPUShader *shader = (color_type != V3D_SHADING_TEXTURE_COLOR) ?
+ struct GPUShader *shader = (wpd->shading.color_type == color_type) ?
wpd->transparent_accum_hair_sh :
- wpd->transparent_accum_texture_hair_sh;
+ wpd->transparent_accum_uniform_hair_sh;
DRWShadingGroup *shgrp = DRW_shgroup_hair_create(
ob, psys, md, psl->transparent_accum_pass, shader);
DRW_shgroup_uniform_block(shgrp, "world_block", wpd->world_ubo);
@@ -564,8 +565,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
WORKBENCH_MaterialData *material;
if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) {
- const bool is_active = (ob == draw_ctx->obact);
- const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
+ const bool is_sculpt_mode = (ob->sculpt != NULL);
bool is_drawn = false;
if (!is_sculpt_mode && TEXTURE_DRAWING_ENABLED(wpd) && ELEM(ob->type, OB_MESH)) {
@@ -579,9 +579,9 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
ImageUser *iuser;
int interp;
workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat);
- int color_type = workbench_material_determine_color_type(wpd, image, ob);
+ int color_type = workbench_material_determine_color_type(wpd, image, ob, is_sculpt_mode);
material = workbench_forward_get_or_create_material_data(
- vedata, ob, mat, image, iuser, color_type, interp);
+ vedata, ob, mat, image, iuser, color_type, interp, is_sculpt_mode);
DRW_shgroup_call_object_add(material->shgrp_object_outline, geom_array[i], ob);
DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob);
}
@@ -594,12 +594,21 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
if (ELEM(wpd->shading.color_type,
V3D_SHADING_SINGLE_COLOR,
V3D_SHADING_OBJECT_COLOR,
- V3D_SHADING_RANDOM_COLOR)) {
+ V3D_SHADING_RANDOM_COLOR,
+ V3D_SHADING_VERTEX_COLOR)) {
/* No material split needed */
- struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
+ int color_type = workbench_material_determine_color_type(wpd, NULL, ob, is_sculpt_mode);
+
+ struct GPUBatch *geom;
+ if (color_type == V3D_SHADING_VERTEX_COLOR) {
+ geom = DRW_cache_mesh_surface_vertpaint_get(ob);
+ }
+ else {
+ geom = DRW_cache_object_surface_get(ob);
+ }
if (geom) {
material = workbench_forward_get_or_create_material_data(
- vedata, ob, NULL, NULL, NULL, wpd->shading.color_type, 0);
+ vedata, ob, NULL, NULL, NULL, color_type, 0, is_sculpt_mode);
if (is_sculpt_mode) {
DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat);
if (!is_wire) {
@@ -631,7 +640,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
Material *mat = give_current_material(ob, i + 1);
material = workbench_forward_get_or_create_material_data(
- vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
+ vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode);
if (is_sculpt_mode) {
DRW_shgroup_call_sculpt_add(material->shgrp_object_outline, ob, ob->obmat);
if (!is_wire) {
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index d73eee37a98..c403e358d6a 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -31,6 +31,7 @@
#include "BLI_hash.h"
#include "DNA_node_types.h"
+#include "DNA_mesh_types.h"
#include "ED_uvedit.h"
@@ -42,7 +43,8 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd,
Material *mat,
WORKBENCH_MaterialData *data)
{
- /* When V3D_SHADING_TEXTURE_COLOR is active, use V3D_SHADING_MATERIAL_COLOR as fallback when no texture could be determined */
+ /* When V3D_SHADING_TEXTURE_COLOR is active, use V3D_SHADING_MATERIAL_COLOR as fallback when no
+ * texture could be determined */
int color_type = wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR ?
V3D_SHADING_MATERIAL_COLOR :
wpd->shading.color_type;
@@ -67,7 +69,7 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd,
hsv_to_rgb_v(hsv, data->diffuse_color);
copy_v3_v3(data->base_color, data->diffuse_color);
}
- else if (color_type == V3D_SHADING_OBJECT_COLOR) {
+ else if (ELEM(color_type, V3D_SHADING_OBJECT_COLOR, V3D_SHADING_VERTEX_COLOR)) {
copy_v3_v3(data->diffuse_color, ob->color);
copy_v3_v3(data->base_color, data->diffuse_color);
}
@@ -90,9 +92,14 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd,
}
}
-char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_textures, bool is_hair)
+char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd,
+ bool is_uniform_color,
+ bool is_hair)
{
char *str = NULL;
+ bool use_textures = (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR) && !is_uniform_color;
+ bool use_vertex_colors = (wpd->shading.color_type == V3D_SHADING_VERTEX_COLOR) &&
+ !is_uniform_color;
DynStr *ds = BLI_dynstr_new();
@@ -126,6 +133,9 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_text
if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
BLI_dynstr_append(ds, "#define NORMAL_VIEWPORT_PASS_ENABLED\n");
}
+ if (use_vertex_colors) {
+ BLI_dynstr_append(ds, "#define V3D_SHADING_VERTEX_COLOR\n");
+ }
if (use_textures) {
BLI_dynstr_append(ds, "#define V3D_SHADING_TEXTURE_COLOR\n");
}
@@ -160,6 +170,7 @@ uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template, bool
result += BLI_ghashutil_uinthash_v4_murmur(input);
result += BLI_ghashutil_uinthash((uint)is_ghost);
+ result += BLI_ghashutil_uinthash(material_template->color_type);
/* add texture reference */
if (material_template->ima) {
@@ -184,9 +195,12 @@ int workbench_material_get_composite_shader_index(WORKBENCH_PrivateData *wpd)
}
int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd,
- bool use_textures,
+ bool is_uniform_color,
bool is_hair)
{
+ bool use_textures = (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR) && !is_uniform_color;
+ bool use_vertex_colors = (wpd->shading.color_type == V3D_SHADING_VERTEX_COLOR) &&
+ !is_uniform_color;
/* NOTE: change MAX_PREPASS_SHADERS accordingly when modifying this function. */
int index = 0;
SET_FLAG_FROM_TEST(index, is_hair, 1 << 0);
@@ -195,32 +209,46 @@ int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd,
SET_FLAG_FROM_TEST(index, NORMAL_VIEWPORT_PASS_ENABLED(wpd), 1 << 3);
SET_FLAG_FROM_TEST(index, MATCAP_ENABLED(wpd), 1 << 4);
SET_FLAG_FROM_TEST(index, use_textures, 1 << 5);
+ SET_FLAG_FROM_TEST(index, use_vertex_colors, 1 << 6);
BLI_assert(index < MAX_PREPASS_SHADERS);
return index;
}
int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd,
- bool use_textures,
+ bool is_uniform_color,
bool is_hair)
{
+ bool use_textures = (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR) && !is_uniform_color;
+ bool use_vertex_colors = (wpd->shading.color_type == V3D_SHADING_VERTEX_COLOR) &&
+ !is_uniform_color;
/* NOTE: change MAX_ACCUM_SHADERS accordingly when modifying this function. */
int index = 0;
/* 2 bits FLAT/STUDIO/MATCAP + Specular highlight */
index = SPECULAR_HIGHLIGHT_ENABLED(wpd) ? 3 : wpd->shading.light;
SET_FLAG_FROM_TEST(index, use_textures, 1 << 2);
- SET_FLAG_FROM_TEST(index, is_hair, 1 << 3);
+ SET_FLAG_FROM_TEST(index, use_vertex_colors, 1 << 3);
+ SET_FLAG_FROM_TEST(index, is_hair, 1 << 4);
/* 1 bits SHADOWS (only facing factor) */
- SET_FLAG_FROM_TEST(index, SHADOW_ENABLED(wpd), 1 << 4);
+ SET_FLAG_FROM_TEST(index, SHADOW_ENABLED(wpd), 1 << 5);
BLI_assert(index < MAX_ACCUM_SHADERS);
return index;
}
-int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima, Object *ob)
+int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd,
+ Image *ima,
+ Object *ob,
+ bool is_sculpt_mode)
{
int color_type = wpd->shading.color_type;
- if ((color_type == V3D_SHADING_TEXTURE_COLOR && ima == NULL) || (ob->dt < OB_TEXTURE)) {
+ const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
+
+ if ((color_type == V3D_SHADING_TEXTURE_COLOR && (ima == NULL || is_sculpt_mode)) ||
+ (ob->dt < OB_TEXTURE)) {
color_type = V3D_SHADING_MATERIAL_COLOR;
}
+ if (color_type == V3D_SHADING_VERTEX_COLOR && (me == NULL || me->mloopcol == NULL)) {
+ color_type = V3D_SHADING_OBJECT_COLOR;
+ }
return color_type;
}
@@ -264,7 +292,7 @@ void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd,
return;
}
- if (workbench_material_determine_color_type(wpd, material->ima, ob) ==
+ if (workbench_material_determine_color_type(wpd, material->ima, ob, false) ==
V3D_SHADING_TEXTURE_COLOR) {
ImBuf *ibuf = BKE_image_acquire_ibuf(material->ima, material->iuser, NULL);
const bool do_color_correction = wpd->use_color_management &&
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 0e2ef2f94d2..3cfb1283416 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -37,11 +37,12 @@
#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
#define M_GOLDEN_RATION_CONJUGATE 0.618033988749895
#define MAX_COMPOSITE_SHADERS (1 << 6)
-#define MAX_PREPASS_SHADERS (1 << 6)
-#define MAX_ACCUM_SHADERS (1 << 5)
+#define MAX_PREPASS_SHADERS (1 << 7)
+#define MAX_ACCUM_SHADERS (1 << 6)
#define MAX_CAVITY_SHADERS (1 << 3)
#define TEXTURE_DRAWING_ENABLED(wpd) (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR)
+#define VERTEX_COLORS_ENABLED(wpd) (wpd->shading.color_type == V3D_SHADING_VERTEX_COLOR)
#define FLAT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_FLAT)
#define STUDIOLIGHT_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_STUDIO)
#define MATCAP_ENABLED(wpd) (wpd->shading.light == V3D_LIGHTING_MATCAP)
@@ -69,7 +70,8 @@
(ELEM(wpd->shading.color_type, \
V3D_SHADING_MATERIAL_COLOR, \
V3D_SHADING_OBJECT_COLOR, \
- V3D_SHADING_TEXTURE_COLOR))
+ V3D_SHADING_TEXTURE_COLOR, \
+ V3D_SHADING_VERTEX_COLOR))
#define IS_NAVIGATING(wpd) \
((DRW_context_state_get()->rv3d) && (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING))
@@ -213,16 +215,16 @@ BLI_STATIC_ASSERT_ALIGN(WORKBENCH_UBO_World, 16)
typedef struct WORKBENCH_PrivateData {
struct GHash *material_hash;
struct GHash *material_transp_hash;
- struct GPUShader *prepass_solid_sh;
- struct GPUShader *prepass_solid_hair_sh;
- struct GPUShader *prepass_texture_sh;
- struct GPUShader *prepass_texture_hair_sh;
+ struct GPUShader *prepass_sh;
+ struct GPUShader *prepass_hair_sh;
+ struct GPUShader *prepass_uniform_sh;
+ struct GPUShader *prepass_uniform_hair_sh;
struct GPUShader *composite_sh;
struct GPUShader *background_sh;
struct GPUShader *transparent_accum_sh;
struct GPUShader *transparent_accum_hair_sh;
- struct GPUShader *transparent_accum_texture_sh;
- struct GPUShader *transparent_accum_texture_hair_sh;
+ struct GPUShader *transparent_accum_uniform_sh;
+ struct GPUShader *transparent_accum_uniform_hair_sh;
View3DShading shading;
StudioLight *studio_light;
const UserDef *preferences;
@@ -353,7 +355,8 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_
Image *ima,
ImageUser *iuser,
int color_type,
- int interp);
+ int interp,
+ bool is_sculpt_mode);
/* workbench_effect_aa.c */
void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx);
@@ -382,11 +385,14 @@ void workbench_dof_create_pass(WORKBENCH_Data *vedata,
void workbench_dof_draw_pass(WORKBENCH_Data *vedata);
/* workbench_materials.c */
-int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima, Object *ob);
+int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd,
+ Image *ima,
+ Object *ob,
+ bool is_sculpt_mode);
void workbench_material_get_image_and_mat(
Object *ob, int mat_nr, Image **r_image, ImageUser **r_iuser, int *r_interp, Material **r_mat);
char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd,
- bool use_textures,
+ bool is_uniform_color,
bool is_hair);
void workbench_material_update_data(WORKBENCH_PrivateData *wpd,
Object *ob,
@@ -395,10 +401,10 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd,
uint workbench_material_get_hash(WORKBENCH_MaterialData *material_template, bool is_ghost);
int workbench_material_get_composite_shader_index(WORKBENCH_PrivateData *wpd);
int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd,
- bool use_textures,
+ bool is_uniform_color,
bool is_hair);
int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd,
- bool use_textures,
+ bool is_uniform_color,
bool is_hair);
void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd,
DRWShadingGroup *grp,
diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c
index 5c95a835adc..3fc83fea7c6 100644
--- a/source/blender/draw/engines/workbench/workbench_studiolight.c
+++ b/source/blender/draw/engines/workbench/workbench_studiolight.c
@@ -78,12 +78,12 @@ void studiolight_update_world(WORKBENCH_PrivateData *wpd,
mul_v3_v3fl(wd->spherical_harmonics_coefs[0], sl->spherical_harmonics_coefs[0], M_1_PI);
/* Swizzle to make shader code simpler. */
for (int i = 0; i < 3; ++i) {
- copy_v3_fl3(
- wd->spherical_harmonics_coefs[i + 1],
- -sl->spherical_harmonics_coefs[3][i],
- sl->spherical_harmonics_coefs[2][i],
- -sl->spherical_harmonics_coefs[1][i]);
- mul_v3_fl(wd->spherical_harmonics_coefs[i + 1], M_1_PI * 1.5f); /* 1.5f is to improve the contrast a bit. */
+ copy_v3_fl3(wd->spherical_harmonics_coefs[i + 1],
+ -sl->spherical_harmonics_coefs[3][i],
+ sl->spherical_harmonics_coefs[2][i],
+ -sl->spherical_harmonics_coefs[1][i]);
+ mul_v3_fl(wd->spherical_harmonics_coefs[i + 1],
+ M_1_PI * 1.5f); /* 1.5f is to improve the contrast a bit. */
}
/* Precompute as much as we can. See shader code for derivation. */
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index b0320a522f8..4d8fefbbc06 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -329,7 +329,7 @@ typedef enum {
DRW_STATE_BLEND = (1 << 15),
DRW_STATE_ADDITIVE = (1 << 16),
DRW_STATE_MULTIPLY = (1 << 17),
- /* DRW_STATE_TRANSMISSION = (1 << 18), */ /* Not used */
+ DRW_STATE_BLEND_PREMUL_UNDER = (1 << 18),
DRW_STATE_CLIP_PLANES = (1 << 19),
/** Same as DRW_STATE_ADDITIVE but let alpha accumulate without premult. */
DRW_STATE_ADDITIVE_FULL = (1 << 20),
diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c
index 8ff2916b040..a6026c9da3a 100644
--- a/source/blender/draw/intern/draw_anim_viz.c
+++ b/source/blender/draw/intern/draw_anim_viz.c
@@ -184,7 +184,7 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
struct DRWTextStore *dt = DRW_text_cache_ensure();
int txt_flag = DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_ASCII;
int cfra = (int)DEG_get_ctime(draw_ctx->depsgraph);
- bool sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT);
+ bool sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->base_flag & BASE_SELECTED);
bool show_keyframes = (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) != 0;
int sfra, efra, stepsize;
@@ -259,7 +259,8 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
else if (avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) {
bMotionPathVert *mpvP = (mpv - stepsize);
bMotionPathVert *mpvN = (mpv + stepsize);
- /* only draw framenum if several consecutive highlighted points don't occur on same point */
+ /* only draw framenum if several consecutive highlighted points don't occur on same point
+ */
if ((equals_v3v3(mpv->co, mpvP->co) == 0) || (equals_v3v3(mpv->co, mpvN->co) == 0)) {
numstr_len = sprintf(numstr, " %d", frame);
DRW_text_cache_add(dt, mpv->co, numstr, numstr_len, 0, 0, txt_flag, col);
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 12d4ca95a39..9b52f282944 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -345,36 +345,61 @@ static void drw_shgroup_bone_custom_solid(const float (*bone_mat)[4],
const eGPUShaderConfig sh_cfg,
Object *custom)
{
- /* grr, not re-using instances! */
struct GPUBatch *surf = DRW_cache_object_surface_get(custom);
struct GPUBatch *edges = DRW_cache_object_edge_detection_get(custom, NULL);
struct GPUBatch *ledges = DRW_cache_object_loose_edges_get(custom);
float final_bonemat[4][4];
- /* XXXXXXX needs to be moved elsewhere. */
- drw_batch_cache_generate_requested(custom);
-
if (surf || edges || ledges) {
mul_m4_m4m4(final_bonemat, g_data.ob->obmat, bone_mat);
}
+ BLI_assert(g_data.passes.custom_shapes != NULL);
+
if (surf && g_data.passes.bone_solid != NULL) {
- DRWShadingGroup *shgrp_geom_solid = shgroup_instance_bone_shape_solid(
- g_data.passes.bone_solid, surf, g_data.transparent, sh_cfg);
+ DRWShadingGroup *shgrp_geom_solid = BLI_ghash_lookup(g_data.passes.custom_shapes, surf);
+
+ if (shgrp_geom_solid == NULL) {
+ /* TODO(fclem) needs to be moved elsewhere. */
+ drw_batch_cache_generate_requested(custom);
+
+ /* NOTE! g_data.transparent require a separate shading group if the
+ * object is transparent. This is done by passing a different ghash
+ * for transparent armature in pose mode. */
+ shgrp_geom_solid = shgroup_instance_bone_shape_solid(
+ g_data.passes.bone_solid, surf, g_data.transparent, sh_cfg);
+ BLI_ghash_insert(g_data.passes.custom_shapes, surf, shgrp_geom_solid);
+ }
DRW_shgroup_call_dynamic_add(shgrp_geom_solid, final_bonemat, bone_color, hint_color);
}
if (edges && outline_color[3] > 0.0f) {
- DRWShadingGroup *shgrp_geom_wire = shgroup_instance_bone_shape_outline(
- g_data.passes.bone_outline, edges, sh_cfg);
+ DRWShadingGroup *shgrp_geom_wire = BLI_ghash_lookup(g_data.passes.custom_shapes, edges);
+
+ if (shgrp_geom_wire == NULL) {
+ /* TODO(fclem) needs to be moved elsewhere. */
+ drw_batch_cache_generate_requested(custom);
+
+ shgrp_geom_wire = shgroup_instance_bone_shape_outline(
+ g_data.passes.bone_outline, edges, sh_cfg);
+
+ BLI_ghash_insert(g_data.passes.custom_shapes, edges, shgrp_geom_wire);
+ }
DRW_shgroup_call_dynamic_add(shgrp_geom_wire, final_bonemat, outline_color);
}
if (ledges) {
- DRWShadingGroup *shgrp_geom_ledges = shgroup_instance_wire(g_data.passes.bone_wire, ledges);
- float final_color[4];
- copy_v3_v3(final_color, outline_color);
- final_color[3] = 1.0f; /* hack */
+ DRWShadingGroup *shgrp_geom_ledges = BLI_ghash_lookup(g_data.passes.custom_shapes, ledges);
+
+ if (shgrp_geom_ledges == NULL) {
+ /* TODO(fclem) needs to be moved elsewhere. */
+ drw_batch_cache_generate_requested(custom);
+
+ shgrp_geom_ledges = shgroup_instance_wire(g_data.passes.bone_wire, ledges);
+
+ BLI_ghash_insert(g_data.passes.custom_shapes, ledges, shgrp_geom_ledges);
+ }
+ float final_color[4] = {outline_color[0], outline_color[1], outline_color[2], 1.0f};
DRW_shgroup_call_dynamic_add(shgrp_geom_ledges, final_bonemat, final_color);
}
}
@@ -383,18 +408,22 @@ static void drw_shgroup_bone_custom_wire(const float (*bone_mat)[4],
const float color[4],
Object *custom)
{
- /* grr, not re-using instances! */
struct GPUBatch *geom = DRW_cache_object_all_edges_get(custom);
- /* XXXXXXX needs to be moved elsewhere. */
- drw_batch_cache_generate_requested(custom);
-
if (geom) {
- DRWShadingGroup *shgrp_geom_wire = shgroup_instance_wire(g_data.passes.bone_wire, geom);
- float final_bonemat[4][4], final_color[4];
+ DRWShadingGroup *shgrp_geom_wire = BLI_ghash_lookup(g_data.passes.custom_shapes, geom);
+
+ if (shgrp_geom_wire == NULL) {
+ /* TODO(fclem) needs to be moved elsewhere. */
+ drw_batch_cache_generate_requested(custom);
+
+ shgrp_geom_wire = shgroup_instance_wire(g_data.passes.bone_wire, geom);
+
+ BLI_ghash_insert(g_data.passes.custom_shapes, geom, shgrp_geom_wire);
+ }
+ float final_color[4] = {color[0], color[1], color[2], 1.0f};
+ float final_bonemat[4][4];
mul_m4_m4m4(final_bonemat, g_data.ob->obmat, bone_mat);
- copy_v3_v3(final_color, color);
- final_color[3] = 1.0f; /* hack */
DRW_shgroup_call_dynamic_add(shgrp_geom_wire, final_bonemat, final_color);
}
}
@@ -1110,14 +1139,17 @@ static void ebone_spline_preview(EditBone *ebone, float result_array[MAX_BBONE_S
param.roll1 += prev->roll2;
}
- param.scaleIn = ebone->scaleIn;
- param.scaleOut = ebone->scaleOut;
+ param.scale_in_x = ebone->scale_in_x;
+ param.scale_in_y = ebone->scale_in_y;
+
+ param.scale_out_x = ebone->scale_out_x;
+ param.scale_out_y = ebone->scale_out_y;
- param.curveInX = ebone->curveInX;
- param.curveInY = ebone->curveInY;
+ param.curve_in_x = ebone->curve_in_x;
+ param.curve_in_y = ebone->curve_in_y;
- param.curveOutX = ebone->curveOutX;
- param.curveOutY = ebone->curveOutY;
+ param.curve_out_x = ebone->curve_out_x;
+ param.curve_out_y = ebone->curve_out_y;
ebone->segments = BKE_pchan_bbone_spline_compute(&param, false, (Mat4 *)result_array);
}
@@ -1153,8 +1185,8 @@ static void draw_bone_update_disp_matrix_bbone(EditBone *eBone, bPoseChannel *pc
size_to_mat4(s, (const float[3]){xwidth, length / bbone_segments, zwidth});
/* Compute BBones segment matrices... */
- /* Note that we need this even for one-segment bones, because box drawing need specific weirdo matrix for the box,
- * that we cannot use to draw end points & co. */
+ /* Note that we need this even for one-segment bones, because box drawing need specific weirdo
+ * matrix for the box, that we cannot use to draw end points & co. */
if (pchan) {
Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix;
if (bbone_segments > 1) {
@@ -1765,7 +1797,8 @@ static void draw_bone_relations(EditBone *ebone,
}
else if (pchan && pchan->parent) {
if (do_relations) {
- /* Only draw if bone or its parent is selected - reduces viewport complexity with complex rigs */
+ /* Only draw if bone or its parent is selected - reduces viewport complexity with complex
+ * rigs */
if ((boneflag & BONE_SELECTED) ||
(pchan->parent->bone && (pchan->parent->bone->flag & BONE_SELECTED))) {
if ((boneflag & BONE_CONNECTED) == 0) {
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 74c87162afd..6b4c4cef9c8 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -161,9 +161,13 @@ static void UNUSED_FUNCTION(add_fancy_edge)(GPUVertBuf *vbo,
}
#if 0 /* UNUSED */
-static void add_lat_lon_vert(
- GPUVertBuf *vbo, uint pos_id, uint nor_id,
- uint *v_idx, const float rad, const float lat, const float lon)
+static void add_lat_lon_vert(GPUVertBuf *vbo,
+ uint pos_id,
+ uint nor_id,
+ uint *v_idx,
+ const float rad,
+ const float lat,
+ const float lon)
{
float pos[3], nor[3];
nor[0] = sinf(lat) * cosf(lon);
@@ -178,8 +182,10 @@ static void add_lat_lon_vert(
static GPUVertBuf *fill_arrows_vbo(const float scale)
{
/* Position Only 3D format */
- static GPUVertFormat format = { 0 };
- static struct { uint pos; } attr_id;
+ static GPUVertFormat format = {0};
+ static struct {
+ uint pos;
+ } attr_id;
if (format.attr_len == 0) {
attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
}
@@ -476,8 +482,9 @@ GPUBatch *DRW_cache_empty_cube_get(void)
{1.0f, 1.0f, 1.0f},
};
- const GLubyte indices[24] = {0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 4, 5,
- 5, 7, 7, 6, 6, 4, 1, 5, 3, 7, 2, 6};
+ const GLubyte indices[24] = {
+ 0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 4, 5, 5, 7, 7, 6, 6, 4, 1, 5, 3, 7, 2, 6,
+ };
/* Position Only 3D format */
static GPUVertFormat format = {0};
@@ -653,17 +660,20 @@ GPUBatch *DRW_cache_gpencil_axes_get(void)
float v2[3] = {0.0f, 0.0f, 0.0f};
/* cube data */
- const GLfloat verts[8][3] = {{-0.25f, -0.25f, -0.25f},
- {-0.25f, -0.25f, 0.25f},
- {-0.25f, 0.25f, -0.25f},
- {-0.25f, 0.25f, 0.25f},
- {0.25f, -0.25f, -0.25f},
- {0.25f, -0.25f, 0.25f},
- {0.25f, 0.25f, -0.25f},
- {0.25f, 0.25f, 0.25f}};
-
- const GLubyte indices[24] = {0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 4, 5,
- 5, 7, 7, 6, 6, 4, 1, 5, 3, 7, 2, 6};
+ const GLfloat verts[8][3] = {
+ {-0.25f, -0.25f, -0.25f},
+ {-0.25f, -0.25f, 0.25f},
+ {-0.25f, 0.25f, -0.25f},
+ {-0.25f, 0.25f, 0.25f},
+ {0.25f, -0.25f, -0.25f},
+ {0.25f, -0.25f, 0.25f},
+ {0.25f, 0.25f, -0.25f},
+ {0.25f, 0.25f, 0.25f},
+ };
+
+ const GLubyte indices[24] = {
+ 0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 4, 5, 5, 7, 7, 6, 6, 4, 1, 5, 3, 7, 2, 6,
+ };
/* Position Only 3D format */
static GPUVertFormat format = {0};
@@ -1740,11 +1750,13 @@ GPUBatch *DRW_cache_light_spot_volume_get(void)
GPUBatch *DRW_cache_light_spot_square_get(void)
{
if (!SHC.drw_light_spot_square) {
- float p[5][3] = {{0.0f, 0.0f, 0.0f},
- {1.0f, 1.0f, -1.0f},
- {1.0f, -1.0f, -1.0f},
- {-1.0f, -1.0f, -1.0f},
- {-1.0f, 1.0f, -1.0f}};
+ float p[5][3] = {
+ {0.0f, 0.0f, 0.0f},
+ {1.0f, 1.0f, -1.0f},
+ {1.0f, -1.0f, -1.0f},
+ {-1.0f, -1.0f, -1.0f},
+ {-1.0f, 1.0f, -1.0f},
+ };
uint v_idx = 0;
@@ -1777,11 +1789,13 @@ GPUBatch *DRW_cache_light_spot_square_get(void)
GPUBatch *DRW_cache_light_spot_square_volume_get(void)
{
if (!SHC.drw_light_spot_square_volume) {
- float p[5][3] = {{0.0f, 0.0f, 0.0f},
- {1.0f, 1.0f, -1.0f},
- {1.0f, -1.0f, -1.0f},
- {-1.0f, -1.0f, -1.0f},
- {-1.0f, 1.0f, -1.0f}};
+ float p[5][3] = {
+ {0.0f, 0.0f, 0.0f},
+ {1.0f, 1.0f, -1.0f},
+ {1.0f, -1.0f, -1.0f},
+ {-1.0f, -1.0f, -1.0f},
+ {-1.0f, 1.0f, -1.0f},
+ };
uint v_idx = 0;
@@ -2039,10 +2053,10 @@ static const float bone_octahedral_verts[6][3] = {
static const float bone_octahedral_smooth_normals[6][3] = {
{0.0f, -1.0f, 0.0f},
#if 0 /* creates problems for outlines when scaled */
- { 0.943608f * M_SQRT1_2, -0.331048f, 0.943608f * M_SQRT1_2},
- { 0.943608f * M_SQRT1_2, -0.331048f, -0.943608f * M_SQRT1_2},
- {-0.943608f * M_SQRT1_2, -0.331048f, -0.943608f * M_SQRT1_2},
- {-0.943608f * M_SQRT1_2, -0.331048f, 0.943608f * M_SQRT1_2},
+ {0.943608f * M_SQRT1_2, -0.331048f, 0.943608f * M_SQRT1_2},
+ {0.943608f * M_SQRT1_2, -0.331048f, -0.943608f * M_SQRT1_2},
+ {-0.943608f * M_SQRT1_2, -0.331048f, -0.943608f * M_SQRT1_2},
+ {-0.943608f * M_SQRT1_2, -0.331048f, 0.943608f * M_SQRT1_2},
#else
{M_SQRT1_2, 0.0f, M_SQRT1_2},
{M_SQRT1_2, 0.0f, -M_SQRT1_2},
@@ -2055,17 +2069,13 @@ static const float bone_octahedral_smooth_normals[6][3] = {
#if 0 /* UNUSED */
static const uint bone_octahedral_wire[24] = {
- 0, 1, 1, 5, 5, 3, 3, 0,
- 0, 4, 4, 5, 5, 2, 2, 0,
- 1, 2, 2, 3, 3, 4, 4, 1,
+ 0, 1, 1, 5, 5, 3, 3, 0, 0, 4, 4, 5, 5, 2, 2, 0, 1, 2, 2, 3, 3, 4, 4, 1,
};
/* aligned with bone_octahedral_wire
* Contains adjacent normal index */
static const uint bone_octahedral_wire_adjacent_face[24] = {
- 0, 3, 4, 7, 5, 6, 1, 2,
- 2, 3, 6, 7, 4, 5, 0, 1,
- 0, 4, 1, 5, 2, 6, 3, 7,
+ 0, 3, 4, 7, 5, 6, 1, 2, 2, 3, 6, 7, 4, 5, 0, 1, 0, 4, 1, 5, 2, 6, 3, 7,
};
#endif
@@ -2109,15 +2119,15 @@ static const uint bone_octahedral_wire_lines_adjacency[12][4] = {
#if 0 /* UNUSED */
static const uint bone_octahedral_solid_tris_adjacency[8][6] = {
- { 0, 12, 1, 10, 2, 3},
- { 3, 15, 4, 1, 5, 6},
- { 6, 18, 7, 4, 8, 9},
- { 9, 21, 10, 7, 11, 0},
-
- {12, 22, 13, 2, 14, 17},
- {15, 13, 16, 5, 17, 20},
- {18, 16, 19, 8, 20, 23},
- {21, 19, 22, 11, 23, 14},
+ {0, 12, 1, 10, 2, 3},
+ {3, 15, 4, 1, 5, 6},
+ {6, 18, 7, 4, 8, 9},
+ {9, 21, 10, 7, 11, 0},
+
+ {12, 22, 13, 2, 14, 17},
+ {15, 13, 16, 5, 17, 20},
+ {18, 16, 19, 8, 20, 23},
+ {21, 19, 22, 11, 23, 14},
};
#endif
@@ -2219,17 +2229,13 @@ static const float bone_box_smooth_normals[8][3] = {
#if 0 /* UNUSED */
static const uint bone_box_wire[24] = {
- 0, 1, 1, 2, 2, 3, 3, 0,
- 4, 5, 5, 6, 6, 7, 7, 4,
- 0, 4, 1, 5, 2, 6, 3, 7,
+ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7,
};
/* aligned with bone_octahedral_wire
* Contains adjacent normal index */
static const uint bone_box_wire_adjacent_face[24] = {
- 0, 2, 0, 4, 1, 6, 1, 8,
- 3, 10, 5, 10, 7, 11, 9, 11,
- 3, 8, 2, 5, 4, 7, 6, 9,
+ 0, 2, 0, 4, 1, 6, 1, 8, 3, 10, 5, 10, 7, 11, 9, 11, 3, 8, 2, 5, 4, 7, 6, 9,
};
#endif
@@ -2274,23 +2280,23 @@ static const uint bone_box_wire_lines_adjacency[12][4] = {
#if 0 /* UNUSED */
static const uint bone_box_solid_tris_adjacency[12][6] = {
- { 0, 5, 1, 14, 2, 8},
- { 3, 26, 4, 20, 5, 1},
+ {0, 5, 1, 14, 2, 8},
+ {3, 26, 4, 20, 5, 1},
- { 6, 2, 7, 16, 8, 11},
- { 9, 7, 10, 32, 11, 24},
+ {6, 2, 7, 16, 8, 11},
+ {9, 7, 10, 32, 11, 24},
- {12, 0, 13, 22, 14, 17},
- {15, 13, 16, 30, 17, 6},
+ {12, 0, 13, 22, 14, 17},
+ {15, 13, 16, 30, 17, 6},
- {18, 3, 19, 28, 20, 23},
- {21, 19, 22, 33, 23, 12},
+ {18, 3, 19, 28, 20, 23},
+ {21, 19, 22, 33, 23, 12},
- {24, 4, 25, 10, 26, 29},
- {27, 25, 28, 34, 29, 18},
+ {24, 4, 25, 10, 26, 29},
+ {27, 25, 28, 34, 29, 18},
- {30, 9, 31, 15, 32, 35},
- {33, 31, 34, 21, 35, 27},
+ {30, 9, 31, 15, 32, 35},
+ {33, 31, 34, 21, 35, 27},
};
#endif
@@ -2499,8 +2505,10 @@ GPUBatch *DRW_cache_bone_point_get(void)
const float lat_inc = M_PI / lat_res;
uint v_idx = 0;
- static GPUVertFormat format = { 0 };
- static struct { uint pos, nor; } attr_id;
+ static GPUVertFormat format = {0};
+ static struct {
+ uint pos, nor;
+ } attr_id;
if (format.attr_len == 0) {
attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -2515,15 +2523,17 @@ GPUBatch *DRW_cache_bone_point_get(void)
float lat = 0.0f;
for (int j = 0; j < lat_res; j++, lat += lat_inc) {
if (j != lat_res - 1) { /* Pole */
- add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
+ add_lat_lon_vert(
+ vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon);
- add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
+ add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
}
if (j != 0) { /* Pole */
- add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon + lon_inc);
- add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
- add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
+ add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon + lon_inc);
+ add_lat_lon_vert(
+ vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
+ add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
}
}
}
@@ -2755,10 +2765,14 @@ static float z_axis_name[10][2] = {
#define S_Y 0.007f
static float axis_marker[8][2] = {
#if 0 /* square */
- {-1.0f * S_X, 1.0f * S_Y}, { 1.0f * S_X, 1.0f * S_Y},
- { 1.0f * S_X, 1.0f * S_Y}, { 1.0f * S_X, -1.0f * S_Y},
- { 1.0f * S_X, -1.0f * S_Y}, {-1.0f * S_X, -1.0f * S_Y},
- {-1.0f * S_X, -1.0f * S_Y}, {-1.0f * S_X, 1.0f * S_Y}
+ {-1.0f * S_X, 1.0f * S_Y},
+ {1.0f * S_X, 1.0f * S_Y},
+ {1.0f * S_X, 1.0f * S_Y},
+ {1.0f * S_X, -1.0f * S_Y},
+ {1.0f * S_X, -1.0f * S_Y},
+ {-1.0f * S_X, -1.0f * S_Y},
+ {-1.0f * S_X, -1.0f * S_Y},
+ {-1.0f * S_X, 1.0f * S_Y}
#else /* diamond */
{-S_X, 0.f},
{0.f, S_Y},
@@ -3003,7 +3017,8 @@ GPUBatch *DRW_cache_bone_dof_lines_get(void)
* We could make these more generic functions.
* although filling 1d lines is not common.
*
- * \note Use x coordinate to identify the vertex the vertex shader take care to place it appropriately.
+ * \note Use x coordinate to identify the vertex the vertex shader take care to place it
+ * appropriately.
*/
static const float camera_coords_frame_bounds[5] = {
@@ -3269,6 +3284,12 @@ GPUBatch *DRW_cache_mesh_face_wireframe_get(Object *ob)
return DRW_mesh_batch_cache_get_wireframes_face(ob->data);
}
+GPUBatch *DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
+{
+ BLI_assert(ob->type == OB_MESH);
+ return DRW_mesh_batch_cache_get_edit_mesh_analysis(ob->data);
+}
+
void DRW_cache_mesh_sculpt_coords_ensure(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
@@ -3288,7 +3309,13 @@ GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
- return DRW_curve_batch_cache_get_wire_edge(cu);
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ if (mesh_eval != NULL) {
+ return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
+ }
+ else {
+ return DRW_curve_batch_cache_get_wire_edge(cu);
+ }
}
GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob)
@@ -3434,7 +3461,13 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
- return DRW_curve_batch_cache_get_wire_edge(cu);
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ if (mesh_eval != NULL) {
+ return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
+ }
+ else {
+ return DRW_curve_batch_cache_get_wire_edge(cu);
+ }
}
GPUBatch *DRW_cache_text_surface_get(Object *ob)
@@ -3546,7 +3579,13 @@ GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
- return DRW_curve_batch_cache_get_wire_edge(cu);
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ if (mesh_eval != NULL) {
+ return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
+ }
+ else {
+ return DRW_curve_batch_cache_get_wire_edge(cu);
+ }
}
GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)
@@ -4017,4 +4056,25 @@ void drw_batch_cache_generate_requested(Object *ob)
}
}
+void DRW_batch_cache_free_old(Object *ob, int ctime)
+{
+ struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+
+ switch (ob->type) {
+ case OB_MESH:
+ DRW_mesh_batch_cache_free_old((Mesh *)ob->data, ctime);
+ break;
+ case OB_CURVE:
+ case OB_FONT:
+ case OB_SURF:
+ if (mesh_eval) {
+ DRW_mesh_batch_cache_free_old(mesh_eval, ctime);
+ }
+ break;
+ /* TODO all cases */
+ default:
+ break;
+ }
+}
+
/** \} */
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index c9ae0a01cb9..129b180957a 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -140,6 +140,7 @@ struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_surface_vertpaint_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_mesh_analysis_get(struct Object *ob);
struct GPUBatch *DRW_cache_mesh_face_wireframe_get(struct Object *ob);
void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob);
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 94d8a82f2e4..4ef8f5a9326 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -61,6 +61,11 @@ void DRW_particle_batch_cache_free(struct ParticleSystem *psys);
void DRW_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd);
void DRW_gpencil_batch_cache_free(struct bGPdata *gpd);
+/* Garbage collection */
+void DRW_batch_cache_free_old(struct Object *ob, int ctime);
+
+void DRW_mesh_batch_cache_free_old(struct Mesh *me, int ctime);
+
/* Curve */
void DRW_curve_batch_cache_create_requested(struct Object *ob);
@@ -152,6 +157,7 @@ struct GPUBatch *DRW_mesh_batch_cache_get_edituv_verts(struct Mesh *me);
struct GPUBatch *DRW_mesh_batch_cache_get_edituv_facedots(struct Mesh *me);
/* For Image UV editor. */
struct GPUBatch *DRW_mesh_batch_cache_get_uv_edges(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_edit_mesh_analysis(struct Mesh *me);
void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me);
@@ -199,10 +205,19 @@ struct GPUBatch *DRW_particles_batch_cache_get_edit_tip_points(struct Object *ob
struct PTCacheEdit *edit);
/* Common */
-#define DRW_ADD_FLAG_FROM_VBO_REQUEST(flag, vbo, value) \
- (flag |= DRW_vbo_requested(vbo) ? (value) : 0)
-#define DRW_ADD_FLAG_FROM_IBO_REQUEST(flag, ibo, value) \
- (flag |= DRW_ibo_requested(ibo) ? (value) : 0)
+// #define DRW_DEBUG_MESH_CACHE_REQUEST
+
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+# define DRW_ADD_FLAG_FROM_VBO_REQUEST(flag, vbo, value) \
+ (flag |= DRW_vbo_requested(vbo) ? (printf(" VBO requested " #vbo "\n") ? value : value) : 0)
+# define DRW_ADD_FLAG_FROM_IBO_REQUEST(flag, ibo, value) \
+ (flag |= DRW_ibo_requested(ibo) ? (printf(" IBO requested " #ibo "\n") ? value : value) : 0)
+#else
+# define DRW_ADD_FLAG_FROM_VBO_REQUEST(flag, vbo, value) \
+ (flag |= DRW_vbo_requested(vbo) ? (value) : 0)
+# define DRW_ADD_FLAG_FROM_IBO_REQUEST(flag, ibo, value) \
+ (flag |= DRW_ibo_requested(ibo) ? (value) : 0)
+#endif
/* Test and assign NULL if test fails */
#define DRW_TEST_ASSIGN_VBO(v) (v = (DRW_vbo_requested(v) ? (v) : NULL))
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 8e7a2253e21..33b872109a5 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -988,6 +988,10 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
}
}
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+ printf("-- %s %s --\n", __func__, ob->id.name + 2);
+#endif
+
/* Generate MeshRenderData flags */
int mr_flag = 0;
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.pos_nor, CU_DATATYPE_SURFACE);
@@ -1011,6 +1015,10 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->surf_per_mat_tris[i], CU_DATATYPE_SURFACE);
}
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+ printf(" mr_flag %d\n\n", mr_flag);
+#endif
+
CurveRenderData *rdata = curve_render_data_create(cu, ob->runtime.curve_cache, mr_flag);
/* DispLists */
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index ded9d0963b7..1d8c7f0e5a7 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -304,7 +304,7 @@ typedef struct MeshRenderData {
bool *edge_visible_bool;
} MeshRenderData;
-enum {
+typedef enum eMRDataType {
MR_DATATYPE_VERT = 1 << 0,
MR_DATATYPE_EDGE = 1 << 1,
MR_DATATYPE_LOOPTRI = 1 << 2,
@@ -317,11 +317,16 @@ enum {
MR_DATATYPE_LOOPUV = 1 << 9,
MR_DATATYPE_LOOSE_VERT = 1 << 10,
MR_DATATYPE_LOOSE_EDGE = 1 << 11,
-};
+ MR_DATATYPE_LOOP_NORMALS = 1 << 12,
+} eMRDataType;
+
+#define MR_DATATYPE_VERT_LOOP_POLY (MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP)
+#define MR_DATATYPE_VERT_LOOP_TRI_POLY (MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_LOOPTRI)
+#define MR_DATATYPE_LOOSE_VERT_EGDE (MR_DATATYPE_LOOSE_VERT | MR_DATATYPE_LOOSE_EDGE)
/**
- * These functions look like they would be slow but they will typically return true on the first iteration.
- * Only false when all attached elements are hidden.
+ * These functions look like they would be slow but they will typically return true on the first
+ * iteration. Only false when all attached elements are hidden.
*/
static bool bm_vert_has_visible_edge(const BMVert *v)
{
@@ -364,6 +369,11 @@ BLI_INLINE bool mesh_cd_layers_type_overlap(DRW_MeshCDMask a, DRW_MeshCDMask b)
return (*((uint32_t *)&a) & *((uint32_t *)&b)) == *((uint32_t *)&b);
}
+BLI_INLINE bool mesh_cd_layers_type_equal(DRW_MeshCDMask a, DRW_MeshCDMask b)
+{
+ return *((uint32_t *)&a) == *((uint32_t *)&b);
+}
+
BLI_INLINE void mesh_cd_layers_type_merge(DRW_MeshCDMask *a, DRW_MeshCDMask b)
{
atomic_fetch_and_or_uint32((uint32_t *)a, *(uint32_t *)&b);
@@ -670,9 +680,17 @@ static MeshRenderData *mesh_render_data_create_ex(Mesh *me,
bm_ensure_types |= BM_LOOP;
}
if (types & MR_DATATYPE_LOOP) {
- int totloop = bm->totloop;
+ rdata->loop_len = bm->totloop;
+ bm_ensure_types |= BM_LOOP;
+ }
+ if (types & MR_DATATYPE_POLY) {
+ rdata->poly_len = bm->totface;
+ bm_ensure_types |= BM_FACE;
+ }
+ if (types & MR_DATATYPE_LOOP_NORMALS) {
+ BLI_assert(types & MR_DATATYPE_LOOP);
if (is_auto_smooth) {
- rdata->loop_normals = MEM_mallocN(sizeof(*rdata->loop_normals) * totloop, __func__);
+ rdata->loop_normals = MEM_mallocN(sizeof(*rdata->loop_normals) * bm->totloop, __func__);
int cd_loop_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
BM_loops_calc_normal_vcos(bm,
NULL,
@@ -686,12 +704,6 @@ static MeshRenderData *mesh_render_data_create_ex(Mesh *me,
cd_loop_clnors_offset,
false);
}
- rdata->loop_len = totloop;
- bm_ensure_types |= BM_LOOP;
- }
- if (types & MR_DATATYPE_POLY) {
- rdata->poly_len = bm->totface;
- bm_ensure_types |= BM_FACE;
}
if (types & MR_DATATYPE_OVERLAY) {
rdata->efa_act_uv = EDBM_uv_active_face_get(embm, false, false);
@@ -828,7 +840,9 @@ static MeshRenderData *mesh_render_data_create_ex(Mesh *me,
if (types & MR_DATATYPE_LOOP) {
rdata->loop_len = me->totloop;
rdata->mloop = CustomData_get_layer(&me->ldata, CD_MLOOP);
-
+ }
+ if (types & MR_DATATYPE_LOOP_NORMALS) {
+ BLI_assert(types & MR_DATATYPE_LOOP);
if (is_auto_smooth) {
mesh_render_calc_normals_loop_and_poly(me, split_angle, rdata);
}
@@ -1145,7 +1159,8 @@ static MeshRenderData *mesh_render_data_create_ex(Mesh *me,
/* note: BKE_editmesh_loop_tangent_calc calculates 'CD_TANGENT',
* not 'CD_MLOOPTANGENT' (as done below). It's OK, they're compatible. */
- /* note: normally we'd use 'i_src' here, but 'i_dst' is in sync with 'rdata->cd.output' */
+ /* note: normally we'd use 'i_src' here, but 'i_dst' is in sync with 'rdata->cd.output'
+ */
rdata->cd.layers.tangent[i_dst] = CustomData_get_layer_n(
&rdata->cd.output.ldata, CD_TANGENT, i_dst);
if (rdata->tri_len != 0) {
@@ -1344,10 +1359,6 @@ static int mesh_render_data_polys_len_get_maybe_mapped(const MeshRenderData *rda
/* ---------------------------------------------------------------------- */
-/* TODO remove prototype. */
-static void mesh_create_edit_facedots(MeshRenderData *rdata,
- GPUVertBuf *vbo_facedots_pos_nor_data);
-
/** \name Internal Cache (Lazy Initialization)
* \{ */
@@ -1645,7 +1656,7 @@ static void mesh_render_data_edge_flag(const MeshRenderData *rdata,
* specular highlights make it hard to see T55456#510873.
*
* This isn't ideal since it can't be used when mixing edge/face modes
- * but it's still better then not being able to see the active face. */
+ * but it's still better then not being able to see the active face. */
if (is_face_only_select_mode) {
if (rdata->efa_act != NULL) {
if (BM_edge_in_face(eed, rdata->efa_act)) {
@@ -1906,6 +1917,7 @@ typedef struct MeshBatchCache {
GPUVertBuf *loop_data;
GPUVertBuf *loop_lnor;
GPUVertBuf *facedots_pos_nor_data;
+ GPUVertBuf *loop_mesh_analysis;
/* UV data without modifier applied.
* Vertex count is always the one of the cage. */
GPUVertBuf *loop_uv;
@@ -1953,6 +1965,7 @@ typedef struct MeshBatchCache {
GPUBatch *edit_edges;
GPUBatch *edit_lnor;
GPUBatch *edit_facedots;
+ GPUBatch *edit_mesh_analysis;
/* Edit UVs */
GPUBatch *edituv_faces_strech_area;
GPUBatch *edituv_faces_strech_angle;
@@ -1997,7 +2010,9 @@ typedef struct MeshBatchCache {
struct DRW_MeshWeightState weight_state;
- DRW_MeshCDMask cd_used, cd_needed;
+ DRW_MeshCDMask cd_used, cd_needed, cd_used_over_time;
+
+ int lastmatch;
/* XXX, only keep for as long as sculpt mode uses shaded drawing. */
bool is_sculpt_points_tag;
@@ -2121,6 +2136,8 @@ static void mesh_batch_cache_discard_shaded_tri(MeshBatchCache *cache)
MEM_SAFE_FREE(cache->auto_layer_names);
MEM_SAFE_FREE(cache->auto_layer_is_srgb);
+ mesh_cd_layers_type_clear(&cache->cd_used);
+
cache->mat_len = 0;
}
@@ -2160,8 +2177,13 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
GPU_BATCH_DISCARD_SAFE(cache->batch.edit_vertices);
GPU_BATCH_DISCARD_SAFE(cache->batch.edit_edges);
GPU_BATCH_DISCARD_SAFE(cache->batch.edit_facedots);
- /* Paint mode selection */
- /* TODO only do that in paint mode. */
+ GPU_BATCH_DISCARD_SAFE(cache->batch.edit_mesh_analysis);
+ /* Because visible UVs depends on edit mode selection, discard everything. */
+ mesh_batch_cache_discard_uvedit(cache);
+ break;
+ case BKE_MESH_BATCH_DIRTY_SELECT_PAINT:
+ /* Paint mode selection flag is packed inside the nor attrib.
+ * Note that it can be slow if auto smooth is enabled. (see T63946) */
GPU_VERTBUF_DISCARD_SAFE(cache->ordered.loop_pos_nor);
GPU_BATCH_DISCARD_SAFE(cache->batch.surface);
GPU_BATCH_DISCARD_SAFE(cache->batch.wire_loops);
@@ -2170,8 +2192,6 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
GPU_BATCH_DISCARD_SAFE(cache->surf_per_mat[i]);
}
}
- /* Because visible UVs depends on edit mode selection, discard everything. */
- mesh_batch_cache_discard_uvedit(cache);
break;
case BKE_MESH_BATCH_DIRTY_ALL:
cache->is_dirty = true;
@@ -3128,7 +3148,8 @@ static void mesh_create_loop_uv_and_tan(MeshRenderData *rdata, GPUVertBuf *vbo)
for (uint i = 0; i < uv_len; i++) {
const char *attr_name = mesh_render_data_uv_layer_uuid_get(rdata, i);
#if 0 /* these are clamped. Maybe use them as an option in the future */
- uv_id[i] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ uv_id[i] = GPU_vertformat_attr_add(
+ &format, attr_name, GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT);
#else
uv_id[i] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
#endif
@@ -3373,6 +3394,71 @@ static void mesh_create_edit_facedots(MeshRenderData *rdata, GPUVertBuf *vbo_fac
}
}
+static void mesh_create_edit_mesh_analysis(MeshRenderData *rdata, GPUVertBuf *vbo_mesh_analysis)
+{
+ const MeshStatVis *mesh_stat_vis = &rdata->toolsettings->statvis;
+
+ int mesh_analysis_len_used = 0;
+
+ const uint loops_len = mesh_render_data_loops_len_get(rdata);
+ BMesh *bm = rdata->edit_bmesh->bm;
+ BMIter iter_efa, iter_loop;
+ BMFace *efa;
+ BMLoop *loop;
+
+ static struct {
+ uint weight;
+ } attr_id;
+ static GPUVertFormat mesh_analysis_format = {0};
+ if (mesh_analysis_format.attr_len == 0) {
+ attr_id.weight = GPU_vertformat_attr_add(
+ &mesh_analysis_format, "weight_color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
+
+ /* TODO(jbakker): Maybe move data generation to mesh_render_data_create() */
+ BKE_editmesh_statvis_calc(rdata->edit_bmesh, rdata->edit_data, mesh_stat_vis);
+
+ if (DRW_TEST_ASSIGN_VBO(vbo_mesh_analysis)) {
+ GPU_vertbuf_init_with_format(vbo_mesh_analysis, &mesh_analysis_format);
+ GPU_vertbuf_data_alloc(vbo_mesh_analysis, loops_len);
+ }
+
+ const bool is_vertex_data = mesh_stat_vis->type == SCE_STATVIS_SHARP;
+ if (is_vertex_data) {
+ BM_ITER_MESH (efa, &iter_efa, bm, BM_FACES_OF_MESH) {
+ BM_ITER_ELEM (loop, &iter_loop, efa, BM_LOOPS_OF_FACE) {
+ uint vertex_index = BM_elem_index_get(loop->v);
+ GPU_vertbuf_attr_set(vbo_mesh_analysis,
+ attr_id.weight,
+ mesh_analysis_len_used,
+ &rdata->edit_bmesh->derivedVertColor[vertex_index]);
+ mesh_analysis_len_used += 1;
+ }
+ }
+ }
+ else {
+ uint face_index;
+ BM_ITER_MESH_INDEX (efa, &iter_efa, bm, BM_FACES_OF_MESH, face_index) {
+ BM_ITER_ELEM (loop, &iter_loop, efa, BM_LOOPS_OF_FACE) {
+ GPU_vertbuf_attr_set(vbo_mesh_analysis,
+ attr_id.weight,
+ mesh_analysis_len_used,
+ &rdata->edit_bmesh->derivedFaceColor[face_index]);
+ mesh_analysis_len_used += 1;
+ }
+ }
+ }
+
+ // Free temp data in edit bmesh
+ BKE_editmesh_color_free(rdata->edit_bmesh);
+
+ /* Resize & Finish */
+ if (mesh_analysis_len_used != loops_len) {
+ if (vbo_mesh_analysis != NULL) {
+ GPU_vertbuf_data_resize(vbo_mesh_analysis, mesh_analysis_len_used);
+ }
+ }
+}
/* Indices */
#define NO_EDGE INT_MAX
@@ -4185,6 +4271,12 @@ GPUBatch *DRW_mesh_batch_cache_get_wireframes_face(Mesh *me)
return DRW_batch_request(&cache->batch.wire_edges);
}
+GPUBatch *DRW_mesh_batch_cache_get_edit_mesh_analysis(Mesh *me)
+{
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
+ return DRW_batch_request(&cache->batch.edit_mesh_analysis);
+}
+
GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(Mesh *me,
struct GPUMaterial **gpumat_array,
uint gpumat_array_len,
@@ -4197,16 +4289,16 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(Mesh *me,
BLI_assert(gpumat_array_len == cache->mat_len);
- bool cd_overlap = mesh_cd_layers_type_overlap(cache->cd_used, cd_needed);
- if (!cd_overlap) {
- mesh_cd_layers_type_merge(&cache->cd_needed, cd_needed);
+ mesh_cd_layers_type_merge(&cache->cd_needed, cd_needed);
+ if (!mesh_cd_layers_type_overlap(cache->cd_used, cd_needed)) {
mesh_cd_extract_auto_layers_names_and_srgb(me,
cache->cd_needed,
&cache->auto_layer_names,
&cache->auto_layer_is_srgb,
&cache->auto_layer_len);
}
+
if (auto_layer_names) {
*auto_layer_names = cache->auto_layer_names;
*auto_layer_is_srgb = cache->auto_layer_is_srgb;
@@ -4419,8 +4511,7 @@ BLI_INLINE void edit_uv_preprocess_stretch_angle(float (*auv)[2],
BMLoop *l;
BMIter liter;
int i;
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
MLoopUV *luv_prev = BM_ELEM_CD_GET_VOID_P(l->prev, cd_loop_uv_offset);
@@ -4433,8 +4524,10 @@ BLI_INLINE void edit_uv_preprocess_stretch_angle(float (*auv)[2],
}
#if 0 /* here for reference, this is done in shader now. */
-BLI_INLINE float edit_uv_get_loop_stretch_angle(
- const float auv0[2], const float auv1[2], const float av0[3], const float av1[3])
+BLI_INLINE float edit_uv_get_loop_stretch_angle(const float auv0[2],
+ const float auv1[2],
+ const float av0[3],
+ const float av1[3])
{
float uvang = angle_normalized_v2v2(auv0, auv1);
float ang = angle_normalized_v3v3(av0, av1);
@@ -4509,16 +4602,25 @@ static void uvedit_fill_buffer_data(MeshRenderData *rdata,
}
/* Skip hidden faces. */
- if (elb_face && face_visible) {
- for (i = 0; i < efa->len; ++i) {
- GPU_indexbuf_add_generic_vert(elb_face, vidx + i);
- GPU_indexbuf_add_generic_vert(elb_vert, vidx + i);
- GPU_indexbuf_add_line_verts(elb_edge, vidx + i, vidx + (i + 1) % efa->len);
+ if (face_visible) {
+ if (elb_face) {
+ for (i = 0; i < efa->len; ++i) {
+ GPU_indexbuf_add_generic_vert(elb_face, vidx + i);
+ }
+ }
+ if (elb_vert) {
+ for (i = 0; i < efa->len; ++i) {
+ GPU_indexbuf_add_generic_vert(elb_vert, vidx + i);
+ }
+ }
+ if (elb_edge) {
+ for (i = 0; i < efa->len; ++i) {
+ GPU_indexbuf_add_line_verts(elb_edge, vidx + i, vidx + (i + 1) % efa->len);
+ }
}
}
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (vbo_area) {
GPU_vertbuf_attr_set(vbo_area, uv_attr_id.area, vidx, &area_stretch);
@@ -4578,18 +4680,24 @@ static void uvedit_fill_buffer_data(MeshRenderData *rdata,
GPU_vertbuf_attr_set(vbo_fdots_data, uv_attr_id.fdots_flag, fdot_idx, &face_flag);
}
/* Skip hidden faces. */
- if (elb_face && face_visible) {
- for (i = 0; i < mpoly->totloop; ++i) {
- GPU_indexbuf_add_generic_vert(elb_face, vidx + i);
- if (e_origindex[l[i].e] != ORIGINDEX_NONE) {
+ if (face_visible) {
+ if (elb_face) {
+ for (i = 0; i < mpoly->totloop; ++i) {
+ GPU_indexbuf_add_generic_vert(elb_face, vidx + i);
+ }
+ GPU_indexbuf_add_generic_vert(elb_face, vidx);
+ GPU_indexbuf_add_primitive_restart(elb_face);
+ }
+ if (elb_edge && e_origindex[l[i].e] != ORIGINDEX_NONE) {
+ for (i = 0; i < mpoly->totloop; ++i) {
GPU_indexbuf_add_line_verts(elb_edge, vidx + i, vidx + (i + 1) % mpoly->totloop);
}
- if (v_origindex[l[i].v] != ORIGINDEX_NONE) {
+ }
+ if (elb_vert && v_origindex[l[i].v] != ORIGINDEX_NONE) {
+ for (i = 0; i < mpoly->totloop; ++i) {
GPU_indexbuf_add_generic_vert(elb_vert, vidx + i);
}
}
- GPU_indexbuf_add_generic_vert(elb_face, vidx);
- GPU_indexbuf_add_primitive_restart(elb_face);
}
for (i = 0; i < mpoly->totloop; i++, l++) {
/* TODO support stretch. */
@@ -4714,6 +4822,28 @@ static void mesh_create_uvedit_buffers(MeshRenderData *rdata,
/** \name Grouped batch generation
* \{ */
+/* Thread safety need to be assured by caller. Don't call this during drawing.
+ * Note: For now this only free the shading batches / vbo if any cd layers is
+ * not needed anymore. */
+void DRW_mesh_batch_cache_free_old(Mesh *me, int ctime)
+{
+ MeshBatchCache *cache = me->runtime.batch_cache;
+
+ if (cache == NULL) {
+ return;
+ }
+
+ if (mesh_cd_layers_type_equal(cache->cd_used_over_time, cache->cd_used)) {
+ cache->lastmatch = ctime;
+ }
+
+ if (ctime - cache->lastmatch > U.vbotimeout) {
+ mesh_batch_cache_discard_shaded_tri(cache);
+ }
+
+ mesh_cd_layers_type_clear(&cache->cd_used_over_time);
+}
+
/* Can be called for any surface type. Mesh *me is the final mesh. */
void DRW_mesh_batch_cache_create_requested(
Object *ob, Mesh *me, const ToolSettings *ts, const bool is_paint_mode, const bool use_hide)
@@ -4730,6 +4860,18 @@ void DRW_mesh_batch_cache_create_requested(
drw_mesh_weight_state_clear(&wstate);
}
+ /* Optimization : Only create orco layer if mesh is deformed. */
+ if (cache->cd_needed.orco != 0) {
+ CustomData *cd_vdata = (me->edit_mesh) ? &me->edit_mesh->bm->vdata : &me->vdata;
+ if (CustomData_get_layer(cd_vdata, CD_ORCO) != NULL && ob->modifiers.first != NULL) {
+ /* Orco layer is needed. */
+ }
+ else if (cache->cd_needed.tan_orco == 0) {
+ /* Skip orco calculation if not needed by tangent generation. */
+ cache->cd_needed.orco = 0;
+ }
+ }
+
/* Verify that all surface batches have needed attribute layers. */
/* TODO(fclem): We could be a bit smarter here and only do it per material. */
bool cd_overlap = mesh_cd_layers_type_overlap(cache->cd_used, cache->cd_needed);
@@ -4754,6 +4896,7 @@ void DRW_mesh_batch_cache_create_requested(
mesh_cd_layers_type_merge(&cache->cd_used, cache->cd_needed);
}
+ mesh_cd_layers_type_merge(&cache->cd_used_over_time, cache->cd_needed);
mesh_cd_layers_type_clear(&cache->cd_needed);
/* Discard UV batches if sync_selection changes */
@@ -4779,8 +4922,10 @@ void DRW_mesh_batch_cache_create_requested(
}
}
+ bool has_request = false;
/* Init batches and request VBOs & IBOs */
if (DRW_batch_requested(cache->batch.surface, GPU_PRIM_TRIS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.surface, &cache->ibo.loops_tris);
DRW_vbo_request(cache->batch.surface, &cache->ordered.loop_pos_nor);
/* For paint overlay. Active layer should have been queried. */
@@ -4792,35 +4937,43 @@ void DRW_mesh_batch_cache_create_requested(
}
}
if (DRW_batch_requested(cache->batch.all_verts, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_vbo_request(cache->batch.all_verts, &cache->ordered.pos_nor);
}
if (DRW_batch_requested(cache->batch.all_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.all_edges, &cache->ibo.edges_lines);
DRW_vbo_request(cache->batch.all_edges, &cache->ordered.pos_nor);
}
if (DRW_batch_requested(cache->batch.loose_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.loose_edges, &cache->ibo.loose_edges_lines);
DRW_vbo_request(cache->batch.loose_edges, &cache->ordered.pos_nor);
}
if (DRW_batch_requested(cache->batch.edge_detection, GPU_PRIM_LINES_ADJ)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edge_detection, &cache->ibo.edges_adj_lines);
DRW_vbo_request(cache->batch.edge_detection, &cache->ordered.pos_nor);
}
if (DRW_batch_requested(cache->batch.surface_weights, GPU_PRIM_TRIS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.surface_weights, &cache->ibo.surf_tris);
DRW_vbo_request(cache->batch.surface_weights, &cache->ordered.pos_nor);
DRW_vbo_request(cache->batch.surface_weights, &cache->ordered.weights);
}
if (DRW_batch_requested(cache->batch.wire_loops, GPU_PRIM_LINE_STRIP)) {
+ has_request = true;
DRW_ibo_request(cache->batch.wire_loops, &cache->ibo.loops_line_strips);
DRW_vbo_request(cache->batch.wire_loops, &cache->ordered.loop_pos_nor);
}
if (DRW_batch_requested(cache->batch.wire_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.wire_edges, &cache->ibo.loops_lines);
DRW_vbo_request(cache->batch.wire_edges, &cache->ordered.loop_pos_nor);
DRW_vbo_request(cache->batch.wire_edges, &cache->ordered.loop_edge_fac);
}
if (DRW_batch_requested(cache->batch.wire_loops_uvs, GPU_PRIM_LINE_STRIP)) {
+ has_request = true;
DRW_ibo_request(cache->batch.wire_loops_uvs, &cache->ibo.loops_line_strips);
/* For paint overlay. Active layer should have been queried. */
if (cache->cd_used.uv != 0) {
@@ -4830,58 +4983,77 @@ void DRW_mesh_batch_cache_create_requested(
/* Edit Mesh */
if (DRW_batch_requested(cache->batch.edit_triangles, GPU_PRIM_TRIS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_triangles, &cache->ibo.edit_loops_tris);
DRW_vbo_request(cache->batch.edit_triangles, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_triangles, &cache->edit.loop_data);
}
if (DRW_batch_requested(cache->batch.edit_vertices, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_vertices, &cache->ibo.edit_loops_points);
DRW_vbo_request(cache->batch.edit_vertices, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_vertices, &cache->edit.loop_data);
}
if (DRW_batch_requested(cache->batch.edit_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_edges, &cache->ibo.edit_loops_lines);
DRW_vbo_request(cache->batch.edit_edges, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_edges, &cache->edit.loop_data);
}
if (DRW_batch_requested(cache->batch.edit_lnor, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_lnor, &cache->ibo.edit_loops_tris);
DRW_vbo_request(cache->batch.edit_lnor, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_lnor, &cache->edit.loop_lnor);
}
if (DRW_batch_requested(cache->batch.edit_facedots, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_vbo_request(cache->batch.edit_facedots, &cache->edit.facedots_pos_nor_data);
}
+ /* Mesh Analysis */
+ if (DRW_batch_requested(cache->batch.edit_mesh_analysis, GPU_PRIM_TRIS)) {
+ has_request = true;
+ DRW_ibo_request(cache->batch.edit_mesh_analysis, &cache->ibo.edit_loops_tris);
+ DRW_vbo_request(cache->batch.edit_mesh_analysis, &cache->edit.loop_pos_nor);
+ DRW_vbo_request(cache->batch.edit_mesh_analysis, &cache->edit.loop_mesh_analysis);
+ }
+
/* Edit UV */
if (DRW_batch_requested(cache->batch.edituv_faces, GPU_PRIM_TRI_FAN)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_faces, &cache->ibo.edituv_loops_tri_fans);
DRW_vbo_request(cache->batch.edituv_faces, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_faces, &cache->edit.loop_uv_data);
}
if (DRW_batch_requested(cache->batch.edituv_faces_strech_area, GPU_PRIM_TRI_FAN)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_faces_strech_area, &cache->ibo.edituv_loops_tri_fans);
DRW_vbo_request(cache->batch.edituv_faces_strech_area, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_faces_strech_area, &cache->edit.loop_uv_data);
DRW_vbo_request(cache->batch.edituv_faces_strech_area, &cache->edit.loop_stretch_area);
}
if (DRW_batch_requested(cache->batch.edituv_faces_strech_angle, GPU_PRIM_TRI_FAN)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_faces_strech_angle, &cache->ibo.edituv_loops_tri_fans);
DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &cache->edit.loop_uv_data);
DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &cache->edit.loop_stretch_angle);
}
if (DRW_batch_requested(cache->batch.edituv_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_edges, &cache->ibo.edituv_loops_line_strips);
DRW_vbo_request(cache->batch.edituv_edges, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_edges, &cache->edit.loop_uv_data);
}
if (DRW_batch_requested(cache->batch.edituv_verts, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edituv_verts, &cache->ibo.edituv_loops_points);
DRW_vbo_request(cache->batch.edituv_verts, &cache->edit.loop_uv);
DRW_vbo_request(cache->batch.edituv_verts, &cache->edit.loop_uv_data);
}
if (DRW_batch_requested(cache->batch.edituv_facedots, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_vbo_request(cache->batch.edituv_facedots, &cache->edit.facedots_uv);
DRW_vbo_request(cache->batch.edituv_facedots, &cache->edit.facedots_uv_data);
}
@@ -4889,21 +5061,25 @@ void DRW_mesh_batch_cache_create_requested(
/* Selection */
/* TODO reuse ordered.loop_pos_nor if possible. */
if (DRW_batch_requested(cache->batch.edit_selection_verts, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_selection_verts, &cache->ibo.edit_loops_points);
DRW_vbo_request(cache->batch.edit_selection_verts, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_selection_verts, &cache->edit.loop_vert_idx);
}
if (DRW_batch_requested(cache->batch.edit_selection_edges, GPU_PRIM_LINES)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_selection_edges, &cache->ibo.edit_loops_lines);
DRW_vbo_request(cache->batch.edit_selection_edges, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_selection_edges, &cache->edit.loop_edge_idx);
}
if (DRW_batch_requested(cache->batch.edit_selection_faces, GPU_PRIM_TRIS)) {
+ has_request = true;
DRW_ibo_request(cache->batch.edit_selection_faces, &cache->ibo.edit_loops_tris);
DRW_vbo_request(cache->batch.edit_selection_faces, &cache->edit.loop_pos_nor);
DRW_vbo_request(cache->batch.edit_selection_faces, &cache->edit.loop_face_idx);
}
if (DRW_batch_requested(cache->batch.edit_selection_facedots, GPU_PRIM_POINTS)) {
+ has_request = true;
DRW_vbo_request(cache->batch.edit_selection_facedots, &cache->edit.facedots_pos_nor_data);
DRW_vbo_request(cache->batch.edit_selection_facedots, &cache->edit.facedots_idx);
}
@@ -4911,6 +5087,7 @@ void DRW_mesh_batch_cache_create_requested(
/* Per Material */
for (int i = 0; i < cache->mat_len; ++i) {
if (DRW_batch_requested(cache->surf_per_mat[i], GPU_PRIM_TRIS)) {
+ has_request = true;
if (cache->mat_len > 1) {
DRW_ibo_request(cache->surf_per_mat[i], &cache->surf_per_mat_tris[i]);
}
@@ -4926,47 +5103,39 @@ void DRW_mesh_batch_cache_create_requested(
DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_vcol);
}
if (cache->cd_used.orco != 0) {
- /* OPTI : Only do that if there is modifiers that modify orcos. */
- CustomData *cd_vdata = (me->edit_mesh) ? &me->edit_mesh->bm->vdata : &me->vdata;
- if (CustomData_get_layer(cd_vdata, CD_ORCO) != NULL && ob->modifiers.first != NULL) {
- DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_orco);
- }
- else if (cache->cd_used.tan_orco == 0) {
- /* Skip orco calculation if not needed by tangent generation. */
- cache->cd_used.orco = 0;
- }
+ DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_orco);
}
}
}
+ /* Early out if no request. */
+ if (!has_request) {
+ return;
+ }
+
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+ printf("-- %s %s --\n", __func__, ob->id.name + 2);
+#endif
+
/* Generate MeshRenderData flags */
- int mr_flag = 0, mr_edit_flag = 0;
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.pos_nor, MR_DATATYPE_VERT);
+ eMRDataType mr_flag = 0, mr_edit_flag = 0;
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.pos_nor, MR_DATATYPE_VERT /* A comment to wrap the line ;) */);
DRW_ADD_FLAG_FROM_VBO_REQUEST(
mr_flag, cache->ordered.weights, MR_DATATYPE_VERT | MR_DATATYPE_DVERT);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_pos_nor,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_uv_tan,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_SHADING | MR_DATATYPE_LOOPTRI);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_orco,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_SHADING);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_vcol,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_SHADING);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag,
- cache->ordered.loop_edge_fac,
- MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_EDGE |
- MR_DATATYPE_LOOP);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag,
- cache->ibo.surf_tris,
- MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY |
- MR_DATATYPE_LOOPTRI);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_pos_nor, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_LOOP_NORMALS);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_uv_tan, MR_DATATYPE_VERT_LOOP_TRI_POLY | MR_DATATYPE_SHADING);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_orco, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_SHADING);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_vcol, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_SHADING);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_flag, cache->ordered.loop_edge_fac, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_EDGE);
+
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_flag, cache->ibo.surf_tris, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_LOOPTRI);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
mr_flag, cache->ibo.loops_tris, MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
@@ -4975,74 +5144,69 @@ void DRW_mesh_batch_cache_create_requested(
mr_flag, cache->ibo.loops_line_strips, MR_DATATYPE_LOOP | MR_DATATYPE_POLY);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
mr_flag, cache->ibo.edges_lines, MR_DATATYPE_VERT | MR_DATATYPE_EDGE);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag,
- cache->ibo.edges_adj_lines,
- MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY |
- MR_DATATYPE_LOOPTRI);
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_flag, cache->ibo.edges_adj_lines, MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_LOOPTRI);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
mr_flag, cache->ibo.loose_edges_lines, MR_DATATYPE_VERT | MR_DATATYPE_EDGE);
for (int i = 0; i < cache->mat_len; ++i) {
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag,
- cache->surf_per_mat_tris[i],
- MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI);
- }
-
- int combined_edit_flag = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP |
- MR_DATATYPE_POLY | MR_DATATYPE_LOOSE_VERT | MR_DATATYPE_LOOSE_EDGE |
- MR_DATATYPE_OVERLAY;
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_pos_nor, combined_edit_flag);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_lnor, combined_edit_flag);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_data, combined_edit_flag);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_uv_data, combined_edit_flag);
+ int combined_flag = MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI;
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->surf_per_mat_tris[i], combined_flag);
+ }
+
+ int combined_edit_flag = MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_EDGE |
+ MR_DATATYPE_LOOSE_VERT_EGDE;
+ int combined_edit_with_lnor_flag = combined_edit_flag | MR_DATATYPE_LOOP_NORMALS;
+ int combined_edituv_flag = combined_edit_flag | MR_DATATYPE_LOOPUV;
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_pos_nor, combined_edit_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_lnor, combined_edit_with_lnor_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_data, combined_edit_flag | MR_DATATYPE_OVERLAY);
DRW_ADD_FLAG_FROM_VBO_REQUEST(
- mr_edit_flag, cache->edit.loop_uv, combined_edit_flag | MR_DATATYPE_LOOPUV);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag,
- cache->edit.loop_vert_idx,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag,
- cache->edit.loop_edge_idx,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag,
- cache->edit.loop_face_idx,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP);
+ mr_edit_flag, cache->edit.loop_uv_data, combined_edit_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_uv, combined_edituv_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_stretch_angle, combined_edit_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_stretch_area, combined_edit_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.loop_mesh_analysis, MR_DATATYPE_VERT_LOOP_POLY);
+
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_vert_idx, combined_edit_flag);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_edge_idx, combined_edit_flag);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_face_idx, combined_edit_flag);
DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.facedots_idx, MR_DATATYPE_POLY);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag,
- cache->edit.facedots_pos_nor_data,
- MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY |
- MR_DATATYPE_OVERLAY);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_stretch_angle, combined_edit_flag);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.loop_stretch_area, combined_edit_flag);
+
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.facedots_pos_nor_data, MR_DATATYPE_POLY | MR_DATATYPE_OVERLAY);
DRW_ADD_FLAG_FROM_VBO_REQUEST(
- mr_edit_flag, cache->edit.facedots_uv, combined_edit_flag | MR_DATATYPE_LOOPUV);
- DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_edit_flag, cache->edit.facedots_uv_data, combined_edit_flag);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_edit_flag, cache->ibo.edituv_loops_points, combined_edit_flag);
+ mr_edit_flag, cache->edit.facedots_uv, combined_edituv_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_VBO_REQUEST(
+ mr_edit_flag, cache->edit.facedots_uv_data, combined_edit_flag | MR_DATATYPE_OVERLAY);
+
DRW_ADD_FLAG_FROM_IBO_REQUEST(
- mr_edit_flag, cache->ibo.edituv_loops_line_strips, combined_edit_flag);
+ mr_edit_flag, cache->ibo.edituv_loops_points, combined_edit_flag | MR_DATATYPE_OVERLAY);
DRW_ADD_FLAG_FROM_IBO_REQUEST(
- mr_edit_flag, cache->ibo.edituv_loops_tri_fans, combined_edit_flag);
- /* TODO: Some of the flags here may not be needed. */
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_edit_flag,
- cache->ibo.edit_loops_points,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_LOOPTRI);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_edit_flag,
- cache->ibo.edit_loops_lines,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_LOOPTRI);
- DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_edit_flag,
- cache->ibo.edit_loops_tris,
- MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOSE_VERT |
- MR_DATATYPE_LOOSE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP |
- MR_DATATYPE_LOOPTRI);
+ mr_edit_flag, cache->ibo.edituv_loops_line_strips, combined_edit_flag | MR_DATATYPE_OVERLAY);
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_edit_flag, cache->ibo.edituv_loops_tri_fans, combined_edit_flag | MR_DATATYPE_OVERLAY);
+
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_edit_flag, cache->ibo.edit_loops_points, combined_edit_flag | MR_DATATYPE_LOOPTRI);
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_edit_flag, cache->ibo.edit_loops_lines, combined_edit_flag | MR_DATATYPE_LOOPTRI);
+ DRW_ADD_FLAG_FROM_IBO_REQUEST(
+ mr_edit_flag, cache->ibo.edit_loops_tris, combined_edit_flag | MR_DATATYPE_LOOPTRI);
Mesh *me_original = me;
MBC_GET_FINAL_MESH(me);
+#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
+ printf(" mr_flag %u, mr_edit_flag %u\n\n", mr_flag, mr_edit_flag);
+#endif
+
if (me_original == me) {
mr_flag |= mr_edit_flag;
}
@@ -5140,6 +5304,9 @@ void DRW_mesh_batch_cache_create_requested(
if (DRW_ibo_requested(cache->ibo.edit_loops_tris)) {
mesh_create_edit_loops_tris(rdata, cache->ibo.edit_loops_tris);
}
+ if (DRW_vbo_requested(cache->edit.loop_mesh_analysis)) {
+ mesh_create_edit_mesh_analysis(rdata, cache->edit.loop_mesh_analysis);
+ }
/* UV editor */
/**
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index 2c06d536f3d..432c5092274 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -265,4 +265,4 @@ struct GPUBatch *DRW_metaball_batch_cache_get_edge_detection(struct Object *ob,
}
return cache->edge_detection;
-} \ No newline at end of file
+}
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index e998b17a44f..9a15c51598f 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -99,7 +99,7 @@ typedef struct HairAttributeID {
typedef struct EditStrandData {
float pos[3];
- uchar color;
+ float color;
} EditStrandData;
static GPUVertFormat *edit_points_vert_format_get(uint *r_pos_id, uint *r_color_id)
@@ -110,7 +110,7 @@ static GPUVertFormat *edit_points_vert_format_get(uint *r_pos_id, uint *r_color_
/* Keep in sync with EditStrandData */
pos_id = GPU_vertformat_attr_add(&edit_point_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
color_id = GPU_vertformat_attr_add(
- &edit_point_format, "color", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ &edit_point_format, "color", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
}
*r_pos_id = pos_id;
*r_color_id = color_id;
@@ -693,12 +693,12 @@ static int particle_batch_cache_fill_segments_edit(
float strand_t = (float)(j) / path->segments;
if (particle) {
float weight = particle_key_weight(particle, i, strand_t);
- /* NaN or unclamped become 0xFF */
- seg_data->color = (uchar)((weight <= 1.0f) ? 0xFE * weight : 0xFF);
+ /* NaN or unclamped become 1.0f */
+ seg_data->color = (weight < 1.0f) ? weight : 1.0f;
}
else {
float selected = particle_key_select_ratio(edit, i, strand_t);
- seg_data->color = (uchar)(0xFF * selected);
+ seg_data->color = selected;
}
GPU_indexbuf_add_generic_vert(elb, curr_point);
curr_point++;
@@ -1565,7 +1565,7 @@ static void particle_batch_cache_ensure_edit_inner_pos(PTCacheEdit *edit,
const PTCacheEditPoint *point = &edit->points[point_index];
for (int key_index = 0; key_index < point->totkey - 1; key_index++) {
PTCacheEditKey *key = &point->keys[key_index];
- uchar color = (key->flag & PEK_SELECT) ? 0xFF : 0x00;
+ float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
GPU_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co);
GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, &color);
global_key_index++;
@@ -1611,7 +1611,8 @@ static void particle_batch_cache_ensure_edit_tip_pos(PTCacheEdit *edit, Particle
for (int point_index = 0; point_index < edit->totpoint; point_index++) {
const PTCacheEditPoint *point = &edit->points[point_index];
PTCacheEditKey *key = &point->keys[point->totkey - 1];
- uchar color = (key->flag & PEK_SELECT) ? 0xFF : 0x00;
+ float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
+
GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co);
GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, &color);
}
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 465a4f7a897..b4eb354ec59 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -90,8 +90,8 @@ void DRW_globals_update(void)
dot_v3v3(gb->colorEditMeshMiddle, (float[3]){0.3333f, 0.3333f, 0.3333f})); /* Desaturate */
interp_v4_v4v4(gb->colorDupliSelect, gb->colorBackground, gb->colorSelect, 0.5f);
- /* Was 50% in 2.7x since the background was lighter making it easier to tell the color from black,
- * with a darker background we need a more faded color. */
+ /* Was 50% in 2.7x since the background was lighter making it easier to tell the color from
+ * black, with a darker background we need a more faded color. */
interp_v4_v4v4(gb->colorDupli, gb->colorBackground, gb->colorWire, 0.3f);
#ifdef WITH_FREESTYLE
@@ -142,7 +142,7 @@ void DRW_globals_update(void)
UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, gb->colorOutline);
UI_GetThemeColorShadeAlpha4fv(TH_LIGHT, 0, 255, gb->colorLightNoAlpha);
- gb->sizeLightCenter = (U.obcenter_dia + 1.5f) * U.pixelsize;
+ gb->sizeLightCenter = (UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.5f) * U.pixelsize;
gb->sizeLightCircle = U.pixelsize * 9.0f;
gb->sizeLightCircleShadow = gb->sizeLightCircle + U.pixelsize * 3.0f;
@@ -1045,7 +1045,7 @@ struct GPUShader *volume_velocity_shader_get(bool use_needle)
}
}
-/* ******************************************** COLOR UTILS *********************************************** */
+/* ******************************************** COLOR UTILS ************************************ */
/* TODO FINISH */
/**
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index db8f8d46e85..489bc7459df 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -216,6 +216,7 @@ typedef struct DRWArmaturePasses {
struct DRWPass *bone_envelope;
struct DRWPass *bone_axes;
struct DRWPass *relationship_lines;
+ struct GHash *custom_shapes;
} DRWArmaturePasses;
void DRW_shgroup_armature_object(struct Object *ob,
diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c
index b3081a44dfb..cb83265195a 100644
--- a/source/blender/draw/intern/draw_hair.c
+++ b/source/blender/draw/intern/draw_hair.c
@@ -193,7 +193,8 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(Object *object,
DRW_shgroup_uniform_float_copy(shgrp, "hairRadTip", part->rad_tip * part->rad_scale * 0.5f);
DRW_shgroup_uniform_bool_copy(
shgrp, "hairCloseTip", (part->shape_flag & PART_SHAPE_CLOSE_TIP) != 0);
- /* TODO(fclem): Until we have a better way to cull the hair and render with orco, bypass culling test. */
+ /* TODO(fclem): Until we have a better way to cull the hair and render with orco, bypass culling
+ * test. */
DRW_shgroup_call_object_add_no_cull(
shgrp, hair_cache->final[subdiv].proc_hairs[thickness_res - 1], object);
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 27e03a3495a..e8d91309e06 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -22,11 +22,11 @@
/**
* DRW Instance Data Manager
- * This is a special memory manager that keeps memory blocks ready to send as vbo data in one continuous allocation.
- * This way we avoid feeding gawain each instance data one by one and unnecessary memcpy.
- * Since we loose which memory block was used each #DRWShadingGroup we need to redistribute them in the same order/size
- * to avoid to realloc each frame.
- * This is why #DRWInstanceDatas are sorted in a list for each different data size.
+ * This is a special memory manager that keeps memory blocks ready to send as vbo data in one
+ * continuous allocation. This way we avoid feeding gawain each instance data one by one and
+ * unnecessary memcpy. Since we loose which memory block was used each #DRWShadingGroup we need to
+ * redistribute them in the same order/size to avoid to realloc each frame. This is why
+ * #DRWInstanceDatas are sorted in a list for each different data size.
*/
#include "draw_instance_data.h"
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 9e078fd2774..5c88c1f93db 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -35,6 +35,7 @@
#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_lattice.h"
+#include "BKE_main.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
@@ -404,7 +405,7 @@ void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color, bool
builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_16_DEPTH_TEST;
break;
default:
- BLI_assert("Mulisample count unsupported by blit shader.");
+ BLI_assert(!"Mulisample count unsupported by blit shader.");
builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2_DEPTH_TEST;
break;
}
@@ -424,7 +425,7 @@ void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color, bool
builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_16;
break;
default:
- BLI_assert("Mulisample count unsupported by blit shader.");
+ BLI_assert(!"Mulisample count unsupported by blit shader.");
builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2;
break;
}
@@ -518,11 +519,20 @@ static void drw_viewport_cache_resize(void)
GPU_viewport_cache_release(DST.viewport);
if (DST.vmempool != NULL) {
+ /* Release Image textures. */
+ BLI_mempool_iter iter;
+ GPUTexture **tex;
+ BLI_mempool_iternew(DST.vmempool->images, &iter);
+ while ((tex = BLI_mempool_iterstep(&iter))) {
+ GPU_texture_free(*tex);
+ }
+
BLI_mempool_clear_ex(DST.vmempool->calls, BLI_mempool_len(DST.vmempool->calls));
BLI_mempool_clear_ex(DST.vmempool->states, BLI_mempool_len(DST.vmempool->states));
BLI_mempool_clear_ex(DST.vmempool->shgroups, BLI_mempool_len(DST.vmempool->shgroups));
BLI_mempool_clear_ex(DST.vmempool->uniforms, BLI_mempool_len(DST.vmempool->uniforms));
BLI_mempool_clear_ex(DST.vmempool->passes, BLI_mempool_len(DST.vmempool->passes));
+ BLI_mempool_clear_ex(DST.vmempool->images, BLI_mempool_len(DST.vmempool->images));
}
DRW_instance_data_list_free_unused(DST.idatalist);
@@ -602,6 +612,10 @@ static void drw_viewport_var_init(void)
if (DST.vmempool->passes == NULL) {
DST.vmempool->passes = BLI_mempool_create(sizeof(DRWPass), 0, 64, 0);
}
+ if (DST.vmempool->images == NULL) {
+ DST.vmempool->images = BLI_mempool_create(
+ sizeof(GPUTexture *), 0, 512, BLI_MEMPOOL_ALLOW_ITER);
+ }
DST.idatalist = GPU_viewport_instance_data_list_get(DST.viewport);
DRW_instance_data_list_reset(DST.idatalist);
@@ -966,6 +980,45 @@ static void drw_drawdata_unlink_dupli(ID *id)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Garbage Collection
+ * \{ */
+
+void DRW_cache_free_old_batches(Main *bmain)
+{
+ Scene *scene;
+ ViewLayer *view_layer;
+ static int lasttime = 0;
+ int ctime = (int)PIL_check_seconds_timer();
+
+ if (U.vbotimeout == 0 || (ctime - lasttime) < U.vbocollectrate || ctime == lasttime) {
+ return;
+ }
+
+ lasttime = ctime;
+
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
+ Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, false);
+ if (depsgraph == NULL) {
+ continue;
+ }
+
+ /* TODO(fclem): This is not optimal since it iter over all dupli instances.
+ * In this case only the source object should be tagged. */
+ int iter_flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
+ DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI;
+
+ DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flags) {
+ DRW_batch_cache_free_old(ob, ctime);
+ }
+ DEG_OBJECT_ITER_END;
+ }
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Rendering (DRW_engines)
* \{ */
@@ -1083,9 +1136,8 @@ static void drw_engines_draw_background(void)
}
/* No draw_background found, doing default background */
- if (DRW_state_draw_background()) {
- DRW_draw_background();
- }
+ const bool do_alpha_checker = !DRW_state_draw_background();
+ DRW_draw_background(do_alpha_checker);
}
static void drw_engines_draw_scene(void)
@@ -1434,6 +1486,7 @@ void DRW_draw_view(const bContext *C)
drw_state_prepare_clean_for_draw(&DST);
DST.options.draw_text = ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0 &&
(v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) != 0);
+ DST.options.draw_background = scene->r.alphamode == R_ADDSKY;
DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, viewport, C);
}
@@ -1500,11 +1553,10 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph,
drw_engines_world_update(scene);
const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
- DEG_OBJECT_ITER_BEGIN (depsgraph,
- ob,
- DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
- DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
- DEG_ITER_OBJECT_FLAG_DUPLI) {
+ const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI;
+ DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flag) {
if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
continue;
}
@@ -1951,11 +2003,10 @@ void DRW_render_object_iter(
const int object_type_exclude_viewport = draw_ctx->v3d ?
draw_ctx->v3d->object_type_exclude_viewport :
0;
- DEG_OBJECT_ITER_BEGIN (depsgraph,
- ob,
- DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
- DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
- DEG_ITER_OBJECT_FLAG_DUPLI) {
+ const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI;
+ DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flag) {
if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
DST.dupli_parent = data_.dupli_parent;
DST.dupli_source = data_.dupli_object_current;
@@ -2205,14 +2256,13 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
# endif
}
else {
+ const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI;
const int object_type_exclude_select = (v3d->object_type_exclude_viewport |
v3d->object_type_exclude_select);
bool filter_exclude = false;
- DEG_OBJECT_ITER_BEGIN (depsgraph,
- ob,
- DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
- DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
- DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI) {
+ DEG_OBJECT_ITER_BEGIN (depsgraph, ob, iter_flag) {
if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
continue;
}
@@ -2294,42 +2344,6 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
#endif /* USE_GPU_SELECT */
}
-static void draw_depth_texture_to_screen(GPUTexture *texture)
-{
- const float w = (float)GPU_texture_width(texture);
- const float h = (float)GPU_texture_height(texture);
-
- GPUVertFormat *format = immVertexFormat();
- uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_IMAGE_DEPTH_COPY);
-
- GPU_texture_bind(texture, 0);
-
- immUniform1i("image", 0); /* default GL_TEXTURE0 unit */
-
- immBegin(GPU_PRIM_TRI_STRIP, 4);
-
- immAttr2f(texcoord, 0.0f, 0.0f);
- immVertex2f(pos, 0.0f, 0.0f);
-
- immAttr2f(texcoord, 1.0f, 0.0f);
- immVertex2f(pos, w, 0.0f);
-
- immAttr2f(texcoord, 0.0f, 1.0f);
- immVertex2f(pos, 0.0f, h);
-
- immAttr2f(texcoord, 1.0f, 1.0f);
- immVertex2f(pos, w, h);
-
- immEnd();
-
- GPU_texture_unbind(texture);
-
- immUnbindProgram();
-}
-
/**
* object mode select-loop, see: ED_view3d_draw_depth_loop (legacy drawing).
*/
@@ -2360,11 +2374,10 @@ static void drw_draw_depth_loop_imp(void)
View3D *v3d = DST.draw_ctx.v3d;
const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
- DEG_OBJECT_ITER_BEGIN (DST.draw_ctx.depsgraph,
- ob,
- DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
- DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
- DEG_ITER_OBJECT_FLAG_DUPLI) {
+ const int iter_flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
+ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE |
+ DEG_ITER_OBJECT_FLAG_DUPLI;
+ DEG_OBJECT_ITER_BEGIN (DST.draw_ctx.depsgraph, ob, iter_flag) {
if ((object_type_exclude_viewport & (1 << ob->type)) != 0) {
continue;
}
@@ -2446,21 +2459,6 @@ void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
drw_engines_disable();
- /* XXX Drawing the resulting buffer to the BACK_BUFFER */
- GPU_matrix_push();
- GPU_matrix_push_projection();
- wmOrtho2_region_pixelspace(DST.draw_ctx.ar);
- GPU_matrix_identity_set();
-
- glEnable(GL_DEPTH_TEST); /* Cannot write to depth buffer without testing */
- glDepthFunc(GL_ALWAYS);
- DefaultTextureList *dtxl = (DefaultTextureList *)GPU_viewport_texture_list_get(DST.viewport);
- draw_depth_texture_to_screen(dtxl->depth);
- glDepthFunc(GL_LEQUAL);
-
- GPU_matrix_pop();
- GPU_matrix_pop_projection();
-
#ifdef DEBUG
/* Avoid accidental reuse. */
drw_state_ensure_not_reused(&DST);
@@ -2506,6 +2504,69 @@ void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
#endif
}
+/**
+ * Clears the Depth Buffer and draws only the specified object.
+ */
+void DRW_draw_depth_object(ARegion *ar, GPUViewport *viewport, Object *object)
+{
+ RegionView3D *rv3d = ar->regiondata;
+
+ DRW_opengl_context_enable();
+
+ /* Setup framebuffer */
+ DefaultFramebufferList *fbl = GPU_viewport_framebuffer_list_get(viewport);
+
+ GPU_framebuffer_bind(fbl->depth_only_fb);
+ GPU_framebuffer_clear_depth(fbl->depth_only_fb, 1.0f);
+ GPU_depth_test(true);
+ GPU_matrix_mul(object->obmat);
+
+ const float(*world_clip_planes)[4] = NULL;
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ ED_view3d_clipping_set(rv3d);
+ ED_view3d_clipping_local(rv3d, object->obmat);
+ world_clip_planes = rv3d->clip_local;
+ }
+
+ switch (object->type) {
+ case OB_MESH: {
+ GPUBatch *batch;
+
+ Mesh *me = object->data;
+
+ if (object->mode & OB_MODE_EDIT) {
+ batch = DRW_mesh_batch_cache_get_edit_triangles(me);
+ }
+ else {
+ batch = DRW_mesh_batch_cache_get_surface(me);
+ }
+
+ DRW_mesh_batch_cache_create_requested(object, me, NULL, false, true);
+
+ const eGPUShaderConfig sh_cfg = world_clip_planes ? GPU_SHADER_CFG_CLIPPED :
+ GPU_SHADER_CFG_DEFAULT;
+ GPU_batch_program_set_builtin_with_config(batch, GPU_SHADER_3D_DEPTH_ONLY, sh_cfg);
+ if (world_clip_planes != NULL) {
+ GPU_batch_uniform_4fv_array(batch, "WorldClipPlanes", 6, world_clip_planes[0]);
+ }
+
+ GPU_batch_draw(batch);
+ } break;
+ case OB_CURVE:
+ case OB_SURF:
+ break;
+ }
+
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ ED_view3d_clipping_disable();
+ }
+
+ GPU_matrix_set(rv3d->viewmat);
+ GPU_depth_test(false);
+ GPU_framebuffer_restore();
+ DRW_opengl_context_disable();
+}
+
/* Set an opengl context to be used with shaders that draw on U32 colors. */
void DRW_framebuffer_select_id_setup(ARegion *ar, const bool clear)
{
@@ -2669,9 +2730,6 @@ bool DRW_state_draw_support(void)
*/
bool DRW_state_draw_background(void)
{
- if (DRW_state_is_image_render() == false) {
- return true;
- }
return DST.options.draw_background;
}
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 35e2ab86a80..a70438a2d37 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -56,7 +56,9 @@
# define PROFILE_TIMER_FALLOFF 0.04
-# define PROFILE_START(time_start) double time_start = PIL_check_seconds_timer();
+# define PROFILE_START(time_start) \
+ double time_start = PIL_check_seconds_timer(); \
+ ((void)0)
# define PROFILE_END_ACCUM(time_accum, time_start) \
{ \
@@ -251,10 +253,12 @@ struct DRWShadingGroup {
};
};
- DRWState state_extra; /* State changes for this batch only (or'd with the pass's state) */
- DRWState
- state_extra_disable; /* State changes for this batch only (and'd with the pass's state) */
- uint stencil_mask; /* Stencil mask to use for stencil test / write operations */
+ /** State changes for this batch only (or'd with the pass's state) */
+ DRWState state_extra;
+ /** State changes for this batch only (and'd with the pass's state) */
+ DRWState state_extra_disable;
+ /** Stencil mask to use for stencil test / write operations */
+ uint stencil_mask;
DRWShadingGroupType type;
/* Builtin matrices locations */
@@ -393,10 +397,11 @@ typedef struct DRWManager {
/* gl_context serves as the offset for clearing only
* the top portion of the struct so DO NOT MOVE IT! */
- void *gl_context; /* Unique ghost context used by the draw manager. */
+ /** Unique ghost context used by the draw manager. */
+ void *gl_context;
GPUContext *gpu_context;
- TicketMutex
- *gl_context_mutex; /* Mutex to lock the drw manager and avoid concurrent context usage. */
+ /** Mutex to lock the drw manager and avoid concurrent context usage. */
+ TicketMutex *gl_context_mutex;
/** GPU Resource State: Memory storage between drawing. */
struct {
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 4a9f4fe910b..65ef2fa66fa 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -161,7 +161,8 @@ void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, con
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_TEXTURE, tex, 0, 1);
}
-/* Same as DRW_shgroup_uniform_texture but is guaranteed to be bound if shader does not change between shgrp. */
+/* Same as DRW_shgroup_uniform_texture but is guaranteed to be bound if shader does not change
+ * between shgrp. */
void DRW_shgroup_uniform_texture_persistent(DRWShadingGroup *shgroup,
const char *name,
const GPUTexture *tex)
@@ -178,7 +179,8 @@ void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup,
drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_BLOCK, ubo, 0, 1);
}
-/* Same as DRW_shgroup_uniform_block but is guaranteed to be bound if shader does not change between shgrp. */
+/* Same as DRW_shgroup_uniform_block but is guaranteed to be bound if shader does not change
+ * between shgrp. */
void DRW_shgroup_uniform_block_persistent(DRWShadingGroup *shgroup,
const char *name,
const GPUUniformBuffer *ubo)
@@ -634,6 +636,17 @@ void DRW_shgroup_call_generate_add(DRWShadingGroup *shgroup,
BLI_LINKS_APPEND(&shgroup->calls, call);
}
+/* This function tests if the current draw engine draws the vertex colors
+ * It is used when drawing sculpts
+ *
+ * XXX: should we use a callback to a the draw engine to retrieve this
+ * setting, this makes the draw manager more clean? */
+static bool DRW_draw_vertex_color_active(const DRWContextState *draw_ctx)
+{
+ View3D *v3d = draw_ctx->v3d;
+ return v3d->shading.type == OB_SOLID && v3d->shading.color_type == V3D_SHADING_VERTEX_COLOR;
+}
+
static void sculpt_draw_cb(DRWShadingGroup *shgroup,
void (*draw_fn)(DRWShadingGroup *shgroup, GPUBatch *geom),
void *user_data)
@@ -654,8 +667,16 @@ static void sculpt_draw_cb(DRWShadingGroup *shgroup,
}
if (pbvh) {
- BKE_pbvh_draw_cb(
- pbvh, NULL, NULL, fast_mode, false, false, (void (*)(void *, GPUBatch *))draw_fn, shgroup);
+ const bool show_vcol = DRW_draw_vertex_color_active(drwctx);
+ BKE_pbvh_draw_cb(pbvh,
+ NULL,
+ NULL,
+ fast_mode,
+ false,
+ false,
+ show_vcol,
+ (void (*)(void *, GPUBatch *))draw_fn,
+ shgroup);
}
}
@@ -679,8 +700,15 @@ static void sculpt_draw_wires_cb(DRWShadingGroup *shgroup,
}
if (pbvh) {
- BKE_pbvh_draw_cb(
- pbvh, NULL, NULL, fast_mode, true, false, (void (*)(void *, GPUBatch *))draw_fn, shgroup);
+ BKE_pbvh_draw_cb(pbvh,
+ NULL,
+ NULL,
+ fast_mode,
+ true,
+ false,
+ false,
+ (void (*)(void *, GPUBatch *))draw_fn,
+ shgroup);
}
}
@@ -955,8 +983,12 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp,
GPUTexture *tex = NULL;
if (input->ima) {
- tex = GPU_texture_from_blender(
+ GPUTexture **tex_ref = BLI_mempool_alloc(DST.vmempool->images);
+
+ *tex_ref = tex = GPU_texture_from_blender(
input->ima, input->iuser, GL_TEXTURE_2D, input->image_isdata);
+
+ GPU_texture_ref(tex);
}
else {
/* Color Ramps */
@@ -1148,7 +1180,7 @@ void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch
/* PERF : This destroys the vaos cache so better check if it's necessary. */
/* Note: This WILL break if batch->verts[0] is destroyed and reallocated
* at the same address. Bindings/VAOs would remain obsolete. */
- //if (shgroup->instancing_geom->inst != batch->verts[0])
+ // if (shgroup->instancing_geom->inst != batch->verts[0])
GPU_batch_instbuf_set(shgroup->instance_geom, batch->verts[0], false);
#ifdef USE_GPU_SELECT
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index db675ee0210..8e23a616ff5 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -205,7 +205,7 @@ void drw_state_set(DRWState state)
int test;
if (CHANGED_ANY_STORE_VAR(DRW_STATE_BLEND | DRW_STATE_BLEND_PREMUL | DRW_STATE_ADDITIVE |
DRW_STATE_MULTIPLY | DRW_STATE_ADDITIVE_FULL |
- DRW_STATE_BLEND_OIT,
+ DRW_STATE_BLEND_OIT | DRW_STATE_BLEND_PREMUL_UNDER,
test)) {
if (test) {
glEnable(GL_BLEND);
@@ -216,6 +216,9 @@ void drw_state_set(DRWState state)
GL_ONE,
GL_ONE_MINUS_SRC_ALPHA); /* Alpha */
}
+ else if ((state & DRW_STATE_BLEND_PREMUL_UNDER) != 0) {
+ glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);
+ }
else if ((state & DRW_STATE_BLEND_PREMUL) != 0) {
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
@@ -445,8 +448,9 @@ void DRW_state_clip_planes_set_from_rv3d(RegionView3D *rv3d)
/* Extract the 8 corners from a Projection Matrix.
* Although less accurate, this solution can be simplified as follows:
- * BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const float[3]){1.0f, 1.0f, 1.0f});
- * for (int i = 0; i < 8; i++) {mul_project_m4_v3(projinv, bbox.vec[i]);}
+ * BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const
+ * float[3]){1.0f, 1.0f, 1.0f}); for (int i = 0; i < 8; i++) {mul_project_m4_v3(projinv,
+ * bbox.vec[i]);}
*/
static void draw_frustum_boundbox_calc(const float (*projmat)[4], BoundBox *r_bbox)
{
@@ -498,7 +502,8 @@ static void draw_clipping_setup_from_view(void)
/* Extract Clipping Planes */
BoundBox bbox;
#if 0 /* It has accuracy problems. */
- BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const float[3]){1.0f, 1.0f, 1.0f});
+ BKE_boundbox_init_from_minmax(
+ &bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const float[3]){1.0f, 1.0f, 1.0f});
for (int i = 0; i < 8; i++) {
mul_project_m4_v3(projinv, bbox.vec[i]);
}
@@ -616,9 +621,9 @@ static void draw_clipping_setup_from_view(void)
float F = -1.0f, N; /* square distance of far and near point to origin */
float f, n; /* distance of far and near point to z axis. f is always > 0 but n can be < 0 */
float e, s; /* far and near clipping distance (<0) */
- float
- c; /* slope of center line = distance of far clipping center to z axis / far clipping distance */
- float z; /* projection of sphere center on z axis (<0) */
+ float c; /* slope of center line = distance of far clipping center
+ * to z axis / far clipping distance. */
+ float z; /* projection of sphere center on z axis (<0) */
/* Find farthest corner and center of far clip plane. */
float corner[3] = {1.0f, 1.0f, 1.0f}; /* in clip space */
@@ -1230,12 +1235,13 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
# define GPU_SELECT_LOAD_IF_PICKSEL_LIST_END(_start, _count) \
_start += _count; \
- }
+ } \
+ ((void)0)
#else
# define GPU_SELECT_LOAD_IF_PICKSEL(select_id)
# define GPU_SELECT_LOAD_IF_PICKSEL_CALL(call)
-# define GPU_SELECT_LOAD_IF_PICKSEL_LIST_END(start, count)
+# define GPU_SELECT_LOAD_IF_PICKSEL_LIST_END(start, count) ((void)0)
# define GPU_SELECT_LOAD_IF_PICKSEL_LIST(_shgroup, _start, _count) \
_start = 0; \
_count = _shgroup->instance_count;
@@ -1259,11 +1265,10 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
if (shgroup->instance_count > 0) {
uint count, start;
draw_geometry_prepare(shgroup, NULL);
- GPU_SELECT_LOAD_IF_PICKSEL_LIST(shgroup, start, count)
- {
+ GPU_SELECT_LOAD_IF_PICKSEL_LIST (shgroup, start, count) {
draw_geometry_execute_ex(shgroup, shgroup->instance_geom, start, count, true);
}
- GPU_SELECT_LOAD_IF_PICKSEL_LIST_END(start, count)
+ GPU_SELECT_LOAD_IF_PICKSEL_LIST_END(start, count);
}
}
}
@@ -1272,11 +1277,10 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
if (shgroup->instance_count > 0) {
uint count, start;
draw_geometry_prepare(shgroup, NULL);
- GPU_SELECT_LOAD_IF_PICKSEL_LIST(shgroup, start, count)
- {
+ GPU_SELECT_LOAD_IF_PICKSEL_LIST (shgroup, start, count) {
draw_geometry_execute_ex(shgroup, shgroup->batch_geom, start, count, false);
}
- GPU_SELECT_LOAD_IF_PICKSEL_LIST_END(start, count)
+ GPU_SELECT_LOAD_IF_PICKSEL_LIST_END(start, count);
}
}
}
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 9cb3c1bf226..b60a41ab0c9 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -161,8 +161,10 @@ static void drw_deferred_shader_compilation_free(void *custom_data)
static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred)
{
- /* Do not deferre the compilation if we are rendering for image. */
- if (DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION || !deferred) {
+ /* Do not deferre the compilation if we are rendering for image.
+ * deferred rendering is only possible when `evil_C` is available */
+ if (DST.draw_ctx.evil_C == NULL || DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION ||
+ !deferred) {
/* Double checking that this GPUMaterial is not going to be
* compiled by another thread. */
DRW_deferred_shader_remove(mat);
@@ -181,7 +183,8 @@ static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred)
/* Use original scene ID since this is what the jobs template tests for. */
Scene *scene = (Scene *)DEG_get_original_id(&DST.draw_ctx.scene->id);
- /* Get the running job or a new one if none is running. Can only have one job per type & owner. */
+ /* Get the running job or a new one if none is running. Can only have one job per type & owner.
+ */
wmJob *wm_job = WM_jobs_get(wm,
win,
scene,
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 1543e381d8c..7aa2e007f79 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -61,19 +61,35 @@ void DRW_draw_region_info(void)
/* ************************* Background ************************** */
-void DRW_draw_background(void)
+void DRW_draw_background(bool do_alpha_checker)
{
/* Just to make sure */
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilMask(0xFF);
- if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
+ if (do_alpha_checker) {
+ /* Transparent render, do alpha checker. */
+ GPU_depth_test(false);
+
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
+ GPU_matrix_identity_projection_set();
+
+ imm_draw_box_checker_2d(-1.0f, -1.0f, 1.0f, 1.0f);
+
+ GPU_matrix_pop();
+
+ GPU_clear(GPU_DEPTH_BIT | GPU_STENCIL_BIT);
+
+ GPU_depth_test(true);
+ }
+ else if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
float m[4][4];
unit_m4(m);
/* Gradient background Color */
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -104,14 +120,15 @@ void DRW_draw_background(void)
GPU_matrix_pop();
- glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ GPU_clear(GPU_DEPTH_BIT | GPU_STENCIL_BIT);
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
else {
/* Solid background Color */
UI_ThemeClearColorAlpha(TH_BACK, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT | GPU_STENCIL_BIT);
}
}
diff --git a/source/blender/draw/intern/draw_view.h b/source/blender/draw/intern/draw_view.h
index 08a8e984c87..715c3c0d40c 100644
--- a/source/blender/draw/intern/draw_view.h
+++ b/source/blender/draw/intern/draw_view.h
@@ -24,7 +24,7 @@
#define __DRAW_VIEW_H__
void DRW_draw_region_info(void);
-void DRW_draw_background(void);
+void DRW_draw_background(bool do_alpha_checker);
void DRW_draw_cursor(void);
void DRW_draw_gizmo_3d(void);
void DRW_draw_gizmo_2d(void);
diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c
index 12bf4982ffb..d1ef0d0e104 100644
--- a/source/blender/draw/modes/edit_armature_mode.c
+++ b/source/blender/draw/modes/edit_armature_mode.c
@@ -126,6 +126,7 @@ static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
.bone_envelope = psl->bone_envelope[ghost],
.bone_axes = psl->bone_axes,
.relationship_lines = psl->relationship[ghost],
+ .custom_shapes = NULL, /* Not needed in edit mode. */
};
DRW_shgroup_armature_edit(ob, passes, transp);
}
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index b3b6acf9b7d..ffe7fe5845c 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -55,6 +55,8 @@ extern char datatoc_edit_mesh_overlay_geom_glsl[];
extern char datatoc_edit_mesh_overlay_mix_frag_glsl[];
extern char datatoc_edit_mesh_overlay_facefill_vert_glsl[];
extern char datatoc_edit_mesh_overlay_facefill_frag_glsl[];
+extern char datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl[];
+extern char datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl[];
extern char datatoc_edit_normals_vert_glsl[];
extern char datatoc_edit_normals_geom_glsl[];
extern char datatoc_common_globals_lib_glsl[];
@@ -75,6 +77,7 @@ typedef struct EDIT_MESH_PassList {
struct DRWPass *edit_face_occluded;
struct DRWPass *mix_occlude;
struct DRWPass *facefill_occlude;
+ struct DRWPass *mesh_analysis_pass;
struct DRWPass *normals;
} EDIT_MESH_PassList;
@@ -115,6 +118,10 @@ typedef struct EDIT_MESH_Shaders {
GPUShader *normals_loop;
GPUShader *normals;
GPUShader *depth;
+
+ /* Mesh analysis shader */
+ GPUShader *mesh_analysis_face;
+ GPUShader *mesh_analysis_vertex;
} EDIT_MESH_Shaders;
/* *********** STATIC *********** */
@@ -149,6 +156,7 @@ typedef struct EDIT_MESH_PrivateData {
DRWShadingGroup *facedot_shgrp_in_front;
DRWShadingGroup *facefill_occluded_shgrp;
+ DRWShadingGroup *mesh_analysis_shgrp;
int data_mask[4];
int ghost_ob;
@@ -278,6 +286,22 @@ static void EDIT_MESH_engine_init(void *vedata)
.defs = (const char *[]){sh_cfg_data->def, NULL},
});
+ /* Mesh Analysis */
+ sh_data->mesh_analysis_face = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib,
+ datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl,
+ NULL},
+ .frag = (const char *[]){datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, "#define FACE_COLOR\n", NULL},
+ });
+ sh_data->mesh_analysis_vertex = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib,
+ datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl,
+ NULL},
+ .frag = (const char *[]){datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, "#define VERTEX_COLOR\n", NULL},
+ });
+
sh_data->depth = DRW_shader_create_3d_depth_only(draw_ctx->sh_cfg);
}
}
@@ -300,8 +324,6 @@ static DRWPass *edit_mesh_create_overlay_pass(float *face_alpha,
const bool select_vert = (tsettings->selectmode & SCE_SELECT_VERTEX) != 0;
const bool select_face = (tsettings->selectmode & SCE_SELECT_FACE) != 0;
const bool select_edge = (tsettings->selectmode & SCE_SELECT_EDGE) != 0;
- const bool show_wide_edge = select_edge &&
- !(draw_ctx->v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_DOT);
float winmat[4][4];
float viewdist = rv3d->dist;
@@ -336,8 +358,8 @@ static DRWPass *edit_mesh_create_overlay_pass(float *face_alpha,
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_float(grp, "faceAlphaMod", face_alpha, 1);
DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1);
- DRW_shgroup_uniform_bool_copy(grp, "doEdges", do_edges);
DRW_shgroup_uniform_float_copy(grp, "ofs", 0.0f);
+ DRW_shgroup_uniform_bool_copy(grp, "selectFaces", select_face);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
}
@@ -354,7 +376,8 @@ static DRWPass *edit_mesh_create_overlay_pass(float *face_alpha,
DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1);
DRW_shgroup_uniform_bool_copy(grp, "doEdges", do_edges);
DRW_shgroup_uniform_float_copy(grp, "ofs", depth_ofs);
- DRW_shgroup_uniform_float_copy(grp, "edgeScale", show_wide_edge ? 1.75f : 1.0f);
+ DRW_shgroup_uniform_bool_copy(grp, "selectEdges", select_edge);
+
DRW_shgroup_state_enable(grp, DRW_STATE_OFFSET_NEGATIVE);
/* To match blender loop structure. */
DRW_shgroup_state_enable(grp, DRW_STATE_FIRST_VERTEX_CONVENTION);
@@ -422,9 +445,6 @@ static void EDIT_MESH_cache_init(void *vedata)
stl->g_data->do_faces = false;
stl->g_data->do_zbufclip = false;
}
- if ((tsettings->selectmode & SCE_SELECT_FACE) == 0) {
- stl->g_data->data_mask[0] &= ~VFLAG_FACE_ACTIVE;
- }
if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_SEAMS) == 0) {
stl->g_data->data_mask[1] &= ~VFLAG_EDGE_SEAM;
}
@@ -513,6 +533,18 @@ static void EDIT_MESH_cache_init(void *vedata)
}
}
+ {
+ /* Mesh Analysis Pass */
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND;
+ psl->mesh_analysis_pass = DRW_pass_create("Mesh Analysis", state);
+ const bool is_vertex_color = scene->toolsettings->statvis.type == SCE_STATVIS_SHARP;
+ stl->g_data->mesh_analysis_shgrp = DRW_shgroup_create(
+ is_vertex_color ? sh_data->mesh_analysis_vertex : sh_data->mesh_analysis_face,
+ psl->mesh_analysis_pass);
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->mesh_analysis_shgrp, rv3d);
+ }
+ }
/* For in front option */
psl->edit_face_overlay_in_front = edit_mesh_create_overlay_pass(
&face_mod,
@@ -538,7 +570,8 @@ static void EDIT_MESH_cache_init(void *vedata)
&stl->g_data->vert_shgrp);
}
else {
- /* We render all wires with depth and opaque to a new fbo and blend the result based on depth values */
+ /* We render all wires with depth and opaque to a new fbo and blend the result based on depth
+ * values */
psl->edit_face_occluded = edit_mesh_create_overlay_pass(&zero,
stl->g_data->data_mask,
stl->g_data->do_edges,
@@ -632,6 +665,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
bool do_in_front = (ob->dtx & OB_DRAWXRAY) != 0;
bool do_occlude_wire = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) != 0;
bool do_show_weight = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_WEIGHT) != 0;
+ bool do_show_mesh_analysis = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_STATVIS) != 0;
bool fnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_NORMALS) != 0;
bool vnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_VERT_NORMALS) != 0;
bool lnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_LOOP_NORMALS) != 0;
@@ -660,6 +694,19 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
DRW_shgroup_call_add(g_data->fweights_shgrp, geom, ob->obmat);
}
+ if (do_show_mesh_analysis) {
+ Mesh *me = (Mesh *)ob->data;
+ BMEditMesh *embm = me->edit_mesh;
+ const bool is_original = embm->mesh_eval_final &&
+ (embm->mesh_eval_final->runtime.is_original == true);
+ if (is_original) {
+ geom = DRW_cache_mesh_surface_mesh_analysis_get(ob);
+ if (geom) {
+ DRW_shgroup_call_add(g_data->mesh_analysis_shgrp, geom, ob->obmat);
+ }
+ }
+ }
+
if (do_occlude_wire || do_in_front) {
geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(do_in_front ? g_data->depth_shgrp_hidden_wire_in_front :
@@ -735,6 +782,7 @@ static void EDIT_MESH_draw_scene(void *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DRW_draw_pass(psl->weight_faces);
+ DRW_draw_pass(psl->mesh_analysis_pass);
DRW_draw_pass(psl->depth_hidden_wire);
diff --git a/source/blender/draw/modes/edit_mesh_mode_text.c b/source/blender/draw/modes/edit_mesh_mode_text.c
index 90396785eb3..f3630a77e9a 100644
--- a/source/blender/draw/modes/edit_mesh_mode_text.c
+++ b/source/blender/draw/modes/edit_mesh_mode_text.c
@@ -47,8 +47,8 @@ void DRW_edit_mesh_mode_text_measure_stats(ARegion *ar,
Object *ob,
const UnitSettings *unit)
{
- /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square, etc.).
- * See bug #36090.
+ /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square,
+ * etc.). See bug #36090.
*/
struct DRWTextStore *dt = DRW_text_cache_ensure();
const short txt_flag = DRW_TEXT_CACHE_GLOBALSPACE | (unit->system ? 0 : DRW_TEXT_CACHE_ASCII);
@@ -157,12 +157,12 @@ void DRW_edit_mesh_mode_text_measure_stats(ARegion *ar,
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
BMLoop *l_a, *l_b;
if (BM_edge_loop_pair(eed, &l_a, &l_b)) {
- /* draw selected edges, or edges next to selected verts while dragging */
+ /* Draw selected edges, or edges next to selected verts while dragging. */
if (BM_elem_flag_test(eed, BM_ELEM_SELECT) ||
(do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
BM_elem_flag_test(eed->v2, BM_ELEM_SELECT) ||
- /* special case, this is useful to show when verts connected to
- * this edge via a face are being transformed */
+ /* Special case, this is useful to show when verts connected
+ * to this edge via a face are being transformed. */
BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) ||
BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) ||
BM_elem_flag_test(l_b->next->next->v, BM_ELEM_SELECT) ||
@@ -319,7 +319,8 @@ void DRW_edit_mesh_mode_text_measure_stats(ARegion *ar,
}
}
- /* This option is for mesh ops and addons debugging; only available in UI if Blender starts with --debug */
+ /* This option is for mesh ops and addons debugging; only available in UI if Blender starts with
+ * --debug */
if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_INDICES) {
int i;
diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c
index 90c5676727f..aa7c6863423 100644
--- a/source/blender/draw/modes/edit_metaball_mode.c
+++ b/source/blender/draw/modes/edit_metaball_mode.c
@@ -126,7 +126,7 @@ static void EDIT_METABALL_cache_init(void *vedata)
/* Add geometry to shadingGroups. Execute for each objects */
static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
{
- //EDIT_METABALL_PassList *psl = ((EDIT_METABALL_Data *)vedata)->psl;
+ // EDIT_METABALL_PassList *psl = ((EDIT_METABALL_Data *)vedata)->psl;
EDIT_METABALL_StorageList *stl = ((EDIT_METABALL_Data *)vedata)->stl;
if (ob->type == OB_MBALL) {
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index ec49b4dbe51..ee2c660ca06 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -53,6 +53,8 @@
#include "BKE_particle.h"
#include "BKE_tracking.h"
+#include "BLI_ghash.h"
+
#include "ED_view3d.h"
#include "GPU_batch.h"
@@ -273,6 +275,8 @@ typedef struct OBJECT_PrivateData {
OBJECT_ShadingGroupList sgl;
OBJECT_ShadingGroupList sgl_ghost;
+ GHash *custom_shapes;
+
/* Outlines */
DRWShadingGroup *outlines_active;
DRWShadingGroup *outlines_select;
@@ -511,6 +515,7 @@ static void OBJECT_engine_init(void *vedata)
const bool show_axis_y = (v3d->gridflag & V3D_SHOW_Y) != 0;
const bool show_axis_z = (v3d->gridflag & V3D_SHOW_Z) != 0;
const bool show_floor = (v3d->gridflag & V3D_SHOW_FLOOR) != 0;
+ const bool show_ortho_grid = (v3d->gridflag & V3D_SHOW_ORTHO_GRID) != 0;
e_data.draw_grid = show_axis_x || show_axis_y || show_axis_z || show_floor;
DRW_viewport_matrix_get(winmat, DRW_MAT_WIN);
@@ -559,15 +564,15 @@ static void OBJECT_engine_init(void *vedata)
grid_res = viewdist / grid_scale;
if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) {
- e_data.draw_grid = true;
+ e_data.draw_grid = show_ortho_grid;
e_data.grid_flag = PLANE_YZ | SHOW_AXIS_Y | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK;
}
else if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) {
- e_data.draw_grid = true;
+ e_data.draw_grid = show_ortho_grid;
e_data.grid_flag = PLANE_XY | SHOW_AXIS_X | SHOW_AXIS_Y | SHOW_GRID | GRID_BACK;
}
else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) {
- e_data.draw_grid = true;
+ e_data.draw_grid = show_ortho_grid;
e_data.grid_flag = PLANE_XZ | SHOW_AXIS_X | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK;
}
else { /* RV3D_VIEW_USER */
@@ -948,7 +953,8 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
return;
}
- /* Calling 'BKE_image_get_size' may free the texture. Get the size from 'tex' instead, see: T59347 */
+ /* Calling 'BKE_image_get_size' may free the texture. Get the size from 'tex' instead,
+ * see: T59347 */
int size[2] = {0};
const bool use_alpha_blend = (ob->empty_image_flag & OB_EMPTY_IMAGE_USE_ALPHA_BLEND) != 0;
@@ -1039,6 +1045,8 @@ static void OBJECT_cache_init(void *vedata)
g_data->xray_enabled_and_not_wire = g_data->xray_enabled &&
draw_ctx->v3d->shading.type > OB_WIRE;
+ g_data->custom_shapes = BLI_ghash_ptr_new(__func__);
+
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_WIRE;
@@ -1494,7 +1502,7 @@ static void OBJECT_cache_init(void *vedata)
psl->ob_center = DRW_pass_create("Obj Center Pass", state);
outlineWidth = 1.0f * U.pixelsize;
- size = U.obcenter_dia * U.pixelsize + outlineWidth;
+ size = UI_GetThemeValuef(TH_OBCENTER_DIA) * U.pixelsize + outlineWidth;
GPUShader *sh = GPU_shader_get_builtin_shader_with_config(
GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA, draw_ctx->sh_cfg);
@@ -1853,8 +1861,10 @@ static void camera_view3d_stereoscopy_display_extra(OBJECT_ShadingGroupList *sgl
static float one = 1.0f;
float plane_mat[4][4], scale_mat[4][4];
float scale_factor[3] = {1.0f, 1.0f, 1.0f};
- float color_plane[2][4] = {{0.0f, 0.0f, 0.0f, v3d->stereo3d_convergence_alpha},
- {0.0f, 0.0f, 0.0f, 1.0f}};
+ float color_plane[2][4] = {
+ {0.0f, 0.0f, 0.0f, v3d->stereo3d_convergence_alpha},
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ };
const float height = convergence_plane[1][1] - convergence_plane[0][1];
const float width = convergence_plane[2][0] - convergence_plane[0][0];
@@ -1877,9 +1887,11 @@ static void camera_view3d_stereoscopy_display_extra(OBJECT_ShadingGroupList *sgl
/* Draw convergence volume. */
if (is_stereo3d_volume && !is_select) {
static float one = 1.0f;
- float color_volume[3][4] = {{0.0f, 1.0f, 1.0f, v3d->stereo3d_volume_alpha},
- {1.0f, 0.0f, 0.0f, v3d->stereo3d_volume_alpha},
- {0.0f, 0.0f, 0.0f, 1.0f}};
+ float color_volume[3][4] = {
+ {0.0f, 1.0f, 1.0f, v3d->stereo3d_volume_alpha},
+ {1.0f, 0.0f, 0.0f, v3d->stereo3d_volume_alpha},
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ };
for (int eye = 0; eye < 2; eye++) {
float winmat[4][4], viewinv[4][4], viewmat[4][4], persmat[4][4], persinv[4][4];
@@ -3115,11 +3127,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
((DRW_object_is_renderable(ob) && (ob->dt > OB_WIRE)) ||
(ob->dt == OB_WIRE)));
const bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0);
- const bool hide_object_extra = ((v3d->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) != 0 &&
- /* Show if this is the camera we're looking through
- * since it's useful for moving the camera. */
- (((rv3d->persp == RV3D_CAMOB) &&
- ((ID *)v3d->camera == ob->id.orig_id)) == 0));
+ const bool hide_object_extra =
+ ((v3d->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) != 0 &&
+ /* Show if this is the camera we're looking through since it's useful for selecting. */
+ (((rv3d->persp == RV3D_CAMOB) && ((ID *)v3d->camera == ob->id.orig_id)) == 0));
if (do_outlines) {
if (!BKE_object_is_in_editmode(ob) &&
@@ -3284,6 +3295,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
.bone_envelope = sgl->bone_envelope,
.bone_axes = sgl->bone_axes,
.relationship_lines = NULL, /* Don't draw relationship lines */
+ .custom_shapes = stl->g_data->custom_shapes,
};
DRW_shgroup_armature_object(ob, view_layer, passes, is_wire);
}
@@ -3391,6 +3403,11 @@ static void OBJECT_cache_finish(void *vedata)
DRW_pass_sort_shgroup_z(stl->g_data->sgl.image_empties);
DRW_pass_sort_shgroup_z(stl->g_data->sgl_ghost.image_empties);
+
+ if (stl->g_data->custom_shapes) {
+ /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */
+ BLI_ghash_free(stl->g_data->custom_shapes, NULL, NULL);
+ }
}
static void OBJECT_draw_scene(void *vedata)
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
index 4d583066f44..ed96b2a05bc 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -359,8 +359,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
if ((!pd->show_overlays) ||
(((ob != draw_ctx->object_edit) && !is_edit_mode) || has_edit_mesh_cage) ||
ob->type != OB_MESH) {
- const bool is_active = (ob == draw_ctx->obact);
- const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
+ const bool is_sculpt_mode = (ob->sculpt != NULL);
const bool all_wires = (ob->dtx & OB_DRAW_ALL_EDGES);
const bool is_wire = (ob->dt < OB_SOLID);
const bool use_coloring = (pd->show_overlays && !is_edit_mode && !is_sculpt_mode &&
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index 84852ff7ab3..3e292f4e4bc 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -294,7 +294,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
const Mesh *me_orig = DEG_get_original_object(ob)->data;
Scene *scene = draw_ctx->scene;
const bool use_surface = draw_ctx->v3d->overlay.texture_paint_mode_opacity !=
- 0.0; //DRW_object_is_mode_shade(ob) == true;
+ 0.0; // DRW_object_is_mode_shade(ob) == true;
const bool use_material_slots = (scene->toolsettings->imapaint.mode ==
IMAGEPAINT_MODE_MATERIAL);
const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 5e3353414f5..a37901a1fa9 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -72,6 +72,7 @@ typedef struct POSE_Data {
typedef struct POSE_PrivateData {
DRWShadingGroup *bone_selection_shgrp;
DRWShadingGroup *bone_selection_invert_shgrp;
+ GHash *custom_shapes[2];
float blend_color[4];
float blend_color_invert[4];
bool transparent_bones;
@@ -139,6 +140,8 @@ static void POSE_cache_init(void *vedata)
state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_BLEND | DRW_STATE_WIRE;
psl->relationship[i] = DRW_pass_create("Bone Relationship Pass", state);
+
+ ppd->custom_shapes[i] = BLI_ghash_ptr_new(__func__);
}
{
@@ -213,6 +216,7 @@ static void POSE_cache_populate(void *vedata, Object *ob)
.bone_envelope = psl->bone_envelope[ghost],
.bone_axes = psl->bone_axes,
.relationship_lines = psl->relationship[ghost],
+ .custom_shapes = ppd->custom_shapes[transp],
};
DRW_shgroup_armature_pose(ob, passes, transp);
}
@@ -231,6 +235,16 @@ static void POSE_cache_populate(void *vedata, Object *ob)
}
}
+static void POSE_cache_finish(void *vedata)
+{
+ POSE_PrivateData *ppd = ((POSE_Data *)vedata)->stl->g_data;
+
+ /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */
+ for (int i = 0; i < 2; i++) {
+ BLI_ghash_free(ppd->custom_shapes[i], NULL, NULL);
+ }
+}
+
/**
* Return true if armature should be handled by the pose mode engine.
*/
@@ -323,7 +337,7 @@ DrawEngineType draw_engine_pose_type = {
&POSE_engine_free,
&POSE_cache_init,
&POSE_cache_populate,
- NULL,
+ &POSE_cache_finish,
NULL,
&POSE_draw_scene,
NULL,
diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c
index b25a8af795b..8adae0a4238 100644
--- a/source/blender/draw/modes/sculpt_mode.c
+++ b/source/blender/draw/modes/sculpt_mode.c
@@ -135,9 +135,15 @@ static void SCULPT_cache_init(void *vedata)
}
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ View3D *v3d = draw_ctx->v3d;
+
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY;
psl->pass = DRW_pass_create("Sculpt Pass", state);
- stl->g_data->group_smooth = DRW_shgroup_create(e_data.shader_smooth, psl->pass);
+
+ DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.shader_smooth, psl->pass);
+ DRW_shgroup_uniform_float(shgrp, "maskOpacity", &v3d->overlay.sculpt_mode_mask_opacity, 1);
+ stl->g_data->group_smooth = shgrp;
}
}
@@ -155,6 +161,7 @@ static void sculpt_draw_mask_cb(DRWShadingGroup *shgroup,
false,
false,
true,
+ false,
(void (*)(void *, struct GPUBatch *))draw_fn,
shgroup);
}
@@ -193,7 +200,8 @@ static void SCULPT_cache_populate(void *vedata, Object *ob)
sculpt_update_pbvh_normals(ob);
/* XXX, needed for dyntopo-undo (which clears).
- * probably depsgraph should handlle? in 2.7x getting derived-mesh does this (mesh_build_data) */
+ * probably depsgraph should handlle? in 2.7x
+ * getting derived-mesh does this (mesh_build_data). */
if (ob->sculpt->pbvh == NULL) {
/* create PBVH immediately (would be created on the fly too,
* but this avoids waiting on first stroke) */
diff --git a/source/blender/draw/modes/shaders/common_fxaa_lib.glsl b/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
index dcb7c0ba7f2..d9e78855dc9 100644
--- a/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
@@ -674,7 +674,7 @@ vec4 FxaaPixelShader(
posP.x += offNP.x * FXAA_QUALITY__P10;
if (!doneP)
posP.y += offNP.y * FXAA_QUALITY__P10;
- /*--------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------*/
# if (FXAA_QUALITY__PS > 11)
if (doneNP) {
if (!doneN)
@@ -696,7 +696,7 @@ vec4 FxaaPixelShader(
posP.x += offNP.x * FXAA_QUALITY__P11;
if (!doneP)
posP.y += offNP.y * FXAA_QUALITY__P11;
- /*--------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------*/
# if (FXAA_QUALITY__PS > 12)
if (doneNP) {
if (!doneN)
@@ -718,10 +718,10 @@ vec4 FxaaPixelShader(
posP.x += offNP.x * FXAA_QUALITY__P12;
if (!doneP)
posP.y += offNP.y * FXAA_QUALITY__P12;
- /*--------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------*/
}
# endif
- /*--------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
diff --git a/source/blender/draw/modes/shaders/common_hair_lib.glsl b/source/blender/draw/modes/shaders/common_hair_lib.glsl
index 02254908232..1c0a31c59fd 100644
--- a/source/blender/draw/modes/shaders/common_hair_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_hair_lib.glsl
@@ -38,8 +38,8 @@ uniform usamplerBuffer hairStrandBuffer; /* R32UI */
uniform usamplerBuffer hairStrandSegBuffer; /* R16UI */
/* Not used, use one buffer per uv layer */
-//uniform samplerBuffer hairUVBuffer; /* RG32F */
-//uniform samplerBuffer hairColBuffer; /* RGBA16 linear color */
+// uniform samplerBuffer hairUVBuffer; /* RG32F */
+// uniform samplerBuffer hairColBuffer; /* RGBA16 linear color */
/* -- Subdivision stage -- */
/**
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl
index ffabfd3fcee..7d4cba66933 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl
@@ -1,5 +1,7 @@
uniform bool doEdges = true;
+uniform bool selectFaces = true;
+uniform bool selectEdges = true;
vec4 EDIT_MESH_edge_color_outer(int edge_flag, int face_flag, float crease, float bweight)
{
@@ -15,16 +17,21 @@ vec4 EDIT_MESH_edge_color_outer(int edge_flag, int face_flag, float crease, floa
vec4 EDIT_MESH_edge_color_inner(int edge_flag)
{
vec4 color = colorWireEdit;
- color = ((edge_flag & EDGE_SELECTED) != 0) ? colorEdgeSelect : color;
- color = ((edge_flag & EDGE_ACTIVE) != 0) ? colorEditMeshActive : color;
+ vec4 color_select = (selectEdges) ? colorEdgeSelect : colorFaceSelect;
+ color = (doEdges && ((edge_flag & EDGE_SELECTED) != 0)) ? color_select : color;
+ color = (doEdges && ((edge_flag & EDGE_ACTIVE) != 0)) ? colorEditMeshActive : color;
+
+ float non_edge_select_alpha = (selectFaces && (edge_flag & EDGE_SELECTED) != 0) ? 0.75 : 0.4;
+ color.a = (selectEdges) ? 1.0 : non_edge_select_alpha;
return color;
}
vec4 EDIT_MESH_edge_vertex_color(int vertex_flag)
{
vec4 color = colorWireEdit;
- color = (doEdges && (vertex_flag & (VERT_ACTIVE | VERT_SELECTED)) != 0) ? colorEdgeSelect :
- color;
+ vec4 color_select = (selectEdges) ? colorEdgeSelect : colorFaceSelect;
+ color = (doEdges && (vertex_flag & (VERT_ACTIVE | VERT_SELECTED)) != 0) ? color_select : color;
+ color.a = (selectEdges) ? 1.0 : 0.4;
return color;
}
@@ -43,18 +50,15 @@ vec4 EDIT_MESH_vertex_color(int vertex_flag)
vec4 EDIT_MESH_face_color(int face_flag)
{
- if ((face_flag & FACE_ACTIVE) != 0) {
- return mix(colorFaceSelect, colorEditMeshActive, 0.5);
- }
- else if ((face_flag & FACE_SELECTED) != 0) {
- return colorFaceSelect;
- }
- else if ((face_flag & FACE_FREESTYLE) != 0) {
- return colorFaceFreestyle;
- }
- else {
- return colorFace;
- }
+ vec4 color = colorFace;
+ vec4 color_active = mix(colorFaceSelect, colorEditMeshActive, 0.5);
+ color = ((face_flag & FACE_FREESTYLE) != 0) ? colorFaceFreestyle : color;
+ color = ((face_flag & FACE_SELECTED) != 0) ? colorFaceSelect : color;
+ color = ((face_flag & FACE_ACTIVE) != 0) ? color_active : color;
+ color.a *= ((face_flag & (FACE_FREESTYLE | FACE_SELECTED | FACE_ACTIVE)) == 0 || selectFaces) ?
+ 1.0 :
+ 0.5;
+ return color;
}
vec4 EDIT_MESH_facedot_color(float facedot_flag)
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
index 3418732afc2..7fe3cea8a42 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
@@ -5,15 +5,13 @@
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with acircle of the same area and try to find the intersection area.
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
- * The formula for the area uses inverse trig function and is quite complexe.
- * Instead, we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
+ * The formula for the area uses inverse trig function and is quite complexe. Instead,
+ * we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
*/
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
#define GRID_LINE_SMOOTH_END (0.5 + DISC_RADIUS)
-uniform float edgeScale;
-
flat in vec4 finalColorOuter_f;
in vec4 finalColor_f;
noperspective in float edgeCoord_f;
@@ -22,8 +20,8 @@ out vec4 FragColor;
void main()
{
- float dist = abs(edgeCoord_f) - max(sizeEdge * edgeScale - 0.5, 0.0);
- float dist_outer = dist - max(sizeEdge * edgeScale, 1.0);
+ float dist = abs(edgeCoord_f) - max(sizeEdge - 0.5, 0.0);
+ float dist_outer = dist - max(sizeEdge, 1.0);
#ifdef USE_SMOOTH_WIRE
float mix_w = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist);
float mix_w_outer = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist_outer);
@@ -31,6 +29,8 @@ void main()
float mix_w = step(0.5, dist);
float mix_w_outer = step(0.5, dist_outer);
#endif
+ /* Line color & alpha. */
FragColor = mix(finalColorOuter_f, finalColor_f, 1.0 - mix_w * finalColorOuter_f.a);
+ /* Line edges shape. */
FragColor.a *= 1.0 - (finalColorOuter_f.a > 0.0 ? mix_w_outer : mix_w);
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
index 6e59de12260..047bd1dccc6 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
@@ -4,7 +4,6 @@ layout(triangle_strip, max_vertices = 4) out;
uniform vec2 viewportSize;
uniform vec2 viewportSizeInv;
-uniform float edgeScale;
in vec4 finalColor[2];
in vec4 finalColorOuter[2];
@@ -14,14 +13,16 @@ flat out vec4 finalColorOuter_f;
out vec4 finalColor_f;
noperspective out float edgeCoord_f;
-void do_vertex(const int i, vec4 pos, float coord, vec2 offset)
+void do_vertex(vec4 color, vec4 pos, float coord, vec2 offset)
{
- finalColor_f = (selectOveride[0] == 0) ? finalColor[i] : finalColor[0];
+ finalColor_f = color;
edgeCoord_f = coord;
gl_Position = pos;
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
gl_Position.xy += offset * 2.0 * pos.w;
-#ifdef USE_WORLD_CLIP_PLANES
+ /* Correct but fails due to an AMD compiler bug, see: T62792.
+ * Do inline instead. */
+#if 0
world_clip_planes_set_clip_distance(gl_in[i].gl_ClipDistance);
#endif
EmitVertex();
@@ -57,9 +58,9 @@ void main()
line = abs(line) * viewportSize;
finalColorOuter_f = finalColorOuter[0];
- float half_size = sizeEdge * edgeScale;
+ float half_size = sizeEdge;
/* Enlarge edge for flag display. */
- half_size += (finalColorOuter_f.a > 0.0) ? max(sizeEdge * edgeScale, 1.0) : 0.0;
+ half_size += (finalColorOuter_f.a > 0.0) ? max(sizeEdge, 1.0) : 0.0;
#ifdef USE_SMOOTH_WIRE
/* Add 1 px for AA */
@@ -71,10 +72,20 @@ void main()
bool horizontal = line.x > line.y;
edge_ofs = (horizontal) ? edge_ofs.zyz : edge_ofs.xzz;
- do_vertex(0, pos0, half_size, edge_ofs.xy);
- do_vertex(0, pos0, -half_size, -edge_ofs.xy);
- do_vertex(1, pos1, half_size, edge_ofs.xy);
- do_vertex(1, pos1, -half_size, -edge_ofs.xy);
+#ifdef USE_WORLD_CLIP_PLANES
+ /* Due to an AMD glitch, this line was moved out of the `do_vertex`
+ * function (see T62792). */
+ world_clip_planes_set_clip_distance(gl_in[0].gl_ClipDistance);
+#endif
+ do_vertex(finalColor[0], pos0, half_size, edge_ofs.xy);
+ do_vertex(finalColor[0], pos0, -half_size, -edge_ofs.xy);
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_set_clip_distance(gl_in[1].gl_ClipDistance);
+#endif
+ vec4 final_color = (selectOveride[0] == 0) ? finalColor[1] : finalColor[0];
+ do_vertex(final_color, pos1, half_size, edge_ofs.xy);
+ do_vertex(final_color, pos1, -half_size, -edge_ofs.xy);
EndPrimitive();
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl
new file mode 100644
index 00000000000..8581453e810
--- /dev/null
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl
@@ -0,0 +1,14 @@
+out vec4 fragColor;
+
+#ifdef FACE_COLOR
+flat in vec4 weightColor;
+#endif
+
+#ifdef VERTEX_COLOR
+in vec4 weightColor;
+#endif
+
+void main()
+{
+ fragColor = weightColor;
+}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl
new file mode 100644
index 00000000000..94d8d2e701c
--- /dev/null
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl
@@ -0,0 +1,23 @@
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat4 ModelMatrix;
+
+in vec3 pos;
+in vec4 weight_color;
+
+#ifdef FACE_COLOR
+flat out vec4 weightColor;
+#endif
+
+#ifdef VERTEX_COLOR
+out vec4 weightColor;
+#endif
+
+void main()
+{
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ weightColor = vec4(weight_color.rgb, 1.0);
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
+#endif
+}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
index 8c54470cd5a..d700e69fb57 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
@@ -74,21 +74,15 @@ void main()
#endif
-#if !defined(FACE) && !defined(EDGE_DECORATION)
+#if !defined(FACE)
/* Facing based color blend */
vec4 vpos = ModelViewMatrix * vec4(pos, 1.0);
vec3 view_normal = normalize(NormalMatrix * vnor + 1e-4);
vec3 view_vec = (ProjectionMatrix[3][3] == 0.0) ? normalize(vpos.xyz) : vec3(0.0, 0.0, 1.0);
float facing = dot(view_vec, view_normal);
- facing = 1.0 - abs(facing) * 0.3;
-
- finalColor = mix(colorEditMeshMiddle, finalColor, facing);
- finalColor.a = 1.0;
+ facing = 1.0 - abs(facing) * 0.2;
-# if defined(EDGE) && !defined(FLAT)
- /* Hack to blend color in pixel shader in case of overide. */
- finalColor.a = facing;
-# endif
+ finalColor.rgb = mix(colorEditMeshMiddle.rgb, finalColor.rgb, facing);
#endif
diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl
index 841b4a95b21..df2cfe7be82 100644
--- a/source/blender/draw/modes/shaders/object_grid_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl
@@ -40,8 +40,8 @@ uniform int gridFlag;
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with acircle of the same area and try to find the intersection area.
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
- * The formula for the area uses inverse trig function and is quite complexe.
- * Instead, we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
+ * The formula for the area uses inverse trig function and is quite complexe. Instead,
+ * we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
*/
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
diff --git a/source/blender/draw/modes/shaders/particle_strand_vert.glsl b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
index 745499800e5..6dac6d6b980 100644
--- a/source/blender/draw/modes/shaders/particle_strand_vert.glsl
+++ b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
@@ -45,14 +45,12 @@ vec3 weight_to_rgb(float weight)
return r_rgb;
}
-#define DECOMPRESS_RANGE 1.0039
-
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
#ifdef USE_WEIGHT
- finalColor = vec4(weight_to_rgb(color * DECOMPRESS_RANGE), 1.0);
+ finalColor = vec4(weight_to_rgb(color), 1.0);
#else
finalColor = mix(colorWire, colorEdgeSelect, color);
#endif
diff --git a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
index 5ae97ec5cb9..e5e34fee57e 100644
--- a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
+++ b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
@@ -1,5 +1,6 @@
uniform mat4 ModelViewProjectionMatrix;
+uniform float maskOpacity;
in vec3 pos;
in float msk;
@@ -10,6 +11,6 @@ void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
- float mask = 1.0 - msk * 0.75;
+ float mask = 1.0 - (msk * maskOpacity);
finalColor = vec4(mask, mask, mask, 1.0);
}
diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt
index b67298a6df6..978bd772b6f 100644
--- a/source/blender/editors/animation/CMakeLists.txt
+++ b/source/blender/editors/animation/CMakeLists.txt
@@ -26,8 +26,8 @@ set(INC
../../makesrna
../../windowmanager
../../../../intern/clog
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 78c17ac7015..6d1ee08d5e9 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -222,7 +222,8 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
rgb_uchar_to_float(r_color, cp);
}
else {
- // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
+ /* FIXME: what happens when the indention is 1 greater than what it should be
+ * (due to grouping)? */
int colOfs = 10 - 10 * indent;
UI_GetThemeColorShade3fv(TH_SHADE2, colOfs, r_color);
}
@@ -298,8 +299,9 @@ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListE
FCurve *fcu = (FCurve *)ale->data;
// TODO: we need some way of specifying that the indention color should be one less...
- if (fcu->grp)
+ if (fcu->grp) {
indent++;
+ }
}
/* no indention */
@@ -311,10 +313,12 @@ static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
- if (acf && acf->get_indent_level)
+ if (acf && acf->get_indent_level) {
return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE;
- else
+ }
+ else {
return 0;
+ }
}
/* offset based on nodetree type */
@@ -353,12 +357,15 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
offset += U.widget_unit;
}
/* materials and particles animdata */
- else if (ELEM(GS(ale->id->name), ID_MA, ID_PA))
+ else if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) {
offset += (short)(0.7f * U.widget_unit);
- /* if not in Action Editor mode, action-groups (and their children) must carry some offset too... */
- else if (ac->datatype != ANIMCONT_ACTION)
+ /* If not in Action Editor mode, action-groups (and their children)
+ * must carry some offset too. */
+ }
+ else if (ac->datatype != ANIMCONT_ACTION) {
offset += (short)(0.7f * U.widget_unit);
+ }
/* nodetree animdata */
if (GS(ale->id->name) == ID_NT) {
@@ -378,8 +385,9 @@ static void acf_generic_idblock_name(bAnimListElem *ale, char *name)
ID *id = (ID *)ale->data; /* data pointed to should be an ID block */
/* just copy the name... */
- if (id && name)
+ if (id && name) {
BLI_strncpy(name, id->name + 2, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for ID block entries */
@@ -405,7 +413,9 @@ static bool acf_generic_idfill_name_prop(bAnimListElem *ale, PointerRNA *ptr, Pr
#if 0
/* channel type has no settings */
-static bool acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
+static bool acf_generic_none_setting_valid(bAnimContext *ac,
+ bAnimListElem *ale,
+ eAnimChannel_Settings setting)
{
return false;
}
@@ -474,8 +484,9 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
/* name for summary entries */
static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name)
{
- if (name)
+ if (name) {
BLI_strncpy(name, IFACE_("Dope Sheet Summary"), ANIM_CHAN_NAME_SIZE);
+ }
}
// FIXME: this is really a temp icon I think
@@ -633,8 +644,9 @@ static void *acf_scene_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (scene->adt)
+ if (scene->adt) {
return GET_ACF_FLAG_PTR(scene->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -708,8 +720,9 @@ static void acf_object_name(bAnimListElem *ale, char *name)
Object *ob = base->object;
/* just copy the name... */
- if (ob && name)
+ if (ob && name) {
BLI_strncpy(name, ob->id.name + 2, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for object */
@@ -801,8 +814,9 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
- if (ob->adt)
+ if (ob->adt) {
return GET_ACF_FLAG_PTR(ob->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -841,20 +855,24 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[
unsigned char cp[3];
/* highlight only for active */
- if (ale->flag & AGRP_ACTIVE)
+ if (ale->flag & AGRP_ACTIVE) {
copy_v3_v3_char((char *)cp, agrp->cs.select);
- else
+ }
+ else {
copy_v3_v3_char((char *)cp, agrp->cs.solid);
+ }
/* copy the colors over, transforming from bytes to floats */
rgb_uchar_to_float(r_color, cp);
}
else {
/* highlight only for active */
- if (ale->flag & AGRP_ACTIVE)
+ if (ale->flag & AGRP_ACTIVE) {
UI_GetThemeColor3fv(TH_GROUP_ACTIVE, r_color);
- else
+ }
+ else {
UI_GetThemeColor3fv(TH_GROUP, r_color);
+ }
}
}
@@ -882,8 +900,9 @@ static void acf_group_name(bAnimListElem *ale, char *name)
bActionGroup *agrp = (bActionGroup *)ale->data;
/* just copy the name... */
- if (agrp && name)
+ if (agrp && name) {
BLI_strncpy(name, agrp->name, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for group entries */
@@ -1036,10 +1055,12 @@ static bool acf_fcurve_setting_valid(bAnimContext *ac,
/* conditionally available */
case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */
- if (fcu->bezt)
+ if (fcu->bezt) {
return true;
- else
+ }
+ else {
return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT
+ }
case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
return (ac->spacetype == SPACE_GRAPH);
@@ -1489,8 +1510,9 @@ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (ma->adt)
+ if (ma->adt) {
return GET_ACF_FLAG_PTR(ma->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1569,8 +1591,9 @@ static void *acf_dslight_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (la->adt)
+ if (la->adt) {
return GET_ACF_FLAG_PTR(la->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1654,8 +1677,9 @@ static void *acf_dstex_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (tex->adt)
+ if (tex->adt) {
return GET_ACF_FLAG_PTR(tex->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1819,8 +1843,9 @@ static void *acf_dscam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
- if (ca->adt)
+ if (ca->adt) {
return GET_ACF_FLAG_PTR(ca->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1907,8 +1932,9 @@ static void *acf_dscur_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (cu->adt)
+ if (cu->adt) {
return GET_ACF_FLAG_PTR(cu->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1985,8 +2011,9 @@ static void *acf_dsskey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (key->adt)
+ if (key->adt) {
return GET_ACF_FLAG_PTR(key->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2063,8 +2090,9 @@ static void *acf_dswor_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (wo->adt)
+ if (wo->adt) {
return GET_ACF_FLAG_PTR(wo->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2141,8 +2169,9 @@ static void *acf_dspart_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (part->adt)
+ if (part->adt) {
return GET_ACF_FLAG_PTR(part->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2221,8 +2250,9 @@ static void *acf_dsmball_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (mb->adt)
+ if (mb->adt) {
return GET_ACF_FLAG_PTR(mb->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2299,8 +2329,9 @@ static void *acf_dsarm_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (arm->adt)
+ if (arm->adt) {
return GET_ACF_FLAG_PTR(arm->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2390,8 +2421,9 @@ static void *acf_dsntree_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (ntree->adt)
+ if (ntree->adt) {
return GET_ACF_FLAG_PTR(ntree->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2470,8 +2502,9 @@ static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (linestyle->adt)
+ if (linestyle->adt) {
return GET_ACF_FLAG_PTR(linestyle->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2548,8 +2581,9 @@ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (me->adt)
+ if (me->adt) {
return GET_ACF_FLAG_PTR(me->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2627,8 +2661,9 @@ static void *acf_dslat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (lt->adt)
+ if (lt->adt) {
return GET_ACF_FLAG_PTR(lt->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2706,8 +2741,9 @@ static void *acf_dsspk_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (spk->adt)
+ if (spk->adt) {
return GET_ACF_FLAG_PTR(spk->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2786,8 +2822,9 @@ static void *acf_dsgpencil_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (gpd->adt)
+ if (gpd->adt) {
return GET_ACF_FLAG_PTR(gpd->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2905,10 +2942,12 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name)
/* just copy the name... */
if (kb && name) {
/* if the KeyBlock had a name, use it, otherwise use the index */
- if (kb->name[0])
+ if (kb->name[0]) {
BLI_strncpy(name, kb->name, ANIM_CHAN_NAME_SIZE);
- else
+ }
+ else {
BLI_snprintf(name, ANIM_CHAN_NAME_SIZE, IFACE_("Key %d"), ale->index);
+ }
}
}
@@ -3095,8 +3134,9 @@ static void acf_gpl_name(bAnimListElem *ale, char *name)
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
- if (gpl && name)
+ if (gpl && name) {
BLI_strncpy(name, gpl->info, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for grease pencil layer entries */
@@ -3273,8 +3313,9 @@ static void acf_masklay_name(bAnimListElem *ale, char *name)
{
MaskLayer *masklay = (MaskLayer *)ale->data;
- if (masklay && name)
+ if (masklay && name) {
BLI_strncpy(name, masklay->name, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for grease pencil layer entries */
@@ -3384,8 +3425,9 @@ static void acf_nlatrack_name(bAnimListElem *ale, char *name)
{
NlaTrack *nlt = (NlaTrack *)ale->data;
- if (nlt && name)
+ if (nlt && name) {
BLI_strncpy(name, nlt->name, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for nla track entries */
@@ -3556,10 +3598,12 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y
*/
nla_action_get_color(adt, (bAction *)ale->data, color);
- if (adt && (adt->flag & ADT_NLA_EDIT_ON))
+ if (adt && (adt->flag & ADT_NLA_EDIT_ON)) {
color[3] = 1.0f;
- else
+ }
+ else {
color[3] = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f;
+ }
/* only on top left corner, to show that this channel sits on top of the preceding ones
* while still linking into the action line strip to the right
@@ -3665,7 +3709,7 @@ static bAnimChannelType ACF_NLAACTION = {
ACHANNEL_ROLE_CHANNEL, /* role */
acf_nlaaction_color, /* backdrop color (NOTE: the backdrop handles this too,
- * since it needs special hacks) */
+ * since it needs special hacks). */
acf_nlaaction_backdrop, /* backdrop */
acf_generic_indention_flexible, /* indent level */
acf_generic_group_offset,
@@ -3752,17 +3796,20 @@ static void ANIM_init_channel_typeinfo_data(void)
const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale)
{
/* santiy checks */
- if (ale == NULL)
+ if (ale == NULL) {
return NULL;
+ }
/* init the typeinfo if not available yet... */
ANIM_init_channel_typeinfo_data();
/* check if type is in bounds... */
- if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES))
+ if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES)) {
return animchannelTypeInfo[ale->type];
- else
+ }
+ else {
return NULL;
+ }
}
/* --------------------------- */
@@ -3773,26 +3820,31 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level)
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
/* print indents */
- for (; indent_level > 0; indent_level--)
+ for (; indent_level > 0; indent_level--) {
printf(" ");
+ }
/* print info */
if (acf) {
char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
/* get UI name */
- if (acf->name)
+ if (acf->name) {
acf->name(ale, name);
- else
+ }
+ else {
BLI_strncpy(name, "<No name>", sizeof(name));
+ }
/* print type name + ui name */
printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name);
}
- else if (ale)
+ else if (ale) {
printf("ChanType: <Unknown - %d>\n", ale->type);
- else
+ }
+ else {
printf("<Invalid channel - NULL>\n");
+ }
}
/* --------------------------- */
@@ -3822,28 +3874,34 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne
{
const int *val = (int *)ptr;
- if (negflag)
+ if (negflag) {
return ((*val) & flag) == 0;
- else
+ }
+ else {
return ((*val) & flag) != 0;
+ }
}
case sizeof(short): /* short pointer for setting */
{
const short *val = (short *)ptr;
- if (negflag)
+ if (negflag) {
return ((*val) & flag) == 0;
- else
+ }
+ else {
return ((*val) & flag) != 0;
+ }
}
case sizeof(char): /* char pointer for setting */
{
const char *val = (char *)ptr;
- if (negflag)
+ if (negflag) {
return ((*val) & flag) == 0;
- else
+ }
+ else {
return ((*val) & flag) != 0;
+ }
}
}
}
@@ -3853,7 +3911,8 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne
return -1;
}
-/* quick macro for use in ANIM_channel_setting_set - set flag for setting according the mode given */
+/* Quick macro for use in ANIM_channel_setting_set -
+ * set flag for setting according the mode given. */
#define ACF_SETTING_SET(sval, sflag, smode) \
{ \
if (negflag) { \
@@ -3958,14 +4017,17 @@ void ANIM_channel_draw(
float y, ymid, ytext;
/* sanity checks - don't draw anything */
- if (ELEM(NULL, acf, ale))
+ if (ELEM(NULL, acf, ale)) {
return;
+ }
/* get initial offset */
- if (acf->get_offset)
+ if (acf->get_offset) {
offset = acf->get_offset(ac, ale);
- else
+ }
+ else {
offset = 0;
+ }
/* calculate appropriate y-coordinates for icon buttons */
y = (ymaxc - yminc) / 2 + yminc;
@@ -3974,10 +4036,12 @@ void ANIM_channel_draw(
ytext = y - 0.2f * U.widget_unit;
/* check if channel is selected */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) {
selected = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT);
- else
+ }
+ else {
selected = 0;
+ }
/* set blending again, as may not be set in previous step */
GPU_blend_set_func_separate(
@@ -3985,8 +4049,9 @@ void ANIM_channel_draw(
GPU_blend(true);
/* step 1) draw backdrop ........................................... */
- if (acf->draw_backdrop)
+ if (acf->draw_backdrop) {
acf->draw_backdrop(ac, ale, yminc, ymaxc);
+ }
/* step 2) draw expand widget ....................................... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) {
@@ -4020,8 +4085,8 @@ void ANIM_channel_draw(
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever
- * color the curve has stored
+ /* F-Curve channels need to have a special 'color code' box drawn,
+ * which is colored with whatever color the curve has stored.
*/
immUniformColor3fv(fcu->color);
@@ -4059,10 +4124,12 @@ void ANIM_channel_draw(
/* set text color */
/* XXX: if active, highlight differently? */
- if (selected)
+ if (selected) {
UI_GetThemeColor4ubv(TH_TEXT_HI, col);
- else
+ }
+ else {
UI_GetThemeColor4ubv(TH_TEXT, col);
+ }
/* get name */
acf->name(ale, name);
@@ -4128,39 +4195,47 @@ void ANIM_channel_draw(
/* check if there's enough space for the toggles if the sliders are drawn too */
if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2)) {
/* protect... */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
offset += ICON_WIDTH;
+ }
/* mute... */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) {
offset += ICON_WIDTH;
- if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ if (ale->type == ANIMTYPE_GPLAYER) {
offset += ICON_WIDTH;
+ }
/* pinned... */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED)) {
offset += ICON_WIDTH;
+ }
- /* NOTE: technically, NLA Action "pushdown" should be here too, but there are no sliders there */
+ /* NOTE: technically, NLA Action "pushdown" should be here too,
+ * but there are no sliders there. */
/* NLA action channels have slightly different spacing requirements... */
- if (ale->type == ANIMTYPE_NLAACTION)
+ if (ale->type == ANIMTYPE_NLAACTION) {
ymin_ofs = NLACHANNEL_SKIP;
+ }
}
- /* draw slider
- * - even if we can draw sliders for this view, we must also check that the channel-type supports them
- * (only only F-Curves really can support them for now)
- * - slider should start before the toggles (if they're visible) to keep a clean line down the side
+ /* Draw slider:
+ * - Even if we can draw sliders for this view,
+ * we must also check that the channel-type supports them
+ * (only only F-Curves really can support them for now).
+ * - Slider should start before the toggles (if they're visible)
+ * to keep a clean line down the side.
*/
if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY)) {
/* adjust offset */
offset += SLIDER_WIDTH;
}
- /* finally draw a backdrop rect behind these
- * - starts from the point where the first toggle/slider starts,
- * - ends past the space that might be reserved for a scroller
+ /* Finally draw a backdrop rect behind these:
+ * - Starts from the point where the first toggle/slider starts.
+ * - Ends past the space that might be reserved for a scroller.
*/
immRectf(pos,
v2d->cur.xmax - (float)offset,
@@ -4219,8 +4294,9 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
}
/* verify animation context */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
/* check if the setting is on... */
on = ANIM_channel_setting_get(&ac, ale_setting, setting);
@@ -4297,8 +4373,9 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
/* try to resolve the path stored in the F-Curve */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
/* set the special 'replace' flag if on a keyframe */
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
flag |= INSERTKEY_REPLACE;
+ }
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
@@ -4356,20 +4433,23 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
FCurve *fcu = verify_fcurve(bmain, act, NULL, &ptr, rna_path, 0, 1);
/* set the special 'replace' flag if on a keyframe */
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
flag |= INSERTKEY_REPLACE;
+ }
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag);
- if (done)
+ if (done) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ }
}
/* free the path */
- if (rna_path)
+ if (rna_path) {
MEM_freeN(rna_path);
+ }
BKE_animsys_free_nla_keyframing_context_cache(&nla_cache);
}
@@ -4400,20 +4480,23 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C,
/* get flags for keyframing */
flag = ANIM_get_keyframing_flags(scene, 1);
- /* get pointer and property from the slider - this should all match up with the NlaStrip required... */
+ /* Get pointer and property from the slider -
+ * this should all match up with the NlaStrip required. */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
if (fcu && prop) {
/* set the special 'replace' flag if on a keyframe */
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
flag |= INSERTKEY_REPLACE;
+ }
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag);
- if (done)
+ if (done) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ }
}
}
@@ -4443,15 +4526,18 @@ static void draw_setting_widget(bAnimContext *ac,
/* get the base icon for the setting */
switch (setting) {
case ACHANNEL_SETTING_VISIBLE: /* visibility eyes */
- //icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF);
+ // icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF);
icon = ICON_VISIBLE_IPO_OFF;
- if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
+ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
tooltip = TIP_("F-Curve is visible in Graph Editor for editing");
- else if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ else if (ale->type == ANIMTYPE_GPLAYER) {
tooltip = TIP_("Grease Pencil layer is visible in the viewport");
- else
+ }
+ else {
tooltip = TIP_("Channels are visible in Graph Editor for editing");
+ }
break;
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
@@ -4465,13 +4551,13 @@ static void draw_setting_widget(bAnimContext *ac,
break;
case ACHANNEL_SETTING_EXPAND: /* expanded triangle */
- //icon = ((enabled) ? ICON_TRIA_DOWN : ICON_TRIA_RIGHT);
+ // icon = ((enabled) ? ICON_TRIA_DOWN : ICON_TRIA_RIGHT);
icon = ICON_TRIA_RIGHT;
tooltip = TIP_("Make channels grouped under this channel visible");
break;
case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */
- //icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON);
+ // icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON);
icon = ICON_SOLO_OFF;
tooltip = TIP_(
"NLA Track is the only one evaluated in this animation data-block, with all others "
@@ -4482,13 +4568,15 @@ static void draw_setting_widget(bAnimContext *ac,
case ACHANNEL_SETTING_PROTECT: /* protected lock */
// TODO: what about when there's no protect needed?
- //icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
+ // icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
icon = ICON_UNLOCKED;
- if (ale->datatype != ALE_NLASTRIP)
+ if (ale->datatype != ALE_NLASTRIP) {
tooltip = TIP_("Editability of keyframes for this channel");
- else
+ }
+ else {
tooltip = TIP_("Editability of NLA Strips in this track");
+ }
break;
case ACHANNEL_SETTING_MUTE: /* muted speaker */
@@ -4511,7 +4599,7 @@ static void draw_setting_widget(bAnimContext *ac,
break;
case ACHANNEL_SETTING_PINNED: /* pin icon */
- //icon = ((enabled) ? ICON_PINNED : ICON_UNPINNED);
+ // icon = ((enabled) ? ICON_PINNED : ICON_UNPINNED);
icon = ICON_UNPINNED;
if (ale->type == ANIMTYPE_NLAACTION) {
@@ -4531,16 +4619,20 @@ static void draw_setting_widget(bAnimContext *ac,
/* type of button */
if (usetoggle) {
- if (negflag)
+ if (negflag) {
butType = UI_BTYPE_ICON_TOGGLE_N;
- else
+ }
+ else {
butType = UI_BTYPE_ICON_TOGGLE;
+ }
}
else {
- if (negflag)
+ if (negflag) {
butType = UI_BTYPE_TOGGLE_N;
- else
+ }
+ else {
butType = UI_BTYPE_TOGGLE;
+ }
}
/* draw button for setting */
if (ptr && flag) {
@@ -4628,12 +4720,14 @@ static void draw_setting_widget(bAnimContext *ac,
UI_but_func_set(but, achannel_setting_widget_cb, NULL, NULL);
break;
}
- }
- }
- if ((ale->fcurve_owner_id != NULL && ID_IS_LINKED(ale->fcurve_owner_id)) ||
- (ale->id != NULL && ID_IS_LINKED(ale->id))) {
- UI_but_flag_enable(but, UI_BUT_DISABLED);
+ if ((ale->fcurve_owner_id != NULL && ID_IS_LINKED(ale->fcurve_owner_id)) ||
+ (ale->id != NULL && ID_IS_LINKED(ale->id))) {
+ if (setting != ACHANNEL_SETTING_EXPAND) {
+ UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
+ }
+ }
}
}
@@ -4652,8 +4746,9 @@ void ANIM_channel_draw_widgets(const bContext *C,
const bool is_being_renamed = achannel_is_being_renamed(ac, acf, channel_index);
/* sanity checks - don't draw anything */
- if (ELEM(NULL, acf, ale, block))
+ if (ELEM(NULL, acf, ale, block)) {
return;
+ }
/* get initial offset */
short offset = rect->xmin;
@@ -4715,15 +4810,43 @@ void ANIM_channel_draw_widgets(const bContext *C,
RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, &ptr);
UI_block_align_begin(block);
- UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_stroke_visible") ? UI_EMBOSS : UI_EMBOSS_NONE);
- uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset, yminc, w, ICON_WIDTH,
- &ptr, "color", -1,
- 0, 0, 0, 0, gpl->info);
-
- UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_fill_visible") ? UI_EMBOSS : UI_EMBOSS_NONE);
- uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset + w, yminc, w, ICON_WIDTH,
- &ptr, "fill_color", -1,
- 0, 0, 0, 0, gpl->info);
+ UI_block_emboss_set(block,
+ RNA_boolean_get(&ptr, "is_stroke_visible") ? UI_EMBOSS : UI_EMBOSS_NONE);
+ uiDefButR(block,
+ UI_BTYPE_COLOR,
+ 1,
+ "",
+ offset,
+ yminc,
+ w,
+ ICON_WIDTH,
+ &ptr,
+ "color",
+ -1,
+ 0,
+ 0,
+ 0,
+ 0,
+ gpl->info);
+
+ UI_block_emboss_set(block,
+ RNA_boolean_get(&ptr, "is_fill_visible") ? UI_EMBOSS : UI_EMBOSS_NONE);
+ uiDefButR(block,
+ UI_BTYPE_COLOR,
+ 1,
+ "",
+ offset + w,
+ yminc,
+ w,
+ ICON_WIDTH,
+ &ptr,
+ "fill_color",
+ -1,
+ 0,
+ 0,
+ 0,
+ 0,
+ gpl->info);
UI_block_emboss_set(block, UI_EMBOSS_NONE);
UI_block_align_end(block);
@@ -4821,7 +4944,8 @@ void ANIM_channel_draw_widgets(const bContext *C,
draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_MUTE);
}
if (ale->type == ANIMTYPE_GPLAYER) {
- /* Not technically "mute" (in terms of anim channels, but this sets layer visibility instead) */
+ /* Not technically "mute"
+ * (in terms of anim channels, but this sets layer visibility instead). */
offset -= ICON_WIDTH;
draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_VISIBLE);
}
@@ -4868,17 +4992,20 @@ void ANIM_channel_draw_widgets(const bContext *C,
}
}
- /* draw slider
- * - even if we can draw sliders for this view, we must also check that the channel-type supports them
- * (only only F-Curves really can support them for now)
- * - to make things easier, we use RNA-autobuts for this so that changes are reflected immediately,
- * wherever they occurred. BUT, we don't use the layout engine, otherwise we'd get wrong alignment,
- * and wouldn't be able to auto-keyframe...
- * - slider should start before the toggles (if they're visible) to keep a clean line down the side
+ /* Draw slider:
+ * - Even if we can draw sliders for this view, we must also check that the channel-type
+ * supports them (only only F-Curves really can support them for now).
+ * - To make things easier, we use RNA-autobuts for this so that changes are
+ * reflected immediately, wherever they occurred.
+ * BUT, we don't use the layout engine, otherwise we'd get wrong alignment,
+ * and wouldn't be able to auto-keyframe.
+ * - Slider should start before the toggles (if they're visible)
+ * to keep a clean line down the side.
*/
if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY)) {
/* adjust offset */
- // TODO: make slider width dynamic, so that they can be easier to use when the view is wide enough
+ /* TODO: make slider width dynamic,
+ * so that they can be easier to use when the view is wide enough. */
offset -= SLIDER_WIDTH;
/* need backdrop behind sliders... */
@@ -4899,7 +5026,8 @@ void ANIM_channel_draw_widgets(const bContext *C,
if (prop) {
uiBut *but;
- /* create the slider button, and assign relevant callback to ensure keyframes are inserted... */
+ /* Create the slider button,
+ * and assign relevant callback to ensure keyframes are inserted. */
but = uiDefAutoButR(block,
&ptr,
prop,
@@ -4945,7 +5073,8 @@ void ANIM_channel_draw_widgets(const bContext *C,
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) {
uiBut *but;
- /* create the slider button, and assign relevant callback to ensure keyframes are inserted... */
+ /* Create the slider button,
+ * and assign relevant callback to ensure keyframes are inserted. */
but = uiDefAutoButR(block,
&ptr,
prop,
@@ -4958,15 +5087,18 @@ void ANIM_channel_draw_widgets(const bContext *C,
channel_height);
/* assign keyframing function according to slider type */
- if (ale->type == ANIMTYPE_SHAPEKEY)
+ if (ale->type == ANIMTYPE_SHAPEKEY) {
UI_but_func_set(but, achannel_setting_slider_shapekey_cb, ale->id, ale->data);
- else
+ }
+ else {
UI_but_func_set(but, achannel_setting_slider_cb, ale->id, ale->data);
+ }
}
/* free the path if necessary */
- if (free_path)
+ if (free_path) {
MEM_freeN(rna_path);
+ }
}
}
else { /* Special Slider for stuff without RNA Access ---------- */
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index c2878a64e97..6e0277d5fff 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -85,14 +85,16 @@ void ANIM_set_active_channel(bAnimContext *ac,
/* try to build list of filtered items */
ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
- if (BLI_listbase_is_empty(&anim_data))
+ if (BLI_listbase_is_empty(&anim_data)) {
return;
+ }
/* only clear the 'active' flag for the channels of the same type */
for (ale = anim_data.first; ale; ale = ale->next) {
/* skip if types don't match */
- if (channel_type != ale->type)
+ if (channel_type != ale->type) {
continue;
+ }
/* flag to set depends on type */
switch (ale->type) {
@@ -263,13 +265,15 @@ void ANIM_deselect_anim_channels(
/* See if we should be selecting or deselecting */
if (test) {
for (ale = anim_data.first; ale; ale = ale->next) {
- if (sel == 0)
+ if (sel == 0) {
break;
+ }
switch (ale->type) {
case ANIMTYPE_SCENE:
- if (ale->flag & SCE_DS_SELECTED)
+ if (ale->flag & SCE_DS_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_OBJECT:
#if 0 /* for now, do not take object selection into account, since it gets too annoying */
@@ -278,21 +282,25 @@ void ANIM_deselect_anim_channels(
#endif
break;
case ANIMTYPE_GROUP:
- if (ale->flag & AGRP_SELECTED)
+ if (ale->flag & AGRP_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_FCURVE:
case ANIMTYPE_NLACURVE:
- if (ale->flag & FCURVE_SELECTED)
+ if (ale->flag & FCURVE_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_SHAPEKEY:
- if (ale->flag & KEYBLOCK_SEL)
+ if (ale->flag & KEYBLOCK_SEL) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_NLATRACK:
- if (ale->flag & NLATRACK_SELECTED)
+ if (ale->flag & NLATRACK_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_FILLACTD: /* Action Expander */
@@ -314,17 +322,20 @@ void ANIM_deselect_anim_channels(
case ANIMTYPE_DSSPK:
case ANIMTYPE_DSGPENCIL:
case ANIMTYPE_DSMCLIP: {
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
+ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
}
case ANIMTYPE_GPLAYER:
- if (ale->flag & GP_LAYER_SELECT)
+ if (ale->flag & GP_LAYER_SELECT) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_MASKLAYER:
- if (ale->flag & MASK_LAYERFLAG_SELECT)
+ if (ale->flag & MASK_LAYERFLAG_SELECT) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
}
}
@@ -451,8 +462,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
int prevLevel = 0, matchLevel = 0;
/* sanity check */
- if (ELEM(NULL, anim_data, anim_data->first))
+ if (ELEM(NULL, anim_data, anim_data->first)) {
return;
+ }
if (setting == ACHANNEL_SETTING_ALWAYS_VISIBLE) {
return;
@@ -462,7 +474,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
for (ale = anim_data->first; ale; ale = ale->next) {
/* compare data, and type as main way of identifying the channel */
if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) {
- /* we also have to check the ID, this is assigned to, since a block may have multiple users */
+ /* We also have to check the ID, this is assigned to,
+ * since a block may have multiple users. */
/* TODO: is the owner-data more revealing? */
if (ale->id == ale_setting->id) {
match = ale;
@@ -501,14 +514,16 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
*/
if (((setting == ACHANNEL_SETTING_VISIBLE) && (mode != ACHANNEL_SETFLAG_CLEAR)) ||
((setting != ACHANNEL_SETTING_VISIBLE) && (mode == ACHANNEL_SETFLAG_CLEAR))) {
- /* go backwards in the list, until the highest-ranking element (by indention has been covered) */
+ /* Go backwards in the list, until the highest-ranking element
+ * (by indention has been covered). */
for (ale = match->prev; ale; ale = ale->prev) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
int level;
/* if no channel info was found, skip, since this type might not have any useful info */
- if (acf == NULL)
+ if (acf == NULL) {
continue;
+ }
/* get the level of the current channel traversed
* - we define the level as simply being the offset for the start of the channel
@@ -517,8 +532,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
/* if the level is 'less than' (i.e. more important) the level we're matching
* but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves,
- * when toggling visibility of F-Curves, gets flushed, which should happen if we don't let prevLevel
- * get updated below once the first 1st group is found)...
+ * when toggling visibility of F-Curves, gets flushed, which should happen if we don't let
+ * prevLevel get updated below once the first 1st group is found).
*/
if (level < prevLevel) {
/* flush the new status... */
@@ -532,13 +547,15 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
/* if previous level was a base-level (i.e. 0 offset / root of one hierarchy),
* stop here
*/
- if (prevLevel == 0)
+ if (prevLevel == 0) {
break;
- /* otherwise, this level weaves into another sibling hierarchy to the previous one just
- * finished, so skip until we get to the parent of this level
- */
- else
+ /* otherwise, this level weaves into another sibling hierarchy to the previous one just
+ * finished, so skip until we get to the parent of this level
+ */
+ }
+ else {
continue;
+ }
}
}
}
@@ -551,8 +568,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
int level;
/* if no channel info was found, skip, since this type might not have any useful info */
- if (acf == NULL)
+ if (acf == NULL) {
continue;
+ }
/* get the level of the current channel traversed
* - we define the level as simply being the offset for the start of the channel
@@ -562,14 +580,17 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
/* if the level is 'greater than' (i.e. less important) the channel that was changed,
* flush the new status...
*/
- if (level > matchLevel)
+ if (level > matchLevel) {
ANIM_channel_setting_set(ac, ale, setting, mode);
- /* however, if the level is 'less than or equal to' the channel that was changed,
- * (i.e. the current channel is as important if not more important than the changed channel)
- * then we should stop, since we've found the last one of the children we should flush
- */
- else
+ /* however, if the level is 'less than or equal to' the channel that was changed,
+ * (i.e. the current channel is as important if not more important than the changed
+ * channel) then we should stop, since we've found the last one of the children we should
+ * flush
+ */
+ }
+ else {
break;
+ }
/* store this level as the 'old' level now */
// prevLevel = level; // XXX: prevLevel is unused
@@ -586,8 +607,9 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
* (this doesn't guarantee that the F-Curve is in there, but at least we tried
* - if no F-Curve, there is nothing to remove
*/
- if (ELEM(NULL, adt, fcu))
+ if (ELEM(NULL, adt, fcu)) {
return;
+ }
/* remove from whatever list it came from
* - Action Group
@@ -627,14 +649,28 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
* channel list that are empty, and linger around long after the data they
* are for has disappeared (and probably won't come back).
*/
+ ANIM_remove_empty_action_from_animdata(adt);
+ }
+
+ /* free the F-Curve itself */
+ free_fcurve(fcu);
+}
+
+/* If the action has no F-Curves, unlink it from AnimData if it did not
+ * come from a NLA Strip being tweaked. */
+bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt)
+{
+ if (adt->action != NULL) {
+ bAction *act = adt->action;
+
if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) {
id_us_min(&act->id);
adt->action = NULL;
+ return true;
}
}
- /* free the F-Curve itself */
- free_fcurve(fcu);
+ return false;
}
/* ************************************************************************** */
@@ -649,11 +685,13 @@ static bool animedit_poll_channels_active(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0)
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
+ }
return 1;
}
@@ -666,16 +704,19 @@ static bool animedit_poll_channels_nla_tweakmode_off(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0)
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
+ }
/* NLA TweakMode test */
if (sa->spacetype == SPACE_NLA) {
- if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
+ if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
+ }
}
return 1;
@@ -724,8 +765,9 @@ typedef enum eReorderIslandFlag {
static bool rearrange_island_ok(tReorderChannelIsland *island)
{
/* island must not be untouchable */
- if (island->flag & REORDER_ISLAND_UNTOUCHABLE)
+ if (island->flag & REORDER_ISLAND_UNTOUCHABLE) {
return 0;
+ }
/* island should be selected to be moved */
return (island->flag & REORDER_ISLAND_SELECTED) && !(island->flag & REORDER_ISLAND_MOVED);
@@ -907,7 +949,8 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands,
(island == NULL) ||
/* 2) unselected islands have single channels only - to allow up/down movement */
((island->flag & REORDER_ISLAND_SELECTED) == 0) ||
- /* 3) if channel is unselected, stop existing island (it was either wrong sel status, or full already) */
+ /* 3) if channel is unselected, stop existing island
+ * (it was either wrong sel status, or full already) */
(is_sel == 0) ||
/* 4) hidden status changes */
((island->flag & REORDER_ISLAND_HIDDEN) != is_hidden)) {
@@ -915,12 +958,15 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands,
island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland");
BLI_addtail(islands, island);
- if (is_sel)
+ if (is_sel) {
island->flag |= REORDER_ISLAND_SELECTED;
- if (is_untouchable)
+ }
+ if (is_untouchable) {
island->flag |= REORDER_ISLAND_UNTOUCHABLE;
- if (is_hidden)
+ }
+ if (is_hidden) {
island->flag |= REORDER_ISLAND_HIDDEN;
+ }
}
/* add channel to island - need to remove it from its existing list first though */
@@ -985,8 +1031,9 @@ static bool rearrange_animchannel_islands(ListBase *list,
bool done = false;
/* don't waste effort on an empty list */
- if (BLI_listbase_is_empty(list))
+ if (BLI_listbase_is_empty(list)) {
return 0;
+ }
/* group channels into islands */
for (channel = list->first; channel; channel = chanNext) {
@@ -997,9 +1044,12 @@ static bool rearrange_animchannel_islands(ListBase *list,
rearrange_animchannel_add_to_islands(&islands, list, channel, type, is_hidden);
}
- /* perform moving of selected islands now, but only if there is more than one of 'em so that something will happen
- * - scanning of the list is performed in the opposite direction to the direction we're moving things, so that we
- * shouldn't need to encounter items we've moved already
+ /* Perform moving of selected islands now, but only if there is more than one of them
+ * so that something will happen:
+ *
+ * - Scanning of the list is performed in the opposite direction
+ * to the direction we're moving things,
+ * so that we shouldn't need to encounter items we've moved already.
*/
if (islands.first != islands.last) {
tReorderChannelIsland *first = (mode > 0) ? islands.last : islands.first;
@@ -1039,8 +1089,9 @@ static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAn
/* get rearranging function */
rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLATRACK);
@@ -1066,12 +1117,14 @@ static void rearrange_driver_channels(bAnimContext *ac,
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
ListBase anim_data_visible = {NULL, NULL};
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* only consider drivers if they're accessible */
- if (EXPANDED_DRVD(adt) == 0)
+ if (EXPANDED_DRVD(adt) == 0) {
return;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE);
@@ -1092,8 +1145,9 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp)
bActionGroup *agrp;
FCurve *fcu;
- if (act == NULL)
+ if (act == NULL) {
return;
+ }
/* Separate F-Curves into lists per group */
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
@@ -1185,8 +1239,9 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* make sure we're only operating with groups (vs a mixture of groups+curves) */
split_groups_action_temp(act, &tgrp);
@@ -1194,9 +1249,10 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GROUP);
- /* rearrange groups first
- * - the group's channels will only get considered if nothing happened when rearranging the groups
- * i.e. the rearrange function returned 0
+ /* Rearrange groups first:
+ * - The group's channels will only get considered
+ * if nothing happened when rearranging the groups
+ * i.e. the rearrange function returned 0.
*/
do_channels = (rearrange_animchannel_islands(
&act->groups, rearrange_func, mode, ANIMTYPE_GROUP, &anim_data_visible) == 0);
@@ -1240,12 +1296,14 @@ static void rearrange_nla_control_channels(bAnimContext *ac,
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* skip if these curves aren't being shown */
- if (adt->flag & ADT_NLA_SKEYS_COLLAPSED)
+ if (adt->flag & ADT_NLA_SKEYS_COLLAPSED) {
return;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLACURVE);
@@ -1273,8 +1331,9 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* get Grease Pencil datablocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
@@ -1286,8 +1345,9 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode
/* only consider layers if this datablock is open */
BLI_assert(ale->type == ANIMTYPE_GPDATABLOCK);
- if ((gpd->flag & GP_DATA_EXPAND) == 0)
+ if ((gpd->flag & GP_DATA_EXPAND) == 0) {
continue;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GPLAYER);
@@ -1312,8 +1372,9 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
eRearrangeAnimChan_Mode mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get mode */
mode = RNA_enum_get(op->ptr, "direction");
@@ -1356,24 +1417,29 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
case ANIMCONT_ACTION: /* Single Action only... */
case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME...
{
- if (adt->action)
+ if (adt->action) {
rearrange_action_channels(&ac, adt->action, mode);
- else if (G.debug & G_DEBUG)
+ }
+ else if (G.debug & G_DEBUG) {
printf("Animdata has no action\n");
+ }
break;
}
default: /* DopeSheet/Graph Editor - Some Actions + NLA Control Curves */
{
/* NLA Control Curves */
- if (adt->nla_tracks.first)
+ if (adt->nla_tracks.first) {
rearrange_nla_control_channels(&ac, adt, mode);
+ }
/* Action */
- if (adt->action)
+ if (adt->action) {
rearrange_action_channels(&ac, adt->action, mode);
- else if (G.debug & G_DEBUG)
+ }
+ else if (G.debug & G_DEBUG) {
printf("Animdata has no action\n");
+ }
break;
}
}
@@ -1421,8 +1487,9 @@ static bool animchannels_grouping_poll(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test - must be suitable modes only */
sl = CTX_wm_space_data(C);
@@ -1433,8 +1500,9 @@ static bool animchannels_grouping_poll(bContext *C)
SpaceAction *saction = (SpaceAction *)sl;
/* dopesheet and action only - all others are for other datatypes or have no groups */
- if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0)
+ if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0) {
return 0;
+ }
break;
}
@@ -1442,8 +1510,9 @@ static bool animchannels_grouping_poll(bContext *C)
SpaceGraph *sipo = (SpaceGraph *)sl;
/* drivers can't have groups... */
- if (sipo->mode != SIPO_MODE_ANIMATION)
+ if (sipo->mode != SIPO_MODE_ANIMATION) {
return 0;
+ }
break;
}
@@ -1508,8 +1577,9 @@ static int animchannels_group_exec(bContext *C, wmOperator *op)
char name[MAX_NAME];
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get name for new group */
RNA_string_get(op->ptr, "name", name);
@@ -1576,8 +1646,9 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* just selected F-Curves... */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
@@ -1661,12 +1732,14 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* cannot delete in shapekey */
- if (ac.datatype == ANIMCONT_SHAPEKEY)
+ if (ac.datatype == ANIMCONT_SHAPEKEY) {
return OPERATOR_CANCELLED;
+ }
/* do groups only first (unless in Drivers mode, where there are none) */
if (ac.datatype != ANIMCONT_DRIVERS) {
@@ -1684,8 +1757,9 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
FCurve *fcu, *fcn;
/* skip this group if no AnimData available, as we can't safely remove the F-Curves */
- if (adt == NULL)
+ if (adt == NULL) {
continue;
+ }
/* delete all of the Group's F-Curves, but no others */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) {
@@ -1701,8 +1775,9 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
BLI_freelinkN(&adt->action->groups, agrp);
DEG_id_tag_update_ex(CTX_data_main(C), &adt->action->id, ID_RECALC_ANIMATION);
}
- else
+ else {
MEM_freeN(agrp);
+ }
}
}
@@ -1862,8 +1937,9 @@ static void setflag_anim_channels(bAnimContext *ac,
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_NODUPLIS);
}
- if (onlysel)
+ if (onlysel) {
filter |= ANIMFILTER_SEL;
+ }
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* if toggling, check if disable or enable */
@@ -1884,15 +1960,17 @@ static void setflag_anim_channels(bAnimContext *ac,
/* apply the setting */
for (ale = anim_data.first; ale; ale = ale->next) {
/* skip channel if setting is not available */
- if (ANIM_channel_setting_get(ac, ale, setting) == -1)
+ if (ANIM_channel_setting_get(ac, ale, setting) == -1) {
continue;
+ }
/* set the setting in the appropriate way */
ANIM_channel_setting_set(ac, ale, setting, mode);
/* if flush status... */
- if (flush)
+ if (flush) {
ANIM_flush_setting_anim_channels(ac, &all_data, ale, setting, mode);
+ }
}
ANIM_animdata_freelist(&anim_data);
@@ -1909,16 +1987,18 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op)
bool flush = true;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */
mode = RNA_enum_get(op->ptr, "mode");
setting = RNA_enum_get(op->ptr, "type");
/* check if setting is flushable */
- if (setting == ACHANNEL_SETTING_EXPAND)
+ if (setting == ACHANNEL_SETTING_EXPAND) {
flush = false;
+ }
/* modify setting
* - only selected channels are affected
@@ -2044,12 +2124,14 @@ static int animchannels_expand_exec(bContext *C, wmOperator *op)
bool onlysel = true;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* only affect selected channels? */
- if (RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all")) {
onlysel = false;
+ }
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, false);
@@ -2087,12 +2169,14 @@ static int animchannels_collapse_exec(bContext *C, wmOperator *op)
bool onlysel = true;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* only affect selected channels? */
- if (RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all")) {
onlysel = false;
+ }
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, false);
@@ -2143,8 +2227,9 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get animdata blocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
@@ -2236,12 +2321,14 @@ static bool animchannels_enable_poll(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test - Action/Dopesheet/etc. and Graph only */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0)
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0) {
return 0;
+ }
return 1;
}
@@ -2255,8 +2342,9 @@ static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
@@ -2270,8 +2358,9 @@ static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op))
fcu->flag &= ~FCURVE_DISABLED;
/* for drivers, let's do the same too */
- if (fcu->driver)
+ if (fcu->driver) {
fcu->driver->flag &= ~DRIVER_FLAG_INVALID;
+ }
/* tag everything for updates - in particular, this is needed to get drivers working again */
ale->update |= ANIM_UPDATE_DEPS;
@@ -2308,8 +2397,9 @@ static bool animchannels_find_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa == NULL)
+ if (sa == NULL) {
return 0;
+ }
/* animation editor with dopesheet */
return ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA);
@@ -2321,8 +2411,9 @@ static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent *
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* set initial filter text, and enable filter */
RNA_string_set(op->ptr, "query", ac.ads->searchstr);
@@ -2337,8 +2428,9 @@ static int animchannels_find_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* update filter text */
RNA_string_get(op->ptr, "query", ac.ads->searchstr);
@@ -2380,8 +2472,9 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* 'standard' behavior - check if selected, then apply relevant selection */
const int action = RNA_enum_get(op->ptr, "action");
@@ -2460,10 +2553,12 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm
/* loop over data, doing box select */
for (ale = anim_data.first; ale; ale = ale->next) {
- if (ac->datatype == ANIMCONT_NLA)
+ if (ac->datatype == ANIMCONT_NLA) {
ymin = ymax - NLACHANNEL_STEP(snla);
- else
+ }
+ else {
ymin = ymax - ACHANNEL_STEP(ac);
+ }
/* if channel is within border-select region, alter it */
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
@@ -2510,8 +2605,9 @@ static int animchannels_box_select_exec(bContext *C, wmOperator *op)
const bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
@@ -2578,14 +2674,22 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index)
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return false;
}
+ /* don't allow renaming linked channels */
+ if ((ale->fcurve_owner_id != NULL && ID_IS_LINKED(ale->fcurve_owner_id)) ||
+ (ale->id != NULL && ID_IS_LINKED(ale->id))) {
+ ANIM_animdata_freelist(&anim_data);
+ return false;
+ }
+
/* check that channel can be renamed */
acf = ANIM_channel_get_typeinfo(ale);
if (acf && acf->name_prop) {
@@ -2625,10 +2729,11 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2])
ar = ac->ar;
v2d = &ar->v2d;
- /* figure out which channel user clicked in
- * Note: although channels technically start at (y = ACHANNEL_FIRST), we need to adjust by half a channel's height
- * so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use
- * ACHANNEL_HEIGHT_HALF.
+ /* Figure out which channel user clicked in.
+ *
+ * Note: although channels technically start at (y = ACHANNEL_FIRST),
+ * we need to adjust by half a channel's height so that the tops of channels get caught ok.
+ * Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use ACHANNEL_HEIGHT_HALF.
*/
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
@@ -2665,17 +2770,20 @@ static int animchannels_rename_invoke(bContext *C, wmOperator *UNUSED(op), const
int channel_index;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
channel_index = animchannels_channel_get(&ac, event->mval);
/* handle click */
- if (rename_anim_channels(&ac, channel_index))
+ if (rename_anim_channels(&ac, channel_index)) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
/* allow event to be handled by selectall operator */
return OPERATOR_PASS_THROUGH;
+ }
}
static void ANIM_OT_channels_rename(wmOperatorType *ot)
@@ -2709,15 +2817,17 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return 0;
}
- /* selectmode -1 is a special case for ActionGroups only, which selects all of the channels underneath it only... */
+ /* selectmode -1 is a special case for ActionGroups only,
+ * which selects all of the channels underneath it only. */
/* TODO: should this feature be extended to work with other channel types too? */
if ((selectmode == -1) && (ale->type != ANIMTYPE_GROUP)) {
/* normal channels should not behave normally in this case */
@@ -2736,13 +2846,15 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
if (selectmode == SELECT_INVERT) {
/* swap select */
sce->flag ^= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
sce->flag |= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -2763,10 +2875,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
if (selectmode == SELECT_INVERT) {
/* swap select */
ED_object_base_select(base, BA_INVERT);
- BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
Base *b;
@@ -2775,25 +2887,27 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* TODO: should this deselect all other types of channels too? */
for (b = view_layer->object_bases.first; b; b = b->next) {
ED_object_base_select(b, BA_DESELECT);
- BKE_scene_object_base_flag_sync_from_base(b);
- if (b->object->adt)
+ if (b->object->adt) {
b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
+ }
}
/* select object now */
ED_object_base_select(base, BA_SELECT);
- BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
/* change active object - regardless of whether it is now selected [T37883] */
ED_object_base_activate(C, base); /* adds notifier */
- if ((adt) && (adt->flag & ADT_UI_SELECTED))
+ if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
adt->flag |= ADT_UI_ACTIVE;
+ }
- /* ensure we exit editmode on whatever object was active before to avoid getting stuck there - T48747 */
+ /* Ensure we exit editmode on whatever object was active before
+ * to avoid getting stuck there - T48747. */
if (ob != CTX_data_edit_object(C)) {
ED_object_editmode_exit(C, EM_FREEDATA);
}
@@ -2835,8 +2949,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
}
/* set active? */
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
+ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
ale->adt->flag |= ADT_UI_ACTIVE;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -2884,19 +2999,22 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* deselect all other channels */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan)
+ if (pchan) {
ED_pose_deselect_all(ob, SEL_DESELECT, false);
+ }
/* only select channels in group and group itself */
- for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next)
+ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
fcu->flag |= FCURVE_SELECTED;
+ }
agrp->flag |= AGRP_SELECTED;
}
else {
/* select group by itself */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan)
+ if (pchan) {
ED_pose_deselect_all(ob, SEL_DESELECT, false);
+ }
agrp->flag |= AGRP_SELECTED;
}
@@ -2904,13 +3022,15 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* if group is selected now, make group the 'active' one in the visible list */
if (agrp->flag & AGRP_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
- if (pchan)
+ if (pchan) {
ED_pose_bone_select(ob, pchan, true);
+ }
}
else {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP);
- if (pchan)
+ if (pchan) {
ED_pose_bone_select(ob, pchan, false);
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -2932,8 +3052,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
}
/* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */
- if (fcu->flag & FCURVE_SELECTED)
+ if (fcu->flag & FCURVE_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type);
+ }
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
@@ -2958,9 +3079,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
case ANIMTYPE_NLACONTROLS: {
AnimData *adt = (AnimData *)ale->data;
- /* toggle expand
- * - Although the triangle widget already allows this, since there's nothing else that can be done here now,
- * let's just use it for easier expand/collapse for now
+ /* Toggle expand:
+ * - Although the triangle widget already allows this,
+ * since there's nothing else that can be done here now,
+ * let's just use it for easier expand/collapse for now.
*/
adt->flag ^= ADT_NLA_SKEYS_COLLAPSED;
@@ -2970,8 +3092,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
case ANIMTYPE_GPDATABLOCK: {
bGPdata *gpd = (bGPdata *)ale->data;
- /* toggle expand
- * - although the triangle widget already allows this, the whole channel can also be used for this purpose
+ /* Toggle expand:
+ * - Although the triangle widget already allows this,
+ * the whole channel can also be used for this purpose.
*/
gpd->flag ^= GP_DATA_EXPAND;
@@ -3008,8 +3131,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
case ANIMTYPE_MASKDATABLOCK: {
Mask *mask = (Mask *)ale->data;
- /* toggle expand
- * - although the triangle widget already allows this, the whole channel can also be used for this purpose
+ /* Toggle expand
+ * - Although the triangle widget already allows this,
+ * the whole channel can also be used for this purpose.
*/
mask->flag ^= MASK_ANIMF_EXPAND;
@@ -3034,8 +3158,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
break;
}
default:
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Invalid channel type in mouse_anim_channels()\n");
+ }
break;
}
@@ -3060,8 +3185,9 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE
float x, y;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get useful pointers from animation context data */
ar = ac.ar;
@@ -3151,9 +3277,10 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return false;
@@ -3203,8 +3330,9 @@ static int animchannels_channel_select_keys_invoke(bContext *C,
bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
channel_index = animchannels_channel_get(&ac, event->mval);
@@ -3213,9 +3341,10 @@ static int animchannels_channel_select_keys_invoke(bContext *C,
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
- else
+ else {
/* allow event to be handled by selectall operator */
return OPERATOR_PASS_THROUGH;
+ }
}
static void ANIM_OT_channel_select_keys(wmOperatorType *ot)
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 53fec2e1ef7..5c9f0707aa9 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -63,8 +63,9 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
AnimData *adt;
id = ale->id;
- if (!id)
+ if (!id) {
return;
+ }
/* tag AnimData for refresh so that other views will update in realtime with these changes */
adt = BKE_animdata_from_id(id);
@@ -97,8 +98,9 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
RNA_id_pointer_create(id, &id_ptr);
- if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop))
+ if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
RNA_property_update_main(bmain, scene, &ptr, prop);
+ }
}
else {
/* in other case we do standard depsgraph update, ideally
@@ -141,15 +143,17 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
/* major priority is selection status
* so we need both a group and an owner
*/
- if (ELEM(NULL, agrp, owner_id))
+ if (ELEM(NULL, agrp, owner_id)) {
return;
+ }
/* for standard Objects, check if group is the name of some bone */
if (GS(owner_id->name) == ID_OB) {
Object *ob = (Object *)owner_id;
/* check if there are bones, and whether the name matches any
- * NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone
+ * NOTE: this feature will only really work if groups by default contain the F-Curves
+ * for a single bone.
*/
if (ob->pose) {
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name);
@@ -159,10 +163,12 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
bActionGroup *bgrp;
/* if one matches, sync the selection status */
- if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))
+ if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
agrp->flag |= AGRP_SELECTED;
- else
+ }
+ else {
agrp->flag &= ~AGRP_SELECTED;
+ }
/* also sync active group status */
if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) {
@@ -203,8 +209,9 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
/* major priority is selection status, so refer to the checks done in anim_filter.c
* skip_fcurve_selected_data() for reference about what's going on here...
*/
- if (ELEM(NULL, fcu, fcu->rna_path, owner_id))
+ if (ELEM(NULL, fcu, fcu->rna_path, owner_id)) {
return;
+ }
if (GS(owner_id->name) == ID_SCE) {
Scene *scene = (Scene *)owner_id;
@@ -218,15 +225,18 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
/* get strip name, and check if this strip is selected */
seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
- if (seq_name)
+ if (seq_name) {
MEM_freeN(seq_name);
+ }
/* update selection status */
if (seq) {
- if (seq->flag & SELECT)
+ if (seq->flag & SELECT) {
fcu->flag |= FCURVE_SELECTED;
- else
+ }
+ else {
fcu->flag &= ~FCURVE_SELECTED;
+ }
}
}
}
@@ -241,16 +251,19 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
/* get strip name, and check if this strip is selected */
node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
node = nodeFindNodebyName(ntree, node_name);
- if (node_name)
+ if (node_name) {
MEM_freeN(node_name);
+ }
/* update selection/active status */
if (node) {
/* update selection status */
- if (node->flag & NODE_SELECT)
+ if (node->flag & NODE_SELECT) {
fcu->flag |= FCURVE_SELECTED;
- else
+ }
+ else {
fcu->flag &= ~FCURVE_SELECTED;
+ }
/* update active status */
/* XXX: this may interfere with setting bones as active if both exist at once;
@@ -310,12 +323,15 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
FCurve *active_fcurve = NULL;
/* get animation context info for filtering the channels */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
/* filter data */
- /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed
- * However, don't include duplicates so that selection statuses don't override each other
+
+ /* NOTE: we want all channels, since we want to be able to set selection status on some of them
+ * even when collapsed... however,
+ * don't include duplicates so that selection statuses don't override each other.
*/
filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -361,7 +377,7 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
if (ale->update & ANIM_UPDATE_ORDER) {
ale->update &= ~ANIM_UPDATE_ORDER;
if (gpl) {
- //gpencil_sort_frames(gpl);
+ // gpencil_sort_frames(gpl);
}
}
@@ -379,14 +395,16 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
if (ale->update & ANIM_UPDATE_ORDER) {
ale->update &= ~ANIM_UPDATE_ORDER;
- if (fcu)
+ if (fcu) {
sort_time_fcurve(fcu);
+ }
}
if (ale->update & ANIM_UPDATE_HANDLES) {
ale->update &= ~ANIM_UPDATE_HANDLES;
- if (fcu)
+ if (fcu) {
calchandles_fcurve(fcu);
+ }
}
if (ale->update & ANIM_UPDATE_DEPS) {
@@ -408,7 +426,10 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
#if 0
if (G.debug & G_DEBUG) {
printf("%s: Unhandled animchannel updates (%d) for type=%d (%p)\n",
- __func__, ale->update, ale->type, ale->data);
+ __func__,
+ ale->update,
+ ale->type,
+ ale->data);
}
#endif
/* Prevent crashes in cases where it can't be handled */
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 11c768a8efd..61bf7f95340 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -169,7 +169,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_ANIM_PREVIEW_RANGE, -25, -30);
/* XXX: Fix this hardcoded color (anim_active) */
- //immUniformColor4f(0.8f, 0.44f, 0.1f, 0.2f);
+ // immUniformColor4f(0.8f, 0.44f, 0.1f, 0.2f);
/* only draw two separate 'curtains' if there's no overlap between them */
if (PSFRA < PEFRA + end_frame_width) {
@@ -237,12 +237,14 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
{
/* sanity checks */
- if (ac == NULL)
+ if (ac == NULL) {
return NULL;
+ }
/* abort if rendering - we may get some race condition issues... */
- if (G.is_rendering)
+ if (G.is_rendering) {
return NULL;
+ }
/* apart from strictly keyframe-related contexts, this shouldn't even happen */
// XXX: nla and channel here may not be necessary...
@@ -255,9 +257,11 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
ANIMCONT_CHANNEL)) {
/* handling depends on the type of animation-context we've got */
if (ale) {
- /* NLA Control Curves occur on NLA strips, and shouldn't be subjected to this kind of mapping */
- if (ale->type != ANIMTYPE_NLACURVE)
+ /* NLA Control Curves occur on NLA strips,
+ * and shouldn't be subjected to this kind of mapping. */
+ if (ale->type != ANIMTYPE_NLACURVE) {
return ale->adt;
+ }
}
}
@@ -267,7 +271,8 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
/* ------------------- */
-/* helper function for ANIM_nla_mapping_apply_fcurve() -> "restore", i.e. mapping points back to action-time */
+/* Helper function for ANIM_nla_mapping_apply_fcurve() -> "restore",
+ * i.e. mapping points back to action-time. */
static short bezt_nlamapping_restore(KeyframeEditData *ked, BezTriple *bezt)
{
/* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */
@@ -321,10 +326,12 @@ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, boo
ked.i1 = (int)only_keys;
/* get editing callback */
- if (restore)
+ if (restore) {
map_cb = bezt_nlamapping_restore;
- else
+ }
+ else {
map_cb = bezt_nlamapping_apply;
+ }
/* apply to F-Curve */
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, map_cb, NULL);
@@ -353,15 +360,17 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
float factor = 1.0f, offset = 0.0f;
if (flag & ANIM_UNITCONV_RESTORE) {
- if (r_offset)
+ if (r_offset) {
*r_offset = fcu->prev_offset;
+ }
return 1.0f / fcu->prev_norm_factor;
}
if (flag & ANIM_UNITCONV_NORMALIZE_FREEZE) {
- if (r_offset)
+ if (r_offset) {
*r_offset = fcu->prev_offset;
+ }
if (fcu->prev_norm_factor == 0.0f) {
/* Happens when Auto Normalize was disabled before
* any curves were displayed.
@@ -372,8 +381,9 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
}
if (G.moving & G_TRANSFORM_FCURVES) {
- if (r_offset)
+ if (r_offset) {
*r_offset = fcu->prev_offset;
+ }
if (fcu->prev_norm_factor == 0.0f) {
/* Same as above. */
return 1.0f;
@@ -497,8 +507,9 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag
return normalization_factor_get(scene, fcu, flag, r_offset);
}
- if (r_offset)
+ if (r_offset) {
*r_offset = 0.0f;
+ }
/* sanity checks */
if (id && fcu && fcu->rna_path) {
@@ -512,10 +523,12 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag
if (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION) {
/* if the radians flag is not set, default to using degrees which need conversions */
if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) {
- if (flag & ANIM_UNITCONV_RESTORE)
+ if (flag & ANIM_UNITCONV_RESTORE) {
return DEG2RADF(1.0f); /* degrees to radians */
- else
+ }
+ else {
return RAD2DEGF(1.0f); /* radians to degrees */
+ }
}
}
@@ -575,8 +588,9 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev
}
else {
/* this changes the frame, so set the frame and we're done */
- if (++nextcount == U.view_frame_keyframes)
+ if (++nextcount == U.view_frame_keyframes) {
donenext = true;
+ }
}
cfranext = aknext->cfra;
}
@@ -591,8 +605,9 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev
}
else {
/* this changes the frame, so set the frame and we're done */
- if (++prevcount == U.view_frame_keyframes)
+ if (++prevcount == U.view_frame_keyframes) {
doneprev = true;
+ }
}
cfraprev = akprev->cfra;
}
@@ -603,15 +618,19 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev
/* any success? */
if (doneprev || donenext) {
- if (doneprev)
+ if (doneprev) {
*prevfra = cfraprev;
- else
+ }
+ else {
*prevfra = CFRA - (cfranext - CFRA);
+ }
- if (donenext)
+ if (donenext) {
*nextfra = cfranext;
- else
+ }
+ else {
*nextfra = CFRA + (CFRA - cfraprev);
+ }
return true;
}
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 57ea5ad81f5..b94d0e3ada7 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -114,9 +114,10 @@ static void animedit_get_yscale_factor(bAnimContext *ac)
ac->yscale_fac = btheme->space_action.keyframe_scale_fac;
/* clamp to avoid problems with uninitialised values... */
- if (ac->yscale_fac < 0.1f)
+ if (ac->yscale_fac < 0.1f) {
ac->yscale_fac = 1.0f;
- //printf("yscale_fac = %f\n", ac->yscale_fac);
+ }
+ // printf("yscale_fac = %f\n", ac->yscale_fac);
}
/* ----------- Private Stuff - Action Editor ------------- */
@@ -130,18 +131,20 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
Key *key;
ob = OBACT(view_layer);
- if (ob == NULL)
+ if (ob == NULL) {
return NULL;
+ }
/* XXX pinning is not available in 'ShapeKey' mode... */
- //if (saction->pin) return NULL;
+ // if (saction->pin) return NULL;
/* shapekey data is stored with geometry data */
key = BKE_key_from_object(ob);
if (key) {
- if (key->type == KEY_RELATIVE)
+ if (key->type == KEY_RELATIVE) {
return key;
+ }
}
return NULL;
@@ -158,10 +161,12 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
case SACTCONT_ACTION: /* 'Action Editor' */
/* if not pinned, sync with active object */
if (/*saction->pin == 0*/ true) {
- if (ac->obact && ac->obact->adt)
+ if (ac->obact && ac->obact->adt) {
saction->action = ac->obact->adt->action;
- else
+ }
+ else {
saction->action = NULL;
+ }
}
ac->datatype = ANIMCONT_ACTION;
@@ -178,10 +183,12 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
if (/*saction->pin == 0*/ true) {
Key *key = (Key *)ac->data;
- if (key && key->adt)
+ if (key && key->adt) {
saction->action = key->adt->action;
- else
+ }
+ else {
saction->action = NULL;
+ }
}
ac->mode = saction->mode;
@@ -211,7 +218,7 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
{
/* TODO, other methods to get the mask */
// Sequence *seq = BKE_sequencer_active_get(ac->scene);
- //MovieClip *clip = ac->scene->clip;
+ // MovieClip *clip = ac->scene->clip;
// struct Mask *mask = seq ? seq->mask : NULL;
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
@@ -239,16 +246,19 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
saction->ads.source = (ID *)ac->scene;
/* sync scene's "selected keys only" flag with our "only selected" flag
+ *
* XXX: This is a workaround for T55525. We shouldn't really be syncing the flags like this,
- * but it's a simpler fix for now than also figuring out how the next/prev keyframe tools
- * should work in the 3D View if we allowed full access to the timeline's dopesheet filters
- * (i.e. we'd have to figure out where to host those settings, to be on a scene level like
- * this flag currently is, along with several other unknowns)
+ * but it's a simpler fix for now than also figuring out how the next/prev keyframe
+ * tools should work in the 3D View if we allowed full access to the timeline's
+ * dopesheet filters (i.e. we'd have to figure out where to host those settings,
+ * to be on a scene level like this flag currently is, along with several other unknowns).
*/
- if (ac->scene->flag & SCE_KEYS_NO_SELONLY)
+ if (ac->scene->flag & SCE_KEYS_NO_SELONLY) {
saction->ads.filterflag &= ~ADS_FILTER_ONLYSEL;
- else
+ }
+ else {
saction->ads.filterflag |= ADS_FILTER_ONLYSEL;
+ }
ac->datatype = ANIMCONT_TIMELINE;
ac->data = &saction->ads;
@@ -278,10 +288,12 @@ static bool graphedit_get_context(bAnimContext *ac, SpaceGraph *sipo)
ac->ads = sipo->ads;
/* set settings for Graph Editor - "Selected = Editable" */
- if (sipo->flag & SIPO_SELCUVERTSONLY)
+ if (sipo->flag & SIPO_SELCUVERTSONLY) {
sipo->ads->filterflag |= ADS_FILTER_SELEDIT;
- else
+ }
+ else {
sipo->ads->filterflag &= ~ADS_FILTER_SELEDIT;
+ }
/* sync settings with current view status, then return appropriate data */
switch (sipo->mode) {
@@ -322,8 +334,9 @@ static bool graphedit_get_context(bAnimContext *ac, SpaceGraph *sipo)
static bool nlaedit_get_context(bAnimContext *ac, SpaceNla *snla)
{
/* init dopesheet data if non-existent (i.e. for old files) */
- if (snla->ads == NULL)
+ if (snla->ads == NULL) {
snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
+ }
ac->ads = snla->ads;
/* sync settings with current view status, then return appropriate data */
@@ -339,7 +352,8 @@ static bool nlaedit_get_context(bAnimContext *ac, SpaceNla *snla)
/* ----------- Public API --------------- */
-/* Obtain current anim-data context, given that context info from Blender context has already been set
+/* Obtain current anim-data context,
+ * given that context info from Blender context has already been set:
* - AnimContext to write to is provided as pointer to var on stack so that we don't have
* allocation/freeing costs (which are not that avoidable with channels).
*/
@@ -387,8 +401,9 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
Scene *scene = CTX_data_scene(C);
/* clear old context info */
- if (ac == NULL)
+ if (ac == NULL) {
return false;
+ }
memset(ac, 0, sizeof(bAnimContext));
/* get useful default context settings from context */
@@ -410,7 +425,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
animedit_get_yscale_factor(ac);
/* get data context info */
- // XXX: if the below fails, try to grab this info from context instead... (to allow for scripting)
+ /* XXX: if the below fails, try to grab this info from context instead...
+ * (to allow for scripting). */
return ANIM_animdata_context_getdata(ac);
}
@@ -467,20 +483,25 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
/* quick macro to test if AnimData is usable for NLA */
#define ANIMDATA_HAS_NLA(id) ((id)->adt && (id)->adt->nla_tracks.first)
-/* Quick macro to test for all three above usability tests, performing the appropriate provided
+/**
+ * Quick macro to test for all three above usability tests, performing the appropriate provided
* action for each when the AnimData context is appropriate.
*
- * Priority order for this goes (most important, to least): AnimData blocks, NLA, Drivers, Keyframes.
+ * Priority order for this goes (most important, to least):
+ * AnimData blocks, NLA, Drivers, Keyframes.
+ *
+ * For this to work correctly,
+ * a standard set of data needs to be available within the scope that this
*
- * For this to work correctly, a standard set of data needs to be available within the scope that this
- * gets called in:
+ * Gets called in:
* - ListBase anim_data;
* - bDopeSheet *ads;
* - bAnimListElem *ale;
* - size_t items;
*
* - id: ID block which should have an AnimData pointer following it immediately, to use
- * - adtOk: line or block of code to execute for AnimData-blocks case (usually ANIMDATA_ADD_ANIMDATA)
+ * - adtOk: line or block of code to execute for AnimData-blocks case
+ * (usually #ANIMDATA_ADD_ANIMDATA).
* - nlaOk: line or block of code to execute for NLA tracks+strips case
* - driversOk: line or block of code to execute for Drivers case
* - nlaKeysOk: line or block of code for NLA Strip Keyframes case
@@ -563,7 +584,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
#define ANIMCHANNEL_ACTIVEOK(ale) \
(!(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE))
-/* quick macro to test if an anim-channel (F-Curve, Group, etc.) is selected in an acceptable way */
+/* Quick macro to test if an anim-channel (F-Curve, Group, etc.)
+ * is selected in an acceptable way. */
#define ANIMCHANNEL_SELOK(test_func) \
(!(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) || \
((filter_mode & ANIMFILTER_SEL) && test_func) || \
@@ -986,27 +1008,32 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
/* check whether to continue or skip */
if ((pchan) && (pchan->bone)) {
- /* if only visible channels, skip if bone not visible unless user wants channels from hidden data too */
+ /* If only visible channels,
+ * skip if bone not visible unless user wants channels from hidden data too. */
if (skip_hidden) {
bArmature *arm = (bArmature *)ob->data;
/* skipping - not visible on currently visible layers */
- if ((arm->layer & pchan->bone->layer) == 0)
+ if ((arm->layer & pchan->bone->layer) == 0) {
return true;
+ }
/* skipping - is currently hidden */
- if (pchan->bone->flag & BONE_HIDDEN_P)
+ if (pchan->bone->flag & BONE_HIDDEN_P) {
return true;
+ }
}
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((pchan->bone->flag & BONE_SELECTED) == 0)
+ if ((pchan->bone->flag & BONE_SELECTED) == 0) {
return true;
+ }
}
}
}
@@ -1024,14 +1051,16 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
/* get strip name, and check if this strip is selected */
seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
- if (seq_name)
+ if (seq_name) {
MEM_freeN(seq_name);
+ }
}
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((seq == NULL) || (seq->flag & SELECT) == 0)
+ if ((seq == NULL) || (seq->flag & SELECT) == 0) {
return true;
+ }
}
}
}
@@ -1046,13 +1075,15 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
/* get strip name, and check if this strip is selected */
node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
node = nodeFindNodebyName(ntree, node_name);
- if (node_name)
+ if (node_name) {
MEM_freeN(node_name);
+ }
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((node) && (node->flag & NODE_SELECT) == 0)
+ if ((node) && (node->flag & NODE_SELECT) == 0) {
return true;
+ }
}
}
}
@@ -1144,15 +1175,17 @@ static bool fcurve_has_errors(FCurve *fcu)
* BUT this may not hold with PyDrivers as this flag gets cleared
* if no critical errors prevent the driver from working...
*/
- if (driver->flag & DRIVER_FLAG_INVALID)
+ if (driver->flag & DRIVER_FLAG_INVALID) {
return true;
+ }
/* check variables for other things that need linting... */
// TODO: maybe it would be more efficient just to have a quick flag for this?
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
- if (dtar->flag & DTAR_FLAG_INVALID)
+ if (dtar->flag & DTAR_FLAG_INVALID) {
return true;
+ }
}
DRIVER_TARGETS_LOOPER_END;
}
@@ -1173,24 +1206,28 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
bActionGroup *grp = (channel_type == ANIMTYPE_FCURVE) ? owner : NULL;
FCurve *fcu = NULL;
- /* loop over F-Curves - assume that the caller of this has already checked that these should be included
- * NOTE: we need to check if the F-Curves belong to the same group, as this gets called for groups too...
+ /* Loop over F-Curves - assume that the caller of this has already checked
+ * that these should be included.
+ * NOTE: we need to check if the F-Curves belong to the same group,
+ * as this gets called for groups too...
*/
for (fcu = first; ((fcu) && (fcu->grp == grp)); fcu = fcu->next) {
/* special exception for Pose-Channel/Sequence-Strip/Node Based F-Curves:
- * - the 'Only Selected' and 'Include Hidden' data filters should be applied to sub-ID data which
- * can be independently selected/hidden, such as Pose-Channels, Sequence Strips, and Nodes.
- * Since these checks were traditionally done as first check for objects, we do the same here
- * - we currently use an 'approximate' method for getting these F-Curves that doesn't require
- * carefully checking the entire path
- * - this will also affect things like Drivers, and also works for Bone Constraints
+ * - The 'Only Selected' and 'Include Hidden' data filters should be applied to sub-ID data
+ * which can be independently selected/hidden, such as Pose-Channels, Sequence Strips,
+ * and Nodes. Since these checks were traditionally done as first check for objects,
+ * we do the same here.
+ * - We currently use an 'approximate' method for getting these F-Curves that doesn't require
+ * carefully checking the entire path.
+ * - This will also affect things like Drivers, and also works for Bone Constraints.
*/
if (ads && owner_id) {
if ((filter_mode & ANIMFILTER_TMP_IGNORE_ONLYSEL) == 0) {
if ((ads->filterflag & ADS_FILTER_ONLYSEL) ||
(ads->filterflag & ADS_FILTER_INCL_HIDDEN) == 0) {
- if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode))
+ if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode)) {
continue;
+ }
}
}
}
@@ -1199,21 +1236,24 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || (fcu->flag & FCURVE_VISIBLE)) {
/* only work with this channel and its subchannels if it is editable */
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_FCU(fcu)) {
- /* only include this curve if selected in a way consistent with the filtering requirements */
+ /* Only include this curve if selected in a way consistent
+ * with the filtering requirements. */
if (ANIMCHANNEL_SELOK(SEL_FCU(fcu)) && ANIMCHANNEL_SELEDITOK(SEL_FCU(fcu))) {
/* only include if this curve is active */
if (!(filter_mode & ANIMFILTER_ACTIVE) || (fcu->flag & FCURVE_ACTIVE)) {
/* name based filtering... */
if (((ads) && (ads->searchstr[0] != '\0')) && (owner_id)) {
- if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id))
+ if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id)) {
continue;
+ }
}
/* error-based filtering... */
if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) {
/* skip if no errors... */
- if (fcurve_has_errors(fcu) == false)
+ if (fcurve_has_errors(fcu) == false) {
continue;
+ }
}
/* this F-Curve can be used, so return it */
@@ -1240,14 +1280,17 @@ static size_t animfilter_fcurves(ListBase *anim_data,
FCurve *fcu;
size_t items = 0;
- /* loop over every F-Curve able to be included
- * - this for-loop works like this:
- * 1) the starting F-Curve is assigned to the fcu pointer so that we have a starting point to search from
- * 2) the first valid F-Curve to start from (which may include the one given as 'first') in the remaining
- * list of F-Curves is found, and verified to be non-null
- * 3) the F-Curve referenced by fcu pointer is added to the list
- * 4) the fcu pointer is set to the F-Curve after the one we just added, so that we can keep going through
- * the rest of the F-Curve list without an eternal loop. Back to step 2 :)
+ /* Loop over every F-Curve able to be included.
+ *
+ * This for-loop works like this:
+ * 1) The starting F-Curve is assigned to the fcu pointer
+ * so that we have a starting point to search from.
+ * 2) The first valid F-Curve to start from (which may include the one given as 'first')
+ * in the remaining list of F-Curves is found, and verified to be non-null.
+ * 3) The F-Curve referenced by fcu pointer is added to the list
+ * 4) The fcu pointer is set to the F-Curve after the one we just added,
+ * so that we can keep going through the rest of the F-Curve list without an eternal loop.
+ * Back to step 2 :)
*/
for (fcu = first;
((fcu = animfilter_fcurve_next(ads, fcu, fcurve_type, filter_mode, owner, owner_id)));
@@ -1281,7 +1324,7 @@ static size_t animfilter_act_group(bAnimContext *ac,
ListBase tmp_data = {NULL, NULL};
size_t tmp_items = 0;
size_t items = 0;
- //int ofilter = filter_mode;
+ // int ofilter = filter_mode;
/* if we care about the selection status of the channels,
* but the group isn't expanded (1)...
@@ -1290,28 +1333,30 @@ static size_t animfilter_act_group(bAnimContext *ac,
* - Hierarchy ignored: cases like [#21276] won't work properly, unless we skip this hack
*/
if (
- /* care about hierarchy but group isn't expanded */
+ /* Care about hierarchy but group isn't expanded. */
((filter_mode & ANIMFILTER_LIST_VISIBLE) && EXPANDED_AGRP(ac, agrp) == 0) &&
- /* care about selection status */
+ /* Care about selection status. */
(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL))) {
- /* if the group itself isn't selected appropriately, we shouldn't consider it's children either */
- if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0)
+ /* If the group itself isn't selected appropriately,
+ * we shouldn't consider it's children either. */
+ if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0) {
return 0;
+ }
- /* if we're still here, then the selection status of the curves within this group should not matter,
- * since this creates too much overhead for animators (i.e. making a slow workflow)
+ /* if we're still here,
+ * then the selection status of the curves within this group should not matter,
+ * since this creates too much overhead for animators (i.e. making a slow workflow).
*
* Tools affected by this at time of coding (2010 Feb 09):
- * - inserting keyframes on selected channels only
- * - pasting keyframes
- * - creating ghost curves in Graph Editor
+ * - Inserting keyframes on selected channels only.
+ * - Pasting keyframes.
+ * - Creating ghost curves in Graph Editor.
*/
filter_mode &= ~(ANIMFILTER_SEL | ANIMFILTER_UNSEL | ANIMFILTER_LIST_VISIBLE);
}
/* add grouped F-Curves */
- BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_AGRP(ac, agrp))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_AGRP(ac, agrp)) {
/* special filter so that we can get just the F-Curves within the active group */
if (!(filter_mode & ANIMFILTER_ACTGROUPED) || (agrp->flag & AGRP_ACTIVE)) {
/* for the Graph Editor, curves may be set to not be visible in the view to lessen
@@ -1339,12 +1384,12 @@ static size_t animfilter_act_group(bAnimContext *ac,
/* add this group as a channel first */
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
/* restore original filter mode so that this next step works ok... */
- //filter_mode = ofilter;
+ // filter_mode = ofilter;
/* filter selection of channel specially here again,
* since may be open and not subject to previous test */
if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp))) {
- ANIMCHANNEL_NEW_CHANNEL(agrp, ANIMTYPE_GROUP, owner_id, NULL);
+ ANIMCHANNEL_NEW_CHANNEL(agrp, ANIMTYPE_GROUP, owner_id, &act->id);
}
}
@@ -1372,15 +1417,17 @@ static size_t animfilter_action(bAnimContext *ac,
/* don't include anything from this action if it is linked in from another file,
* and we're getting stuff for editing...
*/
- if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED(act))
+ if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED(act)) {
return 0;
+ }
/* do groups */
// TODO: do nested groups?
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
/* store reference to last channel of group */
- if (agrp->channels.last)
+ if (agrp->channels.last) {
lastchan = agrp->channels.last;
+ }
/* action group's channels */
items += animfilter_act_group(ac, anim_data, ads, act, agrp, filter_mode, owner_id);
@@ -1398,12 +1445,13 @@ static size_t animfilter_action(bAnimContext *ac,
}
/* Include NLA-Data for NLA-Editor:
- * - when ANIMFILTER_LIST_CHANNELS is used, that means we should be filtering the list for display
- * Although the evaluation order is from the first track to the last and then apply the Action on top,
- * we present this in the UI as the Active Action followed by the last track to the first so that we
- * get the evaluation order presented as per a stack.
- * - for normal filtering (i.e. for editing), we only need the NLA-tracks but they can be in 'normal' evaluation
- * order, i.e. first to last. Otherwise, some tools may get screwed up.
+ * - When ANIMFILTER_LIST_CHANNELS is used, that means we should be filtering the list for display
+ * Although the evaluation order is from the first track to the last and then apply the
+ * Action on top, we present this in the UI as the Active Action followed by the last track
+ * to the first so that we get the evaluation order presented as per a stack.
+ * - For normal filtering (i.e. for editing),
+ * we only need the NLA-tracks but they can be in 'normal' evaluation order, i.e. first to last.
+ * Otherwise, some tools may get screwed up.
*/
static size_t animfilter_nla(bAnimContext *UNUSED(ac),
ListBase *anim_data,
@@ -1424,9 +1472,10 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac),
if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) || (adt->action)) {
/* there isn't really anything editable here, so skip if need editable */
if ((filter_mode & ANIMFILTER_FOREDIT) == 0) {
- /* just add the action track now (this MUST appear for drawing)
- * - as AnimData may not have an action, we pass a dummy pointer just to get the list elem created, then
- * overwrite this with the real value - REVIEW THIS...
+ /* Just add the action track now (this MUST appear for drawing):
+ * - As AnimData may not have an action,
+ * we pass a dummy pointer just to get the list elem created,
+ * then overwrite this with the real value - REVIEW THIS.
*/
ANIMCHANNEL_NEW_CHANNEL_FULL((void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id, NULL, {
ale->data = adt->action ? adt->action : NULL;
@@ -1442,21 +1491,27 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac),
first = adt->nla_tracks.first;
}
- /* loop over NLA Tracks - assume that the caller of this has already checked that these should be included */
+ /* loop over NLA Tracks -
+ * assume that the caller of this has already checked that these should be included */
for (nlt = first; nlt; nlt = next) {
/* 'next' NLA-Track to use depends on whether we're filtering for drawing or not */
- if (filter_mode & ANIMFILTER_LIST_CHANNELS)
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
next = nlt->prev;
- else
+ }
+ else {
next = nlt->next;
+ }
- /* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now
+ /* if we're in NLA-tweakmode, don't show this track if it was disabled
+ * (due to tweaking) for now:
* - active track should still get shown though (even though it has disabled flag set)
*/
- // FIXME: the channels after should still get drawn, just 'differently', and after an active-action channel
+ // FIXME: the channels after should still get drawn, just 'differently',
+ // and after an active-action channel.
if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED) &&
- (adt->act_track != nlt))
+ (adt->act_track != nlt)) {
continue;
+ }
/* only work with this channel and its subchannels if it is editable */
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) {
@@ -1510,15 +1565,15 @@ static size_t animfilter_nla_controls(
/* add control curves from each NLA strip... */
/* NOTE: ANIMTYPE_FCURVES are created here, to avoid duplicating the code needed */
- BEGIN_ANIMFILTER_SUBCHANNELS(((adt->flag & ADT_NLA_SKEYS_COLLAPSED) == 0))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (((adt->flag & ADT_NLA_SKEYS_COLLAPSED) == 0)) {
NlaTrack *nlt;
NlaStrip *strip;
/* for now, we only go one level deep - so controls on grouped FCurves are not handled */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
- /* pass strip as the "owner", so that the name lookups (used while filtering) will resolve */
+ /* pass strip as the "owner",
+ * so that the name lookups (used while filtering) will resolve */
/* NLA tracks are coming from AnimData, so owner of f-curves
* is the same as owner of animation data. */
tmp_items += animfilter_fcurves(&tmp_data,
@@ -1565,8 +1620,9 @@ static size_t animfilter_block_data(
if (adt) {
IdAdtTemplate *iat = (IdAdtTemplate *)id;
- /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed
- * in a few places in the rest of the code still - notably for the few cases where special mode-based
+ /* NOTE: this macro is used instead of inlining the logic here,
+ * since this sort of filtering is still needed in a few places in the rest of the code still -
+ * notably for the few cases where special mode-based
* different types of data expanders are required.
*/
ANIMDATA_FILTER_CASES(
@@ -1610,12 +1666,14 @@ static size_t animdata_filter_shapekey(bAnimContext *ac,
/* loop through the channels adding ShapeKeys as appropriate */
for (kb = key->block.first; kb; kb = kb->next) {
/* skip the first one, since that's the non-animatable basis */
- if (kb == key->block.first)
+ if (kb == key->block.first) {
continue;
+ }
/* only work with this channel and its subchannels if it is editable */
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_SHAPEKEY(kb)) {
- /* only include this track if selected in a way consistent with the filtering requirements */
+ /* Only include this track if selected in a way consistent
+ * with the filtering requirements. */
if (ANIMCHANNEL_SELOK(SEL_SHAPEKEY(kb))) {
// TODO: consider 'active' too?
@@ -1663,8 +1721,9 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data,
if (!(filter_mode & ANIMFILTER_ACTIVE) || (gpl->flag & GP_LAYER_ACTIVE)) {
/* skip layer if the name doesn't match the filter string */
if ((ads) && (ads->searchstr[0] != '\0')) {
- if (name_matches_dopesheet_filter(ads, gpl->info) == false)
+ if (name_matches_dopesheet_filter(ads, gpl->info) == false) {
continue;
+ }
}
/* add to list */
ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd, NULL);
@@ -1697,8 +1756,7 @@ static size_t animdata_filter_gpencil_data(ListBase *anim_data,
size_t tmp_items = 0;
/* add gpencil animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_GPD(gpd)) {
tmp_items += animdata_filter_gpencil_layers_data(&tmp_data, ads, gpd, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
@@ -1758,13 +1816,16 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
*/
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) &&
!(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
- /* layer visibility - we check both object and base, since these may not be in sync yet */
- if ((base->flag & BASE_VISIBLE) == 0)
+ /* Layer visibility - we check both object and base,
+ * since these may not be in sync yet. */
+ if ((base->flag & BASE_VISIBLE) == 0) {
continue;
+ }
/* outliner restrict-flag */
- if (ob->restrictflag & OB_RESTRICT_VIEW)
+ if (ob->restrictflag & OB_RESTRICT_VIEW) {
continue;
+ }
}
/* check selection and object type filters */
@@ -1779,8 +1840,9 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
* - used to ease the process of doing multiple-character choreographies
*/
if (ads->filter_grp != NULL) {
- if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0)
+ if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) {
continue;
+ }
}
/* finally, include this object's grease pencil datablock */
@@ -1796,8 +1858,9 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
* but only those that seem to be useful somewhere */
for (gpd = ac->bmain->gpencils.first; gpd; gpd = gpd->id.next) {
/* only show if gpd is used by something... */
- if (ID_REAL_USERS(gpd) < 1)
+ if (ID_REAL_USERS(gpd) < 1) {
continue;
+ }
/* add GP frames from this datablock */
items += animdata_filter_gpencil_data(anim_data, ads, gpd, filter_mode);
@@ -1817,8 +1880,7 @@ static size_t animdata_filter_ds_gpencil(
size_t items = 0;
/* add relevant animation channels for Grease Pencil */
- BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_GPD(gpd)) {
/* add animation channels */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, &gpd->id, filter_mode);
@@ -1858,8 +1920,7 @@ static size_t animdata_filter_ds_cachefile(
size_t items = 0;
/* add relevant animation channels for Cache File */
- BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_CACHEFILE_OBJD(cache_file))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_CACHEFILE_OBJD(cache_file)) {
/* add animation channels */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, &cache_file->id, filter_mode);
}
@@ -1927,12 +1988,12 @@ static size_t animdata_filter_mask(Main *bmain,
size_t tmp_items = 0;
/* only show if mask is used by something... */
- if (ID_REAL_USERS(mask) < 1)
+ if (ID_REAL_USERS(mask) < 1) {
continue;
+ }
/* add mask animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_MASK(mask))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_MASK(mask)) {
tmp_items += animdata_filter_mask_data(&tmp_data, mask, filter_mode);
}
END_ANIMFILTER_SUBCHANNELS;
@@ -1956,7 +2017,8 @@ static size_t animdata_filter_mask(Main *bmain,
return items;
}
-/* NOTE: owner_id is scene, material, or texture block, which is the direct owner of the node tree in question */
+/* NOTE: owner_id is scene, material, or texture block,
+ * which is the direct owner of the node tree in question. */
static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac,
ListBase *anim_data,
bDopeSheet *ads,
@@ -1969,8 +2031,7 @@ static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac,
size_t items = 0;
/* add nodetree animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_NTREE_DATA(ntree))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_NTREE_DATA(ntree)) {
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ntree, filter_mode);
}
@@ -2061,8 +2122,7 @@ static size_t animdata_filter_ds_linestyle(
linestyle->id.tag &= ~LIB_TAG_DOIT;
/* add scene-level animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_LS_SCED(linestyle))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_LS_SCED(linestyle)) {
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)linestyle, filter_mode);
}
@@ -2102,16 +2162,16 @@ static size_t animdata_filter_ds_texture(bAnimContext *ac,
size_t items = 0;
/* add texture's animation data to temp collection */
- BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_TEX_DATA(tex))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_TEX_DATA(tex)) {
/* texture animdata */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)tex, filter_mode);
/* nodes */
if ((tex->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
- /* owner_id as id instead of texture, since it'll otherwise be impossible to track the depth */
- // FIXME: perhaps as a result, textures should NOT be included under materials, but under their own section instead
- // so that free-floating textures can also be animated
+ /* owner_id as id instead of texture,
+ * since it'll otherwise be impossible to track the depth. */
+ // FIXME: perhaps as a result, textures should NOT be included under materials,
+ // but under their own section instead so that free-floating textures can also be animated.
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, (ID *)tex, tex->nodetree, filter_mode);
}
@@ -2149,8 +2209,9 @@ static size_t animdata_filter_ds_textures(
int a = 0;
/* get datatype specific data first */
- if (owner_id == NULL)
+ if (owner_id == NULL) {
return 0;
+ }
switch (GS(owner_id->name)) {
case ID_PA: {
@@ -2160,20 +2221,23 @@ static size_t animdata_filter_ds_textures(
}
default: {
/* invalid/unsupported option */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("ERROR: Unsupported owner_id (i.e. texture stack) for filter textures - %s\n",
owner_id->name);
+ }
return 0;
}
}
- /* firstly check that we actuallly have some textures, by gathering all textures in a temp list */
+ /* Firstly check that we actuallly have some textures,
+ * by gathering all textures in a temp list. */
for (a = 0; a < MAX_MTEX; a++) {
Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL;
/* for now, if no texture returned, skip (this shouldn't confuse the user I hope) */
- if (tex == NULL)
+ if (tex == NULL) {
continue;
+ }
/* add texture's anim channels */
items += animdata_filter_ds_texture(ac, anim_data, ads, tex, owner_id, filter_mode);
@@ -2191,15 +2255,15 @@ static size_t animdata_filter_ds_material(
size_t items = 0;
/* add material's animation data to temp collection */
- BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_MAT_OBJD(ma))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_MAT_OBJD(ma)) {
/* material's animation data */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode);
/* nodes */
- if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode);
+ }
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2229,7 +2293,7 @@ static size_t animdata_filter_ds_materials(
size_t items = 0;
int a = 0;
- /* first pass: take the materials referenced via the Material slots of the object */
+ /* First pass: take the materials referenced via the Material slots of the object. */
for (a = 1; a <= ob->totcol; a++) {
Material *ma = give_current_material(ob, a);
@@ -2245,10 +2309,12 @@ static size_t animdata_filter_ds_materials(
}
}
- /* second pass: go through a second time looking for "nested" materials (material.material references)
+ /* Second pass: go through a second time looking for "nested" materials
+ * (material.material references).
*
- * NOTE: here we ignore the expanded status of the parent, as it could be too confusing as to why these are
- * disappearing/not available, since the relationships between these is not that clear
+ * NOTE: here we ignore the expanded status of the parent, as it could be too confusing as to
+ * why these are disappearing/not available,
+ * since the relationships between these is not that clear.
*/
if (has_nested) {
for (a = 1; a <= ob->totcol; a++) {
@@ -2296,8 +2362,9 @@ static void animfilter_modifier_idpoin_cb(void *afm_ptr,
/* NOTE: the walker only guarantees to give us all the ID-ptr *slots*,
* not just the ones which are actually used, so be careful!
*/
- if (id == NULL)
+ if (id == NULL) {
return;
+ }
/* check if this is something we're interested in... */
switch (GS(id->name)) {
@@ -2333,7 +2400,8 @@ static size_t animdata_filter_ds_modifiers(
/* 1) create a temporary "context" containing all the info we have here to pass to the callback
* use to walk through the dependencies of the modifiers
*
- * ! Assumes that all other unspecified values (i.e. accumulation buffers) are zero'd out properly
+ * Assumes that all other unspecified values (i.e. accumulation buffers)
+ * are zero'd out properly!
*/
afm.ac = ac;
afm.ads = ads;
@@ -2366,19 +2434,20 @@ static size_t animdata_filter_ds_particles(
size_t tmp_items = 0;
/* if no material returned, skip - so that we don't get weird blank entries... */
- if (ELEM(NULL, psys->part, psys->part->adt))
+ if (ELEM(NULL, psys->part, psys->part->adt)) {
continue;
+ }
/* add particle-system's animation data to temp collection */
- BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_PART_OBJD(psys->part))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_PART_OBJD(psys->part)) {
/* particle system's animation data */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)psys->part, filter_mode);
/* textures */
- if (!(ads->filterflag & ADS_FILTER_NOTEX))
+ if (!(ads->filterflag & ADS_FILTER_NOTEX)) {
tmp_items += animdata_filter_ds_textures(
ac, &tmp_data, ads, (ID *)psys->part, filter_mode);
+ }
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2419,8 +2488,9 @@ static size_t animdata_filter_ds_obdata(
{
Camera *ca = (Camera *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOCAM)
+ if (ads->filterflag & ADS_FILTER_NOCAM) {
return 0;
+ }
type = ANIMTYPE_DSCAM;
expanded = FILTER_CAM_OBJD(ca);
@@ -2430,8 +2500,9 @@ static size_t animdata_filter_ds_obdata(
{
Light *la = (Light *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOLAM)
+ if (ads->filterflag & ADS_FILTER_NOLAM) {
return 0;
+ }
type = ANIMTYPE_DSLAM;
expanded = FILTER_LAM_OBJD(la);
@@ -2443,8 +2514,9 @@ static size_t animdata_filter_ds_obdata(
{
Curve *cu = (Curve *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOCUR)
+ if (ads->filterflag & ADS_FILTER_NOCUR) {
return 0;
+ }
type = ANIMTYPE_DSCUR;
expanded = FILTER_CUR_OBJD(cu);
@@ -2454,8 +2526,9 @@ static size_t animdata_filter_ds_obdata(
{
MetaBall *mb = (MetaBall *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOMBA)
+ if (ads->filterflag & ADS_FILTER_NOMBA) {
return 0;
+ }
type = ANIMTYPE_DSMBALL;
expanded = FILTER_MBALL_OBJD(mb);
@@ -2465,8 +2538,9 @@ static size_t animdata_filter_ds_obdata(
{
bArmature *arm = (bArmature *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOARM)
+ if (ads->filterflag & ADS_FILTER_NOARM) {
return 0;
+ }
type = ANIMTYPE_DSARM;
expanded = FILTER_ARM_OBJD(arm);
@@ -2476,8 +2550,9 @@ static size_t animdata_filter_ds_obdata(
{
Mesh *me = (Mesh *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOMESH)
+ if (ads->filterflag & ADS_FILTER_NOMESH) {
return 0;
+ }
type = ANIMTYPE_DSMESH;
expanded = FILTER_MESH_OBJD(me);
@@ -2487,8 +2562,9 @@ static size_t animdata_filter_ds_obdata(
{
Lattice *lt = (Lattice *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOLAT)
+ if (ads->filterflag & ADS_FILTER_NOLAT) {
return 0;
+ }
type = ANIMTYPE_DSLAT;
expanded = FILTER_LATTICE_OBJD(lt);
@@ -2505,8 +2581,7 @@ static size_t animdata_filter_ds_obdata(
}
/* add object data animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (expanded) {
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)iat, filter_mode);
@@ -2518,9 +2593,10 @@ static size_t animdata_filter_ds_obdata(
bNodeTree *ntree = la->nodetree;
/* nodetree */
- if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, &la->id, ntree, filter_mode);
+ }
break;
}
}
@@ -2556,8 +2632,7 @@ static size_t animdata_filter_ds_keyanim(
size_t items = 0;
/* add shapekey-level animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_SKE_OBJD(key))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_SKE_OBJD(key)) {
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)key, filter_mode);
}
@@ -2597,7 +2672,7 @@ static size_t animdata_filter_ds_obanim(
/* determine the type of expander channels to use */
/* this is the best way to do this for now... */
ANIMDATA_FILTER_CASES(
- ob,
+ ob, /* Some useless long comment to prevent wrapping by old clang-format versions... */
{/* AnimData - no channel, but consider data */},
{/* NLA - no channel, but consider data */},
{ /* Drivers */
@@ -2613,8 +2688,7 @@ static size_t animdata_filter_ds_obanim(
});
/* add object-level animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (expanded) {
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ob, filter_mode);
}
@@ -2650,8 +2724,7 @@ static size_t animdata_filter_dopesheet_ob(
size_t items = 0;
/* filter data contained under object first */
- BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_OBJC(ob)) {
Key *key = BKE_key_from_object(ob);
/* object-level animation */
@@ -2696,7 +2769,8 @@ static size_t animdata_filter_dopesheet_ob(
/* firstly add object expander if required */
if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
/* check if filtering by selection */
- // XXX: double-check on this - most of the time, a lot of tools need to filter out these channels!
+ /* XXX: double-check on this -
+ * most of the time, a lot of tools need to filter out these channels! */
if (ANIMCHANNEL_SELOK((base->flag & BASE_SELECTED))) {
/* check if filtering by active status */
if (ANIMCHANNEL_ACTIVEOK(ob)) {
@@ -2723,15 +2797,15 @@ static size_t animdata_filter_ds_world(
size_t items = 0;
/* add world animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_WOR_SCED(wo))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_WOR_SCED(wo)) {
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)wo, filter_mode);
/* nodes */
- if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, (ID *)wo, wo->nodetree, filter_mode);
+ }
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2769,7 +2843,7 @@ static size_t animdata_filter_ds_scene(
/* determine the type of expander channels to use */
// this is the best way to do this for now...
ANIMDATA_FILTER_CASES(
- sce,
+ sce, /* Some useless long comment to prevent wrapping by old clang-format versions... */
{/* AnimData - no channel, but consider data */},
{/* NLA - no channel, but consider data */},
{ /* Drivers */
@@ -2785,8 +2859,7 @@ static size_t animdata_filter_ds_scene(
});
/* add scene-level animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(expanded)
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (expanded) {
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)sce, filter_mode);
}
@@ -2820,8 +2893,7 @@ static size_t animdata_filter_dopesheet_scene(
size_t items = 0;
/* filter data contained under object first */
- BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_SCEC(sce))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_SCEC(sce)) {
bNodeTree *ntree = sce->nodetree;
bGPdata *gpd = sce->gpd;
World *wo = sce->world;
@@ -2851,7 +2923,8 @@ static size_t animdata_filter_dopesheet_scene(
tmp_items += animdata_filter_ds_gpencil(ac, &tmp_data, ads, gpd, filter_mode);
}
- /* TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here */
+ /* TODO: one day, when sequencer becomes its own datatype,
+ * perhaps it should be included here. */
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2883,8 +2956,7 @@ static size_t animdata_filter_ds_movieclip(
size_t tmp_items = 0;
size_t items = 0;
/* add world animation channels */
- BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_MCLIP(clip))
- {
+ BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_MCLIP(clip)) {
/* animation data filtering */
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)clip, filter_mode);
}
@@ -2930,8 +3002,9 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
{
Object *ob = base->object;
- if (base->object == NULL)
+ if (base->object == NULL) {
return false;
+ }
/* firstly, check if object can be included, by the following factors:
* - if only visible, must check for layer and also viewport visibility
@@ -2944,20 +3017,23 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
*/
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
/* layer visibility - we check both object and base, since these may not be in sync yet */
- if ((base->flag & BASE_VISIBLE) == 0)
+ if ((base->flag & BASE_VISIBLE) == 0) {
return false;
+ }
/* outliner restrict-flag */
- if (ob->restrictflag & OB_RESTRICT_VIEW)
+ if (ob->restrictflag & OB_RESTRICT_VIEW) {
return false;
+ }
}
/* if only F-Curves with visible flags set can be shown, check that
* datablock hasn't been set to invisible
*/
if (filter_mode & ANIMFILTER_CURVE_VISIBLE) {
- if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE))
+ if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE)) {
return false;
+ }
}
/* Pinned curves are visible regardless of selection flags. */
@@ -2990,8 +3066,9 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
* - used to ease the process of doing multiple-character choreographies
*/
if (ads->filter_grp != NULL) {
- if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0)
+ if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) {
return false;
+ }
}
/* no reason to exclude this object... */
@@ -3032,7 +3109,9 @@ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads,
return sorted_bases;
}
-// TODO: implement pinning... (if and when pinning is done, what we need to do is to provide freeing mechanisms - to protect against data that was deleted)
+// TODO: implement pinning...
+// (if and when pinning is done, what we need to do is to provide freeing mechanisms -
+// to protect against data that was deleted).
static size_t animdata_filter_dopesheet(bAnimContext *ac,
ListBase *anim_data,
bDopeSheet *ads,
@@ -3045,10 +3124,11 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac,
/* check that we do indeed have a scene */
if ((ads->source == NULL) || (GS(ads->source->name) != ID_SCE)) {
printf("Dope Sheet Error: No scene!\n");
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tPointer = %p, Name = '%s'\n",
(void *)ads->source,
(ads->source) ? ads->source->name : NULL);
+ }
return 0;
}
@@ -3071,12 +3151,14 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac,
/* movie clip's animation */
items += animdata_filter_dopesheet_movieclips(ac, anim_data, ads, filter_mode);
- /* scene-linked animation - e.g. world, compositing nodes, scene anim (including sequencer currently) */
+ /* Scene-linked animation - e.g. world, compositing nodes, scene anim
+ * (including sequencer currently). */
items += animdata_filter_dopesheet_scene(ac, anim_data, ads, scene, filter_mode);
/* If filtering for channel drawing, we want the objects in alphabetical order,
* to make it easier to predict where items are in the hierarchy
- * - This order only really matters if we need to show all channels in the list (e.g. for drawing)
+ * - This order only really matters
+ * if we need to show all channels in the list (e.g. for drawing).
* (XXX: What about lingering "active" flags? The order may now become unpredictable)
* - Don't do this if this behavior has been turned off (i.e. due to it being too slow)
* - Don't do this if there's just a single object
@@ -3152,11 +3234,12 @@ static short animdata_filter_dopesheet_summary(bAnimContext *ac,
(*items)++;
}
- /* if summary is collapsed, don't show other channels beneath this
- * - this check is put inside the summary check so that it doesn't interfere with normal operation
+ /* If summary is collapsed, don't show other channels beneath this - this check is put inside
+ * the summary check so that it doesn't interfere with normal operation.
*/
- if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED)
+ if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED) {
return 0;
+ }
}
/* the other channels beneath this can be shown */
@@ -3218,10 +3301,12 @@ static size_t animdata_filter_remove_invalid(ListBase *anim_data)
for (ale = anim_data->first; ale; ale = next) {
next = ale->next;
- if (ale->type == ANIMTYPE_NONE)
+ if (ale->type == ANIMTYPE_NONE) {
BLI_freelinkN(anim_data, ale);
- else
+ }
+ else {
items++;
+ }
}
return items;
@@ -3245,7 +3330,8 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data)
/* check if hash has any record of an entry like this
* - just use ale->data for now, though it would be nicer to involve
- * ale->type in combination too to capture corner cases (where same data performs differently)
+ * ale->type in combination too to capture corner cases
+ * (where same data performs differently)
*/
if (BLI_gset_add(gs, ale->data)) {
/* this entry is 'unique' and can be kept */
@@ -3300,9 +3386,11 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
}
}
else {
- /* the check for the DopeSheet summary is included here since the summary works here too */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ /* The check for the DopeSheet summary is included here
+ * since the summary works here too. */
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact);
+ }
}
break;
@@ -3319,9 +3407,11 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
}
}
else {
- /* the check for the DopeSheet summary is included here since the summary works here too */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ /* The check for the DopeSheet summary is included here
+ * since the summary works here too. */
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items = animdata_filter_shapekey(ac, anim_data, key, filter_mode);
+ }
}
break;
@@ -3329,13 +3419,15 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
/* Modes for Specialty Data Types (i.e. not keyframes) */
case ANIMCONT_GPENCIL: {
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items = animdata_filter_gpencil(ac, anim_data, data, filter_mode);
+ }
break;
}
case ANIMCONT_MASK: {
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items = animdata_filter_mask(ac->bmain, anim_data, data, filter_mode);
+ }
break;
}
@@ -3343,8 +3435,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */
{
/* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
+ }
break;
}
case ANIMCONT_FCURVES: /* Graph Editor -> F-Curves/Animation Editing */
@@ -3357,11 +3450,13 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
break;
}
- /* Timeline Mode - Basically the same as dopesheet, except we only have the summary for now */
+ /* Timeline Mode - Basically the same as dopesheet,
+ * except we only have the summary for now */
case ANIMCONT_TIMELINE: {
/* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
+ }
break;
}
@@ -3386,8 +3481,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
items = animdata_filter_remove_invalid(anim_data);
/* remove duplicates (if required) */
- if (filter_mode & ANIMFILTER_NODUPLIS)
+ if (filter_mode & ANIMFILTER_NODUPLIS) {
items = animdata_filter_remove_duplis(anim_data);
+ }
}
/* return the number of items in the list */
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index fd22fa16fe8..19fd521d7d9 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -43,24 +43,32 @@
/* ----------------------- Getter functions ----------------------- */
-/* Write into "name" buffer, the name of the property (retrieved using RNA from the curve's settings),
+/**
+ * Write into "name" buffer, the name of the property
+ * (retrieved using RNA from the curve's settings),
* and return the icon used for the struct that this property refers to
- * WARNING: name buffer we're writing to cannot exceed 256 chars (check anim_channels_defines.c for details)
+ *
+ * \warning name buffer we're writing to cannot exceed 256 chars
+ * (check anim_channels_defines.c for details).
*/
int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
{
int icon = 0;
/* sanity checks */
- if (name == NULL)
+ if (name == NULL) {
return icon;
+ }
else if (ELEM(NULL, id, fcu, fcu->rna_path)) {
- if (fcu == NULL)
+ if (fcu == NULL) {
strcpy(name, IFACE_("<invalid>"));
- else if (fcu->rna_path == NULL)
+ }
+ else if (fcu->rna_path == NULL) {
strcpy(name, IFACE_("<no path>"));
- else /* id == NULL */
+ }
+ else { /* id == NULL */
BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index);
+ }
}
else {
PointerRNA id_ptr, ptr;
@@ -83,17 +91,19 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
* 2) <array-index> <property-name> (<struct name>)
* i.e. X Location (Bone1), or X Location (Object)
*
- * Currently, option 2 is in use, to try and make it easier to quickly identify F-Curves (it does have
- * problems with looking rather odd though). Option 1 is better in terms of revealing a consistent sense of
- * hierarchy though, which isn't so clear with option 2.
+ * Currently, option 2 is in use, to try and make it easier to quickly identify F-Curves
+ * (it does have problems with looking rather odd though).
+ * Option 1 is better in terms of revealing a consistent sense of hierarchy though,
+ * which isn't so clear with option 2.
*/
- /* for structname
- * - as base, we use a custom name from the structs if one is available
- * - however, if we're showing subdata of bones (probably there will be other exceptions later)
- * need to include that info too since it gets confusing otherwise
- * - if a pointer just refers to the ID-block, then don't repeat this info
- * since this just introduces clutter
+ /* For structname:
+ * - As base, we use a custom name from the structs if one is available
+ * - However, if we're showing subdata of bones
+ * (probably there will be other exceptions later).
+ * need to include that info too since it gets confusing otherwise.
+ * - If a pointer just refers to the ID-block, then don't repeat this info
+ * since this just introduces clutter.
*/
if (strstr(fcu->rna_path, "bones") && strstr(fcu->rna_path, "constraints")) {
/* perform string 'chopping' to get "Bone Name : Constraint Name" */
@@ -105,10 +115,12 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
free_structname = 1;
/* free the temp names */
- if (pchanName)
+ if (pchanName) {
MEM_freeN(pchanName);
- if (constName)
+ }
+ if (constName) {
MEM_freeN(constName);
+ }
}
else if (ptr.data != ptr.id.data) {
PropertyRNA *nameprop = RNA_struct_name_property(ptr.type);
@@ -117,8 +129,9 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
structname = RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL);
free_structname = 1;
}
- else
+ else {
structname = RNA_struct_ui_name(ptr.type);
+ }
}
/* Property Name is straightforward */
@@ -129,10 +142,12 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
char c = RNA_property_array_item_char(prop, fcu->array_index);
/* we need to write the index to a temp buffer (in py syntax) */
- if (c)
+ if (c) {
BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c);
- else
+ }
+ else {
BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index);
+ }
arrayname = &arrayindbuf[0];
}
@@ -144,14 +159,17 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
/* putting this all together into the buffer */
/* XXX we need to check for invalid names...
* XXX the name length limit needs to be passed in or as some define */
- if (structname)
+ if (structname) {
BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname);
- else
+ }
+ else {
BLI_snprintf(name, 256, "%s%s", arrayname, propname);
+ }
/* free temp name if nameprop is set */
- if (free_structname)
+ if (free_structname) {
MEM_freeN((void *)structname);
+ }
/* Icon for this property's owner:
* use the struct's icon if it is set
@@ -210,8 +228,9 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3])
/* the base color can get offset a bit so that the colors aren't so identical */
hsv[0] += fac * HSV_BANDWIDTH;
- if (hsv[0] > 1.0f)
+ if (hsv[0] > 1.0f) {
hsv[0] = fmod(hsv[0], 1.0f);
+ }
/* saturation adjustments for more visible range */
hsv[1] = ((hsv[0] > 0.5f) && (hsv[0] < 0.8f)) ? 0.5f : 0.6f;
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index beffa47b2c5..66cdae07a36 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -107,10 +107,12 @@ ListBase *ED_context_get_markers(const bContext *C)
/* public API for getting markers from "animation" context */
ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
{
- if (ac)
+ if (ac) {
return context_get_markers(ac->scene, ac->sa);
- else
+ }
+ else {
return NULL;
+ }
}
/* --------------------------------- */
@@ -118,7 +120,8 @@ ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
/**
* Apply some transformation to markers after the fact
*
- * \param markers: List of markers to affect - this may or may not be the scene markers list, so don't assume anything
+ * \param markers: List of markers to affect - this may or may not be the scene markers list,
+ * so don't assume anything.
* \param scene: Current scene (for getting current frame)
* \param mode: (TfmMode) transform mode that this transform is for
* \param value: From the transform code, this is ``t->vec[0]``
@@ -200,7 +203,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
float min, max;
/* sanity check */
- //printf("markers = %p - %p, %p\n", markers, markers->first, markers->last);
+ // printf("markers = %p - %p, %p\n", markers, markers->first, markers->last);
if (ELEM(NULL, markers, markers->first, markers->last)) {
*first = 0.0f;
*last = 0.0f;
@@ -211,10 +214,12 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
max = -FLT_MAX;
for (marker = markers->first; marker; marker = marker->next) {
if (!sel || (marker->flag & SELECT)) {
- if (marker->frame < min)
+ if (marker->frame < min) {
min = (float)marker->frame;
- if (marker->frame > max)
+ }
+ if (marker->frame > max) {
max = (float)marker->frame;
+ }
}
}
@@ -231,15 +236,17 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
CfraElem *ce, *cen;
/* should this one only be considered if it is selected? */
- if ((only_sel) && ((marker->flag & SELECT) == 0))
+ if ((only_sel) && ((marker->flag & SELECT) == 0)) {
return;
+ }
/* insertion sort - try to find a previous cfra elem */
for (ce = lb->first; ce; ce = ce->next) {
if (ce->cfra == marker->frame) {
/* do because of double keys */
- if (marker->flag & SELECT)
+ if (marker->flag & SELECT) {
ce->sel = marker->flag;
+ }
return;
}
else if (ce->cfra > marker->frame) {
@@ -248,10 +255,12 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
}
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
- if (ce)
+ if (ce) {
BLI_insertlinkbefore(lb, ce, cen);
- else
+ }
+ else {
BLI_addtail(lb, cen);
+ }
cen->cfra = marker->frame;
cen->sel = marker->flag;
@@ -280,8 +289,9 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
return;
}
- for (marker = markers->first; marker; marker = marker->next)
+ for (marker = markers->first; marker; marker = marker->next) {
add_marker_to_cfra_elem(lb, marker, only_sel);
+ }
}
void ED_markers_deselect_all(ListBase *markers, int action)
@@ -315,8 +325,9 @@ TimeMarker *ED_markers_get_first_selected(ListBase *markers)
if (markers) {
for (marker = markers->first; marker; marker = marker->next) {
- if (marker->flag & SELECT)
+ if (marker->flag & SELECT) {
return marker;
+ }
}
}
@@ -326,7 +337,8 @@ TimeMarker *ED_markers_get_first_selected(ListBase *markers)
/* --------------------------------- */
/* Print debugging prints of list of markers
- * BSI's: do NOT make static or put in if-defs as "unused code". That's too much trouble when we need to use for quick debugging!
+ * BSI's: do NOT make static or put in if-defs as "unused code".
+ * That's too much trouble when we need to use for quick debugging!
*/
void debug_markers_print_list(ListBase *markers)
{
@@ -349,45 +361,38 @@ void debug_markers_print_list(ListBase *markers)
/* ************* Marker Drawing ************ */
-static void draw_marker_name(const uiFontStyle *fstyle,
- TimeMarker *marker,
- const char *name,
- int cfra,
- const float xpos,
- const float ypixels)
+static void marker_color_get(TimeMarker *marker, unsigned char *color)
{
- unsigned char text_col[4];
- float x, y;
-
- /* minimal y coordinate which wouldn't be occluded by scroll */
- int min_y = 17.0f * UI_DPI_FAC;
-
if (marker->flag & SELECT) {
- UI_GetThemeColor4ubv(TH_TEXT_HI, text_col);
- x = xpos + 4.0f * UI_DPI_FAC;
- y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
- y = max_ii(y, min_y);
+ UI_GetThemeColor4ubv(TH_TEXT_HI, color);
}
else {
- UI_GetThemeColor4ubv(TH_TEXT, text_col);
- if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) {
- x = xpos + 8.0f * UI_DPI_FAC;
- y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
- y = max_ii(y, min_y);
- }
- else {
- x = xpos + 8.0f * UI_DPI_FAC;
- y = 17.0f * UI_DPI_FAC;
- }
+ UI_GetThemeColor4ubv(TH_TEXT, color);
}
+}
+
+static void draw_marker_name(const uiFontStyle *fstyle,
+ TimeMarker *marker,
+ float marker_x,
+ float text_y)
+{
+ unsigned char text_color[4];
+ marker_color_get(marker, text_color);
+
+ const char *name = marker->name;
#ifdef DURIAN_CAMERA_SWITCH
- if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) {
- text_col[3] = 100;
+ if (marker->camera) {
+ Object *camera = marker->camera;
+ name = camera->id.name + 2;
+ if (camera->restrictflag & OB_RESTRICT_RENDER) {
+ text_color[3] = 100;
+ }
}
#endif
- UI_fontstyle_draw_simple(fstyle, x, y, name, text_col);
+ int name_x = marker_x + UI_DPI_ICON_SIZE * 0.6;
+ UI_fontstyle_draw_simple(fstyle, name_x, text_y, name, text_color);
}
static void draw_marker_line(const float color[4], float x, float ymin, float ymax)
@@ -414,29 +419,24 @@ static void draw_marker_line(const float color[4], float x, float ymin, float ym
immUnbindProgram();
}
-/* function to draw markers */
-static void draw_marker(const uiFontStyle *fstyle,
- TimeMarker *marker,
- int cfra,
- int flag,
- /* avoid re-calculating each time */
- const float ypixels,
- const float xscale,
- int height)
+static int marker_get_icon_id(TimeMarker *marker, int flag)
{
- const float xpos = marker->frame * xscale;
+ if (flag & DRAW_MARKERS_LOCAL) {
+ return (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
+ (marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER;
+ }
#ifdef DURIAN_CAMERA_SWITCH
- const float yoffs = (marker->camera) ? 0.2f * UI_DPI_ICON_SIZE : 0.0f;
-#else
- const float yoffs = 0.0f;
+ else if (marker->camera) {
+ return (marker->flag & SELECT) ? ICON_OUTLINER_OB_CAMERA : ICON_CAMERA_DATA;
+ }
#endif
- int icon_id;
-
- GPU_blend(true);
- GPU_blend_set_func_separate(
- GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ else {
+ return (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER;
+ }
+}
- /* vertical line - dotted */
+static void draw_marker_line_if_necessary(TimeMarker *marker, int flag, int xpos, int height)
+{
#ifdef DURIAN_CAMERA_SWITCH
if ((marker->camera) || (flag & DRAW_MARKERS_LINES))
#else
@@ -451,103 +451,114 @@ static void draw_marker(const uiFontStyle *fstyle,
copy_v4_fl4(color, 0.0f, 0.0f, 0.0f, 0.38f);
}
- draw_marker_line(color, xpos, yoffs + 1.5f * UI_DPI_ICON_SIZE, height);
+ draw_marker_line(color, xpos, UI_DPI_FAC * 20, height);
}
+}
- /* 5 px to offset icon to align properly, space / pixels corrects for zoom */
- if (flag & DRAW_MARKERS_LOCAL) {
- icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
- (marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER;
- }
-#ifdef DURIAN_CAMERA_SWITCH
- else if (marker->camera) {
- icon_id = (marker->flag & SELECT) ? ICON_OUTLINER_OB_CAMERA : ICON_CAMERA_DATA;
- }
-#endif
- else {
- icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER;
- }
+static void draw_marker(
+ const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int flag, int region_height)
+{
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ draw_marker_line_if_necessary(marker, flag, xpos, region_height);
- UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, yoffs + UI_DPI_ICON_SIZE, icon_id);
+ int icon_id = marker_get_icon_id(marker, flag);
+ UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, UI_DPI_FAC * 18, icon_id);
GPU_blend(false);
- /* and the marker name too, shifted slightly to the top-right */
-#ifdef DURIAN_CAMERA_SWITCH
- if (marker->camera) {
- draw_marker_name(fstyle, marker, marker->camera->id.name + 2, cfra, xpos, ypixels);
+ float name_y = UI_DPI_FAC * 18;
+ if (marker->flag & SELECT) {
+ name_y += UI_DPI_FAC * 10;
}
- else if (marker->name[0]) {
- draw_marker_name(fstyle, marker, marker->name, cfra, xpos, ypixels);
+ draw_marker_name(fstyle, marker, xpos, name_y);
+}
+
+static void draw_markers_background(rctf *rect)
+{
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ const unsigned char shade[4] = {0, 0, 0, 16};
+ immUniformColor4ubv(shade);
+
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+
+ GPU_blend(false);
+
+ immUnbindProgram();
+}
+
+static bool marker_is_in_frame_range(TimeMarker *marker, int frame_range[2])
+{
+ if (marker->frame < frame_range[0]) {
+ return false;
}
-#else
- if (marker->name[0]) {
- draw_marker_name(fstyle, marker, marker->name, cfra, xpos, ypixels);
+ if (marker->frame > frame_range[1]) {
+ return false;
}
-#endif
+ return true;
+}
+
+static void get_marker_region_rect(View2D *v2d, rctf *rect)
+{
+ rect->xmin = v2d->cur.xmin;
+ rect->xmax = v2d->cur.xmax;
+ rect->ymin = 0;
+ rect->ymax = UI_MARKER_MARGIN_Y;
+}
+
+static void get_marker_clip_frame_range(View2D *v2d, float xscale, int r_range[2])
+{
+ float font_width_max = (10 * UI_DPI_FAC) / xscale;
+ r_range[0] = v2d->cur.xmin - sizeof(((TimeMarker *)NULL)->name) * font_width_max;
+ r_range[1] = v2d->cur.xmax + font_width_max;
}
/* Draw Scene-Markers in time window */
void ED_markers_draw(const bContext *C, int flag)
{
- const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
ListBase *markers = ED_context_get_markers(C);
- View2D *v2d;
- TimeMarker *marker;
- Scene *scene;
- int select_pass;
- int v2d_clip_range_x[2];
- float font_width_max;
-
- /* cache values */
- float ypixels, xscale, yscale;
-
if (markers == NULL || BLI_listbase_is_empty(markers)) {
return;
}
- scene = CTX_data_scene(C);
- v2d = UI_view2d_fromcontext(C);
- int height = v2d->mask.ymax - v2d->mask.ymin;
-
- if (flag & DRAW_MARKERS_MARGIN) {
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- const unsigned char shade[4] = {0, 0, 0, 16};
- immUniformColor4ubv(shade);
-
- GPU_blend(true);
- GPU_blend_set_func_separate(
- GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
-
- immRectf(pos, v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y);
+ ARegion *ar = CTX_wm_region(C);
+ View2D *v2d = UI_view2d_fromcontext(C);
- GPU_blend(false);
+ rctf markers_region_rect;
+ get_marker_region_rect(v2d, &markers_region_rect);
- immUnbindProgram();
- }
+ draw_markers_background(&markers_region_rect);
/* no time correction for framelen! space is drawn with old values */
- ypixels = BLI_rcti_size_y(&v2d->mask);
- UI_view2d_scale_get(v2d, &xscale, &yscale);
+ float xscale, dummy;
+ UI_view2d_scale_get(v2d, &xscale, &dummy);
GPU_matrix_push();
GPU_matrix_scale_2f(1.0f / xscale, 1.0f);
- /* x-bounds with offset for text (adjust for long string, avoid checking string width) */
- font_width_max = (10 * UI_DPI_FAC) / xscale;
- v2d_clip_range_x[0] = v2d->cur.xmin - (sizeof(marker->name) * font_width_max);
- v2d_clip_range_x[1] = v2d->cur.xmax + font_width_max;
+ int clip_frame_range[2];
+ get_marker_clip_frame_range(v2d, xscale, clip_frame_range);
- /* loop [unselected, selected] */
- for (select_pass = 0; select_pass <= SELECT; select_pass += SELECT) {
- /* unselected markers are drawn at the first time */
- for (marker = markers->first; marker; marker = marker->next) {
- if ((marker->flag & SELECT) == select_pass) {
- /* bounds check */
- if ((marker->frame >= v2d_clip_range_x[0]) && (marker->frame <= v2d_clip_range_x[1])) {
- draw_marker(fstyle, marker, scene->r.cfra, flag, ypixels, xscale, height);
- }
+ const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
+
+ for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ if ((marker->flag & SELECT) == 0) {
+ if (marker_is_in_frame_range(marker, clip_frame_range)) {
+ draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy);
+ }
+ }
+ }
+ for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ if (marker->flag & SELECT) {
+ if (marker_is_in_frame_range(marker, clip_frame_range)) {
+ draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy);
}
}
}
@@ -569,8 +580,9 @@ static bool ed_markers_poll_selected_markers(bContext *C)
ListBase *markers = ED_context_get_markers(C);
/* first things first: markers can only exist in timeline views */
- if (ED_operator_animview_active(C) == 0)
+ if (ED_operator_animview_active(C) == 0) {
return 0;
+ }
/* check if some marker is selected */
return ED_markers_get_first_selected(markers) != NULL;
@@ -581,12 +593,14 @@ static bool ed_markers_poll_selected_no_locked_markers(bContext *C)
ListBase *markers = ED_context_get_markers(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- if (ts->lock_markers)
+ if (ts->lock_markers) {
return 0;
+ }
/* first things first: markers can only exist in timeline views */
- if (ED_operator_animview_active(C) == 0)
+ if (ED_operator_animview_active(C) == 0) {
return 0;
+ }
/* check if some marker is selected */
return ED_markers_get_first_selected(markers) != NULL;
@@ -598,12 +612,14 @@ static bool ed_markers_poll_markers_exist(bContext *C)
ListBase *markers = ED_context_get_markers(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- if (ts->lock_markers)
+ if (ts->lock_markers) {
return 0;
+ }
/* first things first: markers can only exist in timeline views */
- if (ED_operator_animview_active(C) == 0)
+ if (ED_operator_animview_active(C) == 0) {
return 0;
+ }
/* list of markers must exist, as well as some markers in it! */
return (markers && markers->first);
@@ -632,14 +648,17 @@ static int ed_markers_opwrap_invoke_custom(bContext *C,
/* removed check for Y coord of event, keymap has bounbox now */
/* allow operator to run now */
- if (invoke_func)
+ if (invoke_func) {
retval = invoke_func(C, op, event);
- else if (op->type->exec)
+ }
+ else if (op->type->exec) {
retval = op->type->exec(C, op);
- else
+ }
+ else {
BKE_report(op->reports,
RPT_ERROR,
"Programming error: operator does not actually have code to do anything!");
+ }
/* unless successful, must add "pass-through"
* to let normal operator's have a chance at tackling this event */
@@ -669,19 +688,22 @@ static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op))
TimeMarker *marker;
int frame = CTX_data_scene(C)->r.cfra;
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_CANCELLED;
+ }
/* prefer not having 2 markers at the same place,
* though the user can move them to overlap once added */
for (marker = markers->first; marker; marker = marker->next) {
- if (marker->frame == frame)
+ if (marker->frame == frame) {
return OPERATOR_CANCELLED;
+ }
}
/* deselect all */
- for (marker = markers->first; marker; marker = marker->next)
+ for (marker = markers->first; marker; marker = marker->next) {
marker->flag &= ~SELECT;
+ }
marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
marker->flag = SELECT;
@@ -1079,8 +1101,9 @@ static void ed_marker_duplicate_apply(bContext *C)
ListBase *markers = ED_context_get_markers(C);
TimeMarker *marker, *newmarker;
- if (markers == NULL)
+ if (markers == NULL) {
return;
+ }
/* go through the list of markers, duplicate selected markers and add duplicated copies
* to the beginning of the list (unselect original markers)
@@ -1189,8 +1212,9 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
float viewx;
int x, cfra;
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
x = event->x - ar->winrct.xmin;
@@ -1209,8 +1233,9 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
TimeMarker *marker;
int sel = 0;
- if (!extend)
+ if (!extend) {
BKE_view_layer_base_deselect_all(view_layer);
+ }
for (marker = markers->first; marker; marker = marker->next) {
if (marker->frame == cfra) {
@@ -1225,8 +1250,9 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
base = BKE_view_layer_base_find(view_layer, marker->camera);
if (base) {
ED_object_base_select(base, sel);
- if (sel)
+ if (sel) {
ED_object_base_activate(C, base);
+ }
}
}
}
@@ -1315,8 +1341,9 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rctf(op, &rect);
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
- if (markers == NULL)
+ if (markers == NULL) {
return 0;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const bool select = (sel_op != SEL_OP_SUB);
@@ -1410,8 +1437,9 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op))
TimeMarker *marker, *nmarker;
bool changed = false;
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_CANCELLED;
+ }
for (marker = markers->first; marker; marker = nmarker) {
nmarker = marker->next;
@@ -1475,8 +1503,9 @@ static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, const wm
{
/* must initialize the marker name first if there is a marker selected */
TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C));
- if (marker)
+ if (marker) {
RNA_string_set(op->ptr, "name", marker->name);
+ }
/* now see if the operator is usable */
return ed_markers_opwrap_invoke_custom(C, op, event, WM_operator_props_popup_confirm);
@@ -1504,7 +1533,13 @@ static void MARKER_OT_rename(wmOperatorType *ot)
sizeof(((TimeMarker *)NULL)->name),
"Name",
"New name for marker");
- //RNA_def_boolean(ot->srna, "ensure_unique", 0, "Ensure Unique", "Ensure that new name is unique within collection of markers");
+#if 0
+ RNA_def_boolean(ot->srna,
+ "ensure_unique",
+ 0,
+ "Ensure Unique",
+ "Ensure that new name is unique within collection of markers");
+#endif
}
/* **************** make links to scene ***************** */
@@ -1592,8 +1627,9 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op)
}
/* add new marker, unless we already have one on this frame, in which case, replace it */
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_CANCELLED;
+ }
marker = ED_markers_find_nearest_marker(markers, CFRA);
if ((marker == NULL) || (marker->frame != CFRA)) {
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c
index b1183167945..e3c4e2a8cfb 100644
--- a/source/blender/editors/animation/anim_motion_paths.c
+++ b/source/blender/editors/animation/anim_motion_paths.c
@@ -216,8 +216,9 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
bool current_frame_only)
{
/* sanity check */
- if (ELEM(NULL, targets, targets->first))
+ if (ELEM(NULL, targets, targets->first)) {
return;
+ }
/* Compute frame range to bake within.
* TODO: this method could be improved...
@@ -249,7 +250,8 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
/* get copies of objects/bones to get the calculated results from
* (for copy-on-write evaluation), so that we actually get some results
*/
- // TODO: Create a copy of background depsgraph that only contain these entities, and only evaluates them..
+ // TODO: Create a copy of background depsgraph that only contain these entities,
+ // and only evaluates them.
for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) {
mpt->ob_eval = DEG_get_evaluated_object(depsgraph, mpt->ob);
@@ -262,10 +264,12 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
bAnimVizSettings *avs;
/* get pointer to animviz settings for each target */
- if (mpt->pchan)
+ if (mpt->pchan) {
avs = &mpt->ob->pose->avs;
- else
+ }
+ else {
avs = &mpt->ob->avs;
+ }
/* it is assumed that keyframes for bones are all grouped in a single group
* unless an option is set to always use the whole action
@@ -319,10 +323,12 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
bMotionPath *mpath = mpt->mpath;
/* get pointer to animviz settings for each target */
- if (mpt->pchan)
+ if (mpt->pchan) {
avs = &mpt->ob->pose->avs;
- else
+ }
+ else {
avs = &mpt->ob->avs;
+ }
/* clear the flag requesting recalculation of targets */
avs->recalc &= ~ANIMVIZ_RECALC_PATHS;
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 91cbc2ff3e0..45bb8f3b11e 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -62,8 +62,9 @@ static bool change_frame_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
/* XXX temp? prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return false;
+ }
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
@@ -157,8 +158,9 @@ static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event)
ED_sequencer_special_preview_set(C, event->mval);
}
}
- if (screen)
+ if (screen) {
screen->scrubbing = true;
+ }
}
static void change_frame_seq_preview_end(bContext *C)
@@ -225,8 +227,9 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RIGHTMOUSE:
case MIDDLEMOUSE:
/* We check for either mouse-button to end, to work with all user keymaps. */
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
ret = OPERATOR_FINISHED;
+ }
break;
case LEFTCTRLKEY:
@@ -281,8 +284,9 @@ static bool anim_set_end_frames_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
/* XXX temp? prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return false;
+ }
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
@@ -302,22 +306,27 @@ static int anim_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
int frame;
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
frame = CFRA;
/* if Preview Range is defined, set the 'start' frame for that */
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.psfra = frame;
- else
+ }
+ else {
scene->r.sfra = frame;
+ }
if (PEFRA < frame) {
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.pefra = frame;
- else
+ }
+ else {
scene->r.efra = frame;
+ }
}
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -345,22 +354,27 @@ static int anim_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
int frame;
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
frame = CFRA;
/* if Preview Range is defined, set the 'end' frame for that */
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.pefra = frame;
- else
+ }
+ else {
scene->r.efra = frame;
+ }
if (PSFRA > frame) {
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.psfra = frame;
- else
+ }
+ else {
scene->r.sfra = frame;
+ }
}
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -405,8 +419,9 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
*/
FRAMENUMBER_MIN_CLAMP(sfra);
FRAMENUMBER_MIN_CLAMP(efra);
- if (efra < sfra)
+ if (efra < sfra) {
efra = sfra;
+ }
scene->r.flag |= SCER_PRV_RANGE;
scene->r.psfra = round_fl_to_int(sfra);
@@ -452,8 +467,9 @@ static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op))
ScrArea *curarea = CTX_wm_area(C);
/* sanity checks */
- if (ELEM(NULL, scene, curarea))
+ if (ELEM(NULL, scene, curarea)) {
return OPERATOR_CANCELLED;
+ }
/* simply clear values */
scene->r.flag &= ~SCER_PRV_RANGE;
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index d6564be9574..2a8702802aa 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -73,13 +73,15 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, id, rna_path))
+ if (ELEM(NULL, id, rna_path)) {
return NULL;
+ }
/* init animdata if none available yet */
adt = BKE_animdata_from_id(id);
- if ((adt == NULL) && (add))
+ if ((adt == NULL) && (add)) {
adt = BKE_animdata_add_id(id);
+ }
if (adt == NULL) {
/* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
return NULL;
@@ -102,7 +104,8 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
fcu->rna_path = BLI_strdup(rna_path);
fcu->array_index = array_index;
- /* if add is negative, don't init this data yet, since it will be filled in by the pasted driver */
+ /* If add is negative, don't init this data yet,
+ * since it will be filled in by the pasted driver. */
if (add > 0) {
BezTriple *bezt;
size_t i;
@@ -232,31 +235,40 @@ static int add_driver_with_target(ReportList *UNUSED(reports),
/* Transform channel depends on type */
if (STREQ(prop_name, "location")) {
- if (src_index == 2)
+ if (src_index == 2) {
dtar->transChan = DTAR_TRANSCHAN_LOCZ;
- else if (src_index == 1)
+ }
+ else if (src_index == 1) {
dtar->transChan = DTAR_TRANSCHAN_LOCY;
- else
+ }
+ else {
dtar->transChan = DTAR_TRANSCHAN_LOCX;
+ }
}
else if (STREQ(prop_name, "scale")) {
- if (src_index == 2)
+ if (src_index == 2) {
dtar->transChan = DTAR_TRANSCHAN_SCALEZ;
- else if (src_index == 1)
+ }
+ else if (src_index == 1) {
dtar->transChan = DTAR_TRANSCHAN_SCALEY;
- else
+ }
+ else {
dtar->transChan = DTAR_TRANSCHAN_SCALEX;
+ }
}
else {
/* XXX: With quaternions and axis-angle, this mapping might not be correct...
* But since those have 4 elements instead, there's not much we can do
*/
- if (src_index == 2)
+ if (src_index == 2) {
dtar->transChan = DTAR_TRANSCHAN_ROTZ;
- else if (src_index == 1)
+ }
+ else if (src_index == 1) {
dtar->transChan = DTAR_TRANSCHAN_ROTY;
- else
+ }
+ else {
dtar->transChan = DTAR_TRANSCHAN_ROTX;
+ }
}
}
else {
@@ -437,12 +449,14 @@ int ANIM_add_driver(
array_index_max = RNA_property_array_length(&ptr, prop);
array_index = 0;
}
- else
+ else {
array_index_max = array_index;
+ }
/* maximum index should be greater than the start index */
- if (array_index == array_index_max)
+ if (array_index == array_index_max) {
array_index_max += 1;
+ }
/* will only loop once unless the array index was -1 */
for (; array_index < array_index_max; array_index++) {
@@ -476,26 +490,32 @@ int ANIM_add_driver(
float fval;
if (proptype == PROP_BOOLEAN) {
- if (!array)
+ if (!array) {
val = RNA_property_boolean_get(&ptr, prop);
- else
+ }
+ else {
val = RNA_property_boolean_get_index(&ptr, prop, array_index);
+ }
BLI_snprintf(expression, maxlen, "%s%s", dvar_prefix, (val) ? "True" : "False");
}
else if (proptype == PROP_INT) {
- if (!array)
+ if (!array) {
val = RNA_property_int_get(&ptr, prop);
- else
+ }
+ else {
val = RNA_property_int_get_index(&ptr, prop, array_index);
+ }
BLI_snprintf(expression, maxlen, "%s%d", dvar_prefix, val);
}
else if (proptype == PROP_FLOAT) {
- if (!array)
+ if (!array) {
fval = RNA_property_float_get(&ptr, prop);
- else
+ }
+ else {
fval = RNA_property_float_get_index(&ptr, prop, array_index);
+ }
BLI_snprintf(expression, maxlen, "%s%.3f", dvar_prefix, fval);
BLI_str_rstrip_float_zero(expression, '\0');
@@ -586,8 +606,9 @@ static FCurve *channeldriver_copypaste_buf = NULL;
void ANIM_drivers_copybuf_free(void)
{
/* free the buffer F-Curve if it exists, as if it were just another F-Curve */
- if (channeldriver_copypaste_buf)
+ if (channeldriver_copypaste_buf) {
free_fcurve(channeldriver_copypaste_buf);
+ }
channeldriver_copypaste_buf = NULL;
}
@@ -629,8 +650,9 @@ bool ANIM_copy_driver(
/* copy this to the copy/paste buf if it exists */
if (fcu && fcu->driver) {
- /* make copies of some info such as the rna_path, then clear this info from the F-Curve temporarily
- * so that we don't end up wasting memory storing the path which won't get used ever...
+ /* Make copies of some info such as the rna_path, then clear this info from the
+ * F-Curve temporarily so that we don't end up wasting memory storing the path
+ * which won't get used ever.
*/
char *tmp_path = fcu->rna_path;
fcu->rna_path = NULL;
@@ -866,8 +888,9 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C,
int totitem = 0;
- if (!C) /* needed for docs */
+ if (!C) { /* needed for docs */
return prop_driver_create_mapping_types;
+ }
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
@@ -899,13 +922,25 @@ static bool add_driver_button_poll(bContext *C)
PointerRNA ptr = {{NULL}};
PropertyRNA *prop = NULL;
int index;
+ bool driven, special;
/* this operator can only run if there's a property button active, and it can be animated */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- return (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop));
+
+ if (!(ptr.id.data && ptr.data && prop)) {
+ return false;
+ }
+ if (!RNA_property_animateable(&ptr, prop)) {
+ return false;
+ }
+
+ /* Don't do anything if there is an fcurve for animation without a driver. */
+ FCurve *fcu = rna_get_fcurve_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special);
+ return (fcu == NULL || fcu->driver);
}
-/* Wrapper for creating a driver without knowing what the targets will be yet (i.e. "manual/add later") */
+/* Wrapper for creating a driver without knowing what the targets will be yet
+ * (i.e. "manual/add later"). */
static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_type)
{
PointerRNA ptr = {{NULL}};
@@ -915,8 +950,9 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL)
+ if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL) {
index = -1;
+ }
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
@@ -952,7 +988,8 @@ static int add_driver_button_menu_exec(bContext *C, wmOperator *op)
/* Create Driver using Eyedropper */
wmOperatorType *ot = WM_operatortype_find("UI_OT_eyedropper_driver", true);
- /* XXX: We assume that it's fine to use the same set of properties, since they're actually the same... */
+ /* XXX: We assume that it's fine to use the same set of properties,
+ * since they're actually the same. */
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, op->ptr);
return OPERATOR_FINISHED;
@@ -1069,8 +1106,9 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op)
/* try to find driver using property retrieved from UI */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- if (all)
+ if (all) {
index = -1;
+ }
if (ptr.id.data && ptr.data && prop) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
@@ -1102,7 +1140,7 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot)
/* callbacks */
ot->exec = remove_driver_button_exec;
- //op->poll = ??? // TODO: need to have some driver to be able to do this...
+ // op->poll = ??? // TODO: need to have some driver to be able to do this...
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1139,7 +1177,7 @@ void ANIM_OT_driver_button_edit(wmOperatorType *ot)
/* callbacks */
ot->exec = edit_driver_button_exec;
- //op->poll = ??? // TODO: need to have some driver to be able to do this...
+ // op->poll = ??? // TODO: need to have some driver to be able to do this...
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1183,7 +1221,7 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot)
/* callbacks */
ot->exec = copy_driver_button_exec;
- //op->poll = ??? // TODO: need to have some driver to be able to do this...
+ // op->poll = ??? // TODO: need to have some driver to be able to do this...
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -1232,7 +1270,7 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot)
/* callbacks */
ot->exec = paste_driver_button_exec;
- //op->poll = ??? // TODO: need to have some driver to be able to do this...
+ // op->poll = ??? // TODO: need to have some driver to be able to do this...
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 919090cdee9..f4e1268ab77 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -63,7 +63,8 @@
/* UI STUFF */
// XXX! --------------------------------
-/* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */
+/* Temporary definition for limits of float number buttons
+ * (FLT_MAX tends to infinity with old system). */
#define UI_FLT_MAX 10000.0f
#define B_REDR 1
@@ -76,8 +77,9 @@ static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
/* call the verify callback on the modifier if applicable */
- if (fmi && fmi->verify_data)
+ if (fmi && fmi->verify_data) {
fmi->verify_data(fcm);
+ }
}
/* callback to remove the given modifier */
@@ -97,7 +99,8 @@ static void delete_fmodifier_cb(bContext *C, void *ctx_v, void *fcm_v)
ED_undo_push(C, "Delete F-Curve Modifier");
/* send notifiers */
- // XXX for now, this is the only way to get updates in all the right places... but would be nice to have a special one in this case
+ /* XXX for now, this is the only way to get updates in all the right places...
+ * but would be nice to have a special one in this case. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
DEG_id_tag_update(ctx->fcurve_owner_id, ID_RECALC_ANIMATION);
}
@@ -208,7 +211,7 @@ static void draw_modifier__generator(uiLayout *layout,
cp = data->coefficients;
for (i = 0; (i < data->arraysize) && (cp); i++, cp++) {
/* To align with first line... */
- if (i)
+ if (i) {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -223,7 +226,8 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
- else
+ }
+ else {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -238,6 +242,7 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
+ }
/* coefficient */
uiDefButF(block,
@@ -256,12 +261,15 @@ static void draw_modifier__generator(uiLayout *layout,
TIP_("Coefficient for polynomial"));
/* 'x' param (and '+' if necessary) */
- if (i == 0)
+ if (i == 0) {
BLI_strncpy(xval, "", sizeof(xval));
- else if (i == 1)
+ }
+ else if (i == 1) {
BLI_strncpy(xval, "x", sizeof(xval));
- else
+ }
+ else {
BLI_snprintf(xval, sizeof(xval), "x^%u", i);
+ }
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -326,7 +334,7 @@ static void draw_modifier__generator(uiLayout *layout,
cp = data->coefficients;
for (i = 0; (i < data->poly_order) && (cp); i++, cp += 2) {
/* To align with first line */
- if (i)
+ if (i) {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -341,7 +349,8 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
- else
+ }
+ else {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -356,6 +365,7 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
+ }
/* opening bracket */
uiDefBut(
block, UI_BTYPE_LABEL, 1, "(", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -427,7 +437,7 @@ static void draw_modifier__generator(uiLayout *layout,
row = uiLayoutRow(layout, true);
block = uiLayoutGetBlock(row);
}
- else
+ else {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -442,6 +452,7 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
+ }
}
break;
}
@@ -567,15 +578,17 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar
fedn = MEM_callocN((env->totvert + 1) * sizeof(FCM_EnvelopeData), "FCM_EnvelopeData");
/* add the points that should occur before the point to be pasted */
- if (i > 0)
+ if (i > 0) {
memcpy(fedn, env->data, i * sizeof(FCM_EnvelopeData));
+ }
/* add point to paste at index i */
*(fedn + i) = fed;
/* add the points that occur after the point to be pasted */
- if (i < env->totvert)
+ if (i < env->totvert) {
memcpy(fedn + i + 1, env->data + i, (env->totvert - i) * sizeof(FCM_EnvelopeData));
+ }
/* replace (+ free) old with new */
MEM_freeN(env->data);
@@ -883,10 +896,12 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout,
uiItemR(sub, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
/* name */
- if (fmi)
+ if (fmi) {
uiItemL(sub, IFACE_(fmi->name), ICON_NONE);
- else
+ }
+ else {
uiItemL(sub, IFACE_("<Unknown Modifier>"), ICON_NONE);
+ }
/* right-align ------------------------------------------- */
sub = uiLayoutRow(row, true);
@@ -1023,8 +1038,9 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
bool ok = true;
/* sanity checks */
- if (ELEM(NULL, modifiers, modifiers->first))
+ if (ELEM(NULL, modifiers, modifiers->first)) {
return 0;
+ }
/* copy the whole list, or just the active one? */
if (active) {
@@ -1034,11 +1050,13 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
FModifier *fcmN = copy_fmodifier(fcm);
BLI_addtail(&fmodifier_copypaste_buf, fcmN);
}
- else
+ else {
ok = 0;
+ }
}
- else
+ else {
copy_fmodifiers(&fmodifier_copypaste_buf, modifiers);
+ }
/* did we succeed? */
return ok;
@@ -1053,14 +1071,16 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c
bool ok = false;
/* sanity checks */
- if (modifiers == NULL)
+ if (modifiers == NULL) {
return 0;
+ }
bool was_cyclic = curve && BKE_fcurve_is_cyclic(curve);
/* if replacing the list, free the existing modifiers */
- if (replace)
+ if (replace) {
free_fmodifiers(modifiers);
+ }
/* now copy over all the modifiers in the buffer to the end of the list */
for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) {
@@ -1078,8 +1098,9 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c
}
/* adding or removing the Cycles modifier requires an update to handles */
- if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic)
+ if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic) {
calchandles_fcurve(curve);
+ }
/* did we succeed? */
return ok;
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index e8c17e10b17..678afef5773 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -77,13 +77,16 @@ short compare_ak_cfraPtr(void *node, void *data)
const float *cframe = data;
float val = *cframe;
- if (is_cfra_eq(val, ak->cfra))
+ if (is_cfra_eq(val, ak->cfra)) {
return 0;
+ }
- if (val < ak->cfra)
+ if (val < ak->cfra) {
return -1;
- else
+ }
+ else {
return 1;
+ }
}
/* --------------- */
@@ -205,15 +208,18 @@ static void nupdate_ak_bezt(void *node, void *data)
BezTriple *bezt = chain->cur;
/* set selection status and 'touched' status */
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
ak->sel = SELECT;
+ }
/* count keyframes in this column */
ak->totkey++;
- /* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */
- if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME)
+ /* For keyframe type, 'proper' keyframes have priority over breakdowns
+ * (and other types for now). */
+ if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME) {
ak->key_type = BEZT_KEYTYPE_KEYFRAME;
+ }
/* For interpolation type, select the highest value (enum is sorted). */
ak->handle_type = MAX2(ak->handle_type, bezt_handle_type(bezt));
@@ -267,15 +273,18 @@ static void nupdate_ak_gpframe(void *node, void *data)
bGPDframe *gpf = (bGPDframe *)data;
/* set selection status and 'touched' status */
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
ak->sel = SELECT;
+ }
/* count keyframes in this column */
ak->totkey++;
- /* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */
- if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME)
+ /* for keyframe type, 'proper' keyframes have priority over breakdowns
+ * (and other types for now). */
+ if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME) {
ak->key_type = BEZT_KEYTYPE_KEYFRAME;
+ }
}
/* ......... */
@@ -312,8 +321,9 @@ static void nupdate_ak_masklayshape(void *node, void *data)
MaskLayerShape *masklay_shape = (MaskLayerShape *)data;
/* set selection status and 'touched' status */
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
ak->sel = SELECT;
+ }
/* count keyframes in this column */
ak->totkey++;
@@ -324,32 +334,38 @@ static void nupdate_ak_masklayshape(void *node, void *data)
/* Add the given BezTriple to the given 'list' of Keyframes */
static void add_bezt_to_keycolumns_list(DLRBT_Tree *keys, BezTripleChain *bezt)
{
- if (ELEM(NULL, keys, bezt))
+ if (ELEM(NULL, keys, bezt)) {
return;
- else
+ }
+ else {
BLI_dlrbTree_add(keys, compare_ak_bezt, nalloc_ak_bezt, nupdate_ak_bezt, bezt);
+ }
}
/* Add the given GPencil Frame to the given 'list' of Keyframes */
static void add_gpframe_to_keycolumns_list(DLRBT_Tree *keys, bGPDframe *gpf)
{
- if (ELEM(NULL, keys, gpf))
+ if (ELEM(NULL, keys, gpf)) {
return;
- else
+ }
+ else {
BLI_dlrbTree_add(keys, compare_ak_gpframe, nalloc_ak_gpframe, nupdate_ak_gpframe, gpf);
+ }
}
/* Add the given MaskLayerShape Frame to the given 'list' of Keyframes */
static void add_masklay_to_keycolumns_list(DLRBT_Tree *keys, MaskLayerShape *masklay_shape)
{
- if (ELEM(NULL, keys, masklay_shape))
+ if (ELEM(NULL, keys, masklay_shape)) {
return;
- else
+ }
+ else {
BLI_dlrbTree_add(keys,
compare_ak_masklayshape,
nalloc_ak_masklayshape,
nupdate_ak_masklayshape,
masklay_shape);
+ }
}
/* ActKeyBlocks (Long Keyframes) ------------------------------------------ */
@@ -526,8 +542,9 @@ bool actkeyblock_is_valid(ActKeyColumn *ac)
int actkeyblock_get_valid_hold(ActKeyColumn *ac)
{
/* check that block is valid */
- if (!actkeyblock_is_valid(ac))
+ if (!actkeyblock_is_valid(ac)) {
return 0;
+ }
const int hold_mask = (ACTKEYBLOCK_FLAG_ANY_HOLD | ACTKEYBLOCK_FLAG_STATIC_HOLD |
ACTKEYBLOCK_FLAG_ANY_HOLD);
@@ -567,8 +584,8 @@ void draw_keyframe_shape(float x,
size *= 0.85f;
break;
- case BEZT_KEYTYPE_MOVEHOLD: /* slightly smaller than normal keyframes
- * (but by less than for breakdowns) */
+ case BEZT_KEYTYPE_MOVEHOLD: /* Slightly smaller than normal keyframes
+ * (but by less than for breakdowns). */
size *= 0.925f;
break;
@@ -698,7 +715,7 @@ static void draw_keylist(View2D *v2d,
float sel_mhcol[4], unsel_mhcol[4];
float ipo_color[4], ipo_color_mix[4];
- /* cache colours first */
+ /* cache colors first */
UI_GetThemeColor4fv(TH_STRIP_SELECT, sel_color);
UI_GetThemeColor4fv(TH_STRIP, unsel_color);
UI_GetThemeColor4fv(TH_DOPESHEET_IPOLINE, ipo_color);
@@ -777,11 +794,14 @@ static void draw_keylist(View2D *v2d,
/* count keys */
uint key_len = 0;
for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
- /* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw
- * - this might give some improvements, since we current have to flip between view/region matrices
+ /* Optimization: if keyframe doesn't appear within 5 units (screenspace)
+ * in visible area, don't draw.
+ * This might give some improvements,
+ * since we current have to flip between view/region matrices.
*/
- if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax))
+ if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) {
key_len++;
+ }
}
if (key_len > 0) {
@@ -1042,8 +1062,9 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, int saction
bAnimListElem dummychan = {NULL};
- if (sce == NULL)
+ if (sce == NULL) {
return;
+ }
/* create a dummy wrapper data to work with */
dummychan.type = ANIMTYPE_SCENE;
@@ -1060,8 +1081,9 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, int saction
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
fcurve_to_keylist(ale->adt, ale->data, keys, saction_flag);
+ }
ANIM_animdata_freelist(&anim_data);
}
@@ -1076,8 +1098,9 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, int saction_fl
bAnimListElem dummychan = {NULL};
Base dummybase = {NULL};
- if (ob == NULL)
+ if (ob == NULL) {
return;
+ }
/* create a dummy wrapper data to work with */
dummybase.object = ob;
@@ -1096,8 +1119,9 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, int saction_fl
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
fcurve_to_keylist(ale->adt, ale->data, keys, saction_flag);
+ }
ANIM_animdata_freelist(&anim_data);
}
@@ -1140,8 +1164,9 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, int saction
{
if (fcu && fcu->totvert && fcu->bezt) {
/* apply NLA-mapping (if applicable) */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0);
+ }
/* Check if the curve is cyclic. */
bool is_cyclic = BKE_fcurve_is_cyclic(fcu) && (fcu->totvert >= 2);
@@ -1166,8 +1191,9 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, int saction
update_keyblocks(keys, fcu->bezt, fcu->totvert);
/* unapply NLA-mapping if applicable */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
+ }
}
}
@@ -1216,9 +1242,11 @@ void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys)
bGPDframe *gpf;
if (gpl && keys) {
- /* although the frames should already be in an ordered list, they are not suitable for displaying yet */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next)
+ /* Although the frames should already be in an ordered list,
+ * they are not suitable for displaying yet. */
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
add_gpframe_to_keycolumns_list(keys, gpf);
+ }
update_keyblocks(keys, NULL, 0);
}
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index bb0ab112af4..884a8c20b19 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -43,7 +43,8 @@
#include "ED_keyframes_edit.h"
#include "ED_markers.h"
-/* This file defines an API and set of callback-operators for non-destructive editing of keyframe data.
+/* This file defines an API and set of callback-operators for
+ * non-destructive editing of keyframe data.
*
* Two API functions are defined for actually performing the operations on the data:
* ANIM_fcurve_keyframes_loop()
@@ -81,8 +82,9 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
unsigned int i;
/* sanity check */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return 0;
+ }
/* set the F-Curve into the editdata so that it can be accessed */
if (ked) {
@@ -106,27 +108,31 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
/* Only operate on this BezTriple if it fulfills the criteria of the validation func */
if ((ok = key_ok(ked, bezt))) {
- if (ked)
+ if (ked) {
ked->curflags = ok;
+ }
/* Exit with return-code '1' if function returns positive
* This is useful if finding if some BezTriple satisfies a condition.
*/
- if (key_cb(ked, bezt))
+ if (key_cb(ked, bezt)) {
return 1;
+ }
}
}
}
else {
for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
- if (ked)
+ if (ked) {
ked->curIndex = i;
+ }
/* Exit with return-code '1' if function returns positive
* This is useful if finding if some BezTriple satisfies a condition.
*/
- if (key_cb(ked, bezt))
+ if (key_cb(ked, bezt)) {
return 1;
+ }
}
}
}
@@ -139,14 +145,15 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
}
/* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */
- if (fcu_cb)
+ if (fcu_cb) {
fcu_cb(fcu);
+ }
/* done */
return 0;
}
-/* -------------------------------- Further Abstracted (Not Exposed Directly) ----------------------------- */
+/* --------------------- Further Abstracted (Not Exposed Directly) ----------------------------- */
/* This function is used to loop over the keyframe data in an Action Group */
static short agrp_keyframes_loop(KeyframeEditData *ked,
@@ -158,13 +165,15 @@ static short agrp_keyframes_loop(KeyframeEditData *ked,
FCurve *fcu;
/* sanity check */
- if (agrp == NULL)
+ if (agrp == NULL) {
return 0;
+ }
/* only iterate over the F-Curves that are in this group */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
- if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
+ if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) {
return 1;
+ }
}
return 0;
@@ -180,13 +189,15 @@ static short act_keyframes_loop(KeyframeEditData *ked,
FCurve *fcu;
/* sanity check */
- if (act == NULL)
+ if (act == NULL) {
return 0;
+ }
/* just loop through all F-Curves */
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
- if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
+ if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) {
return 1;
+ }
}
return 0;
@@ -209,8 +220,9 @@ static short ob_keyframes_loop(KeyframeEditData *ked,
bAnimListElem dummychan = {NULL};
Base dummybase = {NULL};
- if (ob == NULL)
+ if (ob == NULL) {
return 0;
+ }
/* create a dummy wrapper data to work with */
dummybase.object = ob;
@@ -228,7 +240,8 @@ static short ob_keyframes_loop(KeyframeEditData *ked,
filter = ANIMFILTER_DATA_VISIBLE; // curves only
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- /* loop through each F-Curve, applying the operation as required, but stopping on the first one */
+ /* Loop through each F-Curve, applying the operation as required,
+ * but stopping on the first one. */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) {
ret = 1;
@@ -258,8 +271,9 @@ static short scene_keyframes_loop(KeyframeEditData *ked,
bAnimListElem dummychan = {NULL};
- if (sce == NULL)
+ if (sce == NULL) {
return 0;
+ }
/* create a dummy wrapper data to work with */
dummychan.type = ANIMTYPE_SCENE;
@@ -275,7 +289,8 @@ static short scene_keyframes_loop(KeyframeEditData *ked,
filter = ANIMFILTER_DATA_VISIBLE; // curves only
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- /* loop through each F-Curve, applying the operation as required, but stopping on the first one */
+ /* Loop through each F-Curve, applying the operation as required,
+ * but stopping on the first one. */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) {
ret = 1;
@@ -301,8 +316,9 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
int filter, ret_code = 0;
/* sanity check */
- if (ac == NULL)
+ if (ac == NULL) {
return 0;
+ }
/* get F-Curves to take keyframes from */
filter = ANIMFILTER_DATA_VISIBLE;
@@ -327,10 +343,12 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
- if (ked->iterflags & KED_F1_NLA_UNMAP)
+ if (ked->iterflags & KED_F1_NLA_UNMAP) {
ked->f1 = BKE_nla_tweakedit_remap(adt, f1, NLATIME_CONVERT_UNMAP);
- if (ked->iterflags & KED_F2_NLA_UNMAP)
+ }
+ if (ked->iterflags & KED_F2_NLA_UNMAP) {
ked->f2 = BKE_nla_tweakedit_remap(adt, f2, NLATIME_CONVERT_UNMAP);
+ }
}
/* now operate on the channel as per normal */
@@ -348,8 +366,9 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
}
}
- if (ret_code)
+ if (ret_code) {
break;
+ }
}
ANIM_animdata_freelist(&anim_data);
@@ -368,8 +387,9 @@ short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked,
FcuEditFunc fcu_cb)
{
/* sanity checks */
- if (ale == NULL)
+ if (ale == NULL) {
return 0;
+ }
/* method to use depends on the type of keyframe data */
switch (ale->datatype) {
@@ -407,8 +427,9 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked,
FcuEditFunc fcu_cb)
{
/* sanity checks */
- if (data == NULL)
+ if (data == NULL) {
return 0;
+ }
/* method to use depends on the type of keyframe data */
switch (keytype) {
@@ -467,9 +488,11 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac)
/* ------------------------ */
/* Some macros to make this easier... */
-/* run the given check on the 3 handles
- * - check should be a macro, which takes the handle index as its single arg, which it substitutes later
- * - requires that a var, of type short, is named 'ok', and has been initialized to 0
+/* run the given check on the 3 handles:
+ * - Check should be a macro, which takes the handle index as its single arg,
+ * which it substitutes later.
+ * - Requires that a var, of type short, is named 'ok',
+ * and has been initialized to 0.
*/
#define KEYFRAME_OK_CHECKS(check) \
{ \
@@ -519,19 +542,22 @@ static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
/* this macro checks all beztriple handles for selection...
* only one of the verts has to be selected for this to be ok...
*/
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
return KEYFRAME_OK_ALL;
- else
+ }
+ else {
return 0;
+ }
}
static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
{
short ok = 0;
- /* value is stored in f1 property
- * - this float accuracy check may need to be dropped?
- * - should value be stored in f2 instead so that we won't have conflicts when using f1 for frames too?
+ /* Value is stored in f1 property:
+ * - This float accuracy check may need to be dropped?
+ * - Should value be stored in f2 instead
+ * so that we won't have conflicts when using f1 for frames too?
*/
#define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][1], ked->f1)
KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
@@ -567,8 +593,9 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
/**
@@ -603,8 +630,9 @@ static short ok_bezier_region_lasso(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
@@ -628,8 +656,9 @@ static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
pt[0] = bezt->vec[1][0];
pt[1] = ked->channel_y;
- if (keyframe_region_lasso_test(data, pt))
+ if (keyframe_region_lasso_test(data, pt)) {
return KEYFRAME_OK_KEY;
+ }
}
return 0;
}
@@ -665,8 +694,9 @@ static short ok_bezier_region_circle(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
@@ -690,8 +720,9 @@ static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
pt[0] = bezt->vec[1][0];
pt[1] = ked->channel_y;
- if (keyframe_region_circle_test(data, pt))
+ if (keyframe_region_circle_test(data, pt)) {
return KEYFRAME_OK_KEY;
+ }
}
return 0;
}
@@ -798,8 +829,9 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
/* snaps the keyframe to the nearest frame */
static short snap_bezier_nearest(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)(floorf(bezt->vec[1][0] + 0.5f));
+ }
return 0;
}
@@ -809,8 +841,9 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
const Scene *scene = ked->scene;
const float secf = (float)FPS;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (floorf(bezt->vec[1][0] / secf + 0.5f) * secf);
+ }
return 0;
}
@@ -818,16 +851,18 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
{
const Scene *scene = ked->scene;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)CFRA;
+ }
return 0;
}
/* snaps the keyframe time to the nearest marker's frame */
static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]);
+ }
return 0;
}
@@ -837,10 +872,12 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be
if (bezt->f2 & SELECT) {
bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1];
- if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT))
+ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
bezt->h1 = HD_ALIGN;
- if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT))
+ }
+ if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
bezt->h2 = HD_ALIGN;
+ }
}
return 0;
}
@@ -848,16 +885,18 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be
/* frame to snap to is stored in the custom data -> first float value slot */
static short snap_bezier_time(KeyframeEditData *ked, BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = ked->f1;
+ }
return 0;
}
/* value to snap to is stored in the custom data -> first float value slot */
static short snap_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][1] = ked->f1;
+ }
return 0;
}
@@ -998,8 +1037,10 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type)
/* ******************************************* */
/* Settings */
-/* standard validation step for a few of these (implemented as macro for inlining without fn-call overhead):
- * "if the handles are not of the same type, set them to type free"
+/**
+ * Standard validation step for a few of these
+ * (implemented as macro for inlining without fn-call overhead):
+ * "if the handles are not of the same type, set them to type free".
*/
#define ENSURE_HANDLES_MATCH(bezt) \
if (bezt->h1 != bezt->h2) { \
@@ -1014,10 +1055,12 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type)
static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_AUTO;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_AUTO;
+ }
ENSURE_HANDLES_MATCH(bezt);
}
@@ -1030,10 +1073,12 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_AUTO_ANIM;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_AUTO_ANIM;
+ }
ENSURE_HANDLES_MATCH(bezt);
}
@@ -1043,10 +1088,12 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b
/* Sets the selected bezier handles to type 'vector' */
static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_VECT;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_VECT;
+ }
return 0;
}
@@ -1055,30 +1102,36 @@ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
// currently this isn't used, but may be restored later
static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if ((bezt->f1 & SELECT) && (bezt->h1))
+ if ((bezt->f1 & SELECT) && (bezt->h1)) {
return 1;
- if ((bezt->f3 & SELECT) && (bezt->h2))
+ }
+ if ((bezt->f3 & SELECT) && (bezt->h2)) {
return 1;
+ }
return 0;
}
/* Sets selected bezier handles to type 'align' */
static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_ALIGN;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_ALIGN;
+ }
return 0;
}
/* Sets selected bezier handles to type 'free' */
static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_FREE;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_FREE;
+ }
return 0;
}
@@ -1108,92 +1161,105 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code)
static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_CONST;
+ }
return 0;
}
static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_LIN;
+ }
return 0;
}
static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_BEZ;
+ }
return 0;
}
static short set_bezt_back(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_BACK;
+ }
return 0;
}
static short set_bezt_bounce(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_BOUNCE;
+ }
return 0;
}
static short set_bezt_circle(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_CIRC;
+ }
return 0;
}
static short set_bezt_cubic(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_CUBIC;
+ }
return 0;
}
static short set_bezt_elastic(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_ELASTIC;
+ }
return 0;
}
static short set_bezt_expo(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_EXPO;
+ }
return 0;
}
static short set_bezt_quad(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_QUAD;
+ }
return 0;
}
static short set_bezt_quart(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_QUART;
+ }
return 0;
}
static short set_bezt_quint(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_QUINT;
+ }
return 0;
}
static short set_bezt_sine(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_SINE;
+ }
return 0;
}
@@ -1239,36 +1305,41 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code)
static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_KEYFRAME;
+ }
return 0;
}
static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_BREAKDOWN;
+ }
return 0;
}
static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_EXTREME;
+ }
return 0;
}
static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_JITTER;
+ }
return 0;
}
static short set_keytype_moving_hold(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_MOVEHOLD;
+ }
return 0;
}
@@ -1298,29 +1369,33 @@ KeyframeEditFunc ANIM_editkeyframes_keytype(short code)
static short set_easingtype_easein(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_IN;
+ }
return 0;
}
static short set_easingtype_easeout(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_OUT;
+ }
return 0;
}
static short set_easingtype_easeinout(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_IN_OUT;
+ }
return 0;
}
static short set_easingtype_easeauto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_AUTO;
+ }
return 0;
}
@@ -1349,12 +1424,15 @@ static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt)
{
/* if we've got info on what to select, use it, otherwise select all */
if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
- if (ked->curflags & KEYFRAME_OK_KEY)
+ if (ked->curflags & KEYFRAME_OK_KEY) {
bezt->f2 |= SELECT;
- if (ked->curflags & KEYFRAME_OK_H1)
+ }
+ if (ked->curflags & KEYFRAME_OK_H1) {
bezt->f1 |= SELECT;
- if (ked->curflags & KEYFRAME_OK_H2)
+ }
+ if (ked->curflags & KEYFRAME_OK_H2) {
bezt->f3 |= SELECT;
+ }
}
else {
BEZT_SEL_ALL(bezt);
@@ -1367,12 +1445,15 @@ static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt)
{
/* if we've got info on what to deselect, use it, otherwise deselect all */
if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
- if (ked->curflags & KEYFRAME_OK_KEY)
+ if (ked->curflags & KEYFRAME_OK_KEY) {
bezt->f2 &= ~SELECT;
- if (ked->curflags & KEYFRAME_OK_H1)
+ }
+ if (ked->curflags & KEYFRAME_OK_H1) {
bezt->f1 &= ~SELECT;
- if (ked->curflags & KEYFRAME_OK_H2)
+ }
+ if (ked->curflags & KEYFRAME_OK_H2) {
bezt->f3 &= ~SELECT;
+ }
}
else {
BEZT_DESEL_ALL(bezt);
@@ -1470,8 +1551,9 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
if (i > 0) {
BezTriple *prev = bezt - 1;
- if (BEZT_ISSEL_ANY(prev) == 0)
+ if (BEZT_ISSEL_ANY(prev) == 0) {
return 0;
+ }
}
else if (i == 0) {
/* current keyframe is selected at an endpoint, so should get deselected */
@@ -1482,8 +1564,9 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
if (i < (fcu->totvert - 1)) {
BezTriple *next = bezt + 1;
- if (BEZT_ISSEL_ANY(next) == 0)
+ if (BEZT_ISSEL_ANY(next) == 0) {
return 0;
+ }
}
else if (i == (fcu->totvert - 1)) {
/* current keyframe is selected at an endpoint, so should get deselected */
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 945327ed78b..5214c5f78fa 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -70,17 +70,20 @@
void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
{
/* sanity check */
- if (fcu == NULL)
+ if (fcu == NULL) {
return;
+ }
/* verify the index:
* 1) cannot be greater than the number of available keyframes
* 2) negative indices are for specifying a value from the end of the array
*/
- if (abs(index) >= fcu->totvert)
+ if (abs(index) >= fcu->totvert) {
return;
- else if (index < 0)
+ }
+ else if (index < 0) {
index += fcu->totvert;
+ }
/* Delete this keyframe */
memmove(
@@ -88,14 +91,16 @@ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
fcu->totvert--;
if (fcu->totvert == 0) {
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
+ }
fcu->bezt = NULL;
}
/* recalc handles - only if it won't cause problems */
- if (do_recalc)
+ if (do_recalc) {
calchandles_fcurve(fcu);
+ }
}
/* Delete selected keyframes in given F-Curve */
@@ -104,8 +109,9 @@ bool delete_fcurve_keys(FCurve *fcu)
int i;
bool changed = false;
- if (fcu->bezt == NULL) /* ignore baked curves */
+ if (fcu->bezt == NULL) { /* ignore baked curves */
return false;
+ }
/* Delete selected BezTriples */
for (i = 0; i < fcu->totvert; i++) {
@@ -118,16 +124,18 @@ bool delete_fcurve_keys(FCurve *fcu)
}
/* Free the array of BezTriples if there are not keyframes */
- if (fcu->totvert == 0)
+ if (fcu->totvert == 0) {
clear_fcurve_keys(fcu);
+ }
return changed;
}
void clear_fcurve_keys(FCurve *fcu)
{
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
+ }
fcu->bezt = NULL;
fcu->totvert = 0;
@@ -142,8 +150,9 @@ void duplicate_fcurve_keys(FCurve *fcu)
int i;
/* this can only work when there is an F-Curve, and also when there are some BezTriples */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return;
+ }
for (i = 0; i < fcu->totvert; i++) {
/* If a key is selected */
@@ -173,8 +182,9 @@ void duplicate_fcurve_keys(FCurve *fcu)
/* **************************************************** */
/* Various Tools */
-/* Basic F-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only
- * optionally clears up curve if one keyframe with default value remains
+/**
+ * Basic F-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on
+ * linear-segments only optionally clears up curve if one keyframe with default value remains.
*/
void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, bool cleardefault)
{
@@ -282,8 +292,9 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
}
/* now free the memory used by the old BezTriples */
- if (old_bezts)
+ if (old_bezts) {
MEM_freeN(old_bezts);
+ }
/* final step, if there is just one key in fcurve, check if it's
* the default value and if is, remove fcurve completely. */
@@ -295,8 +306,9 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
/* get property to read from, and get value as appropriate */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
- if (RNA_property_type(prop) == PROP_FLOAT)
+ if (RNA_property_type(prop) == PROP_FLOAT) {
default_value = RNA_property_float_get_default_index(&ptr, prop, fcu->array_index);
+ }
}
if (fcu->bezt->vec[1][1] == default_value) {
@@ -335,8 +347,9 @@ void smooth_fcurve(FCurve *fcu)
/* first loop through - count how many verts are selected */
bezt = fcu->bezt;
for (i = 0; i < fcu->totvert; i++, bezt++) {
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
totSel++;
+ }
}
/* if any points were selected, allocate tSmooth_Bezt points to work on */
@@ -356,10 +369,12 @@ void smooth_fcurve(FCurve *fcu)
tsb->h3 = &bezt->vec[2][1];
/* advance to the next tsb to populate */
- if (x < totSel - 1)
+ if (x < totSel - 1) {
tsb++;
- else
+ }
+ else {
break;
+ }
}
}
@@ -373,7 +388,8 @@ void smooth_fcurve(FCurve *fcu)
/* round 1: calculate smoothing deltas and new values */
tsb = tarray;
for (i = 0; i < totSel; i++, tsb++) {
- /* don't touch end points (otherwise, curves slowly explode, as we don't have enough data there) */
+ /* Don't touch end points (otherwise, curves slowly explode,
+ * as we don't have enough data there). */
if (ELEM(i, 0, (totSel - 1)) == 0) {
const tSmooth_Bezt *tP1 = tsb - 1;
const tSmooth_Bezt *tP2 = (i - 2 > 0) ? (tsb - 2) : (NULL);
@@ -431,8 +447,9 @@ void sample_fcurve(FCurve *fcu)
int sfra, range;
int i, n;
- if (fcu->bezt == NULL) /* ignore baked */
+ if (fcu->bezt == NULL) { /* ignore baked */
return;
+ }
/* find selected keyframes... once pair has been found, add keyframes */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
@@ -500,11 +517,12 @@ void sample_fcurve(FCurve *fcu)
}
/* **************************************************** */
-/* Copy/Paste Tools */
-/* - The copy/paste buffer currently stores a set of temporary F-Curves containing only the keyframes
- * that were selected in each of the original F-Curves
- * - All pasted frames are offset by the same amount. This is calculated as the difference in the times of
- * the current frame and the 'first keyframe' (i.e. the earliest one in all channels).
+/* Copy/Paste Tools:
+ * - The copy/paste buffer currently stores a set of temporary F-Curves containing only the
+ * keyframes that were selected in each of the original F-Curves.
+ * - All pasted frames are offset by the same amount.
+ * This is calculated as the difference in the times of the current frame and the
+ * 'first keyframe' (i.e. the earliest one in all channels).
* - The earliest frame is calculated per copy operation.
*/
@@ -540,12 +558,14 @@ void ANIM_fcurves_copybuf_free(void)
acn = aci->next;
/* free keyframes */
- if (aci->bezt)
+ if (aci->bezt) {
MEM_freeN(aci->bezt);
+ }
/* free RNA-path */
- if (aci->rna_path)
+ if (aci->rna_path) {
MEM_freeN(aci->rna_path);
+ }
/* free ourself */
BLI_freelinkN(&animcopybuf, aci);
@@ -580,8 +600,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
* - this check should also eliminate any problems associated with using sample-data
*/
if (ANIM_fcurve_keyframes_loop(
- NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0)
+ NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0) {
continue;
+ }
/* init copybuf item info */
aci = MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem");
@@ -591,8 +612,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
aci->rna_path = MEM_dupallocN(fcu->rna_path);
aci->array_index = fcu->array_index;
- /* detect if this is a bone. We do that here rather than during pasting because ID pointers will get invalidated if we undo.
- * storing the relevant information here helps avoiding crashes if we undo-repaste */
+ /* Detect if this is a bone. We do that here rather than during pasting because ID pointers
+ * will get invalidated if we undo.
+ * Storing the relevant information here helps avoiding crashes if we undo-repaste. */
if ((aci->id_type == ID_OB) && (((Object *)aci->id)->type == OB_ARMATURE) && aci->rna_path) {
Object *ob = (Object *)aci->id;
bPoseChannel *pchan;
@@ -603,8 +625,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
if (pchan) {
aci->is_bone = true;
}
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
}
BLI_addtail(&animcopybuf, aci);
@@ -618,8 +641,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple");
/* assume that since we are just re-sizing the array, just copy all existing data across */
- if (aci->bezt)
+ if (aci->bezt) {
memcpy(newbuf, aci->bezt, sizeof(BezTriple) * (aci->totvert));
+ }
/* copy current beztriple across too */
nbezt = &newbuf[aci->totvert];
@@ -629,23 +653,27 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
BEZT_SEL_ALL(nbezt);
/* free old array and set the new */
- if (aci->bezt)
+ if (aci->bezt) {
MEM_freeN(aci->bezt);
+ }
aci->bezt = newbuf;
aci->totvert++;
/* check if this is the earliest frame encountered so far */
- if (bezt->vec[1][0] < animcopy_firstframe)
+ if (bezt->vec[1][0] < animcopy_firstframe) {
animcopy_firstframe = bezt->vec[1][0];
- if (bezt->vec[1][0] > animcopy_lastframe)
+ }
+ if (bezt->vec[1][0] > animcopy_lastframe) {
animcopy_lastframe = bezt->vec[1][0];
+ }
}
}
}
/* check if anything ended up in the buffer */
- if (ELEM(NULL, animcopybuf.first, animcopybuf.last))
+ if (ELEM(NULL, animcopybuf.first, animcopybuf.last)) {
return -1;
+ }
/* in case 'relative' paste method is used */
animcopy_cfra = CFRA;
@@ -758,8 +786,9 @@ static tAnimCopybufItem *pastebuf_match_path_property(Main *bmain,
if (len_id <= len_path) {
/* note, paths which end with "] will fail with this test - Animated ID Props */
if (STREQ(identifier, fcu->rna_path + (len_path - len_id))) {
- if ((from_single) || (aci->array_index == fcu->array_index))
+ if ((from_single) || (aci->array_index == fcu->array_index)) {
break;
+ }
}
}
}
@@ -799,17 +828,21 @@ static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt)
if (aci->is_bone) {
const size_t slength = strlen(aci->rna_path);
bool flip = false;
- if (BLI_strn_endswith(aci->rna_path, "location", slength) && aci->array_index == 0)
+ if (BLI_strn_endswith(aci->rna_path, "location", slength) && aci->array_index == 0) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_quaternion", slength) &&
- ELEM(aci->array_index, 2, 3))
+ ELEM(aci->array_index, 2, 3)) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_euler", slength) &&
- ELEM(aci->array_index, 1, 2))
+ ELEM(aci->array_index, 1, 2)) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_axis_angle", slength) &&
- ELEM(aci->array_index, 2, 3))
+ ELEM(aci->array_index, 2, 3)) {
flip = true;
+ }
if (flip) {
bezt->vec[0][1] = -bezt->vec[0][1];
@@ -875,8 +908,9 @@ static void paste_animedit_keys_fcurve(
/* just start pasting, with the first keyframe on the current frame, and so on */
for (i = 0, bezt = aci->bezt; i < aci->totvert; i++, bezt++) {
/* temporarily apply offset to src beztriple while copying */
- if (flip)
+ if (flip) {
do_curve_mirror_flippping(aci, bezt);
+ }
bezt->vec[0][0] += offset;
bezt->vec[1][0] += offset;
@@ -893,8 +927,9 @@ static void paste_animedit_keys_fcurve(
bezt->vec[1][0] -= offset;
bezt->vec[2][0] -= offset;
- if (flip)
+ if (flip) {
do_curve_mirror_flippping(aci, bezt);
+ }
}
/* recalculate F-Curve's handles? */
@@ -1005,10 +1040,11 @@ short paste_animedit_keys(bAnimContext *ac,
unsigned int totmatch = 0;
for (ale = anim_data->first; ale; ale = ale->next) {
- /* find buffer item to paste from
- * - if names don't matter (i.e. only 1 channel in buffer), don't check id/group
- * - if names do matter, only check if id-type is ok for now (group check is not that important)
- * - most importantly, rna-paths should match (array indices are unimportant for now)
+ /* Find buffer item to paste from:
+ * - If names don't matter (i.e. only 1 channel in buffer), don't check id/group
+ * - If names do matter, only check if id-type is ok for now
+ * (group check is not that important).
+ * - Most importantly, rna-paths should match (array indices are unimportant for now)
*/
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->data; /* destination F-Curve */
@@ -1049,8 +1085,9 @@ short paste_animedit_keys(bAnimContext *ac,
}
/* don't continue if some fcurves were pasted */
- if (totmatch)
+ if (totmatch) {
break;
+ }
}
}
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index cc8dbbca439..a0433b49b16 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -94,27 +94,32 @@ short ANIM_get_keyframing_flags(Scene *scene, short incl_mode)
/* standard flags */
{
/* visual keying */
- if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY))
+ if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY)) {
flag |= INSERTKEY_MATRIX;
+ }
/* only needed */
- if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED))
+ if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) {
flag |= INSERTKEY_NEEDED;
+ }
/* default F-Curve color mode - RGB from XYZ indices */
- if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
+ if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) {
flag |= INSERTKEY_XYZ2RGB;
+ }
}
/* only if including settings from the autokeying mode... */
if (incl_mode) {
/* keyframing mode - only replace existing keyframes */
- if (IS_AUTOKEY_MODE(scene, EDITKEYS))
+ if (IS_AUTOKEY_MODE(scene, EDITKEYS)) {
flag |= INSERTKEY_REPLACE;
+ }
/* cycle-aware keyframe insertion - preserve cycle period and flow */
- if (IS_AUTOKEY_FLAG(scene, CYCLEAWARE))
+ if (IS_AUTOKEY_FLAG(scene, CYCLEAWARE)) {
flag |= INSERTKEY_CYCLE_AWARE;
+ }
}
return flag;
@@ -132,8 +137,9 @@ bAction *verify_adt_action(Main *bmain, ID *id, short add)
/* init animdata if none available yet */
adt = BKE_animdata_from_id(id);
- if ((adt == NULL) && (add))
+ if ((adt == NULL) && (add)) {
adt = BKE_animdata_add_id(id);
+ }
if (adt == NULL) {
/* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : "<None>");
@@ -181,8 +187,9 @@ FCurve *verify_fcurve(Main *bmain,
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, act, rna_path))
+ if (ELEM(NULL, act, rna_path)) {
return NULL;
+ }
/* try to find f-curve matching for this setting
* - add if not found and allowed to add one
@@ -196,8 +203,9 @@ FCurve *verify_fcurve(Main *bmain,
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
- if (BLI_listbase_is_empty(&act->curves))
+ if (BLI_listbase_is_empty(&act->curves)) {
fcu->flag |= FCURVE_ACTIVE; /* first one added active */
+ }
/* store path - make copy, and store that */
fcu->rna_path = BLI_strdup(rna_path);
@@ -398,7 +406,8 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
}
if (flag & INSERTKEY_CYCLE_AWARE) {
- /* If replacing an end point of a cyclic curve without offset, modify the other end too. */
+ /* If replacing an end point of a cyclic curve without offset,
+ * modify the other end too. */
if ((i == 0 || i == fcu->totvert - 1) &&
BKE_fcurve_get_cycle_type(fcu) == FCU_CYCLE_PERFECT) {
replace_bezt_keyframe_ypos(&fcu->bezt[i == 0 ? fcu->totvert - 1 : 0], bezt);
@@ -411,16 +420,19 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
/* insert new - if we're not restricted to replacing keyframes only */
BezTriple *newb = MEM_callocN((fcu->totvert + 1) * sizeof(BezTriple), "beztriple");
- /* add the beztriples that should occur before the beztriple to be pasted (originally in fcu) */
- if (i > 0)
+ /* Add the beztriples that should occur before the beztriple to be pasted
+ * (originally in fcu). */
+ if (i > 0) {
memcpy(newb, fcu->bezt, i * sizeof(BezTriple));
+ }
/* add beztriple to paste at index i */
*(newb + i) = *bezt;
/* add the beztriples that occur after the beztriple to be pasted (originally in fcu) */
- if (i < fcu->totvert)
+ if (i < fcu->totvert) {
memcpy(newb + i + 1, fcu->bezt + i, (fcu->totvert - i) * sizeof(BezTriple));
+ }
/* replace (+ free) old with new, only if necessary to do so */
MEM_freeN(fcu->bezt);
@@ -531,37 +543,43 @@ int insert_vert_fcurve(
/* what if 'a' is a negative index?
* for now, just exit to prevent any segfaults
*/
- if (a < 0)
+ if (a < 0) {
return -1;
+ }
/* don't recalculate handles if fast is set
* - this is a hack to make importers faster
* - we may calculate twice (due to autohandle needing to be calculated twice)
*/
- if ((flag & INSERTKEY_FAST) == 0)
+ if ((flag & INSERTKEY_FAST) == 0) {
calchandles_fcurve(fcu);
+ }
/* set handletype and interpolation */
if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE) == 0) {
BezTriple *bezt = (fcu->bezt + a);
- /* set interpolation from previous (if available), but only if we didn't just replace some keyframe
- * - replacement is indicated by no-change in number of verts
- * - when replacing, the user may have specified some interpolation that should be kept
+ /* Set interpolation from previous (if available),
+ * but only if we didn't just replace some keyframe:
+ * - Replacement is indicated by no-change in number of verts.
+ * - When replacing, the user may have specified some interpolation that should be kept.
*/
if (fcu->totvert > oldTot) {
- if (a > 0)
+ if (a > 0) {
bezt->ipo = (bezt - 1)->ipo;
- else if (a < fcu->totvert - 1)
+ }
+ else if (a < fcu->totvert - 1) {
bezt->ipo = (bezt + 1)->ipo;
+ }
}
/* don't recalculate handles if fast is set
* - this is a hack to make importers faster
* - we may calculate twice (due to autohandle needing to be calculated twice)
*/
- if ((flag & INSERTKEY_FAST) == 0)
+ if ((flag & INSERTKEY_FAST) == 0) {
calchandles_fcurve(fcu);
+ }
}
/* return the index at which the keyframe was added */
@@ -590,11 +608,13 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
float valA = 0.0f, valB = 0.0f;
/* safety checking */
- if (fcu == NULL)
+ if (fcu == NULL) {
return KEYNEEDED_JUSTADD;
+ }
totCount = fcu->totvert;
- if (totCount == 0)
+ if (totCount == 0) {
return KEYNEEDED_JUSTADD;
+ }
/* loop through checking if any are the same */
bezt = fcu->bezt;
@@ -631,10 +651,12 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
realVal = evaluate_fcurve(fcu, cFrame);
/* compare whether it's the same as proposed */
- if (IS_EQF(realVal, nValue))
+ if (IS_EQF(realVal, nValue)) {
return KEYNEEDED_DONTADD;
- else
+ }
+ else {
return KEYNEEDED_JUSTADD;
+ }
}
}
@@ -644,18 +666,21 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
* stays around or not depends on whether the values of previous/current
* beztriples and new keyframe are the same.
*/
- if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal))
+ if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal)) {
return KEYNEEDED_DELNEXT;
- else
+ }
+ else {
return KEYNEEDED_JUSTADD;
+ }
}
}
else {
/* just add a keyframe if there's only one keyframe
* and the new one occurs before the existing one does.
*/
- if ((cFrame < beztPosi) && (totCount == 1))
+ if ((cFrame < beztPosi) && (totCount == 1)) {
return KEYNEEDED_JUSTADD;
+ }
}
/* continue. frame to do not yet passed (or other conditions not met) */
@@ -663,8 +688,9 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
prev = bezt;
bezt++;
}
- else
+ else {
break;
+ }
}
/* Frame in which to add a new-keyframe occurs after all other keys
@@ -677,15 +703,19 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
bezt = (fcu->bezt + (fcu->totvert - 1));
valA = bezt->vec[1][1];
- if (prev)
+ if (prev) {
valB = prev->vec[1][1];
- else
+ }
+ else {
valB = bezt->vec[1][1] + 1.0f;
+ }
- if (IS_EQF(valA, nValue) && IS_EQF(valA, valB))
+ if (IS_EQF(valA, nValue) && IS_EQF(valA, valB)) {
return KEYNEEDED_DELPREV;
- else
+ }
+ else {
return KEYNEEDED_JUSTADD;
+ }
}
/* ------------------ RNA Data-Access Functions ------------------ */
@@ -791,8 +821,9 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
const char *identifier = NULL;
/* validate data */
- if (ELEM(NULL, ptr, ptr->data, prop))
+ if (ELEM(NULL, ptr, ptr->data, prop)) {
return false;
+ }
/* get first constraint and determine type of keyframe constraints to check for
* - constraints can be on either Objects or PoseChannels, so we only check if the
@@ -821,8 +852,9 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
}
/* check if any data to search using */
- if (ELEM(NULL, con, identifier) && (has_parent == false) && (has_rigidbody == false))
+ if (ELEM(NULL, con, identifier) && (has_parent == false) && (has_rigidbody == false)) {
return false;
+ }
/* location or rotation identifiers only... */
if (identifier == NULL) {
@@ -846,16 +878,19 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
/* only search if a searchtype and initial constraint are available */
if (searchtype) {
/* parent or rigidbody are always matching */
- if (has_parent || has_rigidbody)
+ if (has_parent || has_rigidbody) {
return true;
+ }
/* constraints */
for (; con; con = con->next) {
/* only consider constraint if it is not disabled, and has influence */
- if (con->flag & CONSTRAINT_DISABLE)
+ if (con->flag & CONSTRAINT_DISABLE) {
continue;
- if (con->enforce == 0.0f)
+ }
+ if (con->enforce == 0.0f) {
continue;
+ }
/* some constraints may alter these transforms */
switch (con->type) {
@@ -873,48 +908,59 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
/* single-transform constraints */
case CONSTRAINT_TYPE_TRACKTO:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_DAMPTRACK:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_ROTLIMIT:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_LOCLIMIT:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
case CONSTRAINT_TYPE_SIZELIMIT:
- if (searchtype == VISUALKEY_SCA)
+ if (searchtype == VISUALKEY_SCA) {
return true;
+ }
break;
case CONSTRAINT_TYPE_DISTLIMIT:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
case CONSTRAINT_TYPE_ROTLIKE:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_LOCLIKE:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
case CONSTRAINT_TYPE_SIZELIKE:
- if (searchtype == VISUALKEY_SCA)
+ if (searchtype == VISUALKEY_SCA) {
return true;
+ }
break;
case CONSTRAINT_TYPE_LOCKTRACK:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_MINMAX:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
default:
@@ -1025,7 +1071,10 @@ static float *visualkey_get_values(Depsgraph *depsgraph,
/* ------------------------- Insert Key API ------------------------- */
-/* Retrieve current property values to keyframe, possibly applying NLA correction when necessary. */
+/**
+ * Retrieve current property values to keyframe,
+ * possibly applying NLA correction when necessary.
+ */
static float *get_keyframe_values(Depsgraph *depsgraph,
ReportList *reports,
PointerRNA ptr,
@@ -1146,8 +1195,9 @@ static bool insert_keyframe_value(ReportList *reports,
}
/* Secondary Keyframing API call:
- * Use this when validation of necessary animation data is not necessary, since an RNA-pointer to the necessary
- * data being keyframed, and a pointer to the F-Curve to use have both been provided.
+ * Use this when validation of necessary animation data is not necessary,
+ * since an RNA-pointer to the necessary data being keyframed,
+ * and a pointer to the F-Curve to use have both been provided.
*
* This function can't keyframe quaternion channels on some NLA strip types.
*
@@ -1508,8 +1558,9 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra)
/* Only delete curve too if it won't be doing anything anymore */
if ((fcu->totvert == 0) &&
- (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0))
+ (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) {
ANIM_fcurve_delete_from_animdata(NULL, adt, fcu);
+ }
/* return success */
return true;
@@ -1594,8 +1645,9 @@ short delete_keyframe(Main *bmain,
* but don't do this for standard arrays since that can cause corruption issues
* (extra unused curves)
*/
- if (array_index_max == array_index)
+ if (array_index_max == array_index) {
array_index_max++;
+ }
}
/* will only loop once unless the array index was -1 */
@@ -1603,8 +1655,9 @@ short delete_keyframe(Main *bmain,
FCurve *fcu = verify_fcurve(bmain, act, group, &ptr, rna_path, array_index, 0);
/* check if F-Curve exists and/or whether it can be edited */
- if (fcu == NULL)
+ if (fcu == NULL) {
continue;
+ }
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(reports,
@@ -1694,8 +1747,9 @@ static short clear_keyframe(Main *bmain,
* but don't do this for standard arrays since that can cause corruption issues
* (extra unused curves)
*/
- if (array_index_max == array_index)
+ if (array_index_max == array_index) {
array_index_max++;
+ }
}
/* will only loop once unless the array index was -1 */
@@ -1703,8 +1757,9 @@ static short clear_keyframe(Main *bmain,
FCurve *fcu = verify_fcurve(bmain, act, group, &ptr, rna_path, array_index, 0);
/* check if F-Curve exists and/or whether it can be edited */
- if (fcu == NULL)
+ if (fcu == NULL) {
continue;
+ }
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(reports,
@@ -1747,8 +1802,9 @@ static bool modify_key_op_poll(bContext *C)
Scene *scene = CTX_data_scene(C);
/* if no area or active scene */
- if (ELEM(NULL, sa, scene))
+ if (ELEM(NULL, sa, scene)) {
return false;
+ }
/* should be fine */
return true;
@@ -1780,12 +1836,13 @@ static int insert_key_exec(bContext *C, wmOperator *op)
/* try to insert keyframes for the channels specified by KeyingSet */
success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
BKE_reportf(op->reports,
RPT_INFO,
"Keying set '%s' - successfully added %d keyframes",
ks->name,
success);
+ }
/* restore the edit mode if necessary */
if (ob_edit_mode) {
@@ -1799,18 +1856,20 @@ static int insert_key_exec(bContext *C, wmOperator *op)
}
else if (success) {
/* if the appropriate properties have been set, make a note that we've inserted something */
- if (RNA_boolean_get(op->ptr, "confirm_success"))
+ if (RNA_boolean_get(op->ptr, "confirm_success")) {
BKE_reportf(op->reports,
RPT_INFO,
"Successfully added %d keyframes for keying set '%s'",
success,
ks->name);
+ }
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
}
- else
+ else {
BKE_report(op->reports, RPT_WARNING, "Keying set failed to insert any keyframes");
+ }
return OPERATOR_FINISHED;
}
@@ -2002,8 +2061,9 @@ static int delete_key_exec(bContext *C, wmOperator *op)
/* try to delete keyframes for the channels specified by KeyingSet */
success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, success);
+ }
/* report failure or do updates? */
if (success == MODIFYKEY_INVALID_CONTEXT) {
@@ -2012,18 +2072,20 @@ static int delete_key_exec(bContext *C, wmOperator *op)
}
else if (success) {
/* if the appropriate properties have been set, make a note that we've inserted something */
- if (RNA_boolean_get(op->ptr, "confirm_success"))
+ if (RNA_boolean_get(op->ptr, "confirm_success")) {
BKE_reportf(op->reports,
RPT_INFO,
"Successfully removed %d keyframes for keying set '%s'",
success,
ks->name);
+ }
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
}
- else
+ else {
BKE_report(op->reports, RPT_WARNING, "Keying set failed to remove any keyframes");
+ }
return OPERATOR_FINISHED;
}
@@ -2123,13 +2185,15 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
/* delete if bone is selected*/
if ((pchan) && (pchan->bone)) {
- if (pchan->bone->flag & BONE_SELECTED)
+ if (pchan->bone->flag & BONE_SELECTED) {
can_delete = true;
+ }
}
}
}
@@ -2145,6 +2209,11 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
changed = true;
}
}
+
+ /* Delete the action itself if it is empty. */
+ if (ANIM_remove_empty_action_from_animdata(adt)) {
+ changed = true;
+ }
}
}
CTX_DATA_END;
@@ -2205,8 +2274,9 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
continue;
}
- /* special exception for bones, as this makes this operator more convenient to use
- * NOTE: This is only done in pose mode. In object mode, we're dealing with the entire object.
+ /* Special exception for bones, as this makes this operator more convenient to use
+ * NOTE: This is only done in pose mode.
+ * In object mode, we're dealing with the entire object.
*/
if ((ob->mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) {
bPoseChannel *pchan;
@@ -2215,8 +2285,9 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
/* skip if bone is not selected */
if ((pchan) && (pchan->bone)) {
@@ -2224,15 +2295,18 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
bArmature *arm = (bArmature *)ob->data;
/* skipping - not visible on currently visible layers */
- if ((arm->layer & pchan->bone->layer) == 0)
+ if ((arm->layer & pchan->bone->layer) == 0) {
continue;
+ }
/* skipping - is currently hidden */
- if (pchan->bone->flag & BONE_HIDDEN_P)
+ if (pchan->bone->flag & BONE_HIDDEN_P) {
continue;
+ }
/* selection flag... */
- if ((pchan->bone->flag & BONE_SELECTED) == 0)
+ if ((pchan->bone->flag & BONE_SELECTED) == 0) {
continue;
+ }
}
}
@@ -2245,14 +2319,16 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
}
/* report success (or failure) */
- if (success)
+ if (success) {
BKE_reportf(op->reports,
RPT_INFO,
"Object '%s' successfully had %d keyframes removed",
id->name + 2,
success);
- else
+ }
+ else {
BKE_reportf(op->reports, RPT_ERROR, "No keyframes removed from Object '%s'", id->name + 2);
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
@@ -2355,8 +2431,9 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
const char *group = NULL;
/* Special exception for keyframing transforms:
- * Set "group" for this manually, instead of having them appearing at the bottom (ungrouped)
- * part of the channels list. Leaving these ungrouped is not a nice user behavior in this case.
+ * Set "group" for this manually, instead of having them appearing at the bottom
+ * (ungrouped) part of the channels list.
+ * Leaving these ungrouped is not a nice user behavior in this case.
*
* TODO: Perhaps we can extend this behavior in future for other properties...
*/
@@ -2526,8 +2603,9 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
bmain, op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0);
MEM_freeN(path);
}
- else if (G.debug & G_DEBUG)
+ else if (G.debug & G_DEBUG) {
printf("Button Delete-Key: no path to property\n");
+ }
}
}
else if (G.debug & G_DEBUG) {
@@ -2593,8 +2671,9 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
success += clear_keyframe(bmain, op->reports, ptr.id.data, NULL, NULL, path, index, 0);
MEM_freeN(path);
}
- else if (G.debug & G_DEBUG)
+ else if (G.debug & G_DEBUG) {
printf("Button Clear-Key: no path to property\n");
+ }
}
else if (G.debug & G_DEBUG) {
printf("ptr.data = %p, prop = %p\n", (void *)ptr.data, (void *)prop);
@@ -2637,8 +2716,9 @@ bool autokeyframe_cfra_can_key(Scene *scene, ID *id)
float cfra = (float)CFRA; // XXX for now, this will do
/* only filter if auto-key mode requires this */
- if (IS_AUTOKEY_ON(scene) == 0)
+ if (IS_AUTOKEY_ON(scene) == 0) {
return false;
+ }
if (IS_AUTOKEY_MODE(scene, EDITKEYS)) {
/* Replace Mode:
@@ -2669,8 +2749,9 @@ bool autokeyframe_cfra_can_key(Scene *scene, ID *id)
bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
{
/* quick sanity check */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return false;
+ }
/* we either include all regardless of muting, or only non-muted */
if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED) == 0) {
@@ -2682,8 +2763,9 @@ bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
*/
if (replace) {
/* sanity check: 'i' may in rare cases exceed arraylen */
- if ((i >= 0) && (i < fcu->totvert))
+ if ((i >= 0) && (i < fcu->totvert)) {
return true;
+ }
}
}
@@ -2713,20 +2795,24 @@ bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float fra
return !compare_ff_relative(fcurve_val, cur_val, FLT_EPSILON, 64);
}
-/* Checks whether an Action has a keyframe for a given frame
- * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found...
+/**
+ * Checks whether an Action has a keyframe for a given frame
+ * Since we're only concerned whether a keyframe exists,
+ * we can simply loop until a match is found.
*/
static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
{
FCurve *fcu;
/* can only find if there is data */
- if (act == NULL)
+ if (act == NULL) {
return false;
+ }
/* if only check non-muted, check if muted */
- if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED))
+ if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED)) {
return false;
+ }
/* loop over F-Curves, using binary-search to try to find matches
* - this assumes that keyframes are only beztriples
@@ -2734,8 +2820,9 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
/* only check if there are keyframes (currently only of type BezTriple) */
if (fcu->bezt && fcu->totvert) {
- if (fcurve_frame_has_keyframe(fcu, frame, filter))
+ if (fcurve_frame_has_keyframe(fcu, frame, filter)) {
return true;
+ }
}
}
@@ -2747,8 +2834,9 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
{
/* error checking */
- if (ob == NULL)
+ if (ob == NULL) {
return false;
+ }
/* check own animation data - specifically, the action it contains */
if ((ob->adt) && (ob->adt->action)) {
@@ -2758,8 +2846,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
*/
float ob_frame = BKE_nla_tweakedit_remap(ob->adt, frame, NLATIME_CONVERT_UNMAP);
- if (action_frame_has_keyframe(ob->adt->action, ob_frame, filter))
+ if (action_frame_has_keyframe(ob->adt->action, ob_frame, filter)) {
return true;
+ }
}
/* try shapekey keyframes (if available, and allowed by filter) */
@@ -2771,8 +2860,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
*/
/* 1. test for relative (with keyframes) */
- if (id_frame_has_keyframe((ID *)key, frame, filter))
+ if (id_frame_has_keyframe((ID *)key, frame, filter)) {
return true;
+ }
/* 2. test for time */
/* TODO... yet to be implemented (this feature may evolve before then anyway) */
@@ -2785,8 +2875,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
Material *ma = give_current_material(ob, (ob->actcol + 1));
/* we only retrieve the active material... */
- if (id_frame_has_keyframe((ID *)ma, frame, filter))
+ if (id_frame_has_keyframe((ID *)ma, frame, filter)) {
return true;
+ }
}
else {
int a;
@@ -2795,8 +2886,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
for (a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a + 1);
- if (id_frame_has_keyframe((ID *)ma, frame, filter))
+ if (id_frame_has_keyframe((ID *)ma, frame, filter)) {
return true;
+ }
}
}
}
@@ -2811,8 +2903,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
bool id_frame_has_keyframe(ID *id, float frame, short filter)
{
/* sanity checks */
- if (id == NULL)
+ if (id == NULL) {
return false;
+ }
/* perform special checks for 'macro' types */
switch (GS(id->name)) {
@@ -2828,8 +2921,9 @@ bool id_frame_has_keyframe(ID *id, float frame, short filter)
AnimData *adt = BKE_animdata_from_id(id);
/* only check keyframes in active action */
- if (adt)
+ if (adt) {
return action_frame_has_keyframe(adt->action, frame, filter);
+ }
break;
}
}
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 93bae636571..ab5e3186c47 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -76,8 +76,9 @@ static bool keyingset_poll_active_edit(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (scene == NULL)
+ if (scene == NULL) {
return 0;
+ }
/* there must be an active KeyingSet (and KeyingSets) */
return ((scene->active_keyingset > 0) && (scene->keyingsets.first));
@@ -89,12 +90,15 @@ static bool keyingset_poll_activePath_edit(bContext *C)
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
- if (scene == NULL)
+ if (scene == NULL) {
return 0;
- if (scene->active_keyingset <= 0)
+ }
+ if (scene->active_keyingset <= 0) {
return 0;
- else
+ }
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* there must be an active KeyingSet and an active path */
return ((ks) && (ks->paths.first) && (ks->active_path > 0));
@@ -157,8 +161,9 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot remove built in keying set");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* free KeyingSet's data, then remove it from the scene */
BKE_keyingset_free(ks);
@@ -201,8 +206,9 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active keying set to add empty path to");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* don't use the API method for this, since that checks on values... */
ksp = MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty");
@@ -307,8 +313,9 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op)
keyingflag |= ANIM_get_keyframing_flags(scene, 0);
- if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
+ if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) {
keyingflag |= INSERTKEY_XYZ2RGB;
+ }
/* call the API func, and set the active keyingset index */
ks = BKE_keyingset_add(
@@ -370,7 +377,7 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot)
/* callbacks */
ot->exec = add_keyingset_button_exec;
- //op->poll = ???
+ // op->poll = ???
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -452,7 +459,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot)
/* callbacks */
ot->exec = remove_keyingset_button_exec;
- //op->poll = ???
+ // op->poll = ???
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -461,7 +468,8 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot)
/* ******************************************* */
/* Change Active KeyingSet Operator ------------------------ */
-/* This operator checks if a menu should be shown for choosing the KeyingSet to make the active one */
+/* This operator checks if a menu should be shown
+ * for choosing the KeyingSet to make the active one. */
static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
@@ -526,36 +534,41 @@ ListBase builtin_keyingsets = {NULL, NULL};
/* --------------- */
-/* Find KeyingSet type info given a name */
+/* Find KeyingSet type info given a name. */
KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[])
{
/* sanity checks */
- if ((name == NULL) || (name[0] == 0))
+ if ((name == NULL) || (name[0] == 0)) {
return NULL;
+ }
/* search by comparing names */
return BLI_findstring(&keyingset_type_infos, name, offsetof(KeyingSetInfo, idname));
}
-/* Find builtin KeyingSet by name */
+/* Find builtin KeyingSet by name. */
KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[])
{
KeyingSet *ks, *first = NULL;
/* sanity checks any name to check? */
- if (name[0] == 0)
+ if (name[0] == 0) {
return NULL;
+ }
/* get first KeyingSet to use */
- if (prevKS && prevKS->next)
+ if (prevKS && prevKS->next) {
first = prevKS->next;
- else
+ }
+ else {
first = builtin_keyingsets.first;
+ }
/* loop over KeyingSets checking names */
for (ks = first; ks; ks = ks->next) {
- if (STREQ(name, ks->idname))
+ if (STREQ(name, ks->idname)) {
return ks;
+ }
}
/* complain about missing keying sets on debug builds */
@@ -569,7 +582,8 @@ KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[]
/* --------------- */
-/* Add the given KeyingSetInfo to the list of type infos, and create an appropriate builtin set too */
+/* Add the given KeyingSetInfo to the list of type infos,
+ * and create an appropriate builtin set too. */
void ANIM_keyingset_info_register(KeyingSetInfo *ksi)
{
KeyingSet *ks;
@@ -589,7 +603,8 @@ void ANIM_keyingset_info_register(KeyingSetInfo *ksi)
BLI_addtail(&keyingset_type_infos, ksi);
}
-/* Remove the given KeyingSetInfo from the list of type infos, and also remove the builtin set if appropriate */
+/* Remove the given KeyingSetInfo from the list of type infos,
+ * and also remove the builtin set if appropriate. */
void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi)
{
KeyingSet *ks, *ksn;
@@ -606,8 +621,9 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi)
BKE_keyingset_free(ks);
BLI_remlink(&builtin_keyingsets, ks);
- for (scene = bmain->scenes.first; scene; scene = scene->id.next)
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
BLI_remlink_safe(&scene->keyingsets, ks);
+ }
MEM_freeN(ks);
}
@@ -628,8 +644,9 @@ void ANIM_keyingset_infos_exit(void)
next = ksi->next;
/* free extra RNA data, and remove from list */
- if (ksi->ext.free)
+ if (ksi->ext.free) {
ksi->ext.free(ksi->ext.data);
+ }
BLI_freelinkN(&keyingset_type_infos, ksi);
}
@@ -641,8 +658,9 @@ void ANIM_keyingset_infos_exit(void)
bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id)
{
/* sanity checks */
- if (ELEM(NULL, ks, id))
+ if (ELEM(NULL, ks, id)) {
return false;
+ }
return BLI_findptr(&ks->paths, id, offsetof(KS_Path, id)) != NULL;
}
@@ -656,18 +674,21 @@ bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id)
KeyingSet *ANIM_scene_get_active_keyingset(Scene *scene)
{
/* if no scene, we've got no hope of finding the Keying Set */
- if (scene == NULL)
+ if (scene == NULL) {
return NULL;
+ }
/* currently, there are several possibilities here:
* - 0: no active keying set
* - > 0: one of the user-defined Keying Sets, but indices start from 0 (hence the -1)
* - < 0: a builtin keying set
*/
- if (scene->active_keyingset > 0)
+ if (scene->active_keyingset > 0) {
return BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
- else
+ }
+ else {
return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset) - 1);
+ }
}
/* Get the index of the Keying Set provided, for the given Scene */
@@ -676,8 +697,9 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
int index;
/* if no KeyingSet provided, have none */
- if (ks == NULL)
+ if (ks == NULL) {
return 0;
+ }
/* check if the KeyingSet exists in scene list */
if (scene) {
@@ -685,8 +707,9 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
* - (absolute) Scene KeyingSets are from (>= 1)
*/
index = BLI_findindex(&scene->keyingsets, ks);
- if (index != -1)
+ if (index != -1) {
return (index + 1);
+ }
}
/* still here, so try builtins list too
@@ -694,10 +717,12 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
* - none/invalid is (= 0)
*/
index = BLI_findindex(&builtin_keyingsets, ks);
- if (index != -1)
+ if (index != -1) {
return -(index + 1);
- else
+ }
+ else {
return 0;
+ }
}
/* Get Keying Set to use for Auto-Keyframing some transforms */
@@ -707,12 +732,15 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *transform
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
* or otherwise key transforms only
*/
- if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset))
+ if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset)) {
return ANIM_scene_get_active_keyingset(scene);
- else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL))
+ }
+ else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) {
return ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_AVAILABLE_ID);
- else
+ }
+ else {
return ANIM_builtin_keyingset_get_named(NULL, transformKSName);
+ }
}
/* Menu of All Keying Sets ----------------------------- */
@@ -832,8 +860,9 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks)
KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo);
/* get the associated 'type info' for this KeyingSet */
- if (ksi == NULL)
+ if (ksi == NULL) {
return 0;
+ }
/* TODO: check for missing callbacks! */
/* check if it can be used in the current context */
@@ -880,20 +909,24 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s
* - we must have somewhere to output the data
* - we must have both srna+data (and with id too optionally), or id by itself only
*/
- if (dsources == NULL)
+ if (dsources == NULL) {
return;
- if (ELEM(NULL, srna, data) && (id == NULL))
+ }
+ if (ELEM(NULL, srna, data) && (id == NULL)) {
return;
+ }
/* allocate new elem, and add to the list */
ds = MEM_callocN(sizeof(tRKS_DSource), "tRKS_DSource");
BLI_addtail(dsources, ds);
/* depending on what data we have, create using ID or full pointer call */
- if (srna && data)
+ if (srna && data) {
RNA_pointer_create(id, srna, data, &ds->ptr);
- else
+ }
+ else {
RNA_id_pointer_create(id, &ds->ptr);
+ }
}
/* KeyingSet Operations (Insert/Delete Keyframes) ------------ */
@@ -908,8 +941,9 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s
short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
{
/* sanity check */
- if (ks == NULL)
+ if (ks == NULL) {
return 0;
+ }
/* if relative Keying Sets, poll and build up the paths */
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
@@ -921,8 +955,9 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
BKE_keyingset_free(ks);
/* get the associated 'type info' for this KeyingSet */
- if (ksi == NULL)
+ if (ksi == NULL) {
return MODIFYKEY_MISSING_TYPEINFO;
+ }
/* TODO: check for missing callbacks! */
/* check if it can be used in the current context */
@@ -930,15 +965,18 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
/* if a list of data sources are provided, run a special iterator over them,
* otherwise, just continue per normal
*/
- if (dsources)
+ if (dsources) {
RKS_ITER_overrides_list(ksi, C, ks, dsources);
- else
+ }
+ else {
ksi->iter(ksi, C, ks);
+ }
/* if we don't have any paths now, then this still qualifies as invalid context */
// FIXME: we need some error conditions (to be retrieved from the iterator why this failed!)
- if (BLI_listbase_is_empty(&ks->paths))
+ if (BLI_listbase_is_empty(&ks->paths)) {
return MODIFYKEY_INVALID_CONTEXT;
+ }
}
else {
/* poll callback tells us that KeyingSet is useless in current context */
@@ -983,8 +1021,10 @@ static short keyingset_apply_keying_flags(const short base_flags,
return result;
}
-/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified
- * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets.
+/**
+ * Given a KeyingSet and context info (if required),
+ * modify keyframes for the channels specified by the KeyingSet.
+ * This takes into account many of the different combinations of using KeyingSets.
* Returns the number of channels that keyframes were added to
*/
int ANIM_apply_keyingset(
@@ -1002,16 +1042,18 @@ int ANIM_apply_keyingset(
char keytype = scene->toolsettings->keyframe_type;
/* sanity checks */
- if (ks == NULL)
+ if (ks == NULL) {
return 0;
+ }
/* get flags to use */
if (mode == MODIFYKEY_MODE_INSERT) {
/* use context settings as base */
kflag = keyingset_apply_keying_flags(base_kflags, ks->keyingoverride, ks->keyingflag);
}
- else if (mode == MODIFYKEY_MODE_DELETE)
+ else if (mode == MODIFYKEY_MODE_DELETE) {
kflag = 0;
+ }
/* if relative Keying Sets, poll and build up the paths */
success = ANIM_validate_keyingset(C, dsources, ks);
@@ -1037,16 +1079,20 @@ int ANIM_apply_keyingset(
continue;
}
- /* since keying settings can be defined on the paths too, apply the settings for this path first */
+ /* Since keying settings can be defined on the paths too,
+ * apply the settings for this path first. */
kflag2 = keyingset_apply_keying_flags(kflag, ksp->keyingoverride, ksp->keyingflag);
/* get pointer to name of group to add channels to */
- if (ksp->groupmode == KSP_GROUP_NONE)
+ if (ksp->groupmode == KSP_GROUP_NONE) {
groupname = NULL;
- else if (ksp->groupmode == KSP_GROUP_KSNAME)
+ }
+ else if (ksp->groupmode == KSP_GROUP_KSNAME) {
groupname = ks->name;
- else
+ }
+ else {
groupname = ksp->group;
+ }
/* init arraylen and i - arraylen should be greater than i so that
* normal non-array entries get keyframed correctly
@@ -1068,15 +1114,16 @@ int ANIM_apply_keyingset(
}
/* we should do at least one step */
- if (arraylen == i)
+ if (arraylen == i) {
arraylen++;
+ }
/* for each possible index, perform operation
* - assume that arraylen is greater than index
*/
for (; i < arraylen; i++) {
/* action to take depends on mode */
- if (mode == MODIFYKEY_MODE_INSERT)
+ if (mode == MODIFYKEY_MODE_INSERT) {
success += insert_keyframe(bmain,
depsgraph,
reports,
@@ -1089,9 +1136,11 @@ int ANIM_apply_keyingset(
keytype,
&nla_cache,
kflag2);
- else if (mode == MODIFYKEY_MODE_DELETE)
+ }
+ else if (mode == MODIFYKEY_MODE_DELETE) {
success += delete_keyframe(
bmain, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2);
+ }
}
/* set recalc-flags */
diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt
index 274fa86184d..71c7febe192 100644
--- a/source/blender/editors/armature/CMakeLists.txt
+++ b/source/blender/editors/armature/CMakeLists.txt
@@ -26,9 +26,9 @@ set(INC
../../makesrna
../../windowmanager
../../../../intern/clog
- ../../../../intern/guardedalloc
../../../../intern/eigen
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 6943d6bdc54..d02e58d48a9 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -79,14 +79,16 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name)
/* Bendy-Bone parameters */
bone->roll1 = 0.0f;
bone->roll2 = 0.0f;
- bone->curveInX = 0.0f;
- bone->curveInY = 0.0f;
- bone->curveOutX = 0.0f;
- bone->curveOutY = 0.0f;
+ bone->curve_in_x = 0.0f;
+ bone->curve_in_y = 0.0f;
+ bone->curve_out_x = 0.0f;
+ bone->curve_out_y = 0.0f;
bone->ease1 = 1.0f;
bone->ease2 = 1.0f;
- bone->scaleIn = 1.0f;
- bone->scaleOut = 1.0f;
+ bone->scale_in_x = 1.0f;
+ bone->scale_in_y = 1.0f;
+ bone->scale_out_x = 1.0f;
+ bone->scale_out_y = 1.0f;
return bone;
}
@@ -137,20 +139,23 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
/* find the active or selected bone */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
- if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone)
+ if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone) {
break;
+ }
}
}
if (ebone == NULL) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
- if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone)
+ if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone) {
break;
+ }
}
}
- if (ebone == NULL)
+ if (ebone == NULL) {
return OPERATOR_CANCELLED;
+ }
to_root = 1;
}
@@ -159,13 +164,15 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
/* we re-use code for mirror editing... */
flipbone = NULL;
- if (arm->flag & ARM_MIRROR_EDIT)
+ if (arm->flag & ARM_MIRROR_EDIT) {
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+ }
for (a = 0; a < 2; a++) {
if (a == 1) {
- if (flipbone == NULL)
+ if (flipbone == NULL) {
break;
+ }
else {
SWAP(EditBone *, flipbone, ebone);
}
@@ -190,8 +197,9 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
copy_v3_v3(newbone->tail, curs->location);
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
- if (a == 1)
+ if (a == 1) {
newbone->tail[0] = -newbone->tail[0];
+ }
copy_m3_m4(mat, obedit->obmat);
invert_m3_m3(imat, mat);
@@ -279,8 +287,9 @@ static EditBone *get_named_editbone(ListBase *edbo, const char *name)
if (name) {
for (eBone = edbo->first; eBone; eBone = eBone->next) {
- if (STREQ(name, eBone->name))
+ if (STREQ(name, eBone->name)) {
return eBone;
+ }
}
}
@@ -410,8 +419,9 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone,
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(curcon, &targets, 0);
+ }
}
}
}
@@ -442,8 +452,9 @@ EditBone *duplicateEditBoneObjects(
BLI_addtail(editbones, eBone);
/* copy the ID property */
- if (curBone->prop)
+ if (curBone->prop) {
eBone->prop = IDP_CopyProperty(curBone->prop);
+ }
/* Lets duplicate the list of constraints that the
* current bone has.
@@ -478,8 +489,9 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
const bool do_flip_names = RNA_boolean_get(op->ptr, "do_flip_names");
/* cancel if nothing selected */
- if (CTX_DATA_COUNT(C, selected_bones) == 0)
+ if (CTX_DATA_COUNT(C, selected_bones) == 0) {
return OPERATOR_CANCELLED;
+ }
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
@@ -888,8 +900,9 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_ROOTSEL) {
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
- if (ebone->parent->flag & BONE_TIPSEL)
+ if (ebone->parent->flag & BONE_TIPSEL) {
ebone->flag &= ~BONE_ROOTSEL;
+ }
}
}
}
@@ -920,18 +933,21 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (flipbone) {
forked_iter = 0; // we extrude 2 different bones
- if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED))
+ if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED)) {
/* don't want this bone to be selected... */
flipbone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
+ }
}
- if ((flipbone == NULL) && (forked_iter))
+ if ((flipbone == NULL) && (forked_iter)) {
flipbone = ebone;
+ }
}
for (a = 0; a < 2; a++) {
if (a == 1) {
- if (flipbone == NULL)
+ if (flipbone == NULL) {
break;
+ }
else {
SWAP(EditBone *, flipbone, ebone);
}
@@ -948,8 +964,9 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
/* copies it, in case mirrored bone */
newbone->flag = ebone->flag & (BONE_TIPSEL | BONE_RELATIVE_PARENTING);
- if (newbone->parent)
+ if (newbone->parent) {
newbone->flag |= BONE_CONNECTED;
+ }
}
else {
copy_v3_v3(newbone->head, ebone->head);
@@ -975,35 +992,41 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
/* Bendy-Bone parameters */
newbone->roll1 = ebone->roll1;
newbone->roll2 = ebone->roll2;
- newbone->curveInX = ebone->curveInX;
- newbone->curveInY = ebone->curveInY;
- newbone->curveOutX = ebone->curveOutX;
- newbone->curveOutY = ebone->curveOutY;
+ newbone->curve_in_x = ebone->curve_in_x;
+ newbone->curve_in_y = ebone->curve_in_y;
+ newbone->curve_out_x = ebone->curve_out_x;
+ newbone->curve_out_y = ebone->curve_out_y;
newbone->ease1 = ebone->ease1;
newbone->ease2 = ebone->ease2;
- newbone->scaleIn = ebone->scaleIn;
- newbone->scaleOut = ebone->scaleOut;
+ newbone->scale_in_x = ebone->scale_in_x;
+ newbone->scale_in_y = ebone->scale_in_y;
+ newbone->scale_out_x = ebone->scale_out_x;
+ newbone->scale_out_y = ebone->scale_out_y;
BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name));
if (flipbone && forked_iter) { // only set if mirror edit
if (strlen(newbone->name) < (MAXBONENAME - 2)) {
- if (a == 0)
+ if (a == 0) {
strcat(newbone->name, "_L");
- else
+ }
+ else {
strcat(newbone->name, "_R");
+ }
}
}
ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL);
/* Add the new bone to the list */
BLI_addtail(arm->edbo, newbone);
- if (!first)
+ if (!first) {
first = newbone;
+ }
/* restore ebone if we were flipping */
- if (a == 1 && flipbone)
+ if (a == 1 && flipbone) {
SWAP(EditBone *, flipbone, ebone);
+ }
}
}
@@ -1073,10 +1096,12 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
invert_m4_m4(obedit->imat, obedit->obmat);
mul_m4_v3(obedit->imat, curs);
- if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
+ if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) {
copy_m3_m4(obmat, rv3d->viewmat);
- else
+ }
+ else {
unit_m3(obmat);
+ }
copy_m3_m4(viewmat, obedit->obmat);
mul_m3_m3m3(totmat, obmat, viewmat);
@@ -1089,10 +1114,12 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
copy_v3_v3(bone->head, curs);
- if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
+ if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) {
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
- else
+ }
+ else {
add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
+ }
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -1136,8 +1163,7 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
/* loop over all editable bones */
// XXX the old code did this in reverse order though!
- CTX_DATA_BEGIN_WITH_ID(C, EditBone *, ebone, selected_editable_bones, bArmature *, arm)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, EditBone *, ebone, selected_editable_bones, bArmature *, arm) {
for (i = cuts + 1; i > 1; i--) {
/* compute cut ratio first */
float cutratio = 1.0f / (float)i;
@@ -1175,8 +1201,9 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
/* correct parent bones */
for (tbone = arm->edbo->first; tbone; tbone = tbone->next) {
- if (tbone->parent == ebone)
+ if (tbone->parent == ebone) {
tbone->parent = newbone;
+ }
}
newbone->parent = ebone;
}
@@ -1207,6 +1234,7 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot)
/* Properties */
prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, 1000, "Number of Cuts", "", 1, 10);
- /* avoid re-using last var because it can cause _very_ high poly meshes and annoy users (or worse crash) */
+ /* Avoid re-using last var because it can cause
+ * _very_ high poly meshes and annoy users (or worse crash) */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index dfcd0bf69f7..c5430e06b6e 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -334,8 +334,9 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
float cursor_rel[3];
sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
- if (axis_flip)
+ if (axis_flip) {
negate_v3(cursor_rel);
+ }
if (normalize_v3(cursor_rel) != 0.0f) {
ebone->roll = ED_armature_ebone_roll_to_vector(ebone, cursor_rel, axis_only);
changed = true;
@@ -375,8 +376,9 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
(ebone_other = ebone_other->parent));
if (!is_vec_zero) {
- if (axis_flip)
+ if (axis_flip) {
negate_v3(vec);
+ }
if (is_edit) {
ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only);
@@ -424,16 +426,19 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
else { /* Axis */
assert(type <= 5);
- if (type < 3)
+ if (type < 3) {
vec[type] = 1.0f;
- else
+ }
+ else {
vec[type - 2] = -1.0f;
+ }
mul_m3_v3(imat, vec);
normalize_v3(vec);
}
- if (axis_flip)
+ if (axis_flip) {
negate_v3(vec);
+ }
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
@@ -591,12 +596,14 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
}
}
- if (stop)
+ if (stop) {
break;
+ }
}
/* skip current bone if it is part of an existing chain */
- if (stop)
+ if (stop) {
continue;
+ }
/* is any existing chain part of the chain formed by this bone? */
stop = 0;
@@ -609,12 +616,14 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
}
}
- if (stop)
+ if (stop) {
break;
+ }
}
/* current bone has already been added to a chain? */
- if (stop)
+ if (stop) {
continue;
+ }
/* add current bone to a new chain */
ld = MEM_callocN(sizeof(LinkData), "BoneChain");
@@ -688,8 +697,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* loop over all bones, and only consider if visible */
bArmature *arm = NULL;
- CTX_DATA_BEGIN_WITH_ID(C, EditBone *, ebone, visible_bones, bArmature *, arm_iter)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, EditBone *, ebone, visible_bones, bArmature *, arm_iter) {
bool check = false;
if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL)) {
fill_add_joint(ebone, 0, &points);
@@ -818,17 +826,21 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* do parenting (will need to set connected flag too) */
if (headtail == 2) {
/* ebp tail or head - tail gets priority */
- if (ebp_a->tail_owner)
+ if (ebp_a->tail_owner) {
newbone->parent = ebp_a->tail_owner;
- else
+ }
+ else {
newbone->parent = ebp_a->head_owner;
+ }
}
else {
/* ebp_b tail or head - tail gets priority */
- if (ebp_b->tail_owner)
+ if (ebp_b->tail_owner) {
newbone->parent = ebp_b->tail_owner;
- else
+ }
+ else {
newbone->parent = ebp_b->head_owner;
+ }
}
/* don't set for bone connecting two head points of bones */
@@ -918,17 +930,17 @@ static void bones_merge(
newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE |
BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE);
- /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge
- * - potentially several tips for side chains leading to some tree exist...
+ /* Step 2a: reparent any side chains which may be parented to any bone in the chain
+ * of bones to merge - potentially several tips for side chains leading to some tree exist.
*/
for (chain = chains->first; chain; chain = chain->next) {
- /* traverse down chain until we hit the bottom or if we run into the tip of the chain of bones we're
- * merging (need to stop in this case to avoid corrupting this chain too!)
+ /* Traverse down chain until we hit the bottom or if we run into the tip of the chain of bones
+ * we're merging (need to stop in this case to avoid corrupting this chain too!).
*/
for (ebone = chain->data; (ebone) && (ebone != end); ebone = ebone->parent) {
short found = 0;
- /* check if this bone is parented to one in the merging chain
+ /* Check if this bone is parented to one in the merging chain
* ! WATCHIT: must only go check until end of checking chain
*/
for (ebo = end; (ebo) && (ebo != start->parent); ebo = ebo->parent) {
@@ -941,14 +953,16 @@ static void bones_merge(
}
/* carry on to the next tip now */
- if (found)
+ if (found) {
break;
+ }
}
}
/* step 2b: parent child of end to newbone (child from this chain) */
- if (endchild)
+ if (endchild) {
endchild->parent = newbone;
+ }
/* step 3: delete all bones between and including start and end */
for (ebo = end; ebo; ebo = ebone) {
@@ -1007,13 +1021,15 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
bend = ebo;
bchild = child;
}
- else
+ else {
bstart = ebo;
+ }
}
else {
/* chain is broken... merge any continuous segments then clear */
- if (bstart && bend)
+ if (bstart && bend) {
bones_merge(obedit, bstart, bend, bchild, &chains);
+ }
bstart = NULL;
bend = NULL;
@@ -1022,8 +1038,9 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
}
/* merge from bstart to bend if something not merged */
- if (bstart && bend)
+ if (bstart && bend) {
bones_merge(obedit, bstart, bend, bchild, &chains);
+ }
/* put back link */
BLI_insertlinkbefore(&chains, nchain, chain);
@@ -1138,10 +1155,12 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
* - connected flag is only set if points are coincidental
*/
ebo->parent = child;
- if ((child) && equals_v3v3(ebo->head, child->tail))
+ if ((child) && equals_v3v3(ebo->head, child->tail)) {
ebo->flag |= BONE_CONNECTED;
- else
+ }
+ else {
ebo->flag &= ~BONE_CONNECTED;
+ }
/* get next bones
* - child will become the new parent of next bone
@@ -1208,8 +1227,9 @@ static void fix_connected_bone(EditBone *ebone)
float diff[3];
if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) ||
- equals_v3v3(ebone->parent->tail, ebone->head))
+ equals_v3v3(ebone->parent->tail, ebone->head)) {
return;
+ }
/* if the parent has moved we translate child's head and tail accordingly */
sub_v3_v3v3(diff, ebone->parent->tail, ebone->head);
@@ -1272,8 +1292,9 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
* then just use actbone. Useful when doing upper arm to spine.
*/
actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
- if (actmirb == NULL)
+ if (actmirb == NULL) {
actmirb = actbone;
+ }
}
/* if there is only 1 selected bone, we assume that that is the active bone,
@@ -1287,8 +1308,9 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
if (actbone->parent) {
bone_align_to_bone(arm->edbo, actbone, actbone->parent);
- if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
+ if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent)) {
bone_align_to_bone(arm->edbo, actmirb, actmirb->parent);
+ }
BKE_reportf(op->reports, RPT_INFO, "Aligned bone '%s' to parent", actbone->name);
}
@@ -1305,10 +1327,12 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
/* align selected bones to the active one */
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
if (ELEM(ebone, actbone, actmirb) == 0) {
- if (ebone->flag & BONE_SELECTED)
+ if (ebone->flag & BONE_SELECTED) {
bone_align_to_bone(arm->edbo, ebone, actbone);
- else
+ }
+ else {
bone_align_to_bone(arm->edbo, ebone, actmirb);
+ }
}
}
CTX_DATA_END;
@@ -1402,8 +1426,9 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
bool changed_multi = false;
/* cancel if nothing selected */
- if (CTX_DATA_COUNT(C, selected_bones) == 0)
+ if (CTX_DATA_COUNT(C, selected_bones) == 0) {
return OPERATOR_CANCELLED;
+ }
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
@@ -1422,8 +1447,9 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
ebone_next = curBone->next;
if (arm->layer & curBone->layer) {
if (curBone->flag & BONE_SELECTED) {
- if (curBone == arm->act_edbone)
+ if (curBone == arm->act_edbone) {
arm->act_edbone = NULL;
+ }
ED_armature_ebone_remove(arm, curBone);
changed = true;
}
@@ -1644,8 +1670,9 @@ static int armature_hide_exec(bContext *C, wmOperator *op)
const int invert = RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0;
/* cancel if nothing selected */
- if (CTX_DATA_COUNT(C, selected_bones) == 0)
+ if (CTX_DATA_COUNT(C, selected_bones) == 0) {
return OPERATOR_CANCELLED;
+ }
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 09e4c1acae7..6c2d9fe8f42 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -162,10 +162,11 @@ typedef struct tPChanFCurveLink {
/** old bbone values (to be restored along with the transform properties) */
float roll1, roll2;
/** (NOTE: we haven't renamed these this time, as their names are already long enough) */
- float curveInX, curveInY;
- float curveOutX, curveOutY;
+ float curve_in_x, curve_in_y;
+ float curve_out_x, curve_out_y;
float ease1, ease2;
- float scaleIn, scaleOut;
+ float scale_in_x, scale_in_y;
+ float scale_out_x, scale_out_y;
/** copy of custom properties at start of operator (to be restored before each modal step) */
struct IDProperty *oldprops;
@@ -216,8 +217,9 @@ void POSE_OT_propagate(struct wmOperatorType *ot);
/* ******************************************************* */
/* Various Armature Edit/Pose Editing API's */
-/* Ideally, many of these defines would not be needed as everything would be strictly self-contained
- * within each file, but some tools still have a bit of overlap which makes things messy -- Feb 2013
+/* Ideally, many of these defines would not be needed as everything would be strictly
+ * self-contained within each file,
+ * but some tools still have a bit of overlap which makes things messy -- Feb 2013
*/
EditBone *make_boneList(struct ListBase *edbo, struct ListBase *bones, struct Bone *actBone);
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index b1f0297bb29..083967d5d41 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -130,8 +130,9 @@ static void constraint_bone_name_fix(Object *ob,
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(curcon, &targets, 0);
+ }
}
/* action constraints */
@@ -221,8 +222,9 @@ void ED_armature_bone_rename(Main *bmain,
/* Update any object constraints to use the new bone name */
for (cob = bmain->objects.first; cob; cob = cob->id.next) {
- if (cob->constraints.first)
+ if (cob->constraints.first) {
constraint_bone_name_fix(ob, &cob->constraints, oldname, newname);
+ }
if (cob->pose) {
bPoseChannel *pchan;
for (pchan = cob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -236,8 +238,9 @@ void ED_armature_bone_rename(Main *bmain,
if (ob->parent && (ob->parent->data == arm)) {
if (ob->partype == PARBONE) {
/* bone name in object */
- if (STREQ(ob->parsubstr, oldname))
+ if (STREQ(ob->parsubstr, oldname)) {
BLI_strncpy(ob->parsubstr, newname, MAXBONENAME);
+ }
}
}
@@ -255,8 +258,9 @@ void ED_armature_bone_rename(Main *bmain,
HookModifierData *hmd = (HookModifierData *)md;
if (hmd->object && (hmd->object->data == arm)) {
- if (STREQ(hmd->subtarget, oldname))
+ if (STREQ(hmd->subtarget, oldname)) {
BLI_strncpy(hmd->subtarget, newname, MAXBONENAME);
+ }
}
break;
}
@@ -264,12 +268,14 @@ void ED_armature_bone_rename(Main *bmain,
UVWarpModifierData *umd = (UVWarpModifierData *)md;
if (umd->object_src && (umd->object_src->data == arm)) {
- if (STREQ(umd->bone_src, oldname))
+ if (STREQ(umd->bone_src, oldname)) {
BLI_strncpy(umd->bone_src, newname, MAXBONENAME);
+ }
}
if (umd->object_dst && (umd->object_dst->data == arm)) {
- if (STREQ(umd->bone_dst, oldname))
+ if (STREQ(umd->bone_dst, oldname)) {
BLI_strncpy(umd->bone_dst, newname, MAXBONENAME);
+ }
}
break;
}
@@ -284,8 +290,9 @@ void ED_armature_bone_rename(Main *bmain,
bGPdata *gpd = (bGPdata *)ob->data;
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if ((gpl->parent != NULL) && (gpl->parent->data == arm)) {
- if (STREQ(gpl->parsubstr, oldname))
+ if (STREQ(gpl->parsubstr, oldname)) {
BLI_strncpy(gpl->parsubstr, newname, MAXBONENAME);
+ }
}
}
@@ -305,8 +312,9 @@ void ED_armature_bone_rename(Main *bmain,
case eGpencilModifierType_Hook: {
HookGpencilModifierData *hgp_md = (HookGpencilModifierData *)gp_md;
if (hgp_md->object && (hgp_md->object->data == arm)) {
- if (STREQ(hgp_md->subtarget, oldname))
+ if (STREQ(hgp_md->subtarget, oldname)) {
BLI_strncpy(hgp_md->subtarget, newname, MAXBONENAME);
+ }
}
break;
}
@@ -318,10 +326,12 @@ void ED_armature_bone_rename(Main *bmain,
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
}
- /* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since
- * other ID-blocks may have drivers referring to this bone [#29822]
- */
- // XXX: the ID here is for armatures, but most bone drivers are actually on the object instead...
+ /* Fix all animdata that may refer to this bone -
+ * we can't just do the ones attached to objects,
+ * since other ID-blocks may have drivers referring to this bone T29822. */
+
+ /* XXX: the ID here is for armatures,
+ * but most bone drivers are actually on the object instead. */
{
BKE_animdata_fix_paths_rename_all(&arm->id, "pose.bones", oldname, newname);
@@ -376,8 +386,8 @@ void ED_armature_bones_flip_names(Main *bmain,
BoneFlipNameData *bfn;
/* First pass: generate flip names, and blindly rename.
- * If rename did not yield expected result, store both bone's name and expected flipped one into temp list
- * for second pass. */
+ * If rename did not yield expected result,
+ * store both bone's name and expected flipped one into temp list for second pass. */
for (LinkData *link = bones_names->first; link; link = link->next) {
char name_flip[MAXBONENAME];
char *name = link->data;
@@ -397,8 +407,9 @@ void ED_armature_bones_flip_names(Main *bmain,
}
/* Second pass to handle the bones that have naming conflicts with other bones.
- * Note that if the other bone was not selected, its name was not flipped, so conflict remains and that second
- * rename simply generates a new numbered alternative name. */
+ * Note that if the other bone was not selected, its name was not flipped,
+ * so conflict remains and that second rename simply generates a new numbered alternative name.
+ */
for (bfn = bones_names_conflicts.first; bfn; bfn = bfn->next) {
ED_armature_bone_rename(bmain, arm, bfn->name, bfn->name_flip);
}
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index c820077fbf9..b53ae813f10 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -161,7 +161,7 @@ void ED_operatormacros_armature(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move",
"Extrude",
@@ -170,10 +170,11 @@ void ED_operatormacros_armature(void)
otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
RNA_boolean_set(otmacro->ptr, "forked", false);
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
- /* XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate?
- * that would require fixing a properties bug 19733 */
+ /* XXX would it be nicer to just be able to have standard extrude_move,
+ * but set the forked property separate?
+ * that would require fixing a properties bug T19733. */
ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked",
"Extrude Forked",
"Create new bones from the selected joints and move them",
@@ -181,7 +182,7 @@ void ED_operatormacros_armature(void)
otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
RNA_boolean_set(otmacro->ptr, "forked", true);
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
void ED_keymap_armature(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 6226059e794..b2ca1d84520 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -92,8 +92,9 @@ static void joined_armature_fix_links_constraints(
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
/* action constraint? (pose constraints only) */
@@ -116,9 +117,10 @@ typedef struct tJoinArmature_AdtFixData {
GHash *names_map;
} tJoinArmature_AdtFixData;
-/* Callback to pass to BKE_animdata_main_cb() for fixing driver ID's to point to the new ID */
-/* FIXME: For now, we only care about drivers here. When editing rigs, it's very rare to have animation
- * on the rigs being edited already, so it should be safe to skip these.
+/* Callback to pass to BKE_animdata_main_cb() for fixing driver ID's to point to the new ID. */
+/* FIXME: For now, we only care about drivers here.
+ * When editing rigs, it's very rare to have animation on the rigs being edited already,
+ * so it should be safe to skip these.
*/
static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
{
@@ -247,10 +249,12 @@ int join_armature_exec(bContext *C, wmOperator *op)
bool ok = false;
/* Ensure we're not in editmode and that the active object is an armature*/
- if (!ob_active || ob_active->type != OB_ARMATURE)
+ if (!ob_active || ob_active->type != OB_ARMATURE) {
return OPERATOR_CANCELLED;
- if (!arm || arm->edbo)
+ }
+ if (!arm || arm->edbo) {
return OPERATOR_CANCELLED;
+ }
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
if (ob_iter == ob_active) {
@@ -292,7 +296,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
/* Get Pose of current armature */
opose = ob_iter->pose;
ob_iter->mode &= ~OB_MODE_POSE;
- //BASACT->flag &= ~OB_MODE_POSE;
+ // BASACT->flag &= ~OB_MODE_POSE;
/* Find the difference matrix */
invert_m4_m4(oimat, ob_active->obmat);
@@ -428,9 +432,10 @@ static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *n
cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) {
- /* any targets which point to original armature are redirected to the new one only if:
- * - the target isn't origArm/newArm itself
- * - the target is one that can be found in newArm/origArm
+ /* Any targets which point to original armature
+ * are redirected to the new one only if:
+ * - The target isn't origArm/newArm itself.
+ * - The target is one that can be found in newArm/origArm.
*/
if (ct->subtarget[0] != 0) {
if (ct->tar == origArm) {
@@ -591,12 +596,13 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
Object *oldob, *newob;
Base *oldbase, *newbase;
- /* we are going to do this as follows (unlike every other instance of separate):
- * 1. exit editmode +posemode for active armature/base. Take note of what this is.
- * 2. duplicate base - BASACT is the new one now
- * 3. for each of the two armatures, enter editmode -> remove appropriate bones -> exit editmode + recalc
- * 4. fix constraint links
- * 5. make original armature active and enter editmode
+ /* We are going to do this as follows (unlike every other instance of separate):
+ * 1. Exit editmode +posemode for active armature/base. Take note of what this is.
+ * 2. Duplicate base - BASACT is the new one now
+ * 3. For each of the two armatures,
+ * enter editmode -> remove appropriate bones -> exit editmode + recalc.
+ * 4. Fix constraint links
+ * 5. Make original armature active and enter editmode
*/
/* 1) only edit-base selected */
@@ -606,7 +612,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
oldob = obedit;
oldbase = base_iter;
oldob->mode &= ~OB_MODE_POSE;
- //oldbase->flag &= ~OB_POSEMODE;
+ // oldbase->flag &= ~OB_POSEMODE;
ED_armature_from_edit(bmain, obedit->data);
ED_armature_edit_free(obedit->data);
@@ -672,7 +678,7 @@ void ARMATURE_OT_separate(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* ******************************************** Parenting ************************************************* */
+/* ********************************* Parenting ************************************************* */
/* armature parenting options */
#define ARM_PAR_CONNECT 1
@@ -694,8 +700,9 @@ static void bone_connect_to_new_parent(ListBase *edbo,
EditBone *ebone;
float offset[3];
- if ((selbone->parent) && (selbone->flag & BONE_CONNECTED))
+ if ((selbone->parent) && (selbone->flag & BONE_CONNECTED)) {
selbone->parent->flag &= ~(BONE_TIPSEL);
+ }
/* make actbone the parent of selbone */
selbone->parent = actbone;
@@ -757,51 +764,72 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
else if (arm->flag & ARM_MIRROR_EDIT) {
- /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone
- * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
+ /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone:
+ * - If there's a mirrored copy of selbone, try to find a mirrored copy of actbone
* (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
- * This is useful for arm-chains, for example parenting lower arm to upper arm
- * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
+ * This is useful for arm-chains, for example parenting lower arm to upper arm.
+ * - If there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
- if (actmirb == NULL)
+ if (actmirb == NULL) {
actmirb = actbone;
+ }
}
- /* if there is only 1 selected bone, we assume that that is the active bone,
- * since a user will need to have clicked on a bone (thus selecting it) to make it active
- */
- if (CTX_DATA_COUNT(C, selected_editable_bones) <= 1) {
+ /* If there is only 1 selected bone, we assume that that is the active bone,
+ * since a user will need to have clicked on a bone (thus selecting it) to make it active. */
+ bool is_active_only_selected = false;
+ if (actbone->flag & BONE_SELECTED) {
+ is_active_only_selected = true;
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
+ if (ebone != actbone) {
+ is_active_only_selected = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (is_active_only_selected) {
/* When only the active bone is selected, and it has a parent,
* connect it to the parent, as that is the only possible outcome.
*/
if (actbone->parent) {
bone_connect_to_existing_parent(actbone);
- if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
+ if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent)) {
bone_connect_to_existing_parent(actmirb);
+ }
}
}
else {
- /* Parent 'selected' bones to the active one
- * - the context iterator contains both selected bones and their mirrored copies,
- * so we assume that unselected bones are mirrored copies of some selected bone
- * - since the active one (and/or its mirror) will also be selected, we also need
+ /* Parent 'selected' bones to the active one:
+ * - The context iterator contains both selected bones and their mirrored copies,
+ * so we assume that unselected bones are mirrored copies of some selected bone.
+ * - Since the active one (and/or its mirror) will also be selected, we also need
* to check that we are not trying to operate on them, since such an operation
- * would cause errors
+ * would cause errors.
*/
- /* parent selected bones to the active one */
- CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
- if (ELEM(ebone, actbone, actmirb) == 0) {
- if (ebone->flag & BONE_SELECTED)
+ /* Parent selected bones to the active one. */
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
+ if (ebone != actbone) {
bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
- else
- bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val);
+ }
+
+ if (arm->flag & ARM_MIRROR_EDIT) {
+ EditBone *ebone_mirror = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+ if (ebone_mirror && (ebone_mirror->flag & BONE_SELECTED) == 0) {
+ if (ebone_mirror != actmirb) {
+ bone_connect_to_new_parent(arm->edbo, ebone_mirror, actmirb, val);
+ }
+ }
+ }
}
}
- CTX_DATA_END;
}
/* note, notifier might evolve */
@@ -814,25 +842,31 @@ static int armature_parent_set_invoke(bContext *C,
wmOperator *UNUSED(op),
const wmEvent *UNUSED(event))
{
- EditBone *actbone = CTX_data_active_bone(C);
- uiPopupMenu *pup = UI_popup_menu_begin(
- C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE);
- uiLayout *layout = UI_popup_menu_layout(pup);
- int allchildbones = 0;
-
- CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
- if (ebone != actbone) {
- if (ebone->parent != actbone)
- allchildbones = 1;
+ bool all_childbones = false;
+ {
+ Object *ob = CTX_data_edit_object(C);
+ bArmature *arm = ob->data;
+ EditBone *actbone = arm->act_edbone;
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
+ if (ebone != actbone) {
+ if (ebone->parent != actbone) {
+ all_childbones = true;
+ break;
+ }
+ }
+ }
}
}
- CTX_DATA_END;
+ uiPopupMenu *pup = UI_popup_menu_begin(
+ C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE);
+ uiLayout *layout = UI_popup_menu_layout(pup);
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT);
-
- /* ob becomes parent, make the associated menus */
- if (allchildbones)
+ if (all_childbones) {
+ /* Object becomes parent, make the associated menus. */
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET);
+ }
UI_popup_menu_end(C, pup);
@@ -871,8 +905,9 @@ static void editbone_clear_parent(EditBone *ebone, int mode)
ebone->parent->flag &= ~(BONE_TIPSEL);
}
- if (mode == 1)
+ if (mode == 1) {
ebone->parent = NULL;
+ }
ebone->flag &= ~BONE_CONNECTED;
}
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 0c493672d9e..fbbb68d2003 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -167,10 +167,12 @@ void *get_bone_from_selectbuffer(Base **bases,
if (is_editmode == false) {
base = ED_armature_base_and_bone_from_select_buffer(bases, bases_len, hitresult, &bone);
if (bone != NULL) {
- if (findunsel)
+ if (findunsel) {
sel = (bone->flag & BONE_SELECTED);
- else
+ }
+ else {
sel = !(bone->flag & BONE_SELECTED);
+ }
data = bone;
}
@@ -182,10 +184,12 @@ void *get_bone_from_selectbuffer(Base **bases,
else {
base = ED_armature_base_and_ebone_from_select_buffer(
bases, bases_len, hitresult, &ebone);
- if (findunsel)
+ if (findunsel) {
sel = (ebone->flag & BONE_SELECTED);
- else
+ }
+ else {
sel = !(ebone->flag & BONE_SELECTED);
+ }
data = ebone;
}
@@ -300,8 +304,9 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
Base *base = NULL;
bone = get_nearest_bone(C, event->mval, true, &base);
- if (!bone)
+ if (!bone) {
return OPERATOR_CANCELLED;
+ }
arm = base->object->data;
@@ -316,10 +321,12 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
}
}
- if (curBone->flag & BONE_CONNECTED)
+ if (curBone->flag & BONE_CONNECTED) {
next = curBone->parent;
- else
+ }
+ else {
next = NULL;
+ }
}
/* Select children */
@@ -343,8 +350,9 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
}
}
}
- if (!curBone)
+ if (!curBone) {
bone = NULL;
+ }
}
ED_armature_edit_sync_selection(arm->edbo);
@@ -515,12 +523,15 @@ cache_end:
if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) {
/* but also the unselected one */
if (findunsel) {
- if ((hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL) == 0)
+ if ((hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL) == 0) {
dep = 1;
- else if ((hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0)
+ }
+ else if ((hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0) {
dep = 1;
- else
+ }
+ else {
dep = 2;
+ }
}
else {
dep = 1;
@@ -529,10 +540,12 @@ cache_end:
else {
/* bone found */
if (findunsel) {
- if ((ebone->flag & BONE_SELECTED) == 0)
+ if ((ebone->flag & BONE_SELECTED) == 0) {
dep = 3;
- else
+ }
+ else {
dep = 4;
+ }
}
else {
dep = 3;
@@ -698,8 +711,9 @@ bool ED_armature_edit_select_pick(
/* deselect this bone */
nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED);
/* only deselect parent tip if it is not selected */
- if (!(nearBone->parent->flag & BONE_SELECTED))
+ if (!(nearBone->parent->flag & BONE_SELECTED)) {
nearBone->parent->flag &= ~BONE_TIPSEL;
+ }
}
else if (toggle) {
/* hold shift inverts this bone's selection */
@@ -707,8 +721,9 @@ bool ED_armature_edit_select_pick(
/* deselect this bone */
nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED);
/* only deselect parent tip if it is not selected */
- if (!(nearBone->parent->flag & BONE_SELECTED))
+ if (!(nearBone->parent->flag & BONE_SELECTED)) {
nearBone->parent->flag &= ~BONE_TIPSEL;
+ }
}
else {
/* select this bone */
@@ -731,24 +746,31 @@ bool ED_armature_edit_select_pick(
}
else if (toggle) {
/* hold shift inverts this bone's selection */
- if (nearBone->flag & BONE_SELECTED)
+ if (nearBone->flag & BONE_SELECTED) {
nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL);
- else
+ }
+ else {
nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
+ }
}
- else
+ else {
nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
+ }
}
}
else {
- if (extend)
+ if (extend) {
nearBone->flag |= selmask;
- else if (deselect)
+ }
+ else if (deselect) {
nearBone->flag &= ~selmask;
- else if (toggle && (nearBone->flag & selmask))
+ }
+ else if (toggle && (nearBone->flag & selmask)) {
nearBone->flag &= ~selmask;
- else
+ }
+ else {
nearBone->flag |= selmask;
+ }
}
ED_armature_edit_sync_selection(arm->edbo);
@@ -845,8 +867,8 @@ static bool armature_edit_select_op_apply(bArmature *arm,
}
/**
- * Perform a selection operation on elements which have been 'touched', use for lasso & border select
- * but can be used elsewhere too.
+ * Perform a selection operation on elements which have been 'touched',
+ * use for lasso & border select but can be used elsewhere too.
*
* Tagging is done via #EditBone.temp.i using: #BONESEL_ROOT, #BONESEL_TIP, #BONESEL_BONE
* And optionally ignoring end-points using the #BONESEL_ROOT, #BONESEL_TIP right shifted 16 bits.
@@ -1373,8 +1395,9 @@ static void select_similar_suffix(bContext *C)
BLI_string_split_suffix(ebone_act->name, body_tmp, suffix_act, sizeof(ebone_act->name));
- if (suffix_act[0] == '\0')
+ if (suffix_act[0] == '\0') {
return;
+ }
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
@@ -1429,11 +1452,13 @@ static void select_similar_data_pchan(bContext *C, const size_t bytes_size, cons
static void is_ancestor(EditBone *bone, EditBone *ancestor)
{
- if (bone->temp.ebone == ancestor || bone->temp.ebone == NULL)
+ if (bone->temp.ebone == ancestor || bone->temp.ebone == NULL) {
return;
+ }
- if (bone->temp.ebone->temp.ebone != NULL && bone->temp.ebone->temp.ebone != ancestor)
+ if (bone->temp.ebone->temp.ebone != NULL && bone->temp.ebone->temp.ebone != ancestor) {
is_ancestor(bone->temp.ebone, ancestor);
+ }
bone->temp.ebone = bone->temp.ebone->temp.ebone;
}
@@ -1451,8 +1476,9 @@ static void select_similar_children(bContext *C)
for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
is_ancestor(ebone_iter, ebone_act);
- if (ebone_iter->temp.ebone == ebone_act && EBONE_SELECTABLE(arm, ebone_iter))
+ if (ebone_iter->temp.ebone == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) {
ED_armature_ebone_select_set(ebone_iter, true);
+ }
}
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -1757,8 +1783,9 @@ static bool armature_shortest_path_select(
{
do {
- if (!use_parent && (ebone_child == ebone_parent))
+ if (!use_parent && (ebone_child == ebone_parent)) {
break;
+ }
if (is_test) {
if (!EBONE_SELECTABLE(arm, ebone_child)) {
@@ -1769,8 +1796,9 @@ static bool armature_shortest_path_select(
ED_armature_ebone_selectflag_set(ebone_child, (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL));
}
- if (ebone_child == ebone_parent)
+ if (ebone_child == ebone_parent) {
break;
+ }
ebone_child = ebone_child->parent;
} while (true);
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index afbeb8e4377..08de699a70b 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -55,7 +55,7 @@
#include "armature_intern.h"
#include "meshlaplacian.h"
-/* ********************************** Bone Skinning *********************************************** */
+/* ******************************* Bone Skinning *********************************************** */
static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap)
{
@@ -93,10 +93,12 @@ static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap)
if (!(data->is_weight_paint) || !(bone->flag & BONE_HIDDEN_P)) {
if (!(bone->flag & BONE_NO_DEFORM)) {
if (data->heat && data->armob->pose &&
- BKE_pose_channel_find_name(data->armob->pose, bone->name))
+ BKE_pose_channel_find_name(data->armob->pose, bone->name)) {
segments = bone->segments;
- else
+ }
+ else {
segments = 1;
+ }
if (data->list != NULL) {
hbone = (Bone ***)&data->list;
@@ -165,10 +167,12 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
if (!data->is_weight_paint || !(bone->flag & BONE_HIDDEN_P)) {
if (!(bone->flag & BONE_NO_DEFORM)) {
if (data->heat && data->armob->pose &&
- BKE_pose_channel_find_name(data->armob->pose, bone->name))
+ BKE_pose_channel_find_name(data->armob->pose, bone->name)) {
segments = bone->segments;
- else
+ }
+ else {
segments = 1;
+ }
if (!data->is_weight_paint || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) {
if (!(defgroup = defgroup_find_name(ob, bone->name))) {
@@ -231,8 +235,9 @@ static void envelope_bone_weighting(Object *ob,
/* for each skinnable bone */
for (j = 0; j < numbones; ++j) {
- if (!selected[j])
+ if (!selected[j]) {
continue;
+ }
bone = bonelist[j];
dgroup = dgrouplist[j];
@@ -246,17 +251,21 @@ static void envelope_bone_weighting(Object *ob,
bone->dist * scale);
/* add the vert to the deform group if (weight != 0.0) */
- if (distance != 0.0f)
+ if (distance != 0.0f) {
ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE);
- else
+ }
+ else {
ED_vgroup_vert_remove(ob, dgroup, i);
+ }
/* do same for mirror */
if (dgroupflip && dgroupflip[j] && iflip != -1) {
- if (distance != 0.0f)
+ if (distance != 0.0f) {
ED_vgroup_vert_add(ob, dgroupflip[j], iflip, distance, WEIGHT_REPLACE);
- else
+ }
+ else {
ED_vgroup_vert_remove(ob, dgroupflip[j], iflip);
+ }
}
}
}
@@ -308,11 +317,13 @@ static void add_verts_to_dgroups(ReportList *reports,
/* count the number of skinnable bones */
numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb);
- if (numbones == 0)
+ if (numbones == 0) {
return;
+ }
- if (BKE_object_defgroup_data_create(ob->data) == NULL)
+ if (BKE_object_defgroup_data_create(ob->data) == NULL) {
return;
+ }
/* create an array of pointer to bones that are skinnable
* and fill it with all of the skinnable bones */
@@ -377,11 +388,13 @@ static void add_verts_to_dgroups(ReportList *reports,
/* set selected */
if (wpmode) {
- if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))
+ if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED)) {
selected[j] = 1;
+ }
}
- else
+ else {
selected[j] = 1;
+ }
/* find flipped group */
if (dgroup && mirror) {
@@ -415,8 +428,9 @@ static void add_verts_to_dgroups(ReportList *reports,
/* transform verts to global space */
for (i = 0; i < mesh->totvert; i++) {
- if (!vertsfilled)
+ if (!vertsfilled) {
copy_v3_v3(verts[i], mesh->mvert[i].co);
+ }
mul_m4_v3(ob->obmat, verts[i]);
}
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 50289197ed4..b23081cd6fa 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -56,16 +56,20 @@ void ED_armature_edit_sync_selection(ListBase *edbo)
/* if bone is not selectable, we shouldn't alter this setting... */
if ((ebo->flag & BONE_UNSELECTABLE) == 0) {
if ((ebo->flag & BONE_CONNECTED) && (ebo->parent)) {
- if (ebo->parent->flag & BONE_TIPSEL)
+ if (ebo->parent->flag & BONE_TIPSEL) {
ebo->flag |= BONE_ROOTSEL;
- else
+ }
+ else {
ebo->flag &= ~BONE_ROOTSEL;
+ }
}
- if ((ebo->flag & BONE_TIPSEL) && (ebo->flag & BONE_ROOTSEL))
+ if ((ebo->flag & BONE_TIPSEL) && (ebo->flag & BONE_ROOTSEL)) {
ebo->flag |= BONE_SELECTED;
- else
+ }
+ else {
ebo->flag &= ~BONE_SELECTED;
+ }
}
}
}
@@ -75,8 +79,9 @@ void ED_armature_edit_validate_active(struct bArmature *arm)
EditBone *ebone = arm->act_edbone;
if (ebone) {
- if (ebone->flag & BONE_HIDDEN_A)
+ if (ebone->flag & BONE_HIDDEN_A) {
arm->act_edbone = NULL;
+ }
}
}
@@ -116,8 +121,9 @@ int bone_looper(Object *ob, Bone *bone, void *data, int (*bone_func)(Object *, B
void bone_free(bArmature *arm, EditBone *bone)
{
- if (arm->act_edbone == bone)
+ if (arm->act_edbone == bone) {
arm->act_edbone = NULL;
+ }
if (bone->prop) {
IDP_FreeProperty(bone->prop);
@@ -165,8 +171,9 @@ void ED_armature_ebone_remove(bArmature *arm, EditBone *exBone)
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child)
{
for (ebone_child = ebone_child->parent; ebone_child; ebone_child = ebone_child->parent) {
- if (ebone_child == ebone_parent)
+ if (ebone_child == ebone_parent) {
return true;
+ }
}
return false;
}
@@ -274,8 +281,9 @@ EditBone *ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo)
{
char name_flip[MAXBONENAME];
- if (ebo == NULL)
+ if (ebo == NULL) {
return NULL;
+ }
BLI_string_flip_side_name(name_flip, ebo->name, false, sizeof(name_flip));
@@ -301,8 +309,9 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
if (arm->layer & curBone->layer) {
if (curBone->flag & flag) {
ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
- if (ebone_mirr)
+ if (ebone_mirr) {
ebone_mirr->flag |= (curBone->flag & flag);
+ }
}
}
}
@@ -381,7 +390,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
eboflip->tail[2] = ebo->tail[2];
eboflip->rad_tail = ebo->rad_tail;
eboflip->roll = -ebo->roll;
- eboflip->curveOutX = -ebo->curveOutX;
+ eboflip->curve_out_x = -ebo->curve_out_x;
eboflip->roll2 = -ebo->roll2;
/* Also move connected children, in case children's name aren't mirrored properly */
@@ -398,7 +407,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
eboflip->head[2] = ebo->head[2];
eboflip->rad_head = ebo->rad_head;
eboflip->roll = -ebo->roll;
- eboflip->curveInX = -ebo->curveInX;
+ eboflip->curve_in_x = -ebo->curve_in_x;
eboflip->roll1 = -ebo->roll1;
/* Also move connected parent, in case parent's name isn't mirrored properly */
@@ -414,8 +423,8 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
eboflip->xwidth = ebo->xwidth;
eboflip->zwidth = ebo->zwidth;
- eboflip->curveInX = -ebo->curveInX;
- eboflip->curveOutX = -ebo->curveOutX;
+ eboflip->curve_in_x = -ebo->curve_in_x;
+ eboflip->curve_out_x = -ebo->curve_out_x;
eboflip->roll1 = -ebo->roll1;
eboflip->roll2 = -ebo->roll2;
}
@@ -457,8 +466,8 @@ static EditBone *make_boneList_rec(ListBase *edbo,
eBone->parent->flag |= BONE_TIPSEL;
}
- /* For connected bones, take care when changing the selection when we have a connected parent,
- * this flag is a copy of '(eBone->parent->flag & BONE_TIPSEL)'. */
+ /* For connected bones, take care when changing the selection when we have a
+ * connected parent, this flag is a copy of '(eBone->parent->flag & BONE_TIPSEL)'. */
eBone->flag |= BONE_ROOTSEL;
}
else {
@@ -487,32 +496,37 @@ static EditBone *make_boneList_rec(ListBase *edbo,
/* Bendy-Bone parameters */
eBone->roll1 = curBone->roll1;
eBone->roll2 = curBone->roll2;
- eBone->curveInX = curBone->curveInX;
- eBone->curveInY = curBone->curveInY;
- eBone->curveOutX = curBone->curveOutX;
- eBone->curveOutY = curBone->curveOutY;
+ eBone->curve_in_x = curBone->curve_in_x;
+ eBone->curve_in_y = curBone->curve_in_y;
+ eBone->curve_out_x = curBone->curve_out_x;
+ eBone->curve_out_y = curBone->curve_out_y;
eBone->ease1 = curBone->ease1;
eBone->ease2 = curBone->ease2;
- eBone->scaleIn = curBone->scaleIn;
- eBone->scaleOut = curBone->scaleOut;
+ eBone->scale_in_x = curBone->scale_in_x;
+ eBone->scale_in_y = curBone->scale_in_y;
+ eBone->scale_out_x = curBone->scale_out_x;
+ eBone->scale_out_y = curBone->scale_out_y;
eBone->bbone_prev_type = curBone->bbone_prev_type;
eBone->bbone_next_type = curBone->bbone_next_type;
- if (curBone->prop)
+ if (curBone->prop) {
eBone->prop = IDP_CopyProperty(curBone->prop);
+ }
BLI_addtail(edbo, eBone);
/* Add children if necessary */
if (curBone->childbase.first) {
eBoneTest = make_boneList_rec(edbo, &curBone->childbase, eBone, actBone);
- if (eBoneTest)
+ if (eBoneTest) {
eBoneAct = eBoneTest;
+ }
}
- if (curBone == actBone)
+ if (curBone == actBone) {
eBoneAct = eBone;
+ }
}
return eBoneAct;
@@ -551,9 +565,11 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, struct Bone *actBone)
/**
* This function:
* - Sets local head/tail rest locations using parent bone's arm_mat.
- * - Calls #BKE_armature_where_is_bone() which uses parent's transform (arm_mat) to define this bone's transform.
+ * - Calls #BKE_armature_where_is_bone() which uses parent's transform (arm_mat)
+ * to define this bone's transform.
* - Fixes (converts) EditBone roll into Bone roll.
- * - Calls again #BKE_armature_where_is_bone(), since roll fiddling may have changed things for our bone...
+ * - Calls again #BKE_armature_where_is_bone(),
+ * since roll fiddling may have changed things for our bone.
*
* \note The order is crucial here, we can only handle child
* if all its parents in chain have already been handled (this is ensured by recursive process).
@@ -565,8 +581,8 @@ static void armature_finalize_restpose(ListBase *bonelist, ListBase *editbonelis
for (curBone = bonelist->first; curBone; curBone = curBone->next) {
/* Set bone's local head/tail.
- * Note that it's important to use final parent's restpose (arm_mat) here, instead of setting those values
- * from editbone's matrix (see T46010). */
+ * Note that it's important to use final parent's restpose (arm_mat) here,
+ * instead of setting those values from editbone's matrix (see T46010). */
if (curBone->parent) {
float parmat_inv[4][4];
@@ -610,7 +626,7 @@ static void armature_finalize_restpose(ListBase *bonelist, ListBase *editbonelis
print_m4("premat", premat);
print_m4("postmat", postmat);
print_m4("difmat", difmat);
- printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
+ printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
#endif
curBone->roll = -atan2f(difmat[2][0], difmat[2][2]);
@@ -646,11 +662,13 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
/* Find any bones that refer to this bone */
for (fBone = arm->edbo->first; fBone; fBone = fBone->next) {
- if (fBone->parent == eBone)
+ if (fBone->parent == eBone) {
fBone->parent = eBone->parent;
+ }
}
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Warning: removed zero sized bone: %s\n", eBone->name);
+ }
bone_free(arm, eBone);
}
}
@@ -690,20 +708,23 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
/* Bendy-Bone parameters */
newBone->roll1 = eBone->roll1;
newBone->roll2 = eBone->roll2;
- newBone->curveInX = eBone->curveInX;
- newBone->curveInY = eBone->curveInY;
- newBone->curveOutX = eBone->curveOutX;
- newBone->curveOutY = eBone->curveOutY;
+ newBone->curve_in_x = eBone->curve_in_x;
+ newBone->curve_in_y = eBone->curve_in_y;
+ newBone->curve_out_x = eBone->curve_out_x;
+ newBone->curve_out_y = eBone->curve_out_y;
newBone->ease1 = eBone->ease1;
newBone->ease2 = eBone->ease2;
- newBone->scaleIn = eBone->scaleIn;
- newBone->scaleOut = eBone->scaleOut;
+ newBone->scale_in_x = eBone->scale_in_x;
+ newBone->scale_in_y = eBone->scale_in_y;
+ newBone->scale_out_x = eBone->scale_out_x;
+ newBone->scale_out_y = eBone->scale_out_y;
newBone->bbone_prev_type = eBone->bbone_prev_type;
newBone->bbone_next_type = eBone->bbone_next_type;
- if (eBone->prop)
+ if (eBone->prop) {
newBone->prop = IDP_CopyProperty(eBone->prop);
+ }
}
/* Fix parenting in a separate pass to ensure ebone->bone connections are valid at this point.
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index febe2a49174..81030c7f199 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -122,10 +122,12 @@ static void laplacian_increase_edge_count(EdgeHash *edgehash, int v1, int v2)
{
void **p;
- if (BLI_edgehash_ensure_p(edgehash, v1, v2, &p))
+ if (BLI_edgehash_ensure_p(edgehash, v1, v2, &p)) {
*p = (void *)((intptr_t)*p + (intptr_t)1);
- else
+ }
+ else {
*p = (void *)((intptr_t)1);
+ }
}
static int laplacian_edge_count(EdgeHash *edgehash, int v1, int v2)
@@ -147,12 +149,15 @@ static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3
t2 = cotangent_tri_weight_v3(v2, v3, v1);
t3 = cotangent_tri_weight_v3(v3, v1, v2);
- if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f))
+ if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) {
obtuse = 1;
- else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f))
+ }
+ else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) {
obtuse = 2;
- else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f))
+ }
+ else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) {
obtuse = 3;
+ }
if (obtuse > 0) {
area = area_tri_v3(v1, v2, v3);
@@ -228,10 +233,12 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac
sys->storeweights = 0;
/* create linear solver */
- if (lsq)
+ if (lsq) {
sys->context = EIG_linear_least_squares_solver_new(0, totvert, 1);
- else
+ }
+ else {
sys->context = EIG_linear_solver_new(0, totvert, 1);
+ }
return sys;
}
@@ -267,28 +274,35 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
laplacian_increase_edge_count(sys->edgehash, (*face)[2], (*face)[0]);
}
- if (sys->areaweights)
- for (a = 0, face = sys->faces; a < sys->totface; a++, face++)
+ if (sys->areaweights) {
+ for (a = 0, face = sys->faces; a < sys->totface; a++, face++) {
laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]);
+ }
+ }
for (a = 0; a < totvert; a++) {
if (sys->areaweights) {
- if (sys->varea[a] != 0.0f)
+ if (sys->varea[a] != 0.0f) {
sys->varea[a] = 0.5f / sys->varea[a];
+ }
}
- else
+ else {
sys->varea[a] = 1.0f;
+ }
/* for heat weighting */
- if (sys->heat.H)
+ if (sys->heat.H) {
EIG_linear_solver_matrix_add(sys->context, a, a, sys->heat.H[a]);
+ }
}
- if (sys->storeweights)
+ if (sys->storeweights) {
sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight");
+ }
- for (a = 0, face = sys->faces; a < totface; a++, face++)
+ for (a = 0, face = sys->faces; a < totface; a++, face++) {
laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]);
+ }
MEM_freeN(sys->faces);
sys->faces = NULL;
@@ -304,16 +318,21 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
static void laplacian_system_delete(LaplacianSystem *sys)
{
- if (sys->verts)
+ if (sys->verts) {
MEM_freeN(sys->verts);
- if (sys->varea)
+ }
+ if (sys->varea) {
MEM_freeN(sys->varea);
- if (sys->vpinned)
+ }
+ if (sys->vpinned) {
MEM_freeN(sys->vpinned);
- if (sys->faces)
+ }
+ if (sys->faces) {
MEM_freeN(sys->faces);
- if (sys->fweights)
+ }
+ if (sys->fweights) {
MEM_freeN(sys->fweights);
+ }
EIG_linear_solver_delete(sys->context);
MEM_freeN(sys);
@@ -346,7 +365,7 @@ int laplacian_system_solve(LaplacianSystem *sys)
{
sys->variablesdone = false;
- //EIG_linear_solver_print_matrix(sys->context, );
+ // EIG_linear_solver_print_matrix(sys->context, );
return EIG_linear_solver_solve(sys->context);
}
@@ -432,7 +451,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2);
- //Setup inverse pointers to use on isect.orig
+ // Setup inverse pointers to use on isect.orig
sys->heat.vltree[vtri[0]] = lt;
sys->heat.vltree[vtri[1]] = lt;
sys->heat.vltree[vtri[2]] = lt;
@@ -450,8 +469,9 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
int visible;
lt = sys->heat.vltree[vertex];
- if (lt == NULL)
+ if (lt == NULL) {
return 1;
+ }
data.sys = sys;
copy_v3_v3(data.start, sys->heat.verts[vertex]);
@@ -496,9 +516,11 @@ static int heat_source_closest(LaplacianSystem *sys, int vertex, int source)
dist = heat_source_distance(sys, vertex, source);
- if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON))
- if (heat_ray_source_visible(sys, vertex, source))
+ if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON)) {
+ if (heat_ray_source_visible(sys, vertex, source)) {
return 1;
+ }
+ }
return 0;
}
@@ -514,16 +536,19 @@ static void heat_set_H(LaplacianSystem *sys, int vertex)
for (j = 0; j < sys->heat.numsource; j++) {
dist = heat_source_distance(sys, vertex, j);
- if (dist < mindist)
+ if (dist < mindist) {
mindist = dist;
+ }
}
sys->heat.mindist[vertex] = mindist;
/* count number of sources with approximately this minimum distance */
- for (j = 0; j < sys->heat.numsource; j++)
- if (heat_source_closest(sys, vertex, j))
+ for (j = 0; j < sys->heat.numsource; j++) {
+ if (heat_source_closest(sys, vertex, j)) {
numclosest++;
+ }
+ }
sys->heat.p[vertex] = (numclosest > 0) ? 1.0f / numclosest : 0.0f;
@@ -532,8 +557,9 @@ static void heat_set_H(LaplacianSystem *sys, int vertex)
mindist = max_ff(mindist, 1e-4f);
h = numclosest * C_WEIGHT / (mindist * mindist);
}
- else
+ else {
h = 0.0f;
+ }
sys->heat.H[vertex] = h;
}
@@ -557,8 +583,9 @@ static void heat_calc_vnormals(LaplacianSystem *sys)
add_v3_v3(sys->heat.vnors[v3], fnor);
}
- for (a = 0; a < sys->totvert; a++)
+ for (a = 0; a < sys->totvert; a++) {
normalize_v3(sys->heat.vnors[a]);
+ }
}
static void heat_laplacian_create(LaplacianSystem *sys)
@@ -575,8 +602,9 @@ static void heat_laplacian_create(LaplacianSystem *sys)
sys->heat.p = MEM_callocN(sizeof(float) * totvert, "HeatP");
/* add verts and faces to laplacian */
- for (a = 0; a < totvert; a++)
+ for (a = 0; a < totvert; a++) {
laplacian_add_vertex(sys, sys->heat.verts[a], 0);
+ }
for (a = 0, lt = mlooptri; a < tottri; a++, lt++) {
int vtri[3];
@@ -589,8 +617,9 @@ static void heat_laplacian_create(LaplacianSystem *sys)
/* for distance computation in set_H */
heat_calc_vnormals(sys);
- for (a = 0; a < totvert; a++)
+ for (a = 0; a < totvert; a++) {
heat_set_H(sys, a);
+ }
}
static void heat_system_free(LaplacianSystem *sys)
@@ -616,8 +645,9 @@ static float heat_limit_weight(float weight)
t = (weight - WEIGHT_LIMIT_END) / (WEIGHT_LIMIT_START - WEIGHT_LIMIT_END);
return t * WEIGHT_LIMIT_START;
}
- else
+ else {
return weight;
+ }
}
void heat_bone_weighting(Object *ob,
@@ -695,14 +725,16 @@ void heat_bone_weighting(Object *ob,
if (dgroupflip) {
vertsflipped = MEM_callocN(sizeof(int) * me->totvert, "vertsflipped");
- for (a = 0; a < me->totvert; a++)
+ for (a = 0; a < me->totvert; a++) {
vertsflipped[a] = mesh_get_x_mirror_vert(ob, NULL, a, use_topology);
+ }
}
/* compute weights per bone */
for (j = 0; j < numsource; j++) {
- if (!selected[j])
+ if (!selected[j]) {
continue;
+ }
firstsegment = (j == 0 || dgrouplist[j - 1] != dgrouplist[j]);
lastsegment = (j == numsource - 1 || dgrouplist[j] != dgrouplist[j + 1]);
@@ -711,55 +743,66 @@ void heat_bone_weighting(Object *ob,
/* clear weights */
if (bbone && firstsegment) {
for (a = 0; a < me->totvert; a++) {
- if (mask && !mask[a])
+ if (mask && !mask[a]) {
continue;
+ }
ED_vgroup_vert_remove(ob, dgrouplist[j], a);
- if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0)
+ if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) {
ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]);
+ }
}
}
/* fill right hand side */
laplacian_begin_solve(sys, -1);
- for (a = 0; a < me->totvert; a++)
- if (heat_source_closest(sys, a, j))
+ for (a = 0; a < me->totvert; a++) {
+ if (heat_source_closest(sys, a, j)) {
laplacian_add_right_hand_side(sys, a, sys->heat.H[a] * sys->heat.p[a]);
+ }
+ }
/* solve */
if (laplacian_system_solve(sys)) {
/* load solution into vertex groups */
for (a = 0; a < me->totvert; a++) {
- if (mask && !mask[a])
+ if (mask && !mask[a]) {
continue;
+ }
solution = laplacian_system_get_solution(sys, a);
if (bbone) {
- if (solution > 0.0f)
+ if (solution > 0.0f) {
ED_vgroup_vert_add(ob, dgrouplist[j], a, solution, WEIGHT_ADD);
+ }
}
else {
weight = heat_limit_weight(solution);
- if (weight > 0.0f)
+ if (weight > 0.0f) {
ED_vgroup_vert_add(ob, dgrouplist[j], a, weight, WEIGHT_REPLACE);
- else
+ }
+ else {
ED_vgroup_vert_remove(ob, dgrouplist[j], a);
+ }
}
/* do same for mirror */
if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) {
if (bbone) {
- if (solution > 0.0f)
+ if (solution > 0.0f) {
ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], solution, WEIGHT_ADD);
+ }
}
else {
weight = heat_limit_weight(solution);
- if (weight > 0.0f)
+ if (weight > 0.0f) {
ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], weight, WEIGHT_REPLACE);
- else
+ }
+ else {
ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]);
+ }
}
}
}
@@ -772,29 +815,34 @@ void heat_bone_weighting(Object *ob,
/* remove too small vertex weights */
if (bbone && lastsegment) {
for (a = 0; a < me->totvert; a++) {
- if (mask && !mask[a])
+ if (mask && !mask[a]) {
continue;
+ }
weight = ED_vgroup_vert_weight(ob, dgrouplist[j], a);
weight = heat_limit_weight(weight);
- if (weight <= 0.0f)
+ if (weight <= 0.0f) {
ED_vgroup_vert_remove(ob, dgrouplist[j], a);
+ }
if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) {
weight = ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]);
weight = heat_limit_weight(weight);
- if (weight <= 0.0f)
+ if (weight <= 0.0f) {
ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]);
+ }
}
}
}
}
/* free */
- if (vertsflipped)
+ if (vertsflipped) {
MEM_freeN(vertsflipped);
- if (mask)
+ }
+ if (mask) {
MEM_freeN(mask);
+ }
heat_system_free(sys);
@@ -964,8 +1012,9 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb,
float end[3], vec_normal[3];
/* happens binding when a cage has no faces */
- if (UNLIKELY(mdb->bvhtree == NULL))
+ if (UNLIKELY(mdb->bvhtree == NULL)) {
return NULL;
+ }
/* setup isec */
memset(&isect_mdef, 0, sizeof(isect_mdef));
@@ -1037,8 +1086,9 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co)
normalize_v3(dir);
isect = meshdeform_ray_tree_intersect(mdb, start, outside);
- if (isect && !isect->facing)
+ if (isect && !isect->facing) {
return 1;
+ }
}
return 0;
@@ -1054,12 +1104,15 @@ BLI_INLINE int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n)
y += MESHDEFORM_OFFSET[n][1];
z += MESHDEFORM_OFFSET[n][2];
- if (x < 0 || x >= mdb->size)
+ if (x < 0 || x >= mdb->size) {
return -1;
- if (y < 0 || y >= mdb->size)
+ }
+ if (y < 0 || y >= mdb->size) {
return -1;
- if (z < 0 || z >= mdb->size)
+ }
+ if (z < 0 || z >= mdb->size) {
return -1;
+ }
return x + y * size + z * size * size;
}
@@ -1087,8 +1140,9 @@ static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int
/* check each outgoing edge for intersection */
for (i = 1; i <= 6; i++) {
- if (meshdeform_index(mdb, x, y, z, i) == -1)
+ if (meshdeform_index(mdb, x, y, z, i) == -1) {
continue;
+ }
meshdeform_cell_center(mdb, x, y, z, i, ncenter);
@@ -1134,9 +1188,11 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb)
}
/* other cells are interior */
- for (a = 0; a < size * size * size; a++)
- if (tag[a] == MESHDEFORM_TAG_UNTYPED)
+ for (a = 0; a < size * size * size; a++) {
+ if (tag[a] == MESHDEFORM_TAG_UNTYPED) {
tag[a] = MESHDEFORM_TAG_INTERIOR;
+ }
+ }
#if 0
{
@@ -1230,8 +1286,9 @@ static float meshdeform_interp_w(MeshDeformBind *mdb,
totweight += weight;
}
- if (totweight > 0.0f)
+ if (totweight > 0.0f) {
result /= totweight;
+ }
return result;
}
@@ -1241,12 +1298,15 @@ static void meshdeform_check_semibound(MeshDeformBind *mdb, int x, int y, int z)
int i, a;
a = meshdeform_index(mdb, x, y, z, 0);
- if (mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR)
+ if (mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR) {
return;
+ }
- for (i = 1; i <= 6; i++)
- if (mdb->boundisect[a][i - 1])
+ for (i = 1; i <= 6; i++) {
+ if (mdb->boundisect[a][i - 1]) {
mdb->semibound[a] = 1;
+ }
+ }
}
static float meshdeform_boundary_total_weight(MeshDeformBind *mdb, int x, int y, int z)
@@ -1258,15 +1318,19 @@ static float meshdeform_boundary_total_weight(MeshDeformBind *mdb, int x, int y,
/* count weight for neighbor cells */
for (i = 1; i <= 6; i++) {
- if (meshdeform_index(mdb, x, y, z, i) == -1)
+ if (meshdeform_index(mdb, x, y, z, i) == -1) {
continue;
+ }
- if (mdb->boundisect[a][i - 1])
+ if (mdb->boundisect[a][i - 1]) {
weight = 1.0f / mdb->boundisect[a][i - 1]->len;
- else if (!mdb->semibound[a])
+ }
+ else if (!mdb->semibound[a]) {
weight = 1.0f / mdb->width[0];
- else
+ }
+ else {
weight = 0.0f;
+ }
totweight += weight;
}
@@ -1282,16 +1346,18 @@ static void meshdeform_matrix_add_cell(
int i, a, acenter;
acenter = meshdeform_index(mdb, x, y, z, 0);
- if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR)
+ if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) {
return;
+ }
EIG_linear_solver_matrix_add(context, mdb->varidx[acenter], mdb->varidx[acenter], 1.0f);
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
for (i = 1; i <= 6; i++) {
a = meshdeform_index(mdb, x, y, z, i);
- if (a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR)
+ if (a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) {
continue;
+ }
isect = mdb->boundisect[acenter][i - 1];
if (!isect) {
@@ -1309,14 +1375,16 @@ static void meshdeform_matrix_add_rhs(
int i, a, acenter;
acenter = meshdeform_index(mdb, x, y, z, 0);
- if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR)
+ if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) {
return;
+ }
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
for (i = 1; i <= 6; i++) {
a = meshdeform_index(mdb, x, y, z, i);
- if (a == -1)
+ if (a == -1) {
continue;
+ }
isect = mdb->boundisect[acenter][i - 1];
@@ -1336,8 +1404,9 @@ static void meshdeform_matrix_add_semibound_phi(
int i, a;
a = meshdeform_index(mdb, x, y, z, 0);
- if (!mdb->semibound[a])
+ if (!mdb->semibound[a]) {
return;
+ }
mdb->phi[a] = 0.0f;
@@ -1360,8 +1429,9 @@ static void meshdeform_matrix_add_exterior_phi(
int i, a, acenter;
acenter = meshdeform_index(mdb, x, y, z, 0);
- if (mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter])
+ if (mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter]) {
return;
+ }
phi = 0.0f;
totweight = 0.0f;
@@ -1374,8 +1444,9 @@ static void meshdeform_matrix_add_exterior_phi(
}
}
- if (totweight != 0.0f)
+ if (totweight != 0.0f) {
mdb->phi[acenter] = phi / totweight;
+ }
}
static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind *mdb)
@@ -1387,8 +1458,9 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
/* setup variable indices */
mdb->varidx = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformDSvaridx");
- for (a = 0, totvar = 0; a < mdb->size3; a++)
+ for (a = 0, totvar = 0; a < mdb->size3; a++) {
mdb->varidx[a] = (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) ? -1 : totvar++;
+ }
if (totvar == 0) {
MEM_freeN(mdb->varidx);
@@ -1401,33 +1473,46 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
context = EIG_linear_solver_new(totvar, totvar, 1);
/* build matrix */
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_matrix_add_cell(mdb, context, x, y, z);
+ }
+ }
+ }
/* solve for each cage vert */
for (a = 0; a < mdb->totcagevert; a++) {
/* fill in right hand side and solve */
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_matrix_add_rhs(mdb, context, x, y, z, a);
+ }
+ }
+ }
if (EIG_linear_solver_solve(context)) {
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_matrix_add_semibound_phi(mdb, x, y, z, a);
+ }
+ }
+ }
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_matrix_add_exterior_phi(mdb, x, y, z, a);
+ }
+ }
+ }
for (b = 0; b < mdb->size3; b++) {
- if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR)
+ if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) {
mdb->phi[b] = EIG_linear_solver_variable_get(context, 0, mdb->varidx[b]);
+ }
mdb->totalphi[b] += mdb->phi[b];
}
@@ -1476,7 +1561,10 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR)
if (fabsf(mdb->totalphi[b] - 1.0f) > 1e-4f)
printf("totalphi deficiency [%s|%d] %d: %.10f\n",
- (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR) ? "interior" : "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]);
+ (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR) ? "interior" : "boundary",
+ mdb->semibound[b],
+ mdb->varidx[b],
+ mdb->totalphi[b]);
#endif
/* free */
@@ -1496,8 +1584,9 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
/* compute bounding box of the cage mesh */
INIT_MINMAX(mdb->min, mdb->max);
- for (a = 0; a < mdb->totcagevert; a++)
+ for (a = 0; a < mdb->totcagevert; a++) {
minmax_v3v3_v3(mdb->min, mdb->max, mdb->cagecos[a]);
+ }
/* allocate memory */
mdb->size = (2 << (mmd->gridsize - 1)) + 2;
@@ -1510,10 +1599,12 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
mdb->bvhtree = BKE_bvhtree_from_mesh_get(&mdb->bvhdata, mdb->cagemesh, BVHTREE_FROM_LOOPTRI, 4);
mdb->inside = MEM_callocN(sizeof(int) * mdb->totvert, "MDefInside");
- if (mmd->flag & MOD_MDEF_DYNAMIC_BIND)
+ if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
mdb->dyngrid = MEM_callocN(sizeof(MDefBindInfluence *) * mdb->size3, "MDefDynGrid");
- else
+ }
+ else {
mdb->weights = MEM_callocN(sizeof(float) * mdb->totvert * mdb->totcagevert, "MDefWeights");
+ }
mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
BLI_memarena_use_calloc(mdb->memarena);
@@ -1531,9 +1622,11 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
/* make bounding box equal size in all directions, add padding, and compute
* width of the cells */
maxwidth = -1.0f;
- for (a = 0; a < 3; a++)
- if (mdb->max[a] - mdb->min[a] > maxwidth)
+ for (a = 0; a < 3; a++) {
+ if (mdb->max[a] - mdb->min[a] > maxwidth) {
maxwidth = mdb->max[a] - mdb->min[a];
+ }
+ }
for (a = 0; a < 3; a++) {
center[a] = (mdb->min[a] + mdb->max[a]) * 0.5f;
@@ -1554,8 +1647,9 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
for (a = 0; a < mdb->totvert; a++) {
copy_v3_v3(vec, mdb->vertexcos[a]);
mdb->inside[a] = meshdeform_inside_cage(mdb, vec);
- if (mdb->inside[a])
+ if (mdb->inside[a]) {
totinside++;
+ }
}
/* free temporary MDefBoundIsects */
@@ -1563,22 +1657,29 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
/* start with all cells untyped */
- for (a = 0; a < mdb->size3; a++)
+ for (a = 0; a < mdb->size3; a++) {
mdb->tag[a] = MESHDEFORM_TAG_UNTYPED;
+ }
/* detect intersections and tag boundary cells */
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_add_intersections(mdb, x, y, z);
+ }
+ }
+ }
/* compute exterior and interior tags */
meshdeform_bind_floodfill(mdb);
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_check_semibound(mdb, x, y, z);
+ }
+ }
+ }
/* solve */
meshdeform_matrix_solve(mmd, mdb);
@@ -1586,9 +1687,11 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
/* assign results */
if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
mmd->totinfluence = 0;
- for (a = 0; a < mdb->size3; a++)
- for (inf = mdb->dyngrid[a]; inf; inf = inf->next)
+ for (a = 0; a < mdb->size3; a++) {
+ for (inf = mdb->dyngrid[a]; inf; inf = inf->next) {
mmd->totinfluence++;
+ }
+ }
/* convert MDefBindInfluences to smaller MDefInfluences */
mmd->dyngrid = MEM_callocN(sizeof(MDefCell) * mdb->size3, "MDefDynGrid");
@@ -1609,8 +1712,9 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
if (totweight > 0.0f) {
mdinf = mmd->dyninfluences + cell->offset;
- for (b = 0; b < cell->totinfluence; b++, mdinf++)
+ for (b = 0; b < cell->totinfluence; b++, mdinf++) {
mdinf->weight /= totweight;
+ }
}
offset += cell->totinfluence;
@@ -1663,10 +1767,12 @@ void ED_mesh_deform_bind_callback(MeshDeformModifierData *mmd,
copy_m4_m4(mdb.cagemat, cagemat);
mvert = mdb.cagemesh->mvert;
- for (a = 0; a < mdb.totcagevert; a++)
+ for (a = 0; a < mdb.totcagevert; a++) {
copy_v3_v3(mdb.cagecos[a], mvert[a].co);
- for (a = 0; a < mdb.totvert; a++)
+ }
+ for (a = 0; a < mdb.totvert; a++) {
mul_v3_m4v3(mdb.vertexcos[a], mdb.cagemat, vertexcos + a * 3);
+ }
/* solve */
harmonic_coordinates_bind(mmd_orig, &mdb);
@@ -1678,8 +1784,9 @@ void ED_mesh_deform_bind_callback(MeshDeformModifierData *mmd,
copy_m4_m4(mmd_orig->bindmat, mmd_orig->object->obmat);
/* transform bindcagecos to world space */
- for (a = 0; a < mdb.totcagevert; a++)
+ for (a = 0; a < mdb.totcagevert; a++) {
mul_m4_v3(mmd_orig->object->obmat, mmd_orig->bindcagecos + a * 3);
+ }
/* free */
MEM_freeN(mdb.vertexcos);
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 51641041ea1..cf64210ebdb 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -78,7 +78,8 @@ Object *ED_pose_object_from_context(bContext *C)
ScrArea *sa = CTX_wm_area(C);
Object *ob;
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
+ /* Since this call may also be used from the buttons window,
+ * we need to check for where to get the object. */
if (sa && sa->spacetype == SPACE_PROPERTIES) {
ob = ED_object_context(C);
}
@@ -167,7 +168,8 @@ static bool pose_has_protected_selected(Object *ob, short warn)
}
}
if (pchan) {
- if (warn) error("Cannot change Proxy protected bones");
+ if (warn)
+ error("Cannot change Proxy protected bones");
return 1;
}
}
@@ -261,8 +263,9 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEven
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* set default settings from existing/stored settings */
{
@@ -289,8 +292,9 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* grab baking settings from operator settings */
{
@@ -389,8 +393,9 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
- if (ELEM(NULL, ob, scene))
+ if (ELEM(NULL, ob, scene)) {
return OPERATOR_CANCELLED;
+ }
/* calculate the bones that now have motionpaths... */
/* TODO: only make for the selected bones? */
@@ -425,8 +430,9 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
bPoseChannel *pchan;
bool skipped = false;
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return;
+ }
/* free the motionpath blocks for all bones - This is easier for users to quickly clear all */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -442,8 +448,9 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
}
/* if nothing was skipped, there should be no paths left! */
- if (skipped == false)
+ if (skipped == false) {
ob->pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
+ }
/* tag armature object for copy on write - so removed paths don't still show */
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
@@ -456,8 +463,9 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op)
bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
/* only continue if there's an object */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* use the backend function for this */
ED_pose_clear_paths(ob, only_selected);
@@ -600,8 +608,7 @@ static int pose_autoside_names_exec(bContext *C, wmOperator *op)
Object *ob_prev = NULL;
/* loop through selected bones, auto-naming them */
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
bArmature *arm = ob->data;
BLI_strncpy(newname, pchan->name, sizeof(newname));
if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis])) {
@@ -658,8 +665,7 @@ static int pose_bone_rotmode_exec(bContext *C, wmOperator *op)
Object *prev_ob = NULL;
/* set rotation mode of selected bones */
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
pchan->rotmode = mode;
if (prev_ob != ob) {
@@ -735,8 +741,9 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
int i;
/* sanity checking */
- if (arm == NULL)
+ if (arm == NULL) {
return OPERATOR_CANCELLED;
+ }
/* use RNA to set the layers
* although it would be faster to just set directly using bitflags, we still
@@ -744,8 +751,9 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
*/
RNA_id_pointer_create(&arm->id, &ptr);
- for (i = 0; i < maxLayers; i++)
+ for (i = 0; i < maxLayers; i++) {
layers[i] = 1;
+ }
RNA_boolean_set_array(&ptr, "layers", layers);
@@ -788,10 +796,12 @@ static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *ev
bool layers[32];
/* sanity checking */
- if (arm == NULL)
+ if (arm == NULL) {
return OPERATOR_CANCELLED;
+ }
- /* get RNA pointer to armature data to use that to retrieve the layers as ints to init the operator */
+ /* Get RNA pointer to armature data to use that to retrieve the layers as ints
+ * to init the operator. */
RNA_id_pointer_create((ID *)arm, &ptr);
RNA_boolean_get_array(&ptr, "layers", layers);
RNA_boolean_set_array(op->ptr, "layers", layers);
@@ -886,8 +896,7 @@ static int pose_bone_layers_exec(bContext *C, wmOperator *op)
Object *prev_ob = NULL;
/* set layers of pchans based on the values set in the operator props */
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
/* get pointer for pchan, and write flags this way */
RNA_pointer_create((ID *)ob->data, &RNA_Bone, pchan->bone, &ptr);
RNA_boolean_set_array(&ptr, "layers", layers);
@@ -963,8 +972,7 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op)
RNA_boolean_get_array(op->ptr, "layers", layers);
/* set layers of pchans based on the values set in the operator props */
- CTX_DATA_BEGIN_WITH_ID(C, EditBone *, ebone, selected_editable_bones, bArmature *, arm)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, EditBone *, ebone, selected_editable_bones, bArmature *, arm) {
/* get pointer for pchan, and write flags this way */
RNA_pointer_create((ID *)arm, &RNA_EditBone, ebone, &ptr);
RNA_boolean_set_array(&ptr, "layers", layers);
diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c
index 0d100a09dfd..3ae9976c948 100644
--- a/source/blender/editors/armature/pose_group.c
+++ b/source/blender/editors/armature/pose_group.c
@@ -59,8 +59,9 @@ static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object and pose */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* for now, just call the API function for this */
BKE_pose_add_group(ob->pose, NULL);
@@ -91,8 +92,9 @@ static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object and pose */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* for now, just call the API function for this */
BKE_pose_remove_group_index(ob->pose, ob->pose->active_group);
@@ -134,8 +136,9 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
int i;
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
pose = ob->pose;
/* If group index is set, try to use it! */
@@ -164,8 +167,9 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
}
/* add entries for each group */
- for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++)
+ for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++) {
uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i);
+ }
/* finish building the menu, and process it (should result in calling self again) */
UI_popup_menu_end(C, pup);
@@ -187,8 +191,9 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
bool done = false;
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
pose = ob->pose;
@@ -196,8 +201,9 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
* - if 0 after this, make a new group...
*/
pose->active_group = RNA_int_get(op->ptr, "type");
- if (pose->active_group == 0)
+ if (pose->active_group == 0) {
BKE_pose_add_group(ob->pose, NULL);
+ }
/* add selected bones to group then */
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan) {
@@ -211,10 +217,12 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
/* report done status */
- if (done)
+ if (done) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void POSE_OT_group_assign(wmOperatorType *ot)
@@ -242,8 +250,9 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
bool done = false;
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* find selected bones to remove from all bone groups */
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan) {
@@ -259,10 +268,12 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
/* report done status */
- if (done)
+ if (done) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void POSE_OT_group_unassign(wmOperatorType *ot)
@@ -288,15 +299,18 @@ static int group_move_exec(bContext *C, wmOperator *op)
bActionGroup *grp;
int dir = RNA_enum_get(op->ptr, "direction");
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose)) {
return OPERATOR_CANCELLED;
- if (pose->active_group <= 0)
+ }
+ if (pose->active_group <= 0) {
return OPERATOR_CANCELLED;
+ }
/* get group to move */
grp = BLI_findlink(&pose->agroups, pose->active_group - 1);
- if (grp == NULL)
+ if (grp == NULL) {
return OPERATOR_CANCELLED;
+ }
/* move bone group */
if (BLI_listbase_link_move(&pose->agroups, grp, dir)) {
@@ -374,10 +388,12 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
int agrp_count;
int i;
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose)) {
return OPERATOR_CANCELLED;
- if (pose->active_group <= 0)
+ }
+ if (pose->active_group <= 0) {
return OPERATOR_CANCELLED;
+ }
/* create temporary array with bone groups and indices */
agrp_count = BLI_listbase_count(&pose->agroups);
@@ -439,12 +455,14 @@ static void pose_group_select(Object *ob, bool select)
FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (ob, pchan) {
if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
if (select) {
- if (pchan->agrp_index == pose->active_group)
+ if (pchan->agrp_index == pose->active_group) {
pchan->bone->flag |= BONE_SELECTED;
+ }
}
else {
- if (pchan->agrp_index == pose->active_group)
+ if (pchan->agrp_index == pose->active_group) {
pchan->bone->flag &= ~BONE_SELECTED;
+ }
}
}
}
@@ -456,8 +474,9 @@ static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
pose_group_select(ob, 1);
@@ -489,8 +508,9 @@ static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
pose_group_select(ob, 0);
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 443bcdde028..7b31897766d 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -77,7 +77,9 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS
}
/* ************************************************************* */
-/* == POSE-LIBRARY TOOL FOR BLENDER ==
+/**
+ * Pose-Library Tool for Blender
+ * =============================
*
* Overview:
* This tool allows animators to store a set of frequently used poses to dump into
@@ -85,13 +87,13 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS
* It acts as a kind of "glorified clipboard for poses", allowing for naming of poses.
*
* Features:
- * - PoseLibs are simply normal Actions
- * - Each "pose" is simply a set of keyframes that occur on a particular frame
- * -> a set of TimeMarkers that belong to each Action, help 'label' where a 'pose' can be
- * found in the Action
+ * - PoseLibs are simply normal Actions.
+ * - Each "pose" is simply a set of keyframes that occur on a particular frame.
+ * - A set of TimeMarkers that belong to each Action, help 'label' where a 'pose' can be
+ * found in the Action.
* - The Scrollwheel or PageUp/Down buttons when used in a special mode or after pressing/holding
- * [a modifier] key, cycles through the poses available for the active pose's poselib, allowing the
- * animator to preview what action best suits that pose
+ * [a modifier] key, cycles through the poses available for the active pose's poselib,
+ * allowing the animator to preview what action best suits that pose.
*/
/* ************************************************************* */
@@ -105,8 +107,9 @@ static int poselib_get_free_index(bAction *act)
bool changed = false;
/* sanity checks */
- if (ELEM(NULL, act, act->markers.first))
+ if (ELEM(NULL, act, act->markers.first)) {
return 1;
+ }
/* As poses are not stored in chronological order, we must iterate over this list
* a few times until we don't make any new discoveries (mostly about the lower bound).
@@ -135,19 +138,23 @@ static int poselib_get_free_index(bAction *act)
/* - if low is not equal to high, then low+1 is a gap
* - if low is equal to high, then high+1 is the next index (add at end)
*/
- if (low < high)
+ if (low < high) {
return (low + 1);
- else
+ }
+ else {
return (high + 1);
+ }
}
/* returns the active pose for a poselib */
static TimeMarker *poselib_get_active_pose(bAction *act)
{
- if ((act) && (act->active_marker))
+ if ((act) && (act->active_marker)) {
return BLI_findlink(&act->markers, act->active_marker - 1);
- else
+ }
+ else {
return NULL;
+ }
}
/* Get object that Pose Lib should be found on */
@@ -157,15 +164,18 @@ static Object *get_poselib_object(bContext *C)
ScrArea *sa;
/* sanity check */
- if (C == NULL)
+ if (C == NULL) {
return NULL;
+ }
sa = CTX_wm_area(C);
- if (sa && (sa->spacetype == SPACE_PROPERTIES))
+ if (sa && (sa->spacetype == SPACE_PROPERTIES)) {
return ED_object_context(C);
- else
+ }
+ else {
return BKE_object_pose_armature_get(CTX_data_active_object(C));
+ }
}
/* Poll callback for operators that require existing PoseLib data (with poses) to work */
@@ -190,12 +200,14 @@ static bool has_poselib_pose_data_for_editing_poll(bContext *C)
static bAction *poselib_init_new(Main *bmain, Object *ob)
{
/* sanity checks - only for armatures */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return NULL;
+ }
/* init object's poselib action (unlink old one if there) */
- if (ob->poselib)
+ if (ob->poselib) {
id_us_min(&ob->poselib->id);
+ }
ob->poselib = BKE_action_add(bmain, "PoseLib");
ob->poselib->idroot = ID_OB;
@@ -206,12 +218,15 @@ static bAction *poselib_init_new(Main *bmain, Object *ob)
/* Initialize a new poselib (checks if that needs to happen) */
static bAction *poselib_validate(Main *bmain, Object *ob)
{
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return NULL;
- else if (ob->poselib == NULL)
+ }
+ else if (ob->poselib == NULL) {
return poselib_init_new(bmain, ob);
- else
+ }
+ else {
return ob->poselib;
+ }
}
/* ************************************************************* */
@@ -223,8 +238,9 @@ static int poselib_new_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = get_poselib_object(C);
/* sanity checks */
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
/* new method here deals with the rest... */
poselib_init_new(bmain, ob);
@@ -257,8 +273,9 @@ static int poselib_unlink_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = get_poselib_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->poselib))
+ if (ELEM(NULL, ob, ob->poselib)) {
return OPERATOR_CANCELLED;
+ }
/* there should be a poselib (we just checked above!), so just lower its user count and remove */
id_us_min(&ob->poselib->id);
@@ -338,10 +355,12 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op)
for (marker = act->markers.first; marker; marker = markern) {
markern = marker->next;
- if (marker->flag != -1)
+ if (marker->flag != -1) {
BLI_freelinkN(&act->markers, marker);
- else
+ }
+ else {
marker->flag = 0;
+ }
}
/* free temp memory */
@@ -423,8 +442,9 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
uiLayout *layout;
/* sanity check */
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose)) {
return OPERATOR_CANCELLED;
+ }
/* start building */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
@@ -472,8 +492,9 @@ static int poselib_add_exec(bContext *C, wmOperator *op)
char name[64];
/* sanity check (invoke should have checked this anyway) */
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose)) {
return OPERATOR_CANCELLED;
+ }
/* get name to give to pose */
RNA_string_get(op->ptr, "name", name);
@@ -677,7 +698,8 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve
return OPERATOR_CANCELLED;
}
else {
- /* use the existing name of the marker as the name, and use the active marker as the one to rename */
+ /* Use the existing name of the marker as the name,
+ * and use the active marker as the one to rename. */
RNA_enum_set(op->ptr, "pose", act->active_marker - 1);
RNA_string_set(op->ptr, "name", marker->name);
}
@@ -954,8 +976,9 @@ static void poselib_backup_posecopy(tPoseLib_PreviewData *pld)
plb->pchan = pchan;
memcpy(&plb->olddata, plb->pchan, sizeof(bPoseChannel));
- if (pchan->prop)
+ if (pchan->prop) {
plb->oldprops = IDP_CopyProperty(pchan->prop);
+ }
BLI_addtail(&pld->backups, plb);
@@ -975,8 +998,9 @@ static void poselib_backup_restore(tPoseLib_PreviewData *pld)
memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel));
/* just overwrite values of properties from the stored copies (there should be some) */
- if (plb->oldprops)
+ if (plb->oldprops) {
IDP_SyncGroupValues(plb->pchan->prop, plb->oldprops);
+ }
/* TODO: constraints settings aren't restored yet,
* even though these could change (though not that likely) */
@@ -1024,10 +1048,12 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
const bool any_bone_selected = pld->flag & PL_PREVIEW_ANY_BONE_SELECTED;
/* get the frame */
- if (pld->marker)
+ if (pld->marker) {
frame = pld->marker->frame;
- else
+ }
+ else {
return;
+ }
/* init settings for testing groups for keyframes */
group_ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
@@ -1058,8 +1084,9 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
}
}
- if (ok)
+ if (ok) {
animsys_evaluate_action_group(ptr, act, agrp, (float)frame);
+ }
}
}
}
@@ -1090,13 +1117,15 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan);
/* clear any unkeyed tags */
- if (pchan->bone)
+ if (pchan->bone) {
pchan->bone->flag &= ~BONE_UNKEYED;
+ }
}
else {
/* add unkeyed tags */
- if (pchan->bone)
+ if (pchan->bone) {
pchan->bone->flag |= BONE_UNKEYED;
+ }
}
}
}
@@ -1121,27 +1150,32 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
/* only recalc pose (and its dependencies) if pose has changed */
if (pld->redraw == PL_PREVIEW_REDRAWALL) {
/* don't clear pose if firsttime */
- if ((pld->flag & PL_PREVIEW_FIRSTTIME) == 0)
+ if ((pld->flag & PL_PREVIEW_FIRSTTIME) == 0) {
poselib_backup_restore(pld);
- else
+ }
+ else {
pld->flag &= ~PL_PREVIEW_FIRSTTIME;
+ }
/* pose should be the right one to draw (unless we're temporarily not showing it) */
if ((pld->flag & PL_PREVIEW_SHOWORIGINAL) == 0) {
RNA_int_set(op->ptr, "pose_index", BLI_findindex(&pld->act->markers, pld->marker));
poselib_apply_pose(pld);
}
- else
+ else {
RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */
+ }
/* old optimize trick... this enforces to bypass the depsgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
// FIXME: shouldn't this use the builtin stuff?
- if ((pld->arm->flag & ARM_DELAYDEFORM) == 0)
+ if ((pld->arm->flag & ARM_DELAYDEFORM) == 0) {
DEG_id_tag_update(&pld->ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
- else
+ }
+ else {
BKE_pose_where_is(CTX_data_depsgraph(C), pld->scene, pld->ob);
+ }
}
/* do header print - if interactively previewing */
@@ -1202,8 +1236,9 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
{
/* stop if not going anywhere, as we assume that there is a direction to move in */
- if (step == 0)
+ if (step == 0) {
return;
+ }
/* search-string dictates a special approach */
if (pld->searchstr[0]) {
@@ -1241,50 +1276,59 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
/* find first match */
for (ldc = pld->searchp.first; ldc; ldc = ldc->next) {
- if (ldc->data == pld->marker)
+ if (ldc->data == pld->marker) {
break;
+ }
}
- if (ldc == NULL)
+ if (ldc == NULL) {
ldc = pld->searchp.first;
+ }
/* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate
* until step == 0. At this point, marker should be the correct marker.
*/
if (step > 0) {
- for (ld = ldc; ld && step; ld = ldn, step--)
+ for (ld = ldc; ld && step; ld = ldn, step--) {
ldn = (ld->next) ? ld->next : pld->searchp.first;
+ }
}
else {
- for (ld = ldc; ld && step; ld = ldn, step++)
+ for (ld = ldc; ld && step; ld = ldn, step++) {
ldn = (ld->prev) ? ld->prev : pld->searchp.last;
+ }
}
/* set marker */
- if (ld)
+ if (ld) {
pld->marker = ld->data;
+ }
}
else {
TimeMarker *marker, *next;
/* if no marker, because we just ended searching, then set that to the start of the list */
- if (pld->marker == NULL)
+ if (pld->marker == NULL) {
pld->marker = pld->act->markers.first;
+ }
/* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate
* until step == 0. At this point, marker should be the correct marker.
*/
if (step > 0) {
- for (marker = pld->marker; marker && step; marker = next, step--)
+ for (marker = pld->marker; marker && step; marker = next, step--) {
next = (marker->next) ? marker->next : pld->act->markers.first;
+ }
}
else {
- for (marker = pld->marker; marker && step; marker = next, step++)
+ for (marker = pld->marker; marker && step; marker = next, step++) {
next = (marker->prev) ? marker->prev : pld->act->markers.last;
+ }
}
/* it should be fairly impossible for marker to be NULL */
- if (marker)
+ if (marker) {
pld->marker = marker;
+ }
}
}
@@ -1301,8 +1345,9 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld,
short index = pld->search_cursor;
short i;
- for (i = index; i <= len; i++)
+ for (i = index; i <= len; i++) {
pld->searchstr[i - 1] = pld->searchstr[i];
+ }
pld->search_cursor--;
@@ -1319,8 +1364,9 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld,
int i;
if (index < len) {
- for (i = index; i < len; i++)
+ for (i = index; i < len; i++) {
pld->searchstr[i] = pld->searchstr[i + 1];
+ }
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
@@ -1337,11 +1383,13 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld,
short i;
if (len) {
- for (i = len; i > index; i--)
+ for (i = len; i > index; i--) {
pld->searchstr[i] = pld->searchstr[i - 1];
+ }
}
- else
+ else {
pld->searchstr[1] = 0;
+ }
pld->searchstr[index] = ascii;
pld->search_cursor++;
@@ -1359,7 +1407,11 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
/* only accept 'press' event, and ignore 'release', so that we don't get double actions */
if (ELEM(event->val, KM_PRESS, KM_NOTHING) == 0) {
- //printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type, false), event->val);
+#if 0
+ printf("PoseLib: skipping event with type '%s' and val %d\n",
+ WM_key_event_string(event->type, false),
+ event->val);
+#endif
return ret;
}
@@ -1403,7 +1455,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case PADMINUS:
case MIDDLEMOUSE:
case MOUSEMOVE:
- //pld->redraw = PL_PREVIEW_REDRAWHEADER;
+ // pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
break;
@@ -1471,8 +1523,9 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case RIGHTARROWKEY:
if (pld->searchstr[0]) {
/* move text-cursor to the right */
- if (pld->search_cursor < strlen(pld->searchstr))
+ if (pld->search_cursor < strlen(pld->searchstr)) {
pld->search_cursor++;
+ }
pld->redraw = PL_PREVIEW_REDRAWHEADER;
}
else {
@@ -1486,8 +1539,9 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case LEFTARROWKEY:
if (pld->searchstr[0]) {
/* move text-cursor to the left */
- if (pld->search_cursor)
+ if (pld->search_cursor) {
pld->search_cursor--;
+ }
pld->redraw = PL_PREVIEW_REDRAWHEADER;
}
else {
@@ -1533,7 +1587,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
*/
case MIDDLEMOUSE:
case MOUSEMOVE:
- //pld->redraw = PL_PREVIEW_REDRAWHEADER;
+ // pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
break;
@@ -1556,7 +1610,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
}
else {
/* view manipulation (see above) */
- //pld->redraw = PL_PREVIEW_REDRAWHEADER;
+ // pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
}
break;
@@ -1592,12 +1646,15 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
pld->sa = CTX_wm_area(C);
/* get starting pose based on RNA-props for this operator */
- if (pose_index == -1)
+ if (pose_index == -1) {
pld->marker = poselib_get_active_pose(pld->act);
- else if (pose_index == -2)
+ }
+ else if (pose_index == -2) {
pld->flag |= PL_PREVIEW_SHOWORIGINAL;
- else
+ }
+ else {
pld->marker = (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL;
+ }
/* check if valid poselib */
if (ELEM(NULL, pld->ob, pld->pose, pld->arm)) {
@@ -1614,8 +1671,9 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
if (pld->act->markers.first) {
/* just use first one then... */
pld->marker = pld->act->markers.first;
- if (pose_index > -2)
+ if (pose_index > -2) {
BKE_report(op->reports, RPT_WARNING, "Pose lib had no active pose");
+ }
}
else {
BKE_report(op->reports, RPT_ERROR, "Pose lib has no poses to preview/apply");
@@ -1670,10 +1728,12 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
/* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
- if ((arm->flag & ARM_DELAYDEFORM) == 0)
+ if ((arm->flag & ARM_DELAYDEFORM) == 0) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
- else
+ }
+ else {
BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
+ }
}
else if (pld->state == PL_PREVIEW_CONFIRM) {
/* tag poses as appropriate */
@@ -1688,10 +1748,11 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
/* updates */
if (IS_AUTOKEY_MODE(scene, NORMAL)) {
- //remake_action_ipos(ob->action);
+ // remake_action_ipos(ob->action);
}
- else
+ else {
BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
+ }
}
/* Request final redraw of the view. */
@@ -1715,10 +1776,12 @@ static int poselib_preview_exit(bContext *C, wmOperator *op)
/* finish up */
poselib_preview_cleanup(C, op);
- if (ELEM(exit_state, PL_PREVIEW_CANCEL, PL_PREVIEW_ERROR))
+ if (ELEM(exit_state, PL_PREVIEW_CANCEL, PL_PREVIEW_ERROR)) {
return OPERATOR_CANCELLED;
- else
+ }
+ else {
return OPERATOR_FINISHED;
+ }
}
/* Cancel previewing operation (called when exiting Blender) */
@@ -1734,15 +1797,17 @@ static int poselib_preview_modal(bContext *C, wmOperator *op, const wmEvent *eve
int ret;
/* 1) check state to see if we're still running */
- if (pld->state != PL_PREVIEW_RUNNING)
+ if (pld->state != PL_PREVIEW_RUNNING) {
return poselib_preview_exit(C, op);
+ }
/* 2) handle events */
ret = poselib_preview_handle_event(C, op, event);
/* 3) apply changes and redraw, otherwise, confirming goes wrong */
- if (pld->redraw)
+ if (pld->redraw) {
poselib_preview_apply(C, op);
+ }
return ret;
}
@@ -1834,9 +1899,15 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot)
// XXX: percentage vs factor?
/* not used yet */
#if 0
- RNA_def_float_factor(
- ot->srna, "blend_factor", 1.0f, 0.0f, 1.0f, "Blend Factor",
- "Amount that the pose is applied on top of the existing poses", 0.0f, 1.0f);
+ RNA_def_float_factor(ot->srna,
+ "blend_factor",
+ 1.0f,
+ 0.0f,
+ 1.0f,
+ "Blend Factor",
+ "Amount that the pose is applied on top of the existing poses",
+ 0.0f,
+ 1.0f);
#endif
}
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index b825d821fe8..e9ea49aaf03 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -71,8 +71,9 @@ static void pose_do_bone_select(bPoseChannel *pchan, const int select_mode)
/* select pchan only if selectable, but deselect works always */
switch (select_mode) {
case SEL_SELECT:
- if (!(pchan->bone->flag & BONE_UNSELECTABLE))
+ if (!(pchan->bone->flag & BONE_UNSELECTABLE)) {
pchan->bone->flag |= BONE_SELECTED;
+ }
break;
case SEL_DESELECT:
pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
@@ -110,8 +111,9 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
/* sanity checks */
// XXX: actually, we can probably still get away with no object - at most we have no updates
- if (ELEM(NULL, ob, ob->pose, pchan, pchan->bone))
+ if (ELEM(NULL, ob, ob->pose, pchan, pchan->bone)) {
return;
+ }
arm = ob->data;
@@ -147,8 +149,9 @@ bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer,
Object *ob = base->object;
Bone *nearBone;
- if (!ob || !ob->pose)
+ if (!ob || !ob->pose) {
return 0;
+ }
Object *ob_act = OBACT(view_layer);
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
@@ -346,16 +349,20 @@ static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
Bone *curBone;
/* stop when unconnected child is encountered, or when unselectable bone is encountered */
- if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE))
+ if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) {
return;
+ }
- if (extend)
+ if (extend) {
bone->flag &= ~BONE_SELECTED;
- else
+ }
+ else {
bone->flag |= BONE_SELECTED;
+ }
- for (curBone = bone->childbase.first; curBone; curBone = curBone->next)
+ for (curBone = bone->childbase.first; curBone; curBone = curBone->next) {
selectconnected_posebonechildren(ob, curBone, extend);
+ }
}
/* within active object context */
@@ -370,30 +377,37 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
Base *base = NULL;
bone = get_nearest_bone(C, event->mval, !extend, &base);
- if (!bone)
+ if (!bone) {
return OPERATOR_CANCELLED;
+ }
/* Select parents */
for (curBone = bone; curBone; curBone = next) {
/* ignore bone if cannot be selected */
if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
- if (extend)
+ if (extend) {
curBone->flag &= ~BONE_SELECTED;
- else
+ }
+ else {
curBone->flag |= BONE_SELECTED;
+ }
- if (curBone->flag & BONE_CONNECTED)
+ if (curBone->flag & BONE_CONNECTED) {
next = curBone->parent;
- else
+ }
+ else {
next = NULL;
+ }
}
- else
+ else {
next = NULL;
+ }
}
/* Select children */
- for (curBone = bone->childbase.first; curBone; curBone = next)
+ for (curBone = bone->childbase.first; curBone; curBone = next) {
selectconnected_posebonechildren(base->object, curBone, extend);
+ }
ED_pose_bone_select_tag_update(base->object);
@@ -444,8 +458,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
Object *ob_prev = NULL;
/* Set the flags */
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
bArmature *arm = ob->data;
pose_do_bone_select(pchan, action);
@@ -558,16 +571,18 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 1);
+ }
}
}
}
}
CTX_DATA_END;
- if (!found)
+ if (!found) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -741,8 +756,7 @@ static bool pose_select_same_group(bContext *C, bool extend)
group_flags = NULL;
ob_index = -1;
ob_prev = NULL;
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, visible_pose_bones, Object, *ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object, *ob) {
if (ob != ob_prev) {
ob_index++;
group_flags = group_flags_array + (ob_index * groups_len);
@@ -768,8 +782,7 @@ static bool pose_select_same_group(bContext *C, bool extend)
ob_index = -1;
ob_prev = NULL;
/* only if group matches (and is not selected or current bone) */
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
if (ob != ob_prev) {
ob_index++;
group_flags = group_flags_array + (ob_index * groups_len);
@@ -824,20 +837,21 @@ static bool pose_select_same_layer(bContext *C, bool extend)
layers = NULL;
ob_prev = NULL;
ob_index = -1;
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
if (ob != ob_prev) {
layers = &layers_array[++ob_index];
ob_prev = ob;
}
/* Keep track of layers to use later? */
- if (pchan->bone->flag & BONE_SELECTED)
+ if (pchan->bone->flag & BONE_SELECTED) {
*layers |= pchan->bone->layer;
+ }
/* Deselect all bones before selecting new ones? */
- if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0)
+ if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
pchan->bone->flag &= ~BONE_SELECTED;
+ }
}
CTX_DATA_END;
@@ -856,8 +870,7 @@ static bool pose_select_same_layer(bContext *C, bool extend)
/* Select bones that are on same layers as layers flag. */
ob_prev = NULL;
ob_index = -1;
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
if (ob != ob_prev) {
layers = &layers_array[++ob_index];
ob_prev = ob;
@@ -917,8 +930,9 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex
/* if not extending selection, deselect all selected first */
if (extend == false) {
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
- if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0)
+ if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
pchan->bone->flag &= ~BONE_SELECTED;
+ }
}
CTX_DATA_END;
}
@@ -982,8 +996,9 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
bool changed = false;
/* sanity check */
- if (ob->pose == NULL)
+ if (ob->pose == NULL) {
return OPERATOR_CANCELLED;
+ }
/* selection types */
switch (type) {
@@ -1005,10 +1020,12 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
}
/* report done status */
- if (changed)
+ if (changed) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void POSE_OT_select_grouped(wmOperatorType *ot)
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index cb9cfa64181..d683c599f7b 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -335,12 +335,6 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
/* next/end */
eVal = evaluate_fcurve(fcu, nextFrameF);
- /* if both values are equal, don't do anything */
- if (IS_EQF(sVal, eVal)) {
- (*val) = sVal;
- return;
- }
-
/* calculate the relative weights of the endpoints */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* get weights from the percentage control */
@@ -362,9 +356,10 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
w2 = (w2 / wtot);
}
- /* depending on the mode, calculate the new value
- * - in all of these, the start+end values are multiplied by w2 and w1 (respectively),
- * since multiplication in another order would decrease the value the current frame is closer to
+ /* Depending on the mode, calculate the new value:
+ * - In all of these, the start+end values are multiplied by w2 and w1 (respectively),
+ * since multiplication in another order would decrease
+ * the value the current frame is closer to.
*/
switch (pso->mode) {
case POSESLIDE_PUSH: /* make the current pose more pronounced */
@@ -397,7 +392,8 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
}
case POSESLIDE_BREAKDOWN: /* make the current pose slide around between the endpoints */
{
- /* perform simple linear interpolation - coefficient for start must come from pso->percentage... */
+ /* Perform simple linear interpolation -
+ * coefficient for start must come from pso->percentage. */
/* TODO: make this use some kind of spline interpolation instead? */
(*val) = ((sVal * w2) + (eVal * w1));
break;
@@ -458,8 +454,9 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
FCurve *fcu = (FCurve *)ld->data;
const char *bPtr, *pPtr;
- if (fcu->rna_path == NULL)
+ if (fcu->rna_path == NULL) {
continue;
+ }
/* do we have a match?
* - bPtr is the RNA Path with the standard part chopped off
@@ -507,7 +504,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
default:
/* cannot handle */
- //printf("Cannot Pose Slide non-numerical property\n");
+ // printf("Cannot Pose Slide non-numerical property\n");
break;
}
}
@@ -583,7 +580,8 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
/* perform blending */
if (pso->mode == POSESLIDE_BREAKDOWN) {
- /* just perform the interpol between quat_prev and quat_next using pso->percentage as a guide */
+ /* Just perform the interpol between quat_prev and
+ * quat_next using pso->percentage as a guide. */
interp_qt_qtqt(quat_final, quat_prev, quat_next, pso->percentage);
}
else if (pso->mode == POSESLIDE_PUSH) {
@@ -695,9 +693,8 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
}
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_PROPS) && (pfl->oldprops)) {
- /* not strictly a transform, but custom properties contribute to the pose produced in many rigs
- * (e.g. the facial rigs used in Sintel)
- */
+ /* Not strictly a transform, but custom properties contribute
+ * to the pose produced in many rigs (e.g. the facial rigs used in Sintel). */
pose_slide_apply_props(pso, pfl, "[\""); /* dummy " for texteditor bugs */
}
}
@@ -979,35 +976,41 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTMOUSE: /* confirm */
case RETKEY:
case PADENTER: {
- /* return to normal cursor and header status */
- ED_area_status_text(pso->sa, NULL);
- WM_cursor_modal_restore(win);
+ if (event->val == KM_PRESS) {
+ /* return to normal cursor and header status */
+ ED_area_status_text(pso->sa, NULL);
+ WM_cursor_modal_restore(win);
- /* insert keyframes as required... */
- pose_slide_autoKeyframe(C, pso);
- pose_slide_exit(op);
+ /* insert keyframes as required... */
+ pose_slide_autoKeyframe(C, pso);
+ pose_slide_exit(op);
- /* done! */
- return OPERATOR_FINISHED;
+ /* done! */
+ return OPERATOR_FINISHED;
+ }
+ break;
}
case ESCKEY: /* cancel */
case RIGHTMOUSE: {
- /* return to normal cursor and header status */
- ED_area_status_text(pso->sa, NULL);
- WM_cursor_modal_restore(win);
+ if (event->val == KM_PRESS) {
+ /* return to normal cursor and header status */
+ ED_area_status_text(pso->sa, NULL);
+ WM_cursor_modal_restore(win);
- /* reset transforms back to original state */
- pose_slide_reset(pso);
+ /* reset transforms back to original state */
+ pose_slide_reset(pso);
- /* depsgraph updates + redraws */
- pose_slide_refresh(C, pso);
+ /* depsgraph updates + redraws */
+ pose_slide_refresh(C, pso);
- /* clean up temp data */
- pose_slide_exit(op);
+ /* clean up temp data */
+ pose_slide_exit(op);
- /* canceled! */
- return OPERATOR_CANCELLED;
+ /* canceled! */
+ return OPERATOR_CANCELLED;
+ }
+ break;
}
/* Percentage Chane... */
@@ -1109,7 +1112,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- /* perform pose updates - in response to some user action (e.g. pressing a key or moving the mouse) */
+ /* Perform pose updates - in response to some user action
+ * (e.g. pressing a key or moving the mouse). */
if (do_pose_update) {
/* update percentage indicator in header */
pose_slide_draw_status(pso);
@@ -1158,8 +1162,8 @@ static void pose_slide_opdef_properties(wmOperatorType *ot)
1.0f,
"Percentage",
"Weighting factor for which keyframe is favored more",
- 0.3,
- 0.7);
+ 0.0,
+ 1.0);
RNA_def_int(ot->srna,
"prev_frame",
@@ -1206,8 +1210,9 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
@@ -1226,8 +1231,9 @@ static int pose_slide_push_exec(bContext *C, wmOperator *op)
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
@@ -1248,7 +1254,7 @@ void POSE_OT_push(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1266,8 +1272,9 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
@@ -1286,8 +1293,9 @@ static int pose_slide_relax_exec(bContext *C, wmOperator *op)
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
@@ -1308,7 +1316,7 @@ void POSE_OT_relax(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1326,8 +1334,9 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
@@ -1346,8 +1355,9 @@ static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
@@ -1368,7 +1378,7 @@ void POSE_OT_breakdown(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1396,7 +1406,8 @@ typedef enum ePosePropagate_Termination {
POSE_PROPAGATE_SELECTED_MARKERS,
} ePosePropagate_Termination;
-/* termination data needed for some modes - assumes only one of these entries will be needed at a time */
+/* Termination data needed for some modes -
+ * assumes only one of these entries will be needed at a time. */
typedef union tPosePropagate_ModeData {
/* smart holds + before frame: frame number to stop on */
float end_frame;
@@ -1561,15 +1572,17 @@ static void pose_propagate_fcurve(
short first = 1;
/* skip if no keyframes to edit */
- if ((fcu->bezt == NULL) || (fcu->totvert < 2))
+ if ((fcu->bezt == NULL) || (fcu->totvert < 2)) {
return;
+ }
/* find the reference value from bones directly, which means that the user
* doesn't need to firstly keyframe the pose (though this doesn't mean that
* they can't either)
*/
- if (!pose_propagate_get_refVal(ob, fcu, &refVal))
+ if (!pose_propagate_get_refVal(ob, fcu, &refVal)) {
return;
+ }
/* find the first keyframe to start propagating from
* - if there's a keyframe on the current frame, we probably want to save this value there too
@@ -1581,10 +1594,12 @@ static void pose_propagate_fcurve(
if (mode != POSE_PROPAGATE_SELECTED_KEYS) {
match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists);
- if (fcu->bezt[match].vec[1][0] < startFrame)
+ if (fcu->bezt[match].vec[1][0] < startFrame) {
i = match + 1;
- else
+ }
+ else {
i = match;
+ }
}
else {
/* selected - start from first keyframe */
@@ -1595,18 +1610,21 @@ static void pose_propagate_fcurve(
/* additional termination conditions based on the operator 'mode' property go here... */
if (ELEM(mode, POSE_PROPAGATE_BEFORE_FRAME, POSE_PROPAGATE_SMART_HOLDS)) {
/* stop if keyframe is outside the accepted range */
- if (bezt->vec[1][0] > modeData.end_frame)
+ if (bezt->vec[1][0] > modeData.end_frame) {
break;
+ }
}
else if (mode == POSE_PROPAGATE_NEXT_KEY) {
/* stop after the first keyframe has been processed */
- if (first == 0)
+ if (first == 0) {
break;
+ }
}
else if (mode == POSE_PROPAGATE_LAST_KEY) {
/* only affect this frame if it will be the last one */
- if (i != (fcu->totvert - 1))
+ if (i != (fcu->totvert - 1)) {
continue;
+ }
}
else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
/* only allow if there's a marker on this frame */
@@ -1614,18 +1632,21 @@ static void pose_propagate_fcurve(
/* stop on matching marker if there is one */
for (ce = modeData.sel_markers.first; ce; ce = ce->next) {
- if (ce->cfra == round_fl_to_int(bezt->vec[1][0]))
+ if (ce->cfra == round_fl_to_int(bezt->vec[1][0])) {
break;
+ }
}
/* skip this keyframe if no marker */
- if (ce == NULL)
+ if (ce == NULL) {
continue;
+ }
}
else if (mode == POSE_PROPAGATE_SELECTED_KEYS) {
/* only allow if this keyframe is already selected - skip otherwise */
- if (BEZT_ISSEL_ANY(bezt) == 0)
+ if (BEZT_ISSEL_ANY(bezt) == 0) {
continue;
+ }
}
/* just flatten handles, since values will now be the same either side... */
@@ -1656,7 +1677,8 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
poseAnim_mapping_get(C, &pflinks);
if (BLI_listbase_is_empty(&pflinks)) {
- /* There is a change the reason the list is empty is that there is no valid object to propagate poses for.
+ /* There is a change the reason the list is empty is
+ * that there is no valid object to propagate poses for.
* This is very unlikely though, so we focus on the most likely issue. */
BKE_report(op->reports, RPT_ERROR, "No keyframed poses to propagate to");
return OPERATOR_CANCELLED;
@@ -1693,8 +1715,9 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
/* free temp data */
poseAnim_mapping_free(&pflinks);
- if (mode == POSE_PROPAGATE_SELECTED_MARKERS)
+ if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
BLI_freelistN(&modeData.sel_markers);
+ }
/* updates + notifiers */
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
@@ -1760,7 +1783,7 @@ void POSE_OT_propagate(wmOperatorType *ot)
ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */
/* flag */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
/* properties */
/* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 3a4413f8c1d..6207d5412cf 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -102,8 +102,9 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
EditBone *curbone;
/* don't check if editmode (should be done by caller) */
- if (ob->type != OB_ARMATURE)
+ if (ob->type != OB_ARMATURE) {
return OPERATOR_CANCELLED;
+ }
if (BKE_object_obdata_is_libdata(ob)) {
BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature");
return OPERATOR_CANCELLED;
@@ -111,11 +112,12 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
/* helpful warnings... */
/* TODO: add warnings to be careful about actions, applying deforms first, etc. */
- if (ob->adt && ob->adt->action)
+ if (ob->adt && ob->adt->action) {
BKE_report(op->reports,
RPT_WARNING,
"Actions on this armature will be destroyed by this new rest pose as the "
"transforms stored are relative to the old rest pose");
+ }
/* Get editbones of active armature to alter */
ED_armature_to_edit(arm);
@@ -160,23 +162,26 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
*/
if (pchan->bone->segments > 1) {
/* combine rest/pose values */
- curbone->curveInX += pchan_eval->curveInX;
- curbone->curveInY += pchan_eval->curveInY;
- curbone->curveOutX += pchan_eval->curveOutX;
- curbone->curveOutY += pchan_eval->curveOutY;
+ curbone->curve_in_x += pchan_eval->curve_in_x;
+ curbone->curve_in_y += pchan_eval->curve_in_y;
+ curbone->curve_out_x += pchan_eval->curve_out_x;
+ curbone->curve_out_y += pchan_eval->curve_out_y;
curbone->roll1 += pchan_eval->roll1;
curbone->roll2 += pchan_eval->roll2;
curbone->ease1 += pchan_eval->ease1;
curbone->ease2 += pchan_eval->ease2;
- curbone->scaleIn += pchan_eval->scaleIn;
- curbone->scaleOut += pchan_eval->scaleOut;
+ curbone->scale_in_x *= pchan_eval->scale_in_x;
+ curbone->scale_in_y *= pchan_eval->scale_in_y;
+ curbone->scale_out_x *= pchan_eval->scale_out_x;
+ curbone->scale_out_y *= pchan_eval->scale_out_y;
/* reset pose values */
- pchan->curveInX = pchan->curveOutX = 0.0f;
- pchan->curveInY = pchan->curveOutY = 0.0f;
+ pchan->curve_in_x = pchan->curve_out_x = 0.0f;
+ pchan->curve_in_y = pchan->curve_out_y = 0.0f;
pchan->roll1 = pchan->roll2 = 0.0f;
pchan->ease1 = pchan->ease2 = 0.0f;
- pchan->scaleIn = pchan->scaleOut = 1.0f;
+ pchan->scale_in_x = pchan->scale_in_y = 1.0f;
+ pchan->scale_out_x = pchan->scale_out_y = 1.0f;
}
/* clear transform values for pchan */
@@ -244,8 +249,9 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
* new raw-transform components, don't recalc the poses yet, otherwise IK result will
* change, thus changing the result we may be trying to record.
*/
- /* XXX For some reason, we can't use pchan->chan_mat here, gives odd rotation/offset (see T38251).
- * Using pchan->pose_mat and bringing it back in bone space seems to work as expected!
+ /* XXX For some reason, we can't use pchan->chan_mat here, gives odd rotation/offset
+ * (see T38251).
+ * Using pchan->pose_mat and bringing it back in bone space seems to work as expected!
*/
BKE_armature_mat_pose_to_bone(pchan_eval, pchan_eval->pose_mat, delta_mat);
@@ -292,10 +298,12 @@ static void set_pose_keys(Object *ob)
if (ob->pose) {
for (chan = ob->pose->chanbase.first; chan; chan = chan->next) {
Bone *bone = chan->bone;
- if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer))
+ if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) {
chan->flag |= POSE_KEY;
- else
+ }
+ else {
chan->flag &= ~POSE_KEY;
+ }
}
}
}
@@ -319,21 +327,26 @@ static bPoseChannel *pose_bone_do_paste(Object *ob,
short paste_ok;
/* get the name - if flipping, we must flip this first */
- if (flip)
+ if (flip) {
BLI_string_flip_side_name(name, chan->name, false, sizeof(name));
- else
+ }
+ else {
BLI_strncpy(name, chan->name, sizeof(name));
+ }
/* only copy when:
* 1) channel exists - poses are not meant to add random channels to anymore
- * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical
+ * 2) if selection-masking is on, channel is selected -
+ * only selected bones get pasted on, allowing making both sides symmetrical.
*/
pchan = BKE_pose_channel_find_name(ob->pose, name);
- if (selOnly)
+ if (selOnly) {
paste_ok = ((pchan) && (pchan->bone->flag & BONE_SELECTED));
- else
+ }
+ else {
paste_ok = (pchan != NULL);
+ }
/* continue? */
if (paste_ok) {
@@ -360,45 +373,53 @@ static bPoseChannel *pose_bone_do_paste(Object *ob,
}
else if (pchan->rotmode > 0) {
/* quat/axis-angle to euler */
- if (chan->rotmode == ROT_MODE_AXISANGLE)
+ if (chan->rotmode == ROT_MODE_AXISANGLE) {
axis_angle_to_eulO(pchan->eul, pchan->rotmode, chan->rotAxis, chan->rotAngle);
- else
+ }
+ else {
quat_to_eulO(pchan->eul, pchan->rotmode, chan->quat);
+ }
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
/* quat/euler to axis angle */
- if (chan->rotmode > 0)
+ if (chan->rotmode > 0) {
eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->eul, chan->rotmode);
- else
+ }
+ else {
quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->quat);
+ }
}
else {
/* euler/axis-angle to quat */
- if (chan->rotmode > 0)
+ if (chan->rotmode > 0) {
eulO_to_quat(pchan->quat, chan->eul, chan->rotmode);
- else
+ }
+ else {
axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle);
+ }
}
/* B-Bone posing options should also be included... */
- pchan->curveInX = chan->curveInX;
- pchan->curveInY = chan->curveInY;
- pchan->curveOutX = chan->curveOutX;
- pchan->curveOutY = chan->curveOutY;
+ pchan->curve_in_x = chan->curve_in_x;
+ pchan->curve_in_y = chan->curve_in_y;
+ pchan->curve_out_x = chan->curve_out_x;
+ pchan->curve_out_y = chan->curve_out_y;
pchan->roll1 = chan->roll1;
pchan->roll2 = chan->roll2;
pchan->ease1 = chan->ease1;
pchan->ease2 = chan->ease2;
- pchan->scaleIn = chan->scaleIn;
- pchan->scaleOut = chan->scaleOut;
+ pchan->scale_in_x = chan->scale_in_x;
+ pchan->scale_in_y = chan->scale_in_y;
+ pchan->scale_out_x = chan->scale_out_x;
+ pchan->scale_out_y = chan->scale_out_y;
/* paste flipped pose? */
if (flip) {
pchan->loc[0] *= -1;
- pchan->curveInX *= -1;
- pchan->curveOutX *= -1;
+ pchan->curve_in_x *= -1;
+ pchan->curve_out_x *= -1;
pchan->roll1 *= -1; // XXX?
pchan->roll2 *= -1; // XXX?
@@ -626,28 +647,34 @@ void POSE_OT_paste(wmOperatorType *ot)
/* clear scale of pose-channel */
static void pchan_clear_scale(bPoseChannel *pchan)
{
- if ((pchan->protectflag & OB_LOCK_SCALEX) == 0)
+ if ((pchan->protectflag & OB_LOCK_SCALEX) == 0) {
pchan->size[0] = 1.0f;
- if ((pchan->protectflag & OB_LOCK_SCALEY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_SCALEY) == 0) {
pchan->size[1] = 1.0f;
- if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0) {
pchan->size[2] = 1.0f;
+ }
pchan->ease1 = 0.0f;
pchan->ease2 = 0.0f;
- pchan->scaleIn = 1.0f;
- pchan->scaleOut = 1.0f;
+ pchan->scale_in_x = pchan->scale_in_y = 1.0f;
+ pchan->scale_out_x = pchan->scale_out_y = 1.0f;
}
/* clear location of pose-channel */
static void pchan_clear_loc(bPoseChannel *pchan)
{
- if ((pchan->protectflag & OB_LOCK_LOCX) == 0)
+ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) {
pchan->loc[0] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_LOCY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_LOCY) == 0) {
pchan->loc[1] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_LOCZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) {
pchan->loc[2] = 0.0f;
+ }
}
/* clear rotation of pose-channel */
@@ -658,38 +685,51 @@ static void pchan_clear_rot(bPoseChannel *pchan)
if (pchan->protectflag & OB_LOCK_ROT4D) {
/* perform clamping on a component by component basis */
if (pchan->rotmode == ROT_MODE_AXISANGLE) {
- if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
+ if ((pchan->protectflag & OB_LOCK_ROTW) == 0) {
pchan->rotAngle = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTX) == 0) {
pchan->rotAxis[0] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTY) == 0) {
pchan->rotAxis[1] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) {
pchan->rotAxis[2] = 0.0f;
+ }
- /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
+ /* check validity of axis - axis should never be 0,0,0
+ * (if so, then we make it rotate about y). */
if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) &&
- IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2]))
+ IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2])) {
pchan->rotAxis[1] = 1.0f;
+ }
}
else if (pchan->rotmode == ROT_MODE_QUAT) {
- if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
+ if ((pchan->protectflag & OB_LOCK_ROTW) == 0) {
pchan->quat[0] = 1.0f;
- if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTX) == 0) {
pchan->quat[1] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTY) == 0) {
pchan->quat[2] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) {
pchan->quat[3] = 0.0f;
+ }
}
else {
/* the flag may have been set for the other modes, so just ignore the extra flag... */
- if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
+ if ((pchan->protectflag & OB_LOCK_ROTX) == 0) {
pchan->eul[0] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTY) == 0) {
pchan->eul[1] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) {
pchan->eul[2] = 0.0f;
+ }
}
}
else {
@@ -710,12 +750,15 @@ static void pchan_clear_rot(bPoseChannel *pchan)
eul[0] = eul[1] = eul[2] = 0.0f;
- if (pchan->protectflag & OB_LOCK_ROTX)
+ if (pchan->protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (pchan->protectflag & OB_LOCK_ROTY)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (pchan->protectflag & OB_LOCK_ROTZ)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
if (pchan->rotmode == ROT_MODE_QUAT) {
eul_to_quat(pchan->quat, eul);
@@ -755,10 +798,10 @@ static void pchan_clear_rot(bPoseChannel *pchan)
pchan->roll1 = 0.0f;
pchan->roll2 = 0.0f;
- pchan->curveInX = 0.0f;
- pchan->curveInY = 0.0f;
- pchan->curveOutX = 0.0f;
- pchan->curveOutY = 0.0f;
+ pchan->curve_in_x = 0.0f;
+ pchan->curve_in_y = 0.0f;
+ pchan->curve_out_x = 0.0f;
+ pchan->curve_out_y = 0.0f;
}
/* clear loc/rot/scale of pose-channel */
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index d8793bc2a1e..a1f763ac57d 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -91,14 +91,18 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks,
BLI_addtail(pfLinks, pfl);
/* set pchan's transform flags */
- if (transFlags & ACT_TRANS_LOC)
+ if (transFlags & ACT_TRANS_LOC) {
pchan->flag |= POSE_LOC;
- if (transFlags & ACT_TRANS_ROT)
+ }
+ if (transFlags & ACT_TRANS_ROT) {
pchan->flag |= POSE_ROT;
- if (transFlags & ACT_TRANS_SCALE)
+ }
+ if (transFlags & ACT_TRANS_SCALE) {
pchan->flag |= POSE_SIZE;
- if (transFlags & ACT_TRANS_BBONE)
+ }
+ if (transFlags & ACT_TRANS_BBONE) {
pchan->flag |= POSE_BBONE_SHAPE;
+ }
/* store current transforms */
copy_v3_v3(pfl->oldloc, pchan->loc);
@@ -111,18 +115,21 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks,
/* store current bbone values */
pfl->roll1 = pchan->roll1;
pfl->roll2 = pchan->roll2;
- pfl->curveInX = pchan->curveInX;
- pfl->curveInY = pchan->curveInY;
- pfl->curveOutX = pchan->curveOutX;
- pfl->curveOutY = pchan->curveOutY;
+ pfl->curve_in_x = pchan->curve_in_x;
+ pfl->curve_in_y = pchan->curve_in_y;
+ pfl->curve_out_x = pchan->curve_out_x;
+ pfl->curve_out_y = pchan->curve_out_y;
pfl->ease1 = pchan->ease1;
pfl->ease2 = pchan->ease2;
- pfl->scaleIn = pchan->scaleIn;
- pfl->scaleOut = pchan->scaleOut;
+ pfl->scale_in_x = pchan->scale_in_x;
+ pfl->scale_in_y = pchan->scale_in_y;
+ pfl->scale_out_x = pchan->scale_out_x;
+ pfl->scale_out_y = pchan->scale_out_y;
/* make copy of custom properties */
- if (pchan->prop && (transFlags & ACT_TRANS_PROP))
+ if (pchan->prop && (transFlags & ACT_TRANS_PROP)) {
pfl->oldprops = IDP_CopyProperty(pchan->prop);
+ }
}
}
@@ -148,8 +155,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks)
prev_ob = NULL;
ob_pose_armature = NULL;
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
if (ob != prev_ob) {
prev_ob = ob;
ob_pose_armature = poseAnim_object_get(ob);
@@ -169,8 +175,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks)
if (BLI_listbase_is_empty(pfLinks)) {
prev_ob = NULL;
ob_pose_armature = NULL;
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
if (ob != prev_ob) {
prev_ob = ob;
ob_pose_armature = poseAnim_object_get(ob);
@@ -215,22 +220,9 @@ void poseAnim_mapping_free(ListBase *pfLinks)
/* ------------------------- */
/* helper for apply() / reset() - refresh the data */
-void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
+void poseAnim_mapping_refresh(bContext *C, Scene *UNUSED(scene), Object *ob)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- bArmature *arm = (bArmature *)ob->data;
-
- /* old optimize trick... this enforces to bypass the depgraph
- * - note: code copied from transform_generics.c -> recalcData()
- */
- /* FIXME: shouldn't this use the builtin stuff? */
- if ((arm->flag & ARM_DELAYDEFORM) == 0)
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
- else
- BKE_pose_where_is(depsgraph, scene, ob);
-
- /* otherwise animation doesn't get updated */
- DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
}
@@ -254,18 +246,21 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
/* store current bbone values */
pchan->roll1 = pfl->roll1;
pchan->roll2 = pfl->roll2;
- pchan->curveInX = pfl->curveInX;
- pchan->curveInY = pfl->curveInY;
- pchan->curveOutX = pfl->curveOutX;
- pchan->curveOutY = pfl->curveOutY;
+ pchan->curve_in_x = pfl->curve_in_x;
+ pchan->curve_in_y = pfl->curve_in_y;
+ pchan->curve_out_x = pfl->curve_out_x;
+ pchan->curve_out_y = pfl->curve_out_y;
pchan->ease1 = pfl->ease1;
pchan->ease2 = pfl->ease2;
- pchan->scaleIn = pfl->scaleIn;
- pchan->scaleOut = pfl->scaleOut;
+ pchan->scale_in_x = pfl->scale_in_x;
+ pchan->scale_in_y = pfl->scale_in_y;
+ pchan->scale_out_x = pfl->scale_out_x;
+ pchan->scale_out_y = pfl->scale_out_y;
/* just overwrite values of properties from the stored copies (there should be some) */
- if (pfl->oldprops)
+ if (pfl->oldprops) {
IDP_SyncGroupValues(pfl->pchan->prop, pfl->oldprops);
+ }
}
}
@@ -332,7 +327,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks,
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
if (ob->id.tag & LIB_TAG_DOIT) {
if (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) {
- //ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
+ // ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
ED_pose_recalculate_paths(C, scene, ob, false);
}
}
@@ -355,8 +350,9 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con
FCurve *fcu = (FCurve *)ld->data;
/* check if paths match */
- if (STREQ(path, fcu->rna_path))
+ if (STREQ(path, fcu->rna_path)) {
return ld;
+ }
}
/* none found */
diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt
index 3df6f3c97d4..8c9309055c8 100644
--- a/source/blender/editors/curve/CMakeLists.txt
+++ b/source/blender/editors/curve/CMakeLists.txt
@@ -26,8 +26,8 @@ set(INC
../../makesrna
../../windowmanager
../../../../intern/clog
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
../../../../extern/curve_fit_nd
)
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index 782b093fab4..3d2ac009072 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -147,7 +147,7 @@ void ED_operatormacros_curve(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "CURVE_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("CURVE_OT_extrude_move",
@@ -156,7 +156,7 @@ void ED_operatormacros_curve(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "CURVE_OT_extrude");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index c37ce4cc89d..a787b45c13c 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -104,11 +104,13 @@ void printknots(Object *obedit)
if (ED_curve_nurb_select_check(nu) && nu->type == CU_NURBS) {
if (nu->knotsu) {
num = KNOTSU(nu);
- for (a = 0; a < num; a++) printf("knotu %d: %f\n", a, nu->knotsu[a]);
+ for (a = 0; a < num; a++)
+ printf("knotu %d: %f\n", a, nu->knotsu[a]);
}
if (nu->knotsv) {
num = KNOTSV(nu);
- for (a = 0; a < num; a++) printf("knotv %d: %f\n", a, nu->knotsv[a]);
+ for (a = 0; a < num; a++)
+ printf("knotv %d: %f\n", a, nu->knotsv[a]);
}
}
}
@@ -731,8 +733,8 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs)
nu = editnurb->nurbs.first;
/* We need to restore to original curve into newnurb, *not* editcurve's nurbs.
- * Otherwise, in case we update obdata *without* leaving editmode (e.g. viewport render), we would
- * invalidate editcurve. */
+ * Otherwise, in case we update obdata *without* leaving editmode (e.g. viewport render),
+ * we would invalidate editcurve. */
newnu = newnurbs->first;
i = 0;
while (nu) {
@@ -1273,9 +1275,10 @@ void ED_curve_editnurb_load(Main *bmain, Object *obedit)
}
}
- /* We have to pass also new copied nurbs, since we want to restore original curve (without edited shapekey)
- * on obdata, but *not* on editcurve itself (ED_curve_editnurb_load call does not always implies freeing
- * of editcurve, e.g. when called to generate render data...). */
+ /* We have to pass also new copied nurbs, since we want to restore original curve
+ * (without edited shapekey) on obdata, but *not* on editcurve itself
+ * (ED_curve_editnurb_load call does not always implies freeing
+ * of editcurve, e.g. when called to generate render data). */
calc_shapeKeys(obedit, &newnurb);
cu->nurb = newnurb;
@@ -2286,7 +2289,8 @@ static void adduplicateflagNurb(
}
else {
if (ED_curve_nurb_select_check(v3d, nu)) {
- /* a rectangular area in nurb has to be selected and if splitting must be in U or V direction */
+ /* A rectangular area in nurb has to be selected and if splitting
+ * must be in U or V direction. */
usel = MEM_callocN(nu->pntsu, "adduplicateN3");
bp = nu->bp;
for (a = 0; a < nu->pntsv; a++) {
@@ -3724,7 +3728,8 @@ void CURVE_OT_subdivide(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, 1000, "Number of cuts", "", 1, 10);
- /* avoid re-using last var because it can cause _very_ high poly meshes and annoy users (or worse crash) */
+ /* Avoid re-using last var because it can cause _very_ high poly meshes
+ * and annoy users (or worse crash). */
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/gizmo_library/CMakeLists.txt b/source/blender/editors/gizmo_library/CMakeLists.txt
index 8b035d3207d..d9503c4e759 100644
--- a/source/blender/editors/gizmo_library/CMakeLists.txt
+++ b/source/blender/editors/gizmo_library/CMakeLists.txt
@@ -27,9 +27,9 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/eigen
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/gizmo_library/gizmo_geometry.h b/source/blender/editors/gizmo_library/gizmo_geometry.h
index 42cb0c0bc1b..ae8ba3c411b 100644
--- a/source/blender/editors/gizmo_library/gizmo_geometry.h
+++ b/source/blender/editors/gizmo_library/gizmo_geometry.h
@@ -22,8 +22,9 @@
*
* \name Gizmo Geometry
*
- * \brief Prototypes for arrays defining the gizmo geometry. The actual definitions can be found in files usually
- * called geom_xxx_gizmo.c
+ * \brief Prototypes for arrays defining the gizmo geometry.
+ * The actual definitions can be found in files usually
+ * called geom_xxx_gizmo.c
*/
#ifndef __GIZMO_GEOMETRY_H__
diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c
index 2e5c3b37542..1f61c45eb80 100644
--- a/source/blender/editors/gizmo_library/gizmo_library_utils.c
+++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c
@@ -68,9 +68,10 @@ float gizmo_offset_from_value(GizmoCommonData *data,
const bool constrained,
const bool inverted)
{
- if (constrained)
+ if (constrained) {
return gizmo_offset_from_value_constr(
data->range_fac, data->min, data->range, value, inverted);
+ }
return value;
}
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
index 77658b8495e..780cca66fb9 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
@@ -573,8 +573,10 @@ static void cage2d_draw_circle_handles(const rctf *r,
}
if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) {
- const float handle[2] = {BLI_rctf_cent_x(r),
- r->ymax + (margin[1] * GIZMO_MARGIN_OFFSET_SCALE)};
+ const float handle[2] = {
+ BLI_rctf_cent_x(r),
+ r->ymax + (margin[1] * GIZMO_MARGIN_OFFSET_SCALE),
+ };
circle_fn(pos, handle[0], handle[1], rad[0], rad[1], resolu);
}
@@ -935,7 +937,8 @@ static int gizmo_cage2d_modal(bContext *C,
}
/* For transform logic to be manageable we operate in -0.5..0.5 2D space,
* no matter the size of the rectangle, mouse coords are scaled to unit space.
- * The mouse coords have been projected into the matrix so we don't need to worry about axis alignment.
+ * The mouse coords have been projected into the matrix
+ * so we don't need to worry about axis alignment.
*
* - The cursor offset are multiplied by 'dims'.
* - Matrix translation is also multiplied by 'dims'.
@@ -1115,8 +1118,9 @@ static void gizmo_cage2d_exit(bContext *C, wmGizmo *gz, const bool cancel)
MEM_SAFE_FREE(data->dial);
- if (!cancel)
+ if (!cancel) {
return;
+ }
wmGizmoProperty *gz_prop;
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
index 3273012930a..e2a86469da1 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
@@ -338,10 +338,10 @@ static void gizmo_cage3d_draw_intern(
else {
#if 0
const rctf _r = {
- .xmin = -size_real[0],
- .ymin = -size_real[1],
- .xmax = size_real[0],
- .ymax = size_real[1],
+ .xmin = -size_real[0],
+ .ymin = -size_real[1],
+ .xmax = size_real[0],
+ .ymax = size_real[1],
};
#endif
if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) {
@@ -470,7 +470,8 @@ static int gizmo_cage3d_modal(bContext *C,
}
/* For transform logic to be manageable we operate in -0.5..0.5 2D space,
* no matter the size of the rectangle, mouse coords are scaled to unit space.
- * The mouse coords have been projected into the matrix so we don't need to worry about axis alignment.
+ * The mouse coords have been projected into the matrix
+ * so we don't need to worry about axis alignment.
*
* - The cursor offset are multiplied by 'dims'.
* - Matrix translation is also multiplied by 'dims'.
@@ -615,8 +616,9 @@ static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
{
RectTransformInteraction *data = gz->interaction_data;
- if (!cancel)
+ if (!cancel) {
return;
+ }
wmGizmoProperty *gz_prop;
diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt
index 5573c88c710..21f1801f7eb 100644
--- a/source/blender/editors/gpencil/CMakeLists.txt
+++ b/source/blender/editors/gpencil/CMakeLists.txt
@@ -22,13 +22,13 @@ set(INC
../../blenlib
../../blentranslation
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index a7fa51350ba..f325422fec7 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -91,22 +91,24 @@ typedef enum eDrawStrokeFlags {
/* ----- Tool Buffer Drawing ------ */
/* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */
-static void gp_draw_stroke_buffer(const tGPspoint *points,
- int totpoints,
- short thickness,
- short dflag,
- short sflag,
- float ink[4])
+static void annotation_draw_stroke_buffer(const tGPspoint *points,
+ int totpoints,
+ short thickness,
+ short dflag,
+ short sflag,
+ float ink[4])
{
int draw_points = 0;
/* error checking */
- if ((points == NULL) || (totpoints <= 0))
+ if ((points == NULL) || (totpoints <= 0)) {
return;
+ }
/* check if buffer can be drawn */
- if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
+ if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) {
return;
+ }
if (sflag & GP_STROKE_ERASER) {
/* don't draw stroke at all! */
@@ -138,8 +140,9 @@ static void gp_draw_stroke_buffer(const tGPspoint *points,
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints);
for (int i = 0; i < totpoints; i++, pt++) {
- /* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
- * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
+ /* If there was a significant pressure change,
+ * stop the curve, change the thickness of the stroke,
+ * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP).
*/
if (fabsf(pt->pressure - oldpressure) > 0.2f) {
/* need to have 2 points to avoid immEnd assert error */
@@ -178,7 +181,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points,
/* --------- 2D Stroke Drawing Helpers --------- */
/* change in parameter list */
-static void gp_calc_2d_stroke_fxy(
+static void annotation_calc_2d_stroke_fxy(
const float pt[3], short sflag, int offsx, int offsy, int winx, int winy, float r_co[2])
{
if (sflag & GP_STROKE_2DSPACE) {
@@ -204,15 +207,15 @@ static void gp_calc_2d_stroke_fxy(
/* ----- Existing Strokes Drawing (3D and Point) ------ */
/* draw a given stroke - just a single dot (only one point) */
-static void gp_draw_stroke_point(const bGPDspoint *points,
- short thickness,
- short UNUSED(dflag),
- short sflag,
- int offsx,
- int offsy,
- int winx,
- int winy,
- const float ink[4])
+static void annotation_draw_stroke_point(const bGPDspoint *points,
+ short thickness,
+ short UNUSED(dflag),
+ short sflag,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ const float ink[4])
{
const bGPDspoint *pt = points;
@@ -231,7 +234,7 @@ static void gp_draw_stroke_point(const bGPDspoint *points,
/* get 2D coordinates of point */
float co[3] = {0.0f};
- gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co);
+ annotation_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co);
copy_v3_v3(fpt, co);
}
@@ -249,12 +252,12 @@ static void gp_draw_stroke_point(const bGPDspoint *points,
}
/* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */
-static void gp_draw_stroke_3d(const bGPDspoint *points,
- int totpoints,
- short thickness,
- short UNUSED(sflag),
- const float ink[4],
- bool cyclic)
+static void annotation_draw_stroke_3d(const bGPDspoint *points,
+ int totpoints,
+ short thickness,
+ short UNUSED(sflag),
+ const float ink[4],
+ bool cyclic)
{
float curpressure = points[0].pressure;
float cyclic_fpt[3];
@@ -277,8 +280,9 @@ static void gp_draw_stroke_3d(const bGPDspoint *points,
immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints + cyclic_add);
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints; i++, pt++) {
- /* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
- * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
+ /* If there was a significant pressure change, stop the curve,
+ * change the thickness of the stroke, and continue drawing again
+ * (since line-width cannot change in middle of GL_LINE_STRIP)
* Note: we want more visible levels of pressures when thickness is bigger.
*/
if (fabsf(pt->pressure - curpressure) > 0.2f / (float)thickness) {
@@ -332,16 +336,16 @@ static void gp_draw_stroke_3d(const bGPDspoint *points,
/* ----- Fancy 2D-Stroke Drawing ------ */
/* draw a given stroke in 2d */
-static void gp_draw_stroke_2d(const bGPDspoint *points,
- int totpoints,
- short thickness_s,
- short dflag,
- short sflag,
- int offsx,
- int offsy,
- int winx,
- int winy,
- const float ink[4])
+static void annotation_draw_stroke_2d(const bGPDspoint *points,
+ int totpoints,
+ short thickness_s,
+ short dflag,
+ short sflag,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ const float ink[4])
{
/* otherwise thickness is twice that of the 3D view */
float thickness = (float)thickness_s * 0.5f;
@@ -352,8 +356,9 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
scalefac = 0.001f;
}
- /* tessellation code - draw stroke as series of connected quads (triangle strips in fact) with connection
- * edges rotated to minimize shrinking artifacts, and rounded endcaps
+ /* Tessellation code - draw stroke as series of connected quads
+ * (triangle strips in fact) with connection edges rotated to minimize shrinking artifacts,
+ * and rounded endcaps.
*/
{
const bGPDspoint *pt1, *pt2;
@@ -369,7 +374,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
immBegin(GPU_PRIM_TRI_STRIP, totpoints * 2 + 4);
/* get x and y coordinates from first point */
- gp_calc_2d_stroke_fxy(&points->x, sflag, offsx, offsy, winx, winy, s0);
+ annotation_calc_2d_stroke_fxy(&points->x, sflag, offsx, offsy, winx, winy, s0);
for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) {
float t0[2], t1[2]; /* tessellated coordinates */
@@ -377,8 +382,9 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
float mt[2], sc[2]; /* gradient for thickness, point for end-cap */
float pthick; /* thickness at segment point */
- /* get x and y coordinates from point2 (point1 has already been computed in previous iteration). */
- gp_calc_2d_stroke_fxy(&pt2->x, sflag, offsx, offsy, winx, winy, s1);
+ /* Get x and y coordinates from point2
+ * (point1 has already been computed in previous iteration). */
+ annotation_calc_2d_stroke_fxy(&pt2->x, sflag, offsx, offsy, winx, winy, s1);
/* calculate gradient and normal - 'angle'=(ny/nx) */
m1[1] = s1[1] - s0[1];
@@ -507,52 +513,59 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
/* ----- Strokes Drawing ------ */
/* Helper for doing all the checks on whether a stroke can be drawn */
-static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag)
+static bool annotation_can_draw_stroke(const bGPDstroke *gps, const int dflag)
{
/* skip stroke if it isn't in the right display space for this drawing context */
/* 1) 3D Strokes */
- if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE))
+ if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE)) {
return false;
+ }
/* 2) Screen Space 2D Strokes */
- if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE))
+ if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE)) {
return false;
+ }
/* 3) Image Space (2D) */
- if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE))
+ if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE)) {
return false;
+ }
/* skip stroke if it doesn't have any valid data */
- if ((gps->points == NULL) || (gps->totpoints < 1))
+ if ((gps->points == NULL) || (gps->totpoints < 1)) {
return false;
+ }
/* stroke can be drawn */
return true;
}
/* draw a set of strokes */
-static void gp_draw_strokes(bGPdata *UNUSED(gpd),
- bGPDlayer *UNUSED(gpl),
- const bGPDframe *gpf,
- int offsx,
- int offsy,
- int winx,
- int winy,
- int dflag,
- short lthick,
- const float color[4])
+static void annotation_draw_strokes(bGPdata *UNUSED(gpd),
+ bGPDlayer *UNUSED(gpl),
+ const bGPDframe *gpf,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ int dflag,
+ short lthick,
+ const float color[4])
{
GPU_enable_program_point_size();
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn */
- if (gp_can_draw_stroke(gps, dflag) == false) {
+ if (annotation_can_draw_stroke(gps, dflag) == false) {
continue;
}
@@ -573,11 +586,11 @@ static void gp_draw_strokes(bGPdata *UNUSED(gpd),
/* 3D Lines - OpenGL primitives-based */
if (gps->totpoints == 1) {
- gp_draw_stroke_point(
+ annotation_draw_stroke_point(
gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy, color);
}
else {
- gp_draw_stroke_3d(
+ annotation_draw_stroke_3d(
gps->points, gps->totpoints, lthick, gps->flag, color, gps->flag & GP_STROKE_CYCLIC);
}
@@ -591,20 +604,20 @@ static void gp_draw_strokes(bGPdata *UNUSED(gpd),
else {
/* 2D Strokes... */
if (gps->totpoints == 1) {
- gp_draw_stroke_point(
+ annotation_draw_stroke_point(
gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy, color);
}
else {
- gp_draw_stroke_2d(gps->points,
- gps->totpoints,
- lthick,
- dflag,
- gps->flag,
- offsx,
- offsy,
- winx,
- winy,
- color);
+ annotation_draw_stroke_2d(gps->points,
+ gps->totpoints,
+ lthick,
+ dflag,
+ gps->flag,
+ offsx,
+ offsy,
+ winx,
+ winy,
+ color);
}
}
}
@@ -613,20 +626,21 @@ static void gp_draw_strokes(bGPdata *UNUSED(gpd),
}
/* Draw selected verts for strokes being edited */
-static void gp_draw_strokes_edit(bGPdata *gpd,
- bGPDlayer *gpl,
- const bGPDframe *gpf,
- int offsx,
- int offsy,
- int winx,
- int winy,
- short dflag,
- short UNUSED(lflag),
- float alpha)
+static void annotation_draw_strokes_edit(bGPdata *gpd,
+ bGPDlayer *gpl,
+ const bGPDframe *gpf,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ short dflag,
+ short UNUSED(lflag),
+ float alpha)
{
/* if alpha 0 do not draw */
- if (alpha == 0.0f)
+ if (alpha == 0.0f) {
return;
+ }
const bool no_xray = (dflag & GP_DRAWDATA_NO_XRAY) != 0;
int mask_orig = 0;
@@ -649,15 +663,17 @@ static void gp_draw_strokes_edit(bGPdata *gpd,
/* draw stroke verts */
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn */
- if (gp_can_draw_stroke(gps, dflag) == false)
+ if (annotation_can_draw_stroke(gps, dflag) == false) {
continue;
+ }
/* Optimisation: only draw points for selected strokes
* We assume that selected points can only occur in
* strokes that are selected too.
*/
- if ((gps->flag & GP_STROKE_SELECT) == 0)
+ if ((gps->flag & GP_STROKE_SELECT) == 0) {
continue;
+ }
/* Get size of verts:
* - The selected state needs to be larger than the unselected state so that
@@ -726,7 +742,7 @@ static void gp_draw_strokes_edit(bGPdata *gpd,
}
else {
float co[2];
- gp_calc_2d_stroke_fxy(&pt->x, gps->flag, offsx, offsy, winx, winy, co);
+ annotation_calc_2d_stroke_fxy(&pt->x, gps->flag, offsx, offsy, winx, winy, co);
immVertex2fv(pos, co);
}
}
@@ -754,15 +770,15 @@ static void gp_draw_strokes_edit(bGPdata *gpd,
/* ----- General Drawing ------ */
/* draw onion-skinning for a layer */
-static void gp_draw_onionskins(bGPdata *gpd,
- bGPDlayer *gpl,
- bGPDframe *gpf,
- int offsx,
- int offsy,
- int winx,
- int winy,
- int UNUSED(cfra),
- int dflag)
+static void annotation_draw_onionskins(bGPdata *gpd,
+ bGPDlayer *gpl,
+ bGPDframe *gpf,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ int UNUSED(cfra),
+ int dflag)
{
const float alpha = 1.0f;
float color[4];
@@ -781,17 +797,20 @@ static void gp_draw_onionskins(bGPdata *gpd,
/* alpha decreases with distance from curframe index */
fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
color[3] = alpha * fac * 0.66f;
- gp_draw_strokes(gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
+ annotation_draw_strokes(
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
- else
+ else {
break;
+ }
}
}
else if (gpl->gstep == 0) {
/* draw the strokes for the ghost frames (at half of the alpha set by user) */
if (gpf->prev) {
color[3] = (alpha / 7);
- gp_draw_strokes(gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
+ annotation_draw_strokes(
+ gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
}
else {
@@ -812,17 +831,20 @@ static void gp_draw_onionskins(bGPdata *gpd,
/* alpha decreases with distance from curframe index */
fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
color[3] = alpha * fac * 0.66f;
- gp_draw_strokes(gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
+ annotation_draw_strokes(
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
- else
+ else {
break;
+ }
}
}
else if (gpl->gstep_next == 0) {
/* draw the strokes for the ghost frames (at half of the alpha set by user) */
if (gpf->next) {
color[3] = (alpha / 4);
- gp_draw_strokes(gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
+ annotation_draw_strokes(
+ gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
}
else {
@@ -831,7 +853,7 @@ static void gp_draw_onionskins(bGPdata *gpd,
}
/* loop over gpencil data layers, drawing them */
-static void gp_draw_data_layers(
+static void annotation_draw_data_layers(
bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag, float alpha)
{
float ink[4];
@@ -846,13 +868,15 @@ static void gp_draw_data_layers(
ink[3] = gpl->opacity;
/* don't draw layer if hidden */
- if (gpl->flag & GP_LAYER_HIDE)
+ if (gpl->flag & GP_LAYER_HIDE) {
continue;
+ }
/* get frame to draw */
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra, GP_GETFRAME_USE_PREV);
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* set basic stroke thickness */
GPU_line_width(lthick);
@@ -867,23 +891,25 @@ static void gp_draw_data_layers(
/* Draw 'onionskins' (frame left + right) */
if (gpl->onion_flag & GP_LAYER_ONIONSKIN) {
- gp_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag);
+ annotation_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag);
}
/* draw the strokes already in active frame */
- gp_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, lthick, ink);
+ annotation_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, lthick, ink);
- /* Draw verts of selected strokes
+ /* Draw verts of selected strokes:
* - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering
* - locked layers can't be edited, so there's no point showing these verts
* as they will have no bearings on what gets edited
* - only show when in editmode, since operators shouldn't work otherwise
- * (NOTE: doing it this way means that the toggling editmode shows visible change immediately)
+ * (NOTE: doing it this way means that the toggling editmode
+ * shows visible change immediately).
*/
/* XXX: perhaps we don't want to show these when users are drawing... */
if ((G.f & G_FLAG_RENDER_VIEWPORT) == 0 && (gpl->flag & GP_LAYER_LOCKED) == 0 &&
(gpd->flag & GP_DATA_STROKE_EDITMODE)) {
- gp_draw_strokes_edit(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, alpha);
+ annotation_draw_strokes_edit(
+ gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, alpha);
}
/* Check if may need to draw the active stroke cache, only if this layer is the active layer
@@ -897,24 +923,25 @@ static void gp_draw_data_layers(
* It should also be noted that sbuffer contains temporary point types
* i.e. tGPspoints NOT bGPDspoints
*/
- gp_draw_stroke_buffer(gpd->runtime.sbuffer,
- gpd->runtime.sbuffer_size,
- lthick,
- dflag,
- gpd->runtime.sbuffer_sflag,
- ink);
+ annotation_draw_stroke_buffer(gpd->runtime.sbuffer,
+ gpd->runtime.sbuffer_size,
+ lthick,
+ dflag,
+ gpd->runtime.sbuffer_sflag,
+ ink);
}
}
}
/* draw a short status message in the top-right corner */
-static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar)
+static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar)
{
rcti rect;
/* Cannot draw any status text when drawing OpenGL Renders */
- if (G.f & G_FLAG_RENDER_VIEWPORT)
+ if (G.f & G_FLAG_RENDER_VIEWPORT) {
return;
+ }
/* Get bounds of region - Necessary to avoid problems with region overlap */
ED_region_visible_rect(ar, &rect);
@@ -956,7 +983,7 @@ static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar)
}
/* draw grease-pencil datablock */
-static void gp_draw_data(
+static void annotation_draw_data(
bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag, float alpha)
{
/* turn on smooth lines (i.e. anti-aliasing) */
@@ -968,7 +995,7 @@ static void gp_draw_data(
GPU_blend(true);
/* draw! */
- gp_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
+ annotation_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
/* turn off alpha blending, then smooth lines */
GPU_blend(false); // alpha blending
@@ -977,15 +1004,15 @@ static void gp_draw_data(
/* if we have strokes for scenes (3d view)/clips (movie clip editor)
* and objects/tracks, multiple data blocks have to be drawn */
-static void gp_draw_data_all(Scene *scene,
- bGPdata *gpd,
- int offsx,
- int offsy,
- int winx,
- int winy,
- int cfra,
- int dflag,
- const char spacetype)
+static void annotation_draw_data_all(Scene *scene,
+ bGPdata *gpd,
+ int offsx,
+ int offsy,
+ int winx,
+ int winy,
+ int cfra,
+ int dflag,
+ const char spacetype)
{
bGPdata *gpd_source = NULL;
float alpha = 1.0f;
@@ -1001,14 +1028,14 @@ static void gp_draw_data_all(Scene *scene,
}
if (gpd_source) {
- gp_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag, alpha);
+ annotation_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag, alpha);
}
}
/* scene/clip data has already been drawn, only object/track data is drawn here
* if gpd_source == gpd, we don't have any object/track data and we can skip */
if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) {
- gp_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
+ annotation_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
}
}
@@ -1032,8 +1059,9 @@ void ED_annotation_draw_2dimage(const bContext *C)
int dflag = GP_DRAWDATA_NOSTATUS;
bGPdata *gpd = ED_gpencil_data_get_active(C); // XXX
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* calculate rect */
switch (sa->spacetype) {
@@ -1041,7 +1069,8 @@ void ED_annotation_draw_2dimage(const bContext *C)
case SPACE_CLIP: /* clip */
{
/* just draw using standard scaling (settings here are currently ignored anyways) */
- /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */
+ /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way,
+ * so disabled. */
offsx = 0;
offsy = 0;
sizex = ar->winx;
@@ -1083,12 +1112,16 @@ void ED_annotation_draw_2dimage(const bContext *C)
}
/* draw it! */
- gp_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype);
+ annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype);
}
-/* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly
- * Note: this gets called twice - first time with onlyv2d=true to draw 'canvas' strokes,
- * second time with onlyv2d=false for screen-aligned strokes */
+/**
+ * Draw grease-pencil sketches to specified 2d-view
+ * assuming that matrices are already set correctly.
+ *
+ * \note This gets called twice - first time with onlyv2d=true to draw 'canvas' strokes,
+ * second time with onlyv2d=false for screen-aligned strokes.
+ */
void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -1098,28 +1131,34 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
int dflag = 0;
/* check that we have grease-pencil stuff to draw */
- if (sa == NULL)
+ if (sa == NULL) {
return;
+ }
bGPdata *gpd = ED_gpencil_data_get_active(C); // XXX
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* special hack for Image Editor */
- /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */
- if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP))
+ /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way,
+ * so disabled. */
+ if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
dflag |= GP_DRAWDATA_IEDITHACK;
+ }
/* draw it! */
- if (onlyv2d)
+ if (onlyv2d) {
dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS);
- if (ED_screen_animation_playing(wm))
+ }
+ if (ED_screen_animation_playing(wm)) {
dflag |= GP_DRAWDATA_NO_ONIONS;
+ }
- gp_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype);
+ annotation_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype);
/* draw status text (if in screen/pixel-space) */
if (!onlyv2d) {
- gp_draw_status_text(gpd, ar);
+ annotation_draw_status_text(gpd, ar);
}
}
@@ -1136,8 +1175,9 @@ void ED_annotation_draw_view3d(
/* check that we have grease-pencil stuff to draw */
/* XXX: Hardcoded reference here may get out of sync if we change how we fetch annotation data */
bGPdata *gpd = scene->gpd;
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* when rendering to the offscreen buffer we don't want to
* deal with the camera border, otherwise map the coords to the camera border. */
@@ -1172,7 +1212,7 @@ void ED_annotation_draw_view3d(
}
/* draw it! */
- gp_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
+ annotation_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
}
void ED_annotation_draw_ex(
@@ -1180,7 +1220,7 @@ void ED_annotation_draw_ex(
{
int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D;
- gp_draw_data_all(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype);
+ annotation_draw_data_all(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype);
}
/* ************************************************** */
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 4933f081790..73230e5fb0e 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -160,7 +160,8 @@ typedef struct tGPsdata {
/* These need to be doubles, as (at least under unix) they are in seconds since epoch,
* float (and its 7 digits precision) is definitively not enough here!
- * double, with its 15 digits precision, ensures us millisecond precision for a few centuries at least.
+ * double, with its 15 digits precision,
+ * ensures us millisecond precision for a few centuries at least.
*/
/** Used when converting to path. */
double inittime;
@@ -231,10 +232,12 @@ static bool gpencil_draw_poll(bContext *C)
/* check if current context can support GPencil data */
if (ED_gpencil_data_get_pointers(C, NULL) != NULL) {
/* check if Grease Pencil isn't already running */
- if (ED_gpencil_session_active() == 0)
+ if (ED_gpencil_session_active() == 0) {
return true;
- else
+ }
+ else {
CTX_wm_operator_poll_msg_set(C, "Annotation operator is already active");
+ }
}
else {
CTX_wm_operator_poll_msg_set(C, "Failed to find Grease Pencil data to draw into");
@@ -278,25 +281,30 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2
int dy = (int)fabsf(mval[1] - pmval[1]);
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
- if (p->gpd->runtime.sbuffer_size == 0)
+ if (p->gpd->runtime.sbuffer_size == 0) {
return true;
- /* check if mouse moved at least certain distance on both axes (best case)
- * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
- */
- else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX))
+ /* check if mouse moved at least certain distance on both axes (best case)
+ * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
+ */
+ }
+ else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
return true;
- /* check if the distance since the last point is significant enough
- * - prevents points being added too densely
- * - distance here doesn't use sqrt to prevent slowness... we should still be safe from overflows though
- */
- else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX)
+ /* Check if the distance since the last point is significant enough:
+ * - Prevents points being added too densely
+ * - Distance here doesn't use sqrt to prevent slowness.
+ * We should still be safe from overflows though.
+ */
+ }
+ else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
return true;
- /* mouse 'didn't move' */
- else
+ /* mouse 'didn't move' */
+ }
+ else {
return false;
+ }
}
/* convert screen-coordinates to buffer-coordinates */
@@ -465,8 +473,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
/* check if still room in buffer */
- if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX)
+ if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX) {
return GP_STROKEADD_OVERFLOW;
+ }
/* get pointer to destination point */
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_size);
@@ -488,10 +497,12 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* check if another operation can still occur */
- if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX)
+ if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX) {
return GP_STROKEADD_FULL;
- else
+ }
+ else {
return GP_STROKEADD_NORMAL;
+ }
}
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
/* get pointer to destination point */
@@ -546,8 +557,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* increment counters */
- if (gpd->runtime.sbuffer_size == 0)
+ if (gpd->runtime.sbuffer_size == 0) {
gpd->runtime.sbuffer_size++;
+ }
return GP_STROKEADD_NORMAL;
}
@@ -569,12 +581,14 @@ static void gp_stroke_simplify(tGPsdata *p)
short i, j;
/* only simplify if simplification is enabled, and we're not doing a straight line */
- if (!(U.gp_settings & GP_PAINT_DOSIMPLIFY) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT))
+ if (!(U.gp_settings & GP_PAINT_DOSIMPLIFY) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)) {
return;
+ }
/* don't simplify if less than 4 points in buffer */
- if ((num_points <= 4) || (old_points == NULL))
+ if ((num_points <= 4) || (old_points == NULL)) {
return;
+ }
/* clear buffer (but don't free mem yet) so that we can write to it
* - firstly set sbuffer to NULL, so a new one is allocated
@@ -646,22 +660,26 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
ToolSettings *ts = p->scene->toolsettings;
int i, totelem;
- /* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */
+ /* Since strokes are so fine, when using their depth we need a margin
+ * otherwise they might get missed. */
int depth_margin = (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 4 : 0;
/* get total number of points to allocate space for
* - drawing straight-lines only requires the endpoints
*/
- if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)
+ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
totelem = (gpd->runtime.sbuffer_size >= 2) ? 2 : gpd->runtime.sbuffer_size;
- else
+ }
+ else {
totelem = gpd->runtime.sbuffer_size;
+ }
/* exit with error if no valid points from this stroke */
if (totelem == 0) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No valid points in stroke buffer to convert (tot=%d)\n",
gpd->runtime.sbuffer_size);
+ }
return;
}
@@ -770,8 +788,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
if (found_depth == false) {
/* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */
- for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--)
+ for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
depth_arr[i] = 0.9999f;
+ }
}
else {
if (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) {
@@ -780,20 +799,23 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
int last_valid = 0;
for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
first_valid = i;
for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
last_valid = i;
/* invalidate non-endpoints, so only blend between first and last */
- for (i = first_valid + 1; i < last_valid; i++)
+ for (i = first_valid + 1; i < last_valid; i++) {
depth_arr[i] = FLT_MAX;
+ }
interp_depth = true;
}
@@ -819,8 +841,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
pt->time = ptc->time;
}
- if (depth_arr)
+ if (depth_arr) {
MEM_freeN(depth_arr);
+ }
}
/* add stroke to frame */
@@ -946,8 +969,9 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
pt2 = gps->points + i + 1;
/* only process if it hasn't been masked out... */
- if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT))
+ if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) {
continue;
+ }
gp_point_to_xy(&p->gsc, gps, pt1, &pc1[0], &pc1[1]);
gp_point_to_xy(&p->gsc, gps, pt2, &pc2[0], &pc2[1]);
@@ -1058,8 +1082,9 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* make sure the active view (at the starting time) is a 3d-view */
if (curarea == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No active view for painting\n");
+ }
return 0;
}
@@ -1088,10 +1113,11 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
if (ar->regiondata == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf(
"Error: 3D-View active region doesn't have any region data, so cannot be "
"drawable\n");
+ }
return 0;
}
break;
@@ -1118,8 +1144,9 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* check that gpencil data is allowed to be drawn */
if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil\n");
+ }
return 0;
}
break;
@@ -1179,8 +1206,9 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* unsupported views */
default: {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Annotations are not supported in this editor\n");
+ }
return 0;
}
}
@@ -1189,8 +1217,9 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr);
if ((gpd_ptr == NULL) || !ED_gpencil_data_owner_is_annotation(&p->ownerPtr)) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Current context doesn't allow for any Annotation data\n");
+ }
return 0;
}
else {
@@ -1254,8 +1283,9 @@ static void gp_session_cleanup(tGPsdata *p)
bGPdata *gpd = (p) ? p->gpd : NULL;
/* error checking */
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* free stroke buffer */
if (gpd->runtime.sbuffer) {
@@ -1288,13 +1318,15 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->gpd->flag |= GP_DATA_ANNOTATIONS;
p->gpl = BKE_gpencil_layer_addnew(p->gpd, DATA_("Note"), true);
- if (p->custom_color[3])
+ if (p->custom_color[3]) {
copy_v3_v3(p->gpl->color, p->custom_color);
+ }
}
if (p->gpl->flag & GP_LAYER_LOCKED) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Cannot paint on locked layer\n");
+ }
return;
}
@@ -1329,7 +1361,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
if (has_layer_to_erase == false) {
p->status = GP_STATUS_CAPTURE;
- //if (G.debug & G_DEBUG)
+ // if (G.debug & G_DEBUG)
printf("Error: Eraser will not be affecting anything (gpencil_paint_init)\n");
return;
}
@@ -1338,17 +1370,20 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* Drawing Modes - Add a new frame if needed on the active layer */
short add_frame_mode = GP_GETFRAME_ADD_NEW;
- if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST)
+ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
add_frame_mode = GP_GETFRAME_ADD_COPY;
- else
+ }
+ else {
add_frame_mode = GP_GETFRAME_ADD_NEW;
+ }
p->gpf = BKE_gpencil_layer_getframe(p->gpl, CFRA, add_frame_mode);
if (p->gpf == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No frame created (gpencil_paint_init)\n");
+ }
return;
}
else {
@@ -1471,8 +1506,9 @@ static void gp_paint_cleanup(tGPsdata *p)
}
/* "unlock" frame */
- if (p->gpf)
+ if (p->gpf) {
p->gpf->flag &= ~GP_FRAME_PAINT;
+ }
}
/* ------------------------------- */
@@ -1508,14 +1544,13 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
immUniform1f("dash_width", 12.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_circle_wire_2d(
- shdr_pos,
- x,
- y,
- p->radius,
- /* XXX Dashed shader gives bad results with sets of small segments currently,
- * temp hack around the issue. :( */
- max_ii(8, p->radius / 2)); /* was fixed 40 */
+ imm_draw_circle_wire_2d(shdr_pos,
+ x,
+ y,
+ p->radius,
+ /* XXX Dashed shader gives bad results with sets of small segments
+ * currently, temp hack around the issue. :( */
+ max_ii(8, p->radius / 2)); /* was fixed 40 */
immUnbindProgram();
@@ -1634,10 +1669,12 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
/* ensure that the correct cursor icon is set */
static void gpencil_draw_cursor_set(tGPsdata *p)
{
- if (p->paintmode == GP_PAINTMODE_ERASER)
+ if (p->paintmode == GP_PAINTMODE_ERASER) {
WM_cursor_modal_set(p->win, BC_CROSSCURSOR); /* XXX need a better cursor */
- else
+ }
+ else {
WM_cursor_modal_set(p->win, BC_PAINTBRUSHCURSOR);
+ }
}
/* update UI indicators of status, including cursor and header prints */
@@ -1718,7 +1755,8 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgraph
p->mvalo[1] = p->mval[1];
p->opressure = p->pressure;
}
- /* only add current point to buffer if mouse moved (even though we got an event, it might be just noise) */
+ /* Only add current point to buffer if mouse moved
+ * (even though we got an event, it might be just noise). */
else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) {
/* try to add point */
short ok = gp_stroke_addpoint(p, p->mval, p->pressure, p->curtime);
@@ -1747,8 +1785,9 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgraph
BKE_report(op->reports, RPT_ERROR, "Cannot paint stroke");
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Grease-Pencil Paint - Add Point Invalid\n");
+ }
return;
}
@@ -1839,8 +1878,9 @@ static void annotation_draw_apply_event(
/* special exception here for too high pressure values on first touch in
* windows for some tablets, then we just skip first touch...
*/
- if (tablet && (p->pressure >= 0.99f))
+ if (tablet && (p->pressure >= 0.99f)) {
return;
+ }
}
/* check if alt key is pressed and limit to straight lines */
@@ -1886,13 +1926,15 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
/* try to initialize context data needed while drawing */
if (!gpencil_draw_init(C, op, NULL)) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
/* printf("\tGP - no valid data\n"); */
return OPERATOR_CANCELLED;
}
- else
+ else {
p = op->customdata;
+ }
/* printf("\tGP - Start redrawing stroke\n"); */
@@ -1984,19 +2026,23 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
}
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("GPencil - Starting Drawing\n");
+ }
/* try to initialize context data needed while drawing */
if (!gpencil_draw_init(C, op, event)) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
- if (G.debug & G_DEBUG)
+ }
+ if (G.debug & G_DEBUG) {
printf("\tGP - no valid data\n");
+ }
return OPERATOR_CANCELLED;
}
- else
+ else {
p = op->customdata;
+ }
/* if empty erase capture and finish */
if (p->status == GP_STATUS_CAPTURE) {
@@ -2068,8 +2114,9 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
/* XXX: watch it with the paintmode! in future,
* it'd be nice to allow changing paint-mode when in sketching-sessions */
- if (gp_session_initdata(C, p))
+ if (gp_session_initdata(C, p)) {
gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C));
+ }
if (p->status != GP_STATUS_ERROR) {
p->status = GP_STATUS_PAINTING;
@@ -2157,7 +2204,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->ar = ar;
}
- /* we don't pass on key events, GP is used with key-modifiers - prevents Dkey to insert drivers */
+ /* We don't pass on key events, GP is used with key-modifiers -
+ * prevents Dkey to insert drivers. */
if (ISKEYBOARD(event->type)) {
if (ELEM(event->type, LEFTARROWKEY, DOWNARROWKEY, RIGHTARROWKEY, UPARROWKEY, ZKEY)) {
/* allow some keys:
@@ -2185,10 +2233,12 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- //printf("\tGP - handle modal event...\n");
+ // printf("\tGP - handle modal event...\n");
- /* exit painting mode (and/or end current stroke)
- * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647]
+ /* Exit painting mode (and/or end current stroke)
+ *
+ * NOTE: cannot do RIGHTMOUSE (as is standard for canceling)
+ * as that would break polyline T32647.
*/
if (ELEM(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY, EKEY)) {
/* exit() ends the current stroke before cleaning up */
@@ -2286,8 +2336,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: Region under cursor is out of bounds, so cannot be drawn on\n", __func__);
+ }
}
}
else if (p->ar) {
@@ -2302,8 +2353,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: No active region found in GP Paint session data\n", __func__);
+ }
}
if (in_bounds) {
@@ -2382,8 +2434,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADMINUS:
p->radius -= 5;
- if (p->radius <= 0)
+ if (p->radius <= 0) {
p->radius = 1;
+ }
break;
}
@@ -2404,8 +2457,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
- if (0 == gpencil_area_exists(C, p->sa))
+ if (0 == gpencil_area_exists(C, p->sa)) {
estate = OPERATOR_CANCELLED;
+ }
else {
/* update status indicators - cursor, header, etc. */
gpencil_draw_status_indicators(C, p);
@@ -2429,7 +2483,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* event doesn't need to be handled */
#if 0
printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n",
- event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE);
+ event->type,
+ event->type == MIDDLEMOUSE,
+ event->type == MOUSEMOVE);
#endif
break;
}
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 24bdbcc4cba..ef74aa28b63 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -121,9 +121,15 @@ static void gp_set_point_uniform_color(const bGPDspoint *pt, const float ink[4])
immUniformColor3fvAlpha(ink, alpha);
}
-static void gp_set_point_varying_color(const bGPDspoint *pt, const float ink[4], uint attr_id)
+static void gp_set_point_varying_color(const bGPDspoint *pt,
+ const float ink[4],
+ uint attr_id,
+ bool fix_strength)
{
float alpha = ink[3] * pt->strength;
+ if ((fix_strength) && (alpha >= 0.1f)) {
+ alpha = 1.0f;
+ }
CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
immAttr4ub(attr_id, F2UB(ink[0]), F2UB(ink[1]), F2UB(ink[2]), F2UB(alpha));
}
@@ -186,7 +192,7 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points,
mul_v3_m4v3(fpt, diff_mat, &pt->x);
gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co);
- gp_set_point_varying_color(pt, ink, color);
+ gp_set_point_varying_color(pt, ink, color, false);
immAttr1f(size, pt->pressure * thickness); /* TODO: scale based on view transform */
immVertex2f(pos, co[0], co[1]);
}
@@ -214,7 +220,7 @@ static void gp_draw_stroke_volumetric_3d(const bGPDspoint *points,
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints && pt; i++, pt++) {
- gp_set_point_varying_color(pt, ink, color);
+ gp_set_point_varying_color(pt, ink, color, false);
/* TODO: scale based on view transform */
immAttr1f(size, pt->pressure * thickness);
/* we can adjust size in vertex shader based on view/projection! */
@@ -274,7 +280,8 @@ static void gp_calc_stroke_text_coordinates(
}
}
-/* Triangulate stroke for high quality fill (this is done only if cache is null or stroke was modified) */
+/* Triangulate stroke for high quality fill
+ * (this is done only if cache is null or stroke was modified). */
static void gp_triangulate_stroke_fill(bGPDstroke *gps)
{
BLI_assert(gps->totpoints >= 3);
@@ -324,8 +331,9 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
}
else {
/* No triangles needed - Free anything allocated previously */
- if (gps->triangles)
+ if (gps->triangles) {
MEM_freeN(gps->triangles);
+ }
gps->triangles = NULL;
}
@@ -375,7 +383,7 @@ static int gp_set_filling_texture(Image *image, short flag)
ImBuf *ibuf;
uint *bind = &image->bindcode[TEXTARGET_TEXTURE_2D];
int error = GL_NO_ERROR;
- ImageUser iuser = { NULL };
+ ImageUser iuser = {NULL};
void *lock;
iuser.ok = true;
@@ -388,8 +396,7 @@ static int gp_set_filling_texture(Image *image, short flag)
}
GPU_create_gl_tex(
- bind, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D,
- false, false, image);
+ bind, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D, false, false, image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -448,11 +455,12 @@ static void gp_draw_stroke_fill(bGPdata *gpd,
immUniform2fv("texture_scale", gp_style->texture_scale);
immUniform2fv("texture_offset", gp_style->texture_offset);
immUniform1f("texture_opacity", gp_style->texture_opacity);
- immUniform1i("t_mix", (gp_style->flag & GP_STYLE_COLOR_TEX_MIX) != 0);
+ immUniform1i("t_mix", (gp_style->flag & GP_STYLE_FILL_TEX_MIX) != 0);
immUniform1i("t_flip", (gp_style->flag & GP_STYLE_COLOR_FLIP_FILL) != 0);
#if 0 /* GPXX disabled, not used in annotations */
/* image texture */
- if ((gp_style->fill_style == GP_STYLE_FILL_STYLE_TEXTURE) || (gp_style->flag & GP_STYLE_COLOR_TEX_MIX)) {
+ if ((gp_style->fill_style == GP_STYLE_FILL_STYLE_TEXTURE) ||
+ (gp_style->flag & GP_STYLE_COLOR_TEX_MIX)) {
gp_set_filling_texture(gp_style->ima, gp_style->flag);
}
#endif
@@ -574,7 +582,7 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
for (int i = 0; i < totpoints; i++, pt++) {
/* first point for adjacency (not drawn) */
if (i == 0) {
- gp_set_point_varying_color(points, ink, attr_id.color);
+ gp_set_point_varying_color(points, ink, attr_id.color, (bool)tgpw->is_fill_stroke);
if ((cyclic) && (totpoints > 2)) {
immAttr1f(attr_id.thickness, max_ff((points + totpoints - 1)->pressure * thickness, 1.0f));
@@ -587,7 +595,7 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
immVertex3fv(attr_id.pos, fpt);
}
/* set point */
- gp_set_point_varying_color(pt, ink, attr_id.color);
+ gp_set_point_varying_color(pt, ink, attr_id.color, (bool)tgpw->is_fill_stroke);
immAttr1f(attr_id.thickness, max_ff(pt->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &pt->x);
immVertex3fv(attr_id.pos, fpt);
@@ -606,7 +614,9 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
}
/* last adjacency point (not drawn) */
else {
- gp_set_point_varying_color(points + totpoints - 2, ink, attr_id.color);
+ gp_set_point_varying_color(
+ points + totpoints - 2, ink, attr_id.color, (bool)tgpw->is_fill_stroke);
+
immAttr1f(attr_id.thickness, max_ff((points + totpoints - 2)->pressure * thickness, 1.0f));
mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 2)->x);
immVertex3fv(attr_id.pos, fpt);
@@ -643,8 +653,8 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
/* TODO: fancy++ with the magic of shaders */
- /* tessellation code - draw stroke as series of connected quads (triangle strips in fact) with connection
- * edges rotated to minimize shrinking artifacts, and rounded endcaps
+ /* tessellation code - draw stroke as series of connected quads (triangle strips in fact)
+ * with connection edges rotated to minimize shrinking artifacts, and rounded endcaps.
*/
{
const bGPDspoint *pt1, *pt2;
@@ -675,7 +685,8 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
float mt[2], sc[2]; /* gradient for thickness, point for end-cap */
float pthick; /* thickness at segment point */
- /* get x and y coordinates from point2 (point1 has already been computed in previous iteration). */
+ /* Get x and y coordinates from point2
+ * (point1 has already been computed in previous iteration). */
mul_v3_m4v3(fpt, diff_mat, &pt2->x);
gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, s1);
@@ -690,7 +701,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
pthick = (pt1->pressure * thickness * scalefac);
/* color of point */
- gp_set_point_varying_color(pt1, ink, attr_id.color);
+ gp_set_point_varying_color(pt1, ink, attr_id.color, false);
/* if the first segment, start of segment is segment's normal */
if (i == 0) {
@@ -765,7 +776,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points,
pthick = (pt2->pressure * thickness * scalefac);
/* color of point */
- gp_set_point_varying_color(pt2, ink, attr_id.color);
+ gp_set_point_varying_color(pt2, ink, attr_id.color, false);
/* calculate points for end of segment */
mt[0] = m2[0] * pthick;
@@ -816,26 +827,33 @@ static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag)
{
/* skip stroke if it isn't in the right display space for this drawing context */
/* 1) 3D Strokes */
- if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE))
+ if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE)) {
return false;
+ }
/* 2) Screen Space 2D Strokes */
- if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE))
+ if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE)) {
return false;
+ }
/* 3) Image Space (2D) */
- if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE))
+ if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE)) {
return false;
+ }
/* skip stroke if it doesn't have any valid data */
- if ((gps->points == NULL) || (gps->totpoints < 1))
+ if ((gps->points == NULL) || (gps->totpoints < 1)) {
return false;
+ }
/* stroke can be drawn */
return true;
@@ -851,7 +869,9 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
GPU_enable_program_point_size();
- for (bGPDstroke *gps = tgpw->t_gpf->strokes.first; gps; gps = gps->next) {
+ bGPDstroke *gps_init = (tgpw->gps) ? tgpw->gps : tgpw->t_gpf->strokes.first;
+
+ for (bGPDstroke *gps = gps_init; gps; gps = gps->next) {
/* check if stroke can be drawn */
if (gp_can_draw_stroke(gps, tgpw->dflag) == false) {
continue;
@@ -899,7 +919,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
}
/* 3D Fill */
- //if ((dflag & GP_DRAWDATA_FILL) && (gps->totpoints >= 3)) {
+ // if ((dflag & GP_DRAWDATA_FILL) && (gps->totpoints >= 3)) {
if ((gps->totpoints >= 3) && (tgpw->disable_fill != 1)) {
/* set color using material, tint color and opacity */
interp_v3_v3v3(tfill, gp_style->fill_rgba, tgpw->tintcolor, tgpw->tintcolor[3]);
@@ -945,6 +965,14 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
copy_v4_v4(ink, tcolor);
}
}
+
+ /* if used for fill, set opacity to 1 */
+ if (tgpw->is_fill_stroke) {
+ if (ink[3] >= GPENCIL_ALPHA_OPACITY_THRESH) {
+ ink[3] = 1.0f;
+ }
+ }
+
if (gp_style->mode == GP_STYLE_MODE_DOTS) {
/* volumetric stroke drawing */
if (tgpw->disable_fill != 1) {
@@ -1070,6 +1098,10 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
}
}
}
+ /* if only one stroke, exit from loop */
+ if (tgpw->gps) {
+ break;
+ }
}
GPU_disable_program_point_size();
@@ -1116,6 +1148,7 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in
tgpw.gpl = tgpil->gpl;
tgpw.gpf = tgpil->interFrame;
tgpw.t_gpf = tgpil->interFrame;
+ tgpw.gps = NULL;
tgpw.lthick = tgpil->gpl->line_change;
tgpw.opacity = 1.0;
@@ -1141,8 +1174,9 @@ static void UNUSED_FUNCTION(gp_draw_status_text)(const bGPdata *gpd, ARegion *ar
rcti rect;
/* Cannot draw any status text when drawing OpenGL Renders */
- if (G.f & G_FLAG_RENDER_VIEWPORT)
+ if (G.f & G_FLAG_RENDER_VIEWPORT) {
return;
+ }
/* Get bounds of region - Necessary to avoid problems with region overlap */
ED_region_visible_rect(ar, &rect);
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index 4724dc068b6..d0f44314c95 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -61,14 +61,16 @@ bool ED_gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPD
bGPDframe *gpf;
/* error checker */
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* do loop */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
/* execute callback */
- if (gpf_cb(gpf, scene))
+ if (gpf_cb(gpf, scene)) {
return true;
+ }
}
/* nothing to return */
@@ -85,8 +87,9 @@ void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, bool onlysel)
CfraElem *ce;
/* error checking */
- if (ELEM(NULL, gpl, elems))
+ if (ELEM(NULL, gpl, elems)) {
return;
+ }
/* loop through gp-frames, adding */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
@@ -110,13 +113,15 @@ bool ED_gplayer_frame_select_check(bGPDlayer *gpl)
bGPDframe *gpf;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* stop at the first one found */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
return true;
+ }
}
/* not found */
@@ -126,8 +131,9 @@ bool ED_gplayer_frame_select_check(bGPDlayer *gpl)
/* helper function - select gp-frame based on SELECT_* mode */
static void gpframe_select(bGPDframe *gpf, short select_mode)
{
- if (gpf == NULL)
+ if (gpf == NULL) {
return;
+ }
switch (select_mode) {
case SELECT_ADD:
@@ -148,8 +154,9 @@ void ED_gpencil_select_frames(bGPDlayer *gpl, short select_mode)
bGPDframe *gpf;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* handle according to mode */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
@@ -161,8 +168,9 @@ void ED_gpencil_select_frames(bGPDlayer *gpl, short select_mode)
void ED_gplayer_frame_select_set(bGPDlayer *gpl, short mode)
{
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* now call the standard function */
ED_gpencil_select_frames(gpl, mode);
@@ -173,8 +181,9 @@ void ED_gpencil_select_frame(bGPDlayer *gpl, int selx, short select_mode)
{
bGPDframe *gpf;
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
gpf = BKE_gpencil_layer_find_frame(gpl, selx);
@@ -188,13 +197,15 @@ void ED_gplayer_frames_select_box(bGPDlayer *gpl, float min, float max, short se
{
bGPDframe *gpf;
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* only select those frames which are in bounds */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- if (IN_RANGE(gpf->framenum, min, max))
+ if (IN_RANGE(gpf->framenum, min, max)) {
gpframe_select(gpf, select_mode);
+ }
}
}
@@ -206,8 +217,9 @@ void ED_gplayer_frames_select_region(KeyframeEditData *ked,
{
bGPDframe *gpf;
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* only select frames which are within the region */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
@@ -220,13 +232,15 @@ void ED_gplayer_frames_select_region(KeyframeEditData *ked,
/* check the necessary regions */
if (tool == BEZT_OK_CHANNEL_LASSO) {
/* Lasso */
- if (keyframe_region_lasso_test(ked->data, pt))
+ if (keyframe_region_lasso_test(ked->data, pt)) {
gpframe_select(gpf, select_mode);
+ }
}
else if (tool == BEZT_OK_CHANNEL_CIRCLE) {
/* Circle */
- if (keyframe_region_circle_test(ked->data, pt))
+ if (keyframe_region_circle_test(ked->data, pt)) {
gpframe_select(gpf, select_mode);
+ }
}
}
}
@@ -241,8 +255,9 @@ bool ED_gplayer_frames_delete(bGPDlayer *gpl)
bool changed = false;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* check for frames to delete */
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
@@ -263,8 +278,9 @@ void ED_gplayer_frames_duplicate(bGPDlayer *gpl)
bGPDframe *gpf, *gpfn;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* duplicate selected frames */
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
@@ -290,8 +306,9 @@ void ED_gplayer_frames_keytype_set(bGPDlayer *gpl, short type)
{
bGPDframe *gpf;
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
@@ -301,12 +318,14 @@ void ED_gplayer_frames_keytype_set(bGPDlayer *gpl, short type)
}
/* -------------------------------------- */
-/* Copy and Paste Tools */
-/* - The copy/paste buffer currently stores a set of GP_Layers, with temporary
+/* Copy and Paste Tools:
+ * - The copy/paste buffer currently stores a set of GP_Layers, with temporary
* GP_Frames with the necessary strokes
- * - Unless there is only one element in the buffer, names are also tested to check for compatibility.
- * - All pasted frames are offset by the same amount. This is calculated as the difference in the times of
- * the current frame and the 'first keyframe' (i.e. the earliest one in all channels).
+ * - Unless there is only one element in the buffer,
+ * names are also tested to check for compatibility.
+ * - All pasted frames are offset by the same amount.
+ * This is calculated as the difference in the times of the current frame and the
+ * 'first keyframe' (i.e. the earliest one in all channels).
* - The earliest frame is calculated per copy operation.
*/
@@ -362,10 +381,12 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac)
BLI_addtail(&copied_frames, new_frame);
/* extend extents for keyframes encountered */
- if (gpf->framenum < gp_anim_copy_firstframe)
+ if (gpf->framenum < gp_anim_copy_firstframe) {
gp_anim_copy_firstframe = gpf->framenum;
- if (gpf->framenum > gp_anim_copy_lastframe)
+ }
+ if (gpf->framenum > gp_anim_copy_lastframe) {
gp_anim_copy_lastframe = gpf->framenum;
+ }
}
}
@@ -458,8 +479,9 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
}
/* this situation might occur! */
- if (gpls == NULL)
+ if (gpls == NULL) {
continue;
+ }
/* add frames from buffer */
for (gpfs = gpls->frames.first; gpfs; gpfs = gpfs->next) {
@@ -493,8 +515,9 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
}
/* if no strokes (i.e. new frame) added, free gpf */
- if (BLI_listbase_is_empty(&gpf->strokes))
+ if (BLI_listbase_is_empty(&gpf->strokes)) {
BKE_gpencil_layer_delframe(gpld, gpf);
+ }
}
/* unapply offset from buffer-frame */
@@ -522,23 +545,26 @@ static short snap_gpf_nearest(bGPDframe *UNUSED(gpf), Scene *UNUSED(scene))
static short snap_gpf_nearestsec(bGPDframe *gpf, Scene *scene)
{
float secf = (float)FPS;
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
gpf->framenum = (int)(floorf(gpf->framenum / secf + 0.5f) * secf);
+ }
return 0;
}
static short snap_gpf_cframe(bGPDframe *gpf, Scene *scene)
{
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
gpf->framenum = (int)CFRA;
+ }
return 0;
}
static short snap_gpf_nearmarker(bGPDframe *gpf, Scene *scene)
{
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
gpf->framenum = (int)ED_markers_find_nearest_marker_time(&scene->markers,
(float)gpf->framenum);
+ }
return 0;
}
diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c
index d6e068926dd..f6ff5ed4f13 100644
--- a/source/blender/editors/gpencil/gpencil_add_stroke.c
+++ b/source/blender/editors/gpencil/gpencil_add_stroke.c
@@ -210,7 +210,8 @@ static const ColorTemplate gp_stroke_material_grey = {
/* ***************************************************************** */
/* Stroke API */
-/* add a Simple stroke with colors (original design created by Daniel M. Lara and Matias Mendiola) */
+/* Add a Simple stroke with colors
+ * (original design created by Daniel M. Lara and Matias Mendiola). */
void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4])
{
Main *bmain = CTX_data_main(C);
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index d99a630a45c..6ad89d2e38d 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -287,8 +287,9 @@ static void gpencil_add_verts_to_dgroups(
/* count the number of skinnable bones */
numbones = gpencil_bone_looper(ob, arm->bonebase.first, &looper_data, gpencil_bone_skinnable_cb);
- if (numbones == 0)
+ if (numbones == 0) {
return;
+ }
/* create an array of pointer to bones that are skinnable
* and fill it with all of the skinnable bones */
@@ -366,13 +367,15 @@ static void gpencil_add_verts_to_dgroups(
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
BKE_gpencil_dvert_ensure(gps);
@@ -477,6 +480,8 @@ static void gpencil_object_vgroup_calc_from_armature(const bContext *C,
*/
gpencil_add_verts_to_dgroups(C, ob, ob_arm, ratio, decay);
}
+
+ DEG_relations_tag_update(CTX_data_main(C));
}
bool ED_gpencil_add_armature_weights(
@@ -564,8 +569,9 @@ static int gpencil_generate_weights_exec(bContext *C, wmOperator *op)
const float decay = RNA_float_get(op->ptr, "decay");
/* sanity checks */
- if (ELEM(NULL, ob, gpd))
+ if (ELEM(NULL, ob, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* get armature */
const int arm_idx = RNA_enum_get(op->ptr, "armature");
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index ef0ebd06d07..9777a8190c1 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -88,6 +88,7 @@ typedef struct tGP_BrushEditData {
/* Current editor/region/etc. */
/* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */
Depsgraph *depsgraph;
+ struct Main *bmain;
Scene *scene;
Object *object;
@@ -190,8 +191,7 @@ static void gpsculpt_compute_lock_axis(tGP_BrushEditData *gso,
break;
}
case GP_LOCKAXIS_CURSOR: {
- /* compute a plane with cursor normal and position of the point
- before do the sculpt */
+ /* Compute a plane with cursor normal and position of the point before do the sculpt. */
const float scale[3] = {1.0f, 1.0f, 1.0f};
float plane_normal[3] = {0.0f, 0.0f, 1.0f};
float plane[4];
@@ -303,7 +303,8 @@ static float gp_brush_influence_calc(tGP_BrushEditData *gso, const int radius, c
/* ----------------------------------------------- */
/* Smooth Brush */
-/* A simple (but slower + inaccurate) smooth-brush implementation to test the algorithm for stroke smoothing */
+/* A simple (but slower + inaccurate)
+ * smooth-brush implementation to test the algorithm for stroke smoothing. */
static bool gp_brush_smooth_apply(
tGP_BrushEditData *gso, bGPDstroke *gps, int pt_index, const int radius, const int co[2])
{
@@ -352,7 +353,8 @@ static bool gp_brush_thickness_apply(
inf = gp_brush_influence_calc(gso, radius, co) / 10.0f;
/* apply */
- // XXX: this is much too strong, and it should probably do some smoothing with the surrounding stuff
+ /* XXX: this is much too strong,
+ * and it should probably do some smoothing with the surrounding stuff. */
if (gp_brush_invert_check(gso)) {
/* make line thinner - reduce stroke pressure */
pt->pressure -= inf;
@@ -367,8 +369,9 @@ static bool gp_brush_thickness_apply(
* the upper end of this range. Therefore, we don't actually clamp
* down on the upper end.
*/
- if (pt->pressure < 0.0f)
+ if (pt->pressure < 0.0f) {
pt->pressure = 0.0f;
+ }
return true;
}
@@ -802,7 +805,16 @@ static bool gp_brush_randomize_apply(
mul_v2_fl(svec, fac);
}
- //printf("%f %f (%f), nco = {%f %f}, co = %d %d\n", svec[0], svec[1], fac, nco[0], nco[1], co[0], co[1]);
+#if 0
+ printf("%f %f (%f), nco = {%f %f}, co = %d %d\n",
+ svec[0],
+ svec[1],
+ fac,
+ nco[0],
+ nco[1],
+ co[0],
+ co[1]);
+#endif
/* convert to dataspace */
if (gps->flag & GP_STROKE_3DSPACE) {
@@ -896,6 +908,7 @@ static bool gp_brush_weight_apply(
if (gso->vrgroup == -1) {
if (gso->object) {
BKE_object_defgroup_add(gso->object);
+ DEG_relations_tag_update(gso->bmain);
gso->vrgroup = 0;
}
}
@@ -927,8 +940,9 @@ static bool gp_brush_weight_apply(
}
/* weight should stay within [0.0, 1.0] */
- if (pt->pressure < 0.0f)
+ if (pt->pressure < 0.0f) {
pt->pressure = 0.0f;
+ }
return true;
}
@@ -957,7 +971,7 @@ typedef struct tGPSB_CloneBrushData {
/* for "stamp" mode, the currently pasted brushes */
bGPDstroke **new_strokes;
- /* mapping from colors referenced per stroke, to the new colours in the "pasted" strokes */
+ /** Mapping from colors referenced per stroke, to the new colors in the "pasted" strokes. */
GHash *new_colors;
} tGPSB_CloneBrushData;
@@ -1005,7 +1019,7 @@ static void gp_brush_clone_init(bContext *C, tGP_BrushEditData *gso)
}
/* Init colormap for mapping between the pasted stroke's source color (names)
- * and the final colours that will be used here instead.
+ * and the final colors that will be used here instead.
*/
data->new_colors = gp_copybuf_validate_colormap(C);
}
@@ -1107,7 +1121,8 @@ static void gp_brush_clone_adjust(tGP_BrushEditData *gso)
gp_brush_grab_calc_dvec(gso);
/* For each of the stored strokes, apply the offset to each point */
- /* NOTE: Again this assumes that in the 3D view, we only have 3d space and not screenspace strokes... */
+ /* NOTE: Again this assumes that in the 3D view,
+ * we only have 3d space and not screenspace strokes... */
for (snum = 0; snum < data->totitems; snum++) {
bGPDstroke *gps = data->new_strokes[snum];
bGPDspoint *pt;
@@ -1154,7 +1169,8 @@ static bool gpsculpt_brush_apply_clone(bContext *C, tGP_BrushEditData *gso)
}
else {
/* Continuous - Just keep pasting everytime we move */
- /* TODO: The spacing of repeat should be controlled using a "stepsize" or similar property? */
+ /* TODO: The spacing of repeat should be controlled using a
+ * "stepsize" or similar property? */
gp_brush_clone_add(C, gso);
}
}
@@ -1206,6 +1222,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
op->customdata = gso;
gso->depsgraph = CTX_data_depsgraph(C);
+ gso->bmain = CTX_data_main(C);
/* store state */
gso->settings = gpsculpt_get_settings(scene);
gso->gp_brush = gpsculpt_get_brush(scene, is_weight_mode);
@@ -1309,7 +1326,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
gpsculpt_brush_header_set(C, gso);
/* setup cursor drawing */
- //WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR);
+ // WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR);
if (gso->sa->spacetype != SPACE_VIEW3D) {
ED_gpencil_toggle_brush_cursor(C, true, NULL);
}
@@ -1383,8 +1400,9 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
int cfra_eval = (int)DEG_get_ctime(gso->depsgraph);
/* only try to add a new frame if this is the first stroke, or the frame has changed */
- if ((gpd == NULL) || (cfra_eval == gso->cfra))
+ if ((gpd == NULL) || (cfra_eval == gso->cfra)) {
return;
+ }
/* go through each layer, and ensure that we've got a valid frame to use */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -1392,9 +1410,10 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
bGPDframe *gpf = gpl->actframe;
- /* Make a new frame to work on if the layer's frame and the current scene frame don't match up
+ /* Make a new frame to work on if the layer's frame
+ * and the current scene frame don't match up:
* - This is useful when animating as it saves that "uh-oh" moment when you realize you've
- * spent too much time editing the wrong frame...
+ * spent too much time editing the wrong frame.
*/
// XXX: should this be allowed when framelock is enabled?
if (gpf->framenum != cfra_eval) {
@@ -1454,7 +1473,8 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
pt1 = gps->points + i;
pt2 = gps->points + i + 1;
- /* Skip if neither one is selected (and we are only allowed to edit/consider selected points) */
+ /* Skip if neither one is selected
+ * (and we are only allowed to edit/consider selected points) */
if (gso->settings->flag & GP_SCULPT_SETT_FLAG_SELECT_MASK) {
if (!(pt1->flag & GP_SPOINT_SELECT) && !(pt2->flag & GP_SPOINT_SELECT)) {
include_last = false;
@@ -1502,9 +1522,10 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
changed |= ok;
}
else if (include_last) {
- /* This case is for cases where for whatever reason the second vert (1st here) doesn't get included
- * because the whole edge isn't in bounds, but it would've qualified since it did with the
- * previous step (but wasn't added then, to avoid double-ups)
+ /* This case is for cases where for whatever reason the second vert (1st here)
+ * doesn't get included because the whole edge isn't in bounds,
+ * but it would've qualified since it did with the previous step
+ * (but wasn't added then, to avoid double-ups).
*/
changed |= apply(gso, gps, i, radius, pc1);
include_last = false;
@@ -1722,10 +1743,12 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt
gso->pressure = RNA_float_get(itemptr, "pressure");
- if (RNA_boolean_get(itemptr, "pen_flip"))
+ if (RNA_boolean_get(itemptr, "pen_flip")) {
gso->flag |= GP_SCULPT_FLAG_INVERT;
- else
+ }
+ else {
gso->flag &= ~GP_SCULPT_FLAG_INVERT;
+ }
/* Store coordinates as reference, if operator just started running */
if (gso->first) {
@@ -1825,8 +1848,9 @@ static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEven
/* reapply */
static int gpsculpt_brush_exec(bContext *C, wmOperator *op)
{
- if (!gpsculpt_brush_init(C, op))
+ if (!gpsculpt_brush_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
RNA_BEGIN (op->ptr, itemptr, "stroke") {
gpsculpt_brush_apply(C, op, &itemptr);
@@ -1855,8 +1879,9 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve
}
/* init painting data */
- if (!gpsculpt_brush_init(C, op))
+ if (!gpsculpt_brush_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
gso = op->customdata;
@@ -1982,7 +2007,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
/* Painting mbut release = Stop painting (back to idle) */
case LEFTMOUSE:
- //BLI_assert(event->val == KM_RELEASE);
+ // BLI_assert(event->val == KM_RELEASE);
if (is_modal) {
/* go back to idling... */
gso->is_painting = false;
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index c1c797b15be..5afa379e04f 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -79,6 +79,7 @@
#include "ED_view3d.h"
#include "ED_clip.h"
#include "ED_keyframing.h"
+#include "ED_object.h"
#include "gpencil_intern.h"
@@ -328,9 +329,9 @@ static int gp_find_end_of_stroke_idx(tGpTimingData *gtd,
else {
float delta, min, max;
- /* This code ensures that if the first gaps have been shorter than average gap_duration,
- * next gaps will tend to be longer (i.e. try to recover the lateness), and vice-versa!
- */
+ /* This code ensures that if the first gaps
+ * have been shorter than average gap_duration, next gaps
+ * will tend to be longer (i.e. try to recover the lateness), and vice-versa! */
delta = delta_time - (gtd->gap_duration * (*nbr_done_gaps));
/* Clamp min between [-gap_randomness, 0.0], with lower delta giving higher min */
@@ -501,8 +502,9 @@ static void gp_stroke_path_animation(bContext *C,
PropertyRNA *prop = NULL;
int nbr_gaps = 0, i;
- if (gtd->mode == GP_STROKECONVERT_TIMING_NONE)
+ if (gtd->mode == GP_STROKECONVERT_TIMING_NONE) {
return;
+ }
/* gap_duration and gap_randomness are in frames, but we need seconds!!! */
gtd->gap_duration = FRA2TIME(gtd->gap_duration);
@@ -693,8 +695,10 @@ static void gp_stroke_to_path(bContext *C,
* the last segment to get the first point (p1) position and timing.
* - If we do not have those (quite odd, but may happen), we linearly interpolate the last point
* with the first point of the current stroke.
- * The same goes for the second point, first segment of the current stroke is "negatively" extrapolated
- * if it exists, else (if the stroke is a single point), linear interpolation with last curve point...
+ *
+ * The same goes for the second point, first segment of the current stroke is "negatively"
+ * extrapolated if it exists, else (if the stroke is a single point),
+ * linear interpolation with last curve point.
*/
if (curnu && !stitch && old_nbp) {
float p1[3], p2[3], p[3], next_p[3];
@@ -774,8 +778,9 @@ static void gp_stroke_to_path(bContext *C,
dt = -GAP_DFAC; /* Rather arbitrary too! */
}
bp = &nu->bp[old_nbp];
- /* Note we can't give anything else than 0.0 as time here, since a negative one (which would be expected value)
- * would not work (it would be *before* gtd->inittime, which is not supported currently).
+ /* Note we can't give anything else than 0.0 as time here, since a negative one
+ * (which would be expected value) would not work
+ * (it would be *before* gtd->inittime, which is not supported currently).
*/
gp_stroke_to_path_add_point(
gtd, bp, p, p, do_gtd, gps->inittime, dt, 0.0f, rad_fac, minmax_weights);
@@ -907,9 +912,10 @@ static void gp_stroke_to_bezier(bContext *C,
/* create new 'nurb' or extend current one within the curve */
if (nu) {
old_nbezt = nu->pntsu;
- /* If we do stitch, first point of current stroke is assumed the same as last point of previous stroke,
- * so no need to add it.
- * If no stitch, we want to add two additional points to make a "zero-radius" link between both strokes.
+ /* If we do stitch, first point of current stroke is assumed the same as last point of
+ * previous stroke, so no need to add it.
+ * If no stitch, we want to add two additional points to make a "zero-radius"
+ * link between both strokes.
*/
BKE_nurb_bezierPoints_add(nu, gps->totpoints + ((stitch) ? -1 : 2) + add_start_end_points);
}
@@ -958,12 +964,15 @@ static void gp_stroke_to_bezier(bContext *C,
/* Create "link points" */
/* About "zero-radius" point interpolations:
- * - If we have at least two points in current curve (most common case), we linearly extrapolate
- * the last segment to get the first point (p1) position and timing.
- * - If we do not have those (quite odd, but may happen), we linearly interpolate the last point
- * with the first point of the current stroke.
- * The same goes for the second point, first segment of the current stroke is "negatively" extrapolated
- * if it exists, else (if the stroke is a single point), linear interpolation with last curve point...
+ * - If we have at least two points in current curve (most common case),
+ * we linearly extrapolate the last segment to get the first point (p1) position and timing.
+ * - If we do not have those (quite odd, but may happen),
+ * we linearly interpolate the last point with the first point of the current stroke.
+ *
+ * The same goes for the second point,
+ * first segment of the current stroke is "negatively" extrapolated
+ * if it exists, else (if the stroke is a single point),
+ * linear interpolation with last curve point.
*/
else {
float p1[3], p2[3];
@@ -1133,7 +1142,8 @@ static void gp_stroke_to_bezier(bContext *C,
/* The end point */
interp_v3_v3v3(h1, p, prev_bezt->vec[1], BEZT_HANDLE_FAC);
interp_v3_v3v3(h2, p, prev_bezt->vec[1], -BEZT_HANDLE_FAC);
- /* Note bezt has already been incremented in main loop above, so it points to the right place. */
+ /* Note bezt has already been incremented in main loop above,
+ * so it points to the right place. */
gp_stroke_to_bezier_add_point(gtd,
bezt,
p,
@@ -1206,10 +1216,12 @@ static void gp_stroke_norm_curve_weights(Curve *cu, const float minmax_weights[2
int i;
/* when delta == minmax_weights[0] == minmax_weights[1], we get div by zero [#35686] */
- if (IS_EQF(delta, minmax_weights[1]))
+ if (IS_EQF(delta, minmax_weights[1])) {
fac = 1.0f;
- else
+ }
+ else {
fac = 1.0f / (minmax_weights[1] - delta);
+ }
for (nu = cu->nurb.first; nu; nu = nu->next) {
if (nu->bezt) {
@@ -1277,12 +1289,14 @@ static void gp_layer_to_curve(bContext *C,
rctf subrect, *subrect_ptr = NULL;
/* error checking */
- if (ELEM(NULL, gpd, gpl, gpf))
+ if (ELEM(NULL, gpd, gpl, gpf)) {
return;
+ }
/* only convert if there are any strokes on this layer's frame to convert */
- if (BLI_listbase_is_empty(&gpf->strokes))
+ if (BLI_listbase_is_empty(&gpf->strokes)) {
return;
+ }
/* initialize camera framing */
if (gp_camera_view_subrect(C, &subrect)) {
@@ -1382,9 +1396,7 @@ static void gp_layer_to_curve(bContext *C,
}
}
- /* set the layer and select */
- base_new->flag |= SELECT;
- BKE_scene_object_base_flag_sync_from_base(base_new);
+ ED_object_base_select(base_new, BA_SELECT);
}
/* --- */
@@ -1405,8 +1417,9 @@ static bool gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOpe
bool valid = true;
if (!gpl || !(gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV)) ||
- !(gps = gpf->strokes.first))
+ !(gps = gpf->strokes.first)) {
return false;
+ }
do {
base_time = cur_time = gps->inittime;
@@ -1572,13 +1585,15 @@ static bool gp_convert_poll_property(const bContext *UNUSED(C),
}
/* Never show this prop */
- if (STREQ(prop_id, "use_timing_data"))
+ if (STREQ(prop_id, "use_timing_data")) {
return false;
+ }
if (link_strokes) {
/* Only show when link_stroke is true */
- if (STREQ(prop_id, "timing_mode"))
+ if (STREQ(prop_id, "timing_mode")) {
return true;
+ }
if (timing_mode != GP_STROKECONVERT_TIMING_NONE) {
/* Only show when link_stroke is true and stroke timing is enabled */
@@ -1587,25 +1602,30 @@ static bool gp_convert_poll_property(const bContext *UNUSED(C),
}
/* Only show if we have valid timing data! */
- if (valid_timing && STREQ(prop_id, "use_realtime"))
+ if (valid_timing && STREQ(prop_id, "use_realtime")) {
return true;
+ }
/* Only show if realtime or valid_timing is false! */
- if ((!realtime || !valid_timing) && STREQ(prop_id, "end_frame"))
+ if ((!realtime || !valid_timing) && STREQ(prop_id, "end_frame")) {
return true;
+ }
if (valid_timing && timing_mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) {
/* Only show for custom gaps! */
- if (STREQ(prop_id, "gap_duration"))
+ if (STREQ(prop_id, "gap_duration")) {
return true;
+ }
/* Only show randomness for non-null custom gaps! */
- if (STREQ(prop_id, "gap_randomness") && (gap_duration > 0.0f))
+ if (STREQ(prop_id, "gap_randomness") && (gap_duration > 0.0f)) {
return true;
+ }
/* Only show seed for randomize action! */
- if (STREQ(prop_id, "seed") && (gap_duration > 0.0f) && (gap_randomness > 0.0f))
+ if (STREQ(prop_id, "seed") && (gap_duration > 0.0f) && (gap_randomness > 0.0f)) {
return true;
+ }
}
}
}
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index c91c543e746..f44c90001e1 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -124,7 +124,8 @@ static int gp_data_add_exec(bContext *C, wmOperator *op)
id_us_min(&gpd->id);
}
- /* add new datablock, with a single layer ready to use (so users don't have to perform an extra step) */
+ /* Add new datablock, with a single layer ready to use
+ * (so users don't have to perform an extra step). */
if (is_annotation) {
bGPdata *gpd = BKE_gpencil_data_addnew(bmain, DATA_("Annotations"));
*gpd_ptr = gpd;
@@ -297,8 +298,9 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
if (gpl->flag & GP_LAYER_LOCKED) {
BKE_report(op->reports, RPT_ERROR, "Cannot delete locked layers");
@@ -309,10 +311,12 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
* - use the one after if this is the first
* - if this is the only layer, this naturally becomes NULL
*/
- if (gpl->prev)
+ if (gpl->prev) {
BKE_gpencil_layer_setactive(gpd, gpl->prev);
- else
+ }
+ else {
BKE_gpencil_layer_setactive(gpd, gpl->next);
+ }
/* delete the layer now... */
BKE_gpencil_layer_delete(gpd, gpl);
@@ -353,8 +357,9 @@ static int gp_layer_move_exec(bContext *C, wmOperator *op)
const int direction = RNA_enum_get(op->ptr, "type") * -1;
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */
if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) {
@@ -397,8 +402,9 @@ static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *new_layer;
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
/* make copy of layer, and add it immediately after the existing layer */
new_layer = BKE_gpencil_layer_duplicate(gpl);
@@ -445,19 +451,22 @@ static bool gp_layer_duplicate_object_poll(bContext *C)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = CTX_data_active_object(C);
- if ((ob == NULL) || (ob->type != OB_GPENCIL))
+ if ((ob == NULL) || (ob->type != OB_GPENCIL)) {
return false;
+ }
bGPdata *gpd = (bGPdata *)ob->data;
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* check there are more grease pencil objects */
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- if ((base->object != ob) && (base->object->type == OB_GPENCIL))
+ if ((base->object != ob) && (base->object->type == OB_GPENCIL)) {
return true;
+ }
}
return false;
@@ -590,8 +599,9 @@ static int gp_frame_duplicate_exec(bContext *C, wmOperator *op)
int mode = RNA_enum_get(op->ptr, "mode");
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
if (mode == 0) {
BKE_gpencil_frame_addcopy(gpl, cfra_eval);
@@ -655,16 +665,18 @@ static int gp_frame_clean_fill_exec(bContext *C, wmOperator *op)
if ((gpf == gpl->actframe) || (mode == GP_FRAME_CLEAN_FILL_ALL)) {
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are no fill */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* free stroke */
if (gps->flag & GP_STROKE_NOFILL) {
@@ -737,16 +749,18 @@ static int gp_frame_clean_loose_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are no loose */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* free stroke */
if (gps->totpoints <= limit) {
@@ -817,8 +831,9 @@ static int gp_hide_exec(bContext *C, wmOperator *op)
bool unselected = RNA_boolean_get(op->ptr, "unselected");
/* sanity checks */
- if (ELEM(NULL, gpd, layer))
+ if (ELEM(NULL, gpd, layer)) {
return OPERATOR_CANCELLED;
+ }
if (unselected) {
bGPDlayer *gpl;
@@ -897,8 +912,9 @@ static int gp_reveal_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
/* sanity checks */
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -957,8 +973,9 @@ static int gp_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *gpl;
/* sanity checks */
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* make all layers non-editable */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -996,8 +1013,9 @@ static int gp_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *gpl;
/* sanity checks */
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* make all layers editable again */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -1036,8 +1054,9 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
int flags = GP_LAYER_LOCKED;
bool isolate = false;
- if (RNA_boolean_get(op->ptr, "affect_visibility"))
+ if (RNA_boolean_get(op->ptr, "affect_visibility")) {
flags |= GP_LAYER_HIDE;
+ }
if (ELEM(NULL, gpd, layer)) {
BKE_report(op->reports, RPT_ERROR, "No active layer to isolate");
@@ -1047,8 +1066,9 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
/* Test whether to isolate or clear all flags */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* Skip if this is the active layer */
- if (gpl == layer)
+ if (gpl == layer) {
continue;
+ }
/* If the flags aren't set, that means that the layer is
* not alone, so we have some layers to isolate still
@@ -1064,10 +1084,12 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
if (isolate) {
/* Set flags on all "other" layers */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- if (gpl == layer)
+ if (gpl == layer) {
continue;
- else
+ }
+ else {
gpl->flag |= flags;
+ }
}
}
else {
@@ -1424,18 +1446,21 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* only if selected */
if (gps->flag & GP_STROKE_SELECT) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
/* assign new color */
gps->mat_nr = idx;
@@ -1485,8 +1510,9 @@ static int gp_stroke_lock_color_exec(bContext *C, wmOperator *UNUSED(op))
short *totcol = give_totcolp(ob);
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* first lock all colors */
for (short i = 0; i < *totcol; i++) {
@@ -1609,8 +1635,9 @@ static int gpencil_vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ts, ob, ob->data))
+ if (ELEM(NULL, ts, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_assign(C, ob, ts->vgroup_weight);
@@ -1643,8 +1670,9 @@ static int gpencil_vertex_group_remove_from_exec(bContext *C, wmOperator *UNUSED
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_remove(C, ob);
@@ -1676,8 +1704,9 @@ static int gpencil_vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_select(C, ob);
@@ -1709,8 +1738,9 @@ static int gpencil_vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_deselect(C, ob);
@@ -2091,7 +2121,10 @@ typedef struct tJoinGPencil_AdtFixData {
GHash *names_map;
} tJoinGPencil_AdtFixData;
-/* Callback to pass to BKE_fcurves_main_cb() for RNA Paths attached to each F-Curve used in the AnimData */
+/**
+ * Callback to pass to #BKE_fcurves_main_cb()
+ * for RNA Paths attached to each F-Curve used in the #AnimData.
+ */
static void joined_gpencil_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
{
tJoinGPencil_AdtFixData *afd = (tJoinGPencil_AdtFixData *)user_data;
@@ -2168,8 +2201,9 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
bool ok = false;
/* Ensure we're in right mode and that the active object is correct */
- if (!ob_active || ob_active->type != OB_GPENCIL)
+ if (!ob_active || ob_active->type != OB_GPENCIL) {
return OPERATOR_CANCELLED;
+ }
bGPdata *gpd = (bGPdata *)ob_active->data;
if ((!gpd) || GPENCIL_ANY_MODE(gpd)) {
@@ -2374,7 +2408,7 @@ static bool gpencil_active_color_poll(bContext *C)
return false;
}
-/* ******************* Lock and hide any color non used in current layer ************************** */
+/* **************** Lock and hide any color non used in current layer ************************** */
static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
@@ -2382,14 +2416,16 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
MaterialGPencilStyle *gp_style = NULL;
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* first lock and hide all colors */
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
for (short i = 0; i < *totcol; i++) {
ma = give_current_material(ob, i + 1);
@@ -2406,8 +2442,9 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
(gpl->flag & GP_LAYER_ACTIVE)) {
for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
ma = give_current_material(ob, gps->mat_nr + 1);
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
@@ -2459,8 +2496,9 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
int flags = GP_STYLE_COLOR_LOCKED;
bool isolate = false;
- if (RNA_boolean_get(op->ptr, "affect_visibility"))
+ if (RNA_boolean_get(op->ptr, "affect_visibility")) {
flags |= GP_STYLE_COLOR_HIDE;
+ }
if (ELEM(NULL, gpd, active_color)) {
BKE_report(op->reports, RPT_ERROR, "No active color to isolate");
@@ -2473,8 +2511,9 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
for (short i = 0; i < *totcol; i++) {
ma = give_current_material(ob, i + 1);
/* Skip if this is the active one */
- if (ma == active_ma)
+ if (ma == active_ma) {
continue;
+ }
/* If the flags aren't set, that means that the color is
* not alone, so we have some colors to isolate still
@@ -2492,10 +2531,12 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
for (short i = 0; i < *totcol; i++) {
ma = give_current_material(ob, i + 1);
gp_style = ma->gp_style;
- if (gp_style == active_color)
+ if (gp_style == active_color) {
continue;
- else
+ }
+ else {
gp_style->flag |= flags;
+ }
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -2556,8 +2597,9 @@ static int gpencil_color_hide_exec(bContext *C, wmOperator *op)
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
if (unselected) {
/* hide unselected */
@@ -2616,8 +2658,9 @@ static int gpencil_color_reveal_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
/* make all colors visible */
MaterialGPencilStyle *gp_style = NULL;
@@ -2666,8 +2709,9 @@ static int gpencil_color_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
/* make all layers non-editable */
MaterialGPencilStyle *gp_style = NULL;
@@ -2716,8 +2760,9 @@ static int gpencil_color_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
/* make all layers editable again*/
MaterialGPencilStyle *gp_style = NULL;
@@ -2767,8 +2812,9 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *op)
const bool deselected = RNA_boolean_get(op->ptr, "deselect");
/* sanity checks */
- if (ELEM(NULL, gpd, gp_style))
+ if (ELEM(NULL, gpd, gp_style)) {
return OPERATOR_CANCELLED;
+ }
/* read all strokes and select*/
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
@@ -2782,11 +2828,13 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *op)
/* verify something to do */
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
/* select */
if (ob->actcol == gps->mat_nr + 1) {
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 40e1e483f41..463c2144276 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -286,8 +286,9 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op)
is_object = true;
}
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Just toggle paintmode flag... */
gpd->flag ^= GP_DATA_STROKE_PAINTMODE;
@@ -386,8 +387,9 @@ static int gpencil_sculptmode_toggle_exec(bContext *C, wmOperator *op)
is_object = true;
}
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Just toggle sculptmode flag... */
gpd->flag ^= GP_DATA_STROKE_SCULPTMODE;
@@ -475,8 +477,9 @@ static int gpencil_weightmode_toggle_exec(bContext *C, wmOperator *op)
is_object = true;
}
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Just toggle weightmode flag... */
gpd->flag ^= GP_DATA_STROKE_WEIGHTMODE;
@@ -545,8 +548,9 @@ void GPENCIL_OT_weightmode_toggle(wmOperatorType *ot)
static int gpencil_hideselect_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
View3D *v3d = CTX_wm_view3d(C);
- if (v3d == NULL)
+ if (v3d == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Just toggle alpha... */
if (v3d->vertex_opacity > 0.0f) {
@@ -615,7 +619,7 @@ static void gp_duplicate_points(const bGPDstroke *gps,
else if (i == gps->totpoints - 1) {
len = i - start_idx + 1;
}
- //printf("copying from %d to %d = %d\n", start_idx, i, len);
+ // printf("copying from %d to %d = %d\n", start_idx, i, len);
/* make copies of the relevant data */
if (len) {
@@ -685,8 +689,9 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op)
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* make copies of selected strokes, and deselect these once we're done */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
@@ -931,13 +936,15 @@ static int gp_extrude_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
if (gps->flag & GP_STROKE_SELECT) {
gpencil_add_move_points(gpf, gps);
@@ -1062,7 +1069,8 @@ void ED_gpencil_strokes_copybuf_free(void)
gp_strokes_copypastebuf.first = gp_strokes_copypastebuf.last = NULL;
}
-/* Ensure that destination datablock has all the colours the pasted strokes need
+/**
+ * Ensure that destination datablock has all the colors the pasted strokes need.
* Helper function for copy-pasting strokes
*/
GHash *gp_copybuf_validate_colormap(bContext *C)
@@ -1123,14 +1131,16 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* make copies of selected strokes, and deselect these once we're done */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
if (gps->flag & GP_STROKE_SELECT) {
if (gps->totpoints == 1) {
@@ -1202,7 +1212,7 @@ void GPENCIL_OT_copy(wmOperatorType *ot)
ot->poll = gp_stroke_edit_poll;
/* flags */
- //ot->flag = OPTYPE_REGISTER;
+ // ot->flag = OPTYPE_REGISTER;
}
/* --------------------- */
@@ -1212,8 +1222,9 @@ static bool gp_strokes_paste_poll(bContext *C)
{
/* 1) Must have GP datablock to paste to
* - We don't need to have an active layer though, as that can easily get added
- * - If the active layer is locked, we can't paste there, but that should prompt a warning instead
- * 2) Copy buffer must at least have something (though it may be the wrong sort...)
+ * - If the active layer is locked, we can't paste there,
+ * but that should prompt a warning instead.
+ * 2) Copy buffer must at least have something (though it may be the wrong sort...).
*/
return (ED_gpencil_data_get_active(C) != NULL) &&
(!BLI_listbase_is_empty(&gp_strokes_copypastebuf));
@@ -1273,13 +1284,16 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
}
if (ok == false) {
- /* XXX: this check is not 100% accurate (i.e. image editor is incompatible with normal 2D strokes),
- * but should be enough to give users a good idea of what's going on
+ /* XXX: this check is not 100% accurate
+ * (i.e. image editor is incompatible with normal 2D strokes),
+ * but should be enough to give users a good idea of what's going on.
*/
- if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D)
+ if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) {
BKE_report(op->reports, RPT_ERROR, "Cannot paste 2D strokes in 3D View");
- else
+ }
+ else {
BKE_report(op->reports, RPT_ERROR, "Cannot paste 3D strokes in 2D editors");
+ }
return OPERATOR_CANCELLED;
}
@@ -1442,16 +1456,18 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
bGPDstroke *gps, *gpsn;
/* skip if no frame with strokes, or if this is the layer we're moving strokes to */
- if ((gpl == target_layer) || (gpf == NULL))
+ if ((gpl == target_layer) || (gpf == NULL)) {
continue;
+ }
/* make copies of selected strokes, and deselect these once we're done */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* TODO: Don't just move entire strokes - instead, only copy the selected portions... */
if (gps->flag & GP_STROKE_SELECT) {
@@ -1541,7 +1557,8 @@ static int gp_blank_frame_add_exec(bContext *C, wmOperator *op)
/* Initialise datablock and an active layer if nothing exists yet */
if (ELEM(NULL, gpd, active_gpl)) {
- /* let's just be lazy, and call the "Add New Layer" operator, which sets everything up as required */
+ /* Let's just be lazy, and call the "Add New Layer" operator,
+ * which sets everything up as required. */
WM_operator_name_call(C, "GPENCIL_OT_layer_add", WM_OP_EXEC_DEFAULT, NULL);
}
@@ -1676,8 +1693,9 @@ static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op)
/* try to get the "active" frame - but only if it actually occurs on this frame */
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* delete it... */
BKE_gpencil_layer_delframe(gpl, gpf);
@@ -1752,16 +1770,18 @@ static int gp_delete_selected_strokes(bContext *C)
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are selected */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* free stroke if selected */
if (gps->flag & GP_STROKE_SELECT) {
@@ -1817,8 +1837,9 @@ static int gp_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete points from selected strokes
* NOTE: we may still have to remove the stroke if it ends up having no points!
@@ -1827,11 +1848,13 @@ static int gp_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
gpsn = gps->next;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
/* the stroke must have at least one point selected for any operator */
if (gps->flag & GP_STROKE_SELECT) {
@@ -2189,7 +2212,8 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf,
/* Watch out for special case where No islands = All points selected = Delete Stroke only */
if (num_islands) {
- /* there are islands, so create a series of new strokes, adding them before the "next" stroke */
+ /* There are islands, so create a series of new strokes,
+ * adding them before the "next" stroke. */
int idx;
bGPDstroke *new_stroke = NULL;
@@ -2239,13 +2263,13 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf,
e++;
}
}
- /* Each island corresponds to a new stroke. We must adjust the
- * timings of these new strokes:
+ /* Each island corresponds to a new stroke.
+ * We must adjust the timings of these new strokes:
*
- * Each point's timing data is a delta from stroke's inittime, so as we erase some points from
- * the start of the stroke, we have to offset this inittime and all remaining points' delta values.
- * This way we get a new stroke with exactly the same timing as if user had started drawing from
- * the first non-removed point...
+ * Each point's timing data is a delta from stroke's inittime, so as we erase some points
+ * from the start of the stroke, we have to offset this inittime and all remaining points'
+ * delta values. This way we get a new stroke with exactly the same timing as if user had
+ * started drawing from the first non-removed point.
*/
{
bGPDspoint *pts;
@@ -2310,19 +2334,22 @@ static int gp_delete_selected_points(bContext *C)
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are selected */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
if (gps->flag & GP_STROKE_SELECT) {
/* deselect old stroke, since it will be used as template for the new strokes */
@@ -2496,11 +2523,13 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
int i;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
continue;
+ }
// TODO: if entire stroke is selected, offset entire stroke by same amount?
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
@@ -2571,14 +2600,17 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
int i;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
continue;
+ }
/* only continue if this stroke is selected (editable doesn't guarantee this)... */
- if ((gps->flag & GP_STROKE_SELECT) == 0)
+ if ((gps->flag & GP_STROKE_SELECT) == 0) {
continue;
+ }
if (use_offset) {
float offset[3];
@@ -2666,14 +2698,17 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
int i;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
continue;
+ }
/* only continue if this stroke is selected (editable doesn't guarantee this)... */
- if ((gps->flag & GP_STROKE_SELECT) == 0)
+ if ((gps->flag & GP_STROKE_SELECT) == 0) {
continue;
+ }
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & GP_SPOINT_SELECT) {
@@ -2728,8 +2763,9 @@ static int gp_stroke_apply_thickness_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
/* sanity checks */
- if (ELEM(NULL, gpd, gpl, gpl->frames.first))
+ if (ELEM(NULL, gpd, gpl, gpl->frames.first)) {
return OPERATOR_CANCELLED;
+ }
/* loop all strokes */
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
@@ -2782,24 +2818,28 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
const int type = RNA_enum_get(op->ptr, "type");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* loop all selected strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- if (gpl->actframe == NULL)
+ if (gpl->actframe == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
/* skip strokes that are not selected or invalid for current view */
- if (((gps->flag & GP_STROKE_SELECT) == 0) || ED_gpencil_stroke_can_use(C, gps) == false)
+ if (((gps->flag & GP_STROKE_SELECT) == 0) || ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* skip hidden or locked colors */
if (!gp_style || (gp_style->flag & GP_STYLE_COLOR_HIDE) ||
- (gp_style->flag & GP_STYLE_COLOR_LOCKED))
+ (gp_style->flag & GP_STYLE_COLOR_LOCKED)) {
continue;
+ }
switch (type) {
case GP_STROKE_CYCLIC_CLOSE:
@@ -2875,13 +2915,15 @@ static int gp_stroke_caps_set_exec(bContext *C, wmOperator *op)
const int type = RNA_enum_get(op->ptr, "type");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* loop all selected strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- if (gpl->actframe == NULL)
+ if (gpl->actframe == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
@@ -3044,11 +3086,13 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a,
float deltatime = 0.0f;
/* sanity checks */
- if (ELEM(NULL, gps_a, gps_b))
+ if (ELEM(NULL, gps_a, gps_b)) {
return;
+ }
- if ((gps_a->totpoints == 0) || (gps_b->totpoints == 0))
+ if ((gps_a->totpoints == 0) || (gps_b->totpoints == 0)) {
return;
+ }
/* define start and end points of each stroke */
float sa[3], sb[3], ea[3], eb[3];
@@ -3109,11 +3153,13 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
const bool leave_gaps = RNA_boolean_get(op->ptr, "leave_gaps");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
- if (activegpl->flag & GP_LAYER_LOCKED)
+ if (activegpl->flag & GP_LAYER_LOCKED) {
return OPERATOR_CANCELLED;
+ }
BLI_assert(ELEM(type, GP_STROKE_JOIN, GP_STROKE_JOINCOPY));
@@ -3121,8 +3167,9 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
bool first = false;
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *gpf = gpl->actframe;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
@@ -3193,8 +3240,9 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
if (type == GP_STROKE_JOINCOPY) {
if (new_stroke) {
/* Add a new frame if needed */
- if (activegpl->actframe == NULL)
+ if (activegpl->actframe == NULL) {
activegpl->actframe = BKE_gpencil_frame_addnew(activegpl, gpf_a->framenum);
+ }
BLI_addtail(&activegpl->actframe->strokes, new_stroke);
}
@@ -3244,14 +3292,16 @@ static int gp_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* read all selected strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *gpf = gpl->actframe;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
if (gps->flag & GP_STROKE_SELECT) {
@@ -3566,8 +3616,9 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op)
int i2;
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* Go through each editable + selected stroke */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
@@ -3728,8 +3779,9 @@ static int gp_stroke_simplify_exec(bContext *C, wmOperator *op)
float factor = RNA_float_get(op->ptr, "factor");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* Go through each editable + selected stroke */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
@@ -3776,8 +3828,9 @@ static int gp_stroke_simplify_fixed_exec(bContext *C, wmOperator *op)
int steps = RNA_int_get(op->ptr, "step");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* Go through each editable + selected stroke */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
@@ -3825,8 +3878,9 @@ static int gp_stroke_trim_exec(bContext *C, wmOperator *UNUSED(op))
bGPdata *gpd = ED_gpencil_data_get_active(C);
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* Go through each editable + selected stroke */
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
@@ -3841,15 +3895,17 @@ static int gp_stroke_trim_exec(bContext *C, wmOperator *UNUSED(op))
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
if (gps->flag & GP_STROKE_SELECT) {
BKE_gpencil_trim_stroke(gps);
@@ -4202,8 +4258,9 @@ static int gp_stroke_smooth_exec(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
gp_smooth_stroke(C, op);
@@ -4424,8 +4481,9 @@ static bool gpencil_cutter_poll(bContext *C)
bGPdata *gpd = ED_gpencil_data_get_active(C);
if (GPENCIL_PAINT_MODE(gpd)) {
- if (gpd->layers.first)
+ if (gpd->layers.first) {
return true;
+ }
}
return false;
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 8d3137ed3db..96f405fab2f 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -250,8 +250,9 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
ED_gpencil_parent_location(tgpw.depsgraph, ob, gpd, gpl, tgpw.diff_mat);
/* do not draw layer if hidden */
- if (gpl->flag & GP_LAYER_HIDE)
+ if (gpl->flag & GP_LAYER_HIDE) {
continue;
+ }
/* if active layer and no keyframe, create a new one */
if (gpl == tgpf->gpl) {
@@ -262,8 +263,9 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
/* get frame to draw */
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn */
@@ -453,7 +455,7 @@ static void get_pixel(const ImBuf *ibuf, const int idx, float r_col[4])
/* set pixel data (rgba) at index */
static void set_pixel(ImBuf *ibuf, int idx, const float col[4])
{
- //BLI_assert(idx <= ibuf->x * ibuf->y);
+ // BLI_assert(idx <= ibuf->x * ibuf->y);
if (ibuf->rect) {
uint *rrect = &ibuf->rect[idx];
uchar ccol[4];
@@ -930,7 +932,8 @@ static void gpencil_get_depth_array(tGPDfill *tgpf)
view3d_region_operator_needs_opengl(tgpf->win, tgpf->ar);
ED_view3d_autodist_init(tgpf->depsgraph, tgpf->ar, tgpf->v3d, 0);
- /* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */
+ /* Since strokes are so fine, when using their depth we need a margin
+ * otherwise they might get missed. */
int depth_margin = 0;
/* get an array of depths, far depths are blended */
@@ -959,8 +962,9 @@ static void gpencil_get_depth_array(tGPDfill *tgpf)
if (found_depth == false) {
/* eeh... not much we can do.. :/, ignore depth in this case */
- for (i = totpoints - 1; i >= 0; i--)
+ for (i = totpoints - 1; i >= 0; i--) {
tgpf->depth_arr[i] = 0.9999f;
+ }
}
else {
if (interp_depth) {
@@ -1346,8 +1350,9 @@ static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
/* try to initialize context data needed */
if (!gpencil_fill_init(C, op)) {
gpencil_fill_exit(C, op);
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
return OPERATOR_CANCELLED;
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 5c9b9416330..d83cc7858bd 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -541,8 +541,9 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent
/* try to initialize context data needed */
if (!gpencil_interpolate_init(C, op)) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
return OPERATOR_CANCELLED;
}
else {
@@ -1129,8 +1130,9 @@ static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op))
bGPDframe *gpf, *gpfn;
/* Only continue if we're currently on a breakdown keyframe */
- if ((gpl->actframe == NULL) || (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN))
+ if ((gpl->actframe == NULL) || (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN)) {
continue;
+ }
/* Search left for "start_key" (i.e. the first breakdown to remove) */
gpf = gpl->actframe;
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index 48c761919e5..9d3c2a6e271 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -66,10 +66,12 @@ static int gpencil_sort_points(const void *a1, const void *a2)
{
const tGPencilPointCache *ps1 = a1, *ps2 = a2;
- if (ps1->factor < ps2->factor)
+ if (ps1->factor < ps2->factor) {
return -1;
- else if (ps1->factor > ps2->factor)
+ }
+ else if (ps1->factor > ps2->factor) {
return 1;
+ }
return 0;
}
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index fce8fa79217..db4c601709c 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -362,7 +362,7 @@ void ED_operatormacros_gpencil(void)
WM_operatortype_macro_define(ot, "GPENCIL_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_boolean_set(otmacro->ptr, "gpencil_strokes", true);
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
/* Extrude + Move = Interactively add new points */
@@ -373,7 +373,7 @@ void ED_operatormacros_gpencil(void)
WM_operatortype_macro_define(ot, "GPENCIL_OT_extrude");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_boolean_set(otmacro->ptr, "gpencil_strokes", true);
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index bfdfe64ed54..b1b29356060 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -178,7 +178,8 @@ typedef struct tGPsdata {
/* These need to be doubles, as (at least under unix) they are in seconds since epoch,
* float (and its 7 digits precision) is definitively not enough here!
- * double, with its 15 digits precision, ensures us millisecond precision for a few centuries at least.
+ * double, with its 15 digits precision,
+ * ensures us millisecond precision for a few centuries at least.
*/
/** Used when converting to path. */
double inittime;
@@ -367,19 +368,23 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float mvalo[2
/* check if mouse moved at least certain distance on both axes (best case)
* - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
*/
- else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX))
+ else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
return true;
- /* check if the distance since the last point is significant enough
- * - prevents points being added too densely
- * - distance here doesn't use sqrt to prevent slowness... we should still be safe from overflows though
- */
- else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX)
+ /* Check if the distance since the last point is significant enough:
+ * - Prevents points being added too densely
+ * - Distance here doesn't use sqrt to prevent slowness.
+ * We should still be safe from overflows though.
+ */
+ }
+ else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
return true;
- /* mouse 'didn't move' */
- else
+ /* mouse 'didn't move' */
+ }
+ else {
return false;
+ }
}
/* reproject stroke to plane locked to axis in 3d cursor location */
@@ -657,8 +662,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
/* check if still room in buffer */
- if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX)
+ if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX) {
return GP_STROKEADD_OVERFLOW;
+ }
/* get pointer to destination point */
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_size);
@@ -793,10 +799,12 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* check if another operation can still occur */
- if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX)
+ if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX) {
return GP_STROKEADD_FULL;
- else
+ }
+ else {
return GP_STROKEADD_NORMAL;
+ }
}
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
@@ -881,8 +889,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* increment counters */
- if (gpd->runtime.sbuffer_size == 0)
+ if (gpd->runtime.sbuffer_size == 0) {
gpd->runtime.sbuffer_size++;
+ }
return GP_STROKEADD_NORMAL;
}
@@ -913,22 +922,26 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
(!is_depth);
int i, totelem;
- /* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */
+ /* Since strokes are so fine,
+ * when using their depth we need a margin otherwise they might get missed. */
int depth_margin = (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 4 : 0;
/* get total number of points to allocate space for
* - drawing straight-lines only requires the endpoints
*/
- if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)
+ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
totelem = (gpd->runtime.sbuffer_size >= 2) ? 2 : gpd->runtime.sbuffer_size;
- else
+ }
+ else {
totelem = gpd->runtime.sbuffer_size;
+ }
/* exit with error if no valid points from this stroke */
if (totelem == 0) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No valid points in stroke buffer to convert (tot=%d)\n",
gpd->runtime.sbuffer_size);
+ }
return;
}
@@ -1112,8 +1125,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
if (found_depth == false) {
/* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */
- for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--)
+ for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
depth_arr[i] = 0.9999f;
+ }
}
else {
if ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) ||
@@ -1123,8 +1137,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
/* find first valid contact point */
for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
first_valid = i;
@@ -1134,8 +1149,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
}
else {
for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
last_valid = i;
}
@@ -1189,10 +1205,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
gp_randomize_stroke(gps, brush, p->rng);
}
- /* smooth stroke after subdiv - only if there's something to do
- * for each iteration, the factor is reduced to get a better smoothing without changing too much
- * the original stroke
- */
+ /* Smooth stroke after subdiv - only if there's something to do for each iteration,
+ * the factor is reduced to get a better smoothing
+ * without changing too much the original stroke. */
if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) &&
(brush->gpencil_settings->draw_smoothfac > 0.0f)) {
float reduce = 0.0f;
@@ -1223,8 +1238,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps);
}
- if (depth_arr)
+ if (depth_arr) {
MEM_freeN(depth_arr);
+ }
}
/* Save material index */
@@ -1233,9 +1249,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
/* calculate UVs along the stroke */
ED_gpencil_calc_stroke_uv(obact, gps);
- /* add stroke to frame, usually on tail of the listbase, but if on back is enabled the stroke is added on listbase head
- * because the drawing order is inverse and the head stroke is the first to draw. This is very useful for artist
- * when drawing the background
+ /* add stroke to frame, usually on tail of the listbase, but if on back is enabled the stroke
+ * is added on listbase head because the drawing order is inverse and the head stroke is the
+ * first to draw. This is very useful for artist when drawing the background.
*/
if ((ts->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK) &&
(p->paintmode != GP_PAINTMODE_DRAW_POLY)) {
@@ -1362,8 +1378,9 @@ static void gp_free_stroke(bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps)
MEM_freeN(gps->dvert);
}
- if (gps->triangles)
+ if (gps->triangles) {
MEM_freeN(gps->triangles);
+ }
BLI_freelinkN(&gpf->strokes, gps);
gp_update_cache(gpd);
}
@@ -1458,8 +1475,9 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
for (i = 0; (i + 1) < gps->totpoints; i++) {
/* only process if it hasn't been masked out... */
- if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT))
+ if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) {
continue;
+ }
/* get points to work with */
pt1 = gps->points + i;
@@ -1510,8 +1528,9 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
pt2 = gps->points + i + 1;
/* only process if it hasn't been masked out... */
- if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT))
+ if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) {
continue;
+ }
bGPDspoint npt;
if (pt0) {
@@ -1881,8 +1900,9 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
/* make sure the active view (at the starting time) is a 3d-view */
if (curarea == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No active view for painting\n");
+ }
return 0;
}
@@ -1913,10 +1933,11 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
if (ar->regiondata == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf(
"Error: 3D-View active region doesn't have any region data, so cannot be "
"drawable\n");
+ }
return 0;
}
@@ -1941,8 +1962,9 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
/* unsupported views */
default: {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Active view not appropriate for Grease Pencil drawing\n");
+ }
return 0;
}
}
@@ -1951,14 +1973,16 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr);
if ((gpd_ptr == NULL) || ED_gpencil_data_owner_is_annotation(&p->ownerPtr)) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Current context doesn't allow for any Grease Pencil data\n");
+ }
return 0;
}
else {
/* if no existing GPencil block exists, add one */
- if (*gpd_ptr == NULL)
+ if (*gpd_ptr == NULL) {
*gpd_ptr = BKE_gpencil_data_addnew(bmain, "GPencil");
+ }
p->gpd = *gpd_ptr;
}
@@ -2033,8 +2057,9 @@ static void gp_session_cleanup(tGPsdata *p)
bGPdata *gpd = (p) ? p->gpd : NULL;
/* error checking */
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* free stroke buffer */
if (gpd->runtime.sbuffer) {
@@ -2076,8 +2101,9 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
}
if ((paintmode != GP_PAINTMODE_ERASER) && (p->gpl->flag & GP_LAYER_LOCKED)) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Cannot paint on locked layer\n");
+ }
return;
}
@@ -2092,8 +2118,9 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
for (bGPDlayer *gpl = p->gpd->layers.first; gpl; gpl = gpl->next) {
/* Skip if layer not editable */
- if (gpencil_layer_is_editable(gpl) == false)
+ if (gpencil_layer_is_editable(gpl) == false) {
continue;
+ }
/* Add a new frame if needed (and based off the active frame,
* as we need some existing strokes to erase)
@@ -2134,17 +2161,20 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* Drawing Modes - Add a new frame if needed on the active layer */
short add_frame_mode;
- if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST)
+ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
add_frame_mode = GP_GETFRAME_ADD_COPY;
- else
+ }
+ else {
add_frame_mode = GP_GETFRAME_ADD_NEW;
+ }
p->gpf = BKE_gpencil_layer_getframe(p->gpl, cfra_eval, add_frame_mode);
if (p->gpf == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No frame created (gpencil_paint_init)\n");
+ }
return;
}
else {
@@ -2251,8 +2281,9 @@ static void gp_paint_cleanup(tGPsdata *p)
}
/* "unlock" frame */
- if (p->gpf)
+ if (p->gpf) {
p->gpf->flag &= ~GP_FRAME_PAINT;
+ }
}
/* ------------------------------- */
@@ -2288,14 +2319,13 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
immUniform1f("dash_width", 12.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_circle_wire_2d(
- shdr_pos,
- x,
- y,
- p->radius,
- /* XXX Dashed shader gives bad results with sets of small segments currently,
- * temp hack around the issue. :( */
- max_ii(8, p->radius / 2)); /* was fixed 40 */
+ imm_draw_circle_wire_2d(shdr_pos,
+ x,
+ y,
+ p->radius,
+ /* XXX Dashed shader gives bad results with sets of small segments
+ * currently, temp hack around the issue. :( */
+ max_ii(8, p->radius / 2)); /* was fixed 40 */
immUnbindProgram();
@@ -2544,7 +2574,8 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra
copy_v2_v2(p->mvalo, p->mval);
p->opressure = p->pressure;
}
- /* only add current point to buffer if mouse moved (even though we got an event, it might be just noise) */
+ /* Only add current point to buffer if mouse moved
+ * (even though we got an event, it might be just noise). */
else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) {
/* if lazy mouse, interpolate the last and current mouse positions */
@@ -2584,8 +2615,9 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra
BKE_report(op->reports, RPT_ERROR, "Cannot paint stroke");
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Grease-Pencil Paint - Add Point Invalid\n");
+ }
return;
}
@@ -2684,6 +2716,8 @@ static void gpencil_draw_apply_event(
PointerRNA itemptr;
float mousef[2];
int tablet = 0;
+ bool is_speed_guide = ((guide->use_guide) &&
+ (p->brush && (p->brush->gpencil_tool == GPAINT_TOOL_DRAW)));
/* convert from window-space to area-space mouse coordinates
* add any x,y override position for fake events
@@ -2693,7 +2727,7 @@ static void gpencil_draw_apply_event(
p->shift = event->shift;
/* verify direction for straight lines */
- if ((guide->use_guide) ||
+ if ((is_speed_guide) ||
((event->alt > 0) && (RNA_boolean_get(op->ptr, "disable_straight") == false))) {
if (p->straight == 0) {
int dx = (int)fabsf(p->mval[0] - p->mvali[0]);
@@ -2791,7 +2825,7 @@ static void gpencil_draw_apply_event(
/* special exception for grid snapping
* it requires direction which needs at least two points
*/
- if (!ELEM(p->paintmode, GP_PAINTMODE_ERASER, GP_PAINTMODE_SET_CP) && guide->use_guide &&
+ if (!ELEM(p->paintmode, GP_PAINTMODE_ERASER, GP_PAINTMODE_SET_CP) && is_speed_guide &&
guide->use_snapping && (guide->type == GP_GUIDE_GRID)) {
p->flags |= GP_PAINTFLAG_REQ_VECTOR;
}
@@ -2819,9 +2853,9 @@ static void gpencil_draw_apply_event(
}
/* check if stroke is straight or guided */
- if ((p->paintmode != GP_PAINTMODE_ERASER) && ((p->straight) || (guide->use_guide))) {
+ if ((p->paintmode != GP_PAINTMODE_ERASER) && ((p->straight) || (is_speed_guide))) {
/* guided stroke */
- if (guide->use_guide) {
+ if (is_speed_guide) {
switch (guide->type) {
default:
case GP_GUIDE_CIRCULAR: {
@@ -2943,8 +2977,9 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
/* printf("\tGP - no valid data\n"); */
return OPERATOR_CANCELLED;
}
- else
+ else {
p = op->customdata;
+ }
/* printf("\tGP - Start redrawing stroke\n"); */
@@ -3082,10 +3117,12 @@ static void gpencil_guide_event_handling(bContext *C,
add_notifier = true;
float angle = guide->angle;
float adjust = (float)M_PI / 180.0f;
- if (event->alt)
+ if (event->alt) {
adjust *= 45.0f;
- else if (!event->shift)
+ }
+ else if (!event->shift) {
adjust *= 15.0f;
+ }
angle += (event->type == JKEY) ? adjust : -adjust;
angle = angle_compat_rad(angle, M_PI);
guide->angle = angle;
@@ -3103,8 +3140,9 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = (bGPdata *)ob->data;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("GPencil - Starting Drawing\n");
+ }
/* support for tablets eraser pen */
if (gpencil_is_tablet_eraser_active(event)) {
@@ -3140,14 +3178,17 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
/* try to initialize context data needed while drawing */
if (!gpencil_draw_init(C, op, event)) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
- if (G.debug & G_DEBUG)
+ }
+ if (G.debug & G_DEBUG) {
printf("\tGP - no valid data\n");
+ }
return OPERATOR_CANCELLED;
}
- else
+ else {
p = op->customdata;
+ }
/* TODO: set any additional settings that we can take from the events?
* TODO? if tablet is erasing, force eraser to be on? */
@@ -3237,8 +3278,9 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
/* XXX: watch it with the paintmode! in future,
* it'd be nice to allow changing paint-mode when in sketching-sessions */
- if (gp_session_initdata(C, op, p))
+ if (gp_session_initdata(C, op, p)) {
gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C));
+ }
if (p->status != GP_STATUS_ERROR) {
p->status = GP_STATUS_PAINTING;
@@ -3266,10 +3308,12 @@ static void gpencil_stroke_end(wmOperator *op)
p->gpf = NULL;
}
-/* Move last stroke in the listbase to the head to be drawn below all previous strokes in the layer */
+/* Move last stroke in the listbase to the head
+ * to be drawn below all previous strokes in the layer. */
static void gpencil_move_last_stroke_to_back(bContext *C)
{
- /* move last stroke (the polygon) to head of the listbase stroke to draw on back of all previous strokes */
+ /* Move last stroke (the polygon) to head of the listbase stroke
+ * to draw on back of all previous strokes. */
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
@@ -3430,7 +3474,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- /* we don't pass on key events, GP is used with key-modifiers - prevents Dkey to insert drivers */
+ /* We don't pass on key events, GP is used with key-modifiers -
+ * prevents Dkey to insert drivers. */
if (ISKEYBOARD(event->type)) {
if (ELEM(event->type, LEFTARROWKEY, DOWNARROWKEY, RIGHTARROWKEY, UPARROWKEY, ZKEY)) {
/* allow some keys:
@@ -3462,10 +3507,12 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- //printf("\tGP - handle modal event...\n");
+ // printf("\tGP - handle modal event...\n");
- /* exit painting mode (and/or end current stroke)
- * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647]
+ /* Exit painting mode (and/or end current stroke).
+ *
+ * NOTE: cannot do RIGHTMOUSE (as is standard for canceling)
+ * as that would break polyline T32647.
*/
/* if polyline and release shift must cancel */
if ((ELEM(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY, EKEY)) ||
@@ -3587,8 +3634,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: Region under cursor is out of bounds, so cannot be drawn on\n", __func__);
+ }
}
}
else if (p->ar) {
@@ -3603,8 +3651,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: No active region found in GP Paint session data\n", __func__);
+ }
}
if (in_bounds) {
@@ -3661,7 +3710,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* handle drawing event */
/* printf("\t\tGP - add point\n"); */
- if (((p->flags & GP_PAINTFLAG_FIRSTRUN) == 0) || (guide->use_guide)) {
+ if (((p->flags & GP_PAINTFLAG_FIRSTRUN) == 0)) {
gpencil_add_missing_events(C, op, event, p);
}
@@ -3695,8 +3744,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADMINUS:
p->radius -= 5;
- if (p->radius <= 0)
+ if (p->radius <= 0) {
p->radius = 1;
+ }
break;
}
@@ -3717,8 +3767,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
- if (0 == gpencil_area_exists(C, p->sa))
+ if (0 == gpencil_area_exists(C, p->sa)) {
estate = OPERATOR_CANCELLED;
+ }
else {
/* update status indicators - cursor, header, etc. */
gpencil_draw_status_indicators(C, p);
@@ -3748,7 +3799,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* event doesn't need to be handled */
#if 0
printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n",
- event->type, event->type == MIDDLEMOUSE, event->type == MOUSEMOVE);
+ event->type,
+ event->type == MIDDLEMOUSE,
+ event->type == MOUSEMOVE);
#endif
break;
}
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index f178d232376..08fee2bb393 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -129,8 +129,9 @@ static void gp_session_validatebuffer(tGPDprimitive *p)
gpd->runtime.sbuffer_sflag = 0;
gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
- if (ELEM(p->type, GP_STROKE_BOX, GP_STROKE_CIRCLE))
+ if (ELEM(p->type, GP_STROKE_BOX, GP_STROKE_CIRCLE)) {
gpd->runtime.sbuffer_sflag |= GP_STROKE_CYCLIC;
+ }
}
static void gp_init_colors(tGPDprimitive *p)
@@ -174,16 +175,20 @@ static void gpencil_primitive_to_square(tGPDprimitive *tgpi, const float x, cons
float w = fabsf(x);
float h = fabsf(y);
if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
- if (w > h)
+ if (w > h) {
tgpi->end[1] = tgpi->origin[1] + x;
- else
+ }
+ else {
tgpi->end[0] = tgpi->origin[0] + y;
+ }
}
else {
- if (w > h)
+ if (w > h) {
tgpi->end[1] = tgpi->origin[1] - x;
- else
+ }
+ else {
tgpi->end[0] = tgpi->origin[0] - y;
+ }
}
}
@@ -289,8 +294,9 @@ static void gpencil_primitive_allocate_memory(tGPDprimitive *tgpi)
tgpi->point_count += (tgpi->type == GP_STROKE_BOX) ? (MAX_EDGES * 4 + 1) : (MAX_EDGES + 1);
bGPDstroke *gpsf = tgpi->gpf->strokes.first;
gpsf->points = MEM_reallocN(gpsf->points, sizeof(bGPDspoint) * tgpi->point_count);
- if (gpsf->dvert != NULL)
+ if (gpsf->dvert != NULL) {
gpsf->dvert = MEM_reallocN(gpsf->dvert, sizeof(MDeformVert) * tgpi->point_count);
+ }
tgpi->points = MEM_reallocN(tgpi->points, sizeof(tGPspoint) * tgpi->point_count);
}
@@ -675,13 +681,16 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
const bool is_camera = (bool)(ts->gp_sculpt.lock_axis == 0) &&
(tgpi->rv3d->persp == RV3D_CAMOB) && (!is_depth);
- if (tgpi->type == GP_STROKE_BOX)
+ if (tgpi->type == GP_STROKE_BOX) {
gps->totpoints = (tgpi->tot_edges * 4 + tgpi->tot_stored_edges);
- else
+ }
+ else {
gps->totpoints = (tgpi->tot_edges + tgpi->tot_stored_edges);
+ }
- if (tgpi->tot_stored_edges)
+ if (tgpi->tot_stored_edges) {
gps->totpoints--;
+ }
tgpi->gpd->runtime.tot_cp_points = 0;
@@ -778,8 +787,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* find first valid contact point */
for (i = 0; i < gps->totpoints; i++) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
first_valid = i;
@@ -789,8 +799,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
}
else {
for (i = gps->totpoints - 1; i >= 0; i--) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
last_valid = i;
}
@@ -1325,16 +1336,18 @@ static void gpencil_primitive_edit_event_handling(
float dy = (tgpi->mval[1] - tgpi->mvalo[1]);
tgpi->cp1[0] += dx;
tgpi->cp1[1] += dy;
- if (event->shift)
+ if (event->shift) {
copy_v2_v2(tgpi->cp2, tgpi->cp1);
+ }
}
else if (tgpi->sel_cp == SELECT_CP2) {
float dx = (tgpi->mval[0] - tgpi->mvalo[0]);
float dy = (tgpi->mval[1] - tgpi->mvalo[1]);
tgpi->cp2[0] += dx;
tgpi->cp2[1] += dy;
- if (event->shift)
+ if (event->shift) {
copy_v2_v2(tgpi->cp1, tgpi->cp2);
+ }
}
/* update screen */
gpencil_primitive_update(C, op, tgpi);
@@ -1344,12 +1357,15 @@ static void gpencil_primitive_edit_event_handling(
case LEFTMOUSE: {
if ((event->val == KM_PRESS)) {
/* find nearest cp based on stroke end points */
- if (move == MOVE_ENDS)
+ if (move == MOVE_ENDS) {
tgpi->sel_cp = (a < b) ? SELECT_START : SELECT_END;
- else if (move == MOVE_CP)
+ }
+ else if (move == MOVE_CP) {
tgpi->sel_cp = (c < d) ? SELECT_CP1 : SELECT_CP2;
- else
+ }
+ else {
tgpi->sel_cp = SELECT_NONE;
+ }
break;
}
else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS)) {
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index ef7a198111b..ba806022d3e 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -74,8 +74,9 @@ static bool gpencil_select_poll(bContext *C)
/* we just need some visible strokes, and to be in editmode or other modes only to catch event */
if (GPENCIL_ANY_MODE(gpd)) {
/* TODO: include a check for visible strokes? */
- if (gpd->layers.first)
+ if (gpd->layers.first) {
return true;
+ }
}
return false;
@@ -291,8 +292,9 @@ typedef enum eGP_SelectGrouped {
/* Select strokes with the same color */
GP_SEL_SAME_MATERIAL = 1,
- /* TODO: All with same prefix - Useful for isolating all layers for a particular character for instance */
- /* TODO: All with same appearance - colour/opacity/volumetric/fills ? */
+ /* TODO: All with same prefix -
+ * Useful for isolating all layers for a particular character for instance. */
+ /* TODO: All with same appearance - color/opacity/volumetric/fills ? */
} eGP_SelectGrouped;
/* ----------------------------------- */
@@ -308,8 +310,9 @@ static void gp_select_same_layer(bContext *C)
bGPDstroke *gps;
bool found = false;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* Search for a selected stroke */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
@@ -621,7 +624,8 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op))
int i;
bool prev_sel;
- /* First Pass: Go in forward order, expanding selection if previous was selected (pre changes)...
+ /* First Pass: Go in forward order,
+ * expanding selection if previous was selected (pre changes).
* - This pass covers the "after" edges of selection islands
*/
prev_sel = false;
@@ -705,7 +709,8 @@ static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op))
int i;
bool prev_sel;
- /* First Pass: Go in forward order, shrinking selection if previous was not selected (pre changes)...
+ /* First Pass: Go in forward order, shrinking selection
+ * if previous was not selected (pre changes).
* - This pass covers the "after" edges of selection islands
*/
prev_sel = false;
@@ -776,9 +781,12 @@ void GPENCIL_OT_select_less(wmOperatorType *ot)
/** \name Circle Select Operator
* \{ */
-/* Helper to check if a given stroke is within the area */
-/* NOTE: Code here is adapted (i.e. copied directly) from gpencil_paint.c::gp_stroke_eraser_dostroke()
- * It would be great to de-duplicate the logic here sometime, but that can wait...
+/**
+ * Helper to check if a given stroke is within the area.
+ *
+ * \note Code here is adapted (i.e. copied directly)
+ * from gpencil_paint.c #gp_stroke_eraser_dostroke().
+ * It would be great to de-duplicate the logic here sometime, but that can wait.
*/
static bool gp_stroke_do_circle_sel(bGPDlayer *gpl,
bGPDstroke *gps,
@@ -1290,6 +1298,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
bool deselect = RNA_boolean_get(op->ptr, "deselect");
bool toggle = RNA_boolean_get(op->ptr, "toggle");
bool whole = RNA_boolean_get(op->ptr, "entire_strokes");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
int mval[2] = {0};
@@ -1352,15 +1361,18 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* Abort if nothing hit... */
if (ELEM(NULL, hit_stroke, hit_point)) {
+ if (deselect_all) {
+ /* since left mouse select change, deselect all if click outside any hit */
+ deselect_all_selected(C);
- /* since left mouse select change, deselect all if click outside any hit */
- deselect_all_selected(C);
+ /* copy on write tag is needed, or else no refresh happens */
+ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+ DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
- /* copy on write tag is needed, or else no refresh happens */
- DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
- DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
- WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ return OPERATOR_FINISHED;
+ }
return OPERATOR_CANCELLED;
}
@@ -1382,17 +1394,21 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* entire stroke's points */
for (i = 0, pt = hit_stroke->points; i < hit_stroke->totpoints; i++, pt++) {
- if (deselect == false)
+ if (deselect == false) {
pt->flag |= GP_SPOINT_SELECT;
- else
+ }
+ else {
pt->flag &= ~GP_SPOINT_SELECT;
+ }
}
/* stroke too... */
- if (deselect == false)
+ if (deselect == false) {
hit_stroke->flag |= GP_STROKE_SELECT;
- else
+ }
+ else {
hit_stroke->flag &= ~GP_STROKE_SELECT;
+ }
}
else {
/* just the point (and the stroke) */
diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c
index d91977bc0da..7b57dacd3e4 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -68,7 +68,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
if (step == 1) { /* undo */
- //printf("\t\tGP - undo step\n");
+ // printf("\t\tGP - undo step\n");
if (cur_node->prev) {
if (!name || STREQ(cur_node->name, name)) {
cur_node = cur_node->prev;
@@ -77,7 +77,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
}
}
else if (step == -1) {
- //printf("\t\tGP - redo step\n");
+ // printf("\t\tGP - redo step\n");
if (cur_node->next) {
if (!name || STREQ(cur_node->name, name)) {
cur_node = cur_node->next;
@@ -134,7 +134,7 @@ void gpencil_undo_push(bGPdata *gpd)
{
bGPundonode *undo_node;
- //printf("\t\tGP - undo push\n");
+ // printf("\t\tGP - undo push\n");
if (cur_node) {
/* remove all un-done nodes from stack */
@@ -154,7 +154,8 @@ void gpencil_undo_push(bGPdata *gpd)
* - to prevent running out of memory during **really**
* long drawing sessions (triggering swapping)
*/
- /* TODO: Undo-memory constraint is not respected yet, but can be added if we have any need for it */
+ /* TODO: Undo-memory constraint is not respected yet,
+ * but can be added if we have any need for it. */
if (U.undosteps && !BLI_listbase_is_empty(&undo_nodes)) {
/* remove anything older than n-steps before cur_node */
int steps = 0;
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 858415061b1..129bd01574c 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -85,7 +85,9 @@
/* ******************************************************** */
/* Context Wrangling... */
-/* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it,
+/**
+ * Get pointer to active Grease Pencil datablock,
+ * and an RNA-pointer to trace back to whatever owns it,
* when context info is not available.
*/
bGPdata **ED_gpencil_data_get_pointers_direct(
@@ -104,8 +106,9 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
{
if (ob && (ob->type == OB_GPENCIL)) {
/* GP Object */
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&ob->id, r_ptr);
+ }
return (bGPdata **)&ob->data;
}
else {
@@ -120,15 +123,17 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
{
if (ob && (ob->type == OB_GPENCIL)) {
/* GP Object */
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&ob->id, r_ptr);
+ }
return (bGPdata **)&ob->data;
}
else {
/* Annotations */
/* XXX: */
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&scene->id, r_ptr);
+ }
return &scene->gpd;
}
@@ -142,8 +147,9 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
if (snode && snode->nodetree) {
/* for now, as long as there's an active node tree,
* default to using that in the Nodes Editor */
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&snode->nodetree->id, r_ptr);
+ }
return &snode->nodetree->gpd;
}
@@ -154,10 +160,12 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
{
SpaceSeq *sseq = (SpaceSeq *)sl;
- /* for now, Grease Pencil data is associated with the space (actually preview region only) */
+ /* For now, Grease Pencil data is associated with the space
+ * (actually preview region only). */
/* XXX our convention for everything else is to link to data though... */
- if (r_ptr)
+ if (r_ptr) {
RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, r_ptr);
+ }
return &sseq->gpd;
}
case SPACE_IMAGE: /* Image/UV Editor */
@@ -166,8 +174,9 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
/* for now, Grease Pencil data is associated with the space... */
/* XXX our convention for everything else is to link to data though... */
- if (r_ptr)
+ if (r_ptr) {
RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, r_ptr);
+ }
return &sima->gpd;
}
case SPACE_CLIP: /* Nodes Editor */
@@ -179,16 +188,19 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking);
- if (!track)
+ if (!track) {
return NULL;
+ }
- if (r_ptr)
+ if (r_ptr) {
RNA_pointer_create(&clip->id, &RNA_MovieTrackingTrack, track, r_ptr);
+ }
return &track->gpd;
}
else {
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&clip->id, r_ptr);
+ }
return &clip->gpd;
}
}
@@ -202,7 +214,8 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
return NULL;
}
-/* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it */
+/* Get pointer to active Grease Pencil datablock,
+ * and an RNA-pointer to trace back to whatever owns it. */
bGPdata **ED_gpencil_data_get_pointers(const bContext *C, PointerRNA *r_ptr)
{
ID *screen_id = (ID *)CTX_wm_screen(C);
@@ -251,7 +264,11 @@ bGPdata *ED_gpencil_data_get_active_evaluated(const bContext *C)
Object *ob = CTX_data_active_object(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- /* if (ob && ob->type == OB_GPENCIL) BLI_assert(ob_eval->data == DEG_get_evaluated_id(ob->data)); */
+#if 0
+ if (ob && ob->type == OB_GPENCIL) {
+ BLI_assert(ob_eval->data == DEG_get_evaluated_id(ob->data));
+ }
+#endif
return ED_gpencil_data_get_active_direct(screen_id, sa, scene_eval, ob_eval);
}
@@ -350,10 +367,12 @@ const EnumPropertyItem *ED_gpencil_layers_enum_itemf(bContext *C,
item_tmp.name = gpl->info;
item_tmp.value = i;
- if (gpl->flag & GP_LAYER_ACTIVE)
+ if (gpl->flag & GP_LAYER_ACTIVE) {
item_tmp.icon = ICON_GREASEPENCIL;
- else
+ }
+ else {
item_tmp.icon = ICON_NONE;
+ }
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
@@ -400,10 +419,12 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(bContext *C,
item_tmp.name = gpl->info;
item_tmp.value = tot - i - 1;
- if (gpl->flag & GP_LAYER_ACTIVE)
+ if (gpl->flag & GP_LAYER_ACTIVE) {
item_tmp.icon = ICON_GREASEPENCIL;
- else
+ }
+ else {
item_tmp.icon = ICON_NONE;
+ }
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
@@ -450,8 +471,9 @@ bool gp_stroke_inside_circle(
bool ED_gpencil_stroke_can_use_direct(const ScrArea *sa, const bGPDstroke *gps)
{
/* sanity check */
- if (ELEM(NULL, sa, gps))
+ if (ELEM(NULL, sa, gps)) {
return false;
+ }
/* filter stroke types by flags + spacetype */
if (gps->flag & GP_STROKE_3DSPACE) {
@@ -486,10 +508,12 @@ bool ED_gpencil_stroke_color_use(Object *ob, const bGPDlayer *gpl, const bGPDstr
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
if (gp_style != NULL) {
- if (gp_style->flag & GP_STYLE_COLOR_HIDE)
+ if (gp_style->flag & GP_STYLE_COLOR_HIDE) {
return false;
- if (((gpl->flag & GP_LAYER_UNLOCK_COLOR) == 0) && (gp_style->flag & GP_STYLE_COLOR_LOCKED))
+ }
+ if (((gpl->flag & GP_LAYER_UNLOCK_COLOR) == 0) && (gp_style->flag & GP_STYLE_COLOR_LOCKED)) {
return false;
+ }
}
return true;
@@ -606,7 +630,8 @@ void gp_apply_parent_point(
* \param[out] r_x The screen-space x-coordinate of the point
* \param[out] r_y The screen-space y-coordinate of the point
*
- * \warning This assumes that the caller has already checked whether the stroke in question can be drawn.
+ * \warning This assumes that the caller has already checked
+ * whether the stroke in question can be drawn.
*/
void gp_point_to_xy(
const GP_SpaceConversion *gsc, const bGPDstroke *gps, const bGPDspoint *pt, int *r_x, int *r_y)
@@ -650,15 +675,17 @@ void gp_point_to_xy(
}
/**
- * Convert a Grease Pencil coordinate (i.e. can be 2D or 3D) to screenspace (2D)
+ * Convert a Grease Pencil coordinate (i.e. can be 2D or 3D) to screenspace (2D).
*
* Just like #gp_point_to_xy(), except the resulting coordinates are floats not ints.
- * Use this version to solve "stair-step" artifacts which may arise when roundtripping the calculations.
+ * Use this version to solve "stair-step" artifacts which may arise when
+ * roundtripping the calculations.
*
- * \param r_x: [out] The screen-space x-coordinate of the point.
- * \param r_y: [out] The screen-space y-coordinate of the point.
+ * \param r_x[out]: The screen-space x-coordinate of the point.
+ * \param r_y[out]: The screen-space y-coordinate of the point.
*
- * \warning This assumes that the caller has already checked whether the stroke in question can be drawn.
+ * \warning This assumes that the caller has already checked
+ * whether the stroke in question can be drawn.
*/
void gp_point_to_xy_fl(const GP_SpaceConversion *gsc,
const bGPDstroke *gps,
@@ -1079,7 +1106,9 @@ void ED_gp_project_point_to_plane(const Scene *scene,
/* ******************************************************** */
/* Stroke Operations */
-// XXX: Check if these functions duplicate stuff in blenkernel, and/or whether we should just deduplicate
+
+/* XXX: Check if these functions duplicate stuff in blenkernel,
+ * and/or whether we should just deduplicate. */
/**
* Subdivide a stroke once, by adding a point half way between each pair of existing points
@@ -1259,6 +1288,7 @@ void ED_gpencil_parent_location(const Depsgraph *depsgraph,
else {
if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) {
mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse);
+ add_v3_v3(diff_mat[3], ob_eval->obmat[3]);
return;
}
else if (gpl->partype == PARBONE) {
@@ -1267,10 +1297,12 @@ void ED_gpencil_parent_location(const Depsgraph *depsgraph,
float tmp_mat[4][4];
mul_m4_m4m4(tmp_mat, obparent_eval->obmat, pchan->pose_mat);
mul_m4_m4m4(diff_mat, tmp_mat, gpl->inverse);
+ add_v3_v3(diff_mat[3], ob_eval->obmat[3]);
}
else {
/* if bone not found use object (armature) */
mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse);
+ add_v3_v3(diff_mat[3], ob_eval->obmat[3]);
}
return;
}
@@ -1287,12 +1319,15 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata
int i;
float diff_mat[4][4];
float cur_mat[4][4];
+ float gpl_loc[3];
+ zero_v3(gpl_loc);
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if (gpl->parent != NULL) {
/* calculate new matrix */
if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) {
invert_m4_m4(cur_mat, gpl->parent->obmat);
+ copy_v3_v3(gpl_loc, obact->obmat[3]);
}
else if (gpl->partype == PARBONE) {
bPoseChannel *pchan = BKE_pose_channel_find_name(gpl->parent->pose, gpl->parsubstr);
@@ -1300,6 +1335,7 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata
float tmp_mat[4][4];
mul_m4_m4m4(tmp_mat, gpl->parent->obmat, pchan->pose_mat);
invert_m4_m4(cur_mat, tmp_mat);
+ copy_v3_v3(gpl_loc, obact->obmat[3]);
}
}
@@ -1307,6 +1343,9 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata
if (!equals_m4m4(gpl->inverse, cur_mat)) {
/* first apply current transformation to all strokes */
ED_gpencil_parent_location(depsgraph, obact, gpd, gpl, diff_mat);
+ /* undo local object */
+ sub_v3_v3(diff_mat[3], gpl_loc);
+
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
@@ -1377,8 +1416,9 @@ void ED_gpencil_vgroup_assign(bContext *C, Object *ob, float weight)
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = gpl->actframe;
@@ -1389,14 +1429,16 @@ void ED_gpencil_vgroup_assign(bContext *C, Object *ob, float weight)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
if (gps->flag & GP_STROKE_SELECT) {
/* verify the weight array is created */
@@ -1431,8 +1473,9 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob)
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = gpl->actframe;
@@ -1443,14 +1486,16 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
@@ -1484,8 +1529,9 @@ void ED_gpencil_vgroup_select(bContext *C, Object *ob)
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = gpl->actframe;
@@ -1496,14 +1542,16 @@ void ED_gpencil_vgroup_select(bContext *C, Object *ob)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
@@ -1535,8 +1583,9 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = gpl->actframe;
@@ -1547,14 +1596,16 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
@@ -1638,14 +1689,13 @@ void ED_gpencil_brush_draw_eraser(Brush *brush, int x, int y)
immUniform1f("dash_width", 12.0f);
immUniform1f("dash_factor", 0.5f);
- imm_draw_circle_wire_2d(
- shdr_pos,
- x,
- y,
- radius,
- /* XXX Dashed shader gives bad results with sets of small segments currently,
- * temp hack around the issue. :( */
- max_ii(8, radius / 2)); /* was fixed 40 */
+ imm_draw_circle_wire_2d(shdr_pos,
+ x,
+ y,
+ radius,
+ /* XXX Dashed shader gives bad results with sets of small segments
+ * currently, temp hack around the issue. :( */
+ max_ii(8, radius / 2)); /* was fixed 40 */
immUnbindProgram();
@@ -2463,7 +2513,7 @@ void ED_gpencil_select_toggle_all(bContext *C, int action)
case SEL_SELECT:
pt->flag |= GP_SPOINT_SELECT;
break;
- //case SEL_DESELECT:
+ // case SEL_DESELECT:
// pt->flag &= ~GP_SPOINT_SELECT;
// break;
case SEL_INVERT:
@@ -2471,15 +2521,18 @@ void ED_gpencil_select_toggle_all(bContext *C, int action)
break;
}
- if (pt->flag & GP_SPOINT_SELECT)
+ if (pt->flag & GP_SPOINT_SELECT) {
selected = true;
+ }
}
/* Change status of stroke */
- if (selected)
+ if (selected) {
gps->flag |= GP_STROKE_SELECT;
- else
+ }
+ else {
gps->flag &= ~GP_STROKE_SELECT;
+ }
}
CTX_DATA_END;
}
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index a2e8d6afd4b..7d4b6dbeea2 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -32,35 +32,6 @@ struct ColorManagedViewSettings;
struct ImBuf;
struct bContext;
-/* A few functions defined here are being DEPRECATED for Blender 2.8
- *
- * Do not use them in new code, and you are encouraged to
- * convert existing code to draw without these.
- *
- * These will be deleted before we ship 2.8!
- * - merwin
- */
-
-/**
- * Returns a float value as obtained by glGetFloatv.
- * The param must cause only one value to be gotten from GL.
- */
-float glaGetOneFloat(int param);
-int glaGetOneInt(int param);
-
-/**
- * Functions like glRasterPos2i, except ensures that the resulting
- * raster position is valid. \a known_good_x and \a known_good_y
- * should be coordinates of a point known to be within the current
- * view frustum.
- * \attention This routine should be used when the distance of \a x
- * and \a y away from the known good point is small (ie. for small icons
- * and for bitmap characters), when drawing large+zoomed images it is
- * possible for overflow to occur, the glaDrawPixelsSafe routine should
- * be used instead.
- */
-void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y);
-
typedef struct IMMDrawPixelsTexState {
struct GPUShader *shader;
unsigned int pos;
@@ -148,29 +119,47 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
float yzoom,
float color[4]);
-void set_inverted_drawing(int enable);
-
-/* own working polygon offset */
-float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist);
-void bglPolygonOffset(float viewdist, float dist);
-
-/* **** Color management helper functions for GLSL display/transform ***** */
-
-/* Draw imbuf on a screen, preferably using GLSL display transform */
-void glaDrawImBuf_glsl(struct ImBuf *ibuf,
+/* Image buffer drawing functions, with display transform
+ *
+ * The view and display settings can either be specified manually,
+ * or retrieved from the context with the '_ctx' variations.
+ *
+ * For better performance clipping coordinates can be specified so parts of the
+ * image outside the view are skipped. */
+
+void ED_draw_imbuf(struct ImBuf *ibuf,
+ float x,
+ float y,
+ int zoomfilter,
+ struct ColorManagedViewSettings *view_settings,
+ struct ColorManagedDisplaySettings *display_settings,
+ float zoom_x,
+ float zoom_y);
+void ED_draw_imbuf_clipping(struct ImBuf *ibuf,
+ float x,
+ float y,
+ int zoomfilter,
+ struct ColorManagedViewSettings *view_settings,
+ struct ColorManagedDisplaySettings *display_settings,
+ float clip_min_x,
+ float clip_min_y,
+ float clip_max_x,
+ float clip_max_y,
+ float zoom_x,
+ float zoom_y);
+
+void ED_draw_imbuf_ctx(const struct bContext *C,
+ struct ImBuf *ibuf,
float x,
float y,
int zoomfilter,
- struct ColorManagedViewSettings *view_settings,
- struct ColorManagedDisplaySettings *display_settings,
float zoom_x,
float zoom_y);
-void glaDrawImBuf_glsl_clipping(struct ImBuf *ibuf,
+void ED_draw_imbuf_ctx_clipping(const struct bContext *C,
+ struct ImBuf *ibuf,
float x,
float y,
int zoomfilter,
- struct ColorManagedViewSettings *view_settings,
- struct ColorManagedDisplaySettings *display_settings,
float clip_min_x,
float clip_min_y,
float clip_max_x,
@@ -178,25 +167,16 @@ void glaDrawImBuf_glsl_clipping(struct ImBuf *ibuf,
float zoom_x,
float zoom_y);
-/* Draw imbuf on a screen, preferably using GLSL display transform */
-void glaDrawImBuf_glsl_ctx(const struct bContext *C,
- struct ImBuf *ibuf,
- float x,
- float y,
- int zoomfilter,
- float zoom_x,
- float zoom_y);
-void glaDrawImBuf_glsl_ctx_clipping(const struct bContext *C,
- struct ImBuf *ibuf,
- float x,
- float y,
- int zoomfilter,
- float clip_min_x,
- float clip_min_y,
- float clip_max_x,
- float clip_max_y,
- float zoom_x,
- float zoom_y);
+int ED_draw_imbuf_method(struct ImBuf *ibuf);
+
+/* OpenGL drawing utility functions. Do not use these in new code, these
+ * are intended to be moved or removed in the future. */
+
+void set_inverted_drawing(int enable);
+
+/* own working polygon offset */
+float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist);
+void bglPolygonOffset(float viewdist, float dist);
void immDrawBorderCorners(unsigned int pos, const struct rcti *border, float zoomx, float zoomy);
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 3a9539ee52c..d947322f708 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -276,7 +276,8 @@ typedef enum eAnim_Update_Flags {
typedef enum eAnimFilter_Flags {
/** data which channel represents is fits the dopesheet filters
* (i.e. scene visibility criteria) */
- // XXX: it's hard to think of any examples where this *ISN'T* the case... perhaps becomes implicit?
+ /* XXX: it's hard to think of any examples where this *ISN'T* the case...
+ * perhaps becomes implicit?. */
ANIMFILTER_DATA_VISIBLE = (1 << 0),
/** channel is visible within the channel-list hierarchy
* (i.e. F-Curves within Groups in ActEdit) */
@@ -611,6 +612,9 @@ void ANIM_set_active_channel(bAnimContext *ac,
* as appropriate according to animation context */
void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, struct AnimData *adt, struct FCurve *fcu);
+/* Unlink the action from animdata if it's empty. */
+bool ANIM_remove_empty_action_from_animdata(struct AnimData *adt);
+
/* ************************************************ */
/* DRAWING API */
/* anim_draw.c */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 9fb8f1b1b04..3eb277ad776 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -82,10 +82,11 @@ typedef struct EditBone {
/* Bendy-Bone parameters */
float roll1, roll2;
- float curveOutX, curveOutY;
- float curveInX, curveInY;
+ float curve_in_x, curve_in_y;
+ float curve_out_x, curve_out_y;
float ease1, ease2;
- float scaleIn, scaleOut;
+ float scale_in_x, scale_in_y;
+ float scale_out_x, scale_out_y;
/** for envelope scaling */
float oldlength;
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index ac998cbcb71..6af8197aa8f 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -268,7 +268,7 @@ void ED_gpencil_update_color_uv(struct Main *bmain, struct Material *mat);
* 1 - Hit in point A
* 2 - Hit in point B
* 3 - Hit in point A and B
-*/
+ */
int ED_gpencil_select_stroke_segment(struct bGPDlayer *gpl,
struct bGPDstroke *gps,
struct bGPDspoint *pt,
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index ba5a6a8a339..5bd806b3dbf 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -71,9 +71,6 @@ void ED_space_image_scopes_update(const struct bContext *C,
void ED_space_image_paint_update(struct Main *bmain,
struct wmWindowManager *wm,
struct Scene *scene);
-void ED_space_image_uv_sculpt_update(struct Main *bmain,
- struct wmWindowManager *wm,
- struct Scene *scene);
void ED_image_get_uv_aspect(struct Image *ima, struct ImageUser *iuser, float *aspx, float *aspy);
void ED_image_mouse_pos(struct SpaceImage *sima,
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 54570938de1..a893f03bd88 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -143,8 +143,8 @@ short insert_keyframe(struct Main *bmain,
eInsertKeyFlags flag);
/* Main Keyframing API call:
- * Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case.
- */
+ * Use this to delete keyframe on current frame for relevant channel.
+ * Will perform checks just in case. */
short delete_keyframe(struct Main *bmain,
struct ReportList *reports,
struct ID *id,
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index dcac5301da5..ce8521a1f6a 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -358,7 +358,10 @@ float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vert
void ED_vgroup_vert_active_mirror(struct Object *ob, int def_nr);
/* mesh_data.c */
-// void ED_mesh_geometry_add(struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces);
+#if 0
+void ED_mesh_geometry_add(
+ struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces);
+#endif
void ED_mesh_polys_add(struct Mesh *mesh, struct ReportList *reports, int count);
void ED_mesh_tessfaces_add(struct Mesh *mesh, struct ReportList *reports, int count);
void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int count);
diff --git a/source/blender/editors/include/ED_numinput.h b/source/blender/editors/include/ED_numinput.h
index 697a236341f..b13f228b1ec 100644
--- a/source/blender/editors/include/ED_numinput.h
+++ b/source/blender/editors/include/ED_numinput.h
@@ -78,12 +78,16 @@ struct UnitSettings;
/**
* There are important things to note here for code using numinput:
- * - Values passed to #applyNumInput() should be valid and are stored as default ones (val_org), if it is not EDITED.
- * - bool returned by #applyNumInput should be used to decide whether to apply numinput-specific post-process to data.
- * - Once #applyNumInput has been called, #hasNumInput returns a valid value to decide whether to use numinput
- * as drawstr source or not (i.e. to call #outputNumInput).
+ * - Values passed to #applyNumInput() should be valid and are stored as default ones (val_org),
+ * if it is not EDITED.
+ * - bool returned by #applyNumInput should be used to decide whether to apply
+ * numinput-specific post-process to data.
+ * - Once #applyNumInput has been called,
+ * #hasNumInput returns a valid value to decide whether to use numinput as drawstr source or not
+ * (i.e. to call #outputNumInput).
*
- * Those two steps have to be separated (so do not use a common call to #hasNumInput() to do both in the same time!).
+ * Those two steps have to be separated
+ * (so do not use a common call to #hasNumInput() to do both in the same time!).
*/
void initNumInput(NumInput *n);
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index bcf9cb3fcc0..543b2a5781f 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -100,7 +100,14 @@ void ED_region_header_draw(const struct bContext *C, struct ARegion *ar);
void ED_region_cursor_set(struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar);
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
-void ED_region_visibility_change_update(struct bContext *C, struct ARegion *ar);
+void ED_region_visibility_change_update(struct bContext *C,
+ struct ScrArea *sa,
+ struct ARegion *ar);
+/* screen_ops.c */
+void ED_region_visibility_change_update_animated(struct bContext *C,
+ struct ScrArea *sa,
+ struct ARegion *ar);
+
void ED_region_info_draw(struct ARegion *ar,
const char *text,
float fill_color[4],
@@ -128,6 +135,14 @@ void ED_area_do_msg_notify_tag_refresh(struct bContext *C,
struct wmMsgSubscribeKey *msg_key,
struct wmMsgSubscribeValue *msg_val);
+void ED_area_do_mgs_subscribe_for_tool_header(const struct bContext *C,
+ struct WorkSpace *workspace,
+ struct Scene *scene,
+ struct bScreen *screen,
+ struct ScrArea *sa,
+ struct ARegion *ar,
+ struct wmMsgBus *mbus);
+
/* message bus */
void ED_region_message_subscribe(struct bContext *C,
struct WorkSpace *workspace,
@@ -388,6 +403,21 @@ void ED_region_generic_tools_region_message_subscribe(const struct bContext *C,
struct wmMsgBus *mbus);
int ED_region_generic_tools_region_snap_size(const struct ARegion *ar, int size, int axis);
+/* area_query.c */
+bool ED_region_overlap_isect_x(const ARegion *ar, const int event_x);
+bool ED_region_overlap_isect_y(const ARegion *ar, const int event_y);
+bool ED_region_overlap_isect_xy(const ARegion *ar, const int event_xy[2]);
+bool ED_region_overlap_isect_x_with_margin(const ARegion *ar, const int event_x, const int margin);
+bool ED_region_overlap_isect_y_with_margin(const ARegion *ar, const int event_y, const int margin);
+bool ED_region_overlap_isect_xy_with_margin(const ARegion *ar,
+ const int event_xy[2],
+ const int margin);
+
+bool ED_region_panel_category_gutter_calc_rect(const ARegion *ar, rcti *r_ar_gutter);
+bool ED_region_panel_category_gutter_isect_xy(const ARegion *ar, const int event_xy[2]);
+
+bool ED_region_contains_xy(const struct ARegion *ar, const int event_xy[2]);
+
/* interface_region_hud.c */
struct ARegionType *ED_area_type_hud(int space_type);
void ED_area_type_hud_clear(struct wmWindowManager *wm, ScrArea *sa_keep);
diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h
index 3cbeab247ef..c515d501a8d 100644
--- a/source/blender/editors/include/ED_screen_types.h
+++ b/source/blender/editors/include/ED_screen_types.h
@@ -108,15 +108,29 @@ typedef struct AZone {
float alpha;
} AZone;
-/* actionzone type */
+/** Action-Zone Type: #AZone.type */
enum {
- /* corner widgets for splitting areas */
+ /**
+ * Corner widgets for:
+ * - Splitting areas.
+ * - Swapping areas (Ctrl).
+ * - Copying the area into a new window (Shift).
+ */
AZONE_AREA = 1,
- /* when a region is collapsed, draw a handle to expose */
+ /**
+ * Use for region show/hide state:
+ * - When a region is collapsed, draw a handle to expose.
+ * - When a region is expanded, use the action zone to resize the region.
+ */
AZONE_REGION,
- /* when in editor fullscreen draw a corner to go to normal mode */
+ /**
+ * Used when in editor fullscreen draw a corner to return to normal mode.
+ */
AZONE_FULLSCREEN,
- /* Hotspot azone around scrollbars to show/hide them. */
+ /**
+ * Hotspot azone around scroll-bars to show/hide them.
+ * Only show the scroll-bars when the cursor is close.
+ */
AZONE_REGION_SCROLL,
};
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index 01de5fd8441..766f2b31192 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -62,6 +62,7 @@ void ED_file_exit(void);
#define REGION_DRAW_POST_VIEW 0
#define REGION_DRAW_POST_PIXEL 1
#define REGION_DRAW_PRE_VIEW 2
+#define REGION_DRAW_BACKDROP 3
void *ED_region_draw_cb_activate(struct ARegionType *,
void (*draw)(const struct bContext *, struct ARegion *, void *),
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h
index 9259afd1d5f..8dd2dab5209 100644
--- a/source/blender/editors/include/ED_uvedit.h
+++ b/source/blender/editors/include/ED_uvedit.h
@@ -178,7 +178,6 @@ void ED_uvedit_add_simple_uvs(struct Main *bmain, struct Scene *scene, struct Ob
/* uvedit_draw.c */
void ED_image_draw_cursor(struct ARegion *ar, const float cursor[2]);
void ED_uvedit_draw_main(struct SpaceImage *sima,
- struct ARegion *ar,
struct Scene *scene,
struct ViewLayer *view_layer,
struct Object *obedit,
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index e747dda95d4..fd51419a3ee 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -54,6 +54,7 @@ struct RenderEngineType;
struct Scene;
struct ScrArea;
struct View3D;
+struct View3DShading;
struct ViewContext;
struct ViewLayer;
struct WorkSpace;
@@ -524,8 +525,6 @@ void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc);
void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact);
void view3d_operator_needs_opengl(const struct bContext *C);
void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar);
-void view3d_opengl_read_pixels(
- struct ARegion *ar, int x, int y, int w, int h, int format, int type, void *data);
/* XXX should move to BLI_math */
bool edge_inside_circle(const float cent[2],
@@ -586,16 +585,6 @@ void ED_view3d_draw_setup_view(struct wmWindow *win,
float winmat[4][4],
const struct rcti *rect);
-enum {
- V3D_OFSDRAW_NONE = (0),
-
- V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 0),
-
- /* Only works with ED_view3d_draw_offscreen_imbuf_simple(). */
- V3D_OFSDRAW_USE_GPENCIL = (1 << 1),
- V3D_OFSDRAW_USE_CAMERA_DOF = (1 << 2),
-};
-
struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph,
struct Scene *scene,
int drawtype,
@@ -612,6 +601,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph,
char err_out[256]);
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Depsgraph *depsgraph,
struct Scene *scene,
+ struct View3DShading *shading_override,
int drawtype,
struct Object *camera,
int width,
@@ -707,7 +697,10 @@ void ED_scene_draw_fps(struct Scene *scene, int xoffset, int *yoffset);
#if 0
void ED_view3d_operator_properties_viewmat(struct wmOperatorType *ot);
void ED_view3d_operator_properties_viewmat_set(struct bContext *C, struct wmOperator *op);
-void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op, int *winx, int *winy, float persmat[4][4]);
+void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op,
+ int *winx,
+ int *winy,
+ float persmat[4][4]);
#endif
/* render */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d3cce4a5dde..18960853011 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -86,6 +86,14 @@ typedef struct uiPopupBlockHandle uiPopupBlockHandle;
#define UI_MAX_NAME_STR 128
#define UI_MAX_SHORTCUT_STR 64
+/**
+ * For #ARegion.overlap regions, pass events though if they don't overlap
+ * the regions contents (the usable part of the #View2D and buttons).
+ *
+ * The margin is needed so it's not possible to accidentally click inbetween buttons.
+ */
+#define UI_REGION_OVERLAP_MARGIN (U.widget_unit / 3)
+
/* use for clamping popups within the screen */
#define UI_SCREEN_MARGIN 10
@@ -416,8 +424,16 @@ void UI_draw_roundbox_shade_x(bool filled,
const float col[4]);
#if 0 /* unused */
-int UI_draw_roundbox_corner_get(void);
-void UI_draw_roundbox_shade_y(bool filled, float minx, float miny, float maxx, float maxy, float rad, float shadeleft, float shaderight, const float col[4]);
+int UI_draw_roundbox_corner_get(void);
+void UI_draw_roundbox_shade_y(bool filled,
+ float minx,
+ float miny,
+ float maxx,
+ float maxy,
+ float rad,
+ float shadeleft,
+ float shaderight,
+ const float col[4]);
#endif
void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
@@ -504,6 +520,7 @@ bool UI_but_is_tool(const uiBut *but);
#define UI_but_is_decorator(but) ((but)->func == ui_but_anim_decorate_cb)
bool UI_block_is_empty(const uiBlock *block);
+bool UI_block_can_add_separator(const uiBlock *block);
/* interface_region_menu_popup.c */
/**
@@ -587,7 +604,10 @@ void UI_popup_block_ex(struct bContext *C,
void *arg,
struct wmOperator *op);
#if 0 /* UNUSED */
-void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext);
+void uiPupBlockOperator(struct bContext *C,
+ uiBlockCreateFunc func,
+ struct wmOperator *op,
+ int opcontext);
#endif
void UI_popup_block_close(struct bContext *C, struct wmWindow *win, uiBlock *block);
@@ -1603,7 +1623,7 @@ void UI_panels_scale(struct ARegion *ar, float new_width);
void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y);
int UI_panel_size_y(const struct Panel *pa);
-bool UI_panel_category_is_visible(struct ARegion *ar);
+bool UI_panel_category_is_visible(const struct ARegion *ar);
void UI_panel_category_add(struct ARegion *ar, const char *name);
struct PanelCategoryDyn *UI_panel_category_find(struct ARegion *ar, const char *idname);
struct PanelCategoryStack *UI_panel_category_active_find(struct ARegion *ar, const char *idname);
@@ -2291,6 +2311,7 @@ void UI_context_active_but_prop_get_templateID(struct bContext *C,
struct ID *UI_context_active_but_get_tab_ID(struct bContext *C);
uiBut *UI_region_active_but_get(struct ARegion *ar);
+uiBut *UI_region_but_find_rect_over(const struct ARegion *ar, const struct rcti *isect);
/* uiFontStyle.align */
typedef enum eFontStyle_Align {
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 1fc1fba4b4a..af94889a1bb 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -92,6 +92,7 @@ typedef enum ThemeColorID {
TH_VERTEX_UNREFERENCED,
TH_VERTEX_SIZE,
TH_OUTLINE_WIDTH,
+ TH_OBCENTER_DIA,
TH_EDGE,
TH_EDGE_SELECT,
TH_EDGE_SEAM,
@@ -341,7 +342,8 @@ void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3]);
void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3]);
void UI_GetThemeColorShade4ubv(int colorid, int offset, unsigned char col[4]);
-// get three color values, range 0-255, complete with shading offset for the RGB components and blending
+// get three color values, range 0-255,
+// complete with shading offset for the RGB components and blending.
void UI_GetThemeColorBlendShade3ubv(
int colorid1, int colorid2, float fac, int offset, unsigned char col[3]);
@@ -355,13 +357,14 @@ void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4]);
void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]);
void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]);
-// get four colour values ranged between 0 and 255; includes the alpha channel
+// get four color values ranged between 0 and 255; includes the alpha channel
void UI_GetThemeColorShadeAlpha4ubv(int colorid,
int coloffset,
int alphaoffset,
unsigned char col[4]);
-// get four color values, range 0.0-1.0, complete with shading offset for the RGB components and blending
+// get four color values, range 0.0-1.0,
+// complete with shading offset for the RGB components and blending.
void UI_GetThemeColorBlendShade3fv(
int colorid1, int colorid2, float fac, int offset, float col[3]);
void UI_GetThemeColorBlendShade4fv(
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index fde865d4bba..07dbb49ac07 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -56,40 +56,7 @@ enum eView2D_CommonViewTypes {
V2D_COMMONVIEW_PANELS_UI,
};
-/* ---- Defines for Scroller/Grid Arguments ----- */
-
-/* 'dummy' argument to pass when argument is irrelevant */
-#define V2D_ARG_DUMMY -1
-
-/* Grid units */
-enum eView2D_Units {
- /* for drawing time */
- V2D_UNIT_SECONDS = 0,
- V2D_UNIT_FRAMES,
- V2D_UNIT_FRAMESCALE,
-
- /* for drawing values */
- V2D_UNIT_VALUES,
-};
-
-/* clamping of grid values to whole numbers */
-enum eView2D_Clamp {
- V2D_GRID_NOCLAMP = 0,
- V2D_GRID_CLAMP,
-};
-
-/* flags for grid-lines to draw */
-enum eView2D_Gridlines {
- V2D_HORIZONTAL_LINES = (1 << 0),
- V2D_VERTICAL_LINES = (1 << 1),
- V2D_HORIZONTAL_AXIS = (1 << 2),
- V2D_VERTICAL_AXIS = (1 << 3),
- V2D_HORIZONTAL_FINELINES = (1 << 4),
-
- V2D_GRIDLINES_MAJOR = (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS | V2D_HORIZONTAL_LINES |
- V2D_HORIZONTAL_AXIS),
- V2D_GRIDLINES_ALL = (V2D_GRIDLINES_MAJOR | V2D_HORIZONTAL_FINELINES),
-};
+/* ---- Defines for Scroller Arguments ----- */
/* ------ Defines for Scrollers ----- */
@@ -117,11 +84,13 @@ enum eView2D_Gridlines {
#define IN_2D_VERT_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->vert, co))
#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->hor, co))
+#define IN_2D_VERT_SCROLL_RECT(v2d, rct) (BLI_rcti_isect(&v2d->vert, rct, NULL))
+#define IN_2D_HORIZ_SCROLL_RECT(v2d, rct) (BLI_rcti_isect(&v2d->hor, rct, NULL))
+
/* ------------------------------------------ */
/* Type definitions: */
struct View2D;
-struct View2DGrid;
struct View2DScrollers;
struct ARegion;
@@ -132,7 +101,6 @@ struct bScreen;
struct rctf;
struct wmKeyConfig;
-typedef struct View2DGrid View2DGrid;
typedef struct View2DScrollers View2DScrollers;
/* ----------------------------------------- */
@@ -156,49 +124,62 @@ bool UI_view2d_tab_set(struct View2D *v2d, int tab);
void UI_view2d_zoom_cache_reset(void);
/* view matrix operations */
-void UI_view2d_view_ortho(struct View2D *v2d);
+void UI_view2d_view_ortho(const struct View2D *v2d);
void UI_view2d_view_orthoSpecial(struct ARegion *ar, struct View2D *v2d, const bool xaxis);
void UI_view2d_view_restore(const struct bContext *C);
/* grid drawing */
-View2DGrid *UI_view2d_grid_calc(struct Scene *scene,
- struct View2D *v2d,
- short xunits,
- short xclamp,
- short yunits,
- short yclamp,
- int winx,
- int winy);
-void UI_view2d_grid_draw(struct View2D *v2d, View2DGrid *grid, int flag);
void UI_view2d_constant_grid_draw(struct View2D *v2d, float step);
void UI_view2d_multi_grid_draw(
struct View2D *v2d, int colorid, float step, int level_size, int totlevels);
-void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy);
-void UI_view2d_grid_draw_numbers_horizontal(const struct Scene *scene,
- const struct View2D *v2d,
- const View2DGrid *grid,
- const struct rcti *rect,
- int unit,
- bool whole_numbers_only);
-void UI_view2d_grid_draw_numbers_vertical(const struct Scene *scene,
- const struct View2D *v2d,
- const View2DGrid *grid,
- const struct rcti *rect,
- int unit,
- float text_offset);
-void UI_view2d_grid_free(View2DGrid *grid);
+
+void UI_view2d_draw_lines_y__values(const struct View2D *v2d);
+void UI_view2d_draw_lines_x__values(const struct View2D *v2d);
+void UI_view2d_draw_lines_x__discrete_values(const struct View2D *v2d);
+void UI_view2d_draw_lines_x__discrete_time(const struct View2D *v2d, const struct Scene *scene);
+void UI_view2d_draw_lines_x__discrete_frames_or_seconds(const struct View2D *v2d,
+ const struct Scene *scene,
+ bool display_seconds);
+void UI_view2d_draw_lines_x__frames_or_seconds(const struct View2D *v2d,
+ const struct Scene *scene,
+ bool display_seconds);
+
+float UI_view2d_grid_resolution_x__frames_or_seconds(const struct View2D *v2d,
+ const struct Scene *scene,
+ bool display_seconds);
+float UI_view2d_grid_resolution_y__values(const struct View2D *v2d);
+
+/* scale indicator text drawing */
+void UI_view2d_draw_scale_y__values(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect);
+void UI_view2d_draw_scale_y__block(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect);
+void UI_view2d_draw_scale_x__values(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect);
+void UI_view2d_draw_scale_x__discrete_values(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect);
+void UI_view2d_draw_scale_x__discrete_time(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ const struct Scene *scene);
+void UI_view2d_draw_scale_x__discrete_frames_or_seconds(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ const struct Scene *scene,
+ bool display_seconds);
+void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ const struct Scene *scene,
+ bool display_seconds);
/* scrollbar drawing */
-View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C,
- struct View2D *v2d,
- const struct rcti *mask_custom,
- short xunits,
- short xclamp,
- short yunits,
- short yclamp);
-void UI_view2d_scrollers_draw(const struct bContext *C,
- struct View2D *v2d,
- View2DScrollers *scrollers);
+View2DScrollers *UI_view2d_scrollers_calc(struct View2D *v2d, const struct rcti *mask_custom);
+void UI_view2d_scrollers_draw(struct View2D *v2d, View2DScrollers *scrollers);
void UI_view2d_scrollers_free(View2DScrollers *scrollers);
/* list view tools */
@@ -275,6 +256,13 @@ char UI_view2d_mouse_in_scrollers(const struct ARegion *ar,
const struct View2D *v2d,
int x,
int y);
+char UI_view2d_rect_in_scrollers_ex(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ int *r_scroll);
+char UI_view2d_rect_in_scrollers(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect);
/* cached text drawing in v2d, to allow pixel-aligned draw as post process */
void UI_view2d_text_cache_add(
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index 622f89b1f87..6ab1761e7f8 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -30,8 +30,8 @@ set(INC
../../makesrna
../../python
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
@@ -72,6 +72,7 @@ set(SRC
interface_widgets.c
resources.c
view2d.c
+ view2d_draw.c
view2d_ops.c
interface_eyedropper_intern.h
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 06b0634f6fb..42f4b4495c3 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -213,6 +213,16 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y
}
}
+void ui_window_to_block_rctf(const struct ARegion *ar,
+ uiBlock *block,
+ rctf *rct_dst,
+ const rctf *rct_src)
+{
+ *rct_dst = *rct_src;
+ ui_window_to_block_fl(ar, block, &rct_dst->xmin, &rct_dst->ymin);
+ ui_window_to_block_fl(ar, block, &rct_dst->xmax, &rct_dst->ymax);
+}
+
void ui_window_to_block(const ARegion *ar, uiBlock *block, int *x, int *y)
{
float fx, fy;
@@ -232,6 +242,14 @@ void ui_window_to_region(const ARegion *ar, int *x, int *y)
*y -= ar->winrct.ymin;
}
+void ui_window_to_region_rcti(const ARegion *ar, rcti *rect_dst, const rcti *rct_src)
+{
+ rect_dst->xmin = rct_src->xmin - ar->winrct.xmin;
+ rect_dst->xmax = rct_src->xmax - ar->winrct.xmin;
+ rect_dst->ymin = rct_src->ymin - ar->winrct.ymin;
+ rect_dst->ymax = rct_src->ymax - ar->winrct.ymin;
+}
+
void ui_region_to_window(const ARegion *ar, int *x, int *y)
{
*x += ar->winrct.xmin;
@@ -1274,16 +1292,17 @@ static bool ui_but_event_property_operator_string(const bContext *C,
#if 0
else {
printf("ERROR in %s(): Couldn't get path for scene property - %s\n",
- __func__, RNA_property_identifier(prop));
+ __func__,
+ RNA_property_identifier(prop));
}
#endif
}
}
else {
- //puts("other id");
+ // puts("other id");
}
- //printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(prop), data_path);
+ // printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(prop), data_path);
}
/* we have a datapath! */
@@ -1374,14 +1393,16 @@ static bool ui_but_event_property_operator_string(const bContext *C,
*
* --Matt 07/2006
*/
-const char ui_radial_dir_order[8] = {UI_RADIAL_W,
- UI_RADIAL_E,
- UI_RADIAL_S,
- UI_RADIAL_N,
- UI_RADIAL_NW,
- UI_RADIAL_NE,
- UI_RADIAL_SW,
- UI_RADIAL_SE};
+const char ui_radial_dir_order[8] = {
+ UI_RADIAL_W,
+ UI_RADIAL_E,
+ UI_RADIAL_S,
+ UI_RADIAL_N,
+ UI_RADIAL_NW,
+ UI_RADIAL_NE,
+ UI_RADIAL_SW,
+ UI_RADIAL_SE,
+};
const char ui_radial_dir_to_numpad[8] = {8, 9, 6, 3, 2, 1, 4, 7};
const short ui_radial_dir_to_angle[8] = {90, 45, 0, 315, 270, 225, 180, 135};
@@ -1594,7 +1615,7 @@ void ui_fontscale(short *points, float aspect)
/* for some reason scaling fonts goes too fast compared to widget size */
/* XXX not true anymore? (ton) */
- //aspect = sqrt(aspect);
+ // aspect = sqrt(aspect);
pointsf /= aspect;
if (aspect > 1.0f) {
@@ -2421,8 +2442,10 @@ static float ui_get_but_step_unit(uiBut *but, float step_default)
}
/**
- * \param float_precision: For number buttons the precision to use or -1 to fallback to the button default.
- * \param use_exp_float: Use exponent representation of floats when out of reasonable range (outside of 1e3/1e-3).
+ * \param float_precision: For number buttons the precision
+ * to use or -1 to fallback to the button default.
+ * \param use_exp_float: Use exponent representation of floats
+ * when out of reasonable range (outside of 1e3/1e-3).
*/
void ui_but_string_get_ex(uiBut *but,
char *str,
@@ -2751,10 +2774,10 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
/* This is kind of hackish, in theory think we could only ever use the second member of
* this if/else, since ui_searchbox_apply() is supposed to always set that pointer when
- * we are storing pointers... But keeping str search first for now, to try to break as little as
- * possible existing code. All this is band-aids anyway.
- * Fact remains, using editstr as main 'reference' over whole search button thingy is utterly weak
- * and should be redesigned imho, but that's not a simple task. */
+ * we are storing pointers... But keeping str search first for now,
+ * to try to break as little as possible existing code. All this is band-aids anyway.
+ * Fact remains, using editstr as main 'reference' over whole search button thingy
+ * is utterly weak and should be redesigned imho, but that's not a simple task. */
if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) {
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
}
@@ -6183,9 +6206,9 @@ static void operator_enum_call_cb(struct bContext *UNUSED(C), void *but, void *a
if (ot->prop) {
RNA_property_enum_set(opptr, ot->prop, POINTER_AS_INT(arg2));
/* We do not call op from here, will be called by button code.
- * ui_apply_but_funcs_after() (in interface_handlers.c) called this func before checking operators,
- * because one of its parameters is the button itself!
- */
+ * ui_apply_but_funcs_after() (in interface_handlers.c)
+ * called this func before checking operators,
+ * because one of its parameters is the button itself! */
}
else {
printf("%s: op->prop for '%s' is NULL\n", __func__, ot->idname);
@@ -6194,8 +6217,8 @@ static void operator_enum_call_cb(struct bContext *UNUSED(C), void *but, void *a
}
/**
- * Same parameters as for uiDefSearchBut, with additional operator type and properties, used by callback
- * to call again the right op with the right options (properties values).
+ * Same parameters as for uiDefSearchBut, with additional operator type and properties,
+ * used by callback to call again the right op with the right options (properties values).
*/
uiBut *uiDefSearchButO_ptr(uiBlock *block,
wmOperatorType *ot,
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c
index 61f9005ce44..be02def1693 100644
--- a/source/blender/editors/interface/interface_align.c
+++ b/source/blender/editors/interface/interface_align.c
@@ -139,10 +139,11 @@ int ui_but_align_opposite_to_area_align_get(const ARegion *ar)
}
/**
- * This function checks a pair of buttons (assumed in a same align group), and if they are neighbors,
- * set needed data accordingly.
+ * This function checks a pair of buttons (assumed in a same align group),
+ * and if they are neighbors, set needed data accordingly.
*
- * \note It is designed to be called in total random order of buttons. Order-based optimizations are done by caller.
+ * \note It is designed to be called in total random order of buttons.
+ * Order-based optimizations are done by caller.
*/
static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other)
{
@@ -268,13 +269,15 @@ static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other
* +-----------+
* </pre>
*
- * Here, BUT 3 RIGHT side would not get 'dragged' to align with BUT 1 RIGHT side, since BUT 3 has not RIGHT neighbor.
- * So, this function, when called with BUT 1, will 'walk' the whole column in \a side_s1 direction (TOP or DOWN when
- * called for RIGHT side), and force buttons like BUT 3 to align as needed, if BUT 1 and BUT 3 were detected as needing
- * top-right corner stitching in #block_align_proximity_compute() step.
+ * Here, BUT 3 RIGHT side would not get 'dragged' to align with BUT 1 RIGHT side,
+ * since BUT 3 has not RIGHT neighbor.
+ * So, this function, when called with BUT 1, will 'walk' the whole column in \a side_s1 direction
+ * (TOP or DOWN when called for RIGHT side), and force buttons like BUT 3 to align as needed,
+ * if BUT 1 and BUT 3 were detected as needing top-right corner stitching in
+ * #block_align_proximity_compute() step.
*
- * \note To avoid doing this twice, some stitching flags are cleared to break the 'stitching connection'
- * between neighbors.
+ * \note To avoid doing this twice, some stitching flags are cleared to break the
+ * 'stitching connection' between neighbors.
*/
static void block_align_stitch_neighbors(ButAlign *butal,
const int side,
@@ -290,16 +293,17 @@ static void block_align_stitch_neighbors(ButAlign *butal,
const int stitch_s1 = STITCH(side_s1);
const int stitch_s2 = STITCH(side_s2);
- /* We have to check stitching flags on both sides of the stitching, since we only clear one of them flags to break
- * any future loop on same 'columns/side' case.
- * Also, if butal is spanning over several rows or columns of neighbors, it may have both of its stitching flags
+ /* We have to check stitching flags on both sides of the stitching,
+ * since we only clear one of them flags to break any future loop on same 'columns/side' case.
+ * Also, if butal is spanning over several rows or columns of neighbors,
+ * it may have both of its stitching flags
* set, but would not be the case of its immediate neighbor! */
while ((butal->flags[side] & stitch_s1) && (butal = butal->neighbors[side_s1]) &&
(butal->flags[side] & stitch_s2)) {
butal_neighbor = butal->neighbors[side];
- /* If we actually do have a neighbor, we directly set its values accordingly, and clear its matching 'dist'
- * to prevent it being set again later... */
+ /* If we actually do have a neighbor, we directly set its values accordingly,
+ * and clear its matching 'dist' to prevent it being set again later... */
if (butal_neighbor) {
butal->but->drawflag |= align;
butal_neighbor->but->drawflag |= align_opp;
@@ -389,7 +393,8 @@ static void ui_block_align_but_to_region(uiBut *but, const ARegion *region)
/**
* Compute the alignment of all 'align groups' of buttons in given block.
*
- * This is using an order-independent algorithm, i.e. alignment of buttons should be OK regardless of order in which
+ * This is using an order-independent algorithm,
+ * i.e. alignment of buttons should be OK regardless of order in which
* they are added to the block.
*/
void ui_block_align_calc(uiBlock *block, const ARegion *region)
@@ -404,7 +409,8 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region)
int side;
int i, j;
- /* First loop: we count number of buttons belonging to an align group, and clear their align flag.
+ /* First loop: we count number of buttons belonging to an align group,
+ * and clear their align flag.
* Tabs get some special treatment here, they get aligned to region border. */
for (but = block->buttons.first; but; but = but->next) {
/* special case: tabs need to be aligned to a region border, drawflag tells which one */
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index afa1b5c87e1..748d6e6c183 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -148,7 +148,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
if (prop) {
prop = IDP_CopyProperty(prop);
}
- WM_keymap_properties_reset(kmi, prop);
+ WM_keymap_item_properties_reset(kmi, prop);
/* update and get pointers again */
WM_keyconfig_update(wm);
@@ -655,12 +655,16 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
#if 0 /* Disabled for now. */
ot = WM_operatortype_find("UI_OT_override_type_set_button", false);
uiItemFullO_ptr(
- layout, ot, "Overrides Type", ICON_NONE,
- NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
+ layout, ot, "Overrides Type", ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
RNA_boolean_set(&op_ptr, "all", true);
- uiItemFullO_ptr(
- layout, ot, "Single Override Type", ICON_NONE,
- NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
+ uiItemFullO_ptr(layout,
+ ot,
+ "Single Override Type",
+ ICON_NONE,
+ NULL,
+ WM_OP_INVOKE_DEFAULT,
+ 0,
+ &op_ptr);
RNA_boolean_set(&op_ptr, "all", false);
#endif
uiItemBooleanO(layout,
@@ -678,9 +682,14 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
}
else {
#if 0 /* Disabled for now. */
- uiItemFullO(
- layout, "UI_OT_override_type_set_button", "Override Type", ICON_NONE,
- NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
+ uiItemFullO(layout,
+ "UI_OT_override_type_set_button",
+ "Override Type",
+ ICON_NONE,
+ NULL,
+ WM_OP_INVOKE_DEFAULT,
+ 0,
+ &op_ptr);
RNA_boolean_set(&op_ptr, "all", false);
#endif
uiItemBooleanO(layout,
@@ -896,9 +905,15 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
if (kmi) {
if (ISKEYBOARD(kmi->type)) {
#if 0 /* would rather use a block but, but gets weirdly positioned... */
- uiDefBlockBut(
- block, menu_change_shortcut, but, "Change Shortcut",
- 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, "");
+ uiDefBlockBut(block,
+ menu_change_shortcut,
+ but,
+ "Change Shortcut",
+ 0,
+ 0,
+ uiLayoutGetWidth(layout),
+ UI_UNIT_Y,
+ "");
#endif
but2 = uiDefIconTextBut(block,
@@ -1005,9 +1020,14 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
/* XXX inactive option, not for public! */
#if 0
- uiItemFullO(
- layout, "WM_OT_doc_edit", "Submit Description", ICON_NONE,
- NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr_props);
+ uiItemFullO(layout,
+ "WM_OT_doc_edit",
+ "Submit Description",
+ ICON_NONE,
+ NULL,
+ WM_OP_INVOKE_DEFAULT,
+ 0,
+ &ptr_props);
RNA_string_set(&ptr_props, "doc_id", buf);
RNA_string_set(&ptr_props, "doc_new", RNA_property_description(but->rnaprop));
#endif
@@ -1044,7 +1064,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
if (!ar) {
/* skip */
}
- else if (ar->regiontype == RGN_TYPE_HEADER) {
+ else if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL);
}
else if (ar->regiontype == RGN_TYPE_NAV_BAR) {
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 0517278a149..640d5127446 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -167,8 +167,13 @@ void UI_draw_roundbox_4fv(
{
#if 0
float vec[7][2] = {
- {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
- {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805},
+ {0.195, 0.02},
+ {0.383, 0.067},
+ {0.55, 0.169},
+ {0.707, 0.293},
+ {0.831, 0.45},
+ {0.924, 0.617},
+ {0.98, 0.805},
};
int a;
@@ -270,13 +275,16 @@ void UI_draw_roundbox_4fv(
}
#if 0
-static void round_box_shade_col(uint attr, const float col1[3], float const col2[3], const float fac)
+static void round_box_shade_col(uint attr,
+ const float col1[3],
+ float const col2[3],
+ const float fac)
{
float col[4] = {
- fac * col1[0] + (1.0f - fac) * col2[0],
- fac * col1[1] + (1.0f - fac) * col2[1],
- fac * col1[2] + (1.0f - fac) * col2[2],
- 1.0f,
+ fac * col1[0] + (1.0f - fac) * col2[0],
+ fac * col1[1] + (1.0f - fac) * col2[1],
+ fac * col1[2] + (1.0f - fac) * col2[2],
+ 1.0f,
};
immAttr4fv(attr, col);
}
@@ -296,8 +304,13 @@ void UI_draw_roundbox_shade_x(bool filled,
{
#if 0
float vec[7][2] = {
- {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
- {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805},
+ {0.195, 0.02},
+ {0.383, 0.067},
+ {0.55, 0.169},
+ {0.707, 0.293},
+ {0.831, 0.45},
+ {0.924, 0.617},
+ {0.98, 0.805},
};
const float div = maxy - miny;
const float idiv = 1.0f / div;
@@ -317,9 +330,9 @@ void UI_draw_roundbox_shade_x(bool filled,
}
/* 'shade' defines strength of shading */
- coltop[0] = min_ff(1.0f, col[0] + shadetop);
- coltop[1] = min_ff(1.0f, col[1] + shadetop);
- coltop[2] = min_ff(1.0f, col[2] + shadetop);
+ coltop[0] = min_ff(1.0f, col[0] + shadetop);
+ coltop[1] = min_ff(1.0f, col[1] + shadetop);
+ coltop[2] = min_ff(1.0f, col[2] + shadetop);
coldown[0] = max_ff(0.0f, col[0] + shadedown);
coldown[1] = max_ff(0.0f, col[1] + shadedown);
coldown[2] = max_ff(0.0f, col[2] + shadedown);
@@ -440,13 +453,24 @@ void UI_draw_roundbox_shade_x(bool filled,
#if 0 /* unused */
/* linear vertical shade within button or in outline */
/* view2d scrollers use it */
-void UI_draw_roundbox_shade_y(
- bool filled, float minx, float miny, float maxx, float maxy,
- float rad, float shadeleft, float shaderight, const float col[4])
+void UI_draw_roundbox_shade_y(bool filled,
+ float minx,
+ float miny,
+ float maxx,
+ float maxy,
+ float rad,
+ float shadeleft,
+ float shaderight,
+ const float col[4])
{
float vec[7][2] = {
- {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
- {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805},
+ {0.195, 0.02},
+ {0.383, 0.067},
+ {0.55, 0.169},
+ {0.707, 0.293},
+ {0.831, 0.45},
+ {0.924, 0.617},
+ {0.98, 0.805},
};
const float div = maxx - minx;
const float idiv = 1.0f / div;
@@ -466,14 +490,13 @@ void UI_draw_roundbox_shade_y(
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
/* 'shade' defines strength of shading */
- colLeft[0] = min_ff(1.0f, col[0] + shadeleft);
- colLeft[1] = min_ff(1.0f, col[1] + shadeleft);
- colLeft[2] = min_ff(1.0f, col[2] + shadeleft);
+ colLeft[0] = min_ff(1.0f, col[0] + shadeleft);
+ colLeft[1] = min_ff(1.0f, col[1] + shadeleft);
+ colLeft[2] = min_ff(1.0f, col[2] + shadeleft);
colRight[0] = max_ff(0.0f, col[0] + shaderight);
colRight[1] = max_ff(0.0f, col[1] + shaderight);
colRight[2] = max_ff(0.0f, col[2] + shaderight);
-
vert_count += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 9 : 1;
vert_count += (roundboxtype & UI_CNR_TOP_RIGHT) ? 9 : 1;
vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1;
@@ -1310,12 +1333,14 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar),
const float skin_rad = DEG2RADF(123.0f); /* angle in radians of the skin tone line */
Scopes *scopes = (Scopes *)but->poin;
- const float colors[6][3] = {{0.75, 0.0, 0.0},
- {0.75, 0.75, 0.0},
- {0.0, 0.75, 0.0},
- {0.0, 0.75, 0.75},
- {0.0, 0.0, 0.75},
- {0.75, 0.0, 0.75}};
+ const float colors[6][3] = {
+ {0.75, 0.0, 0.0},
+ {0.75, 0.75, 0.0},
+ {0.0, 0.75, 0.0},
+ {0.0, 0.75, 0.75},
+ {0.0, 0.0, 0.75},
+ {0.75, 0.0, 0.75},
+ };
rctf rect = {
.xmin = (float)recti->xmin + 1,
@@ -1585,16 +1610,10 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
/* Drawing the checkerboard. */
- immUniform4f("color1",
- UI_ALPHA_CHECKER_DARK / 255.0f,
- UI_ALPHA_CHECKER_DARK / 255.0f,
- UI_ALPHA_CHECKER_DARK / 255.0f,
- 1.0f);
- immUniform4f("color2",
- UI_ALPHA_CHECKER_LIGHT / 255.0f,
- UI_ALPHA_CHECKER_LIGHT / 255.0f,
- UI_ALPHA_CHECKER_LIGHT / 255.0f,
- 1.0f);
+ const float checker_dark = UI_ALPHA_CHECKER_DARK / 255.0f;
+ const float checker_light = UI_ALPHA_CHECKER_LIGHT / 255.0f;
+ immUniform4f("color1", checker_dark, checker_dark, checker_dark, 1.0f);
+ immUniform4f("color2", checker_light, checker_light, checker_light, 1.0f);
immUniform1i("size", 8);
immRectf(pos_id, x1, y1, x1 + sizex, rect->ymax);
immUnbindProgram();
@@ -1779,12 +1798,12 @@ static void ui_draw_but_curve_grid(
1.0f);
immBegin(GPU_PRIM_LINES, (int)line_count * 2);
- while (fx < rect->xmax) {
+ while (fx <= rect->xmax) {
immVertex2f(pos, fx, rect->ymin);
immVertex2f(pos, fx, rect->ymax);
fx += dx;
}
- while (fy < rect->ymax) {
+ while (fy <= rect->ymax) {
immVertex2f(pos, rect->xmin, fy);
immVertex2f(pos, rect->xmax, fy);
fy += dy;
@@ -1824,6 +1843,17 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons
cumap = (CurveMapping *)but->poin;
}
+ /* calculate offset and zoom */
+ float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr);
+ float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr);
+ float offsx = cumap->curr.xmin - (1.0f / zoomx);
+ float offsy = cumap->curr.ymin - (1.0f / zoomy);
+
+ /* exit early if too narrow */
+ if (zoomx == 0.0f) {
+ return;
+ }
+
CurveMap *cuma = &cumap->cm[cumap->cur];
/* need scissor test, curve can draw outside of boundary */
@@ -1842,12 +1872,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons
BLI_rcti_size_x(&scissor_new),
BLI_rcti_size_y(&scissor_new));
- /* calculate offset and zoom */
- float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr);
- float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr);
- float offsx = cumap->curr.xmin - (1.0f / zoomx);
- float offsy = cumap->curr.ymin - (1.0f / zoomy);
-
/* Do this first to not mess imm context */
if (but->a1 == UI_GRAD_H) {
/* magic trigger for curve backgrounds */
@@ -2461,7 +2485,8 @@ void ui_draw_dropshadow(
/* alpha ranges from 2 to 20 or so */
#if 0 /* Old Method (pre 2.8) */
float color[4] = {0.0f, 0.0f, 0.0f, calpha};
- UI_draw_roundbox_4fv(true, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax - 10.0f + a, rad + a, color);
+ UI_draw_roundbox_4fv(
+ true, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax - 10.0f + a, rad + a, color);
#endif
/* Compute final visibility to match old method result. */
/* TODO we could just find a better fit function inside the shader instead of this. */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 0fe12b21636..8f19f40d1c0 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -205,14 +205,20 @@ static void ui_selectcontext_apply(bContext *C,
# define DRAG_MULTINUM_THRESHOLD_DRAG_X (UI_UNIT_Y / 4)
/**
- * how far to drag horizontally before we stop checking which buttons the gesture spans (in pixels),
- * locking down the buttons so we can drag freely without worrying about vertical movement. */
+ * How far to drag horizontally
+ * before we stop checking which buttons the gesture spans (in pixels),
+ * locking down the buttons so we can drag freely without worrying about vertical movement.
+ */
# define DRAG_MULTINUM_THRESHOLD_DRAG_Y (UI_UNIT_Y / 4)
/**
- * how strict to be when detecting a vertical gesture, [0.5 == sloppy], [0.9 == strict], (unsigned dot-product)
- * note: we should be quite strict here, since doing a vertical gesture by accident should be avoided,
- * however with some care a user should be able to do a vertical movement without *missing*. */
+ * How strict to be when detecting a vertical gesture:
+ * [0.5 == sloppy], [0.9 == strict], (unsigned dot-product).
+ *
+ * \note We should be quite strict here,
+ * since doing a vertical gesture by accident should be avoided,
+ * however with some care a user should be able to do a vertical movement without _missing_.
+ */
# define DRAG_MULTINUM_THRESHOLD_VERTICAL (0.75f)
/* a simple version of uiHandleButtonData when accessing multiple buttons */
@@ -912,8 +918,8 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
* feature used for bone renaming, channels, etc.
* afterfunc frees rename_orig */
if (data->origstr && (but->flag & UI_BUT_TEXTEDIT_UPDATE)) {
- /* In this case, we need to keep origstr available, to restore real org string in case we cancel after
- * having typed something already. */
+ /* In this case, we need to keep origstr available,
+ * to restore real org string in case we cancel after having typed something already. */
but->rename_orig = BLI_strdup(data->origstr);
}
/* only if there are afterfuncs, otherwise 'renam_orig' isn't freed */
@@ -1271,8 +1277,8 @@ static int ui_drag_toggle_but_pushed_state(bContext *C, uiBut *but)
}
else {
/* Assume icon identifies a unique state, for buttons that
- * work though functions callbacks and don't have an boolean
- * value that indicates the state. */
+ * work though functions callbacks and don't have an boolean
+ * value that indicates the state. */
return but->icon + but->iconadd;
}
}
@@ -1314,8 +1320,8 @@ static bool ui_drag_toggle_set_xy_xy(
ui_window_to_block_fl(ar, block, &xy_b_block[0], &xy_b_block[1]);
for (but = block->buttons.first; but; but = but->next) {
- /* Note: ctrl is always true here because (at least for now) we always want to consider text control
- * in this case, even when not embossed. */
+ /* Note: ctrl is always true here because (at least for now)
+ * we always want to consider text control in this case, even when not embossed. */
if (ui_but_is_interactive(but, true)) {
if (BLI_rctf_isect_segment(&but->rect, xy_a_block, xy_b_block)) {
@@ -1772,7 +1778,11 @@ static bool ui_but_drag_init(bContext *C,
/* Initialize alignment for single row/column regions,
* otherwise we use the relative position of the first other button dragged over. */
- if (ELEM(data->region->regiontype, RGN_TYPE_NAV_BAR, RGN_TYPE_HEADER, RGN_TYPE_FOOTER)) {
+ if (ELEM(data->region->regiontype,
+ RGN_TYPE_NAV_BAR,
+ RGN_TYPE_HEADER,
+ RGN_TYPE_TOOL_HEADER,
+ RGN_TYPE_FOOTER)) {
int lock_axis = -1;
if (ELEM(data->region->alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
lock_axis = 0;
@@ -3787,7 +3797,7 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat
#endif
/* this makes adjacent blocks auto open from now on */
- //if (but->block->auto_open == 0) {
+ // if (but->block->auto_open == 0) {
// but->block->auto_open = 1;
//}
}
@@ -5302,12 +5312,14 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_but(C, but->block, but, data, true);
- /* button's state need to be changed to EXIT so moving mouse away from this mouse wouldn't lead
- * to cancel changes made to this button, but changing state to EXIT also makes no button active for
- * a while which leads to triggering operator when doing fast scrolling mouse wheel.
- * using post activate stuff from button allows to make button be active again after checking for all
- * all that mouse leave and cancel stuff, so quick scroll wouldn't be an issue anymore.
- * same goes for scrolling wheel in another direction below (sergey)
+ /* Button's state need to be changed to EXIT so moving mouse away from this mouse wouldn't
+ * lead to cancel changes made to this button, but changing state to EXIT also makes no
+ * button active for a while which leads to triggering operator
+ * when doing fast scrolling mouse wheel.
+ * using post activate stuff from button allows to make button be active again after
+ * checking for all all that mouse leave and cancel stuff,
+ * so quick scroll wouldn't be an issue anymore.
+ * Same goes for scrolling wheel in another direction below (sergey).
*/
data->postbut = but;
data->posttype = BUTTON_ACTIVATE_OVER;
@@ -7680,6 +7692,11 @@ uiBut *UI_region_active_but_get(ARegion *ar)
return ui_context_button_active(ar, NULL);
}
+uiBut *UI_region_but_find_rect_over(const ARegion *ar, const rcti *rect_px)
+{
+ return ui_but_find_rect_over(ar, rect_px);
+}
+
/**
* Version of #UI_context_active_but_get that also returns RNA property info.
* Helper function for insert keyframe, reset to default, etc operators.
@@ -8730,6 +8747,13 @@ static bool ui_menu_scroll_step(ARegion *ar, uiBlock *block, const int scroll_di
/** \name Menu Event Handling
* \{ */
+static void ui_region_auto_open_clear(ARegion *ar)
+{
+ for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
+ block->auto_open = false;
+ }
+}
+
/**
* Special function to handle nested menus.
* let the parent menu get the event.
@@ -8772,6 +8796,7 @@ static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlock
}
else if (!ui_region_contains_point_px(but->active->region, event->x, event->y)) {
/* pass, needed to click-exit outside of non-flaoting menus */
+ ui_region_auto_open_clear(but->active->region);
}
else if ((!ELEM(event->type, MOUSEMOVE, WHEELUPMOUSE, WHEELDOWNMOUSE, MOUSEPAN)) &&
ISMOUSE(event->type)) {
@@ -9905,7 +9930,8 @@ static int ui_handle_menus_recursive(bContext *C,
}
/**
- * Allow setting menu return value from externals. E.g. WM might need to do this for exiting files correctly.
+ * Allow setting menu return value from externals.
+ * E.g. WM might need to do this for exiting files correctly.
*/
void UI_popup_menu_retval_set(const uiBlock *block, const int retval, const bool enable)
{
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index e2a75abebd7..7e295f83390 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -731,7 +731,11 @@ static void init_internal_icons(void)
bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL);
if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
- printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
+ printf(
+ "\n***WARNING***\n"
+ "Icons file '%s' too small.\n"
+ "Using built-in Icons instead\n",
+ iconfilestr);
IMB_freeImBuf(bbuf);
bbuf = NULL;
}
@@ -1822,15 +1826,14 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
ui_id_icon_render(C, id, true);
}
else {
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
const EnumPropertyItem *items = NULL;
ePaintMode paint_mode = PAINT_MODE_INVALID;
ScrArea *sa = CTX_wm_area(C);
char space_type = sa->spacetype;
- /* When in an unsupported space. */
- if (!ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE)) {
- space_type = workspace->tools_space_type;
+ /* Fallback to 3D view. */
+ if (space_type == SPACE_PROPERTIES) {
+ space_type = SPACE_VIEW3D;
}
/* XXX: this is not nice, should probably make brushes
@@ -1852,17 +1855,11 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
}
else if (space_type == SPACE_IMAGE) {
- int sima_mode;
if (sa->spacetype == space_type) {
- SpaceImage *sima = sa->spacedata.first;
- sima_mode = sima->mode;
- }
- else {
- sima_mode = workspace->tools_mode;
- }
-
- if (sima_mode == SI_MODE_PAINT) {
- paint_mode = PAINT_MODE_TEXTURE_2D;
+ const SpaceImage *sima = sa->spacedata.first;
+ if (sima->mode == SI_MODE_PAINT) {
+ paint_mode = PAINT_MODE_TEXTURE_2D;
+ }
}
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 86ca2241881..4af7fdd779f 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -172,21 +172,25 @@ struct uiBut {
/* both these values use depends on the button type
* (polymorphic struct or union would be nicer for this stuff) */
- /* (type == UI_BTYPE_HSVCUBE), Use UI_GRAD_* values.
- * (type == UI_BTYPE_NUM), Use to store RNA 'step' value, for dragging and click-step.
- * (type == UI_BTYPE_LABEL), Use (a1 == 1.0f) to use a2 as a blending factor (wow, this is imaginative!).
- * (type == UI_BTYPE_SCROLL) Use as scroll size.
- * (type == UI_BTYPE_SEARCH_MENU) Use as number or rows.
- * (type == UI_BTYPE_COLOR) Use as indication of color palette
- * (type == UI_BTYPE_PROGRESS_BAR) Use to store progress (0..1).
+ /**
+ * For #uiBut.type:
+ * - UI_BTYPE_HSVCUBE: Use UI_GRAD_* values.
+ * - UI_BTYPE_NUM: Use to store RNA 'step' value, for dragging and click-step.
+ * - UI_BTYPE_LABEL: Use `(a1 == 1.0f)` to use a2 as a blending factor (imaginative!).
+ * - UI_BTYPE_SCROLL: Use as scroll size.
+ * - UI_BTYPE_SEARCH_MENU: Use as number or rows.
+ * - UI_BTYPE_COLOR: Use as indication of color palette.
+ * - UI_BTYPE_PROGRESS_BAR: Use to store progress (0..1).
*/
float a1;
- /* (type == UI_BTYPE_HSVCIRCLE ), Use to store the luminosity.
- * (type == UI_BTYPE_NUM), Use to store RNA 'precision' value, for dragging and click-step.
- * (type == UI_BTYPE_LABEL), If (a1 == 1.0f) use a2 as a blending factor.
- * (type == UI_BTYPE_SEARCH_MENU) Use as number or columns.
- * (type == UI_BTYPE_COLOR) Use as index in palette (not so good, needs refactor)
+ /**
+ * For #uiBut.type:
+ * - UI_BTYPE_HSVCIRCLE: Use to store the luminosity.
+ * - UI_BTYPE_NUM: Use to store RNA 'precision' value, for dragging and click-step.
+ * - UI_BTYPE_LABEL: If `(a1 == 1.0f)` use a2 as a blending factor.
+ * - UI_BTYPE_SEARCH_MENU: Use as number or columns.
+ * - UI_BTYPE_COLOR: Use as index in palette (not so good, needs refactor).
*/
float a2;
@@ -456,7 +460,12 @@ extern void ui_block_to_window_rctf(const struct ARegion *ar,
extern float ui_block_to_window_scale(const struct ARegion *ar, uiBlock *block);
extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
+extern void ui_window_to_block_rctf(const struct ARegion *ar,
+ uiBlock *block,
+ rctf *rct_dst,
+ const rctf *rct_src);
extern void ui_window_to_region(const ARegion *ar, int *x, int *y);
+extern void ui_window_to_region_rcti(const ARegion *ar, rcti *rect_dst, const rcti *rct_src);
extern void ui_region_to_window(const struct ARegion *ar, int *x, int *y);
extern void ui_region_winrct_get_no_margin(const struct ARegion *ar, struct rcti *r_rect);
@@ -894,6 +903,7 @@ void ui_but_pie_dir(RadialDirection dir, float vec[2]);
bool ui_but_is_cursor_warp(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
bool ui_but_contains_pt(const uiBut *but, float mx, float my) ATTR_WARN_UNUSED_RESULT;
+bool ui_but_contains_rect(const uiBut *but, const rctf *rect);
bool ui_but_contains_point_px_icon(const uiBut *but,
struct ARegion *ar,
const struct wmEvent *event) ATTR_WARN_UNUSED_RESULT;
@@ -909,6 +919,8 @@ uiBut *ui_but_find_mouse_over_ex(struct ARegion *ar,
const bool labeledit) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_but_find_mouse_over(struct ARegion *ar,
const struct wmEvent *event) ATTR_WARN_UNUSED_RESULT;
+uiBut *ui_but_find_rect_over(const struct ARegion *ar,
+ const rcti *rect_px) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_list_find_mouse_over_ex(struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT;
@@ -927,6 +939,7 @@ bool ui_block_is_popup_any(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_region_find_first_but_test_flag(struct ARegion *ar, int flag_include, int flag_exclude);
uiBut *ui_region_find_active_but(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT;
bool ui_region_contains_point_px(const struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT;
+bool ui_region_contains_rect_px(const struct ARegion *ar, const rcti *rect_px);
/* interface_context_menu.c */
bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 8e463bf8447..41001ff6d14 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -112,7 +112,7 @@ typedef enum uiItemType {
ITEM_LAYOUT_ROOT
#if 0
- TEMPLATE_COLUMN_FLOW,
+ TEMPLATE_COLUMN_FLOW,
TEMPLATE_SPLIT,
TEMPLATE_BOX,
@@ -722,33 +722,87 @@ static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2)
RNA_property_enum_set(&but->rnapoin, but->rnaprop, current_value);
}
}
+
+/**
+ * Draw a single enum button, a utility for #ui_item_enum_expand_exec
+ */
+static void ui_item_enum_expand_elem_exec(uiLayout *layout,
+ uiBlock *block,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ const char *uiname,
+ const int h,
+ const eButType but_type,
+ const bool icon_only,
+ const EnumPropertyItem *item,
+ const bool is_first)
+{
+ const char *name = (!uiname || uiname[0]) ? item->name : "";
+ const int icon = item->icon;
+ const int value = item->value;
+ const int itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0);
+
+ uiBut *but;
+
+ if (icon && name[0] && !icon_only) {
+ but = uiDefIconTextButR_prop(
+ block, but_type, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
+ }
+ else if (icon) {
+ const int w = (is_first) ? itemw : ceilf(itemw - U.pixelsize);
+ but = uiDefIconButR_prop(
+ block, but_type, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
+ }
+ else {
+ but = uiDefButR_prop(
+ block, but_type, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
+ }
+
+ if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
+ /* If this is set, assert since we're clobbering someone elses callback. */
+ BLI_assert(but->func == NULL);
+ UI_but_func_set(but, ui_item_enum_expand_handle, but, POINTER_FROM_INT(value));
+ }
+
+ if (uiLayoutGetLocalDir(layout) != UI_LAYOUT_HORIZONTAL) {
+ but->drawflag |= UI_BUT_TEXT_LEFT;
+ }
+
+ /* Allow quick, inaccurate swipe motions to switch tabs
+ * (no need to keep cursor over them). */
+ if (but_type == UI_BTYPE_TAB) {
+ but->flag |= UI_BUT_DRAG_LOCK;
+ }
+}
+
static void ui_item_enum_expand_exec(uiLayout *layout,
uiBlock *block,
PointerRNA *ptr,
PropertyRNA *prop,
const char *uiname,
- int h,
- int but_type,
- bool icon_only)
-{
- /* XXX The way this function currently handles uiname parameter is insane and inconsistent with general UI API:
- * * uiname is the *enum property* label.
- * * when it is NULL or empty, we do not draw *enum items* labels, this doubles the icon_only parameter.
- * * we *never* draw (i.e. really use) the enum label uiname, it is just used as a mere flag!
- * Unfortunately, fixing this implies an API "soft break", so better to defer it for later... :/
- * --mont29
+ const int h,
+ const eButType but_type,
+ const bool icon_only)
+{
+ /* XXX: The way this function currently handles uiname parameter
+ * is insane and inconsistent with general UI API:
+ *
+ * - uiname is the *enum property* label.
+ * - when it is NULL or empty, we do not draw *enum items* labels,
+ * this doubles the icon_only parameter.
+ * - we *never* draw (i.e. really use) the enum label uiname, it is just used as a mere flag!
+ *
+ * Unfortunately, fixing this implies an API "soft break", so better to defer it for later... :/
+ * - mont29
*/
- uiBut *but;
- uiLayout *layout_radial = NULL;
const EnumPropertyItem *item, *item_array;
- const char *name;
- int itemw, icon, value;
bool free;
- bool radial = (layout->root->type == UI_LAYOUT_PIEMENU);
BLI_assert(RNA_property_type(prop) == PROP_ENUM);
+ uiLayout *layout_radial = NULL;
+ bool radial = (layout->root->type == UI_LAYOUT_PIEMENU);
if (radial) {
RNA_property_enum_items_gettexted_all(block->evil_C, ptr, prop, &item_array, NULL, &free);
}
@@ -769,11 +823,12 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
UI_block_layout_set_current(block, layout);
}
}
- else if (layout->root->type != UI_LAYOUT_MENU) {
- UI_block_layout_set_current(block, ui_item_local_sublayout(layout, layout, 1));
+ else if (ELEM(layout->item.type, ITEM_LAYOUT_GRID_FLOW, ITEM_LAYOUT_COLUMN_FLOW) ||
+ layout->root->type == UI_LAYOUT_MENU) {
+ UI_block_layout_set_current(block, layout);
}
else {
- UI_block_layout_set_current(block, layout);
+ UI_block_layout_set_current(block, ui_item_local_sublayout(layout, layout, 1));
}
for (item = item_array; item->identifier; item++) {
@@ -802,54 +857,10 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
continue;
}
- name = (!uiname || uiname[0]) ? item->name : "";
- icon = item->icon;
- value = item->value;
- itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0);
-
- if (icon && name[0] && !icon_only) {
- but = uiDefIconTextButR_prop(
- block, but_type, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
- }
- else if (icon) {
- but = uiDefIconButR_prop(block,
- but_type,
- 0,
- icon,
- 0,
- 0,
- (is_first) ? itemw : ceilf(itemw - U.pixelsize),
- h,
- ptr,
- prop,
- -1,
- 0,
- value,
- -1,
- -1,
- NULL);
- }
- else {
- but = uiDefButR_prop(
- block, but_type, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
- }
-
- if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
- /* If this is set, assert since we're clobbering someone elses callback. */
- BLI_assert(but->func == NULL);
- UI_but_func_set(but, ui_item_enum_expand_handle, but, POINTER_FROM_INT(value));
- }
-
- if (uiLayoutGetLocalDir(layout) != UI_LAYOUT_HORIZONTAL) {
- but->drawflag |= UI_BUT_TEXT_LEFT;
- }
-
- /* Allow quick, inaccurate swipe motions to switch tabs
- * (no need to keep cursor over them). */
- if (but_type == UI_BTYPE_TAB) {
- but->flag |= UI_BUT_DRAG_LOCK;
- }
+ ui_item_enum_expand_elem_exec(
+ layout, block, ptr, prop, uiname, h, but_type, icon_only, item, is_first);
}
+
UI_block_layout_set_current(block, layout);
if (free) {
@@ -861,8 +872,8 @@ static void ui_item_enum_expand(uiLayout *layout,
PointerRNA *ptr,
PropertyRNA *prop,
const char *uiname,
- int h,
- bool icon_only)
+ const int h,
+ const bool icon_only)
{
ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_ROW, icon_only);
}
@@ -872,8 +883,8 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
PointerRNA *ptr,
PropertyRNA *prop,
const char *uiname,
- int h,
- bool icon_only)
+ const int h,
+ const bool icon_only)
{
uiBut *last = block->buttons.last;
@@ -1533,12 +1544,14 @@ void uiItemsFullEnumO(uiLayout *layout,
bool free;
if (ui_layout_is_radial(layout)) {
- /* XXX: While "_all()" guarantees spatial stability, it's bad when an enum has > 8 items total,
- * but only a small subset will ever be shown at once (e.g. Mode Switch menu, after the
- * introduction of GP editing modes)
+ /* XXX: While "_all()" guarantees spatial stability,
+ * it's bad when an enum has > 8 items total,
+ * but only a small subset will ever be shown at once
+ * (e.g. Mode Switch menu, after the introduction of GP editing modes).
*/
#if 0
- RNA_property_enum_items_gettexted_all(block->evil_C, &ptr, prop, &item_array, &totitem, &free);
+ RNA_property_enum_items_gettexted_all(
+ block->evil_C, &ptr, prop, &item_array, &totitem, &free);
#else
RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item_array, &totitem, &free);
#endif
@@ -2955,6 +2968,9 @@ void uiItemS_ex(uiLayout *layout, float factor)
{
uiBlock *block = layout->root->block;
bool is_menu = ui_block_is_menu(block);
+ if (is_menu && !UI_block_can_add_separator(block)) {
+ return;
+ }
int space = (is_menu) ? 0.45f * UI_UNIT_X : 0.3f * UI_UNIT_X;
space *= factor;
@@ -3736,9 +3752,10 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
emy = 0; /* need to reset height again for next column */
col++;
- /* (< remaining width > - < space between remaining columns >) / <remamining columns > */
- w = ((litem->w - (x - litem->x)) - (flow->totcol - col - 1) * style->columnspace) /
- (flow->totcol - col);
+ const int remaining_width = litem->w - (x - litem->x);
+ const int remaining_width_between_columns = (flow->totcol - col - 1) * style->columnspace;
+ const int remaining_columns = flow->totcol - col;
+ w = (remaining_width - remaining_width_between_columns) / remaining_columns;
}
}
@@ -3963,9 +3980,10 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
return;
}
- /* Even in varying column width case, we fix our columns number from weighted average width of items,
- * a proper solving of required width would be too costly, and this should give reasonably good results
- * in all reasonable cases... */
+ /* Even in varying column width case,
+ * we fix our columns number from weighted average width of items,
+ * a proper solving of required width would be too costly,
+ * and this should give reasonably good results in all reasonable cases. */
if (gflow->columns_len > 0) {
gflow->tot_columns = gflow->columns_len;
}
@@ -4434,7 +4452,8 @@ uiLayout *uiLayoutBox(uiLayout *layout)
}
/**
- * Check all buttons defined in this layout, and set any button flagged as UI_BUT_LIST_ITEM as active/selected.
+ * Check all buttons defined in this layout,
+ * and set any button flagged as UI_BUT_LIST_ITEM as active/selected.
* Needed to handle correctly text colors of active (selected) list item.
*/
void ui_layout_list_set_labels_active(uiLayout *layout)
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 537a1d4c851..768cc32aeb5 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1125,8 +1125,7 @@ static void ui_editsource_active_but_clear(void)
static bool ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
{
# if 0
- printf("matching buttons: '%s' == '%s'\n",
- but_a->drawstr, but_b->drawstr);
+ printf("matching buttons: '%s' == '%s'\n", but_a->drawstr, but_b->drawstr);
# endif
/* this just needs to be a 'good-enough' comparison so we can know beyond
@@ -1153,8 +1152,7 @@ void UI_editsource_active_but_test(uiBut *but)
int lineno = -1;
# if 0
- printf("comparing buttons: '%s' == '%s'\n",
- but->drawstr, ui_editsource_info->but_orig.drawstr);
+ printf("comparing buttons: '%s' == '%s'\n", but->drawstr, ui_editsource_info->but_orig.drawstr);
# endif
PyC_FileAndNum_Safe(&fn, &lineno);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 34e13f6620b..87e58a4b3b5 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -267,7 +267,8 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar)
}
/**
- * XXX Disabled paneltab handling for now. Old 2.4x feature, *DO NOT* confuse it with new tool tabs in 2.70. ;)
+ * XXX Disabled paneltab handling for now. Old 2.4x feature,
+ * *DO NOT* confuse it with new tool tabs in 2.70. ;)
* See also T41704.
*/
/* #define UI_USE_PANELTAB */
@@ -700,11 +701,10 @@ void ui_draw_aligned_panel(uiStyle *style,
const bool is_closed_x = (panel->flag & PNL_CLOSEDX) ? true : false;
const bool is_closed_y = (panel->flag & PNL_CLOSEDY) ? true : false;
const bool is_subpanel = (panel->type && panel->type->parent);
- const bool show_drag =
- (!is_subpanel &&
- /* FIXME(campbell): currently no background means floating panel which can't be dragged.
- * This may be changed in future. */
- show_background);
+ const bool show_drag = (!is_subpanel &&
+ /* FIXME(campbell): currently no background means floating panel which
+ * can't be dragged. This may be changed in future. */
+ show_background);
if (panel->paneltab) {
return;
@@ -1671,7 +1671,7 @@ static void ui_handle_panel_header(
if (mx <= block->rect.xmax - 8 - PNL_ICON) {
button = 2;
}
- //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) {
+ // else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) {
// button = 1;
//}
}
@@ -1756,7 +1756,7 @@ static void ui_handle_panel_header(
}
}
-bool UI_panel_category_is_visible(ARegion *ar)
+bool UI_panel_category_is_visible(const ARegion *ar)
{
/* more than one */
return ar->panels_category.first && ar->panels_category.first != ar->panels_category.last;
@@ -2063,7 +2063,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
BLF_enable(fontid, BLF_ROTATION);
BLF_rotation(fontid, M_PI_2);
- //UI_fontstyle_set(&style->widget);
+ // UI_fontstyle_set(&style->widget);
ui_fontscale(&fstyle_points, aspect / (U.pixelsize * 1.1f));
BLF_size(fontid, fstyle_points, U.dpi);
@@ -2568,7 +2568,7 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
* is very hard to control and use, and has no real benefit." - BillRey
* Aligorith, 2009Sep
*/
- //test_add_new_tabs(ar); // also copies locations of tabs in dragged panel
+ // test_add_new_tabs(ar); // also copies locations of tabs in dragged panel
check_panel_overlap(ar, NULL); /* clears */
}
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index be09e44fa9d..b0fd0cdc35f 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -201,17 +201,19 @@ bool ui_but_contains_pt(const uiBut *but, float mx, float my)
return BLI_rctf_isect_pt(&but->rect, mx, my);
}
+bool ui_but_contains_rect(const uiBut *but, const rctf *rect)
+{
+ return BLI_rctf_isect(&but->rect, rect, NULL);
+}
+
bool ui_but_contains_point_px(const uiBut *but, const ARegion *ar, int x, int y)
{
uiBlock *block = but->block;
- float mx, my;
if (!ui_region_contains_point_px(ar, x, y)) {
return false;
}
- mx = x;
- my = y;
-
+ float mx = x, my = y;
ui_window_to_block_fl(ar, block, &mx, &my);
if (but->pie_dir != UI_RADIAL_NONE) {
@@ -253,23 +255,16 @@ bool ui_but_contains_point_px_icon(const uiBut *but, ARegion *ar, const wmEvent
/* x and y are only used in case event is NULL... */
uiBut *ui_but_find_mouse_over_ex(ARegion *ar, const int x, const int y, const bool labeledit)
{
- uiBlock *block;
- uiBut *but, *butover = NULL;
- float mx, my;
+ uiBut *butover = NULL;
- // if (!win->active) {
- // return NULL;
- // }
if (!ui_region_contains_point_px(ar, x, y)) {
return NULL;
}
-
- for (block = ar->uiblocks.first; block; block = block->next) {
- mx = x;
- my = y;
+ for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
+ float mx = x, my = y;
ui_window_to_block_fl(ar, block, &mx, &my);
- for (but = block->buttons.last; but; but = but->prev) {
+ for (uiBut *but = block->buttons.last; but; but = but->prev) {
if (ui_but_is_interactive(but, labeledit)) {
if (but->pie_dir != UI_RADIAL_NONE) {
if (ui_but_isect_pie_seg(block, but)) {
@@ -301,22 +296,53 @@ uiBut *ui_but_find_mouse_over(ARegion *ar, const wmEvent *event)
return ui_but_find_mouse_over_ex(ar, event->x, event->y, event->ctrl != 0);
}
-uiBut *ui_list_find_mouse_over_ex(ARegion *ar, int x, int y)
+uiBut *ui_but_find_rect_over(const struct ARegion *ar, const rcti *rect_px)
{
- uiBlock *block;
- uiBut *but;
- float mx, my;
+ if (!ui_region_contains_rect_px(ar, rect_px)) {
+ return NULL;
+ }
+
+ /* Currently no need to expose this at the moment. */
+ bool labeledit = true;
+ rctf rect_px_fl;
+ BLI_rctf_rcti_copy(&rect_px_fl, rect_px);
+ uiBut *butover = NULL;
+
+ for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
+ rctf rect_block;
+ ui_window_to_block_rctf(ar, block, &rect_block, &rect_px_fl);
+ for (uiBut *but = block->buttons.last; but; but = but->prev) {
+ if (ui_but_is_interactive(but, labeledit)) {
+ /* No pie menu support. */
+ BLI_assert(but->pie_dir == UI_RADIAL_NONE);
+ if (ui_but_contains_rect(but, &rect_block)) {
+ butover = but;
+ break;
+ }
+ }
+ }
+
+ /* CLIP_EVENTS prevents the event from reaching other blocks */
+ if (block->flag & UI_BLOCK_CLIP_EVENTS) {
+ /* check if mouse is inside block */
+ if (BLI_rctf_isect(&block->rect, &rect_block, NULL)) {
+ break;
+ }
+ }
+ }
+ return butover;
+}
+
+uiBut *ui_list_find_mouse_over_ex(ARegion *ar, int x, int y)
+{
if (!ui_region_contains_point_px(ar, x, y)) {
return NULL;
}
-
- for (block = ar->uiblocks.first; block; block = block->next) {
- mx = x;
- my = y;
+ for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
+ float mx = x, my = y;
ui_window_to_block_fl(ar, block, &mx, &my);
-
- for (but = block->buttons.last; but; but = but->prev) {
+ for (uiBut *but = block->buttons.last; but; but = but->prev) {
if (but->type == UI_BTYPE_LISTBOX && ui_but_contains_pt(but, mx, my)) {
return but;
}
@@ -447,6 +473,15 @@ bool UI_block_is_empty(const uiBlock *block)
return true;
}
+bool UI_block_can_add_separator(const uiBlock *block)
+{
+ if (ui_block_is_menu(block) && !ui_block_is_pie_menu(block)) {
+ const uiBut *but = block->buttons.last;
+ return (but && !ELEM(but->type, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR));
+ }
+ return true;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -455,11 +490,8 @@ bool UI_block_is_empty(const uiBlock *block)
uiBut *ui_region_find_active_but(ARegion *ar)
{
- uiBlock *block;
- uiBut *but;
-
- for (block = ar->uiblocks.first; block; block = block->next) {
- for (but = block->buttons.first; but; but = but->next) {
+ for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
+ for (uiBut *but = block->buttons.first; but; but = but->next) {
if (but->active) {
return but;
}
@@ -485,22 +517,14 @@ uiBut *ui_region_find_first_but_test_flag(ARegion *ar, int flag_include, int fla
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Region (#ARegion) State
+/** \name Region (#ARegion) Spatial
* \{ */
bool ui_region_contains_point_px(const ARegion *ar, int x, int y)
{
rcti winrct;
-
- /* scale down area rect to exclude shadow */
ui_region_winrct_get_no_margin(ar, &winrct);
-
- /* check if the mouse is in the region */
if (!BLI_rcti_isect_pt(&winrct, x, y)) {
- for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
- block->auto_open = false;
- }
-
return false;
}
@@ -511,14 +535,9 @@ bool ui_region_contains_point_px(const ARegion *ar, int x, int y)
*/
if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) {
const View2D *v2d = &ar->v2d;
- int mx, my;
+ int mx = x, my = y;
- /* convert window coordinates to region coordinates */
- mx = x;
- my = y;
ui_window_to_region(ar, &mx, &my);
-
- /* check if in the rect */
if (!BLI_rcti_isect_pt(&v2d->mask, mx, my) ||
UI_view2d_mouse_in_scrollers(ar, &ar->v2d, x, y)) {
return false;
@@ -528,4 +547,26 @@ bool ui_region_contains_point_px(const ARegion *ar, int x, int y)
return true;
}
+bool ui_region_contains_rect_px(const ARegion *ar, const rcti *rect_px)
+{
+ rcti winrct;
+ ui_region_winrct_get_no_margin(ar, &winrct);
+ if (!BLI_rcti_isect(&winrct, rect_px, NULL)) {
+ return false;
+ }
+
+ /* See comment in 'ui_region_contains_point_px' */
+ if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) {
+ const View2D *v2d = &ar->v2d;
+ rcti rect_region;
+ ui_window_to_region_rcti(ar, &rect_region, rect_px);
+ if (!BLI_rcti_isect(&v2d->mask, &rect_region, NULL) ||
+ UI_view2d_rect_in_scrollers(ar, &ar->v2d, rect_px)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
/** \} */
diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c
index 7ffe572a848..723222d56d1 100644
--- a/source/blender/editors/interface/interface_region_color_picker.c
+++ b/source/blender/editors/interface/interface_region_color_picker.c
@@ -663,7 +663,8 @@ static void ui_block_colorpicker(uiBlock *block, uiBut *from_but, float rgba[4],
UI_but_func_set(bt, ui_colorpicker_rna_cb, bt, NULL);
bt->custom_data = cpicker;
- /* could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE);
+ /* Could use:
+ * uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND | UI_ITEM_R_SLIDER, "", ICON_NONE);
* but need to use UI_but_func_set for updating other fake buttons */
/* HSV values */
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index a1f4b71dc6d..362a1c8a22c 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -193,7 +193,8 @@ static void hud_region_layout(const bContext *C, ARegion *ar)
UI_view2d_region_reinit(v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy);
- /* Weak, but needed to avoid glitches, especially with hi-dpi (where resizing the view glitches often).
+ /* Weak, but needed to avoid glitches, especially with hi-dpi
+ * (where resizing the view glitches often).
* Fortunately this only happens occasionally. */
ED_region_panels_layout(C, ar);
}
@@ -285,6 +286,13 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
}
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HUD);
+
+ if (ar && (ar->flag & RGN_FLAG_HIDDEN_BY_USER)) {
+ /* The region is intentionally hidden by the user, don't show it. */
+ hud_region_hide(ar);
+ return;
+ }
+
bool init = false;
bool was_hidden = ar == NULL || ar->visible == false;
if (!last_redo_poll(C)) {
diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c
index b115600a80b..dcbbde259f2 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.c
+++ b/source/blender/editors/interface/interface_region_menu_pie.c
@@ -310,12 +310,14 @@ int UI_pie_menu_invoke_from_rna_enum(struct bContext *C,
/**
* \name Pie Menu Levels
*
- * Pie menus can't contain more than 8 items (yet). When using #uiItemsFullEnumO, a "More" button is created that calls
+ * Pie menus can't contain more than 8 items (yet).
+ * When using #uiItemsFullEnumO, a "More" button is created that calls
* a new pie menu if the enum has too many items. We call this a new "level".
* Indirect recursion is used, so that a theoretically unlimited number of items is supported.
*
- * This is a implementation specifically for operator enums, needed since the object mode pie now has more than 8
- * items. Ideally we'd have some way of handling this for all kinds of pie items, but that's tricky.
+ * This is a implementation specifically for operator enums,
+ * needed since the object mode pie now has more than 8 items.
+ * Ideally we'd have some way of handling this for all kinds of pie items, but that's tricky.
*
* - Julian (Feb 2016)
*
diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c
index d364bf7e102..b97cbcdfef5 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -279,7 +279,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
if (sa && ar) {
- if (ar->regiontype == RGN_TYPE_HEADER) {
+ if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
if (ED_area_header_alignment(sa) == RGN_ALIGN_BOTTOM) {
UI_block_direction_set(block, UI_DIR_UP);
UI_block_order_flip(block);
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index bbf3df6a264..f149ccd626c 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -187,7 +187,7 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
}
/* Prefer popover from header to be positioned into the editor. */
else if (sa && ar) {
- if (ar->regiontype == RGN_TYPE_HEADER) {
+ if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
if (ED_area_header_alignment(sa) == RGN_ALIGN_BOTTOM) {
UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X);
}
@@ -257,6 +257,8 @@ static void ui_block_free_func_POPOVER(uiPopupBlockHandle *UNUSED(handle), void
uiPopupBlockHandle *ui_popover_panel_create(
bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg)
{
+ wmWindow *window = CTX_wm_window(C);
+
/* Create popover, buttons are created from callback. */
uiPopover *pup = MEM_callocN(sizeof(uiPopover), __func__);
pup->but = but;
@@ -271,7 +273,11 @@ uiPopupBlockHandle *ui_popover_panel_create(
pup->menu_arg = arg;
#ifdef USE_UI_POPOVER_ONCE
- pup->is_once = true;
+ {
+ /* Ideally this would be passed in. */
+ const wmEvent *event = window->eventstate;
+ pup->is_once = (event->type == LEFTMOUSE) && (event->val == KM_PRESS);
+ }
#endif
/* Create popup block. */
@@ -283,7 +289,6 @@ uiPopupBlockHandle *ui_popover_panel_create(
/* Add handlers. If attached to a button, the button will already
* add a modal handler and pass on events. */
if (!but) {
- wmWindow *window = CTX_wm_window(C);
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
WM_event_add_mousemove(C);
handle->popup = true;
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 11b2e069d6c..c4bcd7074d8 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -236,10 +236,13 @@ static void ui_popup_block_position(wmWindow *window,
}
/* Compute offset based on direction. */
- int offset_x = 0, offset_y = 0;
+ float offset_x = 0, offset_y = 0;
+
+ /* Ensure buttons don't come between the parent button and the popup, see: T63566. */
+ const float offset_overlap = max_ff(U.pixelsize, 1.0f);
if (dir1 == UI_DIR_LEFT) {
- offset_x = butrct.xmin - block->rect.xmax;
+ offset_x = (butrct.xmin - block->rect.xmax) + offset_overlap;
if (dir2 == UI_DIR_UP) {
offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING;
}
@@ -248,7 +251,7 @@ static void ui_popup_block_position(wmWindow *window,
}
}
else if (dir1 == UI_DIR_RIGHT) {
- offset_x = butrct.xmax - block->rect.xmin;
+ offset_x = (butrct.xmax - block->rect.xmin) - offset_overlap;
if (dir2 == UI_DIR_UP) {
offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING;
}
@@ -257,7 +260,7 @@ static void ui_popup_block_position(wmWindow *window,
}
}
else if (dir1 == UI_DIR_UP) {
- offset_y = butrct.ymax - block->rect.ymin;
+ offset_y = (butrct.ymax - block->rect.ymin) - offset_overlap;
if (dir2 == UI_DIR_RIGHT) {
offset_x = butrct.xmax - block->rect.xmax + center_x;
}
@@ -271,7 +274,7 @@ static void ui_popup_block_position(wmWindow *window,
}
}
else if (dir1 == UI_DIR_DOWN) {
- offset_y = butrct.ymin - block->rect.ymax;
+ offset_y = (butrct.ymin - block->rect.ymax) + offset_overlap;
if (dir2 == UI_DIR_RIGHT) {
offset_x = butrct.xmax - block->rect.xmax + center_x;
}
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index c37775febda..251bc86a3f5 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -539,9 +539,10 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but
data->prv_cols = but->a2;
}
- /* Only show key shortcuts when needed (checking RNA prop pointer is useless here, a lot of buttons are about data
- * without having that pointer defined, let's rather try with optype!). One can also enforce that behavior by
- * setting UI_BUT_HAS_SHORTCUT drawflag of search button. */
+ /* Only show key shortcuts when needed (checking RNA prop pointer is useless here, a lot of
+ * buttons are about data without having that pointer defined, let's rather try with optype!).
+ * One can also enforce that behavior by setting
+ * UI_BUT_HAS_SHORTCUT drawflag of search button. */
if (but->optype != NULL || (but->drawflag & UI_BUT_HAS_SHORTCUT) != 0) {
data->use_sep = true;
}
@@ -597,7 +598,7 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but
winx = WM_window_pixels_x(win);
// winy = WM_window_pixels_y(win); /* UNUSED */
- //wm_window_get_size(win, &winx, &winy);
+ // wm_window_get_size(win, &winx, &winy);
if (rect_i.xmax > winx) {
/* super size */
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index c8029a2b21a..4a9c7b689c1 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -26,7 +26,8 @@
/* TODO(campbell):
* We may want to have a higher level API that initializes a timer,
* checks for mouse motion and clears the tool-tip afterwards.
- * We never want multiple tool-tips at once so this could be handled on the window / window-manager level.
+ * We never want multiple tool-tips at once
+ * so this could be handled on the window / window-manager level.
*
* For now it's not a priority, so leave as-is.
*/
@@ -461,7 +462,8 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
*
* - Direct access to the tool (as if the toolbar button is pressed).
* - The key is bound to a brush type (not the exact brush name).
- * - The key is assigned to the operator it's self (bypassing the tool, executing the operator).
+ * - The key is assigned to the operator it's self
+ * (bypassing the tool, executing the operator).
*
* Either way case it's useful to show the shortcut.
*/
@@ -1061,7 +1063,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C,
field->geom.x_pos = x_pos;
}
- //fontw *= aspect;
+ // fontw *= aspect;
BLF_disable(data->fstyle.uifont_id, font_flag);
BLF_disable(blf_mono_font, font_flag);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 6666991ad26..e96141eaa05 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -127,11 +127,8 @@ static void template_add_button_search_menu(const bContext *C,
if (use_previews) {
ARegion *region = CTX_wm_region(C);
- ScrArea *area = CTX_wm_area(C);
- /* XXX ugly top-bar exception */
- const bool use_big_size = (
- /* silly check, could be more generic */
- (region->regiontype != RGN_TYPE_HEADER) && (area->spacetype != SPACE_TOPBAR));
+ /* Ugly tool header exception. */
+ const bool use_big_size = (region->regiontype != RGN_TYPE_TOOL_HEADER);
/* Ugly exception for screens here,
* drawing their preview in icon size looks ugly/useless */
const bool use_preview_icon = use_big_size || (id && (GS(id->name) != ID_SCR));
@@ -801,7 +798,7 @@ static void template_ID(bContext *C,
char name[UI_MAX_NAME_STR];
const bool user_alert = (id->us <= 0);
- //text_idbutton(id, name);
+ // text_idbutton(id, name);
name[0] = '\0';
but = uiDefButR(block,
UI_BTYPE_TEXT,
@@ -1371,10 +1368,12 @@ void uiTemplateIDTabs(uiLayout *layout,
/************************ ID Chooser Template ***************************/
/**
- * This is for selecting the type of ID-block to use, and then from the relevant type choosing the block to use
+ * This is for selecting the type of ID-block to use,
+ * and then from the relevant type choosing the block to use.
*
- * - propname: property identifier for property that ID-pointer gets stored to
- * - proptypename: property identifier for property used to determine the type of ID-pointer that can be used
+ * \param propname: property identifier for property that ID-pointer gets stored to.
+ * \param proptypename: property identifier for property
+ * used to determine the type of ID-pointer that can be used.
*/
void uiTemplateAnyID(uiLayout *layout,
PointerRNA *ptr,
@@ -2354,8 +2353,14 @@ void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
/* Disable for now, doesn't fit well in popover. */
#if 0
/* Repeat button with operator name as text. */
- uiItemFullO(layout, "SCREEN_OT_repeat_last", RNA_struct_ui_name(op->type->srna),
- ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL);
+ uiItemFullO(layout,
+ "SCREEN_OT_repeat_last",
+ RNA_struct_ui_name(op->type->srna),
+ ICON_NONE,
+ NULL,
+ WM_OP_INVOKE_DEFAULT,
+ 0,
+ NULL);
#endif
if (WM_operator_repeat_check(C, op)) {
@@ -4277,7 +4282,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
/* curve itself */
- size = uiLayoutGetWidth(layout);
+ size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
row = uiLayoutRow(layout, false);
uiDefBut(
block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, bg, 0, "");
@@ -4801,9 +4806,9 @@ void uiTemplateLayers(uiLayout *layout,
/* the number of layers determines the way we group them
* - we want 2 rows only (for now)
- * - the number of columns (cols) is the total number of buttons per row
- * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
- * - for now, only split into groups if group will have at least 5 items
+ * - The number of columns (cols) is the total number of buttons per row the 'remainder'
+ * is added to this, as it will be ok to have first row slightly wider if need be.
+ * - For now, only split into groups if group will have at least 5 items.
*/
layers = RNA_property_array_length(ptr, prop);
cols = (layers / 2) + (layers % 2);
@@ -4992,7 +4997,7 @@ static void uilist_filter_items_default(struct uiList *ui_list,
dyn_data->items_shown++;
do_order = order_by_name;
}
- //printf("%s: '%s' matches '%s'\n", __func__, name, filter);
+ // printf("%s: '%s' matches '%s'\n", __func__, name, filter);
}
else if (filter_exclude) {
dyn_data->items_shown++;
@@ -5316,16 +5321,16 @@ void uiTemplateList(uiLayout *layout,
dyn_data->items_len = dyn_data->items_shown = RNA_property_collection_length(dataptr, prop);
}
else {
- //printf("%s: filtering...\n", __func__);
+ // printf("%s: filtering...\n", __func__);
filter_items(ui_list, C, dataptr, propname);
- //printf("%s: filtering done.\n", __func__);
+ // printf("%s: filtering done.\n", __func__);
}
items_shown = dyn_data->items_shown;
if (items_shown >= 0) {
bool activei_mapping_pending = true;
items_ptr = MEM_mallocN(sizeof(_uilist_item) * items_shown, __func__);
- //printf("%s: items shown: %d.\n", __func__, items_shown);
+ // printf("%s: items shown: %d.\n", __func__, items_shown);
RNA_PROP_BEGIN (dataptr, itemptr, prop) {
if (!dyn_data->items_filter_flags ||
((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude)) {
@@ -5337,7 +5342,7 @@ void uiTemplateList(uiLayout *layout,
else {
ii = order_reverse ? items_shown - ++idx : idx++;
}
- //printf("%s: ii: %d\n", __func__, ii);
+ // printf("%s: ii: %d\n", __func__, ii);
items_ptr[ii].item = itemptr;
items_ptr[ii].org_idx = i;
items_ptr[ii].flt_flag = dyn_data->items_filter_flags ? dyn_data->items_filter_flags[i] :
@@ -5624,14 +5629,17 @@ void uiTemplateList(uiLayout *layout,
if (glob) {
/* About UI_BTYPE_GRIP drag-resize:
- * We can't directly use results from a grip button, since we have a rather complex behavior here
- * (sizing by discrete steps and, overall, autosize feature).
- * Since we *never* know whether we are grip-resizing or not (because there is no callback for when a
- * button enters/leaves its "edit mode"), we use the fact that grip-controlled value (dyn_data->resize)
- * is completely handled by the grip during the grab resize, so settings its value here has no effect
- * at all.
- * It is only meaningful when we are not resizing, in which case this gives us the correct "init drag" value.
- * Note we cannot affect dyn_data->resize_prev here, since this value is not controlled by the grip!
+ * We can't directly use results from a grip button, since we have a
+ * rather complex behavior here (sizing by discrete steps and, overall, autosize feature).
+ * Since we *never* know whether we are grip-resizing or not
+ * (because there is no callback for when a button enters/leaves its "edit mode"),
+ * we use the fact that grip-controlled value (dyn_data->resize) is completely handled
+ * by the grip during the grab resize, so settings its value here has no effect at all.
+ *
+ * It is only meaningful when we are not resizing,
+ * in which case this gives us the correct "init drag" value.
+ * Note we cannot affect dyn_data->resize_prev here,
+ * since this value is not controlled by the grip!
*/
dyn_data->resize = dyn_data->resize_prev +
(dyn_data->visual_height - ui_list->list_grip) * UI_UNIT_Y;
@@ -5874,7 +5882,8 @@ static bool ui_layout_operator_buts_poll_property(struct PointerRNA *UNUSED(ptr)
/**
* Draw Operator property buttons for redoing execution with different settings.
- * This function does not initialize the layout, functions can be called on the layout before and after.
+ * This function does not initialize the layout,
+ * functions can be called on the layout before and after.
*/
eAutoPropButsReturn uiTemplateOperatorPropertyButs(const bContext *C,
uiLayout *layout,
@@ -5890,8 +5899,8 @@ eAutoPropButsReturn uiTemplateOperatorPropertyButs(const bContext *C,
op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
}
- /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens
- * just fails silently */
+ /* poll() on this operator may still fail,
+ * at the moment there is no nice feedback when this happens just fails silently. */
if (!WM_operator_repeat_check(C, op)) {
UI_block_lock_set(block, true, "Operator can't' redo");
return return_info;
@@ -6702,17 +6711,18 @@ void uiTemplateCacheFile(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
uiItemR(row, &fileptr, "override_frame", 0, "Override Frame", ICON_NONE);
row = uiLayoutRow(layout, false);
- uiLayoutSetEnabled(row, RNA_boolean_get(&fileptr, "override_frame"));
+ uiLayoutSetActive(row, RNA_boolean_get(&fileptr, "override_frame"));
uiItemR(row, &fileptr, "frame", 0, "Frame", ICON_NONE);
row = uiLayoutRow(layout, false);
uiItemR(row, &fileptr, "frame_offset", 0, "Frame Offset", ICON_NONE);
+ uiLayoutSetActive(row, !RNA_boolean_get(&fileptr, "is_sequence"));
row = uiLayoutRow(layout, false);
uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
row = uiLayoutRow(layout, false);
- uiLayoutSetEnabled(row, (sbuts->mainb == BCONTEXT_CONSTRAINT));
+ uiLayoutSetActive(row, (sbuts->mainb == BCONTEXT_CONSTRAINT));
uiItemR(row, &fileptr, "scale", 0, "Scale", ICON_NONE);
/* TODO: unused for now, so no need to expose. */
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 9920d4f1fa5..bf52cc625c2 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -508,7 +508,8 @@ int UI_icon_from_report_type(int type)
/********************************** Misc **************************************/
/**
- * Returns the best "UI" precision for given floating value, so that e.g. 10.000001 rather gets drawn as '10'...
+ * Returns the best "UI" precision for given floating value,
+ * so that e.g. 10.000001 rather gets drawn as '10'...
*/
int UI_calc_float_precision(int prec, double value)
{
@@ -519,7 +520,8 @@ int UI_calc_float_precision(int prec, double value)
BLI_assert(prec <= UI_PRECISION_FLOAT_MAX);
BLI_assert(fabs(pow10_neg[prec] - pow(10, -prec)) < 1e-16);
- /* check on the number of decimal places need to display the number, this is so 0.00001 is not displayed as 0.00,
+ /* Check on the number of decimal places need to display the number,
+ * this is so 0.00001 is not displayed as 0.00,
* _but_, this is only for small values si 10.0001 will not get the same treatment.
*/
value = ABS(value);
@@ -631,8 +633,10 @@ uiButStore *UI_butstore_create(uiBlock *block)
void UI_butstore_free(uiBlock *block, uiButStore *bs_handle)
{
/* Workaround for button store being moved into new block,
- * which then can't use the previous buttons state ('ui_but_update_from_old_block' fails to find a match),
- * keeping the active button in the old block holding a reference to the button-state in the new block: see T49034.
+ * which then can't use the previous buttons state
+ * ('ui_but_update_from_old_block' fails to find a match),
+ * keeping the active button in the old block holding a reference
+ * to the button-state in the new block: see T49034.
*
* Ideally we would manage moving the 'uiButStore', keeping a correct state.
* All things considered this is the most straightforward fix - Campbell.
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index e18a2e6068a..a9cd2f9cee1 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1604,9 +1604,14 @@ static void ui_text_clip_right_ex(const uiFontStyle *fstyle,
/**
* Cut off the middle of the text to fit into the given width.
- * Note in case this middle clipping would just remove a few chars, it rather clips right, which is more readable.
- * If rpart_sep is not Null, the part of str starting to first occurrence of rpart_sep is preserved at all cost (useful
- * for strings with shortcuts, like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
+ *
+ * \note in case this middle clipping would just remove a few chars,
+ * it rather clips right, which is more readable.
+ *
+ * If rpart_sep is not Null, the part of str starting to first occurrence of rpart_sep
+ * is preserved at all cost.
+ * Useful for strings with shortcuts
+ * (like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
*/
float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
char *str,
@@ -1691,8 +1696,8 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
r_len = strlen(str + r_offset) + 1; /* +1 for the trailing '\0'. */
if (l_end + sep_len + r_len + rpart_len > max_len) {
- /* Corner case, the str already takes all available mem, and the ellipsis chars would actually
- * add more chars...
+ /* Corner case, the str already takes all available mem,
+ * and the ellipsis chars would actually add more chars.
* Better to just trim one or two letters to the right in this case...
* Note: with a single-char ellipsis, this should never happen! But better be safe here...
*/
@@ -1753,8 +1758,10 @@ static void ui_text_clip_middle(const uiFontStyle *fstyle, uiBut *but, const rct
}
/**
- * Like ui_text_clip_middle(), but protect/preserve at all cost the right part of the string after sep.
- * Useful for strings with shortcuts (like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
+ * Like #ui_text_clip_middle(), but protect/preserve at all cost
+ * the right part of the string after sep.
+ * Useful for strings with shortcuts
+ * (like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
*/
static void ui_text_clip_middle_protect_right(const uiFontStyle *fstyle,
uiBut *but,
@@ -2780,8 +2787,8 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
/* menu is 2nd level or deeper */
if (flag & UI_BLOCK_POPUP) {
- //rect->ymin -= 4.0;
- //rect->ymax += 4.0;
+ // rect->ymin -= 4.0;
+ // rect->ymax += 4.0;
}
else if (direction == UI_DIR_DOWN) {
roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
@@ -4111,7 +4118,7 @@ static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundbox
const bool is_active = (state & UI_SELECT);
/* Draw shaded outline - Disabled for now,
- * seems incorrect and also looks nicer without it imho ;) */
+ * seems incorrect and also looks nicer without it imho ;) */
//#define USE_TAB_SHADED_HIGHLIGHT
uiWidgetBase wtb;
@@ -4679,7 +4686,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
}
if (wt) {
- //rcti disablerect = *rect; /* rect gets clipped smaller for text */
+ // rcti disablerect = *rect; /* rect gets clipped smaller for text */
int roundboxalign, state, drawflag;
bool disabled = false;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index fa56dc04143..587cccf516c 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -366,6 +366,10 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
case TH_OUTLINE_WIDTH:
cp = &ts->outline_width;
break;
+ case TH_OBCENTER_DIA:
+ cp = &ts->obcenter_dia;
+ break;
+ break;
case TH_EDGE:
cp = ts->edge;
break;
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index fa56721c11f..58d26c4a840 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -31,12 +31,14 @@
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
+#include "BLI_array.h"
#include "BLI_utildefines.h"
#include "BLI_link_utils.h"
#include "BLI_rect.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_timecode.h"
+#include "BLI_string.h"
#include "BKE_context.h"
#include "BKE_screen.h"
@@ -212,11 +214,14 @@ static void view2d_masks(View2D *v2d, bool check_scrollers, const rcti *mask_scr
/* Refresh and Validation */
/**
- * Initialize all relevant View2D data (including view rects if first time) and/or refresh mask sizes after view resize
- * - for some of these presets, it is expected that the region will have defined some
+ * Initialize all relevant View2D data (including view rects if first time)
+ * and/or refresh mask sizes after view resize.
+ *
+ * - For some of these presets, it is expected that the region will have defined some
* additional settings necessary for the customization of the 2D viewport to its requirements
- * - this function should only be called from region init() callbacks, where it is expected that
- * this is called before UI_view2d_size_update(), as this one checks that the rects are properly initialized.
+ * - This function should only be called from region init() callbacks, where it is expected that
+ * this is called before #UI_view2d_size_update(),
+ * as this one checks that the rects are properly initialized.
*/
void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
{
@@ -238,7 +243,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
v2d->minzoom = 0.01f;
v2d->maxzoom = 1000.0f;
- /* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now
+ /* View2D tot rect and cur should be same size,
+ * and aligned using 'standard' OpenGL coordinates for now:
* - region can resize 'tot' later to fit other data
* - keeptot is only within bounds, as strict locking is not that critical
* - view is aligned for (0,0) -> (winx-1, winy-1) setup
@@ -271,8 +277,9 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* scroller settings are currently not set here... that is left for regions... */
break;
}
- /* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead.
- * zoom, aspect ratio, and alignment restrictions are set here */
+ /* 'stack view' - practically the same as list/channel view,
+ * except is located in the pos y half instead.
+ * Zoom, aspect ratio, and alignment restrictions are set here. */
case V2D_COMMONVIEW_STACK: {
/* zoom + aspect ratio are locked */
v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
@@ -545,10 +552,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
if (do_cur) {
if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winx != v2d->oldwinx)) {
- /* special exception for Outliner (and later channel-lists):
- * - The view may be moved left to avoid contents being pushed out of view when view shrinks.
- * - The keeptot code will make sure cur->xmin will not be less than tot->xmin (which cannot be allowed)
- * - width is not adjusted for changed ratios here...
+ /* Special exception for Outliner (and later channel-lists):
+ * - The view may be moved left to avoid contents
+ * being pushed out of view when view shrinks.
+ * - The keeptot code will make sure cur->xmin will not be less than tot->xmin
+ * (which cannot be allowed).
+ * - width is not adjusted for changed ratios here.
*/
if (winx < v2d->oldwinx) {
float temp = v2d->oldwinx - winx;
@@ -906,8 +915,9 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
}
/**
- * Restore 'cur' rect to standard orientation (i.e. optimal maximum view of tot)
- * This does not take into account if zooming the view on an axis will improve the view (if allowed)
+ * Restore 'cur' rect to standard orientation (i.e. optimal maximum view of tot).
+ * This does not take into account if zooming the view on an axis
+ * will improve the view (if allowed).
*/
void UI_view2d_curRect_reset(View2D *v2d)
{
@@ -1109,7 +1119,7 @@ void UI_view2d_zoom_cache_reset(void)
/* View Matrix Setup */
/* mapping function to ensure 'cur' draws extended over the area where sliders are */
-static void view2d_map_cur_using_mask(View2D *v2d, rctf *r_curmasked)
+static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked)
{
*r_curmasked = v2d->cur;
@@ -1141,7 +1151,7 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *r_curmasked)
}
/* Set view matrices to use 'cur' rect as viewing frame for View2D drawing */
-void UI_view2d_view_ortho(View2D *v2d)
+void UI_view2d_view_ortho(const View2D *v2d)
{
rctf curmasked;
const int sizex = BLI_rcti_size_x(&v2d->mask);
@@ -1149,8 +1159,9 @@ void UI_view2d_view_ortho(View2D *v2d)
const float eps = 0.001f;
float xofs = 0.0f, yofs = 0.0f;
- /* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
- * but only applied where requested
+ /* Pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1
+ * correspondence with pixels for smooth UI drawing,
+ * but only applied where requested.
*/
/* XXX brecht: instead of zero at least use a tiny offset, otherwise
* pixel rounding is effectively random due to float inaccuracy */
@@ -1184,15 +1195,17 @@ void UI_view2d_view_ortho(View2D *v2d)
/**
* Set view matrices to only use one axis of 'cur' only
*
- * \param xaxis: if non-zero, only use cur x-axis, otherwise use cur-yaxis (mostly this will be used for x)
+ * \param xaxis: if non-zero, only use cur x-axis,
+ * otherwise use cur-yaxis (mostly this will be used for x).
*/
void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, const bool xaxis)
{
rctf curmasked;
float xofs, yofs;
- /* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
- * but only applied where requested
+ /* Pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1
+ * correspondence with pixels for smooth UI drawing,
+ * but only applied where requested.
*/
/* XXX temp (ton) */
xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? GLA_PIXEL_OFS : 0.0f;
@@ -1227,338 +1240,6 @@ void UI_view2d_view_restore(const bContext *C)
/* *********************************************************************** */
/* Gridlines */
-/* View2DGrid is typedef'd in UI_view2d.h */
-struct View2DGrid {
- float dx, dy; /* stepsize (in pixels) between gridlines */
- float startx, starty; /* initial coordinates to start drawing grid from */
- int powerx, powery; /* step as power of 10 */
-};
-
-/* --------------- */
-
-/* try to write step as a power of 10 */
-static void step_to_grid(float *step, const int unit, int *r_power)
-{
- const float loga = (float)log10(*step);
- float rem;
-
- int power = (int)(loga);
-
- rem = loga - power;
- rem = (float)pow(10.0, rem);
-
- if (loga < 0.0f) {
- if (rem < 0.2f) {
- rem = 0.2f;
- }
- else if (rem < 0.5f) {
- rem = 0.5f;
- }
- else {
- rem = 1.0f;
- }
-
- *step = rem * (float)pow(10.0, power);
-
- /* for frames, we want 1.0 frame intervals only */
- if (unit == V2D_UNIT_FRAMES) {
- rem = 1.0f;
- /* use 2 since there are grid lines drawn in between,
- * this way to get 1 line per frame */
- *step = 2.0f;
- }
-
- /* prevents printing 1.0 2.0 3.0 etc */
- if (rem == 1.0f) {
- power++;
- }
- }
- else {
- if (rem < 2.0f) {
- rem = 2.0f;
- }
- else if (rem < 5.0f) {
- rem = 5.0f;
- }
- else {
- rem = 10.0f;
- }
-
- *step = rem * (float)pow(10.0, power);
-
- power++;
- /* prevents printing 1.0, 2.0, 3.0, etc. */
- if (rem == 10.0f) {
- power++;
- }
- }
-
- *r_power = power;
-}
-
-/**
- * Initialize settings necessary for drawing gridlines in a 2d-view
- *
- * - Currently, will return pointer to View2DGrid struct that needs to
- * be freed with UI_view2d_grid_free()
- * - Is used for scrollbar drawing too (for units drawing)
- * - Units + clamping args will be checked, to make sure they are valid values that can be used
- * so it is very possible that we won't return grid at all!
- *
- * - xunits,yunits = V2D_UNIT_* grid steps in seconds or frames
- * - xclamp,yclamp = V2D_CLAMP_* only show whole-number intervals
- * - winx = width of region we're drawing to, note: not used but keeping for completeness.
- * - winy = height of region we're drawing into
- */
-View2DGrid *UI_view2d_grid_calc(Scene *scene,
- View2D *v2d,
- short xunits,
- short xclamp,
- short yunits,
- short yclamp,
- int UNUSED(winx),
- int winy)
-{
-
- View2DGrid *grid;
- float space, seconddiv;
-
- /* check that there are at least some workable args */
- if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) && ELEM(V2D_ARG_DUMMY, yunits, yclamp)) {
- return NULL;
- }
-
- /* grid here is allocated... */
- grid = MEM_callocN(sizeof(View2DGrid), "View2DGrid");
-
- /* rule: gridstep is minimal GRIDSTEP pixels */
- if (xunits == V2D_UNIT_SECONDS) {
- seconddiv = (float)(0.01 * FPS);
- }
- else {
- seconddiv = 1.0f;
- }
-
- /* calculate x-axis grid scale (only if both args are valid) */
- if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
- space = BLI_rctf_size_x(&v2d->cur);
-
- if (space != 0.0f) {
- const float pixels = (float)BLI_rcti_size_x(&v2d->mask);
- if (pixels != 0.0f) {
- grid->dx = (U.v2d_min_gridsize * UI_DPI_FAC * space) / (seconddiv * pixels);
- step_to_grid(&grid->dx, xunits, &grid->powerx);
- grid->dx *= seconddiv;
- }
- }
-
- if (xclamp == V2D_GRID_CLAMP) {
- CLAMP_MIN(grid->dx, 0.1f);
- CLAMP_MIN(grid->powerx, 0);
- grid->powerx -= 2;
- }
- }
-
- /* calculate y-axis grid scale (only if both args are valid) */
- if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
- space = BLI_rctf_size_y(&v2d->cur);
- if (space != 0.0f) {
- const float pixels = (float)winy;
- if (pixels != 0.0f) {
- grid->dy = U.v2d_min_gridsize * UI_DPI_FAC * space / pixels;
- step_to_grid(&grid->dy, yunits, &grid->powery);
- }
- }
-
- if (yclamp == V2D_GRID_CLAMP) {
- CLAMP_MIN(grid->dy, 1.0f);
- CLAMP_MIN(grid->powery, 1);
- }
- }
-
- /* calculate start position */
- if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
- grid->startx = seconddiv * (v2d->cur.xmin / seconddiv -
- (float)fmod(v2d->cur.xmin / seconddiv, grid->dx / seconddiv));
- if (v2d->cur.xmin < 0.0f) {
- grid->startx -= grid->dx;
- }
- }
- else {
- grid->startx = v2d->cur.xmin;
- }
-
- if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
- grid->starty = (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy));
- if (v2d->cur.ymin < 0.0f) {
- grid->starty -= grid->dy;
- }
- }
- else {
- grid->starty = v2d->cur.ymin;
- }
-
- return grid;
-}
-
-/* Draw gridlines in the given 2d-region */
-void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
-{
- float vec1[2], vec2[2];
- int a, step;
- int vertical_minor_step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC);
- int horizontal_major_step = (BLI_rcti_size_y(&v2d->mask) + 1) /
- (U.v2d_min_gridsize * UI_DPI_FAC);
- uchar grid_line_color[3];
-
- /* check for grid first, as it may not exist */
- if (grid == NULL) {
- return;
- }
-
- /* Count the needed vertices for the gridlines */
- unsigned vertex_count = 0;
- if (flag & V2D_VERTICAL_LINES) {
- /* vertical lines */
- vertex_count += 2 * vertical_minor_step; /* minor gridlines */
- vertex_count += 2 * (vertical_minor_step + 2); /* major gridlines */
- }
- if (flag & V2D_HORIZONTAL_LINES) {
- /* horizontal lines */
- vertex_count += 2 * (horizontal_major_step + 1); /* major gridlines */
-
- /* fine lines */
- if (flag & V2D_HORIZONTAL_FINELINES) {
- vertex_count += 2 * (horizontal_major_step + 1);
- }
- }
- /* axes */
- if (flag & V2D_HORIZONTAL_AXIS) {
- vertex_count += 2;
- }
- if (flag & V2D_VERTICAL_AXIS) {
- vertex_count += 2;
- }
-
- /* If there is nothing to render, exit early */
- if (vertex_count == 0) {
- return;
- }
-
- GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint color = GPU_vertformat_attr_add(
- format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GPU_PRIM_LINES, vertex_count);
-
- /* vertical lines */
- if (flag & V2D_VERTICAL_LINES) {
- /* initialize initial settings */
- vec1[0] = vec2[0] = grid->startx;
- vec1[1] = grid->starty;
- vec2[1] = v2d->cur.ymax;
-
- /* minor gridlines */
- step = vertical_minor_step;
- if (step != 0) {
- UI_GetThemeColor3ubv(TH_GRID, grid_line_color);
-
- for (a = 0; a < step; a++) {
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
-
- vec2[0] = vec1[0] += grid->dx;
- }
- }
-
- /* major gridlines */
- vec2[0] = vec1[0] -= 0.5f * grid->dx;
-
- UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color);
-
- step++;
- for (a = 0; a <= step; a++) {
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
-
- vec2[0] = vec1[0] -= grid->dx;
- }
- }
-
- /* horizontal lines */
- if (flag & V2D_HORIZONTAL_LINES) {
- /* only major gridlines */
- vec1[1] = vec2[1] = grid->starty;
- vec1[0] = grid->startx;
- vec2[0] = v2d->cur.xmax;
-
- step = horizontal_major_step;
-
- UI_GetThemeColor3ubv(TH_GRID, grid_line_color);
-
- for (a = 0; a <= step; a++) {
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
-
- vec2[1] = vec1[1] += grid->dy;
- }
-
- /* fine grid lines */
- vec2[1] = vec1[1] -= 0.5f * grid->dy;
- step++;
-
- if (flag & V2D_HORIZONTAL_FINELINES) {
- UI_GetThemeColorShade3ubv(TH_GRID, 16, grid_line_color);
- for (a = 0; a < step; a++) {
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
-
- vec2[1] = vec1[1] -= grid->dy;
- }
- }
- }
-
- /* Axes are drawn as darker lines */
- UI_GetThemeColorShade3ubv(TH_GRID, -50, grid_line_color);
-
- /* horizontal axis */
- if (flag & V2D_HORIZONTAL_AXIS) {
- vec1[0] = v2d->cur.xmin;
- vec2[0] = v2d->cur.xmax;
- vec1[1] = vec2[1] = 0.0f;
-
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
- }
-
- /* vertical axis */
- if (flag & V2D_VERTICAL_AXIS) {
- vec1[1] = v2d->cur.ymin;
- vec2[1] = v2d->cur.ymax;
- vec1[0] = vec2[0] = 0.0f;
-
- immAttrSkip(color);
- immVertex2fv(pos, vec1);
- immAttr3ubv(color, grid_line_color);
- immVertex2fv(pos, vec2);
- }
-
- immEnd();
- immUnbindProgram();
-}
-
/* Draw a constant grid in given 2d-region */
void UI_view2d_constant_grid_draw(View2D *v2d, float step)
{
@@ -1716,135 +1397,6 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
immUnbindProgram();
}
-static void get_scale_indicator_text(
- const Scene *scene, float value, int brevity_level, short unit, uint max_length, char *r_str)
-{
- if (unit == V2D_UNIT_SECONDS) {
- BLI_timecode_string_from_time(
- r_str, max_length, brevity_level, value / (float)FPS, FPS, U.timecode_style);
- }
- else {
- BLI_timecode_string_from_time_seconds(r_str, max_length, brevity_level, value);
- }
-}
-
-void UI_view2d_grid_draw_numbers_horizontal(const Scene *scene,
- const View2D *v2d,
- const View2DGrid *grid,
- const rcti *rect,
- int unit,
- bool whole_numbers_only)
-{
- BLI_assert(grid);
- float xstep = grid->dx * UI_view2d_scale_get_x(v2d);
- if (xstep <= 0.0f) {
- return;
- }
-
- float initial_xpos = UI_view2d_view_to_region_x(v2d, grid->startx);
- float ypos = (float)rect->ymin + 2 * UI_DPI_FAC;
- float initial_value = grid->startx;
- float value_step = grid->dx;
- int brevity_level = grid->powerx;
-
- /* Make sure that the value_step is >= 1 when only whole numbers are displayed.
- * Otherwise the same number could be displayed more than once. */
- if (whole_numbers_only) {
- while (value_step < 0.9999f) {
- xstep *= 2.0f;
- value_step *= 2.0f;
- }
- }
-
- /* Skip first few steps if they don't intersect
- * the rectangle that will contain the numbers. */
- while (initial_xpos < rect->xmin) {
- initial_xpos += xstep;
- initial_value += value_step;
- }
-
- if (unit == V2D_UNIT_FRAMES) {
- brevity_level = 1;
- }
-
- const int font_id = BLF_default();
- UI_FontThemeColor(font_id, TH_TEXT);
-
- BLF_batch_draw_begin();
-
- for (float xpos = initial_xpos, value = initial_value; xpos < rect->xmax;
- xpos += xstep, value += value_step) {
- char text[32];
- get_scale_indicator_text(scene, value, brevity_level, unit, sizeof(text), text);
- float text_width = BLF_width(font_id, text, strlen(text));
- BLF_draw_default_ascii(xpos - text_width / 2.0f, ypos, 0.0f, text, sizeof(text));
- }
-
- BLF_batch_draw_end();
-}
-
-void UI_view2d_grid_draw_numbers_vertical(const Scene *scene,
- const View2D *v2d,
- const View2DGrid *grid,
- const rcti *rect,
- int unit,
- float text_offset)
-{
- BLI_assert(grid);
- float ystep = grid->dy * UI_view2d_scale_get_y(v2d);
- if (ystep <= 0.0f) {
- return;
- }
-
- const int font_id = BLF_default();
- UI_FontThemeColor(font_id, TH_TEXT);
-
- BLF_enable(font_id, BLF_ROTATION);
- BLF_rotation(font_id, M_PI_2);
-
- float initial_value = grid->starty;
- float value_step = grid->dy;
- float xpos = rect->xmax - 2.0f * UI_DPI_FAC;
- float initial_ypos = UI_view2d_view_to_region_y(v2d, grid->starty);
-
- /* Currently only used by the sequencer to display
- * channel numbers in the center. */
- initial_ypos += text_offset * ystep;
-
- /* Skip first few steps if they don't intersect
- * the rectangle that will contain the numbers. */
- while (initial_ypos < rect->ymin) {
- initial_ypos += ystep;
- initial_value += value_step;
- }
-
- for (float ypos = initial_ypos, value = initial_value; ypos < rect->ymax;
- ypos += ystep, value += value_step) {
- char text[32];
- get_scale_indicator_text(scene, value, grid->powery, unit, sizeof(text), text);
- float text_width = BLF_width(font_id, text, sizeof(text));
- BLF_draw_default_ascii(xpos, ypos - text_width / 2.0f, 0.0f, text, sizeof(text));
- }
-
- BLF_disable(font_id, BLF_ROTATION);
-}
-
-/* the price we pay for not exposting structs :( */
-void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy)
-{
- *r_dx = grid->dx;
- *r_dy = grid->dy;
-}
-
-/* free temporary memory used for drawing grid */
-void UI_view2d_grid_free(View2DGrid *grid)
-{
- /* only free if there's a grid */
- if (grid) {
- MEM_freeN(grid);
- }
-}
-
/* *********************************************************************** */
/* Scrollers */
@@ -1861,21 +1413,10 @@ struct View2DScrollers {
rcti hor, vert; /* exact size of slider backdrop */
int horfull, vertfull; /* set if sliders are full, we don't draw them */
-
- /* scales */
- View2DGrid *grid; /* grid for coordinate drawing */
- short xunits, xclamp; /* units and clamping options for x-axis */
- short yunits, yclamp; /* units and clamping options for y-axis */
};
/* Calculate relevant scroller properties */
-View2DScrollers *UI_view2d_scrollers_calc(const bContext *C,
- View2D *v2d,
- const rcti *mask_custom,
- short xunits,
- short xclamp,
- short yunits,
- short yclamp)
+View2DScrollers *UI_view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom)
{
View2DScrollers *scrollers;
rcti vert, hor;
@@ -2003,30 +1544,11 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C,
}
}
- /* grid markings on scrollbars */
- if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL | V2D_SCROLL_SCALE_VERTICAL)) {
- /* store clamping */
- scrollers->xclamp = xclamp;
- scrollers->xunits = xunits;
- scrollers->yclamp = yclamp;
- scrollers->yunits = yunits;
-
- scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C),
- v2d,
- xunits,
- xclamp,
- yunits,
- yclamp,
- BLI_rcti_size_x(&hor),
- BLI_rcti_size_y(&vert));
- }
-
- /* return scrollers */
return scrollers;
}
/* Draw scrollbars in the given 2d-region */
-void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs)
+void UI_view2d_scrollers_draw(View2D *v2d, View2DScrollers *vs)
{
bTheme *btheme = UI_GetTheme();
rcti vert, hor;
@@ -2073,13 +1595,6 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
}
UI_draw_widget_scroll(&wcol, &hor, &slider, state);
-
- {
- if (scroll & V2D_SCROLL_SCALE_HORIZONTAL) {
- UI_view2d_grid_draw_numbers_horizontal(
- CTX_data_scene(C), v2d, vs->grid, &vs->hor, vs->xunits, vs->xclamp == V2D_GRID_CLAMP);
- }
- }
}
/* vertical scrollbar */
@@ -2114,17 +1629,6 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
}
UI_draw_widget_scroll(&wcol, &vert, &slider, state);
-
- {
- if (scroll & V2D_SCROLL_SCALE_VERTICAL) {
- float text_offset = 0.0f;
- if (vs->yclamp & V2D_GRID_CLAMP) {
- text_offset = 0.5f;
- }
- UI_view2d_grid_draw_numbers_vertical(
- CTX_data_scene(C), v2d, vs->grid, &vs->vert, vs->yunits, text_offset);
- }
- }
}
/* Was changed above, so reset. */
@@ -2134,10 +1638,6 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* free temporary memory used for drawing scrollers */
void UI_view2d_scrollers_free(View2DScrollers *scrollers)
{
- /* need to free grid as well... */
- if (scrollers->grid) {
- MEM_freeN(scrollers->grid);
- }
MEM_freeN(scrollers);
}
@@ -2198,7 +1698,8 @@ void UI_view2d_listview_cell_to_view(View2D *v2d,
}
/**
- * Get the 'cell' (row, column) that the given 2D-view coordinates (i.e. in 'tot' rect space) lie in.
+ * Get the 'cell' (row, column) that the given 2D-view coordinates
+ * (i.e. in 'tot' rect space) lie in.
*
* \param columnwidth, rowheight: size of each 'cell'
* \param startx, starty: coordinates (in 'tot' rect space) that the list starts from.
@@ -2255,7 +1756,8 @@ void UI_view2d_listview_view_to_cell(View2D *v2d,
* Get the 'extreme' (min/max) column and row indices which are visible within the 'cur' rect
*
* \param columnwidth, rowheight: Size of each 'cell'
- * \param startx, starty: Coordinates that the list starts from, which should be (0,0) for most views
+ * \param startx, starty: Coordinates that the list starts from,
+ * which should be (0,0) for most views.
* \param column_min, column_max, row_min, row_max: The starting and ending column/row indices
*/
void UI_view2d_listview_visible_cells(View2D *v2d,
@@ -2613,27 +2115,54 @@ void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac)
char UI_view2d_mouse_in_scrollers_ex(
const ARegion *ar, const View2D *v2d, int x, int y, int *r_scroll)
{
- int co[2];
- int scroll = view2d_scroll_mapped(v2d->scroll);
+ const int scroll = view2d_scroll_mapped(v2d->scroll);
*r_scroll = scroll;
- /* clamp x,y to region-coordinates first */
- co[0] = x - ar->winrct.xmin;
- co[1] = y - ar->winrct.ymin;
-
- /* check if within scrollbars */
- if (scroll & V2D_SCROLL_HORIZONTAL) {
- if (IN_2D_HORIZ_SCROLL(v2d, co)) {
- return 'h';
+ if (scroll) {
+ /* Move to region-coordinates. */
+ const int co[2] = {
+ x - ar->winrct.xmin,
+ y - ar->winrct.ymin,
+ };
+ if (scroll & V2D_SCROLL_HORIZONTAL) {
+ if (IN_2D_HORIZ_SCROLL(v2d, co)) {
+ return 'h';
+ }
+ }
+ if (scroll & V2D_SCROLL_VERTICAL) {
+ if (IN_2D_VERT_SCROLL(v2d, co)) {
+ return 'v';
+ }
}
}
- if (scroll & V2D_SCROLL_VERTICAL) {
- if (IN_2D_VERT_SCROLL(v2d, co)) {
- return 'v';
+
+ return 0;
+}
+
+char UI_view2d_rect_in_scrollers_ex(const ARegion *ar,
+ const View2D *v2d,
+ const rcti *rect,
+ int *r_scroll)
+{
+ const int scroll = view2d_scroll_mapped(v2d->scroll);
+ *r_scroll = scroll;
+
+ if (scroll) {
+ /* Move to region-coordinates. */
+ rcti rect_region = *rect;
+ BLI_rcti_translate(&rect_region, -ar->winrct.xmin, ar->winrct.ymin);
+ if (scroll & V2D_SCROLL_HORIZONTAL) {
+ if (IN_2D_HORIZ_SCROLL_RECT(v2d, &rect_region)) {
+ return 'h';
+ }
+ }
+ if (scroll & V2D_SCROLL_VERTICAL) {
+ if (IN_2D_VERT_SCROLL_RECT(v2d, &rect_region)) {
+ return 'v';
+ }
}
}
- /* not found */
return 0;
}
@@ -2643,6 +2172,12 @@ char UI_view2d_mouse_in_scrollers(const ARegion *ar, const View2D *v2d, int x, i
return UI_view2d_mouse_in_scrollers_ex(ar, v2d, x, y, &scroll_dummy);
}
+char UI_view2d_rect_in_scrollers(const ARegion *ar, const View2D *v2d, const rcti *rect)
+{
+ int scroll_dummy = 0;
+ return UI_view2d_rect_in_scrollers_ex(ar, v2d, rect, &scroll_dummy);
+}
+
/* ******************* view2d text drawing cache ******************** */
typedef struct View2DString {
diff --git a/source/blender/editors/interface/view2d_draw.c b/source/blender/editors/interface/view2d_draw.c
new file mode 100644
index 00000000000..91128e49a60
--- /dev/null
+++ b/source/blender/editors/interface/view2d_draw.c
@@ -0,0 +1,526 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edinterface
+ */
+
+#include <float.h>
+#include <limits.h>
+#include <math.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_userdef_types.h"
+
+#include "BLI_array.h"
+#include "BLI_utildefines.h"
+#include "BLI_rect.h"
+#include "BLI_math.h"
+#include "BLI_timecode.h"
+#include "BLI_string.h"
+
+#include "GPU_immediate.h"
+#include "GPU_matrix.h"
+
+#include "WM_api.h"
+
+#include "BLF_api.h"
+
+#include "UI_interface.h"
+#include "UI_view2d.h"
+
+#include "interface_intern.h"
+
+/* Compute display grid resolution
+ ********************************************************/
+
+#define MIN_MAJOR_LINE_DISTANCE (UI_DPI_FAC * 50)
+
+static float select_major_distance(const float *possible_distances,
+ uint amount,
+ float pixel_width,
+ float view_width)
+{
+ BLI_assert(amount >= 1);
+
+ if (IS_EQF(view_width, 0.0f)) {
+ return possible_distances[0];
+ }
+
+ float pixels_per_view_unit = pixel_width / view_width;
+
+ for (uint i = 0; i < amount; i++) {
+ float distance = possible_distances[i];
+ if (pixels_per_view_unit * distance >= MIN_MAJOR_LINE_DISTANCE) {
+ return distance;
+ }
+ }
+ return possible_distances[amount - 1];
+}
+
+static const float discrete_value_scales[] = {
+ 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000};
+
+static const float continuous_value_scales[] = {0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2,
+ 5, 10, 20, 50, 100, 200, 500, 1000,
+ 2000, 5000, 10000, 20000, 50000, 100000};
+
+static uint view2d_major_step_x__discrete(const View2D *v2d)
+{
+ return select_major_distance(discrete_value_scales,
+ ARRAY_SIZE(discrete_value_scales),
+ BLI_rcti_size_x(&v2d->mask),
+ BLI_rctf_size_x(&v2d->cur));
+}
+
+static float view2d_major_step_x__continuous(const View2D *v2d)
+{
+ return select_major_distance(continuous_value_scales,
+ ARRAY_SIZE(continuous_value_scales),
+ BLI_rcti_size_x(&v2d->mask),
+ BLI_rctf_size_x(&v2d->cur));
+}
+
+static float view2d_major_step_y__continuous(const View2D *v2d)
+{
+ return select_major_distance(continuous_value_scales,
+ ARRAY_SIZE(continuous_value_scales),
+ BLI_rcti_size_y(&v2d->mask),
+ BLI_rctf_size_y(&v2d->cur));
+}
+
+static float view2d_major_step_x__time(const View2D *v2d, const Scene *scene)
+{
+ double fps = FPS;
+
+ float *possible_distances = NULL;
+ BLI_array_staticdeclare(possible_distances, 32);
+
+ for (uint step = 1; step < fps; step *= 2) {
+ BLI_array_append(possible_distances, step);
+ }
+ BLI_array_append(possible_distances, fps);
+ BLI_array_append(possible_distances, 2 * fps);
+ BLI_array_append(possible_distances, 5 * fps);
+ BLI_array_append(possible_distances, 10 * fps);
+ BLI_array_append(possible_distances, 30 * fps);
+ BLI_array_append(possible_distances, 60 * fps);
+ BLI_array_append(possible_distances, 2 * 60 * fps);
+ BLI_array_append(possible_distances, 5 * 60 * fps);
+ BLI_array_append(possible_distances, 10 * 60 * fps);
+ BLI_array_append(possible_distances, 30 * 60 * fps);
+ BLI_array_append(possible_distances, 60 * 60 * fps);
+
+ float distance = select_major_distance(possible_distances,
+ BLI_array_len(possible_distances),
+ BLI_rcti_size_x(&v2d->mask),
+ BLI_rctf_size_x(&v2d->cur));
+
+ BLI_array_free(possible_distances);
+ return distance;
+}
+
+/* Draw parallel lines
+ ************************************/
+
+typedef struct ParallelLinesSet {
+ float offset;
+ float distance;
+} ParallelLinesSet;
+
+static void get_parallel_lines_draw_steps(const ParallelLinesSet *lines,
+ float region_start,
+ float region_end,
+ float *r_first,
+ uint *r_steps)
+{
+ BLI_assert(lines->distance > 0);
+ BLI_assert(region_start <= region_end);
+
+ *r_first = ceilf((region_start - lines->offset) / lines->distance) * lines->distance +
+ lines->offset;
+
+ if (region_start <= *r_first && region_end >= *r_first) {
+ *r_steps = MAX2(0, floorf((region_end - *r_first) / lines->distance)) + 1;
+ }
+ else {
+ *r_steps = 0;
+ }
+}
+
+static void draw_parallel_lines(const ParallelLinesSet *lines,
+ const rctf *rect,
+ const uchar *color,
+ char direction)
+{
+ float first;
+ uint steps;
+
+ if (direction == 'v') {
+ get_parallel_lines_draw_steps(lines, rect->xmin, rect->xmax, &first, &steps);
+ }
+ else {
+ BLI_assert(direction == 'h');
+ get_parallel_lines_draw_steps(lines, rect->ymin, rect->ymax, &first, &steps);
+ }
+
+ if (steps == 0) {
+ return;
+ }
+
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor3ubv(color);
+ immBegin(GPU_PRIM_LINES, steps * 2);
+
+ if (direction == 'v') {
+ for (uint i = 0; i < steps; i++) {
+ float xpos = first + i * lines->distance;
+ immVertex2f(pos, xpos, rect->ymin);
+ immVertex2f(pos, xpos, rect->ymax);
+ }
+ }
+ else {
+ for (uint i = 0; i < steps; i++) {
+ float ypos = first + i * lines->distance;
+ immVertex2f(pos, rect->xmin, ypos);
+ immVertex2f(pos, rect->xmax, ypos);
+ }
+ }
+
+ immEnd();
+ immUnbindProgram();
+}
+
+static void view2d_draw_lines_internal(const View2D *v2d,
+ const ParallelLinesSet *lines,
+ const uchar *color,
+ char direction)
+{
+ GPU_matrix_push_projection();
+ UI_view2d_view_ortho(v2d);
+ draw_parallel_lines(lines, &v2d->cur, color, direction);
+ GPU_matrix_pop_projection();
+}
+
+static void view2d_draw_lines(const View2D *v2d,
+ float major_distance,
+ bool display_minor_lines,
+ char direction)
+{
+ uchar major_color[3];
+ uchar minor_color[3];
+ UI_GetThemeColor3ubv(TH_GRID, major_color);
+ UI_GetThemeColorShade3ubv(TH_GRID, 16, minor_color);
+
+ ParallelLinesSet major_lines;
+ major_lines.distance = major_distance;
+ major_lines.offset = 0;
+ view2d_draw_lines_internal(v2d, &major_lines, major_color, direction);
+
+ if (display_minor_lines) {
+ ParallelLinesSet minor_lines;
+ minor_lines.distance = major_distance;
+ minor_lines.offset = major_distance / 2.0f;
+ view2d_draw_lines_internal(v2d, &minor_lines, minor_color, direction);
+ }
+}
+
+/* Scale indicator text drawing
+ **************************************************/
+
+typedef void (*PositionToString)(
+ void *user_data, float v2d_pos, float v2d_step, uint max_len, char *r_str);
+
+static void draw_horizontal_scale_indicators(const ARegion *ar,
+ const View2D *v2d,
+ float distance,
+ const rcti *rect,
+ PositionToString to_string,
+ void *to_string_data)
+{
+ GPU_matrix_push_projection();
+ wmOrtho2_region_pixelspace(ar);
+
+ float start;
+ uint steps;
+ {
+ ParallelLinesSet lines;
+ lines.distance = distance;
+ lines.offset = 0;
+ get_parallel_lines_draw_steps(&lines,
+ UI_view2d_region_to_view_x(v2d, rect->xmin),
+ UI_view2d_region_to_view_x(v2d, rect->xmax),
+ &start,
+ &steps);
+ }
+
+ const int font_id = BLF_default();
+ UI_FontThemeColor(font_id, TH_TEXT);
+
+ BLF_batch_draw_begin();
+
+ float ypos = rect->ymin + 4 * UI_DPI_FAC;
+ float xmin = rect->xmin;
+ float xmax = rect->xmax;
+
+ for (uint i = 0; i < steps; i++) {
+ float xpos_view = start + i * distance;
+ float xpos_region = UI_view2d_view_to_region_x(v2d, xpos_view);
+ char text[32];
+ to_string(to_string_data, xpos_view, distance, sizeof(text), text);
+ float text_width = BLF_width(font_id, text, strlen(text));
+
+ if (xpos_region - text_width / 2.0f >= xmin && xpos_region + text_width / 2.0f <= xmax) {
+ BLF_draw_default_ascii(xpos_region - text_width / 2.0f, ypos, 0.0f, text, sizeof(text));
+ }
+ }
+
+ BLF_batch_draw_end();
+
+ GPU_matrix_pop_projection();
+}
+
+static void draw_vertical_scale_indicators(const ARegion *ar,
+ const View2D *v2d,
+ float distance,
+ float display_offset,
+ const rcti *rect,
+ PositionToString to_string,
+ void *to_string_data)
+{
+ GPU_matrix_push_projection();
+ wmOrtho2_region_pixelspace(ar);
+
+ float start;
+ uint steps;
+ {
+ ParallelLinesSet lines;
+ lines.distance = distance;
+ lines.offset = 0;
+ get_parallel_lines_draw_steps(&lines,
+ UI_view2d_region_to_view_y(v2d, rect->ymin),
+ UI_view2d_region_to_view_y(v2d, rect->ymax),
+ &start,
+ &steps);
+ }
+
+ const int font_id = BLF_default();
+ UI_FontThemeColor(font_id, TH_TEXT);
+
+ BLF_enable(font_id, BLF_ROTATION);
+ BLF_rotation(font_id, M_PI_2);
+
+ BLF_batch_draw_begin();
+
+ float xpos = rect->xmax - 2.0f * UI_DPI_FAC;
+ float ymin = rect->ymin;
+ float ymax = rect->ymax;
+
+ for (uint i = 0; i < steps; i++) {
+ float ypos_view = start + i * distance;
+ float ypos_region = UI_view2d_view_to_region_y(v2d, ypos_view + display_offset);
+ char text[32];
+ to_string(to_string_data, ypos_view, distance, sizeof(text), text);
+ float text_width = BLF_width(font_id, text, strlen(text));
+
+ if (ypos_region - text_width / 2.0f >= ymin && ypos_region + text_width / 2.0f <= ymax) {
+ BLF_draw_default_ascii(xpos, ypos_region - text_width / 2.0f, 0.0f, text, sizeof(text));
+ }
+ }
+
+ BLF_batch_draw_end();
+ BLF_disable(font_id, BLF_ROTATION);
+
+ GPU_matrix_pop_projection();
+}
+
+static void view_to_string__frame_number(
+ void *UNUSED(user_data), float v2d_pos, float UNUSED(v2d_step), uint max_len, char *r_str)
+{
+ BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos);
+}
+
+static void view_to_string__time(
+ void *user_data, float v2d_pos, float UNUSED(v2d_step), uint max_len, char *r_str)
+{
+ const Scene *scene = (const Scene *)user_data;
+
+ int brevity_level = 0;
+ BLI_timecode_string_from_time(
+ r_str, max_len, brevity_level, v2d_pos / (float)FPS, FPS, U.timecode_style);
+}
+
+static void view_to_string__value(
+ void *UNUSED(user_data), float v2d_pos, float v2d_step, uint max_len, char *r_str)
+{
+ if (v2d_step >= 1.0f) {
+ BLI_snprintf(r_str, max_len, "%d", (int)v2d_pos);
+ }
+ else if (v2d_step >= 0.1f) {
+ BLI_snprintf(r_str, max_len, "%.1f", v2d_pos);
+ }
+ else if (v2d_step >= 0.01f) {
+ BLI_snprintf(r_str, max_len, "%.2f", v2d_pos);
+ }
+ else {
+ BLI_snprintf(r_str, max_len, "%.3f", v2d_pos);
+ }
+}
+
+/* Grid Resolution API
+ **************************************************/
+
+float UI_view2d_grid_resolution_x__frames_or_seconds(const struct View2D *v2d,
+ const struct Scene *scene,
+ bool display_seconds)
+{
+ if (display_seconds) {
+ return view2d_major_step_x__time(v2d, scene);
+ }
+ else {
+ return view2d_major_step_x__continuous(v2d);
+ }
+}
+
+float UI_view2d_grid_resolution_y__values(const struct View2D *v2d)
+{
+ return view2d_major_step_y__continuous(v2d);
+}
+
+/* Line Drawing API
+ **************************************************/
+
+void UI_view2d_draw_lines_x__discrete_values(const View2D *v2d)
+{
+ uint major_line_distance = view2d_major_step_x__discrete(v2d);
+ view2d_draw_lines(v2d, major_line_distance, major_line_distance > 1, 'v');
+}
+
+void UI_view2d_draw_lines_x__values(const View2D *v2d)
+{
+ float major_line_distance = view2d_major_step_x__continuous(v2d);
+ view2d_draw_lines(v2d, major_line_distance, true, 'v');
+}
+
+void UI_view2d_draw_lines_y__values(const View2D *v2d)
+{
+ float major_line_distance = view2d_major_step_y__continuous(v2d);
+ view2d_draw_lines(v2d, major_line_distance, true, 'h');
+}
+
+void UI_view2d_draw_lines_x__discrete_time(const View2D *v2d, const Scene *scene)
+{
+ float major_line_distance = view2d_major_step_x__time(v2d, scene);
+ view2d_draw_lines(v2d, major_line_distance, major_line_distance > 1, 'v');
+}
+
+void UI_view2d_draw_lines_x__discrete_frames_or_seconds(const View2D *v2d,
+ const Scene *scene,
+ bool display_seconds)
+{
+ if (display_seconds) {
+ UI_view2d_draw_lines_x__discrete_time(v2d, scene);
+ }
+ else {
+ UI_view2d_draw_lines_x__discrete_values(v2d);
+ }
+}
+
+void UI_view2d_draw_lines_x__frames_or_seconds(const View2D *v2d,
+ const Scene *scene,
+ bool display_seconds)
+{
+ if (display_seconds) {
+ UI_view2d_draw_lines_x__discrete_time(v2d, scene);
+ }
+ else {
+ UI_view2d_draw_lines_x__values(v2d);
+ }
+}
+
+/* Scale indicator text drawing API
+ **************************************************/
+
+void UI_view2d_draw_scale_x__discrete_values(const ARegion *ar,
+ const View2D *v2d,
+ const rcti *rect)
+{
+ float number_step = view2d_major_step_x__discrete(v2d);
+ draw_horizontal_scale_indicators(ar, v2d, number_step, rect, view_to_string__frame_number, NULL);
+}
+
+void UI_view2d_draw_scale_x__discrete_time(const ARegion *ar,
+ const View2D *v2d,
+ const rcti *rect,
+ const Scene *scene)
+{
+ float step = view2d_major_step_x__time(v2d, scene);
+ draw_horizontal_scale_indicators(ar, v2d, step, rect, view_to_string__time, (void *)scene);
+}
+
+void UI_view2d_draw_scale_x__values(const ARegion *ar, const View2D *v2d, const rcti *rect)
+{
+ float step = view2d_major_step_x__continuous(v2d);
+ draw_horizontal_scale_indicators(ar, v2d, step, rect, view_to_string__value, NULL);
+}
+
+void UI_view2d_draw_scale_y__values(const ARegion *ar, const View2D *v2d, const rcti *rect)
+{
+ float step = view2d_major_step_y__continuous(v2d);
+ draw_vertical_scale_indicators(ar, v2d, step, 0.0f, rect, view_to_string__value, NULL);
+}
+
+void UI_view2d_draw_scale_y__block(const ARegion *ar, const View2D *v2d, const rcti *rect)
+{
+ draw_vertical_scale_indicators(ar, v2d, 1.0f, 0.5f, rect, view_to_string__value, NULL);
+}
+
+void UI_view2d_draw_scale_x__discrete_frames_or_seconds(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ const struct Scene *scene,
+ bool display_seconds)
+{
+ if (display_seconds) {
+ UI_view2d_draw_scale_x__discrete_time(ar, v2d, rect, scene);
+ }
+ else {
+ UI_view2d_draw_scale_x__discrete_values(ar, v2d, rect);
+ }
+}
+
+void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *ar,
+ const struct View2D *v2d,
+ const struct rcti *rect,
+ const struct Scene *scene,
+ bool display_seconds)
+{
+ if (display_seconds) {
+ UI_view2d_draw_scale_x__discrete_time(ar, v2d, rect, scene);
+ }
+ else {
+ UI_view2d_draw_scale_x__values(ar, v2d, rect);
+ }
+}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 855ad0306c4..ab8d1cf9bf6 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1183,8 +1183,9 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
vzd->dx += dx;
vzd->dy += dy;
- /* store mouse coordinates for next time, if not doing continuous zoom
- * - continuous zoom only depends on distance of mouse to starting point to determine rate of change
+ /* Store mouse coordinates for next time, if not doing continuous zoom:
+ * - Continuous zoom only depends on distance of mouse
+ * to starting point to determine rate of change.
*/
if (U.viewzoom != USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
vzd->lastx = event->x;
@@ -1647,9 +1648,11 @@ typedef struct v2dScrollerMove {
/**
* #View2DScrollers is typedef'd in UI_view2d.h
- * This is a CUT DOWN VERSION of the 'real' version, which is defined in view2d.c, as we only need focus bubble info
+ * This is a CUT DOWN VERSION of the 'real' version, which is defined in view2d.c,
+ * as we only need focus bubble info.
*
- * \warning: The start of this struct must not change, so that it stays in sync with the 'real' version
+ * \warning: The start of this struct must not change,
+ * so that it stays in sync with the 'real' version.
* For now, we don't need to have a separate (internal) header for structs like this...
*/
struct View2DScrollers {
@@ -1782,8 +1785,7 @@ static void scroller_activate_init(bContext *C,
/* 'zone' depends on where mouse is relative to bubble
* - zooming must be allowed on this axis, otherwise, default to pan
*/
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
/* use a union of 'cur' & 'tot' incase the current view is far outside 'tot'. In this cases
* moving the scroll bars has far too little effect and the view can get stuck T31476. */
diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt
index fbbb8621ae6..5a35b251d0c 100644
--- a/source/blender/editors/io/CMakeLists.txt
+++ b/source/blender/editors/io/CMakeLists.txt
@@ -17,16 +17,16 @@
set(INC
../include
+ ../../alembic
../../blenkernel
../../blenlib
../../blentranslation
../../bmesh
+ ../../collada
../../depsgraph
../../makesdna
../../makesrna
../../windowmanager
- ../../collada
- ../../alembic
../../../../intern/guardedalloc
)
diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c
index dc8e33c817e..2f3e73f32d5 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -504,10 +504,12 @@ static int cmp_frame(const void *a, const void *b)
const CacheFrame *frame_a = a;
const CacheFrame *frame_b = b;
- if (frame_a->framenr < frame_b->framenr)
+ if (frame_a->framenr < frame_b->framenr) {
return -1;
- if (frame_a->framenr > frame_b->framenr)
+ }
+ if (frame_a->framenr > frame_b->framenr) {
return 1;
+ }
return 0;
}
diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c
index 6358c2c1370..3dd3b20bda3 100644
--- a/source/blender/editors/io/io_cache.c
+++ b/source/blender/editors/io/io_cache.c
@@ -38,6 +38,8 @@
#include "RNA_access.h"
+#include "DEG_depsgraph.h"
+
#include "UI_interface.h"
#include "WM_api.h"
@@ -93,7 +95,7 @@ static int cachefile_open_exec(bContext *C, wmOperator *op)
CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filename), 0);
BLI_strncpy(cache_file->filepath, filename, FILE_MAX);
- BKE_cachefile_reload(bmain, cache_file);
+ DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE);
/* Will be set when running invoke, not exec directly. */
if (op->customdata != NULL) {
@@ -137,7 +139,7 @@ void CACHEFILE_OT_open(wmOperatorType *ot)
/* ***************************** Reload Operator **************************** */
-static int cachefile_reload_exec(bContext *C, wmOperator *op)
+static int cachefile_reload_exec(bContext *C, wmOperator *UNUSED(op))
{
CacheFile *cache_file = CTX_data_edit_cachefile(C);
@@ -145,14 +147,10 @@ static int cachefile_reload_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- Main *bmain = CTX_data_main(C);
-
- BLI_freelistN(&cache_file->object_paths);
- BKE_cachefile_reload(bmain, cache_file);
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ BKE_cachefile_reload(depsgraph, cache_file);
return OPERATOR_FINISHED;
-
- UNUSED_VARS(op);
}
void CACHEFILE_OT_reload(wmOperatorType *ot)
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index af2366e7485..aa0c2b58468 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -60,10 +60,12 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *
char filepath[FILE_MAX];
const char *blendfile_path = BKE_main_blendfile_path(bmain);
- if (blendfile_path[0] == '\0')
+ if (blendfile_path[0] == '\0') {
BLI_strncpy(filepath, "untitled", sizeof(filepath));
- else
+ }
+ else {
BLI_strncpy(filepath, blendfile_path, sizeof(filepath));
+ }
BLI_path_extension_replace(filepath, sizeof(filepath), ".dae");
RNA_string_set(op->ptr, "filepath", filepath);
@@ -179,7 +181,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
/* get editmode results */
ED_object_editmode_load(bmain, CTX_data_edit_object(C));
- //Scene *scene = CTX_data_scene(C);
+ // Scene *scene = CTX_data_scene(C);
ExportSettings export_settings;
@@ -233,10 +235,12 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
export_settings.keep_bind_info = keep_bind_info != 0;
int includeFilter = OB_REL_NONE;
- if (export_settings.include_armatures)
+ if (export_settings.include_armatures) {
includeFilter |= OB_REL_MOD_ARMATURE;
- if (export_settings.include_children)
+ }
+ if (export_settings.include_children) {
includeFilter |= OB_REL_CHILDREN_RECURSIVE;
+ }
export_count = collada_export(C, &export_settings);
@@ -813,7 +817,7 @@ void WM_OT_collada_import(wmOperatorType *ot)
ot->exec = wm_collada_import_exec;
ot->poll = WM_operator_winactive;
- //ot->flag |= OPTYPE_PRESET;
+ // ot->flag |= OPTYPE_PRESET;
ot->ui = wm_collada_import_draw;
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index 782c0644313..7e89ed9511f 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -582,8 +582,9 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, const flo
} *data = userData;
float dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
- if ((bp->f1 & SELECT) && data->select)
+ if ((bp->f1 & SELECT) && data->select) {
dist_test += 5.0f;
+ }
if (dist_test < data->dist) {
data->dist = dist_test;
diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.c
index 8ef383de552..0cfe59ef06c 100644
--- a/source/blender/editors/lattice/editlattice_tools.c
+++ b/source/blender/editors/lattice/editlattice_tools.c
@@ -57,8 +57,9 @@ static bool make_regular_poll(bContext *C)
{
Object *ob;
- if (ED_operator_editlattice(C))
+ if (ED_operator_editlattice(C)) {
return 1;
+ }
ob = CTX_data_active_object(C);
return (ob && ob->type == OB_LATTICE);
diff --git a/source/blender/editors/lattice/editlattice_undo.c b/source/blender/editors/lattice/editlattice_undo.c
index 9ee2e8b563b..166201adc15 100644
--- a/source/blender/editors/lattice/editlattice_undo.c
+++ b/source/blender/editors/lattice/editlattice_undo.c
@@ -102,8 +102,7 @@ static int validate_undoLatt(void *data, void *edata)
UndoLattice *ult = (UndoLattice *)data;
EditLatt *editlatt = (EditLatt *)edata;
- return (ult->pntsu == editlatt->latt->pntsu &&
- ult->pntsv == editlatt->latt->pntsv &&
+ return (ult->pntsu == editlatt->latt->pntsu && ult->pntsv == editlatt->latt->pntsv &&
ult->pntsw == editlatt->latt->pntsw);
}
#endif
diff --git a/source/blender/editors/mask/CMakeLists.txt b/source/blender/editors/mask/CMakeLists.txt
index 9dabcc0e8bb..81c861ab4e4 100644
--- a/source/blender/editors/mask/CMakeLists.txt
+++ b/source/blender/editors/mask/CMakeLists.txt
@@ -26,8 +26,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 1c872e73226..3c456f9e2e2 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -126,8 +126,9 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
dist_sq = dist_squared_to_line_segment_v2(co, a, b);
if (dist_sq < dist_best_sq) {
- if (tangent)
+ if (tangent) {
sub_v2_v2v2(tangent, &diff_points[2 * j + 2], &diff_points[2 * j]);
+ }
point_masklay = masklay;
point_spline = spline;
@@ -138,8 +139,9 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
}
}
- if (feather_points)
+ if (feather_points) {
MEM_freeN(feather_points);
+ }
MEM_freeN(diff_points);
}
@@ -148,14 +150,17 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
}
if (point && dist_best_sq < threshold) {
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = point_masklay;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = point_spline;
+ }
- if (point_r)
+ if (point_r) {
*point_r = point;
+ }
if (u_r) {
/* TODO(sergey): Projection fails in some weirdo cases.. */
@@ -173,14 +178,17 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
return true;
}
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = NULL;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = NULL;
+ }
- if (point_r)
+ if (point_r) {
*point_r = NULL;
+ }
return false;
}
@@ -702,8 +710,9 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op)
RNA_float_get_array(op->ptr, "location", co);
point = ED_mask_point_find_nearest(C, mask, co, threshold, NULL, NULL, NULL, NULL);
- if (point)
+ if (point) {
return OPERATOR_FINISHED;
+ }
if (ED_mask_find_nearest_diff_point(
C, mask, co, threshold, true, NULL, true, true, &masklay, &spline, &point, &u, NULL)) {
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 479e4fd2d6c..305e3a328ab 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -203,11 +203,13 @@ static void draw_spline_points(const bContext *C,
float(*feather_points)[2], (*fp)[2];
float min[2], max[2];
- if (!spline->tot_point)
+ if (!spline->tot_point) {
return;
+ }
- if (sc)
+ if (sc) {
undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT);
+ }
/* TODO, add this to sequence editor */
float handle_size = 2.0f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
@@ -233,8 +235,9 @@ static void draw_spline_points(const bContext *C,
copy_v2_v2(feather_point, *fp);
- if (undistort)
+ if (undistort) {
mask_point_undistort_pos(sc, feather_point, feather_point);
+ }
if (j == 0) {
sel = MASKPOINT_ISSEL_ANY(point);
@@ -244,10 +247,12 @@ static void draw_spline_points(const bContext *C,
}
if (sel) {
- if (point == masklay->act_point)
+ if (point == masklay->act_point) {
immUniformColor3f(1.0f, 1.0f, 1.0f);
- else
+ }
+ else {
immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX_SELECT, 0, 255);
+ }
}
else {
immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX, 0, 255);
@@ -314,13 +319,16 @@ static void draw_spline_points(const bContext *C,
/* draw CV point */
if (MASKPOINT_ISSEL_KNOT(point)) {
- if (point == masklay->act_point)
+ if (point == masklay->act_point) {
immUniformColor3f(1.0f, 1.0f, 1.0f);
- else
+ }
+ else {
immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX_SELECT, 0, 255);
+ }
}
- else
+ else {
immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX, 0, 255);
+ }
immBegin(GPU_PRIM_POINTS, 1);
immVertex2fv(pos, vert);
@@ -502,8 +510,9 @@ static void mask_draw_curve_type(const bContext *C,
BLI_assert(false);
}
- if (points != orig_points)
+ if (points != orig_points) {
MEM_freeN(points);
+ }
}
static void draw_spline_curve(const bContext *C,
@@ -533,8 +542,9 @@ static void draw_spline_curve(const bContext *C,
diff_points = BKE_mask_spline_differentiate_with_resolution(spline, &tot_diff_point, resol);
- if (!diff_points)
+ if (!diff_points) {
return;
+ }
if (is_smooth) {
GPU_line_smooth(true);
@@ -633,8 +643,9 @@ void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type)
Mask *mask = CTX_data_edit_mask(C);
int width, height;
- if (!mask)
+ if (!mask) {
return;
+ }
ED_mask_get_size(sa, &width, &height);
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index 7325686d4f0..0c5591ed89b 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -374,8 +374,9 @@ bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2])
MaskLayer *mask_layer;
bool ok = false;
- if (mask == NULL)
+ if (mask == NULL) {
return ok;
+ }
INIT_MINMAX2(min, max);
for (mask_layer = mask->masklayers.first; mask_layer != NULL; mask_layer = mask_layer->next) {
@@ -519,6 +520,6 @@ void ED_operatormacros_mask(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MASK_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c
index d30e62d89f5..985fa58cace 100644
--- a/source/blender/editors/mask/mask_editaction.c
+++ b/source/blender/editors/mask/mask_editaction.c
@@ -60,15 +60,17 @@ bool ED_masklayer_frames_looper(MaskLayer *masklay,
MaskLayerShape *masklay_shape;
/* error checker */
- if (masklay == NULL)
+ if (masklay == NULL) {
return false;
+ }
/* do loop */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next) {
/* execute callback */
- if (masklay_shape_cb(masklay_shape, scene))
+ if (masklay_shape_cb(masklay_shape, scene)) {
return true;
+ }
}
/* nothing to return */
@@ -85,8 +87,9 @@ void ED_masklayer_make_cfra_list(MaskLayer *masklay, ListBase *elems, bool onlys
CfraElem *ce;
/* error checking */
- if (ELEM(NULL, masklay, elems))
+ if (ELEM(NULL, masklay, elems)) {
return;
+ }
/* loop through mask-frames, adding */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
@@ -111,14 +114,16 @@ bool ED_masklayer_frame_select_check(MaskLayer *masklay)
MaskLayerShape *masklay_shape;
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return 0;
+ }
/* stop at the first one found */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next) {
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
return 1;
+ }
}
/* not found */
@@ -128,8 +133,9 @@ bool ED_masklayer_frame_select_check(MaskLayer *masklay)
/* helper function - select mask-frame based on SELECT_* mode */
static void masklayshape_select(MaskLayerShape *masklay_shape, short select_mode)
{
- if (masklay_shape == NULL)
+ if (masklay_shape == NULL) {
return;
+ }
switch (select_mode) {
case SELECT_ADD:
@@ -150,8 +156,9 @@ void ED_mask_select_frames(MaskLayer *masklay, short select_mode)
MaskLayerShape *masklay_shape;
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* handle according to mode */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
@@ -164,8 +171,9 @@ void ED_mask_select_frames(MaskLayer *masklay, short select_mode)
void ED_masklayer_frame_select_set(MaskLayer *masklay, short mode)
{
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* now call the standard function */
ED_mask_select_frames(masklay, mode);
@@ -176,8 +184,9 @@ void ED_mask_select_frame(MaskLayer *masklay, int selx, short select_mode)
{
MaskLayerShape *masklay_shape;
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
masklay_shape = BKE_mask_layer_shape_find_frame(masklay, selx);
@@ -191,14 +200,16 @@ void ED_masklayer_frames_select_box(MaskLayer *masklay, float min, float max, sh
{
MaskLayerShape *masklay_shape;
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* only select those frames which are in bounds */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next) {
- if (IN_RANGE(masklay_shape->frame, min, max))
+ if (IN_RANGE(masklay_shape->frame, min, max)) {
masklayshape_select(masklay_shape, select_mode);
+ }
}
}
@@ -210,8 +221,9 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked,
{
MaskLayerShape *masklay_shape;
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* only select frames which are within the region */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
@@ -225,13 +237,15 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked,
/* check the necessary regions */
if (tool == BEZT_OK_CHANNEL_LASSO) {
/* Lasso */
- if (keyframe_region_lasso_test(ked->data, pt))
+ if (keyframe_region_lasso_test(ked->data, pt)) {
masklayshape_select(masklay_shape, select_mode);
+ }
}
else if (tool == BEZT_OK_CHANNEL_CIRCLE) {
/* Circle */
- if (keyframe_region_circle_test(ked->data, pt))
+ if (keyframe_region_circle_test(ked->data, pt)) {
masklayshape_select(masklay_shape, select_mode);
+ }
}
}
}
@@ -246,8 +260,9 @@ bool ED_masklayer_frames_delete(MaskLayer *masklay)
bool changed = false;
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return false;
+ }
/* check for frames to delete */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
@@ -269,8 +284,9 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay)
MaskLayerShape *masklay_shape, *gpfn;
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* duplicate selected frames */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = gpfn) {
@@ -295,31 +311,35 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay)
static short snap_masklayer_nearest(MaskLayerShape *masklay_shape, Scene *UNUSED(scene))
{
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
masklay_shape->frame = (int)(floor(masklay_shape->frame + 0.5));
+ }
return 0;
}
static short snap_masklayer_nearestsec(MaskLayerShape *masklay_shape, Scene *scene)
{
float secf = (float)FPS;
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
masklay_shape->frame = (int)(floorf(masklay_shape->frame / secf + 0.5f) * secf);
+ }
return 0;
}
static short snap_masklayer_cframe(MaskLayerShape *masklay_shape, Scene *scene)
{
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
masklay_shape->frame = (int)CFRA;
+ }
return 0;
}
static short snap_masklayer_nearmarker(MaskLayerShape *masklay_shape, Scene *scene)
{
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
masklay_shape->frame = (int)ED_markers_find_nearest_marker_time(&scene->markers,
(float)masklay_shape->frame);
+ }
return 0;
}
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 2b925b9095e..c0f3b1f8338 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -179,29 +179,36 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
}
if (len_sq < threshold_sq) {
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = point_masklay;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = point_spline;
+ }
- if (which_handle_r)
+ if (which_handle_r) {
*which_handle_r = which_handle;
+ }
- if (score)
+ if (score) {
*score = sqrtf(len_sq);
+ }
return point;
}
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = NULL;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = NULL;
+ }
- if (which_handle_r)
+ if (which_handle_r) {
*which_handle_r = MASK_WHICH_HANDLE_NONE;
+ }
return NULL;
}
@@ -238,7 +245,7 @@ bool ED_mask_feather_find_nearest(const bContext *C,
MaskSpline *spline;
for (spline = masklay->splines.first; spline; spline = spline->next) {
- //MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
+ // MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
int i, tot_feather_point;
float(*feather_points)[2], (*fp)[2];
@@ -262,10 +269,12 @@ bool ED_mask_feather_find_nearest(const bContext *C,
cur_len_sq = len_squared_v2v2(vec, co);
if (point == NULL || cur_len_sq < len) {
- if (j == 0)
+ if (j == 0) {
uw = NULL;
- else
+ }
+ else {
uw = &cur_point->uw[j - 1];
+ }
point_masklay = masklay;
point_spline = spline;
@@ -282,32 +291,40 @@ bool ED_mask_feather_find_nearest(const bContext *C,
}
if (len < threshold_sq) {
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = point_masklay;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = point_spline;
+ }
- if (point_r)
+ if (point_r) {
*point_r = point;
+ }
- if (uw_r)
+ if (uw_r) {
*uw_r = uw;
+ }
- if (score)
+ if (score) {
*score = sqrtf(len);
+ }
return true;
}
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = NULL;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = NULL;
+ }
- if (point_r)
+ if (point_r) {
*point_r = NULL;
+ }
return false;
}
@@ -720,10 +737,12 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
}
if (cv_point && action == SLIDE_ACTION_NONE) {
- if (which_handle != MASK_WHICH_HANDLE_NONE)
+ if (which_handle != MASK_WHICH_HANDLE_NONE) {
action = SLIDE_ACTION_HANDLE;
- else
+ }
+ else {
action = SLIDE_ACTION_POINT;
+ }
masklay = cv_masklay;
spline = cv_spline;
@@ -851,8 +870,9 @@ static void slide_point_restore_spline(SlidePointData *data)
point->bezt = orig_point->bezt;
- for (j = 0; j < point->tot_uw; j++)
+ for (j = 0; j < point->tot_uw; j++) {
point->uw[j] = orig_point->uw[j];
+ }
}
}
@@ -865,10 +885,12 @@ static void cancel_slide_point(SlidePointData *data)
}
else {
if (data->action == SLIDE_ACTION_FEATHER) {
- if (data->uw)
+ if (data->uw) {
data->uw->w = data->weight;
- else
+ }
+ else {
data->point->bezt.weight = data->weight;
+ }
}
else if (data->action != SLIDE_ACTION_SPLINE) {
copy_m3_m3(data->point->bezt.vec, data->vec);
@@ -880,8 +902,9 @@ static void cancel_slide_point(SlidePointData *data)
static void free_slide_point_data(SlidePointData *data)
{
- if (data->orig_spline)
+ if (data->orig_spline) {
BKE_mask_spline_free(data->orig_spline);
+ }
MEM_freeN(data);
}
@@ -906,8 +929,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY))
+ if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) {
data->is_accurate = (event->val == KM_PRESS);
+ }
ATTR_FALLTHROUGH; /* update CV position */
case MOUSEMOVE: {
@@ -1028,8 +1052,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (is_overall_feather) {
float w_delta;
- if (dot_v2v2(no, vec) <= 0.0f)
+ if (dot_v2v2(no, vec) <= 0.0f) {
w = -w;
+ }
w_delta = w - data->weight * data->weight_scalar;
@@ -1049,8 +1074,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
slide_point_delta_all_feather(data, w_delta);
}
else {
- if (dot_v2v2(no, vec) <= 0.0f)
+ if (dot_v2v2(no, vec) <= 0.0f) {
w = 0.0f;
+ }
if (data->orig_spline) {
/* restore possible overall feather changes */
@@ -1586,12 +1612,14 @@ static void delete_feather_points(MaskSplinePoint *point)
{
int i, count = 0;
- if (!point->tot_uw)
+ if (!point->tot_uw) {
return;
+ }
for (i = 0; i < point->tot_uw; i++) {
- if ((point->uw[i].flag & SELECT) == 0)
+ if ((point->uw[i].flag & SELECT) == 0) {
count++;
+ }
}
if (count == 0) {
@@ -1644,8 +1672,9 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
- if (!MASKPOINT_ISSEL_ANY(point))
+ if (!MASKPOINT_ISSEL_ANY(point)) {
count++;
+ }
}
if (count == 0) {
@@ -1670,8 +1699,9 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
MaskSplinePoint *point = &spline->points[i];
if (!MASKPOINT_ISSEL_ANY(point)) {
- if (point == masklay->act_point)
+ if (point == masklay->act_point) {
masklay->act_point = &new_points[j];
+ }
delete_feather_points(point);
@@ -1679,8 +1709,9 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
j++;
}
else {
- if (point == masklay->act_point)
+ if (point == masklay->act_point) {
masklay->act_point = NULL;
+ }
BKE_mask_point_free(point);
spline->tot_point--;
@@ -2138,14 +2169,16 @@ static int mask_layer_move_exec(bContext *C, wmOperator *op)
MaskLayer *mask_layer_other;
int direction = RNA_enum_get(op->ptr, "direction");
- if (!mask_layer)
+ if (!mask_layer) {
return OPERATOR_CANCELLED;
+ }
if (direction == -1) {
mask_layer_other = mask_layer->prev;
- if (!mask_layer_other)
+ if (!mask_layer_other) {
return OPERATOR_CANCELLED;
+ }
BLI_remlink(&mask->masklayers, mask_layer);
BLI_insertlinkbefore(&mask->masklayers, mask_layer_other, mask_layer);
@@ -2154,8 +2187,9 @@ static int mask_layer_move_exec(bContext *C, wmOperator *op)
else if (direction == 1) {
mask_layer_other = mask_layer->next;
- if (!mask_layer_other)
+ if (!mask_layer_other) {
return OPERATOR_CANCELLED;
+ }
BLI_remlink(&mask->masklayers, mask_layer);
BLI_insertlinkafter(&mask->masklayers, mask_layer_other, mask_layer);
diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c
index bb9359bad71..75b2aee3570 100644
--- a/source/blender/editors/mask/mask_relationships.c
+++ b/source/blender/editors/mask/mask_relationships.c
@@ -184,7 +184,7 @@ void MASK_OT_parent_set(wmOperatorType *ot)
ot->idname = "MASK_OT_parent_set";
/* api callbacks */
- //ot->invoke = mask_parent_set_invoke;
+ // ot->invoke = mask_parent_set_invoke;
ot->exec = mask_parent_set_exec;
ot->poll = ED_space_clip_maskedit_mask_poll;
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 076f8d067b9..a592f39d24b 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -57,8 +57,9 @@ bool ED_mask_spline_select_check(MaskSpline *spline)
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
- if (MASKPOINT_ISSEL_ANY(point))
+ if (MASKPOINT_ISSEL_ANY(point)) {
return true;
+ }
}
return false;
@@ -99,10 +100,12 @@ void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select)
{
int i;
- if (do_select)
+ if (do_select) {
spline->flag |= SELECT;
- else
+ }
+ else {
spline->flag &= ~SELECT;
+ }
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -131,10 +134,12 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
MaskLayer *masklay;
if (action == SEL_TOGGLE) {
- if (ED_mask_select_check(mask))
+ if (ED_mask_select_check(mask)) {
action = SEL_DESELECT;
- else
+ }
+ else {
action = SEL_SELECT;
+ }
}
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
@@ -257,6 +262,7 @@ static int select_exec(bContext *C, wmOperator *op)
bool extend = RNA_boolean_get(op->ptr, "extend");
bool deselect = RNA_boolean_get(op->ptr, "deselect");
bool toggle = RNA_boolean_get(op->ptr, "toggle");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
eMaskWhichHandle which_handle;
const float threshold = 19;
@@ -265,8 +271,9 @@ static int select_exec(bContext *C, wmOperator *op)
point = ED_mask_point_find_nearest(
C, mask, co, threshold, &masklay, &spline, &which_handle, NULL);
- if (extend == false && deselect == false && toggle == false)
+ if (extend == false && deselect == false && toggle == false) {
ED_mask_select_toggle_all(mask, SEL_DESELECT);
+ }
if (point) {
if (which_handle != MASK_WHICH_HANDLE_NONE) {
@@ -333,12 +340,14 @@ static int select_exec(bContext *C, wmOperator *op)
masklay->act_spline = spline;
masklay->act_point = point;
- if (uw)
+ if (uw) {
uw->flag |= SELECT;
+ }
}
else if (deselect) {
- if (uw)
+ if (uw) {
uw->flag &= ~SELECT;
+ }
}
else {
masklay->act_spline = spline;
@@ -360,6 +369,15 @@ static int select_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+ else if (deselect_all) {
+ ED_mask_select_toggle_all(mask, SEL_DESELECT);
+
+ ED_mask_select_flush_all(mask);
+
+ WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
+
+ return OPERATOR_FINISHED;
+ }
}
return OPERATOR_PASS_THROUGH;
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index e67d63b01a5..57bf67e825e 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -21,8 +21,8 @@ set(INC
../../blenkernel
../../blenlib
../../blentranslation
- ../../depsgraph
../../bmesh
+ ../../depsgraph
../../gpu
../../imbuf
../../makesdna
@@ -30,8 +30,8 @@ set(INC
../../render/extern/include
../../windowmanager
../../../../intern/clog
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index f342cc3a809..990250792a1 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -65,8 +65,9 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag)
BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0);
- if (me == NULL)
+ if (me == NULL) {
return;
+ }
/* note, call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags */
@@ -120,7 +121,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag)
BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_ALL);
}
else {
- BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_SELECT);
+ BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_SELECT_PAINT);
}
DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
@@ -139,8 +140,9 @@ void paintface_hide(bContext *C, Object *ob, const bool unselected)
int a;
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return;
+ }
mpoly = me->mpoly;
a = me->totpoly;
@@ -170,8 +172,9 @@ void paintface_reveal(bContext *C, Object *ob, const bool select)
int a;
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return;
+ }
mpoly = me->mpoly;
a = me->totpoly;
@@ -227,8 +230,9 @@ static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index,
/* expand selection */
mp = me->mpoly;
for (a = 0; a < me->totpoly; a++, mp++) {
- if (mp->flag & ME_HIDE)
+ if (mp->flag & ME_HIDE) {
continue;
+ }
if (!BLI_BITMAP_TEST(poly_tag, a)) {
mark = false;
@@ -269,8 +273,9 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b
unsigned int index = (unsigned int)-1;
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return;
+ }
if (mval) {
if (!ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
@@ -364,8 +369,9 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
mvert = me->mvert;
mp = me->mpoly;
for (a = me->totpoly; a > 0; a--, mp++) {
- if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL))
+ if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL)) {
continue;
+ }
ml = me->mloop + mp->totloop;
for (b = 0; b < mp->totloop; b++, ml++) {
@@ -399,8 +405,9 @@ bool paintface_mouse_select(
}
mpoly_sel = me->mpoly + index;
- if (mpoly_sel->flag & ME_HIDE)
+ if (mpoly_sel->flag & ME_HIDE) {
return false;
+ }
/* clear flags */
if (!extend && !deselect && !toggle) {
@@ -416,10 +423,12 @@ bool paintface_mouse_select(
mpoly_sel->flag &= ~ME_FACE_SEL;
}
else if (toggle) {
- if (mpoly_sel->flag & ME_FACE_SEL)
+ if (mpoly_sel->flag & ME_FACE_SEL) {
mpoly_sel->flag &= ~ME_FACE_SEL;
- else
+ }
+ else {
mpoly_sel->flag |= ME_FACE_SEL;
+ }
}
else {
mpoly_sel->flag |= ME_FACE_SEL;
@@ -512,15 +521,17 @@ void paintvert_flush_flags(Object *ob)
int totvert;
int i;
- if (me == NULL)
+ if (me == NULL) {
return;
+ }
/* we could call this directly in all areas that change selection,
* since this could become slow for realtime updates (circle-select for eg) */
BKE_mesh_flush_select_from_verts(me);
- if (me_eval == NULL)
+ if (me_eval == NULL) {
return;
+ }
index_array = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX);
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index 815f51a4772..a7d1e54ad59 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -490,8 +490,8 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- /* Note that if you use MESH_ADD_VERTS_MAXI for both x and y at the same time you will still reach
- * impossible values (10^12 vertices or so...). */
+ /* Note that if you use MESH_ADD_VERTS_MAXI for both x and y at the same time
+ * you will still reach impossible values (10^12 vertices or so...). */
RNA_def_int(
ot->srna, "x_subdivisions", 10, 2, MESH_ADD_VERTS_MAXI, "X Subdivisions", "", 2, 1000);
RNA_def_int(
diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c b/source/blender/editors/mesh/editmesh_add_gizmo.c
index 9ed2c15f1c1..839ee186016 100644
--- a/source/blender/editors/mesh/editmesh_add_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_add_gizmo.c
@@ -58,7 +58,8 @@
* When we place a shape, pick a plane.
*
* We may base this choice on context,
- * for now pick the "ground" based on the 3D cursor's dominant plane pointing down relative to the view.
+ * for now pick the "ground" based on the 3D cursor's dominant plane
+ * pointing down relative to the view.
*/
static void calc_initial_placement_point_from_view(bContext *C,
const float mval[2],
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 2c0c8b2c708..f6940cae953 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -120,10 +120,12 @@ static float get_bevel_offset(wmOperator *op)
{
float val;
- if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT)
+ if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) {
val = RNA_float_get(op->ptr, "offset_pct");
- else
+ }
+ else {
val = RNA_float_get(op->ptr, "offset");
+ }
return val;
}
@@ -491,7 +493,8 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* for OFFSET_VALUE only, the scale is the size of a pixel under the mouse in 3d space */
opdata->scale[OFFSET_VALUE] = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
- /* since we are affecting untransformed object but seeing in transformed space, compensate for that */
+ /* since we are affecting untransformed object but seeing in transformed space,
+ * compensate for that */
opdata->scale[OFFSET_VALUE] /= opdata->max_obj_scale;
edbm_bevel_calc_initial_length(op, event, false);
@@ -578,10 +581,12 @@ static bool edbm_bevel_poll_property(const bContext *UNUSED(C),
if (STRPREFIX(prop_id, "offset")) {
int offset_type = RNA_enum_get(op->ptr, "offset_type");
- if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT)
+ if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT) {
return false;
- else if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT)
+ }
+ else if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT) {
return false;
+ }
}
return true;
@@ -647,8 +652,9 @@ wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Bevel Modal Map");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return NULL;
+ }
keymap = WM_modalkeymap_add(keyconf, "Bevel Modal Map", modal_items);
@@ -688,10 +694,12 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else if (etype == MOUSEPAN) {
float delta = 0.02f * (event->y - event->prevy);
- if (opdata->segments >= 1 && opdata->segments + delta < 1)
+ if (opdata->segments >= 1 && opdata->segments + delta < 1) {
opdata->segments = 1;
- else
+ }
+ else {
opdata->segments += delta;
+ }
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
@@ -732,13 +740,16 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (type > BEVEL_AMT_PERCENT) {
type = BEVEL_AMT_OFFSET;
}
- if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT)
+ if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT) {
opdata->value_mode = OFFSET_VALUE_PERCENT;
- else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT)
+ }
+ else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT) {
opdata->value_mode = OFFSET_VALUE;
+ }
RNA_enum_set(op->ptr, "offset_type", type);
- if (opdata->initial_length[opdata->value_mode] == -1.0f)
+ if (opdata->initial_length[opdata->value_mode] == -1.0f) {
edbm_bevel_calc_initial_length(op, event, true);
+ }
}
/* Update offset accordingly to new offset_type. */
if (!has_numinput &&
@@ -804,10 +815,12 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
case BEV_MODAL_INNER_MITER_CHANGE: {
int miter_inner = RNA_enum_get(op->ptr, "miter_inner");
miter_inner++;
- if (miter_inner == BEVEL_MITER_PATCH)
+ if (miter_inner == BEVEL_MITER_PATCH) {
miter_inner++; /* no patch option for inner miter */
- if (miter_inner > BEVEL_MITER_ARC)
+ }
+ if (miter_inner > BEVEL_MITER_ARC) {
miter_inner = BEVEL_MITER_SHARP;
+ }
RNA_enum_set(op->ptr, "miter_inner", miter_inner);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
@@ -818,8 +831,9 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
case BEV_MODAL_OUTER_MITER_CHANGE: {
int miter_outer = RNA_enum_get(op->ptr, "miter_outer");
miter_outer++;
- if (miter_outer > BEVEL_MITER_ARC)
+ if (miter_outer > BEVEL_MITER_ARC) {
miter_outer = BEVEL_MITER_SHARP;
+ }
RNA_enum_set(op->ptr, "miter_outer", miter_outer);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index eeda7ec5f2d..82cff8363f8 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -347,28 +347,37 @@ static bool edbm_extrude_mesh(Object *obedit, BMEditMesh *em, wmOperator *op)
bool changed = false;
if (em->selectmode & SCE_SELECT_VERTEX) {
- if (em->bm->totvertsel == 0)
+ if (em->bm->totvertsel == 0) {
nr = NONE;
- else if (em->bm->totvertsel == 1)
+ }
+ else if (em->bm->totvertsel == 1) {
nr = VERT_ONLY;
- else if (em->bm->totedgesel == 0)
+ }
+ else if (em->bm->totedgesel == 0) {
nr = VERT_ONLY;
- else
+ }
+ else {
nr = ELEM_FLAG;
+ }
}
else if (em->selectmode & SCE_SELECT_EDGE) {
- if (em->bm->totedgesel == 0)
+ if (em->bm->totedgesel == 0) {
nr = NONE;
- else if (em->bm->totfacesel == 0)
+ }
+ else if (em->bm->totfacesel == 0) {
nr = EDGE_ONLY;
- else
+ }
+ else {
nr = ELEM_FLAG;
+ }
}
else {
- if (em->bm->totfacesel == 0)
+ if (em->bm->totfacesel == 0) {
nr = NONE;
- else
+ }
+ else {
nr = ELEM_FLAG;
+ }
}
switch (nr) {
@@ -431,7 +440,7 @@ void MESH_OT_extrude_region(wmOperatorType *ot)
ot->description = "Extrude region of faces";
/* api callbacks */
- //ot->invoke = mesh_extrude_region_invoke;
+ // ot->invoke = mesh_extrude_region_invoke;
ot->exec = edbm_extrude_region_exec;
ot->poll = ED_operator_editmesh;
diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.c b/source/blender/editors/mesh/editmesh_extrude_screw.c
index c9422545c7b..252f95a10ac 100644
--- a/source/blender/editors/mesh/editmesh_extrude_screw.c
+++ b/source/blender/editors/mesh/editmesh_extrude_screw.c
@@ -125,8 +125,9 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
sub_v3_v3v3(dvec, v1_co_global, v2_co_global);
mul_v3_fl(dvec, 1.0f / steps);
- if (dot_v3v3(nor, dvec) > 0.0f)
+ if (dot_v3v3(nor, dvec) > 0.0f) {
negate_v3(dvec);
+ }
BMOperator spinop;
if (!EDBM_op_init(
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index 85be7d902ad..269ead7b23f 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -1018,7 +1018,8 @@ static void gizmo_mesh_spin_redo_draw_prepare(const bContext *UNUSED(C), wmGizmo
ggd->data.op = WM_operator_last_redo((bContext *)ggd->data.context);
}
- /* Not essential, just avoids feedback loop where matrices could shift because of float precision.
+ /* Not essential, just avoids feedback loop where matrices
+ * could shift because of float precision.
* Updates in this case are also redundant. */
bool is_modal = false;
for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index 7bee030bb46..2955488a597 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -91,8 +91,9 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C)
if (sa) {
char flts_str[NUM_STR_REP_LEN * 2];
- if (hasNumInput(&opdata->num_input))
+ if (hasNumInput(&opdata->num_input)) {
outputNumInput(&opdata->num_input, flts_str, &sce->unit);
+ }
else {
BLI_snprintf(flts_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "thickness"));
BLI_snprintf(
@@ -413,18 +414,21 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* Fake shift-transform... */
- if (opdata->shift)
+ if (opdata->shift) {
amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount;
+ }
- if (opdata->modify_depth)
+ if (opdata->modify_depth) {
RNA_float_set(op->ptr, "depth", amount);
+ }
else {
amount = max_ff(amount, 0.0f);
RNA_float_set(op->ptr, "thickness", amount);
}
- if (edbm_inset_calc(op))
+ if (edbm_inset_calc(op)) {
edbm_inset_update_header(op, C);
+ }
else {
edbm_inset_cancel(C, op);
return OPERATOR_CANCELLED;
@@ -446,10 +450,12 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
if (event->val == KM_PRESS) {
- if (opdata->modify_depth)
+ if (opdata->modify_depth) {
opdata->shift_amount = RNA_float_get(op->ptr, "depth");
- else
+ }
+ else {
opdata->shift_amount = RNA_float_get(op->ptr, "thickness");
+ }
opdata->shift = true;
handled = true;
}
@@ -469,14 +475,16 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
opdata->old_thickness = RNA_float_get(op->ptr, "thickness");
- if (opdata->shift)
+ if (opdata->shift) {
opdata->shift_amount = opdata->old_thickness;
+ }
opdata->modify_depth = true;
}
else {
opdata->old_depth = RNA_float_get(op->ptr, "depth");
- if (opdata->shift)
+ if (opdata->shift) {
opdata->shift_amount = opdata->old_depth;
+ }
opdata->modify_depth = false;
}
opdata->initial_length = len_v2(mlen);
diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c
index 06e2ef6e304..370cc6a2a6d 100644
--- a/source/blender/editors/mesh/editmesh_intersect.c
+++ b/source/blender/editors/mesh/editmesh_intersect.c
@@ -512,12 +512,15 @@ static int bm_edge_sort_length_cb(const void *e_a_v, const void *e_b_v)
const float val_a = -BM_edge_calc_length_squared(*((BMEdge **)e_a_v));
const float val_b = -BM_edge_calc_length_squared(*((BMEdge **)e_b_v));
- if (val_a > val_b)
+ if (val_a > val_b) {
return 1;
- else if (val_a < val_b)
+ }
+ else if (val_a < val_b) {
return -1;
- else
+ }
+ else {
return 0;
+ }
}
static void bm_face_split_by_edges_island_connect(
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index f4979c8f2a8..cc0c2f5bbe4 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -157,7 +157,7 @@ typedef struct KnifeTool_OpData {
void *draw_handle; /* for drawing preview loop */
ViewContext vc; /* note: _don't_ use 'mval', instead use the one we define below */
float mval[2]; /* mouse value with snapping applied */
- //bContext *C;
+ // bContext *C;
Scene *scene;
Object *ob;
@@ -366,8 +366,9 @@ static Ref *find_ref(ListBase *lb, void *ref)
Ref *ref1;
for (ref1 = lb->first; ref1; ref1 = ref1->next) {
- if (ref1->ref == ref)
+ if (ref1->ref == ref) {
return ref1;
+ }
}
return NULL;
@@ -375,8 +376,9 @@ static Ref *find_ref(ListBase *lb, void *ref)
static void knife_append_list_no_dup(KnifeTool_OpData *kcd, ListBase *lst, void *elem)
{
- if (!find_ref(lst, elem))
+ if (!find_ref(lst, elem)) {
knife_append_list(kcd, lst, elem);
+ }
}
static KnifeEdge *new_knife_edge(KnifeTool_OpData *kcd)
@@ -410,8 +412,9 @@ static BMFace *knife_find_common_face(ListBase *faces1, ListBase *faces2)
for (ref1 = faces1->first; ref1; ref1 = ref1->next) {
for (ref2 = faces2->first; ref2; ref2 = ref2->next) {
- if (ref1->ref == ref2->ref)
+ if (ref1->ref == ref2->ref) {
return (BMFace *)(ref1->ref);
+ }
}
}
return NULL;
@@ -441,10 +444,12 @@ static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v)
BMIter bmiter;
BMFace *f;
- if (BM_elem_index_get(v) >= 0)
+ if (BM_elem_index_get(v) >= 0) {
cageco = kcd->cagecos[BM_elem_index_get(v)];
- else
+ }
+ else {
cageco = v->co;
+ }
kfv = new_knife_vert(kcd, v->co, cageco);
kfv->v = v;
BLI_ghash_insert(kcd->origvertmap, v, kfv);
@@ -493,8 +498,9 @@ static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index)
{
int i;
- if (BLI_ghash_lookup(kcd->facetrimap, f))
+ if (BLI_ghash_lookup(kcd->facetrimap, f)) {
return;
+ }
BLI_assert(index >= 0 && index < kcd->em->tottri);
BLI_assert(kcd->em->looptris[index][0]->f == f);
@@ -504,8 +510,9 @@ static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index)
break;
}
}
- if (i == -1)
+ if (i == -1) {
i++;
+ }
BLI_ghash_insert(kcd->facetrimap, f, POINTER_FROM_INT(i + 1));
}
@@ -594,8 +601,9 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd,
* If v1 and v2 are in multiple faces together (e.g., if they
* are in doubled polys) then this arbitrarily chooses one of them */
f = knife_find_common_face(&kfe->v1->faces, &kfe->v2->faces);
- if (f)
+ if (f) {
knife_append_list(kcd, &newkfe->v2->faces, f);
+ }
}
newkfe->basef = kfe->basef;
@@ -605,8 +613,9 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd,
kfe->v1 = newkfe->v2;
BLI_addtail(&kfe->v1->edges, ref);
- for (ref = kfe->faces.first; ref; ref = ref->next)
+ for (ref = kfe->faces.first; ref; ref = ref->next) {
knife_edge_append_face(kcd, newkfe, ref->ref);
+ }
knife_add_to_vert_edges(kcd, newkfe);
@@ -637,22 +646,29 @@ static int linehit_compare(const void *vlh1, const void *vlh2)
const KnifeLineHit *lh1 = vlh1;
const KnifeLineHit *lh2 = vlh2;
- if (lh1->l < lh2->l)
+ if (lh1->l < lh2->l) {
return -1;
- else if (lh1->l > lh2->l)
+ }
+ else if (lh1->l > lh2->l) {
return 1;
+ }
else {
- if (lh1->m < lh2->m)
+ if (lh1->m < lh2->m) {
return -1;
- else if (lh1->m > lh2->m)
+ }
+ else if (lh1->m > lh2->m) {
return 1;
+ }
else {
- if (lh1->v < lh2->v)
+ if (lh1->v < lh2->v) {
return -1;
- else if (lh1->v > lh2->v)
+ }
+ else if (lh1->v > lh2->v) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
}
}
@@ -670,8 +686,9 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd)
n = kcd->totlinehit;
linehits = kcd->linehits;
- if (n == 0)
+ if (n == 0) {
return;
+ }
qsort(linehits, n, sizeof(KnifeLineHit), linehit_compare);
@@ -725,8 +742,9 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd)
memcpy(&linehits[i], &linehits[j], sizeof(KnifeLineHit));
}
else {
- if (i + 1 != j)
+ if (i + 1 != j) {
memcpy(&linehits[i + 1], &linehits[j], sizeof(KnifeLineHit));
+ }
i++;
}
j++;
@@ -851,8 +869,9 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd,
knife_add_to_vert_edges(kcd, kfe);
/* TODO: check if this is ever needed */
- if (kfe->basef && !find_ref(&kfe->faces, kfe->basef))
+ if (kfe->basef && !find_ref(&kfe->faces, kfe->basef)) {
knife_edge_append_face(kcd, kfe, kfe->basef);
+ }
}
/* Given a list of KnifeLineHits for one face, sorted by l
@@ -863,8 +882,9 @@ static void knife_cut_face(KnifeTool_OpData *kcd, BMFace *f, ListBase *hits)
{
Ref *r;
- if (BLI_listbase_count_at_most(hits, 2) != 2)
+ if (BLI_listbase_count_at_most(hits, 2) != 2) {
return;
+ }
for (r = hits->first; r->next; r = r->next) {
knife_add_single_cut(kcd, r->ref, r->next->ref, f);
@@ -1167,8 +1187,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
BLI_mempool_iternew(kcd->kedges, &iter);
for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) {
- if (!kfe->is_cut)
+ if (!kfe->is_cut) {
continue;
+ }
immVertex3fv(pos, kfe->v1->cageco);
immVertex3fv(pos, kfe->v2->cageco);
@@ -1191,8 +1212,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
BLI_mempool_iternew(kcd->kverts, &iter);
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
- if (!kfv->is_cut)
+ if (!kfv->is_cut) {
continue;
+ }
immVertex3fv(pos, kfv->cageco);
}
@@ -1249,8 +1271,9 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd,
float ray_tri_uv[2];
tri = kcd->em->looptris[tri_i];
- if (tri[0]->f != f)
+ if (tri[0]->f != f) {
break;
+ }
lv1 = kcd->cagecos[BM_elem_index_get(tri[0]->v)];
lv2 = kcd->cagecos[BM_elem_index_get(tri[1]->v)];
lv3 = kcd->cagecos[BM_elem_index_get(tri[2]->v)];
@@ -1594,8 +1617,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
* (which may involve using doubles everywhere!),
* limit the distance between these points */
if (kcd->is_ortho && (kcd->vc.rv3d->persp != RV3D_CAMOB)) {
- if (kcd->ortho_extent == 0.0f)
+ if (kcd->ortho_extent == 0.0f) {
calc_ortho_extent(kcd);
+ }
clip_to_ortho_planes(v1, v3, kcd->ortho_extent_center, kcd->ortho_extent + 10.0f);
clip_to_ortho_planes(v2, v4, kcd->ortho_extent_center, kcd->ortho_extent + 10.0f);
}
@@ -1642,8 +1666,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
lst = knife_get_face_kedges(kcd, f);
for (ref = lst->first; ref; ref = ref->next) {
kfe = ref->ref;
- if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe))
+ if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe)) {
continue;
+ }
BLI_smallhash_insert(&kfes, (uintptr_t)kfe, kfe);
v = kfe->v1;
BLI_smallhash_reinsert(&kfvs, (uintptr_t)v, v);
@@ -1653,7 +1678,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
}
/* Now go through the candidates and find intersections */
- /* These tolerances, in screen space, are for intermediate hits, as ends are already snapped to screen */
+ /* These tolerances, in screen space, are for intermediate hits,
+ * as ends are already snapped to screen. */
if (kcd->is_interactive) {
vert_tol = KNIFE_FLT_EPS_PX_VERT;
@@ -1663,8 +1689,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
else {
/* Use 1/100th of a pixel, see T43896 (too big), T47910 (too small).
*
- * Update, leave this as is until we investigate not using pixel coords for geometry calculations: T48023
- */
+ * Update, leave this as is until we investigate not using pixel coords
+ * for geometry calculations: T48023. */
vert_tol = line_tol = face_tol = 0.5f;
}
@@ -1724,12 +1750,14 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
if (isect_kind == -1) {
/* isect_seg_seg_v2_simple doesn't do tolerance test around ends of s1-s2 */
closest_to_line_segment_v2(sint, s1, se1, se2);
- if (len_squared_v2v2(sint, s1) <= line_tol_sq)
+ if (len_squared_v2v2(sint, s1) <= line_tol_sq) {
isect_kind = 1;
+ }
else {
closest_to_line_segment_v2(sint, s2, se1, se2);
- if (len_squared_v2v2(sint, s2) <= line_tol_sq)
+ if (len_squared_v2v2(sint, s2) <= line_tol_sq) {
isect_kind = 1;
+ }
}
}
if (isect_kind == 1) {
@@ -1808,8 +1836,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
BLI_smallhash_release(&kfes);
BLI_smallhash_release(&kfvs);
BLI_bvhtree_free(planetree);
- if (results)
+ if (results) {
MEM_freeN(results);
+ }
}
static void knife_input_ray_segment(KnifeTool_OpData *kcd,
@@ -1851,8 +1880,9 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd,
f = NULL;
}
- if (is_space)
+ if (is_space) {
*is_space = !f;
+ }
if (!f) {
if (kcd->is_interactive) {
@@ -2024,8 +2054,9 @@ static KnifeEdge *knife_find_closest_edge(
copy_v3_v3(cur_cagep, test_cagep);
}
- if (fptr)
+ if (fptr) {
*fptr = f;
+ }
if (cure) {
if (!kcd->ignore_edge_snapping || !(cure->e)) {
@@ -2055,8 +2086,9 @@ static KnifeEdge *knife_find_closest_edge(
return cure;
}
- if (fptr)
+ if (fptr) {
*fptr = NULL;
+ }
return NULL;
}
@@ -2132,8 +2164,9 @@ static KnifeVert *knife_find_closest_vert(
}
if (!kcd->ignore_vert_snapping || !(curv && curv->v)) {
- if (fptr)
+ if (fptr) {
*fptr = f;
+ }
if (curv) {
copy_v3_v3(p, curv->co);
@@ -2148,15 +2181,17 @@ static KnifeVert *knife_find_closest_vert(
return curv;
}
else {
- if (fptr)
+ if (fptr) {
*fptr = f;
+ }
return NULL;
}
}
- if (fptr)
+ if (fptr) {
*fptr = NULL;
+ }
return NULL;
}
@@ -2261,12 +2296,15 @@ static int sort_verts_by_dist_cb(void *co_p, const void *cur_a_p, const void *cu
const float a_sq = len_squared_v3v3(co, cur_a->co);
const float b_sq = len_squared_v3v3(co, cur_b->co);
- if (a_sq < b_sq)
+ if (a_sq < b_sq) {
return -1;
- else if (a_sq > b_sq)
+ }
+ else if (a_sq > b_sq) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f)
@@ -2275,8 +2313,9 @@ static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f)
bool v1_inface, v2_inface;
BMLoop *l1, *l2;
- if (!f || !v1 || !v2)
+ if (!f || !v1 || !v2) {
return false;
+ }
l1 = v1->v ? BM_face_vert_share_loop(f, v1->v) : NULL;
l2 = v2->v ? BM_face_vert_share_loop(f, v2->v) : NULL;
@@ -2453,8 +2492,9 @@ static void knife_make_cuts(KnifeTool_OpData *kcd)
}
f = kfe->basef;
- if (!f || kfe->e)
+ if (!f || kfe->e) {
continue;
+ }
lst = BLI_smallhash_lookup(fhash, (uintptr_t)f);
if (!lst) {
lst = knife_empty_list(kcd);
@@ -2466,21 +2506,24 @@ static void knife_make_cuts(KnifeTool_OpData *kcd)
/* put list of splitting vertices for an edge into ehash, keyed by edge */
BLI_mempool_iternew(kcd->kverts, &iter);
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
- if (kfv->v)
+ if (kfv->v) {
continue; /* already have a BMVert */
+ }
for (ref = kfv->edges.first; ref; ref = ref->next) {
kfe = ref->ref;
e = kfe->e;
- if (!e)
+ if (!e) {
continue;
+ }
lst = BLI_smallhash_lookup(ehash, (uintptr_t)e);
if (!lst) {
lst = knife_empty_list(kcd);
BLI_smallhash_insert(ehash, (uintptr_t)e, lst);
}
/* there can be more than one kfe in kfv's list with same e */
- if (!find_ref(lst, kfv))
+ if (!find_ref(lst, kfv)) {
knife_append_list(kcd, lst, kfv);
+ }
}
}
@@ -2544,8 +2587,9 @@ static void knife_recalc_projmat(KnifeTool_OpData *kcd)
/* called when modal loop selection is done... */
static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd)
{
- if (!kcd)
+ if (!kcd) {
return;
+ }
if (kcd->is_interactive) {
WM_cursor_modal_restore(CTX_wm_window(C));
@@ -2575,8 +2619,9 @@ static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd)
knifetool_free_bmbvh(kcd);
- if (kcd->linehits)
+ if (kcd->linehits) {
MEM_freeN(kcd->linehits);
+ }
/* destroy kcd itself */
MEM_freeN(kcd);
@@ -2773,8 +2818,9 @@ wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Knife Tool Modal Map");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return NULL;
+ }
keymap = WM_modalkeymap_add(keyconf, "Knife Tool Modal Map", modal_items);
@@ -2801,8 +2847,9 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
view3d_operator_needs_opengl(C);
ED_view3d_init_mats_rv3d(obedit, kcd->vc.rv3d); /* needed to initialize clipping */
- if (kcd->mode == MODE_PANNING)
+ if (kcd->mode == MODE_PANNING) {
kcd->mode = kcd->prevmode;
+ }
/* handle modal keymap */
if (event->type == EVT_MODAL_MAP) {
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index d0988811d15..528235e693a 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -545,8 +545,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RETKEY:
case PADENTER:
case LEFTMOUSE: /* confirm */ // XXX hardcoded
- if (event->val == KM_PRESS)
+ if (event->val == KM_PRESS) {
return loopcut_finish(lcd, C, op);
+ }
ED_region_tag_redraw(lcd->ar);
handled = true;
@@ -573,8 +574,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case MOUSEPAN:
if (event->alt == 0) {
cuts += 0.02f * (event->y - event->prevy);
- if (cuts < 1 && lcd->cuts >= 1)
+ if (cuts < 1 && lcd->cuts >= 1) {
cuts = 1;
+ }
}
else {
smoothness += 0.002f * (event->y - event->prevy);
@@ -584,8 +586,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADPLUSKEY:
case PAGEUPKEY:
case WHEELUPMOUSE: /* change number of cuts */
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
break;
+ }
if (event->alt == 0) {
cuts += 1;
}
@@ -597,8 +600,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADMINUS:
case PAGEDOWNKEY:
case WHEELDOWNMOUSE: /* change number of cuts */
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
break;
+ }
if (event->alt == 0) {
cuts = max_ff(cuts - 1, 1);
}
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index c6b1ab9f1f2..f8ec4334427 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -281,10 +281,12 @@ static void edgetag_set_cb(BMEdge *e, bool val, void *user_data_v)
case EDGE_MODE_TAG_FREESTYLE: {
FreestyleEdge *fed;
fed = CustomData_bmesh_get(&bm->edata, e->head.data, CD_FREESTYLE_EDGE);
- if (!val)
+ if (!val) {
fed->flag &= ~FREESTYLE_EDGE_MARK;
- else
+ }
+ else {
fed->flag |= FREESTYLE_EDGE_MARK;
+ }
break;
}
#endif
@@ -396,8 +398,9 @@ static void mouse_mesh_shortest_path_edge(Scene *UNUSED(scene),
if (op_params->edge_mode != EDGE_MODE_SELECT) {
if (op_params->track_active) {
/* simple rules - last edge is _always_ active and selected */
- if (e_act)
+ if (e_act) {
BM_edge_select_set(bm, e_act, false);
+ }
BM_edge_select_set(bm, e_dst_last, true);
BM_select_history_store(bm, e_dst_last);
}
@@ -408,10 +411,12 @@ static void mouse_mesh_shortest_path_edge(Scene *UNUSED(scene),
if (op_params->track_active) {
/* even if this is selected it may not be in the selection list */
if (op_params->edge_mode == EDGE_MODE_SELECT) {
- if (edgetag_test_cb(e_dst_last, &user_data) == 0)
+ if (edgetag_test_cb(e_dst_last, &user_data) == 0) {
BM_select_history_remove(bm, e_dst_last);
- else
+ }
+ else {
BM_select_history_store(bm, e_dst_last);
+ }
}
}
@@ -429,12 +434,12 @@ static bool facetag_filter_cb(BMFace *f, void *UNUSED(user_data_v))
{
return !BM_elem_flag_test(f, BM_ELEM_HIDDEN);
}
-//static bool facetag_test_cb(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f)
+// static bool facetag_test_cb(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f)
static bool facetag_test_cb(BMFace *f, void *UNUSED(user_data_v))
{
return BM_elem_flag_test_bool(f, BM_ELEM_SELECT);
}
-//static void facetag_set_cb(BMesh *bm, Scene *UNUSED(scene), BMFace *f, const bool val)
+// static void facetag_set_cb(BMesh *bm, Scene *UNUSED(scene), BMFace *f, const bool val)
static void facetag_set_cb(BMFace *f, bool val, void *user_data_v)
{
struct UserData *user_data = user_data_v;
@@ -777,12 +782,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
if ((em->selectmode & SCE_SELECT_VERTEX) && (bm->totvertsel >= 2)) {
BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL)
+ if (ele_src == NULL) {
ele_src = ele;
- else if (ele_dst == NULL)
+ }
+ else if (ele_dst == NULL) {
ele_dst = ele;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -791,12 +799,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
ele_src = NULL;
BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL)
+ if (ele_src == NULL) {
ele_src = ele;
- else if (ele_dst == NULL)
+ }
+ else if (ele_dst == NULL) {
ele_dst = ele;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -805,12 +816,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
ele_src = NULL;
BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL)
+ if (ele_src == NULL) {
ele_src = ele;
- else if (ele_dst == NULL)
+ }
+ else if (ele_dst == NULL) {
ele_dst = ele;
- else
+ }
+ else {
break;
+ }
}
}
}
diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.c
index b007343e14e..92a8c7da71d 100644
--- a/source/blender/editors/mesh/editmesh_preselect_edgering.c
+++ b/source/blender/editors/mesh/editmesh_preselect_edgering.c
@@ -93,8 +93,9 @@ static void edgering_find_order(BMEdge *eed_last, BMEdge *eed, BMVert *eve_last,
if (!(BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f))) {
BMIter liter;
BM_ITER_ELEM (l, &liter, l, BM_LOOPS_OF_LOOP) {
- if (BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f))
+ if (BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f)) {
break;
+ }
}
}
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 42521d04008..ffdb434405e 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -86,8 +86,7 @@ static float edbm_rip_edgedist_squared(ARegion *ar,
#if 0
static float edbm_rip_linedist(
- ARegion *ar, float mat[4][4],
- const float co1[3], const float co2[3], const float mvalf[2])
+ ARegion *ar, float mat[4][4], const float co1[3], const float co2[3], const float mvalf[2])
{
float vec1[2], vec2[2];
@@ -171,23 +170,26 @@ static float edbm_rip_edge_side_measure(
*
* The method used for checking the side of selection is as follows...
* - First tag all rip-able edges.
- * - Build a contiguous edge list by looping over tagged edges and following each ones tagged siblings in both
- * directions.
- * - The loops are not stored in an array, Instead both loops on either side of each edge has its index values set
- * to count down from the last edge, this way, once we have the 'last' edge its very easy to walk down the
- * connected edge loops.
- * The reason for using loops like this is because when the edges are split we don't which face user gets the newly
- * created edge (its as good as random so we cant assume new edges will be on once side).
- * After splitting, its very simple to walk along boundary loops since each only has one edge from a single side.
- * - The end loop pairs are stored in an array however to support multiple edge-selection-islands, so you can rip
- * multiple selections at once.
+ * - Build a contiguous edge list by looping over tagged edges and following each ones tagged
+ * siblings in both directions.
+ * - The loops are not stored in an array, Instead both loops on either side of each edge has
+ * its index values set to count down from the last edge, this way, once we have the 'last'
+ * edge its very easy to walk down the connected edge loops.
+ * The reason for using loops like this is because when the edges are split we don't which
+ * face user gets the newly created edge
+ * (its as good as random so we cant assume new edges will be on once side).
+ * After splitting, its very simple to walk along boundary loops since each only has one edge
+ * from a single side.
+ * - The end loop pairs are stored in an array however to support multiple edge-selection-islands,
+ * so you can rip multiple selections at once.
* - * Execute the split *
- * - For each #EdgeLoopPair walk down both sides of the split using the loops and measure which is facing the mouse.
+ * - For each #EdgeLoopPair walk down both sides of the split using the loops and measure
+ * which is facing the mouse.
* - Deselect the edge loop facing away.
*
* Limitation!
- * This currently works very poorly with intersecting edge islands (verts with more than 2 tagged edges)
- * This is nice to but for now not essential.
+ * This currently works very poorly with intersecting edge islands
+ * (verts with more than 2 tagged edges). This is nice to but for now not essential.
*
* - campbell.
*/
@@ -540,8 +542,9 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed
ese.ele = NULL;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
break;
+ }
}
}
@@ -810,8 +813,9 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed
BM_vert_select_set(bm, v_rip, true);
}
else {
- if (fill_uloop_pairs)
+ if (fill_uloop_pairs) {
MEM_freeN(fill_uloop_pairs);
+ }
return OPERATOR_CANCELLED;
}
}
@@ -905,6 +909,9 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
e_best = e;
i++;
+ /* Tag the edge verts so we know which verts to rip */
+ BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
}
totedge_manifold++;
}
@@ -932,13 +939,14 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
l_b;
l = BM_loop_other_edge_loop(l, v);
- /* important edge is manifold else we can be attempting to split off a fan that don't budge,
- * not crashing but adds duplicate edge. */
+ /* Important edge is manifold else we can be attempting to split off
+ * a fan that don't budge, not crashing but adds duplicate edge. */
if (BM_edge_is_manifold(l->e)) {
l = l->radial_next;
- if (totedge_manifold != 3)
+ if (totedge_manifold != 3) {
l = BM_loop_other_edge_loop(l, v);
+ }
if (l) {
BLI_assert(!BM_elem_flag_test(l->e, BM_ELEM_TAG));
diff --git a/source/blender/editors/mesh/editmesh_rip_edge.c b/source/blender/editors/mesh/editmesh_rip_edge.c
index e2b77d8c83b..61253f06f9f 100644
--- a/source/blender/editors/mesh/editmesh_rip_edge.c
+++ b/source/blender/editors/mesh/editmesh_rip_edge.c
@@ -71,8 +71,9 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve
float projectMat[4][4];
- if (bm->totvertsel == 0)
+ if (bm->totvertsel == 0) {
continue;
+ }
ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 94886266d24..9df03a81762 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -110,8 +110,9 @@ void EDBM_select_mirrored(
EDBM_verts_mirror_cache_begin(em, axis, true, true, use_topology);
- if (!extend)
+ if (!extend) {
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ }
if (bm->selectmode & SCE_SELECT_VERTEX) {
BMVert *v;
@@ -241,19 +242,22 @@ bool EDBM_backbuf_check(unsigned int index)
/* odd logic, if selbuf is NULL we assume no zbuf-selection is enabled
* and just ignore the depth buffer, this is error prone since its possible
* code doesn't set the depth buffer by accident, but leave for now. - Campbell */
- if (selbuf == NULL)
+ if (selbuf == NULL) {
return true;
+ }
- if (index > 0 && index <= bm_vertoffs)
+ if (index > 0 && index <= bm_vertoffs) {
return BLI_BITMAP_TEST_BOOL(selbuf, index);
+ }
return false;
}
void EDBM_backbuf_free(void)
{
- if (selbuf)
+ if (selbuf) {
MEM_freeN(selbuf);
+ }
selbuf = NULL;
}
@@ -458,7 +462,8 @@ static void findnearestvert__doClosest(void *userData,
*
* \param r_dist: (in/out), minimal distance to the nearest and at the end, actual distance
* \param use_select_bias:
- * - When true, selected vertices are given a 5 pixel bias to make them further than unselect verts.
+ * - When true, selected vertices are given a 5 pixel bias
+ * to make them further than unselect verts.
* - When false, unselected vertices are given the bias.
* \param use_cycle: Cycle over elements within #FIND_NEAR_CYCLE_THRESHOLD_MIN in order of index.
*/
@@ -1173,9 +1178,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc,
float point[3];
#if 0
const float dist_sq_test = dist_squared_ray_to_seg_v3(
- ray_origin, ray_direction,
- e->v1->co, e->v2->co,
- point, &depth);
+ ray_origin, ray_direction, e->v1->co, e->v2->co, point, &depth);
#else
if (coords) {
mid_v3_v3v3(
@@ -1425,10 +1428,12 @@ static int edbm_select_mode_invoke(bContext *C, wmOperator *op, const wmEvent *e
/* detecting these options based on shift/ctrl here is weak, but it's done
* to make this work when clicking buttons or menus */
- if (!RNA_struct_property_is_set(op->ptr, "use_extend"))
+ if (!RNA_struct_property_is_set(op->ptr, "use_extend")) {
RNA_boolean_set(op->ptr, "use_extend", event->shift);
- if (!RNA_struct_property_is_set(op->ptr, "use_expand"))
+ }
+ if (!RNA_struct_property_is_set(op->ptr, "use_expand")) {
RNA_boolean_set(op->ptr, "use_expand", event->ctrl);
+ }
return edbm_select_mode_exec(C, op);
}
@@ -1801,7 +1806,8 @@ static bool mouse_mesh_loop(
length_2 = len_squared_v2v2(mvalf, v2_co);
}
#if 0
- printf("mouse to v1: %f\nmouse to v2: %f\n", len_squared_v2v2(mvalf, v1_co),
+ printf("mouse to v1: %f\nmouse to v2: %f\n",
+ len_squared_v2v2(mvalf, v1_co),
len_squared_v2v2(mvalf, v2_co));
#endif
BM_select_history_store(em->bm, (length_1 < length_2) ? eed->v1 : eed->v2);
@@ -2205,8 +2211,9 @@ static void edbm_strip_selections(BMEditMesh *em)
ese = em->bm->selected.first;
while (ese) {
nextese = ese->next;
- if (ese->htype == BM_VERT)
+ if (ese->htype == BM_VERT) {
BLI_freelinkN(&(em->bm->selected), ese);
+ }
ese = nextese;
}
}
@@ -2214,8 +2221,9 @@ static void edbm_strip_selections(BMEditMesh *em)
ese = em->bm->selected.first;
while (ese) {
nextese = ese->next;
- if (ese->htype == BM_EDGE)
+ if (ese->htype == BM_EDGE) {
BLI_freelinkN(&(em->bm->selected), ese);
+ }
ese = nextese;
}
}
@@ -2223,8 +2231,9 @@ static void edbm_strip_selections(BMEditMesh *em)
ese = em->bm->selected.first;
while (ese) {
nextese = ese->next;
- if (ese->htype == BM_FACE)
+ if (ese->htype == BM_FACE) {
BLI_freelinkN(&(em->bm->selected), ese);
+ }
ese = nextese;
}
}
@@ -2576,8 +2585,9 @@ bool EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool sel
bool changed = false;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
if (efa->mat_nr == index) {
changed = true;
BM_face_select_set(em->bm, efa, select);
@@ -2588,10 +2598,12 @@ bool EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool sel
void EDBM_select_toggle_all(BMEditMesh *em) /* exported for UV */
{
- if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel)
+ if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) {
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- else
+ }
+ else {
EDBM_flag_enable_all(em, BM_ELEM_SELECT);
+ }
}
void EDBM_select_swap(BMEditMesh *em) /* exported for UV */
@@ -2603,22 +2615,25 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */
if (em->bm->selectmode & SCE_SELECT_VERTEX) {
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
continue;
+ }
BM_vert_select_set(em->bm, eve, !BM_elem_flag_test(eve, BM_ELEM_SELECT));
}
}
else if (em->selectmode & SCE_SELECT_EDGE) {
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
continue;
+ }
BM_edge_select_set(em->bm, eed, !BM_elem_flag_test(eed, BM_ELEM_SELECT));
}
}
else {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
BM_face_select_set(em->bm, efa, !BM_elem_flag_test(efa, BM_ELEM_SELECT));
}
}
@@ -2675,8 +2690,9 @@ bool EDBM_select_interior_faces(BMEditMesh *em)
bool changed = false;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
ok = true;
BM_ITER_ELEM (eed, &eiter, efa, BM_EDGES_OF_FACE) {
@@ -4602,8 +4618,9 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op))
totsel += BM_elem_flag_test(l2->f, BM_ELEM_SELECT) != 0;
}
- if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1))
+ if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1)) {
BM_elem_flag_enable(l1->e, BM_ELEM_TAG);
+ }
}
}
@@ -4671,8 +4688,9 @@ static int loop_find_region(BMLoop *l, int flag, GSet *visit_face_set, BMFace **
BLI_array_append(region, f);
BM_ITER_ELEM (l1, &liter1, f, BM_LOOPS_OF_FACE) {
- if (BM_elem_flag_test(l1->e, flag))
+ if (BM_elem_flag_test(l1->e, flag)) {
continue;
+ }
BM_ITER_ELEM (l2, &liter2, l1->e, BM_LOOPS_OF_EDGE) {
/* avoids finding same region twice
@@ -4702,10 +4720,12 @@ static int verg_radial(const void *va, const void *vb)
const int a = BM_edge_face_count(e_a);
const int b = BM_edge_face_count(e_b);
- if (a > b)
+ if (a > b) {
return -1;
- if (a < b)
+ }
+ if (a < b) {
return 1;
+ }
return 0;
}
@@ -4748,12 +4768,14 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger)
e = edges[i];
- if (!BM_elem_flag_test(e, BM_ELEM_TAG))
+ if (!BM_elem_flag_test(e, BM_ELEM_TAG)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
- if (BLI_gset_haskey(visit_face_set, l->f))
+ if (BLI_gset_haskey(visit_face_set, l->f)) {
continue;
+ }
c = loop_find_region(l, BM_ELEM_SELECT, visit_face_set, &region_out);
diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c
index 3006e2ed73d..2782cc92aca 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -1218,12 +1218,15 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op)
ts->select_thresh = RNA_property_float_get(op->ptr, prop);
}
- if (type < 100)
+ if (type < 100) {
return similar_vert_select_exec(C, op);
- else if (type < 200)
+ }
+ else if (type < 200) {
return similar_edge_select_exec(C, op);
- else
+ }
+ else {
return similar_face_select_exec(C, op);
+ }
}
static const EnumPropertyItem *select_similar_type_itemf(bContext *C,
@@ -1233,8 +1236,9 @@ static const EnumPropertyItem *select_similar_type_itemf(bContext *C,
{
Object *obedit;
- if (!C) /* needed for docs and i18n tools */
+ if (!C) { /* needed for docs and i18n tools */
return prop_similar_types;
+ }
obedit = CTX_data_edit_object(C);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 79bbf021829..cd9d046ae04 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -885,8 +885,9 @@ static void edbm_add_edge_face_exec__tricky_finalize_sel(BMesh *bm, BMElem *ele_
BM_select_history_clear(bm);
/* Notes on hidden geometry:
- * - un-hide the face since its possible hidden was copied when copying surrounding face attributes.
- * - un-hide before adding to select history
+ * - Un-hide the face since its possible hidden was copied when copying
+ * surrounding face attributes.
+ * - Un-hide before adding to select history
* since we may extend into an existing, hidden vert/edge.
*/
@@ -946,8 +947,8 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
BMElem *ele_desel;
BMFace *ele_desel_face;
- /* be extra clever, figure out if a partial selection should be extended so we can create geometry
- * with single vert or single edge selection */
+ /* be extra clever, figure out if a partial selection should be extended so we can create
+ * geometry with single vert or single edge selection. */
ele_desel = edbm_add_edge_face_exec__tricky_extend_sel(em->bm);
#endif
if (!EDBM_op_init(em,
@@ -980,7 +981,8 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
/* Newly created faces may include existing hidden edges,
* copying face data from surrounding, may have copied hidden face flag too.
*
- * Important that faces use flushing since 'edges.out' wont include hidden edges that already existed.
+ * Important that faces use flushing since 'edges.out'
+ * wont include hidden edges that already existed.
*/
BMO_slot_buffer_hflag_disable(
em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_HIDDEN, true);
@@ -2207,7 +2209,7 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op)
void MESH_OT_normals_make_consistent(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Make Normals Consistent";
+ ot->name = "Recalculate Normals";
ot->description = "Make face and vertex normals point either outside or inside the mesh";
ot->idname = "MESH_OT_normals_make_consistent";
@@ -2271,12 +2273,15 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
MirrorModifierData *mmd = (MirrorModifierData *)md;
if (mmd->flag & MOD_MIR_CLIPPING) {
- if (mmd->flag & MOD_MIR_AXIS_X)
+ if (mmd->flag & MOD_MIR_AXIS_X) {
mirrx = true;
- if (mmd->flag & MOD_MIR_AXIS_Y)
+ }
+ if (mmd->flag & MOD_MIR_AXIS_Y) {
mirry = true;
- if (mmd->flag & MOD_MIR_AXIS_Z)
+ }
+ if (mmd->flag & MOD_MIR_AXIS_Z) {
mirrz = true;
+ }
clip_dist = mmd->tolerance;
}
@@ -2496,8 +2501,9 @@ static void mesh_set_smooth_faces(BMEditMesh *em, short smooth)
BMIter iter;
BMFace *efa;
- if (em == NULL)
+ if (em == NULL) {
return;
+ }
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
@@ -2768,7 +2774,7 @@ void MESH_OT_uvs_reverse(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- //RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around");
+ // RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around");
}
void MESH_OT_colors_rotate(wmOperatorType *ot)
@@ -2804,7 +2810,9 @@ void MESH_OT_colors_reverse(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- //RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around");
+#if 0
+ RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around");
+#endif
}
/** \} */
@@ -2835,31 +2843,37 @@ static bool merge_firstlast(BMEditMesh *em,
/* do sanity check in mergemenu in edit.c ?*/
if (use_first == false) {
- if (!em->bm->selected.last || ((BMEditSelection *)em->bm->selected.last)->htype != BM_VERT)
+ if (!em->bm->selected.last || ((BMEditSelection *)em->bm->selected.last)->htype != BM_VERT) {
return false;
+ }
ese = em->bm->selected.last;
mergevert = (BMVert *)ese->ele;
}
else {
- if (!em->bm->selected.first || ((BMEditSelection *)em->bm->selected.first)->htype != BM_VERT)
+ if (!em->bm->selected.first || ((BMEditSelection *)em->bm->selected.first)->htype != BM_VERT) {
return false;
+ }
ese = em->bm->selected.first;
mergevert = (BMVert *)ese->ele;
}
- if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT)) {
return false;
+ }
if (use_uvmerge) {
if (!EDBM_op_callf(
- em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert))
+ em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert)) {
return false;
+ }
}
- if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co))
+ if (!EDBM_op_callf(
+ em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) {
return false;
+ }
return true;
}
@@ -2886,14 +2900,16 @@ static bool merge_target(BMEditMesh *em,
float fac;
int i = 0;
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(v, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(v, BM_ELEM_SELECT)) {
continue;
+ }
add_v3_v3(cent, v->co);
i++;
}
- if (!i)
+ if (!i) {
return false;
+ }
fac = 1.0f / (float)i;
mul_v3_fl(cent, fac);
@@ -2901,16 +2917,19 @@ static bool merge_target(BMEditMesh *em,
vco = co;
}
- if (!vco)
+ if (!vco) {
return false;
+ }
if (use_uvmerge) {
- if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT))
+ if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT)) {
return false;
+ }
}
- if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co))
+ if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co)) {
return false;
+ }
return true;
}
@@ -2994,8 +3013,9 @@ static const EnumPropertyItem *merge_type_itemf(bContext *C,
EnumPropertyItem *item = NULL;
int totitem = 0;
- if (!C) /* needed for docs */
+ if (!C) { /* needed for docs */
return merge_type_items;
+ }
obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_MESH) {
@@ -3092,12 +3112,15 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
/* avoid losing selection state (select -> tags) */
char htype_select;
- if (em->selectmode & SCE_SELECT_VERTEX)
+ if (em->selectmode & SCE_SELECT_VERTEX) {
htype_select = BM_VERT;
- else if (em->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (em->selectmode & SCE_SELECT_EDGE) {
htype_select = BM_EDGE;
- else
+ }
+ else {
htype_select = BM_FACE;
+ }
/* store selection as tags */
BM_mesh_elem_hflag_enable_test(em->bm, htype_select, BM_ELEM_TAG, true, true, BM_ELEM_SELECT);
@@ -3146,8 +3169,8 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
void MESH_OT_remove_doubles(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Remove Doubles";
- ot->description = "Remove duplicate vertices";
+ ot->name = "Merge by Distance";
+ ot->description = "Merge vertices based on their proximity";
ot->idname = "MESH_OT_remove_doubles";
/* api callbacks */
@@ -3330,8 +3353,9 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
if (kb) {
/* Perform blending on selected vertices. */
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
+ if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
continue;
+ }
/* Get coordinates of shapekey we're blending from. */
sco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, shape);
@@ -3381,8 +3405,9 @@ static const EnumPropertyItem *shape_itemf(bContext *C,
int a;
for (a = 0; a < em->bm->vdata.totlayer; a++) {
- if (em->bm->vdata.layers[a].type != CD_SHAPEKEY)
+ if (em->bm->vdata.layers[a].type != CD_SHAPEKEY) {
continue;
+ }
tmp.value = totitem;
tmp.identifier = em->bm->vdata.layers[a].name;
@@ -3425,7 +3450,8 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot)
/* api callbacks */
ot->exec = edbm_blend_from_shape_exec;
- // ot->invoke = WM_operator_props_popup_call; /* disable because search popup closes too easily */
+ /* disable because search popup closes too easily */
+ // ot->invoke = WM_operator_props_popup_call;
ot->ui = edbm_blend_from_shape_ui;
ot->poll = ED_operator_editmesh;
@@ -3547,7 +3573,7 @@ static float bm_edge_seg_isect(const float sco_a[2],
float threshold = 0.0;
int i;
- //threshold = 0.000001; /* tolerance for vertex intersection */
+ // threshold = 0.000001; /* tolerance for vertex intersection */
// XXX threshold = scene->toolsettings->select_thresh / 100;
/* Get screen coords of verts */
@@ -3616,11 +3642,13 @@ static float bm_edge_seg_isect(const float sco_a[2],
/* sqrt(m2 * m2 + 1); Only looking for change in sign. Skip extra math .*/
dist = (y12 - m2 * x12 - b2);
}
- else
+ else {
dist = x22 - x12;
+ }
- if (i == 0)
+ if (i == 0) {
lastdist = dist;
+ }
/* if dist changes sign, and intersect point in edge's Bound Box */
if ((lastdist * dist) <= 0) {
@@ -3681,11 +3709,13 @@ static float bm_edge_seg_isect(const float sco_a[2],
}
}
}
- if ((m2 <= 1.0f) && (m2 >= -1.0f))
+ if ((m2 <= 1.0f) && (m2 >= -1.0f)) {
perc = (xi - x21) / (x22 - x21);
- else
+ }
+ else {
perc = (yi - y21) / (y22 - y21); /* lower slope more accurate */
- //isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */
+ }
+ // isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */
break;
}
@@ -3717,8 +3747,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
float(*screen_vert_coords)[2], (*sco)[2], (*mouse_path)[2];
/* edit-object needed for matrix, and ar->regiondata for projections to work */
- if (ELEM(NULL, obedit, ar, ar->regiondata))
+ if (ELEM(NULL, obedit, ar, ar->regiondata)) {
return OPERATOR_CANCELLED;
+ }
if (bm->totvertsel < 2) {
BKE_report(op->reports, RPT_ERROR, "No edges are selected to operate on");
@@ -3794,8 +3825,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
BMO_slot_buffer_from_enabled_flag(bm, &bmop, bmop.slots_in, "edges", BM_EDGE, ELE_EDGE_CUT);
- if (mode == KNIFE_MIDPOINT)
+ if (mode == KNIFE_MIDPOINT) {
numcuts = 1;
+ }
BMO_slot_int_set(bmop.slots_in, "cuts", numcuts);
BMO_slot_int_set(bmop.slots_in, "quad_corner_type", SUBD_CORNER_STRAIGHT_CUT);
@@ -4267,7 +4299,7 @@ void MESH_OT_separate(wmOperatorType *ot)
static const EnumPropertyItem prop_separate_types[] = {
{MESH_SEPARATE_SELECTED, "SELECTED", 0, "Selection", ""},
{MESH_SEPARATE_MATERIAL, "MATERIAL", 0, "By Material", ""},
- {MESH_SEPARATE_LOOSE, "LOOSE", 0, "By loose parts", ""},
+ {MESH_SEPARATE_LOOSE, "LOOSE", 0, "By Loose Parts", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -5904,19 +5936,28 @@ void MESH_OT_split(wmOperatorType *ot)
* \{ */
enum {
- SRT_VIEW_ZAXIS = 1, /* Use view Z (deep) axis. */
- SRT_VIEW_XAXIS, /* Use view X (left to right) axis. */
- SRT_CURSOR_DISTANCE, /* Use distance from element to 3D cursor. */
- SRT_MATERIAL, /* Face only: use mat number. */
- SRT_SELECTED, /* Move selected elements in first, without modifying
- * relative order of selected and unselected elements. */
- SRT_RANDOMIZE, /* Randomize selected elements. */
- SRT_REVERSE, /* Reverse current order of selected elements. */
+ /** Use view Z (deep) axis. */
+ SRT_VIEW_ZAXIS = 1,
+ /** Use view X (left to right) axis. */
+ SRT_VIEW_XAXIS,
+ /** Use distance from element to 3D cursor. */
+ SRT_CURSOR_DISTANCE,
+ /** Face only: use mat number. */
+ SRT_MATERIAL,
+ /** Move selected elements in first, without modifying
+ * relative order of selected and unselected elements. */
+ SRT_SELECTED,
+ /** Randomize selected elements. */
+ SRT_RANDOMIZE,
+ /** Reverse current order of selected elements. */
+ SRT_REVERSE,
};
typedef struct BMElemSort {
- float srt; /* Sort factor */
- int org_idx; /* Original index of this element _in its mempool_ */
+ /** Sort factor */
+ float srt;
+ /** Original index of this element _in its mempool_ */
+ int org_idx;
} BMElemSort;
static int bmelemsort_comp(const void *v1, const void *v2)
@@ -5953,15 +5994,19 @@ static void sort_bmelem_flag(bContext *C,
int affected[3] = {0, 0, 0};
int i, j;
- if (!(types && flag && action))
+ if (!(types && flag && action)) {
return;
+ }
- if (types & BM_VERT)
+ if (types & BM_VERT) {
totelem[0] = em->bm->totvert;
- if (types & BM_EDGE)
+ }
+ if (types & BM_EDGE) {
totelem[1] = em->bm->totedge;
- if (types & BM_FACE)
+ }
+ if (types & BM_FACE) {
totelem[2] = em->bm->totface;
+ }
if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) {
float mat[4][4];
@@ -6173,8 +6218,9 @@ static void sort_bmelem_flag(bContext *C,
int aff = affected[j];
tb = tbuf[j];
mp = map[j];
- if (!(tb && mp))
+ if (!(tb && mp)) {
continue;
+ }
if (ELEM(aff, 0, tot)) {
MEM_freeN(tb);
MEM_freeN(mp);
@@ -6315,12 +6361,15 @@ static void sort_bmelem_flag(bContext *C,
/* printf("%d faces: %d to be affected...\n", totelem[2], affected[2]);*/
if (affected[0] == 0 && affected[1] == 0 && affected[2] == 0) {
for (j = 3; j--;) {
- if (pblock[j])
+ if (pblock[j]) {
MEM_freeN(pblock[j]);
- if (sblock[j])
+ }
+ if (sblock[j]) {
MEM_freeN(sblock[j]);
- if (map[j])
+ }
+ if (map[j]) {
MEM_freeN(map[j]);
+ }
}
return;
}
@@ -6350,10 +6399,12 @@ static void sort_bmelem_flag(bContext *C,
}
}
}
- if (pb)
+ if (pb) {
MEM_freeN(pb);
- if (sb)
+ }
+ if (sb) {
MEM_freeN(sb);
+ }
}
BM_mesh_remap(em->bm, map[0], map[1], map[2]);
@@ -6361,8 +6412,9 @@ static void sort_bmelem_flag(bContext *C,
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
for (j = 3; j--;) {
- if (map[j])
+ if (map[j]) {
MEM_freeN(map[j]);
+ }
}
}
@@ -6394,12 +6446,15 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
}
else {
BMEditMesh *em = BKE_editmesh_from_object(ob_active);
- if (em->selectmode & SCE_SELECT_VERTEX)
+ if (em->selectmode & SCE_SELECT_VERTEX) {
elem_types |= BM_VERT;
- if (em->selectmode & SCE_SELECT_EDGE)
+ }
+ if (em->selectmode & SCE_SELECT_EDGE) {
elem_types |= BM_EDGE;
- if (em->selectmode & SCE_SELECT_FACE)
+ }
+ if (em->selectmode & SCE_SELECT_FACE) {
elem_types |= BM_FACE;
+ }
RNA_enum_set(op->ptr, "elements", elem_types);
}
@@ -6441,18 +6496,22 @@ static bool edbm_sort_elements_poll_property(const bContext *UNUSED(C),
/* Only show seed for randomize action! */
if (STREQ(prop_id, "seed")) {
- if (action == SRT_RANDOMIZE)
+ if (action == SRT_RANDOMIZE) {
return true;
- else
+ }
+ else {
return false;
+ }
}
/* Hide seed for reverse and randomize actions! */
if (STREQ(prop_id, "reverse")) {
- if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE))
+ if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) {
return false;
- else
+ }
+ else {
return true;
+ }
}
return true;
@@ -6953,7 +7012,8 @@ void MESH_OT_offset_edge_loops(wmOperatorType *ot)
ot->exec = edbm_offset_edgeloop_exec;
ot->poll = ED_operator_editmesh;
- /* Keep internal, since this is only meant to be accessed via 'MESH_OT_offset_edge_loops_slide' */
+ /* Keep internal, since this is only meant to be accessed via
+ * 'MESH_OT_offset_edge_loops_slide'. */
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -7589,8 +7649,9 @@ wmKeyMap *point_normals_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, keymap_name);
/* We only need to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return NULL;
+ }
keymap = WM_modalkeymap_add(keyconf, keymap_name, modal_items);
@@ -7721,7 +7782,8 @@ static void point_normals_apply(bContext *C, wmOperator *op, float target[3], co
copy_v3_v3(lnor_ed->nloc, lnor_ed->niloc);
}
else if (do_spherize) {
- /* Note that this is *not* real spherical interpolation. Probably good enough in this case though? */
+ /* Note that this is *not* real spherical interpolation.
+ * Probably good enough in this case though? */
const float strength = RNA_float_get(op->ptr, "spherize_strength");
float spherized_normal[3];
@@ -8801,12 +8863,13 @@ static int edbm_smoothen_normals_exec(bContext *C, wmOperator *op)
float(*smooth_normal)[3] = MEM_callocN(sizeof(*smooth_normal) * lnors_ed_arr->totloop, __func__);
- /* This is weird choice of operation, taking all loops of faces of current vertex... Could lead to some rather
- * far away loops weighting as much as very close ones (topologically speaking), with complex polygons.
- * Using topological distance here (rather than geometrical one) makes sense imho, but would rather go with
- * a more consistent and flexible code, we could even add max topological distance to take into account,
- * and a weighting curve...
- * Would do that later though, think for now we can live with that choice. --mont29 */
+ /* This is weird choice of operation, taking all loops of faces of current vertex.
+ * Could lead to some rather far away loops weighting as much as very close ones
+ * (topologically speaking), with complex polygons.
+ * Using topological distance here (rather than geometrical one)
+ * makes sense imho, but would rather go with a more consistent and flexible code,
+ * we could even add max topological distance to take into account, * and a weighting curve.
+ * Would do that later though, think for now we can live with that choice. --mont29. */
BMLoopNorEditData *lnor_ed = lnors_ed_arr->lnor_editdata;
for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) {
l = lnor_ed->loop;
@@ -8864,7 +8927,7 @@ static int edbm_smoothen_normals_exec(bContext *C, wmOperator *op)
void MESH_OT_smoothen_normals(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Smoothen Normals";
+ ot->name = "Smooth Normals Vectors";
ot->description = "Smoothen custom normals based on adjacent vertex normals";
ot->idname = "MESH_OT_smoothen_normals";
@@ -8941,7 +9004,7 @@ static int edbm_mod_weighted_strength_exec(bContext *C, wmOperator *op)
void MESH_OT_mod_weighted_strength(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Face Strength";
+ ot->name = "Face Normals Strength";
ot->description = "Set/Get strength of face (used in Weighted Normal modifier)";
ot->idname = "MESH_OT_mod_weighted_strength";
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index 2e855d9c5de..28b14b0060d 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -93,13 +93,13 @@ typedef struct UndoMesh {
int selectmode;
/** \note
- * this isn't a prefect solution, if you edit keys and change shapes this works well (fixing [#32442]),
- * but editing shape keys, going into object mode, removing or changing their order,
- * then go back into editmode and undo will give issues - where the old index will be out of sync
- * with the new object index.
+ * this isn't a prefect solution, if you edit keys and change shapes this works well
+ * (fixing T32442), but editing shape keys, going into object mode, removing or changing their
+ * order, then go back into editmode and undo will give issues - where the old index will be
+ * out of sync with the new object index.
*
* There are a few ways this could be made to work but for now its a known limitation with mixing
- * object and editmode operations - Campbell */
+ * object and editmode operations - Campbell. */
int shapenr;
#ifdef USE_ARRAY_STORE
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 1cb550fccc4..d7ed14184fa 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -363,10 +363,8 @@ void EDBM_mesh_load(Main *bmain, Object *ob)
* cycles.
*/
#if 0
- for (Object *other_object = bmain->objects.first;
- other_object != NULL;
- other_object = other_object->id.next)
- {
+ for (Object *other_object = bmain->objects.first; other_object != NULL;
+ other_object = other_object->id.next) {
if (other_object->data == ob->data) {
BKE_object_free_derived_caches(other_object);
}
@@ -575,8 +573,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa->len);
}
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
buf->loop_of_poly_index = i;
buf->poly_index = a;
buf->separate = 0;
@@ -629,10 +626,12 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
if (fabsf(uvdiff[0]) < limit[0] && fabsf(uvdiff[1]) < limit[1] &&
(!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) {
- if (lastv)
+ if (lastv) {
lastv->next = next;
- else
+ }
+ else {
vlist = next;
+ }
iterv->next = newvlist;
newvlist = iterv;
}
@@ -725,8 +724,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa->len);
}
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
buf->l = l;
buf->separate = 0;
buf->island = INVALID_ISLAND;
@@ -780,10 +778,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
if (fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT && fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT &&
(!use_winding ||
winding[BM_elem_index_get(iterv->l->f)] == winding[BM_elem_index_get(v->l->f)])) {
- if (lastv)
+ if (lastv) {
lastv->next = next;
- else
+ }
+ else {
vlist = next;
+ }
iterv->next = newvlist;
newvlist = iterv;
}
@@ -837,8 +837,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
UvElement *element, *initelement = element_map->vert[BM_elem_index_get(l->v)];
for (element = initelement; element; element = element->next) {
- if (element->separate)
+ if (element->separate) {
initelement = element;
+ }
if (element->l->f == efa) {
/* found the uv corresponding to our face and vertex.
@@ -852,8 +853,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
islandbufsize++;
for (element = initelement; element; element = element->next) {
- if (element->separate && element != initelement)
+ if (element->separate && element != initelement) {
break;
+ }
if (island_number[BM_elem_index_get(element->l->f)] == INVALID_ISLAND) {
stack[stacksize++] = element->l->f;
@@ -875,8 +877,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
/* remap */
for (i = 0; i < bm->totvert; i++) {
/* important since we may do selection only. Some of these may be NULL */
- if (element_map->vert[i])
+ if (element_map->vert[i]) {
element_map->vert[i] = &islandbuf[map[element_map->vert[i] - element_map->buf]];
+ }
}
element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices) * nislands,
@@ -884,10 +887,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
j = 0;
for (i = 0; i < totuv; i++) {
UvElement *element = element_map->buf[i].next;
- if (element == NULL)
+ if (element == NULL) {
islandbuf[map[i]].next = NULL;
- else
+ }
+ else {
islandbuf[map[i]].next = &islandbuf[map[element - element_map->buf]];
+ }
if (islandbuf[i].island != j) {
j++;
@@ -911,10 +916,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
void BM_uv_vert_map_free(UvVertMap *vmap)
{
if (vmap) {
- if (vmap->vert)
+ if (vmap->vert) {
MEM_freeN(vmap->vert);
- if (vmap->buf)
+ }
+ if (vmap->buf) {
MEM_freeN(vmap->buf);
+ }
MEM_freeN(vmap);
}
}
@@ -922,12 +929,15 @@ void BM_uv_vert_map_free(UvVertMap *vmap)
void BM_uv_element_map_free(UvElementMap *element_map)
{
if (element_map) {
- if (element_map->vert)
+ if (element_map->vert) {
MEM_freeN(element_map->vert);
- if (element_map->buf)
+ }
+ if (element_map->buf) {
MEM_freeN(element_map->buf);
- if (element_map->islandIndices)
+ }
+ if (element_map->islandIndices) {
MEM_freeN(element_map->islandIndices);
+ }
MEM_freeN(element_map);
}
}
@@ -1021,7 +1031,8 @@ static BMVert *cache_mirr_intptr_as_bmvert(intptr_t *index_lookup, int index)
* \param use_select: Restrict to selected verts.
* \param use_topology: Use topology mirror.
* \param maxdist: Distance for close point test.
- * \param r_index: Optional array to write into, as an alternative to a customdata layer (length of total verts).
+ * \param r_index: Optional array to write into, as an alternative to a customdata layer
+ * (length of total verts).
*/
void EDBM_verts_mirror_cache_begin_ex(BMEditMesh *em,
const int axis,
@@ -1246,12 +1257,15 @@ bool EDBM_mesh_hide(BMEditMesh *em, bool swap)
char hflag_swap = swap ? BM_ELEM_SELECT : 0;
bool changed = true;
- if (em->selectmode & SCE_SELECT_VERTEX)
+ if (em->selectmode & SCE_SELECT_VERTEX) {
itermode = BM_VERTS_OF_MESH;
- else if (em->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (em->selectmode & SCE_SELECT_EDGE) {
itermode = BM_EDGES_OF_MESH;
- else
+ }
+ else {
itermode = BM_FACES_OF_MESH;
+ }
BM_ITER_MESH (ele, &iter, em->bm, itermode) {
if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 2f4fbcab9bc..385b3c69422 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -183,8 +183,7 @@ static void mesh_uv_reset_bmface(BMFace *f, const int cd_loop_uv_offset)
BMLoop *l;
int i;
- BM_ITER_ELEM_INDEX(l, &liter, f, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, i) {
fuv[i] = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset))->uv;
}
@@ -218,8 +217,9 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum)
BLI_assert(cd_loop_uv_offset != -1);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
mesh_uv_reset_bmface(efa, cd_loop_uv_offset);
}
@@ -262,8 +262,9 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co
em = me->edit_mesh;
layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
- if (layernum_dst >= MAX_MTFACE)
+ if (layernum_dst >= MAX_MTFACE) {
return -1;
+ }
/* CD_MLOOPUV */
BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPUV, name);
@@ -280,8 +281,9 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co
}
else {
layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
- if (layernum_dst >= MAX_MTFACE)
+ if (layernum_dst >= MAX_MTFACE) {
return -1;
+ }
if (me->mloopuv && do_init) {
CustomData_add_layer_named(
@@ -323,13 +325,15 @@ void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name)
em = me->edit_mesh;
layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
- if (layernum_dst == 0)
+ if (layernum_dst == 0) {
ED_mesh_uv_texture_add(me, name, true, true);
+ }
}
else {
layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
- if (layernum_dst == 0)
+ if (layernum_dst == 0) {
ED_mesh_uv_texture_add(me, name, true, true);
+ }
}
}
@@ -342,8 +346,9 @@ bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n)
index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n);
cdlu = (index == -1) ? NULL : &ldata->layers[index];
- if (!cdlu)
+ if (!cdlu) {
return false;
+ }
delete_customdata_layer(me, cdlu);
@@ -456,8 +461,9 @@ bool ED_mesh_color_remove_index(Mesh *me, const int n)
index = CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, n);
cdl = (index == -1) ? NULL : &ldata->layers[index];
- if (!cdl)
+ if (!cdl) {
return false;
+ }
delete_customdata_layer(me, cdl);
DEG_id_tag_update(&me->id, 0);
@@ -502,8 +508,9 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1)
+ if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1) {
return OPERATOR_CANCELLED;
+ }
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
@@ -534,8 +541,9 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (!ED_mesh_uv_texture_remove_active(me))
+ if (!ED_mesh_uv_texture_remove_active(me)) {
return OPERATOR_CANCELLED;
+ }
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
@@ -568,8 +576,9 @@ static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (ED_mesh_color_add(me, NULL, true, true) == -1)
+ if (ED_mesh_color_add(me, NULL, true, true) == -1) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -594,8 +603,9 @@ static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (!ED_mesh_color_remove_active(me))
+ if (!ED_mesh_color_remove_active(me)) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -785,7 +795,8 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
CustomData *data = GET_CD_DATA(me, ldata);
if (me->edit_mesh) {
- /* Tag edges as sharp according to smooth threshold if needed, to preserve autosmooth shading. */
+ /* Tag edges as sharp according to smooth threshold if needed,
+ * to preserve autosmooth shading. */
if (me->flag & ME_AUTOSMOOTH) {
BM_edges_sharp_from_angle_set(me->edit_mesh->bm, me->smoothresh);
}
@@ -793,7 +804,8 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
BM_data_layer_add(me->edit_mesh->bm, data, CD_CUSTOMLOOPNORMAL);
}
else {
- /* Tag edges as sharp according to smooth threshold if needed, to preserve autosmooth shading. */
+ /* Tag edges as sharp according to smooth threshold if needed,
+ * to preserve autosmooth shading. */
if (me->flag & ME_AUTOSMOOTH) {
float(*polynors)[3] = MEM_mallocN(sizeof(*polynors) * (size_t)me->totpoly, __func__);
@@ -891,8 +903,9 @@ void ED_mesh_update(
BKE_mesh_calc_edges_loose(mesh);
}
- if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0))
+ if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0)) {
BKE_mesh_calc_edges(mesh, calc_edges, true);
+ }
if (calc_tessface) {
if (tessface_input == false) {
@@ -916,15 +929,17 @@ static void mesh_add_verts(Mesh *mesh, int len)
MVert *mvert;
int i, totvert;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totvert = mesh->totvert + len;
CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert);
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
- if (!CustomData_has_layer(&vdata, CD_MVERT))
+ if (!CustomData_has_layer(&vdata, CD_MVERT)) {
CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
+ }
CustomData_free(&mesh->vdata, mesh->totvert);
mesh->vdata = vdata;
@@ -934,8 +949,9 @@ static void mesh_add_verts(Mesh *mesh, int len)
/* set default flags */
mvert = &mesh->mvert[mesh->totvert];
- for (i = 0; i < len; i++, mvert++)
+ for (i = 0; i < len; i++, mvert++) {
mvert->flag |= SELECT;
+ }
/* set final vertex list size */
mesh->totvert = totvert;
@@ -947,8 +963,9 @@ static void mesh_add_edges(Mesh *mesh, int len)
MEdge *medge;
int i, totedge;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totedge = mesh->totedge + len;
@@ -956,8 +973,9 @@ static void mesh_add_edges(Mesh *mesh, int len)
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
- if (!CustomData_has_layer(&edata, CD_MEDGE))
+ if (!CustomData_has_layer(&edata, CD_MEDGE)) {
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
+ }
CustomData_free(&mesh->edata, mesh->totedge);
mesh->edata = edata;
@@ -965,8 +983,9 @@ static void mesh_add_edges(Mesh *mesh, int len)
/* set default flags */
medge = &mesh->medge[mesh->totedge];
- for (i = 0; i < len; i++, medge++)
+ for (i = 0; i < len; i++, medge++) {
medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
+ }
mesh->totedge = totedge;
}
@@ -977,8 +996,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
MFace *mface;
int i, totface;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totface = mesh->totface + len; /* new face count */
@@ -986,8 +1006,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH.fmask, CD_DEFAULT, totface);
CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface);
- if (!CustomData_has_layer(&fdata, CD_MFACE))
+ if (!CustomData_has_layer(&fdata, CD_MFACE)) {
CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface);
+ }
CustomData_free(&mesh->fdata, mesh->totface);
mesh->fdata = fdata;
@@ -995,8 +1016,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
/* set default flags */
mface = &mesh->mface[mesh->totface];
- for (i = 0; i < len; i++, mface++)
+ for (i = 0; i < len; i++, mface++) {
mface->flag = ME_FACE_SEL;
+ }
mesh->totface = totface;
}
@@ -1006,8 +1028,9 @@ static void mesh_add_loops(Mesh *mesh, int len)
CustomData ldata;
int totloop;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totloop = mesh->totloop + len; /* new face count */
@@ -1015,8 +1038,9 @@ static void mesh_add_loops(Mesh *mesh, int len)
CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop);
CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
- if (!CustomData_has_layer(&ldata, CD_MLOOP))
+ if (!CustomData_has_layer(&ldata, CD_MLOOP)) {
CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
+ }
CustomData_free(&mesh->ldata, mesh->totloop);
mesh->ldata = ldata;
@@ -1031,8 +1055,9 @@ static void mesh_add_polys(Mesh *mesh, int len)
MPoly *mpoly;
int i, totpoly;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totpoly = mesh->totpoly + len; /* new face count */
@@ -1040,8 +1065,9 @@ static void mesh_add_polys(Mesh *mesh, int len)
CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly);
CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
- if (!CustomData_has_layer(&pdata, CD_MPOLY))
+ if (!CustomData_has_layer(&pdata, CD_MPOLY)) {
CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
+ }
CustomData_free(&mesh->pdata, mesh->totpoly);
mesh->pdata = pdata;
@@ -1049,8 +1075,9 @@ static void mesh_add_polys(Mesh *mesh, int len)
/* set default flags */
mpoly = &mesh->mpoly[mesh->totpoly];
- for (i = 0; i < len; i++, mpoly++)
+ for (i = 0; i < len; i++, mpoly++) {
mpoly->flag = ME_FACE_SEL;
+ }
mesh->totpoly = totpoly;
}
@@ -1059,8 +1086,9 @@ static void mesh_remove_verts(Mesh *mesh, int len)
{
int totvert;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totvert = mesh->totvert - len;
CustomData_free_elem(&mesh->vdata, totvert, len);
@@ -1073,8 +1101,9 @@ static void mesh_remove_edges(Mesh *mesh, int len)
{
int totedge;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totedge = mesh->totedge - len;
CustomData_free_elem(&mesh->edata, totedge, len);
@@ -1086,8 +1115,9 @@ static void mesh_remove_faces(Mesh *mesh, int len)
{
int totface;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totface = mesh->totface - len; /* new face count */
CustomData_free_elem(&mesh->fdata, totface, len);
diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c
index 7d0ee19b5ea..eec0c4a57fa 100644
--- a/source/blender/editors/mesh/mesh_mirror.c
+++ b/source/blender/editors/mesh/mesh_mirror.c
@@ -50,8 +50,9 @@ int ED_mesh_mirror_spatial_table(
Object *ob, BMEditMesh *em, Mesh *me_eval, const float co[3], char mode)
{
if (mode == 'u') { /* use table */
- if (MirrKdStore.tree == NULL)
+ if (MirrKdStore.tree == NULL) {
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's');
+ }
if (MirrKdStore.tree) {
KDTreeNearest_3d nearest;
@@ -70,8 +71,9 @@ int ED_mesh_mirror_spatial_table(
const bool use_em = (!me_eval && em && me->edit_mesh == em);
const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert;
- if (MirrKdStore.tree) /* happens when entering this call without ending it */
+ if (MirrKdStore.tree) { /* happens when entering this call without ending it */
ED_mesh_mirror_spatial_table(ob, em, me_eval, co, 'e');
+ }
MirrKdStore.tree = BLI_kdtree_3d_new(totvert);
@@ -126,19 +128,23 @@ typedef struct MirrTopoVert_t {
static int mirrtopo_hash_sort(const void *l1, const void *l2)
{
- if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2)
+ if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2) {
return 1;
- else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2)
+ }
+ else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2) {
return -1;
+ }
return 0;
}
static int mirrtopo_vert_sort(const void *v1, const void *v2)
{
- if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash)
+ if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash) {
return 1;
- else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash)
+ }
+ else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash) {
return -1;
+ }
return 0;
}
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 8a51b9ba54e..ed5e6c39f85 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -242,7 +242,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_rip_move",
@@ -251,7 +251,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_rip_edge_move",
@@ -260,7 +260,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_rip_edge");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move",
@@ -269,7 +269,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_context_move",
@@ -278,7 +278,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_context");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten",
@@ -287,7 +287,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move",
@@ -296,7 +296,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move",
@@ -305,7 +305,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move",
@@ -314,7 +314,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_polybuild_face_at_cursor_move",
@@ -323,7 +323,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_polybuild_face_at_cursor");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_polybuild_split_at_cursor_move",
@@ -332,7 +332,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_polybuild_split_at_cursor");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index ce7908bf0a3..c32fef42d27 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -150,9 +150,11 @@ static void join_mesh_single(Depsgraph *depsgraph,
mul_m4_v3(cmat, mvert->co);
}
- /* for each shapekey in destination mesh:
- * - if there's a matching one, copy it across (will need to transform vertices into new space...)
- * - otherwise, just copy own coordinates of mesh (no need to transform vertex coordinates into new space)
+ /* For each shapekey in destination mesh:
+ * - if there's a matching one, copy it across
+ * (will need to transform vertices into new space...).
+ * - otherwise, just copy own coordinates of mesh
+ * (no need to transform vertex coordinates into new space).
*/
if (key) {
/* if this mesh has any shapekeys, check first, otherwise just copy coordinates */
@@ -321,12 +323,14 @@ int join_mesh_exec(bContext *C, wmOperator *op)
totpoly += me->totpoly;
totmat += ob_iter->totcol;
- if (ob_iter == ob)
+ if (ob_iter == ob) {
ok = true;
+ }
/* check for shapekeys */
- if (me->key)
+ if (me->key) {
haskey++;
+ }
}
}
CTX_DATA_END;
@@ -337,7 +341,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* only join meshes if there are verts to join, there aren't too many, and we only had one mesh selected */
+ /* Only join meshes if there are verts to join,
+ * there aren't too many, and we only had one mesh selected. */
me = (Mesh *)ob->data;
key = me->key;
@@ -383,8 +388,9 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* for all keys in old block, clear data-arrays */
for (kb = key->block.first; kb; kb = kb->next) {
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
kb->data = MEM_callocN(sizeof(float) * 3 * totvert, "join_shapekey");
kb->totelem = totvert;
}
@@ -410,8 +416,9 @@ int join_mesh_exec(bContext *C, wmOperator *op)
BLI_addtail(&ob->defbase, odg);
}
}
- if (ob->defbase.first && ob->actdef == 0)
+ if (ob->defbase.first && ob->actdef == 0) {
ob->actdef = 1;
+ }
if (me->totvert) {
/* Add this object's materials to the base one's if they don't exist already
@@ -606,13 +613,15 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* old material array */
for (a = 1; a <= ob->totcol; a++) {
ma = ob->mat[a - 1];
- if (ma)
+ if (ma) {
id_us_min(&ma->id);
+ }
}
for (a = 1; a <= me->totcol; a++) {
ma = me->mat[a - 1];
- if (ma)
+ if (ma) {
id_us_min(&ma->id);
+ }
}
MEM_SAFE_FREE(ob->mat);
MEM_SAFE_FREE(ob->matbits);
@@ -680,21 +689,25 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
if (ob_iter->type == OB_MESH) {
selme = (Mesh *)ob_iter->data;
- if (selme->totvert == me->totvert)
+ if (selme->totvert == me->totvert) {
ok = true;
- else
+ }
+ else {
nonequal_verts = 1;
+ }
}
}
CTX_DATA_END;
if (!ok) {
- if (nonequal_verts)
+ if (nonequal_verts) {
BKE_report(op->reports, RPT_WARNING, "Selected meshes must have equal numbers of vertices");
- else
+ }
+ else {
BKE_report(op->reports,
RPT_WARNING,
"No additional selected meshes with equal vertex count to join");
+ }
return OPERATOR_CANCELLED;
}
@@ -748,9 +761,10 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
static MirrTopoStore_t mesh_topo_store = {NULL, -1. - 1, -1};
-/* mode is 's' start, or 'e' end, or 'u' use */
-/* if end, ob can be NULL */
-/* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */
+/** mode is 's' start, or 'e' end, or 'u' use
+ * if end, ob can be NULL.
+ * \note, is supposed return -1 on error,
+ * which callers are currently checking for, but is not used so far. */
int ED_mesh_mirror_topo_table(Object *ob, Mesh *me_eval, char mode)
{
if (mode == 'u') { /* use table */
@@ -789,8 +803,9 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index)
static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index)
{
- if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1)
+ if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1) {
return -1;
+ }
return mesh_topo_store.index_lookup[index];
}
@@ -832,8 +847,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
int index)
{
intptr_t poinval;
- if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1)
+ if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1) {
return NULL;
+ }
if (index == -1) {
BMIter iter;
@@ -841,8 +857,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
index = 0;
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (v == eve)
+ if (v == eve) {
break;
+ }
index++;
}
@@ -853,8 +870,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
poinval = mesh_topo_store.index_lookup[index];
- if (poinval != -1)
+ if (poinval != -1) {
return (BMVert *)(poinval);
+ }
return NULL;
}
@@ -900,17 +918,15 @@ int ED_mesh_mirror_get_vert(Object *ob, int index)
#if 0
-static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float *mirrCent, float *face_cent)
+static float *editmesh_get_mirror_uv(
+ BMEditMesh *em, int axis, float *uv, float *mirrCent, float *face_cent)
{
float vec[2];
float cent_vec[2];
float cent[2];
/* ignore nan verts */
- if (isnan(uv[0]) || !isfinite(uv[0]) ||
- isnan(uv[1]) || !isfinite(uv[1])
- )
- {
+ if (isnan(uv[0]) || !isfinite(uv[0]) || isnan(uv[1]) || !isfinite(uv[1])) {
return NULL;
}
@@ -937,15 +953,14 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
uv_poly_center(efa, cent, cd_loop_uv_offset);
- if ( (fabsf(cent[0] - cent_vec[0]) < 0.001f) && (fabsf(cent[1] - cent_vec[1]) < 0.001f) ) {
+ if ((fabsf(cent[0] - cent_vec[0]) < 0.001f) && (fabsf(cent[1] - cent_vec[1]) < 0.001f)) {
BMIter liter;
BMLoop *l;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if ( (fabsf(luv->uv[0] - vec[0]) < 0.001f) && (fabsf(luv->uv[1] - vec[1]) < 0.001f) ) {
+ if ((fabsf(luv->uv[0] - vec[0]) < 0.001f) && (fabsf(luv->uv[1] - vec[1]) < 0.001f)) {
return luv->uv;
-
}
}
}
@@ -977,22 +992,29 @@ static unsigned int mirror_facehash(const void *ptr)
static int mirror_facerotation(MFace *a, MFace *b)
{
if (b->v4) {
- if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4)
+ if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4) {
return 0;
- else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4)
+ }
+ else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4) {
return 1;
- else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4)
+ }
+ else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4) {
return 2;
- else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4)
+ }
+ else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4) {
return 3;
+ }
}
else {
- if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3)
+ if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3) {
return 0;
- else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3)
+ }
+ else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3) {
return 1;
- else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3)
+ }
+ else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) {
return 2;
+ }
}
return -1;
@@ -1027,14 +1049,16 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's');
- for (a = 0, mv = mvert; a < totvert; a++, mv++)
+ for (a = 0, mv = mvert; a < totvert; a++, mv++) {
mirrorverts[a] = mesh_get_x_mirror_vert(ob, me_eval, a, use_topology);
+ }
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 'e');
fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface);
- for (a = 0, mf = mface; a < totface; a++, mf++)
+ for (a = 0, mf = mface; a < totface; a++, mf++) {
BLI_ghash_insert(fhash, mf, mf);
+ }
for (a = 0, mf = mface; a < totface; a++, mf++) {
mirrormf.v1 = mirrorverts[mf->v3];
@@ -1053,8 +1077,9 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
mirrorfaces[a * 2] = hashmf - mface;
mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf);
}
- else
+ else {
mirrorfaces[a * 2] = -1;
+ }
}
BLI_ghash_free(fhash, NULL, NULL);
@@ -1079,8 +1104,9 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px,
BLI_assert(me && GS(me->id.name) == ID_ME);
- if (!me || me->totpoly == 0)
+ if (!me || me->totpoly == 0) {
return false;
+ }
ED_view3d_viewcontext_init(C, &vc);
@@ -1260,8 +1286,9 @@ bool ED_mesh_pick_vert(
BLI_assert(me && GS(me->id.name) == ID_ME);
- if (!me || me->totvert == 0)
+ if (!me || me->totvert == 0) {
return false;
+ }
ED_view3d_viewcontext_init(C, &vc);
@@ -1335,15 +1362,17 @@ MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve)
BMVert *eve = BM_mesh_active_vert_get(bm);
if (eve) {
- if (r_eve)
+ if (r_eve) {
*r_eve = eve;
+ }
return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
}
}
}
- if (r_eve)
+ if (r_eve) {
*r_eve = NULL;
+ }
return NULL;
}
@@ -1351,8 +1380,9 @@ MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index)
{
Mesh *me = ob->data;
int index = BKE_mesh_mselect_active_get(me, ME_VSEL);
- if (r_index)
+ if (r_index) {
*r_index = index;
+ }
if (index == -1 || me->dvert == NULL) {
return NULL;
}
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 45eb66c228b..54143822b61 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -15,8 +15,6 @@
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
- *
-
*/
/** \file
diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c
index 4de277901f4..c203ca56d74 100644
--- a/source/blender/editors/metaball/mball_ops.c
+++ b/source/blender/editors/metaball/mball_ops.c
@@ -59,7 +59,7 @@ void ED_operatormacros_metaball(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MBALL_OT_duplicate_metaelems");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
void ED_keymap_metaball(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 8ef0d85bcfd..eaef9313431 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -22,19 +22,19 @@ set(INC
../../blentranslation
../../bmesh
../../depsgraph
+ ../../gpencil_modifiers
../../gpu
../../ikplugin
../../imbuf
../../makesdna
../../makesrna
../../modifiers
- ../../gpencil_modifiers
- ../../shader_fx
../../python
+ ../../shader_fx
../../render/extern/include
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index c050b579aa6..f8a13579732 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -216,14 +216,17 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3],
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
- if (!scene)
+ if (!scene) {
return;
+ }
- if (loc)
+ if (loc) {
copy_v3_v3(ob->loc, loc);
+ }
- if (rot)
+ if (rot) {
copy_v3_v3(ob->rot, rot);
+ }
BKE_object_where_is_calc(depsgraph, scene, ob);
}
@@ -342,11 +345,13 @@ bool ED_object_add_generic_get_opts(bContext *C,
/* Switch to Edit mode? optional prop */
if ((prop = RNA_struct_find_property(op->ptr, "enter_editmode"))) {
bool _enter_editmode;
- if (!enter_editmode)
+ if (!enter_editmode) {
enter_editmode = &_enter_editmode;
+ }
- if (RNA_property_is_set(op->ptr, prop) && enter_editmode)
+ if (RNA_property_is_set(op->ptr, prop) && enter_editmode) {
*enter_editmode = RNA_property_boolean_get(op->ptr, prop);
+ }
else {
*enter_editmode = (U.flag & USER_ADD_EDITMODE) != 0;
RNA_property_boolean_set(op->ptr, prop, *enter_editmode);
@@ -363,8 +368,9 @@ bool ED_object_add_generic_get_opts(bContext *C,
/* Location! */
{
float _loc[3];
- if (!loc)
+ if (!loc) {
loc = _loc;
+ }
if (RNA_struct_property_is_set(op->ptr, "location")) {
RNA_float_get_array(op->ptr, "location", loc);
@@ -379,15 +385,19 @@ bool ED_object_add_generic_get_opts(bContext *C,
{
bool _is_view_aligned;
float _rot[3];
- if (!is_view_aligned)
+ if (!is_view_aligned) {
is_view_aligned = &_is_view_aligned;
- if (!rot)
+ }
+ if (!rot) {
rot = _rot;
+ }
- if (RNA_struct_property_is_set(op->ptr, "rotation"))
+ if (RNA_struct_property_is_set(op->ptr, "rotation")) {
*is_view_aligned = false;
- else if (RNA_struct_property_is_set(op->ptr, "view_align"))
+ }
+ else if (RNA_struct_property_is_set(op->ptr, "view_align")) {
*is_view_aligned = RNA_boolean_get(op->ptr, "view_align");
+ }
else {
*is_view_aligned = (U.flag & USER_ADD_VIEWALIGNED) != 0;
RNA_boolean_set(op->ptr, "view_align", *is_view_aligned);
@@ -397,8 +407,9 @@ bool ED_object_add_generic_get_opts(bContext *C,
ED_object_rotation_from_view(C, rot, view_align_axis);
RNA_float_set_array(op->ptr, "rotation", rot);
}
- else
+ else {
RNA_float_get_array(op->ptr, "rotation", rot);
+ }
}
return true;
@@ -625,15 +636,17 @@ static int effector_add_exec(bContext *C, wmOperator *op)
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
BLI_addtail(&cu->editnurb->nurbs,
ED_curve_add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, dia));
- if (!enter_editmode)
+ if (!enter_editmode) {
ED_object_editmode_exit(C, EM_FREEDATA);
+ }
}
else {
const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field");
ob = ED_object_add_type(C, OB_EMPTY, name, loc, rot, false, local_view_bits);
BKE_object_obdata_size_init(ob, dia);
- if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX))
+ if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX)) {
ob->empty_drawtype = OB_SINGLE_ARROW;
+ }
}
ob->pd = BKE_partdeflect_new(type);
@@ -686,8 +699,9 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false, local_view_bits);
if (v3d) {
- if (v3d->camera == NULL)
+ if (v3d->camera == NULL) {
v3d->camera = ob;
+ }
if (v3d->scenelock && scene->camera == NULL) {
scene->camera = ob;
}
@@ -797,8 +811,9 @@ static int object_add_text_exec(bContext *C, wmOperator *op)
C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
}
- if (obedit && obedit->type == OB_FONT)
+ if (obedit && obedit->type == OB_FONT) {
return OPERATOR_CANCELLED;
+ }
obedit = ED_object_add_type(C, OB_FONT, NULL, loc, rot, enter_editmode, local_view_bits);
BKE_object_obdata_size_init(obedit, RNA_float_get(op->ptr, "radius"));
@@ -862,8 +877,9 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
ED_armature_ebone_add_primitive(obedit, dia, view_aligned);
/* userdef */
- if (newob && !enter_editmode)
+ if (newob && !enter_editmode) {
ED_object_editmode_exit(C, EM_FREEDATA);
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
@@ -1246,8 +1262,9 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
RNA_float_set_array(op->ptr, "location", loc);
}
}
- else
+ else {
collection = BLI_findlink(&CTX_data_main(C)->collections, RNA_enum_get(op->ptr, "collection"));
+ }
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
@@ -1392,8 +1409,9 @@ static int object_delete_exec(bContext *C, wmOperator *op)
const bool use_global = RNA_boolean_get(op->ptr, "use_global");
uint changed_count = 0;
- if (CTX_data_edit_object(C))
+ if (CTX_data_edit_object(C)) {
return OPERATOR_CANCELLED;
+ }
CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
const bool is_indirectly_used = BKE_library_ID_is_indirectly_used(bmain, ob);
@@ -1421,8 +1439,9 @@ static int object_delete_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
}
- /* This is sort of a quick hack to address T51243 - Proper thing to do here would be to nuke most of all this
- * custom scene/object/base handling, and use generic lib remap/query for that.
+ /* This is sort of a quick hack to address T51243 -
+ * Proper thing to do here would be to nuke most of all this custom scene/object/base handling,
+ * and use generic lib remap/query for that.
* But this is for later (aka 2.8, once layers & co are settled and working).
*/
if (use_global && ob->id.lib == NULL) {
@@ -1433,7 +1452,8 @@ static int object_delete_exec(bContext *C, wmOperator *op)
}
/* remove from Grease Pencil parent */
- /* XXX This is likely not correct? Will also remove parent from grease pencil from other scenes,
+ /* XXX This is likely not correct?
+ * Will also remove parent from grease pencil from other scenes,
* even when use_global is false... */
for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -1535,8 +1555,10 @@ static void copy_object_set_idnew(bContext *C)
/********************* Make Duplicates Real ************************/
/**
- * \note regarding hashing dupli-objects when using OB_DUPLICOLLECTION, skip the first member of #DupliObject.persistent_id
- * since its a unique index and we only want to know if the group objects are from the same dupli-group instance.
+ * \note regarding hashing dupli-objects when using OB_DUPLICOLLECTION,
+ * skip the first member of #DupliObject.persistent_id
+ * since its a unique index and we only want to know if the group objects are from the same
+ * dupli-group instance.
*/
static unsigned int dupliobject_group_hash(const void *ptr)
{
@@ -1550,8 +1572,10 @@ static unsigned int dupliobject_group_hash(const void *ptr)
}
/**
- * \note regarding hashing dupli-objects when NOT using OB_DUPLICOLLECTION, include the first member of #DupliObject.persistent_id
- * since its the index of the vertex/face the object is instantiated on and we want to identify objects on the same vertex/face.
+ * \note regarding hashing dupli-objects when NOT using OB_DUPLICOLLECTION,
+ * include the first member of #DupliObject.persistent_id
+ * since its the index of the vertex/face the object is instantiated on and we want to identify
+ * objects on the same vertex/face.
*/
static unsigned int dupliobject_hash(const void *ptr)
{
@@ -1827,7 +1851,8 @@ static void convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *scene, Objec
if (ob->runtime.curve_cache == NULL) {
/* Force creation. This is normally not needed but on operator
* redo we might end up with an object which isn't evaluated yet.
- * Also happens in case we are working on a copy of the object (all its caches have been nuked then).
+ * Also happens in case we are working on a copy of the object
+ * (all its caches have been nuked then).
*/
if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
/* We need 'for render' ON here, to enable computing bevel dipslist if needed.
@@ -1932,8 +1957,9 @@ static int convert_exec(bContext *C, wmOperator *op)
Base *base = link->ptr.data;
Object *ob = base->object;
- /* The way object type conversion works currently (enforcing conversion of *all* objects using converted
- * object-data, even some un-selected/hidden/another scene ones, sounds totally bad to me.
+ /* The way object type conversion works currently (enforcing conversion of *all* objects
+ * using converted object-data, even some un-selected/hidden/another scene ones,
+ * sounds totally bad to me.
* However, changing this is more design than bug-fix, not to mention convoluted code below,
* so that will be for later.
* But at the very least, do not do that with linked IDs! */
@@ -2093,8 +2119,9 @@ static int convert_exec(bContext *C, wmOperator *op)
}
}
- for (nu = cu->nurb.first; nu; nu = nu->next)
+ for (nu = cu->nurb.first; nu; nu = nu->next) {
nu->charidx = 0;
+ }
cu->flag &= ~CU_3D;
BKE_curve_curve_dimension_update(cu);
@@ -2159,8 +2186,9 @@ static int convert_exec(bContext *C, wmOperator *op)
me->totcol = mb->totcol;
if (newob->totcol) {
me->mat = MEM_dupallocN(mb->mat);
- for (a = 0; a < newob->totcol; a++)
+ for (a = 0; a < newob->totcol; a++) {
id_us_plus((ID *)me->mat[a]);
+ }
}
convert_ensure_curve_cache(depsgraph, scene, baseob);
@@ -2269,9 +2297,10 @@ void OBJECT_OT_convert(wmOperatorType *ot)
/*
* dupflag: a flag made from constants declared in DNA_userdef_types.h
- * The flag tells adduplicate() whether to copy data linked to the object, or to reference the existing data.
+ * The flag tells adduplicate() whether to copy data linked to the object,
+ * or to reference the existing data.
* U.dupflag for default operations or you can construct a flag as python does
- * if the dupflag is 0 then no data will be copied (linked duplicate) */
+ * if the dupflag is 0 then no data will be copied (linked duplicate). */
/* used below, assumes id.new is correct */
/* leaves selection of base/object unaltered */
@@ -2310,8 +2339,9 @@ static Base *object_add_duplicate_internal(
if (ob->rigidbody_object || ob->rigidbody_constraint) {
Collection *collection;
for (collection = bmain->collections.first; collection; collection = collection->id.next) {
- if (BKE_collection_has_object(collection, ob))
+ if (BKE_collection_has_object(collection, ob)) {
BKE_collection_object_add(bmain, collection, obn);
+ }
}
}
}
@@ -2372,8 +2402,9 @@ static int duplicate_exec(bContext *C, wmOperator *op)
}
/* new object becomes active */
- if (BASACT(view_layer) == base)
+ if (BASACT(view_layer) == base) {
ED_object_base_activate(C, basen);
+ }
if (basen->object->data) {
DEG_id_tag_update(basen->object->data, 0);
@@ -2450,7 +2481,6 @@ static int add_named_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BKE_scene_object_base_flag_sync_from_object(basen);
basen->object->restrictflag &= ~OB_RESTRICT_VIEW;
if (event) {
@@ -2503,13 +2533,16 @@ static bool join_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
+ }
- if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE, OB_GPENCIL))
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE, OB_GPENCIL)) {
return ED_operator_screenactive(C);
- else
+ }
+ else {
return 0;
+ }
}
static int join_exec(bContext *C, wmOperator *op)
@@ -2532,14 +2565,18 @@ static int join_exec(bContext *C, wmOperator *op)
}
}
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return join_mesh_exec(C, op);
- else if (ELEM(ob->type, OB_CURVE, OB_SURF))
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
return join_curve_exec(C, op);
- else if (ob->type == OB_ARMATURE)
+ }
+ else if (ob->type == OB_ARMATURE) {
return join_armature_exec(C, op);
- else if (ob->type == OB_GPENCIL)
+ }
+ else if (ob->type == OB_GPENCIL) {
return ED_gpencil_join_objects_exec(C, op);
+ }
return OPERATOR_CANCELLED;
}
@@ -2565,14 +2602,17 @@ static bool join_shapes_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
+ }
/* only meshes supported at the moment */
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return ED_operator_screenactive(C);
- else
+ }
+ else {
return 0;
+ }
}
static int join_shapes_exec(bContext *C, wmOperator *op)
@@ -2588,8 +2628,9 @@ static int join_shapes_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return join_mesh_shapes_exec(C, op);
+ }
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index f3138c5afec..70a9870e6ae 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -196,14 +196,17 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
ok = false;
}
else {
- if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
ok = false;
+ }
- if (ibuf->rect_float && !(ibuf->channels == 0 || ibuf->channels == 4))
+ if (ibuf->rect_float && !(ibuf->channels == 0 || ibuf->channels == 4)) {
ok = false;
+ }
- if (!ok)
+ if (!ok) {
BKE_report(op->reports, RPT_ERROR, "Baking to unsupported image type");
+ }
}
BKE_image_release_ibuf(ima, ibuf, NULL);
@@ -211,8 +214,9 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
}
}
- if (!ok)
+ if (!ok) {
break;
+ }
}
CTX_DATA_END;
@@ -289,12 +293,15 @@ static void clear_single_image(Image *image, ClearFlag flag)
if ((image->id.tag & LIB_TAG_DOIT) == 0) {
ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
- if (flag == CLEAR_TANGENT_NORMAL)
+ if (flag == CLEAR_TANGENT_NORMAL) {
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
- else if (flag == CLEAR_DISPLACEMENT)
+ }
+ else if (flag == CLEAR_DISPLACEMENT) {
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? disp_alpha : disp_solid);
- else
+ }
+ else {
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
+ }
image->id.tag |= LIB_TAG_DOIT;
@@ -332,8 +339,9 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
int objects_baked = 0;
- if (!multiresbake_check(C, op))
+ if (!multiresbake_check(C, op)) {
return OPERATOR_CANCELLED;
+ }
if (scene->r.bake_flag & R_BAKE_CLEAR) { /* clear images */
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
@@ -374,7 +382,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
bkr.number_of_rays = scene->r.bake_samples;
bkr.threads = BKE_scene_num_threads(scene);
bkr.user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f;
- //bkr.reports= op->reports;
+ // bkr.reports= op->reports;
/* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */
bkr.ob_image.array = bake_object_image_get_array(ob);
@@ -396,8 +404,9 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- if (!objects_baked)
+ if (!objects_baked) {
BKE_report(op->reports, RPT_ERROR, "No objects found to bake from");
+ }
return OPERATOR_FINISHED;
}
@@ -418,7 +427,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
bkj->number_of_rays = scene->r.bake_samples;
bkj->threads = BKE_scene_num_threads(scene);
bkj->user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f;
- //bkj->reports = op->reports;
+ // bkj->reports = op->reports;
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
MultiresBakerJobData *data;
@@ -475,7 +484,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa
bkr.mode = bkj->mode;
bkr.use_lores_mesh = bkj->use_lores_mesh;
bkr.user_scale = bkj->user_scale;
- //bkr.reports = bkj->reports;
+ // bkr.reports = bkj->reports;
bkr.ob_image.array = data->ob_image.array;
bkr.ob_image.len = data->ob_image.len;
@@ -541,8 +550,9 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op)
MultiresBakeJob *bkr;
wmJob *wm_job;
- if (!multiresbake_check(C, op))
+ if (!multiresbake_check(C, op)) {
return OPERATOR_CANCELLED;
+ }
bkr = MEM_callocN(sizeof(MultiresBakeJob), "MultiresBakeJob data");
init_multiresbake_job(C, bkr);
@@ -580,8 +590,9 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op)
static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
/* no running blender, remove handler and pass through */
- if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE_TEXTURE))
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
/* running render */
switch (event->type) {
@@ -593,8 +604,9 @@ static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const
static bool is_multires_bake(Scene *scene)
{
- if (ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_AO))
+ if (ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_AO)) {
return scene->r.bake_flag & R_BAKE_MULTIRES;
+ }
return 0;
}
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index fba5a4e281e..5ae757cac56 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -137,8 +137,9 @@ static void bake_progress_update(void *bjv, float progress)
static int bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
/* no running blender, remove handler and pass through */
- if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE))
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
/* running render */
switch (event->type) {
@@ -154,8 +155,9 @@ static int bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
* note: this wont check for the escape key being pressed, but doing so isnt threadsafe */
static int bake_break(void *UNUSED(rjv))
{
- if (G.is_break)
+ if (G.is_break) {
return 1;
+ }
return 0;
}
@@ -163,8 +165,9 @@ static void bake_update_image(ScrArea *sa, Image *image)
{
if (sa && sa->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */
SpaceImage *sima = sa->spacedata.first;
- if (sima)
+ if (sima) {
sima->image = image;
+ }
}
}
@@ -185,8 +188,9 @@ static bool write_internal_bake_pixels(Image *image,
ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
- if (!ibuf)
+ if (!ibuf) {
return false;
+ }
if (margin > 0 || !is_clear) {
mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask");
@@ -202,14 +206,17 @@ static bool write_internal_bake_pixels(Image *image,
from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
- if (is_float)
+ if (is_float) {
to_colorspace = IMB_colormanagement_get_float_colorspace(ibuf);
- else
+ }
+ else {
to_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);
+ }
- if (from_colorspace != to_colorspace)
+ if (from_colorspace != to_colorspace) {
IMB_colormanagement_transform(
buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, false);
+ }
}
/* populates the ImBuf */
@@ -266,13 +273,15 @@ static bool write_internal_bake_pixels(Image *image,
}
/* margins */
- if (margin > 0)
+ if (margin > 0) {
RE_bake_margin(ibuf, mask_buffer, margin);
+ }
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID | IB_BITMAPDIRTY;
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
ibuf->userflags |= IB_RECT_INVALID;
+ }
/* force mipmap recalc */
if (ibuf->mipmap[0]) {
@@ -282,8 +291,9 @@ static bool write_internal_bake_pixels(Image *image,
BKE_image_release_ibuf(image, ibuf, NULL);
- if (mask_buffer)
+ if (mask_buffer) {
MEM_freeN(mask_buffer);
+ }
return true;
}
@@ -319,8 +329,9 @@ static bool write_external_bake_pixels(const char *filepath,
/* create a new ImBuf */
ibuf = IMB_allocImBuf(width, height, im_format->planes, (is_float ? IB_rectfloat : IB_rect));
- if (!ibuf)
+ if (!ibuf) {
return false;
+ }
/* populates the ImBuf */
if (is_float) {
@@ -366,15 +377,16 @@ static bool write_external_bake_pixels(const char *filepath,
RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);
RE_bake_margin(ibuf, mask_buffer, margin);
- if (mask_buffer)
+ if (mask_buffer) {
MEM_freeN(mask_buffer);
+ }
}
if ((ok = BKE_imbuf_write(ibuf, filepath, im_format))) {
#ifndef WIN32
chmod(filepath, S_IRUSR | S_IWUSR);
#endif
- //printf("%s saving bake map: '%s'\n", __func__, filepath);
+ // printf("%s saving bake map: '%s'\n", __func__, filepath);
}
/* garbage collection */
@@ -570,14 +582,16 @@ static bool bake_objects_check(Main *bmain,
if (is_selected_to_active) {
int tot_objects = 0;
- if (!bake_object_check(view_layer, ob, reports))
+ if (!bake_object_check(view_layer, ob, reports)) {
return false;
+ }
for (link = selected_objects->first; link; link = link->next) {
Object *ob_iter = (Object *)link->ptr.data;
- if (ob_iter == ob)
+ if (ob_iter == ob) {
continue;
+ }
if (ELEM(ob_iter->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL) == false) {
BKE_reportf(reports,
@@ -602,8 +616,9 @@ static bool bake_objects_check(Main *bmain,
}
for (link = selected_objects->first; link; link = link->next) {
- if (!bake_object_check(view_layer, link->ptr.data, reports))
+ if (!bake_object_check(view_layer, link->ptr.data, reports)) {
return false;
+ }
}
}
return true;
@@ -847,8 +862,9 @@ static int bake(Render *re,
for (link = selected_objects->first; link; link = link->next) {
Object *ob_iter = link->ptr.data;
- if (ob_iter == ob_low)
+ if (ob_iter == ob_low) {
continue;
+ }
tot_highpoly++;
}
@@ -890,8 +906,9 @@ static int bake(Render *re,
me_low = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low_eval);
/* populate the pixel array with the face data */
- if ((is_selected_to_active && (ob_cage == NULL) && is_cage) == false)
+ if ((is_selected_to_active && (ob_cage == NULL) && is_cage) == false) {
RE_bake_pixels_populate(me_low, pixel_array_low, num_pixels, &bake_images, uv_layer);
+ }
/* else populate the pixel array with the 'cage' mesh (the smooth version of the mesh) */
if (is_selected_to_active) {
@@ -939,8 +956,9 @@ static int bake(Render *re,
for (link = selected_objects->first; link; link = link->next) {
Object *ob_iter = link->ptr.data;
- if (ob_iter == ob_low)
+ if (ob_iter == ob_low) {
continue;
+ }
/* initialize highpoly_data */
highpoly[i].ob = ob_iter;
@@ -1082,8 +1100,9 @@ static int bake(Render *re,
ob_low_eval->obmat);
BKE_id_free(bmain, me_nores);
- if (md)
+ if (md) {
md->mode = mode;
+ }
}
break;
}
@@ -1193,43 +1212,53 @@ static int bake(Render *re,
}
}
- if (is_save_internal)
+ if (is_save_internal) {
refresh_images(&bake_images);
+ }
cleanup:
if (highpoly) {
int i;
for (i = 0; i < tot_highpoly; i++) {
- if (highpoly[i].me)
+ if (highpoly[i].me) {
BKE_id_free(bmain, highpoly[i].me);
+ }
}
MEM_freeN(highpoly);
}
- if (mmd_low)
+ if (mmd_low) {
mmd_low->flags = mmd_flags_low;
+ }
- if (pixel_array_low)
+ if (pixel_array_low) {
MEM_freeN(pixel_array_low);
+ }
- if (pixel_array_high)
+ if (pixel_array_high) {
MEM_freeN(pixel_array_high);
+ }
- if (bake_images.data)
+ if (bake_images.data) {
MEM_freeN(bake_images.data);
+ }
- if (bake_images.lookup)
+ if (bake_images.lookup) {
MEM_freeN(bake_images.lookup);
+ }
- if (result)
+ if (result) {
MEM_freeN(result);
+ }
- if (me_low)
+ if (me_low) {
BKE_id_free(bmain, me_low);
+ }
- if (me_cage)
+ if (me_cage) {
BKE_id_free(bmain, me_cage);
+ }
DEG_graph_free(depsgraph);
@@ -1492,8 +1521,9 @@ static void bake_startjob(void *bkv, short *UNUSED(stop), short *do_update, floa
bkr->sa,
bkr->uv_layer);
- if (bkr->result == OPERATOR_CANCELLED)
+ if (bkr->result == OPERATOR_CANCELLED) {
return;
+ }
}
}
@@ -1613,8 +1643,9 @@ static int bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
bake_set_props(op, scene);
/* only one render job at a time */
- if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_OBJECT_BAKE))
+ if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_OBJECT_BAKE)) {
return OPERATOR_CANCELLED;
+ }
bkr = MEM_mallocN(sizeof(BakeAPIRender), "render bake");
diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c
index 0b22dec99c7..fcaefaf220d 100644
--- a/source/blender/editors/object/object_collection.c
+++ b/source/blender/editors/object/object_collection.c
@@ -79,8 +79,9 @@ static const EnumPropertyItem *collection_object_active_itemf(bContext *C,
/* if 2 or more collections, add option to add to all collections */
collection = NULL;
- while ((collection = BKE_collection_object_find(bmain, scene, collection, ob)))
+ while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) {
count++;
+ }
if (count >= 2) {
item_tmp.identifier = item_tmp.name = "All Collections";
@@ -135,20 +136,23 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
bool is_cycle = false;
bool updated = false;
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
/* now add all selected objects to the collection(s) */
- FOREACH_COLLECTION_BEGIN(bmain, scene, Collection *, collection)
- {
- if (single_collection && collection != single_collection)
+ FOREACH_COLLECTION_BEGIN (bmain, scene, Collection *, collection) {
+ if (single_collection && collection != single_collection) {
continue;
- if (!BKE_collection_has_object(collection, ob))
+ }
+ if (!BKE_collection_has_object(collection, ob)) {
continue;
+ }
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
- if (BKE_collection_has_object(collection, base->object))
+ if (BKE_collection_has_object(collection, base->object)) {
continue;
+ }
if (!BKE_collection_object_cyclic_check(bmain, base->object, collection)) {
BKE_collection_object_add(bmain, collection, base->object);
@@ -163,11 +167,13 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
}
FOREACH_COLLECTION_END;
- if (is_cycle)
+ if (is_cycle) {
BKE_report(op->reports, RPT_WARNING, "Skipped some collections because of cycle detected");
+ }
- if (!updated)
+ if (!updated) {
return OPERATOR_CANCELLED;
+ }
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
@@ -215,15 +221,16 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
bmain, scene, ob, single_collection_index);
bool ok = false;
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Linking to same collection requires its own loop so we can avoid
* looking up the active objects collections each time. */
- FOREACH_COLLECTION_BEGIN(bmain, scene, Collection *, collection)
- {
- if (single_collection && collection != single_collection)
+ FOREACH_COLLECTION_BEGIN (bmain, scene, Collection *, collection) {
+ if (single_collection && collection != single_collection) {
continue;
+ }
if (BKE_collection_has_object(collection, ob)) {
/* Remove collections from selected objects */
@@ -237,8 +244,9 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
}
FOREACH_COLLECTION_END;
- if (!ok)
+ if (!ok) {
BKE_report(op->reports, RPT_ERROR, "Active object contains no collections");
+ }
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
@@ -316,15 +324,17 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op)
bmain, scene, ob, single_collection_index);
bool updated = false;
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
- FOREACH_COLLECTION_BEGIN(bmain, scene, Collection *, collection)
- {
- if (single_collection && collection != single_collection)
+ FOREACH_COLLECTION_BEGIN (bmain, scene, Collection *, collection) {
+ if (single_collection && collection != single_collection) {
continue;
- if (!BKE_collection_has_object(collection, ob))
+ }
+ if (!BKE_collection_has_object(collection, ob)) {
continue;
+ }
/* now remove all selected objects from the collection */
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
@@ -336,8 +346,9 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op)
}
FOREACH_COLLECTION_END;
- if (!updated)
+ if (!updated) {
return OPERATOR_CANCELLED;
+ }
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
@@ -421,8 +432,9 @@ static int collection_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Main *bmain = CTX_data_main(C);
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
Collection *collection = BKE_collection_add(bmain, NULL, "Collection");
id_fake_user_set(&collection->id);
@@ -457,8 +469,9 @@ static int collection_link_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_context(C);
Collection *collection = BLI_findlink(&bmain->collections, RNA_enum_get(op->ptr, "collection"));
- if (ELEM(NULL, ob, collection))
+ if (ELEM(NULL, ob, collection)) {
return OPERATOR_CANCELLED;
+ }
/* Early return check, if the object is already in collection
* we could skip all the dependency check and just consider
@@ -468,7 +481,7 @@ static int collection_link_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- /* Adding object to collection which is used as duplicollection for self is bad idea.
+ /* Adding object to collection which is used as dupli-collection for self is bad idea.
*
* It is also bad idea to add object to collection which is in collection which
* contains our current object.
@@ -520,8 +533,9 @@ static int collection_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data;
- if (!ob || !collection)
+ if (!ob || !collection) {
return OPERATOR_CANCELLED;
+ }
BKE_collection_object_remove(bmain, collection, ob, false);
@@ -553,8 +567,9 @@ static int collection_unlink_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data;
- if (!collection)
+ if (!collection) {
return OPERATOR_CANCELLED;
+ }
BKE_id_delete(bmain, collection);
@@ -586,8 +601,9 @@ static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data;
- if (!collection)
+ if (!collection) {
return OPERATOR_CANCELLED;
+ }
CTX_DATA_BEGIN (C, Base *, base, visible_bases) {
if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) {
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index c571fc6821e..6a587bd6e2a 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -79,18 +79,21 @@
/* if object in posemode, active bone constraints, else object constraints */
ListBase *get_active_constraints(Object *ob)
{
- if (ob == NULL)
+ if (ob == NULL) {
return NULL;
+ }
if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan;
pchan = BKE_pose_channel_active(ob);
- if (pchan)
+ if (pchan) {
return &pchan->constraints;
+ }
}
- else
+ else {
return &ob->constraints;
+ }
return NULL;
}
@@ -99,11 +102,13 @@ ListBase *get_active_constraints(Object *ob)
* and/or also get the posechannel this is from (if applicable) */
ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan)
{
- if (r_pchan)
+ if (r_pchan) {
*r_pchan = NULL;
+ }
- if (ELEM(NULL, ob, con))
+ if (ELEM(NULL, ob, con)) {
return NULL;
+ }
/* try object constraints first */
if ((BLI_findindex(&ob->constraints, con) != -1)) {
@@ -120,8 +125,9 @@ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if ((BLI_findindex(&pchan->constraints, con) != -1)) {
- if (r_pchan)
+ if (r_pchan) {
*r_pchan = pchan;
+ }
return &pchan->constraints;
}
@@ -153,8 +159,9 @@ static void validate_pyconstraint_cb(Main *bmain, void *arg1, void *arg2)
/* exception for no script */
if (index) {
/* innovative use of a for...loop to search */
- for (text = bmain->texts.first, i = 1; text && index != i; i++, text = text->id.next)
+ for (text = bmain->texts.first, i = 1; text && index != i; i++, text = text->id.next) {
;
+ }
}
data->text = text;
}
@@ -173,14 +180,16 @@ static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconinde
BLI_dynstr_append(pupds, buf);
/* init active-index first */
- if (con_text == NULL)
+ if (con_text == NULL) {
*pyconindex = 0;
+ }
/* loop through markers, adding them */
for (text = bmain->texts.first, i = 1; text; i++, text = text->id.next) {
/* this is important to ensure that right script is shown as active */
- if (text == con_text)
+ if (text == con_text) {
*pyconindex = i;
+ }
/* only include valid pyconstraint scripts */
if (BPY_is_pyconstraint(text)) {
@@ -189,8 +198,9 @@ static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconinde
sprintf(buf, "%%x%d", i);
BLI_dynstr_append(pupds, buf);
- if (text->id.next)
+ if (text->id.next) {
BLI_dynstr_append(pupds, "|");
+ }
}
}
@@ -234,10 +244,12 @@ static void set_constraint_nth_target(bConstraint *con,
num_targets = BLI_listbase_count(&targets);
if (index < 0) {
- if (abs(index) < num_targets)
+ if (abs(index) < num_targets) {
index = num_targets - abs(index);
- else
+ }
+ else {
index = num_targets - 1;
+ }
}
else if (index >= num_targets) {
index = num_targets - 1;
@@ -251,8 +263,9 @@ static void set_constraint_nth_target(bConstraint *con,
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
}
@@ -338,27 +351,33 @@ static void test_constraint(
bFollowPathConstraint *data = con->data;
/* don't allow track/up axes to be the same */
- if (data->upflag == data->trackflag)
+ if (data->upflag == data->trackflag) {
con->flag |= CONSTRAINT_DISABLE;
- if (data->upflag + 3 == data->trackflag)
+ }
+ if (data->upflag + 3 == data->trackflag) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_TRACKTO) {
bTrackToConstraint *data = con->data;
/* don't allow track/up axes to be the same */
- if (data->reserved2 == data->reserved1)
+ if (data->reserved2 == data->reserved1) {
con->flag |= CONSTRAINT_DISABLE;
- if (data->reserved2 + 3 == data->reserved1)
+ }
+ if (data->reserved2 + 3 == data->reserved1) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_LOCKTRACK) {
bLockTrackConstraint *data = con->data;
- if (data->lockflag == data->trackflag)
+ if (data->lockflag == data->trackflag) {
con->flag |= CONSTRAINT_DISABLE;
- if (data->lockflag + 3 == data->trackflag)
+ }
+ if (data->lockflag + 3 == data->trackflag) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
bSplineIKConstraint *data = con->data;
@@ -385,17 +404,20 @@ static void test_constraint(
MovieTracking *tracking = &data->clip->tracking;
MovieTrackingObject *tracking_object;
- if (data->object[0])
+ if (data->object[0]) {
tracking_object = BKE_tracking_object_get_named(tracking, data->object);
- else
+ }
+ else {
tracking_object = BKE_tracking_object_get_camera(tracking);
+ }
if (!tracking_object) {
con->flag |= CONSTRAINT_DISABLE;
}
else {
- if (!BKE_tracking_track_get_named(tracking, tracking_object, data->track))
+ if (!BKE_tracking_track_get_named(tracking, tracking_object, data->track)) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
}
else {
@@ -406,14 +428,16 @@ static void test_constraint(
else if (con->type == CONSTRAINT_TYPE_CAMERASOLVER) {
bCameraSolverConstraint *data = con->data;
- if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL))
+ if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL)) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
bObjectSolverConstraint *data = con->data;
- if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL))
+ if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL)) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_TRANSFORM_CACHE) {
bTransformCacheConstraint *data = con->data;
@@ -494,8 +518,9 @@ static void test_constraint(
}
/* free any temporary targets */
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
}
@@ -513,8 +538,9 @@ static int constraint_type_get(Object *owner, bPoseChannel *pchan)
break;
}
}
- else
+ else {
type = CONSTRAINT_OBTYPE_OBJECT;
+ }
return type;
}
@@ -527,8 +553,9 @@ static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan)
ListBase *conlist = NULL;
int type;
- if (owner == NULL)
+ if (owner == NULL) {
return;
+ }
type = constraint_type_get(owner, pchan);
@@ -552,15 +579,17 @@ static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan)
void object_test_constraints(Main *bmain, Object *owner)
{
- if (owner->constraints.first)
+ if (owner->constraints.first) {
test_constraints(bmain, owner, NULL);
+ }
if (owner->type == OB_ARMATURE && owner->pose) {
bPoseChannel *pchan;
for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->constraints.first)
+ if (pchan->constraints.first) {
test_constraints(bmain, owner, pchan);
+ }
}
}
}
@@ -586,7 +615,7 @@ static void object_test_constraint(Main *bmain, Object *owner, bConstraint *con)
}
}
-/************************ generic functions for operators using constraint names and data context *********************/
+/*** generic functions for operators using constraint names and data context *********************/
#define EDIT_CONSTRAINT_OWNER_OBJECT 0
#define EDIT_CONSTRAINT_OWNER_BONE 1
@@ -653,8 +682,9 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op)
ListBase *list;
if (RNA_struct_property_is_set(op->ptr, "constraint") &&
- RNA_struct_property_is_set(op->ptr, "owner"))
+ RNA_struct_property_is_set(op->ptr, "owner")) {
return 1;
+ }
if (ptr.data) {
con = ptr.data;
@@ -662,10 +692,12 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op)
list = get_constraint_lb(ob, con, NULL);
- if (&ob->constraints == list)
+ if (&ob->constraints == list) {
RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_OBJECT);
- else
+ }
+ else {
RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_BONE);
+ }
return 1;
}
@@ -687,26 +719,38 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
}
else if (owner == EDIT_CONSTRAINT_OWNER_BONE) {
bPoseChannel *pchan = BKE_pose_channel_active(ob);
- if (pchan)
+ if (pchan) {
list = &pchan->constraints;
+ }
else {
- //if (G.debug & G_DEBUG)
- //printf("edit_constraint_property_get: No active bone for object '%s'\n", (ob) ? ob->id.name + 2 : "<None>");
+#if 0
+ if (G.debug & G_DEBUG) {
+ printf("edit_constraint_property_get: No active bone for object '%s'\n",
+ (ob) ? ob->id.name + 2 : "<None>");
+ }
+#endif
return NULL;
}
}
else {
- //if (G.debug & G_DEBUG)
- //printf("edit_constraint_property_get: defaulting to getting list in the standard way\n");
+#if 0
+ if (G.debug & G_DEBUG) {
+ printf("edit_constraint_property_get: defaulting to getting list in the standard way\n");
+ }
+#endif
list = get_active_constraints(ob);
}
con = BKE_constraints_find_name(list, constraint_name);
- //if (G.debug & G_DEBUG)
- //printf("constraint found = %p, %s\n", (void *)con, (con) ? con->name : "<Not found>");
+#if 0
+ if (G.debug & G_DEBUG) {
+ printf("constraint found = %p, %s\n", (void *)con, (con) ? con->name : "<Not found>");
+ }
+#endif
- if (con && (type != 0) && (con->type != type))
+ if (con && (type != 0) && (con->type != type)) {
con = NULL;
+ }
return con;
}
@@ -724,8 +768,9 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op)
bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL;
/* despite 3 layers of checks, we may still not be able to find a constraint */
- if (data == NULL)
+ if (data == NULL) {
return OPERATOR_CANCELLED;
+ }
/* just set original length to 0.0, which will cause a reset on next recalc */
data->orglength = 0.0f;
@@ -737,10 +782,12 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op)
static int stretchto_reset_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return stretchto_reset_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot)
@@ -770,8 +817,9 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op)
bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL;
/* despite 3 layers of checks, we may still not be able to find a constraint */
- if (data == NULL)
+ if (data == NULL) {
return OPERATOR_CANCELLED;
+ }
/* just set original length to 0.0, which will cause a reset on next recalc */
data->dist = 0.0f;
@@ -783,10 +831,12 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op)
static int limitdistance_reset_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return limitdistance_reset_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot)
@@ -928,10 +978,12 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op)
static int childof_set_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return childof_set_inverse_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot)
@@ -977,10 +1029,12 @@ static int childof_clear_inverse_exec(bContext *C, wmOperator *op)
static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return childof_clear_inverse_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot)
@@ -1065,8 +1119,9 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op)
data->followflag |= FOLLOWPATH_STATIC;
/* path needs to be freed */
- if (path)
+ if (path) {
MEM_freeN(path);
+ }
}
/* setup dummy 'generator' modifier here to get 1-1 correspondence still working
@@ -1171,10 +1226,12 @@ static int objectsolver_set_inverse_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return objectsolver_set_inverse_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot)
@@ -1219,10 +1276,12 @@ static int objectsolver_clear_inverse_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return objectsolver_clear_inverse_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot)
@@ -1252,33 +1311,38 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con)
/* lets be nice and escape if its active already */
/* NOTE: this assumes that the stack doesn't have other active ones set... */
- if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE))
+ if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE)) {
return;
+ }
BKE_constraints_active_set(lb, con);
}
void ED_object_constraint_update(Main *bmain, Object *ob)
{
- if (ob->pose)
+ if (ob->pose) {
BKE_pose_update_constraint_flags(ob->pose);
+ }
object_test_constraints(bmain, ob);
- if (ob->type == OB_ARMATURE)
+ if (ob->type == OB_ARMATURE) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
- else
+ }
+ else {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ }
}
static void object_pose_tag_update(Main *bmain, Object *ob)
{
BKE_pose_tag_recalc(bmain, ob->pose); /* Checks & sort pose channels. */
if (ob->proxy && ob->adt) {
- /* We need to make use of ugly POSE_ANIMATION_WORKAROUND here too, else anim data are not reloaded
- * after calling `BKE_pose_rebuild()`, which causes T43872.
- * Note that this is a bit wide here, since we cannot be sure whether there are some locked proxy bones
- * or not...
+ /* We need to make use of ugly #POSE_ANIMATION_WORKAROUND here too,
+ * else anim data are not reloaded after calling `BKE_pose_rebuild()`,
+ * which causes T43872.
+ * Note that this is a bit wide here, since we cannot be sure whether there are some locked
+ * proxy bones or not.
* XXX Temp hack until new depsgraph hopefully solves this. */
DEG_id_tag_update(&ob->id, ID_RECALC_ANIMATION);
}
@@ -1304,10 +1368,12 @@ void ED_object_constraint_tag_update(Main *bmain, Object *ob, bConstraint *con)
object_test_constraint(bmain, ob, con);
}
- if (ob->type == OB_ARMATURE)
+ if (ob->type == OB_ARMATURE) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
- else
+ }
+ else {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ }
/* Do Copy-on-Write tag here too, otherwise constraint
* influence/mute buttons in UI have no effect
@@ -1398,10 +1464,12 @@ static int constraint_move_down_exec(bContext *C, wmOperator *op)
static int constraint_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return constraint_move_down_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_move_down(wmOperatorType *ot)
@@ -1446,10 +1514,12 @@ static int constraint_move_up_exec(bContext *C, wmOperator *op)
static int constraint_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return constraint_move_up_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_move_up(wmOperatorType *ot)
@@ -1479,8 +1549,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
Object *prev_ob = NULL;
/* free constraints for all selected bones */
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
BKE_constraints_free(&pchan->constraints);
pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_SPLINEIK | PCHAN_HAS_CONST);
@@ -1561,8 +1630,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
Object *prev_ob = NULL;
/* copy all constraints from active posebone to all selected posebones */
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, chan, selected_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, chan, selected_pose_bones, Object *, ob) {
/* if we're not handling the object we're copying from, copy all constraints over */
if (pchan != chan) {
BKE_constraints_copy(&chan->constraints, &pchan->constraints, true);
@@ -1760,13 +1828,14 @@ static bool get_new_constraint_target(
/* transform cent to global coords for loc */
if (pchanact) {
- /* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel
- * if adding a target for an IK Constraint
- */
- if (con_type == CONSTRAINT_TYPE_KINEMATIC)
+ /* Since by default, IK targets the tip of the last bone,
+ * use the tip of the active PoseChannel if adding a target for an IK Constraint. */
+ if (con_type == CONSTRAINT_TYPE_KINEMATIC) {
mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_tail);
- else
+ }
+ else {
mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_head);
+ }
}
else {
copy_v3_v3(obt->loc, obact->obmat[3]);
@@ -1774,7 +1843,7 @@ static bool get_new_constraint_target(
/* restore, BKE_object_add sets active */
BASACT(view_layer) = base;
- base->flag |= BASE_SELECTED;
+ ED_object_base_select(base, BA_SELECT);
/* make our new target the new object */
*tar_ob = obt;
@@ -1818,11 +1887,14 @@ static int constraint_add_exec(
return OPERATOR_CANCELLED;
}
- /* create a new constraint of the type required, and add it to the active/given constraints list */
- if (pchan)
+ /* Create a new constraint of the type required,
+ * and add it to the active/given constraints list. */
+ if (pchan) {
con = BKE_constraint_add_for_pose(ob, pchan, NULL, type);
- else
+ }
+ else {
con = BKE_constraint_add_for_object(ob, NULL, type);
+ }
/* get the first selected object/bone, and make that the target
* - apart from the buttons-window add buttons, we shouldn't add in this way
@@ -1833,13 +1905,15 @@ static int constraint_add_exec(
/* get the target objects, adding them as need be */
if (get_new_constraint_target(C, type, &tar_ob, &tar_pchan, 1)) {
- /* method of setting target depends on the type of target we've got
- * - by default, just set the first target (distinction here is only for multiple-targeted constraints)
+ /* Method of setting target depends on the type of target we've got - by default,
+ * just set the first target (distinction here is only for multiple-targeted constraints).
*/
- if (tar_pchan)
+ if (tar_pchan) {
set_constraint_nth_target(con, tar_ob, tar_pchan->name, 0);
- else
+ }
+ else {
set_constraint_nth_target(con, tar_ob, "", 0);
+ }
}
}
@@ -1874,8 +1948,9 @@ static int constraint_add_exec(
/* make sure all settings are valid - similar to above checks, but sometimes can be wrong */
object_test_constraints(bmain, ob);
- if (pchan)
+ if (pchan) {
BKE_pose_update_constraint_flags(ob->pose);
+ }
/* force depsgraph to get recalculated since new relationships added */
DEG_relations_tag_update(bmain);
@@ -1883,15 +1958,16 @@ static int constraint_add_exec(
if ((ob->type == OB_ARMATURE) && (pchan)) {
BKE_pose_tag_recalc(bmain, ob->pose); /* sort pose channels */
if (BKE_constraints_proxylocked_owner(ob, pchan) && ob->adt) {
- /* We need to make use of ugly POSE_ANIMATION_WORKAROUND here too, else anim data are not reloaded
- * after calling `BKE_pose_rebuild()`, which causes T43872.
+ /* We need to make use of ugly POSE_ANIMATION_WORKAROUND here too,
+ * else anim data are not reloaded after calling `BKE_pose_rebuild()`, which causes T43872.
* XXX Temp hack until new depsgraph hopefully solves this. */
DEG_id_tag_update(&ob->id, ID_RECALC_ANIMATION);
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
}
- else
+ else {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ }
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob);
@@ -1916,8 +1992,9 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op)
/* hack: set constraint targets from selected objects in context is allowed when
* operator name included 'with_targets', since the menu doesn't allow multiple properties
*/
- if (strstr(op->idname, "with_targets"))
+ if (strstr(op->idname, "with_targets")) {
with_targets = 1;
+ }
return constraint_add_exec(C, op, ob, &ob->constraints, type, with_targets);
}
@@ -1937,8 +2014,9 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op)
/* hack: set constraint targets from selected objects in context is allowed when
* operator name included 'with_targets', since the menu doesn't allow multiple properties
*/
- if (strstr(op->idname, "with_targets"))
+ if (strstr(op->idname, "with_targets")) {
with_targets = 1;
+ }
return constraint_add_exec(C, op, ob, get_active_constraints(ob), type, with_targets);
}
@@ -2049,8 +2127,9 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
/* bone must not have any constraints already */
for (con = pchan->constraints.first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_KINEMATIC)
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
break;
+ }
}
if (con) {
BKE_report(op->reports, RPT_ERROR, "Bone already has an IK constraint");
@@ -2066,12 +2145,14 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
/* bone target, or object target?
* - the only thing that matters is that we want a target...
*/
- if (tar_pchan)
+ if (tar_pchan) {
uiItemBooleanO(
layout, IFACE_("To Active Bone"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1);
- else
+ }
+ else {
uiItemBooleanO(
layout, IFACE_("To Active Object"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1);
+ }
}
else {
/* we have a choice of adding to a new empty, or not setting any target (targetless IK) */
@@ -2093,7 +2174,8 @@ static int pose_ik_add_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
const bool with_targets = RNA_boolean_get(op->ptr, "with_targets");
- /* add the constraint - all necessary checks should have been done by the invoke() callback already... */
+ /* add the constraint - all necessary checks should have
+ * been done by the invoke() callback already... */
return constraint_add_exec(
C, op, ob, get_active_constraints(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets);
}
@@ -2129,11 +2211,11 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
Object *prev_ob = NULL;
/* only remove IK Constraints */
- CTX_DATA_BEGIN_WITH_ID(C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob)
- {
+ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
bConstraint *con, *next;
- /* TODO: should we be checking if these constraints were local before we try and remove them? */
+ /* TODO: should we be checking if these constraints were local
+ * before we try and remove them? */
for (con = pchan->constraints.first; con; con = next) {
next = con->next;
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 57c7ff1535d..690bc270605 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -65,11 +65,12 @@ static const EnumPropertyItem DT_layer_items[] = {
"Vertex Group(s)",
"Transfer active or all vertex groups"},
#if 0 /* XXX For now, would like to finish/merge work from 2014 gsoc first. */
- {DT_TYPE_SHAPEKEY, "SHAPEKEYS", 0, "Shapekey(s)", "Transfer active or all shape keys"},
+ {DT_TYPE_SHAPEKEY, "SHAPEKEYS", 0, "Shapekey(s)", "Transfer active or all shape keys"},
#endif
-#if 0 /* XXX When SkinModifier is enabled,
- * it seems to erase its own CD_MVERT_SKIN layer from final DM :( */
- {DT_TYPE_SKIN, "SKIN", 0, "Skin Weight", "Transfer skin weights"},
+/* XXX When SkinModifier is enabled,
+ * it seems to erase its own CD_MVERT_SKIN layer from final DM :( */
+#if 0
+ {DT_TYPE_SKIN, "SKIN", 0, "Skin Weight", "Transfer skin weights"},
#endif
{DT_TYPE_BWEIGHT_VERT, "BEVEL_WEIGHT_VERT", 0, "Bevel Weight", "Transfer bevel weights"},
{0, "", 0, "Edge Data", ""},
@@ -519,7 +520,8 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
}
/* Used by both OBJECT_OT_data_transfer and OBJECT_OT_datalayout_transfer */
-/* Note this context poll is only really partial, it cannot check for all possible invalid cases. */
+/* Note this context poll is only really partial,
+ * it cannot check for all possible invalid cases. */
static bool data_transfer_poll(bContext *C)
{
Object *ob = ED_object_active_context(C);
@@ -772,8 +774,8 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
dtmd = (DataTransferModifierData *)edit_modifier_property_get(
op, ob_act, eModifierType_DataTransfer);
- /* If we have a modifier, we transfer data layout from this modifier's source object to active one.
- * Else, we transfer data layout from active object to all selected ones. */
+ /* If we have a modifier, we transfer data layout from this modifier's source object to
+ * active one. Else, we transfer data layout from active object to all selected ones. */
if (dtmd) {
Object *ob_src = dtmd->ob_source;
Object *ob_dst = ob_act;
@@ -840,6 +842,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
BLI_freelistN(&ctx_objects);
}
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 4e532b0ab41..795e1dd66a5 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -139,8 +139,9 @@ Object *ED_object_active_context(bContext *C)
Object *ob = NULL;
if (C) {
ob = ED_object_context(C);
- if (!ob)
+ if (!ob) {
ob = CTX_data_active_object(C);
+ }
}
return ob;
}
@@ -702,8 +703,6 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
}
}
- ED_space_image_uv_sculpt_update(bmain, CTX_wm_manager(C), scene);
-
WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode);
if (G.background == false) {
@@ -718,8 +717,9 @@ static bool editmode_toggle_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
/* covers proxies too */
- if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob->data))
+ if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob->data)) {
return 0;
+ }
/* if hidden but in edit mode, we still display */
if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT)) {
@@ -857,12 +857,15 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
- if (ob->pd == NULL)
+ if (ob->pd == NULL) {
ob->pd = BKE_partdeflect_new(PFIELD_FORCE);
- else if (ob->pd->forcefield == 0)
+ }
+ else if (ob->pd->forcefield == 0) {
ob->pd->forcefield = PFIELD_FORCE;
- else
+ }
+ else {
ob->pd->forcefield = 0;
+ }
ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -935,8 +938,9 @@ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEv
{
Object *ob = CTX_data_active_object(C);
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
/* set default settings from existing/stored settings */
{
@@ -1032,8 +1036,9 @@ static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
ED_objects_recalculate_paths(C, scene, false);
@@ -1204,10 +1209,12 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
cu = ob->data;
for (nu = cu->nurb.first; nu; nu = nu->next) {
- if (!clear)
+ if (!clear) {
nu->flag |= ME_SMOOTH;
- else
+ }
+ else {
nu->flag &= ~ME_SMOOTH;
+ }
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -1218,8 +1225,9 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- if (linked_data)
+ if (linked_data) {
BKE_report(op->reports, RPT_WARNING, "Can't edit linked mesh or curve data");
+ }
return (done) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1271,8 +1279,9 @@ static const EnumPropertyItem *object_mode_set_itemsf(bContext *C,
Object *ob;
int totitem = 0;
- if (!C) /* needed for docs */
+ if (!C) { /* needed for docs */
return rna_enum_object_mode_items;
+ }
ob = CTX_data_active_object(C);
if (ob) {
@@ -1320,10 +1329,12 @@ static bool object_mode_set_poll(bContext *C)
* to still work in that case when there's no active object
* so that users can exit editmode this way as per normal.
*/
- if (ED_operator_object_active_editable(C))
+ if (ED_operator_object_active_editable(C)) {
return true;
- else
+ }
+ else {
return (CTX_data_gpencil_data(C) != NULL);
+ }
}
static int object_mode_set_exec(bContext *C, wmOperator *op)
@@ -1354,8 +1365,9 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
mode = OB_MODE_EDIT_GPENCIL;
}
- if (!ob || !ED_object_mode_compat_test(ob, mode))
+ if (!ob || !ED_object_mode_compat_test(ob, mode)) {
return OPERATOR_PASS_THROUGH;
+ }
if (ob->mode != mode) {
/* we should be able to remove this call, each operator calls */
@@ -1406,7 +1418,7 @@ void OBJECT_OT_mode_set(wmOperatorType *ot)
/* api callbacks */
ot->exec = object_mode_set_exec;
- ot->poll = object_mode_set_poll; //ED_operator_object_active_editable;
+ ot->poll = object_mode_set_poll; // ED_operator_object_active_editable;
/* flags */
ot->flag = 0; /* no register/undo here, leave it to operators being called */
@@ -1432,7 +1444,7 @@ void OBJECT_OT_mode_set_or_submode(wmOperatorType *ot)
/* api callbacks */
ot->exec = object_mode_set_exec;
- ot->poll = object_mode_set_poll; //ED_operator_object_active_editable;
+ ot->poll = object_mode_set_poll; // ED_operator_object_active_editable;
/* flags */
ot->flag = 0; /* no register/undo here, leave it to operators being called */
diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c
index a77cfab031d..0081e18f33c 100644
--- a/source/blender/editors/object/object_facemap_ops.c
+++ b/source/blender/editors/object/object_facemap_ops.c
@@ -56,8 +56,9 @@
void ED_object_facemap_face_add(Object *ob, bFaceMap *fmap, int facenum)
{
int fmap_nr;
- if (GS(((ID *)ob->data)->name) != ID_ME)
+ if (GS(((ID *)ob->data)->name) != ID_ME) {
return;
+ }
/* get the face map number, exit if it can't be found */
fmap_nr = BLI_findindex(&ob->fmaps, fmap);
@@ -67,8 +68,9 @@ void ED_object_facemap_face_add(Object *ob, bFaceMap *fmap, int facenum)
Mesh *me = ob->data;
/* if there's is no facemap layer then create one */
- if ((facemap = CustomData_get_layer(&me->pdata, CD_FACEMAP)) == NULL)
+ if ((facemap = CustomData_get_layer(&me->pdata, CD_FACEMAP)) == NULL) {
facemap = CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_DEFAULT, NULL, me->totpoly);
+ }
facemap[facenum] = fmap_nr;
}
@@ -78,8 +80,9 @@ void ED_object_facemap_face_add(Object *ob, bFaceMap *fmap, int facenum)
void ED_object_facemap_face_remove(Object *ob, bFaceMap *fmap, int facenum)
{
int fmap_nr;
- if (GS(((ID *)ob->data)->name) != ID_ME)
+ if (GS(((ID *)ob->data)->name) != ID_ME) {
return;
+ }
/* get the face map number, exit if it can't be found */
fmap_nr = BLI_findindex(&ob->fmaps, fmap);
@@ -88,8 +91,9 @@ void ED_object_facemap_face_remove(Object *ob, bFaceMap *fmap, int facenum)
int *facemap;
Mesh *me = ob->data;
- if ((facemap = CustomData_get_layer(&me->pdata, CD_FACEMAP)) == NULL)
+ if ((facemap = CustomData_get_layer(&me->pdata, CD_FACEMAP)) == NULL) {
return;
+ }
facemap[facenum] = -1;
}
@@ -114,10 +118,12 @@ static void object_fmap_swap_edit_mode(Object *ob, int num1, int num2)
if (map) {
if (num1 != -1) {
- if (*map == num1)
+ if (*map == num1) {
*map = num2;
- else if (*map == num2)
+ }
+ else if (*map == num2) {
*map = num1;
+ }
}
}
}
@@ -138,10 +144,12 @@ static void object_fmap_swap_object_mode(Object *ob, int num1, int num2)
if (map) {
for (i = 0; i < me->totpoly; i++) {
if (num1 != -1) {
- if (map[i] == num1)
+ if (map[i] == num1) {
map[i] = num2;
- else if (map[i] == num2)
+ }
+ else if (map[i] == num2) {
map[i] = num1;
+ }
}
}
}
@@ -151,10 +159,12 @@ static void object_fmap_swap_object_mode(Object *ob, int num1, int num2)
static void object_facemap_swap(Object *ob, int num1, int num2)
{
- if (BKE_object_is_in_editmode(ob))
+ if (BKE_object_is_in_editmode(ob)) {
object_fmap_swap_edit_mode(ob, num1, num2);
- else
+ }
+ else {
object_fmap_swap_object_mode(ob, num1, num2);
+ }
}
static bool face_map_supported_poll(bContext *C)
@@ -245,8 +255,9 @@ static int face_map_assign_exec(bContext *C, wmOperator *UNUSED(op))
int *map;
int cd_fmap_offset;
- if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP))
+ if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP)) {
BM_data_layer_add(em->bm, &em->bm->pdata, CD_FACEMAP);
+ }
cd_fmap_offset = CustomData_get_offset(&em->bm->pdata, CD_FACEMAP);
@@ -294,8 +305,9 @@ static int face_map_remove_from_exec(bContext *C, wmOperator *UNUSED(op))
int cd_fmap_offset;
int mapindex = ob->actfmap - 1;
- if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP))
+ if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP)) {
return OPERATOR_CANCELLED;
+ }
cd_fmap_offset = CustomData_get_offset(&em->bm->pdata, CD_FACEMAP);
@@ -339,8 +351,9 @@ static void fmap_select(Object *ob, bool select)
int cd_fmap_offset;
int mapindex = ob->actfmap - 1;
- if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP))
+ if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP)) {
BM_data_layer_add(em->bm, &em->bm->pdata, CD_FACEMAP);
+ }
cd_fmap_offset = CustomData_get_offset(&em->bm->pdata, CD_FACEMAP);
diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c
index a726e2c9f00..383974270f4 100644
--- a/source/blender/editors/object/object_gpencil_modifier.c
+++ b/source/blender/editors/object/object_gpencil_modifier.c
@@ -109,8 +109,9 @@ static bool UNUSED_FUNCTION(gpencil_object_has_modifier)(const Object *ob,
GpencilModifierData *md;
for (md = ob->greasepencil_modifiers.first; md; md = md->next) {
- if ((md != exclude) && (md->type == type))
+ if ((md != exclude) && (md->type == type)) {
return true;
+ }
}
return false;
@@ -163,8 +164,9 @@ void ED_object_gpencil_modifier_clear(Main *bmain, Object *ob)
GpencilModifierData *md = ob->greasepencil_modifiers.first;
bool sort_depsgraph = false;
- if (!md)
+ if (!md) {
return;
+ }
while (md) {
GpencilModifierData *next_md;
@@ -257,8 +259,9 @@ int ED_object_gpencil_modifier_apply(Main *bmain,
return 0;
}
- if (md != ob->greasepencil_modifiers.first)
+ if (md != ob->greasepencil_modifiers.first) {
BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected");
+ }
if (!gpencil_modifier_apply_obdata(reports, bmain, depsgraph, ob, md)) {
return 0;
@@ -300,8 +303,9 @@ static int gpencil_modifier_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
int type = RNA_enum_get(op->ptr, "type");
- if (!ED_object_gpencil_modifier_add(op->reports, bmain, scene, ob, NULL, type))
+ if (!ED_object_gpencil_modifier_add(op->reports, bmain, scene, ob, NULL, type)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -319,16 +323,18 @@ static const EnumPropertyItem *gpencil_modifier_add_itemf(bContext *C,
const GpencilModifierTypeInfo *mti;
int totitem = 0, a;
- if (!ob)
+ if (!ob) {
return rna_enum_object_greasepencil_modifier_type_items;
+ }
for (a = 0; rna_enum_object_greasepencil_modifier_type_items[a].identifier; a++) {
md_item = &rna_enum_object_greasepencil_modifier_type_items[a];
if (md_item->identifier[0]) {
mti = BKE_gpencil_modifierType_getInfo(md_item->value);
- if (mti->flags & eGpencilModifierTypeFlag_NoUserAdd)
+ if (mti->flags & eGpencilModifierTypeFlag_NoUserAdd) {
continue;
+ }
}
else {
group_item = md_item;
@@ -379,19 +385,22 @@ void OBJECT_OT_gpencil_modifier_add(wmOperatorType *ot)
ot->prop = prop;
}
-/************************ generic functions for operators using mod names and data context *********************/
+/********** generic functions for operators using mod names and data context *********************/
static int gpencil_edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type);
Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
- if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0)
+ }
+ if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) {
return 0;
- if (ptr.id.data && ID_IS_LINKED(ptr.id.data))
+ }
+ if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) {
return 0;
+ }
if (ID_IS_STATIC_OVERRIDE(ob)) {
CTX_wm_operator_poll_msg_set(C, "Cannot edit modifiers coming from static override");
@@ -443,8 +452,9 @@ static GpencilModifierData *gpencil_edit_modifier_property_get(wmOperator *op,
md = BKE_gpencil_modifiers_findByName(ob, modifier_name);
- if (md && type != 0 && md->type != type)
+ if (md && type != 0 && md->type != type) {
md = NULL;
+ }
return md;
}
@@ -457,8 +467,9 @@ static int gpencil_modifier_remove_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_gpencil_modifier_remove(op->reports, bmain, ob, md))
+ if (!md || !ED_object_gpencil_modifier_remove(op->reports, bmain, ob, md)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -469,10 +480,12 @@ static int gpencil_modifier_remove_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_remove_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_gpencil_modifier_remove(wmOperatorType *ot)
@@ -497,8 +510,9 @@ static int gpencil_modifier_move_up_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_gpencil_modifier_move_up(op->reports, ob, md))
+ if (!md || !ED_object_gpencil_modifier_move_up(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -510,10 +524,12 @@ static int gpencil_modifier_move_up_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_move_up_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_gpencil_modifier_move_up(wmOperatorType *ot)
@@ -538,8 +554,9 @@ static int gpencil_modifier_move_down_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_gpencil_modifier_move_down(op->reports, ob, md))
+ if (!md || !ED_object_gpencil_modifier_move_down(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -551,10 +568,12 @@ static int gpencil_modifier_move_down_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_move_down_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_gpencil_modifier_move_down(wmOperatorType *ot)
@@ -594,10 +613,12 @@ static int gpencil_modifier_apply_exec(bContext *C, wmOperator *op)
static int gpencil_modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_apply_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
static const EnumPropertyItem gpencil_modifier_apply_as_items[] = {
@@ -639,8 +660,9 @@ static int gpencil_modifier_copy_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_gpencil_modifier_copy(op->reports, ob, md))
+ if (!md || !ED_object_gpencil_modifier_copy(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -650,10 +672,12 @@ static int gpencil_modifier_copy_exec(bContext *C, wmOperator *op)
static int gpencil_modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_copy_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_gpencil_modifier_copy(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index d4e5ba42be2..c939cb0a61d 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -75,11 +75,13 @@ static int return_editmesh_indexar(BMEditMesh *em, int *r_tot, int **r_indexar,
int *index, nr, totvert = 0;
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
totvert++;
+ }
}
- if (totvert == 0)
+ if (totvert == 0) {
return 0;
+ }
*r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar");
*r_tot = totvert;
@@ -144,14 +146,16 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd)
BMIter iter;
int index = 0, nr = 0;
- if (hmd->indexar == NULL)
+ if (hmd->indexar == NULL) {
return;
+ }
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (nr == hmd->indexar[index]) {
BM_vert_select_set(em->bm, eve, true);
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
@@ -173,14 +177,16 @@ static int return_editlattice_indexar(Lattice *editlatt,
bp = editlatt->def;
while (a--) {
if (bp->f1 & SELECT) {
- if (bp->hide == 0)
+ if (bp->hide == 0) {
totvert++;
+ }
}
bp++;
}
- if (totvert == 0)
+ if (totvert == 0) {
return 0;
+ }
*r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar");
*r_tot = totvert;
@@ -219,8 +225,9 @@ static void select_editlattice_hook(Object *obedit, HookModifierData *hmd)
while (a--) {
if (hmd->indexar[index] == nr) {
bp->f1 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
bp++;
@@ -240,12 +247,15 @@ static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar,
bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
totvert++;
- if (bezt->f2 & SELECT)
+ }
+ if (bezt->f2 & SELECT) {
totvert++;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
totvert++;
+ }
bezt++;
}
}
@@ -253,14 +263,16 @@ static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar,
bp = nu->bp;
a = nu->pntsu * nu->pntsv;
while (a--) {
- if (bp->f1 & SELECT)
+ if (bp->f1 & SELECT) {
totvert++;
+ }
bp++;
}
}
}
- if (totvert == 0)
+ if (totvert == 0) {
return 0;
+ }
*r_indexar = index = MEM_mallocN(sizeof(*index) * totvert, "hook indexar");
*r_tot = totvert;
@@ -376,20 +388,23 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
while (a--) {
if (nr == hmd->indexar[index]) {
bezt->f1 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
if (nr == hmd->indexar[index]) {
bezt->f2 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
if (nr == hmd->indexar[index]) {
bezt->f3 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
@@ -402,8 +417,9 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
while (a--) {
if (nr == hmd->indexar[index]) {
bp->f1 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
bp++;
@@ -439,17 +455,22 @@ static void object_hook_from_context(
static void object_hook_select(Object *ob, HookModifierData *hmd)
{
- if (hmd->indexar == NULL)
+ if (hmd->indexar == NULL) {
return;
+ }
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
select_editbmesh_hook(ob, hmd);
- else if (ob->type == OB_LATTICE)
+ }
+ else if (ob->type == OB_LATTICE) {
select_editlattice_hook(ob, hmd);
- else if (ob->type == OB_CURVE)
+ }
+ else if (ob->type == OB_CURVE) {
select_editcurve_hook(ob, hmd);
- else if (ob->type == OB_SURF)
+ }
+ else if (ob->type == OB_SURF) {
select_editcurve_hook(ob, hmd);
+ }
}
/* special poll operators for hook operators */
@@ -459,13 +480,16 @@ static bool hook_op_edit_poll(bContext *C)
Object *obedit = CTX_data_edit_object(C);
if (obedit) {
- if (ED_operator_editmesh(C))
+ if (ED_operator_editmesh(C)) {
return 1;
- if (ED_operator_editsurfcurve(C))
+ }
+ if (ED_operator_editsurfcurve(C)) {
return 1;
- if (ED_operator_editlattice(C))
+ }
+ if (ED_operator_editlattice(C)) {
return 1;
- //if (ED_operator_editmball(C)) return 1;
+ }
+ // if (ED_operator_editmball(C)) return 1;
}
return 0;
@@ -715,8 +739,9 @@ static const EnumPropertyItem *hook_mod_itemf(bContext *C,
ModifierData *md = NULL;
int a, totitem = 0;
- if (!ob)
+ if (!ob) {
return DummyRNA_NULL_items;
+ }
for (a = 0, md = ob->modifiers.first; md; md = md->next, a++) {
if (md->type == eModifierType_Hook) {
@@ -880,8 +905,9 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group");
return OPERATOR_CANCELLED;
}
- if (hmd->indexar)
+ if (hmd->indexar) {
MEM_freeN(hmd->indexar);
+ }
copy_v3_v3(hmd->cent, cent);
hmd->indexar = indexar;
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
index 7c881aa7cab..cc28ceaf95b 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -54,28 +54,39 @@
static const char *object_mode_op_string(eObjectMode mode)
{
- if (mode & OB_MODE_EDIT)
+ if (mode & OB_MODE_EDIT) {
return "OBJECT_OT_editmode_toggle";
- if (mode == OB_MODE_SCULPT)
+ }
+ if (mode == OB_MODE_SCULPT) {
return "SCULPT_OT_sculptmode_toggle";
- if (mode == OB_MODE_VERTEX_PAINT)
+ }
+ if (mode == OB_MODE_VERTEX_PAINT) {
return "PAINT_OT_vertex_paint_toggle";
- if (mode == OB_MODE_WEIGHT_PAINT)
+ }
+ if (mode == OB_MODE_WEIGHT_PAINT) {
return "PAINT_OT_weight_paint_toggle";
- if (mode == OB_MODE_TEXTURE_PAINT)
+ }
+ if (mode == OB_MODE_TEXTURE_PAINT) {
return "PAINT_OT_texture_paint_toggle";
- if (mode == OB_MODE_PARTICLE_EDIT)
+ }
+ if (mode == OB_MODE_PARTICLE_EDIT) {
return "PARTICLE_OT_particle_edit_toggle";
- if (mode == OB_MODE_POSE)
+ }
+ if (mode == OB_MODE_POSE) {
return "OBJECT_OT_posemode_toggle";
- if (mode == OB_MODE_EDIT_GPENCIL)
+ }
+ if (mode == OB_MODE_EDIT_GPENCIL) {
return "GPENCIL_OT_editmode_toggle";
- if (mode == OB_MODE_PAINT_GPENCIL)
+ }
+ if (mode == OB_MODE_PAINT_GPENCIL) {
return "GPENCIL_OT_paintmode_toggle";
- if (mode == OB_MODE_SCULPT_GPENCIL)
+ }
+ if (mode == OB_MODE_SCULPT_GPENCIL) {
return "GPENCIL_OT_sculptmode_toggle";
- if (mode == OB_MODE_WEIGHT_GPENCIL)
+ }
+ if (mode == OB_MODE_WEIGHT_GPENCIL) {
return "GPENCIL_OT_weightmode_toggle";
+ }
return NULL;
}
@@ -86,8 +97,9 @@ static const char *object_mode_op_string(eObjectMode mode)
bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode)
{
if (ob) {
- if (mode == OB_MODE_OBJECT)
+ if (mode == OB_MODE_OBJECT) {
return true;
+ }
switch (ob->type) {
case OB_MESH:
@@ -100,16 +112,19 @@ bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode)
case OB_SURF:
case OB_FONT:
case OB_MBALL:
- if (mode & (OB_MODE_EDIT))
+ if (mode & (OB_MODE_EDIT)) {
return true;
+ }
break;
case OB_LATTICE:
- if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT))
+ if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT)) {
return true;
+ }
break;
case OB_ARMATURE:
- if (mode & (OB_MODE_EDIT | OB_MODE_POSE))
+ if (mode & (OB_MODE_EDIT | OB_MODE_POSE)) {
return true;
+ }
break;
case OB_GPENCIL:
if (mode & (OB_MODE_EDIT | OB_MODE_EDIT_GPENCIL | OB_MODE_PAINT_GPENCIL |
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 7aae0a41c85..e555f0d940d 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -155,13 +155,15 @@ ModifierData *ED_object_modifier_add(
if (mti->flags & eModifierTypeFlag_RequiresOriginalData) {
md = ob->modifiers.first;
- while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform)
+ while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) {
md = md->next;
+ }
BLI_insertlinkbefore(&ob->modifiers, md, new_md);
}
- else
+ else {
BLI_addtail(&ob->modifiers, new_md);
+ }
if (name) {
BLI_strncpy_utf8(new_md->name, name, sizeof(new_md->name));
@@ -179,8 +181,9 @@ ModifierData *ED_object_modifier_add(
}
}
else if (type == eModifierType_Collision) {
- if (!ob->pd)
+ if (!ob->pd) {
ob->pd = BKE_partdeflect_new(0);
+ }
ob->pd->deflect = 1;
}
@@ -215,8 +218,9 @@ static bool object_has_modifier(const Object *ob, const ModifierData *exclude, M
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
- if ((md != exclude) && (md->type == type))
+ if ((md != exclude) && (md->type == type)) {
return true;
+ }
}
return false;
@@ -239,8 +243,9 @@ bool ED_object_iter_other(Main *bmain,
ID *ob_data_id = orig_ob->data;
int users = ob_data_id->us;
- if (ob_data_id->flag & LIB_FAKEUSER)
+ if (ob_data_id->flag & LIB_FAKEUSER) {
users--;
+ }
/* First check that the object's data has multiple users */
if (users > 1) {
@@ -249,8 +254,9 @@ bool ED_object_iter_other(Main *bmain,
for (ob = bmain->objects.first; ob && totfound < users; ob = ob->id.next) {
if (((ob != orig_ob) || include_orig) && (ob->data == orig_ob->data)) {
- if (callback(ob, callback_data))
+ if (callback(ob, callback_data)) {
return true;
+ }
totfound++;
}
@@ -324,8 +330,9 @@ static bool object_modifier_remove(Main *bmain,
}
}
else if (md->type == eModifierType_Collision) {
- if (ob->pd)
+ if (ob->pd) {
ob->pd->deflect = 0;
+ }
*r_sort_depsgraph = true;
}
@@ -334,13 +341,15 @@ static bool object_modifier_remove(Main *bmain,
}
else if (md->type == eModifierType_Multires) {
/* Delete MDisps layer if not used by another multires modifier */
- if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Multires))
+ if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Multires)) {
multires_customdata_delete(ob->data);
+ }
}
else if (md->type == eModifierType_Skin) {
/* Delete MVertSkin layer if not used by another skin modifier */
- if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Skin))
+ if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Skin)) {
modifier_skin_customdata_delete(ob);
+ }
}
if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) &&
@@ -378,8 +387,9 @@ void ED_object_modifier_clear(Main *bmain, Object *ob)
ModifierData *md = ob->modifiers.first;
bool sort_depsgraph = false;
- if (!md)
+ if (!md) {
return;
+ }
while (md) {
ModifierData *next_md;
@@ -456,10 +466,12 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports),
int totvert = 0, totedge = 0, cvert = 0;
int totpart = 0, totchild = 0;
- if (md->type != eModifierType_ParticleSystem)
+ if (md->type != eModifierType_ParticleSystem) {
return 0;
- if (ob && ob->mode & OB_MODE_PARTICLE_EDIT)
+ }
+ if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) {
return 0;
+ }
psys_orig = ((ParticleSystemModifierData *)md)->psys;
part = psys_orig->part;
@@ -475,8 +487,9 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports),
totpart = psys_eval->totcached;
totchild = psys_eval->totchildcache;
- if (totchild && (part->draw & PART_DRAW_PARENT) == 0)
+ if (totchild && (part->draw & PART_DRAW_PARENT) == 0) {
totpart = 0;
+ }
/* count */
cache = psys_eval->pathcache;
@@ -499,8 +512,9 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports),
}
}
- if (totvert == 0)
+ if (totvert == 0) {
return 0;
+ }
/* add new mesh */
obn = BKE_object_add(bmain, scene, view_layer, OB_MESH, NULL);
@@ -564,12 +578,11 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports),
static Mesh *modifier_apply_create_mesh_for_modifier(Depsgraph *depsgraph,
Scene *UNUSED(scene),
Object *object,
- ModifierData *md,
+ ModifierData *md_eval,
bool build_shapekey_layers)
{
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
- ModifierData *md_eval = modifiers_findByName(object_eval, md->name);
Mesh *mesh_applied = BKE_mesh_create_derived_for_modifier(
depsgraph, scene_eval, object_eval, md_eval, build_shapekey_layers);
return mesh_applied;
@@ -580,11 +593,11 @@ static int modifier_apply_shape(Main *bmain,
Depsgraph *depsgraph,
Scene *scene,
Object *ob,
- ModifierData *md)
+ ModifierData *md_eval)
{
- const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ const ModifierTypeInfo *mti = modifierType_getInfo(md_eval->type);
- if (mti->isDisabled && mti->isDisabled(scene, md, 0)) {
+ if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
return 0;
}
@@ -606,12 +619,12 @@ static int modifier_apply_shape(Main *bmain,
Key *key = me->key;
KeyBlock *kb;
- if (!modifier_isSameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) {
+ if (!modifier_isSameTopology(md_eval) || mti->type == eModifierTypeType_NonGeometrical) {
BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes");
return 0;
}
- mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md, false);
+ mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md_eval, false);
if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
return 0;
@@ -626,7 +639,7 @@ static int modifier_apply_shape(Main *bmain,
BKE_keyblock_convert_from_mesh(me, key, kb);
}
- kb = BKE_keyblock_add(key, md->name);
+ kb = BKE_keyblock_add(key, md_eval->name);
BKE_mesh_nomain_to_meshkey(mesh_applied, me, kb);
BKE_id_free(NULL, mesh_applied);
@@ -639,11 +652,11 @@ static int modifier_apply_shape(Main *bmain,
}
static int modifier_apply_obdata(
- ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md)
+ ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md_eval)
{
- const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ const ModifierTypeInfo *mti = modifierType_getInfo(md_eval->type);
- if (mti->isDisabled && mti->isDisabled(scene, md, 0)) {
+ if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
return 0;
}
@@ -651,7 +664,7 @@ static int modifier_apply_obdata(
if (ob->type == OB_MESH) {
Mesh *mesh_applied;
Mesh *me = ob->data;
- MultiresModifierData *mmd = find_multires_modifier_before(scene, md);
+ MultiresModifierData *mmd = find_multires_modifier_before(scene, md_eval);
if (me->key && mti->type != eModifierTypeType_NonGeometrical) {
BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to a mesh with shape keys");
@@ -659,17 +672,18 @@ static int modifier_apply_obdata(
}
/* Multires: ensure that recent sculpting is applied */
- if (md->type == eModifierType_Multires)
+ if (md_eval->type == eModifierType_Multires) {
multires_force_update(ob);
+ }
if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) {
- if (!multiresModifier_reshapeFromDeformModifier(depsgraph, mmd, ob, md)) {
+ if (!multiresModifier_reshapeFromDeformModifier(depsgraph, mmd, ob, md_eval)) {
BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply");
return 0;
}
}
else {
- mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md, true);
+ mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, scene, ob, md_eval, true);
if (!mesh_applied) {
BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
return 0;
@@ -677,8 +691,9 @@ static int modifier_apply_obdata(
BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true);
- if (md->type == eModifierType_Multires)
+ if (md_eval->type == eModifierType_Multires) {
multires_customdata_delete(me);
+ }
}
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
@@ -700,7 +715,7 @@ static int modifier_apply_obdata(
"Applied modifier only changed CV points, not tessellated/bevel vertices");
vertexCos = BKE_curve_nurbs_vertexCos_get(&curve_eval->nurb, &numVerts);
- mti->deformVerts(md, &mectx, NULL, vertexCos, numVerts);
+ mti->deformVerts(md_eval, &mectx, NULL, vertexCos, numVerts);
BK_curve_nurbs_vertexCos_apply(&curve->nurb, vertexCos);
MEM_freeN(vertexCos);
@@ -719,8 +734,9 @@ static int modifier_apply_obdata(
for (; psys; psys = psys->next) {
- if (psys->part->type != PART_HAIR)
+ if (psys->part->type != PART_HAIR) {
continue;
+ }
psys_apply_hair_lattice(depsgraph, scene, ob, psys);
}
@@ -755,8 +771,9 @@ int ED_object_modifier_apply(Main *bmain,
return 0;
}
- if (md != ob->modifiers.first)
+ if (md != ob->modifiers.first) {
BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected");
+ }
/* Get evaluated modifier, so object links pointer to evaluated data,
* but still use original object it is applied to the original mesh. */
@@ -810,8 +827,9 @@ static int modifier_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
int type = RNA_enum_get(op->ptr, "type");
- if (!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type))
+ if (!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -829,8 +847,9 @@ static const EnumPropertyItem *modifier_add_itemf(bContext *C,
const ModifierTypeInfo *mti;
int totitem = 0, a;
- if (!ob)
+ if (!ob) {
return rna_enum_object_modifier_type_items;
+ }
for (a = 0; rna_enum_object_modifier_type_items[a].identifier; a++) {
md_item = &rna_enum_object_modifier_type_items[a];
@@ -838,11 +857,13 @@ static const EnumPropertyItem *modifier_add_itemf(bContext *C,
if (md_item->identifier[0]) {
mti = modifierType_getInfo(md_item->value);
- if (mti->flags & eModifierTypeFlag_NoUserAdd)
+ if (mti->flags & eModifierTypeFlag_NoUserAdd) {
continue;
+ }
- if (!BKE_object_support_modifier_type_check(ob, md_item->value))
+ if (!BKE_object_support_modifier_type_check(ob, md_item->value)) {
continue;
+ }
}
else {
group_item = md_item;
@@ -889,19 +910,22 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot)
ot->prop = prop;
}
-/************************ generic functions for operators using mod names and data context *********************/
+/********** generic functions for operators using mod names and data context *********************/
bool edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type);
Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
- if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0)
+ }
+ if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) {
return 0;
- if (ptr.id.data && ID_IS_LINKED(ptr.id.data))
+ }
+ if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) {
return 0;
+ }
if (ID_IS_STATIC_OVERRIDE(ob)) {
CTX_wm_operator_poll_msg_set(C, "Cannot edit modifiers coming from static override");
@@ -950,8 +974,9 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type)
md = modifiers_findByName(ob, modifier_name);
- if (md && type != 0 && md->type != type)
+ if (md && type != 0 && md->type != type) {
md = NULL;
+ }
return md;
}
@@ -966,8 +991,9 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int mode_orig = ob->mode;
- if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
+ if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -984,10 +1010,12 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_remove_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_remove(wmOperatorType *ot)
@@ -1012,8 +1040,9 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_modifier_move_up(op->reports, ob, md))
+ if (!md || !ED_object_modifier_move_up(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1023,10 +1052,12 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_move_up_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_move_up(wmOperatorType *ot)
@@ -1051,8 +1082,9 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_modifier_move_down(op->reports, ob, md))
+ if (!md || !ED_object_modifier_move_down(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1062,10 +1094,12 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_move_down_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
@@ -1106,10 +1140,12 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_apply_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
static const EnumPropertyItem modifier_apply_as_items[] = {
@@ -1155,8 +1191,10 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_modifier_convert(op->reports, bmain, depsgraph, scene, view_layer, ob, md))
+ if (!md ||
+ !ED_object_modifier_convert(op->reports, bmain, depsgraph, scene, view_layer, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1166,10 +1204,12 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
static int modifier_convert_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_convert_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_convert(wmOperatorType *ot)
@@ -1194,8 +1234,9 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_modifier_copy(op->reports, ob, md))
+ if (!md || !ED_object_modifier_copy(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1205,10 +1246,12 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
static int modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_copy_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_copy(wmOperatorType *ot)
@@ -1240,8 +1283,9 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op)
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
multiresModifier_del_levels(mmd, scene, ob, 1);
@@ -1257,10 +1301,12 @@ static int multires_higher_levels_delete_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return multires_higher_levels_delete_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot)
@@ -1287,8 +1333,9 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
multiresModifier_subdivide(mmd, scene, ob, 0, mmd->simple);
@@ -1308,10 +1355,12 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
static int multires_subdivide_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return multires_subdivide_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
@@ -1338,8 +1387,9 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
if (mmd->lvl == 0) {
BKE_report(op->reports, RPT_ERROR, "Reshape can work only with higher levels of subdivisions");
@@ -1372,10 +1422,12 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
static int multires_reshape_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return multires_reshape_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_multires_reshape(wmOperatorType *ot)
@@ -1403,16 +1455,19 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
char path[FILE_MAX];
const bool relative = RNA_boolean_get(op->ptr, "relative_path");
- if (!me)
+ if (!me) {
return OPERATOR_CANCELLED;
+ }
- if (CustomData_external_test(&me->ldata, CD_MDISPS))
+ if (CustomData_external_test(&me->ldata, CD_MDISPS)) {
return OPERATOR_CANCELLED;
+ }
RNA_string_get(op->ptr, "filepath", path);
- if (relative)
+ if (relative) {
BLI_path_rel(path, BKE_main_blendfile_path(bmain));
+ }
CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path);
CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH.lmask, me->totloop, 0);
@@ -1427,19 +1482,23 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv
Mesh *me = ob->data;
char path[FILE_MAX];
- if (!edit_modifier_invoke_properties(C, op))
+ if (!edit_modifier_invoke_properties(C, op)) {
return OPERATOR_CANCELLED;
+ }
mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
- if (CustomData_external_test(&me->ldata, CD_MDISPS))
+ if (CustomData_external_test(&me->ldata, CD_MDISPS)) {
return OPERATOR_CANCELLED;
+ }
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return multires_external_save_exec(C, op);
+ }
op->customdata = me;
@@ -1482,8 +1541,9 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_active_context(C);
Mesh *me = ob->data;
- if (!CustomData_external_test(&me->ldata, CD_MDISPS))
+ if (!CustomData_external_test(&me->ldata, CD_MDISPS)) {
return OPERATOR_CANCELLED;
+ }
/* XXX don't remove.. */
CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop);
@@ -1512,8 +1572,9 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op)
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
multiresModifier_base_apply(mmd, scene, ob);
@@ -1525,10 +1586,12 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op)
static int multires_base_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return multires_base_apply_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_multires_base_apply(wmOperatorType *ot)
@@ -1553,10 +1616,12 @@ static void modifier_skin_customdata_delete(Object *ob)
Mesh *me = ob->data;
BMEditMesh *em = me->edit_mesh;
- if (em)
+ if (em) {
BM_data_layer_free(em->bm, &em->bm->vdata, CD_MVERT_SKIN);
- else
+ }
+ else {
CustomData_free_layer_active(&me->vdata, CD_MVERT_SKIN, me->totvert);
+ }
}
static bool skin_poll(bContext *C)
@@ -1757,8 +1822,9 @@ static void skin_armature_bone_create(Object *skin_ob,
int v;
/* ignore edge if already visited */
- if (BLI_BITMAP_TEST(edges_visited, endx))
+ if (BLI_BITMAP_TEST(edges_visited, endx)) {
continue;
+ }
BLI_BITMAP_ENABLE(edges_visited, endx);
v = (e->v1 == parent_v ? e->v2 : e->v1);
@@ -1894,10 +1960,12 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
static int skin_armature_create_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return skin_armature_create_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_skin_armature_create(wmOperatorType *ot)
@@ -1967,10 +2035,12 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
static int correctivesmooth_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return correctivesmooth_bind_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_correctivesmooth_bind(wmOperatorType *ot)
@@ -2022,7 +2092,8 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
mmd->totinfluence = 0;
}
else {
- /* Force modifier to run, it will call binding routine (this has to happen outside of depsgraph evaluation). */
+ /* Force modifier to run, it will call binding routine
+ * (this has to happen outside of depsgraph evaluation). */
MeshDeformModifierData *mmd_eval = (MeshDeformModifierData *)modifier_get_evaluated(
depsgraph, ob, &mmd->modifier);
mmd_eval->bindfunc = ED_mesh_deform_bind_callback;
@@ -2037,10 +2108,12 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return meshdeform_bind_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_meshdeform_bind(wmOperatorType *ot)
@@ -2073,8 +2146,9 @@ static int explode_refresh_exec(bContext *C, wmOperator *op)
ExplodeModifierData *emd = (ExplodeModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Explode);
- if (!emd)
+ if (!emd) {
return OPERATOR_CANCELLED;
+ }
emd->flag |= eExplodeFlag_CalcFaces;
@@ -2086,10 +2160,12 @@ static int explode_refresh_exec(bContext *C, wmOperator *op)
static int explode_refresh_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return explode_refresh_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_explode_refresh(wmOperatorType *ot)
@@ -2134,8 +2210,8 @@ static void oceanbake_free(void *customdata)
/* called by oceanbake, only to check job 'stop' value */
static int oceanbake_breakjob(void *UNUSED(customdata))
{
- //OceanBakeJob *ob = (OceanBakeJob *)customdata;
- //return *(ob->stop);
+ // OceanBakeJob *ob = (OceanBakeJob *)customdata;
+ // return *(ob->stop);
/* this is not nice yet, need to make the jobs list template better
* for identifying/acting upon various different jobs */
@@ -2148,8 +2224,9 @@ static void oceanbake_update(void *customdata, float progress, int *cancel)
{
OceanBakeJob *oj = customdata;
- if (oceanbake_breakjob(oj))
+ if (oceanbake_breakjob(oj)) {
*cancel = 1;
+ }
*(oj->do_update) = true;
*(oj->progress) = progress;
@@ -2202,8 +2279,9 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
wmJob *wm_job;
OceanBakeJob *oj;
- if (!omd)
+ if (!omd) {
return OPERATOR_CANCELLED;
+ }
if (free) {
BKE_ocean_free_modifier_cache(omd);
@@ -2281,10 +2359,12 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
static int ocean_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return ocean_bake_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_ocean_bake(wmOperatorType *ot)
@@ -2354,10 +2434,12 @@ static int laplaciandeform_bind_exec(bContext *C, wmOperator *op)
static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return laplaciandeform_bind_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot)
@@ -2417,10 +2499,12 @@ static int surfacedeform_bind_exec(bContext *C, wmOperator *op)
static int surfacedeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return surfacedeform_bind_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_surfacedeform_bind(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 8e3f916b2e4..afc0297cb01 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -271,7 +271,7 @@ void ED_operatormacros_object(void)
if (ot) {
WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
/* grr, should be able to pass options on... */
@@ -283,7 +283,7 @@ void ED_operatormacros_object(void)
otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
RNA_boolean_set(otmacro->ptr, "linked", true);
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
}
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 3744632be3d..e15d85a7953 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -159,16 +159,21 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- if (v1 == 0)
+ if (v1 == 0) {
v1 = nr;
- else if (v2 == 0)
+ }
+ else if (v2 == 0) {
v2 = nr;
- else if (v3 == 0)
+ }
+ else if (v3 == 0) {
v3 = nr;
- else if (v4 == 0)
+ }
+ else if (v4 == 0) {
v4 = nr;
- else
+ }
+ else {
break;
+ }
}
nr++;
}
@@ -183,16 +188,21 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
a = nu->pntsu;
while (a--) {
if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
- if (v1 == 0)
+ if (v1 == 0) {
v1 = nr;
- else if (v2 == 0)
+ }
+ else if (v2 == 0) {
v2 = nr;
- else if (v3 == 0)
+ }
+ else if (v3 == 0) {
v3 = nr;
- else if (v4 == 0)
+ }
+ else if (v4 == 0) {
v4 = nr;
- else
+ }
+ else {
break;
+ }
}
nr++;
bezt++;
@@ -203,16 +213,21 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
a = nu->pntsu * nu->pntsv;
while (a--) {
if (bp->f1 & SELECT) {
- if (v1 == 0)
+ if (v1 == 0) {
v1 = nr;
- else if (v2 == 0)
+ }
+ else if (v2 == 0) {
v2 = nr;
- else if (v3 == 0)
+ }
+ else if (v3 == 0) {
v3 = nr;
- else if (v4 == 0)
+ }
+ else if (v4 == 0) {
v4 = nr;
- else
+ }
+ else {
break;
+ }
}
nr++;
bp++;
@@ -228,16 +243,21 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
bp = lt->editlatt->latt->def;
while (a--) {
if (bp->f1 & SELECT) {
- if (v1 == 0)
+ if (v1 == 0) {
v1 = nr;
- else if (v2 == 0)
+ }
+ else if (v2 == 0) {
v2 = nr;
- else if (v3 == 0)
+ }
+ else if (v3 == 0) {
v3 = nr;
- else if (v4 == 0)
+ }
+ else if (v4 == 0) {
v4 = nr;
- else
+ }
+ else {
break;
+ }
}
nr++;
bp++;
@@ -316,8 +336,9 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Object *ob = ED_object_active_context(C);
/* sanity checks */
- if (!scene || ID_IS_LINKED(scene) || !ob)
+ if (!scene || ID_IS_LINKED(scene) || !ob) {
return OPERATOR_CANCELLED;
+ }
/* Get object to work on - use a menu if we need to... */
if (ob->instance_collection && ID_IS_LINKED(ob->instance_collection)) {
@@ -411,8 +432,9 @@ static const EnumPropertyItem *proxy_collection_object_itemf(bContext *C,
int i = 0;
Object *ob = ED_object_active_context(C);
- if (!ob || !ob->instance_collection)
+ if (!ob || !ob->instance_collection) {
return DummyRNA_DEFAULT_items;
+ }
/* find the object to affect */
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (ob->instance_collection, object) {
@@ -529,8 +551,9 @@ static void object_remove_parent_deform_modifiers(Object *ob, const Object *par)
void ED_object_parent_clear(Object *ob, const int type)
{
- if (ob->parent == NULL)
+ if (ob->parent == NULL) {
return;
+ }
switch (type) {
case CLEAR_PARENT_ALL: {
@@ -664,8 +687,9 @@ bool ED_object_parent_set(ReportList *reports,
/* preconditions */
if (partype == PAR_FOLLOW || partype == PAR_PATH_CONST) {
- if (par->type != OB_CURVE)
+ if (par->type != OB_CURVE) {
return 0;
+ }
else {
Curve *cu = par->data;
Curve *cu_eval = parent_eval->data;
@@ -687,13 +711,15 @@ bool ED_object_parent_set(ReportList *reports,
FCurve *fcu = verify_fcurve(bmain, act, NULL, NULL, "eval_time", 0, 1);
/* setup dummy 'generator' modifier here to get 1-1 correspondence still working */
- if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first)
+ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) {
add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu);
+ }
}
/* fall back on regular parenting now (for follow only) */
- if (partype == PAR_FOLLOW)
+ if (partype == PAR_FOLLOW) {
partype = PAR_OBJECT;
+ }
}
}
else if (ELEM(partype, PAR_BONE, PAR_BONE_RELATIVE)) {
@@ -730,24 +756,29 @@ bool ED_object_parent_set(ReportList *reports,
}
/* handle types */
- if (pchan)
+ if (pchan) {
BLI_strncpy(ob->parsubstr, pchan->name, sizeof(ob->parsubstr));
- else
+ }
+ else {
ob->parsubstr[0] = 0;
+ }
if (partype == PAR_PATH_CONST) {
/* don't do anything here, since this is not technically "parenting" */
}
else if (ELEM(partype, PAR_CURVE, PAR_LATTICE) || (pararm)) {
- /* partype is now set to PAROBJECT so that invisible 'virtual' modifiers don't need to be created
- * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers
+ /* partype is now set to PAROBJECT so that invisible 'virtual'
+ * modifiers don't need to be created.
+ * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL,
+ * creating the virtual modifiers.
*/
ob->partype = PAROBJECT; /* note, dna define, not operator property */
/* ob->partype = PARSKEL; */ /* note, dna define, not operator property */
- /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses
- * - We need to ensure that the modifier we're adding doesn't already exist, so we check this by
- * assuming that the parent is selected too...
+ /* BUT, to keep the deforms, we need a modifier,
+ * and then we need to set the object that it uses
+ * - We need to ensure that the modifier we're adding doesn't already exist,
+ * so we check this by assuming that the parent is selected too.
*/
/* XXX currently this should only happen for meshes, curves, surfaces,
* and lattices - this stuff isn't available for metas yet */
@@ -952,8 +983,9 @@ static int parent_set_exec(bContext *C, wmOperator *op)
BLI_kdtree_3d_free(tree);
}
- if (!ok)
+ if (!ok) {
return OPERATOR_CANCELLED;
+ }
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -962,15 +994,13 @@ static int parent_set_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+static int parent_set_invoke_menu(bContext *C, wmOperatorType *ot)
{
Object *parent = ED_object_active_context(C);
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Set Parent To"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
- wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_parent_set", true);
PointerRNA opptr;
-
#if 0
uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_OBJECT);
#else
@@ -1040,6 +1070,14 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
return OPERATOR_INTERFACE;
}
+static int parent_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ if (RNA_property_is_set(op->ptr, op->type->prop)) {
+ return parent_set_exec(C, op);
+ }
+ return parent_set_invoke_menu(C, op->type);
+}
+
static bool parent_set_poll_property(const bContext *UNUSED(C),
wmOperator *op,
const PropertyRNA *prop)
@@ -1049,10 +1087,12 @@ static bool parent_set_poll_property(const bContext *UNUSED(C),
/* Only show XMirror for PAR_ARMATURE_ENVELOPE and PAR_ARMATURE_AUTO! */
if (STREQ(prop_id, "xmirror")) {
const int type = RNA_enum_get(op->ptr, "type");
- if (ELEM(type, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO))
+ if (ELEM(type, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO)) {
return true;
- else
+ }
+ else {
return false;
+ }
}
return true;
@@ -1181,12 +1221,14 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
if (ELEM(con->type,
CONSTRAINT_TYPE_TRACKTO,
CONSTRAINT_TYPE_LOCKTRACK,
- CONSTRAINT_TYPE_DAMPTRACK))
+ CONSTRAINT_TYPE_DAMPTRACK)) {
BKE_constraint_remove(&ob->constraints, con);
+ }
}
- if (type == CLEAR_TRACK_KEEP_TRANSFORM)
+ if (type == CLEAR_TRACK_KEEP_TRANSFORM) {
BKE_object_apply_mat4(ob, ob->obmat, true, true);
+ }
}
CTX_DATA_END;
@@ -1339,11 +1381,13 @@ void OBJECT_OT_track_set(wmOperatorType *ot)
#if 0
static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr))
{
- Scene *sce = (Scene *) BLI_findlink(&bmain->scene, G.curscreen->scenenr - 1);
+ Scene *sce = (Scene *)BLI_findlink(&bmain->scene, G.curscreen->scenenr - 1);
Base *base, *nbase;
- if (sce == NULL) return;
- if (sce->id.lib) return;
+ if (sce == NULL)
+ return;
+ if (sce->id.lib)
+ return;
for (base = FIRSTBASE; base; base = base->next) {
if (BASE_SELECTED(v3d, base)) {
@@ -1539,20 +1583,24 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
break;
}
- if (cu_dst->vfont)
+ if (cu_dst->vfont) {
id_us_min(&cu_dst->vfont->id);
+ }
cu_dst->vfont = cu_src->vfont;
id_us_plus((ID *)cu_dst->vfont);
- if (cu_dst->vfontb)
+ if (cu_dst->vfontb) {
id_us_min(&cu_dst->vfontb->id);
+ }
cu_dst->vfontb = cu_src->vfontb;
id_us_plus((ID *)cu_dst->vfontb);
- if (cu_dst->vfonti)
+ if (cu_dst->vfonti) {
id_us_min(&cu_dst->vfonti->id);
+ }
cu_dst->vfonti = cu_src->vfonti;
id_us_plus((ID *)cu_dst->vfonti);
- if (cu_dst->vfontbi)
+ if (cu_dst->vfontbi) {
id_us_min(&cu_dst->vfontbi->id);
+ }
cu_dst->vfontbi = cu_src->vfontbi;
id_us_plus((ID *)cu_dst->vfontbi);
@@ -1680,9 +1728,10 @@ static Collection *single_object_users_collection(Main *bmain,
}
}
- /* Since master collection has already be duplicated as part of scene copy, we do not duplictae it here.
- * However, this means its children need to be re-added manually here, otherwise their parent lists are empty
- * (which will lead to crashes, see T63101). */
+ /* Since master collection has already be duplicated as part of scene copy,
+ * we do not duplictae it here.
+ * However, this means its children need to be re-added manually here,
+ * otherwise their parent lists are empty (which will lead to crashes, see T63101). */
CollectionChild *child_next, *child = collection->children.first;
CollectionChild *orig_child_last = collection->children.last;
for (; child != NULL; child = child_next) {
@@ -1711,9 +1760,10 @@ static void single_object_users(
single_object_users_collection(bmain, scene, master_collection, flag, copy_collections, true);
/* duplicate collections that consist entirely of duplicated objects */
- /* XXX I guess that was designed for calls from 'make single user' operator... But since copy_collection is
- * always false then, was not doing anything. And that kind of behavior should be added at operator level,
- * not in a utility function also used by rather different code... */
+ /* XXX I guess that was designed for calls from 'make single user' operator.
+ * But since copy_collection is always false then, was not doing anything.
+ * And that kind of behavior should be added at operator level,
+ * not in a utility function also used by rather different code. */
#if 0
if (copy_collections) {
Collection *collection, *collectionn;
@@ -1753,7 +1803,8 @@ static void single_object_users(
ID_NEW_REMAP(v3d->camera);
}
- /* Making single user may affect other scenes if they share with current one some collections in their ViewLayer. */
+ /* Making single user may affect other scenes if they share
+ * with current one some collections in their ViewLayer. */
BKE_main_collection_sync(bmain);
}
@@ -1821,8 +1872,9 @@ static void single_obdata_users(
case OB_MESH:
/* Needed to remap texcomesh below. */
me = ob->data = ID_NEW_SET(ob->data, BKE_mesh_copy(bmain, ob->data));
- if (me->key) /* We do not need to set me->key->id.newid here... */
+ if (me->key) { /* We do not need to set me->key->id.newid here... */
BKE_animdata_copy_id_action(bmain, (ID *)me->key, false);
+ }
break;
case OB_MBALL:
ob->data = ID_NEW_SET(ob->data, BKE_mball_copy(bmain, ob->data));
@@ -1833,13 +1885,15 @@ static void single_obdata_users(
ob->data = cu = ID_NEW_SET(ob->data, BKE_curve_copy(bmain, ob->data));
ID_NEW_REMAP(cu->bevobj);
ID_NEW_REMAP(cu->taperobj);
- if (cu->key) /* We do not need to set cu->key->id.newid here... */
+ if (cu->key) { /* We do not need to set cu->key->id.newid here... */
BKE_animdata_copy_id_action(bmain, (ID *)cu->key, false);
+ }
break;
case OB_LATTICE:
ob->data = lat = ID_NEW_SET(ob->data, BKE_lattice_copy(bmain, ob->data));
- if (lat->key) /* We do not need to set lat->key->id.newid here... */
+ if (lat->key) { /* We do not need to set lat->key->id.newid here... */
BKE_animdata_copy_id_action(bmain, (ID *)lat->key, false);
+ }
break;
case OB_ARMATURE:
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -1936,25 +1990,35 @@ static void single_mat_users_expand(Main *bmain)
MetaBall *mb;
bGPdata *gpd;
- for (ob = bmain->objects.first; ob; ob = ob->id.next)
- if (ob->id.tag & LIB_TAG_NEW)
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, ob->mat, ob->totcol);
+ }
+ }
- for (me = bmain->meshes.first; me; me = me->id.next)
- if (me->id.tag & LIB_TAG_NEW)
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ if (me->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, me->mat, me->totcol);
+ }
+ }
- for (cu = bmain->curves.first; cu; cu = cu->id.next)
- if (cu->id.tag & LIB_TAG_NEW)
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ if (cu->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, cu->mat, cu->totcol);
+ }
+ }
- for (mb = bmain->metaballs.first; mb; mb = mb->id.next)
- if (mb->id.tag & LIB_TAG_NEW)
+ for (mb = bmain->metaballs.first; mb; mb = mb->id.next) {
+ if (mb->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, mb->mat, mb->totcol);
+ }
+ }
- for (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next)
- if (gpd->id.tag & LIB_TAG_NEW)
+ for (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ if (gpd->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, gpd->mat, gpd->totcol);
+ }
+ }
}
/* used for copying scenes */
@@ -2094,8 +2158,7 @@ static bool make_local_all__instance_indirect_unused(Main *bmain,
BKE_collection_object_add(bmain, collection, ob);
base = BKE_view_layer_base_find(view_layer, ob);
- base->flag |= BASE_SELECTED;
- BKE_scene_object_base_flag_sync_from_base(base);
+ ED_object_base_select(base, BA_SELECT);
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
changed = true;
@@ -2146,7 +2209,8 @@ static void make_local_material_tag(Material *ma)
ma->id.tag &= ~LIB_TAG_PRE_EXISTING;
make_local_animdata_tag(BKE_animdata_from_id(&ma->id));
- /* About nodetrees: root one is made local together with material, others we keep linked for now... */
+ /* About nodetrees: root one is made local together with material,
+ * others we keep linked for now... */
}
}
@@ -2365,7 +2429,8 @@ static int make_override_static_exec(bContext *C, wmOperator *op)
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
- /* Then, we remove (untag) bone shape objects, you shall never want to override those (hopefully)... */
+ /* Then, we remove (untag) bone shape objects, you shall never want to override those
+ * (hopefully)... */
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (collection, ob) {
if (ob->type == OB_ARMATURE && ob->pose != NULL) {
for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
@@ -2582,8 +2647,9 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent
RNA_string_get(op->ptr, "name", name);
ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, name);
- if (base == NULL || ma == NULL)
+ if (base == NULL || ma == NULL) {
return OPERATOR_CANCELLED;
+ }
assign_material(CTX_data_main(C), base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF);
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 06bd4d76973..afdda8d6b7f 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -87,7 +87,7 @@
* \{ */
/**
- * simple API for object selection, rather than just using the flag
+ * Simple API for object selection, rather than just using the flag
* this takes into account the 'restrict selection in 3d view' flag.
* deselect works always, the restriction just prevents selection
*
@@ -387,10 +387,12 @@ static bool objects_selectable_poll(bContext *C)
* still allowed then for inspection of scene */
Object *obact = CTX_data_active_object(C);
- if (CTX_data_edit_object(C))
+ if (CTX_data_edit_object(C)) {
return 0;
- if (obact && obact->mode)
+ }
+ if (obact && obact->mode) {
return 0;
+ }
return 1;
}
@@ -470,7 +472,8 @@ enum {
};
static const EnumPropertyItem prop_select_linked_types[] = {
- //{OBJECT_SELECT_LINKED_IPO, "IPO", 0, "Object IPO", ""}, // XXX deprecated animation system stuff...
+ /* XXX deprecated animation system stuff. */
+ // {OBJECT_SELECT_LINKED_IPO, "IPO", 0, "Object IPO", ""},
{OBJECT_SELECT_LINKED_OBDATA, "OBDATA", 0, "Object Data", ""},
{OBJECT_SELECT_LINKED_MATERIAL, "MATERIAL", 0, "Material", ""},
{OBJECT_SELECT_LINKED_DUPGROUP, "DUPGROUP", 0, "Instanced Collection", ""},
@@ -652,13 +655,14 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
if (nr == OBJECT_SELECT_LINKED_IPO) {
// XXX old animation system
- //if (ob->ipo == 0) return OPERATOR_CANCELLED;
- //object_select_all_by_ipo(C, ob->ipo)
+ // if (ob->ipo == 0) return OPERATOR_CANCELLED;
+ // object_select_all_by_ipo(C, ob->ipo)
return OPERATOR_CANCELLED;
}
else if (nr == OBJECT_SELECT_LINKED_OBDATA) {
- if (ob->data == NULL)
+ if (ob->data == NULL) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_obdata(C, ob->data);
}
@@ -666,20 +670,23 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
Material *mat = NULL;
mat = give_current_material(ob, ob->actcol);
- if (mat == NULL)
+ if (mat == NULL) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_material(C, mat);
}
else if (nr == OBJECT_SELECT_LINKED_DUPGROUP) {
- if (ob->instance_collection == NULL)
+ if (ob->instance_collection == NULL) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_instance_collection(C, ob);
}
else if (nr == OBJECT_SELECT_LINKED_PARTICLE) {
- if (BLI_listbase_is_empty(&ob->particlesystem))
+ if (BLI_listbase_is_empty(&ob->particlesystem)) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_particle(C, ob);
}
@@ -688,13 +695,15 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
changed = object_select_all_by_library(C, ob->id.lib);
}
else if (nr == OBJECT_SELECT_LINKED_LIBRARY_OBDATA) {
- if (ob->data == NULL)
+ if (ob->data == NULL) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_library_obdata(C, ((ID *)ob->data)->lib);
}
- else
+ else {
return OPERATOR_CANCELLED;
+ }
if (changed) {
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
@@ -829,8 +838,9 @@ static bool select_grouped_collection(bContext *C, Object *ob)
}
}
- if (!collection_count)
+ if (!collection_count) {
return 0;
+ }
else if (collection_count == 1) {
collection = ob_collections[0];
CTX_DATA_BEGIN (C, Base *, base, visible_bases) {
@@ -1174,8 +1184,9 @@ static int object_select_same_collection_exec(bContext *C, wmOperator *op)
char collection_name[MAX_ID_NAME];
/* passthrough if no objects are visible */
- if (CTX_DATA_COUNT(C, visible_bases) == 0)
+ if (CTX_DATA_COUNT(C, visible_bases) == 0) {
return OPERATOR_PASS_THROUGH;
+ }
RNA_string_get(op->ptr, "collection", collection_name);
@@ -1251,8 +1262,9 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
}
}
- if (extend == false)
+ if (extend == false) {
ED_object_base_select(primbase, BA_DESELECT);
+ }
}
CTX_DATA_END;
diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.c
index 64535d8f281..f4f944459f7 100644
--- a/source/blender/editors/object/object_shader_fx.c
+++ b/source/blender/editors/object/object_shader_fx.c
@@ -110,8 +110,9 @@ static bool UNUSED_FUNCTION(object_has_shaderfx)(const Object *ob,
ShaderFxData *fx;
for (fx = ob->shader_fx.first; fx; fx = fx->next) {
- if ((fx != exclude) && (fx->type == type))
+ if ((fx != exclude) && (fx->type == type)) {
return true;
+ }
}
return false;
@@ -161,8 +162,9 @@ void ED_object_shaderfx_clear(Main *bmain, Object *ob)
ShaderFxData *fx = ob->shader_fx.first;
bool sort_depsgraph = false;
- if (!fx)
+ if (!fx) {
return;
+ }
while (fx) {
ShaderFxData *next_fx;
@@ -207,8 +209,9 @@ static int shaderfx_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
int type = RNA_enum_get(op->ptr, "type");
- if (!ED_object_shaderfx_add(op->reports, bmain, scene, ob, NULL, type))
+ if (!ED_object_shaderfx_add(op->reports, bmain, scene, ob, NULL, type)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -226,16 +229,18 @@ static const EnumPropertyItem *shaderfx_add_itemf(bContext *C,
const ShaderFxTypeInfo *mti;
int totitem = 0, a;
- if (!ob)
+ if (!ob) {
return rna_enum_object_shaderfx_type_items;
+ }
for (a = 0; rna_enum_object_shaderfx_type_items[a].identifier; a++) {
fx_item = &rna_enum_object_shaderfx_type_items[a];
if (fx_item->identifier[0]) {
mti = BKE_shaderfxType_getInfo(fx_item->value);
- if (mti->flags & eShaderFxTypeFlag_NoUserAdd)
+ if (mti->flags & eShaderFxTypeFlag_NoUserAdd) {
continue;
+ }
}
else {
group_item = fx_item;
@@ -281,7 +286,9 @@ void OBJECT_OT_shaderfx_add(wmOperatorType *ot)
BLT_I18NCONTEXT_ID_ID); /* Abused, for "Light"... */
}
-/************************ generic functions for operators using names and data context *********************/
+/* -------------------------------------------------------------------- */
+/** \name Generic Functions for Operators Using Names and Data Context
+ * \{ */
static bool edit_shaderfx_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag)
{
@@ -293,12 +300,15 @@ static bool edit_shaderfx_poll_generic(bContext *C, StructRNA *rna_type, int obt
return 0;
}
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
- if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0)
+ }
+ if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) {
return 0;
- if (ptr.id.data && ID_IS_LINKED(ptr.id.data))
+ }
+ if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) {
return 0;
+ }
if (ID_IS_STATIC_OVERRIDE(ob)) {
CTX_wm_operator_poll_msg_set(C, "Cannot edit shaderfxs coming from static override");
@@ -347,12 +357,15 @@ static ShaderFxData *edit_shaderfx_property_get(wmOperator *op, Object *ob, int
fx = BKE_shaderfx_findByName(ob, shaderfx_name);
- if (fx && type != 0 && fx->type != type)
+ if (fx && type != 0 && fx->type != type) {
fx = NULL;
+ }
return fx;
}
+/** \} */
+
/************************ remove shaderfx operator *********************/
static int shaderfx_remove_exec(bContext *C, wmOperator *op)
@@ -361,8 +374,9 @@ static int shaderfx_remove_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
- if (!fx || !ED_object_shaderfx_remove(op->reports, bmain, ob, fx))
+ if (!fx || !ED_object_shaderfx_remove(op->reports, bmain, ob, fx)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -371,10 +385,12 @@ static int shaderfx_remove_exec(bContext *C, wmOperator *op)
static int shaderfx_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_shaderfx_invoke_properties(C, op))
+ if (edit_shaderfx_invoke_properties(C, op)) {
return shaderfx_remove_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_shaderfx_remove(wmOperatorType *ot)
@@ -399,8 +415,9 @@ static int shaderfx_move_up_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
- if (!fx || !ED_object_shaderfx_move_up(op->reports, ob, fx))
+ if (!fx || !ED_object_shaderfx_move_up(op->reports, ob, fx)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -410,10 +427,12 @@ static int shaderfx_move_up_exec(bContext *C, wmOperator *op)
static int shaderfx_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_shaderfx_invoke_properties(C, op))
+ if (edit_shaderfx_invoke_properties(C, op)) {
return shaderfx_move_up_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_shaderfx_move_up(wmOperatorType *ot)
@@ -438,8 +457,9 @@ static int shaderfx_move_down_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
- if (!fx || !ED_object_shaderfx_move_down(op->reports, ob, fx))
+ if (!fx || !ED_object_shaderfx_move_down(op->reports, ob, fx)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -449,10 +469,12 @@ static int shaderfx_move_down_exec(bContext *C, wmOperator *op)
static int shaderfx_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_shaderfx_invoke_properties(C, op))
+ if (edit_shaderfx_invoke_properties(C, op)) {
return shaderfx_move_down_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_shaderfx_move_down(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index aa0c6cbeef4..fb76ba6099d 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -110,8 +110,9 @@ static bool object_shape_key_mirror(
*r_totmirr = *r_totfail = 0;
key = BKE_key_from_object(ob);
- if (key == NULL)
+ if (key == NULL) {
return 0;
+ }
kb = BLI_findlink(&key->block, ob->shapenr - 1);
@@ -335,11 +336,13 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
Key *key = BKE_key_from_object(ob);
KeyBlock *kb = BKE_keyblock_from_object(ob);
- if (!key || !kb)
+ if (!key || !kb) {
return OPERATOR_CANCELLED;
+ }
- for (kb = key->block.first; kb; kb = kb->next)
+ for (kb = key->block.first; kb; kb = kb->next) {
kb->curval = 0.0f;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -370,8 +373,9 @@ static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op))
KeyBlock *kb = BKE_keyblock_from_object(ob);
float cfra = 0.0f;
- if (!key || !kb)
+ if (!key || !kb) {
return OPERATOR_CANCELLED;
+ }
for (kb = key->block.first; kb; kb = kb->next) {
kb->pos = cfra;
@@ -405,8 +409,9 @@ static int shape_key_mirror_exec(bContext *C, wmOperator *op)
int totmirr = 0, totfail = 0;
bool use_topology = RNA_boolean_get(op->ptr, "use_topology");
- if (!object_shape_key_mirror(C, ob, &totmirr, &totfail, use_topology))
+ if (!object_shape_key_mirror(C, ob, &totmirr, &totfail, use_topology)) {
return OPERATOR_CANCELLED;
+ }
ED_mesh_report_mirror(op, totmirr, totfail);
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index f2f6afcac81..8836d913475 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -82,18 +82,21 @@ static void object_clear_loc(Object *ob, const bool clear_delta)
/* clear location if not locked */
if ((ob->protectflag & OB_LOCK_LOCX) == 0) {
ob->loc[0] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dloc[0] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_LOCY) == 0) {
ob->loc[1] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dloc[1] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_LOCZ) == 0) {
ob->loc[2] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dloc[2] = 0.0f;
+ }
}
}
@@ -107,52 +110,63 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
if (ob->rotmode == ROT_MODE_AXISANGLE) {
if ((ob->protectflag & OB_LOCK_ROTW) == 0) {
ob->rotAngle = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drotAngle = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTX) == 0) {
ob->rotAxis[0] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drotAxis[0] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTY) == 0) {
ob->rotAxis[1] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drotAxis[1] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTZ) == 0) {
ob->rotAxis[2] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drotAxis[2] = 0.0f;
+ }
}
- /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
- if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2]))
+ /* Check validity of axis - axis should never be 0,0,0
+ * (if so, then we make it rotate about y). */
+ if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2])) {
ob->rotAxis[1] = 1.0f;
+ }
if (IS_EQF(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQF(ob->drotAxis[1], ob->drotAxis[2]) &&
- clear_delta)
+ clear_delta) {
ob->drotAxis[1] = 1.0f;
+ }
}
else if (ob->rotmode == ROT_MODE_QUAT) {
if ((ob->protectflag & OB_LOCK_ROTW) == 0) {
ob->quat[0] = 1.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dquat[0] = 1.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTX) == 0) {
ob->quat[1] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dquat[1] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTY) == 0) {
ob->quat[2] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dquat[2] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTZ) == 0) {
ob->quat[3] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dquat[3] = 0.0f;
+ }
}
/* TODO: does this quat need normalizing now? */
}
@@ -160,18 +174,21 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
/* the flag may have been set for the other modes, so just ignore the extra flag... */
if ((ob->protectflag & OB_LOCK_ROTX) == 0) {
ob->rot[0] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drot[0] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTY) == 0) {
ob->rot[1] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drot[1] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTZ) == 0) {
ob->rot[2] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drot[2] = 0.0f;
+ }
}
}
}
@@ -193,12 +210,15 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
eul[0] = eul[1] = eul[2] = 0.0f;
- if (ob->protectflag & OB_LOCK_ROTX)
+ if (ob->protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (ob->protectflag & OB_LOCK_ROTY)
+ }
+ if (ob->protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (ob->protectflag & OB_LOCK_ROTZ)
+ }
+ if (ob->protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
if (ob->rotmode == ROT_MODE_QUAT) {
eul_to_quat(ob->quat, eul);
@@ -218,18 +238,21 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
else {
if (ob->rotmode == ROT_MODE_QUAT) {
unit_qt(ob->quat);
- if (clear_delta)
+ if (clear_delta) {
unit_qt(ob->dquat);
+ }
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
unit_axis_angle(ob->rotAxis, &ob->rotAngle);
- if (clear_delta)
+ if (clear_delta) {
unit_axis_angle(ob->drotAxis, &ob->drotAngle);
+ }
}
else {
zero_v3(ob->rot);
- if (clear_delta)
+ if (clear_delta) {
zero_v3(ob->drot);
+ }
}
}
}
@@ -240,18 +263,21 @@ static void object_clear_scale(Object *ob, const bool clear_delta)
/* clear scale factors which are not locked */
if ((ob->protectflag & OB_LOCK_SCALEX) == 0) {
ob->scale[0] = 1.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dscale[0] = 1.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_SCALEY) == 0) {
ob->scale[1] = 1.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dscale[1] = 1.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_SCALEZ) == 0) {
ob->scale[2] = 1.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dscale[2] = 1.0f;
+ }
}
}
@@ -584,8 +610,9 @@ static int apply_objects_internal(bContext *C,
}
CTX_DATA_END;
- if (!changed)
+ if (!changed) {
return OPERATOR_CANCELLED;
+ }
changed = false;
@@ -593,10 +620,12 @@ static int apply_objects_internal(bContext *C,
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
/* calculate rotation/scale matrix */
- if (apply_scale && apply_rot)
+ if (apply_scale && apply_rot) {
BKE_object_to_mat3(ob, rsmat);
- else if (apply_scale)
+ }
+ else if (apply_scale) {
BKE_object_scale_to_mat3(ob, rsmat);
+ }
else if (apply_rot) {
float tmat[3][3], timat[3][3];
@@ -609,8 +638,9 @@ static int apply_objects_internal(bContext *C,
mul_m3_m3m3(rsmat, timat, rsmat);
mul_m3_m3m3(rsmat, rsmat, tmat);
}
- else
+ else {
unit_m3(rsmat);
+ }
copy_m4_m3(mat, rsmat);
@@ -632,8 +662,9 @@ static int apply_objects_internal(bContext *C,
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
- if (apply_scale)
+ if (apply_scale) {
multiresModifier_scale_disp(depsgraph, scene, ob);
+ }
/* adjust data */
BKE_mesh_transform(me, mat, true);
@@ -686,11 +717,13 @@ static int apply_objects_internal(bContext *C,
/* applying scale on camera actually scales clip's reconstruction.
* of there's clip assigned to camera nothing to do actually.
*/
- if (!clip)
+ if (!clip) {
continue;
+ }
- if (apply_scale)
+ if (apply_scale) {
BKE_tracking_reconstruction_scale(&clip->tracking, ob->scale);
+ }
}
else if (ob->type == OB_EMPTY) {
/* It's possible for empties too, even though they don't
@@ -734,10 +767,12 @@ static int apply_objects_internal(bContext *C,
continue;
}
- if (apply_loc)
+ if (apply_loc) {
zero_v3(ob->loc);
- if (apply_scale)
+ }
+ if (apply_scale) {
ob->scale[0] = ob->scale[1] = ob->scale[2] = 1.0f;
+ }
if (apply_rot) {
zero_v3(ob->rot);
unit_qt(ob->quat);
@@ -784,8 +819,9 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
}
CTX_DATA_END;
- if (!changed)
+ if (!changed) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
@@ -958,10 +994,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
for (tob = bmain->objects.first; tob; tob = tob->id.next) {
- if (tob->data)
+ if (tob->data) {
((ID *)tob->data)->tag &= ~LIB_TAG_DOIT;
- if (tob->instance_collection)
+ }
+ if (tob->instance_collection) {
((ID *)tob->instance_collection)->tag &= ~LIB_TAG_DOIT;
+ }
}
for (ctx_ob = ctx_data_list.first; ctx_ob; ctx_ob = ctx_ob->next) {
@@ -1049,8 +1087,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
/* don't allow Z change if curve is 2D */
- if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D))
+ if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) {
cent[2] = 0.0;
+ }
negate_v3_v3(cent_neg, cent);
BKE_curve_translate(cu, cent_neg, 1);
@@ -1119,8 +1158,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ignore_parent_tx(C, bmain, scene, ob);
- if (obedit)
+ if (obedit) {
break;
+ }
}
}
else if (ob->type == OB_MBALL) {
@@ -1206,8 +1246,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
float mpt[3];
@@ -1257,7 +1298,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ignore_parent_tx(C, bmain, scene, ob);
/* other users? */
- //CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects)
+ // CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects)
//{
/* use existing context looper */
@@ -1283,7 +1324,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ignore_parent_tx(C, bmain, scene, ob_other);
}
}
- //CTX_DATA_END;
+ // CTX_DATA_END;
}
}
}
@@ -1307,11 +1348,13 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
"%i object(s) not centered, %i changed:",
tot_lib_error + tot_multiuser_arm_error,
tot_change);
- if (tot_lib_error)
+ if (tot_lib_error) {
BKE_reportf(op->reports, RPT_WARNING, "|%i linked library object(s)", tot_lib_error);
- if (tot_multiuser_arm_error)
+ }
+ if (tot_multiuser_arm_error) {
BKE_reportf(
op->reports, RPT_WARNING, "|%i multiuser armature object(s)", tot_multiuser_arm_error);
+ }
}
return OPERATOR_FINISHED;
@@ -1385,11 +1428,12 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
* - campbell.
* \{ */
-/* When using multiple objects, apply their relative rotational offset to the active object. */
+/** When using multiple objects, apply their relative rotational offset to the active object. */
#define USE_RELATIVE_ROTATION
-/* Disable overlays, ignoring user setting (light wire gets in the way). */
+/** Disable overlays, ignoring user setting (light wire gets in the way). */
#define USE_RENDER_OVERRIDE
-/* Calculate a depth if the cursor isn't already over a depth (not essential but feels buggy without). */
+/** Calculate a depth if the cursor isn't already over a depth
+ * (not essential but feels buggy without). */
#define USE_FAKE_DEPTH_INIT
struct XFormAxisItem {
diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.c
index 06a755c30bd..dbca0bbf97b 100644
--- a/source/blender/editors/object/object_utils.c
+++ b/source/blender/editors/object/object_utils.c
@@ -133,7 +133,7 @@ bool ED_object_calc_active_center(Object *ob, const bool select_only, float r_ce
return false;
}
else {
- if (!select_only || (ob->flag & SELECT)) {
+ if (!select_only || (ob->base_flag & BASE_SELECTED)) {
copy_v3_v3(r_center, ob->obmat[3]);
return true;
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 9af0b64bde2..05a3d86a23c 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -58,6 +58,7 @@
#include "BKE_lattice.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
#include "DNA_armature_types.h"
#include "RNA_access.h"
@@ -245,7 +246,8 @@ bool ED_vgroup_parray_alloc(ID *id,
* For use with tools that use ED_vgroup_parray_alloc with \a use_vert_sel == true.
* This finds the unselected mirror deform verts and copies the weights to them from the selected.
*
- * \note \a dvert_array has mirrored weights filled in, in case cleanup operations are needed on both.
+ * \note \a dvert_array has mirrored weights filled in,
+ * in case cleanup operations are needed on both.
*/
void ED_vgroup_parray_mirror_sync(Object *ob,
MDeformVert **dvert_array,
@@ -348,8 +350,9 @@ void ED_vgroup_parray_remove_zero(MDeformVert **dvert_array,
while (j--) {
MDeformWeight *dw;
- if (keep_single && dv->totweight == 1)
+ if (keep_single && dv->totweight == 1) {
break;
+ }
dw = dv->dw + j;
if ((dw->def_nr < vgroup_tot) && vgroup_validmap[dw->def_nr]) {
@@ -373,10 +376,12 @@ bool ED_vgroup_array_copy(Object *ob, Object *ob_from)
int defbase_tot = BLI_listbase_count(&ob->defbase);
bool new_vgroup = false;
- if (ob == ob_from)
+ if (ob == ob_from) {
return true;
+ }
- /* in case we copy vgroup between two objects using same data, we only have to care about object side of things. */
+ /* In case we copy vgroup between two objects using same data,
+ * we only have to care about object side of things. */
if (ob->data != ob_from->data) {
ED_vgroup_parray_alloc(ob_from->data, &dvert_array_from, &dvert_tot_from, false);
ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, false);
@@ -389,10 +394,12 @@ bool ED_vgroup_array_copy(Object *ob, Object *ob_from)
if (dvert_tot == 0 || (dvert_tot != dvert_tot_from) || dvert_array_from == NULL ||
dvert_array == NULL) {
- if (dvert_array)
+ if (dvert_array) {
MEM_freeN(dvert_array);
- if (dvert_array_from)
+ }
+ if (dvert_array_from) {
MEM_freeN(dvert_array_from);
+ }
if (new_vgroup == true) {
/* free the newly added vgroup since it wasn't compatible */
@@ -412,10 +419,12 @@ bool ED_vgroup_array_copy(Object *ob, Object *ob_from)
if (defbase_tot_from < defbase_tot) {
/* correct vgroup indices because the number of vgroups is being reduced. */
int *remap = MEM_mallocN(sizeof(int) * (defbase_tot + 1), __func__);
- for (i = 0; i <= defbase_tot_from; i++)
+ for (i = 0; i <= defbase_tot_from; i++) {
remap[i] = i;
- for (; i <= defbase_tot; i++)
+ }
+ for (; i <= defbase_tot; i++) {
remap[i] = 0; /* can't use these, so disable */
+ }
BKE_object_defgroup_remap_update_users(ob, remap);
MEM_freeN(remap);
@@ -530,8 +539,9 @@ static void ED_mesh_defvert_mirror_update_ob(Object *ob, int def_nr, int vidx)
Mesh *me = ob->data;
bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
- if (vidx == -1)
+ if (vidx == -1) {
return;
+ }
vidx_mirr = mesh_get_x_mirror_vert(ob, NULL, vidx, use_topology);
@@ -702,20 +712,24 @@ const EnumPropertyItem *ED_object_vgroup_selection_itemf_helper(const bContext *
}
ob = CTX_data_active_object(C);
- if (selection_mask & (1 << WT_VGROUP_ACTIVE))
+ if (selection_mask & (1 << WT_VGROUP_ACTIVE)) {
RNA_enum_items_add_value(&item, &totitem, WT_vertex_group_select_item, WT_VGROUP_ACTIVE);
+ }
if (BKE_object_pose_armature_get(ob)) {
- if (selection_mask & (1 << WT_VGROUP_BONE_SELECT))
+ if (selection_mask & (1 << WT_VGROUP_BONE_SELECT)) {
RNA_enum_items_add_value(
&item, &totitem, WT_vertex_group_select_item, WT_VGROUP_BONE_SELECT);
- if (selection_mask & (1 << WT_VGROUP_BONE_DEFORM))
+ }
+ if (selection_mask & (1 << WT_VGROUP_BONE_DEFORM)) {
RNA_enum_items_add_value(
&item, &totitem, WT_vertex_group_select_item, WT_VGROUP_BONE_DEFORM);
+ }
}
- if (selection_mask & (1 << WT_VGROUP_ALL))
+ if (selection_mask & (1 << WT_VGROUP_ALL)) {
RNA_enum_items_add_value(&item, &totitem, WT_vertex_group_select_item, WT_VGROUP_ALL);
+ }
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -777,12 +791,14 @@ static void ED_vgroup_nr_vert_add(
/* get the vert */
BKE_object_defgroup_array_get(ob->data, &dvert, &tot);
- if (dvert == NULL)
+ if (dvert == NULL) {
return;
+ }
/* check that vertnum is valid before trying to get the relevant dvert */
- if ((vertnum < 0) || (vertnum >= tot))
+ if ((vertnum < 0) || (vertnum >= tot)) {
return;
+ }
if (dvert) {
MDeformVert *dv = &dvert[vertnum];
@@ -802,8 +818,9 @@ static void ED_vgroup_nr_vert_add(
break;
case WEIGHT_ADD:
dw->weight += weight;
- if (dw->weight >= 1.0f)
+ if (dw->weight >= 1.0f) {
dw->weight = 1.0f;
+ }
break;
case WEIGHT_SUBTRACT:
dw->weight -= weight;
@@ -860,8 +877,9 @@ void ED_vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight,
/* if there's no deform verts then create some,
*/
- if (BKE_object_defgroup_array_get(ob->data, &dv, &tot) && dv == NULL)
+ if (BKE_object_defgroup_array_get(ob->data, &dv, &tot) && dv == NULL) {
BKE_object_defgroup_data_create(ob->data);
+ }
/* call another function to do the work
*/
@@ -876,7 +894,8 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum)
* deform group.
*/
- /* TODO, this is slow in a loop, better pass def_nr directly, but leave for later... - campbell */
+ /* TODO(campbell): This is slow in a loop, better pass def_nr directly,
+ * but leave for later. */
const int def_nr = BLI_findindex(&ob->defbase, dg);
if (def_nr != -1) {
@@ -965,7 +984,7 @@ float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum)
void ED_vgroup_select_by_name(Object *ob, const char *name)
{
/* note: ob->actdef==0 signals on painting to create a new one,
- * if a bone in posemode is selected */
+ * if a bone in posemode is selected */
ob->actdef = defgroup_name_index(ob, name) + 1;
}
@@ -1001,10 +1020,12 @@ static void vgroup_select_verts(Object *ob, int select)
}
/* this has to be called, because this function operates on vertices only */
- if (select)
+ if (select) {
EDBM_select_flush(em); /* vertices to edges/faces */
- else
+ }
+ else {
EDBM_deselect_flush(em);
+ }
}
}
else {
@@ -1019,10 +1040,12 @@ static void vgroup_select_verts(Object *ob, int select)
for (i = 0; i < me->totvert; i++, mv++, dv++) {
if (!(mv->flag & ME_HIDE)) {
if (defvert_find_index(dv, def_nr)) {
- if (select)
+ if (select) {
mv->flag |= SELECT;
- else
+ }
+ else {
mv->flag &= ~SELECT;
+ }
}
}
}
@@ -1044,12 +1067,14 @@ static void vgroup_select_verts(Object *ob, int select)
tot = lt->pntsu * lt->pntsv * lt->pntsw;
for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) {
if (defvert_find_index(dv, def_nr)) {
- if (select)
+ if (select) {
bp->f1 |= SELECT;
+ }
else {
bp->f1 &= ~SELECT;
- if (actbp && bp == actbp)
+ if (actbp && bp == actbp) {
lt->actbp = LT_ACTBP_NONE;
+ }
}
}
}
@@ -1066,8 +1091,9 @@ static void vgroup_duplicate(Object *ob)
int i, idg, icdg, dvert_tot = 0;
dg = BLI_findlink(&ob->defbase, (ob->actdef - 1));
- if (!dg)
+ if (!dg) {
return;
+ }
if (!strstr(dg->name, "_copy")) {
BLI_snprintf(name, sizeof(name), "%s_copy", dg->name);
@@ -1204,15 +1230,19 @@ static int *getSurroundingVerts(Mesh *me, int vert, int *count)
k = BLI_array_len(verts);
/* XXX Maybe a == b is enough? */
while (k-- && !(a == b && a == -1)) {
- if (verts[k] == a)
+ if (verts[k] == a) {
a = -1;
- else if (verts[k] == b)
+ }
+ else if (verts[k] == b) {
b = -1;
+ }
}
- if (a != -1)
+ if (a != -1) {
BLI_array_append(verts, a);
- if (b != -1)
+ }
+ if (b != -1) {
BLI_array_append(verts, b);
+ }
/* Vert found in this poly, we can go to next one! */
break;
@@ -1227,8 +1257,9 @@ static int *getSurroundingVerts(Mesh *me, int vert, int *count)
return verts;
}
-/* get a single point in space by averaging a point cloud (vectors of size 3)
- * coord is the place the average is stored, points is the point cloud, count is the number of points in the cloud
+/* Get a single point in space by averaging a point cloud (vectors of size 3)
+ * coord is the place the average is stored,
+ * points is the point cloud, count is the number of points in the cloud.
*/
static void getSingleCoordinate(MVert *points, int count, float coord[3])
{
@@ -1268,7 +1299,7 @@ static void getVerticalAndHorizontalChange(const float norm[3],
dists[index] = dot_v3v3(norm, end) + d;
/* vertical change */
changes[index][0] = dists[index] - distToStart;
- //printf("vc %f %f\n", distance(end, projB, 3) - distance(start, projA, 3), changes[index][0]);
+ // printf("vc %f %f\n", distance(end, projB, 3) - distance(start, projA, 3), changes[index][0]);
/* horizontal change */
changes[index][1] = len_v3v3(projA, projB);
}
@@ -1480,8 +1511,9 @@ static void vgroup_fix(
Mesh *me = ob->data;
MVert *mvert = me->mvert;
int *verts = NULL;
- if (!(me->editflag & ME_EDIT_PAINT_VERT_SEL))
+ if (!(me->editflag & ME_EDIT_PAINT_VERT_SEL)) {
return;
+ }
for (i = 0; i < me->totvert && mvert; i++, mvert++) {
if (mvert->flag & SELECT) {
int count = 0;
@@ -1953,15 +1985,17 @@ static void vgroup_smooth_subset(Object *ob,
MEM_freeN(emap_mem);
}
- if (dvert_array)
+ if (dvert_array) {
MEM_freeN(dvert_array);
+ }
/* not so efficient to get 'dvert_array' again just so unselected verts are NULL'd */
if (use_mirror) {
ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, true);
ED_vgroup_parray_mirror_sync(ob, dvert_array, dvert_tot, vgroup_validmap, vgroup_tot);
- if (dvert_array)
+ if (dvert_array) {
MEM_freeN(dvert_array);
+ }
}
}
@@ -1975,14 +2009,18 @@ static int inv_cmp_mdef_vert_weights(const void *a1, const void *a2)
* This does the opposite. */
const struct MDeformWeight *dw1 = a1, *dw2 = a2;
- if (dw1->weight < dw2->weight)
+ if (dw1->weight < dw2->weight) {
return 1;
- else if (dw1->weight > dw2->weight)
+ }
+ else if (dw1->weight > dw2->weight) {
return -1;
- else if (&dw1 < &dw2)
+ }
+ else if (&dw1 < &dw2) {
return 1; /* compare address for stable sort algorithm */
- else
+ }
+ else {
return -1;
+ }
}
/* Used for limiting the number of influencing bones per vertex when exporting
@@ -2407,8 +2445,9 @@ cleanup:
*r_totmirr = totmirr;
*r_totfail = totfail;
- if (flip_map)
+ if (flip_map) {
MEM_freeN(flip_map);
+ }
#undef VGROUP_MIRR_OP
}
@@ -2416,8 +2455,9 @@ cleanup:
static void vgroup_delete_active(Object *ob)
{
bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef - 1);
- if (!dg)
+ if (!dg) {
return;
+ }
BKE_object_defgroup_remove(ob, dg);
}
@@ -2427,8 +2467,9 @@ static void vgroup_assign_verts(Object *ob, const float weight)
{
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
@@ -2440,8 +2481,9 @@ static void vgroup_assign_verts(Object *ob, const float weight)
BMIter iter;
BMVert *eve;
- if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT))
+ if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
BM_data_layer_add(em->bm, &em->bm->vdata, CD_MDEFORMVERT);
+ }
cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
@@ -2487,8 +2529,9 @@ static void vgroup_assign_verts(Object *ob, const float weight)
BPoint *bp;
int a, tot;
- if (lt->dvert == NULL)
+ if (lt->dvert == NULL) {
BKE_object_defgroup_data_create(&lt->id);
+ }
dv = lt->dvert;
@@ -2546,8 +2589,9 @@ static bool UNUSED_FUNCTION(vertex_group_poll_edit)(bContext *C)
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
- if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
+ if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data))) {
return 0;
+ }
return BKE_object_is_in_editmode_vgroup(ob);
}
@@ -2560,8 +2604,9 @@ static bool vertex_group_vert_poll_ex(bContext *C,
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
- if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
+ if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data))) {
return false;
+ }
if (ob_type_flag && (((1 << ob->type) & ob_type_flag)) == 0) {
return false;
@@ -2619,8 +2664,9 @@ static bool vertex_group_vert_select_unlocked_poll(bContext *C)
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
- if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
+ if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data))) {
return 0;
+ }
if (!(BKE_object_is_in_editmode_vgroup(ob) || BKE_object_is_in_wpaint_select_vert(ob))) {
return 0;
@@ -2640,12 +2686,14 @@ static bool vertex_group_vert_select_mesh_poll(bContext *C)
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
- if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
+ if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data))) {
return 0;
+ }
/* only difference to #vertex_group_vert_select_poll */
- if (ob->type != OB_MESH)
+ if (ob->type != OB_MESH) {
return 0;
+ }
return (BKE_object_is_in_editmode_vgroup(ob) || BKE_object_is_in_wpaint_select_vert(ob));
}
@@ -2655,6 +2703,7 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
BKE_object_defgroup_add(ob);
+ DEG_relations_tag_update(CTX_data_main(C));
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -2681,14 +2730,18 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
- if (RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all")) {
BKE_object_defgroup_remove_all(ob);
- else if (RNA_boolean_get(op->ptr, "all_unlocked"))
+ }
+ else if (RNA_boolean_get(op->ptr, "all_unlocked")) {
BKE_object_defgroup_remove_all_ex(ob, true);
- else
+ }
+ else {
vgroup_delete_active(ob);
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -2834,8 +2887,9 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return OPERATOR_CANCELLED;
+ }
vgroup_select_verts(ob, 1);
DEG_id_tag_update(ob->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
@@ -2891,6 +2945,7 @@ static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op))
vgroup_duplicate(ob);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
@@ -3421,6 +3476,7 @@ static int vertex_group_mirror_exec(bContext *C, wmOperator *op)
ED_mesh_report_mirror(op, totmirr, totfail);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
@@ -3509,6 +3565,7 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
if (obact != ob) {
if (ED_vgroup_array_copy(ob, obact)) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
changed_tot++;
}
@@ -3571,8 +3628,9 @@ static const EnumPropertyItem *vgroup_itemf(bContext *C,
bDeformGroup *def;
int a, totitem = 0;
- if (!ob)
+ if (!ob) {
return DummyRNA_NULL_items;
+ }
for (a = 0, def = ob->defbase.first; def; def = def->next, a++) {
tmp.value = a;
@@ -3683,16 +3741,18 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
/*create as necessary*/
if (dvert) {
while (dvert_tot--) {
- if (dvert->totweight)
+ if (dvert->totweight) {
defvert_remap(dvert, sort_map, defbase_tot);
+ }
dvert++;
}
}
}
/* update users */
- for (i = 0; i < defbase_tot; i++)
+ for (i = 0; i < defbase_tot; i++) {
sort_map[i]++;
+ }
sort_map_update[0] = 0;
BKE_object_defgroup_remap_update_users(ob, sort_map_update);
@@ -3776,8 +3836,9 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
}
- if (name_array)
+ if (name_array) {
MEM_freeN(name_array);
+ }
return ret;
}
@@ -3828,8 +3889,9 @@ static int vgroup_move_exec(bContext *C, wmOperator *op)
}
}
- if (name_array)
+ if (name_array) {
MEM_freeN(name_array);
+ }
return ret;
}
diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt
index 3eb443320c3..021c17a94c2 100644
--- a/source/blender/editors/physics/CMakeLists.txt
+++ b/source/blender/editors/physics/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index e0ea53b06ec..cb8fe262730 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -72,19 +72,19 @@ static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
- if (!pmd || !pmd->canvas)
+ if (!pmd || !pmd->canvas) {
return OPERATOR_CANCELLED;
+ }
canvas = pmd->canvas;
surface = dynamicPaint_createNewSurface(canvas, CTX_data_scene(C));
- if (!surface)
+ if (!surface) {
return OPERATOR_CANCELLED;
+ }
- /* set preview for this surface only and set active */
canvas->active_sur = 0;
for (surface = surface->prev; surface; surface = surface->prev) {
- surface->flags &= ~MOD_DPAINT_PREVIEW;
canvas->active_sur++;
}
@@ -117,8 +117,9 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(obj_ctx, eModifierType_DynamicPaint);
- if (!pmd || !pmd->canvas)
+ if (!pmd || !pmd->canvas) {
return OPERATOR_CANCELLED;
+ }
canvas = pmd->canvas;
surface = canvas->surfaces.first;
@@ -133,7 +134,6 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
id++;
}
- dynamicPaint_resetPreview(canvas);
DEG_id_tag_update(&obj_ctx->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obj_ctx);
@@ -165,8 +165,9 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
cObject, eModifierType_DynamicPaint);
int type = RNA_enum_get(op->ptr, "type");
- if (!pmd)
+ if (!pmd) {
return OPERATOR_CANCELLED;
+ }
/* if type is already enabled, toggle it off */
if (type == MOD_DYNAMICPAINT_TYPE_CANVAS && pmd->canvas) {
@@ -177,8 +178,9 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
}
/* else create a new type */
else {
- if (!dynamicPaint_createType(pmd, type, scene))
+ if (!dynamicPaint_createType(pmd, type, scene)) {
return OPERATOR_CANCELLED;
+ }
}
/* update dependency */
@@ -223,8 +225,9 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
ob, eModifierType_DynamicPaint);
int output = RNA_enum_get(op->ptr, "output"); /* currently only 1/0 */
- if (!pmd || !pmd->canvas)
+ if (!pmd || !pmd->canvas) {
return OPERATOR_CANCELLED;
+ }
surface = get_activeSurface(pmd->canvas);
/* if type is already enabled, toggle it off */
@@ -232,27 +235,34 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
int exists = dynamicPaint_outputLayerExists(surface, ob, output);
const char *name;
- if (output == 0)
+ if (output == 0) {
name = surface->output_name;
- else
+ }
+ else {
name = surface->output_name2;
+ }
/* Vertex Color Layer */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
- if (!exists)
+ if (!exists) {
ED_mesh_color_add(ob->data, name, true, true);
- else
+ }
+ else {
ED_mesh_color_remove_named(ob->data, name);
+ }
}
/* Vertex Weight Layer */
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
if (!exists) {
BKE_object_defgroup_add_name(ob, name);
+ DEG_relations_tag_update(CTX_data_main(C));
}
else {
bDeformGroup *defgroup = defgroup_find_name(ob, name);
- if (defgroup)
+ if (defgroup) {
BKE_object_defgroup_remove(ob, defgroup);
+ DEG_relations_tag_update(CTX_data_main(C));
+ }
}
}
}
diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c
index cedb7d6cbc1..55fc49165c9 100644
--- a/source/blender/editors/physics/particle_boids.c
+++ b/source/blender/editors/physics/particle_boids.c
@@ -57,13 +57,15 @@ static int rule_add_exec(bContext *C, wmOperator *op)
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
- for (rule = state->rules.first; rule; rule = rule->next)
+ for (rule = state->rules.first; rule; rule = rule->next) {
rule->flag &= ~BOIDRULE_CURRENT;
+ }
rule = boid_new_rule(type);
rule->flag |= BOIDRULE_CURRENT;
@@ -99,8 +101,9 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
@@ -113,8 +116,9 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
}
rule = state->rules.first;
- if (rule)
+ if (rule) {
rule->flag |= BOIDRULE_CURRENT;
+ }
DEG_relations_tag_update(bmain);
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
@@ -144,8 +148,9 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
@@ -180,8 +185,9 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
@@ -216,11 +222,13 @@ static int state_add_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part = ptr.data;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
- for (state = part->boids->states.first; state; state = state->next)
+ for (state = part->boids->states.first; state; state = state->next) {
state->flag &= ~BOIDSTATE_CURRENT;
+ }
state = boid_new_state(part->boids);
state->flag |= BOIDSTATE_CURRENT;
@@ -250,8 +258,9 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part = ptr.data;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
for (state = part->boids->states.first; state; state = state->next) {
if (state->flag & BOIDSTATE_CURRENT) {
@@ -266,8 +275,9 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
state = boid_new_state(part->boids);
BLI_addtail(&part->boids->states, state);
}
- else
+ else {
state = part->boids->states.first;
+ }
state->flag |= BOIDSTATE_CURRENT;
@@ -299,8 +309,9 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
BoidSettings *boids;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
boids = part->boids;
@@ -334,8 +345,9 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
BoidSettings *boids;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
boids = part->boids;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 627ffd68bbb..dc634865a0a 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -129,21 +129,24 @@ void PE_free_ptcache_edit(PTCacheEdit *edit)
{
POINT_P;
- if (edit == 0)
+ if (edit == 0) {
return;
+ }
if (edit->points) {
LOOP_POINTS
{
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
}
MEM_freeN(edit->points);
}
- if (edit->mirror_cache)
+ if (edit->mirror_cache) {
MEM_freeN(edit->mirror_cache);
+ }
if (edit->emitter_cosnos) {
MEM_freeN(edit->emitter_cosnos);
@@ -168,8 +171,9 @@ int PE_start_edit(PTCacheEdit *edit)
{
if (edit) {
edit->edited = 1;
- if (edit->psys)
+ if (edit->psys) {
edit->psys->flag |= PSYS_EDITED;
+ }
return 1;
}
@@ -242,8 +246,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
ListBase pidlist;
PTCacheID *pid;
- if (pset == NULL || ob == NULL)
+ if (pset == NULL || ob == NULL) {
return NULL;
+ }
pset->scene = scene;
pset->object = ob;
@@ -273,8 +278,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
if (psys->flag & PSYS_CURRENT) {
if (psys->part && psys->part->type == PART_HAIR) {
if (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) {
- if (create && !psys->pointcache->edit)
+ if (create && !psys->pointcache->edit) {
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
+ }
edit = pid->cache->edit;
}
else {
@@ -287,8 +293,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
}
}
else {
- if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
+ if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, psys);
+ }
edit = pid->cache->edit;
}
@@ -359,11 +366,12 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
{
LOOP_KEYS
{
- if (fabsf(cfra - *key->time) < pset->fade_frames)
+ if (fabsf(cfra - *key->time) < pset->fade_frames) {
key->flag &= ~PEK_HIDE;
+ }
else {
key->flag |= PEK_HIDE;
- //key->flag &= ~PEK_SELECT;
+ // key->flag &= ~PEK_SELECT;
}
}
}
@@ -381,8 +389,9 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
static int pe_x_mirror(Object *ob)
{
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X);
+ }
return 0;
}
@@ -505,14 +514,17 @@ static bool key_test_depth(const PEData *data, const float co[3], const int scre
float depth;
/* nothing to do */
- if (XRAY_ENABLED(v3d))
+ if (XRAY_ENABLED(v3d)) {
return true;
+ }
- /* used to calculate here but all callers have the screen_co already, so pass as arg */
+ /* used to calculate here but all callers have the screen_co already, so pass as arg */
#if 0
- if (ED_view3d_project_int_global(data->vc.ar, co, screen_co,
- V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK)
- {
+ if (ED_view3d_project_int_global(data->vc.ar,
+ co,
+ screen_co,
+ V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN |
+ V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK) {
return 0;
}
#endif
@@ -523,16 +535,19 @@ static bool key_test_depth(const PEData *data, const float co[3], const int scre
/* we know its not clipped */
depth = vd->depths[screen_co[1] * vd->w + screen_co[0]];
}
- else
+ else {
return 0;
+ }
float win[3];
ED_view3d_project(data->vc.ar, co, win);
- if (win[2] - 0.00001f > depth)
+ if (win[2] - 0.00001f > depth) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
static bool key_inside_circle(const PEData *data, float rad, const float co[3], float *distance)
@@ -550,12 +565,14 @@ static bool key_inside_circle(const PEData *data, float rad, const float co[3],
dy = data->mval[1] - screen_co[1];
dist = sqrtf(dx * dx + dy * dy);
- if (dist > rad)
+ if (dist > rad) {
return 0;
+ }
if (key_test_depth(data, co, screen_co)) {
- if (distance)
+ if (distance) {
*distance = dist;
+ }
return 1;
}
@@ -582,18 +599,21 @@ static bool key_inside_rect(PEData *data, const float co[3])
static bool key_inside_test(PEData *data, const float co[3])
{
- if (data->mval)
+ if (data->mval) {
return key_inside_circle(data, data->rad, co, NULL);
- else
+ }
+ else {
return key_inside_rect(data, co);
+ }
}
static bool point_is_selected(PTCacheEditPoint *point)
{
KEY_K;
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
return 0;
+ }
LOOP_SELECTED_KEYS
{
@@ -639,8 +659,9 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, const enum ePartic
float dist = data->rad;
/* in path select mode we have no keys */
- if (pset->selectmode == SCE_SELECT_PATH)
+ if (pset->selectmode == SCE_SELECT_PATH) {
return;
+ }
nearest_point = -1;
nearest_key = -1;
@@ -702,8 +723,9 @@ static void foreach_mouse_hit_point(PEData *data, ForHitPointFunc func, int sele
KEY_K;
/* all is selected in path mode */
- if (pset->selectmode == SCE_SELECT_PATH)
+ if (pset->selectmode == SCE_SELECT_PATH) {
selected = 0;
+ }
LOOP_VISIBLE_POINTS
{
@@ -876,8 +898,9 @@ static int count_selected_keys(Scene *scene, PTCacheEdit *edit)
else if (pset->selectmode == SCE_SELECT_END) {
if (point->totkey) {
key = point->keys + point->totkey - 1;
- if (key->flag & PEK_SELECT)
+ if (key->flag & PEK_SELECT) {
sel++;
+ }
}
}
}
@@ -904,8 +927,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
psmd_eval = edit->psmd_eval;
totpart = psys->totpart;
- if (!psmd_eval->mesh_final)
+ if (!psmd_eval->mesh_final) {
return;
+ }
tree = BLI_kdtree_3d_new(totpart);
@@ -922,8 +946,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
BLI_kdtree_3d_balance(tree);
/* lookup particles and set in mirror cache */
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
edit->mirror_cache = MEM_callocN(sizeof(int) * totpart, "PE mirror cache");
+ }
LOOP_PARTICLES
{
@@ -936,10 +961,12 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
index = BLI_kdtree_3d_find_nearest(tree, co, &nearest);
/* this needs a custom threshold still, duplicated for editmode mirror */
- if (index != -1 && index != p && (nearest.dist <= 0.0002f))
+ if (index != -1 && index != p && (nearest.dist <= 0.0002f)) {
edit->mirror_cache[p] = index;
- else
+ }
+ else {
edit->mirror_cache[p] = -1;
+ }
}
/* make sure mirrors are in two directions */
@@ -947,8 +974,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
{
if (edit->mirror_cache[p]) {
index = edit->mirror_cache[p];
- if (edit->mirror_cache[index] != p)
+ if (edit->mirror_cache[index] != p) {
edit->mirror_cache[p] = -1;
+ }
}
}
@@ -970,29 +998,35 @@ static void PE_mirror_particle(
/* find mirrored particle if needed */
if (!mpa) {
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
+ }
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
return; /* something went wrong! */
+ }
mi = edit->mirror_cache[i];
- if (mi == -1)
+ if (mi == -1) {
return;
+ }
mpa = psys->particles + mi;
}
- else
+ else {
mi = mpa - psys->particles;
+ }
point = edit->points + i;
mpoint = edit->points + mi;
/* make sure they have the same amount of keys */
if (pa->totkey != mpa->totkey) {
- if (mpa->hair)
+ if (mpa->hair) {
MEM_freeN(mpa->hair);
- if (mpoint->keys)
+ }
+ if (mpoint->keys) {
MEM_freeN(mpoint->keys);
+ }
mpa->hair = MEM_dupallocN(pa->hair);
mpa->totkey = pa->totkey;
@@ -1023,16 +1057,19 @@ static void PE_mirror_particle(
mhkey->co[0] = -mhkey->co[0];
mul_m4_v3(immat, mhkey->co);
- if (key->flag & PEK_TAG)
+ if (key->flag & PEK_TAG) {
mkey->flag |= PEK_TAG;
+ }
mkey->length = key->length;
}
- if (point->flag & PEP_TAG)
+ if (point->flag & PEP_TAG) {
mpoint->flag |= PEP_TAG;
- if (point->flag & PEP_EDIT_RECALC)
+ }
+ if (point->flag & PEP_EDIT_RECALC) {
mpoint->flag |= PEP_EDIT_RECALC;
+ }
}
static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
@@ -1041,20 +1078,24 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
ParticleSystemModifierData *psmd_eval;
POINT_P;
- if (!psys)
+ if (!psys) {
return;
+ }
edit = psys->edit;
psmd_eval = edit->psmd_eval;
- if (!psmd_eval->mesh_final)
+ if (!psmd_eval->mesh_final) {
return;
+ }
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
+ }
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
return; /* something went wrong */
+ }
/* we delay settings the PARS_EDIT_RECALC for mirrored particles
* to avoid doing mirror twice */
@@ -1063,16 +1104,19 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
if (point->flag & PEP_EDIT_RECALC) {
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL);
- if (edit->mirror_cache[p] != -1)
+ if (edit->mirror_cache[p] != -1) {
edit->points[edit->mirror_cache[p]].flag &= ~PEP_EDIT_RECALC;
+ }
}
}
LOOP_POINTS
{
- if (point->flag & PEP_EDIT_RECALC)
- if (edit->mirror_cache[p] != -1)
+ if (point->flag & PEP_EDIT_RECALC) {
+ if (edit->mirror_cache[p] != -1) {
edit->points[edit->mirror_cache[p]].flag |= PEP_EDIT_RECALC;
+ }
+ }
}
}
@@ -1223,11 +1267,13 @@ static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit)
{
ParticleEditSettings *pset = PE_settings(scene);
- if (edit == 0 || (pset->flag & PE_KEEP_LENGTHS) == 0)
+ if (edit == 0 || (pset->flag & PE_KEEP_LENGTHS) == 0) {
return;
+ }
- if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
+ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
ApplyLengthsIterData iter_data;
iter_data.edit = edit;
@@ -1319,8 +1365,9 @@ void recalc_lengths(PTCacheEdit *edit)
POINT_P;
KEY_K;
- if (edit == 0)
+ if (edit == 0) {
return;
+ }
LOOP_EDITED_POINTS
{
@@ -1339,11 +1386,13 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part
float *vec, *nor;
int i, totface /*, totvert*/;
- if (!mesh)
+ if (!mesh) {
return;
+ }
- if (edit->emitter_cosnos)
+ if (edit->emitter_cosnos) {
MEM_freeN(edit->emitter_cosnos);
+ }
BLI_kdtree_3d_free(edit->emitter_field);
@@ -1400,11 +1449,12 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
KEY_K;
/* flag all particles to be updated if not using flag */
- if (!useflag)
+ if (!useflag) {
LOOP_POINTS
{
point->flag |= PEP_EDIT_RECALC;
}
+ }
/* flush edit key flag to hair key flag to preserve selection
* on save */
@@ -1439,20 +1489,23 @@ void update_world_cos(Depsgraph *UNUSED(depsgraph), Object *ob, PTCacheEdit *edi
KEY_K;
float hairmat[4][4];
- if (psys == 0 || psys->edit == 0 || psmd_eval->mesh_final == NULL)
+ if (psys == 0 || psys->edit == 0 || psmd_eval->mesh_final == NULL) {
return;
+ }
LOOP_POINTS
{
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, hairmat);
+ }
LOOP_KEYS
{
copy_v3_v3(key->world_co, key->co);
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
mul_m4_v3(hairmat, key->world_co);
+ }
}
}
}
@@ -1464,8 +1517,9 @@ static void update_velocities(PTCacheEdit *edit)
KEY_K;
/* hair doesn't use velocities */
- if (edit->psys || !edit->points || !edit->points->keys->vel)
+ if (edit->psys || !edit->points || !edit->points->keys->vel) {
return;
+ }
frs_sec = edit->pid.flag & PTCACHE_VEL_PER_SEC ? 25.0f : 1.0f;
@@ -1476,8 +1530,9 @@ static void update_velocities(PTCacheEdit *edit)
if (k == 0) {
dfra = *(key + 1)->time - *key->time;
- if (dfra <= 0.0f)
+ if (dfra <= 0.0f) {
continue;
+ }
sub_v3_v3v3(key->vel, (key + 1)->co, key->co);
@@ -1491,8 +1546,9 @@ static void update_velocities(PTCacheEdit *edit)
else if (k == point->totkey - 1) {
dfra = *key->time - *(key - 1)->time;
- if (dfra <= 0.0f)
+ if (dfra <= 0.0f) {
continue;
+ }
sub_v3_v3v3(key->vel, key->co, (key - 1)->co);
@@ -1506,8 +1562,9 @@ static void update_velocities(PTCacheEdit *edit)
else {
dfra = *(key + 1)->time - *(key - 1)->time;
- if (dfra <= 0.0f)
+ if (dfra <= 0.0f) {
continue;
+ }
sub_v3_v3v3(key->vel, (key + 1)->co, (key - 1)->co);
}
@@ -1524,26 +1581,31 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
PTCacheEdit *edit = PE_get_current(scene, ob);
POINT_P;
- if (!edit)
+ if (!edit) {
return;
+ }
/* flag all particles to be updated if not using flag */
- if (!useflag)
+ if (!useflag) {
LOOP_POINTS
{
point->flag |= PEP_EDIT_RECALC;
}
+ }
/* do post process on particle edit keys */
pe_iterate_lengths(scene, edit);
pe_deflect_emitter(scene, ob, edit);
PE_apply_lengths(scene, edit);
- if (pe_x_mirror(ob))
+ if (pe_x_mirror(ob)) {
PE_apply_mirror(ob, edit->psys);
- if (edit->psys)
+ }
+ if (edit->psys) {
update_world_cos(depsgraph, ob, edit);
- if (pset->flag & PE_AUTO_VELOCITY)
+ }
+ if (pset->flag & PE_AUTO_VELOCITY) {
update_velocities(edit);
+ }
PE_hide_keys_time(scene, edit, CFRA);
/* regenerate path caches */
@@ -1555,8 +1617,9 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
point->flag &= ~PEP_EDIT_RECALC;
}
- if (edit->psys)
+ if (edit->psys) {
edit->psys->flag &= ~PSYS_HAIR_UPDATED;
+ }
}
/************************************************/
@@ -1571,10 +1634,12 @@ static void select_key(PEData *data, int point_index, int key_index, bool UNUSED
PTCacheEditPoint *point = edit->points + point_index;
PTCacheEditKey *key = point->keys + key_index;
- if (data->select)
+ if (data->select) {
key->flag |= PEK_SELECT;
- else
+ }
+ else {
key->flag &= ~PEK_SELECT;
+ }
point->flag |= PEP_EDIT_RECALC;
data->is_changed = true;
@@ -1605,10 +1670,12 @@ static void select_keys(PEData *data,
LOOP_KEYS
{
- if (data->select)
+ if (data->select) {
key->flag |= PEK_SELECT;
- else
+ }
+ else {
key->flag &= ~PEK_SELECT;
+ }
}
point->flag |= PEP_EDIT_RECALC;
@@ -1710,8 +1777,9 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
break;
}
- if (action == SEL_DESELECT)
+ if (action == SEL_DESELECT) {
break;
+ }
}
}
@@ -1804,8 +1872,9 @@ static void select_root(PEData *data, int point_index)
PTCacheEditPoint *point = data->edit->points + point_index;
PTCacheEditKey *key = point->keys;
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
return;
+ }
if (data->select_action != SEL_TOGGLE) {
data->is_changed = select_action_apply(point, key, data->select_action);
@@ -1872,8 +1941,9 @@ static void select_tip(PEData *data, int point_index)
key = &point->keys[point->totkey - 1];
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
return;
+ }
if (data->select_action != SEL_TOGGLE) {
data->is_changed = select_action_apply(point, key, data->select_action);
@@ -2188,8 +2258,9 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
unit_m4(mat);
- if (!PE_start_edit(edit))
+ if (!PE_start_edit(edit)) {
return OPERATOR_CANCELLED;
+ }
/* only for depths */
PE_set_view3d_data(C, &data);
@@ -2200,9 +2271,10 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
LOOP_VISIBLE_POINTS
{
- if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR))
+ if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
+ }
if (pset->selectmode == SCE_SELECT_POINT) {
LOOP_KEYS
@@ -2373,16 +2445,19 @@ static void select_less_keys(PEData *data, int point_index)
LOOP_SELECTED_KEYS
{
if (k == 0) {
- if (((key + 1)->flag & PEK_SELECT) == 0)
+ if (((key + 1)->flag & PEK_SELECT) == 0) {
key->flag |= PEK_TAG;
+ }
}
else if (k == point->totkey - 1) {
- if (((key - 1)->flag & PEK_SELECT) == 0)
+ if (((key - 1)->flag & PEK_SELECT) == 0) {
key->flag |= PEK_TAG;
+ }
}
else {
- if ((((key - 1)->flag & (key + 1)->flag) & PEK_SELECT) == 0)
+ if ((((key - 1)->flag & (key + 1)->flag) & PEK_SELECT) == 0) {
key->flag |= PEK_TAG;
+ }
}
}
@@ -2434,20 +2509,24 @@ static void select_more_keys(PEData *data, int point_index)
LOOP_KEYS
{
- if (key->flag & PEK_SELECT)
+ if (key->flag & PEK_SELECT) {
continue;
+ }
if (k == 0) {
- if ((key + 1)->flag & PEK_SELECT)
+ if ((key + 1)->flag & PEK_SELECT) {
key->flag |= PEK_TAG;
+ }
}
else if (k == point->totkey - 1) {
- if ((key - 1)->flag & PEK_SELECT)
+ if ((key - 1)->flag & PEK_SELECT) {
key->flag |= PEK_TAG;
+ }
}
else {
- if (((key - 1)->flag | (key + 1)->flag) & PEK_SELECT)
+ if (((key - 1)->flag | (key + 1)->flag) & PEK_SELECT) {
key->flag |= PEK_TAG;
+ }
}
}
@@ -2532,22 +2611,25 @@ static void rekey_particle(PEData *data, int pa_index)
}
/* replace keys */
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = new_keys;
point->totkey = pa->totkey = data->totrekey;
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
ekey = point->keys = MEM_callocN(pa->totkey * sizeof(PTCacheEditKey), "Hair re-key edit keys");
for (k = 0, key = pa->hair; k < pa->totkey; k++, key++, ekey++) {
ekey->co = key->co;
ekey->time = &key->time;
ekey->flag |= PEK_SELECT;
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
ekey->flag |= PEK_USE_WCO;
+ }
}
pa->flag &= ~PARS_REKEY;
@@ -2603,8 +2685,9 @@ static void rekey_particle_to_time(
PTCacheEditKey *ekey;
int k;
- if (!edit || !edit->psys)
+ if (!edit || !edit->psys) {
return;
+ }
psys = edit->psys;
@@ -2627,8 +2710,9 @@ static void rekey_particle_to_time(
}
/* replace hair keys */
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = new_keys;
/* update edit pointers */
@@ -2676,10 +2760,12 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
if (ELEM(NULL, new_pars, new_points)) {
/* allocation error! */
- if (new_pars)
+ if (new_pars) {
MEM_freeN(new_pars);
- if (new_points)
+ }
+ if (new_points) {
MEM_freeN(new_points);
+ }
return 0;
}
}
@@ -2688,10 +2774,12 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
point = edit->points;
for (i = 0; i < psys->totpart; i++, pa++, point++) {
if (point->flag & PEP_TAG) {
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
- if (pa->hair)
+ }
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
}
else {
memcpy(npa, pa, sizeof(ParticleData));
@@ -2701,12 +2789,14 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
}
}
- if (psys->particles)
+ if (psys->particles) {
MEM_freeN(psys->particles);
+ }
psys->particles = new_pars;
- if (edit->points)
+ if (edit->points) {
MEM_freeN(edit->points);
+ }
edit->points = new_points;
if (edit->mirror_cache) {
@@ -2726,7 +2816,7 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
return removed;
}
-static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
+static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem *psys)
{
PTCacheEdit *edit = psys->edit;
ParticleData *pa;
@@ -2734,12 +2824,13 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
POINT_P;
KEY_K;
PTCacheEditKey *nkey, *new_keys;
- ParticleSystemModifierData *psmd_eval;
short new_totkey;
if (pe_x_mirror(ob)) {
/* mirror key tags */
- psmd_eval = psys_get_modifier(ob, psys);
+ ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
+ ParticleSystemModifierData *psmd_eval = (ParticleSystemModifierData *)modifier_get_evaluated(
+ depsgraph, ob, &psmd->modifier);
LOOP_POINTS
{
@@ -2759,8 +2850,9 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
new_totkey--;
}
/* we can't have elements with less than two keys*/
- if (new_totkey < 2)
+ if (new_totkey < 2) {
point->flag |= PEP_TAG;
+ }
}
remove_tagged_particles(ob, psys, pe_x_mirror(ob));
@@ -2805,11 +2897,13 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
hkey++;
}
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
pa->hair = new_hkeys;
point->keys = new_keys;
@@ -2846,12 +2940,14 @@ static void subdivide_particle(PEData *data, int pa_index)
sim.psys = edit->psys;
for (k = 0, ekey = point->keys; k < pa->totkey - 1; k++, ekey++) {
- if (ekey->flag & PEK_SELECT && (ekey + 1)->flag & PEK_SELECT)
+ if (ekey->flag & PEK_SELECT && (ekey + 1)->flag & PEK_SELECT) {
totnewkey++;
+ }
}
- if (totnewkey == 0)
+ if (totnewkey == 0) {
return;
+ }
pa->flag |= PARS_REKEY;
@@ -2883,8 +2979,9 @@ static void subdivide_particle(PEData *data, int pa_index)
nekey->co = nkey->co;
nekey->time = &nkey->time;
nekey->flag |= PEK_SELECT;
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
nekey->flag |= PEK_USE_WCO;
+ }
nekey++;
nkey++;
@@ -2897,12 +2994,14 @@ static void subdivide_particle(PEData *data, int pa_index)
nekey->co = nkey->co;
nekey->time = &nkey->time;
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = new_keys;
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
point->keys = new_ekeys;
point->totkey = pa->totkey = pa->totkey + totnewkey;
@@ -2956,8 +3055,9 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
float mat[4][4], co[3], threshold = RNA_float_get(op->ptr, "threshold");
int n, totn, removed, totremoved;
- if (psys->flag & PSYS_GLOBAL_HAIR)
+ if (psys->flag & PSYS_GLOBAL_HAIR) {
return OPERATOR_CANCELLED;
+ }
edit = psys->edit;
psmd_eval = edit->psmd_eval;
@@ -3008,8 +3108,9 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
totremoved += removed;
} while (removed);
- if (totremoved == 0)
+ if (totremoved == 0) {
return OPERATOR_CANCELLED;
+ }
BKE_reportf(op->reports, RPT_INFO, "Removed %d double particles", totremoved);
@@ -3144,9 +3245,10 @@ static void toggle_particle_cursor(bContext *C, int enable)
WM_paint_cursor_end(CTX_wm_manager(C), pset->paintcursor);
pset->paintcursor = NULL;
}
- else if (enable)
+ else if (enable) {
pset->paintcursor = WM_paint_cursor_activate(
CTX_wm_manager(C), SPACE_VIEW3D, RGN_TYPE_WINDOW, PE_poll_view3d, brush_drawcursor, NULL);
+ }
}
/*************************** delete operator **************************/
@@ -3185,7 +3287,7 @@ static int delete_exec(bContext *C, wmOperator *op)
if (type == DEL_KEY) {
foreach_selected_key(&data, set_delete_particle_key);
- remove_tagged_keys(data.ob, data.edit->psys);
+ remove_tagged_keys(data.depsgraph, data.ob, data.edit->psys);
recalc_lengths(data.edit);
}
else if (type == DEL_PARTICLE) {
@@ -3240,12 +3342,14 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
int *mirrorfaces = NULL;
int rotation, totpart, newtotpart;
- if (psys->flag & PSYS_GLOBAL_HAIR)
+ if (psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
psmd_eval = edit->psmd_eval;
- if (!psmd_eval->mesh_final)
+ if (!psmd_eval->mesh_final) {
return;
+ }
const bool use_dm_final_indices = (psys->part->use_modifier_stack &&
!psmd_eval->mesh_final->runtime.deformed_only);
@@ -3253,13 +3357,14 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
/* NOTE: this is not nice to use tessfaces but hard to avoid since pa->num uses tessfaces */
BKE_mesh_tessface_ensure(me);
- /* Note: In case psys uses Mesh tessface indices, we mirror final Mesh itself, not orig mesh. Avoids an (impossible)
- * mesh -> orig -> mesh tessface indices conversion... */
+ /* NOTE: In case psys uses Mesh tessface indices, we mirror final Mesh itself, not orig mesh.
+ * Avoids an (impossible) mesh -> orig -> mesh tessface indices conversion. */
mirrorfaces = mesh_get_x_mirror_faces(
ob, NULL, use_dm_final_indices ? psmd_eval->mesh_final : NULL);
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
+ }
totpart = psys->totpart;
newtotpart = psys->totpart;
@@ -3274,13 +3379,15 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, pa, NULL);
continue;
}
- else
+ else {
point->flag |= PEP_TAG;
+ }
}
}
- if ((point->flag & PEP_TAG) && mirrorfaces[pa->num * 2] != -1)
+ if ((point->flag & PEP_TAG) && mirrorfaces[pa->num * 2] != -1) {
newtotpart++;
+ }
}
if (newtotpart != psys->totpart) {
@@ -3317,19 +3424,23 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
pa = psys->particles + p;
const int pa_num = pa->num;
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
continue;
+ }
- if (!(point->flag & PEP_TAG) || mirrorfaces[pa_num * 2] == -1)
+ if (!(point->flag & PEP_TAG) || mirrorfaces[pa_num * 2] == -1) {
continue;
+ }
/* duplicate */
*newpa = *pa;
*newpoint = *point;
- if (pa->hair)
+ if (pa->hair) {
newpa->hair = MEM_dupallocN(pa->hair);
- if (point->keys)
+ }
+ if (point->keys) {
newpoint->keys = MEM_dupallocN(point->keys);
+ }
/* rotate weights according to vertex index rotation */
rotation = mirrorfaces[pa_num * 2 + 1];
@@ -3347,7 +3458,8 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
}
/* assign face index */
- /* NOTE: mesh_get_x_mirror_faces generates -1 for non-found mirror, same as DMCACHE_NOTFOUND... */
+ /* NOTE: mesh_get_x_mirror_faces generates -1 for non-found mirror,
+ * same as DMCACHE_NOTFOUND. */
newpa->num = mirrorfaces[pa_num * 2];
if (use_dm_final_indices) {
@@ -3424,8 +3536,9 @@ static void brush_comb(PEData *data,
ParticleEditSettings *pset = PE_settings(data->scene);
float cvec[3], fac;
- if (pset->flag & PE_LOCK_FIRST && key_index == 0)
+ if (pset->flag & PE_LOCK_FIRST && key_index == 0) {
return;
+ }
fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->combfac);
@@ -3456,12 +3569,14 @@ static void brush_cut(PEData *data, int pa_index)
}
/* don't cut hidden */
- if (edit->points[pa_index].flag & PEP_HIDE)
+ if (edit->points[pa_index].flag & PEP_HIDE) {
return;
+ }
if (ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_CLIP_NEAR) !=
- V3D_PROJ_RET_OK)
+ V3D_PROJ_RET_OK) {
return;
+ }
rad2 = data->rad * data->rad;
@@ -3612,8 +3727,9 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
mul_v3_m4v3(kco, data->ob->imat, co);
point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, NULL);
- if (point_index == -1)
+ if (point_index == -1) {
return;
+ }
copy_v3_v3(co_root, co);
copy_v3_v3(no_root, &edit->emitter_cosnos[point_index * 6 + 3]);
@@ -3628,8 +3744,9 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->pufffac);
fac *= 0.025f;
- if (data->invert)
+ if (data->invert) {
fac = -fac;
+ }
}
else {
/* compute position as if hair was standing up straight.
@@ -3725,8 +3842,9 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
}
}
- if (changed)
+ if (changed) {
point->flag |= PEP_EDIT_RECALC;
+ }
}
static void BKE_brush_weight_get(PEData *data,
@@ -3873,15 +3991,17 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
copy_v3_v3(v1, vert_cos + 3 * mface->v1);
copy_v3_v3(v2, vert_cos + 3 * mface->v2);
copy_v3_v3(v3, vert_cos + 3 * mface->v3);
- if (mface->v4)
+ if (mface->v4) {
copy_v3_v3(v4, vert_cos + 3 * mface->v4);
+ }
}
else {
copy_v3_v3(v1, mvert[mface->v1].co);
copy_v3_v3(v2, mvert[mface->v2].co);
copy_v3_v3(v3, mvert[mface->v3].co);
- if (mface->v4)
+ if (mface->v4) {
copy_v3_v3(v4, mvert[mface->v4].co);
+ }
}
if (face_minmax == 0) {
@@ -3889,16 +4009,19 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
DO_MINMAX(v1, min, max);
DO_MINMAX(v2, min, max);
DO_MINMAX(v3, min, max);
- if (mface->v4)
+ if (mface->v4) {
DO_MINMAX(v4, min, max);
- if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0)
+ }
+ if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0) {
continue;
+ }
}
else {
copy_v3_v3(min, face_minmax + 6 * i);
copy_v3_v3(max, face_minmax + 6 * i + 3);
- if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0)
+ if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0) {
continue;
+ }
}
if (radius > 0.0f) {
@@ -3929,8 +4052,9 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
min_w[1] = cur_uv[0];
min_w[2] = cur_uv[1];
min_w[3] = 0.0f;
- if (mface->v4)
+ if (mface->v4) {
intersect_dm_quad_weights(v1, v2, v3, v4, min_w);
+ }
*min_face = i;
intersect = 1;
}
@@ -4038,7 +4162,8 @@ static void brush_add_count_iter(void *__restrict iter_data_v,
add_pars[iter].num_dmcache = DMCACHE_ISCHILD;
}
else if (iter_data->mesh == psmd_eval->mesh_original) {
- /* Final DM is not same topology as orig mesh, we have to map num_dmcache to real final dm. */
+ /* Final DM is not same topology as orig mesh,
+ * we have to map num_dmcache to real final dm. */
add_pars[iter].num = add_pars[iter].num_dmcache;
add_pars[iter].num_dmcache = psys_particle_dm_face_lookup(psmd_eval->mesh_final,
psmd_eval->mesh_original,
@@ -4086,8 +4211,9 @@ static int brush_add(const bContext *C, PEData *data, short number)
invert_m4_m4(imat, ob->obmat);
- if (psys->flag & PSYS_GLOBAL_HAIR)
+ if (psys->flag & PSYS_GLOBAL_HAIR) {
return 0;
+ }
add_pars = MEM_callocN(number * sizeof(ParticleData), "ParticleData add");
@@ -4169,12 +4295,14 @@ static int brush_add(const bContext *C, PEData *data, short number)
memcpy(new_points, edit->points, totpart * sizeof(PTCacheEditPoint));
/* change old arrays to new ones */
- if (psys->particles)
+ if (psys->particles) {
MEM_freeN(psys->particles);
+ }
psys->particles = new_pars;
- if (edit->points)
+ if (edit->points) {
MEM_freeN(edit->points);
+ }
edit->points = new_points;
if (edit->mirror_cache) {
@@ -4221,16 +4349,18 @@ static int brush_add(const bContext *C, PEData *data, short number)
key->co = hkey->co;
key->time = &hkey->time;
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
key->flag |= PEK_USE_WCO;
+ }
}
pa->size = 1.0f;
initialize_particle(&sim, pa);
reset_particle(&sim, pa, 0.0, 1.0);
point->flag |= PEP_EDIT_RECALC;
- if (pe_x_mirror(ob))
+ if (pe_x_mirror(ob)) {
point->flag |= PEP_TAG; /* signal for duplicate */
+ }
framestep = pa->lifetime / (float)(pset->totaddkey - 1);
@@ -4266,12 +4396,14 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
if (totw > 0.0f) {
- for (w = 0; w < maxw; w++)
+ for (w = 0; w < maxw; w++) {
weight[w] /= totw;
+ }
}
else {
- for (w = 0; w < maxw; w++)
+ for (w = 0; w < maxw; w++) {
weight[w] = 1.0f / maxw;
+ }
}
ppa = psys->particles + ptn[0].index;
@@ -4301,8 +4433,9 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
}
- if (k == 0)
+ if (k == 0) {
sub_v3_v3v3(co1, pa->state.co, key3[0].co);
+ }
add_v3_v3v3(thkey->co, key3[0].co, co1);
@@ -4323,8 +4456,9 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
}
- if (tree)
+ if (tree) {
BLI_kdtree_3d_free(tree);
+ }
}
MEM_freeN(add_pars);
@@ -4404,8 +4538,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
float dx, dy, dmax;
int lock_root = pset->flag & PE_LOCK_FIRST;
- if (!PE_start_edit(edit))
+ if (!PE_start_edit(edit)) {
return;
+ }
RNA_float_get_array(itemptr, "mouse", mousef);
mouse[0] = mousef[0];
@@ -4424,8 +4559,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
mval[1] = mouse[1];
/* disable locking temporatily for disconnected hair */
- if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
+ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) {
pset->flag &= ~PE_LOCK_FIRST;
+ }
if (((pset->brushtype == PE_BRUSH_ADD) ?
(sqrtf(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) :
@@ -4454,10 +4590,12 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.rad = pe_brush_size_get(scene, brush);
data.combfac = (brush->strength - 0.5f) * 2.0f;
- if (data.combfac < 0.0f)
+ if (data.combfac < 0.0f) {
data.combfac = 1.0f - 9.0f * data.combfac;
- else
+ }
+ else {
data.combfac = 1.0f - data.combfac;
+ }
invert_m4_m4(ob->imat, ob->obmat);
@@ -4473,17 +4611,21 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.rad = pe_brush_size_get(scene, brush);
data.cutfac = brush->strength;
- if (selected)
+ if (selected) {
foreach_selected_point(&data, brush_cut);
- else
+ }
+ else {
foreach_point(&data, brush_cut);
+ }
removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob));
- if (pset->flag & PE_KEEP_LENGTHS)
+ if (pset->flag & PE_KEEP_LENGTHS) {
recalc_lengths(edit);
+ }
}
- else
+ else {
removed = 0;
+ }
break;
}
@@ -4493,15 +4635,18 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.rad = pe_brush_size_get(scene, brush);
data.growfac = brush->strength / 50.0f;
- if (brush->invert ^ flip)
+ if (brush->invert ^ flip) {
data.growfac = 1.0f - data.growfac;
- else
+ }
+ else {
data.growfac = 1.0f + data.growfac;
+ }
foreach_mouse_hit_point(&data, brush_length, selected);
- if (pset->flag & PE_KEEP_LENGTHS)
+ if (pset->flag & PE_KEEP_LENGTHS) {
recalc_lengths(edit);
+ }
break;
}
case PE_BRUSH_PUFF: {
@@ -4512,10 +4657,12 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.select = selected;
data.pufffac = (brush->strength - 0.5f) * 2.0f;
- if (data.pufffac < 0.0f)
+ if (data.pufffac < 0.0f) {
data.pufffac = 1.0f - 9.0f * data.pufffac;
- else
+ }
+ else {
data.pufffac = 1.0f - data.pufffac;
+ }
data.invert = (brush->invert ^ flip);
invert_m4_m4(ob->imat, ob->obmat);
@@ -4530,11 +4677,13 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
added = brush_add(C, &data, brush->count);
- if (pset->flag & PE_KEEP_LENGTHS)
+ if (pset->flag & PE_KEEP_LENGTHS) {
recalc_lengths(edit);
+ }
}
- else
+ else {
added = 0;
+ }
break;
}
case PE_BRUSH_SMOOTH: {
@@ -4571,12 +4720,14 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
break;
}
}
- if ((pset->flag & PE_KEEP_LENGTHS) == 0)
+ if ((pset->flag & PE_KEEP_LENGTHS) == 0) {
recalc_lengths(edit);
+ }
if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_CUT) && (added || removed)) {
- if (pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob))
+ if (pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob)) {
PE_mirror_x(scene, ob, 1);
+ }
update_world_cos(depsgraph, ob, edit);
psys_free_path_cache(NULL, edit);
@@ -4615,8 +4766,9 @@ static void brush_edit_exit(wmOperator *op)
static int brush_edit_exec(bContext *C, wmOperator *op)
{
- if (!brush_edit_init(C, op))
+ if (!brush_edit_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
RNA_BEGIN (op->ptr, itemptr, "stroke") {
brush_edit_apply(C, op, &itemptr);
@@ -4647,8 +4799,9 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, const wmEvent *e
static int brush_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!brush_edit_init(C, op))
+ if (!brush_edit_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
brush_edit_apply_event(C, op, event);
@@ -4734,8 +4887,9 @@ static void point_inside_bvh_cb(void *userdata,
data->bvhdata.raycast_callback(&data->bvhdata, index, ray, hit);
- if (hit->index != -1)
+ if (hit->index != -1) {
++data->num_hits;
+ }
}
/* true if the point is inside the shape mesh */
@@ -4767,8 +4921,9 @@ static void shape_cut(PEData *data, int pa_index)
int k, totkeys = 1 << pset->draw_step;
/* don't cut hidden */
- if (edit->points[pa_index].flag & PEP_HIDE)
+ if (edit->points[pa_index].flag & PEP_HIDE) {
return;
+ }
cut = false;
@@ -4829,12 +4984,14 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
int selected = count_selected_keys(scene, edit);
int lock_root = pset->flag & PE_LOCK_FIRST;
- if (!PE_start_edit(edit))
+ if (!PE_start_edit(edit)) {
return OPERATOR_CANCELLED;
+ }
/* disable locking temporatily for disconnected hair */
- if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
+ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) {
pset->flag &= ~PE_LOCK_FIRST;
+ }
if (edit->psys && edit->pathcache) {
PEData data;
@@ -4846,10 +5003,12 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- if (selected)
+ if (selected) {
foreach_selected_point(&data, shape_cut);
- else
+ }
+ else {
foreach_point(&data, shape_cut);
+ }
removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob));
recalc_lengths(edit);
@@ -4909,19 +5068,23 @@ int PE_minmax(Scene *scene, ViewLayer *view_layer, float min[3], float max[3])
float co[3], mat[4][4];
int ok = 0;
- if (!edit)
+ if (!edit) {
return ok;
+ }
- if ((psys = edit->psys))
+ if ((psys = edit->psys)) {
psmd_eval = edit->psmd_eval;
- else
+ }
+ else {
unit_m4(mat);
+ }
LOOP_VISIBLE_POINTS
{
- if (psys)
+ if (psys) {
psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
+ }
LOOP_SELECTED_KEYS
{
@@ -4961,14 +5124,17 @@ void PE_create_particle_edit(
}
/* no psmd->dm happens in case particle system modifier is not enabled */
- if (!(psys && psmd && psmd_eval->mesh_final) && !cache)
+ if (!(psys && psmd && psmd_eval->mesh_final) && !cache) {
return;
+ }
- if (cache && cache->flag & PTCACHE_DISK_CACHE)
+ if (cache && cache->flag & PTCACHE_DISK_CACHE) {
return;
+ }
- if (psys == NULL && (cache && BLI_listbase_is_empty(&cache->mem_cache)))
+ if (psys == NULL && (cache && BLI_listbase_is_empty(&cache->mem_cache))) {
return;
+ }
edit = (psys) ? psys->edit : cache->edit;
@@ -5029,21 +5195,24 @@ void PE_create_particle_edit(
cache->free_edit = PE_free_ptcache_edit;
edit->psys = NULL;
- for (pm = cache->mem_cache.first; pm; pm = pm->next)
+ for (pm = cache->mem_cache.first; pm; pm = pm->next) {
totframe++;
+ }
for (pm = cache->mem_cache.first; pm; pm = pm->next) {
LOOP_POINTS
{
- if (BKE_ptcache_mem_pointers_seek(p, pm) == 0)
+ if (BKE_ptcache_mem_pointers_seek(p, pm) == 0) {
continue;
+ }
if (!point->totkey) {
key = point->keys = MEM_callocN(totframe * sizeof(PTCacheEditKey), "ParticleEditKeys");
point->flag |= PEP_EDIT_RECALC;
}
- else
+ else {
key = point->keys + point->totkey;
+ }
key->co = pm->cur[BPHYS_DATA_LOCATION];
key->vel = pm->cur[BPHYS_DATA_VELOCITY];
@@ -5067,8 +5236,9 @@ void PE_create_particle_edit(
memset(edit->nosel_col, 0x00, sizeof(edit->nosel_col));
#endif
recalc_lengths(edit);
- if (psys && !cache)
+ if (psys && !cache) {
recalc_emitter_field(depsgraph, ob, psys);
+ }
PE_update_object(depsgraph, scene, ob, 1);
}
@@ -5078,12 +5248,15 @@ static bool particle_edit_toggle_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (ob == NULL || ob->type != OB_MESH)
+ if (ob == NULL || ob->type != OB_MESH) {
return 0;
- if (!ob->data || ID_IS_LINKED(ob->data))
+ }
+ if (!ob->data || ID_IS_LINKED(ob->data)) {
return 0;
- if (CTX_data_edit_object(C))
+ }
+ if (CTX_data_edit_object(C)) {
return 0;
+ }
return (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) ||
modifiers_findByType(ob, eModifierType_Softbody));
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 92eed9be2f5..b03ec56c7e4 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -69,10 +69,12 @@
#include "physics_intern.h"
-static float I[4][4] = {{1.0f, 0.0f, 0.0f, 0.0f},
- {0.0f, 1.0f, 0.0f, 0.0f},
- {0.0f, 0.0f, 1.0f, 0.0f},
- {0.0f, 0.0f, 0.0f, 1.0f}};
+static float I[4][4] = {
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, 1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 1.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 1.0f},
+};
/********************** particle system slot operators *********************/
@@ -82,8 +84,9 @@ static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
- if (!scene || !ob)
+ if (!scene || !ob) {
return OPERATOR_CANCELLED;
+ }
object_add_particle_system(bmain, scene, ob, NULL);
@@ -116,8 +119,9 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
ViewLayer *view_layer = CTX_data_view_layer(C);
int mode_orig;
- if (!scene || !ob)
+ if (!scene || !ob) {
return OPERATOR_CANCELLED;
+ }
mode_orig = ob->mode;
object_remove_particle_system(bmain, scene, ob);
@@ -175,15 +179,18 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op))
psys = ptr.data;
/* add or copy particle setting */
- if (psys->part)
+ if (psys->part) {
part = BKE_particlesettings_copy(bmain, psys->part);
- else
+ }
+ else {
part = BKE_particlesettings_add(bmain, "ParticleSettings");
+ }
ob = ptr.id.data;
- if (psys->part)
+ if (psys->part) {
id_us_min(&psys->part->id);
+ }
psys->part = part;
@@ -223,12 +230,14 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
- for (; pt; pt = pt->next)
+ for (; pt; pt = pt->next) {
pt->flag &= ~PTARGET_CURRENT;
+ }
pt = MEM_callocN(sizeof(ParticleTarget), "keyed particle target");
@@ -268,8 +277,9 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
for (; pt; pt = pt->next) {
@@ -281,8 +291,9 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
}
pt = psys->targets.last;
- if (pt)
+ if (pt) {
pt->flag |= PTARGET_CURRENT;
+ }
DEG_relations_tag_update(bmain);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -315,8 +326,9 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ptr.id.data;
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
for (; pt; pt = pt->next) {
@@ -354,8 +366,9 @@ static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ptr.id.data;
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
for (; pt; pt = pt->next) {
if (pt->flag & PTARGET_CURRENT && pt->next) {
@@ -390,8 +403,9 @@ static int dupliob_refresh_exec(bContext *C, wmOperator *UNUSED(op))
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
psys_check_group_weights(psys->part);
DEG_id_tag_update(&psys->part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
@@ -421,8 +435,9 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -460,8 +475,9 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
if (dw->flag & PART_DUPLIW_CURRENT) {
@@ -500,8 +516,9 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -513,8 +530,9 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
}
dw = part->instance_weights.last;
- if (dw)
+ if (dw) {
dw->flag |= PART_DUPLIW_CURRENT;
+ }
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
@@ -545,8 +563,9 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -591,11 +610,13 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part
int i, k;
float hairmat[4][4];
- if (!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR)
+ if (!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
- if (!psys->part || psys->part->type != PART_HAIR)
+ if (!psys->part || psys->part->type != PART_HAIR) {
return;
+ }
edit = psys->edit;
point = edit ? edit->points : NULL;
@@ -637,8 +658,9 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op)
ParticleSystem *psys = NULL;
const bool all = RNA_boolean_get(op->ptr, "all");
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
if (all) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
@@ -703,12 +725,15 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float from_ob_imat[4][4], to_ob_imat[4][4];
float from_imat[4][4], to_imat[4][4];
- if (!target_psmd->mesh_final)
+ if (!target_psmd->mesh_final) {
return false;
- if (!psys->part || psys->part->type != PART_HAIR)
+ }
+ if (!psys->part || psys->part->type != PART_HAIR) {
return false;
- if (!target_psys->part || target_psys->part->type != PART_HAIR)
+ }
+ if (!target_psys->part || target_psys->part->type != PART_HAIR) {
return false;
+ }
edit_point = target_edit ? target_edit->points : NULL;
@@ -738,8 +763,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
mvert = mesh->mvert;
/* convert to global coordinates */
- for (i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++) {
mul_m4_v3(to_mat, mvert[i].co);
+ }
if (mesh->totface != 0) {
mface = mesh->mface;
@@ -759,10 +785,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float from_co[3];
BVHTreeNearest nearest;
- if (from_global)
+ if (from_global) {
mul_v3_m4v3(from_co, from_ob_imat, pa->hair[0].co);
- else
+ }
+ else {
mul_v3_m4v3(from_co, from_ob_imat, pa->hair[0].world_co);
+ }
mul_m4_v3(from_mat, from_co);
nearest.index = -1;
@@ -771,8 +799,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
BLI_bvhtree_find_nearest(bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
if (nearest.index == -1) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("No nearest point found for hair root!");
+ }
continue;
}
@@ -788,8 +817,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
copy_v3_v3(v[3], mvert[mf->v4].co);
interp_weights_poly_v3(tpa->fuv, v, 4, nearest.co);
}
- else
+ else {
interp_weights_poly_v3(tpa->fuv, v, 3, nearest.co);
+ }
tpa->foffset = 0.0f;
tpa->num = nearest.index;
@@ -813,8 +843,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float hairmat[4][4], imat[4][4];
float offset[3];
- if (to_global)
+ if (to_global) {
copy_m4_m4(imat, target_ob->obmat);
+ }
else {
/* note: using target_dm here, which is in target_ob object space and has full modifiers */
psys_mat_hair_to_object(target_ob, target_mesh, target_psys->part->from, tpa, hairmat);
@@ -830,10 +861,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
k++, key++, tkey++, ekey++) {
float co_orig[3];
- if (from_global)
+ if (from_global) {
mul_v3_m4v3(co_orig, from_ob_imat, key->co);
- else
+ }
+ else {
mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
+ }
mul_m4_v3(from_mat, co_orig);
add_v3_v3v3(tkey->co, co_orig, offset);
@@ -849,10 +882,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
for (k = 0, key = pa->hair, tkey = tpa->hair; k < tpa->totkey; k++, key++, tkey++) {
float co_orig[3];
- if (from_global)
+ if (from_global) {
mul_v3_m4v3(co_orig, from_ob_imat, key->co);
- else
+ }
+ else {
mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
+ }
mul_m4_v3(from_mat, co_orig);
add_v3_v3v3(tkey->co, co_orig, offset);
@@ -877,8 +912,9 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl
{
bool ok;
- if (!psys)
+ if (!psys) {
return false;
+ }
ok = remap_hair_emitter(depsgraph,
scene,
@@ -905,8 +941,9 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
const bool all = RNA_boolean_get(op->ptr, "all");
bool any_connected = false;
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
if (all) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
@@ -964,8 +1001,9 @@ static void copy_particle_edit(Depsgraph *depsgraph,
KEY_K;
POINT_P;
- if (!edit_from)
+ if (!edit_from) {
return;
+ }
edit = MEM_dupallocN(edit_from);
edit->psys = psys;
@@ -1013,10 +1051,12 @@ static void remove_particle_systems_from_object(Object *ob_to)
{
ModifierData *md, *md_next;
- if (ob_to->type != OB_MESH)
+ if (ob_to->type != OB_MESH) {
return;
- if (!ob_to->data || ID_IS_LINKED(ob_to->data))
+ }
+ if (!ob_to->data || ID_IS_LINKED(ob_to->data)) {
return;
+ }
for (md = ob_to->modifiers.first; md; md = md_next) {
md_next = md->next;
@@ -1054,19 +1094,23 @@ static bool copy_particle_systems_to_object(const bContext *C,
CustomData_MeshMasks cdmask = {0};
int i, totpsys;
- if (ob_to->type != OB_MESH)
+ if (ob_to->type != OB_MESH) {
return false;
- if (!ob_to->data || ID_IS_LINKED(ob_to->data))
+ }
+ if (!ob_to->data || ID_IS_LINKED(ob_to->data)) {
return false;
+ }
/* For remapping we need a valid DM.
- * Because the modifiers are appended at the end it's safe to use
- * the final DM of the object without particles.
- * However, when evaluating the DM all the particle modifiers must be valid,
- * i.e. have the psys assigned already.
- * To break this hen/egg problem we create all psys separately first (to collect required customdata masks),
- * then create the DM, then add them to the object and make the psys modifiers ...
- */
+ * Because the modifiers are appended at the end it's safe to use
+ * the final DM of the object without particles.
+ * However, when evaluating the DM all the particle modifiers must be valid,
+ * i.e. have the psys assigned already.
+ *
+ * To break this hen/egg problem we create all psys separately first
+ * (to collect required customdata masks),
+ * then create the DM, then add them to the object and make the psys modifiers.
+ */
#define PSYS_FROM_FIRST (single_psys_from ? single_psys_from : ob_from->particlesystem.first)
#define PSYS_FROM_NEXT(cur) (single_psys_from ? NULL : (cur)->next)
totpsys = single_psys_from ? 1 : BLI_listbase_count(&ob_from->particlesystem);
@@ -1077,8 +1121,9 @@ static bool copy_particle_systems_to_object(const bContext *C,
psys = BKE_object_copy_particlesystem(psys_from, 0);
tmp_psys[i] = psys;
- if (psys_start == NULL)
+ if (psys_start == NULL) {
psys_start = psys;
+ }
psys_emitter_customdata_mask(psys, &cdmask);
}
@@ -1177,12 +1222,14 @@ static bool copy_particle_systems_to_object(const bContext *C,
static bool copy_particle_systems_poll(bContext *C)
{
Object *ob;
- if (!ED_operator_object_active_editable(C))
+ if (!ED_operator_object_active_editable(C)) {
return false;
+ }
ob = ED_object_active_context(C);
- if (BLI_listbase_is_empty(&ob->particlesystem))
+ if (BLI_listbase_is_empty(&ob->particlesystem)) {
return false;
+ }
return true;
}
@@ -1208,13 +1255,16 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
remove_particle_systems_from_object(ob_to);
changed = true;
}
- if (copy_particle_systems_to_object(C, scene, ob_from, psys_from, ob_to, space, false))
+ if (copy_particle_systems_to_object(C, scene, ob_from, psys_from, ob_to, space, false)) {
changed = true;
- else
+ }
+ else {
fail++;
+ }
- if (changed)
+ if (changed) {
changed_tot++;
+ }
}
}
CTX_DATA_END;
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 2769d1a9dc3..fd092eb4b78 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -80,8 +80,9 @@ static float get_fluid_rate(FluidsimSettings *settings)
rate = settings->animRate;
- if (rate < 0.0f)
+ if (rate < 0.0f) {
rate = 0.0f;
+ }
return rate;
}
@@ -185,16 +186,18 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char
}
fprintf(file, " CHANNEL %s =\n", str);
- for (i=0; i < channelSize; i++) {
+ for (i = 0; i < channelSize; i++) {
fprintf(file, " ");
- for (j=0;j <= entries;j++) { // also print time value
- fprintf(file, " %f ", channel[i*(entries + 1) + j]);
- if (j == entries-1) { fprintf(file, " "); }
+ for (j = 0; j <= entries; j++) { // also print time value
+ fprintf(file, " %f ", channel[i * (entries + 1) + j]);
+ if (j == entries - 1) {
+ fprintf(file, " ");
+ }
}
fprintf(file, "\n");
}
- fprintf(file, " ;\n");
+ fprintf(file, " ;\n");
}
# endif
@@ -255,8 +258,9 @@ static void set_vertex_channel(Depsgraph *depsgraph,
int framesize = (3 * fobj->numVerts) + 1;
int j;
- if (channel == NULL)
+ if (channel == NULL) {
return;
+ }
initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
@@ -279,8 +283,9 @@ static void set_vertex_channel(Depsgraph *depsgraph,
static void free_domain_channels(FluidAnimChannels *channels)
{
- if (!channels->timeAtFrame)
+ if (!channels->timeAtFrame) {
return;
+ }
MEM_freeN(channels->timeAtFrame);
channels->timeAtFrame = NULL;
MEM_freeN(channels->DomainGravity);
@@ -429,7 +434,8 @@ static void fluid_init_all_channels(bContext *C,
/* now scene data should be current according to animation system, so we fill the channels */
/* Domain time */
- // TODO: have option for not running sim, time mangling, in which case second case comes in handy
+ /* TODO: have option for not running sim, time mangling,
+ * in which case second case comes in handy. */
if (channels->DomainTime) {
time = get_fluid_rate(domainSettings) * (float)channels->aniFrameTime;
timeAtFrame = channels->timeAtFrame[i] + time;
@@ -455,8 +461,9 @@ static void fluid_init_all_channels(bContext *C,
float active = (float)((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) ? 1 : 0);
float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f};
- if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
+ if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
continue;
+ }
/* init euler rotation values and convert to elbeem format */
/* get the rotation from ob->obmat rather than ob->rot to account for parent animations */
@@ -524,8 +531,9 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
elbeemMesh fsmesh;
- if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
+ if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
continue;
+ }
elbeemResetMesh(&fsmesh);
@@ -552,12 +560,15 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD) ? 1 : 0);
}
- if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP)
+ if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
- else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP)
+ }
+ else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP;
- else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP)
+ }
+ else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP;
+ }
fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue;
fsmesh.volumeInitType = fluidmd->fss->volumeInitType;
@@ -591,16 +602,19 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
fsmesh.channelTranslation = fsmesh.channelRotation = fsmesh.channelScale = NULL;
/* Override user settings, only noslip is supported here! */
- if (fsmesh.type != OB_FLUIDSIM_CONTROL)
+ if (fsmesh.type != OB_FLUIDSIM_CONTROL) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
+ }
}
elbeemAddMesh(&fsmesh);
- if (verts)
+ if (verts) {
MEM_freeN(verts);
- if (tris)
+ }
+ if (tris) {
MEM_freeN(tris);
+ }
}
}
@@ -617,8 +631,9 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
ob, eModifierType_Fluidsim);
/* only find objects with fluid modifiers */
- if (!fluidmdtmp || ob->type != OB_MESH)
+ if (!fluidmdtmp || ob->type != OB_MESH) {
continue;
+ }
if (fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) {
/* if no initial domain object given, find another potential domain */
@@ -633,16 +648,19 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
}
/* count number of objects needed for animation channels */
- if (!ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
+ if (!ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
channelObjCount++;
+ }
/* count number of fluid input objects */
- if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW))
+ if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) {
fluidInputCount++;
+ }
}
- if (newdomain)
+ if (newdomain) {
fsDomain = newdomain;
+ }
if (!fsDomain) {
BKE_report(reports, RPT_ERROR, "No domain object found");
@@ -699,7 +717,8 @@ static bool fluid_init_filepaths(Main *bmain,
const bool dir_exists = BLI_dir_create_recursive(targetDir);
const bool is_writable = BLI_file_is_writable(targetFile);
- /* We change path to some presumably valid default value, but do not allow bake process to continue,
+ /* We change path to some presumably valid default value,
+ * but do not allow bake process to continue,
* this gives user chance to set manually another path. */
if (!dir_exists || !is_writable) {
modifier_path_init(domainSettings->surfdataPath,
@@ -765,8 +784,9 @@ static int fluidbake_breakjob(void *customdata)
{
FluidBakeJob *fb = (FluidBakeJob *)customdata;
- if (fb->stop && *(fb->stop))
+ if (fb->stop && *(fb->stop)) {
return 1;
+ }
/* this is not nice yet, need to make the jobs list template better
* for identifying/acting upon various different jobs */
@@ -815,7 +835,13 @@ static int runSimulationCallback(void *data, int status, int frame)
if (status == FLUIDSIM_CBSTATUS_NEWFRAME) {
fluidbake_updatejob(fb, frame / (float)settings->noOfFrames);
- //printf("elbeem blender cb s%d, f%d, domainid:%d noOfFrames: %d\n", status, frame, settings->domainId, settings->noOfFrames ); // DEBUG
+# if 0
+ printf("elbeem blender cb s%d, f%d, domainid:%d noOfFrames: %d\n",
+ status,
+ frame,
+ settings->domainId,
+ settings->noOfFrames); // DEBUG
+# endif
}
if (fluidbake_breakjob(fb)) {
@@ -938,7 +964,8 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
elbeemDebugOut(debugStrBuffer);
}
- /* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */
+ /* Make sure it corresponds to startFrame setting
+ * (old: noFrames = scene->r.efra - scene->r.sfra +1). */
;
noFrames = scene->r.efra - 0;
if (noFrames <= 0) {
@@ -1015,9 +1042,9 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
return false;
}
- channels->length =
- scene->r
- .efra; // DG TODO: why using endframe and not "noFrames" here? .. because "noFrames" is buggy too? (not using sfra)
+ /* DG TODO: why using endframe and not "noFrames" here?
+ * because "noFrames" is buggy too? (not using sfra) */
+ channels->length = scene->r.efra;
channels->aniFrameTime = (double)((double)domainSettings->animEnd -
(double)domainSettings->animStart) /
(double)noFrames;
@@ -1089,19 +1116,24 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
fsset->runsimCallback = &runSimulationCallback;
fsset->runsimUserData = fb;
- if (domainSettings->typeFlags & OB_FSBND_NOSLIP)
+ if (domainSettings->typeFlags & OB_FSBND_NOSLIP) {
fsset->domainobsType = FLUIDSIM_OBSTACLE_NOSLIP;
- else if (domainSettings->typeFlags & OB_FSBND_PARTSLIP)
+ }
+ else if (domainSettings->typeFlags & OB_FSBND_PARTSLIP) {
fsset->domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP;
- else if (domainSettings->typeFlags & OB_FSBND_FREESLIP)
+ }
+ else if (domainSettings->typeFlags & OB_FSBND_FREESLIP) {
fsset->domainobsType = FLUIDSIM_OBSTACLE_FREESLIP;
+ }
fsset->domainobsPartslip = domainSettings->partSlipValue;
/* use domainobsType also for surface generation flag (bit: >=64) */
- if (domainSettings->typeFlags & OB_FSSG_NOOBS)
+ if (domainSettings->typeFlags & OB_FSSG_NOOBS) {
fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS;
- else
+ }
+ else {
fsset->mFsSurfGenSetting = 0; // "normal" mode
+ }
fsset->generateVertexVectors = (domainSettings->domainNovecgen == 0);
@@ -1180,19 +1212,22 @@ static int fluidsimBake(bContext *UNUSED(C),
static int fluid_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
/* only one bake job at a time */
- if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_SIM_FLUID))
+ if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_SIM_FLUID)) {
return OPERATOR_CANCELLED;
+ }
- if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), true))
+ if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), true)) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
static int fluid_bake_exec(bContext *C, wmOperator *op)
{
- if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), false))
+ if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), false)) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c
index 2d2c90f9391..2c454448b9b 100644
--- a/source/blender/editors/physics/rigidbody_constraint.c
+++ b/source/blender/editors/physics/rigidbody_constraint.c
@@ -60,8 +60,9 @@ static bool ED_operator_rigidbody_con_active_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
return (ob && ob->rigidbody_constraint);
}
- else
+ else {
return 0;
+ }
}
bool ED_rigidbody_constraint_add(
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c
index 2914127f8d8..ed6d31dfd9b 100644
--- a/source/blender/editors/physics/rigidbody_object.c
+++ b/source/blender/editors/physics/rigidbody_object.c
@@ -66,8 +66,9 @@ static bool ED_operator_rigidbody_active_poll(bContext *C)
Object *ob = ED_object_active_context(C);
return (ob && ob->rigidbody_object);
}
- else
+ else {
return 0;
+ }
}
static bool ED_operator_rigidbody_add_poll(bContext *C)
@@ -76,8 +77,9 @@ static bool ED_operator_rigidbody_add_poll(bContext *C)
Object *ob = ED_object_active_context(C);
return (ob && ob->type == OB_MESH);
}
- else
+ else {
return 0;
+ }
}
/* ----------------- */
@@ -506,8 +508,9 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
/* get density (kg/m^3) to apply */
if (material >= 0) {
/* get density from table, and store in props for later repeating */
- if (material >= NUM_RB_MATERIAL_PRESETS)
+ if (material >= NUM_RB_MATERIAL_PRESETS) {
material = 0;
+ }
density = RB_MATERIAL_DENSITY_TABLE[material].density;
RNA_float_set(op->ptr, "density", density);
diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c
index 179a5a513f4..558a293ccbf 100644
--- a/source/blender/editors/physics/rigidbody_world.c
+++ b/source/blender/editors/physics/rigidbody_world.c
@@ -172,11 +172,13 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
static int rigidbody_world_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (!RNA_struct_property_is_set(op->ptr, "relative_path"))
+ if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
RNA_boolean_set(op->ptr, "relative_path", (U.flag & USER_RELPATHS) != 0);
+ }
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return rigidbody_world_export_exec(C, op);
+ }
// TODO: use the actual rigidbody world's name + .bullet instead of this temp crap
RNA_string_set(op->ptr, "filepath", "rigidbodyworld_export.bullet");
diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt
index 5d414c3af0f..6c62dbcb3a2 100644
--- a/source/blender/editors/render/CMakeLists.txt
+++ b/source/blender/editors/render/CMakeLists.txt
@@ -21,17 +21,17 @@ set(INC
../../blenlib
../../blenloader
../../blentranslation
+ ../../bmesh
../../depsgraph
../../draw
../../gpu
../../imbuf
- ../../bmesh
../../makesdna
../../makesrna
../../render/extern/include
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 6df1ba5e0aa..09bcc0a3058 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -72,6 +72,8 @@
#include "ED_undo.h"
#include "ED_view3d.h"
+#include "BIF_glutil.h"
+
#include "RE_pipeline.h"
#include "RE_engine.h"
@@ -147,19 +149,22 @@ static void image_buffer_rect_update(RenderJob *rj,
if (renrect) {
/* if (ymax == recty), rendering of layer is ready,
* we should not draw, other things happen... */
- if (rr->renlay == NULL || renrect->ymax >= rr->recty)
+ if (rr->renlay == NULL || renrect->ymax >= rr->recty) {
return;
+ }
/* xmin here is first subrect x coord, xmax defines subrect width */
xmin = renrect->xmin + rr->crop;
xmax = renrect->xmax - xmin + rr->crop;
- if (xmax < 2)
+ if (xmax < 2) {
return;
+ }
ymin = renrect->ymin + rr->crop;
ymax = renrect->ymax - ymin + rr->crop;
- if (ymax < 2)
+ if (ymax < 2) {
return;
+ }
renrect->ymin = renrect->ymax;
}
else {
@@ -170,19 +175,24 @@ static void image_buffer_rect_update(RenderJob *rj,
/* xmin ymin is in tile coords. transform to ibuf */
rxmin = rr->tilerect.xmin + xmin;
- if (rxmin >= ibuf->x)
+ if (rxmin >= ibuf->x) {
return;
+ }
rymin = rr->tilerect.ymin + ymin;
- if (rymin >= ibuf->y)
+ if (rymin >= ibuf->y) {
return;
+ }
- if (rxmin + xmax > ibuf->x)
+ if (rxmin + xmax > ibuf->x) {
xmax = ibuf->x - rxmin;
- if (rymin + ymax > ibuf->y)
+ }
+ if (rymin + ymax > ibuf->y) {
ymax = ibuf->y - rymin;
+ }
- if (xmax < 1 || ymax < 1)
+ if (xmax < 1 || ymax < 1) {
return;
+ }
/* The thing here is, the logic below (which was default behavior
* of how rectf is acquiring since forever) gives float buffer for
@@ -203,8 +213,9 @@ static void image_buffer_rect_update(RenderJob *rj,
rv = RE_RenderViewGetById(rr, view_id);
/* find current float rect for display, first case is after composite... still weak */
- if (rv->rectf)
+ if (rv->rectf) {
rectf = rv->rectf;
+ }
else {
if (rv->rect32) {
/* special case, currently only happens with sequencer rendering,
@@ -215,13 +226,15 @@ static void image_buffer_rect_update(RenderJob *rj,
return;
}
else {
- if (rr->renlay == NULL)
+ if (rr->renlay == NULL) {
return;
+ }
rectf = RE_RenderLayerGetPass(rr->renlay, RE_PASSNAME_COMBINED, viewname);
}
}
- if (rectf == NULL)
+ if (rectf == NULL) {
return;
+ }
rectf += 4 * (rr->rectx * ymin + xmin);
linear_stride = rr->rectx;
@@ -294,8 +307,9 @@ static void screen_render_single_layer_set(
RNA_string_get(op->ptr, "layer", rl_name);
rl = (ViewLayer *)BLI_findstring(&(*scene)->view_layers, rl_name, offsetof(ViewLayer, name));
- if (rl)
+ if (rl) {
*single_layer = rl;
+ }
}
else if (((*scene)->r.scemode & R_SINGLE_LAYER) && active_layer) {
*single_layer = active_layer;
@@ -344,12 +358,12 @@ static int screen_render_exec(bContext *C, wmOperator *op)
* otherwise, invalidated cache entries can make their way into
* the output rendering. We can't put that into RE_BlenderFrame,
* since sequence rendering can call that recursively... (peter) */
- BKE_sequencer_cache_cleanup();
+ BKE_sequencer_cache_cleanup(scene);
RE_SetReports(re, op->reports);
BLI_threaded_malloc_begin();
- if (is_animation)
+ if (is_animation) {
RE_BlenderAnim(re,
mainp,
scene,
@@ -358,9 +372,11 @@ static int screen_render_exec(bContext *C, wmOperator *op)
scene->r.sfra,
scene->r.efra,
scene->r.frame_step);
- else
+ }
+ else {
RE_BlenderFrame(
re, mainp, scene, single_layer, camera_override, scene->r.cfra, is_write_still);
+ }
BLI_threaded_malloc_end();
RE_SetReports(re, NULL);
@@ -402,10 +418,12 @@ static void make_renderinfo_string(const RenderStats *rs,
megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
/* local view */
- if (rs->localview)
+ if (rs->localview) {
spos += sprintf(spos, "%s | ", IFACE_("3D Local View"));
- else if (v3d_override)
+ }
+ else if (v3d_override) {
spos += sprintf(spos, "%s | ", IFACE_("3D View"));
+ }
/* frame number */
spos += sprintf(spos, IFACE_("Frame:%d "), (scene->r.cfra));
@@ -414,16 +432,19 @@ static void make_renderinfo_string(const RenderStats *rs,
BLI_timecode_string_from_time_simple(info_time_str, sizeof(info_time_str), rs->lastframetime);
if (rs->infostr && rs->infostr[0]) {
- if (rs->lastframetime != 0.0)
+ if (rs->lastframetime != 0.0) {
spos += sprintf(spos, IFACE_("| Last:%s "), info_time_str);
- else
+ }
+ else {
spos += sprintf(spos, "| ");
+ }
BLI_timecode_string_from_time_simple(
info_time_str, sizeof(info_time_str), PIL_check_seconds_timer() - rs->starttime);
}
- else
+ else {
spos += sprintf(spos, "| ");
+ }
spos += sprintf(spos, IFACE_("Time:%s "), info_time_str);
@@ -434,38 +455,49 @@ static void make_renderinfo_string(const RenderStats *rs,
}
}
else {
- if (rs->totvert || rs->totface || rs->tothalo || rs->totstrand || rs->totlamp)
+ if (rs->totvert || rs->totface || rs->tothalo || rs->totstrand || rs->totlamp) {
spos += sprintf(spos, "| ");
+ }
- if (rs->totvert)
+ if (rs->totvert) {
spos += sprintf(spos, IFACE_("Ve:%d "), rs->totvert);
- if (rs->totface)
+ }
+ if (rs->totface) {
spos += sprintf(spos, IFACE_("Fa:%d "), rs->totface);
- if (rs->tothalo)
+ }
+ if (rs->tothalo) {
spos += sprintf(spos, IFACE_("Ha:%d "), rs->tothalo);
- if (rs->totstrand)
+ }
+ if (rs->totstrand) {
spos += sprintf(spos, IFACE_("St:%d "), rs->totstrand);
- if (rs->totlamp)
+ }
+ if (rs->totlamp) {
spos += sprintf(spos, IFACE_("Li:%d "), rs->totlamp);
+ }
- if (rs->mem_peak == 0.0f)
+ if (rs->mem_peak == 0.0f) {
spos += sprintf(spos,
IFACE_("| Mem:%.2fM (%.2fM, Peak %.2fM) "),
megs_used_memory,
mmap_used_memory,
megs_peak_memory);
- else
+ }
+ else {
spos += sprintf(spos, IFACE_("| Mem:%.2fM, Peak: %.2fM "), rs->mem_used, rs->mem_peak);
+ }
- if (rs->curfield)
+ if (rs->curfield) {
spos += sprintf(spos, IFACE_("Field %d "), rs->curfield);
- if (rs->curblur)
+ }
+ if (rs->curblur) {
spos += sprintf(spos, IFACE_("Blur %d "), rs->curblur);
+ }
}
/* full sample */
- if (rs->curfsa)
+ if (rs->curfsa) {
spos += sprintf(spos, IFACE_("| Full Sample %d "), rs->curfsa);
+ }
/* extra info */
if (rs->infostr && rs->infostr[0]) {
@@ -476,9 +508,11 @@ static void make_renderinfo_string(const RenderStats *rs,
}
/* very weak... but 512 characters is quite safe */
- if (spos >= str + IMA_MAX_RENDER_TEXT)
- if (G.debug & G_DEBUG)
+ if (spos >= str + IMA_MAX_RENDER_TEXT) {
+ if (G.debug & G_DEBUG) {
printf("WARNING! renderwin text beyond limit\n");
+ }
+ }
}
static void image_renderinfo_cb(void *rjv, RenderStats *rs)
@@ -490,8 +524,9 @@ static void image_renderinfo_cb(void *rjv, RenderStats *rs)
if (rr) {
/* malloc OK here, stats_draw is not in tile threads */
- if (rr->text == NULL)
+ if (rr->text == NULL) {
rr->text = MEM_callocN(IMA_MAX_RENDER_TEXT, "rendertext");
+ }
make_renderinfo_string(rs, rj->scene, rj->v3d_override, rr->error, rr->text);
}
@@ -592,8 +627,9 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
return;
}
- if (rr == NULL)
+ if (rr == NULL) {
return;
+ }
/* update part of render */
render_image_update_pass_and_layer(rj, rr, &rj->iuser);
@@ -607,7 +643,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
* operate with.
*/
if (rr->do_exr_tile || !rj->supports_glsl_draw || ibuf->channels == 1 ||
- U.image_draw_method != IMAGE_DRAW_METHOD_GLSL) {
+ ED_draw_imbuf_method(ibuf) != IMAGE_DRAW_METHOD_GLSL) {
image_buffer_rect_update(rj, rr, ibuf, &rj->iuser, renrect, viewname);
}
@@ -634,7 +670,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
RE_SetReports(rj->re, rj->reports);
- if (rj->anim)
+ if (rj->anim) {
RE_BlenderAnim(rj->re,
rj->main,
rj->scene,
@@ -643,7 +679,8 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
rj->scene->r.sfra,
rj->scene->r.efra,
rj->scene->r.frame_step);
- else
+ }
+ else {
RE_BlenderFrame(rj->re,
rj->main,
rj->scene,
@@ -651,6 +688,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
rj->camera_override,
rj->scene->r.cfra,
rj->write_still);
+ }
RE_SetReports(rj->re, NULL);
}
@@ -701,8 +739,9 @@ static void render_endjob(void *rjv)
* to avoid referencing freed renderjobs bug T24508. */
RE_InitRenderCB(rj->re);
- if (rj->main != G_MAIN)
+ if (rj->main != G_MAIN) {
BKE_main_free(rj->main);
+ }
/* else the frame will not update for the original value */
if (rj->anim && !(rj->scene->r.scemode & R_NO_FRAME_UPDATE)) {
@@ -753,8 +792,9 @@ static void render_endjob(void *rjv)
Image *ima = rj->image;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &rj->iuser, &lock);
- if (ibuf)
+ if (ibuf) {
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+ }
BKE_image_release_ibuf(ima, ibuf, lock);
}
@@ -775,10 +815,12 @@ static int render_breakjob(void *rjv)
{
RenderJob *rj = rjv;
- if (G.is_break)
+ if (G.is_break) {
return 1;
- if (rj->stop && *(rj->stop))
+ }
+ if (rj->stop && *(rj->stop)) {
return 1;
+ }
return 0;
}
@@ -786,8 +828,9 @@ static int render_breakjob(void *rjv)
* note: this wont check for the escape key being pressed, but doing so isnt threadsafe */
static int render_break(void *UNUSED(rjv))
{
- if (G.is_break)
+ if (G.is_break) {
return 1;
+ }
return 0;
}
@@ -903,8 +946,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
screen_render_single_layer_set(op, bmain, active_layer, &scene, &single_layer);
/* only one render job at a time */
- if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER))
+ if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) {
return OPERATOR_CANCELLED;
+ }
if (!RE_is_rendering_allowed(scene, single_layer, camera_override, op->reports)) {
return OPERATOR_CANCELLED;
@@ -920,8 +964,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
/* cancel animation playback */
- if (ED_screen_animation_playing(CTX_wm_manager(C)))
+ if (ED_screen_animation_playing(CTX_wm_manager(C))) {
ED_screen_animation_play(C, 0, 0);
+ }
/* handle UI stuff */
WM_cursor_wait(1);
@@ -933,7 +978,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
* otherwise, invalidated cache entries can make their way into
* the output rendering. We can't put that into RE_BlenderFrame,
* since sequence rendering can call that recursively... (peter) */
- BKE_sequencer_cache_cleanup();
+ BKE_sequencer_cache_cleanup(scene);
// store spare
// get view3d layer, local layer, make this nice api call to render
@@ -944,8 +989,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
jobflag = WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS;
- if (RNA_struct_property_is_set(op->ptr, "layer"))
+ if (RNA_struct_property_is_set(op->ptr, "layer")) {
jobflag |= WM_JOB_SUSPEND;
+ }
/* job custom data */
rj = MEM_callocN(sizeof(RenderJob), "render job");
@@ -975,8 +1021,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
}
if (v3d) {
- if (camera_override && camera_override != scene->camera)
+ if (camera_override && camera_override != scene->camera) {
rj->v3d_override = true;
+ }
}
/* Lock the user interface depending on render settings. */
@@ -998,10 +1045,12 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
}
/* setup job */
- if (RE_seq_render_active(scene, &scene->r))
+ if (RE_seq_render_active(scene, &scene->r)) {
name = "Sequence Render";
- else
+ }
+ else {
name = "Render";
+ }
wm_job = WM_jobs_get(
CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag, WM_JOB_TYPE_RENDER);
@@ -1066,7 +1115,10 @@ void RENDER_OT_render(wmOperatorType *ot)
ot->cancel = screen_render_cancel;
ot->exec = screen_render_exec;
- /*ot->poll = ED_operator_screenactive;*/ /* this isn't needed, causes failer in background mode */
+ /* this isn't needed, causes failer in background mode */
+#if 0
+ ot->poll = ED_operator_screenactive;
+#endif
prop = RNA_def_boolean(ot->srna,
"animation",
@@ -1107,8 +1159,9 @@ Scene *ED_render_job_get_scene(const bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER);
- if (rj)
+ if (rj) {
return rj->scene;
+ }
return NULL;
}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 6862881de59..28cfce00e6e 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -154,8 +154,9 @@ static bool screen_opengl_is_multiview(OGLRender *oglrender)
RegionView3D *rv3d = oglrender->rv3d;
RenderData *rd = &oglrender->scene->r;
- if ((rd == NULL) || ((v3d != NULL) && (rv3d == NULL)))
+ if ((rd == NULL) || ((v3d != NULL) && (rv3d == NULL))) {
return false;
+ }
return (rd->scemode & R_MULTIVIEW) &&
((v3d == NULL) || (rv3d->persp == RV3D_CAMOB && v3d->camera));
@@ -189,14 +190,17 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
RenderView *rv_del = rv->next;
BLI_remlink(&rr->views, rv_del);
- if (rv_del->rectf)
+ if (rv_del->rectf) {
MEM_freeN(rv_del->rectf);
+ }
- if (rv_del->rectz)
+ if (rv_del->rectz) {
MEM_freeN(rv_del->rectz);
+ }
- if (rv_del->rect32)
+ if (rv_del->rect32) {
MEM_freeN(rv_del->rect32);
+ }
MEM_freeN(rv_del);
}
@@ -219,14 +223,17 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
BLI_remlink(&rr->views, rv_del);
- if (rv_del->rectf)
+ if (rv_del->rectf) {
MEM_freeN(rv_del->rectf);
+ }
- if (rv_del->rectz)
+ if (rv_del->rectz) {
MEM_freeN(rv_del->rectz);
+ }
- if (rv_del->rect32)
+ if (rv_del->rect32) {
MEM_freeN(rv_del->rect32);
+ }
MEM_freeN(rv_del);
}
@@ -234,8 +241,9 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
/* create all the views that are needed */
for (srv = rd->views.first; srv; srv = srv->next) {
- if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
+ if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
continue;
+ }
rv = BLI_findstring(&rr->views, srv->name, offsetof(SceneRenderView, name));
@@ -247,8 +255,9 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
}
}
- if (!(is_multiview && BKE_scene_multiview_is_stereo3d(rd)))
+ if (!(is_multiview && BKE_scene_multiview_is_stereo3d(rd))) {
oglrender->iuser.flag &= ~IMA_SHOW_STEREO;
+ }
/* will only work for non multiview correctly */
if (v3d) {
@@ -372,9 +381,10 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
}
}
else {
- draw_flags |= V3D_OFSDRAW_USE_GPENCIL;
+ draw_flags |= V3D_OFSDRAW_SHOW_ANNOTATION;
ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene,
+ NULL,
OB_SOLID,
scene->camera,
oglrender->sizex,
@@ -431,10 +441,12 @@ static void screen_opengl_render_write(OGLRender *oglrender)
RE_ReleaseResultImage(oglrender->re);
- if (ok)
+ if (ok) {
printf("OpenGL Render written to '%s'\n", name);
- else
+ }
+ else {
printf("OpenGL Render failed to write '%s'\n", name);
+ }
}
static void UNUSED_FUNCTION(addAlphaOverFloat)(float dest[4], const float source[4])
@@ -551,8 +563,9 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
}
/* only one render job at a time */
- if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER))
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) {
return false;
+ }
if (is_sequencer) {
is_view_context = false;
@@ -951,8 +964,9 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
RenderResult *rr;
/* go to next frame */
- if (CFRA < oglrender->nfra)
+ if (CFRA < oglrender->nfra) {
CFRA++;
+ }
while (CFRA < oglrender->nfra) {
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
CFRA++;
@@ -1035,8 +1049,9 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_FINISHED;
case TIMER:
/* render frame? */
- if (oglrender->timer == event->customdata)
+ if (oglrender->timer == event->customdata) {
break;
+ }
ATTR_FALLTHROUGH;
default:
/* nothing to do */
@@ -1068,12 +1083,14 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, const wmEven
OGLRender *oglrender;
const bool anim = RNA_boolean_get(op->ptr, "animation");
- if (!screen_opengl_render_init(C, op))
+ if (!screen_opengl_render_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
if (anim) {
- if (!screen_opengl_render_anim_initialize(C, op))
+ if (!screen_opengl_render_anim_initialize(C, op)) {
return OPERATOR_CANCELLED;
+ }
}
oglrender = op->customdata;
@@ -1093,8 +1110,9 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op)
{
const bool is_animation = RNA_boolean_get(op->ptr, "animation");
- if (!screen_opengl_render_init(C, op))
+ if (!screen_opengl_render_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
if (!is_animation) { /* same as invoke */
/* render image */
@@ -1106,8 +1124,9 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op)
else {
bool ret = true;
- if (!screen_opengl_render_anim_initialize(C, op))
+ if (!screen_opengl_render_anim_initialize(C, op)) {
return OPERATOR_CANCELLED;
+ }
while (ret) {
ret = screen_opengl_render_anim_step(C, op);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index c62d6530c6b..bf6d658f927 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -131,14 +131,16 @@ ImBuf *get_brush_icon(Brush *brush)
}
}
- if (brush->icon_imbuf)
+ if (brush->icon_imbuf) {
BKE_icon_changed(BKE_icon_id_ensure(&brush->id));
+ }
}
}
}
- if (!(brush->icon_imbuf))
+ if (!(brush->icon_imbuf)) {
brush->id.icon_id = 0;
+ }
return brush->icon_imbuf;
}
@@ -234,17 +236,20 @@ static bool check_engine_supports_preview(Scene *scene)
void ED_preview_free_dbase(void)
{
- if (G_pr_main)
+ if (G_pr_main) {
BKE_main_free(G_pr_main);
+ }
- if (G_pr_main_grease_pencil)
+ if (G_pr_main_grease_pencil) {
BKE_main_free(G_pr_main_grease_pencil);
+ }
}
static Scene *preview_get_scene(Main *pr_main)
{
- if (pr_main == NULL)
+ if (pr_main == NULL) {
return NULL;
+ }
return pr_main->scenes.first;
}
@@ -326,28 +331,22 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world)
return sp->worldcopy;
}
-static ID *duplicate_ids(ID *id, Depsgraph *depsgraph)
+static ID *duplicate_ids(ID *id)
{
if (id == NULL) {
/* Non-ID preview render. */
return NULL;
}
- ID *id_eval = id;
-
- if (depsgraph) {
- id_eval = DEG_get_evaluated_id(depsgraph, id);
- }
-
switch (GS(id->name)) {
case ID_MA:
- return (ID *)BKE_material_localize((Material *)id_eval);
+ return (ID *)BKE_material_localize((Material *)id);
case ID_TE:
- return (ID *)BKE_texture_localize((Tex *)id_eval);
+ return (ID *)BKE_texture_localize((Tex *)id);
case ID_LA:
- return (ID *)BKE_light_localize((Light *)id_eval);
+ return (ID *)BKE_light_localize((Light *)id);
case ID_WO:
- return (ID *)BKE_world_localize((World *)id_eval);
+ return (ID *)BKE_world_localize((World *)id);
case ID_IM:
case ID_BR:
case ID_SCR:
@@ -397,10 +396,12 @@ static Scene *preview_prepare_scene(
sce->r.tiley = sce->r.ysch / 4;
}
- if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO)
+ if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO) {
sce->r.alphamode = R_ALPHAPREMUL;
- else
+ }
+ else {
sce->r.alphamode = R_ADDSKY;
+ }
sce->r.cfra = scene->r.cfra;
@@ -461,8 +462,9 @@ static Scene *preview_prepare_scene(
Material ***matar = give_matarar(base->object);
int actcol = max_ii(base->object->actcol - 1, 0);
- if (matar && actcol < base->object->totcol)
+ if (matar && actcol < base->object->totcol) {
(*matar)[actcol] = mat;
+ }
}
else if (base->object->type == OB_LAMP) {
base->flag |= BASE_VISIBLE;
@@ -510,8 +512,9 @@ static Scene *preview_prepare_scene(
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
if (base->object->id.name[2] == 'p') {
- if (base->object->type == OB_LAMP)
+ if (base->object->type == OB_LAMP) {
base->object->data = la;
+ }
}
}
@@ -562,10 +565,12 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
int newy = BLI_rcti_size_y(rect);
bool ok = false;
- if (!split || first)
+ if (!split || first) {
sprintf(name, "Preview %p", (void *)sa);
- else
+ }
+ else {
sprintf(name, "SecondPreview %p", (void *)sa);
+ }
if (split) {
if (first) {
@@ -581,8 +586,9 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
/* test if something rendered ok */
re = RE_GetRender(name);
- if (re == NULL)
+ if (re == NULL) {
return false;
+ }
RE_AcquireResultImageViews(re, &rres);
@@ -609,8 +615,9 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
float fy = rect->ymin;
/* material preview only needs monoscopy (view 0) */
- if (re)
+ if (re) {
RE_AcquiredResultGet32(re, &rres, (unsigned int *)rect_byte, 0);
+ }
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(&state,
@@ -662,11 +669,13 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
ok = ed_preview_draw_rect(sa, 1, 1, rect, &newrect);
ok &= ed_preview_draw_rect(sa, 1, 0, rect, &newrect);
}
- else
+ else {
ok = ed_preview_draw_rect(sa, 0, 0, rect, &newrect);
+ }
- if (ok)
+ if (ok) {
*rect = newrect;
+ }
/* start a new preview render job if signaled through sbuts->preview,
* if no render result was found and no preview render job is running,
@@ -712,26 +721,30 @@ static void shader_preview_updatejob(void *spv)
if (GS(sp->id->name) == ID_MA) {
Material *mat = (Material *)sp->id;
- if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree)
+ if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree) {
ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree);
+ }
}
else if (GS(sp->id->name) == ID_TE) {
Tex *tex = (Tex *)sp->id;
- if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree)
+ if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree) {
ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree);
+ }
}
else if (GS(sp->id->name) == ID_WO) {
World *wrld = (World *)sp->id;
- if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree)
+ if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) {
ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree);
+ }
}
else if (GS(sp->id->name) == ID_LA) {
Light *la = (Light *)sp->id;
- if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree)
+ if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) {
ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree);
+ }
}
}
}
@@ -801,18 +814,15 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
char name[32];
int sizex;
Main *pr_main = sp->pr_main;
- ID *id_eval = id;
-
- if (sp->depsgraph) {
- id_eval = DEG_get_evaluated_id(sp->depsgraph, id);
- }
/* in case of split preview, use border render */
if (split) {
- if (first)
+ if (first) {
sizex = sp->sizex / 2;
- else
+ }
+ else {
sizex = sp->sizex - sp->sizex / 2;
+ }
}
else {
sizex = sp->sizex;
@@ -827,19 +837,23 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
}
/* get the stuff from the builtin preview dbase */
- sce = preview_prepare_scene(sp->bmain, sp->scene, id_eval, idtype, sp);
- if (sce == NULL)
+ sce = preview_prepare_scene(sp->bmain, sp->scene, id, idtype, sp);
+ if (sce == NULL) {
return;
+ }
- if (!split || first)
+ if (!split || first) {
sprintf(name, "Preview %p", sp->owner);
- else
+ }
+ else {
sprintf(name, "SecondPreview %p", sp->owner);
+ }
re = RE_GetRender(name);
/* full refreshed render from first tile */
- if (re == NULL)
+ if (re == NULL) {
re = RE_NewRender(name);
+ }
/* sce->r gets copied in RE_InitState! */
sce->r.scemode &= ~(R_MATNODE_PREVIEW | R_TEXNODE_PREVIEW);
@@ -850,10 +864,12 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
sce->r.mode |= R_OSA;
}
else if (sp->pr_method == PR_NODE_RENDER) {
- if (idtype == ID_MA)
+ if (idtype == ID_MA) {
sce->r.scemode |= R_MATNODE_PREVIEW;
- else if (idtype == ID_TE)
+ }
+ else if (idtype == ID_TE) {
sce->r.scemode |= R_TEXNODE_PREVIEW;
+ }
sce->r.mode &= ~R_OSA;
}
else { /* PR_BUTS_RENDER */
@@ -869,8 +885,9 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* lens adjust */
oldlens = ((Camera *)sce->camera->data)->lens;
- if (sizex > sp->sizey)
+ if (sizex > sp->sizey) {
((Camera *)sce->camera->data)->lens *= (float)sp->sizey / (float)sizex;
+ }
/* entire cycle for render engine */
if (idtype == ID_TE) {
@@ -887,8 +904,9 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
if (sp->pr_method == PR_ICON_RENDER) {
// char *rct= (char *)(sp->pr_rect + 32*16 + 16);
- if (sp->pr_rect)
+ if (sp->pr_rect) {
RE_ResultGet32(re, sp->pr_rect);
+ }
}
/* unassign the pointers, reset vars */
@@ -914,8 +932,9 @@ static void shader_preview_startjob(void *customdata, short *stop, short *do_upd
shader_preview_render(sp, sp->id, 1, 1);
shader_preview_render(sp, sp->parent, 1, 0);
}
- else
+ else {
shader_preview_render(sp, sp->id, 0, 0);
+ }
*do_update = true;
}
@@ -986,14 +1005,16 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
short ex, ey, dx, dy;
/* paranoia test */
- if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL))
+ if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
return;
+ }
/* waste of cpu cyles... but the imbuf API has no other way to scale fast (ton) */
ima = IMB_dupImBuf(ibuf);
- if (!ima)
+ if (!ima) {
return;
+ }
if (ima->x > ima->y) {
scaledx = (float)w;
@@ -1013,8 +1034,9 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
IMB_scalefastImBuf(ima, ex, ey);
/* if needed, convert to 32 bits */
- if (ima->rect == NULL)
+ if (ima->rect == NULL) {
IMB_rect_from_float(ima);
+ }
srect = ima->rect;
drect = rect;
@@ -1033,8 +1055,9 @@ static void set_alpha(char *cp, int sizex, int sizey, char alpha)
{
int a, size = sizex * sizey;
- for (a = 0; a < size; a++, cp += 4)
+ for (a = 0; a < size; a++, cp += 4) {
cp[3] = alpha;
+ }
}
static void icon_preview_startjob(void *customdata, short *stop, short *do_update)
@@ -1070,8 +1093,9 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
ImageUser iuser = {NULL};
/* ima->ok is zero when Image cannot load */
- if (ima == NULL || ima->ok == 0)
+ if (ima == NULL || ima->ok == 0) {
return;
+ }
/* setup dummy image user */
iuser.ok = iuser.framenr = 1;
@@ -1099,8 +1123,9 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(unsigned int));
- if (!(br->icon_imbuf) || !(br->icon_imbuf->rect))
+ if (!(br->icon_imbuf) || !(br->icon_imbuf->rect)) {
return;
+ }
icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect);
@@ -1135,10 +1160,12 @@ static void common_preview_startjob(void *customdata,
{
ShaderPreview *sp = customdata;
- if (ELEM(sp->pr_method, PR_ICON_RENDER, PR_ICON_DEFERRED))
+ if (ELEM(sp->pr_method, PR_ICON_RENDER, PR_ICON_DEFERRED)) {
icon_preview_startjob(customdata, stop, do_update);
- else
+ }
+ else {
shader_preview_startjob(customdata, stop, do_update);
+ }
}
/* exported functions */
@@ -1228,8 +1255,9 @@ static void icon_preview_endjob(void *customdata)
if (ip->id) {
- if (GS(ip->id->name) == ID_BR)
+ if (GS(ip->id->name) == ID_BR) {
WM_main_add_notifier(NC_BRUSH | NA_EDITED, ip->id);
+ }
#if 0
if (GS(ip->id->name) == ID_MA) {
Material *ma = (Material *)ip->id;
@@ -1241,7 +1269,7 @@ static void icon_preview_endjob(void *customdata)
if (prv_img->gputexture[i]) {
GPU_texture_free(prv_img->gputexture[i]);
prv_img->gputexture[i] = NULL;
- WM_main_add_notifier(NC_MATERIAL|ND_SHADING_DRAW, ip->id);
+ WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ip->id);
}
}
}
@@ -1288,7 +1316,7 @@ void ED_preview_icon_render(
ip.scene = scene;
ip.owner = BKE_previewimg_id_ensure(id);
ip.id = id;
- ip.id_copy = duplicate_ids(id, NULL);
+ ip.id_copy = duplicate_ids(id);
icon_preview_add_size(&ip, rect, sizex, sizey);
@@ -1319,8 +1347,9 @@ void ED_preview_icon_job(
/* render all resolutions from suspended job too */
old_ip = WM_jobs_customdata_get(wm_job);
- if (old_ip)
+ if (old_ip) {
BLI_movelisttolist(&ip->sizes, &old_ip->sizes);
+ }
/* customdata for preview thread */
ip->bmain = CTX_data_main(C);
@@ -1328,11 +1357,12 @@ void ED_preview_icon_job(
ip->depsgraph = CTX_data_depsgraph(C);
ip->owner = owner;
ip->id = id;
- ip->id_copy = duplicate_ids(id, ip->depsgraph);
+ ip->id_copy = duplicate_ids(id);
icon_preview_add_size(ip, rect, sizex, sizey);
- /* Special threading hack: warn main code that this preview is being rendered and cannot be freed... */
+ /* Special threading hack:
+ * warn main code that this preview is being rendered and cannot be freed... */
{
PreviewImage *prv_img = owner;
if (prv_img->tag & PRV_TAG_DEFFERED) {
@@ -1363,7 +1393,8 @@ void ED_preview_shader_job(const bContext *C,
Scene *scene = CTX_data_scene(C);
short id_type = GS(id->name);
- /* Use workspace render only for buttons Window, since the other previews are related to the datablock. */
+ /* Use workspace render only for buttons Window,
+ * since the other previews are related to the datablock. */
if (!check_engine_supports_preview(scene)) {
return;
@@ -1392,7 +1423,7 @@ void ED_preview_shader_job(const bContext *C,
sp->sizey = sizey;
sp->pr_method = method;
sp->id = id;
- sp->id_copy = duplicate_ids(id, sp->depsgraph);
+ sp->id_copy = duplicate_ids(id);
sp->own_id_copy = true;
sp->parent = parent;
sp->slot = slot;
@@ -1431,6 +1462,7 @@ void ED_preview_shader_job(const bContext *C,
void ED_preview_kill_jobs(wmWindowManager *wm, Main *UNUSED(bmain))
{
- if (wm)
+ if (wm) {
WM_jobs_kill(wm, NULL, common_preview_startjob);
+ }
}
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 70157abf2ef..3186f011c6a 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -131,8 +131,9 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
Object *ob = ED_object_context(C);
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
BKE_object_material_slot_add(bmain, ob);
@@ -168,8 +169,9 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
/* Removing material slots in edit mode screws things up, see bug #21822.*/
if (ob == CTX_data_edit_object(C)) {
@@ -366,10 +368,12 @@ static int material_slot_de_select(bContext *C, bool select)
while (a--) {
if (bp->hide == 0) {
changed = true;
- if (select)
+ if (select) {
bp->f1 |= SELECT;
- else
+ }
+ else {
bp->f1 &= ~SELECT;
+ }
}
bp++;
}
@@ -435,13 +439,15 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Material ***matar;
- if (!ob || !(matar = give_matarar(ob)))
+ if (!ob || !(matar = give_matarar(ob))) {
return OPERATOR_CANCELLED;
+ }
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
if (ob != ob_iter && give_matarar(ob_iter)) {
- if (ob->data != ob_iter->data)
+ if (ob->data != ob_iter->data) {
assign_matarar(bmain, ob_iter, matar, ob->totcol);
+ }
if (ob_iter->totcol == ob->totcol) {
ob_iter->actcol = ob->actcol;
@@ -1026,8 +1032,9 @@ static int render_view_remove_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
SceneRenderView *rv = BLI_findlink(&scene->r.views, scene->r.actview);
- if (!BKE_scene_remove_render_view(scene, rv))
+ if (!BKE_scene_remove_render_view(scene, rv)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
@@ -1544,14 +1551,18 @@ void SCENE_OT_freestyle_geometry_modifier_add(wmOperatorType *ot)
static int freestyle_get_modifier_type(PointerRNA *ptr)
{
- if (RNA_struct_is_a(ptr->type, &RNA_LineStyleColorModifier))
+ if (RNA_struct_is_a(ptr->type, &RNA_LineStyleColorModifier)) {
return LS_MODIFIER_TYPE_COLOR;
- else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleAlphaModifier))
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleAlphaModifier)) {
return LS_MODIFIER_TYPE_ALPHA;
- else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleThicknessModifier))
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleThicknessModifier)) {
return LS_MODIFIER_TYPE_THICKNESS;
- else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier))
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier)) {
return LS_MODIFIER_TYPE_GEOMETRY;
+ }
return -1;
}
@@ -1831,8 +1842,9 @@ static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
{
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
- if (ma == NULL)
+ if (ma == NULL) {
return OPERATOR_CANCELLED;
+ }
copy_matcopybuf(CTX_data_main(C), ma);
@@ -1858,8 +1870,9 @@ static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
{
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
- if (ma == NULL)
+ if (ma == NULL) {
return OPERATOR_CANCELLED;
+ }
paste_matcopybuf(CTX_data_main(C), ma);
@@ -1919,8 +1932,9 @@ static void paste_mtex_copybuf(ID *id)
{
MTex **mtex = NULL;
- if (mtexcopied == 0 || mtexcopybuf.tex == NULL)
+ if (mtexcopied == 0 || mtexcopybuf.tex == NULL) {
return;
+ }
switch (GS(id->name)) {
case ID_PA:
@@ -1999,19 +2013,25 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
FreestyleLineStyle *linestyle =
CTX_data_pointer_get_type(C, "line_style", &RNA_FreestyleLineStyle).data;
- if (ma)
+ if (ma) {
id = &ma->id;
- else if (la)
+ }
+ else if (la) {
id = &la->id;
- else if (wo)
+ }
+ else if (wo) {
id = &wo->id;
- else if (psys)
+ }
+ else if (psys) {
id = &psys->part->id;
- else if (linestyle)
+ }
+ else if (linestyle) {
id = &linestyle->id;
+ }
- if (id == NULL)
+ if (id == NULL) {
return OPERATOR_CANCELLED;
+ }
}
paste_mtex_copybuf(id);
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index dfc7610946a..3f3f98bc6e5 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -81,16 +81,19 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
/* don't do this render engine update if we're updating the scene from
* other threads doing e.g. rendering or baking jobs */
- if (!BLI_thread_is_main())
+ if (!BLI_thread_is_main()) {
return;
+ }
/* don't call this recursively for frame updates */
- if (recursive_check)
+ if (recursive_check) {
return;
+ }
/* Do not call if no WM available, see T42688. */
- if (BLI_listbase_is_empty(&bmain->wm))
+ if (BLI_listbase_is_empty(&bmain->wm)) {
return;
+ }
recursive_check = true;
@@ -160,12 +163,14 @@ void ED_render_engine_area_exit(Main *bmain, ScrArea *sa)
ARegion *ar;
wmWindowManager *wm = bmain->wm.first;
- if (sa->spacetype != SPACE_VIEW3D)
+ if (sa->spacetype != SPACE_VIEW3D) {
return;
+ }
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype != RGN_TYPE_WINDOW || !(ar->regiondata))
+ if (ar->regiontype != RGN_TYPE_WINDOW || !(ar->regiondata)) {
continue;
+ }
ED_view3d_stop_render_preview(wm, ar);
}
}
@@ -237,8 +242,9 @@ static void texture_changed(Main *bmain, Tex *tex)
/* find compositing nodes */
if (scene->use_nodes && scene->nodetree) {
for (node = scene->nodetree->nodes.first; node; node = node->next) {
- if (node->id == &tex->id)
+ if (node->id == &tex->id) {
ED_node_tag_update_id(&scene->id);
+ }
}
}
}
@@ -258,9 +264,11 @@ static void image_changed(Main *bmain, Image *ima)
BKE_icon_changed(BKE_icon_id_ensure(&ima->id));
/* textures */
- for (tex = bmain->textures.first; tex; tex = tex->id.next)
- if (tex->ima == ima)
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ if (tex->ima == ima) {
texture_changed(bmain, tex);
+ }
+ }
}
static void scene_changed(Main *bmain, Scene *scene)
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
index 258e98977c7..cd5edcdc3f4 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -92,12 +92,14 @@ static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow *
for (sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_IMAGE) {
sima = sa->spacedata.first;
- if (sima->image && sima->image->type == IMA_TYPE_R_RESULT)
+ if (sima->image && sima->image->type == IMA_TYPE_R_RESULT) {
break;
+ }
}
}
- if (sa)
+ if (sa) {
break;
+ }
}
}
@@ -114,8 +116,9 @@ static ScrArea *find_area_image_empty(bContext *C)
for (sa = sc->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_IMAGE) {
sima = sa->spacedata.first;
- if (!sima->image)
+ if (!sima->image) {
break;
+ }
}
}
@@ -134,18 +137,21 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
SpaceImage *sima;
bool area_was_image = false;
- if (scene->r.displaymode == R_OUTPUT_NONE)
+ if (scene->r.displaymode == R_OUTPUT_NONE) {
return NULL;
+ }
if (scene->r.displaymode == R_OUTPUT_WINDOW) {
int sizex = 30 * UI_DPI_FAC + (scene->r.xsch * scene->r.size) / 100;
int sizey = 60 * UI_DPI_FAC + (scene->r.ysch * scene->r.size) / 100;
/* arbitrary... miniature image window views don't make much sense */
- if (sizex < 320)
+ if (sizex < 320) {
sizex = 320;
- if (sizey < 256)
+ }
+ if (sizey < 256) {
sizey = 256;
+ }
/* changes context! */
if (WM_window_open_temp(C, mx, my, sizex, sizey, WM_WINDOW_RENDER) == NULL) {
@@ -164,8 +170,9 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
sa = NULL;
}
else {
- if (sa && sa->spacetype == SPACE_IMAGE)
+ if (sa && sa->spacetype == SPACE_IMAGE) {
area_was_image = true;
+ }
/* this function returns with changed context */
sa = ED_screen_full_newspace(C, sa, SPACE_IMAGE);
@@ -174,12 +181,14 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
if (!sa) {
sa = find_area_showing_r_result(C, scene, &win);
- if (sa == NULL)
+ if (sa == NULL) {
sa = find_area_image_empty(C);
+ }
/* if area found in other window, we make that one show in front */
- if (win && win != CTX_wm_window(C))
+ if (win && win != CTX_wm_window(C)) {
wm_window_raise(win);
+ }
if (sa == NULL) {
/* find largest open non-image area */
@@ -221,8 +230,9 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
/* Tell the image editor to revert to previous space in space list on close
* _only_ if it wasn't already an image editor when the render was invoked */
- if (area_was_image == 0)
+ if (area_was_image == 0) {
sima->flag |= SI_PREVSPACE;
+ }
else {
/* Leave it alone so the image editor will just go back from
* full screen to the original tiled setup */
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index 381b595171a..8834d243d4a 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -94,12 +94,15 @@ bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene)
wmWindowManager *wm = bmain->wm.first;
WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_ANY);
- if (scene->id.prev)
+ if (scene->id.prev) {
scene_new = scene->id.prev;
- else if (scene->id.next)
+ }
+ else if (scene->id.next) {
scene_new = scene->id.next;
- else
+ }
+ else {
return false;
+ }
WM_window_set_active_scene(bmain, C, win, scene_new);
@@ -245,8 +248,9 @@ static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("scene delete %p\n", scene);
+ }
WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene);
diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt
index daa72ac194c..dc355148ad3 100644
--- a/source/blender/editors/screen/CMakeLists.txt
+++ b/source/blender/editors/screen/CMakeLists.txt
@@ -29,8 +29,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
@@ -39,6 +39,7 @@ set(INC_SYS
set(SRC
area.c
+ area_query.c
area_utils.c
glutil.c
screen_context.c
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 4ca26d108a2..38684afec39 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -151,16 +151,18 @@ void ED_region_do_listen(
/* generic notes first */
switch (note->category) {
case NC_WM:
- if (note->data == ND_FILEREAD)
+ if (note->data == ND_FILEREAD) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_WINDOW:
ED_region_tag_redraw(ar);
break;
}
- if (ar->type && ar->type->listener)
+ if (ar->type && ar->type->listener) {
ar->type->listener(win, sa, ar, note, scene);
+ }
}
/* only exported for WM */
@@ -335,8 +337,9 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
{
AZone *az;
- if (!sa)
+ if (!sa) {
return;
+ }
GPU_line_width(1.0f);
GPU_blend(true);
@@ -421,17 +424,18 @@ static void region_draw_status_text(ScrArea *sa, ARegion *ar)
BLF_draw(fontid, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
}
-/* Follow wmMsgNotifyFn spec */
-void ED_region_do_msg_notify_tag_redraw(bContext *UNUSED(C),
- wmMsgSubscribeKey *UNUSED(msg_key),
- wmMsgSubscribeValue *msg_val)
+void ED_region_do_msg_notify_tag_redraw(
+ /* Follow wmMsgNotifyFn spec */
+ bContext *UNUSED(C),
+ wmMsgSubscribeKey *UNUSED(msg_key),
+ wmMsgSubscribeValue *msg_val)
{
ARegion *ar = msg_val->owner;
ED_region_tag_redraw(ar);
/* This avoids _many_ situations where header/properties control display settings.
* the common case is space properties in the header */
- if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_UI)) {
+ if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_UI)) {
while (ar && ar->prev) {
ar = ar->prev;
}
@@ -442,15 +446,52 @@ void ED_region_do_msg_notify_tag_redraw(bContext *UNUSED(C),
}
}
}
-/* Follow wmMsgNotifyFn spec */
-void ED_area_do_msg_notify_tag_refresh(bContext *UNUSED(C),
- wmMsgSubscribeKey *UNUSED(msg_key),
- wmMsgSubscribeValue *msg_val)
+
+void ED_area_do_msg_notify_tag_refresh(
+ /* Follow wmMsgNotifyFn spec */
+ bContext *UNUSED(C),
+ wmMsgSubscribeKey *UNUSED(msg_key),
+ wmMsgSubscribeValue *msg_val)
{
ScrArea *sa = msg_val->user_data;
ED_area_tag_refresh(sa);
}
+static void region_do_msg_notify_tag_redraw(
+ /* Follow wmMsgNotifyFn spec */
+ bContext *UNUSED(C),
+ wmMsgSubscribeKey *UNUSED(msg_key),
+ wmMsgSubscribeValue *msg_val)
+{
+ ARegion *ar = msg_val->owner;
+ ED_region_tag_redraw(ar);
+
+ /* FIXME(campbell): shouldn't be needed. */
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL);
+}
+
+void ED_area_do_mgs_subscribe_for_tool_header(
+ /* Follow ARegionType.message_subscribe */
+ const struct bContext *UNUSED(C),
+ struct WorkSpace *workspace,
+ struct Scene *UNUSED(scene),
+ struct bScreen *UNUSED(screen),
+ struct ScrArea *UNUSED(sa),
+ struct ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ /* TODO(campbell): investigate why
+ * ED_region_do_msg_notify_tag_redraw doesn't work here. */
+ // .notify = ED_region_do_msg_notify_tag_redraw,
+ .notify = region_do_msg_notify_tag_redraw,
+ };
+ WM_msg_subscribe_rna_prop(
+ mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
+}
+
/**
* Although there's no general support for minimizing areas, the status-bar can
* be snapped to be only a few pixels high. A few pixels rather than 0 so it
@@ -491,8 +532,9 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
ARegionType *at = ar->type;
/* see BKE_spacedata_draw_locks() */
- if (at->do_lock)
+ if (at->do_lock) {
return;
+ }
ar->do_draw |= RGN_DRAWING;
@@ -516,7 +558,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
at->draw(C, ar);
}
- /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
+ /* XXX test: add convention to end regions always in pixel space,
+ * for drawing of borders/gestures etc */
ED_region_pixelspace(ar);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
@@ -530,8 +573,11 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(drand48(), drand48(), drand48(), 0.1f);
- immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin,
- ar->drawrct.xmax - ar->winrct.xmin, ar->drawrct.ymax - ar->winrct.ymin);
+ immRectf(pos,
+ ar->drawrct.xmin - ar->winrct.xmin,
+ ar->drawrct.ymin - ar->winrct.ymin,
+ ar->drawrct.xmax - ar->winrct.xmin,
+ ar->drawrct.ymax - ar->winrct.ymin);
immUnbindProgram();
GPU_blend(false);
#endif
@@ -615,8 +661,9 @@ void ED_region_tag_redraw(ARegion *ar)
void ED_region_tag_redraw_overlay(ARegion *ar)
{
- if (ar)
+ if (ar) {
ar->do_draw_overlay = RGN_DRAW;
+ }
}
void ED_region_tag_redraw_no_rebuild(ARegion *ar)
@@ -659,18 +706,22 @@ void ED_area_tag_redraw(ScrArea *sa)
{
ARegion *ar;
- if (sa)
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ if (sa) {
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ED_region_tag_redraw(ar);
+ }
+ }
}
void ED_area_tag_redraw_no_rebuild(ScrArea *sa)
{
ARegion *ar;
- if (sa)
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ if (sa) {
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ED_region_tag_redraw_no_rebuild(ar);
+ }
+ }
}
void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
@@ -688,8 +739,9 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
void ED_area_tag_refresh(ScrArea *sa)
{
- if (sa)
+ if (sa) {
sa->do_refresh = true;
+ }
}
/* *************************************************************** */
@@ -700,14 +752,16 @@ void ED_area_status_text(ScrArea *sa, const char *str)
ARegion *ar;
/* happens when running transform operators in background mode */
- if (sa == NULL)
+ if (sa == NULL) {
return;
+ }
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_HEADER) {
if (str) {
- if (ar->headerstr == NULL)
+ if (ar->headerstr == NULL) {
ar->headerstr = MEM_mallocN(UI_MAX_DRAW_STR, "headerprint");
+ }
BLI_strncpy(ar->headerstr, str, UI_MAX_DRAW_STR);
BLI_str_rstrip(ar->headerstr);
}
@@ -726,12 +780,14 @@ void ED_workspace_status_text(bContext *C, const char *str)
WorkSpace *workspace = CTX_wm_workspace(C);
/* Can be NULL when running operators in background mode. */
- if (workspace == NULL)
+ if (workspace == NULL) {
return;
+ }
if (str) {
- if (workspace->status_text == NULL)
+ if (workspace->status_text == NULL) {
workspace->status_text = MEM_mallocN(UI_MAX_DRAW_STR, "headerprint");
+ }
BLI_strncpy(workspace->status_text, str, UI_MAX_DRAW_STR);
}
else if (workspace->status_text) {
@@ -773,26 +829,28 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea
return;
}
- float coords[4][4] = {/* Bottom-left. */
- {sa->totrct.xmin - U.pixelsize,
- sa->totrct.ymin - U.pixelsize,
- sa->totrct.xmin + AZONESPOTW,
- sa->totrct.ymin + AZONESPOTH},
- /* Bottom-right. */
- {sa->totrct.xmax - AZONESPOTW,
- sa->totrct.ymin - U.pixelsize,
- sa->totrct.xmax + U.pixelsize,
- sa->totrct.ymin + AZONESPOTH},
- /* Top-left. */
- {sa->totrct.xmin - U.pixelsize,
- sa->totrct.ymax - AZONESPOTH,
- sa->totrct.xmin + AZONESPOTW,
- sa->totrct.ymax + U.pixelsize},
- /* Top-right. */
- {sa->totrct.xmax - AZONESPOTW,
- sa->totrct.ymax - AZONESPOTH,
- sa->totrct.xmax + U.pixelsize,
- sa->totrct.ymax + U.pixelsize}};
+ float coords[4][4] = {
+ /* Bottom-left. */
+ {sa->totrct.xmin - U.pixelsize,
+ sa->totrct.ymin - U.pixelsize,
+ sa->totrct.xmin + AZONESPOTW,
+ sa->totrct.ymin + AZONESPOTH},
+ /* Bottom-right. */
+ {sa->totrct.xmax - AZONESPOTW,
+ sa->totrct.ymin - U.pixelsize,
+ sa->totrct.xmax + U.pixelsize,
+ sa->totrct.ymin + AZONESPOTH},
+ /* Top-left. */
+ {sa->totrct.xmin - U.pixelsize,
+ sa->totrct.ymax - AZONESPOTH,
+ sa->totrct.xmin + AZONESPOTW,
+ sa->totrct.ymax + U.pixelsize},
+ /* Top-right. */
+ {sa->totrct.xmax - AZONESPOTW,
+ sa->totrct.ymax - AZONESPOTH,
+ sa->totrct.xmax + U.pixelsize,
+ sa->totrct.ymax + U.pixelsize},
+ };
for (int i = 0; i < 4; i++) {
/* can't click on bottom corners on OS X, already used for resizing */
@@ -822,8 +880,9 @@ static void fullscreen_azone_initialize(ScrArea *sa, ARegion *ar)
{
AZone *az;
- if (ED_area_is_global(sa) || (ar->regiontype != RGN_TYPE_WINDOW))
+ if (ED_area_is_global(sa) || (ar->regiontype != RGN_TYPE_WINDOW)) {
return;
+ }
az = (AZone *)MEM_callocN(sizeof(AZone), "fullscreen action zone");
BLI_addtail(&(sa->actionzones), az);
@@ -868,7 +927,6 @@ static void region_azone_edge(AZone *az, ARegion *ar)
az->y2 = ar->winrct.ymax;
break;
}
-
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
@@ -884,8 +942,9 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
const float tab_size_y = 0.4f * U.widget_unit;
for (azt = sa->actionzones.first; azt; azt = azt->next) {
- if (azt->edge == az->edge)
+ if (azt->edge == az->edge) {
tot++;
+ }
}
switch (az->edge) {
@@ -926,7 +985,7 @@ static bool region_azone_edge_poll(const ARegion *ar, const bool is_fullscreen)
if (is_hidden && is_fullscreen) {
return false;
}
- if (!is_hidden && ar->regiontype == RGN_TYPE_HEADER) {
+ if (!is_hidden && ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
return false;
}
@@ -1006,15 +1065,25 @@ static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *ar, c
{
const bool is_fullscreen = screen->state == SCREENFULL;
+ /* Only display tab or icons when the header region is hidden
+ * (not the tool header - they overlap). */
+ if (ar->regiontype == RGN_TYPE_TOOL_HEADER) {
+ return;
+ }
+
/* edge code (t b l r) is along which area edge azone will be drawn */
- if (alignment == RGN_ALIGN_TOP)
+ if (alignment == RGN_ALIGN_TOP) {
region_azone_edge_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT, is_fullscreen);
- else if (alignment == RGN_ALIGN_BOTTOM)
+ }
+ else if (alignment == RGN_ALIGN_BOTTOM) {
region_azone_edge_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen);
- else if (alignment == RGN_ALIGN_RIGHT)
+ }
+ else if (alignment == RGN_ALIGN_RIGHT) {
region_azone_edge_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT, is_fullscreen);
- else if (alignment == RGN_ALIGN_LEFT)
+ }
+ else if (alignment == RGN_ALIGN_LEFT) {
region_azone_edge_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT, is_fullscreen);
+ }
if (is_fullscreen) {
fullscreen_azone_initialize(sa, ar);
@@ -1141,8 +1210,9 @@ static void region_rect_recursive(
{
rcti *remainder_prev = remainder;
- if (ar == NULL)
+ if (ar == NULL) {
return;
+ }
int prev_winx = ar->winx;
int prev_winy = ar->winy;
@@ -1151,9 +1221,11 @@ static void region_rect_recursive(
BLI_rcti_init(&ar->winrct, 0, 0, 0, 0);
/* for test; allow split of previously defined region */
- if (ar->alignment & RGN_SPLIT_PREV)
- if (ar->prev)
+ if (ar->alignment & RGN_SPLIT_PREV) {
+ if (ar->prev) {
remainder = &ar->prev->winrct;
+ }
+ }
int alignment = ar->alignment & ~RGN_SPLIT_PREV;
@@ -1178,6 +1250,9 @@ static void region_rect_recursive(
else if (ar->regiontype == RGN_TYPE_HEADER) {
prefsizey = ED_area_headersize();
}
+ else if (ar->regiontype == RGN_TYPE_TOOL_HEADER) {
+ prefsizey = ED_area_headersize();
+ }
else if (ar->regiontype == RGN_TYPE_FOOTER) {
prefsizey = ED_area_footersize();
}
@@ -1251,8 +1326,9 @@ static void region_rect_recursive(
else {
int fac = rct_fits(winrct, 'v', prefsizey);
- if (fac < 0)
+ if (fac < 0) {
prefsizey += fac;
+ }
ar->winrct = *winrct;
@@ -1275,8 +1351,9 @@ static void region_rect_recursive(
else {
int fac = rct_fits(winrct, 'h', prefsizex);
- if (fac < 0)
+ if (fac < 0) {
prefsizex += fac;
+ }
ar->winrct = *winrct;
@@ -1330,8 +1407,9 @@ static void region_rect_recursive(
if (count != 4) {
/* let's stop adding regions */
BLI_rcti_init(remainder, 0, 0, 0, 0);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("region quadsplit failed\n");
+ }
}
else {
quad = 1;
@@ -1366,10 +1444,12 @@ static void region_rect_recursive(
/* if region opened normally, we store this for hide/reveal usage */
/* prevent rounding errors for UI_DPI_FAC mult and divide */
- if (ar->winx > 1)
+ if (ar->winx > 1) {
ar->sizex = (ar->winx + 0.5f) / UI_DPI_FAC;
- if (ar->winy > 1)
+ }
+ if (ar->winy > 1) {
ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC;
+ }
/* exception for multiple overlapping regions on same spot */
if (ar->overlap && (alignment != RGN_ALIGN_FLOAT)) {
@@ -1444,7 +1524,8 @@ static void area_calc_totrct(ScrArea *sa, const rcti *window_rect)
sa->totrct.ymax -= px;
}
/* Although the following asserts are correct they lead to a very unstable Blender.
- * And the asserts would fail even in 2.7x (they were added in 2.8x as part of the top-bar commit).
+ * And the asserts would fail even in 2.7x
+ * (they were added in 2.8x as part of the top-bar commit).
* For more details see T54864. */
#if 0
BLI_assert(sa->totrct.xmin >= 0);
@@ -1463,12 +1544,20 @@ static void region_subwindow(ARegion *ar)
{
bool hidden = (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) != 0;
- if ((ar->alignment & RGN_SPLIT_PREV) && ar->prev)
+ if ((ar->alignment & RGN_SPLIT_PREV) && ar->prev) {
hidden = hidden || (ar->prev->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL));
+ }
ar->visible = !hidden;
}
+static bool event_in_markers_region(const ARegion *ar, const wmEvent *event)
+{
+ rcti rect = ar->winrct;
+ rect.ymax = rect.ymin + UI_MARKER_MARGIN_Y;
+ return BLI_rcti_isect_pt(&rect, event->x, event->y);
+}
+
/**
* \param ar: Region, may be NULL when adding handlers for \a sa.
*/
@@ -1510,13 +1599,7 @@ static void ed_default_handlers(
if (flag & ED_KEYMAP_MARKERS) {
/* time-markers */
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Markers", 0, 0);
-
- /* use a boundbox restricted map */
- /* same local check for all areas */
- static rcti rect = {0, 10000, 0, -1};
- rect.ymax = UI_MARKER_MARGIN_Y;
- BLI_assert(ar->type->regionid == RGN_TYPE_WINDOW);
- WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct);
+ WM_event_add_keymap_handler_poll(handlers, keymap, event_in_markers_region);
}
if (flag & ED_KEYMAP_ANIMATION) {
/* frame changing and timeline operators (for time spaces) */
@@ -1637,8 +1720,9 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
sa->type = BKE_spacetype_from_id(sa->spacetype);
}
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ar->type = BKE_regiontype_from_id_or_first(sa->type, ar->regiontype);
+ }
/* area sizes */
area_calc_totrct(sa, &window_rect);
@@ -1652,8 +1736,9 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
/* default area handlers */
ed_default_handlers(wm, sa, NULL, &sa->handlers, sa->type->keymapflag);
/* checks spacedata, adds own handlers */
- if (sa->type->init)
+ if (sa->type->init) {
sa->type->init(wm, sa);
+ }
/* clear all azones, add the area triangle widgets */
area_azone_initialize(win, screen, sa);
@@ -1732,12 +1817,11 @@ void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *ar)
}
/* for use after changing visibility of regions */
-void ED_region_visibility_change_update(bContext *C, ARegion *ar)
+void ED_region_visibility_change_update(bContext *C, ScrArea *sa, ARegion *ar)
{
- ScrArea *sa = CTX_wm_area(C);
-
- if (ar->flag & RGN_FLAG_HIDDEN)
+ if (ar->flag & RGN_FLAG_HIDDEN) {
WM_event_remove_handlers(C, &ar->handlers);
+ }
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
ED_area_tag_redraw(sa);
@@ -1752,10 +1836,10 @@ void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade)
if (do_fade && ar->overlap) {
/* starts a timer, and in end calls the stuff below itself (region_sblend_invoke()) */
- region_blend_start(C, sa, ar);
+ ED_region_visibility_change_update_animated(C, sa, ar);
}
else {
- ED_region_visibility_change_update(C, ar);
+ ED_region_visibility_change_update(C, sa, ar);
}
}
@@ -1791,8 +1875,9 @@ void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free)
/* regions */
if (do_free) {
st = BKE_spacetype_from_id(spacetype);
- for (ar = sa_dst->regionbase.first; ar; ar = ar->next)
+ for (ar = sa_dst->regionbase.first; ar; ar = ar->next) {
BKE_area_region_free(st, ar);
+ }
BLI_freelistN(&sa_dst->regionbase);
}
st = BKE_spacetype_from_id(sa_src->spacetype);
@@ -1889,9 +1974,11 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
* (e.g. with properties editor) until space-data is properly created */
/* check previously stored space */
- for (sl = sa->spacedata.first; sl; sl = sl->next)
- if (sl->spacetype == type)
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == type) {
break;
+ }
+ }
/* old spacedata... happened during work on 2.50, remove */
if (sl && BLI_listbase_is_empty(&sl->regionbase)) {
@@ -1922,8 +2009,9 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
BLI_addhead(&sa->spacedata, sl);
/* swap regions */
- if (slold)
+ if (slold) {
slold->regionbase = sa->regionbase;
+ }
sa->regionbase = sl->regionbase;
BLI_listbase_clear(&sl->regionbase);
}
@@ -1934,7 +2022,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
/* Spaces with footer. */
if (st->spaceid == SPACE_TEXT) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_HEADER) {
+ if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
ar->alignment = header_alignment;
}
if (ar->regiontype == RGN_TYPE_FOOTER) {
@@ -1947,7 +2035,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
}
else {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_HEADER) {
+ if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
ar->alignment = header_alignment;
break;
}
@@ -2032,6 +2120,7 @@ static ThemeColorID region_background_color_id(const bContext *C, const ARegion
switch (region->regiontype) {
case RGN_TYPE_HEADER:
+ case RGN_TYPE_TOOL_HEADER:
if (ED_screen_area_active(C) || ED_area_is_global(area)) {
return TH_HEADER;
}
@@ -2217,8 +2306,9 @@ void ED_region_panels_layout_ex(
BLI_SMALLSTACK_DECLARE(pt_stack, PanelType *);
- if (contextnr != -1)
+ if (contextnr != -1) {
is_context_new = UI_view2d_tab_set(v2d, contextnr);
+ }
/* before setting the view */
if (vertical) {
@@ -2339,7 +2429,8 @@ void ED_region_panels_layout_ex(
}
}
else if (vertical) {
- /* we always keep the scroll offset - so the total view gets increased with the scrolled away part */
+ /* We always keep the scroll offset -
+ * so the total view gets increased with the scrolled away part. */
if (v2d->cur.ymax < -FLT_EPSILON) {
/* Clamp to lower view boundary */
if (v2d->tot.ymin < -v2d->winy) {
@@ -2425,9 +2516,8 @@ void ED_region_panels_draw(const bContext *C, ARegion *ar)
mask_buf.xmax -= UI_PANEL_CATEGORY_MARGIN_WIDTH;
mask = &mask_buf;
}
- View2DScrollers *scrollers = UI_view2d_scrollers_calc(
- C, v2d, mask, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ View2DScrollers *scrollers = UI_view2d_scrollers_calc(v2d, mask);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -2474,7 +2564,8 @@ void ED_region_header_layout(const bContext *C, ARegion *ar)
int yco = buttony + (ar->winy - buttony) / 2;
int maxco = xco;
- /* XXX workaround for 1 px alignment issue. Not sure what causes it... Would prefer a proper fix - Julian */
+ /* XXX workaround for 1 px alignment issue. Not sure what causes it...
+ * Would prefer a proper fix - Julian */
if (!ELEM(CTX_wm_area(C)->spacetype, SPACE_TOPBAR, SPACE_STATUSBAR)) {
yco -= 1;
}
@@ -2506,15 +2597,17 @@ void ED_region_header_layout(const bContext *C, ARegion *ar)
/* for view2d */
xco = uiLayoutGetWidth(layout);
- if (xco > maxco)
+ if (xco > maxco) {
maxco = xco;
+ }
}
UI_block_layout_resolve(block, &xco, &yco);
/* for view2d */
- if (xco > maxco)
+ if (xco > maxco) {
maxco = xco;
+ }
int new_sizex = (maxco + UI_HEADER_OFFSET) / UI_DPI_FAC;
@@ -2855,8 +2948,9 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
do_newline = true;
}
- if (do_newline)
+ if (do_newline) {
ofs_y += vertical_offset;
+ }
} /* Strip */
else if (i == 1 || i == 2) {
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
@@ -2988,8 +3082,9 @@ void ED_region_image_metadata_draw(
rctf rect;
uiStyle *style = UI_style_get_dpi();
- if (!ibuf->metadata)
+ if (!ibuf->metadata) {
return;
+ }
/* find window pixel coordinates of origin */
GPU_matrix_push();
@@ -3091,8 +3186,9 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
/* gridsize adapted to zoom level */
gridsize = 0.5f * (zoomx + zoomy);
- if (gridsize <= 0.0f)
+ if (gridsize <= 0.0f) {
return;
+ }
if (gridsize < 1.0f) {
while (gridsize < 1.0f) {
@@ -3168,8 +3264,9 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect)
ARegion *arn = ar;
/* allow function to be called without area */
- while (arn->prev)
+ while (arn->prev) {
arn = arn->prev;
+ }
*rect = ar->winrct;
diff --git a/source/blender/editors/screen/area_query.c b/source/blender/editors/screen/area_query.c
new file mode 100644
index 00000000000..420d70e63fb
--- /dev/null
+++ b/source/blender/editors/screen/area_query.c
@@ -0,0 +1,172 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup edscr
+ *
+ * Query functions for area/region.
+ */
+
+#include "DNA_userdef_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
+
+#include "RNA_types.h"
+
+#include "WM_api.h"
+
+#include "ED_screen.h"
+
+#include "UI_interface.h"
+#include "UI_view2d.h"
+
+bool ED_region_overlap_isect_x(const ARegion *ar, const int event_x)
+{
+ BLI_assert(ar->overlap);
+ /* No contents, skip it. */
+ if (ar->v2d.mask.xmin == ar->v2d.mask.xmax) {
+ return false;
+ }
+ return BLI_rctf_isect_x(&ar->v2d.tot,
+ UI_view2d_region_to_view_x(&ar->v2d, event_x - ar->winrct.xmin));
+}
+
+bool ED_region_overlap_isect_y(const ARegion *ar, const int event_y)
+{
+ BLI_assert(ar->overlap);
+ /* No contents, skip it. */
+ if (ar->v2d.mask.ymin == ar->v2d.mask.ymax) {
+ return false;
+ }
+ return BLI_rctf_isect_y(&ar->v2d.tot,
+ UI_view2d_region_to_view_y(&ar->v2d, event_y - ar->winrct.ymin));
+}
+
+bool ED_region_overlap_isect_xy(const ARegion *ar, const int event_xy[2])
+{
+ return (ED_region_overlap_isect_x(ar, event_xy[0]) &&
+ ED_region_overlap_isect_y(ar, event_xy[1]));
+}
+
+bool ED_region_panel_category_gutter_calc_rect(const ARegion *ar, rcti *r_ar_gutter)
+{
+ *r_ar_gutter = ar->winrct;
+ if (UI_panel_category_is_visible(ar)) {
+ const int category_tabs_width = round_fl_to_int(UI_view2d_scale_get_x(&ar->v2d) *
+ UI_PANEL_CATEGORY_MARGIN_WIDTH);
+ if (ar->alignment == RGN_ALIGN_LEFT) {
+ r_ar_gutter->xmax = r_ar_gutter->xmin + category_tabs_width;
+ }
+ else if (ar->alignment == RGN_ALIGN_RIGHT) {
+ r_ar_gutter->xmin = r_ar_gutter->xmax - category_tabs_width;
+ }
+ else {
+ BLI_assert(!"Unsupported alignment");
+ }
+ return true;
+ }
+ return false;
+}
+
+bool ED_region_panel_category_gutter_isect_xy(const ARegion *ar, const int event_xy[2])
+{
+ rcti ar_gutter;
+ if (ED_region_panel_category_gutter_calc_rect(ar, &ar_gutter)) {
+ return BLI_rcti_isect_pt_v(&ar_gutter, event_xy);
+ }
+ return false;
+}
+
+bool ED_region_overlap_isect_x_with_margin(const ARegion *ar, const int event_x, const int margin)
+{
+ BLI_assert(ar->overlap);
+ /* No contents, skip it. */
+ if (ar->v2d.mask.xmin == ar->v2d.mask.xmax) {
+ return false;
+ }
+ int region_x = event_x - ar->winrct.xmin;
+ return ((ar->v2d.tot.xmin <= UI_view2d_region_to_view_x(&ar->v2d, region_x + margin)) &&
+ (ar->v2d.tot.xmax >= UI_view2d_region_to_view_x(&ar->v2d, region_x - margin)));
+}
+
+bool ED_region_overlap_isect_y_with_margin(const ARegion *ar, const int event_y, const int margin)
+{
+ BLI_assert(ar->overlap);
+ /* No contents, skip it. */
+ if (ar->v2d.mask.ymin == ar->v2d.mask.ymax) {
+ return false;
+ }
+ int region_y = event_y - ar->winrct.ymin;
+ return ((ar->v2d.tot.ymin <= UI_view2d_region_to_view_y(&ar->v2d, region_y + margin)) &&
+ (ar->v2d.tot.ymax >= UI_view2d_region_to_view_y(&ar->v2d, region_y - margin)));
+}
+
+bool ED_region_overlap_isect_xy_with_margin(const ARegion *ar,
+ const int event_xy[2],
+ const int margin)
+{
+ return (ED_region_overlap_isect_x_with_margin(ar, event_xy[0], margin) &&
+ ED_region_overlap_isect_y_with_margin(ar, event_xy[1], margin));
+}
+
+bool ED_region_contains_xy(const ARegion *ar, const int event_xy[2])
+{
+ /* Only use the margin when inside the region. */
+ if (BLI_rcti_isect_pt_v(&ar->winrct, event_xy)) {
+ if (ar->overlap) {
+ const int overlap_margin = UI_REGION_OVERLAP_MARGIN;
+ /* Note the View2D.tot isn't reliable for headers with spacers otherwise
+ * we'd check #ED_region_overlap_isect_xy_with_margin for both bases. */
+ if (ar->v2d.keeptot == V2D_KEEPTOT_STRICT) {
+ /* Header. */
+ rcti rect;
+ BLI_rcti_init_pt_radius(&rect, event_xy, overlap_margin);
+ if (UI_region_but_find_rect_over(ar, &rect) == NULL) {
+ return false;
+ }
+ }
+ else {
+ /* Side-bar & any other kind of overlapping region. */
+
+ /* Check alignment to avoid region tabs being clipped out
+ * by only clipping a single axis for aligned regions. */
+ if (ELEM(ar->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
+ if (!ED_region_overlap_isect_x_with_margin(ar, event_xy[0], overlap_margin)) {
+ return false;
+ }
+ }
+ else if (ELEM(ar->alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
+ if (ED_region_panel_category_gutter_isect_xy(ar, event_xy)) {
+ /* pass */
+ }
+ else if (!ED_region_overlap_isect_y_with_margin(ar, event_xy[1], overlap_margin)) {
+ return false;
+ }
+ }
+ else {
+ /* No panel categories for horizontal regions currently. */
+ if (!ED_region_overlap_isect_xy_with_margin(ar, event_xy, overlap_margin)) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+}
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 7fec62157c1..fc771e0db77 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -58,37 +58,6 @@ void set_inverted_drawing(int enable)
GL_TOGGLE(GL_DITHER, !enable);
}
-float glaGetOneFloat(int param)
-{
- GLfloat v;
- glGetFloatv(param, &v);
- return v;
-}
-
-int glaGetOneInt(int param)
-{
- GLint v;
- glGetIntegerv(param, &v);
- return v;
-}
-
-void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y)
-{
- GLubyte dummy = 0;
-
- /* As long as known good coordinates are correct
- * this is guaranteed to generate an ok raster
- * position (ignoring potential (real) overflow
- * issues).
- */
- glRasterPos2f(known_good_x, known_good_y);
-
- /* Now shift the raster position to where we wanted
- * it in the first place using the glBitmap trick.
- */
- glBitmap(0, 0, 0, 0, x - known_good_x, y - known_good_y, &dummy);
-}
-
static int get_cached_work_texture(int *r_w, int *r_h)
{
static GLint texid = -1;
@@ -203,12 +172,15 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
nsubparts_x = (img_w + (offset_x - 1)) / (offset_x);
nsubparts_y = (img_h + (offset_y - 1)) / (offset_y);
- if (format == GL_RGBA)
+ if (format == GL_RGBA) {
components = 4;
- else if (format == GL_RGB)
+ }
+ else if (format == GL_RGB) {
components = 3;
- else if (format == GL_RED)
+ }
+ else if (format == GL_RED) {
components = 1;
+ }
else {
BLI_assert(!"Incompatible format passed to glaDrawPixelsTexScaled");
return;
@@ -246,8 +218,9 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
float rast_x = x + subpart_x * offset_x * xzoom;
float rast_y = y + subpart_y * offset_y * yzoom;
/* check if we already got these because we always get 2 more when doing seamless */
- if (subpart_w <= seamless || subpart_h <= seamless)
+ if (subpart_w <= seamless || subpart_h <= seamless) {
continue;
+ }
if (use_clipping) {
if (rast_x + (float)(subpart_w - offset_right) * xzoom * scaleX < clip_min_x ||
@@ -273,7 +246,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
subpart_x * offset_x * components]);
/* add an extra border of pixels so linear looks ok at edges of full image */
- if (subpart_w < tex_w)
+ if (subpart_w < tex_w) {
glTexSubImage2D(GL_TEXTURE_2D,
0,
subpart_w,
@@ -284,7 +257,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_FLOAT,
&f_rect[((size_t)subpart_y) * offset_y * img_w * components +
(subpart_x * offset_x + subpart_w - 1) * components]);
- if (subpart_h < tex_h)
+ }
+ if (subpart_h < tex_h) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
@@ -296,7 +270,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_FLOAT,
&f_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components +
subpart_x * offset_x * components]);
- if (subpart_w < tex_w && subpart_h < tex_h)
+ }
+ if (subpart_w < tex_w && subpart_h < tex_h) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
@@ -308,6 +283,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_FLOAT,
&f_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components +
(subpart_x * offset_x + subpart_w - 1) * components]);
+ }
}
else {
glTexSubImage2D(GL_TEXTURE_2D,
@@ -321,7 +297,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
&uc_rect[((size_t)subpart_y) * offset_y * img_w * components +
subpart_x * offset_x * components]);
- if (subpart_w < tex_w)
+ if (subpart_w < tex_w) {
glTexSubImage2D(GL_TEXTURE_2D,
0,
subpart_w,
@@ -332,7 +308,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_UNSIGNED_BYTE,
&uc_rect[((size_t)subpart_y) * offset_y * img_w * components +
(subpart_x * offset_x + subpart_w - 1) * components]);
- if (subpart_h < tex_h)
+ }
+ if (subpart_h < tex_h) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
@@ -344,7 +321,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_UNSIGNED_BYTE,
&uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components +
subpart_x * offset_x * components]);
- if (subpart_w < tex_w && subpart_h < tex_h)
+ }
+ if (subpart_w < tex_w && subpart_h < tex_h) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
@@ -356,6 +334,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_UNSIGNED_BYTE,
&uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components +
(subpart_x * offset_x + subpart_w - 1) * components]);
+ }
}
immBegin(GPU_PRIM_TRI_FAN, 4);
@@ -382,7 +361,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
/* NOTE: Weirdly enough this is only required on macOS. Without this there is some sort of
* bleeding of data is happening from tiles which are drawn later on.
- * This doesn't seem to be too slow, but still would be nice to have fast and nice solution. */
+ * This doesn't seem to be too slow,
+ * but still would be nice to have fast and nice solution. */
#ifdef __APPLE__
GPU_flush();
#endif
@@ -525,7 +505,8 @@ float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist)
/* This adjustment effectively results in reducing the Z value by 0.25%.
*
* winmat[14] actually evaluates to `-2 * far * near / (far - near)`,
- * is very close to -0.2 with default clip range, and is used as the coefficient multiplied by `w / z`,
+ * is very close to -0.2 with default clip range,
+ * and is used as the coefficient multiplied by `w / z`,
* thus controlling the z dependent part of the depth value.
*/
return winmat[14] * -0.0025f * dist;
@@ -564,31 +545,32 @@ void bglPolygonOffset(float viewdist, float dist)
/* **** Color management helper functions for GLSL display/transform ***** */
/* Draw given image buffer on a screen using GLSL for display transform */
-void glaDrawImBuf_glsl_clipping(ImBuf *ibuf,
- float x,
- float y,
- int zoomfilter,
- ColorManagedViewSettings *view_settings,
- ColorManagedDisplaySettings *display_settings,
- float clip_min_x,
- float clip_min_y,
- float clip_max_x,
- float clip_max_y,
- float zoom_x,
- float zoom_y)
+void ED_draw_imbuf_clipping(ImBuf *ibuf,
+ float x,
+ float y,
+ int zoomfilter,
+ ColorManagedViewSettings *view_settings,
+ ColorManagedDisplaySettings *display_settings,
+ float clip_min_x,
+ float clip_min_y,
+ float clip_max_x,
+ float clip_max_y,
+ float zoom_x,
+ float zoom_y)
{
bool force_fallback = false;
bool need_fallback = true;
/* Early out */
- if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
return;
+ }
/* Single channel images could not be transformed using GLSL yet */
force_fallback |= ibuf->channels == 1;
/* If user decided not to use GLSL, fallback to glaDrawPixelsAuto */
- force_fallback |= (U.image_draw_method != IMAGE_DRAW_METHOD_GLSL);
+ force_fallback |= (ED_draw_imbuf_method(ibuf) != IMAGE_DRAW_METHOD_GLSL);
/* Try to draw buffer using GLSL display transform */
if (force_fallback == false) {
@@ -618,12 +600,15 @@ void glaDrawImBuf_glsl_clipping(ImBuf *ibuf,
if (ibuf->rect_float) {
int format = 0;
- if (ibuf->channels == 3)
+ if (ibuf->channels == 3) {
format = GL_RGB;
- else if (ibuf->channels == 4)
+ }
+ else if (ibuf->channels == 4) {
format = GL_RGBA;
- else
+ }
+ else {
BLI_assert(!"Incompatible number of channels for GLSL display");
+ }
if (format != 0) {
immDrawPixelsTex_clipping(&state,
@@ -702,65 +687,80 @@ void glaDrawImBuf_glsl_clipping(ImBuf *ibuf,
}
}
-void glaDrawImBuf_glsl(ImBuf *ibuf,
- float x,
- float y,
- int zoomfilter,
- ColorManagedViewSettings *view_settings,
- ColorManagedDisplaySettings *display_settings,
- float zoom_x,
- float zoom_y)
+void ED_draw_imbuf(ImBuf *ibuf,
+ float x,
+ float y,
+ int zoomfilter,
+ ColorManagedViewSettings *view_settings,
+ ColorManagedDisplaySettings *display_settings,
+ float zoom_x,
+ float zoom_y)
{
- glaDrawImBuf_glsl_clipping(ibuf,
- x,
- y,
- zoomfilter,
- view_settings,
- display_settings,
- 0.0f,
- 0.0f,
- 0.0f,
- 0.0f,
- zoom_x,
- zoom_y);
+ ED_draw_imbuf_clipping(ibuf,
+ x,
+ y,
+ zoomfilter,
+ view_settings,
+ display_settings,
+ 0.0f,
+ 0.0f,
+ 0.0f,
+ 0.0f,
+ zoom_x,
+ zoom_y);
}
-void glaDrawImBuf_glsl_ctx_clipping(const bContext *C,
- ImBuf *ibuf,
- float x,
- float y,
- int zoomfilter,
- float clip_min_x,
- float clip_min_y,
- float clip_max_x,
- float clip_max_y,
- float zoom_x,
- float zoom_y)
+void ED_draw_imbuf_ctx_clipping(const bContext *C,
+ ImBuf *ibuf,
+ float x,
+ float y,
+ int zoomfilter,
+ float clip_min_x,
+ float clip_min_y,
+ float clip_max_x,
+ float clip_max_y,
+ float zoom_x,
+ float zoom_y)
{
ColorManagedViewSettings *view_settings;
ColorManagedDisplaySettings *display_settings;
IMB_colormanagement_display_settings_from_ctx(C, &view_settings, &display_settings);
- glaDrawImBuf_glsl_clipping(ibuf,
- x,
- y,
- zoomfilter,
- view_settings,
- display_settings,
- clip_min_x,
- clip_min_y,
- clip_max_x,
- clip_max_y,
- zoom_x,
- zoom_y);
+ ED_draw_imbuf_clipping(ibuf,
+ x,
+ y,
+ zoomfilter,
+ view_settings,
+ display_settings,
+ clip_min_x,
+ clip_min_y,
+ clip_max_x,
+ clip_max_y,
+ zoom_x,
+ zoom_y);
}
-void glaDrawImBuf_glsl_ctx(
+void ED_draw_imbuf_ctx(
const bContext *C, ImBuf *ibuf, float x, float y, int zoomfilter, float zoom_x, float zoom_y)
{
- glaDrawImBuf_glsl_ctx_clipping(
- C, ibuf, x, y, zoomfilter, 0.0f, 0.0f, 0.0f, 0.0f, zoom_x, zoom_y);
+ ED_draw_imbuf_ctx_clipping(C, ibuf, x, y, zoomfilter, 0.0f, 0.0f, 0.0f, 0.0f, zoom_x, zoom_y);
+}
+
+int ED_draw_imbuf_method(ImBuf *ibuf)
+{
+ if (U.image_draw_method == IMAGE_DRAW_METHOD_AUTO) {
+ /* Use faster GLSL when CPU to GPU transfer is unlikely to be a bottleneck,
+ * otherwise do color management on CPU side. */
+ const size_t threshold = 2048 * 2048 * 4 * sizeof(float);
+ const size_t data_size = (ibuf->rect_float) ? sizeof(float) : sizeof(uchar);
+ const size_t size = ibuf->x * ibuf->y * ibuf->channels * data_size;
+
+ return (size > threshold) ? IMAGE_DRAW_METHOD_2DTEXTURE : IMAGE_DRAW_METHOD_GLSL;
+ }
+ else {
+ return U.image_draw_method;
+ }
}
/* don't move to GPU_immediate_util.h because this uses user-prefs
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 719403531ff..c60469e092f 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -65,53 +65,54 @@
#include "screen_intern.h"
-const char *screen_context_dir[] = {"scene",
- "view_layer",
- "visible_objects",
- "visible_bases",
- "selectable_objects",
- "selectable_bases",
- "selected_objects",
- "selected_bases",
- "editable_objects",
- "editable_bases",
- "selected_editable_objects",
- "selected_editable_bases",
- "objects_in_mode",
- "objects_in_mode_unique_data",
- "visible_bones",
- "editable_bones",
- "selected_bones",
- "selected_editable_bones",
- "visible_pose_bones",
- "selected_pose_bones",
- "selected_pose_bones_from_active_object",
- "active_bone",
- "active_pose_bone",
- "active_base",
- "active_object",
- "object",
- "edit_object",
- "sculpt_object",
- "vertex_paint_object",
- "weight_paint_object",
- "image_paint_object",
- "particle_edit_object",
- "uv_sculpt_object",
- "pose_object",
- "sequences",
- "selected_sequences",
- "selected_editable_sequences", /* sequencer */
- "gpencil_data",
- "gpencil_data_owner", /* grease pencil data */
- "visible_gpencil_layers",
- "editable_gpencil_layers",
- "editable_gpencil_strokes",
- "active_gpencil_layer",
- "active_gpencil_frame",
- "active_operator",
- "selected_editable_fcurves",
- NULL};
+const char *screen_context_dir[] = {
+ "scene",
+ "view_layer",
+ "visible_objects",
+ "visible_bases",
+ "selectable_objects",
+ "selectable_bases",
+ "selected_objects",
+ "selected_bases",
+ "editable_objects",
+ "editable_bases",
+ "selected_editable_objects",
+ "selected_editable_bases",
+ "objects_in_mode",
+ "objects_in_mode_unique_data",
+ "visible_bones",
+ "editable_bones",
+ "selected_bones",
+ "selected_editable_bones",
+ "visible_pose_bones",
+ "selected_pose_bones",
+ "selected_pose_bones_from_active_object",
+ "active_bone",
+ "active_pose_bone",
+ "active_base",
+ "active_object",
+ "object",
+ "edit_object",
+ "sculpt_object",
+ "vertex_paint_object",
+ "weight_paint_object",
+ "image_paint_object",
+ "particle_edit_object",
+ "pose_object",
+ "sequences",
+ "selected_sequences",
+ "selected_editable_sequences", /* sequencer */
+ "gpencil_data",
+ "gpencil_data_owner", /* grease pencil data */
+ "visible_gpencil_layers",
+ "editable_gpencil_layers",
+ "editable_gpencil_strokes",
+ "active_gpencil_layer",
+ "active_gpencil_frame",
+ "active_operator",
+ "selected_editable_fcurves",
+ NULL,
+};
int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
{
@@ -274,8 +275,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
* We need to make sure that these mirrored copies are not selected, otherwise some
* bones will be operated on twice.
*/
- if (arm->flag & ARM_MIRROR_EDIT)
+ if (arm->flag & ARM_MIRROR_EDIT) {
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+ }
/* if we're filtering for editable too, use the check for that instead,
* as it has selection check too */
@@ -284,16 +286,18 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (EBONE_EDITABLE(ebone)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
- if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+ if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
}
}
else {
/* only include bones if visible */
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
- if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0)
+ if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
}
}
}
@@ -328,8 +332,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
* We need to make sure that these mirrored copies are not selected, otherwise some
* bones will be operated on twice.
*/
- if (arm->flag & ARM_MIRROR_EDIT)
+ if (arm->flag & ARM_MIRROR_EDIT) {
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+ }
/* if we're filtering for editable too, use the check for that instead,
* as it has selection check too */
@@ -338,16 +343,18 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (EBONE_EDITABLE(ebone)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
- if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+ if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
}
}
else {
/* only include bones if selected */
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
- if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+ if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
}
}
}
@@ -449,74 +456,67 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "active_base")) {
- if (view_layer->basact)
+ if (view_layer->basact) {
CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, view_layer->basact);
+ }
return 1;
}
else if (CTX_data_equals(member, "active_object")) {
- if (obact)
+ if (obact) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "object")) {
- if (obact)
+ if (obact) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "edit_object")) {
/* convenience for now, 1 object per scene in editmode */
- if (obedit)
+ if (obedit) {
CTX_data_id_pointer_set(result, &obedit->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "sculpt_object")) {
- if (obact && (obact->mode & OB_MODE_SCULPT))
+ if (obact && (obact->mode & OB_MODE_SCULPT)) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "vertex_paint_object")) {
- if (obact && (obact->mode & OB_MODE_VERTEX_PAINT))
+ if (obact && (obact->mode & OB_MODE_VERTEX_PAINT)) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "weight_paint_object")) {
- if (obact && (obact->mode & OB_MODE_WEIGHT_PAINT))
+ if (obact && (obact->mode & OB_MODE_WEIGHT_PAINT)) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "image_paint_object")) {
- if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT))
+ if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "particle_edit_object")) {
- if (obact && (obact->mode & OB_MODE_PARTICLE_EDIT))
+ if (obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) {
CTX_data_id_pointer_set(result, &obact->id);
-
- return 1;
- }
- else if (CTX_data_equals(member, "uv_sculpt_object")) {
- /* TODO(campbell): most likely we change rules for uv_sculpt. */
- if (obact && (obact->mode & OB_MODE_EDIT)) {
- const ToolSettings *ts = scene->toolsettings;
- if (ts->use_uv_sculpt) {
- if (ED_uvedit_test(obedit)) {
- WorkSpace *workspace = CTX_wm_workspace(C);
- if ((workspace->tools_space_type == SPACE_IMAGE) &&
- (workspace->tools_mode == SI_MODE_UV)) {
- CTX_data_id_pointer_set(result, &obact->id);
- }
- }
- }
}
+
return 1;
}
else if (CTX_data_equals(member, "pose_object")) {
@@ -564,9 +564,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "gpencil_data")) {
- /* FIXME: for some reason, CTX_data_active_object(C) returns NULL when called from these situations
- * (as outlined above - see Campbell's #ifdefs). That causes the get_active function to fail when
- * called from context. For that reason, we end up using an alternative where we pass everything in!
+ /* FIXME: for some reason, CTX_data_active_object(C) returns NULL when called from these
+ * situations (as outlined above - see Campbell's #ifdefs).
+ * That causes the get_active function to fail when called from context.
+ * For that reason, we end up using an alternative where we pass everything in!
*/
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, sa, scene, obact);
@@ -576,8 +577,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "gpencil_data_owner")) {
- /* pointer to which data/datablock owns the reference to the Grease Pencil data being used (as gpencil_data)
- * XXX: see comment for gpencil_data case...
+ /* Pointer to which data/datablock owns the reference to the Grease Pencil data being used
+ * (as gpencil_data).
+ * XXX: see comment for gpencil_data case.
*/
bGPdata **gpd_ptr = NULL;
PointerRNA ptr;
@@ -726,8 +728,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
for (ale = anim_data.first; ale; ale = ale->next) {
- if (ale->type == ANIMTYPE_FCURVE)
+ if (ale->type == ANIMTYPE_FCURVE) {
CTX_data_list_add(result, ale->id, &RNA_FCurve, ale->data);
+ }
}
ANIM_animdata_freelist(&anim_data);
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index fb738bf40cd..1124070486f 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -40,7 +40,8 @@
#include "screen_intern.h"
/**
- * Draw horizontal shape visualizing future joining (left as well right direction of future joining).
+ * Draw horizontal shape visualizing future joining
+ * (left as well right direction of future joining).
*/
static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos)
{
@@ -540,7 +541,8 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
/* Screen Thumbnail Preview */
/**
- * Calculates a scale factor to squash the preview for \a screen into a rectangle of given size and aspect.
+ * Calculates a scale factor to squash the preview for \a screen into a rectangle
+ * of given size and aspect.
*/
static void screen_preview_scale_get(
const bScreen *screen, float size_x, float size_y, const float asp[2], float r_scale[2])
@@ -588,7 +590,8 @@ static void screen_preview_draw_areas(const bScreen *screen,
static void screen_preview_draw(const bScreen *screen, int size_x, int size_y)
{
const float asp[2] = {1.0f, 0.8f}; /* square previews look a bit ugly */
- /* could use theme color (tui.wcol_menu_item.text), but then we'd need to regenerate all previews when changing */
+ /* could use theme color (tui.wcol_menu_item.text),
+ * but then we'd need to regenerate all previews when changing. */
const float col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
float scale[2];
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 8caa960bb9a..2ce9d732eb7 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -113,14 +113,16 @@ ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, flo
short split;
rcti window_rect;
- if (sa == NULL)
+ if (sa == NULL) {
return NULL;
+ }
WM_window_rect_calc(win, &window_rect);
split = screen_geom_find_area_split_point(sa, &window_rect, dir, fac);
- if (split == 0)
+ if (split == 0) {
return NULL;
+ }
/* note regarding (fac > 0.5f) checks below.
* normally it shouldn't matter which is used since the copy should match the original
@@ -190,8 +192,9 @@ ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, flo
}
/* remove double vertices en edges */
- if (merge)
+ if (merge) {
BKE_screen_remove_double_scrverts(sc);
+ }
BKE_screen_remove_double_scredges(sc);
BKE_screen_remove_unused_scredges(sc);
@@ -269,8 +272,9 @@ void screen_data_copy(bScreen *to, bScreen *from)
}
/* put at zero (needed?) */
- for (s1 = from->vertbase.first; s1; s1 = s1->next)
+ for (s1 = from->vertbase.first; s1; s1 = s1->next) {
s1->newv = NULL;
+ }
}
/**
@@ -291,8 +295,9 @@ int area_getorientation(ScrArea *sa, ScrArea *sb)
ScrVert *sav1, *sav2, *sav3, *sav4;
ScrVert *sbv1, *sbv2, *sbv3, *sbv4;
- if (sa == NULL || sb == NULL)
+ if (sa == NULL || sb == NULL) {
return -1;
+ }
sav1 = sa->v1;
sav2 = sa->v2;
@@ -399,41 +404,26 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note)
/* generic notes */
switch (note->category) {
case NC_WM:
- if (note->data == ND_FILEREAD)
+ if (note->data == ND_FILEREAD) {
screen->do_draw = true;
+ }
break;
case NC_WINDOW:
screen->do_draw = true;
break;
case NC_SCREEN:
- if (note->action == NA_EDITED)
+ if (note->action == NA_EDITED) {
screen->do_draw = screen->do_refresh = true;
+ }
break;
case NC_SCENE:
- if (note->data == ND_MODE)
+ if (note->data == ND_MODE) {
region_cursor_set(win, true);
+ }
break;
}
}
-/* helper call for below, dpi changes headers */
-static void screen_refresh_headersizes(void)
-{
- const ListBase *lb = BKE_spacetypes_list();
- SpaceType *st;
-
- for (st = lb->first; st; st = st->next) {
- ARegionType *art;
- art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER);
- if (art)
- art->prefsizey = ED_area_headersize();
-
- art = BKE_regiontype_from_id(st, RGN_TYPE_FOOTER);
- if (art)
- art->prefsizey = ED_area_headersize();
- }
-}
-
/* make this screen usable */
/* for file read and first use, for scaling window, area moves */
void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
@@ -446,7 +436,6 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
WM_window_set_dpi(win);
ED_screen_global_areas_refresh(win);
- screen_refresh_headersizes();
screen_geom_vertices_scale(win, screen);
@@ -458,8 +447,9 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
}
/* wake up animtimer */
- if (screen->animtimer)
+ if (screen->animtimer) {
WM_event_timer_sleep(wm, win, screen->animtimer, false);
+ }
}
if (G.debug & G_DEBUG_EVENTS) {
@@ -510,8 +500,9 @@ void ED_region_exit(bContext *C, ARegion *ar)
wmWindow *win = CTX_wm_window(C);
ARegion *prevar = CTX_wm_region(C);
- if (ar->type && ar->type->exit)
+ if (ar->type && ar->type->exit) {
ar->type->exit(wm, ar);
+ }
CTX_wm_region_set(C, ar);
@@ -541,13 +532,15 @@ void ED_area_exit(bContext *C, ScrArea *sa)
ScrArea *prevsa = CTX_wm_area(C);
ARegion *ar;
- if (sa->type && sa->type->exit)
+ if (sa->type && sa->type->exit) {
sa->type->exit(wm, sa);
+ }
CTX_wm_area_set(C, sa);
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ED_region_exit(C, ar);
+ }
WM_event_remove_handlers(C, &sa->handlers);
WM_event_modal_handler_area_replace(win, sa, NULL);
@@ -562,8 +555,9 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
CTX_wm_window_set(C, window);
- if (screen->animtimer)
+ if (screen->animtimer) {
WM_event_remove_timer(wm, window, screen->animtimer);
+ }
screen->animtimer = NULL;
screen->scrubbing = false;
@@ -602,31 +596,39 @@ static void screen_cursor_set(wmWindow *win, const int xy[2])
AZone *az = NULL;
ScrArea *sa;
- for (sa = screen->areabase.first; sa; sa = sa->next)
- if ((az = ED_area_actionzone_find_xy(sa, xy)))
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ if ((az = ED_area_actionzone_find_xy(sa, xy))) {
break;
+ }
+ }
if (sa) {
- if (az->type == AZONE_AREA)
+ if (az->type == AZONE_AREA) {
WM_cursor_set(win, CURSOR_EDIT);
+ }
else if (az->type == AZONE_REGION) {
- if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT)
+ if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) {
WM_cursor_set(win, CURSOR_X_MOVE);
- else
+ }
+ else {
WM_cursor_set(win, CURSOR_Y_MOVE);
+ }
}
}
else {
ScrEdge *actedge = screen_geom_find_active_scredge(win, screen, xy[0], xy[1]);
if (actedge) {
- if (screen_geom_edge_is_horizontal(actedge))
+ if (screen_geom_edge_is_horizontal(actedge)) {
WM_cursor_set(win, CURSOR_Y_MOVE);
- else
+ }
+ else {
WM_cursor_set(win, CURSOR_X_MOVE);
+ }
}
- else
+ else {
WM_cursor_set(win, CURSOR_STD);
+ }
}
}
@@ -655,14 +657,15 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
if (sa) {
/* make overlap active when mouse over */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (BLI_rcti_isect_pt_v(&ar->winrct, xy)) {
+ if (ED_region_contains_xy(ar, xy)) {
scr->active_region = ar;
break;
}
}
}
- else
+ else {
scr->active_region = NULL;
+ }
/* check for redraw headers */
if (old_ar != scr->active_region) {
@@ -679,7 +682,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
if (do_draw) {
for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_HEADER) {
+ if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
ED_region_tag_redraw_no_rebuild(ar);
}
}
@@ -703,8 +706,9 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
UI_screen_free_active_but(C, scr);
}
}
- else
+ else {
region_cursor_set(win, false);
+ }
}
}
}
@@ -719,12 +723,15 @@ int ED_screen_area_active(const bContext *C)
AZone *az = ED_area_actionzone_find_xy(sa, &win->eventstate->x);
ARegion *ar;
- if (az && az->type == AZONE_REGION)
+ if (az && az->type == AZONE_REGION) {
return 1;
+ }
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar == sc->active_region)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar == sc->active_region) {
return 1;
+ }
+ }
}
return 0;
}
@@ -813,16 +820,14 @@ static int screen_global_header_size(void)
static void screen_global_topbar_area_refresh(wmWindow *win, bScreen *screen)
{
- const short size_min = screen_global_header_size();
- const short size_max = 2.25 * screen_global_header_size();
- const short size = (screen->flag & SCREEN_COLLAPSE_TOPBAR) ? size_min : size_max;
+ const short size = screen_global_header_size();
rcti rect;
BLI_rcti_init(&rect, 0, WM_window_pixels_x(win) - 1, 0, WM_window_pixels_y(win) - 1);
- rect.ymin = rect.ymax - size_max;
+ rect.ymin = rect.ymax - size;
screen_global_area_refresh(
- win, screen, SPACE_TOPBAR, GLOBAL_AREA_ALIGN_TOP, &rect, size, size_min, size_max);
+ win, screen, SPACE_TOPBAR, GLOBAL_AREA_ALIGN_TOP, &rect, size, size, size);
}
static void screen_global_statusbar_area_refresh(wmWindow *win, bScreen *screen)
@@ -845,14 +850,11 @@ void ED_screen_global_areas_sync(wmWindow *win)
* global areas should just become part of the screen instead. */
bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
- screen->flag &= ~(SCREEN_COLLAPSE_STATUSBAR | SCREEN_COLLAPSE_TOPBAR);
+ screen->flag &= ~SCREEN_COLLAPSE_STATUSBAR;
for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
if (area->global->cur_fixed_height == area->global->size_min) {
- if (area->spacetype == SPACE_TOPBAR) {
- screen->flag |= SCREEN_COLLAPSE_TOPBAR;
- }
- else if (area->spacetype == SPACE_STATUSBAR) {
+ if (area->spacetype == SPACE_STATUSBAR) {
screen->flag |= SCREEN_COLLAPSE_STATUSBAR;
}
}
@@ -995,10 +997,12 @@ static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrAre
ListBase *regionbase;
/* regionbase is in different place depending if space is active */
- if (v3d == sa->spacedata.first)
+ if (v3d == sa->spacedata.first) {
regionbase = &sa->regionbase;
- else
+ }
+ else {
regionbase = &v3d->regionbase;
+ }
for (ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
@@ -1195,8 +1199,9 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
sa->full = NULL;
if (fullsa == NULL) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: something wrong in areafullscreen\n", __func__);
+ }
return NULL;
}
@@ -1278,6 +1283,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
if (ELEM(ar->regiontype,
RGN_TYPE_UI,
RGN_TYPE_HEADER,
+ RGN_TYPE_TOOL_HEADER,
RGN_TYPE_FOOTER,
RGN_TYPE_TOOLS,
RGN_TYPE_NAV_BAR,
@@ -1310,9 +1316,10 @@ void ED_refresh_viewport_fps(bContext *C)
ScreenFrameRateInfo *fpsi = scene->fps_info;
/* if there isn't any info, init it first */
- if (fpsi == NULL)
+ if (fpsi == NULL) {
fpsi = scene->fps_info = MEM_callocN(sizeof(ScreenFrameRateInfo),
"refresh_viewport_fps fps_info");
+ }
/* update the values */
fpsi->redrawtime = fpsi->lredrawtime;
@@ -1320,8 +1327,9 @@ void ED_refresh_viewport_fps(bContext *C)
}
else {
/* playback stopped or shouldn't be running */
- if (scene->fps_info)
+ if (scene->fps_info) {
MEM_freeN(scene->fps_info);
+ }
scene->fps_info = NULL;
}
}
@@ -1355,16 +1363,18 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
sad->sfra = scene->r.cfra;
scene->r.cfra = scene->r.psfra;
}
- else
+ else {
sad->sfra = scene->r.cfra;
+ }
}
else {
if (scene->r.sfra > scene->r.cfra) {
sad->sfra = scene->r.cfra;
scene->r.cfra = scene->r.sfra;
}
- else
+ else {
sad->sfra = scene->r.cfra;
+ }
}
sad->redraws = redraws;
sad->refresh = refresh;
@@ -1375,8 +1385,9 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
char spacetype = -1;
- if (sa)
+ if (sa) {
spacetype = sa->spacetype;
+ }
sad->from_anim_edit = (ELEM(spacetype, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA));
@@ -1420,8 +1431,9 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh)
sad->redraws = redraws;
sad->refresh = refresh;
sad->ar = NULL;
- if (redraws & TIME_REGION)
+ if (redraws & TIME_REGION) {
sad->ar = time_top_left_3dwindow(screen);
+ }
}
}
@@ -1447,20 +1459,6 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
/* this function applies the changes too */
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
-
- /* composite */
- if (scene->use_nodes && scene->nodetree)
- ntreeCompositTagAnimated(scene->nodetree);
-
- /* update animated texture nodes */
- {
- Tex *tex;
- for (tex = bmain->textures.first; tex; tex = tex->id.next) {
- if (tex->use_nodes && tex->nodetree) {
- ntreeTexTagAnimated(tex->nodetree);
- }
- }
- }
}
/*
@@ -1476,8 +1474,9 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
case SPACE_VIEW3D: {
View3D *v3d;
- if (!is_multiview)
+ if (!is_multiview) {
continue;
+ }
v3d = sa->spacedata.first;
if (v3d->camera && v3d->stereo3d_camera == STEREO_3D_ID) {
@@ -1508,8 +1507,9 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
case SPACE_NODE: {
SpaceNode *snode;
- if (!is_multiview)
+ if (!is_multiview) {
continue;
+ }
snode = sa->spacedata.first;
if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) {
@@ -1520,8 +1520,9 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
case SPACE_SEQ: {
SpaceSeq *sseq;
- if (!is_multiview)
+ if (!is_multiview) {
continue;
+ }
sseq = sa->spacedata.first;
if (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) {
diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c
index 1ad0e930582..25855382307 100644
--- a/source/blender/editors/screen/screen_geometry.c
+++ b/source/blender/editors/screen/screen_geometry.c
@@ -84,7 +84,8 @@ bool screen_geom_edge_is_horizontal(ScrEdge *se)
}
/**
- * \param bounds_rect: Either window or screen bounds. Used to exclude edges along window/screen edges.
+ * \param bounds_rect: Either window or screen bounds.
+ * Used to exclude edges along window/screen edges.
*/
ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map,
const rcti *bounds_rect,
@@ -102,8 +103,9 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map,
min = MIN2(se->v1->vec.x, se->v2->vec.x);
max = MAX2(se->v1->vec.x, se->v2->vec.x);
- if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max)
+ if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max) {
return se;
+ }
}
}
else {
@@ -112,8 +114,9 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map,
min = MIN2(se->v1->vec.y, se->v2->vec.y);
max = MAX2(se->v1->vec.y, se->v2->vec.y);
- if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max)
+ if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max) {
return se;
+ }
}
}
}
@@ -152,16 +155,11 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win,
*/
void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
{
- /* clamp Y size of header sized areas when expanding windows
- * avoids annoying empty space around file menu */
-#define USE_HEADER_SIZE_CLAMP
-
rcti window_rect, screen_rect;
WM_window_rect_calc(win, &window_rect);
WM_window_screen_rect_calc(win, &screen_rect);
- const int headery_init = ED_area_headersize();
const int screen_size_x = BLI_rcti_size_x(&screen_rect);
const int screen_size_y = BLI_rcti_size_y(&screen_rect);
ScrVert *sv = NULL;
@@ -181,33 +179,6 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
screen_size_x_prev = (max[0] - min[0]) + 1;
screen_size_y_prev = (max[1] - min[1]) + 1;
-#ifdef USE_HEADER_SIZE_CLAMP
-# define TEMP_BOTTOM 1
-# define TEMP_TOP 2
-
- /* if the window's Y axis grows, clamp header sized areas */
- if (screen_size_y_prev < screen_size_y) { /* growing? */
- const int headery_margin_max = headery_init + 5;
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
- sa->temp = 0;
-
- if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) {
- if (sa->v2->vec.y == max[1]) {
- if (screen_geom_area_height(sa) < headery_margin_max) {
- sa->temp = TEMP_TOP;
- }
- }
- else if (sa->v1->vec.y == min[1]) {
- if (screen_geom_area_height(sa) < headery_margin_max) {
- sa->temp = TEMP_BOTTOM;
- }
- }
- }
- }
- }
-#endif
-
if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) {
const float facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1);
const float facy = ((float)screen_size_y - 1) / ((float)screen_size_y_prev - 1);
@@ -220,85 +191,55 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
sv->vec.y = screen_rect.ymin + round_fl_to_short((sv->vec.y - min[1]) * facy);
CLAMP(sv->vec.y, screen_rect.ymin, screen_rect.ymax - 1);
}
- }
-#ifdef USE_HEADER_SIZE_CLAMP
- if (screen_size_y_prev < screen_size_y) { /* growing? */
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- ScrEdge *se = NULL;
-
- if (sa->temp == 0)
- continue;
-
- if (sa->v1 == sa->v2)
- continue;
-
- /* adjust headery if verts are along the edge of window */
- if (sa->temp == TEMP_TOP) {
- /* lower edge */
- const int yval = sa->v2->vec.y - headery_init;
- se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
- if (se != NULL) {
- screen_geom_select_connected_edge(win, se);
- }
- for (sv = sc->vertbase.first; sv; sv = sv->next) {
- if (sv != sa->v2 && sv != sa->v3) {
- if (sv->flag) {
- sv->vec.y = yval;
- }
- }
- }
- }
- else {
- /* upper edge */
- const int yval = sa->v1->vec.y + headery_init;
- se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
- if (se != NULL) {
- screen_geom_select_connected_edge(win, se);
- }
- for (sv = sc->vertbase.first; sv; sv = sv->next) {
- if (sv != sa->v1 && sv != sa->v4) {
- if (sv->flag) {
- sv->vec.y = yval;
+ /* test for collapsed areas. This could happen in some blender version... */
+ /* ton: removed option now, it needs Context... */
+
+ int headery = ED_area_headersize() + (U.pixelsize * 2);
+
+ if (facy > 1) {
+ /* Keep timeline small in video edit workspace. */
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ if (sa->spacetype == SPACE_ACTION && sa->v1->vec.y == screen_rect.ymin &&
+ screen_geom_area_height(sa) <= headery * facy + 1) {
+ ScrEdge *se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
+ if (se) {
+ const int yval = sa->v1->vec.y + headery - 1;
+
+ screen_geom_select_connected_edge(win, se);
+
+ /* all selected vertices get the right offset */
+ for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ /* if is a collapsed area */
+ if (sv != sa->v1 && sv != sa->v4) {
+ if (sv->flag) {
+ sv->vec.y = yval;
+ }
+ }
}
}
}
}
}
- }
-
-# undef USE_HEADER_SIZE_CLAMP
-# undef TEMP_BOTTOM
-# undef TEMP_TOP
-#endif
-
- /* test for collapsed areas. This could happen in some blender version... */
- /* ton: removed option now, it needs Context... */
-
- /* make each window at least ED_area_headersize() high */
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- int headery = headery_init;
-
- /* adjust headery if verts are along the edge of window */
- if (sa->v1->vec.y > window_rect.ymin)
- headery += U.pixelsize;
- if (sa->v2->vec.y < (window_rect.ymax - 1))
- headery += U.pixelsize;
-
- if (screen_geom_area_height(sa) < headery) {
- /* lower edge */
- ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
- if (se && sa->v1 != sa->v2) {
- const int yval = sa->v2->vec.y - headery + 1;
-
- screen_geom_select_connected_edge(win, se);
-
- /* all selected vertices get the right offset */
- for (sv = sc->vertbase.first; sv; sv = sv->next) {
- /* if is a collapsed area */
- if (sv != sa->v2 && sv != sa->v3) {
- if (sv->flag) {
- sv->vec.y = yval;
+ if (facy < 1) {
+ /* make each window at least ED_area_headersize() high */
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ if (screen_geom_area_height(sa) < headery) {
+ /* lower edge */
+ ScrEdge *se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
+ if (se && sa->v1 != sa->v2) {
+ const int yval = sa->v2->vec.y - headery + 1;
+
+ screen_geom_select_connected_edge(win, se);
+
+ /* all selected vertices get the right offset */
+ for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ /* if is not a collapsed area */
+ if (sv != sa->v2 && sv != sa->v3) {
+ if (sv->flag) {
+ sv->vec.y = yval;
+ }
+ }
}
}
}
@@ -306,7 +247,8 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
}
}
- /* Global areas have a fixed size that only changes with the DPI. Here we ensure that exactly this size is set. */
+ /* Global areas have a fixed size that only changes with the DPI.
+ * Here we ensure that exactly this size is set. */
for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
if (area->global->flag & GLOBAL_AREA_IS_HIDDEN) {
continue;
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index d2c43d1df28..4971b310eff 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -89,9 +89,6 @@ extern const char *screen_context_dir[]; /* doc access */
/* screendump.c */
void SCREEN_OT_screenshot(struct wmOperatorType *ot);
-/* screen_ops.c */
-void region_blend_start(struct bContext *C, struct ScrArea *sa, struct ARegion *ar);
-
/* workspace_layout_edit.c */
bool workspace_layout_set_poll(const struct WorkSpaceLayout *layout);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 94b5f695de8..9f452dd79e0 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -102,44 +102,55 @@
bool ED_operator_regionactive(bContext *C)
{
- if (CTX_wm_window(C) == NULL)
+ if (CTX_wm_window(C) == NULL) {
return 0;
- if (CTX_wm_screen(C) == NULL)
+ }
+ if (CTX_wm_screen(C) == NULL) {
return 0;
- if (CTX_wm_region(C) == NULL)
+ }
+ if (CTX_wm_region(C) == NULL) {
return 0;
+ }
return 1;
}
bool ED_operator_areaactive(bContext *C)
{
- if (CTX_wm_window(C) == NULL)
+ if (CTX_wm_window(C) == NULL) {
return 0;
- if (CTX_wm_screen(C) == NULL)
+ }
+ if (CTX_wm_screen(C) == NULL) {
return 0;
- if (CTX_wm_area(C) == NULL)
+ }
+ if (CTX_wm_area(C) == NULL) {
return 0;
+ }
return 1;
}
bool ED_operator_screenactive(bContext *C)
{
- if (CTX_wm_window(C) == NULL)
+ if (CTX_wm_window(C) == NULL) {
return 0;
- if (CTX_wm_screen(C) == NULL)
+ }
+ if (CTX_wm_screen(C) == NULL) {
return 0;
+ }
return 1;
}
/* XXX added this to prevent anim state to change during renders */
static bool ED_operator_screenactive_norender(bContext *C)
{
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
- if (CTX_wm_window(C) == NULL)
+ }
+ if (CTX_wm_window(C) == NULL) {
return 0;
- if (CTX_wm_screen(C) == NULL)
+ }
+ if (CTX_wm_screen(C) == NULL) {
return 0;
+ }
return 1;
}
@@ -147,29 +158,34 @@ static bool ED_operator_screenactive_norender(bContext *C)
bool ED_operator_screen_mainwinactive(bContext *C)
{
bScreen *screen;
- if (CTX_wm_window(C) == NULL)
+ if (CTX_wm_window(C) == NULL) {
return 0;
+ }
screen = CTX_wm_screen(C);
- if (screen == NULL)
+ if (screen == NULL) {
return 0;
- if (screen->active_region != NULL)
+ }
+ if (screen->active_region != NULL) {
return 0;
+ }
return 1;
}
bool ED_operator_scene(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (scene)
+ if (scene) {
return 1;
+ }
return 0;
}
bool ED_operator_scene_editable(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (scene && !ID_IS_LINKED(scene))
+ if (scene && !ID_IS_LINKED(scene)) {
return 1;
+ }
return 0;
}
@@ -178,14 +194,17 @@ bool ED_operator_objectmode(bContext *C)
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
- if (scene == NULL || ID_IS_LINKED(scene))
+ if (scene == NULL || ID_IS_LINKED(scene)) {
return 0;
- if (CTX_data_edit_object(C))
+ }
+ if (CTX_data_edit_object(C)) {
return 0;
+ }
/* add a check for ob->mode too? */
- if (obact && (obact->mode != OB_MODE_OBJECT))
+ if (obact && (obact->mode != OB_MODE_OBJECT)) {
return 0;
+ }
return 1;
}
@@ -206,8 +225,9 @@ bool ED_operator_view3d_active(bContext *C)
bool ED_operator_region_view3d_active(bContext *C)
{
- if (CTX_wm_region_view3d(C))
+ if (CTX_wm_region_view3d(C)) {
return true;
+ }
CTX_wm_operator_poll_msg_set(C, "expected a view3d region");
return false;
@@ -218,8 +238,9 @@ bool ED_operator_animview_active(bContext *C)
{
if (ED_operator_areaactive(C)) {
SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C);
- if (sl && (ELEM(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_GRAPH)))
+ if (sl && (ELEM(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_GRAPH))) {
return true;
+ }
}
CTX_wm_operator_poll_msg_set(C, "expected a timeline/animation area to be active");
@@ -236,10 +257,12 @@ bool ED_operator_outliner_active_no_editobject(bContext *C)
if (ed_spacetype_test(C, SPACE_OUTLINER)) {
Object *ob = ED_object_active_context(C);
Object *obedit = CTX_data_edit_object(C);
- if (ob && ob == obedit)
+ if (ob && ob == obedit) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
return 0;
}
@@ -263,8 +286,9 @@ bool ED_operator_node_active(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
- if (snode && snode->edittree)
+ if (snode && snode->edittree) {
return 1;
+ }
return 0;
}
@@ -273,8 +297,9 @@ bool ED_operator_node_editable(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
- if (snode && snode->edittree && !ID_IS_LINKED(snode->edittree))
+ if (snode && snode->edittree && !ID_IS_LINKED(snode->edittree)) {
return 1;
+ }
return 0;
}
@@ -348,8 +373,9 @@ bool ED_operator_object_active_editable_font(bContext *C)
bool ED_operator_editmesh(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_MESH)
+ if (obedit && obedit->type == OB_MESH) {
return NULL != BKE_editmesh_from_object(obedit);
+ }
return 0;
}
@@ -360,8 +386,9 @@ bool ED_operator_editmesh_view3d(bContext *C)
bool ED_operator_editmesh_region_view3d(bContext *C)
{
- if (ED_operator_editmesh(C) && CTX_wm_region_view3d(C))
+ if (ED_operator_editmesh(C) && CTX_wm_region_view3d(C)) {
return 1;
+ }
CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editmesh");
return 0;
@@ -379,8 +406,9 @@ bool ED_operator_editmesh_auto_smooth(bContext *C)
bool ED_operator_editarmature(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_ARMATURE)
+ if (obedit && obedit->type == OB_ARMATURE) {
return NULL != ((bArmature *)obedit->data)->edbo;
+ }
return 0;
}
@@ -482,15 +510,17 @@ bool ED_operator_uvmap(bContext *C)
bool ED_operator_editsurfcurve(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && ELEM(obedit->type, OB_CURVE, OB_SURF))
+ if (obedit && ELEM(obedit->type, OB_CURVE, OB_SURF)) {
return NULL != ((Curve *)obedit->data)->editnurb;
+ }
return 0;
}
bool ED_operator_editsurfcurve_region_view3d(bContext *C)
{
- if (ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C))
+ if (ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C)) {
return 1;
+ }
CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editcurve");
return 0;
@@ -499,8 +529,9 @@ bool ED_operator_editsurfcurve_region_view3d(bContext *C)
bool ED_operator_editcurve(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_CURVE)
+ if (obedit && obedit->type == OB_CURVE) {
return NULL != ((Curve *)obedit->data)->editnurb;
+ }
return 0;
}
@@ -518,32 +549,36 @@ bool ED_operator_editcurve_3d(bContext *C)
bool ED_operator_editsurf(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_SURF)
+ if (obedit && obedit->type == OB_SURF) {
return NULL != ((Curve *)obedit->data)->editnurb;
+ }
return 0;
}
bool ED_operator_editfont(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_FONT)
+ if (obedit && obedit->type == OB_FONT) {
return NULL != ((Curve *)obedit->data)->editfont;
+ }
return 0;
}
bool ED_operator_editlattice(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_LATTICE)
+ if (obedit && obedit->type == OB_LATTICE) {
return NULL != ((Lattice *)obedit->data)->editlatt;
+ }
return 0;
}
bool ED_operator_editmball(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_MBALL)
+ if (obedit && obedit->type == OB_MBALL) {
return NULL != ((MetaBall *)obedit->data)->editelems;
+ }
return 0;
}
@@ -588,8 +623,9 @@ static bool screen_active_editable(bContext *C)
{
if (ED_operator_screenactive(C)) {
/* no full window splitting allowed */
- if (CTX_wm_screen(C)->state != SCREENNORMAL)
+ if (CTX_wm_screen(C)->state != SCREENNORMAL) {
return 0;
+ }
return 1;
}
return 0;
@@ -658,9 +694,11 @@ static bool actionzone_area_poll(bContext *C)
AZone *az;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (az = sa->actionzones.first; az; az = az->next)
- if (BLI_rcti_isect_pt_v(&az->rect, xy))
+ for (az = sa->actionzones.first; az; az = az->next) {
+ if (BLI_rcti_isect_pt_v(&az->rect, xy)) {
return 1;
+ }
+ }
}
}
return 0;
@@ -685,12 +723,56 @@ static void fullscreen_click_rcti_init(
BLI_rcti_init(rect, x, x + icon_size, y, y + icon_size);
}
+static bool azone_clipped_rect_calc(const AZone *az, rcti *r_rect_clip)
+{
+ const ARegion *ar = az->ar;
+ *r_rect_clip = az->rect;
+ if (az->type == AZONE_REGION) {
+ if (ar->overlap && (ar->v2d.keeptot != V2D_KEEPTOT_STRICT) &&
+ /* Only when this isn't hidden (where it's displayed as an button that expands). */
+ ((az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) == 0)) {
+ /* A floating region to be resized, clip by the visible region. */
+ switch (az->edge) {
+ case AE_TOP_TO_BOTTOMRIGHT:
+ case AE_BOTTOM_TO_TOPLEFT: {
+ r_rect_clip->xmin = max_ii(
+ r_rect_clip->xmin,
+ (ar->winrct.xmin + UI_view2d_view_to_region_x(&ar->v2d, ar->v2d.tot.xmin)) -
+ UI_REGION_OVERLAP_MARGIN);
+ r_rect_clip->xmax = min_ii(
+ r_rect_clip->xmax,
+ (ar->winrct.xmin + UI_view2d_view_to_region_x(&ar->v2d, ar->v2d.tot.xmax)) +
+ UI_REGION_OVERLAP_MARGIN);
+ return true;
+ }
+ case AE_LEFT_TO_TOPRIGHT:
+ case AE_RIGHT_TO_TOPLEFT: {
+ r_rect_clip->ymin = max_ii(
+ r_rect_clip->ymin,
+ (ar->winrct.ymin + UI_view2d_view_to_region_y(&ar->v2d, ar->v2d.tot.ymin)) -
+ UI_REGION_OVERLAP_MARGIN);
+ r_rect_clip->ymax = min_ii(
+ r_rect_clip->ymax,
+ (ar->winrct.ymin + UI_view2d_view_to_region_y(&ar->v2d, ar->v2d.tot.ymax)) +
+ UI_REGION_OVERLAP_MARGIN);
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const bool test_only)
{
AZone *az = NULL;
for (az = sa->actionzones.first; az; az = az->next) {
- if (BLI_rcti_isect_pt_v(&az->rect, xy)) {
+ rcti az_rect_clip;
+ if (BLI_rcti_isect_pt_v(&az->rect, xy) &&
+ /* Check clipping if this is clipped */
+ (!azone_clipped_rect_calc(az, &az_rect_clip) || BLI_rcti_isect_pt_v(&az_rect_clip, xy))) {
+
if (az->type == AZONE_AREA) {
break;
}
@@ -867,8 +949,9 @@ AZone *ED_area_azones_update(ScrArea *sa, const int xy[2])
static void actionzone_exit(wmOperator *op)
{
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
op->customdata = NULL;
}
@@ -883,12 +966,15 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type)
wm_event_init_from_window(win, &event);
- if (type == AZONE_AREA)
+ if (type == AZONE_AREA) {
event.type = EVT_ACTIONZONE_AREA;
- else if (type == AZONE_FULLSCREEN)
+ }
+ else if (type == AZONE_FULLSCREEN) {
event.type = EVT_ACTIONZONE_FULLSCREEN;
- else
+ }
+ else {
event.type = EVT_ACTIONZONE_REGION;
+ }
event.val = KM_NOTHING;
event.customdata = op->customdata;
@@ -904,9 +990,11 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
AZone *az = screen_actionzone_find_xy(sc, &event->x);
sActionzoneData *sad;
- /* quick escape - Scroll azones only hide/unhide the scroll-bars, they have their own handling. */
- if (az == NULL || ELEM(az->type, AZONE_REGION_SCROLL))
+ /* Quick escape - Scroll azones only hide/unhide the scroll-bars,
+ * they have their own handling. */
+ if (az == NULL || ELEM(az->type, AZONE_REGION_SCROLL)) {
return OPERATOR_PASS_THROUGH;
+ }
/* ok we do the action-zone */
sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
@@ -950,14 +1038,18 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
const int area_threshold = (0.1 * U.widget_unit);
/* Calculate gesture cardinal direction. */
- if (delta_y > ABS(delta_x))
+ if (delta_y > ABS(delta_x)) {
sad->gesture_dir = 'n';
- else if (delta_x >= ABS(delta_y))
+ }
+ else if (delta_x >= ABS(delta_y)) {
sad->gesture_dir = 'e';
- else if (delta_y < -ABS(delta_x))
+ }
+ else if (delta_y < -ABS(delta_x)) {
sad->gesture_dir = 's';
- else
+ }
+ else {
sad->gesture_dir = 'w';
+ }
if (sad->az->type == AZONE_AREA) {
wmWindow *win = CTX_wm_window(C);
@@ -978,14 +1070,18 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
/* Different area, so posible join. */
- if (sad->gesture_dir == 'n')
+ if (sad->gesture_dir == 'n') {
WM_cursor_set(win, BC_N_ARROWCURSOR);
- else if (sad->gesture_dir == 's')
+ }
+ else if (sad->gesture_dir == 's') {
WM_cursor_set(win, BC_S_ARROWCURSOR);
- else if (sad->gesture_dir == 'e')
+ }
+ else if (sad->gesture_dir == 'e') {
WM_cursor_set(win, BC_E_ARROWCURSOR);
- else
+ }
+ else {
WM_cursor_set(win, BC_W_ARROWCURSOR);
+ }
is_gesture = (delta_max > join_threshold);
}
}
@@ -1079,8 +1175,9 @@ static int area_swap_init(wmOperator *op, const wmEvent *event)
sAreaSwapData *sd = NULL;
sActionzoneData *sad = event->customdata;
- if (sad == NULL || sad->sa1 == NULL)
+ if (sad == NULL || sad->sa1 == NULL) {
return 0;
+ }
sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
sd->sa1 = sad->sa1;
@@ -1093,8 +1190,9 @@ static int area_swap_init(wmOperator *op, const wmEvent *event)
static void area_swap_exit(bContext *C, wmOperator *op)
{
WM_cursor_modal_restore(CTX_wm_window(C));
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
op->customdata = NULL;
}
@@ -1106,8 +1204,9 @@ static void area_swap_cancel(bContext *C, wmOperator *op)
static int area_swap_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!area_swap_init(op, event))
+ if (!area_swap_init(op, event)) {
return OPERATOR_PASS_THROUGH;
+ }
/* add modal handler */
WM_cursor_modal_set(CTX_wm_window(C), BC_SWAPAREA_CURSOR);
@@ -1195,8 +1294,9 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
- if (sad == NULL)
+ if (sad == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
sa = sad->sa1;
}
@@ -1233,8 +1333,9 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
finally:
- if (event->type == EVT_ACTIONZONE_AREA)
+ if (event->type == EVT_ACTIONZONE_AREA) {
actionzone_exit(op);
+ }
if (newwin) {
return OPERATOR_FINISHED;
@@ -1324,7 +1425,7 @@ static void area_move_set_limits(
int size_max = ED_area_global_max_size_y(area) - 1;
size_min = max_ii(size_min, 0);
- BLI_assert(size_min < size_max);
+ BLI_assert(size_min <= size_max);
/* logic here is only tested for lower edge :) */
/* left edge */
@@ -1365,35 +1466,43 @@ static void area_move_set_limits(
int y1;
areamin = areaminy;
- if (sa->v1->vec.y > window_rect.ymin)
+ if (sa->v1->vec.y > window_rect.ymin) {
areamin += U.pixelsize;
- if (sa->v2->vec.y < (window_rect.ymax - 1))
+ }
+ if (sa->v2->vec.y < (window_rect.ymax - 1)) {
areamin += U.pixelsize;
+ }
y1 = screen_geom_area_height(sa) - areamin;
/* if top or down edge selected, test height */
- if (sa->v1->editflag && sa->v4->editflag)
+ if (sa->v1->editflag && sa->v4->editflag) {
*bigger = min_ii(*bigger, y1);
- else if (sa->v2->editflag && sa->v3->editflag)
+ }
+ else if (sa->v2->editflag && sa->v3->editflag) {
*smaller = min_ii(*smaller, y1);
+ }
}
else {
int x1;
areamin = AREAMINX;
- if (sa->v1->vec.x > window_rect.xmin)
+ if (sa->v1->vec.x > window_rect.xmin) {
areamin += U.pixelsize;
- if (sa->v4->vec.x < (window_rect.xmax - 1))
+ }
+ if (sa->v4->vec.x < (window_rect.xmax - 1)) {
areamin += U.pixelsize;
+ }
x1 = screen_geom_area_width(sa) - areamin;
/* if left or right edge selected, test width */
- if (sa->v1->editflag && sa->v2->editflag)
+ if (sa->v1->editflag && sa->v2->editflag) {
*bigger = min_ii(*bigger, x1);
- else if (sa->v3->editflag && sa->v4->editflag)
+ }
+ else if (sa->v3->editflag && sa->v4->editflag) {
*smaller = min_ii(*smaller, x1);
+ }
}
}
}
@@ -1414,17 +1523,20 @@ static int area_move_init(bContext *C, wmOperator *op)
/* setup */
actedge = screen_geom_find_active_scredge(win, sc, x, y);
- if (actedge == NULL)
+ if (actedge == NULL) {
return 0;
+ }
md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
op->customdata = md;
md->dir = screen_geom_edge_is_horizontal(actedge) ? 'h' : 'v';
- if (md->dir == 'h')
+ if (md->dir == 'h') {
md->origval = actedge->v1->vec.y;
- else
+ }
+ else {
md->origval = actedge->v1->vec.x;
+ }
screen_geom_select_connected_edge(win, actedge);
/* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */
@@ -1623,8 +1735,9 @@ static void area_move_apply(bContext *C, wmOperator *op)
static void area_move_exit(bContext *C, wmOperator *op)
{
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
op->customdata = NULL;
/* this makes sure aligned edges will result in aligned grabbing */
@@ -1636,8 +1749,9 @@ static void area_move_exit(bContext *C, wmOperator *op)
static int area_move_exec(bContext *C, wmOperator *op)
{
- if (!area_move_init(C, op))
+ if (!area_move_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
area_move_apply(C, op);
area_move_exit(C, op);
@@ -1651,8 +1765,9 @@ static int area_move_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RNA_int_set(op->ptr, "x", event->x);
RNA_int_set(op->ptr, "y", event->y);
- if (!area_move_init(C, op))
+ if (!area_move_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
G.moving |= G_TRANSFORM_WM;
@@ -1830,17 +1945,20 @@ static int area_split_init(bContext *C, wmOperator *op)
int dir;
/* required context */
- if (sa == NULL)
+ if (sa == NULL) {
return 0;
+ }
/* required properties */
dir = RNA_enum_get(op->ptr, "direction");
/* minimal size */
- if (dir == 'v' && sa->winx < 2 * AREAMINX)
+ if (dir == 'v' && sa->winx < 2 * AREAMINX) {
return 0;
- if (dir == 'h' && sa->winy < 2 * areaminy)
+ }
+ if (dir == 'h' && sa->winy < 2 * areaminy) {
return 0;
+ }
/* custom data */
sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
@@ -1914,10 +2032,12 @@ static int area_split_apply(bContext *C, wmOperator *op)
sd->nedge->v1->editflag = 1;
sd->nedge->v2->editflag = 1;
- if (dir == 'h')
+ if (dir == 'h') {
sd->origval = sd->nedge->v1->vec.y;
- else
+ }
+ else {
sd->origval = sd->nedge->v1->vec.x;
+ }
ED_area_tag_redraw(sd->sarea);
ED_area_tag_redraw(sd->narea);
@@ -1936,13 +2056,16 @@ static void area_split_exit(bContext *C, wmOperator *op)
{
if (op->customdata) {
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
- if (sd->sarea)
+ if (sd->sarea) {
ED_area_tag_redraw(sd->sarea);
- if (sd->narea)
+ }
+ if (sd->narea) {
ED_area_tag_redraw(sd->narea);
+ }
- if (sd->draw_callback)
+ if (sd->draw_callback) {
WM_draw_cb_exit(CTX_wm_window(C), sd->draw_callback);
+ }
MEM_freeN(op->customdata);
op->customdata = NULL;
@@ -1986,12 +2109,14 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
/* verify *sad itself */
- if (sad->sa1 == NULL || sad->az == NULL)
+ if (sad->sa1 == NULL || sad->az == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
/* is this our *sad? if areas not equal it should be passed on */
- if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2)
+ if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2) {
return OPERATOR_PASS_THROUGH;
+ }
/* The factor will be close to 1.0f when near the top-left and the bottom-right corners. */
const float factor_v = ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy;
@@ -2106,8 +2231,9 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int area_split_exec(bContext *C, wmOperator *op)
{
- if (!area_split_init(C, op))
+ if (!area_split_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
area_split_apply(C, op);
area_split_exit(C, op);
@@ -2327,8 +2453,9 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
/* subtractwidth of regions on opposite side
* prevents dragging regions into other opposite regions */
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar == scalear)
+ if (ar == scalear) {
continue;
+ }
if (scalear->alignment == RGN_ALIGN_LEFT && ar->alignment == RGN_ALIGN_RIGHT) {
dist -= ar->winx;
@@ -2338,12 +2465,12 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
}
else if (scalear->alignment == RGN_ALIGN_TOP &&
(ar->alignment == RGN_ALIGN_BOTTOM ||
- ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_FOOTER))) {
+ ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER))) {
dist -= ar->winy;
}
else if (scalear->alignment == RGN_ALIGN_BOTTOM &&
(ar->alignment == RGN_ALIGN_TOP ||
- ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_FOOTER))) {
+ ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER))) {
dist -= ar->winy;
}
}
@@ -2379,10 +2506,12 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
rmd->maxsize = area_max_regionsize(rmd->sa, rmd->ar, rmd->edge);
/* if not set we do now, otherwise it uses type */
- if (rmd->ar->sizex == 0)
+ if (rmd->ar->sizex == 0) {
rmd->ar->sizex = rmd->ar->winx;
- if (rmd->ar->sizey == 0)
+ }
+ if (rmd->ar->sizey == 0) {
rmd->ar->sizey = rmd->ar->winy;
+ }
/* now copy to regionmovedata */
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
@@ -2408,15 +2537,18 @@ static void region_scale_validate_size(RegionMoveData *rmd)
if ((rmd->ar->flag & RGN_FLAG_HIDDEN) == 0) {
short *size, maxsize = -1;
- if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT)
+ if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
size = &rmd->ar->sizex;
- else
+ }
+ else {
size = &rmd->ar->sizey;
+ }
maxsize = rmd->maxsize - (UI_UNIT_Y / UI_DPI_FAC);
- if (*size > maxsize && maxsize > 0)
+ if (*size > maxsize && maxsize > 0) {
*size = maxsize;
+ }
}
}
@@ -2430,6 +2562,18 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd)
region_toggle_hidden(C, rmd->ar, 0);
region_scale_validate_size(rmd);
+
+ if ((rmd->ar->flag & RGN_FLAG_HIDDEN) == 0) {
+ if (rmd->ar->regiontype == RGN_TYPE_HEADER) {
+ ARegion *ar_tool_header = BKE_area_find_region_type(rmd->sa, RGN_TYPE_TOOL_HEADER);
+ if (ar_tool_header != NULL) {
+ if ((ar_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER) == 0 &&
+ (ar_tool_header->flag & RGN_FLAG_HIDDEN) != 0) {
+ region_toggle_hidden(C, ar_tool_header, 0);
+ }
+ }
+ }
+ }
}
static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2445,8 +2589,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
const int snap_size_threshold = (U.widget_unit * 2) / aspect;
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
delta = event->x - rmd->origx;
- if (rmd->edge == AE_LEFT_TO_TOPRIGHT)
+ if (rmd->edge == AE_LEFT_TO_TOPRIGHT) {
delta = -delta;
+ }
/* region sizes now get multiplied */
delta /= UI_DPI_FAC;
@@ -2463,8 +2608,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (rmd->ar->sizex < UI_UNIT_X) {
rmd->ar->sizex = rmd->origval;
- if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
+ if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) {
region_scale_toggle_hidden(C, rmd);
+ }
}
else if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
region_scale_toggle_hidden(C, rmd);
@@ -2475,8 +2621,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
delta = event->y - rmd->origy;
- if (rmd->edge == AE_BOTTOM_TO_TOPLEFT)
+ if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) {
delta = -delta;
+ }
/* region sizes now get multiplied */
delta /= UI_DPI_FAC;
@@ -2496,8 +2643,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
* otherwise its too easy to do this by accident */
if (rmd->ar->sizey < UI_UNIT_Y / 4) {
rmd->ar->sizey = rmd->origval;
- if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
+ if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) {
region_scale_toggle_hidden(C, rmd);
+ }
}
else if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
region_scale_toggle_hidden(C, rmd);
@@ -2667,16 +2815,20 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME;
- if (RNA_boolean_get(op->ptr, "end"))
+ if (RNA_boolean_get(op->ptr, "end")) {
sad->nextfra = PEFRA;
- else
+ }
+ else {
sad->nextfra = PSFRA;
+ }
}
else {
- if (RNA_boolean_get(op->ptr, "end"))
+ if (RNA_boolean_get(op->ptr, "end")) {
CFRA = PEFRA;
- else
+ }
+ else {
CFRA = PSFRA;
+ }
areas_do_frame_follow(C, true);
@@ -2724,8 +2876,9 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
bool done = false;
/* sanity checks */
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
cfra = (float)(CFRA);
@@ -2759,10 +2912,12 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
}
/* find matching keyframe in the right direction */
- if (next)
+ if (next) {
ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
- else
+ }
+ else {
ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
+ }
while ((ak != NULL) && (done == false)) {
if (CFRA != (int)ak->cfra) {
@@ -2932,8 +3087,9 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op)
/* search current screen for 'fullscreen' areas */
/* prevents restoring info header, when mouse is over it */
for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->full)
+ if (sa->full) {
break;
+ }
}
if (sa == NULL) {
@@ -3082,8 +3238,9 @@ static int area_join_init(bContext *C, wmOperator *op)
static int area_join_apply(bContext *C, wmOperator *op)
{
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
- if (!jd)
+ if (!jd) {
return 0;
+ }
if (!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)) {
return 0;
@@ -3102,8 +3259,9 @@ static void area_join_exit(bContext *C, wmOperator *op)
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
if (jd) {
- if (jd->draw_callback)
+ if (jd->draw_callback) {
WM_draw_cb_exit(CTX_wm_window(C), jd->draw_callback);
+ }
MEM_freeN(jd);
op->customdata = NULL;
@@ -3117,8 +3275,9 @@ static void area_join_exit(bContext *C, wmOperator *op)
static int area_join_exec(bContext *C, wmOperator *op)
{
- if (!area_join_init(C, op))
+ if (!area_join_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
area_join_apply(C, op);
area_join_exit(C, op);
@@ -3138,12 +3297,14 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
/* verify *sad itself */
- if (sad->sa1 == NULL || sad->sa2 == NULL)
+ if (sad->sa1 == NULL || sad->sa2 == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
/* is this our *sad? if areas equal it should be passed on */
- if (sad->sa1 == sad->sa2)
+ if (sad->sa1 == sad->sa2) {
return OPERATOR_PASS_THROUGH;
+ }
/* prepare operator state vars */
RNA_int_set(op->ptr, "min_x", sad->sa1->totrct.xmin);
@@ -3152,8 +3313,9 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RNA_int_set(op->ptr, "max_y", sad->sa2->totrct.ymin);
}
- if (!area_join_init(C, op))
+ if (!area_join_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -3225,16 +3387,21 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- if (dir == 1)
+ if (dir == 1) {
WM_cursor_set(win, BC_N_ARROWCURSOR);
- else if (dir == 3)
+ }
+ else if (dir == 3) {
WM_cursor_set(win, BC_S_ARROWCURSOR);
- else if (dir == 2)
+ }
+ else if (dir == 2) {
WM_cursor_set(win, BC_E_ARROWCURSOR);
- else if (dir == 0)
+ }
+ else if (dir == 0) {
WM_cursor_set(win, BC_W_ARROWCURSOR);
- else
+ }
+ else {
WM_cursor_set(win, BC_STOPCURSOR);
+ }
break;
}
@@ -3304,8 +3471,9 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
actedge = screen_geom_area_map_find_active_scredge(
AREAMAP_FROM_SCREEN(sc), &window_rect, event->x, event->y);
- if (actedge == NULL)
+ if (actedge == NULL) {
return OPERATOR_CANCELLED;
+ }
pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
layout = UI_popup_menu_layout(pup);
@@ -3442,17 +3610,19 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
int items, i;
items = BLI_listbase_count(&wm->operators);
- if (items == 0)
+ if (items == 0) {
return OPERATOR_CANCELLED;
+ }
pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
layout = UI_popup_menu_layout(pup);
- for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--)
+ for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) {
if ((lastop->type->flag & OPTYPE_REGISTER) && WM_operator_repeat_check(C, lastop)) {
uiItemIntO(
layout, RNA_struct_ui_name(lastop->type->srna), ICON_NONE, op->type->idname, "index", i);
}
+ }
UI_popup_menu_end(C, pup);
@@ -3501,8 +3671,9 @@ static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *
{
wmOperator *lastop = WM_operator_last_redo(C);
- if (lastop)
+ if (lastop) {
WM_operator_redo_popup(C, lastop);
+ }
return OPERATOR_CANCELLED;
}
@@ -3660,8 +3831,10 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
RV3D_ORTHO);
/* forcing camera is distracting */
#if 0
- if (v3d->camera) region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB);
- else region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_USER, RV3D_PERSP);
+ if (v3d->camera)
+ region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB);
+ else
+ region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_USER, RV3D_PERSP);
#else
(void)v3d;
#endif
@@ -3697,17 +3870,22 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
{
ARegion *ar = CTX_wm_region(C);
- if (!ar)
+ if (!ar) {
return OPERATOR_CANCELLED;
+ }
- if (ar->alignment == RGN_ALIGN_TOP)
+ if (ar->alignment == RGN_ALIGN_TOP) {
ar->alignment = RGN_ALIGN_BOTTOM;
- else if (ar->alignment == RGN_ALIGN_BOTTOM)
+ }
+ else if (ar->alignment == RGN_ALIGN_BOTTOM) {
ar->alignment = RGN_ALIGN_TOP;
- else if (ar->alignment == RGN_ALIGN_LEFT)
+ }
+ else if (ar->alignment == RGN_ALIGN_LEFT) {
ar->alignment = RGN_ALIGN_RIGHT;
- else if (ar->alignment == RGN_ALIGN_RIGHT)
+ }
+ else if (ar->alignment == RGN_ALIGN_RIGHT) {
ar->alignment = RGN_ALIGN_LEFT;
+ }
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_mousemove(C);
@@ -3745,40 +3923,6 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Header Toggle Operator
- * \{ */
-
-static int header_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ARegion *ar = screen_find_region_type(C, RGN_TYPE_HEADER);
-
- if (ar == NULL) {
- return OPERATOR_CANCELLED;
- }
-
- ar->flag ^= RGN_FLAG_HIDDEN;
-
- ED_area_tag_redraw(CTX_wm_area(C));
-
- WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
-
- return OPERATOR_FINISHED;
-}
-
-static void SCREEN_OT_header(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Toggle Header";
- ot->description = "Toggle header display";
- ot->idname = "SCREEN_OT_header";
-
- /* api callbacks */
- ot->exec = header_exec;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Header Toggle Menu Operator
* \{ */
@@ -3826,9 +3970,25 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
ARegion *ar = CTX_wm_region(C);
const char *but_flip_str = (ar->alignment == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") :
IFACE_("Flip to Top");
+ {
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, sa->spacedata.first, &ptr);
+ uiItemR(layout, &ptr, "show_region_header", 0, IFACE_("Show Header"), ICON_NONE);
- if (!ELEM(sa->spacetype, SPACE_TOPBAR)) {
- uiItemO(layout, IFACE_("Toggle Header"), ICON_NONE, "SCREEN_OT_header");
+ ARegion *ar_header = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ uiLayout *col = uiLayoutColumn(layout, 0);
+ uiLayoutSetActive(col, (ar_header->flag & RGN_FLAG_HIDDEN) == 0);
+
+ if (BKE_area_find_region_type(sa, RGN_TYPE_TOOL_HEADER)) {
+ uiItemR(col, &ptr, "show_region_tool_header", 0, IFACE_("Show Tool Settings"), ICON_NONE);
+ }
+
+ uiItemO(col,
+ IFACE_("Show Menus"),
+ (sa->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT,
+ "SCREEN_OT_header_toggle_menus");
+
+ uiItemS(layout);
}
/* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */
@@ -3838,11 +3998,6 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
}
- uiItemO(layout,
- IFACE_("Collapse Menus"),
- (sa->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT,
- "SCREEN_OT_header_toggle_menus");
-
/* File browser should be fullscreen all the time, top-bar should
* never be. But other regions can be maximized/restored. */
if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
@@ -4011,8 +4166,9 @@ static int match_area_with_refresh(int spacetype, int refresh)
{
switch (spacetype) {
case SPACE_TIME:
- if (refresh & SPACE_TIME)
+ if (refresh & SPACE_TIME) {
return 1;
+ }
break;
}
@@ -4028,40 +4184,48 @@ static int match_region_with_redraws(int spacetype,
switch (spacetype) {
case SPACE_VIEW3D:
- if ((redraws & TIME_ALL_3D_WIN) || from_anim_edit)
+ if ((redraws & TIME_ALL_3D_WIN) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_GRAPH:
case SPACE_NLA:
- if ((redraws & TIME_ALL_ANIM_WIN) || from_anim_edit)
+ if ((redraws & TIME_ALL_ANIM_WIN) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_ACTION:
/* if only 1 window or 3d windows, we do timeline too
* NOTE: Now we do do action editor in all these cases, since timeline is here
*/
- if ((redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) || from_anim_edit)
+ if ((redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_PROPERTIES:
- if (redraws & TIME_ALL_BUTS_WIN)
+ if (redraws & TIME_ALL_BUTS_WIN) {
return 1;
+ }
break;
case SPACE_SEQ:
- if ((redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) || from_anim_edit)
+ if ((redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_NODE:
- if (redraws & (TIME_NODES))
+ if (redraws & (TIME_NODES)) {
return 1;
+ }
break;
case SPACE_IMAGE:
- if ((redraws & TIME_ALL_IMAGE_WIN) || from_anim_edit)
+ if ((redraws & TIME_ALL_IMAGE_WIN) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_CLIP:
- if ((redraws & TIME_CLIPS) || from_anim_edit)
+ if ((redraws & TIME_CLIPS) || from_anim_edit) {
return 1;
+ }
break;
}
}
@@ -4070,8 +4234,9 @@ static int match_region_with_redraws(int spacetype,
case SPACE_GRAPH:
case SPACE_ACTION:
case SPACE_NLA:
- if (redraws & TIME_ALL_ANIM_WIN)
+ if (redraws & TIME_ALL_ANIM_WIN) {
return 1;
+ }
break;
}
}
@@ -4085,18 +4250,21 @@ static int match_region_with_redraws(int spacetype,
return 1;
}
- if (redraws & TIME_ALL_BUTS_WIN)
+ if (redraws & TIME_ALL_BUTS_WIN) {
return 1;
+ }
}
- else if (regiontype == RGN_TYPE_HEADER) {
- if (spacetype == SPACE_ACTION)
+ else if (ELEM(regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
+ if (spacetype == SPACE_ACTION) {
return 1;
+ }
}
else if (regiontype == RGN_TYPE_PREVIEW) {
switch (spacetype) {
case SPACE_SEQ:
- if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN))
+ if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) {
return 1;
+ }
break;
case SPACE_CLIP:
return 1;
@@ -4129,22 +4297,27 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
float time;
/* sync, don't sync, or follow scene setting */
- if (sad->flag & ANIMPLAY_FLAG_SYNC)
+ if (sad->flag & ANIMPLAY_FLAG_SYNC) {
sync = 1;
- else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC)
+ }
+ else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) {
sync = 0;
- else
+ }
+ else {
sync = (scene->flag & SCE_FRAME_DROP);
+ }
if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false &&
isfinite(time = BKE_sound_sync_scene(scene))) {
double newfra = (double)time * FPS;
/* give some space here to avoid jumps */
- if (newfra + 0.5 > scene->r.cfra && newfra - 0.5 < scene->r.cfra)
+ if (newfra + 0.5 > scene->r.cfra && newfra - 0.5 < scene->r.cfra) {
scene->r.cfra++;
- else
+ }
+ else {
scene->r.cfra = newfra + 0.5;
+ }
#ifdef PROFILE_AUDIO_SYNCH
newfra_int = scene->r.cfra;
@@ -4166,17 +4339,21 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS));
/* skip frames */
- if (sad->flag & ANIMPLAY_FLAG_REVERSE)
+ if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
scene->r.cfra -= step;
- else
+ }
+ else {
scene->r.cfra += step;
+ }
}
else {
/* one frame +/- */
- if (sad->flag & ANIMPLAY_FLAG_REVERSE)
+ if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
scene->r.cfra--;
- else
+ }
+ else {
scene->r.cfra++;
+ }
}
}
@@ -4269,8 +4446,9 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
}
}
- if (match_area_with_refresh(sa->spacetype, sad->refresh))
+ if (match_area_with_refresh(sa->spacetype, sad->refresh)) {
ED_area_tag_refresh(sa);
+ }
}
}
@@ -4283,7 +4461,8 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
/* Recalculate the time-step for the timer now that we've finished calculating this,
* since the frames-per-second value may have been changed.
*/
- /* TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? */
+ /* TODO: this may make evaluation a bit slower if the value doesn't change...
+ * any way to avoid this? */
wt->timestep = (1.0 / FPS);
return OPERATOR_FINISHED;
@@ -4356,8 +4535,9 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
/* these settings are currently only available from a menu in the TimeLine */
int refresh = SPACE_ACTION;
- if (mode == 1) /* XXX only play audio forwards!? */
+ if (mode == 1) { /* XXX only play audio forwards!? */
BKE_sound_play_scene(scene);
+ }
ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode);
@@ -4377,8 +4557,9 @@ static int screen_animation_play_exec(bContext *C, wmOperator *op)
int mode = (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1;
int sync = -1;
- if (RNA_struct_property_is_set(op->ptr, "sync"))
+ if (RNA_struct_property_is_set(op->ptr, "sync")) {
sync = (RNA_boolean_get(op->ptr, "sync"));
+ }
return ED_screen_animation_play(C, sync, mode);
}
@@ -4527,8 +4708,9 @@ static int fullscreen_back_exec(bContext *C, wmOperator *op)
/* search current screen for 'fullscreen' areas */
for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->full)
+ if (sa->full) {
break;
+ }
}
if (!sa) {
BKE_report(op->reports, RPT_ERROR, "No fullscreen areas were found");
@@ -4629,7 +4811,8 @@ static int drivers_editor_show_invoke(bContext *C, wmOperator *op, const wmEvent
ANIM_set_active_channel(&ac, ac.data, ac.datatype, filter, fcu, ANIMTYPE_FCURVE);
}
else {
- /* Just blindly isolate... This isn't the best, and shouldn't happen, but may be enough... */
+ /* Just blindly isolate...
+ * This isn't the best, and shouldn't happen, but may be enough. */
fcu->flag |= (FCURVE_ACTIVE | FCURVE_SELECTED);
}
}
@@ -4719,12 +4902,13 @@ static void SCREEN_OT_delete(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Region Alpha Blending Operator
+ *
+ * Implementation note: a disappearing region needs at least 1 last draw with
+ * 100% backbuffer texture over it - then triple buffer will clear it entirely.
+ * This because flag #RGN_FLAG_HIDDEN is set in end - region doesn't draw at all then.
+ *
* \{ */
-/* implementation note: a disappearing region needs at least 1 last draw with 100% backbuffer
- * texture over it- then triple buffer will clear it entirely.
- * This because flag RGN_HIDDEN is set in end - region doesn't draw at all then */
-
typedef struct RegionAlphaInfo {
ScrArea *sa;
ARegion *ar, *child_ar; /* other region */
@@ -4747,8 +4931,9 @@ float ED_region_blend_alpha(ARegion *ar)
alpha = (float)ar->regiontimer->duration / TIMEOUT;
/* makes sure the blend out works 100% - without area redraws */
- if (rgi->hidden)
+ if (rgi->hidden) {
alpha = 0.9f - TIMESTEP - alpha;
+ }
CLAMP(alpha, 0.0f, 1.0f);
return alpha;
@@ -4763,13 +4948,15 @@ static void region_blend_end(bContext *C, ARegion *ar, const bool is_running)
/* always send redraw */
ED_region_tag_redraw(ar);
- if (rgi->child_ar)
+ if (rgi->child_ar) {
ED_region_tag_redraw(rgi->child_ar);
+ }
/* if running timer was hiding, the flag toggle went wrong */
if (is_running) {
- if (rgi->hidden)
+ if (rgi->hidden) {
rgi->ar->flag &= ~RGN_FLAG_HIDDEN;
+ }
}
else {
if (rgi->hidden) {
@@ -4783,7 +4970,7 @@ static void region_blend_end(bContext *C, ARegion *ar, const bool is_running)
ar->regiontimer = NULL;
}
/* assumes that *ar itself is not a splitted version from previous region */
-void region_blend_start(bContext *C, ScrArea *sa, ARegion *ar)
+void ED_region_visibility_change_update_animated(bContext *C, ScrArea *sa, ARegion *ar)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
@@ -4802,10 +4989,12 @@ void region_blend_start(bContext *C, ScrArea *sa, ARegion *ar)
ar->flag &= ~RGN_FLAG_HIDDEN;
/* blend in, reinitialize regions because it got unhidden */
- if (rgi->hidden == 0)
+ if (rgi->hidden == 0) {
ED_area_initialize(wm, win, sa);
- else
+ }
+ else {
WM_event_remove_handlers(C, &ar->handlers);
+ }
if (ar->next) {
if (ar->next->alignment & RGN_SPLIT_PREV) {
@@ -4825,15 +5014,17 @@ static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
wmTimer *timer = event->customdata;
/* event type is TIMERREGION, but we better check */
- if (event->type != TIMERREGION || timer == NULL)
+ if (event->type != TIMERREGION || timer == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
rgi = timer->customdata;
/* always send redraws */
ED_region_tag_redraw(rgi->ar);
- if (rgi->child_ar)
+ if (rgi->child_ar) {
ED_region_tag_redraw(rgi->child_ar);
+ }
/* end timer? */
if (rgi->ar->regiontimer->duration > (double)TIMEOUT) {
@@ -5107,7 +5298,6 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_region_quadview);
WM_operatortype_append(SCREEN_OT_region_scale);
WM_operatortype_append(SCREEN_OT_region_flip);
- WM_operatortype_append(SCREEN_OT_header);
WM_operatortype_append(SCREEN_OT_header_toggle_menus);
WM_operatortype_append(SCREEN_OT_header_context_menu);
WM_operatortype_append(SCREEN_OT_footer);
@@ -5177,8 +5367,9 @@ static bool blend_file_drop_poll(bContext *UNUSED(C),
const char **UNUSED(tooltip))
{
if (drag->type == WM_DRAG_PATH) {
- if (drag->icon == ICON_FILE_BLEND)
+ if (drag->icon == ICON_FILE_BLEND) {
return 1;
+ }
}
return 0;
}
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 37ffdef0b9b..3b763c7d47a 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -71,8 +71,9 @@ static void screenshot_read_pixels(int x, int y, int w, int h, unsigned char *re
glFinish();
/* clear alpha, it is not set to a meaningful value in opengl */
- for (i = 0, rect += 3; i < w * h; i++, rect += 4)
+ for (i = 0, rect += 3; i < w * h; i++, rect += 4) {
*rect = 255;
+ }
}
/* get shot from frontbuffer */
@@ -137,8 +138,9 @@ static void screenshot_data_free(wmOperator *op)
ScreenshotData *scd = op->customdata;
if (scd) {
- if (scd->dumprect)
+ if (scd->dumprect) {
MEM_freeN(scd->dumprect);
+ }
MEM_freeN(scd);
op->customdata = NULL;
}
@@ -153,8 +155,9 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop)
int y;
if (crop_x > 0 && crop_y > 0) {
- for (y = 0; y < crop_y; y++, to += crop_x, from += ibuf->x)
+ for (y = 0; y < crop_y; y++, to += crop_x, from += ibuf->x) {
memmove(to, from, sizeof(unsigned int) * crop_x);
+ }
ibuf->x = crop_x;
ibuf->y = crop_y;
@@ -185,8 +188,9 @@ static int screenshot_exec(bContext *C, wmOperator *op)
ibuf->rect = scd->dumprect;
/* crop to show only single editor */
- if (!RNA_boolean_get(op->ptr, "full"))
+ if (!RNA_boolean_get(op->ptr, "full")) {
screenshot_crop(ibuf, scd->crop);
+ }
if (scd->im_format.planes == R_IMF_PLANES_BW) {
/* bw screenshot? - users will notice if it fails! */
@@ -211,8 +215,9 @@ static int screenshot_exec(bContext *C, wmOperator *op)
static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
if (screenshot_data_create(C, op)) {
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return screenshot_exec(C, op);
+ }
/* extension is added by 'screenshot_check' after */
char filepath[FILE_MAX] = "//screen";
@@ -267,8 +272,9 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
static bool screenshot_poll(bContext *C)
{
- if (G.background)
+ if (G.background) {
return false;
+ }
return WM_operator_winactive(C);
}
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 5750a1f36a7..6294a64af0f 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -89,8 +89,7 @@ static void workspace_change_update(WorkSpace *workspace_new,
/* needs to be done before changing mode! (to ensure right context) */
UNUSED_VARS(workspace_old, workspace_new, C, wm);
#if 0
- Object *ob_act = CTX_data_active_object(C)
- eObjectMode mode_old = workspace_old->object_mode;
+ Object *ob_act = CTX_data_active_object(C) eObjectMode mode_old = workspace_old->object_mode;
eObjectMode mode_new = workspace_new->object_mode;
if (mode_old != mode_new) {
@@ -110,7 +109,8 @@ static WorkSpaceLayout *workspace_change_get_new_layout(Main *bmain,
WorkSpace *workspace_new,
wmWindow *win)
{
- /* ED_workspace_duplicate may have stored a layout to activate once the workspace gets activated. */
+ /* ED_workspace_duplicate may have stored a layout to activate
+ * once the workspace gets activated. */
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
WorkSpaceLayout *layout_new;
bScreen *screen_new;
@@ -159,7 +159,8 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager
win->workspace_hook->temp_layout_store = NULL;
if (workspace_old == workspace_new) {
- /* Could also return true, everything that needs to be done was done (nothing :P), but nothing changed */
+ /* Could also return true, everything that needs to be done was done (nothing :P),
+ * but nothing changed */
return false;
}
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index cddaf69b965..23617e687ea 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -29,8 +29,8 @@ set(INC
../../makesrna
../../render/extern/include
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index da183d190fa..65e24cecf82 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -96,12 +96,15 @@ static CursorSnapshot cursor_snap = {0};
/* delete overlay cursor textures to preserve memory and invalidate all overlay flags */
void paint_cursor_delete_textures(void)
{
- if (primary_snap.overlay_texture)
+ if (primary_snap.overlay_texture) {
glDeleteTextures(1, &primary_snap.overlay_texture);
- if (secondary_snap.overlay_texture)
+ }
+ if (secondary_snap.overlay_texture) {
glDeleteTextures(1, &secondary_snap.overlay_texture);
- if (cursor_snap.overlay_texture)
+ }
+ if (cursor_snap.overlay_texture) {
glDeleteTextures(1, &cursor_snap.overlay_texture);
+ }
memset(&primary_snap, 0, sizeof(TexSnapshot));
memset(&secondary_snap, 0, sizeof(TexSnapshot));
@@ -194,8 +197,8 @@ static void load_tex_task_cb_ex(void *__restrict userdata,
len = sqrtf(x * x + y * y);
if (ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL) || len <= 1.0f) {
- /* it is probably worth optimizing for those cases where the texture is not rotated by skipping the calls to
- * atan2, sqrtf, sin, and cos. */
+ /* It is probably worth optimizing for those cases where the texture is not rotated by
+ * skipping the calls to atan2, sqrtf, sin, and cos. */
if (mtex->tex && (rotation > 0.001f || rotation < -0.001f)) {
const float angle = atan2f(y, x) + rotation;
@@ -271,16 +274,19 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
int s = BKE_brush_size_get(vc->scene, br);
int r = 1;
- for (s >>= 1; s > 0; s >>= 1)
+ for (s >>= 1; s > 0; s >>= 1) {
r++;
+ }
size = (1 << r);
- if (size < 256)
+ if (size < 256) {
size = 256;
+ }
- if (size < target->old_size)
+ if (size < target->old_size) {
size = target->old_size;
+ }
}
else {
size = 512;
@@ -296,10 +302,12 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
target->old_size = size;
}
- if (col)
+ if (col) {
buffer = MEM_mallocN(sizeof(GLubyte) * size * size * 4, "load_tex");
- else
+ }
+ else {
buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex");
+ }
pool = BKE_image_pool_new();
@@ -324,14 +332,17 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
BLI_parallel_range_settings_defaults(&settings);
BLI_task_parallel_range(0, size, &data, load_tex_task_cb_ex, &settings);
- if (mtex->tex && mtex->tex->nodetree)
+ if (mtex->tex && mtex->tex->nodetree) {
ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
+ }
- if (pool)
+ if (pool) {
BKE_image_pool_free(pool);
+ }
- if (!target->overlay_texture)
+ if (!target->overlay_texture) {
glGenTextures(1, &target->overlay_texture);
+ }
}
else {
size = target->old_size;
@@ -352,8 +363,9 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, format, GL_UNSIGNED_BYTE, buffer);
}
- if (buffer)
+ if (buffer) {
MEM_freeN(buffer);
+ }
target->old_col = col;
}
@@ -422,16 +434,19 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
s = BKE_brush_size_get(vc->scene, br);
r = 1;
- for (s >>= 1; s > 0; s >>= 1)
+ for (s >>= 1; s > 0; s >>= 1) {
r++;
+ }
size = (1 << r);
- if (size < 256)
+ if (size < 256) {
size = 256;
+ }
- if (size < cursor_snap.size)
+ if (size < cursor_snap.size) {
size = cursor_snap.size;
+ }
if (cursor_snap.size != size) {
if (cursor_snap.overlay_texture) {
@@ -457,8 +472,9 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
BLI_parallel_range_settings_defaults(&settings);
BLI_task_parallel_range(0, size, &data, load_tex_cursor_task_cb, &settings);
- if (!cursor_snap.overlay_texture)
+ if (!cursor_snap.overlay_texture) {
glGenTextures(1, &cursor_snap.overlay_texture);
+ }
}
else {
size = cursor_snap.size;
@@ -475,8 +491,9 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, GL_RED, GL_UNSIGNED_BYTE, buffer);
}
- if (buffer)
+ if (buffer) {
MEM_freeN(buffer);
+ }
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -567,8 +584,9 @@ static bool sculpt_get_brush_geometry(bContext *C,
*pixel_radius = project_brush_radius(
vc, BKE_brush_unprojected_radius_get(scene, brush), location);
- if (*pixel_radius == 0)
+ if (*pixel_radius == 0) {
*pixel_radius = BKE_brush_size_get(scene, brush);
+ }
mul_m4_v3(vc->obact->obmat, location);
}
@@ -665,10 +683,12 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups,
quad.ymax = brush->mask_stencil_dimension[1];
}
GPU_matrix_push();
- if (primary)
+ if (primary) {
GPU_matrix_translate_2fv(brush->stencil_pos);
- else
+ }
+ else {
GPU_matrix_translate_2fv(brush->mask_stencil_pos);
+ }
GPU_matrix_rotate_2d(RAD2DEGF(mtex->rot));
}
@@ -787,8 +807,9 @@ static void paint_draw_cursor_overlay(
GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
- if (do_pop)
+ if (do_pop) {
GPU_matrix_pop();
+ }
}
}
@@ -812,20 +833,25 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
x -= vc->ar->winrct.xmin;
y -= vc->ar->winrct.ymin;
- /* coloured overlay should be drawn separately */
+ /* Colored overlay should be drawn separately. */
if (col) {
- if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY))
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY)) {
paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, true, true);
- if (!(flags & PAINT_OVERLAY_OVERRIDE_SECONDARY))
+ }
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_SECONDARY)) {
paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, false);
- if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR))
+ }
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) {
paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom);
+ }
}
else {
- if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PAINT_MODE_WEIGHT))
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PAINT_MODE_WEIGHT)) {
paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, true);
- if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR))
+ }
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) {
paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom);
+ }
}
GPU_matrix_pop();
@@ -954,7 +980,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
draw_rect_point(
pos, selec_col, handle_col, &cp->bez.vec[2][0], 8.0f, cp->bez.f3 || cp->bez.f2);
- for (j = 0; j < 2; j++)
+ for (j = 0; j < 2; j++) {
BKE_curve_forward_diff_bezier(cp->bez.vec[1][j],
cp->bez.vec[2][j],
cp_next->bez.vec[0][j],
@@ -962,6 +988,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
data + j,
PAINT_CURVE_NUM_SEGMENTS,
sizeof(float[2]));
+ }
float(*v)[2] = (float(*)[2])data;
@@ -1010,21 +1037,25 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups,
/* update the brush's cached 3D radius */
if (!BKE_brush_use_locked_size(vc->scene, brush)) {
/* get 2D brush radius */
- if (ups->draw_anchored)
+ if (ups->draw_anchored) {
projected_radius = ups->anchored_size;
+ }
else {
- if (brush->flag & BRUSH_ANCHORED)
+ if (brush->flag & BRUSH_ANCHORED) {
projected_radius = 8;
- else
+ }
+ else {
projected_radius = BKE_brush_size_get(vc->scene, brush);
+ }
}
/* convert brush radius from 2D to 3D */
unprojected_radius = paint_calc_object_space_radius(vc, location, projected_radius);
/* scale 3D brush radius by pressure */
- if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush))
+ if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
unprojected_radius *= ups->size_pressure_value;
+ }
/* set cached value in either Brush or UnifiedPaintSettings */
BKE_brush_unprojected_radius_set(vc->scene, brush, unprojected_radius);
@@ -1053,8 +1084,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
/* check that brush drawing is enabled */
- if (ommit_cursor_drawing(paint, mode, brush))
+ if (ommit_cursor_drawing(paint, mode, brush)) {
return;
+ }
/* can't use stroke vc here because this will be called during
* mouse over too, not just during a stroke */
@@ -1100,8 +1132,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* test if brush is over the mesh */
bool hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location, ups);
- if (BKE_brush_use_locked_size(scene, brush))
+ if (BKE_brush_use_locked_size(scene, brush)) {
BKE_brush_size_set(scene, brush, pixel_radius);
+ }
/* check if brush is subtracting, use different color then */
/* TODO: no way currently to know state of pen flip or
@@ -1112,8 +1145,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
}
/* only do if brush is over the mesh */
- if (hit)
+ if (hit) {
paint_cursor_on_hit(ups, brush, &vc, location);
+ }
}
if (ups->draw_anchored) {
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c
index bc6e019142a..d9fd194e96f 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -60,13 +60,15 @@ bool paint_curve_poll(bContext *C)
RegionView3D *rv3d = CTX_wm_region_view3d(C);
SpaceImage *sima;
- if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0)))
+ if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0))) {
return false;
+ }
sima = CTX_wm_space_image(C);
- if (sima && sima->mode != SI_MODE_PAINT)
+ if (sima && sima->mode != SI_MODE_PAINT) {
return false;
+ }
p = BKE_paint_get_active_from_context(C);
@@ -95,8 +97,9 @@ static PaintCurvePoint *paintcurve_point_get_closest(
if (dist < closest_dist) {
closest = pcp;
closest_dist = dist;
- if (point)
+ if (point) {
*point = SEL_F1;
+ }
}
}
if (!ignore_pivot) {
@@ -105,8 +108,9 @@ static PaintCurvePoint *paintcurve_point_get_closest(
if (dist < closest_dist) {
closest = pcp;
closest_dist = dist;
- if (point)
+ if (point) {
*point = SEL_F2;
+ }
}
}
}
@@ -115,8 +119,9 @@ static PaintCurvePoint *paintcurve_point_get_closest(
if (dist < closest_dist) {
closest = pcp;
closest_dist = dist;
- if (point)
+ if (point) {
*point = SEL_F3;
+ }
}
}
}
@@ -213,12 +218,14 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2])
add_index = pc->add_index;
if (pc->points) {
- if (add_index > 0)
+ if (add_index > 0) {
memcpy(pcp, pc->points, add_index * sizeof(PaintCurvePoint));
- if (add_index < pc->tot_points)
+ }
+ if (add_index < pc->tot_points) {
memcpy(pcp + add_index + 1,
pc->points + add_index,
(pc->tot_points - add_index) * sizeof(PaintCurvePoint));
+ }
MEM_freeN(pc->points);
}
@@ -332,8 +339,9 @@ static int paintcurve_delete_point_exec(bContext *C, wmOperator *op)
int j = 0;
int new_tot = pc->tot_points - tot_del;
PaintCurvePoint *points_new = NULL;
- if (new_tot > 0)
+ if (new_tot > 0) {
points_new = MEM_mallocN(new_tot * sizeof(PaintCurvePoint), "PaintCurvePoint");
+ }
for (i = 0, pcp = pc->points; i < pc->tot_points; i++, pcp++) {
if (!(pcp->bez.f2 & DELETE_TAG)) {
@@ -392,8 +400,9 @@ static bool paintcurve_point_select(
pc = br->paint_curve;
- if (!pc)
+ if (!pc) {
return false;
+ }
ED_paintcurve_undo_push_begin(op->type->name);
@@ -429,22 +438,28 @@ static bool paintcurve_point_select(
BKE_paint_curve_clamp_endpoint_add_index(pc, pcp - pc->points);
if (selflag == SEL_F2) {
- if (extend)
+ if (extend) {
pcp->bez.f2 ^= SELECT;
- else
+ }
+ else {
pcp->bez.f2 |= SELECT;
+ }
}
else if (selflag == SEL_F1) {
- if (extend)
+ if (extend) {
pcp->bez.f1 ^= SELECT;
- else
+ }
+ else {
pcp->bez.f1 |= SELECT;
+ }
}
else if (selflag == SEL_F3) {
- if (extend)
+ if (extend) {
pcp->bez.f3 ^= SELECT;
- else
+ }
+ else {
pcp->bez.f3 |= SELECT;
+ }
}
}
@@ -495,8 +510,9 @@ static int paintcurve_select_point_exec(bContext *C, wmOperator *op)
bool toggle = RNA_boolean_get(op->ptr, "toggle");
bool extend = RNA_boolean_get(op->ptr, "extend");
RNA_int_get_array(op->ptr, "location", loc);
- if (paintcurve_point_select(C, op, loc, toggle, extend))
+ if (paintcurve_point_select(C, op, loc, toggle, extend)) {
return OPERATOR_FINISHED;
+ }
}
return OPERATOR_CANCELLED;
@@ -557,8 +573,9 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e
PaintCurve *pc = br->paint_curve;
PaintCurvePoint *pcp;
- if (!pc)
+ if (!pc) {
return OPERATOR_PASS_THROUGH;
+ }
if (do_select) {
pcp = paintcurve_point_get_closest(pc, loc_fl, align, PAINT_CURVE_SELECT_THRESHOLD, &select);
@@ -589,8 +606,9 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e
op->customdata = psd;
/* first, clear all selection from points */
- for (i = 0; i < pc->tot_points; i++)
+ for (i = 0; i < pc->tot_points; i++) {
pc->points[i].bez.f1 = pc->points[i].bez.f3 = pc->points[i].bez.f2 = 0;
+ }
/* only select the active point */
PAINT_CURVE_POINT_SELECT(pcp, psd->select);
@@ -622,8 +640,9 @@ static int paintcurve_slide_modal(bContext *C, wmOperator *op, const wmEvent *ev
float diff[2] = {event->mval[0] - psd->initial_loc[0], event->mval[1] - psd->initial_loc[1]};
if (psd->select == 1) {
int i;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++) {
add_v2_v2v2(psd->pcp->bez.vec[i], diff, psd->point_initial_loc[i]);
+ }
}
else {
add_v2_v2(diff, psd->point_initial_loc[psd->select]);
@@ -718,8 +737,9 @@ static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const w
SpaceImage *sima = CTX_wm_space_image(C);
float location[2];
- if (!sima)
+ if (!sima) {
return OPERATOR_CANCELLED;
+ }
UI_view2d_region_to_view(
&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index c1f87f676e2..dded9fcf45a 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -66,8 +66,9 @@ static bool is_effected(PartialVisArea area,
const float co[3],
const float mask)
{
- if (area == PARTIALVIS_ALL)
+ if (area == PARTIALVIS_ALL) {
return 1;
+ }
else if (area == PARTIALVIS_MASKED) {
return mask > 0.5f;
}
@@ -103,15 +104,18 @@ static void partialvis_update_mesh(Object *ob,
/* hide vertex if in the hide volume */
if (is_effected(area, planes, v->co, vmask)) {
- if (action == PARTIALVIS_HIDE)
+ if (action == PARTIALVIS_HIDE) {
v->flag |= ME_HIDE;
- else
+ }
+ else {
v->flag &= ~ME_HIDE;
+ }
any_changed = true;
}
- if (!(v->flag & ME_HIDE))
+ if (!(v->flag & ME_HIDE)) {
any_visible = true;
+ }
}
if (any_changed) {
@@ -183,10 +187,12 @@ static void partialvis_update_grids(Object *ob,
}
/* keep track of whether any elements are still hidden */
- if (BLI_BITMAP_TEST(gh, y * key.grid_size + x))
+ if (BLI_BITMAP_TEST(gh, y * key.grid_size + x)) {
any_hidden = true;
- else
+ }
+ else {
any_visible = true;
+ }
}
}
@@ -222,15 +228,18 @@ static void partialvis_update_bmesh_verts(BMesh *bm,
/* hide vertex if in the hide volume */
if (is_effected(area, planes, v->co, *vmask)) {
- if (action == PARTIALVIS_HIDE)
+ if (action == PARTIALVIS_HIDE) {
BM_elem_flag_enable(v, BM_ELEM_HIDDEN);
- else
+ }
+ else {
BM_elem_flag_disable(v, BM_ELEM_HIDDEN);
+ }
(*any_changed) = true;
}
- if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN))
+ if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
(*any_visible) = true;
+ }
}
}
@@ -241,10 +250,12 @@ static void partialvis_update_bmesh_faces(GSet *faces)
GSET_ITER (gs_iter, faces) {
BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
- if (paint_is_bmesh_face_hidden(f))
+ if (paint_is_bmesh_face_hidden(f)) {
BM_elem_flag_enable(f, BM_ELEM_HIDDEN);
- else
+ }
+ else {
BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
+ }
}
}
@@ -375,8 +386,9 @@ static int hide_show_exec(bContext *C, wmOperator *op)
}
}
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
/* end undo */
sculpt_undo_push_end();
@@ -396,10 +408,12 @@ static int hide_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
PartialVisArea area = RNA_enum_get(op->ptr, "area");
- if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED))
+ if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED)) {
return WM_gesture_box_invoke(C, op, event);
- else
+ }
+ else {
return op->type->exec(C, op);
+ }
}
void PAINT_OT_hide_show(struct wmOperatorType *ot)
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 3a3f4335fd5..5a45f4946f2 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -81,8 +81,10 @@
#include "paint_intern.h"
-/* This is a static resource for non-global access.
- * Maybe it should be exposed as part of the paint operation, but for now just give a public interface.
+/**
+ * This is a static resource for non-global access.
+ * Maybe it should be exposed as part of the paint operation,
+ * but for now just give a public interface.
*/
static ImagePaintPartialRedraw imapaintpartial = {0, 0, 0, 0, 0};
@@ -124,8 +126,9 @@ void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, int
IMB_rectclip(ibuf, NULL, &x, &y, &srcx, &srcy, &w, &h);
- if (w == 0 || h == 0)
+ if (w == 0 || h == 0) {
return;
+ }
if (!imapaintpartial.enabled) {
imapaintpartial.x1 = x;
@@ -145,14 +148,17 @@ void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, int
ListBase *undo_tiles = ED_image_undo_get_tiles();
- for (ty = tiley; ty <= tileh; ty++)
- for (tx = tilex; tx <= tilew; tx++)
+ for (ty = tiley; ty <= tileh; ty++) {
+ for (tx = tilex; tx <= tilew; tx++) {
image_undo_push_tile(undo_tiles, ima, ibuf, &tmpibuf, tx, ty, NULL, NULL, false, find_old);
+ }
+ }
ibuf->userflags |= IB_BITMAPDIRTY;
- if (tmpibuf)
+ if (tmpibuf) {
IMB_freeImBuf(tmpibuf);
+ }
}
void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
@@ -162,8 +168,9 @@ void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short te
ibuf, imapaintpartial.x1, imapaintpartial.y1, imapaintpartial.x2, imapaintpartial.y2);
}
- if (ibuf->mipmap[0])
+ if (ibuf->mipmap[0]) {
ibuf->userflags |= IB_MIPMAP_INVALID;
+ }
/* todo: should set_tpage create ->rect? */
if (texpaint || (sima && sima->lock)) {
@@ -195,8 +202,9 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
kernel->pixel_len = radius;
}
else {
- if (br->blur_kernel_radius <= 0)
+ if (br->blur_kernel_radius <= 0) {
br->blur_kernel_radius = 1;
+ }
radius = br->blur_kernel_radius;
@@ -208,8 +216,9 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
switch (type) {
case KERNEL_BOX:
- for (i = 0; i < kernel->side_squared; i++)
+ for (i = 0; i < kernel->side_squared; i++) {
kernel->wdata[i] = 1.0;
+ }
break;
case KERNEL_GAUSSIAN: {
@@ -244,8 +253,9 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
void paint_delete_blur_kernel(BlurKernel *kernel)
{
- if (kernel->wdata)
+ if (kernel->wdata) {
MEM_freeN(kernel->wdata);
+ }
}
/************************ image paint poll ************************/
@@ -262,8 +272,9 @@ static bool image_paint_poll_ex(bContext *C, bool check_tool)
{
Object *obact;
- if (!image_paint_brush(C))
+ if (!image_paint_brush(C)) {
return 0;
+ }
obact = CTX_data_active_object(C);
if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
@@ -300,10 +311,13 @@ static bool image_paint_2d_clone_poll(bContext *C)
{
Brush *brush = image_paint_brush(C);
- if (!CTX_wm_region_view3d(C) && image_paint_poll(C))
- if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE))
- if (brush->clone.image)
+ if (!CTX_wm_region_view3d(C) && image_paint_poll(C)) {
+ if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) {
+ if (brush->clone.image) {
return 1;
+ }
+ }
+ }
return 0;
}
@@ -351,8 +365,9 @@ void paint_brush_color_get(struct Scene *scene,
float color[3],
struct ColorManagedDisplay *display)
{
- if (invert)
+ if (invert) {
copy_v3_v3(color, BKE_brush_secondary_color_get(scene, br));
+ }
else {
if (br->flag & BRUSH_USE_GRADIENT) {
float color_gr[4];
@@ -372,11 +387,13 @@ void paint_brush_color_get(struct Scene *scene,
}
copy_v3_v3(color, color_gr);
}
- else
+ else {
copy_v3_v3(color, BKE_brush_color_get(scene, br));
+ }
}
- if (color_correction)
+ if (color_correction) {
IMB_colormanagement_display_to_scene_linear_v3(color, display);
+ }
}
void paint_brush_init_tex(Brush *brush)
@@ -399,11 +416,13 @@ void paint_brush_exit_tex(Brush *brush)
{
if (brush) {
MTex *mtex = &brush->mtex;
- if (mtex->tex && mtex->tex->nodetree)
+ if (mtex->tex && mtex->tex->nodetree) {
ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
+ }
mtex = &brush->mask_mtex;
- if (mtex->tex && mtex->tex->nodetree)
+ if (mtex->tex && mtex->tex->nodetree) {
ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
+ }
}
}
@@ -526,10 +545,12 @@ static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, Po
return;
}
- if (BKE_brush_use_alpha_pressure(scene, brush))
+ if (BKE_brush_use_alpha_pressure(scene, brush)) {
BKE_brush_alpha_set(scene, brush, max_ff(0.0f, startalpha * pressure * alphafac));
- else
+ }
+ else {
BKE_brush_alpha_set(scene, brush, max_ff(0.0f, startalpha * alphafac));
+ }
if ((brush->flag & BRUSH_DRAG_DOT) || (brush->flag & BRUSH_ANCHORED)) {
UndoStack *ustack = CTX_wm_manager(C)->undo_stack;
@@ -632,9 +653,15 @@ static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke)
/* duplicate warning, see texpaint_init */
#if 0
if (pop->s.warnmultifile)
- BKE_reportf(op->reports, RPT_WARNING, "Image requires 4 color channels to paint: %s", pop->s.warnmultifile);
+ BKE_reportf(op->reports,
+ RPT_WARNING,
+ "Image requires 4 color channels to paint: %s",
+ pop->s.warnmultifile);
if (pop->s.warnpackedfile)
- BKE_reportf(op->reports, RPT_WARNING, "Packed MultiLayer files cannot be painted: %s", pop->s.warnpackedfile);
+ BKE_reportf(op->reports,
+ RPT_WARNING,
+ "Packed MultiLayer files cannot be painted: %s",
+ pop->s.warnpackedfile);
#endif
MEM_freeN(pop);
}
@@ -689,8 +716,9 @@ static int paint_exec(bContext *C, wmOperator *op)
strokeprop = RNA_struct_find_property(op->ptr, "stroke");
- if (!RNA_property_collection_lookup_int(op->ptr, strokeprop, 0, &firstpoint))
+ if (!RNA_property_collection_lookup_int(op->ptr, strokeprop, 0, &firstpoint)) {
return OPERATOR_CANCELLED;
+ }
RNA_float_get_array(&firstpoint, "mouse", mouse);
@@ -759,8 +787,9 @@ static void toggle_paint_cursor(bContext *C, int enable)
settings->imapaint.paintcursor = NULL;
paint_cursor_delete_textures();
}
- else if (enable)
+ else if (enable) {
paint_cursor_start(C, image_paint_poll);
+ }
}
/* enable the paint cursor if it isn't already.
@@ -1086,12 +1115,15 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
static bool texture_paint_toggle_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (ob == NULL || ob->type != OB_MESH)
+ if (ob == NULL || ob->type != OB_MESH) {
return 0;
- if (!ob->data || ID_IS_LINKED(ob->data))
+ }
+ if (!ob->data || ID_IS_LINKED(ob->data)) {
return 0;
- if (CTX_data_edit_object(C))
+ }
+ if (CTX_data_edit_object(C)) {
return 0;
+ }
return 1;
}
@@ -1114,8 +1146,9 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
if (ob->mode & mode_flag) {
ob->mode &= ~mode_flag;
- if (U.glreslimit != 0)
+ if (U.glreslimit != 0) {
GPU_free_images(bmain);
+ }
GPU_paint_set_mipmap(bmain, 1);
toggle_paint_cursor(C, 0);
@@ -1136,8 +1169,9 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
/* set the current material active paint slot on image editor */
Material *ma = give_current_material(ob, ob->actcol);
- if (ma && ma->texpaintslot)
+ if (ma && ma->texpaintslot) {
ima = ma->texpaintslot[ma->paint_active_slot].ima;
+ }
}
else if (imapaint->mode == IMAGEPAINT_MODE_IMAGE) {
ima = imapaint->canvas;
@@ -1168,8 +1202,9 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
BKE_paint_toolslots_brush_validate(bmain, &imapaint->paint);
- if (U.glreslimit != 0)
+ if (U.glreslimit != 0) {
GPU_free_images(bmain);
+ }
GPU_paint_set_mipmap(bmain, 0);
toggle_paint_cursor(C, 1);
@@ -1227,8 +1262,9 @@ static bool brush_colors_flip_poll(bContext *C)
{
if (image_paint_poll(C)) {
Brush *br = image_paint_brush(C);
- if (ELEM(br->imagepaint_tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL))
+ if (ELEM(br->imagepaint_tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL)) {
return true;
+ }
}
else {
Object *ob = CTX_data_active_object(C);
@@ -1275,9 +1311,11 @@ void ED_imapaint_bucket_fill(struct bContext *C, float color[3], wmOperator *op)
static bool texture_paint_poll(bContext *C)
{
- if (texture_paint_toggle_poll(C))
- if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT)
+ if (texture_paint_toggle_poll(C)) {
+ if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) {
return 1;
+ }
+ }
return 0;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 5390f18304a..474d3a8ceba 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -158,14 +158,18 @@ static void brush_painter_2d_require_imbuf(BrushPainter *painter,
Brush *brush = painter->brush;
if ((painter->cache.use_float != use_float)) {
- if (painter->cache.ibuf)
+ if (painter->cache.ibuf) {
IMB_freeImBuf(painter->cache.ibuf);
- if (painter->cache.curve_mask)
+ }
+ if (painter->cache.curve_mask) {
MEM_freeN(painter->cache.curve_mask);
- if (painter->cache.tex_mask)
+ }
+ if (painter->cache.tex_mask) {
MEM_freeN(painter->cache.tex_mask);
- if (painter->cache.tex_mask_old)
+ }
+ if (painter->cache.tex_mask_old) {
MEM_freeN(painter->cache.tex_mask_old);
+ }
painter->cache.ibuf = NULL;
painter->cache.curve_mask = NULL;
painter->cache.tex_mask = NULL;
@@ -182,16 +186,21 @@ static void brush_painter_2d_require_imbuf(BrushPainter *painter,
static void brush_painter_2d_free(BrushPainter *painter)
{
- if (painter->cache.ibuf)
+ if (painter->cache.ibuf) {
IMB_freeImBuf(painter->cache.ibuf);
- if (painter->cache.texibuf)
+ }
+ if (painter->cache.texibuf) {
IMB_freeImBuf(painter->cache.texibuf);
- if (painter->cache.curve_mask)
+ }
+ if (painter->cache.curve_mask) {
MEM_freeN(painter->cache.curve_mask);
- if (painter->cache.tex_mask)
+ }
+ if (painter->cache.tex_mask) {
MEM_freeN(painter->cache.tex_mask);
- if (painter->cache.tex_mask_old)
+ }
+ if (painter->cache.tex_mask_old) {
MEM_freeN(painter->cache.tex_mask_old);
+ }
MEM_freeN(painter);
}
@@ -297,9 +306,10 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter,
int destx, desty, srcx, srcy, w, h, x1, y1, x2, y2;
/* create brush image buffer if it didn't exist yet */
- if (!cache->tex_mask)
+ if (!cache->tex_mask) {
cache->tex_mask = MEM_mallocN(sizeof(unsigned short) * diameter * diameter,
"brush_painter_mask");
+ }
/* create new texture image buffer with coordinates relative to old */
tex_mask_old = cache->tex_mask_old;
@@ -334,21 +344,27 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter,
y2 = min_ii(desty + h, diameter);
/* blend existing texture in new position */
- if ((x1 < x2) && (y1 < y2))
+ if ((x1 < x2) && (y1 < y2)) {
brush_painter_mask_imbuf_update(painter, tex_mask_old, x1, y1, x2, y2, srcx, srcy, diameter);
+ }
- if (tex_mask_old)
+ if (tex_mask_old) {
MEM_freeN(tex_mask_old);
+ }
/* sample texture in new areas */
- if ((0 < x1) && (0 < diameter))
+ if ((0 < x1) && (0 < diameter)) {
brush_painter_mask_imbuf_update(painter, NULL, 0, 0, x1, diameter, 0, 0, diameter);
- if ((x2 < diameter) && (0 < diameter))
+ }
+ if ((x2 < diameter) && (0 < diameter)) {
brush_painter_mask_imbuf_update(painter, NULL, x2, 0, diameter, diameter, 0, 0, diameter);
- if ((x1 < x2) && (0 < y1))
+ }
+ if ((x1 < x2) && (0 < y1)) {
brush_painter_mask_imbuf_update(painter, NULL, x1, 0, x2, y1, 0, 0, diameter);
- if ((x1 < x2) && (y2 < diameter))
+ }
+ if ((x1 < x2) && (y2 < diameter)) {
brush_painter_mask_imbuf_update(painter, NULL, x1, y2, x2, diameter, 0, 0, diameter);
+ }
/* through with sampling, now update sizes */
cache->tex_mask_old_w = diameter;
@@ -556,8 +572,9 @@ static void brush_painter_imbuf_update(
crgba[2] = ot[2];
crgba[3] = ot[3];
}
- else
+ else {
rgba_float_to_uchar(crgba, rgba);
+ }
/* write to new texture buffer */
t[0] = crgba[0];
@@ -588,8 +605,9 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter,
/* create brush image buffer if it didn't exist yet */
imbflag = (cache->use_float) ? IB_rectfloat : IB_rect;
- if (!cache->ibuf)
+ if (!cache->ibuf) {
cache->ibuf = IMB_allocImBuf(diameter, diameter, 32, imbflag);
+ }
ibuf = cache->ibuf;
/* create new texture image buffer with coordinates relative to old */
@@ -617,21 +635,27 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter,
y2 = min_ii(desty + h, ibuf->y);
/* blend existing texture in new position */
- if ((x1 < x2) && (y1 < y2))
+ if ((x1 < x2) && (y1 < y2)) {
brush_painter_imbuf_update(painter, oldtexibuf, x1, y1, x2, y2, srcx, srcy);
+ }
- if (oldtexibuf)
+ if (oldtexibuf) {
IMB_freeImBuf(oldtexibuf);
+ }
/* sample texture in new areas */
- if ((0 < x1) && (0 < ibuf->y))
+ if ((0 < x1) && (0 < ibuf->y)) {
brush_painter_imbuf_update(painter, NULL, 0, 0, x1, ibuf->y, 0, 0);
- if ((x2 < ibuf->x) && (0 < ibuf->y))
+ }
+ if ((x2 < ibuf->x) && (0 < ibuf->y)) {
brush_painter_imbuf_update(painter, NULL, x2, 0, ibuf->x, ibuf->y, 0, 0);
- if ((x1 < x2) && (0 < y1))
+ }
+ if ((x1 < x2) && (0 < y1)) {
brush_painter_imbuf_update(painter, NULL, x1, 0, x2, y1, 0, 0);
- if ((x1 < x2) && (y2 < ibuf->y))
+ }
+ if ((x1 < x2) && (y2 < ibuf->y)) {
brush_painter_imbuf_update(painter, NULL, x1, y2, x2, ibuf->y, 0, 0);
+ }
}
static void brush_painter_2d_tex_mapping(ImagePaintState *s,
@@ -716,10 +740,12 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s,
if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
tex_rotation += ups->brush_rotation;
}
- else if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)
+ else if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM) {
do_random = true;
- else if (!((brush->flag & BRUSH_ANCHORED) || update_color))
+ }
+ else if (!((brush->flag & BRUSH_ANCHORED) || update_color)) {
do_partial_update = true;
+ }
brush_painter_2d_tex_mapping(s,
diameter,
@@ -765,10 +791,12 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s,
brush->mask_mtex.brush_map_mode,
&painter->mask_mapping);
- if (do_partial_update_mask)
+ if (do_partial_update_mask) {
brush_painter_mask_imbuf_partial_update(painter, pos, diameter);
- else
+ }
+ else {
cache->tex_mask = brush_painter_mask_ibuf_new(painter, diameter);
+ }
cache->last_mask_rotation = mask_rotation;
}
}
@@ -835,11 +863,13 @@ static void paint_2d_ibuf_rgb_set(
{
if (is_torus) {
x %= ibuf->x;
- if (x < 0)
+ if (x < 0) {
x += ibuf->x;
+ }
y %= ibuf->y;
- if (y < 0)
+ if (y < 0) {
y += ibuf->y;
+ }
}
if (ibuf->rect_float) {
@@ -865,13 +895,15 @@ static void paint_2d_ibuf_tile_convert(ImBuf *ibuf, int *x, int *y, short tile)
{
if (tile & PAINT_TILE_X) {
*x %= ibuf->x;
- if (*x < 0)
+ if (*x < 0) {
*x += ibuf->x;
+ }
}
if (tile & PAINT_TILE_Y) {
*y %= ibuf->y;
- if (*y < 0)
+ if (*y < 0) {
*y += ibuf->y;
+ }
}
}
@@ -879,15 +911,17 @@ static float paint_2d_ibuf_add_if(ImBuf *ibuf, int x, int y, float *outrgb, shor
{
float inrgb[4];
- if (tile)
+ if (tile) {
paint_2d_ibuf_tile_convert(ibuf, &x, &y, tile);
+ }
/* need to also do clipping here always since tiled coordinates
* are not always within bounds */
if (x < ibuf->x && x >= 0 && y < ibuf->y && y >= 0) {
paint_2d_ibuf_rgb_get(ibuf, x, y, inrgb);
}
- else
+ else {
return 0;
+ }
mul_v4_fl(inrgb, w);
add_v4_v4(outrgb, inrgb);
@@ -917,8 +951,9 @@ static void paint_2d_lift_soften(
if (!tile) {
IMB_rectclip(ibuf, ibufb, &in_off[0], &in_off[1], &out_off[0], &out_off[1], &dim[0], &dim[1]);
- if ((dim[0] == 0) || (dim[1] == 0))
+ if ((dim[0] == 0) || (dim[1] == 0)) {
return;
+ }
}
/* find offset inside mask buffers to sample them */
@@ -933,10 +968,12 @@ static void paint_2d_lift_soften(
count = 0.0;
if (tile) {
paint_2d_ibuf_tile_convert(ibuf, &xi, &yi, tile);
- if (xi < ibuf->x && xi >= 0 && yi < ibuf->y && yi >= 0)
+ if (xi < ibuf->x && xi >= 0 && yi < ibuf->y && yi >= 0) {
paint_2d_ibuf_rgb_get(ibuf, xi, yi, rgba);
- else
+ }
+ else {
zero_v4(rgba);
+ }
}
else {
/* coordinates have been clipped properly here, it should be safe to do this */
@@ -962,8 +999,8 @@ static void paint_2d_lift_soften(
/* subtract blurred image from normal image gives high pass filter */
sub_v3_v3v3(outrgb, rgba, outrgb);
- /* now rgba_ub contains the edge result, but this should be converted to luminance to avoid
- * colored speckles appearing in final image, and also to check for threshold */
+ /* Now rgba_ub contains the edge result, but this should be converted to luminance to
+ * avoid colored speckles appearing in final image, and also to check for threshold. */
outrgb[0] = outrgb[1] = outrgb[2] = IMB_colormanagement_get_luminance(outrgb);
if (fabsf(outrgb[0]) > threshold) {
float mask = BKE_brush_alpha_get(s->scene, s->brush);
@@ -974,12 +1011,14 @@ static void paint_2d_lift_soften(
blend_color_add_float(outrgb, rgba, outrgb);
outrgb[3] = alpha;
}
- else
+ else {
copy_v4_v4(outrgb, rgba);
+ }
}
}
- else
+ else {
copy_v4_v4(outrgb, rgba);
+ }
/* write into brush buffer */
xo = out_off[0] + x;
yo = out_off[1] + y;
@@ -1015,19 +1054,23 @@ static int paint_2d_torus_split_region(ImagePaintRegion region[4],
/* convert destination and source coordinates to be within image */
if (tile & PAINT_TILE_X) {
destx = destx % dbuf->x;
- if (destx < 0)
+ if (destx < 0) {
destx += dbuf->x;
+ }
srcx = srcx % sbuf->x;
- if (srcx < 0)
+ if (srcx < 0) {
srcx += sbuf->x;
+ }
}
if (tile & PAINT_TILE_Y) {
desty = desty % dbuf->y;
- if (desty < 0)
+ if (desty < 0) {
desty += dbuf->y;
+ }
srcy = srcy % sbuf->y;
- if (srcy < 0)
+ if (srcy < 0) {
srcy += sbuf->y;
+ }
}
/* clip width of blending area to destination imbuf, to avoid writing the
* same pixel twice */
@@ -1039,13 +1082,15 @@ static int paint_2d_torus_split_region(ImagePaintRegion region[4],
paint_2d_set_region(&region[tot++], destx, desty, srcx, srcy, w, h);
/* do 3 other rects if needed */
- if ((tile & PAINT_TILE_X) && w < origw)
+ if ((tile & PAINT_TILE_X) && w < origw) {
paint_2d_set_region(
&region[tot++], (destx + w) % dbuf->x, desty, (srcx + w) % sbuf->x, srcy, origw - w, h);
- if ((tile & PAINT_TILE_Y) && h < origh)
+ }
+ if ((tile & PAINT_TILE_Y) && h < origh) {
paint_2d_set_region(
&region[tot++], destx, (desty + h) % dbuf->y, srcx, (srcy + h) % sbuf->y, w, origh - h);
- if ((tile & PAINT_TILE_X) && (tile & PAINT_TILE_Y) && (w < origw) && (h < origh))
+ }
+ if ((tile & PAINT_TILE_X) && (tile & PAINT_TILE_Y) && (w < origw) && (h < origh)) {
paint_2d_set_region(&region[tot++],
(destx + w) % dbuf->x,
(desty + h) % dbuf->y,
@@ -1053,6 +1098,7 @@ static int paint_2d_torus_split_region(ImagePaintRegion region[4],
(srcy + h) % sbuf->y,
origw - w,
origh - h);
+ }
return tot;
}
@@ -1065,7 +1111,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile)
paint_2d_set_region(region, 0, 0, pos[0], pos[1], ibufb->x, ibufb->y);
tot = paint_2d_torus_split_region(region, ibufb, ibuf, tile);
- for (a = 0; a < tot; a++)
+ for (a = 0; a < tot; a++) {
IMB_rectblend(ibufb,
ibufb,
ibuf,
@@ -1083,6 +1129,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile)
region[a].height,
IMB_BLEND_COPY,
false);
+ }
}
static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)
@@ -1161,11 +1208,13 @@ static void paint_2d_do_making_brush(ImagePaintState *s,
int origx = region->destx - tx * IMAPAINT_TILE_SIZE;
int origy = region->desty - ty * IMAPAINT_TILE_SIZE;
- if (s->canvas->rect_float)
+ if (s->canvas->rect_float) {
tmpbuf.rect_float = image_undo_find_tile(
undo_tiles, s->image, s->canvas, tx, ty, &mask, false);
- else
+ }
+ else {
tmpbuf.rect = image_undo_find_tile(undo_tiles, s->image, s->canvas, tx, ty, &mask, false);
+ }
IMB_rectblend(s->canvas,
&tmpbuf,
@@ -1244,8 +1293,9 @@ static int paint_2d_op(void *state,
blend = IMB_BLEND_INTERPOLATE;
}
else if (s->tool == PAINT_TOOL_SMEAR) {
- if (lastpos[0] == pos[0] && lastpos[1] == pos[1])
+ if (lastpos[0] == pos[0] && lastpos[1] == pos[1]) {
return 0;
+ }
paint_2d_convert_brushco(ibufb, lastpos, blastpos);
paint_2d_lift_smear(s->canvas, ibufb, blastpos, tile);
@@ -1337,8 +1387,9 @@ static int paint_2d_op(void *state,
}
}
- if (clonebuf)
+ if (clonebuf) {
IMB_freeImBuf(clonebuf);
+ }
return 1;
}
@@ -1359,8 +1410,9 @@ static int paint_2d_canvas_set(ImagePaintState *s, Image *ima)
s->warnmultifile = ima->id.name + 2;
return 0;
}
- else if (!ibuf || !(ibuf->rect || ibuf->rect_float))
+ else if (!ibuf || !(ibuf->rect || ibuf->rect_float)) {
return 0;
+ }
s->image = ima;
s->canvas = ibuf;
@@ -1382,8 +1434,9 @@ static int paint_2d_canvas_set(ImagePaintState *s, Image *ima)
if (s->canvas->rect_float && !s->clonecanvas->rect_float) {
IMB_float_from_rect(s->clonecanvas);
}
- else if (!s->canvas->rect_float && !s->clonecanvas->rect)
+ else if (!s->canvas->rect_float && !s->clonecanvas->rect) {
IMB_rect_from_float(s->clonecanvas);
+ }
}
/* set masking */
@@ -1419,12 +1472,14 @@ void paint_2d_stroke(void *ps,
ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, s->sima ? &s->sima->iuser : NULL, NULL);
const bool is_data = (ibuf && ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA);
- if (!ibuf)
+ if (!ibuf) {
return;
+ }
s->blend = s->brush->blend;
- if (eraser)
+ if (eraser) {
s->blend = IMB_BLEND_ERASE_ALPHA;
+ }
UI_view2d_region_to_view(s->v2d, mval[0], mval[1], &newuv[0], &newuv[1]);
UI_view2d_region_to_view(s->v2d, prev_mval[0], prev_mval[1], &olduv[0], &olduv[1]);
@@ -1463,8 +1518,9 @@ void paint_2d_stroke(void *ps,
painter->cache.curve_mask,
painter->cache.tex_mask,
olduv,
- newuv))
+ newuv)) {
s->need_redraw = true;
+ }
BKE_image_release_ibuf(s->image, ibuf, NULL);
}
@@ -1490,10 +1546,12 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
s->symmetry = settings->imapaint.paint.symmetry_flags;
if (!paint_2d_canvas_set(s, s->image)) {
- if (s->warnmultifile)
+ if (s->warnmultifile) {
BKE_report(op->reports, RPT_WARNING, "Image requires 4 color channels to paint");
- if (s->warnpackedfile)
+ }
+ if (s->warnpackedfile) {
BKE_report(op->reports, RPT_WARNING, "Packed MultiLayer files cannot be painted");
+ }
MEM_freeN(s);
return NULL;
@@ -1530,18 +1588,21 @@ void paint_2d_redraw(const bContext *C, void *ps, bool final)
}
if (final) {
- if (s->image && !(s->sima && s->sima->lock))
+ if (s->image && !(s->sima && s->sima->lock)) {
GPU_free_image(s->image);
+ }
/* compositor listener deals with updating */
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, s->image);
DEG_id_tag_update(&s->image->id, 0);
}
else {
- if (!s->sima || !s->sima->lock)
+ if (!s->sima || !s->sima->lock) {
ED_region_tag_redraw(CTX_wm_region(C));
- else
+ }
+ else {
WM_event_add_notifier(C, NC_IMAGE | NA_PAINTING, s->image);
+ }
}
}
@@ -1566,8 +1627,9 @@ static void paint_2d_fill_add_pixel_byte(const int x_px,
{
size_t coordinate;
- if (x_px >= ibuf->x || x_px < 0 || y_px >= ibuf->y || y_px < 0)
+ if (x_px >= ibuf->x || x_px < 0 || y_px >= ibuf->y || y_px < 0) {
return;
+ }
coordinate = ((size_t)y_px) * ibuf->x + x_px;
@@ -1594,8 +1656,9 @@ static void paint_2d_fill_add_pixel_float(const int x_px,
{
size_t coordinate;
- if (x_px >= ibuf->x || x_px < 0 || y_px >= ibuf->y || y_px < 0)
+ if (x_px >= ibuf->x || x_px < 0 || y_px >= ibuf->y || y_px < 0) {
return;
+ }
coordinate = ((size_t)y_px) * ibuf->x + x_px;
@@ -1624,13 +1687,15 @@ void paint_2d_bucket_fill(
bool do_float;
- if (!ima)
+ if (!ima) {
return;
+ }
ibuf = BKE_image_acquire_ibuf(ima, &sima->iuser, NULL);
- if (!ibuf)
+ if (!ibuf) {
return;
+ }
do_float = (ibuf->rect_float != NULL);
/* first check if our image is float. If it is not we should correct the color to
@@ -1742,14 +1807,18 @@ void paint_2d_bucket_fill(
paint_2d_fill_add_pixel_float(
x_px + 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
- if (x_px > maxx)
+ if (x_px > maxx) {
maxx = x_px;
- if (x_px < minx)
+ }
+ if (x_px < minx) {
minx = x_px;
- if (y_px > maxy)
+ }
+ if (y_px > maxy) {
maxy = y_px;
- if (x_px > miny)
+ }
+ if (x_px > miny) {
miny = y_px;
+ }
}
}
else {
@@ -1782,14 +1851,18 @@ void paint_2d_bucket_fill(
paint_2d_fill_add_pixel_byte(
x_px + 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
- if (x_px > maxx)
+ if (x_px > maxx) {
maxx = x_px;
- if (x_px < minx)
+ }
+ if (x_px < minx) {
minx = x_px;
- if (y_px > maxy)
+ }
+ if (y_px > maxy) {
maxy = y_px;
- if (x_px > miny)
+ }
+ if (x_px > miny) {
miny = y_px;
+ }
}
}
@@ -1822,13 +1895,15 @@ void paint_2d_gradient_fill(
bool do_float;
- if (!ima)
+ if (!ima) {
return;
+ }
ibuf = BKE_image_acquire_ibuf(ima, &sima->iuser, NULL);
- if (!ibuf)
+ if (!ibuf) {
return;
+ }
UI_view2d_region_to_view(
s->v2d, mouse_final[0], mouse_final[1], &image_final[0], &image_final[1]);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 7a99f819913..0737218eea4 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -395,7 +395,7 @@ typedef struct ProjPaintState {
* helps as an extra validation step for seam detection. */
char *faceWindingFlags;
/** expanded UVs for faces to use as seams. */
- LoopSeamData(*loopSeamData);
+ LoopSeamData *loopSeamData;
/** Only needed for when seam_bleed_px is enabled, use to find UV seams. */
LinkNode **vertFaces;
/** Seams per vert, to find adjacent seams. */
@@ -627,8 +627,9 @@ static float VecZDepthPersp(
w_tmp[1] = w_tmp[1] * wtot_inv;
w_tmp[2] = w_tmp[2] * wtot_inv;
}
- else /* dummy values for zero area face */
+ else { /* dummy values for zero area face */
w_tmp[0] = w_tmp[1] = w_tmp[2] = 1.0f / 3.0f;
+ }
/* done mimicking barycentric_weights_v2() */
return (v1[2] * w_tmp[0]) + (v2[2] * w_tmp[1]) + (v3[2] * w_tmp[2]);
@@ -644,8 +645,9 @@ static int project_paint_PickFace(const ProjPaintState *ps, const float pt[2], f
float z_depth_best = FLT_MAX, z_depth;
bucket_index = project_bucket_offset_safe(ps, pt);
- if (bucket_index == -1)
+ if (bucket_index == -1) {
return -1;
+ }
/* we could return 0 for 1 face buckets, as long as this function assumes
* that the point its testing is only every originated from an existing face */
@@ -686,10 +688,12 @@ static void uvco_to_wrapped_pxco(const float uv[2], int ibuf_x, int ibuf_y, floa
*x = fmodf(uv[0], 1.0f);
*y = fmodf(uv[1], 1.0f);
- if (*x < 0.0f)
+ if (*x < 0.0f) {
*x += 1.0f;
- if (*y < 0.0f)
+ }
+ if (*y < 0.0f) {
*y += 1.0f;
+ }
*x = *x * ibuf_x - 0.5f;
*y = *y * ibuf_y - 0.5f;
@@ -713,8 +717,9 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
tri_index = project_paint_PickFace(ps, pt, w);
- if (tri_index == -1)
+ if (tri_index == -1) {
return 0;
+ }
lt = &ps->mlooptri_eval[tri_index];
PS_LOOPTRI_ASSIGN_UV_3(lt_tri_uv, ps->poly_to_loop_uv, lt);
@@ -724,8 +729,9 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
ima = project_paint_face_paint_image(ps, tri_index);
/** we must have got the imbuf before getting here. */
ibuf = BKE_image_get_first_ibuf(ima);
- if (!ibuf)
+ if (!ibuf) {
return 0;
+ }
if (interp) {
float x, y;
@@ -753,9 +759,9 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
}
}
else {
- //xi = (int)((uv[0]*ibuf->x) + 0.5f);
- //yi = (int)((uv[1]*ibuf->y) + 0.5f);
- //if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0;
+ // xi = (int)((uv[0]*ibuf->x) + 0.5f);
+ // yi = (int)((uv[1]*ibuf->y) + 0.5f);
+ // if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0;
/* wrap */
xi = mod_i((int)(uv[0] * ibuf->x), ibuf->x);
@@ -802,12 +808,14 @@ static int project_paint_occlude_ptv(const float pt[3],
const bool is_ortho)
{
/* if all are behind us, return false */
- if (v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2])
+ if (v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2]) {
return 0;
+ }
/* do a 2D point in try intersection */
- if (!isect_point_tri_v2(pt, v1, v2, v3))
+ if (!isect_point_tri_v2(pt, v1, v2, v3)) {
return 0;
+ }
/* From here on we know there IS an intersection */
/* if ALL of the verts are infront of us then we know it intersects ? */
@@ -818,12 +826,14 @@ static int project_paint_occlude_ptv(const float pt[3],
/* we intersect? - find the exact depth at the point of intersection */
/* Is this point is occluded by another face? */
if (is_ortho) {
- if (VecZDepthOrtho(pt, v1, v2, v3, w) < pt[2])
+ if (VecZDepthOrtho(pt, v1, v2, v3, w) < pt[2]) {
return 2;
+ }
}
else {
- if (VecZDepthPersp(pt, v1, v2, v3, w) < pt[2])
+ if (VecZDepthPersp(pt, v1, v2, v3, w) < pt[2]) {
return 2;
+ }
}
}
return -1;
@@ -843,8 +853,9 @@ static int project_paint_occlude_ptv_clip(const float pt[3],
float wco[3];
int ret = project_paint_occlude_ptv(pt, v1, v2, v3, w, is_ortho);
- if (ret <= 0)
+ if (ret <= 0) {
return ret;
+ }
if (ret == 1) { /* weights not calculated */
if (is_ortho) {
@@ -1009,15 +1020,19 @@ static bool cmp_uv(const float vec2a[2], const float vec2b[2])
float xb = fmodf(vec2b[0], 1.0f);
float yb = fmodf(vec2b[1], 1.0f);
- if (xa < 0.0f)
+ if (xa < 0.0f) {
xa += 1.0f;
- if (ya < 0.0f)
+ }
+ if (ya < 0.0f) {
ya += 1.0f;
+ }
- if (xb < 0.0f)
+ if (xb < 0.0f) {
xb += 1.0f;
- if (yb < 0.0f)
+ }
+ if (yb < 0.0f) {
yb += 1.0f;
+ }
return ((fabsf(xa - xb) < PROJ_GEOM_TOLERANCE) && (fabsf(ya - yb) < PROJ_GEOM_TOLERANCE)) ? 1 :
0;
@@ -1093,8 +1108,9 @@ static void project_face_winding_init(const ProjPaintState *ps, const int tri_in
const float *lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt)};
float winding = cross_tri_v2(lt_tri_uv[0], lt_tri_uv[1], lt_tri_uv[2]);
- if (winding > 0)
+ if (winding > 0) {
ps->faceWindingFlags[tri_index] |= PROJ_FACE_WINDING_CW;
+ }
ps->faceWindingFlags[tri_index] |= PROJ_FACE_WINDING_INIT;
}
@@ -1131,7 +1147,8 @@ static bool check_seam(const ProjPaintState *ps,
i1_fidx = BKE_MESH_TESSTRI_VINDEX_ORDER(lt_vtri, i1);
i2_fidx = BKE_MESH_TESSTRI_VINDEX_ORDER(lt_vtri, i2);
- /* Only need to check if 'i2_fidx' is valid because we know i1_fidx is the same vert on both faces */
+ /* Only need to check if 'i2_fidx' is valid because
+ * we know i1_fidx is the same vert on both faces. */
if (i2_fidx != -1) {
const float *lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt)};
Image *tpage = project_paint_face_paint_image(ps, tri_index);
@@ -1148,8 +1165,9 @@ static bool check_seam(const ProjPaintState *ps,
*orig_fidx = (i1_fidx < i2_fidx && (i2_fidx - i1_fidx == 1)) ? i1_fidx : i2_fidx;
/* initialize face winding if needed */
- if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_INIT) == 0)
+ if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_INIT) == 0) {
project_face_winding_init(ps, tri_index);
+ }
/* first test if they have the same image */
if ((orig_tpage == tpage) && cmp_uv(orig_lt_tri_uv[orig_i1_fidx], lt_tri_uv[i1_fidx]) &&
@@ -1392,11 +1410,11 @@ static void insert_seam_vert_array(const ProjPaintState *ps,
}
}
-/*
- * Be tricky with flags, first 4 bits are PROJ_FACE_SEAM0 to 4, last 4 bits are PROJ_FACE_NOSEAM0 to 4
- * 1<<i - where i is (0-3)
+/**
+ * Be tricky with flags, first 4 bits are #PROJ_FACE_SEAM0 to 4,
+ * last 4 bits are #PROJ_FACE_NOSEAM0 to 4. `1 << i` - where i is `(0..3)`.
*
- * If we're multithreadng, make sure threads are locked when this is called
+ * If we're multithreadng, make sure threads are locked when this is called.
*/
static void project_face_seams_init(const ProjPaintState *ps,
MemArena *arena,
@@ -1414,8 +1432,9 @@ static void project_face_seams_init(const ProjPaintState *ps,
LinkNode *node;
/* initialize face winding if needed */
- if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_INIT) == 0)
+ if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_INIT) == 0) {
project_face_winding_init(ps, tri_index);
+ }
do {
if (init_all || (ps->mloop_eval[lt->tri[fidx[0]]].v == vert_index) ||
@@ -1427,7 +1446,8 @@ static void project_face_seams_init(const ProjPaintState *ps,
insert_seam_vert_array(ps, arena, tri_index, fidx[0], ibuf_x, ibuf_y);
if (other_face != -1) {
- /* Check if the other seam is already set. We don't want to insert it in the list twice. */
+ /* Check if the other seam is already set.
+ * We don't want to insert it in the list twice. */
if ((ps->faceSeamFlags[other_face] & (PROJ_FACE_SEAM0 << other_fidx)) == 0) {
ps->faceSeamFlags[other_face] |= PROJ_FACE_SEAM0 << other_fidx;
insert_seam_vert_array(ps, arena, other_face, other_fidx, ibuf_x, ibuf_y);
@@ -1752,8 +1772,8 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
} /* otherwise no mask normal is needed, were within the limit */
}
- /* This only works when the opacity doesn't change while painting, stylus pressure messes with this
- * so don't use it. */
+ /* This only works when the opacity doesn't change while painting, stylus pressure messes with
+ * this so don't use it. */
// if (ps->is_airbrush == 0) mask *= BKE_brush_alpha_get(ps->brush);
return mask;
@@ -1777,14 +1797,16 @@ static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
/* double check lock to avoid locking */
if (UNLIKELY(!pjIma->undoRect[tile_index])) {
- if (tinf->lock)
+ if (tinf->lock) {
BLI_spin_lock(tinf->lock);
+ }
if (LIKELY(!pjIma->undoRect[tile_index])) {
pjIma->undoRect[tile_index] = TILE_PENDING;
generate_tile = true;
}
- if (tinf->lock)
+ if (tinf->lock) {
BLI_spin_unlock(tinf->lock);
+ }
}
if (generate_tile) {
@@ -1817,11 +1839,13 @@ static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
pjIma->ibuf->userflags |= IB_BITMAPDIRTY;
/* tile ready, publish */
- if (tinf->lock)
+ if (tinf->lock) {
BLI_spin_lock(tinf->lock);
+ }
pjIma->undoRect[tile_index] = undorect;
- if (tinf->lock)
+ if (tinf->lock) {
BLI_spin_unlock(tinf->lock);
+ }
}
return tile_index;
@@ -1864,14 +1888,15 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
x_round = x_tile * IMAPAINT_TILE_SIZE;
y_round = y_tile * IMAPAINT_TILE_SIZE;
- //memset(projPixel, 0, size);
+ // memset(projPixel, 0, size);
tile_offset = (x_px - x_round) + (y_px - y_round) * IMAPAINT_TILE_SIZE;
tile_index = project_paint_undo_subtiles(tinf, x_tile, y_tile);
/* other thread may be initializing the tile so wait here */
- while (projima->undoRect[tile_index] == TILE_PENDING)
+ while (projima->undoRect[tile_index] == TILE_PENDING) {
;
+ }
BLI_assert(tile_index < (IMAPAINT_TILE_NUMBER(ibuf->x) * IMAPAINT_TILE_NUMBER(ibuf->y)));
BLI_assert(tile_offset < (IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE));
@@ -1900,10 +1925,12 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
projPixel->y_px = y_px;
projPixel->mask = (unsigned short)(mask * 65535);
- if (ps->do_masking)
+ if (ps->do_masking) {
projPixel->mask_accum = projima->maskRect[tile_index] + tile_offset;
- else
+ }
+ else {
projPixel->mask_accum = NULL;
+ }
/* which bounding box cell are we in?, needed for undo */
projPixel->bb_cell_index = ((int)(((float)x_px / (float)ibuf->x) * PROJ_BOUNDBOX_DIV)) +
@@ -1993,10 +2020,12 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
}
#ifdef PROJ_DEBUG_PAINT
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
projPixel->pixel.f_pt[0] = 0;
- else
+ }
+ else {
projPixel->pixel.ch_pt[0] = 0;
+ }
#endif
/* pointer arithmetic */
projPixel->image_index = projima - ps->projImages;
@@ -2089,8 +2118,9 @@ static bool line_clip_rect2f(const rctf *cliprect,
}
/* line inside rect */
- if (ok1 && ok2)
+ if (ok1 && ok2) {
return 1;
+ }
/* top/bottom */
if (line_isect_y(l1, l2, rect->ymin, &isect) && (isect >= cliprect->xmin) &&
@@ -2107,8 +2137,9 @@ static bool line_clip_rect2f(const rctf *cliprect,
}
}
- if (ok1 && ok2)
+ if (ok1 && ok2) {
return 1;
+ }
if (line_isect_y(l1, l2, rect->ymax, &isect) && (isect >= cliprect->xmin) &&
(isect <= cliprect->xmax)) {
@@ -2124,8 +2155,9 @@ static bool line_clip_rect2f(const rctf *cliprect,
}
}
- if (ok1 && ok2)
+ if (ok1 && ok2) {
return 1;
+ }
/* left/right */
if (line_isect_x(l1, l2, rect->xmin, &isect) && (isect >= cliprect->ymin) &&
@@ -2142,8 +2174,9 @@ static bool line_clip_rect2f(const rctf *cliprect,
}
}
- if (ok1 && ok2)
+ if (ok1 && ok2) {
return 1;
+ }
if (line_isect_x(l1, l2, rect->xmax, &isect) && (isect >= cliprect->ymin) &&
(isect <= cliprect->ymax)) {
@@ -2170,8 +2203,8 @@ static bool line_clip_rect2f(const rctf *cliprect,
/**
* Scale the tri about its center
- * scaling by #PROJ_FACE_SCALE_SEAM (0.99x) is used for getting fake UV pixel coords that are on the
- * edge of the face but slightly inside it occlusion tests don't return hits on adjacent faces
+ * scaling by #PROJ_FACE_SCALE_SEAM (0.99x) is used for getting fake UV pixel coords that are on
+ * the edge of the face but slightly inside it occlusion tests don't return hits on adjacent faces.
*/
#ifndef PROJ_DEBUG_NOSEAMBLEED
@@ -2194,7 +2227,7 @@ static void scale_tri(float insetCos[3][3], const float *origCos[4], const float
add_v3_v3(insetCos[1], cent);
add_v3_v3(insetCos[2], cent);
}
-#endif //PROJ_DEBUG_NOSEAMBLEED
+#endif // PROJ_DEBUG_NOSEAMBLEED
static float len_squared_v2v2_alt(const float v1[2], const float v2_1, const float v2_2)
{
@@ -2205,17 +2238,21 @@ static float len_squared_v2v2_alt(const float v1[2], const float v2_1, const flo
return x * x + y * y;
}
-/* note, use a squared value so we can use len_squared_v2v2
- * be sure that you have done a bounds check first or this may fail */
-/* only give bucket_bounds as an arg because we need it elsewhere */
+/**
+ * \note Use a squared value so we can use #len_squared_v2v2
+ * be sure that you have done a bounds check first or this may fail.
+ *
+ * Only give \a bucket_bounds as an arg because we need it elsewhere.
+ */
static bool project_bucket_isect_circle(const float cent[2],
const float radius_squared,
const rctf *bucket_bounds)
{
- /* Would normally to a simple intersection test, however we know the bounds of these 2 already intersect
- * so we only need to test if the center is inside the vertical or horizontal bounds on either axis,
- * this is even less work then an intersection test
+ /* Would normally to a simple intersection test,
+ * however we know the bounds of these 2 already intersect so we only need to test
+ * if the center is inside the vertical or horizontal bounds on either axis,
+ * this is even less work then an intersection test.
*/
#if 0
if (BLI_rctf_isect_pt_v(bucket_bounds, cent))
@@ -2266,8 +2303,8 @@ static bool project_bucket_isect_circle(const float cent[2],
/* Note for rect_to_uvspace_ortho() and rect_to_uvspace_persp()
* in ortho view this function gives good results when bucket_bounds are outside the triangle
- * however in some cases, perspective view will mess up with faces that have minimal screenspace area
- * (viewed from the side)
+ * however in some cases, perspective view will mess up with faces
+ * that have minimal screenspace area (viewed from the side).
*
* for this reason its not reliable in this case so we'll use the Simple Barycentric'
* funcs that only account for points inside the triangle.
@@ -2292,17 +2329,17 @@ static void rect_to_uvspace_ortho(const rctf *bucket_bounds,
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 3 : 0], uv1co, uv2co, uv3co, w);
- //uv[0] = bucket_bounds->xmax; // set above
+ // uv[0] = bucket_bounds->xmax; // set above
uv[1] = bucket_bounds->ymax;
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 2 : 1], uv1co, uv2co, uv3co, w);
uv[0] = bucket_bounds->xmin;
- //uv[1] = bucket_bounds->ymax; // set above
+ // uv[1] = bucket_bounds->ymax; // set above
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 1 : 2], uv1co, uv2co, uv3co, w);
- //uv[0] = bucket_bounds->xmin; // set above
+ // uv[0] = bucket_bounds->xmin; // set above
uv[1] = bucket_bounds->ymin;
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 0 : 3], uv1co, uv2co, uv3co, w);
@@ -2328,17 +2365,17 @@ static void rect_to_uvspace_persp(const rctf *bucket_bounds,
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 3 : 0], uv1co, uv2co, uv3co, w);
- //uv[0] = bucket_bounds->xmax; // set above
+ // uv[0] = bucket_bounds->xmax; // set above
uv[1] = bucket_bounds->ymax;
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 2 : 1], uv1co, uv2co, uv3co, w);
uv[0] = bucket_bounds->xmin;
- //uv[1] = bucket_bounds->ymax; // set above
+ // uv[1] = bucket_bounds->ymax; // set above
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 1 : 2], uv1co, uv2co, uv3co, w);
- //uv[0] = bucket_bounds->xmin; // set above
+ // uv[0] = bucket_bounds->xmin; // set above
uv[1] = bucket_bounds->ymin;
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
interp_v2_v2v2v2(bucket_bounds_uv[flip ? 0 : 3], uv1co, uv2co, uv3co, w);
@@ -2351,8 +2388,10 @@ static float angle_2d_clockwise(const float p1[2], const float p2[2], const floa
{
float v1[2], v2[2];
- v1[0] = p1[0] - p2[0]; v1[1] = p1[1] - p2[1];
- v2[0] = p3[0] - p2[0]; v2[1] = p3[1] - p2[1];
+ v1[0] = p1[0] - p2[0];
+ v1[1] = p1[1] - p2[1];
+ v2[0] = p3[0] - p2[0];
+ v2[1] = p3[1] - p2[1];
return -atan2f(v1[0] * v2[1] - v1[1] * v2[0], v1[0] * v2[0] + v1[1] * v2[1]);
}
@@ -2422,8 +2461,9 @@ static bool line_rect_clip(const rctf *rect,
}
}
- if (min == FLT_MAX)
+ if (min == FLT_MAX) {
return false;
+ }
tmp = (is_ortho) ? 1.0f : (l1[3] + min * (l2[3] - l1[3]));
@@ -2496,8 +2536,9 @@ static void project_bucket_clip_face(const bool is_ortho,
(*tot) = 0;
- if (cull)
+ if (cull) {
return;
+ }
if (inside_bucket_flag & ISECT_1) {
copy_v2_v2(bucket_bounds_uv[*tot], uv1co);
@@ -2507,8 +2548,9 @@ static void project_bucket_clip_face(const bool is_ortho,
flag = inside_bucket_flag & (ISECT_1 | ISECT_2);
if (flag && flag != (ISECT_1 | ISECT_2)) {
if (line_rect_clip(
- bucket_bounds, v1coSS, v2coSS, uv1co, uv2co, bucket_bounds_uv[*tot], is_ortho))
+ bucket_bounds, v1coSS, v2coSS, uv1co, uv2co, bucket_bounds_uv[*tot], is_ortho)) {
(*tot)++;
+ }
}
if (inside_bucket_flag & ISECT_2) {
@@ -2519,8 +2561,9 @@ static void project_bucket_clip_face(const bool is_ortho,
flag = inside_bucket_flag & (ISECT_2 | ISECT_3);
if (flag && flag != (ISECT_2 | ISECT_3)) {
if (line_rect_clip(
- bucket_bounds, v2coSS, v3coSS, uv2co, uv3co, bucket_bounds_uv[*tot], is_ortho))
+ bucket_bounds, v2coSS, v3coSS, uv2co, uv3co, bucket_bounds_uv[*tot], is_ortho)) {
(*tot)++;
+ }
}
if (inside_bucket_flag & ISECT_3) {
@@ -2531,8 +2574,9 @@ static void project_bucket_clip_face(const bool is_ortho,
flag = inside_bucket_flag & (ISECT_3 | ISECT_1);
if (flag && flag != (ISECT_3 | ISECT_1)) {
if (line_rect_clip(
- bucket_bounds, v3coSS, v1coSS, uv3co, uv1co, bucket_bounds_uv[*tot], is_ortho))
+ bucket_bounds, v3coSS, v1coSS, uv3co, uv1co, bucket_bounds_uv[*tot], is_ortho)) {
(*tot)++;
+ }
}
if ((*tot) < 3) {
@@ -2735,10 +2779,12 @@ static void project_bucket_clip_face(const bool is_ortho,
v1_clipSS[0] * v2_clipSS[0] + v1_clipSS[1] * v2_clipSS[1]);
}
- if (flip)
+ if (flip) {
qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort_flip);
- else
+ }
+ else {
qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort);
+ }
doubles = true;
while (doubles == true) {
@@ -2787,12 +2833,14 @@ static void project_bucket_clip_face(const bool is_ortho,
/* If there are ever any problems, */
float test_uv[4][2];
int i;
- if (is_ortho)
+ if (is_ortho) {
rect_to_uvspace_ortho(
bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
- else
+ }
+ else {
rect_to_uvspace_persp(
bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
+ }
printf("( [(%f,%f), (%f,%f), (%f,%f), (%f,%f)], ",
test_uv[0][0],
test_uv[0][1],
@@ -2878,12 +2926,14 @@ static void project_bucket_clip_face(const bool is_ortho,
static bool IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
{
int i;
- if (line_point_side_v2(uv[tot - 1], uv[0], pt) < 0.0f)
+ if (line_point_side_v2(uv[tot - 1], uv[0], pt) < 0.0f) {
return 0;
+ }
for (i = 1; i < tot; i++) {
- if (line_point_side_v2(uv[i - 1], uv[i], pt) < 0.0f)
+ if (line_point_side_v2(uv[i - 1], uv[i], pt) < 0.0f) {
return 0;
+ }
}
return 1;
@@ -2894,8 +2944,9 @@ static bool IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot
bool side = (line_point_side_v2(uv[tot - 1], uv[0], pt) > 0.0f);
for (i = 1; i < tot; i++) {
- if ((line_point_side_v2(uv[i - 1], uv[i], pt) > 0.0f) != side)
+ if ((line_point_side_v2(uv[i - 1], uv[i], pt) > 0.0f) != side) {
return 0;
+ }
}
return 1;
@@ -3025,7 +3076,8 @@ static void project_paint_face_init(const ProjPaintState *ps,
&uv_clip_tot,
do_backfacecull || ps->do_occlude);
- /* sometimes this happens, better just allow for 8 intersectiosn even though there should be max 6 */
+ /* Sometimes this happens, better just allow for 8 intersections
+ * even though there should be max 6 */
#if 0
if (uv_clip_tot > 6) {
printf("this should never happen! %d\n", uv_clip_tot);
@@ -3035,20 +3087,19 @@ static void project_paint_face_init(const ProjPaintState *ps,
if (pixel_bounds_array(uv_clip, &bounds_px, ibuf->x, ibuf->y, uv_clip_tot)) {
#if 0
project_paint_undo_tiles_init(
- &bounds_px, ps->projImages + image_index, tmpibuf,
- tile_width, threaded, ps->do_masking);
+ &bounds_px, ps->projImages + image_index, tmpibuf, tile_width, threaded, ps->do_masking);
#endif
/* clip face and */
has_isect = 0;
for (y = bounds_px.ymin; y < bounds_px.ymax; y++) {
- //uv[1] = (((float)y) + 0.5f) / (float)ibuf->y;
+ // uv[1] = (((float)y) + 0.5f) / (float)ibuf->y;
/* use pixel offset UV coords instead */
uv[1] = (float)y / ibuf_yf;
has_x_isect = 0;
for (x = bounds_px.xmin; x < bounds_px.xmax; x++) {
- //uv[0] = (((float)x) + 0.5f) / ibuf->x;
+ // uv[0] = (((float)x) + 0.5f) / ibuf->x;
/* use pixel offset UV coords instead */
uv[0] = (float)x / ibuf_xf;
@@ -3059,12 +3110,14 @@ static void project_paint_face_init(const ProjPaintState *ps,
has_x_isect = has_isect = 1;
- if (is_ortho)
+ if (is_ortho) {
screen_px_from_ortho(
uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
- else
+ }
+ else {
screen_px_from_persp(
uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
+ }
/* a pity we need to get the worldspace pixel location here */
if (do_clip || do_3d_mapping) {
@@ -3081,7 +3134,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
/* Is this UV visible from the view? - raytrace */
/* project_paint_PickFace is less complex, use for testing */
- //if (project_paint_PickFace(ps, pixelScreenCo, w, &side) == tri_index) {
+ // if (project_paint_PickFace(ps, pixelScreenCo, w, &side) == tri_index) {
if ((ps->do_occlude == false) ||
!project_bucket_point_occluded(ps, bucketFaceNodes, tri_index, pixelScreenCo)) {
mask = project_paint_uvpixel_mask(ps, tri_index, w);
@@ -3131,7 +3184,12 @@ static void project_paint_face_init(const ProjPaintState *ps,
(face_seam_flag & PROJ_FACE_SEAM_INIT2) == 0) {
project_face_seams_init(ps, arena, tri_index, 0, true, ibuf->x, ibuf->y);
face_seam_flag = ps->faceSeamFlags[tri_index];
- //printf("seams - %d %d %d %d\n", flag&PROJ_FACE_SEAM0, flag&PROJ_FACE_SEAM1, flag&PROJ_FACE_SEAM2);
+# if 0
+ printf("seams - %d %d %d %d\n",
+ flag & PROJ_FACE_SEAM0,
+ flag & PROJ_FACE_SEAM1,
+ flag & PROJ_FACE_SEAM2);
+# endif
}
if ((face_seam_flag & (PROJ_FACE_SEAM0 | PROJ_FACE_SEAM1 | PROJ_FACE_SEAM2)) == 0) {
@@ -3249,7 +3307,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
for (x = bounds_px.xmin; x < bounds_px.xmax; x++) {
float puv[2] = {(float)x, (float)y};
bool in_bounds;
- //uv[0] = (((float)x) + 0.5f) / (float)ibuf->x;
+ // uv[0] = (((float)x) + 0.5f) / (float)ibuf->x;
/* use offset uvs instead */
uv[0] = (float)x / ibuf_xf;
@@ -3475,8 +3533,9 @@ static void project_bucket_init(const ProjPaintState *ps,
}
}
- if (tmpibuf)
+ if (tmpibuf) {
IMB_freeImBuf(tmpibuf);
+ }
ps->bucketFlags[bucket_index] |= PROJ_BUCKET_INIT;
}
@@ -3821,8 +3880,9 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps)
/* augment the diffe*/
cavities[a] = saacos(10.0f * dot_v3v3(no, edges[a])) * (float)M_1_PI;
}
- else
+ else {
cavities[a] = 0.0;
+ }
}
MEM_freeN(counter);
@@ -3858,8 +3918,9 @@ static void proj_paint_state_thread_init(ProjPaintState *ps, const bool reset_th
/* workaround for #35057, disable threading if diameter is less than is possible for
* optimum bucket number generation */
- if (reset_threads)
+ if (reset_threads) {
ps->thread_tot = 1;
+ }
if (ps->is_shared_user == false) {
if (ps->thread_tot > 1) {
@@ -4035,8 +4096,9 @@ static void proj_paint_layer_clone_init(ProjPaintState *ps, ProjPaintLayerClone
ps->poly_to_loop_uv_clone = MEM_mallocN(ps->totpoly_eval * sizeof(MLoopUV *),
"proj_paint_mtfaces");
- if (layer_num != -1)
+ if (layer_num != -1) {
mloopuv_clone_base = CustomData_get_layer_n(&ps->me_eval->ldata, CD_MLOOPUV, layer_num);
+ }
if (mloopuv_clone_base == NULL) {
/* get active instead */
@@ -4058,11 +4120,13 @@ static bool project_paint_clone_face_skip(ProjPaintState *ps,
if (ps->do_material_slots) {
lc->slot_clone = project_paint_face_clone_slot(ps, tri_index);
/* all faces should have a valid slot, reassert here */
- if (ELEM(lc->slot_clone, NULL, slot))
+ if (ELEM(lc->slot_clone, NULL, slot)) {
return true;
+ }
}
- else if (ps->clone_ima == ps->canvas_ima)
+ else if (ps->clone_ima == ps->canvas_ima) {
return true;
+ }
if (ps->do_material_slots) {
if (lc->slot_clone != lc->slot_last_clone) {
@@ -4164,7 +4228,7 @@ static bool project_paint_winclip(const ProjPaintState *ps, const ProjPaintFaceC
(coSS->v1[1] > ps->screenMax[1] && coSS->v2[1] > ps->screenMax[1] &&
coSS->v3[1] > ps->screenMax[1])));
}
-#endif //PROJ_DEBUG_WINCLIP
+#endif // PROJ_DEBUG_WINCLIP
static void project_paint_build_proj_ima(ProjPaintState *ps,
MemArena *arena,
@@ -4229,8 +4293,9 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
else {
if (slot != slot_last) {
if (!slot->uvname || !(mloopuv_base = CustomData_get_layer_named(
- &ps->me_eval->ldata, CD_MLOOPUV, slot->uvname)))
+ &ps->me_eval->ldata, CD_MLOOPUV, slot->uvname))) {
mloopuv_base = CustomData_get_layer(&ps->me_eval->ldata, CD_MLOOPUV);
+ }
slot_last = slot;
}
@@ -4241,6 +4306,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
* It's less trouble to set all faces to valid UV's,
* avoiding NULL checks all over. */
skip_tri = true;
+ tpage = NULL;
}
else {
tpage = slot->ima;
@@ -4278,7 +4344,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
continue;
}
-#endif //PROJ_DEBUG_WINCLIP
+#endif // PROJ_DEBUG_WINCLIP
/* backface culls individual triangles but mask normal will use polygon */
if (ps->do_backfacecull) {
@@ -4383,19 +4449,21 @@ static void project_paint_begin(const bContext *C,
proj_paint_layer_clone_init(ps, &layer_clone);
if (ps->do_layer_stencil || ps->do_stencil_brush) {
- //int layer_num = CustomData_get_stencil_layer(&ps->me_eval->ldata, CD_MLOOPUV);
+ // int layer_num = CustomData_get_stencil_layer(&ps->me_eval->ldata, CD_MLOOPUV);
int layer_num = CustomData_get_stencil_layer(&((Mesh *)ps->ob->data)->ldata, CD_MLOOPUV);
- if (layer_num != -1)
+ if (layer_num != -1) {
ps->mloopuv_stencil_eval = CustomData_get_layer_n(
&ps->me_eval->ldata, CD_MLOOPUV, layer_num);
+ }
if (ps->mloopuv_stencil_eval == NULL) {
/* get active instead */
ps->mloopuv_stencil_eval = CustomData_get_layer(&ps->me_eval->ldata, CD_MLOOPUV);
}
- if (ps->do_stencil_brush)
+ if (ps->do_stencil_brush) {
mloopuv_base = ps->mloopuv_stencil_eval;
+ }
}
/* when using subsurf or multires, mface arrays are thrown away, we need to keep a copy */
@@ -4500,11 +4568,13 @@ static void project_paint_end(ProjPaintState *ps)
/* must be set for non-shared */
BLI_assert(ps->poly_to_loop_uv || ps->is_shared_user);
- if (ps->poly_to_loop_uv)
+ if (ps->poly_to_loop_uv) {
MEM_freeN((void *)ps->poly_to_loop_uv);
+ }
- if (ps->do_layer_clone)
+ if (ps->do_layer_clone) {
MEM_freeN((void *)ps->poly_to_loop_uv_clone);
+ }
if (ps->thread_tot > 1) {
BLI_spin_end(ps->tile_lock);
MEM_freeN((void *)ps->tile_lock);
@@ -4537,8 +4607,9 @@ static void project_paint_end(ProjPaintState *ps)
MEM_freeN(ps->blurkernel);
}
- if (ps->vertFlags)
+ if (ps->vertFlags) {
MEM_freeN(ps->vertFlags);
+ }
for (a = 0; a < ps->thread_tot; a++) {
BLI_memarena_free(ps->arena_mt[a]);
@@ -4578,8 +4649,9 @@ static bool partial_redraw_array_merge(ImagePaintPartialRedraw *pr,
pr->x2 = max_ii(pr->x2, pr_other->x2);
pr->y2 = max_ii(pr->y2, pr_other->y2);
- if (pr->x2 != -1)
+ if (pr->x2 != -1) {
touch = 1;
+ }
pr++;
pr_other++;
@@ -4665,10 +4737,11 @@ static bool project_bucket_iter_next(ProjPaintState *ps,
{
const int diameter = 2 * ps->brush_size;
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_thread_lock(LOCK_CUSTOM1);
+ }
- //printf("%d %d\n", ps->context_bucket_x, ps->context_bucket_y);
+ // printf("%d %d\n", ps->context_bucket_x, ps->context_bucket_y);
for (; ps->context_bucket_y < ps->bucketMax[1]; ps->context_bucket_y++) {
for (; ps->context_bucket_x < ps->bucketMax[0]; ps->context_bucket_x++) {
@@ -4681,8 +4754,9 @@ static bool project_bucket_iter_next(ProjPaintState *ps,
*bucket_index = ps->context_bucket_x + (ps->context_bucket_y * ps->buckets_x);
ps->context_bucket_x++;
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_thread_unlock(LOCK_CUSTOM1);
+ }
return 1;
}
@@ -4690,8 +4764,9 @@ static bool project_bucket_iter_next(ProjPaintState *ps,
ps->context_bucket_x = ps->bucketMin[0];
}
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_thread_unlock(LOCK_CUSTOM1);
+ }
return 0;
}
@@ -4769,8 +4844,9 @@ static void do_projectpaint_smear(ProjPaintState *ps,
{
unsigned char rgba_ub[4];
- if (project_paint_PickColor(ps, co, NULL, rgba_ub, 1) == 0)
+ if (project_paint_PickColor(ps, co, NULL, rgba_ub, 1) == 0) {
return;
+ }
blend_color_interpolate_byte(
((ProjPixelClone *)projPixel)->clonepx.ch, projPixel->pixel.ch_pt, rgba_ub, mask);
@@ -4786,8 +4862,9 @@ static void do_projectpaint_smear_f(ProjPaintState *ps,
{
float rgba[4];
- if (project_paint_PickColor(ps, co, rgba, NULL, 1) == 0)
+ if (project_paint_PickColor(ps, co, rgba, NULL, 1) == 0) {
return;
+ }
blend_color_interpolate_float(
((ProjPixelClone *)projPixel)->clonepx.f, projPixel->pixel.f_pt, rgba, mask);
@@ -4842,8 +4919,9 @@ static void do_projectpaint_soften_f(ProjPaintState *ps,
blend_color_add_float(rgba, projPixel->pixel.f_pt, rgba);
rgba[3] = alpha;
}
- else
+ else {
return;
+ }
}
else {
blend_color_interpolate_float(rgba, projPixel->pixel.f_pt, rgba, mask);
@@ -4909,8 +4987,9 @@ static void do_projectpaint_soften(ProjPaintState *ps,
rgba[3] = alpha;
premul_float_to_straight_uchar(rgba_ub, rgba);
}
- else
+ else {
return;
+ }
}
else {
premul_float_to_straight_uchar(rgba_ub, rgba);
@@ -4970,8 +5049,9 @@ static void do_projectpaint_draw_f(ProjPaintState *ps,
copy_v3_v3(rgba, ps->paint_color_linear);
- if (ps->is_texbrush)
+ if (ps->is_texbrush) {
mul_v3_v3(rgba, texrgb);
+ }
mul_v3_fl(rgba, mask);
rgba[3] = mask;
@@ -5317,10 +5397,12 @@ static void *do_projectpaint_thread(void *ph_v)
float mask_accum = *projPixel->mask_accum;
float max_mask = brush_alpha * custom_mask * falloff * 65535.0f;
- if (brush->flag & BRUSH_ACCUMULATE)
+ if (brush->flag & BRUSH_ACCUMULATE) {
mask = mask_accum + max_mask;
- else
+ }
+ else {
mask = mask_accum + (max_mask - mask_accum * falloff);
+ }
mask = min_ff(mask, 65535.0f);
mask_short = (unsigned short)mask;
@@ -5359,37 +5441,47 @@ static void *do_projectpaint_thread(void *ph_v)
/* texrgb is not used for clone, smear or soften */
switch (tool) {
case PAINT_TOOL_CLONE:
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_clone_f(ps, projPixel, mask);
- else
+ }
+ else {
do_projectpaint_clone(ps, projPixel, mask);
+ }
break;
case PAINT_TOOL_SMEAR:
sub_v2_v2v2(co, projPixel->projCoSS, pos_ofs);
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_smear_f(ps, projPixel, mask, smearArena, &smearPixels_f, co);
- else
+ }
+ else {
do_projectpaint_smear(ps, projPixel, mask, smearArena, &smearPixels, co);
+ }
break;
case PAINT_TOOL_SOFTEN:
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_soften_f(ps, projPixel, mask, softenArena, &softenPixels_f);
- else
+ }
+ else {
do_projectpaint_soften(ps, projPixel, mask, softenArena, &softenPixels);
+ }
break;
case PAINT_TOOL_MASK:
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_mask_f(ps, projPixel, mask);
- else
+ }
+ else {
do_projectpaint_mask(ps, projPixel, mask);
+ }
break;
default:
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_draw_f(ps, projPixel, texrgb, mask);
- else
+ }
+ else {
do_projectpaint_draw(
ps, projPixel, texrgb, mask, ps->dither, projPixel->x_px, projPixel->y_px);
+ }
break;
}
@@ -5463,8 +5555,9 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
return touch_any;
}
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_threadpool_init(&threads, do_projectpaint_thread, ps->thread_tot);
+ }
pool = BKE_image_pool_new();
@@ -5472,7 +5565,7 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
for (a = 0; a < ps->thread_tot; a++) {
/* set defaults in handles */
- //memset(&handles[a], 0, sizeof(BakeShade));
+ // memset(&handles[a], 0, sizeof(BakeShade));
handles[a].ps = ps;
copy_v2_v2(handles[a].mval, pos);
@@ -5497,14 +5590,17 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
handles[a].pool = pool;
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_threadpool_insert(&threads, &handles[a]);
+ }
}
- if (ps->thread_tot > 1) /* wait for everything to be done */
+ if (ps->thread_tot > 1) { /* wait for everything to be done */
BLI_threadpool_end(&threads);
- else
+ }
+ else {
do_projectpaint_thread(&handles[0]);
+ }
BKE_image_pool_free(pool);
@@ -5569,8 +5665,9 @@ static void paint_proj_stroke_ps(const bContext *UNUSED(C),
ps->brush_size = size;
ps->blend = brush->blend;
- if (eraser)
+ if (eraser) {
ps->blend = IMB_BLEND_ERASE_ALPHA;
+ }
/* handle gradient and inverted stroke color here */
if (ELEM(ps->tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL)) {
@@ -5710,8 +5807,9 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
ps->do_backfacecull = ps->do_occlude = ps->do_mask_normal = 0;
}
- if (ps->tool == PAINT_TOOL_CLONE)
+ if (ps->tool == PAINT_TOOL_CLONE) {
ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) ? 1 : 0;
+ }
ps->do_stencil_brush = (ps->brush && ps->brush->imagepaint_tool == PAINT_TOOL_MASK);
/* deactivate stenciling for the stencil brush :) */
@@ -5814,8 +5912,9 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
}
/* Don't allow brush size below 2 */
- if (BKE_brush_size_get(scene, ps_handle->brush) < 2)
+ if (BKE_brush_size_get(scene, ps_handle->brush) < 2) {
BKE_brush_size_set(scene, ps_handle->brush, 2 * U.pixelsize);
+ }
/* allocate and initialize spatial data structures */
@@ -6074,10 +6173,12 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
maxsize = GPU_max_texture_size();
- if (w > maxsize)
+ if (w > maxsize) {
w = maxsize;
- if (h > maxsize)
+ }
+ if (h > maxsize) {
h = maxsize;
+ }
ibuf = ED_view3d_draw_offscreen_imbuf(depsgraph,
scene,
@@ -6242,14 +6343,18 @@ bool BKE_paint_proj_mesh_data_check(
}
}
- if (!hasuvs)
+ if (!hasuvs) {
imapaint->missing_data |= IMAGEPAINT_MISSING_UVS;
- if (!hasmat)
+ }
+ if (!hasmat) {
imapaint->missing_data |= IMAGEPAINT_MISSING_MATERIAL;
- if (!hastex)
+ }
+ if (!hastex) {
imapaint->missing_data |= IMAGEPAINT_MISSING_TEX;
- if (!hasstencil)
+ }
+ if (!hasstencil) {
imapaint->missing_data |= IMAGEPAINT_MISSING_STENCIL;
+ }
if (uvs) {
*uvs = hasuvs;
@@ -6373,8 +6478,9 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op)
Material *ma;
Image *ima = NULL;
- if (!ob)
+ if (!ob) {
return false;
+ }
ma = give_current_material(ob, ob->actcol);
diff --git a/source/blender/editors/sculpt_paint/paint_image_undo.c b/source/blender/editors/sculpt_paint/paint_image_undo.c
index 68abdfbf95b..b80144ac4af 100644
--- a/source/blender/editors/sculpt_paint/paint_image_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_image_undo.c
@@ -417,7 +417,8 @@ static void paint_undosys_step_decode_restore_ids(ImageUndoStep *us)
{
ID *image_prev[2] = {NULL};
for (UndoImageTile *tile = us->tiles.first; tile; tile = tile->next) {
- tile->ima = (Image *)BKE_undosys_ID_map_lookup_with_prev(us->id_map, &tile->ima->id, image_prev);
+ tile->ima = (Image *)BKE_undosys_ID_map_lookup_with_prev(
+ us->id_map, &tile->ima->id, image_prev);
}
}
#endif
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 1a8d2f79290..ea4814857ba 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -279,9 +279,6 @@ struct ListBase *ED_image_undosys_step_get_tiles(struct UndoStep *us_p);
struct ListBase *ED_image_undo_get_tiles(void);
/* sculpt_uv.c */
-bool uv_sculpt_poll(struct bContext *C);
-bool uv_sculpt_keymap_poll(struct bContext *C);
-
void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot);
/* paint_utils.c */
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index ca48030daed..79d09967b75 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -121,8 +121,9 @@ static void mask_flood_fill_task_cb(void *__restrict userdata,
BKE_pbvh_vertex_iter_end;
BKE_pbvh_node_mark_redraw(node);
- if (data->multires)
+ if (data->multires) {
BKE_pbvh_node_mark_normals_update(node);
+ }
}
static int mask_flood_fill_exec(bContext *C, wmOperator *op)
@@ -166,13 +167,15 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
0, totnode, &data, mask_flood_fill_task_cb, &settings);
- if (multires)
+ if (multires) {
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
sculpt_undo_push_end();
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
ED_region_tag_redraw(ar);
@@ -217,18 +220,24 @@ static bool is_effected(float planes[4][4], const float co[3])
static void flip_plane(float out[4], const float in[4], const char symm)
{
- if (symm & PAINT_SYMM_X)
+ if (symm & PAINT_SYMM_X) {
out[0] = -in[0];
- else
+ }
+ else {
out[0] = in[0];
- if (symm & PAINT_SYMM_Y)
+ }
+ if (symm & PAINT_SYMM_Y) {
out[1] = -in[1];
- else
+ }
+ else {
out[1] = in[1];
- if (symm & PAINT_SYMM_Z)
+ }
+ if (symm & PAINT_SYMM_Z) {
out[2] = -in[2];
- else
+ }
+ else {
out[2] = in[2];
+ }
out[3] = in[3];
}
@@ -257,8 +266,9 @@ static void mask_box_select_task_cb(void *__restrict userdata,
sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_MASK);
BKE_pbvh_node_mark_redraw(node);
- if (data->multires)
+ if (data->multires) {
BKE_pbvh_node_mark_normals_update(node);
+ }
}
mask_flood_fill_set_elem(vi.mask, mode, value);
}
@@ -326,13 +336,15 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
totnode > SCULPT_THREADED_LIMIT);
BLI_task_parallel_range(0, totnode, &data, mask_box_select_task_cb, &settings);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
}
- if (multires)
+ if (multires) {
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
sculpt_undo_push_end();
@@ -354,9 +366,10 @@ typedef struct LassoMaskData {
MaskTaskData task_data;
} LassoMaskData;
-/* Lasso select. This could be defined as part of VIEW3D_OT_select_lasso, still the shortcuts conflict,
- * so we will use a separate operator */
-
+/**
+ * Lasso select. This could be defined as part of #VIEW3D_OT_select_lasso,
+ * still the shortcuts conflict, so we will use a separate operator.
+ */
static bool is_effected_lasso(LassoMaskData *data, float co[3])
{
float scr_co_f[2];
@@ -416,8 +429,9 @@ static void mask_gesture_lasso_task_cb(void *__restrict userdata,
sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_MASK);
BKE_pbvh_node_mark_redraw(node);
- if (data->multires)
+ if (data->multires) {
BKE_pbvh_node_mark_normals_update(node);
+ }
}
mask_flood_fill_set_elem(vi.mask, mode, value);
@@ -510,13 +524,15 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
(totnode > SCULPT_THREADED_LIMIT));
BLI_task_parallel_range(0, totnode, &data, mask_gesture_lasso_task_cb, &settings);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
}
- if (multires)
+ if (multires) {
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
sculpt_undo_push_end();
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 6686e255b08..f58afcdadc1 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -168,8 +168,9 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
{
float unprojected_radius = scalar * BKE_brush_unprojected_radius_get(scene, brush);
- if (unprojected_radius < 0.001f) // XXX magic number
+ if (unprojected_radius < 0.001f) { // XXX magic number
unprojected_radius = 0.001f;
+ }
BKE_brush_unprojected_radius_set(scene, brush, unprojected_radius);
}
@@ -229,8 +230,9 @@ static bool palette_poll(bContext *C)
{
Paint *paint = BKE_paint_get_active_from_context(C);
- if (paint && paint->palette != NULL)
+ if (paint && paint->palette != NULL) {
return true;
+ }
return false;
}
@@ -306,8 +308,9 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
Brush *brush = BKE_paint_brush(paint);
Object *ob = CTX_data_active_object(C);
- if (!ob || !brush)
+ if (!ob || !brush) {
return OPERATOR_CANCELLED;
+ }
/* TODO: other modes */
if (ob->mode & OB_MODE_SCULPT) {
@@ -396,8 +399,9 @@ static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, co
* for one that is */
br = brush_tool_cycle(bmain, paint, brush_orig, tool);
/* store the previously-selected brush */
- if (br)
+ if (br) {
br->toggle_brush = brush_orig;
+ }
return br;
}
@@ -406,8 +410,9 @@ static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, co
* back to the previously selected brush. */
return brush_orig->toggle_brush;
}
- else
+ else {
return NULL;
+ }
}
static int brush_generic_tool_set(Main *bmain,
@@ -519,37 +524,6 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
-static int brush_uv_sculpt_tool_set_exec(bContext *C, wmOperator *op)
-{
- Brush *brush;
- Scene *scene = CTX_data_scene(C);
- ToolSettings *ts = scene->toolsettings;
- ts->uv_sculpt_tool = RNA_enum_get(op->ptr, "tool");
- brush = ts->uvsculpt->paint.brush;
- /* To update toolshelf */
- WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
-
- return OPERATOR_FINISHED;
-}
-
-static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "UV Sculpt Tool Set";
- ot->description = "Set the UV sculpt tool";
- ot->idname = "BRUSH_OT_uv_sculpt_tool_set";
-
- /* api callbacks */
- ot->exec = brush_uv_sculpt_tool_set_exec;
- ot->poll = uv_sculpt_poll;
-
- /* flags */
- ot->flag = 0;
-
- /* props */
- ot->prop = RNA_def_enum(ot->srna, "tool", rna_enum_uv_sculpt_tool_items, 0, "Tool", "");
-}
-
/***** Stencil Control *****/
typedef enum {
@@ -578,7 +552,8 @@ typedef struct {
float area_size[2];
StencilControlMode mode;
StencilConstraint constrain_mode;
- int mask; /* we are twaking mask or colour stencil */
+ /** We are tweaking mask or color stencil. */
+ int mask;
Brush *br;
float *dim_target;
float *rot_target;
@@ -628,12 +603,14 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev
int mask = RNA_enum_get(op->ptr, "texmode");
if (mask) {
- if (br->mask_mtex.brush_map_mode != MTEX_MAP_MODE_STENCIL)
+ if (br->mask_mtex.brush_map_mode != MTEX_MAP_MODE_STENCIL) {
return OPERATOR_CANCELLED;
+ }
}
else {
- if (br->mtex.brush_map_mode != MTEX_MAP_MODE_STENCIL)
+ if (br->mtex.brush_map_mode != MTEX_MAP_MODE_STENCIL) {
return OPERATOR_CANCELLED;
+ }
}
scd = MEM_mallocN(sizeof(StencilControlData), "stencil_control");
@@ -695,10 +672,12 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2]
len = len_v2(mdiff);
factor = len / scd->lenorig;
copy_v2_v2(mdiff, scd->init_sdim);
- if (scd->constrain_mode != STENCIL_CONSTRAINT_Y)
+ if (scd->constrain_mode != STENCIL_CONSTRAINT_Y) {
mdiff[0] = factor * scd->init_sdim[0];
- if (scd->constrain_mode != STENCIL_CONSTRAINT_X)
+ }
+ if (scd->constrain_mode != STENCIL_CONSTRAINT_X) {
mdiff[1] = factor * scd->init_sdim[1];
+ }
CLAMP(mdiff[0], 5.0f, 10000.0f);
CLAMP(mdiff[1], 5.0f, 10000.0f);
copy_v2_v2(scd->dim_target, mdiff);
@@ -709,10 +688,12 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2]
sub_v2_v2v2(mdiff, mvalf, scd->pos_target);
angle = atan2f(mdiff[1], mdiff[0]);
angle = scd->init_rot + angle - scd->init_angle;
- if (angle < 0.0f)
+ if (angle < 0.0f) {
angle += (float)(2 * M_PI);
- if (angle > (float)(2 * M_PI))
+ }
+ if (angle > (float)(2 * M_PI)) {
angle -= (float)(2 * M_PI);
+ }
*scd->rot_target = angle;
break;
}
@@ -744,20 +725,24 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
case XKEY:
if (event->val == KM_PRESS) {
- if (scd->constrain_mode == STENCIL_CONSTRAINT_X)
+ if (scd->constrain_mode == STENCIL_CONSTRAINT_X) {
scd->constrain_mode = 0;
- else
+ }
+ else {
scd->constrain_mode = STENCIL_CONSTRAINT_X;
+ }
stencil_control_calculate(scd, event->mval);
}
break;
case YKEY:
if (event->val == KM_PRESS) {
- if (scd->constrain_mode == STENCIL_CONSTRAINT_Y)
+ if (scd->constrain_mode == STENCIL_CONSTRAINT_Y) {
scd->constrain_mode = 0;
- else
+ }
+ else {
scd->constrain_mode = STENCIL_CONSTRAINT_Y;
+ }
stencil_control_calculate(scd, event->mval);
}
@@ -778,8 +763,9 @@ static bool stencil_control_poll(bContext *C)
Paint *paint;
Brush *br;
- if (!paint_supports_texture(mode))
+ if (!paint_supports_texture(mode)) {
return false;
+ }
paint = BKE_paint_get_active_from_context(C);
br = BKE_paint_brush(paint);
@@ -905,8 +891,9 @@ static int stencil_reset_transform_exec(bContext *C, wmOperator *op)
Brush *br = BKE_paint_brush(paint);
bool do_mask = RNA_boolean_get(op->ptr, "mask");
- if (!br)
+ if (!br) {
return OPERATOR_CANCELLED;
+ }
if (do_mask) {
br->mask_stencil_pos[0] = 256;
@@ -996,7 +983,6 @@ void ED_operatortypes_paint(void)
/* note, particle uses a different system, can be added with existing operators in wm.py */
WM_operatortype_append(PAINT_OT_brush_select);
- WM_operatortype_append(BRUSH_OT_uv_sculpt_tool_set);
/* image */
WM_operatortype_append(PAINT_OT_texture_paint_toggle);
@@ -1083,9 +1069,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap = WM_keymap_ensure(keyconf, "Face Mask", 0, 0);
keymap->poll = facemask_paint_poll;
- keymap = WM_keymap_ensure(keyconf, "UV Sculpt", 0, 0);
- keymap->poll = uv_sculpt_keymap_poll;
-
/* paint stroke */
keymap = paint_stroke_modal_keymap(keyconf);
WM_modalkeymap_assign(keymap, "SCULPT_OT_brush_stroke");
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 4a586f4f7df..9a46dab8c20 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -309,8 +309,9 @@ static bool paint_brush_update(bContext *C,
do_random = true;
}
- if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)
+ if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM) {
BKE_brush_randomize_texture_coords(ups, false);
+ }
else {
copy_v2_v2(ups->tex_mouse, mouse);
}
@@ -325,8 +326,9 @@ static bool paint_brush_update(bContext *C,
do_random_mask = true;
}
- if (brush->mask_mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)
+ if (brush->mask_mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM) {
BKE_brush_randomize_texture_coords(ups, true);
+ }
else {
copy_v2_v2(ups->mask_tex_mouse, mouse);
}
@@ -427,8 +429,9 @@ static bool paint_brush_update(bContext *C,
location_success = true;
*r_location_is_set = true;
}
- else if (!paint_tool_require_location(brush, mode))
+ else if (!paint_tool_require_location(brush, mode)) {
location_success = true;
+ }
}
else {
zero_v3(r_location);
@@ -479,8 +482,7 @@ static void paint_brush_stroke_add_step(bContext *C,
if (tablet && (pressure >= 0.99f) &&
((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) ||
BKE_brush_use_alpha_pressure(scene, pop->s.brush) ||
- BKE_brush_use_size_pressure(scene, pop->s.brush)))
- {
+ BKE_brush_use_size_pressure(scene, pop->s.brush))) {
return;
}
@@ -493,8 +495,7 @@ static void paint_brush_stroke_add_step(bContext *C,
if (tablet && (pressure < 0.0002f) &&
((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) ||
BKE_brush_use_alpha_pressure(scene, pop->s.brush) ||
- BKE_brush_use_size_pressure(scene, pop->s.brush)))
- {
+ BKE_brush_use_size_pressure(scene, pop->s.brush))) {
return;
}
#endif
@@ -508,8 +509,9 @@ static void paint_brush_stroke_add_step(bContext *C,
float delta[2];
float factor = stroke->zoom_2d;
- if (brush->flag & BRUSH_JITTER_PRESSURE)
+ if (brush->flag & BRUSH_JITTER_PRESSURE) {
factor *= pressure;
+ }
BKE_brush_jitter_pos(scene, brush, mouse_in, mouse_out);
@@ -591,8 +593,9 @@ static float paint_space_stroke_spacing(const Scene *scene,
float spacing = stroke->brush->spacing;
/* apply spacing pressure */
- if (stroke->brush->flag & BRUSH_SPACING_PRESSURE)
+ if (stroke->brush->flag & BRUSH_SPACING_PRESSURE) {
spacing = spacing * (1.5f - spacing_pressure);
+ }
/* stroke system is used for 2d paint too, so we need to account for
* the fact that brush can be scaled there. */
@@ -616,8 +619,9 @@ static float paint_stroke_overlapped_curve(Brush *br, float x, float spacing)
xx = fabsf(x0 + i * h);
- if (xx < 1.0f)
+ if (xx < 1.0f) {
sum += BKE_brush_curve_strength(br, xx, 1);
+ }
}
return sum;
@@ -632,8 +636,9 @@ static float paint_stroke_integrate_overlap(Brush *br, float factor)
float spacing = br->spacing * factor;
- if (!(br->flag & BRUSH_SPACE_ATTEN && (br->spacing < 100)))
+ if (!(br->flag & BRUSH_SPACE_ATTEN && (br->spacing < 100))) {
return 1.0;
+ }
m = 10;
g = 1.0f / m;
@@ -641,14 +646,17 @@ static float paint_stroke_integrate_overlap(Brush *br, float factor)
for (i = 0; i < m; i++) {
float overlap = fabs(paint_stroke_overlapped_curve(br, i * g, spacing));
- if (overlap > max)
+ if (overlap > max) {
max = overlap;
+ }
}
- if (max == 0.0f)
+ if (max == 0.0f) {
return 1.0f;
- else
+ }
+ else {
return 1.0f / max;
+ }
}
static float paint_space_stroke_spacing_variable(
@@ -776,8 +784,9 @@ PaintStroke *paint_stroke_new(bContext *C,
/* initialize here to avoid initialization conflict with threaded strokes */
curvemapping_initialize(br->curve);
- if (p->flags & PAINT_USE_CAVITY_MASK)
+ if (p->flags & PAINT_USE_CAVITY_MASK) {
curvemapping_initialize(p->cavity_curve);
+ }
BKE_paint_set_overlay_override(br->overlay_flags);
@@ -799,18 +808,22 @@ static void stroke_done(struct bContext *C, struct wmOperator *op)
ups->stroke_active = false;
/* reset rotation here to avoid doing so in cursor display */
- if (!(stroke->brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE))
+ if (!(stroke->brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) {
ups->brush_rotation = 0.0f;
+ }
- if (!(stroke->brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE))
+ if (!(stroke->brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) {
ups->brush_rotation_sec = 0.0f;
+ }
if (stroke->stroke_started) {
- if (stroke->redraw)
+ if (stroke->redraw) {
stroke->redraw(C, stroke, true);
+ }
- if (stroke->done)
+ if (stroke->done) {
stroke->done(C, stroke);
+ }
}
if (stroke->timer) {
@@ -821,8 +834,9 @@ static void stroke_done(struct bContext *C, struct wmOperator *op)
BLI_rng_free(stroke->rng);
}
- if (stroke->stroke_cursor)
+ if (stroke->stroke_cursor) {
WM_paint_cursor_end(CTX_wm_manager(C), stroke->stroke_cursor);
+ }
BLI_freelistN(&stroke->line);
@@ -847,13 +861,15 @@ static bool sculpt_is_grab_tool(Brush *br)
/* return true if the brush size can change during paint (normally used for pressure) */
bool paint_supports_dynamic_size(Brush *br, ePaintMode mode)
{
- if (br->flag & BRUSH_ANCHORED)
+ if (br->flag & BRUSH_ANCHORED) {
return false;
+ }
switch (mode) {
case PAINT_MODE_SCULPT:
- if (sculpt_is_grab_tool(br))
+ if (sculpt_is_grab_tool(br)) {
return false;
+ }
break;
case PAINT_MODE_TEXTURE_2D: /* fall through */
@@ -878,8 +894,9 @@ bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
switch (mode) {
case PAINT_MODE_SCULPT:
- if (sculpt_is_grab_tool(br))
+ if (sculpt_is_grab_tool(br)) {
return false;
+ }
break;
default:
break;
@@ -897,13 +914,15 @@ bool paint_supports_texture(ePaintMode mode)
/* return true if the brush size can change during paint (normally used for pressure) */
bool paint_supports_dynamic_tex_coords(Brush *br, ePaintMode mode)
{
- if (br->flag & BRUSH_ANCHORED)
+ if (br->flag & BRUSH_ANCHORED) {
return false;
+ }
switch (mode) {
case PAINT_MODE_SCULPT:
- if (sculpt_is_grab_tool(br))
+ if (sculpt_is_grab_tool(br)) {
return false;
+ }
break;
default:
break;
@@ -944,10 +963,12 @@ static void paint_stroke_add_sample(
sample->pressure = pressure;
stroke->cur_sample++;
- if (stroke->cur_sample >= max_samples)
+ if (stroke->cur_sample >= max_samples) {
stroke->cur_sample = 0;
- if (stroke->num_samples < max_samples)
+ }
+ if (stroke->num_samples < max_samples) {
stroke->num_samples++;
+ }
}
static void paint_stroke_sample_average(const PaintStroke *stroke, PaintSample *average)
@@ -993,8 +1014,9 @@ static void paint_line_strokes_spacing(bContext *C,
BLI_assert(length >= 0.0f);
- if (length == 0.0f)
+ if (length == 0.0f) {
return;
+ }
while (length > 0.0f) {
float spacing_final = spacing - *length_residue;
@@ -1045,8 +1067,9 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str
float length_residue = 0.0f;
int i;
- if (!pc)
+ if (!pc) {
return true;
+ }
#ifdef DEBUG_TIME
TIMEIT_START_AVERAGED(whole_stroke);
@@ -1177,22 +1200,25 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
* this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it
* since the 2D deltas are zero -- code in this file needs to be updated to use the
* post-NDOF_MOTION MOUSEMOVE */
- if (event->type == NDOF_MOTION)
+ if (event->type == NDOF_MOTION) {
return OPERATOR_PASS_THROUGH;
+ }
#endif
/* one time initialization */
if (!stroke->stroke_init) {
- if (paint_stroke_curve_end(C, op, stroke))
+ if (paint_stroke_curve_end(C, op, stroke)) {
return OPERATOR_FINISHED;
+ }
- if (paint_supports_smooth_stroke(br, mode))
+ if (paint_supports_smooth_stroke(br, mode)) {
stroke->stroke_cursor = WM_paint_cursor_activate(CTX_wm_manager(C),
SPACE_TYPE_ANY,
RGN_TYPE_ANY,
paint_poll,
paint_draw_smooth_cursor,
stroke);
+ }
stroke->stroke_init = true;
first_modal = true;
@@ -1206,9 +1232,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
BLI_assert((stroke->stroke_started & ~1) == 0); /* 0/1 */
if (stroke->stroke_started) {
- if (br->flag & BRUSH_AIRBRUSH)
+ if (br->flag & BRUSH_AIRBRUSH) {
stroke->timer = WM_event_add_timer(
CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate);
+ }
if (br->flag & BRUSH_LINE) {
stroke->stroke_cursor = WM_paint_cursor_activate(CTX_wm_manager(C),
@@ -1249,10 +1276,12 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
}
else if (br->flag & BRUSH_LINE) {
- if (event->alt)
+ if (event->alt) {
stroke->constrain_line = true;
- else
+ }
+ else {
stroke->constrain_line = false;
+ }
copy_v2_fl2(mouse, event->mval[0], event->mval[1]);
paint_stroke_line_constrain(stroke, mouse);
@@ -1276,8 +1305,9 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (paint_smooth_stroke(stroke, &sample_average, mode, mouse, &pressure)) {
if (stroke->stroke_started) {
if (paint_space_stroke_enabled(br, mode)) {
- if (paint_space_stroke(C, op, mouse, pressure))
+ if (paint_space_stroke(C, op, mouse, pressure)) {
redraw = true;
+ }
}
else {
float dmouse[2];
@@ -1305,11 +1335,13 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
ARegion *ar = CTX_wm_region(C);
/* At the very least, invalidate the cursor */
- if (ar && (p->flags & PAINT_SHOW_BRUSH))
+ if (ar && (p->flags & PAINT_SHOW_BRUSH)) {
WM_paint_cursor_tag_redraw(window, ar);
+ }
- if (redraw && stroke->redraw)
+ if (redraw && stroke->redraw) {
stroke->redraw(C, stroke, false);
+ }
}
return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 098e38dbdb5..6d003820723 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -93,8 +93,9 @@ bool paint_convert_bb_to_rect(rcti *rect,
BLI_rcti_init_minmax(rect);
/* return zero if the bounding box has non-positive volume */
- if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2])
+ if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) {
return 0;
+ }
ED_view3d_ob_project_mat_get(rv3d, ob, projection_mat);
@@ -195,8 +196,9 @@ void paint_get_tex_pixel_col(const MTex *mtex,
rgba[3] = 1.0f;
}
- if (convert_to_linear)
+ if (convert_to_linear) {
IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, colorspace);
+ }
linearrgb_to_srgb_v3_v3(rgba, rgba);
@@ -382,8 +384,9 @@ static int imapaint_pick_face(ViewContext *vc,
unsigned int *r_index,
unsigned int totpoly)
{
- if (totpoly == 0)
+ if (totpoly == 0) {
return 0;
+ }
/* sample only on the exact position */
*r_index = ED_view3d_select_id_sample(vc, mval[0], mval[1]);
@@ -410,18 +413,24 @@ static Image *imapaint_face_image(Object *ob, Mesh *me, int face_index)
/* Uses symm to selectively flip any axis of a coordinate. */
void flip_v3_v3(float out[3], const float in[3], const char symm)
{
- if (symm & PAINT_SYMM_X)
+ if (symm & PAINT_SYMM_X) {
out[0] = -in[0];
- else
+ }
+ else {
out[0] = in[0];
- if (symm & PAINT_SYMM_Y)
+ }
+ if (symm & PAINT_SYMM_Y) {
out[1] = -in[1];
- else
+ }
+ else {
out[1] = in[1];
- if (symm & PAINT_SYMM_Z)
+ }
+ if (symm & PAINT_SYMM_Z) {
out[2] = -in[2];
- else
+ }
+ else {
out[2] = in[2];
+ }
}
void flip_qt_qt(float out[4], const float in[4], const char symm)
@@ -474,7 +483,7 @@ void paint_sample_color(
}
if (CTX_wm_view3d(C) && texpaint_proj) {
- /* first try getting a colour directly from the mesh faces if possible */
+ /* first try getting a color directly from the mesh faces if possible */
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
@@ -501,10 +510,12 @@ void paint_sample_color(
if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) {
Image *image;
- if (use_material)
+ if (use_material) {
image = imapaint_face_image(ob_eval, me_eval, faceindex);
- else
+ }
+ else {
image = imapaint->canvas;
+ }
if (image) {
ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
@@ -517,10 +528,12 @@ void paint_sample_color(
u = fmodf(uv[0], 1.0f);
v = fmodf(uv[1], 1.0f);
- if (u < 0.0f)
+ if (u < 0.0f) {
u += 1.0f;
- if (v < 0.0f)
+ }
+ if (v < 0.0f) {
v += 1.0f;
+ }
u = u * ibuf->x;
v = v * ibuf->y;
@@ -563,8 +576,9 @@ void paint_sample_color(
x + ar->winrct.xmin, y + ar->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
glReadBuffer(GL_BACK);
}
- else
+ else {
return;
+ }
}
else {
glReadBuffer(GL_FRONT);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 70783ff004e..7852cd61ae1 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -312,16 +312,20 @@ static uint vpaint_blend(const VPaint *vp,
for (a = 0; a < 4; a++) {
if (ct[a] < co[a]) {
- if (cp[a] < ct[a])
+ if (cp[a] < ct[a]) {
cp[a] = ct[a];
- else if (cp[a] > co[a])
+ }
+ else if (cp[a] > co[a]) {
cp[a] = co[a];
+ }
}
else {
- if (cp[a] < co[a])
+ if (cp[a] < co[a]) {
cp[a] = co[a];
- else if (cp[a] > ct[a])
+ }
+ else if (cp[a] > ct[a]) {
cp[a] = ct[a];
+ }
}
}
}
@@ -400,12 +404,15 @@ static float wpaint_blend(const VPaint *wp,
static float wpaint_clamp_monotonic(float oldval, float curval, float newval)
{
- if (newval < oldval)
+ if (newval < oldval) {
return MIN2(newval, curval);
- else if (newval > oldval)
+ }
+ else if (newval > oldval) {
return MAX2(newval, curval);
- else
+ }
+ else {
return newval;
+ }
}
/* ----------------------------------------------------- */
@@ -553,7 +560,8 @@ static void do_weight_paint_normalize_all_locked_try_active(MDeformVert *dvert,
if (!success) {
/**
- * Locks prevented the first pass from full completion, so remove restriction on active group; e.g:
+ * Locks prevented the first pass from full completion,
+ * so remove restriction on active group; e.g:
*
* - With 1.0 weight painted into active:
* nonzero locked weight; first pass zeroed out unlocked weight; scale 1 down to fit.
@@ -565,9 +573,11 @@ static void do_weight_paint_normalize_all_locked_try_active(MDeformVert *dvert,
}
#if 0 /* UNUSED */
-static bool has_unselected_unlocked_bone_group(
- int defbase_tot, bool *defbase_sel, int selected,
- const bool *lock_flags, const bool *vgroup_validmap)
+static bool has_unselected_unlocked_bone_group(int defbase_tot,
+ bool *defbase_sel,
+ int selected,
+ const bool *lock_flags,
+ const bool *vgroup_validmap)
{
int i;
if (defbase_tot == selected) {
@@ -843,15 +853,15 @@ static void do_weight_paint_vertex_single(
dv_mirr, wpi->defbase_tot, wpi->vgroup_validmap, wpi->lock_flags, wpi->mirror.lock);
}
else {
- /* this case accounts for...
- * - painting onto a center vertex of a mesh
- * - x mirror is enabled
- * - auto normalize is enabled
- * - the group you are painting onto has a L / R version
+ /* This case accounts for:
+ * - Painting onto a center vertex of a mesh.
+ * - X-mirror is enabled.
+ * - Auto normalize is enabled.
+ * - The group you are painting onto has a L / R version.
*
* We want L/R vgroups to have the same weight but this cant be if both are over 0.5,
- * We _could_ have special check for that, but this would need its own normalize function which
- * holds 2 groups from changing at once.
+ * We _could_ have special check for that, but this would need its own
+ * normalize function which holds 2 groups from changing at once.
*
* So! just balance out the 2 weights, it keeps them equal and everything normalized.
*
@@ -1287,7 +1297,8 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
BKE_paint_toolslots_brush_validate(bmain, &ts->wpaint->paint);
}
- /* When locked, it's almost impossible to select the pose then the object to enter weight paint mode.
+ /* When locked, it's almost impossible to select the pose
+ * then the object to enter weight paint mode.
* In this case move our pose object in/out of pose mode.
* This is in fits with the convention of selecting multiple objects and entering a mode. */
if (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) {
@@ -1322,12 +1333,15 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
static bool paint_poll_test(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (ob == NULL || ob->type != OB_MESH)
+ if (ob == NULL || ob->type != OB_MESH) {
return 0;
- if (!ob->data || ID_IS_LINKED(ob->data))
+ }
+ if (!ob->data || ID_IS_LINKED(ob->data)) {
return 0;
- if (CTX_data_edit_object(C))
+ }
+ if (CTX_data_edit_object(C)) {
return 0;
+ }
return 1;
}
@@ -1395,20 +1409,24 @@ static void vwpaint_update_cache_invariants(
}
/* Initial mouse location */
- if (mouse)
+ if (mouse) {
copy_v2_v2(cache->initial_mouse, mouse);
- else
+ }
+ else {
zero_v2(cache->initial_mouse);
+ }
mode = RNA_enum_get(op->ptr, "mode");
cache->invert = mode == BRUSH_STROKE_INVERT;
cache->alt_smooth = mode == BRUSH_STROKE_SMOOTH;
/* not very nice, but with current events system implementation
* we can't handle brush appearance inversion hotkey separately (sergey) */
- if (cache->invert)
+ if (cache->invert) {
ups->draw_inverted = true;
- else
+ }
+ else {
ups->draw_inverted = false;
+ }
copy_v2_v2(cache->mouse, cache->initial_mouse);
/* Truly temporary data that isn't stored in properties */
@@ -1665,8 +1683,9 @@ static void do_wpaint_precompute_weight_cb_ex(void *__restrict userdata,
static void precompute_weight_values(
bContext *C, Object *ob, Brush *brush, struct WPaintData *wpd, WeightPaintInfo *wpi, Mesh *me)
{
- if (wpd->precomputed_weight_ready && !brush_use_accumulate_ex(brush, ob->mode))
+ if (wpd->precomputed_weight_ready && !brush_use_accumulate_ex(brush, ob->mode)) {
return;
+ }
/* threaded loop over vertices */
SculptThreadedTaskData data = {
@@ -1872,8 +1891,9 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata,
const float final_alpha = brush_fade * brush_strength * grid_alpha *
brush_alpha_pressure;
- if (final_alpha <= 0.0f)
+ if (final_alpha <= 0.0f) {
continue;
+ }
do_weight_paint_vertex(
data->vp, data->ob, data->wpi, v_index, final_alpha, (float)weight_final);
@@ -2156,8 +2176,9 @@ static void wpaint_do_paint(bContext *C,
wpaint_paint_leaves(C, ob, sd, wp, wpd, wpi, me, nodes, totnode);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
static void wpaint_do_radial_symmetry(bContext *C,
@@ -2306,8 +2327,9 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
/* previous is not set in the current cache else
* the partial rect will always grow */
if (ss->cache) {
- if (!BLI_rcti_is_empty(&ss->cache->previous_r))
+ if (!BLI_rcti_is_empty(&ss->cache->previous_r)) {
BLI_rcti_union(&r, &ss->cache->previous_r);
+ }
}
r.xmin += vc->ar->winrct.xmin - 2;
@@ -2326,18 +2348,24 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
struct WPaintData *wpd = paint_stroke_mode_data(stroke);
if (wpd) {
- if (wpd->defbase_sel)
+ if (wpd->defbase_sel) {
MEM_freeN((void *)wpd->defbase_sel);
- if (wpd->vgroup_validmap)
+ }
+ if (wpd->vgroup_validmap) {
MEM_freeN((void *)wpd->vgroup_validmap);
- if (wpd->lock_flags)
+ }
+ if (wpd->lock_flags) {
MEM_freeN((void *)wpd->lock_flags);
- if (wpd->active.lock)
+ }
+ if (wpd->active.lock) {
MEM_freeN((void *)wpd->active.lock);
- if (wpd->mirror.lock)
+ }
+ if (wpd->mirror.lock) {
MEM_freeN((void *)wpd->mirror.lock);
- if (wpd->precomputed_weight)
+ }
+ if (wpd->precomputed_weight) {
MEM_freeN(wpd->precomputed_weight);
+ }
MEM_freeN(wpd);
}
@@ -2568,12 +2596,14 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
/* context checks could be a poll() */
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return false;
+ }
ED_mesh_color_ensure(me, NULL);
- if (me->mloopcol == NULL)
+ if (me->mloopcol == NULL) {
return false;
+ }
/* make mode data storage */
vpd = MEM_callocN(sizeof(*vpd), "VPaintData");
@@ -3278,12 +3308,15 @@ static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
ED_vpaint_proj_handle_free(vpd->vp_handle);
}
- if (vpd->mlooptag)
+ if (vpd->mlooptag) {
MEM_freeN(vpd->mlooptag);
- if (vpd->smear.color_prev)
+ }
+ if (vpd->smear.color_prev) {
MEM_freeN(vpd->smear.color_prev);
- if (vpd->smear.color_curr)
+ }
+ if (vpd->smear.color_curr) {
MEM_freeN(vpd->smear.color_curr);
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
index ad7cfebb8d5..fed477ace14 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
@@ -82,8 +82,9 @@ static bool vertex_color_set(Object *ob, uint paintcol)
for (i = 0; i < me->totpoly; i++, mp++) {
MLoopCol *lcol = me->mloopcol + mp->loopstart;
- if (use_face_sel && !(mp->flag & ME_FACE_SEL))
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL)) {
continue;
+ }
j = 0;
do {
@@ -151,7 +152,7 @@ static bool vertex_paint_from_weight(Object *ob)
}
/* TODO: respect selection. */
- /* TODO: Do we want to take weights from evaluated mesh instead? 2.7x was not doing it anyway... */
+ /* TODO: Do we want to take weights from evaluated mesh instead? 2.7x was not doing it anyway. */
mp = me->mpoly;
vgroup_active = ob->actdef - 1;
for (int i = 0; i < me->totpoly; i++, mp++) {
@@ -220,8 +221,9 @@ static void vertex_color_smooth_looptag(Mesh *me, bool *mlooptag)
/* if no mloopcol: do not do */
/* if mtexpoly: only the involved faces, otherwise all */
- if (me->mloopcol == NULL || me->totvert == 0 || me->totpoly == 0)
+ if (me->mloopcol == NULL || me->totvert == 0 || me->totpoly == 0) {
return;
+ }
scol = MEM_callocN(sizeof(int) * me->totvert * 5, "scol");
@@ -289,8 +291,9 @@ static bool vertex_color_smooth(Object *ob)
const MLoop *ml = me->mloop + mp->loopstart;
int ml_index = mp->loopstart;
- if (use_face_sel && !(mp->flag & ME_FACE_SEL))
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL)) {
continue;
+ }
for (j = 0; j < mp->totloop; j++, ml_index++, ml++) {
mlooptag[ml_index] = true;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 29d150c44fe..c1c2964156f 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -130,6 +130,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op)
op->reports, depsgraph, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
DEG_id_tag_update(&me->id, 0);
+ DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
index 88aed201b48..c71315872f6 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
@@ -41,6 +41,8 @@
#include "BKE_report.h"
#include "BKE_object.h"
+#include "DEG_depsgraph_build.h"
+
/* Only for blend modes. */
#include "IMB_imbuf.h"
@@ -93,6 +95,7 @@ bool ED_wpaint_ensure_data(bContext *C,
bDeformGroup *dg = defgroup_find_name(ob, pchan->name);
if (dg == NULL) {
dg = BKE_object_defgroup_add_name(ob, pchan->name); /* sets actdef */
+ DEG_relations_tag_update(CTX_data_main(C));
}
else {
int actdef = 1 + BLI_findindex(&ob->defbase, dg);
@@ -105,6 +108,7 @@ bool ED_wpaint_ensure_data(bContext *C,
}
if (BLI_listbase_is_empty(&ob->defbase)) {
BKE_object_defgroup_add(ob);
+ DEG_relations_tag_update(CTX_data_main(C));
}
/* ensure we don't try paint onto an invalid group */
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 9309def4a77..9ba7561b18b 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -109,8 +109,9 @@ static bool sculpt_has_active_modifiers(Scene *scene, Object *ob)
/* exception for shape keys because we can edit those */
for (; md; md = md->next) {
- if (modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
return 1;
+ }
}
return 0;
@@ -394,17 +395,20 @@ static void paint_mesh_restore_co_task_cb(void *__restrict userdata,
if (orig_data.unode->type == SCULPT_UNDO_COORDS) {
copy_v3_v3(vd.co, orig_data.co);
- if (vd.no)
+ if (vd.no) {
copy_v3_v3_short(vd.no, orig_data.no);
- else
+ }
+ else {
normal_short_to_float_v3(vd.fno, orig_data.no);
+ }
}
else if (orig_data.unode->type == SCULPT_UNDO_MASK) {
*vd.mask = orig_data.mask;
}
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
BKE_pbvh_vertex_iter_end;
@@ -422,9 +426,10 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob)
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
- /* Disable OpenMP when dynamic-topology is enabled. Otherwise, new entries might be inserted by
- * sculpt_undo_push_node() into the GHash used internally by BM_log_original_vert_co() by a different thread.
- * See T33787. */
+ /**
+ * Disable OpenMP when dynamic-topology is enabled. Otherwise, new entries might be inserted by
+ * #sculpt_undo_push_node() into the GHash used internally by #BM_log_original_vert_co()
+ * by a different thread. See T33787. */
SculptThreadedTaskData data = {
.sd = sd,
.ob = ob,
@@ -438,8 +443,9 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob)
totnode > SCULPT_THREADED_LIMIT);
BLI_task_parallel_range(0, totnode, &data, paint_mesh_restore_co_task_cb, &settings);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
/*** BVH Tree ***/
@@ -455,8 +461,9 @@ static void sculpt_extend_redraw_rect_previous(Object *ob, rcti *rect)
SculptSession *ss = ob->sculpt;
if (ss->cache) {
- if (!BLI_rcti_is_empty(&ss->cache->previous_r))
+ if (!BLI_rcti_is_empty(&ss->cache->previous_r)) {
BLI_rcti_union(rect, &ss->cache->previous_r);
+ }
}
}
@@ -466,8 +473,9 @@ bool sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, Object *ob, rcti *r
PBVH *pbvh = ob->sculpt->pbvh;
float bb_min[3], bb_max[3];
- if (!pbvh)
+ if (!pbvh) {
return 0;
+ }
BKE_pbvh_redraw_BB(pbvh, bb_min, bb_max);
@@ -496,8 +504,9 @@ void ED_sculpt_redraw_planes_get(float planes[4][4], ARegion *ar, Object *ob)
ob->sculpt->cache->previous_r = ob->sculpt->cache->current_r;
/* clear redraw flag from nodes */
- if (pbvh)
+ if (pbvh) {
BKE_pbvh_update(pbvh, PBVH_UpdateRedraw, NULL);
+ }
}
/************************ Brush Testing *******************/
@@ -676,7 +685,10 @@ static float frontface(const Brush *br,
#if 0
-static bool sculpt_brush_test_cyl(SculptBrushTest *test, float co[3], float location[3], const float area_no[3])
+static bool sculpt_brush_test_cyl(SculptBrushTest *test,
+ float co[3],
+ float location[3],
+ const float area_no[3])
{
if (sculpt_brush_test_sphere_fast(test, co)) {
float t1[3], t2[3], t3[3], dist;
@@ -722,10 +734,12 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis,
/* distsq = len_squared_v3v3(mirror, cache->traced_location); */
distsq = len_squared_v3v3(mirror, cache->true_location);
- if (distsq <= 4.0f * (cache->radius_squared))
+ if (distsq <= 4.0f * (cache->radius_squared)) {
return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius));
- else
+ }
+ else {
return 0;
+ }
}
static float calc_radial_symmetry_feather(Sculpt *sd,
@@ -837,10 +851,12 @@ static void calc_area_normal_and_center_task_cb(void *__restrict userdata,
normal_tri_v3(no, UNPACK3(co_tri));
flip_index = (dot_v3v3(ss->cache->view_normal, no) <= 0.0f);
- if (area_cos)
+ if (area_cos) {
add_v3_v3(private_co[flip_index], co);
- if (area_nos)
+ }
+ if (area_nos) {
add_v3_v3(private_no[flip_index], no);
+ }
private_count[flip_index] += 1;
}
}
@@ -884,10 +900,12 @@ static void calc_area_normal_and_center_task_cb(void *__restrict userdata,
}
flip_index = (dot_v3v3(ss->cache->view_normal, no) <= 0.0f);
- if (area_cos)
+ if (area_cos) {
add_v3_v3(private_co[flip_index], co);
- if (area_nos)
+ }
+ if (area_nos) {
add_v3_v3(private_no[flip_index], no);
+ }
private_count[flip_index] += 1;
}
}
@@ -1208,8 +1226,9 @@ float tex_strength(SculptSession *ss,
flip_v3_v3(symm_point, point, cache->mirror_symmetry_pass);
- if (cache->radial_symmetry_pass)
+ if (cache->radial_symmetry_pass) {
mul_m4_v3(cache->symm_rot_mat_inv, symm_point);
+ }
ED_view3d_project_float_v2_m4(cache->vc->ar, symm_point, point_2d, cache->projection_mat);
@@ -1259,18 +1278,23 @@ bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v)
float t[3], bb_min[3], bb_max[3];
int i;
- if (data->original)
+ if (data->original) {
BKE_pbvh_node_get_original_BB(node, bb_min, bb_max);
- else
+ }
+ else {
BKE_pbvh_node_get_BB(node, bb_min, bb_max);
+ }
for (i = 0; i < 3; ++i) {
- if (bb_min[i] > center[i])
+ if (bb_min[i] > center[i]) {
nearest[i] = bb_min[i];
- else if (bb_max[i] < center[i])
+ }
+ else if (bb_max[i] < center[i]) {
nearest[i] = bb_max[i];
- else
+ }
+ else {
nearest[i] = center[i];
+ }
}
sub_v3_v3v3(t, center, nearest);
@@ -1284,10 +1308,12 @@ bool sculpt_search_circle_cb(PBVHNode *node, void *data_v)
SculptSearchCircleData *data = data_v;
float bb_min[3], bb_max[3];
- if (data->original)
+ if (data->original) {
BKE_pbvh_node_get_original_BB(node, bb_min, bb_max);
- else
+ }
+ else {
BKE_pbvh_node_get_BB(node, bb_min, bb_min);
+ }
float dummy_co[3], dummy_depth;
const float dist_sq = dist_squared_ray_to_aabb_v3(
@@ -1302,13 +1328,16 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float co[3], const float
int i;
for (i = 0; i < 3; ++i) {
- if (sd->flags & (SCULPT_LOCK_X << i))
+ if (sd->flags & (SCULPT_LOCK_X << i)) {
continue;
+ }
- if ((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i]))
+ if ((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i])) {
co[i] = 0.0f;
- else
+ }
+ else {
co[i] = val[i];
+ }
}
}
@@ -1533,10 +1562,12 @@ static float neighbor_average_mask(SculptSession *ss, unsigned vert)
}
}
- if (total > 0)
+ if (total > 0) {
return avg / (float)total;
- else
+ }
+ else {
return vmask[vert];
+ }
}
/* Same logic as neighbor_average(), but for bmesh rather than mesh */
@@ -1767,8 +1798,9 @@ static void do_smooth_brush_mesh_task_cb_ex(void *__restrict userdata,
sculpt_clip(sd, ss, vd.co, val);
}
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -1821,8 +1853,9 @@ static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata,
sculpt_clip(sd, ss, vd.co, val);
}
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -1877,8 +1910,9 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata,
sculpt_clip(sd, ss, vd.co, val);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -1920,20 +1954,24 @@ static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
grid_hidden = BKE_pbvh_grid_hidden(ss->pbvh);
- if (smooth_mask)
+ if (smooth_mask) {
tmpgrid_mask = (void *)(data_chunk + 1);
- else
+ }
+ else {
tmpgrid_co = (void *)(data_chunk + 1);
+ }
for (i = 0; i < totgrid; i++) {
int gi = grid_indices[i];
const BLI_bitmap *gh = grid_hidden[gi];
gddata = griddata[gi];
- if (smooth_mask)
+ if (smooth_mask) {
memset(tmpgrid_mask, 0, data_chunk->tmpgrid_size);
- else
+ }
+ else {
memset(tmpgrid_co, 0, data_chunk->tmpgrid_size);
+ }
for (y = 0; y < gridsize - 1; y++) {
const int v = y * gridsize;
@@ -1990,8 +2028,9 @@ static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
const int index = y * gridsize + x;
if (gh) {
- if (BLI_BITMAP_TEST(gh, index))
+ if (BLI_BITMAP_TEST(gh, index)) {
continue;
+ }
}
co = CCG_elem_offset_co(&key, gddata, index);
@@ -2006,11 +2045,13 @@ static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
ss, brush, co, sqrtf(test.dist), NULL, fno, strength_mask, tls->thread_id);
float f = 1.0f / 16.0f;
- if (x == 0 || x == gridsize - 1)
+ if (x == 0 || x == gridsize - 1) {
f *= 2.0f;
+ }
- if (y == 0 || y == gridsize - 1)
+ if (y == 0 || y == gridsize - 1) {
f *= 2.0f;
+ }
if (smooth_mask) {
*mask += ((tmpgrid_mask[index] * f) - *mask) * fade;
@@ -2101,8 +2142,9 @@ static void smooth(Sculpt *sd,
break;
}
- if (ss->multires)
+ if (ss->multires) {
multires_stitch_grids(ob);
+ }
}
}
@@ -2166,8 +2208,9 @@ static void do_mask_brush_draw_task_cb_ex(void *__restrict userdata,
(*vd.mask) += fade * bstrength;
CLAMP(*vd.mask, 0, 1);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
BKE_pbvh_vertex_iter_end;
}
@@ -2239,8 +2282,9 @@ static void do_draw_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2330,8 +2374,9 @@ static void do_crease_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3v3(proxy[vd.i], val1, val2);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2354,20 +2399,24 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
- /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */
+ /* We divide out the squared alpha and multiply by the squared crease
+ * to give us the pinch strength. */
crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor;
brush_alpha = BKE_brush_alpha_get(scene, brush);
- if (brush_alpha > 0.0f)
+ if (brush_alpha > 0.0f) {
crease_correction /= brush_alpha * brush_alpha;
+ }
/* we always want crease to pinch or blob to relax even when draw is negative */
flippedbstrength = (bstrength < 0) ? -crease_correction * bstrength :
crease_correction * bstrength;
- if (brush->sculpt_tool == SCULPT_TOOL_BLOB)
+ if (brush->sculpt_tool == SCULPT_TOOL_BLOB) {
flippedbstrength *= -1.0f;
+ }
- /* Use surface normal for 'spvc', so the vertices are pinched towards a line instead of a single point.
+ /* Use surface normal for 'spvc',
+ * so the vertices are pinched towards a line instead of a single point.
* Without this we get a 'flat' surface surrounding the pinch */
sculpt_project_v3_cache_init(&spvc, ss->cache->sculpt_normal_symm);
@@ -2425,8 +2474,9 @@ static void do_pinch_brush_task_cb_ex(void *__restrict userdata,
}
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2487,8 +2537,9 @@ static void do_grab_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2553,8 +2604,9 @@ static void do_nudge_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], cono, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2660,8 +2712,9 @@ static void do_snake_hook_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3(proxy[vd.i], delta_rotate);
}
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2678,8 +2731,9 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
- if (bstrength < 0)
+ if (bstrength < 0) {
negate_v3(grab_delta);
+ }
if (ss->cache->normal_weight > 0.0f) {
sculpt_project_v3_normal_align(ss, ss->cache->normal_weight, grab_delta);
@@ -2743,8 +2797,9 @@ static void do_thumb_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], cono, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2819,8 +2874,9 @@ static void do_rotate_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3(proxy[vd.i], ss->cache->location);
sub_v3_v3(proxy[vd.i], orig_data.co);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2896,8 +2952,9 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
*disp += fade;
/* Don't let the displacement go past the limit */
- if ((lim < 0.0f && *disp < lim) || (lim >= 0.0f && *disp > lim))
+ if ((lim < 0.0f && *disp < lim) || (lim >= 0.0f && *disp > lim)) {
*disp = lim;
+ }
mul_v3_v3fl(val, offset, *disp);
@@ -2913,8 +2970,9 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
sculpt_clip(sd, ss, vd.co, val);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2976,16 +3034,19 @@ static void do_inflate_brush_task_cb_ex(void *__restrict userdata,
tls->thread_id);
float val[3];
- if (vd.fno)
+ if (vd.fno) {
copy_v3_v3(val, vd.fno);
- else
+ }
+ else {
normal_short_to_float_v3(val, vd.no);
+ }
mul_v3_fl(val, fade * ss->cache->radius);
mul_v3_v3v3(proxy[vd.i], val, ss->cache->scale);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -3048,8 +3109,9 @@ static void calc_sculpt_plane(
/* for flatten center */
/* flatten center has not been calculated yet if we are not using the area normal */
- if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA)
+ if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA) {
calc_area_center(sd, ob, nodes, totnode, r_area_co);
+ }
/* for area normal */
copy_v3_v3(ss->cache->sculpt_normal, r_area_no);
@@ -3090,8 +3152,9 @@ static int plane_trim(const StrokeCache *cache, const Brush *brush, const float
static bool plane_point_side_flip(const float co[3], const float plane[4], const bool flip)
{
float d = plane_point_side_v3(plane, co);
- if (flip)
+ if (flip) {
d = -d;
+ }
return d <= 0.0f;
}
@@ -3158,8 +3221,9 @@ static void do_flatten_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3251,8 +3315,9 @@ static void do_clay_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3347,8 +3412,9 @@ static void do_clay_strips_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3377,14 +3443,21 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
calc_sculpt_plane(sd, ob, nodes, totnode, area_no_sp, area_co);
- if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA || (brush->flag & BRUSH_ORIGINAL_NORMAL))
+ if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA || (brush->flag & BRUSH_ORIGINAL_NORMAL)) {
calc_area_normal(sd, ob, nodes, totnode, area_no);
- else
+ }
+ else {
copy_v3_v3(area_no, area_no_sp);
+ }
/* delay the first daub because grab delta is not setup */
- if (ss->cache->first_time)
+ if (ss->cache->first_time) {
return;
+ }
+
+ if (is_zero_v3(ss->cache->grab_delta_symmetry)) {
+ return;
+ }
mul_v3_v3v3(temp, area_no_sp, ss->cache->scale);
mul_v3_fl(temp, displace);
@@ -3467,8 +3540,9 @@ static void do_fill_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3558,8 +3632,9 @@ static void do_scrape_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3637,8 +3712,9 @@ static void do_gravity_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -3704,8 +3780,9 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
if (kb == me->key->refkey) {
MVert *mvert = me->mvert;
- for (a = 0; a < me->totvert; a++, mvert++)
+ for (a = 0; a < me->totvert; a++, mvert++) {
copy_v3_v3(mvert->co, vertCos[a]);
+ }
BKE_mesh_calc_normals(me);
}
@@ -3819,11 +3896,13 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT);
BLI_task_parallel_range(0, totnode, &task_data, do_brush_action_task_cb, &settings);
- if (sculpt_brush_needs_normal(ss, brush))
+ if (sculpt_brush_needs_normal(ss, brush)) {
update_sculpt_normal(sd, ob, nodes, totnode);
+ }
- if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA)
+ if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA) {
update_brush_local_mat(sd, ob);
+ }
/* Apply one type of brush action */
switch (brush->sculpt_tool) {
@@ -3898,8 +3977,9 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
bmesh_topology_rake(sd, ob, nodes, totnode, brush->topology_rake_factor);
}
- if (ss->cache->supports_gravity)
+ if (ss->cache->supports_gravity) {
do_gravity(sd, ob, nodes, totnode, sd->gravity_factor);
+ }
MEM_freeN(nodes);
@@ -3929,8 +4009,9 @@ static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd)
copy_v3_v3(ss->deform_cos[index], vd->co);
copy_v3_v3(ss->orig_cos[index], newco);
- if (!ss->kb)
+ if (!ss->kb) {
copy_v3_v3(me->mvert[index].co, newco);
+ }
}
static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
@@ -3951,8 +4032,9 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
int proxy_count;
float(*orco)[3] = NULL;
- if (use_orco && !ss->bm)
+ if (use_orco && !ss->bm) {
orco = sculpt_undo_push_node(data->ob, data->nodes[n], SCULPT_UNDO_COORDS)->co;
+ }
BKE_pbvh_node_get_proxies(data->nodes[n], &proxies, &proxy_count);
@@ -3973,13 +4055,15 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
copy_v3_v3(val, vd.co);
}
- for (p = 0; p < proxy_count; p++)
+ for (p = 0; p < proxy_count; p++) {
add_v3_v3(val, proxies[p].co[vd.i]);
+ }
sculpt_clip(sd, ss, vd.co, val);
- if (ss->modifiers_active)
+ if (ss->modifiers_active) {
sculpt_flush_pbvhvert_deform(ob, &vd);
+ }
}
BKE_pbvh_vertex_iter_end;
@@ -4010,8 +4094,9 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob)
BLI_task_parallel_range(0, totnode, &data, sculpt_combine_proxies_task_cb, &settings);
}
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
/* copy the modified vertices from bvh to the active key */
@@ -4022,16 +4107,19 @@ static void sculpt_update_keyblock(Object *ob)
/* Keyblock update happens after handling deformation caused by modifiers,
* so ss->orig_cos would be updated with new stroke */
- if (ss->orig_cos)
+ if (ss->orig_cos) {
vertCos = ss->orig_cos;
- else
+ }
+ else {
vertCos = BKE_pbvh_get_vertCos(ss->pbvh);
+ }
if (vertCos) {
sculpt_vertcos_to_key(ob, ss->kb, vertCos);
- if (vertCos != ss->orig_cos)
+ if (vertCos != ss->orig_cos) {
MEM_freeN(vertCos);
+ }
}
}
@@ -4191,8 +4279,9 @@ static void do_tiled(
start[dim] = (bbMin[dim] - orgLoc[dim] - radius) / step[dim];
end[dim] = (bbMax[dim] - orgLoc[dim] + radius) / step[dim];
}
- else
+ else {
start[dim] = end[dim] = 0;
+ }
}
/* first do the "untiled" position to initialize the stroke for this location */
@@ -4204,8 +4293,9 @@ static void do_tiled(
for (cur[0] = start[0]; cur[0] <= end[0]; ++cur[0]) {
for (cur[1] = start[1]; cur[1] <= end[1]; ++cur[1]) {
for (cur[2] = start[2]; cur[2] <= end[2]; ++cur[2]) {
- if (!cur[0] && !cur[1] && !cur[2])
+ if (!cur[0] && !cur[1] && !cur[2]) {
continue; /* skip tile at orgLoc, this was already handled before all others */
+ }
++cache->tile_pass;
@@ -4248,8 +4338,9 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob)
Brush *brush = BKE_paint_brush(&sd->paint);
MTex *mtex = &brush->mtex;
- if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE)
+ if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE) {
multires_stitch_grids(ob);
+ }
}
static void do_symmetrical_brush_actions(Sculpt *sd,
@@ -4268,7 +4359,8 @@ static void do_symmetrical_brush_actions(Sculpt *sd,
cache->bstrength = brush_strength(sd, cache, feather, ups);
cache->symmetry = symm;
- /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
+ /* symm is a bit combination of XYZ -
+ * 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
for (i = 0; i <= symm; ++i) {
if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) {
cache->mirror_symmetry_pass = i;
@@ -4383,8 +4475,9 @@ static const char *sculpt_tool_name(Sculpt *sd)
void sculpt_cache_free(StrokeCache *cache)
{
- if (cache->dial)
+ if (cache->dial) {
MEM_freeN(cache->dial);
+ }
MEM_freeN(cache);
}
@@ -4456,10 +4549,12 @@ static void sculpt_update_cache_invariants(
sculpt_init_mirror_clipping(ob, ss);
/* Initial mouse location */
- if (mouse)
+ if (mouse) {
copy_v2_v2(cache->initial_mouse, mouse);
- else
+ }
+ else {
zero_v2(cache->initial_mouse);
+ }
mode = RNA_enum_get(op->ptr, "mode");
cache->invert = mode == BRUSH_STROKE_INVERT;
@@ -4476,10 +4571,12 @@ static void sculpt_update_cache_invariants(
/* not very nice, but with current events system implementation
* we can't handle brush appearance inversion hotkey separately (sergey) */
- if (cache->invert)
+ if (cache->invert) {
ups->draw_inverted = true;
- else
+ }
+ else {
ups->draw_inverted = false;
+ }
/* Alt-Smooth */
if (cache->alt_smooth) {
@@ -4550,8 +4647,9 @@ static void sculpt_update_cache_invariants(
if (brush->sculpt_tool == SCULPT_TOOL_LAYER) {
/* not supported yet for multires or dynamic topology */
if (!ss->multires && !ss->bm && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
- if (!ss->layer_co)
+ if (!ss->layer_co) {
ss->layer_co = MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy");
+ }
if (ss->deform_cos) {
memcpy(ss->layer_co, ss->deform_cos, ss->totvert);
@@ -4585,8 +4683,9 @@ static void sculpt_update_cache_invariants(
cache->first_time = 1;
#define PIXEL_INPUT_THRESHHOLD 5
- if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
+ if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) {
cache->dial = BLI_dial_initialize(cache->initial_mouse, PIXEL_INPUT_THRESHHOLD);
+ }
#undef PIXEL_INPUT_THRESHHOLD
}
@@ -4613,8 +4712,9 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
if (cache->first_time) {
copy_v3_v3(cache->orig_grab_location, cache->true_location);
}
- else if (tool == SCULPT_TOOL_SNAKE_HOOK)
+ else if (tool == SCULPT_TOOL_SNAKE_HOOK) {
add_v3_v3(cache->true_location, cache->grab_delta);
+ }
/* compute 3d coordinate at same z from original location + mouse */
mul_v3_m4v3(loc, ob->obmat, cache->orig_grab_location);
@@ -4660,10 +4760,12 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
copy_v3_v3(cache->old_grab_location, grab_location);
- if (tool == SCULPT_TOOL_GRAB)
+ if (tool == SCULPT_TOOL_GRAB) {
copy_v3_v3(cache->anchored_location, cache->true_location);
- else if (tool == SCULPT_TOOL_THUMB)
+ }
+ else if (tool == SCULPT_TOOL_THUMB) {
copy_v3_v3(cache->anchored_location, cache->orig_grab_location);
+ }
if (ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) {
/* location stays the same for finding vertices in brush radius */
@@ -5179,8 +5281,9 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
return 1;
}
- else
+ else {
return 0;
+ }
}
static void sculpt_stroke_update_step(bContext *C,
@@ -5249,8 +5352,9 @@ static void sculpt_brush_exit_tex(Sculpt *sd)
Brush *brush = BKE_paint_brush(&sd->paint);
MTex *mtex = &brush->mtex;
- if (mtex->tex && mtex->tex->nodetree)
+ if (mtex->tex && mtex->tex->nodetree) {
ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
+ }
}
static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(stroke))
@@ -5291,20 +5395,23 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
BKE_pbvh_update(ss->pbvh, PBVH_UpdateOriginalBB, NULL);
- if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH)
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
BKE_pbvh_bmesh_after_stroke(ss->pbvh);
+ }
/* optimization: if there is locked key and active modifiers present in */
/* the stack, keyblock is updating at each step. otherwise we could update */
/* keyblock only when stroke is finished */
- if (ss->kb && !ss->modifiers_active)
+ if (ss->kb && !ss->modifiers_active) {
sculpt_update_keyblock(ob);
+ }
ss->partial_redraw = 0;
/* try to avoid calling this, only for e.g. linked duplicates now */
- if (((Mesh *)ob->data)->id.us > 1)
+ if (((Mesh *)ob->data)->id.us > 1) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -5378,8 +5485,8 @@ static void sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
const Brush *brush = BKE_paint_brush(&sd->paint);
- /* XXX Canceling strokes that way does not work with dynamic topology, user will have to do real undo for now.
- * See T46456. */
+ /* XXX Canceling strokes that way does not work with dynamic topology,
+ * user will have to do real undo for now. See T46456. */
if (ss->cache && !sculpt_stroke_is_dynamic_topology(ss, brush)) {
paint_mesh_restore_co(sd, ob);
}
@@ -5429,8 +5536,9 @@ static int sculpt_set_persistent_base_exec(bContext *C, wmOperator *UNUSED(op))
SculptSession *ss = CTX_data_active_object(C)->sculpt;
if (ss) {
- if (ss->layer_co)
+ if (ss->layer_co) {
MEM_freeN(ss->layer_co);
+ }
ss->layer_co = NULL;
}
@@ -5758,8 +5866,9 @@ static enum eDynTopoWarnFlag sculpt_dynamic_topology_check(Scene *scene, Object
/* exception for shape keys because we can edit those */
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
continue;
+ }
if (mti->type == eModifierTypeType_Constructive) {
flag |= DYNTOPO_WARN_MODIFIER;
@@ -5938,8 +6047,9 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
const int flush_recalc = ed_object_sculptmode_flush_recalc_flag(scene, ob, mmd);
- if (flush_recalc)
+ if (flush_recalc) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
/* Create sculpt mode session data */
if (ob->sculpt) {
@@ -6166,8 +6276,9 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnodes);
- if (!totnodes)
+ if (!totnodes) {
return OPERATOR_CANCELLED;
+ }
for (i = 0; i < totnodes; i++) {
BKE_pbvh_node_mark_topology_update(nodes[i]);
@@ -6188,8 +6299,9 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
while (BKE_pbvh_bmesh_update_topology(
ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, NULL, size, false, false)) {
- for (i = 0; i < totnodes; i++)
+ for (i = 0; i < totnodes; i++) {
BKE_pbvh_node_mark_topology_update(nodes[i]);
+ }
}
MEM_freeN(nodes);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 97f2ca1a143..be4ab5809e4 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -147,8 +147,10 @@ typedef struct SculptThreadedTaskData {
void *custom_data;
/* Data specific to some callbacks. */
- /* Note: even if only one or two of those are used at a time, keeping them separated, names help figuring out
- * what it is, and memory overhead is ridiculous anyway... */
+
+ /* Note: even if only one or two of those are used at a time,
+ * keeping them separated, names help figuring out
+ * what it is, and memory overhead is ridiculous anyway. */
float flippedbstrength;
float angle;
float strength;
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 0b995860feb..c66c1d91a77 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -81,8 +81,9 @@ static UndoSculpt *sculpt_undo_get_nodes(void);
static void update_cb(PBVHNode *node, void *rebuild)
{
BKE_pbvh_node_mark_update(node);
- if (*((bool *)rebuild))
+ if (*((bool *)rebuild)) {
BKE_pbvh_node_mark_rebuild_draw(node);
+ }
BKE_pbvh_node_fully_hidden_set(node, 0);
}
@@ -314,8 +315,9 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
for (j = 0; j < unode->totgrid; j++) {
grid = grids[unode->grids[j]];
- for (i = 0; i < gridsize * gridsize; i++, mask++)
+ for (i = 0; i < gridsize * gridsize; i++, mask++) {
SWAP(float, *CCG_elem_offset_mask(&key, grid, i), *mask);
+ }
}
}
@@ -357,8 +359,9 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C,
BLI_task_parallel_range(
0, totnode, nodes, sculpt_undo_bmesh_restore_generic_task_cb, &settings);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
else {
sculpt_pbvh_clear(ob);
@@ -483,18 +486,21 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, need_mask);
- if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss))
+ if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) {
return;
+ }
for (unode = lb->first; unode; unode = unode->next) {
- if (!STREQ(unode->idname, ob->id.name))
+ if (!STREQ(unode->idname, ob->id.name)) {
continue;
+ }
/* check if undo data matches current data well enough to
* continue */
if (unode->maxvert) {
- if (ss->totvert != unode->maxvert)
+ if (ss->totvert != unode->maxvert) {
continue;
+ }
}
else if (unode->maxgrid && subdiv_ccg != NULL) {
if ((subdiv_ccg->num_grids != unode->maxgrid) ||
@@ -508,16 +514,19 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
switch (unode->type) {
case SCULPT_UNDO_COORDS:
- if (sculpt_undo_restore_coords(C, unode))
+ if (sculpt_undo_restore_coords(C, unode)) {
update = true;
+ }
break;
case SCULPT_UNDO_HIDDEN:
- if (sculpt_undo_restore_hidden(C, unode))
+ if (sculpt_undo_restore_hidden(C, unode)) {
rebuild = true;
+ }
break;
case SCULPT_UNDO_MASK:
- if (sculpt_undo_restore_mask(C, unode))
+ if (sculpt_undo_restore_mask(C, unode)) {
update = true;
+ }
break;
case SCULPT_UNDO_DYNTOPO_BEGIN:
@@ -548,10 +557,12 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
NULL);
if (BKE_sculpt_multires_active(scene, ob)) {
- if (rebuild)
+ if (rebuild) {
multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED);
- else
+ }
+ else {
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
}
tag_update |= ((Mesh *)ob->data)->id.us > 1;
@@ -578,40 +589,52 @@ static void sculpt_undo_free_list(ListBase *lb)
SculptUndoNode *unode = lb->first;
while (unode != NULL) {
SculptUndoNode *unode_next = unode->next;
- if (unode->co)
+ if (unode->co) {
MEM_freeN(unode->co);
- if (unode->no)
+ }
+ if (unode->no) {
MEM_freeN(unode->no);
- if (unode->index)
+ }
+ if (unode->index) {
MEM_freeN(unode->index);
- if (unode->grids)
+ }
+ if (unode->grids) {
MEM_freeN(unode->grids);
- if (unode->orig_co)
+ }
+ if (unode->orig_co) {
MEM_freeN(unode->orig_co);
- if (unode->vert_hidden)
+ }
+ if (unode->vert_hidden) {
MEM_freeN(unode->vert_hidden);
+ }
if (unode->grid_hidden) {
for (int i = 0; i < unode->totgrid; i++) {
- if (unode->grid_hidden[i])
+ if (unode->grid_hidden[i]) {
MEM_freeN(unode->grid_hidden[i]);
+ }
}
MEM_freeN(unode->grid_hidden);
}
- if (unode->mask)
+ if (unode->mask) {
MEM_freeN(unode->mask);
+ }
if (unode->bm_entry) {
BM_log_entry_drop(unode->bm_entry);
}
- if (unode->bm_enter_totvert)
+ if (unode->bm_enter_totvert) {
CustomData_free(&unode->bm_enter_vdata, unode->bm_enter_totvert);
- if (unode->bm_enter_totedge)
+ }
+ if (unode->bm_enter_totedge) {
CustomData_free(&unode->bm_enter_edata, unode->bm_enter_totedge);
- if (unode->bm_enter_totloop)
+ }
+ if (unode->bm_enter_totloop) {
CustomData_free(&unode->bm_enter_ldata, unode->bm_enter_totloop);
- if (unode->bm_enter_totpoly)
+ }
+ if (unode->bm_enter_totpoly) {
CustomData_free(&unode->bm_enter_pdata, unode->bm_enter_totpoly);
+ }
MEM_freeN(unode);
@@ -665,10 +688,12 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, SculptUndoNode *unode
unode->grid_hidden = MEM_mapallocN(sizeof(*unode->grid_hidden) * totgrid, "unode->grid_hidden");
for (i = 0; i < totgrid; i++) {
- if (grid_hidden[grid_indices[i]])
+ if (grid_hidden[grid_indices[i]]) {
unode->grid_hidden[i] = MEM_dupallocN(grid_hidden[grid_indices[i]]);
- else
+ }
+ else {
unode->grid_hidden[i] = NULL;
+ }
}
}
@@ -690,8 +715,9 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
unode->totvert = totvert;
}
- else
+ else {
maxgrid = 0;
+ }
/* we will use this while sculpting, is mapalloc slow to access then? */
@@ -704,10 +730,12 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
usculpt->undo_size = (sizeof(float[3]) + sizeof(short[3]) + sizeof(int)) * allvert;
break;
case SCULPT_UNDO_HIDDEN:
- if (maxgrid)
+ if (maxgrid) {
sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode);
- else
+ }
+ else {
unode->vert_hidden = BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden");
+ }
break;
case SCULPT_UNDO_MASK:
@@ -738,8 +766,9 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
unode->index = MEM_mapallocN(sizeof(int) * allvert, "SculptUndoNode.index");
}
- if (ss->modifiers_active)
+ if (ss->modifiers_active) {
unode->orig_co = MEM_callocN(allvert * sizeof(*unode->orig_co), "undoSculpt orig_cos");
+ }
return unode;
}
@@ -752,13 +781,16 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode)
BKE_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL)
{
copy_v3_v3(unode->co[vd.i], vd.co);
- if (vd.no)
+ if (vd.no) {
copy_v3_v3_short(unode->no[vd.i], vd.no);
- else
+ }
+ else {
normal_float_to_short_v3(unode->no[vd.i], vd.fno);
+ }
- if (ss->modifiers_active)
+ if (ss->modifiers_active) {
copy_v3_v3(unode->orig_co[vd.i], ss->orig_cos[unode->index[vd.i]]);
+ }
}
BKE_pbvh_vertex_iter_end;
}
@@ -944,10 +976,12 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
}
/* store active shape key */
- if (ss->kb)
+ if (ss->kb) {
BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name));
- else
+ }
+ else {
unode->shapeName[0] = '\0';
+ }
BLI_thread_unlock(LOCK_CUSTOM1);
@@ -973,8 +1007,9 @@ void sculpt_undo_push_end(void)
unode->no = NULL;
}
- if (unode->node)
+ if (unode->node) {
BKE_pbvh_node_layer_disp_free(unode->node);
+ }
}
/* We could remove this and enforce all callers run in an operator using 'OPTYPE_UNDO'. */
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 39ada703b9b..3356edd6b36 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -139,120 +139,6 @@ typedef struct UvSculptData {
char invert;
} UvSculptData;
-static Brush *uv_sculpt_brush(bContext *C)
-{
- Scene *scene = CTX_data_scene(C);
- ToolSettings *settings = scene->toolsettings;
-
- if (!settings->uvsculpt)
- return NULL;
- return BKE_paint_brush(&settings->uvsculpt->paint);
-}
-
-static bool uv_sculpt_brush_poll_do(bContext *C, const bool check_region)
-{
- BMEditMesh *em;
- int ret;
- Object *obedit = CTX_data_edit_object(C);
- SpaceImage *sima = CTX_wm_space_image(C);
- Scene *scene = CTX_data_scene(C);
- ToolSettings *toolsettings = scene->toolsettings;
-
- if (!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH || !sima ||
- ED_space_image_show_render(sima) || (sima->mode == SI_MODE_PAINT)) {
- return 0;
- }
-
- em = BKE_editmesh_from_object(obedit);
- ret = EDBM_uv_check(em);
-
- if (ret) {
- ARegion *ar = CTX_wm_region(C);
- if ((!toolsettings->use_uv_sculpt) ||
- (check_region && ar && (ar->regiontype != RGN_TYPE_WINDOW))) {
- ret = 0;
- }
- }
-
- return ret;
-}
-
-static bool uv_sculpt_brush_poll(bContext *C)
-{
- return uv_sculpt_brush_poll_do(C, true);
-}
-
-static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(customdata))
-{
-#define PX_SIZE_FADE_MAX 12.0f
-#define PX_SIZE_FADE_MIN 4.0f
-
- Scene *scene = CTX_data_scene(C);
- //Brush *brush = image_paint_brush(C);
- Paint *paint = BKE_paint_get_active_from_context(C);
- Brush *brush = BKE_paint_brush(paint);
-
- if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
- const float size = (float)BKE_brush_size_get(scene, brush);
- float alpha = 0.5f;
-
- /* fade out the brush (cheap trick to work around brush interfering with sampling [#])*/
- if (size < PX_SIZE_FADE_MIN) {
- return;
- }
- else if (size < PX_SIZE_FADE_MAX) {
- alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
- }
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformColor3fvAlpha(brush->add_col, alpha);
-
- GPU_line_smooth(true);
- GPU_blend(true);
- imm_draw_circle_wire_2d(pos, (float)x, (float)y, size, 40);
- GPU_blend(false);
- GPU_line_smooth(false);
-
- immUnbindProgram();
- }
-#undef PX_SIZE_FADE_MAX
-#undef PX_SIZE_FADE_MIN
-}
-
-void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *scene)
-{
- ToolSettings *settings = scene->toolsettings;
- if (settings->use_uv_sculpt) {
- if (settings->uvsculpt == NULL) {
- settings->uv_sculpt_tool = UV_SCULPT_TOOL_GRAB;
- settings->uv_sculpt_settings = UV_SCULPT_LOCK_BORDERS | UV_SCULPT_ALL_ISLANDS;
- settings->uv_relax_method = UV_SCULPT_TOOL_RELAX_LAPLACIAN;
- }
- BKE_paint_ensure(settings, (Paint **)&settings->uvsculpt);
- BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT_UV, PAINT_CURSOR_SCULPT);
-
- settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate(
- wm, SPACE_IMAGE, RGN_TYPE_WINDOW, uv_sculpt_brush_poll, brush_drawcursor_uvsculpt, NULL);
- }
- else {
- if (settings->uvsculpt) {
- WM_paint_cursor_end(wm, settings->uvsculpt->paint.paint_cursor);
- settings->uvsculpt->paint.paint_cursor = NULL;
- }
- }
-}
-
-bool uv_sculpt_poll(bContext *C)
-{
- return uv_sculpt_brush_poll_do(C, true);
-}
-
-bool uv_sculpt_keymap_poll(bContext *C)
-{
- return uv_sculpt_brush_poll_do(C, false);
-}
-
/*********** Improved Laplacian Relaxation Operator ************************/
/* original code by Raul Fernandez Hernandez "farsthary" *
* adapted to uv smoothing by Antony Riakiatakis *
@@ -306,8 +192,9 @@ static void HC_relaxation_iteration_uv(BMEditMesh *em,
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
float dist;
- /* This is supposed to happen only if "Pin Edges" is on, since we have initialization on stroke start
- * If ever uv brushes get their own mode we should check for toolsettings option too */
+ /* This is supposed to happen only if "Pin Edges" is on,
+ * since we have initialization on stroke start.
+ * If ever uv brushes get their own mode we should check for toolsettings option too. */
if ((sculptdata->uv[i].flag & MARK_BOUNDARY)) {
continue;
}
@@ -334,8 +221,9 @@ static void HC_relaxation_iteration_uv(BMEditMesh *em,
MLoopUV *luv;
BMLoop *l;
- if (element->separate && element != sculptdata->uv[i].element)
+ if (element->separate && element != sculptdata->uv[i].element) {
break;
+ }
l = element->l;
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -375,8 +263,8 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em,
add_v2_v2(tmp_uvdata[tmpedge->uv1].sum_co, sculptdata->uv[tmpedge->uv2].uv);
}
- /* Original Lacplacian algorithm included removal of normal component of translation. here it is not
- * needed since we translate along the UV plane always.*/
+ /* Original Lacplacian algorithm included removal of normal component of translation.
+ * here it is not needed since we translate along the UV plane always. */
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
copy_v2_v2(tmp_uvdata[i].p, tmp_uvdata[i].sum_co);
mul_v2_fl(tmp_uvdata[i].p, 1.f / tmp_uvdata[i].ncounter);
@@ -384,8 +272,9 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em,
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
float dist;
- /* This is supposed to happen only if "Pin Edges" is on, since we have initialization on stroke start
- * If ever uv brushes get their own mode we should check for toolsettings option too */
+ /* This is supposed to happen only if "Pin Edges" is on,
+ * since we have initialization on stroke start.
+ * If ever uv brushes get their own mode we should check for toolsettings option too. */
if ((sculptdata->uv[i].flag & MARK_BOUNDARY)) {
continue;
}
@@ -406,8 +295,9 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em,
MLoopUV *luv;
BMLoop *l;
- if (element->separate && element != sculptdata->uv[i].element)
+ if (element->separate && element != sculptdata->uv[i].element) {
break;
+ }
l = element->l;
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -463,8 +353,9 @@ static void uv_sculpt_stroke_apply(bContext *C,
alpha *= invert;
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
float dist, diff[2];
- /* This is supposed to happen only if "Lock Borders" is on, since we have initialization on stroke start
- * If ever uv brushes get their own mode we should check for toolsettings option too */
+ /* This is supposed to happen only if "Lock Borders" is on,
+ * since we have initialization on stroke start.
+ * If ever uv brushes get their own mode we should check for toolsettings option too. */
if (sculptdata->uv[i].flag & MARK_BOUNDARY) {
continue;
}
@@ -484,8 +375,9 @@ static void uv_sculpt_stroke_apply(bContext *C,
MLoopUV *luv;
BMLoop *l;
- if (element->separate && element != sculptdata->uv[i].element)
+ if (element->separate && element != sculptdata->uv[i].element) {
break;
+ }
l = element->l;
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -529,8 +421,9 @@ static void uv_sculpt_stroke_apply(bContext *C,
MLoopUV *luv;
BMLoop *l;
- if (element->separate && element != sculptdata->uv[uvindex].element)
+ if (element->separate && element != sculptdata->uv[uvindex].element) {
break;
+ }
l = element->l;
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -623,8 +516,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
int island_index = 0;
/* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/
int *uniqueUv;
- data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH) ? UV_SCULPT_TOOL_RELAX :
- ts->uv_sculpt_tool;
+ data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH) ?
+ UV_SCULPT_TOOL_RELAX :
+ ts->uvsculpt->paint.brush->uv_sculpt_tool;
data->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT) ? 1 : 0;
data->uvsculpt = &ts->uvsculpt->paint;
@@ -705,8 +599,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
if (element->separate) {
if (do_island_optimization && (element->island != island_index)) {
/* skip this uv if not on the active island */
- for (; element->next && !(element->next->separate); element = element->next)
+ for (; element->next && !(element->next->separate); element = element->next) {
;
+ }
continue;
}
@@ -734,8 +629,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
char *flag;
/* Skip edge if not found(unlikely) or not on valid island */
- if (itmp1 == -1 || itmp2 == -1)
+ if (itmp1 == -1 || itmp2 == -1) {
continue;
+ }
offset1 = uniqueUv[itmp1];
offset2 = uniqueUv[itmp2];
@@ -902,8 +798,9 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, const wmEvent *ev
uv_sculpt_stroke_apply(C, op, event, obedit);
break;
case TIMER:
- if (event->customdata == data->timer)
+ if (event->customdata == data->timer) {
uv_sculpt_stroke_apply(C, op, event, obedit);
+ }
break;
default:
return OPERATOR_RUNNING_MODAL;
@@ -940,7 +837,7 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
/* api callbacks */
ot->invoke = uv_sculpt_stroke_invoke;
ot->modal = uv_sculpt_stroke_modal;
- ot->poll = uv_sculpt_poll;
+ ot->poll = ED_operator_uvedit_space_image;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 31dfe0bd30a..25c05e2d1d0 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -94,12 +94,14 @@ static int sound_open_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", path);
sound = BKE_sound_new_file(bmain, path);
- if (!op->customdata)
+ if (!op->customdata) {
sound_open_init(C, op);
+ }
if (sound->playback_handle == NULL) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
BKE_id_free(bmain, sound);
BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
return OPERATOR_CANCELLED;
@@ -109,8 +111,9 @@ static int sound_open_exec(bContext *C, wmOperator *op)
if (info.specs.channels == AUD_CHANNELS_INVALID) {
BKE_id_free(bmain, sound);
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
return OPERATOR_CANCELLED;
}
@@ -141,7 +144,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-#else //WITH_AUDASPACE
+#else // WITH_AUDASPACE
static int sound_open_exec(bContext *UNUSED(C), wmOperator *op)
{
@@ -154,8 +157,9 @@ static int sound_open_exec(bContext *UNUSED(C), wmOperator *op)
static int sound_open_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return sound_open_exec(C, op);
+ }
sound_open_init(C, op);
@@ -227,22 +231,28 @@ static int sound_update_animation_flags_cb(Sequence *seq, void *user_data)
bool driven;
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, &driven);
- if (fcu || driven)
+ if (fcu || driven) {
seq->flag |= SEQ_AUDIO_VOLUME_ANIMATED;
- else
+ }
+ else {
seq->flag &= ~SEQ_AUDIO_VOLUME_ANIMATED;
+ }
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pitch", 0, &driven);
- if (fcu || driven)
+ if (fcu || driven) {
seq->flag |= SEQ_AUDIO_PITCH_ANIMATED;
- else
+ }
+ else {
seq->flag &= ~SEQ_AUDIO_PITCH_ANIMATED;
+ }
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pan", 0, &driven);
- if (fcu || driven)
+ if (fcu || driven) {
seq->flag |= SEQ_AUDIO_PAN_ANIMATED;
- else
+ }
+ else {
seq->flag &= ~SEQ_AUDIO_PAN_ANIMATED;
+ }
if (seq->type == SEQ_TYPE_SCENE) {
/* TODO(sergey): For now we do manual recursion into the scene strips,
@@ -271,10 +281,12 @@ static void sound_update_animation_flags(Scene *scene)
SEQ_END;
fcu = id_data_find_fcurve(&scene->id, scene, &RNA_Scene, "audio_volume", 0, &driven);
- if (fcu || driven)
+ if (fcu || driven) {
scene->audio.flag |= AUDIO_VOLUME_ANIMATED;
- else
+ }
+ else {
scene->audio.flag &= ~AUDIO_VOLUME_ANIMATED;
+ }
}
static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op))
@@ -376,7 +388,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
BLI_strncpy(filename, path, sizeof(filename));
BLI_path_abs(filename, BKE_main_blendfile_path(bmain));
- if (split)
+ if (split) {
result = AUD_mixdown_per_channel(scene->sound_scene,
SFRA * specs.rate / FPS,
(EFRA - SFRA + 1) * specs.rate / FPS,
@@ -386,7 +398,8 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
container,
codec,
bitrate);
- else
+ }
+ else {
result = AUD_mixdown(scene->sound_scene,
SFRA * specs.rate / FPS,
(EFRA - SFRA + 1) * specs.rate / FPS,
@@ -396,6 +409,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
container,
codec,
bitrate);
+ }
BKE_sound_reset_scene_specs(scene);
@@ -468,13 +482,16 @@ static bool sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
prop = RNA_struct_find_property(op->ptr, "filepath");
RNA_property_string_get(op->ptr, prop, filepath);
- if (BLI_path_extension_check_array(filepath, snd_ext_sound))
+ if (BLI_path_extension_check_array(filepath, snd_ext_sound)) {
check = BLI_path_extension_replace(filepath, FILE_MAX, extension);
- else
+ }
+ else {
check = BLI_path_extension_ensure(filepath, FILE_MAX, extension);
+ }
- if (!check)
+ if (!check) {
return check;
+ }
RNA_property_string_set(op->ptr, prop, filepath);
return true;
@@ -487,8 +504,9 @@ static bool sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
static int sound_mixdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return sound_mixdown_exec(C, op);
+ }
return WM_operator_filesel(C, op, event);
}
@@ -738,8 +756,9 @@ static bool sound_poll(bContext *C)
{
Editing *ed = CTX_data_scene(C)->ed;
- if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM)
+ if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM) {
return 0;
+ }
return 1;
}
@@ -751,13 +770,15 @@ static int sound_pack_exec(bContext *C, wmOperator *op)
Editing *ed = CTX_data_scene(C)->ed;
bSound *sound;
- if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM)
+ if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM) {
return OPERATOR_CANCELLED;
+ }
sound = ed->act_seq->sound;
- if (!sound || sound->packedfile)
+ if (!sound || sound->packedfile) {
return OPERATOR_CANCELLED;
+ }
sound->packedfile = newPackedFile(op->reports, sound->name, ID_BLEND_PATH(bmain, &sound->id));
BKE_sound_load(bmain, sound);
@@ -795,13 +816,15 @@ static int sound_unpack_exec(bContext *C, wmOperator *op)
sound = BLI_findstring(&bmain->sounds, sndname, offsetof(ID, name) + 2);
}
- if (!sound || !sound->packedfile)
+ if (!sound || !sound->packedfile) {
return OPERATOR_CANCELLED;
+ }
- if (G.fileflags & G_FILE_AUTOPACK)
+ if (G.fileflags & G_FILE_AUTOPACK) {
BKE_report(op->reports,
RPT_WARNING,
"AutoPack is enabled, so image will be packed again on file save");
+ }
unpackSound(bmain, op->reports, sound, method);
@@ -813,21 +836,25 @@ static int sound_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
Editing *ed = CTX_data_scene(C)->ed;
bSound *sound;
- if (RNA_struct_property_is_set(op->ptr, "id"))
+ if (RNA_struct_property_is_set(op->ptr, "id")) {
return sound_unpack_exec(C, op);
+ }
- if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM)
+ if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM) {
return OPERATOR_CANCELLED;
+ }
sound = ed->act_seq->sound;
- if (!sound || !sound->packedfile)
+ if (!sound || !sound->packedfile) {
return OPERATOR_CANCELLED;
+ }
- if (G.fileflags & G_FILE_AUTOPACK)
+ if (G.fileflags & G_FILE_AUTOPACK) {
BKE_report(op->reports,
RPT_WARNING,
"AutoPack is enabled, so image will be packed again on file save");
+ }
unpack_menu(C, "SOUND_OT_unpack", sound->id.name + 2, sound->name, "sounds", sound->packedfile);
diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt
index 5251ebb1267..6c43f8b9549 100644
--- a/source/blender/editors/space_action/CMakeLists.txt
+++ b/source/blender/editors/space_action/CMakeLists.txt
@@ -24,8 +24,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_action/action_buttons.c b/source/blender/editors/space_action/action_buttons.c
index a30d5f34ed0..c9c20adcab4 100644
--- a/source/blender/editors/space_action/action_buttons.c
+++ b/source/blender/editors/space_action/action_buttons.c
@@ -92,27 +92,3 @@ void action_buttons_register(ARegionType *UNUSED(art))
BLI_addtail(&art->paneltypes, pt);
#endif
}
-
-static int action_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = action_has_buttons_region(sa);
-
- if (ar)
- ED_region_toggle_hidden(C, ar);
-
- return OPERATOR_FINISHED;
-}
-
-void ACTION_OT_properties(wmOperatorType *ot)
-{
- ot->name = "Toggle Sidebar";
- ot->idname = "ACTION_OT_properties";
- ot->description = "Toggle the properties region visibility";
-
- ot->exec = action_properties_toggle_exec;
- ot->poll = ED_operator_action_active;
-
- /* flags */
- ot->flag = 0;
-}
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index e9670a0048d..db504272d2f 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -127,10 +127,12 @@ static bAction *action_create_new(bContext *C, bAction *oldact)
if (sa->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
- if (saction->mode == SACTCONT_SHAPEKEY)
+ if (saction->mode == SACTCONT_SHAPEKEY) {
action->idroot = ID_KE;
- else
+ }
+ else {
action->idroot = ID_OB;
+ }
}
return action;
@@ -170,7 +172,8 @@ static bool action_new_poll(bContext *C)
Scene *scene = CTX_data_scene(C);
/* Check tweakmode is off (as you don't want to be tampering with the action in that case) */
- /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */
+ /* NOTE: unlike for pushdown,
+ * this operator needs to be run when creating an action from nothing... */
if (ED_operator_action_active(C)) {
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
Object *ob = CTX_data_active_object(C);
@@ -179,15 +182,17 @@ static bool action_new_poll(bContext *C)
if (saction->mode == SACTCONT_ACTION) {
/* XXX: This assumes that actions are assigned to the active object in this mode */
if (ob) {
- if ((ob->adt == NULL) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0)
+ if ((ob->adt == NULL) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0) {
return true;
+ }
}
}
else if (saction->mode == SACTCONT_SHAPEKEY) {
Key *key = BKE_key_from_object(ob);
if (key) {
- if ((key->adt == NULL) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0)
+ if ((key->adt == NULL) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0) {
return true;
+ }
}
}
}
@@ -242,7 +247,10 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
}
}
else {
- //printf("WARNING: Failed to stash %s. It may already exist in the NLA stack though\n", oldact->id.name);
+#if 0
+ printf("WARNING: Failed to stash %s. It may already exist in the NLA stack though\n",
+ oldact->id.name);
+#endif
}
}
@@ -296,8 +304,9 @@ static bool action_pushdown_poll(bContext *C)
/* NOTE: We check this for the AnimData block in question and not the global flag,
* as the global flag may be left dirty by some of the browsing ops here.
*/
- if (!(adt->flag & ADT_NLA_EDIT_ON))
+ if (!(adt->flag & ADT_NLA_EDIT_ON)) {
return true;
+ }
}
}
@@ -425,10 +434,12 @@ static bool action_stash_create_poll(bContext *C)
AnimData *adt = ED_actedit_animdata_from_context(C);
/* Check tweakmode is off (as you don't want to be tampering with the action in that case) */
- /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */
+ /* NOTE: unlike for pushdown,
+ * this operator needs to be run when creating an action from nothing... */
if (adt) {
- if (!(adt->flag & ADT_NLA_EDIT_ON))
+ if (!(adt->flag & ADT_NLA_EDIT_ON)) {
return true;
+ }
}
else {
/* There may not be any action/animdata yet, so, just fallback to the global setting
@@ -472,7 +483,8 @@ static int action_stash_create_exec(bContext *C, wmOperator *op)
if (BKE_nla_action_stash(adt)) {
bAction *new_action = NULL;
- /* create new action not based on the old one (since the "new" operator already does that) */
+ /* Create new action not based on the old one
+ * (since the "new" operator already does that). */
new_action = action_create_new(C, NULL);
/* The stash operation will remove the user already,
@@ -622,8 +634,9 @@ static bool action_unlink_poll(bContext *C)
AnimData *adt = ED_actedit_animdata_from_context(C);
/* Only when there's an active action, in the right modes... */
- if (saction->action && adt)
+ if (saction->action && adt) {
return true;
+ }
}
/* something failed... */
@@ -644,7 +657,8 @@ static int action_unlink_exec(bContext *C, wmOperator *op)
static int action_unlink_invoke(bContext *C, wmOperator *op, const wmEvent *evt)
{
- /* NOTE: this is hardcoded to match the behavior for the unlink button (in interface_templates.c) */
+ /* NOTE: this is hardcoded to match the behavior for the unlink button
+ * (in interface_templates.c). */
RNA_boolean_set(op->ptr, "force_delete", evt->shift != 0);
return action_unlink_exec(C, op);
}
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index b2baace1592..9827967f947 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -210,8 +210,9 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* determine if any need to draw channel */
if (ale->datatype != ALE_NONE) {
/* determine if channel is selected */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) {
sel = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT);
+ }
if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) {
switch (ale->type) {
@@ -271,9 +272,9 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
}
else if (ac->datatype == ANIMCONT_GPENCIL) {
unsigned char *color;
+ unsigned char gpl_col[4];
if ((show_group_colors) && (ale->type == ANIMTYPE_GPLAYER)) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
- unsigned char gpl_col[4];
rgb_float_to_uchar(gpl_col, gpl->color);
gpl_col[3] = col1[3];
@@ -407,8 +408,9 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
float yoffs = 0.f;
- if (!(saction->cache_display & TIME_CACHE_DISPLAY) || (!ob))
+ if (!(saction->cache_display & TIME_CACHE_DISPLAY) || (!ob)) {
return;
+ }
BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
@@ -421,34 +423,41 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
- if (!(saction->cache_display & TIME_CACHE_SOFTBODY))
+ if (!(saction->cache_display & TIME_CACHE_SOFTBODY)) {
continue;
+ }
break;
case PTCACHE_TYPE_PARTICLES:
- if (!(saction->cache_display & TIME_CACHE_PARTICLES))
+ if (!(saction->cache_display & TIME_CACHE_PARTICLES)) {
continue;
+ }
break;
case PTCACHE_TYPE_CLOTH:
- if (!(saction->cache_display & TIME_CACHE_CLOTH))
+ if (!(saction->cache_display & TIME_CACHE_CLOTH)) {
continue;
+ }
break;
case PTCACHE_TYPE_SMOKE_DOMAIN:
case PTCACHE_TYPE_SMOKE_HIGHRES:
- if (!(saction->cache_display & TIME_CACHE_SMOKE))
+ if (!(saction->cache_display & TIME_CACHE_SMOKE)) {
continue;
+ }
break;
case PTCACHE_TYPE_DYNAMICPAINT:
- if (!(saction->cache_display & TIME_CACHE_DYNAMICPAINT))
+ if (!(saction->cache_display & TIME_CACHE_DYNAMICPAINT)) {
continue;
+ }
break;
case PTCACHE_TYPE_RIGIDBODY:
- if (!(saction->cache_display & TIME_CACHE_RIGIDBODY))
+ if (!(saction->cache_display & TIME_CACHE_RIGIDBODY)) {
continue;
+ }
break;
}
- if (pid->cache->cached_frames == NULL)
+ if (pid->cache->cached_frames == NULL) {
continue;
+ }
GPU_matrix_push();
GPU_matrix_translate_2f(0.0, (float)V2D_SCROLL_HEIGHT_TEXT + yoffs);
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 9ce709e1134..8df773e98d6 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -86,18 +86,22 @@ static bool act_markers_make_local_poll(bContext *C)
SpaceAction *sact = CTX_wm_space_action(C);
/* 1) */
- if (sact == NULL)
+ if (sact == NULL) {
return 0;
+ }
/* 2) */
- if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0)
+ if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0) {
return 0;
- if (sact->action == NULL)
+ }
+ if (sact->action == NULL) {
return 0;
+ }
/* 3) */
- if (sact->flag & SACTION_POSEMARKERS_SHOW)
+ if (sact->flag & SACTION_POSEMARKERS_SHOW) {
return 0;
+ }
/* 4) */
return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL;
@@ -113,8 +117,9 @@ static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
TimeMarker *marker, *markern = NULL;
/* sanity checks */
- if (ELEM(NULL, markers, act))
+ if (ELEM(NULL, markers, act)) {
return OPERATOR_CANCELLED;
+ }
/* migrate markers */
for (marker = markers->first; marker; marker = markern) {
@@ -127,7 +132,8 @@ static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- /* now enable the "show posemarkers only" setting, so that we can see that something did happen */
+ /* Now enable the "show posemarkers only" setting,
+ * so that we can see that something did happen */
sact->flag |= SACTION_POSEMARKERS_SHOW;
/* notifiers - both sets, as this change affects both */
@@ -219,7 +225,8 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
tmax = BKE_nla_tweakedit_remap(adt, tmax, NLATIME_CONVERT_MAP);
}
- /* try to set cur using these values, if they're more extreme than previously set values */
+ /* Try to set cur using these values,
+ * if they're more extreme than previously set values. */
*min = min_ff(*min, tmin);
*max = max_ff(*max, tmax);
found = true;
@@ -259,12 +266,15 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
float min, max;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
- if (ac.scene == NULL)
+ }
+ if (ac.scene == NULL) {
return OPERATOR_CANCELLED;
- else
+ }
+ else {
scene = ac.scene;
+ }
/* set the range directly */
get_keyframe_extents(&ac, &min, &max, false);
@@ -363,15 +373,17 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
bool found;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
v2d = &ac.ar->v2d;
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
found = get_keyframe_extents(&ac, &min, &max, only_sel);
- if (only_sel && (found == false))
+ if (only_sel && (found == false)) {
return OPERATOR_CANCELLED;
+ }
if (fabsf(max - min) < 1.0f) {
/* Exception - center the single keyfrme */
@@ -392,7 +404,8 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
/* set vertical range */
if (only_sel == false) {
- /* view all -> the summary channel is usually the shows everything, and resides right at the top... */
+ /* view all -> the summary channel is usually the shows everything,
+ * and resides right at the top... */
v2d->cur.ymax = 0.0f;
v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
}
@@ -556,8 +569,9 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* copy keyframes */
if (ac.datatype == ANIMCONT_GPENCIL) {
@@ -605,8 +619,9 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* ac.reports by default will be the global reports list, which won't show warnings */
ac.reports = op->reports;
@@ -680,7 +695,8 @@ void ACTION_OT_paste(wmOperatorType *ot)
static const EnumPropertyItem prop_actkeys_insertkey_types[] = {
{1, "ALL", 0, "All Channels", ""},
{2, "SEL", 0, "Only Selected Channels", ""},
- {3, "GROUP", 0, "In Active Group", ""}, /* XXX not in all cases */
+ /* XXX not in all cases. */
+ {3, "GROUP", 0, "In Active Group", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -718,11 +734,14 @@ static void insert_action_keys(bAnimContext *ac, short mode)
FCurve *fcu = (FCurve *)ale->key_data;
float cfra = (float)CFRA;
- /* read value from property the F-Curve represents, or from the curve only?
- * - ale->id != NULL: Typically, this means that we have enough info to try resolving the path
- * - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone,
- * so it's easier for now to just read the F-Curve directly.
- * (TODO: add the full-blown PointerRNA relative parsing case here...)
+ /* Read value from property the F-Curve represents, or from the curve only?
+ * - ale->id != NULL:
+ * Typically, this means that we have enough info to try resolving the path.
+ *
+ * - ale->owner != NULL:
+ * If this is set, then the path may not be resolvable from the ID alone,
+ * so it's easier for now to just read the F-Curve directly.
+ * (TODO: add the full-blown PointerRNA relative parsing case here...)
*/
if (ale->id && !ale->owner) {
insert_keyframe(ac->bmain,
@@ -742,8 +761,9 @@ static void insert_action_keys(bAnimContext *ac, short mode)
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* adjust current frame for NLA-scaling */
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
+ }
const float curval = evaluate_fcurve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
@@ -772,16 +792,19 @@ static void insert_gpencil_keys(bAnimContext *ac, short mode)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
- if (mode == 2)
+ if (mode == 2) {
filter |= ANIMFILTER_SEL;
+ }
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* add a copy or a blank frame? */
- if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST)
+ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
add_frame_mode = GP_GETFRAME_ADD_COPY; /* XXX: actframe may not be what we want? */
- else
+ }
+ else {
add_frame_mode = GP_GETFRAME_ADD_NEW;
+ }
/* insert gp frames */
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -801,8 +824,9 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ac.datatype == ANIMCONT_MASK) {
BKE_report(op->reports, RPT_ERROR, "Insert Keyframes is not yet implemented for this mode");
@@ -866,14 +890,18 @@ static void duplicate_action_keys(bAnimContext *ac)
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
- if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
+ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
duplicate_fcurve_keys((FCurve *)ale->key_data);
- else if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ else if (ale->type == ANIMTYPE_GPLAYER) {
ED_gplayer_frames_duplicate((bGPDlayer *)ale->data);
- else if (ale->type == ANIMTYPE_MASKLAYER)
+ }
+ else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_masklayer_frames_duplicate((MaskLayer *)ale->data);
- else
+ }
+ else {
BLI_assert(0);
+ }
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -889,8 +917,9 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* duplicate keyframes */
duplicate_action_keys(&ac);
@@ -980,12 +1009,14 @@ static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* delete keyframes */
- if (!delete_action_keys(&ac))
+ if (!delete_action_keys(&ac)) {
return OPERATOR_CANCELLED;
+ }
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
@@ -1042,8 +1073,9 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op)
bool clean_chan;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1071,7 +1103,7 @@ void ACTION_OT_clean(wmOperatorType *ot)
ot->description = "Simplify F-Curves by removing closely spaced keyframes";
/* api callbacks */
- //ot->invoke = // XXX we need that number popup for this!
+ // ot->invoke = // XXX we need that number popup for this!
ot->exec = actkeys_clean_exec;
ot->poll = ED_operator_action_active;
@@ -1116,8 +1148,9 @@ static int actkeys_sample_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1221,8 +1254,9 @@ static void setexpo_action_keys(bAnimContext *ac, short mode)
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
fcn = fcm->next;
- if (fcm->type == FMODIFIER_TYPE_CYCLES)
+ if (fcm->type == FMODIFIER_TYPE_CYCLES) {
remove_fmodifier(&fcu->modifiers, fcm);
+ }
}
}
}
@@ -1242,8 +1276,9 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1296,8 +1331,9 @@ static void setipo_action_keys(bAnimContext *ac, short mode)
ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* loop through setting BezTriple interpolation
- * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
+ /* Loop through setting BezTriple interpolation
+ * Note: we do not supply KeyframeEditData to the looper yet.
+ * Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve);
@@ -1317,8 +1353,9 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1375,8 +1412,9 @@ static void sethandles_action_keys(bAnimContext *ac, short mode)
ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* loop through setting flags for handles
- * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
+ /* Loop through setting flags for handles
+ * Note: we do not supply KeyframeEditData to the looper yet.
+ * Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
@@ -1402,8 +1440,9 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1456,8 +1495,9 @@ static void setkeytype_action_keys(bAnimContext *ac, short mode)
ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* loop through setting BezTriple interpolation
- * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
+ /* Loop through setting BezTriple interpolation
+ * Note: we do not supply KeyframeEditData to the looper yet.
+ * Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, NULL);
@@ -1501,8 +1541,9 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ac.datatype == ANIMCONT_MASK) {
BKE_report(op->reports, RPT_ERROR, "Not implemented for Masks");
@@ -1553,8 +1594,9 @@ void ACTION_OT_keyframe_type(wmOperatorType *ot)
static bool actkeys_framejump_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return ED_operator_action_active(C);
}
@@ -1569,8 +1611,9 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditData ked = {{NULL}};
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* init edit data */
/* loop over action data, averaging values */
@@ -1585,8 +1628,9 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
+ }
}
ANIM_animdata_freelist(&anim_data);
@@ -1710,8 +1754,9 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get snapping mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1786,10 +1831,12 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
if (mode == ACTKEYS_MIRROR_MARKER) {
TimeMarker *marker = ED_markers_get_first_selected(ac->markers);
- if (marker)
+ if (marker) {
ked.f1 = (float)marker->frame;
- else
+ }
+ else {
return;
+ }
}
/* filter data */
@@ -1837,8 +1884,9 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get mirroring mode */
mode = RNA_enum_get(op->ptr, "type");
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index 5d86cf6faec..eaca7968a34 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -40,10 +40,7 @@ struct wmOperatorType;
/* **************************************** */
/* space_action.c / action_buttons.c */
-struct ARegion *action_has_buttons_region(struct ScrArea *sa);
-
void action_buttons_register(struct ARegionType *art);
-void ACTION_OT_properties(struct wmOperatorType *ot);
/* ***************************************** */
/* action_draw.c */
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index d5ddf974284..cba86ac5131 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -43,9 +43,6 @@
void action_operatortypes(void)
{
- /* view */
- WM_operatortype_append(ACTION_OT_properties);
-
/* keyframes */
/* selection */
WM_operatortype_append(ACTION_OT_clickselect);
@@ -105,7 +102,7 @@ void ED_operatormacros_action(void)
WM_operatortype_macro_define(ot, "ACTION_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform");
RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE);
- RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
/* ************************** registration - keymaps **********************************/
@@ -118,8 +115,10 @@ void action_keymap(wmKeyConfig *keyconf)
WM_keymap_ensure(keyconf, "Dopesheet Generic", SPACE_ACTION, 0);
/* channels */
- /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module.
- * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these
+ /* Channels are not directly handled by the Action Editor module,
+ * but are inherited from the Animation module.
+ * All the relevant operations, keymaps, drawing, etc.
+ * can therefore all be found in that module instead, as these
* are all used for the Graph-Editor too.
*/
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 7499458181e..1614e1c432d 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -155,8 +155,9 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* 'standard' behavior - check if selected, then apply relevant selection */
const int action = RNA_enum_get(op->ptr, "action");
@@ -203,11 +204,13 @@ void ACTION_OT_select_all(wmOperatorType *ot)
}
/* ******************** Box Select Operator **************************** */
-/* This operator currently works in one of three ways:
- * -> BKEY - 1) all keyframes within region are selected (ACTKEYS_BORDERSEL_ALLKEYS)
- * -> ALT-BKEY - depending on which axis of the region was larger...
- * -> 2) x-axis, so select all frames within frame range (ACTKEYS_BORDERSEL_FRAMERANGE)
- * -> 3) y-axis, so select all frames within channels that region included (ACTKEYS_BORDERSEL_CHANNELS)
+/**
+ * This operator currently works in one of three ways:
+ * - BKEY - 1) all keyframes within region are selected #ACTKEYS_BORDERSEL_ALLKEYS.
+ * - ALT-BKEY - depending on which axis of the region was larger...
+ * - 2) x-axis, so select all frames within frame range #ACTKEYS_BORDERSEL_FRAMERANGE.
+ * - 3) y-axis, so select all frames within channels that region included
+ * #ACTKEYS_BORDERSEL_CHANNELS.
*/
/* defines for box_select mode */
@@ -229,7 +232,8 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
rctf rectf;
float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac));
- /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
+ /* Convert mouse coordinates to frame ranges and channel
+ * coordinates corrected for view pan/zoom. */
UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin);
UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax);
@@ -240,10 +244,12 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
/* get beztriple editing/validation funcs */
select_cb = ANIM_editkeyframes_select(selectmode);
- if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS))
+ if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) {
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
- else
+ }
+ else {
ok_cb = NULL;
+ }
/* init editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
@@ -275,8 +281,7 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
/* loop over data selecting */
switch (ale->type) {
#if 0 /* XXX: Keyframes are not currently shown here */
- case ANIMTYPE_GPDATABLOCK:
- {
+ case ANIMTYPE_GPDATABLOCK: {
bGPdata *gpd = ale->data;
bGPDlayer *gpl;
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -343,18 +348,23 @@ static int actkeys_box_select_exec(bContext *C, wmOperator *op)
/* selection 'mode' depends on whether box_select region only matters on one axis */
if (RNA_boolean_get(op->ptr, "axis_range")) {
- /* mode depends on which axis of the range is larger to determine which axis to use
- * - checking this in region-space is fine, as it's fundamentally still going to be a different rect size
- * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
- * used for tweaking timing when "blocking", while channels is not that useful...
+ /* Mode depends on which axis of the range is larger to determine which axis to use:
+ * - checking this in region-space is fine,
+ * as it's fundamentally still going to be a different rect size.
+ * - the frame-range select option is favored over the channel one (x over y),
+ * as frame-range one is often used for tweaking timing when "blocking",
+ * while channels is not that useful...
*/
- if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect))
+ if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect)) {
mode = ACTKEYS_BORDERSEL_FRAMERANGE;
- else
+ }
+ else {
mode = ACTKEYS_BORDERSEL_CHANNELS;
+ }
}
- else
+ else {
mode = ACTKEYS_BORDERSEL_ALLKEYS;
+ }
/* apply box_select action */
box_select_action(&ac, rect, mode, selectmode);
@@ -410,7 +420,8 @@ static void region_select_action_keys(
rctf rectf, scaled_rectf;
float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac));
- /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
+ /* Convert mouse coordinates to frame ranges and channel
+ * coordinates corrected for view pan/zoom. */
UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf);
/* filter data */
@@ -478,8 +489,7 @@ static void region_select_action_keys(
/* loop over data selecting */
switch (ale->type) {
#if 0 /* XXX: Keyframes are not currently shown here */
- case ANIMTYPE_GPDATABLOCK:
- {
+ case ANIMTYPE_GPDATABLOCK: {
bGPdata *gpd = ale->data;
bGPDlayer *gpl;
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -531,13 +541,15 @@ static int actkeys_lassoselect_exec(bContext *C, wmOperator *op)
rctf rect_fl;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
data_lasso.rectf_view = &rect_fl;
data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot);
- if (data_lasso.mcords == NULL)
+ if (data_lasso.mcords == NULL) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
@@ -596,8 +608,9 @@ static int action_circle_select_exec(bContext *C, wmOperator *op)
float radius = RNA_int_get(op->ptr, "radius");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
@@ -743,15 +756,17 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
ED_gplayer_make_cfra_list(ale->data, &ked.list, 1);
+ }
}
else {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL);
+ }
}
ANIM_animdata_freelist(&anim_data);
break;
@@ -779,10 +794,12 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
/* loop through all of the keys and select additional keyframes
* based on the keys found to be selected above
*/
- if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
+ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
- else
+ }
+ else {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/);
+ }
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -793,10 +810,12 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
*/
for (ce = ked.list.first; ce; ce = ce->next) {
/* set frame for validation callback to refer to */
- if (adt)
+ if (adt) {
ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
ked.f1 = ce->cfra;
+ }
/* select elements with frame number matching cfraelem */
if (ale->type == ANIMTYPE_GPLAYER) {
@@ -827,16 +846,19 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* action to take depends on the mode */
mode = RNA_enum_get(op->ptr, "mode");
- if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN)
+ if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN) {
markers_selectkeys_between(&ac);
- else
+ }
+ else {
columnselect_action_keys(&ac, mode);
+ }
/* set notifier that keyframe selection have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
@@ -876,8 +898,9 @@ static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD);
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ |
@@ -942,8 +965,9 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode)
FCurve *fcu = (FCurve *)ale->key_data;
/* only continue if F-Curve has keyframes */
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
/* build up map of whether F-Curve's keyframes should be selected or not */
ked.data = MEM_callocN(fcu->totvert, "selmap actEdit more");
@@ -968,8 +992,9 @@ static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform select changes */
select_moreless_action_keys(&ac, SELMAP_MORE);
@@ -1002,8 +1027,9 @@ static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform select changes */
select_moreless_action_keys(&ac, SELMAP_LESS);
@@ -1140,18 +1166,22 @@ static int actkeys_select_leftright_exec(bContext *C, wmOperator *op)
short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* if "test" mode is set, we don't have any info to set this with */
- if (leftright == ACTKEYS_LRSEL_TEST)
+ if (leftright == ACTKEYS_LRSEL_TEST) {
return OPERATOR_CANCELLED;
+ }
/* do the selecting now */
actkeys_select_leftright(&ac, leftright, selectmode);
@@ -1169,8 +1199,9 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm
short leftright = RNA_enum_get(op->ptr, "mode");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* handle mode-based testing */
if (leftright == ACTKEYS_LRSEL_TEST) {
@@ -1181,10 +1212,12 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm
/* determine which side of the current frame mouse is on */
x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
- if (x < CFRA)
+ if (x < CFRA) {
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT);
- else
+ }
+ else {
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
+ }
}
/* perform selection */
@@ -1316,10 +1349,12 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* set frame for validation callback to refer to */
- if (adt)
+ if (adt) {
ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
ked.f1 = selx;
+ }
/* select elements with frame number matching cfra */
if (ale->type == ANIMTYPE_GPLAYER) {
@@ -1388,8 +1423,12 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s
/* ------------------- */
-static void mouse_action_keys(
- bAnimContext *ac, const int mval[2], short select_mode, bool column, bool same_channel)
+static void mouse_action_keys(bAnimContext *ac,
+ const int mval[2],
+ short select_mode,
+ const bool deselect_all,
+ const bool column,
+ const bool same_channel)
{
ListBase anim_data = {NULL, NULL};
DLRBT_Tree anim_keys;
@@ -1407,16 +1446,17 @@ static void mouse_action_keys(
rctf rectf;
/* get dopesheet info */
- if (ELEM(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE))
+ if (ELEM(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) {
ads = ac->data;
+ }
/* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
UI_view2d_listview_view_to_cell(
v2d, 0, ACHANNEL_STEP(ac), 0, (float)ACHANNEL_HEIGHT_HALF(ac), x, y, NULL, &channel_index);
- /* x-range to check is +/- 7px for standard keyframe under standard dpi/y-scale (in screen/region-space),
- * on either side of mouse click (size of keyframe icon)
+ /* x-range to check is +/- 7px for standard keyframe under standard dpi/y-scale
+ * (in screen/region-space), on either side of mouse click (size of keyframe icon).
*/
/* standard channel height (to allow for some slop) */
@@ -1433,14 +1473,7 @@ static void mouse_action_keys(
/* try to get channel */
ale = BLI_findlink(&anim_data, channel_index);
- if (ale == NULL) {
- /* channel not found */
- printf("Error: animation channel (index = %d) not found in mouse_action_keys()\n",
- channel_index);
- ANIM_animdata_freelist(&anim_data);
- return;
- }
- else {
+ if (ale != NULL) {
/* found match - must return here... */
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
ActKeyColumn *ak, *akn = NULL;
@@ -1505,25 +1538,30 @@ static void mouse_action_keys(
found = true;
break;
}
- else if (ak->cfra < rectf.xmin)
+ else if (ak->cfra < rectf.xmin) {
akn = ak->right;
- else
+ }
+ else {
akn = ak->left;
+ }
}
- /* remove active channel from list of channels for separate treatment (since it's needed later on) */
+ /* Remove active channel from list of channels for separate treatment
+ * (since it's needed later on). */
BLI_remlink(&anim_data, ale);
ale->next = ale->prev = NULL;
/* cleanup temporary lists */
BLI_dlrbTree_free(&anim_keys);
-
- /* free list of channels, since it's not used anymore */
- ANIM_animdata_freelist(&anim_data);
}
- /* for replacing selection, firstly need to clear existing selection */
- if (select_mode == SELECT_REPLACE) {
+ /* free list of channels, since it's not used anymore */
+ ANIM_animdata_freelist(&anim_data);
+
+ /* For replacing selection, if we have something to select, we have to clear existing selection.
+ * The same goes if we found nothing to select, and deselect_all is true
+ * (deselect on nothing behavior). */
+ if ((select_mode == SELECT_REPLACE && found) || (!found && deselect_all)) {
/* reset selection mode for next steps */
select_mode = SELECT_ADD;
@@ -1536,7 +1574,7 @@ static void mouse_action_keys(
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
/* Highlight Action-Group or F-Curve? */
- if (ale && ale->data) {
+ if (ale != NULL && ale->data) {
if (ale->type == ANIMTYPE_GROUP) {
bActionGroup *agrp = ale->data;
@@ -1556,11 +1594,11 @@ static void mouse_action_keys(
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
/* Highlight GPencil Layer */
- if ((ale && ale->data) && (ale->type == ANIMTYPE_GPLAYER)) {
+ if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_GPLAYER) {
bGPDlayer *gpl = ale->data;
gpl->flag |= GP_LAYER_SELECT;
- //gpencil_layer_setactive(gpd, gpl);
+ // gpencil_layer_setactive(gpd, gpl);
}
}
else if (ac->datatype == ANIMCONT_MASK) {
@@ -1568,17 +1606,17 @@ static void mouse_action_keys(
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
/* Highlight GPencil Layer */
- if ((ale && ale->data) && (ale->type == ANIMTYPE_MASKLAYER)) {
+ if (ale != NULL && ale->data != NULL && ale->type == ANIMTYPE_MASKLAYER) {
MaskLayer *masklay = ale->data;
masklay->flag |= MASK_LAYERFLAG_SELECT;
- //gpencil_layer_setactive(gpd, gpl);
+ // gpencil_layer_setactive(gpd, gpl);
}
}
}
/* only select keyframes if we clicked on a valid channel and hit something */
- if (ale) {
+ if (ale != NULL) {
if (found) {
/* apply selection to keyframes */
if (column) {
@@ -1613,29 +1651,25 @@ static void mouse_action_keys(
static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
- /* ARegion *ar; */ /* UNUSED */
- short selectmode;
- bool column, channel;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get useful pointers from animation context data */
/* ar = ac.ar; */ /* UNUSED */
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
- selectmode = SELECT_INVERT;
- else
- selectmode = SELECT_REPLACE;
+ const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE;
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
/* column selection */
- column = RNA_boolean_get(op->ptr, "column");
- channel = RNA_boolean_get(op->ptr, "channel");
+ const bool column = RNA_boolean_get(op->ptr, "column");
+ const bool channel = RNA_boolean_get(op->ptr, "channel");
/* select keyframe(s) based upon mouse position*/
- mouse_action_keys(&ac, event->mval, selectmode, column, channel);
+ mouse_action_keys(&ac, event->mval, selectmode, deselect_all, column, channel);
/* set notifier that keyframe selection (and channels too) have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
@@ -1670,6 +1704,13 @@ void ACTION_OT_clickselect(wmOperatorType *ot)
"Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
prop = RNA_def_boolean(
ot->srna,
"column",
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index bfbca07d530..843abbd16db 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -56,34 +56,6 @@
#include "action_intern.h" /* own include */
#include "GPU_framebuffer.h"
-/* ******************** manage regions ********************* */
-
-ARegion *action_has_buttons_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar)
- return ar;
-
- /* add subdiv level; after main */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-
- /* is error! */
- if (ar == NULL)
- return NULL;
-
- arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
/* ******************** default callbacks for action space ***************** */
static SpaceLink *action_new(const ScrArea *sa, const Scene *scene)
@@ -194,7 +166,7 @@ static void action_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -207,11 +179,9 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
Object *obact = CTX_data_active_object(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
View2DScrollers *scrollers;
short marker_flag = 0;
short cfra_flag = 0;
- short unit = 0;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -220,17 +190,7 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* time grid */
- unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
- grid = UI_view2d_grid_calc(CTX_data_scene(C),
- v2d,
- unit,
- V2D_GRID_CLAMP,
- V2D_ARG_DUMMY,
- V2D_ARG_DUMMY,
- ar->winx,
- ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
- UI_view2d_grid_free(grid);
+ UI_view2d_draw_lines_x__discrete_frames_or_seconds(v2d, scene, saction->flag & SACTION_DRAWTIME);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -243,8 +203,9 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
}
/* current frame */
- if (saction->flag & SACTION_DRAWTIME)
+ if (saction->flag & SACTION_DRAWTIME) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
/* markers */
@@ -252,8 +213,9 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
marker_flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) |
DRAW_MARKERS_MARGIN;
- if (saction->flag & SACTION_SHOW_MARKER_LINES)
+ if (saction->flag & SACTION_SHOW_MARKER_LINES) {
marker_flag |= DRAW_MARKERS_LINES;
+ }
ED_markers_draw(C, marker_flag);
/* caches */
@@ -273,11 +235,14 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* frame numbers */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, saction->flag & SACTION_DRAWTIME);
+
/* draw current frame number-indicator on top of scrollers */
if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -297,7 +262,7 @@ static void action_channel_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
@@ -364,22 +329,26 @@ static void action_channel_region_listener(wmWindow *UNUSED(win),
ED_region_tag_redraw(ar);
break;
case ND_MODIFIER:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
}
break;
case NC_GPENCIL:
- if (ELEM(wmn->action, NA_RENAME, NA_SELECTED))
+ if (ELEM(wmn->action, NA_RENAME, NA_SELECTED)) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -471,8 +440,9 @@ static void action_main_region_listener(wmWindow *UNUSED(win),
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCREEN:
if (ELEM(wmn->data, ND_LAYER)) {
@@ -480,8 +450,9 @@ static void action_main_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -607,8 +578,8 @@ static void action_listener(wmWindow *UNUSED(win),
break;
case NC_OBJECT:
switch (wmn->data) {
- case ND_BONE_SELECT: /* selection changed, so force refresh to flush
- * (needs flag set to do syncing) */
+ case ND_BONE_SELECT: /* Selection changed, so force refresh to flush
+ * (needs flag set to do syncing). */
case ND_BONE_ACTIVE:
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
@@ -689,8 +660,9 @@ static void action_header_region_listener(
switch (wmn->category) {
case NC_SCREEN:
if (saction->mode == SACTCONT_TIMELINE) {
- if (wmn->data == ND_ANIMPLAY)
+ if (wmn->data == ND_ANIMPLAY) {
ED_region_tag_redraw(ar);
+ }
}
break;
case NC_SCENE:
@@ -715,8 +687,9 @@ static void action_header_region_listener(
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_ANIMATION:
switch (wmn->data) {
@@ -728,7 +701,7 @@ static void action_header_region_listener(
break;
case ND_KEYFRAME: /* new keyframed added -> active action may have changed */
- //saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
+ // saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_region_tag_redraw(ar);
break;
}
@@ -782,8 +755,9 @@ static void action_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -792,15 +766,15 @@ static void action_refresh(const bContext *C, ScrArea *sa)
{
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
- /* update the state of the animchannels in response to changes from the data they represent
- * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
- */
+ /* Update the state of the animchannels in response to changes from the data they represent
+ * NOTE: the temp flag is used to indicate when this needs to be done,
+ * and will be cleared once handled. */
if (saction->runtime.flag & SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC) {
ARegion *ar;
/* Perform syncing of channel state incl. selection
- * Active action setting also occurs here (as part of anim channel filtering in anim_filter.c)
- */
+ * Active action setting also occurs here
+ * (as part of anim channel filtering in anim_filter.c). */
ANIM_sync_animchannels_to_data(C);
saction->runtime.flag &= ~SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
@@ -809,8 +783,9 @@ static void action_refresh(const bContext *C, ScrArea *sa)
* or else they don't update [#28962]
*/
ED_area_tag_redraw(sa);
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ED_region_tag_redraw(ar);
+ }
}
/* region updates? */
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 89758bd35da..95775f80b50 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -179,8 +179,9 @@ void ED_spacemacros_init(void)
/* register dropboxes (can use macros) */
spacetypes = BKE_spacetypes_list();
for (type = spacetypes->first; type; type = type->next) {
- if (type->dropboxes)
+ if (type->dropboxes) {
type->dropboxes();
+ }
}
}
@@ -216,11 +217,13 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf)
spacetypes = BKE_spacetypes_list();
for (stype = spacetypes->first; stype; stype = stype->next) {
- if (stype->keymap)
+ if (stype->keymap) {
stype->keymap(keyconf);
+ }
for (atype = stype->regiontypes.first; atype; atype = atype->next) {
- if (atype->keymap)
+ if (atype->keymap) {
atype->keymap(keyconf);
+ }
}
}
}
diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt
index ce08b62e8ef..25ff6bbd098 100644
--- a/source/blender/editors/space_buttons/CMakeLists.txt
+++ b/source/blender/editors/space_buttons/CMakeLists.txt
@@ -24,8 +24,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 1b1c3bf6d13..f9244049d54 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -203,14 +203,14 @@ static void buttons_main_region_layout_properties(const bContext *C,
static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
const enum eContextObjectMode mode = CTX_data_mode_enum(C);
const char *contexts_base[5] = {NULL};
contexts_base[0] = ".active_tool";
const char **contexts = &contexts_base[1];
- if (workspace->tools_space_type == SPACE_VIEW3D) {
+ /* Hard coded to 3D view. */
+ {
switch (mode) {
case CTX_MODE_EDIT_MESH:
ARRAY_SET_ITEMS(contexts, ".mesh_edit");
@@ -267,22 +267,6 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
break;
}
}
- else if (workspace->tools_space_type == SPACE_IMAGE) {
- switch (workspace->tools_mode) {
- case SI_MODE_VIEW:
- break;
- case SI_MODE_PAINT:
- ARRAY_SET_ITEMS(contexts, ".paint_common_2d", ".imagepaint_2d");
- break;
- case SI_MODE_MASK:
- break;
- case SI_MODE_UV:
- if (mode == CTX_MODE_EDIT_MESH) {
- ARRAY_SET_ITEMS(contexts, ".uv_sculpt");
- }
- break;
- }
- }
/* for grease pencil we don't use tool system yet, so we need check outside
* workspace->tools_space_type because this value is not available
diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt
index ed98dcdc159..2ea4bc97d18 100644
--- a/source/blender/editors/space_clip/CMakeLists.txt
+++ b/source/blender/editors/space_clip/CMakeLists.txt
@@ -24,13 +24,13 @@ set(INC
../../blenlib
../../blentranslation
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index 6f950ec5bc4..c985d61a8b8 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -110,8 +110,9 @@ void uiTemplateMovieClip(
uiLayout *row, *split;
uiBlock *block;
- if (!ptr->data)
+ if (!ptr->data) {
return;
+ }
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -133,9 +134,10 @@ void uiTemplateMovieClip(
uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr);
- if (!compact)
+ if (!compact) {
uiTemplateID(
layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
+ }
if (clip) {
uiLayout *col;
@@ -166,8 +168,9 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
uiLayout *col;
MovieClipScopes *scopes;
- if (!ptr->data)
+ if (!ptr->data) {
return;
+ }
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -274,8 +277,9 @@ static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb;
MovieTrackingMarker *marker;
- if (!cb->compact)
+ if (!cb->compact) {
return;
+ }
marker = BKE_tracking_marker_ensure(cb->track, cb->framenr);
@@ -381,8 +385,9 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
sub_v2_v2v2(delta, offset, cb->track->offset);
copy_v2_v2(cb->track->offset, offset);
- for (i = 0; i < cb->track->markersnr; i++)
+ for (i = 0; i < cb->track->markersnr; i++) {
sub_v2_v2(cb->track->markers[i].pos, delta);
+ }
/* to update position of "parented" objects */
DEG_id_tag_update(&cb->clip->id, 0);
@@ -391,8 +396,9 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
ok = true;
}
- if (ok)
+ if (ok) {
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, cb->clip);
+ }
}
void uiTemplateMarker(uiLayout *layout,
@@ -414,8 +420,9 @@ void uiTemplateMarker(uiLayout *layout,
const char *tip;
float pat_min[2], pat_max[2];
- if (!ptr->data)
+ if (!ptr->data) {
return;
+ }
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -451,10 +458,12 @@ void uiTemplateMarker(uiLayout *layout,
if (compact) {
block = uiLayoutGetBlock(layout);
- if (cb->marker_flag & MARKER_DISABLED)
+ if (cb->marker_flag & MARKER_DISABLED) {
tip = TIP_("Marker is disabled at current frame");
- else
+ }
+ else {
tip = TIP_("Marker is enabled at current frame");
+ }
bt = uiDefIconButBitI(block,
UI_BTYPE_TOGGLE_N,
@@ -525,10 +534,12 @@ void uiTemplateMarker(uiLayout *layout,
UI_block_func_handle_set(block, marker_block_handler, cb);
UI_block_funcN_set(block, marker_update_cb, cb, NULL);
- if (cb->marker_flag & MARKER_DISABLED)
+ if (cb->marker_flag & MARKER_DISABLED) {
tip = TIP_("Marker is disabled at current frame");
- else
+ }
+ else {
tip = TIP_("Marker is enabled at current frame");
+ }
uiDefButBitI(block,
UI_BTYPE_CHECKBOX_N,
@@ -773,8 +784,9 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
ImBuf *ibuf;
size_t ofs = 0;
- if (!ptr->data)
+ if (!ptr->data) {
return;
+ }
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -805,19 +817,24 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
if (ibuf) {
if (ibuf->rect_float) {
- if (ibuf->channels != 4)
+ if (ibuf->channels != 4) {
ofs += BLI_snprintf(
str + ofs, sizeof(str) - ofs, IFACE_(", %d float channel(s)"), ibuf->channels);
- else if (ibuf->planes == R_IMF_PLANES_RGBA)
+ }
+ else if (ibuf->planes == R_IMF_PLANES_RGBA) {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(", RGBA float"), sizeof(str) - ofs);
- else
+ }
+ else {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(", RGB float"), sizeof(str) - ofs);
+ }
}
else {
- if (ibuf->planes == R_IMF_PLANES_RGBA)
+ if (ibuf->planes == R_IMF_PLANES_RGBA) {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(", RGBA byte"), sizeof(str) - ofs);
- else
+ }
+ else {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(", RGB byte"), sizeof(str) - ofs);
+ }
}
if (clip->anim != NULL) {
@@ -837,10 +854,12 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
/* Display current frame number. */
framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
- if (framenr <= clip->len)
+ if (framenr <= clip->len) {
BLI_snprintf(str, sizeof(str), IFACE_("Frame: %d / %d"), framenr, clip->len);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Frame: - / %d"), clip->len);
+ }
uiItemL(col, str, ICON_NONE);
/* Display current file name if it's a sequence clip. */
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index 8ac0870f7f1..0f6e7947482 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -59,10 +59,12 @@ static void track_channel_color(MovieTrackingTrack *track, float default_color[3
interp_v3_v3v3(color, track->color, bg, 0.5);
}
else {
- if (default_color)
+ if (default_color) {
copy_v3_v3(color, default_color);
- else
+ }
+ else {
UI_GetThemeColor3fv(TH_HEADER, color);
+ }
}
}
@@ -297,8 +299,9 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
uiStyle *style = UI_style_get();
int fontid = style->widget.uifont_id;
- if (!clip)
+ if (!clip) {
return;
+ }
MovieTracking *tracking = &clip->tracking;
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c
index e7f0f8c3fcc..785ced96b13 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_ops.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c
@@ -66,8 +66,9 @@ static bool dopesheet_select_channel_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
- if (sc && sc->clip)
+ if (sc && sc->clip) {
return sc->view == SC_VIEW_DOPESHEET;
+ }
return false;
}
@@ -93,10 +94,12 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op)
MovieTrackingTrack *track = channel->track;
if (current_channel_index == channel_index) {
- if (extend)
+ if (extend) {
track->flag ^= TRACK_DOPE_SEL;
- else
+ }
+ else {
track->flag |= TRACK_DOPE_SEL;
+ }
if (track->flag & TRACK_DOPE_SEL) {
tracking->act_track = track;
@@ -106,8 +109,9 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op)
BKE_tracking_track_deselect(track, TRACK_AREA_ALL);
}
}
- else if (!extend)
+ else if (!extend) {
track->flag &= ~TRACK_DOPE_SEL;
+ }
current_channel_index++;
}
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index a3aa4f4bed5..99f9a91775e 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -178,12 +178,14 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
while (a < markersnr) {
int marker_framenr = generic_track_get_marker_framenr(act_track, act_plane_track, a);
- if (marker_framenr >= i)
+ if (marker_framenr >= i) {
break;
+ }
if (a < markersnr - 1 &&
- generic_track_get_marker_framenr(act_track, act_plane_track, a + 1) > i)
+ generic_track_get_marker_framenr(act_track, act_plane_track, a + 1) > i) {
break;
+ }
a++;
}
@@ -284,8 +286,9 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar)
full_redraw = true;
}
else {
- if (sc->flag & SC_LOCK_SELECTION)
+ if (sc->flag & SC_LOCK_SELECTION) {
strcpy(str, "Locked");
+ }
}
if (str[0]) {
@@ -341,7 +344,7 @@ static void draw_movieclip_buffer(const bContext *C,
filter = GL_NEAREST;
}
- glaDrawImBuf_glsl_ctx(C, ibuf, x, y, filter, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
+ ED_draw_imbuf_ctx(C, ibuf, x, y, filter, zoomx * width / ibuf->x, zoomy * height / ibuf->y);
if (ibuf->planes == 32) {
GPU_blend(false);
@@ -411,14 +414,16 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
int tiny = sc->flag & SC_SHOW_TINY_MARKER, framenr, start_frame;
MovieTrackingMarker *marker;
- if (count == 0)
+ if (count == 0) {
return;
+ }
start_frame = framenr = ED_space_clip_get_clip_frame_number(sc);
marker = BKE_tracking_marker_get(track, framenr);
- if (marker->framenr != framenr || marker->flag & MARKER_DISABLED)
+ if (marker->framenr != framenr || marker->flag & MARKER_DISABLED) {
return;
+ }
if (count < MAX_STATIC_PATH) {
path = path_static;
@@ -432,15 +437,17 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
while (i >= framenr - count) {
marker = BKE_tracking_marker_get(track, i);
- if (!marker || marker->flag & MARKER_DISABLED)
+ if (!marker || marker->flag & MARKER_DISABLED) {
break;
+ }
if (marker->framenr == i) {
add_v2_v2v2(path[--a], marker->pos, track->offset);
ED_clip_point_undistorted_pos(sc, path[a], path[a]);
- if (marker->framenr == start_frame)
+ if (marker->framenr == start_frame) {
curindex = a;
+ }
}
else {
break;
@@ -454,18 +461,21 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
while (i <= framenr + count) {
marker = BKE_tracking_marker_get(track, i);
- if (!marker || marker->flag & MARKER_DISABLED)
+ if (!marker || marker->flag & MARKER_DISABLED) {
break;
+ }
if (marker->framenr == i) {
- if (marker->framenr == start_frame)
+ if (marker->framenr == start_frame) {
curindex = b;
+ }
add_v2_v2v2(path[b++], marker->pos, track->offset);
ED_clip_point_undistorted_pos(sc, path[b - 1], path[b - 1]);
}
- else
+ else {
break;
+ }
i++;
}
@@ -658,20 +668,24 @@ static void draw_marker_outline(SpaceClip *sc,
static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3])
{
if (track->flag & TRACK_CUSTOMCOLOR) {
- if (act)
+ if (act) {
UI_GetThemeColor3fv(TH_ACT_MARKER, scol);
- else
+ }
+ else {
copy_v3_v3(scol, track->color);
+ }
mul_v3_v3fl(col, track->color, 0.5f);
}
else {
UI_GetThemeColor3fv(TH_MARKER, col);
- if (act)
+ if (act) {
UI_GetThemeColor3fv(TH_ACT_MARKER, scol);
- else
+ }
+ else {
UI_GetThemeColor3fv(TH_SEL_MARKER, scol);
+ }
}
}
@@ -923,11 +937,13 @@ static void draw_marker_slide_zones(SpaceClip *sc,
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
float col[3], scol[3], px[2], side;
- if ((tiny && outline) || (marker->flag & MARKER_DISABLED))
+ if ((tiny && outline) || (marker->flag & MARKER_DISABLED)) {
return;
+ }
- if (!TRACK_VIEW_SELECTED(sc, track) || track->flag & TRACK_LOCKED)
+ if (!TRACK_VIEW_SELECTED(sc, track) || track->flag & TRACK_LOCKED) {
return;
+ }
track_colors(track, act, col, scol);
@@ -1020,8 +1036,9 @@ static void draw_marker_texts(SpaceClip *sc,
uiStyle *style = U.uistyles.first;
int fontid = style->widget.uifont_id;
- if (!TRACK_VIEW_SELECTED(sc, track))
+ if (!TRACK_VIEW_SELECTED(sc, track)) {
return;
+ }
BLF_size(fontid, 11.0f * U.pixelsize, U.dpi);
fontsize = BLF_height_max(fontid);
@@ -1062,19 +1079,25 @@ static void draw_marker_texts(SpaceClip *sc,
pos[0] = pos[0] * zoomx;
pos[1] = pos[1] * zoomy - fontsize;
- if (marker->flag & MARKER_DISABLED)
+ if (marker->flag & MARKER_DISABLED) {
strcpy(state, "disabled");
- else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc))
+ }
+ else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc)) {
strcpy(state, "estimated");
- else if (marker->flag & MARKER_TRACKED)
+ }
+ else if (marker->flag & MARKER_TRACKED) {
strcpy(state, "tracked");
- else
+ }
+ else {
strcpy(state, "keyframed");
+ }
- if (state[0])
+ if (state[0]) {
BLI_snprintf(str, sizeof(str), "%s: %s", track->name, state);
- else
+ }
+ else {
BLI_strncpy(str, track->name, sizeof(str));
+ }
BLF_position(fontid, pos[0], pos[1], 0.0f);
BLF_draw(fontid, str, sizeof(str));
@@ -1479,8 +1502,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
if ((track->flag & TRACK_HIDDEN) == 0) {
marker = BKE_tracking_marker_get(track, framenr);
- if (MARKER_VISIBLE(sc, track, marker))
+ if (MARKER_VISIBLE(sc, track, marker)) {
count++;
+ }
}
track = track->next;
@@ -1499,8 +1523,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
if (MARKER_VISIBLE(sc, track, marker)) {
ED_clip_point_undistorted_pos(sc, marker->pos, fp);
- if (track == act_track)
+ if (track == act_track) {
active_pos = fp;
+ }
fp += 2;
}
@@ -1514,8 +1539,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
if (sc->flag & SC_SHOW_TRACK_PATH) {
track = tracksbase->first;
while (track) {
- if ((track->flag & TRACK_HIDDEN) == 0)
+ if ((track->flag & TRACK_HIDDEN) == 0) {
draw_track_path(sc, clip, track);
+ }
track = track->next;
}
@@ -1541,8 +1567,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
draw_marker_slide_zones(sc, track, marker, cur_pos, 1, 0, 0, width, height, position);
draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 0, 0, width, height, position);
- if (fp)
+ if (fp) {
fp += 2;
+ }
}
}
@@ -1566,8 +1593,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 1, 0, width, height, position);
}
- if (fp)
+ if (fp) {
fp += 2;
+ }
}
}
@@ -1664,8 +1692,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
draw_marker_texts(sc, track, marker, cur_pos, act, width, height, zoomx, zoomy);
- if (fp)
+ if (fp) {
fp += 2;
+ }
}
}
@@ -1675,8 +1704,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
GPU_matrix_pop();
- if (marker_pos)
+ if (marker_pos) {
MEM_freeN(marker_pos);
+ }
}
static void draw_distortion(
@@ -1692,11 +1722,13 @@ static void draw_distortion(
float dx = (float)width / n, dy = (float)height / n * aspy;
float offsx = 0.0f, offsy = 0.0f;
- if (!tracking->camera.focal)
+ if (!tracking->camera.focal) {
return;
+ }
- if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0)
+ if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0) {
return;
+ }
UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
@@ -1717,10 +1749,12 @@ static void draw_distortion(
float min[2], max[2];
for (a = 0; a < 4; a++) {
- if (a < 2)
+ if (a < 2) {
val[a][a % 2] = FLT_MAX;
- else
+ }
+ else {
val[a][a % 2] = -FLT_MAX;
+ }
}
zero_v2(pos);
@@ -1732,10 +1766,12 @@ static void draw_distortion(
for (a = 0; a < 4; a++) {
int ok;
- if (a < 2)
+ if (a < 2) {
ok = tpos[a % 2] < val[a][a % 2];
- else
+ }
+ else {
ok = tpos[a % 2] > val[a][a % 2];
+ }
if (ok) {
copy_v2_v2(val[a], tpos);
@@ -1912,10 +1948,12 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle);
}
- if (ibuf != NULL && width != ibuf->x)
+ if (ibuf != NULL && width != ibuf->x) {
mul_v2_v2fl(translation, sc->loc, (float)width / ibuf->x);
- else
+ }
+ else {
copy_v2_v2(translation, sc->loc);
+ }
BKE_tracking_stabilization_data_to_mat4(
width, height, aspect, translation, sc->scale, sc->angle, sc->stabmat);
@@ -1970,8 +2008,9 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
- if (!clip)
+ if (!clip) {
return;
+ }
if (onlyv2d) {
bool is_track_source = sc->gpencil_src == SC_GPENCIL_SRC_TRACK;
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 8351f79aac7..b0b6aa47df1 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -72,8 +72,9 @@ bool ED_space_clip_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
- if (sc && sc->clip)
+ if (sc && sc->clip) {
return true;
+ }
return false;
}
@@ -93,8 +94,9 @@ bool ED_space_clip_tracking_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
- if (sc && sc->clip)
+ if (sc && sc->clip) {
return ED_space_clip_check_show_trackedit(sc);
+ }
return false;
}
@@ -159,10 +161,12 @@ void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
- if (clip)
+ if (clip) {
BKE_movieclip_get_aspect(clip, aspx, aspy);
- else
+ }
+ else {
*aspx = *aspy = 1.0f;
+ }
if (*aspx < *aspy) {
*aspy = *aspy / *aspx;
@@ -224,11 +228,13 @@ ImBuf *ED_space_clip_get_buffer(SpaceClip *sc)
ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag);
- if (ibuf && (ibuf->rect || ibuf->rect_float))
+ if (ibuf && (ibuf->rect || ibuf->rect_float)) {
return ibuf;
+ }
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
}
return NULL;
@@ -242,11 +248,13 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale
ibuf = BKE_movieclip_get_stable_ibuf(
sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag);
- if (ibuf && (ibuf->rect || ibuf->rect_float))
+ if (ibuf && (ibuf->rect || ibuf->rect_float)) {
return ibuf;
+ }
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
}
return NULL;
@@ -395,11 +403,13 @@ bool ED_clip_view_selection(const bContext *C, ARegion *ar, bool fit)
ED_space_clip_get_size(sc, &frame_width, &frame_height);
- if ((frame_width == 0) || (frame_height == 0) || (sc->clip == NULL))
+ if ((frame_width == 0) || (frame_height == 0) || (sc->clip == NULL)) {
return false;
+ }
- if (!selected_boundbox(C, min, max))
+ if (!selected_boundbox(C, min, max)) {
return false;
+ }
/* center view */
clip_view_center_to_point(
@@ -423,8 +433,9 @@ bool ED_clip_view_selection(const bContext *C, ARegion *ar, bool fit)
newzoom = 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy));
- if (fit || sc->zoom > newzoom)
+ if (fit || sc->zoom > newzoom) {
sc->zoom = newzoom;
+ }
}
return true;
@@ -489,8 +500,9 @@ void ED_clip_select_all(SpaceClip *sc, int action, bool *r_has_selection)
}
}
- if (TRACK_VIEW_SELECTED(sc, track))
+ if (TRACK_VIEW_SELECTED(sc, track)) {
has_selection = true;
+ }
}
for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) {
@@ -635,8 +647,9 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
MovieClip *old_clip;
bool old_clip_visible = false;
- if (!screen && C)
+ if (!screen && C) {
screen = CTX_wm_screen(C);
+ }
old_clip = sc->clip;
sc->clip = clip;
@@ -654,8 +667,9 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
if (cur_sc != sc) {
if (cur_sc->view == SC_VIEW_CLIP) {
- if (cur_sc->clip == old_clip)
+ if (cur_sc->clip == old_clip) {
old_clip_visible = true;
+ }
}
else {
if (cur_sc->clip == old_clip || cur_sc->clip == NULL) {
@@ -673,8 +687,9 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
BKE_movieclip_clear_cache(old_clip);
}
- if (C)
+ if (C) {
WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip);
+ }
}
/* ******** masking editing functions ******** */
@@ -785,16 +800,18 @@ static int prefetch_find_uncached_frame(MovieClip *clip,
for (current_frame = from_frame; current_frame <= end_frame; current_frame++) {
user.framenr = current_frame;
- if (!BKE_movieclip_has_cached_frame(clip, &user))
+ if (!BKE_movieclip_has_cached_frame(clip, &user)) {
break;
+ }
}
}
else {
for (current_frame = from_frame; current_frame >= end_frame; current_frame--) {
user.framenr = current_frame;
- if (!BKE_movieclip_has_cached_frame(clip, &user))
+ if (!BKE_movieclip_has_cached_frame(clip, &user)) {
break;
+ }
}
}
@@ -956,8 +973,9 @@ static bool prefetch_movie_frame(
MovieClipUser user = {0};
ImBuf *ibuf;
- if (check_prefetch_break() || *stop)
+ if (check_prefetch_break() || *stop) {
return false;
+ }
user.framenr = frame;
user.render_size = render_size;
@@ -1002,8 +1020,9 @@ static void do_prefetch_movie(MovieClip *clip,
/* read frames starting from current frame up to scene end frame */
for (frame = current_frame; frame <= end_frame; frame++) {
- if (!prefetch_movie_frame(clip, frame, render_size, render_flag, stop))
+ if (!prefetch_movie_frame(clip, frame, render_size, render_flag, stop)) {
return;
+ }
frames_processed++;
@@ -1013,8 +1032,9 @@ static void do_prefetch_movie(MovieClip *clip,
/* read frames starting from current frame up to scene start frame */
for (frame = current_frame; frame >= start_frame; frame--) {
- if (!prefetch_movie_frame(clip, frame, render_size, render_flag, stop))
+ if (!prefetch_movie_frame(clip, frame, render_size, render_flag, stop)) {
return;
+ }
frames_processed++;
@@ -1113,8 +1133,9 @@ static bool prefetch_check_early_out(const bContext *C)
first_uncached_frame = prefetch_find_uncached_frame(
clip, sc->user.framenr, start_frame, sc->user.render_size, sc->user.render_flag, -1);
- if (first_uncached_frame < start_frame)
+ if (first_uncached_frame < start_frame) {
return true;
+ }
}
return false;
@@ -1126,8 +1147,9 @@ void clip_start_prefetch_job(const bContext *C)
PrefetchJob *pj;
SpaceClip *sc = CTX_wm_space_clip(C);
- if (prefetch_check_early_out(C))
+ if (prefetch_check_early_out(C)) {
return;
+ }
wm_job = WM_jobs_get(CTX_wm_manager(C),
CTX_wm_window(C),
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index c7602907954..ef5de1acee3 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -111,8 +111,9 @@ static void tracking_segment_knot_cb(void *userdata,
TrackMotionCurveUserData *data = (TrackMotionCurveUserData *)userdata;
int sel = 0, sel_flag;
- if (track != data->act_track)
+ if (track != data->act_track) {
return;
+ }
sel_flag = coord == 0 ? MARKER_GRAPH_SEL_X : MARKER_GRAPH_SEL_Y;
sel = (marker->flag & sel_flag) ? 1 : 0;
@@ -140,8 +141,9 @@ static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc, unsigned int p
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
- if (!width || !height)
+ if (!width || !height) {
return;
+ }
/* non-selected knot handles */
userdata.hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
@@ -337,14 +339,10 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
- short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES;
/* grid */
- grid = UI_view2d_grid_calc(
- scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
- UI_view2d_grid_free(grid);
+ UI_view2d_draw_lines_x__values(v2d);
+ UI_view2d_draw_lines_y__values(v2d);
if (clip) {
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 7a61aced8b5..a3722433e33 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -200,16 +200,20 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend)
}
if (userdata.coord == 0) {
- if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_X) != 0)
+ if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_X) != 0) {
userdata.marker->flag &= ~MARKER_GRAPH_SEL_X;
- else
+ }
+ else {
userdata.marker->flag |= MARKER_GRAPH_SEL_X;
+ }
}
else {
- if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_Y) != 0)
+ if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_Y) != 0) {
userdata.marker->flag &= ~MARKER_GRAPH_SEL_Y;
- else
+ }
+ else {
userdata.marker->flag |= MARKER_GRAPH_SEL_Y;
+ }
}
return true;
@@ -281,8 +285,9 @@ static int mouse_select(bContext *C, float co[2], bool extend)
sel = mouse_select_curve(C, co, extend);
}
- if (sel)
+ if (sel) {
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -360,10 +365,12 @@ static void box_select_cb(void *userdata,
if (BLI_rctf_isect_pt(&data->rect, scene_framenr, val)) {
int flag = 0;
- if (coord == 0)
+ if (coord == 0) {
flag = MARKER_GRAPH_SEL_X;
- else
+ }
+ else {
flag = MARKER_GRAPH_SEL_Y;
+ }
if (data->select) {
marker->flag |= flag;
@@ -444,8 +451,9 @@ static int graph_select_all_markers_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
int a;
- if (!act_track)
+ if (!act_track) {
return OPERATOR_CANCELLED;
+ }
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@@ -507,8 +515,9 @@ static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op))
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
- if (!act_track)
+ if (!act_track) {
return OPERATOR_CANCELLED;
+ }
clip_delete_track(C, clip, act_track);
@@ -546,10 +555,12 @@ static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op))
while (a < act_track->markersnr) {
MovieTrackingMarker *marker = &act_track->markers[a];
- if (marker->flag & MARKER_GRAPH_SEL)
+ if (marker->flag & MARKER_GRAPH_SEL) {
clip_delete_marker(C, clip, act_track, marker);
- else
+ }
+ else {
a++;
+ }
}
}
@@ -586,11 +597,13 @@ static void view_all_cb(void *userdata,
{
ViewAllUserData *data = (ViewAllUserData *)userdata;
- if (val < data->min)
+ if (val < data->min) {
data->min = val;
+ }
- if (val > data->max)
+ if (val > data->max) {
data->max = val;
+ }
}
static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
@@ -700,19 +713,23 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
int a;
- if (!act_track || (act_track->flag & TRACK_LOCKED))
+ if (!act_track || (act_track->flag & TRACK_LOCKED)) {
return OPERATOR_CANCELLED;
+ }
for (a = 0; a < act_track->markersnr; a++) {
marker = &act_track->markers[a];
if (marker->flag & MARKER_GRAPH_SEL) {
- if (action == 0)
+ if (action == 0) {
marker->flag |= MARKER_DISABLED;
- else if (action == 1)
+ }
+ else if (action == 1) {
marker->flag &= ~MARKER_DISABLED;
- else
+ }
+ else {
marker->flag ^= MARKER_DISABLED;
+ }
}
}
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 8ecf596fac7..70dc1caf36f 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -110,8 +110,6 @@ void CLIP_OT_cursor_set(struct wmOperatorType *ot);
/* clip_toolbar.c */
struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa);
-void CLIP_OT_tools(struct wmOperatorType *ot);
-void CLIP_OT_properties(struct wmOperatorType *ot);
/* clip_utils.c */
void clip_graph_tracking_values_iterate_track(
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 3cebb53d31e..3f971c4444a 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -97,12 +97,15 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2])
width *= sc->zoom;
height *= sc->zoom;
- if ((width < 4) && (height < 4) && sc->zoom < oldzoom)
+ if ((width < 4) && (height < 4) && sc->zoom < oldzoom) {
sc->zoom = oldzoom;
- else if (BLI_rcti_size_x(&ar->winrct) <= sc->zoom)
+ }
+ else if (BLI_rcti_size_x(&ar->winrct) <= sc->zoom) {
sc->zoom = oldzoom;
- else if (BLI_rcti_size_y(&ar->winrct) <= sc->zoom)
+ }
+ else if (BLI_rcti_size_y(&ar->winrct) <= sc->zoom) {
sc->zoom = oldzoom;
+ }
}
if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) {
@@ -216,8 +219,9 @@ static int open_exec(bContext *C, wmOperator *op)
clip = BKE_movieclip_file_add_exists(bmain, str);
if (!clip) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
BKE_reportf(op->reports,
RPT_ERROR,
@@ -228,8 +232,9 @@ static int open_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (!op->customdata)
+ if (!op->customdata) {
open_init(C, op);
+ }
/* hook into UI */
pprop = op->customdata;
@@ -261,8 +266,9 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
char path[FILE_MAX];
MovieClip *clip = NULL;
- if (sc)
+ if (sc) {
clip = ED_space_clip_get_clip(sc);
+ }
if (clip) {
BLI_strncpy(path, clip->name, sizeof(path));
@@ -274,11 +280,13 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
BLI_strncpy(path, U.textudir, sizeof(path));
}
- if (RNA_struct_property_is_set(op->ptr, "files"))
+ if (RNA_struct_property_is_set(op->ptr, "files")) {
return open_exec(C, op);
+ }
- if (!RNA_struct_property_is_set(op->ptr, "relative_path"))
+ if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
RNA_boolean_set(op->ptr, "relative_path", (U.flag & USER_RELPATHS) != 0);
+ }
open_init(C, op);
@@ -318,8 +326,9 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op))
{
MovieClip *clip = CTX_data_edit_movieclip(C);
- if (!clip)
+ if (!clip) {
return OPERATOR_CANCELLED;
+ }
WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_CLIP_PREFETCH);
BKE_movieclip_reload(CTX_data_main(C), clip);
@@ -360,10 +369,12 @@ static void view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
vpd->x = event->x;
vpd->y = event->y;
- if (sc->flag & SC_LOCK_SELECTION)
+ if (sc->flag & SC_LOCK_SELECTION) {
vpd->vec = &sc->xlockof;
- else
+ }
+ else {
vpd->vec = &sc->xof;
+ }
copy_v2_v2(&vpd->xof, vpd->vec);
copy_v2_v2(&vpd->xorig, &vpd->xof);
@@ -569,8 +580,9 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
delta = event->prevx - event->x + event->prevy - event->y;
- if (U.uiflag & USER_ZOOM_INVERT)
+ if (U.uiflag & USER_ZOOM_INVERT) {
delta *= -1;
+ }
factor = 1.0f + delta / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
@@ -879,8 +891,9 @@ static int view_all_exec(bContext *C, wmOperator *op)
/* find the zoom value that will fit the image in the image space */
sclip_zoom_set(C, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL);
}
- else
+ else {
sclip_zoom_set(C, 1.0f, NULL);
+ }
}
sc->xof = sc->yof = 0.0f;
@@ -941,8 +954,9 @@ void CLIP_OT_view_selected(wmOperatorType *ot)
static bool change_frame_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return ED_space_clip_poll(C);
}
@@ -995,8 +1009,9 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event
ARegion *ar = CTX_wm_region(C);
if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (event->mval[1] > 16)
+ if (event->mval[1] > 16) {
return OPERATOR_PASS_THROUGH;
+ }
}
RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
@@ -1022,8 +1037,9 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTMOUSE:
case RIGHTMOUSE:
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
return OPERATOR_FINISHED;
+ }
break;
}
@@ -1079,17 +1095,21 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto
MCLIP_PROXY_UNDISTORTED_SIZE_100}};
int size_nr = undistort ? 1 : 0;
- if (size_flag & size_flags[size_nr][0])
+ if (size_flag & size_flags[size_nr][0]) {
build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_25;
+ }
- if (size_flag & size_flags[size_nr][1])
+ if (size_flag & size_flags[size_nr][1]) {
build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_50;
+ }
- if (size_flag & size_flags[size_nr][2])
+ if (size_flag & size_flags[size_nr][2]) {
build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_75;
+ }
- if (size_flag & size_flags[size_nr][3])
+ if (size_flag & size_flags[size_nr][3]) {
build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_100;
+ }
return build_count;
}
@@ -1110,12 +1130,14 @@ static void do_movie_proxy(void *pjv,
struct MovieDistortion *distortion = NULL;
int cfra, sfra = SFRA, efra = EFRA;
- if (pj->index_context)
+ if (pj->index_context) {
IMB_anim_index_rebuild(pj->index_context, stop, do_update, progress);
+ }
if (!build_undistort_count) {
- if (*stop)
+ if (*stop) {
pj->stop = 1;
+ }
return;
}
@@ -1138,18 +1160,21 @@ static void do_movie_proxy(void *pjv,
BKE_movieclip_build_proxy_frame(
clip, pj->clip_flag, distortion, cfra, build_undistort_sizes, build_undistort_count, 1);
- if (*stop || G.is_break)
+ if (*stop || G.is_break) {
break;
+ }
*do_update = true;
*progress = ((float)cfra - sfra) / (efra - sfra);
}
- if (distortion)
+ if (distortion) {
BKE_tracking_distortion_free(distortion);
+ }
- if (*stop)
+ if (*stop) {
pj->stop = 1;
+ }
}
/* *****
@@ -1371,11 +1396,13 @@ static void proxy_endjob(void *pjv)
{
ProxyJob *pj = pjv;
- if (pj->clip->anim)
+ if (pj->clip->anim) {
IMB_close_anim_proxies(pj->clip->anim);
+ }
- if (pj->index_context)
+ if (pj->index_context) {
IMB_anim_index_rebuild_finish(pj->index_context, pj->stop);
+ }
if (pj->clip->source == MCLIP_SRC_MOVIE) {
/* Timecode might have changed, so do a full reload to deal with this. */
@@ -1398,8 +1425,9 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
- if ((clip->flag & MCLIP_USE_PROXY) == 0)
+ if ((clip->flag & MCLIP_USE_PROXY) == 0) {
return OPERATOR_CANCELLED;
+ }
wm_job = WM_jobs_get(CTX_wm_manager(C),
CTX_wm_window(C),
@@ -1491,8 +1519,9 @@ void CLIP_OT_mode_set(wmOperatorType *ot)
static int clip_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
- if (event->type != NDOF_MOTION)
+ if (event->type != NDOF_MOTION) {
return OPERATOR_CANCELLED;
+ }
else {
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
@@ -1534,8 +1563,9 @@ void CLIP_OT_view_ndof(wmOperatorType *ot)
static int clip_prefetch_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
/* no running blender, remove handler and pass through */
- if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_CLIP_PREFETCH))
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_CLIP_PREFETCH)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
/* running render */
switch (event->type) {
@@ -1577,8 +1607,9 @@ static int clip_set_scene_frames_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
int clip_length;
- if (ELEM(NULL, scene, clip))
+ if (ELEM(NULL, scene, clip)) {
return OPERATOR_CANCELLED;
+ }
clip_length = BKE_movieclip_get_duration(clip);
diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c
index acb05e7d542..fb0362fffd3 100644
--- a/source/blender/editors/space_clip/clip_toolbar.c
+++ b/source/blender/editors/space_clip/clip_toolbar.c
@@ -58,15 +58,17 @@ ARegion *ED_clip_has_properties_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar)
+ if (ar) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "clip properties region");
@@ -78,95 +80,3 @@ ARegion *ED_clip_has_properties_region(ScrArea *sa)
return arnew;
}
-
-static bool properties_poll(bContext *C)
-{
- return (CTX_wm_space_clip(C) != NULL);
-}
-
-static int properties_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = ED_clip_has_properties_region(sa);
-
- if (ar && ar->alignment != RGN_ALIGN_NONE)
- ED_region_toggle_hidden(C, ar);
-
- return OPERATOR_FINISHED;
-}
-
-void CLIP_OT_properties(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Toggle Sidebar";
- ot->description = "Toggle the properties region visibility";
- ot->idname = "CLIP_OT_properties";
-
- /* api callbacks */
- ot->exec = properties_exec;
- ot->poll = properties_poll;
-}
-
-/************************** tools ******************************/
-
-static ARegion *clip_has_tools_region(ScrArea *sa)
-{
- ARegion *ar, *artool = NULL, *arhead;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_TOOLS)
- artool = ar;
- }
-
- /* tool region hide/unhide also hides props */
- if (artool) {
- return artool;
- }
-
- if (artool == NULL) {
- /* add subdiv level; after header */
- arhead = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
- /* is error! */
- if (arhead == NULL)
- return NULL;
-
- artool = MEM_callocN(sizeof(ARegion), "clip tools region");
-
- BLI_insertlinkafter(&sa->regionbase, arhead, artool);
- artool->regiontype = RGN_TYPE_TOOLS;
- artool->alignment = RGN_ALIGN_LEFT;
-
- artool->flag = RGN_FLAG_HIDDEN;
- }
-
- return artool;
-}
-
-static bool tools_poll(bContext *C)
-{
- return (CTX_wm_space_clip(C) != NULL);
-}
-
-static int tools_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = clip_has_tools_region(sa);
-
- if (ar && ar->alignment != RGN_ALIGN_NONE)
- ED_region_toggle_hidden(C, ar);
-
- return OPERATOR_FINISHED;
-}
-
-void CLIP_OT_tools(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Toggle Toolbar";
- ot->description = "Toggle clip tools panel";
- ot->idname = "CLIP_OT_tools";
-
- /* api callbacks */
- ot->exec = tools_exec;
- ot->poll = tools_poll;
-}
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 37a28e6189a..3dfe529f8e8 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -81,8 +81,9 @@ void clip_graph_tracking_values_iterate_track(
if (marker->flag & MARKER_DISABLED) {
if (open) {
- if (segment_end)
+ if (segment_end) {
segment_end(userdata, coord);
+ }
open = false;
}
@@ -119,8 +120,9 @@ void clip_graph_tracking_values_iterate_track(
}
if (open) {
- if (segment_end)
+ if (segment_end) {
segment_end(userdata, coord);
+ }
}
}
}
@@ -145,11 +147,13 @@ void clip_graph_tracking_values_iterate(
MovieTrackingTrack *track;
for (track = tracksbase->first; track; track = track->next) {
- if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
+ if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0) {
continue;
+ }
- if (selected_only && !TRACK_SELECTED(track))
+ if (selected_only && !TRACK_SELECTED(track)) {
continue;
+ }
clip_graph_tracking_values_iterate_track(
sc, track, userdata, func, segment_start, segment_end);
@@ -170,20 +174,24 @@ void clip_graph_tracking_iterate(SpaceClip *sc,
for (track = tracksbase->first; track; track = track->next) {
int i;
- if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
+ if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0) {
continue;
+ }
- if (selected_only && !TRACK_SELECTED(track))
+ if (selected_only && !TRACK_SELECTED(track)) {
continue;
+ }
for (i = 0; i < track->markersnr; i++) {
MovieTrackingMarker *marker = &track->markers[i];
- if (marker->flag & MARKER_DISABLED)
+ if (marker->flag & MARKER_DISABLED) {
continue;
+ }
- if (func)
+ if (func) {
func(userdata, marker);
+ }
}
}
}
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 7c62af80a0f..542f99e49ee 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -136,12 +136,14 @@ static void reinit_preview_region(const bContext *C, ARegion *ar)
SpaceClip *sc = CTX_wm_space_clip(C);
if (sc->view == SC_VIEW_DOPESHEET) {
- if ((ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) == 0)
+ if ((ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) == 0) {
init_preview_region(scene, sa, sc, ar);
+ }
}
else {
- if (ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL)
+ if (ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) {
init_preview_region(scene, sa, sc, ar);
+ }
}
}
@@ -150,15 +152,17 @@ static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
- if (ar)
+ if (ar) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "clip preview region");
@@ -173,15 +177,17 @@ static ARegion *ED_clip_has_channels_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
- if (ar)
+ if (ar) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "clip channels region");
@@ -200,13 +206,15 @@ static void clip_scopes_tag_refresh(ScrArea *sa)
SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
ARegion *ar;
- if (sc->mode != SC_MODE_TRACKING)
+ if (sc->mode != SC_MODE_TRACKING) {
return;
+ }
/* only while properties are visible */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_UI && ar->flag & RGN_FLAG_HIDDEN)
+ if (ar->regiontype == RGN_TYPE_UI && ar->flag & RGN_FLAG_HIDDEN) {
return;
+ }
}
sc->scopes.ok = false;
@@ -296,11 +304,13 @@ static void clip_free(SpaceLink *sl)
sc->clip = NULL;
- if (sc->scopes.track_preview)
+ if (sc->scopes.track_preview) {
IMB_freeImBuf(sc->scopes.track_preview);
+ }
- if (sc->scopes.track_search)
+ if (sc->scopes.track_search) {
IMB_freeImBuf(sc->scopes.track_search);
+ }
}
/* spacetype; init callback */
@@ -434,10 +444,6 @@ static void clip_operatortypes(void)
WM_operatortype_append(CLIP_OT_set_scene_frames);
WM_operatortype_append(CLIP_OT_cursor_set);
- /* ** clip_toolbar.c ** */
- WM_operatortype_append(CLIP_OT_tools);
- WM_operatortype_append(CLIP_OT_properties);
-
/* ** tracking_ops.c ** */
/* navigation */
@@ -569,13 +575,15 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul
return true;
}
else if (CTX_data_equals(member, "edit_movieclip")) {
- if (sc->clip)
+ if (sc->clip) {
CTX_data_id_pointer_set(result, &sc->clip->id);
+ }
return true;
}
else if (CTX_data_equals(member, "edit_mask")) {
- if (sc->mask_info.mask)
+ if (sc->mask_info.mask) {
CTX_data_id_pointer_set(result, &sc->mask_info.mask->id);
+ }
return true;
}
@@ -851,14 +859,14 @@ static void clip_main_region_init(wmWindowManager *wm, ARegion *ar)
/* mask polls mode */
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Editor", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void clip_main_region_draw(const bContext *C, ARegion *ar)
@@ -872,8 +880,9 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
/* if tracking is in progress, we should synchronize framenr from clipuser
* so latest tracked frame would be shown */
- if (clip && clip->tracking_context)
+ if (clip && clip->tracking_context) {
BKE_autotrack_context_sync_user(clip->tracking_context, &sc->user);
+ }
if (sc->flag & SC_LOCK_SELECTION) {
ImBuf *tmpibuf = NULL;
@@ -887,8 +896,9 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
sc->yof += sc->ylockof;
}
- if (tmpibuf)
+ if (tmpibuf) {
IMB_freeImBuf(tmpibuf);
+ }
}
/* clear and setup matrix */
@@ -972,10 +982,12 @@ static void clip_main_region_listener(wmWindow *UNUSED(win),
/* context changes */
switch (wmn->category) {
case NC_GPENCIL:
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
- else if (wmn->data & ND_GPENCIL_EDITMODE)
+ }
+ else if (wmn->data & ND_GPENCIL_EDITMODE) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -990,13 +1002,13 @@ static void clip_preview_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Graph Editor", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void graph_region_draw(const bContext *C, ARegion *ar)
@@ -1005,11 +1017,11 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
View2DScrollers *scrollers;
SpaceClip *sc = CTX_wm_space_clip(C);
Scene *scene = CTX_data_scene(C);
- short unitx, unity;
short cfra_flag = 0;
- if (sc->flag & SC_LOCK_TIMECURSOR)
+ if (sc->flag & SC_LOCK_TIMECURSOR) {
ED_clip_graph_center_current_frame(scene, ar);
+ }
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -1021,24 +1033,28 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
clip_draw_graph(sc, ar, scene);
/* current frame indicator line */
- if (sc->flag & SC_SHOW_SECONDS)
+ if (sc->flag & SC_SHOW_SECONDS) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
/* reset view matrix */
UI_view2d_view_restore(C);
/* scrollers */
- unitx = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
- unity = V2D_UNIT_VALUES;
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* scale indicators */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, sc->flag & SC_SHOW_SECONDS);
+ UI_view2d_draw_scale_y__values(ar, v2d, &v2d->vert);
+
/* current frame indicator */
- if (sc->flag & SC_SHOW_SECONDS)
+ if (sc->flag & SC_SHOW_SECONDS) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ANIM_draw_cfra_number(C, v2d, cfra_flag);
}
@@ -1049,12 +1065,12 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
View2DScrollers *scrollers;
- short unit = 0, cfra_flag = 0;
+ short cfra_flag = 0;
- if (clip)
+ if (clip) {
BKE_tracking_dopesheet_update(&clip->tracking);
+ }
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -1063,29 +1079,29 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* time grid */
- unit = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
- grid = UI_view2d_grid_calc(
- scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
- UI_view2d_grid_free(grid);
+ UI_view2d_draw_lines_x__discrete_frames_or_seconds(v2d, scene, sc->flag & SC_SHOW_SECONDS);
/* data... */
clip_draw_dopesheet_main(sc, ar, scene);
/* current frame indicator line */
- if (sc->flag & SC_SHOW_SECONDS)
+ if (sc->flag & SC_SHOW_SECONDS) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
/* reset view matrix */
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* frame numbers */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, sc->flag & SC_SHOW_SECONDS);
+
/* current frame number indicator */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ANIM_draw_cfra_number(C, v2d, cfra_flag);
@@ -1095,10 +1111,12 @@ static void clip_preview_region_draw(const bContext *C, ARegion *ar)
{
SpaceClip *sc = CTX_wm_space_clip(C);
- if (sc->view == SC_VIEW_GRAPH)
+ if (sc->view == SC_VIEW_GRAPH) {
graph_region_draw(C, ar);
- else if (sc->view == SC_VIEW_DOPESHEET)
+ }
+ else if (sc->view == SC_VIEW_DOPESHEET) {
dopesheet_region_draw(C, ar);
+ }
}
static void clip_preview_region_listener(wmWindow *UNUSED(win),
@@ -1121,7 +1139,7 @@ static void clip_channels_region_init(wmWindowManager *wm, ARegion *ar)
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
keymap = WM_keymap_ensure(wm->defaultconf, "Clip Dopesheet Editor", SPACE_CLIP, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void clip_channels_region_draw(const bContext *C, ARegion *ar)
@@ -1130,8 +1148,9 @@ static void clip_channels_region_draw(const bContext *C, ARegion *ar)
MovieClip *clip = ED_space_clip_get_clip(sc);
View2D *v2d = &ar->v2d;
- if (clip)
+ if (clip) {
BKE_tracking_dopesheet_update(&clip->tracking);
+ }
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -1219,20 +1238,24 @@ static void clip_props_region_listener(wmWindow *UNUSED(win),
/* context changes */
switch (wmn->category) {
case NC_WM:
- if (wmn->data == ND_HISTORY)
+ if (wmn->data == ND_HISTORY) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCENE:
- if (wmn->data == ND_MODE)
+ if (wmn->data == ND_MODE) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_CLIP)
+ if (wmn->data == ND_SPACE_CLIP) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_GPENCIL:
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -1268,12 +1291,14 @@ static void clip_properties_region_listener(wmWindow *UNUSED(win),
/* context changes */
switch (wmn->category) {
case NC_GPENCIL:
- if (ELEM(wmn->data, ND_DATA, ND_GPENCIL_EDITMODE))
+ if (ELEM(wmn->data, ND_DATA, ND_GPENCIL_EDITMODE)) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_BRUSH:
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index ce1ade80823..18d48b426e0 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -512,8 +512,9 @@ static bool slide_check_corners(float (*corners)[2])
float cross = 0.0f;
float p[2] = {0.0f, 0.0f};
- if (!isect_point_quad_v2(p, corners[0], corners[1], corners[2], corners[3]))
+ if (!isect_point_quad_v2(p, corners[0], corners[1], corners[2], corners[3])) {
return false;
+ }
for (i = 0; i < 4; i++) {
float v1[2], v2[2], cur_cross;
@@ -562,8 +563,9 @@ MovieTrackingTrack *tracking_marker_check_slide(
ED_space_clip_get_size(sc, &width, &height);
- if (width == 0 || height == 0)
+ if (width == 0 || height == 0) {
return NULL;
+ }
ED_clip_mouse_pos(sc, ar, event->mval, co);
diff --git a/source/blender/editors/space_clip/tracking_ops_detect.c b/source/blender/editors/space_clip/tracking_ops_detect.c
index ead150bba7f..a9c97258def 100644
--- a/source/blender/editors/space_clip/tracking_ops_detect.c
+++ b/source/blender/editors/space_clip/tracking_ops_detect.c
@@ -90,7 +90,7 @@ static int detect_features_exec(bContext *C, wmOperator *op)
}
/* Deselect existing tracks. */
- ed_tracking_delect_all_tracks(tracksbase);
+ ed_tracking_deselect_all_tracks(tracksbase);
/* Run detector. */
BKE_tracking_detect_harris(tracking,
tracksbase,
diff --git a/source/blender/editors/space_clip/tracking_ops_intern.h b/source/blender/editors/space_clip/tracking_ops_intern.h
index 8d2d61f050e..c29a485e234 100644
--- a/source/blender/editors/space_clip/tracking_ops_intern.h
+++ b/source/blender/editors/space_clip/tracking_ops_intern.h
@@ -38,7 +38,7 @@ void clip_tracking_hide_cursor(struct bContext *C);
/* tracking_select.h */
-void ed_tracking_delect_all_tracks(struct ListBase *tracks_base);
-void ed_tracking_delect_all_plane_tracks(struct ListBase *plane_tracks_base);
+void ed_tracking_deselect_all_tracks(struct ListBase *tracks_base);
+void ed_tracking_deselect_all_plane_tracks(struct ListBase *plane_tracks_base);
#endif /* __TRACKING_OPS_INTERN_H__ */
diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c
index e13598b0322..61991993b10 100644
--- a/source/blender/editors/space_clip/tracking_ops_orient.c
+++ b/source/blender/editors/space_clip/tracking_ops_orient.c
@@ -399,10 +399,12 @@ static int set_plane_exec(bContext *C, wmOperator *op)
int tot = 0;
float vec[3][3], mat[4][4], obmat[4][4], newmat[4][4], orig[3] = {0.0f, 0.0f, 0.0f};
int plane = RNA_enum_get(op->ptr, "plane");
- float rot[4][4] = {{0.0f, 0.0f, -1.0f, 0.0f},
- {0.0f, 1.0f, 0.0f, 0.0f},
- {1.0f, 0.0f, 0.0f, 0.0f},
- {0.0f, 0.0f, 0.0f, 1.0f}}; /* 90 degrees Y-axis rotation matrix */
+ float rot[4][4] = {
+ {0.0f, 0.0f, -1.0f, 0.0f},
+ {0.0f, 1.0f, 0.0f, 0.0f},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ }; /* 90 degrees Y-axis rotation matrix */
if (count_selected_bundles(C) != 3) {
BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor");
@@ -677,8 +679,9 @@ static int do_set_scale(bContext *C, wmOperator *op, bool scale_solution, bool a
DEG_id_tag_update(&clip->id, 0);
- if (object)
+ if (object) {
DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM);
+ }
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -698,8 +701,9 @@ static int set_scale_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
- if (!RNA_struct_property_is_set(op->ptr, "distance"))
+ if (!RNA_struct_property_is_set(op->ptr, "distance")) {
RNA_float_set(op->ptr, "distance", clip->tracking.settings.dist);
+ }
return set_scale_exec(C, op);
}
diff --git a/source/blender/editors/space_clip/tracking_ops_plane.c b/source/blender/editors/space_clip/tracking_ops_plane.c
index 238410da5e1..fc6a9ee1478 100644
--- a/source/blender/editors/space_clip/tracking_ops_plane.c
+++ b/source/blender/editors/space_clip/tracking_ops_plane.c
@@ -293,19 +293,19 @@ static int slide_plane_marker_modal(bContext *C, wmOperator *op, const wmEvent *
data->corner[1] = data->previous_corner[1] + dy;
/*
- prev_edge
- (Corner 3, current) <----------------------- (Corner 2, previous)
- | ^
- | |
- | |
- | |
- next_edge | | next_diag_edge
- | |
- | |
- | |
- v |
- (Corner 0, next) -----------------------> (Corner 1, diagonal)
- prev_diag_edge
+ * prev_edge
+ * (Corner 3, current) <----------------------- (Corner 2, previous)
+ * | ^
+ * | |
+ * | |
+ * | |
+ * next_edge | | next_diag_edge
+ * | |
+ * | |
+ * | |
+ * v |
+ * (Corner 0, next) -----------------------> (Corner 1, diagonal)
+ * prev_diag_edge
*/
next_corner_index = (data->corner_index + 1) % 4;
diff --git a/source/blender/editors/space_clip/tracking_ops_solve.c b/source/blender/editors/space_clip/tracking_ops_solve.c
index ca57b3ea57f..4490655393e 100644
--- a/source/blender/editors/space_clip/tracking_ops_solve.c
+++ b/source/blender/editors/space_clip/tracking_ops_solve.c
@@ -239,8 +239,9 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
static int solve_camera_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
/* No running solver, remove handler and pass through. */
- if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY))
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
/* Running solver. */
switch (event->type) {
diff --git a/source/blender/editors/space_clip/tracking_ops_track.c b/source/blender/editors/space_clip/tracking_ops_track.c
index d985e82fd1a..e7880331331 100644
--- a/source/blender/editors/space_clip/tracking_ops_track.c
+++ b/source/blender/editors/space_clip/tracking_ops_track.c
@@ -55,7 +55,7 @@ typedef struct TrackMarkersJob {
int backwards; /* Backwards tracking flag */
MovieClip *clip; /* Clip which is tracking */
float delay; /* Delay in milliseconds to allow
- * tracking at fixed FPS */
+ * tracking at fixed FPS */
struct Main *main;
struct Scene *scene;
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index 24282ce0e96..2b70aec02bb 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -58,11 +58,13 @@ static float dist_to_crns(float co[2], float pos[2], float crns[4][2]);
static int mouse_on_side(
float co[2], float x1, float y1, float x2, float y2, float epsx, float epsy)
{
- if (x1 > x2)
+ if (x1 > x2) {
SWAP(float, x1, x2);
+ }
- if (y1 > y2)
+ if (y1 > y2) {
SWAP(float, y1, y2);
+ }
return (co[0] >= x1 - epsx && co[0] <= x2 + epsx) && (co[1] >= y1 - epsy && co[1] <= y2 + epsy);
}
@@ -115,14 +117,17 @@ static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *
epsy = max_ff(epsy, 2.0f / height);
if (sc->flag & SC_SHOW_MARKER_SEARCH) {
- if (mouse_on_rect(co, marker->pos, marker->search_min, marker->search_max, epsx, epsy))
+ if (mouse_on_rect(co, marker->pos, marker->search_min, marker->search_max, epsx, epsy)) {
return TRACK_AREA_SEARCH;
+ }
}
if ((marker->flag & MARKER_DISABLED) == 0) {
- if (sc->flag & SC_SHOW_MARKER_PATTERN)
- if (mouse_on_crns(co, marker->pos, marker->pattern_corners, epsx, epsy))
+ if (sc->flag & SC_SHOW_MARKER_PATTERN) {
+ if (mouse_on_crns(co, marker->pos, marker->pattern_corners, epsx, epsy)) {
return TRACK_AREA_PAT;
+ }
+ }
epsx = 12.0f / width;
epsy = 12.0f / height;
@@ -204,12 +209,14 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc,
(co[1] - marker->pos[1] - cur->offset[1]) * (co[1] - marker->pos[1] - cur->offset[1]));
/* distance to pattern boundbox */
- if (sc->flag & SC_SHOW_MARKER_PATTERN)
+ if (sc->flag & SC_SHOW_MARKER_PATTERN) {
d2 = dist_to_crns(co, marker->pos, marker->pattern_corners);
+ }
/* distance to search boundbox */
- if (sc->flag & SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur))
+ if (sc->flag & SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur)) {
d3 = dist_to_rect(co, marker->pos, marker->search_min, marker->search_max);
+ }
/* choose minimal distance. useful for cases of overlapped markers. */
dist = min_fff(d1, d2, d3);
@@ -256,7 +263,7 @@ static MovieTrackingPlaneTrack *find_nearest_plane_track(SpaceClip *sc,
return plane_track;
}
-void ed_tracking_delect_all_tracks(ListBase *tracks_base)
+void ed_tracking_deselect_all_tracks(ListBase *tracks_base)
{
MovieTrackingTrack *track;
for (track = tracks_base->first; track != NULL; track = track->next) {
@@ -264,7 +271,7 @@ void ed_tracking_delect_all_tracks(ListBase *tracks_base)
}
}
-void ed_tracking_delect_all_plane_tracks(ListBase *plane_tracks_base)
+void ed_tracking_deselect_all_plane_tracks(ListBase *plane_tracks_base)
{
MovieTrackingPlaneTrack *plane_track;
for (plane_track = plane_tracks_base->first; plane_track != NULL;
@@ -273,7 +280,7 @@ void ed_tracking_delect_all_plane_tracks(ListBase *plane_tracks_base)
}
}
-static int mouse_select(bContext *C, float co[2], int extend)
+static int mouse_select(bContext *C, float co[2], const bool extend, const bool deselect_all)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -288,6 +295,15 @@ static int mouse_select(bContext *C, float co[2], int extend)
track = find_nearest_track(sc, tracksbase, co, &distance_to_track);
plane_track = find_nearest_plane_track(sc, plane_tracks_base, co, &distance_to_plane_track);
+ /* Do not select beyond some reasonable distance, that is useless and
+ * prevents the 'deselect on nothing' behavior. */
+ if (distance_to_track > 0.05f) {
+ track = NULL;
+ }
+ if (distance_to_plane_track > 0.05f) {
+ plane_track = NULL;
+ }
+
/* Between track and plane we choose closest to the mouse for selection here. */
if (track && plane_track) {
if (distance_to_track < distance_to_plane_track) {
@@ -298,15 +314,16 @@ static int mouse_select(bContext *C, float co[2], int extend)
}
}
- if (!extend) {
- ed_tracking_delect_all_plane_tracks(plane_tracks_base);
- }
-
if (track) {
+ if (!extend) {
+ ed_tracking_deselect_all_plane_tracks(plane_tracks_base);
+ }
+
int area = track_mouse_area(C, co, track);
- if (!extend || !TRACK_VIEW_SELECTED(sc, track))
+ if (!extend || !TRACK_VIEW_SELECTED(sc, track)) {
area = TRACK_AREA_ALL;
+ }
if (extend && TRACK_AREA_SELECTED(track, area)) {
if (track == act_track) {
@@ -318,8 +335,9 @@ static int mouse_select(bContext *C, float co[2], int extend)
}
}
else {
- if (area == TRACK_AREA_POINT)
+ if (area == TRACK_AREA_POINT) {
area = TRACK_AREA_ALL;
+ }
BKE_tracking_track_select(tracksbase, track, area, extend);
clip->tracking.act_track = track;
@@ -328,7 +346,7 @@ static int mouse_select(bContext *C, float co[2], int extend)
}
else if (plane_track) {
if (!extend) {
- ed_tracking_delect_all_tracks(tracksbase);
+ ed_tracking_deselect_all_tracks(tracksbase);
}
if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
@@ -343,6 +361,10 @@ static int mouse_select(bContext *C, float co[2], int extend)
clip->tracking.act_track = NULL;
clip->tracking.act_plane_track = plane_track;
}
+ else if (deselect_all) {
+ ed_tracking_deselect_all_tracks(tracksbase);
+ ed_tracking_deselect_all_plane_tracks(plane_tracks_base);
+ }
if (!extend) {
sc->xlockof = 0.0f;
@@ -371,12 +393,12 @@ static bool select_poll(bContext *C)
static int select_exec(bContext *C, wmOperator *op)
{
float co[2];
- int extend;
RNA_float_get_array(op->ptr, "location", co);
- extend = RNA_boolean_get(op->ptr, "extend");
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
- return mouse_select(C, co, extend);
+ return mouse_select(C, co, extend, deselect_all);
}
static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -424,11 +446,19 @@ void CLIP_OT_select(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
+ PropertyRNA *prop;
RNA_def_boolean(ot->srna,
"extend",
0,
"Extend",
"Extend selection rather than clearing the existing selection");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
RNA_def_float_vector(
ot->srna,
"location",
@@ -584,10 +614,12 @@ static int do_lasso_select_marker(bContext *C,
if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) {
- if (select)
+ if (select) {
BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
- else
+ }
+ else {
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
+ }
}
changed = true;
@@ -820,8 +852,9 @@ static int select_all_exec(bContext *C, wmOperator *op)
ED_clip_select_all(sc, action, &has_selection);
- if (!has_selection)
+ if (!has_selection) {
sc->flag &= ~SC_LOCK_SELECTION;
+ }
BKE_tracking_dopesheet_tag_update(tracking);
@@ -888,8 +921,9 @@ static int select_grouped_exec(bContext *C, wmOperator *op)
if (act_track) {
ok = (track->flag & TRACK_CUSTOMCOLOR) == (act_track->flag & TRACK_CUSTOMCOLOR);
- if (ok && track->flag & TRACK_CUSTOMCOLOR)
+ if (ok && track->flag & TRACK_CUSTOMCOLOR) {
ok = equals_v3v3(track->color, act_track->color);
+ }
}
}
else if (group == 6) { /* failed */
@@ -898,10 +932,12 @@ static int select_grouped_exec(bContext *C, wmOperator *op)
if (ok) {
track->flag |= SELECT;
- if (sc->flag & SC_SHOW_MARKER_PATTERN)
+ if (sc->flag & SC_SHOW_MARKER_PATTERN) {
track->pat_flag |= SELECT;
- if (sc->flag & SC_SHOW_MARKER_SEARCH)
+ }
+ if (sc->flag & SC_SHOW_MARKER_SEARCH) {
track->search_flag |= SELECT;
+ }
}
track = track->next;
diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt
index 5070b6fcf65..33934832ccc 100644
--- a/source/blender/editors/space_console/CMakeLists.txt
+++ b/source/blender/editors/space_console/CMakeLists.txt
@@ -24,8 +24,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index a17c1b675e6..1fc218c9461 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -144,14 +144,12 @@ static void console_lb_debug__internal(ListBase *lb)
for (cl = lb->first; cl; cl = cl->next)
printf("<%s> ", cl->line);
printf("\n");
-
}
static void console_history_debug(const bContext *C)
{
SpaceConsole *sc = CTX_wm_space_console(C);
-
console_lb_debug__internal(&sc->history);
}
#endif
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 2cf8f6c46b9..999255aef88 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -77,7 +77,7 @@ static SpaceLink *console_new(const ScrArea *UNUSED(area), const Scene *UNUSED(s
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
- //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
+ // ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
return (SpaceLink *)sconsole;
}
@@ -136,7 +136,7 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Console", SPACE_CONSOLE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* add drop boxes */
lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
@@ -231,9 +231,8 @@ static void console_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt
index 6bf975b98e0..33f57b9c235 100644
--- a/source/blender/editors/space_file/CMakeLists.txt
+++ b/source/blender/editors/space_file/CMakeLists.txt
@@ -22,15 +22,15 @@ set(INC
../../blenlib
../../blenloader
../../blentranslation
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../render/extern/include
../../windowmanager
../../../../intern/atomic
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 87560436d52..bb8680682d2 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -193,8 +193,9 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
/* TODO, directory editing is non-functional while a library is loaded
* until this is properly supported just disable it. */
- if (sfile->files && filelist_lib(sfile->files))
+ if (sfile->files && filelist_lib(sfile->files)) {
UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
if ((params->flag & FILE_DIRSEL_ONLY) == 0) {
but = uiDefBut(
@@ -660,8 +661,9 @@ void file_draw_list(const bContext *C, ARegion *ar)
}
offset = ED_fileselect_layout_offset(layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax);
- if (offset < 0)
+ if (offset < 0) {
offset = 0;
+ }
numfiles_layout = ED_fileselect_layout_numfiles(layout, ar);
@@ -689,7 +691,8 @@ void file_draw_list(const bContext *C, ARegion *ar)
filelist_cache_previews_update(files);
- /* Handle preview timer here, since it's filelist_file_cache_block() and filelist_cache_previews_update()
+ /* Handle preview timer here,
+ * since it's filelist_file_cache_block() and filelist_cache_previews_update()
* which controls previews task. */
{
const bool previews_running = filelist_cache_previews_running(files);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 073b6d0f487..674735f3e1d 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -119,8 +119,9 @@ static void clamp_to_filelist(int numfiles, FileSelection *sel)
}
/* fix if last file invalid */
- if ((sel->first > 0) && (sel->last < 0))
+ if ((sel->first > 0) && (sel->last < 0)) {
sel->last = numfiles - 1;
+ }
/* clamp */
if ((sel->first >= numfiles)) {
@@ -148,8 +149,9 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill
int f;
/* Try to find a smaller-index selected item. */
for (f = sel.last; f >= 0; f--) {
- if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL))
+ if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL)) {
break;
+ }
}
if (f >= 0) {
sel.first = f + 1;
@@ -157,8 +159,9 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill
/* If none found, try to find a higher-index selected item. */
else {
for (f = sel.first; f < numfiles; f++) {
- if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL))
+ if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL)) {
break;
+ }
}
if (f < numfiles) {
sel.last = f - 1;
@@ -298,8 +301,9 @@ static FileSelect file_select(
sfile->files, &sel, select, FILE_SEL_SELECTED, check_type);
/* Don't act on multiple selected files */
- if (sel.first != sel.last)
+ if (sel.first != sel.last) {
select = 0;
+ }
/* Do we have a valid selection and are we actually selecting */
if ((sel.last >= 0) && (select != FILE_SEL_REMOVE)) {
@@ -482,14 +486,16 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const bool fill = RNA_boolean_get(op->ptr, "fill");
const bool do_diropen = RNA_boolean_get(op->ptr, "open");
- if (ar->regiontype != RGN_TYPE_WINDOW)
+ if (ar->regiontype != RGN_TYPE_WINDOW) {
return OPERATOR_CANCELLED;
+ }
rect.xmin = rect.xmax = event->mval[0];
rect.ymin = rect.ymax = event->mval[1];
- if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin))
+ if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin)) {
return OPERATOR_CANCELLED;
+ }
if (sfile && sfile->params) {
int idx = sfile->params->highlight_file;
@@ -512,10 +518,12 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
}
- if (FILE_SELECT_DIR == ret)
+ if (FILE_SELECT_DIR == ret) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
- else if (FILE_SELECT_FILE == ret)
+ }
+ else if (FILE_SELECT_FILE == ret) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ }
WM_event_add_mousemove(C); /* for directory changes */
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
@@ -1149,8 +1157,9 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
FileSelectParams *params;
int numfiles, origfile;
- if (sfile == NULL || sfile->files == NULL)
+ if (sfile == NULL || sfile->files == NULL) {
return 0;
+ }
numfiles = filelist_files_ensure(sfile->files);
params = ED_fileselect_get_params(sfile);
@@ -1169,13 +1178,16 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
highlight_file = ED_fileselect_layout_offset(
sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy));
- if ((highlight_file >= 0) && (highlight_file < numfiles))
+ if ((highlight_file >= 0) && (highlight_file < numfiles)) {
params->highlight_file = highlight_file;
- else
+ }
+ else {
params->highlight_file = -1;
+ }
}
- else
+ else {
params->highlight_file = -1;
+ }
return (params->highlight_file != origfile);
}
@@ -1185,8 +1197,9 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv
ARegion *ar = CTX_wm_region(C);
SpaceFile *sfile = CTX_wm_space_file(C);
- if (!file_highlight_set(sfile, ar, event->x, event->y))
+ if (!file_highlight_set(sfile, ar, event->x, event->y)) {
return OPERATOR_PASS_THROUGH;
+ }
ED_area_tag_redraw(CTX_wm_area(C));
@@ -1223,8 +1236,9 @@ static bool file_operator_poll(bContext *C)
bool poll = ED_operator_file_active(C);
SpaceFile *sfile = CTX_wm_space_file(C);
- if (!sfile || !sfile->op)
+ if (!sfile || !sfile->op) {
poll = 0;
+ }
return poll;
}
@@ -1447,8 +1461,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
else if (sfile->op) {
wmOperator *op = sfile->op;
- /* when used as a macro, for doubleclick,
- * to prevent closing when doubleclicking on .. item */
+ /* When used as a macro, for double-click, to prevent closing when double-clicking on item. */
if (RNA_boolean_get(exec_op->ptr, "need_active")) {
const int numfiles = filelist_files_ensure(sfile->files);
int i, active = 0;
@@ -1459,8 +1472,9 @@ int file_exec(bContext *C, wmOperator *exec_op)
break;
}
}
- if (active == 0)
+ if (active == 0) {
return OPERATOR_CANCELLED;
+ }
}
sfile->op = NULL;
@@ -1575,8 +1589,9 @@ int file_previous_exec(bContext *C, wmOperator *UNUSED(unused))
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile->params) {
- if (!sfile->folders_next)
+ if (!sfile->folders_next) {
sfile->folders_next = folderlist_new();
+ }
folderlist_pushdir(sfile->folders_next, sfile->params->dir);
folderlist_popdir(sfile->folders_prev, sfile->params->dir);
@@ -1605,8 +1620,9 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused))
{
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile->params) {
- if (!sfile->folders_next)
+ if (!sfile->folders_next) {
sfile->folders_next = folderlist_new();
+ }
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
folderlist_popdir(sfile->folders_next, sfile->params->dir);
@@ -1633,13 +1649,15 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
int i;
/* escape if not our timer */
- if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata)
+ if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata) {
return OPERATOR_PASS_THROUGH;
+ }
numfiles = filelist_files_ensure(sfile->files);
/* Due to async nature of file listing, we may execute this code before `file_refresh()`
- * editing entry is available in our listing, so we also have to handle switching to rename mode here. */
+ * editing entry is available in our listing,
+ * so we also have to handle switching to rename mode here. */
FileSelectParams *params = ED_fileselect_get_params(sfile);
if ((params->rename_flag &
(FILE_PARAMS_RENAME_PENDING | FILE_PARAMS_RENAME_POSTSCROLL_PENDING)) != 0) {
@@ -1657,8 +1675,8 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
/* if we are not editing, we are done */
if (edit_idx == -1) {
- /* Do not invalidate timer if filerename is still pending, we might still be building the filelist
- * and yet have to find edited entry... */
+ /* Do not invalidate timer if filerename is still pending,
+ * we might still be building the filelist and yet have to find edited entry. */
if (params->rename_flag == 0) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
sfile->smoothscroll_timer = NULL;
@@ -1682,19 +1700,21 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
if (sfile->scroll_offset == 0) {
if (sfile->layout->flag & FILE_LAYOUT_HOR) {
sfile->scroll_offset = (edit_idx / sfile->layout->rows) * sfile->layout->rows;
- if (sfile->scroll_offset <= offset)
+ if (sfile->scroll_offset <= offset) {
sfile->scroll_offset -= sfile->layout->rows;
+ }
}
else {
sfile->scroll_offset = (edit_idx / sfile->layout->columns) * sfile->layout->columns;
- if (sfile->scroll_offset <= offset)
+ if (sfile->scroll_offset <= offset) {
sfile->scroll_offset -= sfile->layout->columns;
+ }
}
}
numfiles_layout = ED_fileselect_layout_numfiles(sfile->layout, ar);
- /* Using margins helps avoiding scrolling to stop when target item is barely visible on one side of the screen
- * (i.e. it centers a bit more the target). */
+ /* Using margins helps avoiding scrolling to stop when target item
+ * is barely visible on one side of the screen (i.e. it centers a bit more the target). */
int numfiles_layout_margin = max_ii(0, numfiles_layout / 3);
/* check if we have reached our final scroll position */
@@ -1702,7 +1722,8 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
(sfile->scroll_offset < offset + numfiles_layout - numfiles_layout_margin)) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
sfile->smoothscroll_timer = NULL;
- /* Postscroll (after rename has been validated by user) is done, rename process is totally finisehd, cleanup. */
+ /* Post-scroll (after rename has been validated by user) is done,
+ * rename process is totally finished, cleanup. */
if ((params->rename_flag & FILE_PARAMS_RENAME_POSTSCROLL_ACTIVE) != 0) {
params->renamefile[0] = '\0';
params->rename_flag = 0;
@@ -1791,8 +1812,10 @@ void FILE_OT_filepath_drop(wmOperatorType *ot)
RNA_def_string_file_path(ot->srna, "filepath", "Path", FILE_MAX, "", "");
}
-/* create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created.
- * The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name.
+/**
+ * Create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created.
+ * The actual name is returned in 'name', 'folder' contains the complete path,
+ * including the new folder name.
*/
static int new_folder_path(const char *parent, char *folder, char *name)
{
@@ -2026,8 +2049,9 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
#if defined(WIN32)
else if (!can_create_dir(sfile->params->dir)) {
const char *lastdir = folderlist_peeklastdir(sfile->folders_prev);
- if (lastdir)
+ if (lastdir) {
BLI_strncpy(sfile->params->dir, lastdir, sizeof(sfile->params->dir));
+ }
}
#endif
else {
@@ -2046,8 +2070,9 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
RNA_string_set(&ptr, "directory", sfile->params->dir);
RNA_boolean_set(&ptr, "open", true);
- if (lastdir)
+ if (lastdir) {
BLI_strncpy(sfile->params->dir, lastdir, sizeof(sfile->params->dir));
+ }
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr);
WM_operator_properties_free(&ptr);
@@ -2149,15 +2174,17 @@ ARegion *file_tools_region(ScrArea *sa)
{
ARegion *ar, *arnew;
- if ((ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS)) != NULL)
+ if ((ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS)) != NULL) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "tools for file");
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
@@ -2177,8 +2204,9 @@ static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused))
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = file_tools_region(sa);
- if (ar)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
@@ -2220,8 +2248,9 @@ static void filenum_newname(char *name, size_t name_size, int add)
}
pic += add;
- if (pic < 0)
+ if (pic < 0) {
pic = 0;
+ }
BLI_stringenc(name_temp, head, tail, digits, pic);
BLI_strncpy(name, name_temp, name_size);
}
@@ -2270,7 +2299,8 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
filelist_entry_select_index_set(
sfile->files, idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL);
BLI_strncpy(sfile->params->renamefile, file->relpath, FILE_MAXFILE);
- /* We can skip the pending state, as we can directly set FILE_SEL_EDITING on the expected entry here. */
+ /* We can skip the pending state,
+ * as we can directly set FILE_SEL_EDITING on the expected entry here. */
sfile->params->rename_flag = FILE_PARAMS_RENAME_ACTIVE;
}
ED_area_tag_redraw(sa);
@@ -2335,8 +2365,9 @@ static bool file_delete_poll(bContext *C)
int i;
int num_selected = 0;
- if (filelist_islibrary(sfile->files, dir, NULL))
+ if (filelist_islibrary(sfile->files, dir, NULL)) {
poll = 0;
+ }
for (i = 0; i < numfiles; i++) {
if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) {
num_selected++;
@@ -2346,8 +2377,9 @@ static bool file_delete_poll(bContext *C)
poll = 0;
}
}
- else
+ else {
poll = 0;
+ }
return poll;
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 31a59f06079..564dd0ec81d 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -139,8 +139,9 @@ const char *folderlist_peeklastdir(ListBase *folderlist)
{
struct FolderList *folder;
- if (!folderlist->last)
+ if (!folderlist->last) {
return NULL;
+ }
folder = folderlist->last;
return folder->foldername;
@@ -151,14 +152,16 @@ int folderlist_clear_next(struct SpaceFile *sfile)
struct FolderList *folder;
/* if there is no folder_next there is nothing we can clear */
- if (!sfile->folders_next)
+ if (!sfile->folders_next) {
return 0;
+ }
/* if previous_folder, next_folder or refresh_folder operators are executed
* it doesn't clear folder_next */
folder = sfile->folders_prev->last;
- if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0))
+ if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) {
return 0;
+ }
/* eventually clear flist->folders_next */
return 1;
@@ -169,8 +172,9 @@ void folderlist_free(ListBase *folderlist)
{
if (folderlist) {
FolderList *folder;
- for (folder = folderlist->first; folder; folder = folder->next)
+ for (folder = folderlist->first; folder; folder = folder->next) {
MEM_freeN(folder->foldername);
+ }
BLI_freelistN(folderlist);
}
}
@@ -293,9 +297,11 @@ typedef struct FileList {
struct FileListEntryCache filelist_cache;
- /* We need to keep those info outside of actual filelist items, because those are no more persistent
+ /* We need to keep those info outside of actual filelist items,
+ * because those are no more persistent
* (only generated on demand, and freed as soon as possible).
- * Persistent part (mere list of paths + stat info) is kept as small as possible, and filebrowser-agnostic.
+ * Persistent part (mere list of paths + stat info)
+ * is kept as small as possible, and filebrowser-agnostic.
*/
GHash *selection_state;
@@ -304,7 +310,8 @@ typedef struct FileList {
struct BlendHandle *libfiledata;
- /* Set given path as root directory, if last bool is true may change given string in place to a valid value.
+ /* Set given path as root directory,
+ * if last bool is true may change given string in place to a valid value.
* Returns True if valid dir. */
bool (*checkdirf)(struct FileList *, char *, const bool);
@@ -397,14 +404,18 @@ static int compare_direntry_generic(const FileListInternEntry *entry1,
}
/* make sure "." and ".." are always first */
- if (FILENAME_IS_CURRENT(entry1->relpath))
+ if (FILENAME_IS_CURRENT(entry1->relpath)) {
return -1;
- if (FILENAME_IS_CURRENT(entry2->relpath))
+ }
+ if (FILENAME_IS_CURRENT(entry2->relpath)) {
return 1;
- if (FILENAME_IS_PARENT(entry1->relpath))
+ }
+ if (FILENAME_IS_PARENT(entry1->relpath)) {
return -1;
- if (FILENAME_IS_PARENT(entry2->relpath))
+ }
+ if (FILENAME_IS_PARENT(entry2->relpath)) {
return 1;
+ }
return 0;
}
@@ -440,10 +451,12 @@ static int compare_date(void *UNUSED(user_data), const void *a1, const void *a2)
time1 = (int64_t)entry1->st.st_mtime;
time2 = (int64_t)entry2->st.st_mtime;
- if (time1 < time2)
+ if (time1 < time2) {
return 1;
- if (time1 > time2)
+ }
+ if (time1 > time2) {
return -1;
+ }
name1 = entry1->name;
name2 = entry2->name;
@@ -465,10 +478,12 @@ static int compare_size(void *UNUSED(user_data), const void *a1, const void *a2)
size1 = entry1->st.st_size;
size2 = entry2->st.st_size;
- if (size1 < size2)
+ if (size1 < size2) {
return 1;
- if (size1 > size2)
+ }
+ if (size1 > size2) {
return -1;
+ }
name1 = entry1->name;
name2 = entry2->name;
@@ -487,31 +502,41 @@ static int compare_extension(void *UNUSED(user_data), const void *a1, const void
return ret;
}
- if ((entry1->typeflag & FILE_TYPE_BLENDERLIB) && !(entry2->typeflag & FILE_TYPE_BLENDERLIB))
+ if ((entry1->typeflag & FILE_TYPE_BLENDERLIB) && !(entry2->typeflag & FILE_TYPE_BLENDERLIB)) {
return -1;
- if (!(entry1->typeflag & FILE_TYPE_BLENDERLIB) && (entry2->typeflag & FILE_TYPE_BLENDERLIB))
+ }
+ if (!(entry1->typeflag & FILE_TYPE_BLENDERLIB) && (entry2->typeflag & FILE_TYPE_BLENDERLIB)) {
return 1;
+ }
if ((entry1->typeflag & FILE_TYPE_BLENDERLIB) && (entry2->typeflag & FILE_TYPE_BLENDERLIB)) {
- if ((entry1->typeflag & FILE_TYPE_DIR) && !(entry2->typeflag & FILE_TYPE_DIR))
+ if ((entry1->typeflag & FILE_TYPE_DIR) && !(entry2->typeflag & FILE_TYPE_DIR)) {
return 1;
- if (!(entry1->typeflag & FILE_TYPE_DIR) && (entry2->typeflag & FILE_TYPE_DIR))
+ }
+ if (!(entry1->typeflag & FILE_TYPE_DIR) && (entry2->typeflag & FILE_TYPE_DIR)) {
return -1;
- if (entry1->blentype < entry2->blentype)
+ }
+ if (entry1->blentype < entry2->blentype) {
return -1;
- if (entry1->blentype > entry2->blentype)
+ }
+ if (entry1->blentype > entry2->blentype) {
return 1;
+ }
}
else {
const char *sufix1, *sufix2;
- if (!(sufix1 = strstr(entry1->relpath, ".blend.gz")))
+ if (!(sufix1 = strstr(entry1->relpath, ".blend.gz"))) {
sufix1 = strrchr(entry1->relpath, '.');
- if (!(sufix2 = strstr(entry2->relpath, ".blend.gz")))
+ }
+ if (!(sufix2 = strstr(entry2->relpath, ".blend.gz"))) {
sufix2 = strrchr(entry2->relpath, '.');
- if (!sufix1)
+ }
+ if (!sufix1) {
sufix1 = "";
- if (!sufix2)
+ }
+ if (!sufix2) {
sufix2 = "";
+ }
if ((ret = BLI_strcasecmp(sufix1, sufix2))) {
return ret;
@@ -951,28 +976,39 @@ static int filelist_geticon_ex(const int typeflag,
}
}
- if (typeflag & FILE_TYPE_BLENDER)
+ if (typeflag & FILE_TYPE_BLENDER) {
return ICON_FILE_BLEND;
- else if (typeflag & FILE_TYPE_BLENDER_BACKUP)
+ }
+ else if (typeflag & FILE_TYPE_BLENDER_BACKUP) {
return ICON_FILE_BACKUP;
- else if (typeflag & FILE_TYPE_IMAGE)
+ }
+ else if (typeflag & FILE_TYPE_IMAGE) {
return ICON_FILE_IMAGE;
- else if (typeflag & FILE_TYPE_MOVIE)
+ }
+ else if (typeflag & FILE_TYPE_MOVIE) {
return ICON_FILE_MOVIE;
- else if (typeflag & FILE_TYPE_PYSCRIPT)
+ }
+ else if (typeflag & FILE_TYPE_PYSCRIPT) {
return ICON_FILE_SCRIPT;
- else if (typeflag & FILE_TYPE_SOUND)
+ }
+ else if (typeflag & FILE_TYPE_SOUND) {
return ICON_FILE_SOUND;
- else if (typeflag & FILE_TYPE_FTFONT)
+ }
+ else if (typeflag & FILE_TYPE_FTFONT) {
return ICON_FILE_FONT;
- else if (typeflag & FILE_TYPE_BTX)
+ }
+ else if (typeflag & FILE_TYPE_BTX) {
return ICON_FILE_BLANK;
- else if (typeflag & FILE_TYPE_COLLADA)
+ }
+ else if (typeflag & FILE_TYPE_COLLADA) {
return ICON_FILE_BLANK;
- else if (typeflag & FILE_TYPE_ALEMBIC)
+ }
+ else if (typeflag & FILE_TYPE_ALEMBIC) {
return ICON_FILE_BLANK;
- else if (typeflag & FILE_TYPE_TEXT)
+ }
+ else if (typeflag & FILE_TYPE_TEXT) {
return ICON_FILE_TEXT;
+ }
else if (typeflag & FILE_TYPE_BLENDERLIB) {
const int ret = UI_idcode_icon_get(blentype);
if (ret != ICON_NONE) {
@@ -1177,8 +1213,8 @@ static void filelist_cache_preview_freef(TaskPool *__restrict UNUSED(pool),
{
FileListEntryPreview *preview = taskdata;
- /* If preview->flag is empty, it means that preview has already been generated and added to done queue,
- * we do not own it anymore. */
+ /* If preview->flag is empty, it means that preview has already been generated and
+ * added to done queue, we do not own it anymore. */
if (preview->flags) {
if (preview->img) {
IMB_freeImBuf(preview->img);
@@ -1207,7 +1243,7 @@ static void filelist_cache_previews_clear(FileListEntryCache *cache)
BLI_task_pool_cancel(cache->previews_pool);
while ((preview = BLI_thread_queue_pop_timeout(cache->previews_done, 0))) {
- // printf("%s: DONE %d - %s - %p\n", __func__, preview->index, preview->path, preview->img);
+ // printf("%s: DONE %d - %s - %p\n", __func__, preview->index, preview->path, preview->img);
if (preview->img) {
IMB_freeImBuf(preview->img);
}
@@ -1421,8 +1457,9 @@ void filelist_free(struct FileList *filelist)
void filelist_freelib(struct FileList *filelist)
{
- if (filelist->libfiledata)
+ if (filelist->libfiledata) {
BLO_blendhandle_close(filelist->libfiledata);
+ }
filelist->libfiledata = NULL;
}
@@ -1514,8 +1551,10 @@ bool filelist_pending(struct FileList *filelist)
}
/**
- * Limited version of full update done by space_file's file_refresh(), to be used by operators and such.
- * Ensures given filelist is ready to be used (i.e. it is filtered and sorted), unless it is tagged for a full refresh.
+ * Limited version of full update done by space_file's file_refresh(),
+ * to be used by operators and such.
+ * Ensures given filelist is ready to be used (i.e. it is filtered and sorted),
+ * unless it is tagged for a full refresh.
*/
int filelist_files_ensure(FileList *filelist)
{
@@ -1717,7 +1756,11 @@ static void filelist_file_cache_block_release(struct FileList *filelist,
for (i = 0; i < size; i++, cursor++) {
FileDirEntry *entry = cache->block_entries[cursor];
- // printf("%s: release cacheidx %d (%%p %%s)\n", __func__, cursor/*, cache->block_entries[cursor], cache->block_entries[cursor]->relpath*/);
+#if 0
+ printf("%s: release cacheidx %d (%%p %%s)\n",
+ __func__,
+ cursor /*, cache->block_entries[cursor], cache->block_entries[cursor]->relpath*/);
+#endif
BLI_ghash_remove(cache->uuids, entry->uuid, NULL, NULL);
filelist_file_release_entry(filelist, entry);
#ifndef NDEBUG
@@ -1828,8 +1871,12 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index)
int size2 = 0;
int idx1, idx2 = 0;
- // printf("\tcache releasing: [%d:%d] (%d)\n",
- // cache->block_end_index - size1, cache->block_end_index, cache->block_cursor);
+#if 0
+ printf("\tcache releasing: [%d:%d] (%d)\n",
+ cache->block_end_index - size1,
+ cache->block_end_index,
+ cache->block_cursor);
+#endif
idx1 = (cache->block_cursor + end_index - cache->block_start_index) % cache_size;
if (idx1 + size1 > cache_size) {
@@ -1988,8 +2035,8 @@ bool filelist_cache_previews_update(FileList *filelist)
// printf("%s: %d - %s - %p\n", __func__, preview->index, preview->path, preview->img);
if (preview->img) {
- /* Due to asynchronous process, a preview for a given image may be generated several times, i.e.
- * entry->image may already be set at this point. */
+ /* Due to asynchronous process, a preview for a given image may be generated several times,
+ * i.e. entry->image may already be set at this point. */
if (entry && !entry->image) {
entry->image = preview->img;
changed = true;
@@ -2031,14 +2078,16 @@ static bool file_is_blend_backup(const char *str)
else {
const char *loc;
- if (a > b + 1)
+ if (a > b + 1) {
b++;
+ }
/* allow .blend1 .blend2 .blend32 */
loc = BLI_strcasestr(str + a - b, ".blend");
- if (loc)
+ if (loc) {
retval = 1;
+ }
}
return (retval);
@@ -2261,8 +2310,9 @@ static int groupname_to_code(const char *group)
BLI_strncpy(buf, group, sizeof(buf));
lslash = (char *)BLI_last_slash(buf);
- if (lslash)
+ if (lslash) {
lslash[0] = '\0';
+ }
return buf[0] ? BKE_idcode_from_name(buf) : 0;
}
@@ -2275,7 +2325,8 @@ static unsigned int groupname_to_filter_id(const char *group)
}
/**
- * From here, we are in 'Job Context', i.e. have to be careful about sharing stuff between background working thread
+ * From here, we are in 'Job Context',
+ * i.e. have to be careful about sharing stuff between background working thread.
* and main one (used by UI among other things).
*/
typedef struct TodoDir {
@@ -2420,11 +2471,13 @@ static void filelist_readjob_main_rec(Main *bmain, FileList *filelist)
BLI_assert(filelist->filelist.entries == NULL);
- if (filelist->filelist.root[0] == '/') filelist->filelist.root[0] = '\0';
+ if (filelist->filelist.root[0] == '/')
+ filelist->filelist.root[0] = '\0';
if (filelist->filelist.root[0]) {
idcode = groupname_to_code(filelist->filelist.root);
- if (idcode == 0) filelist->filelist.root[0] = '\0';
+ if (idcode == 0)
+ filelist->filelist.root[0] = '\0';
}
if (filelist->dir[0] == 0) {
@@ -2472,7 +2525,8 @@ static void filelist_readjob_main_rec(Main *bmain, FileList *filelist)
idcode = groupname_to_code(filelist->filelist.root);
lb = which_libbase(bmain, idcode);
- if (lb == NULL) return;
+ if (lb == NULL)
+ return;
filelist->filelist.nbr_entries = 0;
for (id = lb->first; id; id = id->next) {
@@ -2516,26 +2570,42 @@ static void filelist_readjob_main_rec(Main *bmain, FileList *filelist)
# if 0 /* XXX TODO show the selection status of the objects */
if (!filelist->has_func) { /* F4 DATA BROWSE */
if (idcode == ID_OB) {
- if ( ((Object *)id)->flag & SELECT) files->entry->selflag |= FILE_SEL_SELECTED;
+ if ( ((Object *)id)->flag & SELECT) {
+ files->entry->selflag |= FILE_SEL_SELECTED;
+ }
}
else if (idcode == ID_SCE) {
- if ( ((Scene *)id)->r.scemode & R_BG_RENDER) files->entry->selflag |= FILE_SEL_SELECTED;
+ if ( ((Scene *)id)->r.scemode & R_BG_RENDER) {
+ files->entry->selflag |= FILE_SEL_SELECTED;
+ }
}
}
# endif
-// files->entry->nr = totbl + 1;
+ // files->entry->nr = totbl + 1;
files->entry->poin = id;
fake = id->flag & LIB_FAKEUSER;
- if (idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) {
+ if (idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO ||
+ idcode == ID_IM) {
files->typeflag |= FILE_TYPE_IMAGE;
}
-// if (id->lib && fake) BLI_snprintf(files->extra, sizeof(files->entry->extra), "LF %d", id->us);
-// else if (id->lib) BLI_snprintf(files->extra, sizeof(files->entry->extra), "L %d", id->us);
-// else if (fake) BLI_snprintf(files->extra, sizeof(files->entry->extra), "F %d", id->us);
-// else BLI_snprintf(files->extra, sizeof(files->entry->extra), " %d", id->us);
+# if 0
+ if (id->lib && fake) {
+ BLI_snprintf(files->extra, sizeof(files->entry->extra), "LF %d", id->us);
+ }
+ else if (id->lib) {
+ BLI_snprintf(files->extra, sizeof(files->entry->extra), "L %d", id->us);
+ }
+ else if (fake) {
+ BLI_snprintf(files->extra, sizeof(files->entry->extra), "F %d", id->us);
+ }
+ else {
+ BLI_snprintf(files->extra, sizeof(files->entry->extra), " %d", id->us);
+ }
+# endif
if (id->lib) {
- if (totlib == 0) firstlib = files;
+ if (totlib == 0)
+ firstlib = files;
totlib++;
}
@@ -2634,7 +2704,7 @@ static void filelist_readjob_do(const bool do_lib,
/* Only thing we change in direntry here, so we need to free it first. */
MEM_freeN(entry->relpath);
entry->relpath = BLI_strdup(dir + 2); /* + 2 to remove '//'
- * added by BLI_path_rel to rel_subdir */
+ * added by BLI_path_rel to rel_subdir. */
entry->name = BLI_strdup(fileentry_uiname(root, entry->relpath, entry->typeflag, dir));
/* Here we decide whether current filedirentry is to be listed too, or not. */
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 24689d52110..e5f19f0164d 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -161,32 +161,45 @@ short ED_fileselect_set_params(SpaceFile *sfile)
}
params->filter = 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_blender")))
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_blender"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BLENDER : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_blenlib")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_blenlib"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BLENDERLIB : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_backup")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_backup"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BLENDER_BACKUP : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_image")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_image"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_IMAGE : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_movie")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_movie"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_MOVIE : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_python")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_python"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_PYSCRIPT : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_font")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_font"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_FTFONT : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_sound")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_sound"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_SOUND : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_text")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_text"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_TEXT : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_folder")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_folder"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_FOLDER : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_btx")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_btx"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BTX : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_collada")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_collada"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_COLLADA : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_alembic")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_alembic"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_ALEMBIC : 0;
+ }
if ((prop = RNA_struct_find_property(op->ptr, "filter_glob"))) {
/* Protection against pyscripts not setting proper size limit... */
char *tmp = RNA_property_string_get_alloc(
@@ -290,8 +303,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->active_file = -1;
/* initialize the list with previous folders */
- if (!sfile->folders_prev)
+ if (!sfile->folders_prev) {
sfile->folders_prev = folderlist_new();
+ }
if (!sfile->params->dir[0]) {
if (blendfile_path[0] != '\0') {
@@ -375,8 +389,9 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
FileSelection sel;
sel.first = sel.last = -1;
- if (layout == NULL)
+ if (layout == NULL) {
return sel;
+ }
colmin = (rect->xmin) / (layout->tile_w + 2 * layout->tile_border_x);
rowmin = (rect->ymin) / (layout->tile_h + 2 * layout->tile_border_y);
@@ -395,19 +410,23 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
sel.first = -1;
}
else {
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR) {
sel.first = layout->rows * colmin + rowmin;
- else
+ }
+ else {
sel.first = colmin + layout->columns * rowmin;
+ }
}
if ((colmax > layout->columns - 1) || (rowmax > layout->rows - 1)) {
sel.last = -1;
}
else {
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR) {
sel.last = layout->rows * colmax + rowmax;
- else
+ }
+ else {
sel.last = colmax + layout->columns * rowmax;
+ }
}
return sel;
@@ -418,21 +437,26 @@ int ED_fileselect_layout_offset(FileLayout *layout, int x, int y)
int offsetx, offsety;
int active_file;
- if (layout == NULL)
+ if (layout == NULL) {
return -1;
+ }
offsetx = (x) / (layout->tile_w + 2 * layout->tile_border_x);
offsety = (y) / (layout->tile_h + 2 * layout->tile_border_y);
- if (offsetx > layout->columns - 1)
+ if (offsetx > layout->columns - 1) {
return -1;
- if (offsety > layout->rows - 1)
+ }
+ if (offsety > layout->rows - 1) {
return -1;
+ }
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR) {
active_file = layout->rows * offsetx + offsety;
- else
+ }
+ else {
active_file = offsetx + layout->columns * offsety;
+ }
return active_file;
}
@@ -536,8 +560,9 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight;
layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x);
- if (layout->columns > 0)
+ if (layout->columns > 0) {
layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero
+ }
else {
layout->columns = 1;
layout->rows = numfiles + 1; // XXX dirty, modulo is zero
@@ -577,8 +602,9 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
(int)layout->column_widths[COLUMN_SIZE] + column_space;
}
layout->tile_w = maxlen;
- if (layout->rows > 0)
+ if (layout->rows > 0) {
layout->columns = numfiles / layout->rows + 1; // XXX dirty, modulo is zero
+ }
else {
layout->rows = 1;
layout->columns = numfiles + 1; // XXX dirty, modulo is zero
@@ -619,8 +645,9 @@ void ED_file_change_dir(bContext *C)
}
filelist_setdir(sfile->files, sfile->params->dir);
- if (folderlist_clear_next(sfile))
+ if (folderlist_clear_next(sfile)) {
folderlist_free(sfile->folders_next);
+ }
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
@@ -739,8 +766,9 @@ void ED_fileselect_clear(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
{
- if (!sfile)
+ if (!sfile) {
return;
+ }
if (sfile->op) {
WM_event_fileselect_event(wm, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL);
sfile->op = NULL;
@@ -757,8 +785,8 @@ void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
}
}
-/** Helper used by both main update code, and smoothscroll timer, to try to enable rename editing from
- * params->renamefile name. */
+/** Helper used by both main update code, and smoothscroll timer,
+ * to try to enable rename editing from #FileSelectParams.renamefile name. */
void file_params_renamefile_activate(SpaceFile *sfile, FileSelectParams *params)
{
BLI_assert(params->rename_flag != 0);
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index f14148abe86..38423a87447 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -39,7 +39,7 @@
/* Need to include windows.h so _WIN32_IE is defined. */
# include <windows.h>
/* For SHGetSpecialFolderPath, has to be done before BLI_winstuff
- * because 'near' is disabled through BLI_windstuff. */
+ * because 'near' is disabled through BLI_windstuff. */
# include <shlobj.h>
# include "BLI_winstuff.h"
#endif
@@ -219,9 +219,8 @@ void fsmenu_entry_refresh_valid(struct FSMenuEntry *fsentry)
if (fsentry->path && fsentry->path[0]) {
#ifdef WIN32
/* XXX Special case, always consider those as valid.
- * Thanks to Windows, which can spend five seconds to perform a mere stat() call on those paths...
- * See T43684.
- */
+ * Thanks to Windows, which can spend five seconds to perform a mere stat() call on those paths
+ * See T43684. */
const char *exceptions[] = {"A:\\", "B:\\", NULL};
const size_t exceptions_len[] = {strlen(exceptions[0]), strlen(exceptions[1]), 0};
int i;
@@ -297,8 +296,8 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu,
fsm_iter->save = (flag & FS_INSERT_SAVE) != 0;
if ((category == FS_CATEGORY_RECENT) && (!name || !name[0])) {
- /* Special handling when adding new recent entry - check if dir exists in some other categories,
- * and try to use name from there if so. */
+ /* Special handling when adding new recent entry - check if dir exists in
+ * some other categories, and try to use name from there if so. */
FSMenuCategory cats[] = {
FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, FS_CATEGORY_BOOKMARKS};
int i = ARRAY_SIZE(cats);
@@ -352,8 +351,9 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx
fsm_head = ED_fsmenu_get_category(fsmenu, category);
- for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next)
+ for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next) {
idx--;
+ }
if (fsm_iter) {
/* you should only be able to remove entries that were
@@ -383,8 +383,9 @@ void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename)
int nwritten = 0;
FILE *fp = BLI_fopen(filename, "w");
- if (!fp)
+ if (!fp) {
return;
+ }
fprintf(fp, "[Bookmarks]\n");
for (fsm_iter = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsm_iter;
@@ -420,8 +421,9 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
FILE *fp;
fp = BLI_fopen(filename, "r");
- if (!fp)
+ if (!fp) {
return;
+ }
name[0] = '\0';
@@ -519,11 +521,12 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
#else
# ifdef __APPLE__
{
- /* Get mounted volumes better method OSX 10.6 and higher, see: */
- /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/
+ /* Get mounted volumes better method OSX 10.6 and higher, see:
+ * https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html
+ */
- /* we get all volumes sorted including network and do not relay
- * on user-defined finder visibility, less confusing */
+ /* We get all volumes sorted including network and do not relay
+ * on user-defined finder visibility, less confusing. */
CFURLRef cfURL = NULL;
CFURLEnumeratorResult result = kCFURLEnumeratorSuccess;
@@ -534,8 +537,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
char defPath[FILE_MAX];
result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL);
- if (result != kCFURLEnumeratorSuccess)
+ if (result != kCFURLEnumeratorSuccess) {
continue;
+ }
CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX);
@@ -565,14 +569,16 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
kLSSharedFileListDoNotMountVolumes,
&cfURL,
NULL);
- if (err != noErr || !cfURL)
+ if (err != noErr || !cfURL) {
continue;
+ }
CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle);
if (pathString == NULL ||
- !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8))
+ !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) {
continue;
+ }
/* Add end slash for consistency with other platforms */
BLI_add_slash(line);
@@ -678,8 +684,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
# endif
/* fallback */
- if (!found)
+ if (!found) {
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", NULL, FS_INSERT_SORTED);
+ }
}
}
# endif
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 53bcf7068f4..9fb07042104 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -155,8 +155,9 @@ static void file_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
*/
fsmenu_refresh_bookmarks_status(ED_fsmenu_get());
- if (sfile->layout)
+ if (sfile->layout) {
sfile->layout->dirty = true;
+ }
}
static void file_exit(wmWindowManager *wm, ScrArea *sa)
@@ -188,11 +189,13 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
filelist_setdir(sfilen->files, sfilen->params->dir);
}
- if (sfileo->folders_prev)
+ if (sfileo->folders_prev) {
sfilen->folders_prev = folderlist_duplicate(sfileo->folders_prev);
+ }
- if (sfileo->folders_next)
+ if (sfileo->folders_next) {
sfilen->folders_next = folderlist_duplicate(sfileo->folders_next);
+ }
if (sfileo->layout) {
sfilen->layout = MEM_dupallocN(sfileo->layout);
@@ -313,10 +316,10 @@ static void file_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Main", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void file_main_region_listener(wmWindow *UNUSED(win),
@@ -389,8 +392,9 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
float col[3];
/* Needed, because filelist is not initialized on loading */
- if (!sfile->files || filelist_empty(sfile->files))
+ if (!sfile->files || filelist_empty(sfile->files)) {
file_refresh(C, NULL);
+ }
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
@@ -437,9 +441,8 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -494,7 +497,7 @@ static void file_tools_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void file_tools_region_draw(const bContext *C, ARegion *ar)
@@ -524,7 +527,7 @@ static void file_header_region_init(wmWindowManager *wm, ARegion *ar)
ED_region_header_init(ar);
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void file_header_region_draw(const bContext *C, ARegion *ar)
@@ -541,10 +544,10 @@ static void file_ui_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "File Browser Buttons", SPACE_FILE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void file_ui_region_draw(const bContext *C, ARegion *ar)
diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt
index cf5ffdb2be5..f4d31886e3f 100644
--- a/source/blender/editors/space_graph/CMakeLists.txt
+++ b/source/blender/editors/space_graph/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index ac77095cbe2..3b1e70b8db7 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -76,23 +76,30 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **
bAnimContext ac;
bAnimListElem *elem = NULL;
- /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
- * to work correctly is able to be correctly retrieved. There's no point showing empty panels?
+ /* For now, only draw if we could init the anim-context info
+ * (necessary for all animation-related tools)
+ * to work correctly is able to be correctly retrieved.
+ * There's no point showing empty panels?
*/
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
/* try to find 'active' F-Curve */
elem = get_active_fcurve_channel(&ac);
- if (elem == NULL)
+ if (elem == NULL) {
return 0;
+ }
- if (fcu)
+ if (fcu) {
*fcu = (FCurve *)elem->data;
- if (ale)
+ }
+ if (ale) {
*ale = elem;
- else
+ }
+ else {
MEM_freeN(elem);
+ }
return 1;
}
@@ -128,10 +135,12 @@ static void graph_panel_view(const bContext *C, Panel *pa)
sub = uiLayoutColumn(col, true);
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
row = uiLayoutSplit(sub, 0.7f, true);
- if (sipo->mode == SIPO_MODE_DRIVERS)
+ if (sipo->mode == SIPO_MODE_DRIVERS) {
uiItemR(row, &spaceptr, "cursor_position_x", 0, IFACE_("Cursor X"), ICON_NONE);
- else
+ }
+ else {
uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
+ }
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
row = uiLayoutSplit(sub, 0.7f, true);
@@ -151,8 +160,9 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
char name[256];
int icon = 0;
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
/* F-Curve pointer */
RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
@@ -177,8 +187,9 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
}
/* icon */
- if (ale->type == ANIMTYPE_NLACURVE)
+ if (ale->type == ANIMTYPE_NLACURVE) {
icon = ICON_NLA;
+ }
}
uiItemL(col, name, icon);
@@ -219,8 +230,9 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT
*bezt = *prevbezt = NULL;
/* sanity checks */
- if ((fcu->bezt == NULL) || (fcu->totvert == 0))
+ if ((fcu->bezt == NULL) || (fcu->totvert == 0)) {
return 0;
+ }
/* find first selected keyframe for now, and call it the active one
* - this is a reasonable assumption, given that whenever anyone
@@ -330,8 +342,9 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
uiLayout *col;
uiBlock *block;
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
block = uiLayoutGetBlock(layout);
/* UI_block_func_handle_set(block, do_graph_region_buttons, NULL); */
@@ -365,8 +378,9 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
}
/* easing type */
- if (bezt->ipo > BEZT_IPO_BEZ)
+ if (bezt->ipo > BEZT_IPO_BEZ) {
uiItemR(col, &bezt_ptr, "easing", 0, NULL, 0);
+ }
/* easing extra */
switch (bezt->ipo) {
@@ -565,8 +579,9 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
IFACE_("F-Curve doesn't have any keyframes as it only contains sampled points"),
ICON_NONE);
}
- else
+ else {
uiItemL(layout, IFACE_("No active keyframe on F-Curve"), ICON_NONE);
+ }
}
MEM_freeN(ale);
@@ -693,8 +708,9 @@ static bool graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
{
SpaceGraph *sipo = CTX_wm_space_graph(C);
- if (sipo->mode != SIPO_MODE_DRIVERS)
+ if (sipo->mode != SIPO_MODE_DRIVERS) {
return 0;
+ }
return graph_panel_context(C, NULL, NULL);
}
@@ -869,7 +885,8 @@ static void graph_draw_driven_property_panel(uiLayout *layout, ID *id, FCurve *f
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
/* -> user friendly 'name' for datablock that owns F-Curve */
- /* XXX: Actually, we may need the datablock icons only... (e.g. right now will show bone for bone props) */
+ /* XXX: Actually, we may need the datablock icons only...
+ * (e.g. right now will show bone for bone props). */
uiItemL(row, id->name + 2, icon);
/* -> user friendly 'name' for F-Curve/driver target */
@@ -915,7 +932,8 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
uiItemS(layout);
uiItemS(layout);
- /* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
+ /* show expression box if doing scripted drivers,
+ * and/or error messages when invalid drivers exist */
if (driver->type == DRIVER_TYPE_PYTHON) {
bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL);
bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL);
@@ -965,8 +983,9 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
col = uiLayoutColumn(layout, true);
block = uiLayoutGetBlock(col);
- if (driver->flag & DRIVER_FLAG_INVALID)
+ if (driver->flag & DRIVER_FLAG_INVALID) {
uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR);
+ }
/* Warnings about a lack of variables
* NOTE: The lack of variables is generally a bad thing, since it indicates
@@ -1190,14 +1209,16 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
/* ----------------------------------------------------------------- */
-/* panel to show property driven by the driver (in Drivers Editor) - duplicates Active FCurve, but useful for clarity */
+/* Panel to show property driven by the driver (in Drivers Editor) - duplicates Active FCurve,
+ * but useful for clarity. */
static void graph_panel_driven_property(const bContext *C, Panel *pa)
{
bAnimListElem *ale;
FCurve *fcu;
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
graph_draw_driven_property_panel(pa->layout, ale->id, fcu);
@@ -1212,8 +1233,9 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
FCurve *fcu;
/* Get settings from context */
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
graph_draw_driver_settings_panel(pa->layout, ale->id, fcu, false);
@@ -1223,7 +1245,8 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
/* ----------------------------------------------------------------- */
-/* poll to make this not show up in the graph editor, as this is only to be used as a popup elsewhere */
+/* Poll to make this not show up in the graph editor,
+ * as this is only to be used as a popup elsewhere. */
static bool graph_panel_drivers_popover_poll(const bContext *C, PanelType *UNUSED(pt))
{
return ED_operator_graphedit_active((bContext *)C) == false;
@@ -1255,7 +1278,7 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *pa)
uiLayoutSetContextFromBut(layout, but);
/* Populate Panel - With a combination of the contents of the Driven and Driver panels */
- if (fcu) {
+ if (fcu && fcu->driver) {
ID *id = ptr.id.data;
/* Driven Property Settings */
@@ -1300,8 +1323,9 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa)
uiBlock *block;
bool active;
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
block = uiLayoutGetBlock(pa->layout);
UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL);
@@ -1405,27 +1429,3 @@ void graph_buttons_register(ARegionType *art)
pt->draw = graph_panel_view;
BLI_addtail(&art->paneltypes, pt);
}
-
-static int graph_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = graph_has_buttons_region(sa);
-
- if (ar)
- ED_region_toggle_hidden(C, ar);
-
- return OPERATOR_FINISHED;
-}
-
-void GRAPH_OT_properties(wmOperatorType *ot)
-{
- ot->name = "Toggle Sidebar";
- ot->idname = "GRAPH_OT_properties";
- ot->description = "Toggle the properties region visibility";
-
- ot->exec = graph_properties_toggle_exec;
- ot->poll = ED_operator_graphedit_active;
-
- /* flags */
- ot->flag = 0;
-}
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 5bfe1c1aadd..dfc59a79c49 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -175,8 +175,9 @@ static void draw_fcurve_selected_keyframe_vertices(
BezTriple *bezt = fcu->bezt;
for (int i = 0; i < fcu->totvert; i++, bezt++) {
- /* as an optimization step, only draw those in view
- * - we apply a correction factor to ensure that points don't pop in/out due to slight twitches of view size
+ /* As an optimization step, only draw those in view
+ * - We apply a correction factor to ensure that points
+ * don't pop in/out due to slight twitches of view size.
*/
if (IN_RANGE(bezt->vec[1][0], (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) {
if (edit) {
@@ -184,8 +185,9 @@ static void draw_fcurve_selected_keyframe_vertices(
* - only draw those with correct selection state for the current drawing color
* -
*/
- if ((bezt->f2 & SELECT) == sel)
+ if ((bezt->f2 & SELECT) == sel) {
immVertex2fv(pos, bezt->vec[1]);
+ }
}
else {
/* no check for selection here, as curve is not editable... */
@@ -281,9 +283,10 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool
View2D *v2d = &ar->v2d;
/* only draw points if curve is visible
- * - draw unselected points before selected points as separate passes
+ * - Draw unselected points before selected points as separate passes
* to make sure in the case of overlapping points that the selected is always visible
- * - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users)
+ * - Draw handles before keyframes, so that keyframes will overlap handles
+ * (keyframes are more important for users).
*/
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -315,13 +318,13 @@ static bool draw_fcurve_handles_check(SpaceGraph *sipo, FCurve *fcu)
/* keyframes aren't editable */
(fcu->flag & FCURVE_PROTECTED) ||
#if 0 /* handles can still be selected and handle types set, better draw - campbell */
- /* editing the handles here will cause weird/incorrect interpolation issues */
- (fcu->flag & FCURVE_INT_VALUES) ||
+ /* editing the handles here will cause weird/incorrect interpolation issues */
+ (fcu->flag & FCURVE_INT_VALUES) ||
#endif
/* group that curve belongs to is not editable */
((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ||
- /* do not show handles if there is only 1 keyframe,
- * otherwise they all clump together in an ugly ball */
+ /* Do not show handles if there is only 1 keyframe,
+ * otherwise they all clump together in an ugly ball. */
(fcu->totvert <= 1)) {
return false;
}
@@ -358,8 +361,9 @@ static void draw_fcurve_handles(SpaceGraph *sipo, FCurve *fcu)
* check that keyframe is selected
*/
if (sipo->flag & SIPO_SELVHANDLESONLY) {
- if (BEZT_ISSEL_ANY(bezt) == 0)
+ if (BEZT_ISSEL_ANY(bezt) == 0) {
continue;
+ }
}
/* draw handle with appropriate set of colors if selection is ok */
@@ -462,8 +466,9 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *ar, FCurve *fcu)
/* draw */
if (first && last) {
/* anti-aliased lines for more consistent appearance */
- if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0)
+ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
GPU_line_smooth(true);
+ }
GPU_blend(true);
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -477,30 +482,31 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *ar, FCurve *fcu)
immUnbindProgram();
GPU_blend(false);
- if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0)
+ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
GPU_line_smooth(false);
+ }
}
}
/* Curve ---------------- */
-/* helper func - just draw the F-Curve by sampling the visible region (for drawing curves with modifiers) */
+/* Helper func - just draw the F-Curve by sampling the visible region
+ * (for drawing curves with modifiers). */
static void draw_fcurve_curve(
- bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, View2DGrid *grid, unsigned int pos)
+ bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, unsigned int pos)
{
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
float samplefreq;
float stime, etime;
float unitFac, offset;
- float dx, dy;
short mapping_flag = ANIM_get_normalization_flags(ac);
int i, n;
- /* when opening a blend file on a different sized screen or while dragging the toolbar this can happen
- * best just bail out in this case */
- UI_view2d_grid_size(grid, &dx, &dy);
- if (dx <= 0.0f)
+ /* when opening a blend file on a different sized screen or while dragging the toolbar this can
+ * happen best just bail out in this case. */
+ if (UI_view2d_scale_get_x(v2d) <= 0.0f) {
return;
+ }
/* disable any drivers */
FCurve fcurve_for_draw = *fcu_;
@@ -521,10 +527,11 @@ static void draw_fcurve_curve(
* loop (i.e. too close to 0), then clamp it to a determined "safe" value. The value
* chosen here is just the coarsest value which still looks reasonable...
*/
- /* grid->dx represents the number of 'frames' between gridlines,
- * but we divide by U.v2d_min_gridsize to get pixels-steps */
- /* TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? */
- samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize);
+
+ /* TODO: perhaps we should have 1.0 frames
+ * as upper limit so that curves don't get too distorted? */
+ float pixels_per_sample = 1.5f;
+ samplefreq = pixels_per_sample / UI_view2d_scale_get_x(v2d);
if (sipo->flag & SIPO_BEAUTYDRAW_OFF) {
/* Low Precision = coarse lower-bound clamping
@@ -536,13 +543,15 @@ static void draw_fcurve_curve(
* This one still amounts to 10 sample-frames for each 1-frame interval
* which should be quite a decent approximation in many situations.
*/
- if (samplefreq < 0.1f)
+ if (samplefreq < 0.1f) {
samplefreq = 0.1f;
+ }
}
else {
/* "Higher Precision" but slower - especially on larger windows (e.g. T40372) */
- if (samplefreq < 0.00001f)
+ if (samplefreq < 0.00001f) {
samplefreq = 0.00001f;
+ }
}
/* the start/end times are simply the horizontal extents of the 'cur' rect */
@@ -609,8 +618,9 @@ static void draw_fcurve_curve_samples(
else {
/* extrapolate linear doesn't use the handle, use the next points center instead */
fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
@@ -643,8 +653,9 @@ static void draw_fcurve_curve_samples(
/* extrapolate linear doesn't use the handle, use the previous points center instead */
fpt = prevfpt - 1;
fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
@@ -712,15 +723,17 @@ static void draw_fcurve_curve_bezts(
else if (prevbezt->ipo == BEZT_IPO_LIN) {
/* extrapolate linear dosnt use the handle, use the next points center instead */
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
}
else {
/* based on angle of handle 1 (relative to keyframe) */
fac = (prevbezt->vec[0][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]);
}
@@ -778,8 +791,9 @@ static void draw_fcurve_curve_bezts(
else {
/* clamp resolution to max of 32 */
/* NOTE: higher values will crash */
- if (resol > 32)
+ if (resol > 32) {
resol = 32;
+ }
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
@@ -829,15 +843,17 @@ static void draw_fcurve_curve_bezts(
/* extrapolate linear dosnt use the handle, use the previous points center instead */
bezt = prevbezt - 1;
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
}
else {
/* based on angle of handle 1 (relative to keyframe) */
fac = (prevbezt->vec[2][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]);
}
@@ -865,7 +881,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
/* for now, only show when debugging driver... */
- //if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
+ // if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
// return;
const uint shdr_pos = GPU_vertformat_attr_add(
@@ -1025,8 +1041,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *ar)
/* This is called twice from space_graph.c -> graph_main_region_draw()
* Unselected then selected F-Curves are drawn so that they do not occlude each other.
*/
-void graph_draw_curves(
- bAnimContext *ac, SpaceGraph *sipo, ARegion *ar, View2DGrid *grid, short sel)
+void graph_draw_curves(bAnimContext *ac, SpaceGraph *sipo, ARegion *ar, short sel)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
@@ -1113,7 +1128,7 @@ void graph_draw_curves(
/* draw a curve affected by modifiers or only allowed to have integer values
* by sampling it at various small-intervals over the visible region
*/
- draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid, shdr_pos);
+ draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, shdr_pos);
}
else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
/* just draw curve based on defined data (i.e. no modifiers) */
@@ -1122,7 +1137,7 @@ void graph_draw_curves(
draw_fcurve_curve_bezts(ac, ale->id, fcu, &ar->v2d, shdr_pos);
}
else {
- draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid, shdr_pos);
+ draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, shdr_pos);
}
}
else if (fcu->fpt) {
@@ -1139,7 +1154,8 @@ void graph_draw_curves(
}
/* 2) draw handles and vertices as appropriate based on active
- * - if the option to only show controls if the F-Curve is selected is enabled, we must obey this
+ * - If the option to only show controls if the F-Curve is selected is enabled,
+ * we must obey this.
*/
if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) {
if (!fcurve_are_keyframes_usable(fcu) && !(fcu->fpt && fcu->totvert)) {
@@ -1163,7 +1179,8 @@ void graph_draw_curves(
GPU_matrix_scale_2f(1.0f, unit_scale);
GPU_matrix_translate_2f(0.0f, offset);
- /* set this once and for all - all handles and handle-verts should use the same thickness */
+ /* Set this once and for all -
+ * all handles and handle-verts should use the same thickness. */
GPU_line_width(1.0);
if (fcu->bezt) {
@@ -1193,8 +1210,9 @@ void graph_draw_curves(
}
/* undo mapping of keyframes for drawing if scaled F-Curve */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
+ }
}
/* free list of curves */
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 29058e47199..0954538e430 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -94,14 +94,18 @@ void get_graph_keyframe_extents(bAnimContext *ac,
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* set large values initial values that will be easy to override */
- if (xmin)
+ if (xmin) {
*xmin = 999999999.0f;
- if (xmax)
+ }
+ if (xmax) {
*xmax = -999999999.0f;
- if (ymin)
+ }
+ if (ymin) {
*ymin = 999999999.0f;
- if (ymax)
+ }
+ if (ymax) {
*ymax = -999999999.0f;
+ }
/* check if any channels to set range with */
if (anim_data.first) {
@@ -132,14 +136,18 @@ void get_graph_keyframe_extents(bAnimContext *ac,
tymax *= unitFac;
/* try to set cur using these values, if they're more extreme than previously set values */
- if ((xmin) && (txmin < *xmin))
+ if ((xmin) && (txmin < *xmin)) {
*xmin = txmin;
- if ((xmax) && (txmax > *xmax))
+ }
+ if ((xmax) && (txmax > *xmax)) {
*xmax = txmax;
- if ((ymin) && (tymin < *ymin))
+ }
+ if ((ymin) && (tymin < *ymin)) {
*ymin = tymin;
- if ((ymax) && (tymax > *ymax))
+ }
+ if ((ymax) && (tymax > *ymax)) {
*ymax = tymax;
+ }
foundBounds = true;
}
@@ -157,14 +165,18 @@ void get_graph_keyframe_extents(bAnimContext *ac,
}
}
else {
- if (xmin)
+ if (xmin) {
*xmin = (float)PSFRA;
- if (xmax)
+ }
+ if (xmax) {
*xmax = (float)PEFRA;
- if (ymin)
+ }
+ if (ymin) {
*ymin = -5;
- if (ymax)
+ }
+ if (ymax) {
*ymax = 5;
+ }
}
/* free memory */
@@ -173,22 +185,28 @@ void get_graph_keyframe_extents(bAnimContext *ac,
else {
/* set default range */
if (ac->scene) {
- if (xmin)
+ if (xmin) {
*xmin = (float)PSFRA;
- if (xmax)
+ }
+ if (xmax) {
*xmax = (float)PEFRA;
+ }
}
else {
- if (xmin)
+ if (xmin) {
*xmin = -5;
- if (xmax)
+ }
+ if (xmax) {
*xmax = 100;
+ }
}
- if (ymin)
+ if (ymin) {
*ymin = -5;
- if (ymax)
+ }
+ if (ymax) {
*ymax = 5;
+ }
}
}
@@ -201,12 +219,15 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
float min, max;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
- if (ac.scene == NULL)
+ }
+ if (ac.scene == NULL) {
return OPERATOR_CANCELLED;
- else
+ }
+ else {
scene = ac.scene;
+ }
/* set the range directly */
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, false, false);
@@ -230,8 +251,8 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot)
/* api callbacks */
ot->exec = graphkeys_previewrange_exec;
- ot->poll =
- ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier...
+ // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier...
+ ot->poll = ED_operator_graphedit_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -248,8 +269,9 @@ static int graphkeys_viewall(bContext *C,
rctf cur_new;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_graph_keyframe_extents(&ac,
@@ -444,10 +466,12 @@ static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)
int start, end;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
- /* ghost curves are snapshots of the visible portions of the curves, so set range to be the visible range */
+ /* Ghost curves are snapshots of the visible portions of the curves,
+ * so set range to be the visible range. */
v2d = &ac.ar->v2d;
start = (int)v2d->cur.xmin;
end = (int)v2d->cur.xmax;
@@ -488,8 +512,9 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op))
SpaceGraph *sipo;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
sipo = (SpaceGraph *)ac.sl;
/* if no ghost curves, don't do anything */
@@ -578,21 +603,26 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
- if (mode & GRAPHKEYS_INSERTKEY_SEL)
+ if (mode & GRAPHKEYS_INSERTKEY_SEL) {
filter |= ANIMFILTER_SEL;
- else if (mode & GRAPHKEYS_INSERTKEY_ACTIVE)
+ }
+ else if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) {
filter |= ANIMFILTER_ACTIVE;
+ }
num_items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
if (num_items == 0) {
- if (mode & GRAPHKEYS_INSERTKEY_ACTIVE)
+ if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) {
BKE_report(reports,
RPT_ERROR,
"No active F-Curve to add a keyframe to. Select an editable F-Curve first");
- else if (mode & GRAPHKEYS_INSERTKEY_SEL)
+ }
+ else if (mode & GRAPHKEYS_INSERTKEY_SEL) {
BKE_report(reports, RPT_ERROR, "No selected F-Curves to add keyframes to");
- else
+ }
+ else {
BKE_report(reports, RPT_ERROR, "No channels to add keyframes to");
+ }
return;
}
@@ -614,18 +644,23 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
float x, y;
/* perform time remapping for x-coordinate (if necessary) */
- if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS))
+ if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) {
x = sipo->cursorTime;
- else if (adt)
+ }
+ else if (adt) {
x = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
x = (float)CFRA;
+ }
/* normalise units of cursor's value */
- if (sipo)
+ if (sipo) {
y = (sipo->cursorVal / unit_scale) - offset;
- else
+ }
+ else {
y = 0.0f;
+ }
/* insert keyframe directly into the F-Curve */
insert_vert_fcurve(fcu, x, y, ts->keyframe_type, 0);
@@ -638,13 +673,17 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
FCurve *fcu = (FCurve *)ale->key_data;
float cfra = (float)CFRA;
- /* read value from property the F-Curve represents, or from the curve only?
- * - ale->id != NULL: Typically, this means that we have enough info to try resolving the path
- * - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone,
- * so it's easier for now to just read the F-Curve directly.
- * (TODO: add the full-blown PointerRNA relative parsing case here...)
- * - fcu->driver != NULL: If this is set, then it's a driver. If we don't check for this, we'd end
- * up adding the keyframes on a new F-Curve in the action data instead.
+ /* Read value from property the F-Curve represents, or from the curve only?
+ *
+ * - ale->id != NULL:
+ * Typically, this means that we have enough info to try resolving the path.
+ * - ale->owner != NULL:
+ * If this is set, then the path may not be resolvable from the ID alone,
+ * so it's easier for now to just read the F-Curve directly.
+ * (TODO: add the full-blown PointerRNA relative parsing case here...)
+ * - fcu->driver != NULL:
+ * If this is set, then it's a driver. If we don't check for this, we'd end
+ * up adding the keyframes on a new F-Curve in the action data instead.
*/
if (ale->id && !ale->owner && !fcu->driver) {
insert_keyframe(ac->bmain,
@@ -664,10 +703,12 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* adjust current frame for NLA-mapping */
- if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS))
+ if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) {
cfra = sipo->cursorTime;
- else if (adt)
+ }
+ else if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
+ }
const float curval = evaluate_fcurve_only_curve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
@@ -691,8 +732,9 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op)
eGraphKeys_InsertKey_Types mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* which channels to affect? */
mode = RNA_enum_get(op->ptr, "type");
@@ -736,14 +778,16 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
float frame, val;
/* get animation context */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get active F-Curve 'anim-list-element' */
ale = get_active_fcurve_channel(&ac);
if (ELEM(NULL, ale, ale->data)) {
- if (ale)
+ if (ale) {
MEM_freeN(ale);
+ }
return OPERATOR_CANCELLED;
}
fcu = ale->data;
@@ -760,9 +804,9 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
/* preserve selection? */
if (RNA_boolean_get(op->ptr, "extend") == false) {
- /* deselect all keyframes first, so that we can immediately start manipulating the newly added one(s)
- * - only affect the keyframes themselves, as we don't want channels popping in and out...
- */
+ /* Deselect all keyframes first,
+ * so that we can immediately start manipulating the newly added one(s)
+ * - only affect the keyframes themselves, as we don't want channels popping in and out. */
deselect_graph_keys(&ac, false, SELECT_SUBTRACT, false);
}
@@ -792,12 +836,15 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
}
else {
/* warn about why this can't happen */
- if (fcu->fpt)
+ if (fcu->fpt) {
BKE_report(op->reports, RPT_ERROR, "Keyframes cannot be added to sampled F-Curves");
- else if (fcu->flag & FCURVE_PROTECTED)
+ }
+ else if (fcu->flag & FCURVE_PROTECTED) {
BKE_report(op->reports, RPT_ERROR, "Active F-Curve is not editable");
- else
+ }
+ else {
BKE_report(op->reports, RPT_ERROR, "Remove F-Modifiers from F-Curve to add keyframes");
+ }
}
/* free temp data */
@@ -819,8 +866,9 @@ static int graphkeys_click_insert_invoke(bContext *C, wmOperator *op, const wmEv
float x, y;
/* get animation context */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* store mouse coordinates in View2D space, into the operator's properties */
ar = ac.ar;
@@ -884,9 +932,15 @@ static short copy_graph_keys(bAnimContext *ac)
/* clear buffer first */
ANIM_fcurves_copybuf_free();
- /* filter data */
+ /* filter data
+ * - First time we try to filter more strictly, allowing only selected channels
+ * to allow copying animation between channels
+ */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
- ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) {
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ }
/* copy keyframes */
ok = copy_animedit_keys(ac, &anim_data);
@@ -914,8 +968,9 @@ static short paste_graph_keys(bAnimContext *ac,
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
- if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0)
+ if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) {
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ }
/* paste keyframes */
ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip);
@@ -933,8 +988,9 @@ static int graphkeys_copy_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* copy keyframes */
if (copy_graph_keys(&ac)) {
@@ -970,8 +1026,9 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op)
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* ac.reports by default will be the global reports list, which won't show warnings */
ac.reports = op->reports;
@@ -1055,8 +1112,9 @@ static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* duplicate keyframes */
duplicate_graph_keys(&ac);
@@ -1135,12 +1193,14 @@ static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* delete keyframes */
- if (!delete_graph_keys(&ac))
+ if (!delete_graph_keys(&ac)) {
return OPERATOR_CANCELLED;
+ }
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
@@ -1197,8 +1257,9 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op)
bool clean_chan;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get cleaning threshold */
thresh = RNA_float_get(op->ptr, "threshold");
@@ -1220,7 +1281,7 @@ void GRAPH_OT_clean(wmOperatorType *ot)
ot->description = "Simplify F-Curves by removing closely spaced keyframes";
/* api callbacks */
- //ot->invoke = // XXX we need that number popup for this!
+ // ot->invoke = // XXX we need that number popup for this!
ot->exec = graphkeys_clean_exec;
ot->poll = graphop_editable_keyframes_poll;
@@ -1278,8 +1339,9 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
int start, end;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* for now, init start/end from preview-range extents */
// TODO: add properties for this
@@ -1341,8 +1403,9 @@ static float fcurve_samplingcb_sound(FCurve *UNUSED(fcu), void *data, float eval
tSoundBakeInfo *sbi = (tSoundBakeInfo *)data;
int position = evaltime - sbi->cfra;
- if ((position < 0) || (position >= sbi->length))
+ if ((position < 0) || (position >= sbi->length)) {
return 0.0f;
+ }
return sbi->samples[position];
}
@@ -1363,8 +1426,9 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
char path[FILE_MAX];
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
RNA_string_get(op->ptr, "filepath", path);
@@ -1426,7 +1490,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-#else //WITH_AUDASPACE
+#else // WITH_AUDASPACE
static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op)
{
@@ -1435,15 +1499,16 @@ static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op)
return OPERATOR_CANCELLED;
}
-#endif //WITH_AUDASPACE
+#endif // WITH_AUDASPACE
static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
/* verify editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
return WM_operator_filesel(C, op, event);
}
@@ -1583,8 +1648,9 @@ static int graphkeys_sample_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* sample keyframes */
sample_graph_keys(&ac);
@@ -1685,8 +1751,9 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
fcn = fcm->next;
- if (fcm->type == FMODIFIER_TYPE_CYCLES)
+ if (fcm->type == FMODIFIER_TYPE_CYCLES) {
remove_fmodifier(&fcu->modifiers, fcm);
+ }
}
}
}
@@ -1706,8 +1773,9 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1755,8 +1823,9 @@ static void setipo_graph_keys(bAnimContext *ac, short mode)
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* loop through setting BezTriple interpolation
- * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
+ /* Loop through setting BezTriple interpolation
+ * Note: we do not supply KeyframeEditData to the looper yet.
+ * Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve);
@@ -1776,8 +1845,9 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1826,8 +1896,9 @@ static void seteasing_graph_keys(bAnimContext *ac, short mode)
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* loop through setting BezTriple easing
- * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
+ /* Loop through setting BezTriple easing.
+ * Note: we do not supply KeyframeEditData to the looper yet.
+ * Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve);
@@ -1845,8 +1916,9 @@ static int graphkeys_easing_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1898,8 +1970,9 @@ static void sethandles_graph_keys(bAnimContext *ac, short mode)
ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- /* loop through setting flags for handles
- * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
+ /* Loop through setting flags for handles.
+ * Note: we do not supply KeyframeEditData to the looper yet.
+ * Currently that's not necessary here.
*/
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
@@ -1924,8 +1997,9 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1993,8 +2067,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
int groups = 0, failed = 0;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* The process is done in two passes:
* 1) Sets of three related rotation curves are identified from the selected channels,
@@ -2015,8 +2090,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
* - only rotation curves
* - for pchan curves, make sure we're only using the euler curves
*/
- if (strstr(fcu->rna_path, "rotation_euler") == NULL)
+ if (strstr(fcu->rna_path, "rotation_euler") == NULL) {
continue;
+ }
else if (ELEM(fcu->array_index, 0, 1, 2) == 0) {
BKE_reportf(op->reports,
RPT_WARNING,
@@ -2081,16 +2157,19 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
continue;
}
- /* simple method: just treat any difference between keys of greater than 180 degrees as being a flip */
- /* FIXME: there are more complicated methods that will be needed to fix more cases than just some */
+ /* Simple method: just treat any difference between
+ * keys of greater than 180 degrees as being a flip. */
+ /* FIXME: there are more complicated methods that
+ * will be needed to fix more cases than just some */
for (f = 0; f < 3; f++) {
FCurve *fcu = euf->fcurves[f];
BezTriple *bezt, *prev;
unsigned int i;
/* skip if not enough vets to do a decent analysis of... */
- if (fcu->totvert <= 2)
+ if (fcu->totvert <= 2) {
continue;
+ }
/* prev follows bezt, bezt = "current" point to be fixed */
/* our method depends on determining a "difference" from the previous vert */
@@ -2168,8 +2247,9 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot)
static bool graphkeys_framejump_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return graphop_visible_keyframes_poll(C);
}
@@ -2184,8 +2264,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditData ked;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* init edit data */
memset(&ked, 0, sizeof(KeyframeEditData));
@@ -2209,8 +2290,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
+ }
ked.f1 += current_ked.f1;
ked.i1 += current_ked.i1;
@@ -2358,8 +2440,9 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
+ }
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -2376,8 +2459,9 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get snapping mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -2467,10 +2551,12 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
marker = ED_markers_get_first_selected(ac->markers);
/* store marker's time (if available) */
- if (marker)
+ if (marker) {
ked.f1 = (float)marker->frame;
- else
+ }
+ else {
return;
+ }
}
else if (mode == GRAPHKEYS_MIRROR_VALUE) {
cursor_value = (sipo) ? sipo->cursorVal : 0.0f;
@@ -2513,8 +2599,9 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
+ }
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -2531,8 +2618,9 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get mirroring mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -2575,8 +2663,9 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT |
@@ -2642,8 +2731,9 @@ static const EnumPropertyItem *graph_fmodifier_itemf(bContext *C,
int index;
/* check if modifier is valid for this context */
- if (fmi == NULL)
+ if (fmi == NULL) {
continue;
+ }
index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type);
if (index != -1) { /* Not all types are implemented yet... */
@@ -2666,19 +2756,22 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
short type;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get type of modifier to add */
type = RNA_enum_get(op->ptr, "type");
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
- if (RNA_boolean_get(op->ptr, "only_active"))
+ if (RNA_boolean_get(op->ptr, "only_active")) {
filter |=
ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled?
- else
+ }
+ else {
filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE);
+ }
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* add f-modifier to each curve */
@@ -2743,8 +2836,9 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* clear buffer first */
ANIM_fmodifiers_copybuf_free();
@@ -2768,8 +2862,9 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied");
return OPERATOR_CANCELLED;
}
- else
+ else {
return OPERATOR_FINISHED;
+ }
}
void GRAPH_OT_fmodifier_copy(wmOperatorType *ot)
@@ -2787,7 +2882,13 @@ void GRAPH_OT_fmodifier_copy(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* id-props */
- //ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one");
+#if 0
+ ot->prop = RNA_def_boolean(ot->srna,
+ "all",
+ 1,
+ "All F-Modifiers",
+ "Copy all the F-Modifiers, instead of just the active one");
+#endif
}
/* ******************** Paste F-Modifiers Operator *********************** */
@@ -2804,8 +2905,9 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* filter data */
if (RNA_boolean_get(op->ptr, "only_active")) {
@@ -2814,7 +2916,8 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
ANIMFILTER_NODUPLIS);
}
else {
- /* This is only if the operator gets called from a hotkey or search - Paste to all visible curves */
+ /* This is only if the operator gets called from a hotkey or search -
+ * Paste to all visible curves. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL |
ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
}
@@ -2889,8 +2992,9 @@ static int graph_driver_vars_copy_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* clear buffer first */
ANIM_driver_vars_copybuf_free();
@@ -2909,10 +3013,12 @@ static int graph_driver_vars_copy_exec(bContext *C, wmOperator *op)
}
/* successful or not? */
- if (ok)
+ if (ok) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void GRAPH_OT_driver_variables_copy(wmOperatorType *ot)
@@ -2944,8 +3050,9 @@ static int graph_driver_vars_paste_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT |
@@ -3011,8 +3118,9 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op)
unsigned int deleted = 0;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* NOTE: we might need a scene update to evaluate the driver flags */
@@ -3064,8 +3172,9 @@ static bool graph_driver_delete_invalid_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
/* firstly, check if in Graph Editor */
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
return ANIM_animdata_get_context(C, &ac) != 0;
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index 7d0a3a1f13d..6ec8e54dce9 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -28,7 +28,6 @@ struct ARegion;
struct ARegionType;
struct ScrArea;
struct SpaceGraph;
-struct View2DGrid;
struct bAnimContext;
struct bAnimListElem;
struct bContext;
@@ -36,17 +35,12 @@ struct bContext;
/* internal exports only */
/* ***************************************** */
-/* space_graph.c */
-struct ARegion *graph_has_buttons_region(struct ScrArea *sa);
-
-/* ***************************************** */
/* graph_draw.c */
void graph_draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar);
void graph_draw_curves(struct bAnimContext *ac,
struct SpaceGraph *sipo,
struct ARegion *ar,
- struct View2DGrid *grid,
short sel);
void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceGraph *sipo, struct ARegion *ar);
@@ -164,7 +158,6 @@ void GRAPH_OT_ghost_curves_clear(struct wmOperatorType *ot);
/* ***************************************** */
/* graph_buttons.c */
-void GRAPH_OT_properties(struct wmOperatorType *ot);
void graph_buttons_register(struct ARegionType *art);
/* ***************************************** */
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 6bbc6a2de1c..5c7035a4c04 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -64,8 +64,9 @@
static bool graphview_cursor_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return ED_operator_graphedit_active(C);
}
@@ -132,8 +133,9 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent
float viewx, viewy;
/* abort if not active region (should not really be possible) */
- if (ar == NULL)
+ if (ar == NULL) {
return;
+ }
/* convert from region coordinates to View2D 'tot' space */
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
@@ -157,8 +159,9 @@ static int graphview_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *e
graphview_cursor_apply(C, op);
/* Signal that a scrubbing operating is starting */
- if (screen)
+ if (screen) {
screen->scrubbing = true;
+ }
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -174,8 +177,9 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *ev
/* execute the events */
switch (event->type) {
case ESCKEY:
- if (screen)
+ if (screen) {
screen->scrubbing = false;
+ }
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
return OPERATOR_FINISHED;
@@ -191,8 +195,9 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *ev
case MIDDLEMOUSE:
/* We check for either mouse-button to end, to work with all user keymaps. */
if (event->val == KM_RELEASE) {
- if (screen)
+ if (screen) {
screen->scrubbing = false;
+ }
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
return OPERATOR_FINISHED;
@@ -236,8 +241,9 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get list of all channels that selection may need to be flushed to
* - hierarchy must not affect what we have access to here...
@@ -250,10 +256,12 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
* selected/unselected (depending on "unselected" prop)
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
- if (unselected)
+ if (unselected) {
filter |= ANIMFILTER_UNSEL;
- else
+ }
+ else {
filter |= ANIMFILTER_SEL;
+ }
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -261,8 +269,9 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
/* hack: skip object channels for now, since flushing those will always flush everything,
* but they are always included */
/* TODO: find out why this is the case, and fix that */
- if (ale->type == ANIMTYPE_OBJECT)
+ if (ale->type == ANIMTYPE_OBJECT) {
continue;
+ }
/* change the hide setting, and unselect it... */
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR);
@@ -290,8 +299,9 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
* will always flush everything, but they are always included */
/* TODO: find out why this is the case, and fix that */
- if (ale->type == ANIMTYPE_OBJECT)
+ if (ale->type == ANIMTYPE_OBJECT) {
continue;
+ }
/* change the hide setting, and unselect it... */
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD);
@@ -341,8 +351,9 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get list of all channels that selection may need to be flushed to
* - hierarchy must not affect what we have access to here...
@@ -360,8 +371,9 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op)
/* hack: skip object channels for now, since flushing those will always flush everything,
* but they are always included. */
/* TODO: find out why this is the case, and fix that */
- if (ale->type == ANIMTYPE_OBJECT)
+ if (ale->type == ANIMTYPE_OBJECT) {
continue;
+ }
/* select if it is not visible */
if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE) == 0) {
@@ -415,7 +427,6 @@ void graphedit_operatortypes(void)
WM_operatortype_append(GRAPH_OT_previewrange_set);
WM_operatortype_append(GRAPH_OT_view_all);
WM_operatortype_append(GRAPH_OT_view_selected);
- WM_operatortype_append(GRAPH_OT_properties);
WM_operatortype_append(GRAPH_OT_view_frame);
WM_operatortype_append(GRAPH_OT_ghost_curves_create);
@@ -483,7 +494,7 @@ void ED_operatormacros_graph(void)
WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform");
RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE);
- RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
}
/* ************************** registration - keymaps **********************************/
@@ -494,9 +505,11 @@ void graphedit_keymap(wmKeyConfig *keyconf)
WM_keymap_ensure(keyconf, "Graph Editor Generic", SPACE_GRAPH, 0);
/* channels */
- /* Channels are not directly handled by the Graph Editor module, but are inherited from the Animation module.
- * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these
- * are all used for the Graph Editor too.
+ /* Channels are not directly handled by the Graph Editor module,
+ * but are inherited from the Animation module.
+ * All the relevant operations, keymaps, drawing, etc.
+ * can therefore all be found in that module instead,
+ * as these are all used for the Graph Editor too.
*/
/* keyframes */
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index a109282978c..13a42f091f6 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -117,15 +117,18 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
/* affect channel selection status? */
if (do_channels) {
- /* only change selection of channel when the visibility of keyframes doesn't depend on this */
+ /* Only change selection of channel when the visibility of keyframes
+ * doesn't depend on this. */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
/* deactivate the F-Curve, and deselect if deselecting keyframes.
* otherwise select the F-Curve too since we've selected all the keyframes
*/
- if (sel == SELECT_SUBTRACT)
+ if (sel == SELECT_SUBTRACT) {
fcu->flag &= ~FCURVE_SELECTED;
- else
+ }
+ else {
fcu->flag |= FCURVE_SELECTED;
+ }
}
/* always deactivate all F-Curves if we perform batch ops for selection */
@@ -145,8 +148,9 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op)
bAnimListElem *ale_active = NULL;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* find active F-Curve, and preserve this for later
* or else it becomes annoying with the current active
@@ -216,7 +220,8 @@ void GRAPH_OT_select_all(wmOperatorType *ot)
* -> BKEY - 1) all keyframes within region are selected (validation with BEZT_OK_REGION)
* -> ALT-BKEY - depending on which axis of the region was larger...
* -> 2) x-axis, so select all frames within frame range (validation with BEZT_OK_FRAMERANGE)
- * -> 3) y-axis, so select all frames within channels that region included (validation with BEZT_OK_VALUERANGE)
+ * -> 3) y-axis, so select all frames within channels that region included
+ * (validation with BEZT_OK_VALUERANGE).
*
* The selection backend is also reused for the Lasso and Circle select operators.
*/
@@ -243,7 +248,8 @@ static void box_select_graphkeys(bAnimContext *ac,
View2D *v2d = &ac->ar->v2d;
rctf rectf, scaled_rectf;
- /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
+ /* Convert mouse coordinates to frame ranges and
+ * channel coordinates corrected for view pan/zoom. */
UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf);
/* filter data */
@@ -275,8 +281,9 @@ static void box_select_graphkeys(bAnimContext *ac,
ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES;
mapping_flag = 0;
}
- else
+ else {
mapping_flag = ANIM_UNITCONV_ONLYKEYS;
+ }
mapping_flag |= ANIM_get_normalization_flags(ac);
@@ -291,8 +298,9 @@ static void box_select_graphkeys(bAnimContext *ac,
/* apply NLA mapping to all the keyframes, since it's easier than trying to
* guess when a callback might use something different
*/
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0);
+ }
scaled_rectf.xmin = rectf.xmin;
scaled_rectf.xmax = rectf.xmax;
@@ -317,17 +325,20 @@ static void box_select_graphkeys(bAnimContext *ac,
/* select keyframes that are in the appropriate places */
ANIM_fcurve_keyframes_loop(&ked, fcu, ok_cb, select_cb, NULL);
- /* only change selection of channel when the visibility of keyframes doesn't depend on this */
+ /* Only change selection of channel when the visibility of keyframes
+ * doesn't depend on this. */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
/* select the curve too now that curve will be touched */
- if (selectmode == SELECT_ADD)
+ if (selectmode == SELECT_ADD) {
fcu->flag |= FCURVE_SELECTED;
+ }
}
}
/* un-apply NLA mapping from all the keyframes */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0);
+ }
}
/* cleanup */
@@ -344,8 +355,9 @@ static int graphkeys_box_select_exec(bContext *C, wmOperator *op)
short mode = 0;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
@@ -362,17 +374,22 @@ static int graphkeys_box_select_exec(bContext *C, wmOperator *op)
/* selection 'mode' depends on whether box_select region only matters on one axis */
if (RNA_boolean_get(op->ptr, "axis_range")) {
/* mode depends on which axis of the range is larger to determine which axis to use
- * - checking this in region-space is fine, as it's fundamentally still going to be a different rect size
- * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
- * used for tweaking timing when "blocking", while channels is not that useful...
+ * - Checking this in region-space is fine, as it's fundamentally still going to be a
+ * different rect size.
+ * - The frame-range select option is favored over the channel one (x over y),
+ * as frame-range one is often used for tweaking timing when "blocking",
+ * while channels is not that useful.
*/
- if ((BLI_rcti_size_x(&rect)) >= (BLI_rcti_size_y(&rect)))
+ if ((BLI_rcti_size_x(&rect)) >= (BLI_rcti_size_y(&rect))) {
mode = BEZT_OK_FRAMERANGE;
- else
+ }
+ else {
mode = BEZT_OK_VALUERANGE;
+ }
}
- else
+ else {
mode = BEZT_OK_REGION;
+ }
BLI_rctf_rcti_copy(&rect_fl, &rect);
@@ -428,13 +445,15 @@ static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op)
bool incl_handles;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
data_lasso.rectf_view = &rect_fl;
data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot);
- if (data_lasso.mcords == NULL)
+ if (data_lasso.mcords == NULL) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const short selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
@@ -504,8 +523,9 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op)
float radius = RNA_int_get(op->ptr, "radius");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
@@ -654,8 +674,9 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode)
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL);
+ }
ANIM_animdata_freelist(&anim_data);
break;
@@ -714,16 +735,19 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* action to take depends on the mode */
mode = RNA_enum_get(op->ptr, "mode");
- if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN)
+ if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN) {
markers_selectkeys_between(&ac);
- else
+ }
+ else {
columnselect_graph_keys(&ac, mode);
+ }
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
@@ -763,8 +787,9 @@ static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD);
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
@@ -828,8 +853,9 @@ static void select_moreless_graph_keys(bAnimContext *ac, short mode)
FCurve *fcu = (FCurve *)ale->key_data;
/* only continue if F-Curve has keyframes */
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
/* build up map of whether F-Curve's keyframes should be selected or not */
ked.data = MEM_callocN(fcu->totvert, "selmap graphEdit");
@@ -854,8 +880,9 @@ static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform select changes */
select_moreless_graph_keys(&ac, SELMAP_MORE);
@@ -888,8 +915,9 @@ static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform select changes */
select_moreless_graph_keys(&ac, SELMAP_LESS);
@@ -974,8 +1002,9 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
+ }
}
/* Cleanup */
@@ -991,18 +1020,22 @@ static int graphkeys_select_leftright_exec(bContext *C, wmOperator *op)
short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* if "test" mode is set, we don't have any info to set this with */
- if (leftright == GRAPHKEYS_LRSEL_TEST)
+ if (leftright == GRAPHKEYS_LRSEL_TEST) {
return OPERATOR_CANCELLED;
+ }
/* do the selecting now */
graphkeys_select_leftright(&ac, leftright, selectmode);
@@ -1020,8 +1053,9 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const
short leftright = RNA_enum_get(op->ptr, "mode");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* handle mode-based testing */
if (leftright == GRAPHKEYS_LRSEL_TEST) {
@@ -1032,10 +1066,12 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const
/* determine which side of the current frame mouse is on */
x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
- if (x < CFRA)
+ if (x < CFRA) {
RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
- else
+ }
+ else {
RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
+ }
}
/* perform selection */
@@ -1113,10 +1149,12 @@ typedef enum eGraphVertIndex {
// XXX also need to check for int-values only?
static bool fcurve_handle_sel_check(SpaceGraph *sipo, BezTriple *bezt)
{
- if (sipo->flag & SIPO_NOHANDLES)
+ if (sipo->flag & SIPO_NOHANDLES) {
return 0;
- if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0)
+ }
+ if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0) {
return 0;
+ }
return 1;
}
@@ -1152,15 +1190,18 @@ static void nearest_fcurve_vert_store(ListBase *matches,
tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last;
bool replace = false;
- /* if there is already a point for the F-Curve, check if this point is closer than that was */
+ /* If there is already a point for the F-Curve,
+ * check if this point is closer than that was. */
if ((nvi) && (nvi->fcu == fcu)) {
/* replace if we are closer, or if equal and that one wasn't selected but we are... */
- if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt)))
+ if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt))) {
replace = 1;
+ }
}
/* add new if not replacing... */
- if (replace == 0)
+ if (replace == 0) {
nvi = MEM_callocN(sizeof(tNearestVertInfo), "Nearest Graph Vert Info - Bezt");
+ }
/* store values */
nvi->fcu = fcu;
@@ -1175,8 +1216,9 @@ static void nearest_fcurve_vert_store(ListBase *matches,
nvi->sel = BEZT_ISSEL_ANY(bezt); // XXX... should this use the individual verts instead?
/* add to list of matches if appropriate... */
- if (replace == 0)
+ if (replace == 0) {
BLI_addtail(matches, nvi);
+ }
}
}
else if (fpt) {
@@ -1201,8 +1243,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
if (sipo->flag &
- SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code...
+ SIPO_SELCUVERTSONLY) { // FIXME: this should really be check for by the filtering code...
filter |= ANIMFILTER_SEL;
+ }
mapping_flag |= ANIM_get_normalization_flags(ac);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
@@ -1214,8 +1257,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
ac->scene, ale->id, fcu, mapping_flag, &offset);
/* apply NLA mapping to all the keyframes */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
+ }
if (fcu->bezt) {
BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL;
@@ -1272,8 +1316,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
}
/* un-apply NLA mapping from all the keyframes */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
+ }
}
/* free channels */
@@ -1287,8 +1332,9 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
short found = 0;
/* abort if list is empty */
- if (BLI_listbase_is_empty(matches))
+ if (BLI_listbase_is_empty(matches)) {
return NULL;
+ }
/* if list only has 1 item, remove it from the list and return */
if (BLI_listbase_is_single(matches)) {
@@ -1300,16 +1346,18 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
for (nvi = matches->first; nvi; nvi = nvi->next) {
/* which mode of search are we in: find first selected, or find vert? */
if (found) {
- /* just take this vert now that we've found the selected one
- * - we'll need to remove this from the list so that it can be returned to the original caller
+ /* Just take this vert now that we've found the selected one
+ * - We'll need to remove this from the list
+ * so that it can be returned to the original caller.
*/
BLI_remlink(matches, nvi);
return nvi;
}
else {
/* if vert is selected, we've got what we want... */
- if (nvi->sel)
+ if (nvi->sel) {
found = 1;
+ }
}
}
@@ -1319,8 +1367,11 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
return BLI_pophead(matches);
}
-/* Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates)
- * NOTE: the match info found must still be freed
+/**
+ * Find the nearest vertices (either a handle or the keyframe)
+ * that are nearest to the mouse cursor (in area coordinates)
+ *
+ * \note the match info found must still be freed.
*/
static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mval[2])
{
@@ -1345,7 +1396,8 @@ static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mv
static void mouse_graph_keys(bAnimContext *ac,
const int mval[2],
short select_mode,
- short curves_only)
+ const bool deselect_all,
+ const bool curves_only)
{
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
tNearestVertInfo *nvi;
@@ -1354,12 +1406,10 @@ static void mouse_graph_keys(bAnimContext *ac,
/* find the beztriple that we're selecting, and the handle that was clicked on */
nvi = find_nearest_fcurve_vert(ac, mval);
- /* check if anything to select */
- if (nvi == NULL)
- return;
-
- /* deselect all other curves? */
- if (select_mode == SELECT_REPLACE) {
+ /* For replacing selection, if we have something to select, we have to clear existing selection.
+ * The same goes if we found nothing to select, and deselect_all is true
+ * (deselect on nothing behavior). */
+ if ((nvi != NULL && select_mode == SELECT_REPLACE) || (nvi == NULL && deselect_all)) {
/* reset selection mode */
select_mode = SELECT_ADD;
@@ -1370,13 +1420,18 @@ static void mouse_graph_keys(bAnimContext *ac,
* selection of channel when the visibility of keyframes
* doesn't depend on this
*/
- if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0)
+ if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ }
+ }
+
+ if (nvi == NULL) {
+ return;
}
/* if points can be selected on this F-Curve */
// TODO: what about those with no keyframes?
- if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
+ if (!curves_only && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
/* only if there's keyframe */
if (nvi->bezt) {
bezt = nvi->bezt; /* used to check bezt seletion is set */
@@ -1408,10 +1463,12 @@ static void mouse_graph_keys(bAnimContext *ac,
BEZT_SEL_ALL(bezt);
}
/* otherwise, select the handle that applied */
- else if (nvi->hpoint == NEAREST_HANDLE_LEFT)
+ else if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
bezt->f1 |= SELECT;
- else
+ }
+ else {
bezt->f3 |= SELECT;
+ }
}
}
else if (nvi->fpt) {
@@ -1439,17 +1496,22 @@ static void mouse_graph_keys(bAnimContext *ac,
/* take selection status from item that got hit, to prevent flip/flop on channel
* selection status when shift-selecting (i.e. "SELECT_INVERT") points
*/
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
nvi->fcu->flag |= FCURVE_SELECTED;
- else
+ }
+ else {
nvi->fcu->flag &= ~FCURVE_SELECTED;
+ }
}
else {
- /* didn't hit any channel, so just apply that selection mode to the curve's selection status */
- if (select_mode == SELECT_INVERT)
+ /* Didn't hit any channel,
+ * so just apply that selection mode to the curve's selection status. */
+ if (select_mode == SELECT_INVERT) {
nvi->fcu->flag ^= FCURVE_SELECTED;
- else if (select_mode == SELECT_ADD)
+ }
+ else if (select_mode == SELECT_ADD) {
nvi->fcu->flag |= FCURVE_SELECTED;
+ }
}
}
@@ -1485,8 +1547,9 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short
nvi = find_nearest_fcurve_vert(ac, mval);
/* check if anything to select */
- if (nvi == NULL)
+ if (nvi == NULL) {
return;
+ }
/* get frame number on which elements should be selected */
// TODO: should we restrict to integer frames only?
@@ -1520,10 +1583,12 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* set frame for validation callback to refer to */
- if (adt)
+ if (adt) {
ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
ked.f1 = selx;
+ }
/* select elements with frame number matching cfra */
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
@@ -1541,17 +1606,15 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short
static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
- short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
- selectmode = SELECT_INVERT;
- else
- selectmode = SELECT_REPLACE;
+ const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE;
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
/* figure out action to take */
if (RNA_boolean_get(op->ptr, "column")) {
@@ -1560,11 +1623,11 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve
}
else if (RNA_boolean_get(op->ptr, "curves")) {
/* select all keyframes in the same F-Curve as the one under the mouse */
- mouse_graph_keys(&ac, event->mval, selectmode, 1);
+ mouse_graph_keys(&ac, event->mval, selectmode, deselect_all, true);
}
else {
/* select keyframe under mouse */
- mouse_graph_keys(&ac, event->mval, selectmode, 0);
+ mouse_graph_keys(&ac, event->mval, selectmode, deselect_all, false);
}
/* set notifier that keyframe selection (and also channel selection in some cases) has changed */
@@ -1600,6 +1663,13 @@ void GRAPH_OT_clickselect(wmOperatorType *ot)
"Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
prop = RNA_def_boolean(
ot->srna,
"column",
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index 1c3b4f1377b..d582ac557fa 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -50,7 +50,8 @@
/* Set Up Drivers Editor */
/* Set up UI configuration for Drivers Editor */
-/* NOTE: Currently called from windowmanager (new drivers editor window) and RNA (mode switching) */
+/* NOTE: Currently called from windowmanager
+ * (new drivers editor window) and RNA (mode switching) */
void ED_drivers_editor_init(bContext *C, ScrArea *sa)
{
SpaceGraph *sipo = (SpaceGraph *)sa->spacedata.first;
@@ -66,7 +67,7 @@ void ED_drivers_editor_init(bContext *C, ScrArea *sa)
ar_props->flag &= ~RGN_FLAG_HIDDEN;
/* XXX: Adjust width of this too? */
- ED_region_visibility_change_update(C, ar_props);
+ ED_region_visibility_change_update(C, sa, ar_props);
}
else {
printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, sa);
@@ -91,11 +92,14 @@ void ED_drivers_editor_init(bContext *C, ScrArea *sa)
/* ************************************************************** */
/* Active F-Curve */
-/* Find 'active' F-Curve. It must be editable, since that's the purpose of these buttons (subject to change).
- * We return the 'wrapper' since it contains valuable context info (about hierarchy), which will need to be freed
- * when the caller is done with it.
+/**
+ * Find 'active' F-Curve.
+ * It must be editable, since that's the purpose of these buttons (subject to change).
+ * We return the 'wrapper' since it contains valuable context info (about hierarchy),
+ * which will need to be freed when the caller is done with it.
*
- * NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome
+ * \note curve-visible flag isn't included,
+ * otherwise selecting a curve via list to edit is too cumbersome.
*/
bAnimListElem *get_active_fcurve_channel(bAnimContext *ac)
{
@@ -136,20 +140,23 @@ bool graphop_visible_keyframes_poll(bContext *C)
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
/* loop over the visible (selection doesn't matter) F-Curves, and see if they're suitable
* stopping on the first successful match
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- if (items == 0)
+ if (items == 0) {
return 0;
+ }
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
@@ -159,8 +166,9 @@ bool graphop_visible_keyframes_poll(bContext *C)
* - F-Curve modifiers do not interfere with the result too much
* (i.e. the modifier-control drawing check returns false)
*/
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
if (fcurve_are_keyframes_usable(fcu)) {
found = 1;
break;
@@ -185,20 +193,23 @@ bool graphop_editable_keyframes_poll(bContext *C)
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
/* loop over the editable F-Curves, and see if they're suitable
* stopping on the first successful match
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- if (items == 0)
+ if (items == 0) {
return 0;
+ }
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
@@ -209,8 +220,9 @@ bool graphop_editable_keyframes_poll(bContext *C)
* - F-Curve modifiers do not interfere with the result too much
* (i.e. the modifier-control drawing check returns false)
*/
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
if (fcurve_is_keyframable(fcu)) {
found = 1;
break;
@@ -232,21 +244,25 @@ bool graphop_active_fcurve_poll(bContext *C)
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
/* try to get the Active F-Curve */
ale = get_active_fcurve_channel(&ac);
- if (ale == NULL)
+ if (ale == NULL) {
return 0;
+ }
- /* do we have a suitable F-Curves?
- * - For most cases, NLA Control Curves are sufficiently similar to NLA curves to serve this role too.
- * Under the hood, they are F-Curves too. The only problems which will arise here are if these need to be
+ /* Do we have a suitable F-Curves?
+ * - For most cases, NLA Control Curves are sufficiently similar to NLA
+ * curves to serve this role too. Under the hood, they are F-Curves too.
+ * The only problems which will arise here are if these need to be
* in an Action too (but drivers would then also be affected!)
*/
has_fcurve = ((ale->data) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE));
@@ -273,20 +289,23 @@ bool graphop_selected_fcurve_poll(bContext *C)
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
- /* get the editable + selected F-Curves, and as long as we got some, we can return
- * NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome
- */
+ /* Get the editable + selected F-Curves, and as long as we got some, we can return.
+ * NOTE: curve-visible flag isn't included,
+ * otherwise selecting a curve via list to edit is too cumbersome. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- if (items == 0)
+ if (items == 0) {
return 0;
+ }
/* cleanup and return findings */
ANIM_animdata_freelist(&anim_data);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index d03431468d8..86d0b961a31 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -60,34 +60,6 @@
#include "graph_intern.h" // own include
-/* ******************** manage regions ********************* */
-
-ARegion *graph_has_buttons_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar)
- return ar;
-
- /* add subdiv level; after main */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-
- /* is error! */
- if (ar == NULL)
- return NULL;
-
- arnew = MEM_callocN(sizeof(ARegion), "buttons for graph");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
/* ******************** default callbacks for ipo space ***************** */
static SpaceLink *graph_new(const ScrArea *UNUSED(sa), const Scene *scene)
@@ -214,7 +186,7 @@ static void graph_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor", SPACE_GRAPH, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -226,10 +198,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
Scene *scene = CTX_data_scene(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
View2DScrollers *scrollers;
float col[3];
- short unitx = 0, unity = V2D_UNIT_VALUES, cfra_flag = 0;
+ short cfra_flag = 0;
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
@@ -239,18 +210,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* grid */
- unitx = ((sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME)) ?
- V2D_UNIT_SECONDS :
- V2D_UNIT_FRAMESCALE;
- grid = UI_view2d_grid_calc(CTX_data_scene(C),
- v2d,
- unitx,
- V2D_GRID_NOCLAMP,
- unity,
- V2D_GRID_NOCLAMP,
- ar->winx,
- ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
+ bool display_seconds = (sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME);
+ UI_view2d_draw_lines_x__frames_or_seconds(v2d, scene, display_seconds);
+ UI_view2d_draw_lines_y__values(v2d);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -265,8 +227,8 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
graph_draw_ghost_curves(&ac, sipo, ar);
/* draw curves twice - unselected, then selected, so that the are fewer occlusion problems */
- graph_draw_curves(&ac, sipo, ar, grid, 0);
- graph_draw_curves(&ac, sipo, ar, grid, 1);
+ graph_draw_curves(&ac, sipo, ar, 0);
+ graph_draw_curves(&ac, sipo, ar, 1);
/* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
get_graph_keyframe_extents(
@@ -276,9 +238,6 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
v2d->tot.xmax += 10.0f;
}
- /* only free grid after drawing data, as we need to use it to determine sampling rate */
- UI_view2d_grid_free(grid);
-
if (((sipo->flag & SIPO_NODRAWCURSOR) == 0) || (sipo->mode == SIPO_MODE_DRIVERS)) {
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -325,8 +284,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
if (sipo->mode != SIPO_MODE_DRIVERS) {
/* current frame */
- if (sipo->flag & SIPO_DRAWTIME)
+ if (sipo->flag & SIPO_DRAWTIME) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
}
@@ -351,11 +311,14 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
/* scrollers */
// FIXME: args for scrollers depend on the type of data being shown...
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* scale numbers */
+ UI_view2d_draw_scale_x__frames_or_seconds(ar, v2d, &v2d->hor, scene, display_seconds);
+ UI_view2d_draw_scale_y__values(ar, v2d, &v2d->vert);
+
/* draw current frame number-indicator on top of scrollers */
if ((sipo->mode != SIPO_MODE_DRIVERS) && ((sipo->flag & SIPO_NODRAWCFRANUM) == 0)) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -380,7 +343,7 @@ static void graph_channel_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -408,9 +371,8 @@ static void graph_channel_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -433,7 +395,7 @@ static void graph_buttons_region_init(wmWindowManager *wm, ARegion *ar)
ED_region_panels_init(wm, ar);
keymap = WM_keymap_ensure(wm->defaultconf, "Graph Editor Generic", SPACE_GRAPH, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void graph_buttons_region_draw(const bContext *C, ARegion *ar)
@@ -462,8 +424,9 @@ static void graph_region_listener(wmWindow *UNUSED(win),
ED_region_tag_redraw(ar);
break;
case ND_SEQUENCER:
- if (wmn->action == NA_SELECTED)
+ if (wmn->action == NA_SELECTED) {
ED_region_tag_redraw(ar);
+ }
break;
}
break;
@@ -475,8 +438,9 @@ static void graph_region_listener(wmWindow *UNUSED(win),
ED_region_tag_redraw(ar);
break;
case ND_MODIFIER:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
}
break;
@@ -489,8 +453,9 @@ static void graph_region_listener(wmWindow *UNUSED(win),
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCREEN:
if (ELEM(wmn->data, ND_LAYER)) {
@@ -498,8 +463,9 @@ static void graph_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -592,15 +558,17 @@ static void graph_listener(wmWindow *UNUSED(win),
case NC_ANIMATION:
/* for selection changes of animation data, we can just redraw...
* otherwise autocolor might need to be done again */
- if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED))
+ if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED)) {
ED_area_tag_redraw(sa);
- else
+ }
+ else {
ED_area_tag_refresh(sa);
+ }
break;
case NC_SCENE:
switch (wmn->data) {
- case ND_OB_ACTIVE: /* selection changed, so force refresh to flush
- * (needs flag set to do syncing) */
+ case ND_OB_ACTIVE: /* Selection changed, so force refresh to flush
+ * (needs flag set to do syncing). */
case ND_OB_SELECT:
sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
@@ -613,8 +581,8 @@ static void graph_listener(wmWindow *UNUSED(win),
break;
case NC_OBJECT:
switch (wmn->data) {
- case ND_BONE_SELECT: /* selection changed, so force refresh to flush
- * (needs flag set to do syncing) */
+ case ND_BONE_SELECT: /* Selection changed, so force refresh to flush
+ * (needs flag set to do syncing). */
case ND_BONE_ACTIVE:
sipo->runtime.flag |= SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
ED_area_tag_refresh(sa);
@@ -635,8 +603,9 @@ static void graph_listener(wmWindow *UNUSED(win),
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_GRAPH)
+ if (wmn->data == ND_SPACE_GRAPH) {
ED_area_tag_redraw(sa);
+ }
break;
case NC_WINDOW:
if (sipo->runtime.flag &
@@ -647,7 +616,7 @@ static void graph_listener(wmWindow *UNUSED(win),
break;
// XXX: restore the case below if not enough updates occur...
- //default:
+ // default:
// if (wmn->data == ND_KEYS)
// ED_area_tag_redraw(sa);
}
@@ -664,8 +633,9 @@ static void graph_refresh_fcurve_colors(const bContext *C)
int filter;
int i;
- if (ANIM_animdata_get_context(C, &ac) == false)
+ if (ANIM_animdata_get_context(C, &ac) == false) {
return;
+ }
UI_SetTheme(SPACE_GRAPH, RGN_TYPE_WINDOW);
@@ -683,13 +653,15 @@ static void graph_refresh_fcurve_colors(const bContext *C)
/* set color of curve here */
switch (fcu->color_mode) {
case FCURVE_COLOR_CUSTOM: {
- /* User has defined a custom color for this curve already (we assume it's not going to cause clashes with text colors),
+ /* User has defined a custom color for this curve already
+ * (we assume it's not going to cause clashes with text colors),
* which should be left alone... Nothing needs to be done here.
*/
break;
}
case FCURVE_COLOR_AUTO_RGB: {
- /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors.
+ /* F-Curve's array index is automatically mapped to RGB values.
+ * This works best of 3-value vectors.
* TODO: find a way to module the hue so that not all curves have same color...
*/
float *col = fcu->color;
@@ -793,9 +765,9 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
/* region updates? */
// XXX re-sizing y-extents of tot should go here?
- /* update the state of the animchannels in response to changes from the data they represent
- * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
- */
+ /* Update the state of the animchannels in response to changes from the data they represent
+ * NOTE: the temp flag is used to indicate when this needs to be done,
+ * and will be cleared once handled. */
if (sipo->runtime.flag & SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC) {
ANIM_sync_animchannels_to_data(C);
sipo->runtime.flag &= ~SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC;
diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt
index 70b7387bf6b..61e6b065cba 100644
--- a/source/blender/editors/space_image/CMakeLists.txt
+++ b/source/blender/editors/space_image/CMakeLists.txt
@@ -23,14 +23,14 @@ set(INC
../../blentranslation
../../bmesh
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../render/extern/include
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index e217987f212..752eedebe71 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -154,146 +154,6 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
return NULL;
}
-/* ************ panel stuff ************* */
-
-#if 0
-/* 0: disable preview
- * otherwise refresh preview
- *
- * XXX if you put this back, also check XXX in image_main_region_draw() */
-void image_preview_event(int event)
-{
- int exec = 0;
-
- if (event == 0) {
- G.scene->r.scemode &= ~R_COMP_CROP;
- exec = 1;
- }
- else {
- if (image_preview_active(curarea, NULL, NULL)) {
- G.scene->r.scemode |= R_COMP_CROP;
- exec = 1;
- }
- else
- G.scene->r.scemode &= ~R_COMP_CROP;
- }
-
- if (exec && G.scene->nodetree) {
- Scene *scene = G.scene;
- /* should work when no node editor in screen..., so we execute right away */
-
- ntreeCompositTagGenerators(G.scene->nodetree);
-
- G.is_break = false;
- G.scene->nodetree->timecursor = set_timecursor;
- G.scene->nodetree->test_break = BKE_blender_test_break;
-
- BIF_store_spare();
-
- /* 1 is do_previews */
- ntreeCompositExecTree(scene->nodetree, &scene->r, 1, &scene->view_settings, &scene->display_settings);
-
- G.scene->nodetree->timecursor = NULL;
- G.scene->nodetree->test_break = NULL;
-
- scrarea_do_windraw(curarea);
- waitcursor(0);
-
- WM_event_add_notifier(C, NC_IMAGE, ima_v);
- }
-}
-
-
-/* nothing drawn here, we use it to store values */
-static void preview_cb(ScrArea *sa, struct uiBlock *block)
-{
- SpaceImage *sima = sa->spacedata.first;
- rctf dispf;
- rcti *disprect = &G.scene->r.disprect;
- int winx = (G.scene->r.size * G.scene->r.xsch) / 100;
- int winy = (G.scene->r.size * G.scene->r.ysch) / 100;
- int mval[2];
-
- if (G.scene->r.mode & R_BORDER) {
- winx *= BLI_rcti_size_x(&G.scene->r.border);
- winy *= BLI_rctf_size_y(&G.scene->r.border);
- }
-
- /* while dragging we need to update the rects, otherwise it doesn't end with correct one */
-
- BLI_rctf_init(&dispf, 15.0f, BLI_rcti_size_x(&block->rect) - 15.0f, 15.0f, (BLI_rctf_size_y(&block->rect)) - 15.0f);
- ui_graphics_to_window_rct(sa->win, &dispf, disprect);
-
- /* correction for gla draw */
- BLI_rcti_translate(disprect, -curarea->winrct.xmin, -curarea->winrct.ymin);
-
- calc_image_view(sima, 'p');
-// printf("winrct %d %d %d %d\n", disprect->xmin, disprect->ymin, disprect->xmax, disprect->ymax);
- /* map to image space coordinates */
- mval[0] = disprect->xmin; mval[1] = disprect->ymin;
- areamouseco_to_ipoco(v2d, mval, &dispf.xmin, &dispf.ymin);
- mval[0] = disprect->xmax; mval[1] = disprect->ymax;
- areamouseco_to_ipoco(v2d, mval, &dispf.xmax, &dispf.ymax);
-
- /* map to render coordinates */
- disprect->xmin = dispf.xmin;
- disprect->xmax = dispf.xmax;
- disprect->ymin = dispf.ymin;
- disprect->ymax = dispf.ymax;
-
- CLAMP(disprect->xmin, 0, winx);
- CLAMP(disprect->xmax, 0, winx);
- CLAMP(disprect->ymin, 0, winy);
- CLAMP(disprect->ymax, 0, winy);
-// printf("drawrct %d %d %d %d\n", disprect->xmin, disprect->ymin, disprect->xmax, disprect->ymax);
-
-}
-
-static bool is_preview_allowed(ScrArea *cur)
-{
- SpaceImage *sima = cur->spacedata.first;
- ScrArea *sa;
-
- /* check if another areawindow has preview set */
- for (sa = G.curscreen->areabase.first; sa; sa = sa->next) {
- if (sa != cur && sa->spacetype == SPACE_IMAGE) {
- if (image_preview_active(sa, NULL, NULL))
- return 0;
- }
- }
- /* check image type */
- if (sima->image == NULL || sima->image->type != IMA_TYPE_COMPOSITE)
- return 0;
-
- return 1;
-}
-
-
-static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVIEW
-{
- uiBlock *block;
- SpaceImage *sima = sa->spacedata.first;
- int ofsx, ofsy;
-
- if (is_preview_allowed(sa) == 0) {
- rem_blockhandler(sa, IMAGE_HANDLER_PREVIEW);
- G.scene->r.scemode &= ~R_COMP_CROP; /* quite weak */
- return;
- }
-
- block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
- uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl);
- uiSetPanelHandler(IMAGE_HANDLER_PREVIEW); // for close and esc
-
- ofsx = -150 + (sa->winx / 2) / sima->blockscale;
- ofsy = -100 + (sa->winy / 2) / sima->blockscale;
- if (uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200) == 0) return;
-
- UI_but_func_drawextra_set(block, preview_cb);
-
-}
-#endif
-
/* ********************* callbacks for standard image buttons *************** */
static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p)
@@ -1063,17 +923,73 @@ void uiTemplateImage(uiLayout *layout,
iuser = ntree_get_active_iuser(scene->nodetree);
if (iuser) {
UI_block_align_begin(block);
- uiDefIconTextBut(block, UI_BTYPE_BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, "");
- uiDefIconTextBut(block, UI_BTYPE_BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110, 120, 100, 20, 0, 0, 0, 0, 0, "");
- but = uiDefBut(block, UI_BTYPE_BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, "");
+ uiDefIconTextBut(block,
+ UI_BTYPE_BUT,
+ B_SIMA_RECORD,
+ ICON_REC,
+ "Record",
+ 10,
+ 120,
+ 100,
+ 20,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ "");
+ uiDefIconTextBut(block,
+ UI_BTYPE_BUT,
+ B_SIMA_PLAY,
+ ICON_PLAY,
+ "Play",
+ 110,
+ 120,
+ 100,
+ 20,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ "");
+ but = uiDefBut(
+ block, UI_BTYPE_BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, "");
UI_but_func_set(but, image_freecache_cb, ima, NULL);
if (iuser->frames)
BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr);
- else strcpy(str, "Frames:");
+ else
+ strcpy(str, "Frames:");
UI_block_align_begin(block);
- uiDefButI(block, UI_BTYPE_NUM, imagechanged, str, 10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use");
- uiDefButI(block, UI_BTYPE_NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie");
+ uiDefButI(block,
+ UI_BTYPE_NUM,
+ imagechanged,
+ str,
+ 10,
+ 90,
+ 150,
+ 20,
+ &iuser->frames,
+ 0.0,
+ MAXFRAMEF,
+ 0,
+ 0,
+ "Number of images of a movie to use");
+ uiDefButI(block,
+ UI_BTYPE_NUM,
+ imagechanged,
+ "StartFr:",
+ 160,
+ 90,
+ 150,
+ 20,
+ &iuser->sfra,
+ 1.0,
+ MAXFRAMEF,
+ 0,
+ 0,
+ "Global starting frame of the movie");
}
#endif
}
@@ -1455,59 +1371,10 @@ void image_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel metadata");
strcpy(pt->idname, "IMAGE_PT_metadata");
strcpy(pt->label, N_("Metadata"));
+ strcpy(pt->category, "Image");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->poll = metadata_panel_context_poll;
pt->draw = metadata_panel_context_draw;
pt->flag |= PNL_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
}
-
-static int image_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = image_has_buttons_region(sa);
-
- if (ar) {
- ED_region_toggle_hidden(C, ar);
- }
-
- return OPERATOR_FINISHED;
-}
-
-void IMAGE_OT_properties(wmOperatorType *ot)
-{
- ot->name = "Toggle Sidebar";
- ot->idname = "IMAGE_OT_properties";
- ot->description = "Toggle the properties region visibility";
-
- ot->exec = image_properties_toggle_exec;
- ot->poll = ED_operator_image_active;
-
- /* flags */
- ot->flag = 0;
-}
-
-static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = image_has_tools_region(sa);
-
- if (ar) {
- ED_region_toggle_hidden(C, ar);
- }
-
- return OPERATOR_FINISHED;
-}
-
-void IMAGE_OT_toolshelf(wmOperatorType *ot)
-{
- ot->name = "Toggle Toolbar";
- ot->idname = "IMAGE_OT_toolshelf";
- ot->description = "Toggles tool shelf display";
-
- ot->exec = image_scopes_toggle_exec;
- ot->poll = ED_operator_image_active;
-
- /* flags */
- ot->flag = 0;
-}
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index a87808e1601..9b57644b6ec 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -575,7 +575,7 @@ static void draw_image_buffer(const bContext *C,
/* If RGBA display with color management */
if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B | SI_SHOW_ALPHA)) == 0) {
- glaDrawImBuf_glsl_ctx_clipping(
+ ED_draw_imbuf_ctx_clipping(
C, ibuf, x, y, GL_NEAREST, 0, 0, clip_max_x, clip_max_y, zoomx, zoomy);
}
else {
@@ -673,7 +673,7 @@ void draw_image_grease_pencil(bContext *C, bool onlyv2d)
}
else {
/* assume that UI_view2d_restore(C) has been called... */
- //SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
+ // SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
/* draw grease-pencil ('screen' strokes) */
ED_annotation_draw_view2d(C, 0);
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index db56f1051c5..a851684f2f3 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -34,8 +34,6 @@ struct bNodeTree;
struct wmOperatorType;
/* space_image.c */
-struct ARegion *image_has_buttons_region(struct ScrArea *sa);
-struct ARegion *image_has_tools_region(struct ScrArea *sa);
extern const char *image_context_dir[]; /* doc access */
@@ -91,7 +89,5 @@ void IMAGE_OT_clear_render_border(struct wmOperatorType *ot);
/* image_panels.c */
struct ImageUser *ntree_get_active_iuser(struct bNodeTree *ntree);
void image_buttons_register(struct ARegionType *art);
-void IMAGE_OT_properties(struct wmOperatorType *ot);
-void IMAGE_OT_toolshelf(struct wmOperatorType *ot);
#endif /* __IMAGE_INTERN_H__ */
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 06bacabe6fa..cec2e1c68d9 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -51,6 +51,7 @@
#include "BKE_context.h"
#include "BKE_icons.h"
#include "BKE_image.h"
+#include "BKE_image_save.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -64,6 +65,7 @@
#include "DEG_depsgraph.h"
#include "GPU_draw.h"
+#include "GPU_state.h"
#include "GPU_immediate.h"
#include "IMB_colormanagement.h"
@@ -289,7 +291,8 @@ static bool image_sample_poll(bContext *C)
if (sima) {
Object *obedit = CTX_data_edit_object(C);
if (obedit) {
- /* Disable when UV editing so it doesn't swallow all click events (use for setting cursor). */
+ /* Disable when UV editing so it doesn't swallow all click events
+ * (use for setting cursor). */
if (ED_space_image_show_uvedit(sima, obedit)) {
return false;
}
@@ -355,15 +358,6 @@ static int image_view_pan_exec(bContext *C, wmOperator *op)
ED_region_tag_redraw(CTX_wm_region(C));
- /* XXX notifier? */
-#if 0
- if (image_preview_active(curarea, NULL, NULL)) {
- /* recalculates new preview rect */
- scrarea_do_windraw(curarea);
- image_preview_event(2);
- }
-#endif
-
return OPERATOR_FINISHED;
}
@@ -520,15 +514,6 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op)
ED_region_tag_redraw(ar);
- /* XXX notifier? */
-#if 0
- if (image_preview_active(curarea, NULL, NULL)) {
- /* recalculates new preview rect */
- scrarea_do_windraw(curarea);
- image_preview_event(2);
- }
-#endif
-
return OPERATOR_FINISHED;
}
@@ -596,7 +581,7 @@ static void image_zoom_apply(ViewZoomData *vpd,
zfac = 1.0f + ((fac / 20.0f) * time_step);
vpd->timer_lastdraw = time;
/* this is the final zoom, but instead make it into a factor */
- //zoom = vpd->sima->zoom * zfac;
+ // zoom = vpd->sima->zoom * zfac;
factor = (vpd->sima->zoom * zfac) / vpd->zoom;
}
else {
@@ -1005,15 +990,6 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
sima->xof = (int)sima->xof;
sima->yof = (int)sima->yof;
- /* XXX notifier? */
-#if 0
- if (image_preview_active(curarea, NULL, NULL)) {
- /* recalculates new preview rect */
- scrarea_do_windraw(curarea);
- image_preview_event(2);
- }
-#endif
-
ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
@@ -1143,9 +1119,10 @@ static void image_open_cancel(bContext *UNUSED(C), wmOperator *op)
}
/**
- * \brief Get a list of frames from the list of image files matching the first file name sequence pattern
- * \param ptr: [in] the RNA pointer containing the "directory" entry and "files" collection
- * \param frames_all: [out] the list of frame numbers found in the files matching the first one by name
+ * Get a list of frames from the list of image files matching the first file name sequence pattern.
+ * \param ptr[in]: The RNA pointer containing the "directory" entry and "files" collection.
+ * \param frames_all[out]: the list of frame numbers found in the files matching
+ * the first one by name.
*/
static void image_sequence_get_frame_ranges(PointerRNA *ptr, ListBase *frames_all)
{
@@ -1200,7 +1177,8 @@ static int image_cmp_frame(const void *a, const void *b)
}
/**
- * Return the start (offset) and the length of the sequence of continuous frames in the list of frames
+ * Return the start (offset) and the length of the sequence of
+ * continuous frames in the list of frames.
*
* \param frames: [in] the list of frame numbers, as a side-effect the list is sorted.
* \param ofs: [out] offset the first frame number in the sequence.
@@ -1678,19 +1656,6 @@ void IMAGE_OT_replace(wmOperatorType *ot)
/******************** save image as operator ********************/
-typedef struct {
- /* matching scene->r settings */
- //short planes, imtype, subimtype, quality;
- ImageFormatData im_format;
- char filepath[FILE_MAX]; /* keep absolute */
-} SaveImageOptions;
-
-static void save_image_options_defaults(SaveImageOptions *simopts)
-{
- BKE_imformat_defaults(&simopts->im_format);
- simopts->filepath[0] = '\0';
-}
-
static char imtype_best_depth(ImBuf *ibuf, const char imtype)
{
const char depth_ok = BKE_imtype_valid_depths(imtype);
@@ -1730,466 +1695,148 @@ static char imtype_best_depth(ImBuf *ibuf, const char imtype)
}
}
-static int save_image_options_init(Main *bmain,
- SaveImageOptions *simopts,
- SpaceImage *sima,
- Scene *scene,
+static int image_save_options_init(Main *bmain,
+ ImageSaveOptions *opts,
+ Image *ima,
+ ImageUser *iuser,
const bool guess_path,
const bool save_as_render)
{
void *lock;
- ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
if (ibuf) {
- Image *ima = sima->image;
+ Scene *scene = opts->scene;
bool is_depth_set = false;
if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) {
/* imtype */
- simopts->im_format = scene->r.im_format;
+ opts->im_format = scene->r.im_format;
is_depth_set = true;
if (!BKE_image_is_multiview(ima)) {
/* In case multiview is disabled,
* render settings would be invalid for render result in this area. */
- simopts->im_format.stereo3d_format = *ima->stereo3d_format;
- simopts->im_format.views_format = ima->views_format;
+ opts->im_format.stereo3d_format = *ima->stereo3d_format;
+ opts->im_format.views_format = ima->views_format;
}
}
else {
if (ima->source == IMA_SRC_GENERATED) {
- simopts->im_format.imtype = R_IMF_IMTYPE_PNG;
- simopts->im_format.compress = ibuf->foptions.quality;
- simopts->im_format.planes = ibuf->planes;
+ opts->im_format.imtype = R_IMF_IMTYPE_PNG;
+ opts->im_format.compress = ibuf->foptions.quality;
+ opts->im_format.planes = ibuf->planes;
}
else {
- BKE_imbuf_to_image_format(&simopts->im_format, ibuf);
+ BKE_imbuf_to_image_format(&opts->im_format, ibuf);
}
/* use the multiview image settings as the default */
- simopts->im_format.stereo3d_format = *ima->stereo3d_format;
- simopts->im_format.views_format = ima->views_format;
+ opts->im_format.stereo3d_format = *ima->stereo3d_format;
+ opts->im_format.views_format = ima->views_format;
}
///* XXX - this is lame, we need to make these available too! */
- //simopts->subimtype = scene->r.subimtype;
+ // opts->subimtype = scene->r.subimtype;
- BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath));
+ BLI_strncpy(opts->filepath, ibuf->name, sizeof(opts->filepath));
/* sanitize all settings */
/* unlikely but just in case */
- if (ELEM(simopts->im_format.planes, R_IMF_PLANES_BW, R_IMF_PLANES_RGB, R_IMF_PLANES_RGBA) ==
- 0) {
- simopts->im_format.planes = R_IMF_PLANES_RGBA;
+ if (ELEM(opts->im_format.planes, R_IMF_PLANES_BW, R_IMF_PLANES_RGB, R_IMF_PLANES_RGBA) == 0) {
+ opts->im_format.planes = R_IMF_PLANES_RGBA;
}
/* depth, account for float buffer and format support */
if (is_depth_set == false) {
- simopts->im_format.depth = imtype_best_depth(ibuf, simopts->im_format.imtype);
+ opts->im_format.depth = imtype_best_depth(ibuf, opts->im_format.imtype);
}
/* some formats don't use quality so fallback to scenes quality */
- if (simopts->im_format.quality == 0) {
- simopts->im_format.quality = scene->r.im_format.quality;
+ if (opts->im_format.quality == 0) {
+ opts->im_format.quality = scene->r.im_format.quality;
}
/* check for empty path */
- if (guess_path && simopts->filepath[0] == 0) {
+ if (guess_path && opts->filepath[0] == 0) {
const bool is_prev_save = !STREQ(G.ima, "//");
if (save_as_render) {
if (is_prev_save) {
- BLI_strncpy(simopts->filepath, G.ima, sizeof(simopts->filepath));
+ BLI_strncpy(opts->filepath, G.ima, sizeof(opts->filepath));
}
else {
- BLI_strncpy(simopts->filepath, "//untitled", sizeof(simopts->filepath));
- BLI_path_abs(simopts->filepath, BKE_main_blendfile_path(bmain));
+ BLI_strncpy(opts->filepath, "//untitled", sizeof(opts->filepath));
+ BLI_path_abs(opts->filepath, BKE_main_blendfile_path(bmain));
}
}
else {
- BLI_snprintf(simopts->filepath, sizeof(simopts->filepath), "//%s", ima->id.name + 2);
- BLI_path_abs(simopts->filepath, is_prev_save ? G.ima : BKE_main_blendfile_path(bmain));
+ BLI_snprintf(opts->filepath, sizeof(opts->filepath), "//%s", ima->id.name + 2);
+ BLI_path_abs(opts->filepath, is_prev_save ? G.ima : BKE_main_blendfile_path(bmain));
}
}
/* color management */
- BKE_color_managed_display_settings_copy(&simopts->im_format.display_settings,
+ BKE_color_managed_display_settings_copy(&opts->im_format.display_settings,
&scene->display_settings);
- BKE_color_managed_view_settings_copy(&simopts->im_format.view_settings, &scene->view_settings);
+ BKE_color_managed_view_settings_copy(&opts->im_format.view_settings, &scene->view_settings);
}
- ED_space_image_release_buffer(sima, ibuf, lock);
+ BKE_image_release_ibuf(ima, ibuf, lock);
return (ibuf != NULL);
}
-static void save_image_options_from_op(Main *bmain, SaveImageOptions *simopts, wmOperator *op)
+static void image_save_options_from_op(Main *bmain, ImageSaveOptions *opts, wmOperator *op)
{
if (op->customdata) {
- BKE_color_managed_view_settings_free(&simopts->im_format.view_settings);
+ BKE_color_managed_view_settings_free(&opts->im_format.view_settings);
- simopts->im_format = *(ImageFormatData *)op->customdata;
+ opts->im_format = *(ImageFormatData *)op->customdata;
}
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
- RNA_string_get(op->ptr, "filepath", simopts->filepath);
- BLI_path_abs(simopts->filepath, BKE_main_blendfile_path(bmain));
+ RNA_string_get(op->ptr, "filepath", opts->filepath);
+ BLI_path_abs(opts->filepath, BKE_main_blendfile_path(bmain));
}
}
-static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
+static void image_save_options_to_op(ImageSaveOptions *opts, wmOperator *op)
{
if (op->customdata) {
BKE_color_managed_view_settings_free(&((ImageFormatData *)op->customdata)->view_settings);
- *(ImageFormatData *)op->customdata = simopts->im_format;
- }
-
- RNA_string_set(op->ptr, "filepath", simopts->filepath);
-}
-
-static void save_image_post(Main *bmain,
- wmOperator *op,
- ImBuf *ibuf,
- Image *ima,
- int ok,
- int save_copy,
- const char *relbase,
- int relative,
- int do_newpath,
- const char *filepath)
-{
- if (ok) {
- if (!save_copy) {
- ColorManagedColorspaceSettings old_colorspace_settings;
-
- if (do_newpath) {
- BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name));
- BLI_strncpy(ima->name, filepath, sizeof(ima->name));
- }
-
- ibuf->userflags &= ~IB_BITMAPDIRTY;
-
- /* change type? */
- if (ima->type == IMA_TYPE_R_RESULT) {
- ima->type = IMA_TYPE_IMAGE;
-
- /* workaround to ensure the render result buffer is no longer used
- * by this image, otherwise can crash when a new render result is
- * created. */
- if (ibuf->rect && !(ibuf->mall & IB_rect)) {
- imb_freerectImBuf(ibuf);
- }
- if (ibuf->rect_float && !(ibuf->mall & IB_rectfloat)) {
- imb_freerectfloatImBuf(ibuf);
- }
- if (ibuf->zbuf && !(ibuf->mall & IB_zbuf)) {
- IMB_freezbufImBuf(ibuf);
- }
- if (ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat)) {
- IMB_freezbuffloatImBuf(ibuf);
- }
- }
- if (ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
- ima->source = IMA_SRC_FILE;
- ima->type = IMA_TYPE_IMAGE;
- }
-
- /* only image path, never ibuf */
- if (relative) {
- BLI_path_rel(ima->name, relbase); /* only after saving */
- }
-
- BKE_color_managed_colorspace_settings_copy(&old_colorspace_settings,
- &ima->colorspace_settings);
- IMB_colormanagement_colorspace_from_ibuf_ftype(&ima->colorspace_settings, ibuf);
- if (!BKE_color_managed_colorspace_settings_equals(&old_colorspace_settings,
- &ima->colorspace_settings)) {
- BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE);
- }
- }
- }
- else {
- BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
+ *(ImageFormatData *)op->customdata = opts->im_format;
}
-}
-
-static void save_imbuf_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf)
-{
- if (colormanaged_ibuf != ibuf) {
- /* This guys might be modified by image buffer write functions,
- * need to copy them back from color managed image buffer to an
- * original one, so file type of image is being properly updated.
- */
- ibuf->ftype = colormanaged_ibuf->ftype;
- ibuf->foptions = colormanaged_ibuf->foptions;
- ibuf->planes = colormanaged_ibuf->planes;
- IMB_freeImBuf(colormanaged_ibuf);
- }
+ RNA_string_set(op->ptr, "filepath", opts->filepath);
}
-/**
- * \return success.
- * \note ``ima->name`` and ``ibuf->name`` should end up the same.
- * \note for multiview the first ``ibuf`` is important to get the settings.
- */
-static bool save_image_doit(
- bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, bool do_newpath)
+static bool save_image_op(const bContext *C,
+ SpaceImage *sima,
+ wmOperator *op,
+ ImageSaveOptions *opts)
{
Main *bmain = CTX_data_main(C);
Image *ima = ED_space_image(sima);
- void *lock;
- ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
- Scene *scene;
- RenderResult *rr = NULL;
- bool ok = false;
-
- WM_cursor_wait(1);
-
- if (ibuf) {
- ImBuf *colormanaged_ibuf = NULL;
- const char *relbase = ID_BLEND_PATH(CTX_data_main(C), &ima->id);
- const bool relative = (RNA_struct_find_property(op->ptr, "relative_path") &&
- RNA_boolean_get(op->ptr, "relative_path"));
- const bool save_copy = (RNA_struct_find_property(op->ptr, "copy") &&
- RNA_boolean_get(op->ptr, "copy"));
- const bool save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") &&
- RNA_boolean_get(op->ptr, "save_as_render"));
- ImageFormatData *imf = &simopts->im_format;
-
- /* old global to ensure a 2nd save goes to same dir */
- BLI_strncpy(G.ima, simopts->filepath, sizeof(G.ima));
-
- if (ima->type == IMA_TYPE_R_RESULT) {
- /* enforce user setting for RGB or RGBA, but skip BW */
- if (simopts->im_format.planes == R_IMF_PLANES_RGBA) {
- ibuf->planes = R_IMF_PLANES_RGBA;
- }
- else if (simopts->im_format.planes == R_IMF_PLANES_RGB) {
- ibuf->planes = R_IMF_PLANES_RGB;
- }
- }
- else {
- /* TODO, better solution, if a 24bit image is painted onto it may contain alpha */
- if ((simopts->im_format.planes == R_IMF_PLANES_RGBA) &&
- /* it has been painted onto */
- (ibuf->userflags & IB_BITMAPDIRTY)) {
- /* checks each pixel, not ideal */
- ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? R_IMF_PLANES_RGBA : R_IMF_PLANES_RGB;
- }
- }
-
- /* we need renderresult for exr and rendered multiview */
- scene = CTX_data_scene(C);
- rr = BKE_image_acquire_renderresult(scene, ima);
- bool is_mono = rr ? BLI_listbase_count_at_most(&rr->views, 2) < 2 :
- BLI_listbase_count_at_most(&ima->views, 2) < 2;
- bool is_exr_rr = rr && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER) &&
- RE_HasFloatPixels(rr);
- bool is_multilayer = is_exr_rr && (imf->imtype == R_IMF_IMTYPE_MULTILAYER);
- int layer = (is_multilayer) ? -1 : sima->iuser.layer;
-
- /* error handling */
- if (!rr) {
- if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) {
- BKE_report(op->reports, RPT_ERROR, "Did not write, no Multilayer Image");
- goto cleanup;
- }
- }
- else {
- if (imf->views_format == R_IMF_VIEWS_STEREO_3D) {
- if (!BKE_image_is_stereo(ima)) {
- BKE_reportf(op->reports,
- RPT_ERROR,
- "Did not write, the image doesn't have a \"%s\" and \"%s\" views",
- STEREO_LEFT_NAME,
- STEREO_RIGHT_NAME);
- goto cleanup;
- }
-
- /* it shouldn't ever happen*/
- if ((BLI_findstring(&rr->views, STEREO_LEFT_NAME, offsetof(RenderView, name)) == NULL) ||
- (BLI_findstring(&rr->views, STEREO_RIGHT_NAME, offsetof(RenderView, name)) == NULL)) {
- BKE_reportf(op->reports,
- RPT_ERROR,
- "Did not write, the image doesn't have a \"%s\" and \"%s\" views",
- STEREO_LEFT_NAME,
- STEREO_RIGHT_NAME);
- goto cleanup;
- }
- }
- BKE_imbuf_stamp_info(rr, ibuf);
- }
-
- /* fancy multiview OpenEXR */
- if (imf->views_format == R_IMF_VIEWS_MULTIVIEW && is_exr_rr) {
- /* save render result */
- ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, layer);
- save_image_post(
- bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
- ED_space_image_release_buffer(sima, ibuf, lock);
- }
- /* regular mono pipeline */
- else if (is_mono) {
- if (is_exr_rr) {
- ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, layer);
- }
- else {
- colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(
- ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
- ok = BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, imf, save_copy);
- save_imbuf_post(ibuf, colormanaged_ibuf);
- }
- save_image_post(bmain,
- op,
- ibuf,
- ima,
- ok,
- (is_exr_rr ? true : save_copy),
- relbase,
- relative,
- do_newpath,
- simopts->filepath);
- ED_space_image_release_buffer(sima, ibuf, lock);
- }
- /* individual multiview images */
- else if (imf->views_format == R_IMF_VIEWS_INDIVIDUAL) {
- int i;
- unsigned char planes = ibuf->planes;
- const int totviews = (rr ? BLI_listbase_count(&rr->views) : BLI_listbase_count(&ima->views));
-
- if (!is_exr_rr) {
- ED_space_image_release_buffer(sima, ibuf, lock);
- }
-
- for (i = 0; i < totviews; i++) {
- char filepath[FILE_MAX];
- bool ok_view = false;
- const char *view = rr ? ((RenderView *)BLI_findlink(&rr->views, i))->name :
- ((ImageView *)BLI_findlink(&ima->views, i))->name;
-
- if (is_exr_rr) {
- BKE_scene_multiview_view_filepath_get(&scene->r, simopts->filepath, view, filepath);
- ok_view = RE_WriteRenderResult(op->reports, rr, filepath, imf, view, layer);
- save_image_post(
- bmain, op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath);
- }
- else {
- /* copy iuser to get the correct ibuf for this view */
- ImageUser iuser = sima->iuser;
- iuser.view = i;
- iuser.flag &= ~IMA_SHOW_STEREO;
-
- if (rr) {
- BKE_image_multilayer_index(rr, &iuser);
- }
- else {
- BKE_image_multiview_index(ima, &iuser);
- }
-
- ibuf = BKE_image_acquire_ibuf(sima->image, &iuser, &lock);
- ibuf->planes = planes;
-
- BKE_scene_multiview_view_filepath_get(&scene->r, simopts->filepath, view, filepath);
-
- colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(
- ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
- ok_view = BKE_imbuf_write_as(
- colormanaged_ibuf, filepath, &simopts->im_format, save_copy);
- save_imbuf_post(ibuf, colormanaged_ibuf);
- save_image_post(
- bmain, op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath);
- BKE_image_release_ibuf(sima->image, ibuf, lock);
- }
- ok &= ok_view;
- }
-
- if (is_exr_rr) {
- ED_space_image_release_buffer(sima, ibuf, lock);
- }
- }
- /* stereo (multiview) images */
- else if (simopts->im_format.views_format == R_IMF_VIEWS_STEREO_3D) {
- if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) {
- ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, layer);
- save_image_post(
- bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath);
- ED_space_image_release_buffer(sima, ibuf, lock);
- }
- else {
- ImBuf *ibuf_stereo[2] = {NULL};
-
- unsigned char planes = ibuf->planes;
- const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
- int i;
+ ImageUser *iuser = &sima->iuser;
- /* we need to get the specific per-view buffers */
- ED_space_image_release_buffer(sima, ibuf, lock);
+ opts->relative = (RNA_struct_find_property(op->ptr, "relative_path") &&
+ RNA_boolean_get(op->ptr, "relative_path"));
+ opts->save_copy = (RNA_struct_find_property(op->ptr, "copy") &&
+ RNA_boolean_get(op->ptr, "copy"));
+ opts->save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") &&
+ RNA_boolean_get(op->ptr, "save_as_render"));
- for (i = 0; i < 2; i++) {
- ImageUser iuser = sima->iuser;
- iuser.flag &= ~IMA_SHOW_STEREO;
-
- if (rr) {
- int id = BLI_findstringindex(&rr->views, names[i], offsetof(RenderView, name));
- iuser.view = id;
- BKE_image_multilayer_index(rr, &iuser);
- }
- else {
- iuser.view = i;
- BKE_image_multiview_index(ima, &iuser);
- }
-
- ibuf = BKE_image_acquire_ibuf(sima->image, &iuser, &lock);
-
- if (ibuf == NULL) {
- BKE_report(op->reports,
- RPT_ERROR,
- "Did not write, unexpected error when saving stereo image");
- goto cleanup;
- }
-
- ibuf->planes = planes;
-
- /* color manage the ImBuf leaving it ready for saving */
- colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(
- ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf);
-
- BKE_imbuf_write_prepare(colormanaged_ibuf, imf);
- IMB_prepare_write_ImBuf(IMB_isfloat(colormanaged_ibuf), colormanaged_ibuf);
-
- /* duplicate buffer to prevent locker issue when using render result */
- ibuf_stereo[i] = IMB_dupImBuf(colormanaged_ibuf);
-
- save_imbuf_post(ibuf, colormanaged_ibuf);
- BKE_image_release_ibuf(sima->image, ibuf, lock);
- }
-
- ibuf = IMB_stereo3d_ImBuf(imf, ibuf_stereo[0], ibuf_stereo[1]);
-
- /* save via traditional path */
- ok = BKE_imbuf_write_as(ibuf, simopts->filepath, imf, save_copy);
-
- IMB_freeImBuf(ibuf);
+ WM_cursor_wait(1);
- for (i = 0; i < 2; i++) {
- IMB_freeImBuf(ibuf_stereo[i]);
- }
- }
- }
+ bool ok = BKE_image_save(op->reports, bmain, ima, iuser, opts);
- WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image);
- }
- else {
- cleanup:
- ED_space_image_release_buffer(sima, ibuf, lock);
- }
+ WM_cursor_wait(0);
- if (rr) {
- BKE_image_release_renderresult(scene, ima);
- }
+ /* Remember file path for next save. */
+ BLI_strncpy(G.ima, opts->filepath, sizeof(G.ima));
- WM_cursor_wait(0);
+ WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
return ok;
}
@@ -2208,18 +1855,20 @@ static void image_save_as_free(wmOperator *op)
static int image_save_as_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
SpaceImage *sima = CTX_wm_space_image(C);
- SaveImageOptions simopts;
+ ImageSaveOptions opts;
- save_image_options_defaults(&simopts);
+ BKE_image_save_options_init(&opts, bmain, scene);
/* just in case to initialize values,
* these should be set on invoke or by the caller. */
- save_image_options_init(bmain, &simopts, sima, CTX_data_scene(C), false, false);
+ image_save_options_init(bmain, &opts, sima->image, &sima->iuser, false, false);
- save_image_options_from_op(bmain, &simopts, op);
+ image_save_options_from_op(bmain, &opts, op);
+ opts.do_newpath = true;
- save_image_doit(C, sima, op, &simopts, true);
+ save_image_op(C, sima, op, &opts);
image_save_as_free(op);
return OPERATOR_FINISHED;
@@ -2237,7 +1886,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = ED_space_image(sima);
Scene *scene = CTX_data_scene(C);
- SaveImageOptions simopts;
+ ImageSaveOptions opts;
PropertyRNA *prop;
const bool save_as_render = ((ima->source == IMA_SRC_VIEWER) ||
(ima->flag & IMA_VIEW_AS_RENDER));
@@ -2246,12 +1895,12 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
return image_save_as_exec(C, op);
}
- save_image_options_defaults(&simopts);
+ BKE_image_save_options_init(&opts, bmain, scene);
- if (save_image_options_init(bmain, &simopts, sima, scene, true, save_as_render) == 0) {
+ if (image_save_options_init(bmain, &opts, ima, &sima->iuser, true, save_as_render) == 0) {
return OPERATOR_CANCELLED;
}
- save_image_options_to_op(&simopts, op);
+ image_save_options_to_op(&opts, op);
/* enable save_copy by default for render results */
if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) &&
@@ -2261,8 +1910,8 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
RNA_boolean_set(op->ptr, "save_as_render", save_as_render);
- op->customdata = MEM_mallocN(sizeof(simopts.im_format), __func__);
- memcpy(op->customdata, &simopts.im_format, sizeof(simopts.im_format));
+ op->customdata = MEM_mallocN(sizeof(opts.im_format), __func__);
+ memcpy(op->customdata, &opts.im_format, sizeof(opts.im_format));
/* show multiview save options only if image has multiviews */
prop = RNA_struct_find_property(op->ptr, "show_multiview");
@@ -2270,7 +1919,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
prop = RNA_struct_find_property(op->ptr, "use_multiview");
RNA_property_boolean_set(op->ptr, prop, BKE_image_is_multiview(ima));
- image_filesel(C, op, simopts.filepath);
+ image_filesel(C, op, opts.filepath);
return OPERATOR_RUNNING_MODAL;
}
@@ -2378,23 +2027,23 @@ static int image_save_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
- SaveImageOptions simopts;
+ ImageSaveOptions opts;
- save_image_options_defaults(&simopts);
- if (save_image_options_init(bmain, &simopts, sima, scene, false, false) == 0) {
+ BKE_image_save_options_init(&opts, bmain, scene);
+ if (image_save_options_init(bmain, &opts, sima->image, &sima->iuser, false, false) == 0) {
return OPERATOR_CANCELLED;
}
- save_image_options_from_op(bmain, &simopts, op);
+ image_save_options_from_op(bmain, &opts, op);
- if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) {
- if (save_image_doit(C, sima, op, &simopts, false)) {
+ if (BLI_exists(opts.filepath) && BLI_file_is_writable(opts.filepath)) {
+ if (save_image_op(C, sima, op, &opts)) {
/* report since this can be called from key-shortcuts */
- BKE_reportf(op->reports, RPT_INFO, "Saved Image '%s'", simopts.filepath);
+ BKE_reportf(op->reports, RPT_INFO, "Saved Image '%s'", opts.filepath);
}
}
else {
BKE_reportf(
- op->reports, RPT_ERROR, "Cannot save image, path '%s' is not writable", simopts.filepath);
+ op->reports, RPT_ERROR, "Cannot save image, path '%s' is not writable", opts.filepath);
return OPERATOR_CANCELLED;
}
@@ -2897,14 +2546,10 @@ void IMAGE_OT_invert(wmOperatorType *ot)
static bool image_pack_test(bContext *C, wmOperator *op)
{
Image *ima = CTX_data_edit_image(C);
- const bool as_png = RNA_boolean_get(op->ptr, "as_png");
if (!ima) {
return 0;
}
- if (!as_png && BKE_image_has_packedfile(ima)) {
- return 0;
- }
if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
BKE_report(op->reports, RPT_ERROR, "Packing movies or image sequences not supported");
@@ -2918,19 +2563,12 @@ static int image_pack_exec(bContext *C, wmOperator *op)
{
struct Main *bmain = CTX_data_main(C);
Image *ima = CTX_data_edit_image(C);
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
- const bool as_png = RNA_boolean_get(op->ptr, "as_png");
if (!image_pack_test(C, op)) {
return OPERATOR_CANCELLED;
}
- if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
- BKE_report(op->reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
- return OPERATOR_CANCELLED;
- }
-
- if (as_png) {
+ if (BKE_image_is_dirty(ima)) {
BKE_image_memorypack(ima);
}
else {
@@ -2939,46 +2577,9 @@ static int image_pack_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
- BKE_image_release_ibuf(ima, ibuf, NULL);
-
return OPERATOR_FINISHED;
}
-static int image_pack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- Image *ima = CTX_data_edit_image(C);
- ImBuf *ibuf;
- uiPopupMenu *pup;
- uiLayout *layout;
- const bool as_png = RNA_boolean_get(op->ptr, "as_png");
-
- if (!image_pack_test(C, op)) {
- return OPERATOR_CANCELLED;
- }
-
- ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
-
- if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
- pup = UI_popup_menu_begin(C, IFACE_("OK"), ICON_QUESTION);
- layout = UI_popup_menu_layout(pup);
- uiItemBooleanO(layout,
- IFACE_("Can't pack edited image from disk, pack as internal PNG?"),
- ICON_NONE,
- op->idname,
- "as_png",
- 1);
- UI_popup_menu_end(C, pup);
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
-
- return OPERATOR_INTERFACE;
- }
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
-
- return image_pack_exec(C, op);
-}
-
void IMAGE_OT_pack(wmOperatorType *ot)
{
/* identifiers */
@@ -2988,13 +2589,9 @@ void IMAGE_OT_pack(wmOperatorType *ot)
/* api callbacks */
ot->exec = image_pack_exec;
- ot->invoke = image_pack_invoke;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_boolean(ot->srna, "as_png", 0, "Pack As PNG", "Pack image as lossless PNG");
}
/********************* unpack operator *********************/
@@ -3164,6 +2761,7 @@ static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info)
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
+ GPU_line_width(1.0f);
imm_draw_box_wire_2d(pos,
(float)sample_rect_fl.xmin,
(float)sample_rect_fl.ymin,
@@ -3403,14 +3001,14 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
{
ScrArea *sa, *cur = curarea;
- node_curvemap_sample(fp); /* sends global to node editor */
+ node_curvemap_sample(fp); /* sends global to node editor */
for (sa = G.curscreen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_NODE) {
areawinset(sa->win);
scrarea_do_windraw(sa);
}
}
- node_curvemap_sample(NULL); /* clears global in node editor */
+ node_curvemap_sample(NULL); /* clears global in node editor */
curarea = cur;
}
#endif
@@ -3649,9 +3247,12 @@ static int image_record_composite_apply(bContext *C, wmOperator *op)
// XXX scene->nodetree->test_break = NULL;
BKE_image_all_free_anim_ibufs(scene->r.cfra);
- ntreeCompositTagAnimated(scene->nodetree);
- ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra,
- &scene->view_settings, &scene->display_settings); /* 1 is no previews */
+ ntreeCompositExecTree(scene->nodetree,
+ &scene->r,
+ 0,
+ scene->r.cfra != rcd->old_cfra,
+ &scene->view_settings,
+ &scene->display_settings); /* 1 is no previews */
ED_area_tag_redraw(CTX_wm_area(C));
@@ -3714,7 +3315,8 @@ static int image_record_composite_exec(bContext *C, wmOperator *op)
if (!image_record_composite_init(C, op))
return OPERATOR_CANCELLED;
- while (image_record_composite_apply(C, op)) {}
+ while (image_record_composite_apply(C, op)) {
+ }
image_record_composite_exit(C, op);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index e1875fd6129..386e258a833 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -115,66 +115,6 @@ static void image_user_refresh_scene(const bContext *C, SpaceImage *sima)
ED_space_image_auto_set(C, sima);
}
-/* ******************** manage regions ********************* */
-
-ARegion *image_has_buttons_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) {
- return ar;
- }
-
- /* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
- /* is error! */
- if (ar == NULL) {
- return NULL;
- }
-
- arnew = MEM_callocN(sizeof(ARegion), "buttons for image");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
-ARegion *image_has_tools_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
- if (ar) {
- return ar;
- }
-
- /* add subdiv level; after buttons */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
-
- /* is error! */
- if (ar == NULL) {
- return NULL;
- }
-
- arnew = MEM_callocN(sizeof(ARegion), "scopes for image");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_TOOLS;
- arnew->alignment = RGN_ALIGN_LEFT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- image_scopes_tag_refresh(sa);
-
- return arnew;
-}
-
/* ******************** default callbacks for image space ***************** */
static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
@@ -188,13 +128,20 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce
simage->lock = true;
simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA | SI_COORDFLOATS;
- simage->iuser.ok = true;
- simage->iuser.frames = 100;
+ BKE_imageuser_default(&simage->iuser);
simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS;
scopes_new(&simage->scopes);
simage->sample_line_hist.height = 100;
+ /* tool header */
+ ar = MEM_callocN(sizeof(ARegion), "tool header for image");
+
+ BLI_addtail(&simage->regionbase, ar);
+ ar->regiontype = RGN_TYPE_TOOL_HEADER;
+ ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+ ar->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for image");
@@ -291,9 +238,6 @@ static void image_operatortypes(void)
WM_operatortype_append(IMAGE_OT_sample_line);
WM_operatortype_append(IMAGE_OT_curves_point_set);
- WM_operatortype_append(IMAGE_OT_properties);
- WM_operatortype_append(IMAGE_OT_toolshelf);
-
WM_operatortype_append(IMAGE_OT_change_frame);
WM_operatortype_append(IMAGE_OT_read_viewlayers);
@@ -593,29 +537,26 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar)
/* mask polls mode */
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* image paint polls for mode */
keymap = WM_keymap_ensure(wm->defaultconf, "Curve", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "UV Editor", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
- keymap = WM_keymap_ensure(wm->defaultconf, "UV Sculpt", 0, 0);
- WM_event_add_keymap_handler(&ar->handlers, keymap);
-
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Image", SPACE_IMAGE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void image_main_region_draw(const bContext *C, ARegion *ar)
@@ -630,7 +571,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
View2D *v2d = &ar->v2d;
- //View2DScrollers *scrollers;
+ // View2DScrollers *scrollers;
float col[3];
/* XXX This is in order to draw UI batches with the DRW
@@ -664,7 +605,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
- ED_uvedit_draw_main(sima, ar, scene, view_layer, obedit, obact, depsgraph);
+ ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph);
/* check for mask (delay draw) */
if (ED_space_image_show_uvedit(sima, obedit)) {
@@ -742,13 +683,6 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
WM_gizmomap_draw(ar->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D);
draw_image_cache(C, ar);
-
- /* scrollers? */
-#if 0
- scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
- UI_view2d_scrollers_free(scrollers);
-#endif
}
static void image_main_region_listener(
@@ -806,6 +740,33 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
+static void image_buttons_region_layout(const bContext *C, ARegion *ar)
+{
+ const enum eContextObjectMode mode = CTX_data_mode_enum(C);
+ const char *contexts_base[3] = {NULL};
+
+ const char **contexts = contexts_base;
+
+ SpaceImage *sima = CTX_wm_space_image(C);
+ switch (sima->mode) {
+ case SI_MODE_VIEW:
+ break;
+ case SI_MODE_PAINT:
+ ARRAY_SET_ITEMS(contexts, ".paint_common_2d", ".imagepaint_2d");
+ break;
+ case SI_MODE_MASK:
+ break;
+ case SI_MODE_UV:
+ if (mode == CTX_MODE_EDIT_MESH) {
+ ARRAY_SET_ITEMS(contexts, ".uv_sculpt");
+ }
+ break;
+ }
+
+ const bool vertical = true;
+ ED_region_panels_layout_ex(C, ar, contexts_base, -1, vertical);
+}
+
static void image_buttons_region_draw(const bContext *C, ARegion *ar)
{
SpaceImage *sima = CTX_wm_space_image(C);
@@ -832,7 +793,8 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar)
}
ED_space_image_release_buffer(sima, ibuf, lock);
- ED_region_panels(C, ar);
+ /* Layout handles details. */
+ ED_region_panels_draw(C, ar);
}
static void image_buttons_region_listener(wmWindow *UNUSED(win),
@@ -1077,6 +1039,7 @@ void ED_spacetype_image(void)
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->listener = image_buttons_region_listener;
art->init = image_buttons_region_init;
+ art->layout = image_buttons_region_layout;
art->draw = image_buttons_region_draw;
BLI_addhead(&st->regiontypes, art);
@@ -1096,6 +1059,17 @@ void ED_spacetype_image(void)
art->draw = image_tools_region_draw;
BLI_addhead(&st->regiontypes, art);
+ /* regions: tool header */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype image tool header region");
+ art->regionid = RGN_TYPE_TOOL_HEADER;
+ art->prefsizey = HEADERY;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
+ art->listener = image_header_region_listener;
+ art->init = image_header_region_init;
+ art->draw = image_header_region_draw;
+ art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header;
+ BLI_addhead(&st->regiontypes, art);
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_HEADER;
diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt
index bb403751fe2..ad410e0aade 100644
--- a/source/blender/editors/space_info/CMakeLists.txt
+++ b/source/blender/editors/space_info/CMakeLists.txt
@@ -22,15 +22,15 @@ set(INC
../../blenlib
../../blenloader
../../blentranslation
- ../../depsgraph
- ../../imbuf
../../bmesh
+ ../../depsgraph
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index a7d6694b362..c588df9528f 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -116,7 +116,7 @@ static int report_textview_begin(TextViewContext *tvc)
// SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
ReportList *reports = (ReportList *)tvc->arg2;
- tvc->lheight = 14 * UI_DPI_FAC; //sc->lheight;
+ tvc->lheight = 14 * UI_DPI_FAC; // sc->lheight;
tvc->sel_start = 0;
tvc->sel_end = 0;
@@ -256,7 +256,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo,
/* view */
tvc.sel_start = 0;
tvc.sel_end = 0;
- tvc.lheight = 14 * UI_DPI_FAC; //sc->lheight;
+ tvc.lheight = 14 * UI_DPI_FAC; // sc->lheight;
tvc.ymin = v2d->cur.ymin;
tvc.ymax = v2d->cur.ymax;
tvc.winx = ar->winx - V2D_SCROLL_WIDTH;
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index 707838cf7e5..4c00512d838 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -41,16 +41,52 @@
#include "info_intern.h"
+static void reports_select_all(ReportList *reports, int report_mask, int action)
+{
+ if (action == SEL_TOGGLE) {
+ action = SEL_SELECT;
+ for (Report *report = reports->list.last; report; report = report->prev) {
+ if ((report->type & report_mask) && (report->flag & SELECT)) {
+ action = SEL_DESELECT;
+ break;
+ }
+ }
+ }
+
+ for (Report *report = reports->list.last; report; report = report->prev) {
+ if (report->type & report_mask) {
+ switch (action) {
+ case SEL_SELECT:
+ report->flag = SELECT;
+ break;
+ case SEL_DESELECT:
+ report->flag = ~SELECT;
+ break;
+ case SEL_INVERT:
+ report->flag ^= SELECT;
+ break;
+ default:
+ BLI_assert(0);
+ }
+ }
+ }
+}
+
int info_report_mask(SpaceInfo *UNUSED(sinfo))
{
#if 0
int report_mask = 0;
- if (sinfo->rpt_mask & INFO_RPT_DEBUG) report_mask |= RPT_DEBUG_ALL;
- if (sinfo->rpt_mask & INFO_RPT_INFO) report_mask |= RPT_INFO_ALL;
- if (sinfo->rpt_mask & INFO_RPT_OP) report_mask |= RPT_OPERATOR_ALL;
- if (sinfo->rpt_mask & INFO_RPT_WARN) report_mask |= RPT_WARNING_ALL;
- if (sinfo->rpt_mask & INFO_RPT_ERR) report_mask |= RPT_ERROR_ALL;
+ if (sinfo->rpt_mask & INFO_RPT_DEBUG)
+ report_mask |= RPT_DEBUG_ALL;
+ if (sinfo->rpt_mask & INFO_RPT_INFO)
+ report_mask |= RPT_INFO_ALL;
+ if (sinfo->rpt_mask & INFO_RPT_OP)
+ report_mask |= RPT_OPERATOR_ALL;
+ if (sinfo->rpt_mask & INFO_RPT_WARN)
+ report_mask |= RPT_WARNING_ALL;
+ if (sinfo->rpt_mask & INFO_RPT_ERR)
+ report_mask |= RPT_ERROR_ALL;
return report_mask;
#endif
@@ -71,10 +107,8 @@ static int report_replay_exec(bContext *C, wmOperator *UNUSED(op))
sc->type = CONSOLE_TYPE_PYTHON;
for (report = reports->list.last; report; report = report->prev) {
- if ((report->type & report_mask) &&
- (report->type & RPT_OPERATOR_ALL | RPT_PROPERTY_ALL) &&
- (report->flag & SELECT))
- {
+ if ((report->type & report_mask) && (report->type & RPT_OPERATOR_ALL | RPT_PROPERTY_ALL) &&
+ (report->flag & SELECT)) {
console_history_add_str(sc, report->message, 0);
WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL);
@@ -109,12 +143,20 @@ void INFO_OT_report_replay(wmOperatorType *ot)
static int select_report_pick_exec(bContext *C, wmOperator *op)
{
int report_index = RNA_int_get(op->ptr, "report_index");
+ bool extend = RNA_boolean_get(op->ptr, "extend");
+
Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index);
+ SpaceInfo *sinfo = CTX_wm_space_info(C);
+ ReportList *reports = CTX_wm_reports(C);
+ const int report_mask = info_report_mask(sinfo);
if (!report) {
return OPERATOR_CANCELLED;
}
+ if (!extend) {
+ reports_select_all(reports, report_mask, SEL_DESELECT);
+ }
report->flag ^= SELECT; /* toggle */
ED_area_tag_redraw(CTX_wm_area(C));
@@ -152,8 +194,11 @@ void INFO_OT_select_pick(wmOperatorType *ot)
/* ot->flag = OPTYPE_REGISTER; */
/* properties */
+ PropertyRNA *prop;
RNA_def_int(
ot->srna, "report_index", 0, 0, INT_MAX, "Report", "Index of the report", 0, INT_MAX);
+ prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend report selection");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
static int report_select_all_exec(bContext *C, wmOperator *op)
@@ -163,34 +208,7 @@ static int report_select_all_exec(bContext *C, wmOperator *op)
const int report_mask = info_report_mask(sinfo);
int action = RNA_enum_get(op->ptr, "action");
-
- if (action == SEL_TOGGLE) {
- action = SEL_SELECT;
- for (Report *report = reports->list.last; report; report = report->prev) {
- if ((report->type & report_mask) && (report->flag & SELECT)) {
- action = SEL_DESELECT;
- break;
- }
- }
- }
-
- for (Report *report = reports->list.last; report; report = report->prev) {
- if (report->type & report_mask) {
- switch (action) {
- case SEL_SELECT:
- report->flag = SELECT;
- break;
- case SEL_DESELECT:
- report->flag = ~SELECT;
- break;
- case SEL_INVERT:
- report->flag ^= SELECT;
- break;
- default:
- BLI_assert(0);
- }
- }
- }
+ reports_select_all(reports, report_mask, action);
ED_area_tag_redraw(CTX_wm_area(C));
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 6ed9d80d145..8eddf90b06b 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -85,7 +85,7 @@ static SpaceLink *info_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
- //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
+ // ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM);
return (SpaceLink *)sinfo;
}
@@ -160,9 +160,8 @@ static void info_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index c81e7574186..108803a865f 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -161,8 +161,9 @@ static int console_draw_string(ConsoleDrawContext *cdc,
CLAMP(ofs, 0, str_len);
*cdc->pos_pick += str_len - ofs;
}
- else
+ else {
*cdc->pos_pick += str_len + 1;
+ }
}
cdc->xy[1] = y_next;
diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt
index 3048c64c49e..60152bffaf4 100644
--- a/source/blender/editors/space_nla/CMakeLists.txt
+++ b/source/blender/editors/space_nla/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index b19dc3680bf..719efc7eeac 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -59,7 +59,7 @@
static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int UNUSED(event))
{
- //Scene *scene = CTX_data_scene(C);
+ // Scene *scene = CTX_data_scene(C);
#if 0
switch (event) {
/* pass */
@@ -81,11 +81,12 @@ bool nla_panel_context(const bContext *C,
short found = 0; /* not bool, since we need to indicate "found but not ideal" status */
int filter;
- /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
- * to work correctly is able to be correctly retrieved. There's no point showing empty panels?
- */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ /* For now, only draw if we could init the anim-context info
+ * (necessary for all animation-related tools)
+ * to work correctly is able to be correctly retrieved. There's no point showing empty panels? */
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return false;
+ }
/* extract list of active channel(s), of which we should only take the first one
* - we need the channels flag to get the active AnimData block when there are no NLA Tracks
@@ -168,8 +169,9 @@ bool nla_panel_context(const bContext *C,
}
}
- if (found > 0)
+ if (found > 0) {
break;
+ }
}
/* free temp data */
@@ -208,10 +210,12 @@ static bool nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt
PointerRNA ptr;
NlaStrip *strip;
- if (!nla_panel_context(C, NULL, NULL, &ptr))
+ if (!nla_panel_context(C, NULL, NULL, &ptr)) {
return 0;
- if (ptr.data == NULL)
+ }
+ if (ptr.data == NULL) {
return 0;
+ }
strip = ptr.data;
return (strip->type == NLASTRIP_TYPE_CLIP);
@@ -222,15 +226,18 @@ static bool nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt))
PointerRNA ptr;
NlaStrip *strip;
- if (!nla_panel_context(C, NULL, NULL, &ptr))
+ if (!nla_panel_context(C, NULL, NULL, &ptr)) {
return 0;
- if (ptr.data == NULL)
+ }
+ if (ptr.data == NULL) {
return 0;
+ }
strip = ptr.data;
- if (strip->type == NLASTRIP_TYPE_SOUND)
+ if (strip->type == NLASTRIP_TYPE_SOUND) {
return 0;
+ }
return 1;
}
@@ -247,8 +254,9 @@ static void nla_panel_animdata(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, &adt_ptr, NULL, NULL))
+ if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) {
return;
+ }
/* adt = adt_ptr.data; */
@@ -312,8 +320,9 @@ static void nla_panel_track(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, NULL, &nlt_ptr, NULL))
+ if (!nla_panel_context(C, NULL, &nlt_ptr, NULL)) {
return;
+ }
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
@@ -332,8 +341,9 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
uiBlock *block;
short showEvalProps = 1;
- if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
+ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
return;
+ }
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
@@ -353,8 +363,9 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
/* Evaluation-Related Strip Properties ------------------ */
/* sound properties strips don't have these settings */
- if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND)
+ if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND) {
showEvalProps = 0;
+ }
/* only show if allowed to... */
if (showEvalProps) {
@@ -398,8 +409,9 @@ static void nla_panel_actclip(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
+ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
return;
+ }
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
@@ -416,7 +428,8 @@ static void nla_panel_actclip(const bContext *C, Panel *pa)
uiItemR(column, &strip_ptr, "action_frame_start", 0, IFACE_("Start Frame"), ICON_NONE);
uiItemR(column, &strip_ptr, "action_frame_end", 0, IFACE_("End Frame"), ICON_NONE);
- // XXX: this layout may actually be too abstract and confusing, and may be better using standard column layout
+ /* XXX: this layout may actually be too abstract and confusing,
+ * and may be better using standard column layout. */
row = uiLayoutRow(layout, false);
uiItemR(row, &strip_ptr, "use_sync_length", 0, IFACE_("Sync Length"), ICON_NONE);
uiItemO(row, IFACE_("Now"), ICON_FILE_REFRESH, "NLA_OT_action_sync_length");
@@ -438,8 +451,9 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
+ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
return;
+ }
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
@@ -471,8 +485,9 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
+ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
return;
+ }
strip = strip_ptr.data;
block = uiLayoutGetBlock(pa->layout);
@@ -483,7 +498,8 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa)
row = uiLayoutRow(pa->layout, false);
block = uiLayoutGetBlock(row);
- // FIXME: we need to set the only-active property so that this will only add modifiers for the active strip (not all selected)
+ // FIXME: we need to set the only-active property so that this
+ // will only add modifiers for the active strip (not all selected).
uiItemMenuEnumO(
row, (bContext *)C, "NLA_OT_fmodifier_add", "type", IFACE_("Add Modifier"), ICON_NONE);
@@ -562,27 +578,3 @@ void nla_buttons_register(ARegionType *art)
pt->poll = nla_strip_eval_panel_poll;
BLI_addtail(&art->paneltypes, pt);
}
-
-static int nla_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = nla_has_buttons_region(sa);
-
- if (ar)
- ED_region_toggle_hidden(C, ar);
-
- return OPERATOR_FINISHED;
-}
-
-void NLA_OT_properties(wmOperatorType *ot)
-{
- ot->name = "Toggle Sidebar";
- ot->idname = "NLA_OT_properties";
- ot->description = "Toggle the properties region visibility";
-
- ot->exec = nla_properties_toggle_exec;
- ot->poll = ED_operator_nla_active;
-
- /* flags */
- ot->flag = 0;
-}
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 90e70b835f8..4115d6b49ba 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -67,8 +67,9 @@
/* Depending on the channel that was clicked on, the mouse click will activate whichever
* part of the channel is relevant.
*
- * NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons
- * --> Most channels are now selection only...
+ * NOTE: eventually,
+ * this should probably be phased out when many of these things are replaced with buttons
+ * --> Most channels are now selection only.
*/
static int mouse_nla_channels(
@@ -90,9 +91,10 @@ static int mouse_nla_channels(
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return 0;
@@ -109,13 +111,15 @@ static int mouse_nla_channels(
if (selectmode == SELECT_INVERT) {
/* swap select */
sce->flag ^= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
sce->flag |= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -132,33 +136,34 @@ static int mouse_nla_channels(
if (selectmode == SELECT_INVERT) {
/* swap select */
ED_object_base_select(base, BA_INVERT);
- BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
/* deselect all */
/* TODO: should this deselect all other types of channels too? */
for (Base *b = view_layer->object_bases.first; b; b = b->next) {
ED_object_base_select(b, BA_DESELECT);
- BKE_scene_object_base_flag_sync_from_base(b);
- if (b->object->adt)
+ if (b->object->adt) {
b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
+ }
}
/* select object now */
ED_object_base_select(base, BA_SELECT);
- BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
/* change active object - regardless of whether it is now selected [T37883] */
ED_object_base_activate(C, base); /* adds notifier */
- if ((adt) && (adt->flag & ADT_UI_SELECTED))
+ if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
adt->flag |= ADT_UI_ACTIVE;
+ }
/* notifiers - channel was selected */
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -198,8 +203,9 @@ static int mouse_nla_channels(
}
/* set active? */
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
+ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
ale->adt->flag |= ADT_UI_ACTIVE;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -213,13 +219,16 @@ static int mouse_nla_channels(
/* offset for start of channel (on LHS of channel-list) */
if (ale->id) {
/* special exception for materials and particles */
- if (ELEM(GS(ale->id->name), ID_MA, ID_PA))
+ if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) {
offset = 21 + NLACHANNEL_BUTTON_WIDTH;
- else
+ }
+ else {
offset = 14;
+ }
}
- else
+ else {
offset = 0;
+ }
if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) {
/* toggle protection (only if there's a toggle there) */
@@ -258,8 +267,9 @@ static int mouse_nla_channels(
/* if NLA-Track is selected now,
* make NLA-Track the 'active' one in the visible list */
- if (nlt->flag & NLATRACK_SELECTED)
+ if (nlt->flag & NLATRACK_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK);
+ }
/* notifier flags - channel was selected */
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -318,8 +328,9 @@ static int mouse_nla_channels(
}
/* set active? */
- if (adt->flag & ADT_UI_SELECTED)
+ if (adt->flag & ADT_UI_SELECTED) {
adt->flag |= ADT_UI_ACTIVE;
+ }
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
}
@@ -327,8 +338,9 @@ static int mouse_nla_channels(
break;
}
default:
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Invalid channel type in mouse_nla_channels()\n");
+ }
break;
}
@@ -355,8 +367,9 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv
float x, y;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get useful pointers from animation context data */
snla = (SpaceNla *)ac.sl;
@@ -364,15 +377,19 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv
v2d = &ar->v2d;
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
- /* figure out which channel user clicked in
- * Note: although channels technically start at y= NLACHANNEL_FIRST, we need to adjust by half a channel's height
- * so that the tops of channels get caught ok. Since NLACHANNEL_FIRST is really NLACHANNEL_HEIGHT, we simply use
- * NLACHANNEL_HEIGHT_HALF.
+ /**
+ * Figure out which channel user clicked in:
+ *
+ * \note Although channels technically start at y= NLACHANNEL_FIRST,
+ * we need to adjust by half a channel's height so that the tops of channels get caught ok.
+ * Since NLACHANNEL_FIRST is really NLACHANNEL_HEIGHT, we simply use NLACHANNEL_HEIGHT_HALF.
*/
UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y);
UI_view2d_listview_view_to_cell(v2d,
@@ -428,8 +445,9 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
int channel_index = RNA_int_get(op->ptr, "channel_index");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get anim-channel to use (or more specifically, the animdata block behind it) */
if (channel_index == -1) {
@@ -555,13 +573,15 @@ static int nla_action_unlink_exec(bContext *C, wmOperator *op)
AnimData *adt;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, &adt_ptr, NULL, NULL))
+ if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) {
return OPERATOR_CANCELLED;
+ }
/* get animdata */
adt = adt_ptr.data;
- if (adt == NULL)
+ if (adt == NULL) {
return OPERATOR_CANCELLED;
+ }
/* do unlinking */
if (adt && adt->action) {
@@ -698,8 +718,9 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op)
bool op_done = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform adding in two passes - existing first so that we don't double up for empty */
op_done |= nlaedit_add_tracks_existing(&ac, above_sel);
@@ -759,8 +780,9 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
@@ -776,8 +798,9 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
/* if track is currently 'solo', then AnimData should have its
* 'has solo' flag disabled
*/
- if (nlt->flag & NLATRACK_SOLO)
+ if (nlt->flag & NLATRACK_SOLO) {
adt->flag &= ~ADT_NLA_SOLO_TRACK;
+ }
/* call delete on this track - deletes all strips too */
BKE_nlatrack_free(&adt->nla_tracks, nlt, true);
@@ -830,8 +853,9 @@ static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNla *snla;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* ensure that filters are set so that the effect will be immediately visible */
snla = (SpaceNla *)ac.sl;
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 65115819874..1df2190b7af 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -86,8 +86,9 @@ void nla_action_get_color(AnimData *adt, bAction *act, float color[4])
/* when an NLA track is tagged "solo", action doesn't contribute,
* so shouldn't be as prominent */
- if (adt && (adt->flag & ADT_NLA_SOLO_TRACK))
+ if (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) {
color[3] *= 0.15f;
+ }
}
/* draw the keyframes in the specified Action */
@@ -99,8 +100,9 @@ static void nla_action_draw_keyframes(
BLI_dlrbTree_init(&keys);
action_to_keylist(adt, act, &keys, 0);
- if (ELEM(NULL, act, keys.first))
+ if (ELEM(NULL, act, keys.first)) {
return;
+ }
/* draw a darkened region behind the strips
* - get and reset the background color, this time without the alpha to stand out better
@@ -181,8 +183,9 @@ static void nla_actionclip_draw_markers(
{
const bAction *act = strip->act;
- if (ELEM(NULL, act, act->markers.first))
+ if (ELEM(NULL, act, act->markers.first)) {
return;
+ }
const uint shdr_pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -351,16 +354,18 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns
immVertex2f(pos, strip->start, yminc);
immVertex2f(pos, strip->start + strip->blendin, ymaxc);
}
- else
+ else {
immVertex2f(pos, strip->start, ymaxc);
+ }
/* end of strip */
if (IS_EQF(strip->blendout, 0.0f) == 0) {
immVertex2f(pos, strip->end - strip->blendout, ymaxc);
immVertex2f(pos, strip->end, yminc);
}
- else
+ else {
immVertex2f(pos, strip->end, ymaxc);
+ }
immEnd();
}
@@ -489,15 +494,17 @@ static void nla_draw_strip(SpaceNla *snla,
/* draw strip's control 'curves'
* - only if user hasn't hidden them...
*/
- if ((snla->flag & SNLA_NOSTRIPCURVES) == 0)
+ if ((snla->flag & SNLA_NOSTRIPCURVES) == 0) {
nla_draw_strip_curves(strip, yminc, ymaxc, shdr_pos);
+ }
immUnbindProgram();
/* draw markings indicating locations of local markers
* (useful for lining up different actions) */
- if ((snla->flag & SNLA_NOLOCALMARKERS) == 0)
+ if ((snla->flag & SNLA_NOLOCALMARKERS) == 0) {
nla_strip_draw_markers(strip, yminc, ymaxc);
+ }
/* draw strip outline
* - color used here is to indicate active vs non-active
@@ -615,10 +622,12 @@ static void nla_draw_strip_text(AnimData *adt,
}
/* text opacity depends on whether if there's a solo'd track, this isn't it */
- if (non_solo == 0)
+ if (non_solo == 0) {
col[3] = 255;
- else
+ }
+ else {
col[3] = 128;
+ }
/* set bounding-box for text
* - padding of 2 'units' on either side
@@ -722,8 +731,9 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* if transforming strips (only real reason for temp-metas currently),
* add to the cache the frame numbers of the strip's extents
*/
- if (strip->flag & NLASTRIP_FLAG_TEMP_META)
+ if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
nla_draw_strip_frames_text(nlt, strip, v2d, yminc, ymaxc);
+ }
}
}
break;
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 79c2242cd01..0446235a776 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -113,8 +113,9 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA);
@@ -257,17 +258,20 @@ static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform operation */
ok = nlaedit_disable_tweakmode(&ac, do_solo);
/* success? */
- if (ok)
+ if (ok) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void NLA_OT_tweakmode_exit(wmOperatorType *ot)
@@ -362,13 +366,16 @@ static int nlaedit_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
float min, max;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
- if (ac.scene == NULL)
+ if (ac.scene == NULL) {
return OPERATOR_CANCELLED;
- else
+ }
+ else {
scene = ac.scene;
+ }
/* set the range directly */
get_nlastrip_extents(&ac, &min, &max, true);
@@ -464,8 +471,9 @@ static int nlaedit_viewall(bContext *C, const bool only_sel)
float extra;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
v2d = &ac.ar->v2d;
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
@@ -597,8 +605,9 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
float cfra;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
scene = ac.scene;
cfra = (float)CFRA;
@@ -608,7 +617,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "No valid action to add");
- //printf("Add strip - actname = '%s'\n", actname);
+ // printf("Add strip - actname = '%s'\n", actname);
return OPERATOR_CANCELLED;
}
else if (act->idroot == 0) {
@@ -648,8 +657,9 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
AnimData *adt = ale->adt;
NlaStrip *strip = NULL;
- /* sanity check: only apply actions of the right type for this ID
- * NOTE: in the case that this hasn't been set, we've already warned the user about this already
+ /* Sanity check: only apply actions of the right type for this ID.
+ * NOTE: in the case that this hasn't been set,
+ * we've already warned the user about this already
*/
if ((act->idroot) && (act->idroot != GS(ale->id->name))) {
BKE_reportf(
@@ -735,8 +745,9 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
bool done = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -749,8 +760,9 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
NlaStrip *s1, *s2;
/* get initial pair of strips */
- if (ELEM(nlt->strips.first, NULL, nlt->strips.last))
+ if (ELEM(nlt->strips.first, NULL, nlt->strips.last)) {
continue;
+ }
s1 = nlt->strips.first;
s2 = s1->next;
@@ -759,20 +771,24 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
NlaStrip *strip;
/* check if both are selected */
- if (ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT)))
+ if (ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT))) {
continue;
+ }
/* check if there's space between the two */
- if (IS_EQF(s1->end, s2->start))
+ if (IS_EQF(s1->end, s2->start)) {
continue;
+ }
/* make sure neither one is a transition
* - although this is impossible to create with the standard tools,
* the user may have altered the settings
*/
- if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type))
+ if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) {
continue;
+ }
/* also make sure neither one is a soundclip */
- if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type))
+ if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type)) {
continue;
+ }
/* allocate new strip */
strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
@@ -856,8 +872,9 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op))
int cfra;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
scene = ac.scene;
cfra = CFRA;
@@ -877,8 +894,9 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op))
NlaStrip *strip;
/* does this belong to speaker - assumed to live on Object level only */
- if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER))
+ if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER)) {
continue;
+ }
/* create a new strip, and offset it to start on the current frame */
strip = BKE_nla_add_soundstrip(ac.scene, ob->data);
@@ -940,8 +958,9 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -959,8 +978,9 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
/* name the metas */
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* auto-name this strip if selected (that means it is a meta) */
- if (strip->flag & NLASTRIP_FLAG_SELECT)
+ if (strip->flag & NLASTRIP_FLAG_SELECT) {
BKE_nlastrip_validate_name(adt, strip);
+ }
}
ale->update |= ANIM_UPDATE_DEPS;
@@ -1004,8 +1024,9 @@ static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1064,8 +1085,9 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
bool done = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1127,8 +1149,9 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
/* done */
return OPERATOR_FINISHED;
}
- else
+ else {
return OPERATOR_CANCELLED;
+ }
}
static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
@@ -1180,8 +1203,9 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1198,8 +1222,9 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* if selected, delete */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* if a strip either side of this was a transition, delete those too */
- if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
+ if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) {
BKE_nlastrip_free(&nlt->strips, strip->prev, true);
+ }
if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) {
nstrip = nstrip->next;
BKE_nlastrip_free(&nlt->strips, strip->next, true);
@@ -1268,17 +1293,21 @@ static void nlaedit_split_strip_actclip(
/* strip extents */
len = strip->end - strip->start;
- if (IS_EQF(len, 0.0f))
+ if (IS_EQF(len, 0.0f)) {
return;
- else
+ }
+ else {
splitframe = strip->start + (len / 2.0f);
+ }
/* action range */
len = strip->actend - strip->actstart;
- if (IS_EQF(len, 0.0f))
+ if (IS_EQF(len, 0.0f)) {
splitaframe = strip->actend;
- else
+ }
+ else {
splitaframe = strip->actstart + (len / 2.0f);
+ }
}
/* make a copy (assume that this is possible) and append
@@ -1324,8 +1353,9 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1402,8 +1432,9 @@ static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1465,8 +1496,9 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1482,7 +1514,8 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
/* make temporary metastrips so that entire islands of selections can be moved around */
BKE_nlastrips_make_metas(&nlt->strips, 1);
- /* special case: if there is only 1 island (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this,
+ /* special case: if there is only 1 island
+ * (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this,
* and this island has two strips inside it, then we should be able to just swap these still...
*/
if (BLI_listbase_is_empty(&nlt->strips) == false) {
@@ -1633,8 +1666,9 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1649,8 +1683,9 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
NlaStrip *strip, *stripn;
/* if this track has no tracks after it, skip for now... */
- if (nltn == NULL)
+ if (nltn == NULL) {
continue;
+ }
/* for every selected strip, try to move */
for (strip = nlt->strips.first; strip; strip = stripn) {
@@ -1708,8 +1743,9 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1724,8 +1760,9 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
NlaStrip *strip, *stripn;
/* if this track has no tracks before it, skip for now... */
- if (nltp == NULL)
+ if (nltp == NULL) {
continue;
+ }
/* for every selected strip, try to move */
for (strip = nlt->strips.first; strip; strip = stripn) {
@@ -1784,13 +1821,15 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
const bool active_only = RNA_boolean_get(op->ptr, "active");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
- if (active_only)
+ if (active_only) {
filter |= ANIMFILTER_ACTIVE;
+ }
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* for each NLA-Track, apply scale of all selected strips */
@@ -1801,18 +1840,21 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* strip selection/active status check */
if (active_only) {
- if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
continue;
+ }
}
else {
- if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) {
continue;
+ }
}
/* must be action-clip only (transitions don't have scale) */
if (strip->type == NLASTRIP_TYPE_CLIP) {
- if (strip->act == NULL)
+ if (strip->act == NULL) {
continue;
+ }
/* recalculate the length of the action */
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
@@ -1873,8 +1915,9 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
bool copied = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1891,8 +1934,9 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
for (strip = nlt->strips.last; strip; strip = strip->prev) {
/* must be action-clip only (as only these have actions) */
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
- if (strip->act == NULL)
+ if (strip->act == NULL) {
continue;
+ }
/* multi-user? */
if (ID_REAL_USERS(strip->act) > 1) {
@@ -1974,8 +2018,9 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditData ked = {{NULL}};
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1992,8 +2037,9 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
/* if the referenced action is used by other strips,
* make this strip use its own copy */
- if (strip->act == NULL)
+ if (strip->act == NULL) {
continue;
+ }
if (strip->act->id.us > 1) {
/* make a copy of the Action to work on */
bAction *act = BKE_action_copy(bmain, strip->act);
@@ -2066,8 +2112,9 @@ static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -2125,11 +2172,8 @@ void NLA_OT_clear_scale(wmOperatorType *ot)
static const EnumPropertyItem prop_nlaedit_snap_types[] = {
{NLAEDIT_SNAP_CFRA, "CFRA", 0, "Current Frame", ""},
{NLAEDIT_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry?
- {NLAEDIT_SNAP_NEAREST_SECOND,
- "NEAREST_SECOND",
- 0,
- "Nearest Second",
- ""}, // XXX as single entry?
+ // XXX as single entry?
+ {NLAEDIT_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""},
{NLAEDIT_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -2147,8 +2191,9 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
float secf;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -2296,10 +2341,12 @@ static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C,
int index;
/* check if modifier is valid for this context */
- if (fmi == NULL)
+ if (fmi == NULL) {
continue;
- if (i == FMODIFIER_TYPE_CYCLES) /* we already have repeat... */
+ }
+ if (i == FMODIFIER_TYPE_CYCLES) { /* we already have repeat... */
continue;
+ }
index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type);
if (index != -1) { /* Not all types are implemented yet... */
@@ -2326,8 +2373,9 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
const bool active_only = RNA_boolean_get(op->ptr, "only_active");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -2342,18 +2390,21 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
/* can F-Modifier be added to the current strip? */
if (active_only) {
/* if not active, cannot add since we're only adding to active strip */
- if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
continue;
+ }
}
else {
/* strip must be selected, since we're not just doing active */
- if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) {
continue;
+ }
}
/* sound clips are not affected by FModifiers */
- if (strip->type == NLASTRIP_TYPE_SOUND)
+ if (strip->type == NLASTRIP_TYPE_SOUND) {
continue;
+ }
/* add F-Modifier of specified type to selected, and make it the active one */
fcm = add_fmodifier(&strip->modifiers, type, NULL);
@@ -2420,8 +2471,9 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* clear buffer first */
ANIM_fmodifiers_copybuf_free();
@@ -2437,8 +2489,9 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* only add F-Modifier if on active strip? */
- if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
continue;
+ }
// TODO: when 'active' vs 'all' boolean is added, change last param!
ok |= ANIM_fmodifiers_copy_to_buf(&strip->modifiers, 0);
@@ -2474,7 +2527,13 @@ void NLA_OT_fmodifier_copy(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* id-props */
- //ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one");
+#if 0
+ ot->prop = RNA_def_boolean(ot->srna,
+ "all",
+ 1,
+ "All F-Modifiers",
+ "Copy all the F-Modifiers, instead of just the active one");
+#endif
}
/* ******************** Paste F-Modifiers Operator *********************** */
@@ -2490,8 +2549,9 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
const bool replace = RNA_boolean_get(op->ptr, "replace");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
@@ -2507,13 +2567,15 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
/* can F-Modifier be added to the current strip? */
if (active_only) {
/* if not active, cannot add since we're only adding to active strip */
- if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
continue;
+ }
}
else {
/* strip must be selected, since we're not just doing active */
- if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) {
continue;
+ }
}
/* paste FModifiers from buffer */
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index 291dfe17343..2b20ab69fa7 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -32,15 +32,12 @@
/* **************************************** */
/* space_nla.c / nla_buttons.c */
-ARegion *nla_has_buttons_region(ScrArea *sa);
-
bool nla_panel_context(const bContext *C,
PointerRNA *adt_ptr,
PointerRNA *nlt_ptr,
PointerRNA *strip_ptr);
void nla_buttons_register(ARegionType *art);
-void NLA_OT_properties(wmOperatorType *ot);
/* **************************************** */
/* nla_draw.c */
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index 51d6232cf71..55470388e22 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -56,12 +56,14 @@ bool nlaop_poll_tweakmode_off(bContext *C)
* but not all AnimData blocks will be in tweakmode for
* various reasons
*/
- if (ED_operator_nla_active(C) == 0)
+ if (ED_operator_nla_active(C) == 0) {
return 0;
+ }
scene = CTX_data_scene(C);
- if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
+ if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
+ }
return 1;
}
@@ -78,12 +80,14 @@ bool nlaop_poll_tweakmode_on(bContext *C)
* but not all AnimData blocks will be in tweakmode for
* various reasons
*/
- if (ED_operator_nla_active(C) == 0)
+ if (ED_operator_nla_active(C) == 0) {
return 0;
+ }
scene = CTX_data_scene(C);
- if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON))
+ if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
+ }
return 1;
}
@@ -91,8 +95,9 @@ bool nlaop_poll_tweakmode_on(bContext *C)
/* is tweakmode enabled - for use in NLA operator code */
bool nlaedit_is_tweakmode_on(bAnimContext *ac)
{
- if (ac && ac->scene)
+ if (ac && ac->scene) {
return (ac->scene->flag & SCE_NLA_EDIT_ON) != 0;
+ }
return 0;
}
@@ -100,9 +105,6 @@ bool nlaedit_is_tweakmode_on(bAnimContext *ac)
void nla_operatortypes(void)
{
- /* view */
- WM_operatortype_append(NLA_OT_properties);
-
/* channels */
WM_operatortype_append(NLA_OT_channels_click);
@@ -170,9 +172,10 @@ void nla_keymap(wmKeyConfig *keyconf)
WM_keymap_ensure(keyconf, "NLA Generic", SPACE_NLA, 0);
/* channels ---------------------------------------------------------- */
- /* Channels are not directly handled by the NLA Editor module, but are inherited from the Animation module.
- * Most of the relevant operations, keymaps, drawing, etc. can therefore all
- * be found in that module instead, as there are many similarities with the other Animation Editors.
+ /* Channels are not directly handled by the NLA Editor module, but are inherited from the
+ * animation module. Most of the relevant operations, keymaps, drawing, etc. can therefore all
+ * be found in that module instead, as there are many similarities with the other
+ * animation editors.
*
* However, those operations which involve clicking on channels and/or
* the placement of them in the view are implemented here instead
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 0df0c5a99da..5c9e48f3d5d 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -119,8 +119,9 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
}
}
- if (sel == SELECT_SUBTRACT)
+ if (sel == SELECT_SUBTRACT) {
break;
+ }
}
}
@@ -135,11 +136,13 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
/* apply same selection to all strips */
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* set selection */
- if (test != DESELECT_STRIPS_CLEARACTIVE)
+ if (test != DESELECT_STRIPS_CLEARACTIVE) {
ACHANNEL_SET_FLAG(strip, smode, NLASTRIP_FLAG_SELECT);
+ }
/* clear active flag */
- // TODO: for clear active, do we want to limit this to only doing this on a certain set of tracks though?
+ /* TODO: for clear active,
+ * do we want to limit this to only doing this on a certain set of tracks though? */
strip->flag &= ~NLASTRIP_FLAG_ACTIVE;
}
}
@@ -155,8 +158,9 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* 'standard' behavior - check if selected, then apply relevant selection */
const int action = RNA_enum_get(op->ptr, "action");
@@ -203,11 +207,13 @@ void NLA_OT_select_all(wmOperatorType *ot)
}
/* ******************** Box Select Operator **************************** */
-/* This operator currently works in one of three ways:
- * -> BKEY - 1) all strips within region are selected (NLAEDIT_BORDERSEL_ALLSTRIPS)
- * -> ALT-BKEY - depending on which axis of the region was larger...
- * -> 2) x-axis, so select all frames within frame range (NLAEDIT_BORDERSEL_FRAMERANGE)
- * -> 3) y-axis, so select all frames within channels that region included (NLAEDIT_BORDERSEL_CHANNELS)
+/**
+ * This operator currently works in one of three ways:
+ * - BKEY - 1: all strips within region are selected #NLAEDIT_BOX_ALLSTRIPS.
+ * - ALT-BKEY - depending on which axis of the region was larger.
+ * - 2: x-axis, so select all frames within frame range #NLAEDIT_BOXSEL_FRAMERANGE.
+ * - 3: y-axis, so select all frames within channels that region included
+ * #NLAEDIT_BOXSEL_CHANNELS.
*/
/* defines for box_select mode */
@@ -281,8 +287,9 @@ static int nlaedit_box_select_exec(bContext *C, wmOperator *op)
short mode = 0;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
@@ -295,18 +302,23 @@ static int nlaedit_box_select_exec(bContext *C, wmOperator *op)
/* selection 'mode' depends on whether box_select region only matters on one axis */
if (RNA_boolean_get(op->ptr, "axis_range")) {
- /* mode depends on which axis of the range is larger to determine which axis to use
- * - checking this in region-space is fine, as it's fundamentally still going to be a different rect size
- * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
- * used for tweaking timing when "blocking", while channels is not that useful...
+ /* mode depends on which axis of the range is larger to determine which axis to use.
+ * - Checking this in region-space is fine,
+ * as it's fundamentally still going to be a different rect size.
+ * - The frame-range select option is favored over the channel one (x over y),
+ * as frame-range one is often.
+ * Used for tweaking timing when "blocking", while channels is not that useful.
*/
- if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect))
+ if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect)) {
mode = NLA_BOXSEL_FRAMERANGE;
- else
+ }
+ else {
mode = NLA_BOXSEL_CHANNELS;
+ }
}
- else
+ else {
mode = NLA_BOXSEL_ALLSTRIPS;
+ }
/* apply box_select action */
box_select_nla_strips(&ac, rect, mode, selectmode);
@@ -368,8 +380,9 @@ static void nlaedit_select_leftright(bContext *C,
float xmin, xmax;
/* if currently in tweakmode, exit tweakmode first */
- if (scene->flag & SCE_NLA_EDIT_ON)
+ if (scene->flag & SCE_NLA_EDIT_ON) {
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL);
+ }
/* if select mode is replace, deselect all keyframes (and channels) first */
if (select_mode == SELECT_REPLACE) {
@@ -423,18 +436,22 @@ static int nlaedit_select_leftright_exec(bContext *C, wmOperator *op)
short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* if "test" mode is set, we don't have any info to set this with */
- if (leftright == NLAEDIT_LRSEL_TEST)
+ if (leftright == NLAEDIT_LRSEL_TEST) {
return OPERATOR_CANCELLED;
+ }
/* do the selecting now */
nlaedit_select_leftright(C, &ac, leftright, selectmode);
@@ -452,8 +469,9 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm
short leftright = RNA_enum_get(op->ptr, "mode");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* handle mode-based testing */
if (leftright == NLAEDIT_LRSEL_TEST) {
@@ -464,10 +482,12 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm
/* determine which side of the current frame mouse is on */
x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
- if (x < CFRA)
+ if (x < CFRA) {
RNA_enum_set(op->ptr, "mode", NLAEDIT_LRSEL_LEFT);
- else
+ }
+ else {
RNA_enum_set(op->ptr, "mode", NLAEDIT_LRSEL_RIGHT);
+ }
}
/* perform selection */
@@ -503,7 +523,8 @@ void NLA_OT_select_leftright(wmOperatorType *ot)
/* ******************** Mouse-Click Select Operator *********************** */
/* select strip directly under mouse */
-static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], short select_mode)
+static void mouse_nla_strips(
+ bContext *C, bAnimContext *ac, const int mval[2], short select_mode, const bool deselect_all)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale = NULL;
@@ -542,14 +563,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* try to get channel */
ale = BLI_findlink(&anim_data, channel_index);
- if (ale == NULL) {
- /* channel not found */
- printf("Error: animation channel (index = %d) not found in mouse_nla_strips()\n",
- channel_index);
- ANIM_animdata_freelist(&anim_data);
- return;
- }
- else {
+ if (ale != NULL) {
/* found some channel - we only really should do something when its an Nla-Track */
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
@@ -557,27 +571,31 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* loop over NLA-strips in this track,
* trying to find one which occurs in the necessary bounds */
for (strip = nlt->strips.first; strip; strip = strip->next) {
- if (BKE_nlastrip_within_bounds(strip, xmin, xmax))
+ if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) {
break;
+ }
}
}
/* remove active channel from list of channels for separate treatment
* (since it's needed later on) */
BLI_remlink(&anim_data, ale);
-
- /* free list of channels, since it's not used anymore */
- ANIM_animdata_freelist(&anim_data);
}
+ /* free list of channels, since it's not used anymore */
+ ANIM_animdata_freelist(&anim_data);
+
/* if currently in tweakmode, exit tweakmode before changing selection states
* now that we've found our target...
*/
- if (scene->flag & SCE_NLA_EDIT_ON)
+ if (scene->flag & SCE_NLA_EDIT_ON) {
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL);
+ }
- /* for replacing selection, firstly need to clear existing selection */
- if (select_mode == SELECT_REPLACE) {
+ /* For replacing selection, if we have something to select, we have to clear existing selection.
+ * The same goes if we found nothing to select, and deselect_all is true
+ * (deselect on nothing behavior). */
+ if ((strip != NULL && select_mode == SELECT_REPLACE) || (strip == NULL && deselect_all)) {
/* reset selection mode for next steps */
select_mode = SELECT_ADD;
@@ -589,9 +607,9 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
}
/* only select strip if we clicked on a valid channel and hit something */
- if (ale) {
+ if (ale != NULL) {
/* select the strip accordingly (if a matching one was found) */
- if (strip) {
+ if (strip != NULL) {
select_mode = selmodes_to_flagmodes(select_mode);
ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT);
@@ -625,28 +643,18 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
bAnimContext ac;
- /* Scene *scene; */ /* UNUSED */
- /* ARegion *ar; */ /* UNUSED */
- // View2D *v2d; /*UNUSED*/
- short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
-
- /* get useful pointers from animation context data */
- /* scene= ac.scene; */ /* UNUSED */
- /* ar= ac.ar; */ /* UNUSED */
- // v2d= &ar->v2d;
+ }
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
- selectmode = SELECT_INVERT;
- else
- selectmode = SELECT_REPLACE;
+ const short selectmode = RNA_boolean_get(op->ptr, "extend") ? SELECT_INVERT : SELECT_REPLACE;
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
/* select strips based upon mouse position */
- mouse_nla_strips(C, &ac, event->mval, selectmode);
+ mouse_nla_strips(C, &ac, event->mval, selectmode, deselect_all);
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL);
@@ -674,6 +682,13 @@ void NLA_OT_click_select(wmOperatorType *ot)
/* properties */
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/* *********************************************** */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index ccf2e552644..b054f550c6c 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -53,34 +53,6 @@
#include "nla_intern.h" /* own include */
#include "GPU_framebuffer.h"
-/* ******************** manage regions ********************* */
-
-ARegion *nla_has_buttons_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar)
- return ar;
-
- /* add subdiv level; after main */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
-
- /* is error! */
- if (ar == NULL)
- return NULL;
-
- arnew = MEM_callocN(sizeof(ARegion), "buttons for nla");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
/* ******************** default callbacks for nla space ***************** */
static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene)
@@ -202,13 +174,13 @@ static void nla_channel_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
/* own channels map first to override some channel keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Channels", SPACE_NLA, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* now generic channels map for everything else that can apply */
keymap = WM_keymap_ensure(wm->defaultconf, "Animation Channels", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
/* draw entirely, view changes should be handled here */
@@ -233,9 +205,8 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -248,7 +219,7 @@ static void nla_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Editor", SPACE_NLA, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
@@ -260,9 +231,8 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
Scene *scene = CTX_data_scene(C);
bAnimContext ac;
View2D *v2d = &ar->v2d;
- View2DGrid *grid;
View2DScrollers *scrollers;
- short unit = 0, cfra_flag = 0;
+ short cfra_flag = 0;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -271,17 +241,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* time grid */
- unit = (snla->flag & SNLA_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
- grid = UI_view2d_grid_calc(CTX_data_scene(C),
- v2d,
- unit,
- V2D_GRID_CLAMP,
- V2D_ARG_DUMMY,
- V2D_ARG_DUMMY,
- ar->winx,
- ar->winy);
- UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
- UI_view2d_grid_free(grid);
+ UI_view2d_draw_lines_x__discrete_frames_or_seconds(v2d, scene, snla->flag & SNLA_DRAWTIME);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
@@ -300,15 +260,17 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* current frame */
- if (snla->flag & SNLA_DRAWTIME)
+ if (snla->flag & SNLA_DRAWTIME) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
int marker_draw_flag = DRAW_MARKERS_MARGIN;
- if (snla->flag & SNLA_SHOW_MARKER_LINES)
+ if (snla->flag & SNLA_SHOW_MARKER_LINES) {
marker_draw_flag |= DRAW_MARKERS_LINES;
+ }
ED_markers_draw(C, marker_draw_flag);
/* preview range */
@@ -323,11 +285,14 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* frame numbers */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, snla->flag & SNLA_DRAWTIME);
+
/* draw current frame number-indicator on top of scrollers */
if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
@@ -354,7 +319,7 @@ static void nla_buttons_region_init(wmWindowManager *wm, ARegion *ar)
ED_region_panels_init(wm, ar);
keymap = WM_keymap_ensure(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void nla_buttons_region_draw(const bContext *C, ARegion *ar)
@@ -392,8 +357,9 @@ static void nla_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -438,8 +404,9 @@ static void nla_main_region_listener(wmWindow *UNUSED(win),
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCREEN:
if (ELEM(wmn->data, ND_LAYER)) {
@@ -447,8 +414,9 @@ static void nla_main_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -523,12 +491,14 @@ static void nla_channel_region_listener(wmWindow *UNUSED(win),
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -598,8 +568,9 @@ static void nla_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Sc
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_NLA)
+ if (wmn->data == ND_SPACE_NLA) {
ED_area_tag_redraw(sa);
+ }
break;
}
}
diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt
index df1b7c03aab..03c83305618 100644
--- a/source/blender/editors/space_node/CMakeLists.txt
+++ b/source/blender/editors/space_node/CMakeLists.txt
@@ -22,16 +22,16 @@ set(INC
../../blenlib
../../blentranslation
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../nodes
../../render/extern/include
- ../../windowmanager
../../compositor
- ../../../../intern/guardedalloc
+ ../../windowmanager
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 7072f34ee4d..447fea8098c 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -55,6 +55,7 @@
#include "RNA_define.h"
#include "ED_node.h"
+#include "ED_space_api.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -204,7 +205,8 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
bNode *node = node_v;
Tex *tex;
- if (node->menunr < 1) return;
+ if (node->menunr < 1)
+ return;
if (node->id) {
id_us_min(node->id);
@@ -3413,6 +3415,14 @@ void draw_nodespace_back_pix(const bContext *C,
void *lock;
ImBuf *ibuf;
+ GPU_matrix_push_projection();
+ GPU_matrix_push();
+ wmOrtho2_region_pixelspace(ar);
+ GPU_matrix_identity_set();
+ ED_region_draw_cb_draw(C, ar, REGION_DRAW_BACKDROP);
+ GPU_matrix_pop_projection();
+ GPU_matrix_pop();
+
if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode)) {
return;
}
@@ -3480,12 +3490,12 @@ void draw_nodespace_back_pix(const bContext *C,
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
+ ED_draw_imbuf_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
GPU_blend(false);
}
else {
- glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
+ ED_draw_imbuf_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
}
if (cache_handle) {
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index 8d754087855..714ed707e18 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -54,8 +54,10 @@
#include "node_intern.h" /* own include */
-/* XXX Does some additional initialization on top of nodeAddNode
- * Can be used with both custom and static nodes, if idname==NULL the static int type will be used instead.
+/**
+ * XXX Does some additional initialization on top of #nodeAddNode
+ * Can be used with both custom and static nodes,
+ * if `idname == NULL` the static int type will be used instead.
*/
bNode *node_add_node(const bContext *C, const char *idname, int type, float locx, float locy)
{
diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
index 63e97ecd955..072a67dee6c 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -226,35 +226,3 @@ void node_buttons_register(ARegionType *art)
pt->poll = node_tree_interface_poll;
BLI_addtail(&art->paneltypes, pt);
}
-
-static int node_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = node_has_buttons_region(sa);
-
- if (ar) {
- ED_region_toggle_hidden(C, ar);
- }
-
- return OPERATOR_FINISHED;
-}
-
-/* non-standard poll operator which doesn't care if there are any nodes */
-static bool node_properties_poll(bContext *C)
-{
- ScrArea *sa = CTX_wm_area(C);
- return (sa && (sa->spacetype == SPACE_NODE));
-}
-
-void NODE_OT_properties(wmOperatorType *ot)
-{
- ot->name = "Toggle Sidebar";
- ot->description = "Toggle the properties region visibility";
- ot->idname = "NODE_OT_properties";
-
- ot->exec = node_properties_toggle_exec;
- ot->poll = node_properties_poll;
-
- /* flags */
- ot->flag = 0;
-}
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index a694ac2c38b..020bdbf60a1 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1309,7 +1309,7 @@ static void node_draw_hidden(const bContext *C,
nodeLabel(ntree, node, showname, sizeof(showname));
/* XXX - don't print into self! */
- //if (node->flag & NODE_MUTED)
+ // if (node->flag & NODE_MUTED)
// BLI_snprintf(showname, sizeof(showname), "[%s]", showname);
uiBut *but = uiDefBut(node->block,
@@ -1728,8 +1728,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
draw_tree_path(snode);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 84f512957c7..3e73cc52c52 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -752,8 +752,8 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
#if 0
if (node->id)
; // XXX BIF_preview_changed(-1);
- // allqueue(REDRAWBUTSSHADING, 1);
- // allqueue(REDRAWIPO, 0);
+ // allqueue(REDRAWBUTSSHADING, 1);
+ // allqueue(REDRAWIPO, 0);
#endif
}
}
@@ -804,7 +804,8 @@ static int edit_node_invoke_properties(bContext *C, wmOperator *op)
return 1;
}
-static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **rnode, bNodeSocket **rsock, int *rin_out)
+static void edit_node_properties_get(
+ wmOperator *op, bNodeTree *ntree, bNode **rnode, bNodeSocket **rsock, int *rin_out)
{
bNode *node;
bNodeSocket *sock = NULL;
@@ -819,8 +820,12 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r
sockindex = RNA_int_get(op->ptr, "socket");
switch (in_out) {
- case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break;
- case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break;
+ case SOCK_IN:
+ sock = BLI_findlink(&node->inputs, sockindex);
+ break;
+ case SOCK_OUT:
+ sock = BLI_findlink(&node->outputs, sockindex);
+ break;
}
if (rnode)
@@ -2027,7 +2032,8 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
for (node = ntree->nodes.first; node; node = node->next) {
if (node->flag & SELECT) {
- /* No ID refcounting, this node is virtual, detached from any actual Blender data currently. */
+ /* No ID refcounting, this node is virtual,
+ * detached from any actual Blender data currently. */
bNode *new_node = BKE_node_copy_ex(NULL, node, LIB_ID_CREATE_NO_USER_REFCOUNT);
BKE_node_clipboard_add_node(new_node);
}
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index 3c65c4854b8..08328681f7a 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -823,8 +823,8 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
/* update the group node and interface node sockets,
* so the new interface socket can be linked.
*/
- node_group_verify(ntree, gnode, (ID *)ngroup);
- node_group_input_verify(ngroup, input_node, (ID *)ngroup);
+ node_group_update(ntree, gnode);
+ node_group_input_update(ngroup, input_node);
/* create new internal link */
input_sock = node_group_input_find_socket(input_node, iosock->identifier);
@@ -857,8 +857,8 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
/* update the group node and interface node sockets,
* so the new interface socket can be linked.
*/
- node_group_verify(ntree, gnode, (ID *)ngroup);
- node_group_output_verify(ngroup, output_node, (ID *)ngroup);
+ node_group_update(ntree, gnode);
+ node_group_output_update(ngroup, output_node);
/* create new internal link */
output_sock = node_group_output_find_socket(output_node, iosock->identifier);
@@ -898,7 +898,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
- node_group_input_verify(ngroup, input_node, (ID *)ngroup);
+ node_group_input_update(ngroup, input_node);
/* create new internal link */
input_sock = node_group_input_find_socket(input_node, iosock->identifier);
@@ -919,7 +919,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock);
- node_group_output_verify(ngroup, output_node, (ID *)ngroup);
+ node_group_output_update(ngroup, output_node);
/* create new internal link */
output_sock = node_group_output_find_socket(output_node, iosock->identifier);
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 7b4102ce324..1825396805c 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -54,8 +54,6 @@ typedef struct bNodeLinkDrag {
} bNodeLinkDrag;
/* space_node.c */
-ARegion *node_has_buttons_region(ScrArea *sa);
-ARegion *node_has_tools_region(ScrArea *sa);
/* transform between View2Ds in the tree path */
void snode_group_offset(struct SpaceNode *snode, float *x, float *y);
@@ -95,11 +93,9 @@ void node_from_view(struct bNode *node, float x, float y, float *rx, float *ry);
/* node_buttons.c */
void node_buttons_register(struct ARegionType *art);
-void NODE_OT_properties(struct wmOperatorType *ot);
/* node_toolbar.c */
void node_toolbar_register(struct ARegionType *art);
-void NODE_OT_toolbar(struct wmOperatorType *ot);
/* node_ops.c */
void node_operatortypes(void);
@@ -155,7 +151,16 @@ bool node_link_bezier_points(struct View2D *v2d,
struct bNodeLink *link,
float coord_array[][2],
int resol);
-// void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 );
+#if 0
+void node_draw_link_straight(View2D *v2d,
+ SpaceNode *snode,
+ bNodeLink *link,
+ int th_col1,
+ int do_shaded,
+ int th_col2,
+ int do_triple,
+ int th_col3);
+#endif
void draw_nodespace_back_pix(const struct bContext *C,
struct ARegion *ar,
struct SpaceNode *snode,
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index ce6bf2820c6..0836617ab44 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -41,9 +41,6 @@
void node_operatortypes(void)
{
- WM_operatortype_append(NODE_OT_properties);
- WM_operatortype_append(NODE_OT_toolbar);
-
WM_operatortype_append(NODE_OT_select);
WM_operatortype_append(NODE_OT_select_all);
WM_operatortype_append(NODE_OT_select_linked_to);
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 14636dad8c6..d34ba14700a 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -986,8 +986,8 @@ void NODE_OT_link_make(wmOperatorType *ot)
/* callbacks */
ot->exec = node_make_link_exec;
- ot->poll =
- ED_operator_node_editable; // XXX we need a special poll which checks that there are selected input/output sockets
+ // XXX we need a special poll which checks that there are selected input/output sockets
+ ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 58531ec32b1..b52d1d3b78f 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -429,8 +429,13 @@ void node_select_single(bContext *C, bNode *node)
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
}
-static int node_mouse_select(
- Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], bool extend, bool socket_select)
+static int node_mouse_select(Main *bmain,
+ SpaceNode *snode,
+ ARegion *ar,
+ const int mval[2],
+ const bool extend,
+ const bool socket_select,
+ const bool deselect_all)
{
bNode *node, *tnode;
bNodeSocket *sock = NULL;
@@ -500,13 +505,15 @@ static int node_mouse_select(
/* find the closest visible node */
node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]);
- if (node) {
+ if (node != NULL || deselect_all) {
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
nodeSetSelected(tnode, false);
}
- nodeSetSelected(node, true);
- ED_node_set_active(bmain, snode->edittree, node);
selected = true;
+ if (node != NULL) {
+ nodeSetSelected(node, true);
+ ED_node_set_active(bmain, snode->edittree, node);
+ }
}
}
}
@@ -526,19 +533,18 @@ static int node_select_exec(bContext *C, wmOperator *op)
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
int mval[2];
- short extend;
- bool socket_select;
/* get settings from RNA properties for operator */
mval[0] = RNA_int_get(op->ptr, "mouse_x");
mval[1] = RNA_int_get(op->ptr, "mouse_y");
- extend = RNA_boolean_get(op->ptr, "extend");
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
/* always do socket_select when extending selection. */
- socket_select = extend || RNA_boolean_get(op->ptr, "socket_select");
+ const bool socket_select = extend || RNA_boolean_get(op->ptr, "socket_select");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
/* perform the select */
- if (node_mouse_select(bmain, snode, ar, mval, extend, socket_select)) {
+ if (node_mouse_select(bmain, snode, ar, mval, extend, socket_select, deselect_all)) {
/* send notifiers */
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
@@ -575,10 +581,17 @@ void NODE_OT_select(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
+ PropertyRNA *prop;
RNA_def_int(ot->srna, "mouse_x", 0, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX);
RNA_def_boolean(ot->srna, "extend", false, "Extend", "");
RNA_def_boolean(ot->srna, "socket_select", false, "Socket Select", "");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/** \} */
diff --git a/source/blender/editors/space_node/node_toolbar.c b/source/blender/editors/space_node/node_toolbar.c
index bc7119fa4ab..7afd3fef4db 100644
--- a/source/blender/editors/space_node/node_toolbar.c
+++ b/source/blender/editors/space_node/node_toolbar.c
@@ -40,37 +40,3 @@
void node_toolbar_register(ARegionType *UNUSED(art))
{
}
-
-/* ********** operator to open/close toolshelf region */
-
-static int node_toolbar_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = node_has_tools_region(sa);
-
- if (ar) {
- ED_region_toggle_hidden(C, ar);
- }
-
- return OPERATOR_FINISHED;
-}
-
-/* non-standard poll operator which doesn't care if there are any nodes */
-static bool node_toolbar_poll(bContext *C)
-{
- ScrArea *sa = CTX_wm_area(C);
- return (sa && (sa->spacetype == SPACE_NODE));
-}
-
-void NODE_OT_toolbar(wmOperatorType *ot)
-{
- ot->name = "Tool Shelf";
- ot->description = "Toggles tool shelf display";
- ot->idname = "NODE_OT_toolbar";
-
- ot->exec = node_toolbar_toggle_exec;
- ot->poll = node_toolbar_poll;
-
- /* flags */
- ot->flag = 0;
-}
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 52dab2a44a8..2152bb9847a 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -242,64 +242,6 @@ void snode_group_offset(SpaceNode *snode, float *x, float *y)
}
}
-/* ******************** manage regions ********************* */
-
-ARegion *node_has_buttons_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) {
- return ar;
- }
-
- /* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
- /* is error! */
- if (ar == NULL) {
- return NULL;
- }
-
- arnew = MEM_callocN(sizeof(ARegion), "buttons for node");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
-ARegion *node_has_tools_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
- if (ar) {
- return ar;
- }
-
- /* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
- /* is error! */
- if (ar == NULL) {
- return NULL;
- }
-
- arnew = MEM_callocN(sizeof(ARegion), "node tools");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_TOOLS;
- arnew->alignment = RGN_ALIGN_LEFT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
/* ******************** default callbacks for node space ***************** */
static SpaceLink *node_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
@@ -675,7 +617,7 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Node Editor", SPACE_NODE, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* add drop boxes */
lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW);
diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index f08069c418b..d235dd47136 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -21,13 +21,13 @@ set(INC
../../blenlib
../../blentranslation
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 835c154786b..6da42ecb3c0 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -284,7 +284,8 @@ static int collection_delete_exec(bContext *C, wmOperator *op)
data.collections_to_edit = BLI_gset_ptr_new(__func__);
- /* We first walk over and find the Collections we actually want to delete (ignoring duplicates). */
+ /* We first walk over and find the Collections we actually want to delete
+ * (ignoring duplicates). */
outliner_tree_traverse(
soops, &soops->tree, 0, TSE_SELECTED, collection_find_data_to_edit, &data);
@@ -295,8 +296,8 @@ static int collection_delete_exec(bContext *C, wmOperator *op)
/* Test in case collection got deleted as part of another one. */
if (BLI_findindex(&bmain->collections, collection) != -1) {
- /* We cannot allow to delete collections that are indirectly linked, or that are used by (linked to...)
- * other linked scene/collection. */
+ /* We cannot allow to delete collections that are indirectly linked,
+ * or that are used by (linked to...) other linked scene/collection. */
bool skip = false;
if (ID_IS_LINKED(collection)) {
if (collection->id.tag & LIB_TAG_INDIRECT) {
@@ -650,7 +651,8 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op))
data.collections_to_edit = BLI_gset_ptr_new(__func__);
- /* We first walk over and find the Collections we actually want to instance (ignoring duplicates). */
+ /* We first walk over and find the Collections we actually want to instance
+ * (ignoring duplicates). */
outliner_tree_traverse(
soops, &soops->tree, 0, TSE_SELECTED, collection_find_data_to_edit, &data);
@@ -957,7 +959,8 @@ static int collection_isolate_exec(bContext *C, wmOperator *op)
};
data.collections_to_edit = BLI_gset_ptr_new(__func__);
- /* Hide all collections before the isolate function - needed in order to support multiple selected collections. */
+ /* Hide all collections before the isolate function -
+ * needed in order to support multiple selected collections. */
if (!extend) {
LayerCollection *lc_master = view_layer->layer_collections.first;
for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter;
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index cff262698fa..49ba397a108 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -144,7 +144,8 @@ static TreeElement *outliner_drop_insert_find(bContext *C,
te_hovered = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
if (te_hovered) {
- /* mouse hovers an element (ignoring x-axis), now find out how to insert the dragged item exactly */
+ /* Mouse hovers an element (ignoring x-axis),
+ * now find out how to insert the dragged item exactly. */
const float margin = UI_UNIT_Y * (1.0f / 4);
if (view_mval[1] < (te_hovered->ys + margin)) {
@@ -174,7 +175,8 @@ static TreeElement *outliner_drop_insert_find(bContext *C,
}
}
else {
- /* mouse doesn't hover any item (ignoring x-axis), so it's either above list bounds or below. */
+ /* Mouse doesn't hover any item (ignoring x-axis),
+ * so it's either above list bounds or below. */
TreeElement *first = soops->tree.first;
TreeElement *last = soops->tree.last;
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 2d33c5db49d..b556f58a02d 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -100,7 +100,7 @@ static void outliner_width(SpaceOutliner *soops, ListBase *lb, int *w)
{
TreeElement *te = lb->first;
while (te) {
-// TreeStoreElem *tselem = TREESTORE(te);
+ // TreeStoreElem *tselem = TREESTORE(te);
// XXX fixme... te->xend is not set yet
if (!TSELEM_OPEN(tselem, soops)) {
@@ -333,7 +333,7 @@ static void hidebutton_base_flag_cb(bContext *C, void *poin, void *poin2)
if (depsgraph_changed) {
BKE_main_collection_sync_remap(bmain);
- DEG_id_tag_update(&ob->id, LIB_TAG_COPIED_ON_WRITE);
+ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id);
}
@@ -627,6 +627,10 @@ static void outliner_draw_restrictbuts(uiBlock *block,
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
}
+ else if ((tselem->type == 0 && te->idcode == ID_OB) &&
+ (te->flag & TE_CHILD_NOT_IN_COLLECTION)) {
+ /* Don't show restrict columns for children that are not directly inside the collection. */
+ }
else if (tselem->type == 0 && te->idcode == ID_OB) {
PointerRNA ptr;
Object *ob = (Object *)tselem->id;
@@ -898,7 +902,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
ICON_HIDE_OFF;
}
bt = uiDefIconBut(block,
- UI_BTYPE_TOGGLE,
+ UI_BTYPE_ICON_TOGGLE,
0,
icon,
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX),
@@ -1010,7 +1014,7 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOutliner *s
tip = TIP_("Data-block has no users and will be deleted");
}
bt = uiDefIconButBitS(block,
- UI_BTYPE_TOGGLE,
+ UI_BTYPE_ICON_TOGGLE,
LIB_FAKEUSER,
1,
icon,
@@ -1045,7 +1049,7 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOutliner *s
UI_but_flag_enable(bt, but_flag);
bt = uiDefButBitS(block,
- UI_BTYPE_TOGGLE,
+ UI_BTYPE_ICON_TOGGLE,
LIB_FAKEUSER,
1,
(id->flag & LIB_FAKEUSER) ? "F" : " ",
@@ -1561,7 +1565,8 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
data.icon = ICON_GROUP;
break;
}
- /* Removed the icons from outliner. Need a better structure with Layers, Palettes and Colors */
+ /* Removed the icons from outliner.
+ * Need a better structure with Layers, Palettes and Colors. */
case TSE_GP_LAYER: {
/* indicate whether layer is active */
bGPDlayer *gpl = te->directdata;
@@ -2073,7 +2078,10 @@ static void outliner_draw_tree_element(bContext *C,
tselem = TREESTORE(te);
if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) {
- const float alpha_fac = ((te->flag & TE_DISABLED) || draw_grayed_out) ? 0.5f : 1.0f;
+ const float alpha_fac = ((te->flag & TE_DISABLED) || (te->flag & TE_CHILD_NOT_IN_COLLECTION) ||
+ draw_grayed_out) ?
+ 0.5f :
+ 1.0f;
const float alpha = 0.5f * alpha_fac;
int xmax = ar->v2d.cur.xmax;
@@ -2099,7 +2107,8 @@ static void outliner_draw_tree_element(bContext *C,
}
else if (te->idcode == ID_OB) {
Object *ob = (Object *)tselem->id;
- Base *base = BKE_view_layer_base_find(view_layer, ob);
+ Base *base = (te->directdata) ? (Base *)te->directdata :
+ BKE_view_layer_base_find(view_layer, ob);
const bool is_selected = (base != NULL) && ((base->flag & BASE_SELECTED) != 0);
if (ob == obact || is_selected) {
@@ -2254,26 +2263,6 @@ static void outliner_draw_tree_element(bContext *C,
GPU_blend(true);
- /* divider */
- {
- GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(
- format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
- unsigned char col[4];
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- UI_GetThemeColorShade4ubv(TH_BACK, -40, col);
- col[3] *= alpha_fac;
-
- immUniformColor4ubv(col);
- immRecti(pos,
- tempx - 10.0f * ufac,
- *starty + 4.0f * ufac,
- tempx - 8.0f * ufac,
- *starty + UI_UNIT_Y - 4.0f * ufac);
- immUnbindProgram();
- }
-
MergedIconRow merged = {{0}};
outliner_draw_iconrow(C,
block,
@@ -2337,17 +2326,28 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos,
bool draw_grayed_out,
int *starty)
{
- TreeElement *te, *te_vertical_line_last = NULL;
- int y1, y2;
+ TreeElement *te, *te_vertical_line_last = NULL, *te_vertical_line_last_dashed = NULL;
+ int y1, y2, y1_dashed, y2_dashed;
if (BLI_listbase_is_empty(lb)) {
return;
}
+ struct {
+ int steps_num;
+ int step_len;
+ int gap_len;
+ } dash = {
+ .steps_num = 4,
+ };
+
+ dash.step_len = UI_UNIT_X / dash.steps_num;
+ dash.gap_len = dash.step_len / 2;
+
const unsigned char grayed_alpha = col[3] / 2;
/* For vertical lines between objects. */
- y1 = y2 = *starty;
+ y1 = y2 = y1_dashed = y2_dashed = *starty;
for (te = lb->first; te; te = te->next) {
bool draw_childs_grayed_out = draw_grayed_out || (te->flag & TE_DRAGGING);
TreeStoreElem *tselem = TREESTORE(te);
@@ -2359,15 +2359,30 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos,
immUniformColor4ubv(col);
}
- /* Horizontal Line? */
- if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) {
- immRecti(pos, startx, *starty, startx + UI_UNIT_X, *starty - 1);
+ if ((te->flag & TE_CHILD_NOT_IN_COLLECTION) == 0) {
+ /* Horizontal Line? */
+ if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) {
+ immRecti(pos, startx, *starty, startx + UI_UNIT_X, *starty - U.pixelsize);
- /* Vertical Line? */
- if (te->idcode == ID_OB) {
- te_vertical_line_last = te;
- y2 = *starty;
+ /* Vertical Line? */
+ if (te->idcode == ID_OB) {
+ te_vertical_line_last = te;
+ y2 = *starty;
+ }
+ y1_dashed = *starty - UI_UNIT_Y;
+ }
+ }
+ else {
+ BLI_assert(te->idcode == ID_OB);
+ /* Horizontal line - dashed. */
+ int start = startx;
+ for (int i = 0; i < dash.steps_num; i++) {
+ immRecti(pos, start, *starty, start + dash.step_len - dash.gap_len, *starty - U.pixelsize);
+ start += dash.step_len;
}
+
+ te_vertical_line_last_dashed = te;
+ y2_dashed = *starty;
}
*starty -= UI_UNIT_Y;
@@ -2388,7 +2403,19 @@ static void outliner_draw_hierarchy_lines_recursive(unsigned pos,
/* Vertical line. */
te = te_vertical_line_last;
if ((te != NULL) && (te->parent || lb->first != lb->last)) {
- immRecti(pos, startx, y1 + UI_UNIT_Y, startx + 1, y2);
+ immRecti(pos, startx, y1 + UI_UNIT_Y, startx + U.pixelsize, y2);
+ }
+
+ /* Children that are not in the collection are always in the end of the subtree.
+ * This way we can draw their own dashed vertical lines. */
+ te = te_vertical_line_last_dashed;
+ if ((te != NULL) && (te->parent || lb->first != lb->last)) {
+ const int steps_num = ((y1_dashed + UI_UNIT_Y) - y2_dashed) / dash.step_len;
+ int start = y1_dashed + UI_UNIT_Y;
+ for (int i = 0; i < steps_num; i++) {
+ immRecti(pos, startx, start, startx + U.pixelsize, start - dash.step_len + dash.gap_len);
+ start -= dash.step_len;
+ }
}
}
@@ -2472,7 +2499,7 @@ static void outliner_draw_highlights_recursive(unsigned pos,
/* selection status */
if (tselem->flag & TSE_SELECTED) {
immUniformColor4fv(col_selection);
- immRecti(pos, 0, start_y + 1, (int)ar->v2d.cur.xmax, start_y + UI_UNIT_Y - 1);
+ immRecti(pos, 0, start_y, (int)ar->v2d.cur.xmax, start_y + UI_UNIT_Y);
}
/* highlights */
@@ -2486,15 +2513,15 @@ static void outliner_draw_highlights_recursive(unsigned pos,
if (tselem->flag & TSE_DRAG_BEFORE) {
immUniformColor4fv(col);
- immRecti(pos, start_x, start_y + UI_UNIT_Y - 1, end_x, start_y + UI_UNIT_Y + 1);
+ immRecti(pos, start_x, start_y + UI_UNIT_Y, end_x, start_y + UI_UNIT_Y);
}
else if (tselem->flag & TSE_DRAG_AFTER) {
immUniformColor4fv(col);
- immRecti(pos, start_x, start_y - 1, end_x, start_y + 1);
+ immRecti(pos, start_x, start_y, end_x, start_y);
}
else {
immUniformColor3fvAlpha(col, col[3] * 0.5f);
- immRecti(pos, start_x, start_y + 1, end_x, start_y + UI_UNIT_Y - 1);
+ immRecti(pos, start_x, start_y, end_x, start_y + UI_UNIT_Y);
}
}
else {
@@ -2503,12 +2530,12 @@ static void outliner_draw_highlights_recursive(unsigned pos,
* we don't expand items when searching in the datablocks but we
* still want to highlight any filter matches. */
immUniformColor4fv(col_searchmatch);
- immRecti(pos, start_x, start_y + 1, end_x, start_y + UI_UNIT_Y - 1);
+ immRecti(pos, start_x, start_y, end_x, start_y + UI_UNIT_Y);
}
else if (tselem->flag & TSE_HIGHLIGHTED) {
/* mouse hover highlight */
immUniformColor4fv(col_highlight);
- immRecti(pos, 0, start_y + 1, end_x, start_y + UI_UNIT_Y - 1);
+ immRecti(pos, 0, start_y, end_x, start_y + UI_UNIT_Y);
}
}
}
@@ -2587,7 +2614,7 @@ static void outliner_draw_tree(bContext *C,
// gray hierarchy lines
starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET;
- startx = UI_UNIT_X / 2 - 1.0f;
+ startx = UI_UNIT_X / 2 - (U.pixelsize + 1) / 2;
outliner_draw_hierarchy_lines(soops, &soops->tree, startx, &starty);
// items themselves
@@ -2649,29 +2676,6 @@ static void outliner_back(ARegion *ar)
immUnbindProgram();
}
-static void outliner_draw_restrictcols(ARegion *ar)
-{
- GPU_line_width(1.0f);
-
- uint pos = GPU_vertformat_attr_add(
- immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformThemeColorShadeAlpha(TH_BACK, -15, -200);
- immBegin(GPU_PRIM_LINES, 6);
-
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymax);
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymin);
-
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymax);
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), (int)ar->v2d.cur.ymin);
-
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymax);
- immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), (int)ar->v2d.cur.ymin);
-
- immEnd();
- immUnbindProgram();
-}
-
/* ****************************************************** */
/* Main Entrypoint - Draw contents of Outliner editor */
@@ -2716,7 +2720,7 @@ void draw_outliner(const bContext *C)
else {
/* width must take into account restriction columns (if visible)
* so that entries will still be visible */
- //outliner_width(soops, &soops->tree, &sizex);
+ // outliner_width(soops, &soops->tree, &sizex);
// XXX should use outliner_width instead when te->xend will be set correctly...
outliner_rna_width(soops, &soops->tree, &sizex, 0);
@@ -2759,13 +2763,10 @@ void draw_outliner(const bContext *C)
}
else if ((soops->outlinevis == SO_ID_ORPHANS) && has_restrict_icons) {
/* draw user toggle columns */
- outliner_draw_restrictcols(ar);
outliner_draw_userbuts(block, ar, soops, &soops->tree);
}
else if (has_restrict_icons) {
/* draw restriction columns */
- outliner_draw_restrictcols(ar);
-
outliner_draw_restrictbuts(block, scene, view_layer, ar, soops, &soops->tree);
}
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 11d01931945..a943e972cf5 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1296,8 +1296,8 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot)
#if 0
/* find next element that has this name */
-static TreeElement *outliner_find_name(SpaceOutliner *soops, ListBase *lb, char *name, int flags,
- TreeElement *prev, int *prevFound)
+static TreeElement *outliner_find_name(
+ SpaceOutliner *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound)
{
TreeElement *te, *tes;
@@ -1318,16 +1318,18 @@ static TreeElement *outliner_find_name(SpaceOutliner *soops, ListBase *lb, char
}
tes = outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound);
- if (tes) return tes;
+ if (tes)
+ return tes;
}
/* nothing valid found */
return NULL;
}
-static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOutliner *soops, int again, int flags)
+static void outliner_find_panel(
+ Scene *UNUSED(scene), ARegion *ar, SpaceOutliner *soops, int again, int flags)
{
- ReportList *reports = NULL; // CTX_wm_reports(C);
+ ReportList *reports = NULL; // CTX_wm_reports(C);
TreeElement *te = NULL;
TreeElement *last_find;
TreeStoreElem *tselem;
@@ -1354,10 +1356,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOutliner
else {
/* pop up panel - no previous, or user didn't want search after previous */
name[0] = '\0';
-// XXX if (sbutton(name, 0, sizeof(name) - 1, "Find: ") && name[0]) {
-// te = outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound);
-// }
-// else return; /* XXX RETURN! XXX */
+ // XXX if (sbutton(name, 0, sizeof(name) - 1, "Find: ") && name[0]) {
+ // te = outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound);
+ // }
+ // else return; /* XXX RETURN! XXX */
}
/* do selection and reveal */
@@ -1374,7 +1376,8 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOutliner
/* make te->ys center of view */
ytop = (int)(te->ys + BLI_rctf_size_y(&ar->v2d.mask) / 2);
- if (ytop > 0) ytop = 0;
+ if (ytop > 0)
+ ytop = 0;
ar->v2d.cur.ymax = (float)ytop;
ar->v2d.cur.ymin = (float)(ytop - BLI_rctf_size_y(&ar->v2d.mask));
@@ -1475,7 +1478,8 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot)
/* Show Hierarchy ----------------------------------------------- */
-/* helper function for tree_element_shwo_hierarchy() - recursively checks whether subtrees have any objects*/
+/* Helper function for tree_element_shwo_hierarchy() -
+ * recursively checks whether subtrees have any objects. */
static int subtree_has_objects(ListBase *lb)
{
TreeElement *te;
@@ -1630,7 +1634,8 @@ static void tree_element_to_path(TreeElement *te,
/* check if we're looking for first ID, or appending to path */
if (*id) {
/* just 'append' property to path
- * - to prevent memory leaks, we must write to newpath not path, then free old path + swap them
+ * - to prevent memory leaks, we must write to newpath not path,
+ * then free old path + swap them.
*/
if (tse->type == TSE_RNA_PROPERTY) {
if (RNA_property_type(prop) == PROP_POINTER) {
@@ -1679,7 +1684,8 @@ static void tree_element_to_path(TreeElement *te,
}
}
else {
- /* no ID, so check if entry is RNA-struct, and if that RNA-struct is an ID datablock to extract info from */
+ /* no ID, so check if entry is RNA-struct,
+ * and if that RNA-struct is an ID datablock to extract info from. */
if (tse->type == TSE_RNA_STRUCT) {
/* ptr->data not ptr->id.data seems to be the one we want,
* since ptr->data is sometimes the owner of this ID? */
@@ -2098,8 +2104,7 @@ static int outliner_orphans_purge_invoke(bContext *C, wmOperator *op, const wmEv
/* Tag all IDs having zero users. */
ID *id;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
outliner_orphans_purge_tag(id, num_tagged);
}
FOREACH_MAIN_ID_END;
@@ -2146,8 +2151,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *op)
if ((num_tagged[INDEX_ID_NULL] = RNA_int_get(op->ptr, "num_deleted")) == 0) {
/* Tag all IDs having zero users. */
ID *id;
- FOREACH_MAIN_ID_BEGIN(bmain, id)
- {
+ FOREACH_MAIN_ID_BEGIN (bmain, id) {
outliner_orphans_purge_tag(id, num_tagged);
}
FOREACH_MAIN_ID_END;
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index d382384076b..8211e3005c7 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -130,6 +130,7 @@ enum {
TE_FREE_NAME = (1 << 3),
TE_DISABLED = (1 << 4),
TE_DRAGGING = (1 << 5),
+ TE_CHILD_NOT_IN_COLLECTION = (1 << 6),
};
/* button events */
@@ -235,10 +236,6 @@ eOLDrawState tree_element_active(struct bContext *C,
void outliner_item_do_activate_from_tree_element(
struct bContext *C, TreeElement *te, TreeStoreElem *tselem, bool extend, bool recursive);
-int outliner_item_do_activate_from_cursor(struct bContext *C,
- const int mval[2],
- bool extend,
- bool recursive);
void outliner_item_select(struct SpaceOutliner *soops,
const struct TreeElement *te,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index bab5ee02916..995f41382cd 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -547,10 +547,11 @@ static eOLDrawState tree_element_active_defgroup(bContext *C,
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
}
else {
- if (ob == OBACT(view_layer))
+ if (ob == OBACT(view_layer)) {
if (ob->actdef == te->index + 1) {
return OL_DRAWSEL_NORMAL;
}
+ }
}
return OL_DRAWSEL_NONE;
}
@@ -1028,8 +1029,9 @@ eOLDrawState tree_element_active(bContext *C,
const bool handle_all_types)
{
switch (te->idcode) {
- /* Note: ID_OB only if handle_all_type is true, else objects are handled specially to allow multiple
- * selection. See do_outliner_item_activate. */
+ /** \note #ID_OB only if handle_all_type is true,
+ * else objects are handled specially to allow multiple selection.
+ * See #do_outliner_item_activate. */
case ID_OB:
if (handle_all_types) {
return tree_element_set_active_object(C, scene, view_layer, soops, te, set, false);
@@ -1131,8 +1133,8 @@ static void do_outliner_item_activate_tree_element(bContext *C,
TSE_SEQUENCE_DUP,
TSE_EBONE,
TSE_LAYER_COLLECTION)) {
- /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects, we do not want
- * to switch out of edit mode (see T48328 for details). */
+ /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects,
+ * we do not want to switch out of edit mode (see T48328 for details). */
}
else if (tselem->id && OB_DATA_SUPPORT_EDITMODE(te->idcode)) {
/* Support edit-mode toggle, keeping the active object as is. */
@@ -1295,10 +1297,11 @@ void outliner_item_do_activate_from_tree_element(
*
* May expend/collapse branches or activate items.
* */
-int outliner_item_do_activate_from_cursor(bContext *C,
- const int mval[2],
- bool extend,
- bool recursive)
+static int outliner_item_do_activate_from_cursor(bContext *C,
+ const int mval[2],
+ const bool extend,
+ const bool recursive,
+ const bool deselect_all)
{
ARegion *ar = CTX_wm_region(C);
SpaceOutliner *soops = CTX_wm_space_outliner(C);
@@ -1313,7 +1316,10 @@ int outliner_item_do_activate_from_cursor(bContext *C,
}
if (!(te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]))) {
- /* skip */
+ if (deselect_all) {
+ outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+ changed = true;
+ }
}
else if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) {
outliner_item_toggle_closed(te, extend);
@@ -1349,9 +1355,10 @@ int outliner_item_do_activate_from_cursor(bContext *C,
/* event can enterkey, then it opens/closes */
static int outliner_item_activate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- bool extend = RNA_boolean_get(op->ptr, "extend");
- bool recursive = RNA_boolean_get(op->ptr, "recursive");
- return outliner_item_do_activate_from_cursor(C, event->mval, extend, recursive);
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool recursive = RNA_boolean_get(op->ptr, "recursive");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
+ return outliner_item_do_activate_from_cursor(C, event->mval, extend, recursive, deselect_all);
}
void OUTLINER_OT_item_activate(wmOperatorType *ot)
@@ -1364,8 +1371,15 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
ot->poll = ED_operator_outliner_active;
+ PropertyRNA *prop;
RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation");
RNA_def_boolean(ot->srna, "recursive", false, "Recursive", "Select Objects and their children");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/* ****************************************************** */
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index ad4661102bc..0f9efb0d2e1 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -283,7 +283,7 @@ static void unlink_collection_cb(bContext *C,
static void unlink_object_cb(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
- TreeElement *UNUSED(te),
+ TreeElement *te,
TreeStoreElem *tsep,
TreeStoreElem *tselem,
void *UNUSED(user_data))
@@ -291,6 +291,15 @@ static void unlink_object_cb(bContext *C,
Main *bmain = CTX_data_main(C);
Object *ob = (Object *)tselem->id;
+ if (GS(tsep->id->name) == ID_OB) {
+ /* Parented objects need to find which collection to unlink from. */
+ TreeElement *te_parent = te->parent;
+ while (tsep && GS(tsep->id->name) == ID_OB) {
+ te_parent = te_parent->parent;
+ tsep = te_parent ? TREESTORE(te_parent) : NULL;
+ }
+ }
+
if (tsep) {
if (GS(tsep->id->name) == ID_GR) {
Collection *parent = (Collection *)tsep->id;
@@ -452,8 +461,8 @@ static void object_select_cb(bContext *C,
Object *ob = (Object *)tselem->id;
Base *base = BKE_view_layer_base_find(view_layer, ob);
- if (base && ((base->flag & BASE_VISIBLE) != 0)) {
- base->flag |= BASE_SELECTED;
+ if (base) {
+ ED_object_base_select(base, BA_SELECT);
}
}
@@ -650,7 +659,8 @@ static void singleuser_world_cb(bContext *C,
}
/**
- * \param select_recurse: Set to false for operations which are already recursively operating on their children.
+ * \param select_recurse: Set to false for operations which are already
+ * recursively operating on their children.
*/
void outliner_do_object_operation_ex(bContext *C,
ReportList *reports,
@@ -738,7 +748,8 @@ static void refreshdrivers_animdata_cb(int UNUSED(event),
IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id;
FCurve *fcu;
- /* loop over drivers, performing refresh (i.e. check graph_buttons.c and rna_fcurve.c for details) */
+ /* Loop over drivers, performing refresh
+ * (i.e. check graph_buttons.c and rna_fcurve.c for details). */
for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) {
fcu->flag &= ~FCURVE_DISABLED;
@@ -1768,7 +1779,8 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
else if (act->idroot == 0) {
- /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */
+ /* Hopefully in this case (i.e. library of userless actions),
+ * the user knows what they're doing. */
BKE_reportf(op->reports,
RPT_WARNING,
"Action '%s' does not specify what data-blocks it can be used on "
@@ -1834,8 +1846,8 @@ typedef enum eOutliner_AnimDataOps {
OUTLINER_ANIMOP_REFRESH_DRV,
OUTLINER_ANIMOP_CLEAR_DRV
- //OUTLINER_ANIMOP_COPY_DRIVERS,
- //OUTLINER_ANIMOP_PASTE_DRIVERS
+ // OUTLINER_ANIMOP_COPY_DRIVERS,
+ // OUTLINER_ANIMOP_PASTE_DRIVERS
} eOutliner_AnimDataOps;
static const EnumPropertyItem prop_animdata_op_types[] = {
@@ -1901,7 +1913,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
- //ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */
+ // ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */
updateDeps = 1;
break;
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index a03d9b6fb6d..4e3fd6037bb 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -48,6 +48,7 @@
#include "DNA_linestyle_types.h"
#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLI_mempool.h"
#include "BLI_fnmatch.h"
@@ -359,12 +360,12 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
pchan->temp = (void *)ten;
if (pchan->constraints.first) {
- //Object *target;
+ // Object *target;
bConstraint *con;
TreeElement *ten1;
TreeElement *tenla1 = outliner_add_element(
soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0);
- //char *str;
+ // char *str;
tenla1->name = IFACE_("Constraints");
for (con = pchan->constraints.first; con; con = con->next, const_index++) {
@@ -372,9 +373,12 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index);
#if 0 /* disabled as it needs to be reworked for recoded constraints system */
target = get_constraint_target(con, &str);
- if (str && str[0]) ten1->name = str;
- else if (target) ten1->name = target->id.name + 2;
- else ten1->name = con->name;
+ if (str && str[0])
+ ten1->name = str;
+ else if (target)
+ ten1->name = target->id.name + 2;
+ else
+ ten1->name = con->name;
#endif
ten1->name = con->name;
ten1->directdata = con;
@@ -422,11 +426,11 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
}
if (ob->constraints.first) {
- //Object *target;
+ // Object *target;
bConstraint *con;
TreeElement *ten;
TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0);
- //char *str;
+ // char *str;
int a;
tenla->name = IFACE_("Constraints");
@@ -434,9 +438,12 @@ static void outliner_add_object_contents(SpaceOutliner *soops,
ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a);
#if 0 /* disabled due to constraints system targets recode... code here needs review */
target = get_constraint_target(con, &str);
- if (str && str[0]) ten->name = str;
- else if (target) ten->name = target->id.name + 2;
- else ten->name = con->name;
+ if (str && str[0])
+ ten->name = str;
+ else if (target)
+ ten->name = target->id.name + 2;
+ else
+ ten->name = con->name;
#endif
ten->name = con->name;
ten->directdata = con;
@@ -647,7 +654,7 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
}
case ID_AC: {
// XXX do we want to be exposing the F-Curves here?
- //bAction *act = (bAction *)id;
+ // bAction *act = (bAction *)id;
break;
}
case ID_AR: {
@@ -952,7 +959,7 @@ static TreeElement *outliner_add_element(
/* Don't display arrays larger, weak but index is stored as a short,
* also the outliner isn't intended for editing such large data-sets. */
- BLI_STATIC_ASSERT(sizeof(te->index) == 2, "Index is no longer short!");
+ BLI_STATIC_ASSERT(sizeof(te->index) == 2, "Index is no longer short!")
const int tot_limit = SHRT_MAX;
int a, tot;
@@ -1464,16 +1471,111 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb)
BLI_remlink(lb, te);
tep = (TreeElement *)ob->parent->id.newid;
BLI_addtail(&tep->subtree, te);
- // set correct parent pointers
- for (te = tep->subtree.first; te; te = te->next) {
- te->parent = tep;
- }
+ te->parent = tep;
}
}
te = ten;
}
}
+/**
+ * For all objects in the tree, lookup the parent in this map,
+ * and move or add tree elements as needed.
+ */
+static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soops,
+ GHash *object_tree_elements_hash)
+{
+ GHashIterator gh_iter;
+ GHASH_ITER (gh_iter, object_tree_elements_hash) {
+ Object *child = BLI_ghashIterator_getKey(&gh_iter);
+
+ if (child->parent == NULL) {
+ continue;
+ }
+
+ ListBase *child_ob_tree_elements = BLI_ghashIterator_getValue(&gh_iter);
+ ListBase *parent_ob_tree_elements = BLI_ghash_lookup(object_tree_elements_hash, child->parent);
+ if (parent_ob_tree_elements == NULL) {
+ continue;
+ }
+
+ for (LinkData *link = parent_ob_tree_elements->first; link; link = link->next) {
+ TreeElement *parent_ob_tree_element = link->data;
+ TreeElement *parent_ob_collection_tree_element = NULL;
+ bool found = false;
+
+ /* We always want to remove the child from the direct collection its parent is nested under.
+ * This is particularly important when dealing with multi-level nesting (grandchildren). */
+ parent_ob_collection_tree_element = parent_ob_tree_element->parent;
+ while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type,
+ TSE_VIEW_COLLECTION_BASE,
+ TSE_LAYER_COLLECTION)) {
+ parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent;
+ }
+
+ for (LinkData *link_iter = child_ob_tree_elements->first; link_iter;
+ link_iter = link_iter->next) {
+ TreeElement *child_ob_tree_element = link_iter->data;
+
+ if (child_ob_tree_element->parent == parent_ob_collection_tree_element) {
+ /* Move from the collection subtree into the parent object subtree. */
+ BLI_remlink(&parent_ob_collection_tree_element->subtree, child_ob_tree_element);
+ BLI_addtail(&parent_ob_tree_element->subtree, child_ob_tree_element);
+ child_ob_tree_element->parent = parent_ob_tree_element;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ /* We add the child in the tree even if it is not in the collection.
+ * We deliberately clear its subtree though, to make it less proeminent. */
+ TreeElement *child_ob_tree_element = outliner_add_element(
+ soops, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0);
+ outliner_free_tree(&child_ob_tree_element->subtree);
+ child_ob_tree_element->flag |= TE_CHILD_NOT_IN_COLLECTION;
+ BLI_addtail(child_ob_tree_elements, BLI_genericNodeN(child_ob_tree_element));
+ }
+ }
+ }
+}
+
+/**
+ * Build a map from Object* to a list of TreeElement* matching the object.
+ */
+static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash,
+ TreeElement *te_parent)
+{
+ for (TreeElement *te = te_parent->subtree.first; te; te = te->next) {
+ TreeStoreElem *tselem = TREESTORE(te);
+
+ if (tselem->type == TSE_LAYER_COLLECTION) {
+ outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te);
+ }
+ else if (tselem->type == 0 && te->idcode == ID_OB) {
+ Object *ob = (Object *)tselem->id;
+ ListBase *tree_elements = BLI_ghash_lookup(object_tree_elements_hash, ob);
+
+ if (tree_elements == NULL) {
+ tree_elements = MEM_callocN(sizeof(ListBase), __func__);
+ BLI_ghash_insert(object_tree_elements_hash, ob, tree_elements);
+ }
+
+ BLI_addtail(tree_elements, BLI_genericNodeN(te));
+ outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te);
+ }
+ }
+}
+
+static void outliner_object_tree_elements_lookup_free(GHash *object_tree_elements_hash)
+{
+ GHASH_FOREACH_BEGIN (ListBase *, tree_elements, object_tree_elements_hash) {
+ BLI_freelistN(tree_elements);
+ MEM_freeN(tree_elements);
+ }
+ GHASH_FOREACH_END();
+}
+
/* Sorting ------------------------------------------------------ */
typedef struct tTreeSort {
@@ -1502,6 +1604,13 @@ static int treesort_alpha_ob(const void *v1, const void *v2)
return -1;
}
else if (comp == 3) {
+ /* Among objects first come the ones in the collection, followed by the ones not on it.
+ * This way we can have the dashed lines in a separate style connecting the former. */
+ if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) !=
+ (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) {
+ return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1;
+ }
+
comp = strcmp(x1->name, x2->name);
if (comp > 0) {
@@ -1515,6 +1624,19 @@ static int treesort_alpha_ob(const void *v1, const void *v2)
return 0;
}
+/* Move children that are not in the collection to the end of the list. */
+static int treesort_child_not_in_collection(const void *v1, const void *v2)
+{
+ const tTreeSort *x1 = v1, *x2 = v2;
+
+ /* Among objects first come the ones in the collection, followed by the ones not on it.
+ * This way we can have the dashed lines in a separate style connecting the former. */
+ if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) {
+ return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1;
+ }
+ return 0;
+}
+
/* alphabetical comparator */
static int treesort_alpha(const void *v1, const void *v2)
{
@@ -1548,15 +1670,20 @@ static int treesort_obtype_alpha(const void *v1, const void *v2)
else {
/* 2nd we check ob type */
if (x1->idcode == ID_OB && x2->idcode == ID_OB) {
- if (((Object *)x1->id)->type > ((Object *)x2->id)->type) return 1;
- else if (((Object *)x1->id)->type > ((Object *)x2->id)->type) return -1;
- else return 0;
+ if (((Object *)x1->id)->type > ((Object *)x2->id)->type)
+ return 1;
+ else if (((Object *)x1->id)->type > ((Object *)x2->id)->type)
+ return -1;
+ else
+ return 0;
}
else {
int comp = strcmp(x1->name, x2->name);
- if (comp > 0) return 1;
- else if (comp < 0) return -1;
+ if (comp > 0)
+ return 1;
+ else if (comp < 0)
+ return -1;
return 0;
}
}
@@ -1633,6 +1760,50 @@ static void outliner_sort(ListBase *lb)
}
}
+static void outliner_collections_children_sort(ListBase *lb)
+{
+ TreeElement *te;
+ TreeStoreElem *tselem;
+
+ te = lb->last;
+ if (te == NULL) {
+ return;
+ }
+ tselem = TREESTORE(te);
+
+ /* Sorting rules: only object lists. */
+ if (tselem->type == 0 && te->idcode == ID_OB) {
+ int totelem = BLI_listbase_count(lb);
+
+ if (totelem > 1) {
+ tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array");
+ tTreeSort *tp = tear;
+
+ for (te = lb->first; te; te = te->next, tp++) {
+ tselem = TREESTORE(te);
+ tp->te = te;
+ tp->name = te->name;
+ tp->idcode = te->idcode;
+ tp->id = tselem->id;
+ }
+
+ qsort(tear, totelem, sizeof(tTreeSort), treesort_child_not_in_collection);
+
+ BLI_listbase_clear(lb);
+ tp = tear;
+ while (totelem--) {
+ BLI_addtail(lb, tp->te);
+ tp++;
+ }
+ MEM_freeN(tear);
+ }
+ }
+
+ for (te = lb->first; te; te = te->next) {
+ outliner_sort(&te->subtree);
+ }
+}
+
/* Filtering ----------------------------------------------- */
typedef struct OutlinerTreeElementFocus {
@@ -1774,10 +1945,11 @@ static TreeElement *outliner_find_first_desired_element_at_y(const SpaceOutliner
}
/**
- * Store information of current outliner scrolling status to be restored later
+ * Store information of current outliner scrolling status to be restored later.
*
- * Finds the top-most collection visible in the outliner and populates the OutlinerTreeElementFocus
- * struct to retrieve this element later to make sure it is in the same original position as before filtering
+ * Finds the top-most collection visible in the outliner and populates the
+ * #OutlinerTreeElementFocus struct to retrieve this element later to make sure it is in the same
+ * original position as before filtering.
*/
static void outliner_store_scrolling_position(SpaceOutliner *soops,
ARegion *ar,
@@ -2182,12 +2354,28 @@ void outliner_build_tree(
bool show_objects = !(soops->filter & SO_FILTER_NO_OBJECT);
outliner_add_view_layer(soops, &ten->subtree, ten, view_layer, show_objects);
+
+ if ((soops->filter & SO_FILTER_NO_CHILDREN) == 0) {
+ GHash *object_tree_elements_hash = BLI_ghash_new(
+ BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+ outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, ten);
+ outliner_make_object_parent_hierarchy_collections(soops, object_tree_elements_hash);
+ outliner_object_tree_elements_lookup_free(object_tree_elements_hash);
+ BLI_ghash_free(object_tree_elements_hash, NULL, NULL);
+ }
}
}
if ((soops->flag & SO_SKIP_SORT_ALPHA) == 0) {
outliner_sort(&soops->tree);
}
+ else if ((soops->filter & SO_FILTER_NO_CHILDREN) == 0) {
+ /* We group the children that are in the collection before the ones that are not.
+ * This way we can try to draw them in a different style altogether.
+ * We also have to respect the original order of the elements in case alphabetical
+ * sorting is not enabled. This keep object data and modifiers before its children. */
+ outliner_collections_children_sort(&soops->tree);
+ }
outliner_filter_tree(soops, view_layer);
outliner_restore_scrolling_position(soops, ar, &focus);
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 26b97a1cdd9..a8e3129b5b4 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -74,8 +74,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0);
- /* don't pass on view2d mask, it's always set with scrollbar space, hide fails */
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* Add dropboxes */
lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW);
@@ -97,9 +96,8 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
diff --git a/source/blender/editors/space_script/CMakeLists.txt b/source/blender/editors/space_script/CMakeLists.txt
index 1abc05d2270..0bd2a01a151 100644
--- a/source/blender/editors/space_script/CMakeLists.txt
+++ b/source/blender/editors/space_script/CMakeLists.txt
@@ -23,8 +23,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index e26c0e3cec3..b99c2eaf54e 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -47,7 +47,7 @@
#include "script_intern.h" // own include
#include "GPU_framebuffer.h"
-//static script_run_python(char *funcname, )
+// static script_run_python(char *funcname, )
/* ******************** default callbacks for script space ***************** */
@@ -116,7 +116,7 @@ static void script_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Script", SPACE_SCRIPT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void script_main_region_draw(const bContext *C, ARegion *ar)
@@ -192,9 +192,8 @@ void ED_spacetype_script(void)
art->init = script_main_region_init;
art->draw = script_main_region_draw;
art->listener = script_main_region_listener;
- art->keymapflag =
- ED_KEYMAP_VIEW2D | ED_KEYMAP_UI |
- ED_KEYMAP_FRAMES; // XXX need to further test this ED_KEYMAP_UI is needed for button interaction
+ /* XXX: Need to further test this ED_KEYMAP_UI is needed for button interaction. */
+ art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt
index 8b97f7537f8..4668a9cef90 100644
--- a/source/blender/editors/space_sequencer/CMakeLists.txt
+++ b/source/blender/editors/space_sequencer/CMakeLists.txt
@@ -20,14 +20,14 @@ set(INC
../../blenkernel
../../blenlib
../../blentranslation
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
../../../../intern/atomic
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 218804b0ab4..b5bb79fb430 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -334,7 +334,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
seq->type = SEQ_TYPE_SCENE;
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
seq->scene = sce_seq;
@@ -422,7 +422,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
seq->type = SEQ_TYPE_MOVIECLIP;
- seq->blend_mode = SEQ_TYPE_CROSS;
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
seq->clip = clip;
id_us_ensure_real(&seq->clip->id);
@@ -508,7 +508,7 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
seq->type = SEQ_TYPE_MASK;
- seq->blend_mode = SEQ_TYPE_CROSS;
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
seq->mask = mask;
id_us_ensure_real(&seq->mask->id);
@@ -715,7 +715,7 @@ static int sequencer_add_movie_strip_invoke(bContext *C,
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
- //return sequencer_add_movie_strip_exec(C, op);
+ // return sequencer_add_movie_strip_exec(C, op);
}
static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
@@ -797,7 +797,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C,
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
- //return sequencer_add_sound_strip_exec(C, op);
+ // return sequencer_add_sound_strip_exec(C, op);
}
void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
@@ -1098,14 +1098,8 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
if (seq->type == SEQ_TYPE_COLOR) {
SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
RNA_float_get_array(op->ptr, "color", colvars->col);
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
- }
- else if (seq->type == SEQ_TYPE_ADJUSTMENT) {
- seq->blend_mode = SEQ_TYPE_CROSS;
- }
- else if (seq->type == SEQ_TYPE_TEXT) {
- seq->blend_mode = SEQ_TYPE_ALPHAOVER;
}
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
/* an unset channel is a special case where we automatically go above
* the other strips. */
@@ -1180,7 +1174,7 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot)
RNA_def_enum(ot->srna,
"type",
sequencer_prop_effect_types,
- SEQ_TYPE_CROSS,
+ SEQ_TYPE_ALPHAOVER,
"Type",
"Sequencer effect type");
RNA_def_float_vector(ot->srna,
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index 8d9fea2cb98..a6458ee5d31 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -119,30 +119,3 @@ void sequencer_buttons_register(ARegionType *art)
pt->flag |= PNL_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
}
-
-/* **************** operator to open/close properties view ************* */
-
-static int sequencer_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = sequencer_has_buttons_region(sa);
-
- if (ar) {
- ED_region_toggle_hidden(C, ar);
- }
-
- return OPERATOR_FINISHED;
-}
-
-void SEQUENCER_OT_properties(wmOperatorType *ot)
-{
- ot->name = "Properties";
- ot->idname = "SEQUENCER_OT_properties";
- ot->description = "Toggle the properties region visibility";
-
- ot->exec = sequencer_properties_toggle_exec;
- ot->poll = ED_operator_sequencer_active;
-
- /* flags */
- ot->flag = 0;
-}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index e2140fba1f6..86bc315b994 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -62,6 +62,8 @@
#include "ED_screen.h"
#include "ED_space_api.h"
+#include "BIF_glutil.h"
+
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -280,8 +282,8 @@ static void drawseqwave(View2D *v2d,
waveform = sound->waveform;
if (waveform->length == 0) {
- /* BKE_sound_read_waveform() set an empty SoundWaveform data in case it cannot generate a valid one...
- * See T45726. */
+ /* BKE_sound_read_waveform() set an empty SoundWaveform data in case it cannot generate a
+ * valid one. See T45726. */
return;
}
@@ -459,7 +461,7 @@ static void draw_seq_handle(View2D *v2d,
const short direction,
unsigned int pos)
{
- float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect
+ float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; // for triangles and rect
float x1, x2, y1, y2;
unsigned int whichsel = 0;
@@ -815,7 +817,7 @@ static void draw_seq_strip(const bContext *C,
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* get the correct color per strip type*/
- //color3ubv_from_seq(scene, seq, col);
+ // color3ubv_from_seq(scene, seq, col);
color3ubv_from_seq(scene, seq, background_col);
if (seq->flag & SEQ_MUTE) {
@@ -1186,7 +1188,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
void sequencer_draw_maskedit(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq)
{
/* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not,
- * for now just disable drawing since the strip frame will likely be offset */
+ * for now just disable drawing since the strip frame will likely be offset */
// if (sc->mode == SC_MODE_MASKEDIT)
if (0 && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
@@ -1201,13 +1203,19 @@ void sequencer_draw_maskedit(const bContext *C, Scene *scene, ARegion *ar, Space
width = (scene->r.size * scene->r.xsch) / 100;
height = (scene->r.size * scene->r.ysch) / 100;
- ED_mask_draw_region(
- mask, ar,
- 0, 0, 0, /* TODO */
- width, height,
- aspx, aspy,
- false, true,
- NULL, C);
+ ED_mask_draw_region(mask,
+ ar,
+ 0,
+ 0,
+ 0, /* TODO */
+ width,
+ height,
+ aspx,
+ aspy,
+ false,
+ true,
+ NULL,
+ C);
}
}
}
@@ -1220,7 +1228,7 @@ static void *sequencer_OCIO_transform_ibuf(
void *cache_handle = NULL;
bool force_fallback = false;
*glsl_used = false;
- force_fallback |= (U.image_draw_method != IMAGE_DRAW_METHOD_GLSL);
+ force_fallback |= (ED_draw_imbuf_method(ibuf) != IMAGE_DRAW_METHOD_GLSL);
force_fallback |= (ibuf->dither != 0.0f);
if (force_fallback) {
@@ -1595,7 +1603,8 @@ void sequencer_draw_preview(const bContext *C,
/* TODO */
/* sequencer_draw_maskedit(C, scene, ar, sseq); */
- /* Scope is freed in sequencer_check_scopes when ibuf changes and scope image is to be replaced. */
+ /* Scope is freed in sequencer_check_scopes when ibuf changes and
+ * scope image is to be replaced. */
if (ibuf) {
IMB_freeImBuf(ibuf);
}
@@ -1623,9 +1632,7 @@ void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq)
recty = (render_size * scene->r.ysch) / 100;
if (sseq->mainb != SEQ_DRAW_SEQUENCE) {
- give_ibuf_prefetch_request(
- rectx, recty, (scene->r.cfra), sseq->chanshown,
- proxy_size);
+ give_ibuf_prefetch_request(rectx, recty, (scene->r.cfra), sseq->chanshown, proxy_size);
}
}
#endif
@@ -1805,6 +1812,182 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
GPU_blend(false);
}
+typedef struct CacheDrawData {
+ const bContext *C;
+ uint pos;
+ float stripe_offs;
+ float stripe_ht;
+} CacheDrawData;
+
+/* Called as a callback */
+static bool draw_cache_view_cb(
+ void *userdata, struct Sequence *seq, int cfra, int cache_type, float UNUSED(cost))
+{
+ CacheDrawData *drawdata = userdata;
+ const bContext *C = drawdata->C;
+ Scene *scene = CTX_data_scene(C);
+ ARegion *ar = CTX_wm_region(C);
+ struct View2D *v2d = &ar->v2d;
+ Editing *ed = scene->ed;
+ uint pos = drawdata->pos;
+
+ if ((ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) == 0) {
+ return true;
+ }
+
+ float stripe_bot, stripe_top, stripe_offs, stripe_ht;
+ float color[4];
+ color[3] = 0.4f;
+
+ switch (cache_type) {
+ case SEQ_CACHE_STORE_FINAL_OUT:
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) {
+ color[0] = 1.0f;
+ color[1] = 0.4f;
+ color[2] = 0.2f;
+ stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) -
+ v2d->cur.ymin;
+ ;
+ stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HEIGHT_TEXT);
+ stripe_top = stripe_bot + stripe_ht;
+ break;
+ }
+ else {
+ return false;
+ }
+
+ case SEQ_CACHE_STORE_RAW:
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) {
+ color[0] = 1.0f;
+ color[1] = 0.1f;
+ color[2] = 0.02f;
+ stripe_offs = drawdata->stripe_offs;
+ stripe_ht = drawdata->stripe_ht;
+ stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + stripe_offs;
+ stripe_top = stripe_bot + stripe_ht;
+ break;
+ }
+ else {
+ return false;
+ }
+
+ case SEQ_CACHE_STORE_PREPROCESSED:
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) {
+ color[0] = 0.1f;
+ color[1] = 0.1f;
+ color[2] = 0.75f;
+ stripe_offs = drawdata->stripe_offs;
+ stripe_ht = drawdata->stripe_ht;
+ stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + (stripe_offs + stripe_ht) + stripe_offs;
+ stripe_top = stripe_bot + stripe_ht;
+ break;
+ }
+ else {
+ return false;
+ }
+
+ case SEQ_CACHE_STORE_COMPOSITE:
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) {
+ color[0] = 1.0f;
+ color[1] = 0.6f;
+ color[2] = 0.0f;
+ stripe_offs = drawdata->stripe_offs;
+ stripe_ht = drawdata->stripe_ht;
+ stripe_top = seq->machine + SEQ_STRIP_OFSTOP - stripe_offs;
+ stripe_bot = stripe_top - stripe_ht;
+ break;
+ }
+ else {
+ return false;
+ }
+ }
+
+ immUniformColor4f(color[0], color[1], color[2], color[3]);
+ immRectf(pos, cfra, stripe_bot, cfra + 1, stripe_top);
+
+ return false;
+}
+
+static void draw_cache_view(const bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+ ARegion *ar = CTX_wm_region(C);
+ struct View2D *v2d = &ar->v2d;
+
+ if ((scene->ed->cache_flag & SEQ_CACHE_VIEW_ENABLE) == 0) {
+ return;
+ }
+
+ GPU_blend(true);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ float stripe_bot, stripe_top, stripe_offs;
+ float stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) -
+ v2d->cur.ymin;
+
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) {
+ stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HEIGHT_TEXT);
+ stripe_top = stripe_bot + stripe_ht;
+ float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f};
+
+ immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
+ immRectf(pos, scene->r.sfra, stripe_bot, scene->r.efra, stripe_top);
+ }
+
+ for (Sequence *seq = scene->ed->seqbasep->first; seq != NULL; seq = seq->next) {
+ if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ continue;
+ }
+
+ if (seq->startdisp > v2d->cur.xmax || seq->enddisp < v2d->cur.xmin) {
+ continue;
+ }
+
+ CLAMP_MAX(stripe_ht, 0.2f);
+ stripe_offs = UI_view2d_region_to_view_y(v2d, 1.0f) - v2d->cur.ymin;
+ CLAMP_MIN(stripe_offs, stripe_ht / 2);
+
+ stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + stripe_offs;
+ stripe_top = stripe_bot + stripe_ht;
+
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) {
+ float bg_color[4] = {1.0f, 0.1f, 0.02f, 0.1f};
+ immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
+ immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top);
+ }
+
+ stripe_bot += stripe_ht + stripe_offs;
+ stripe_top = stripe_bot + stripe_ht;
+
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) {
+ float bg_color[4] = {0.1f, 0.1f, 0.75f, 0.1f};
+ immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
+ immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top);
+ }
+
+ stripe_top = seq->machine + SEQ_STRIP_OFSTOP - stripe_offs;
+ stripe_bot = stripe_top - stripe_ht;
+
+ if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) {
+ float bg_color[4] = {1.0f, 0.6f, 0.0f, 0.1f};
+ immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]);
+ immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top);
+ }
+ }
+
+ CacheDrawData userdata;
+ userdata.C = C;
+ userdata.pos = pos;
+ userdata.stripe_offs = stripe_offs;
+ userdata.stripe_ht = stripe_ht;
+
+ BKE_sequencer_cache_iterate(scene, &userdata, draw_cache_view_cb);
+
+ immUnbindProgram();
+ GPU_blend(false);
+}
+
/* Draw Timeline/Strip Editor Mode for Sequencer */
void draw_timeline_seq(const bContext *C, ARegion *ar)
{
@@ -1813,7 +1996,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
SpaceSeq *sseq = CTX_wm_space_seq(C);
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
- short unit = 0, cfra_flag = 0;
+ short cfra_flag = 0;
float col[3];
/* clear and setup matrix */
@@ -1853,6 +2036,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
if (ed) {
/* draw the data */
draw_seq_strips(C, ed, ar);
+ draw_cache_view(C);
/* text draw cached (for sequence names), in pixelspace now */
UI_view2d_text_cache_draw(ar);
@@ -1903,12 +2087,15 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
- unit = (sseq->flag & SEQ_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS;
- scrollers = UI_view2d_scrollers_calc(
- C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
+ scrollers = UI_view2d_scrollers_calc(v2d, NULL);
+ UI_view2d_scrollers_draw(v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
+ /* scale numbers */
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &v2d->hor, scene, !(sseq->flag & SEQ_DRAWFRAMES));
+ UI_view2d_draw_scale_y__block(ar, v2d, &v2d->vert);
+
/* draw current frame number-indicator on top of scrollers */
if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) {
UI_view2d_view_orthoSpecial(ar, v2d, 1);
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index cf07e252404..94437d4871a 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -759,8 +759,8 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, ListBase *new_seq_lis
/* First Strip! */
/* strips with extended stillfames before */
- /* Precaution, needed because the length saved on-disk may not match the length saved in the blend file,
- * or our code may have minor differences reading file length between versions.
+ /* Precaution, needed because the length saved on-disk may not match the length saved in the
+ * blend file, or our code may have minor differences reading file length between versions.
* This causes hard-cut to fail, see: T47862 */
if (seq->type != SEQ_TYPE_META) {
BKE_sequence_reload_new_file(scene, seq, true);
@@ -1036,22 +1036,22 @@ static void set_filter_seq(Scene *scene)
Sequence *seq;
Editing *ed = BKE_sequencer_editing_get(scene, false);
+ if (ed == NULL)
+ return;
- if (ed == NULL) return;
-
- if (okee("Set Deinterlace") == 0) return;
+ if (okee("Set Deinterlace") == 0)
+ return;
- SEQP_BEGIN (ed, seq)
- {
+ SEQP_BEGIN (ed, seq) {
if (seq->flag & SELECT) {
if (seq->type == SEQ_TYPE_MOVIE) {
seq->flag |= SEQ_FILTERY;
BKE_sequence_reload_new_file(scene, seq, false);
BKE_sequence_calc(scene, seq);
}
-
}
- } SEQ_END;
+ }
+ SEQ_END;
}
#endif
@@ -1228,7 +1228,8 @@ bool sequencer_edit_poll(bContext *C)
bool sequencer_strip_poll(bContext *C)
{
Editing *ed;
- return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) && (ed->act_seq != NULL));
+ return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) &&
+ (ed->act_seq != NULL));
}
#endif
@@ -1547,7 +1548,9 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
seq->enddisp = data->ts[i].enddisp + offset;
}
- /* effects are only added if we they are in a metastrip. In this case, dependent strips will just be transformed and we can skip calculating for effects
+ /* effects are only added if we they are in a meta-strip.
+ * In this case, dependent strips will just be transformed and
+ * we can skip calculating for effects.
* This way we can avoid an extra loop just for effects*/
if (!(seq->type & SEQ_TYPE_EFFECT)) {
BKE_sequence_calc(scene, seq);
@@ -2886,9 +2889,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
/* Apply aspect, dosnt need to be that accurate */
imgwidth = (int)(imgwidth * (scene->r.xasp / scene->r.yasp));
- if (((imgwidth >= width) || (imgheight >= height)) &&
- ((width > 0) && (height > 0)))
- {
+ if (((imgwidth >= width) || (imgheight >= height)) && ((width > 0) && (height > 0))) {
/* Find the zoom value that will fit the image in the image space */
zoomX = ((float)width) / ((float)imgwidth);
zoomY = ((float)height) / ((float)imgheight);
@@ -2965,10 +2966,14 @@ void SEQUENCER_OT_view_zoom_ratio(wmOperatorType *ot)
#if 0
static const EnumPropertyItem view_type_items[] = {
- {SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""},
- {SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Image Preview", ""},
- {SEQ_VIEW_SEQUENCE_PREVIEW, "SEQUENCER_PREVIEW", ICON_SEQ_SEQUENCER, "Sequencer and Image Preview", ""},
- {0, NULL, 0, NULL, NULL},
+ {SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""},
+ {SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Image Preview", ""},
+ {SEQ_VIEW_SEQUENCE_PREVIEW,
+ "SEQUENCER_PREVIEW",
+ ICON_SEQ_SEQUENCER,
+ "Sequencer and Image Preview",
+ ""},
+ {0, NULL, 0, NULL, NULL},
};
#endif
@@ -3169,7 +3174,8 @@ static Sequence *sequence_find_parent(Scene *scene, Sequence *child)
Sequence *parent = NULL;
Sequence *seq;
- if (ed == NULL) return NULL;
+ if (ed == NULL)
+ return NULL;
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if ((seq != child) && seq_is_parent(seq, child)) {
@@ -3885,7 +3891,7 @@ void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot)
ot->prop = RNA_def_enum(ot->srna,
"type",
sequencer_prop_effect_types,
- SEQ_TYPE_CROSS,
+ SEQ_TYPE_ALPHAOVER,
"Type",
"Sequencer effect type");
}
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index a051071ab61..dd04260d80e 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -42,9 +42,6 @@ struct bContext;
struct rctf;
struct wmOperator;
-/* space_sequencer.c */
-struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa);
-
/* sequencer_draw.c */
void draw_timeline_seq(const struct bContext *C, struct ARegion *ar);
void sequencer_draw_preview(const struct bContext *C,
@@ -94,7 +91,7 @@ int seq_effect_find_selected(struct Scene *scene,
/* operator helpers */
bool sequencer_edit_poll(struct bContext *C);
/* UNUSED */
-//bool sequencer_strip_poll(struct bContext *C);
+// bool sequencer_strip_poll(struct bContext *C);
bool sequencer_strip_has_path_poll(struct bContext *C);
bool sequencer_view_preview_poll(struct bContext *C);
bool sequencer_view_strips_poll(struct bContext *C);
@@ -210,7 +207,6 @@ struct ImBuf *make_histogram_view_from_ibuf(struct ImBuf *ibuf);
/* sequencer_buttons.c */
void sequencer_buttons_register(struct ARegionType *art);
-void SEQUENCER_OT_properties(struct wmOperatorType *ot);
/* sequencer_modifiers.c */
void SEQUENCER_OT_strip_modifier_add(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index 6adca28a3fa..b0bb775de83 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -109,9 +109,6 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_image_strip_add);
WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
- /* sequencer_buttons.c */
- WM_operatortype_append(SEQUENCER_OT_properties);
-
/* sequencer_modifiers.c */
WM_operatortype_append(SEQUENCER_OT_strip_modifier_add);
WM_operatortype_append(SEQUENCER_OT_strip_modifier_remove);
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index a59a3b830e3..f40514e7574 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -60,8 +60,8 @@ static void select_surrounding_handles(Scene *scene, Sequence *test) /* XXX BRIN
neighbor = find_neighboring_sequence(scene, test, SEQ_SIDE_LEFT, -1);
if (neighbor) {
- /* Only select neighbor handle if matching handle from test seq is also selected, or if neighbor
- * was not selected at all up till now.
+ /* Only select neighbor handle if matching handle from test seq is also selected,
+ * or if neighbor was not selected at all up till now.
* Otherwise, we get odd mismatch when shift-alt-rmb selecting neighbor strips... */
if (!(neighbor->flag & SELECT) || (test->flag & SEQ_LEFTSEL)) {
neighbor->flag |= SEQ_RIGHTSEL;
@@ -318,6 +318,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle");
const bool linked_time = RNA_boolean_get(op->ptr, "linked_time");
int left_right = RNA_enum_get(op->ptr, "left_right");
@@ -330,7 +331,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
return OPERATOR_CANCELLED;
}
- marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now
+ marker = find_nearest_marker(SCE_MARKERS, 1); // XXX - dummy function for now
seq = find_nearest_seq(scene, v2d, &hand, event->mval);
@@ -401,15 +402,13 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
}
else {
- // seq = find_nearest_seq(scene, v2d, &hand, mval);
-
act_orig = ed->act_seq;
- if (extend == 0 && linked_handle == 0) {
- ED_sequencer_deselect_all(scene);
- }
-
if (seq) {
+ if (!extend && !linked_handle) {
+ ED_sequencer_deselect_all(scene);
+ }
+
BKE_sequencer_active_set(scene, seq);
if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
@@ -427,8 +426,8 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
if (linked_handle) {
if (!ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) {
/* First click selects the strip and its adjacent handles (if valid).
- * Second click selects the strip, both of its handles and its adjacent handles (if valid).
- */
+ * Second click selects the strip,
+ * both of its handles and its adjacent handles (if valid). */
const bool is_striponly_selected = ((seq->flag & SEQ_ALLSEL) == SELECT);
if (!extend) {
@@ -535,25 +534,10 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e
select_linked_time(ed->seqbasep, seq);
}
}
- }
-
- /* marker transform */
-#if 0 // XXX probably need to redo this differently for 2.5
- if (marker) {
- int mval[2], xo, yo;
-// getmouseco_areawin(mval);
- xo = mval[0];
- yo = mval[1];
-
- while (get_mbut()) {
-// getmouseco_areawin(mval);
- if (abs(mval[0] - xo) + abs(mval[1] - yo) > 4) {
- transform_markers('g', 0);
- return;
- }
+ else if (deselect_all) {
+ ED_sequencer_deselect_all(scene);
}
}
-#endif
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
@@ -584,7 +568,14 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
+ PropertyRNA *prop;
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_boolean(
ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip");
/* for animation this is an enum but atm having an enum isn't useful for us */
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 35c031e8bc8..2b0c29a02ad 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -68,34 +68,6 @@ static void sequencer_scopes_tag_refresh(ScrArea *sa)
/* ******************** manage regions ********************* */
-ARegion *sequencer_has_buttons_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) {
- return ar;
- }
-
- /* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
- /* is error! */
- if (ar == NULL) {
- return NULL;
- }
-
- arnew = MEM_callocN(sizeof(ARegion), "buttons for sequencer");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
static ARegion *sequencer_find_region(ScrArea *sa, short type)
{
ARegion *ar = NULL;
@@ -496,15 +468,15 @@ static void sequencer_main_region_init(wmWindowManager *wm, ARegion *ar)
#if 0
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
#endif
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* add drop boxes */
lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
@@ -642,15 +614,15 @@ static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *ar)
#if 0
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
#endif
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void sequencer_preview_region_draw(const bContext *C, ARegion *ar)
@@ -723,8 +695,6 @@ static void sequencer_preview_region_listener(wmWindow *UNUSED(win),
case NC_ANIMATION:
switch (wmn->data) {
case ND_KEYFRAME:
- /* Otherwise, often prevents seeing immediately effects of keyframe editing... */
- BKE_sequencer_cache_cleanup();
ED_region_tag_redraw(ar);
break;
}
@@ -757,7 +727,7 @@ static void sequencer_buttons_region_init(wmWindowManager *wm, ARegion *ar)
wmKeyMap *keymap;
keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
ED_region_panels_init(wm, ar);
}
diff --git a/source/blender/editors/space_statusbar/CMakeLists.txt b/source/blender/editors/space_statusbar/CMakeLists.txt
index 39957c6792c..ad4c060a1f6 100644
--- a/source/blender/editors/space_statusbar/CMakeLists.txt
+++ b/source/blender/editors/space_statusbar/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt
index f5db86ac4c2..740fc9948ef 100644
--- a/source/blender/editors/space_text/CMakeLists.txt
+++ b/source/blender/editors/space_text/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 9232d0322ab..24f282ff920 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -132,16 +132,18 @@ static void text_listener(wmWindow *UNUSED(win),
/* check if active text was changed, no need to redraw if text isn't active
* (reference == NULL) means text was unlinked, should update anyway for this
* case -- no way to know was text active before unlinking or not */
- if (wmn->reference && wmn->reference != st->text)
+ if (wmn->reference && wmn->reference != st->text) {
break;
+ }
switch (wmn->data) {
case ND_DISPLAY:
ED_area_tag_redraw(sa);
break;
case ND_CURSOR:
- if (st->text && st->text == wmn->reference)
+ if (st->text && st->text == wmn->reference) {
text_scroll_to_cursor__area(st, sa, true);
+ }
ED_area_tag_redraw(sa);
break;
@@ -161,16 +163,18 @@ static void text_listener(wmWindow *UNUSED(win),
ED_area_tag_redraw(sa);
break;
case NA_SELECTED:
- if (st->text && st->text == wmn->reference)
+ if (st->text && st->text == wmn->reference) {
text_scroll_to_cursor__area(st, sa, true);
+ }
break;
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_TEXT)
+ if (wmn->data == ND_SPACE_TEXT) {
ED_area_tag_redraw(sa);
+ }
break;
}
}
@@ -219,8 +223,6 @@ static void text_operatortypes(void)
WM_operatortype_append(TEXT_OT_line_break);
WM_operatortype_append(TEXT_OT_insert);
- WM_operatortype_append(TEXT_OT_properties);
-
WM_operatortype_append(TEXT_OT_find);
WM_operatortype_append(TEXT_OT_find_set_selected);
WM_operatortype_append(TEXT_OT_replace);
@@ -271,9 +273,9 @@ static void text_main_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
/* add drop boxes */
lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
@@ -285,7 +287,7 @@ static void text_main_region_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceText *st = CTX_wm_space_text(C);
- //View2D *v2d = &ar->v2d;
+ // View2D *v2d = &ar->v2d;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -392,7 +394,7 @@ static void text_properties_region_init(wmWindowManager *wm, ARegion *ar)
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
}
static void text_properties_region_draw(const bContext *C, ARegion *ar)
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index 10303aeba7c..243642b2e8c 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -56,24 +56,29 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
int tgti, *top;
int mval[2] = {0, 0};
- if (!st || !st->text)
+ if (!st || !st->text) {
return 0;
- if (!texttool_text_is_active(st->text))
+ }
+ if (!texttool_text_is_active(st->text)) {
return 0;
+ }
first = texttool_suggest_first();
last = texttool_suggest_last();
/* sel = texttool_suggest_selected(); */ /* UNUSED */
top = texttool_suggest_top();
- if (!last || !first)
+ if (!last || !first) {
return 0;
+ }
/* Count the visible lines to the cursor */
- for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++)
+ for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) {
;
- if (l < 0)
+ }
+ if (l < 0) {
return 0;
+ }
text_update_character_width(st);
@@ -90,22 +95,27 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
// XXX getmouseco_areawin(mval);
- if (mval[0] < x || x + w < mval[0] || mval[1] < y - h || y < mval[1])
+ if (mval[0] < x || x + w < mval[0] || mval[1] < y - h || y < mval[1]) {
return 0;
+ }
/* Work out which of the items is at the top of the visible list */
- for (i = 0, item = first; i < *top && item->next; i++, item = item->next)
+ for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
;
+ }
/* Work out the target item index in the visible list */
tgti = (y - mval[1] - 4) / st->lheight_dpi;
- if (tgti < 0 || tgti > SUGG_LIST_SIZE)
+ if (tgti < 0 || tgti > SUGG_LIST_SIZE) {
return 1;
+ }
- for (i = tgti; i > 0 && item->next; i--, item = item->next)
+ for (i = tgti; i > 0 && item->next; i--, item = item->next) {
;
- if (item)
+ }
+ if (item) {
texttool_suggest_select(item);
+ }
return 1;
}
@@ -123,10 +133,12 @@ void text_pop_suggest_list(void)
item = item->next;
i++;
}
- if (i > *top + SUGG_LIST_SIZE - 1)
+ if (i > *top + SUGG_LIST_SIZE - 1) {
*top = i - SUGG_LIST_SIZE + 1;
- else if (i < *top)
+ }
+ else if (i < *top) {
*top = i;
+ }
}
/* -------------------------------------------------------------------- */
@@ -179,8 +191,8 @@ static GHash *text_autocomplete_build(Text *text)
}
if ((i_start != i_end) &&
- /* check we're at the beginning of a line or that the previous char is not an identifier
- * this prevents digits from being added */
+ /* Check we're at the beginning of a line or that the previous char is not an
+ * identifier this prevents digits from being added. */
((i_start < 1) ||
!text_check_identifier_unicode(BLI_str_utf8_as_unicode(&linep->line[i_start - 1])))) {
char *str_sub = &linep->line[i_start];
@@ -235,10 +247,12 @@ static void get_suggest_prefix(Text *text, int offset)
int i, len;
const char *line;
- if (!text)
+ if (!text) {
return;
- if (!texttool_text_is_active(text))
+ }
+ if (!texttool_text_is_active(text)) {
return;
+ }
line = text->curl->line;
i = text_find_identifier_start(line, text->curc + offset);
@@ -252,14 +266,17 @@ static void confirm_suggestion(Text *text, TextUndoBuf *utxt)
int i, over = 0;
const char *line;
- if (!text)
+ if (!text) {
return;
- if (!texttool_text_is_active(text))
+ }
+ if (!texttool_text_is_active(text)) {
return;
+ }
sel = texttool_suggest_selected();
- if (!sel)
+ if (!sel) {
return;
+ }
line = text->curl->line;
i = text_find_identifier_start(line, text->curc /* - skipleft */);
@@ -324,17 +341,20 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
(void)text;
if (st->doplugins && texttool_text_is_active(st->text)) {
- if (texttool_suggest_first())
+ if (texttool_suggest_first()) {
tools |= TOOL_SUGG_LIST;
- if (texttool_docs_get())
+ }
+ if (texttool_docs_get()) {
tools |= TOOL_DOCUMENT;
+ }
}
switch (event->type) {
case LEFTMOUSE:
if (event->val == KM_PRESS) {
- if (text_do_suggest_select(st, ar))
+ if (text_do_suggest_select(st, ar)) {
swallow = 1;
+ }
else {
if (tools & TOOL_SUGG_LIST) {
texttool_suggest_clear();
@@ -380,8 +400,9 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
texttool_docs_clear();
doc_scroll = 0;
}
- else
+ else {
draw = swallow = 0;
+ }
retval = OPERATOR_CANCELLED;
}
break;
@@ -510,8 +531,9 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
case UPARROWKEY:
if (event->val == KM_PRESS) {
if (tools & TOOL_DOCUMENT) {
- if (doc_scroll > 0)
+ if (doc_scroll > 0) {
doc_scroll--;
+ }
swallow = 1;
draw = 1;
}
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index dadb86f439b..cdd691fe879 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -107,7 +107,8 @@ static void txt_format_text(SpaceText *st)
{
TextLine *linep;
- if (!st->text) return;
+ if (!st->text)
+ return;
for (linep = st->text->lines.first; linep; linep = linep->next)
txt_format_line(st, linep, 0);
@@ -203,10 +204,12 @@ void wrap_offset(
*offl = *offc = 0;
- if (!st->text)
+ if (!st->text) {
return;
- if (!st->wordwrap)
+ }
+ if (!st->wordwrap) {
return;
+ }
text = st->text;
@@ -218,9 +221,10 @@ void wrap_offset(
/* Line before top */
if (linep == linein) {
- if (lines <= i)
+ if (lines <= i) {
/* no visible part of line */
return;
+ }
}
if (i - lines < 0) {
@@ -249,8 +253,9 @@ void wrap_offset(
ch = linep->line[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
- if (linep == linein && i < cursin)
+ if (linep == linein && i < cursin) {
cursin += chars - 1;
+ }
ch = ' ';
}
else {
@@ -280,14 +285,16 @@ void wrap_offset(
else if (ch == ' ' || ch == '-') {
end = i + 1;
chop = 0;
- if (linep == linein && i >= cursin)
+ if (linep == linein && i >= cursin) {
return;
+ }
}
i += columns;
}
}
- if (linep == linein)
+ if (linep == linein) {
break;
+ }
linep = linep->next;
}
}
@@ -301,10 +308,12 @@ void wrap_offset_in_line(
*offl = *offc = 0;
- if (!st->text)
+ if (!st->text) {
return;
- if (!st->wordwrap)
+ }
+ if (!st->wordwrap) {
return;
+ }
max = wrap_width(st, ar);
@@ -321,12 +330,14 @@ void wrap_offset_in_line(
ch = linein->line[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
- if (i < cursin)
+ if (i < cursin) {
cursin += chars - 1;
+ }
ch = ' ';
}
- else
+ else {
chars = 1;
+ }
while (chars--) {
if (i + columns - start > max) {
@@ -351,8 +362,9 @@ void wrap_offset_in_line(
else if (ch == ' ' || ch == '-') {
end = i + 1;
chop = 0;
- if (i >= cursin)
+ if (i >= cursin) {
return;
+ }
}
i += columns;
}
@@ -364,10 +376,12 @@ int text_get_char_pos(const SpaceText *st, const char *line, int cur)
int a = 0, i;
for (i = 0; i < cur && line[i]; i += BLI_str_utf8_size_safe(line + i)) {
- if (line[i] == '\t')
+ if (line[i] == '\t') {
a += st->tabnumber - a % st->tabnumber;
- else
+ }
+ else {
a += BLI_str_utf8_char_width_safe(line + i);
+ }
}
return a;
}
@@ -378,15 +392,18 @@ static const char *txt_utf8_forward_columns(const char *str, int columns, int *p
const char *p = str;
while (*p) {
col = BLI_str_utf8_char_width(p);
- if (columns - col < 0)
+ if (columns - col < 0) {
break;
+ }
columns -= col;
p += BLI_str_utf8_size_safe(p);
- if (columns == 0)
+ if (columns == 0) {
break;
+ }
}
- if (padding)
+ if (padding) {
*padding = *p ? columns : 0;
+ }
return p;
}
@@ -413,8 +430,9 @@ static int text_draw_wrapped(const SpaceText *st,
flatten_string(st, &fs, str);
str = fs.buf;
max = w / st->cwidth;
- if (max < 8)
+ if (max < 8) {
max = 8;
+ }
basex = x;
lines = 1;
@@ -443,8 +461,9 @@ static int text_draw_wrapped(const SpaceText *st,
/* Draw the visible portion of text on the overshot line */
for (a = fstart, ma = mstart; ma < mend; a++, ma += BLI_str_utf8_size_safe(str + ma)) {
if (use_syntax) {
- if (fmt_prev != format[a])
+ if (fmt_prev != format[a]) {
format_draw_color(tdc, fmt_prev = format[a]);
+ }
}
x += text_font_draw_character_utf8(tdc, x, y, str + ma);
fpos++;
@@ -457,8 +476,9 @@ static int text_draw_wrapped(const SpaceText *st,
mend = txt_utf8_forward_columns(str + mend, max, &padding) - str;
end = (wrap += max - padding);
- if (y <= clip_min_y)
+ if (y <= clip_min_y) {
break;
+ }
}
else if (str[mi] == ' ' || str[mi] == '-') {
wrap = i + 1;
@@ -470,8 +490,9 @@ static int text_draw_wrapped(const SpaceText *st,
for (a = fstart, ma = mstart; str[ma] && y > clip_min_y;
a++, ma += BLI_str_utf8_size_safe(str + ma)) {
if (use_syntax) {
- if (fmt_prev != format[a])
+ if (fmt_prev != format[a]) {
format_draw_color(tdc, fmt_prev = format[a]);
+ }
}
x += text_font_draw_character_utf8(tdc, x, y, str + ma);
@@ -505,12 +526,14 @@ static void text_draw(const SpaceText *st,
padding = w - cshift;
in = str;
}
- else if (format)
+ else if (format) {
format++;
+ }
}
if (in) {
- if (maxwidth && w + columns > cshift + maxwidth)
+ if (maxwidth && w + columns > cshift + maxwidth) {
break;
+ }
amount++;
}
@@ -529,8 +552,9 @@ static void text_draw(const SpaceText *st,
char fmt_prev = 0xff;
for (a = 0; a < amount; a++) {
- if (format[a] != fmt_prev)
+ if (format[a] != fmt_prev) {
format_draw_color(tdc, fmt_prev = format[a]);
+ }
x += text_font_draw_character_utf8(tdc, x, y, in + str_shift);
str_shift += BLI_str_utf8_size_safe(in + str_shift);
}
@@ -576,8 +600,9 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
int full_update = 0, nlines = 0;
Text *txt = st->text;
- if (!st->drawcache)
+ if (!st->drawcache) {
text_drawcache_init(st);
+ }
text_update_character_width(st);
@@ -617,10 +642,12 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
nlines = BLI_listbase_count(&txt->lines);
size = sizeof(int) * nlines;
- if (fp)
+ if (fp) {
fp = MEM_reallocN(fp, size);
- else
+ }
+ else {
fp = MEM_callocN(size, "text drawcache line_height");
+ }
drawcache->valid_tail = drawcache->valid_head = 0;
old_tail = fp + drawcache->nlines - drawcache->valid_tail;
@@ -629,8 +656,9 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
drawcache->total_lines = 0;
- if (st->showlinenrs)
+ if (st->showlinenrs) {
st->linenrs_tot = integer_digits_i(nlines);
+ }
while (line) {
if (drawcache->valid_head) { /* we're inside valid head lines */
@@ -663,8 +691,9 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
if (full_update || drawcache->update_flag) {
nlines = BLI_listbase_count(&txt->lines);
- if (st->showlinenrs)
+ if (st->showlinenrs) {
st->linenrs_tot = integer_digits_i(nlines);
+ }
}
drawcache->total_lines = nlines;
@@ -691,8 +720,9 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
void text_drawcache_tag_update(SpaceText *st, int full)
{
/* this happens if text editor ops are caled from python */
- if (st == NULL)
+ if (st == NULL) {
return;
+ }
if (st->drawcache) {
DrawCache *drawcache = (DrawCache *)st->drawcache;
@@ -720,10 +750,12 @@ void text_drawcache_tag_update(SpaceText *st, int full)
/* quick cache recalculation is also used in delete operator,
* which could merge lines which are adjacent to current selection lines
* expand recalculate area to this lines */
- if (drawcache->valid_head > 0)
+ if (drawcache->valid_head > 0) {
drawcache->valid_head--;
- if (drawcache->valid_tail > 0)
+ }
+ if (drawcache->valid_tail > 0) {
drawcache->valid_tail--;
+ }
}
else {
drawcache->valid_head = 0;
@@ -739,8 +771,9 @@ void text_free_caches(SpaceText *st)
DrawCache *drawcache = (DrawCache *)st->drawcache;
if (drawcache) {
- if (drawcache->line_height)
+ if (drawcache->line_height) {
MEM_freeN(drawcache->line_height);
+ }
MEM_freeN(drawcache);
}
@@ -803,8 +836,9 @@ int text_get_span_wrap(const SpaceText *st, ARegion *ar, TextLine *from, TextLin
/* Look forwards */
while (tmp) {
- if (tmp == to)
+ if (tmp == to) {
return ret;
+ }
ret += text_get_visible_lines(st, ar, tmp->line);
tmp = tmp->next;
}
@@ -875,8 +909,9 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
CLAMP(st->txtbar.ymax, pix_bottom_margin, ar->winy - pix_top_margin);
st->pix_per_line = (pix_available > 0) ? (float)ltexth / pix_available : 0;
- if (st->pix_per_line < 0.1f)
+ if (st->pix_per_line < 0.1f) {
st->pix_per_line = 0.1f;
+ }
curl_off = text_get_span_wrap(st, ar, st->text->lines.first, st->text->curl);
sell_off = text_get_span_wrap(st, ar, st->text->lines.first, st->text->sell);
@@ -989,18 +1024,23 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
int i, br, lines;
int boxw, boxh, l, x, y /* , top */ /* UNUSED */;
- if (!st || !st->text) return;
- if (!texttool_text_is_active(st->text)) return;
+ if (!st || !st->text)
+ return;
+ if (!texttool_text_is_active(st->text))
+ return;
docs = texttool_docs_get();
- if (!docs) return;
+ if (!docs)
+ return;
text_draw_context_init(st, &tdc);
/* Count the visible lines to the cursor */
- for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) ;
- if (l < 0) return;
+ for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++)
+ ;
+ if (l < 0)
+ return;
if (st->showlinenrs) {
x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET + TEXTXLOC - 4;
@@ -1017,7 +1057,8 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
boxh = (DOC_HEIGHT + 1) * (st->lheight_dpi + TXT_LINE_SPACING);
/* Draw panel */
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_BACK);
@@ -1044,9 +1085,12 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
UI_FontThemeColor(tdc.font_id, TH_TEXT);
- i = 0; br = DOC_WIDTH; lines = 0; // XXX -doc_scroll;
+ i = 0;
+ br = DOC_WIDTH;
+ lines = 0; // XXX -doc_scroll;
for (p = docs; *p; p++) {
- if (*p == '\r' && *(++p) != '\n') *(--p) = '\n'; /* Fix line endings */
+ if (*p == '\r' && *(++p) != '\n')
+ *(--p) = '\n'; /* Fix line endings */
if (*p == ' ' || *p == '\t')
br = i;
else if (*p == '\n') {
@@ -1055,7 +1099,9 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
y -= st->lheight_dpi;
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, NULL);
}
- i = 0; br = DOC_WIDTH; lines++;
+ i = 0;
+ br = DOC_WIDTH;
+ lines++;
}
buf[i++] = *p;
if (i == DOC_WIDTH) { /* Reached the width, go to last break and wrap there */
@@ -1065,9 +1111,12 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, NULL);
}
p -= i - br - 1; /* Rewind pointer to last break */
- i = 0; br = DOC_WIDTH; lines++;
+ i = 0;
+ br = DOC_WIDTH;
+ lines++;
}
- if (lines >= DOC_HEIGHT) break;
+ if (lines >= DOC_HEIGHT)
+ break;
}
}
#endif
@@ -1083,16 +1132,19 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
const int lheight = st->lheight_dpi + TXT_LINE_SPACING;
const int margin_x = 2;
- if (!st->text)
+ if (!st->text) {
return;
- if (!texttool_text_is_active(st->text))
+ }
+ if (!texttool_text_is_active(st->text)) {
return;
+ }
first = texttool_suggest_first();
last = texttool_suggest_last();
- if (!first || !last)
+ if (!first || !last) {
return;
+ }
text_pop_suggest_list();
sel = texttool_suggest_selected();
@@ -1114,8 +1166,9 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
boxw = SUGG_LIST_WIDTH * st->cwidth + 20;
boxh = SUGG_LIST_SIZE * lheight + 8;
- if (x + boxw > ar->winx)
+ if (x + boxw > ar->winx) {
x = MAX2(0, ar->winx - boxw);
+ }
/* not needed but stands out nicer */
UI_draw_box_shadow(220, x, y - boxh, x + boxw, y);
@@ -1132,8 +1185,9 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
immUnbindProgram();
/* Set the top 'item' of the visible list */
- for (i = 0, item = first; i < *top && item->next; i++, item = item->next)
+ for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
;
+ }
for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) {
int len = txt_utf8_forward_columns(item->name, SUGG_LIST_WIDTH, NULL) - item->name;
@@ -1158,8 +1212,9 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
format_draw_color(tdc, item->type);
text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, NULL);
- if (item == last)
+ if (item == last) {
break;
+ }
}
}
@@ -1292,8 +1347,9 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
y += TXT_LINE_SPACING;
w = st->cwidth;
- if (ch == '\t')
+ if (ch == '\t') {
w *= st->tabnumber - (vselc + st->left) % st->tabnumber;
+ }
immRecti(pos, x, y - lheight - 1, x + w, y - lheight + 1);
}
@@ -1317,16 +1373,19 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
char ch;
// showsyntax must be on or else the format string will be null
- if (!text->curl || !st->showsyntax)
+ if (!text->curl || !st->showsyntax) {
return;
+ }
startl = text->curl;
startc = text->curc;
b = text_check_bracket(startl->line[startc]);
- if (b == 0 && startc > 0)
+ if (b == 0 && startc > 0) {
b = text_check_bracket(startl->line[--startc]);
- if (b == 0)
+ }
+ if (b == 0) {
return;
+ }
linep = startl;
c = startc;
@@ -1338,8 +1397,9 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
/* Don't highlight backets if syntax HL is off or bracket in string or comment. */
if (!linep->format || linep->format[fc] == FMT_TYPE_STRING ||
- linep->format[fc] == FMT_TYPE_COMMENT)
+ linep->format[fc] == FMT_TYPE_COMMENT) {
return;
+ }
if (b > 0) {
/* opening bracket, search forward for close */
@@ -1365,8 +1425,9 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
fc++;
c += BLI_str_utf8_size_safe(linep->line + c);
}
- if (endl)
+ if (endl) {
break;
+ }
linep = linep->next;
c = 0;
fc = 0;
@@ -1375,8 +1436,9 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
else {
/* closing bracket, search backward for open */
fc--;
- if (c > 0)
+ if (c > 0) {
c -= linep->line + c - BLI_str_prev_char_utf8(linep->line + c);
+ }
while (linep) {
while (fc >= 0) {
if (linep->format && linep->format[fc] != FMT_TYPE_STRING &&
@@ -1395,27 +1457,34 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
}
}
fc--;
- if (c > 0)
+ if (c > 0) {
c -= linep->line + c - BLI_str_prev_char_utf8(linep->line + c);
+ }
}
- if (endl)
+ if (endl) {
break;
+ }
linep = linep->prev;
if (linep) {
- if (linep->format)
+ if (linep->format) {
fc = strlen(linep->format) - 1;
- else
+ }
+ else {
fc = -1;
- if (linep->len)
+ }
+ if (linep->len) {
c = BLI_str_prev_char_utf8(linep->line + linep->len) - linep->line;
- else
+ }
+ else {
fc = -1;
+ }
}
}
}
- if (!endl || endc == -1)
+ if (!endl || endc == -1) {
return;
+ }
UI_FontThemeColor(tdc->font_id, TH_HILITE);
x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
@@ -1465,8 +1534,9 @@ void draw_text_main(SpaceText *st, ARegion *ar)
int margin_column_x;
/* if no text, nothing to do */
- if (!text)
+ if (!text) {
return;
+ }
/* dpi controlled line height and font size */
st->lheight_dpi = (U.widget_unit * st->lheight) / 20;
@@ -1483,8 +1553,9 @@ void draw_text_main(SpaceText *st, ARegion *ar)
text_update_drawcache(st, ar);
/* make sure all the positional pointers exist */
- if (!text->curl || !text->sell || !text->lines.first || !text->lines.last)
+ if (!text->curl || !text->sell || !text->lines.first || !text->lines.last) {
txt_clean_text(text);
+ }
/* update rects for scroll */
calc_text_rcts(st, ar, &scroll, &back); /* scroll will hold the entire bar size */
@@ -1494,8 +1565,9 @@ void draw_text_main(SpaceText *st, ARegion *ar)
tmp = text->lines.first;
lineno = 0;
for (i = 0; i < st->top && tmp; i++) {
- if (st->showsyntax && !tmp->format)
+ if (st->showsyntax && !tmp->format) {
tft->format_line(st, tmp, false);
+ }
if (st->wordwrap) {
int lines = text_get_visible_lines_no(st, lineno);
@@ -1548,8 +1620,9 @@ void draw_text_main(SpaceText *st, ARegion *ar)
UI_FontThemeColor(tdc.font_id, TH_TEXT);
for (i = 0; y > clip_min_y && i < st->viewlines && tmp; i++, tmp = tmp->next) {
- if (st->showsyntax && !tmp->format)
+ if (st->showsyntax && !tmp->format) {
tft->format_line(st, tmp, false);
+ }
if (st->showlinenrs && !wrap_skip) {
/* draw line number */
@@ -1639,8 +1712,9 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center)
Text *text;
int i, x, winx = ar->winx;
- if (ELEM(NULL, st, st->text, st->text->curl))
+ if (ELEM(NULL, st, st->text, st->text->curl)) {
return;
+ }
text = st->text;
@@ -1689,10 +1763,12 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center)
}
}
- if (st->top < 0)
+ if (st->top < 0) {
st->top = 0;
- if (st->left < 0)
+ }
+ if (st->left < 0) {
st->left = 0;
+ }
st->scroll_accum[0] = 0.0f;
st->scroll_accum[1] = 0.0f;
@@ -1703,8 +1779,9 @@ void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center)
{
ARegion *ar;
- if (ELEM(NULL, st, st->text, st->text->curl))
+ if (ELEM(NULL, st, st->text, st->text->curl)) {
return;
+ }
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c
index 0a885fc5875..8c102dc009e 100644
--- a/source/blender/editors/space_text/text_format.c
+++ b/source/blender/editors/space_text/text_format.c
@@ -79,8 +79,9 @@ int flatten_string(const SpaceText *st, FlattenString *fs, const char *in)
i = st->tabnumber - (total % st->tabnumber);
total += i;
- while (i--)
+ while (i--) {
flatten_string_append(fs, " ", r, 1);
+ }
in++;
}
@@ -99,10 +100,12 @@ int flatten_string(const SpaceText *st, FlattenString *fs, const char *in)
void flatten_string_free(FlattenString *fs)
{
- if (fs->buf != fs->fixedbuf)
+ if (fs->buf != fs->fixedbuf) {
MEM_freeN(fs->buf);
- if (fs->accum != fs->fixedaccum)
+ }
+ if (fs->accum != fs->fixedaccum) {
MEM_freeN(fs->accum);
+ }
}
/* takes a string within fs->buf and returns its length */
@@ -121,14 +124,16 @@ int text_check_format_len(TextLine *line, unsigned int len)
if (strlen(line->format) < len) {
MEM_freeN(line->format);
line->format = MEM_mallocN(len + 2, "SyntaxFormat");
- if (!line->format)
+ if (!line->format) {
return 0;
+ }
}
}
else {
line->format = MEM_mallocN(len + 2, "SyntaxFormat");
- if (!line->format)
+ if (!line->format) {
return 0;
+ }
}
return 1;
diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c
index b82e8aec122..347d46a4234 100644
--- a/source/blender/editors/space_text/text_format_lua.c
+++ b/source/blender/editors/space_text/text_format_lua.c
@@ -48,31 +48,33 @@ static int txtfmt_lua_find_keyword(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "and", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "do", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "function", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "in", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "not", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "or", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "then", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "until", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "and", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "do", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "end", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "function", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "in", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "local", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "not", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "or", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "then", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "until", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -94,41 +96,43 @@ static int txtfmt_lua_find_specialvar(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "assert", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "collectgarbage", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dofile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "_G", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "getfenv", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "getmetatable", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "__index", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ipairs", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "load", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "loadfile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "loadstring", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "next", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pairs", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pcall", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "print", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rawequal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rawget", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rawset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "select", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "setfenv", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "setmetatable", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tonumber", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tostring", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "unpack", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "_VERSION", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "xpcall", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "collectgarbage", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dofile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "error", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "_G", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "getfenv", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "getmetatable", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "__index", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ipairs", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "load", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "loadfile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "loadstring", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "next", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pairs", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pcall", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "print", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rawequal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rawget", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rawset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "select", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "setfenv", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "setmetatable", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tonumber", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tostring", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "unpack", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "_VERSION", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "xpcall", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -136,20 +140,25 @@ static int txtfmt_lua_find_bool(const char *string)
{
int i, len;
- if (STR_LITERAL_STARTSWITH(string, "nil", len))
+ if (STR_LITERAL_STARTSWITH(string, "nil", len)) {
i = len;
- else if (STR_LITERAL_STARTSWITH(string, "true", len))
+ }
+ else if (STR_LITERAL_STARTSWITH(string, "true", len)) {
i = len;
- else if (STR_LITERAL_STARTSWITH(string, "false", len))
+ }
+ else if (STR_LITERAL_STARTSWITH(string, "false", len)) {
i = len;
- else
+ }
+ else {
i = 0;
+ }
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -160,9 +169,10 @@ static char txtfmt_lua_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
- if ((txtfmt_lua_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL;
- else if ((txtfmt_lua_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD;
- else fmt = FMT_TYPE_DEFAULT;
+ if ((txtfmt_lua_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
+ } else if ((txtfmt_lua_find_keyword(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
+ } else { fmt = FMT_TYPE_DEFAULT;
+}
/* clang-format on */
@@ -211,8 +221,9 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -236,8 +247,9 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = 0;
+ }
*fmt = FMT_TYPE_STRING;
}
@@ -304,8 +316,9 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_osl_format_identifier()' */
- if ((i = txtfmt_lua_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL;
- else if ((i = txtfmt_lua_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD;
+ if ((i = txtfmt_lua_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
+ } else if ((i = txtfmt_lua_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c
index 8473b3f80ce..fb9ddcb09cb 100644
--- a/source/blender/editors/space_text/text_format_osl.c
+++ b/source/blender/editors/space_text/text_format_osl.c
@@ -40,37 +40,39 @@ static int txtfmt_osl_find_builtinfunc(const char *string)
/* list is from
* https://github.com/imageworks/OpenShadingLanguage/raw/master/src/doc/osl-languagespec.pdf
*/
- if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "closure", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "continue", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "do", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "emit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "float", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "illuminance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "illuminate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "int", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "output", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "point", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "public", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "string", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "struct", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vector", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "void", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "closure", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "continue", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "do", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "emit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "float", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "illuminance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "illuminate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "int", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "output", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "point", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "public", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "string", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "struct", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vector", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "void", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -84,49 +86,51 @@ static int txtfmt_osl_find_reserved(const char *string)
/* list is from...
* https://github.com/imageworks/OpenShadingLanguage/raw/master/src/doc/osl-languagespec.pdf
*/
- if (STR_LITERAL_STARTSWITH(string, "bool", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "catch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "char", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "const", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "delete", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "double", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "enum", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "extern", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "friend", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "goto", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "long", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "new", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "operator", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "private", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "protected", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "short", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "signed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sizeof", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "static", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "template", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "this", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "throw", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "try", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "typedef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uniform", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "union", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "unsigned", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "varying", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "virtual", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "volatile", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "bool", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "case", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "catch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "char", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "const", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "delete", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "default", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "double", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "enum", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "extern", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "friend", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "goto", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "long", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "new", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "operator", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "private", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "protected", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "short", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "signed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sizeof", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "static", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "switch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "template", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "this", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "throw", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "true", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "try", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "typedef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uniform", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "union", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "unsigned", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "varying", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "virtual", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "volatile", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -145,17 +149,19 @@ static int txtfmt_osl_find_specialvar(const char *string)
/* clang-format off */
/* OSL shader types */
- if (STR_LITERAL_STARTSWITH(string, "shader", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "surface", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "volume", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "displacement", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "shader", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "surface", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "volume", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "displacement", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -183,11 +189,12 @@ static char txtfmt_osl_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
- if ((txtfmt_osl_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL;
- else if ((txtfmt_osl_find_builtinfunc(str)) != -1) fmt = FMT_TYPE_KEYWORD;
- else if ((txtfmt_osl_find_reserved(str)) != -1) fmt = FMT_TYPE_RESERVED;
- else if ((txtfmt_osl_find_preprocessor(str)) != -1) fmt = FMT_TYPE_DIRECTIVE;
- else fmt = FMT_TYPE_DEFAULT;
+ if ((txtfmt_osl_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
+ } else if ((txtfmt_osl_find_builtinfunc(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
+ } else if ((txtfmt_osl_find_reserved(str)) != -1) { fmt = FMT_TYPE_RESERVED;
+ } else if ((txtfmt_osl_find_preprocessor(str)) != -1) { fmt = FMT_TYPE_DIRECTIVE;
+ } else { fmt = FMT_TYPE_DEFAULT;
+}
/* clang-format on */
@@ -236,8 +243,9 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -261,8 +269,9 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = 0;
+ }
*fmt = FMT_TYPE_STRING;
}
@@ -314,10 +323,11 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_osl_format_identifier()' */
- if ((i = txtfmt_osl_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL;
- else if ((i = txtfmt_osl_find_builtinfunc(str)) != -1) prev = FMT_TYPE_KEYWORD;
- else if ((i = txtfmt_osl_find_reserved(str)) != -1) prev = FMT_TYPE_RESERVED;
- else if ((i = txtfmt_osl_find_preprocessor(str)) != -1) prev = FMT_TYPE_DIRECTIVE;
+ if ((i = txtfmt_osl_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
+ } else if ((i = txtfmt_osl_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+ } else if ((i = txtfmt_osl_find_reserved(str)) != -1) { prev = FMT_TYPE_RESERVED;
+ } else if ((i = txtfmt_osl_find_preprocessor(str)) != -1) { prev = FMT_TYPE_DIRECTIVE;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c
index 8064f4e69e2..a5e1a3845cf 100644
--- a/source/blender/editors/space_text/text_format_pov.c
+++ b/source/blender/editors/space_text/text_format_pov.c
@@ -48,39 +48,40 @@ static int txtfmt_pov_find_keyword(const char *string)
int i, len;
/* Language Directives */
- if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "persistent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "patch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "range", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "render", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "undef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "write", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "persistent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "version", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "warning", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "declare", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "default", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "include", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "append", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "debug", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "error", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "patch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "local", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "macro", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "range", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "read", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "render", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "switch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "undef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "write", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "case", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "end", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
@@ -100,145 +101,146 @@ static int txtfmt_pov_find_reserved_keywords(const char *string)
/* clang-format off */
/* Float Functions */
- if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bitwise_or", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bitwise_xor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "file_exists", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "precompute", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dimensions", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clipped_by", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "shadowless", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "turb_depth", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "reciprocal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quaternion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "phong_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tesselate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "save_file", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "load_file", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "transform", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "translate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "direction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "roughness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "metallic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gts_load", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gts_save", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "location", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "altitude", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "function", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "evaluate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inverse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "collect", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "target", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "albedo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rotate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "jitter", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "right", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "scale", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "child", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "crand", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blink", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "defined", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "degrees", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inside", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radians", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vlength", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "select", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "floor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strcmp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strlen", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tessel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sturm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "abs", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "acosh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "prod", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "with", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "acos", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "asc", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "asinh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "asin", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atan2", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atand", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atanh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atan", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ceil", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "warp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cosh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "log", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "min", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mod", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rand", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "seed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "form", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sinh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sqrt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tanh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vdot", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sin", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sum", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pwr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tan", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "val", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cos", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "div", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "int", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sky", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "up", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ln", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bitwise_or", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bitwise_xor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "file_exists", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "precompute", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dimensions", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clipped_by", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "shadowless", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "turb_depth", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "reciprocal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quaternion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "phong_size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tesselate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "save_file", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "load_file", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "transform", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "translate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "direction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "roughness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "metallic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gts_load", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gts_save", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "location", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "altitude", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "function", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "evaluate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inverse", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "collect", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "target", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "albedo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rotate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "jitter", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "angle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "right", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "scale", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "child", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "crand", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "blink", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "defined", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "degrees", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inside", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "radians", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vlength", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "select", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "floor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strcmp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strlen", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tessel", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sturm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "abs", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "acosh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "prod", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "with", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "acos", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "asc", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "asinh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "asin", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "atan2", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "atand", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "atanh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "atan", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ceil", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "warp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cosh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "log", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "min", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mod", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pow", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rand", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "seed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "form", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sinh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sqrt", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tanh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vdot", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sin", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sum", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pwr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tan", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "val", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cos", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "div", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "int", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sky", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "up", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ln", len)) { i = len;
/* Color Identifiers */
- else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "filter", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgbft", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgbt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgbft", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "green", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blue", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gray", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgb", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sRGB", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SRGB", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgbt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "red", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "filter", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "srgbft", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "srgbt", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rgbft", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "green", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "blue", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gray", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "srgb", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sRGB", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SRGB", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rgbt", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "red", len)) { i = len;
/* Color Spaces */
- else if (STR_LITERAL_STARTSWITH(string, "pov", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hsl", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hsv", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "xyl", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "xyv", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pov", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hsl", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hsv", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "xyl", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "xyv", len)) { i = len;
/* Vector Functions */
- else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "trace", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "trace", len)) { i = len;
/* String Functions */
- else if (STR_LITERAL_STARTSWITH(string, "file_time", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "concat", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "substr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "chr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "str", len)) i = len;
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "file_time", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "concat", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "substr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "chr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "str", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
@@ -259,221 +261,222 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
/* clang-format off */
/* Language Keywords */
- if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "smooth_triangle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lommel_seeliger", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "falloff_angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aa_threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hypercomplex", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "major_radius", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_distance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_iteration", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "colour_space", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "color_space", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "iridescence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "subsurface", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "scattering", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "absorption", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "water_level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "oren_nayar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "refraction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hierarchy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radiosity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tolerance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interior", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "toroidal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "emission", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "material", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "internal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "photons", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "arc_angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "minnaert", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "texture", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "array", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "black_hole", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "component", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "composite", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "coords", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cube", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dist_exp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exterior", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "file_gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "flatness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "planet", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "screw", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "keep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "flip", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "move", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "roll", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "metric", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "offset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "orientation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pattern", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "precision", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bend", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "alpha", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "slice", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "smooth", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "solid", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "all", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "now", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pot", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "type", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "smooth_triangle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lommel_seeliger", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "falloff_angle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aa_threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hypercomplex", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "major_radius", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_distance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_iteration", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "colour_space", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "color_space", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "iridescence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "subsurface", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "scattering", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "absorption", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "water_level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "oren_nayar", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "refraction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hierarchy", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "radiosity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tolerance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "interior", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "toroidal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "emission", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "material", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "internal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "photons", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "arc_angle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "minnaert", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "texture", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "array", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "black_hole", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "component", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "composite", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "coords", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cube", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dist_exp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exterior", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "file_gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "flatness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "planet", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "screw", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "keep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "flip", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "move", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "roll", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "metric", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "offset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "orientation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pattern", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "precision", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bend", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "alpha", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "slice", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "smooth", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "solid", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "all", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "now", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pot", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "type", len)) { i = len;
/* Animation Options */
- else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock", len)) { i = len;
/* Spline Identifiers */
- else if (STR_LITERAL_STARTSWITH(string, "extended_x_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "general_x_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quadratic_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "basic_x_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "natural_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "linear_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bezier_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "akima_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sor_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tcb_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "extended_x_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "general_x_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quadratic_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "basic_x_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "natural_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "linear_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bezier_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "akima_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sor_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tcb_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) { i = len;
/* Patterns */
- else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "density_file", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cylindrical", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "proportion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "triangular", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "proximity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spherical", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bump_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "wrinkles", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "average", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "voronoi", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "masonry", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "binary", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "boxed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bozo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brick", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bumps", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cells", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "checker", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "crackle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dents", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "facets", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gradient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "granite", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hexagon", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "julia", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "leopard", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "magnet", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mandel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "marble", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "onion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pavement", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "planar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quilted", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radial", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ripples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "slope", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spiral1", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spiral2", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spotted", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "square", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tile2", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tiling", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tiles", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "waves", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "wood", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "agate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "density_file", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cylindrical", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "proportion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "triangular", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "proximity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spherical", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bump_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "wrinkles", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "average", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "voronoi", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "masonry", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "binary", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "boxed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bozo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "brick", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bumps", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cells", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "checker", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "crackle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dents", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "facets", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gradient", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "granite", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hexagon", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "julia", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "leopard", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "magnet", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mandel", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "marble", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "onion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pavement", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "planar", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quilted", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "radial", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ripples", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "slope", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spiral1", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spiral2", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spotted", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "square", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tile2", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tiling", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tiles", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "waves", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "wood", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "agate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) { i = len;
/* Objects */
- else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bicubic_patch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "julia_fractal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "height_field", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sphere_sweep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "light_group", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "light_source", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "intersection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "isosurface", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "background", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sky_sphere", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cylinder", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "difference", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brilliance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "parametric", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interunion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "intermerge", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "polynomial", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "displace", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "specular", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "diffuse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "polygon", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quadric", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quartic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rainbow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "prism", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "galley", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "phong", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cone", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blob", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "box", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "disc", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lathe", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "merge", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mesh2", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mesh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "object", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ovus", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lemon", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "plane", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "poly", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "irid", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "text", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "torus", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "triangle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "union", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "media", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bicubic_patch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "julia_fractal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "height_field", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sphere_sweep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "light_group", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "light_source", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "intersection", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "isosurface", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "background", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sky_sphere", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cylinder", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "difference", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "brilliance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "parametric", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "interunion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "intermerge", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "polynomial", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "displace", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "specular", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "diffuse", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "polygon", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quadric", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quartic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rainbow", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "prism", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "galley", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "phong", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cone", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "blob", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "box", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "disc", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fog", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lathe", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "merge", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mesh2", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mesh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "object", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ovus", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lemon", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "plane", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "poly", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "irid", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "text", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "torus", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "triangle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "union", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "colour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "media", len)) { i = len;
/* Built-in Vectors */
- else if (STR_LITERAL_STARTSWITH(string, "t", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "u", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "v", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "x", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "y", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "z", len)) i = len;
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "t", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "u", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "v", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "x", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "y", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "z", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format off */
@@ -497,202 +500,203 @@ static int txtfmt_pov_find_specialvar(const char *string)
{
int i, len;
/* Modifiers */
- if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "double_illuminate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "expand_thresholds", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "media_interaction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "media_attenuation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "low_error_factor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "recursion_limit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interior_texture", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_trace_level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gray_threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pretrace_start", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal_indices", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal_vectors", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vertex_vectors", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "noise_generator", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "irid_wavelength", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "number_of_waves", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ambient_light", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inside_vector", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "face_indices", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "texture_list", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_gradient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uv_indices", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uv_vectors", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_distance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "global_lights", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_bump_scale", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pretrace_end", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_radiosity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_reflection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "assumed_gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "scallop_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "triangle_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "nearest_count", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "maximum_reuse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "minimum_reuse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "always_sample", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "translucency", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "eccentricity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "contained_by", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inside_point", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "adc_bailout", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "density_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "split_union", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mm_per_unit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "agate_turb", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bounded_by", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brick_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hf_gray_16", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "extinction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "thickness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "color_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "colour_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pigment_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quick_color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quick_colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "material_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pass_through", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interpolate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "texture_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "error_bound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brightness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "use_color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "use_alpha", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "use_colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "use_index", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uv_mapping", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "importance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_sample", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "intervals", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sine_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "slope_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "poly_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_shadow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ramp_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "precision", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "original", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "map_type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_image", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "distance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog_offset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "modulation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "outbound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_cache", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "charset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inbound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "outside", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inner", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "turbulence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "polarity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bump_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "circular", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "control0", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "control1", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "maximal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "minimal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog_type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog_alt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "samples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "origin", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "amount", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "adaptive", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exponent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strength", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "density", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fresnel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "albinos", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "finish", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "method", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "omega", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fixed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spacing", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "u_steps", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "v_steps", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "offset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hollow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gather", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mortar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "count", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "once", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "orient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "phase", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "open", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ior", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "double_illuminate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "expand_thresholds", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "media_interaction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "media_attenuation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "low_error_factor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "recursion_limit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "interior_texture", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_trace_level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gray_threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pretrace_start", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal_indices", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal_vectors", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vertex_vectors", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "noise_generator", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "irid_wavelength", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "number_of_waves", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ambient_light", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inside_vector", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "face_indices", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "texture_list", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_gradient", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uv_indices", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uv_vectors", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_distance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "global_lights", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_bump_scale", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pretrace_end", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_radiosity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_reflection", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "assumed_gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "scallop_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "triangle_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "nearest_count", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "maximum_reuse", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "minimum_reuse", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "always_sample", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "translucency", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "eccentricity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "contained_by", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inside_point", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "adc_bailout", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "density_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "split_union", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mm_per_unit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "agate_turb", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bounded_by", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "brick_size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hf_gray_16", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "extinction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "thickness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "color_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "colour_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_colour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pigment_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quick_color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quick_colour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "material_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pass_through", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "interpolate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "texture_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "error_bound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "brightness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "use_color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "use_alpha", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "use_colour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "use_index", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uv_mapping", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "importance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_sample", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "intervals", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sine_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "slope_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "poly_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_shadow", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ramp_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "precision", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "original", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "map_type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_image", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "distance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fog_offset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "modulation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "outbound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_cache", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "charset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inbound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "outside", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inner", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "turbulence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "polarity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bump_size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "circular", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "control0", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "control1", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "maximal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "minimal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fog_type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fog_alt", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "samples", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "origin", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "amount", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "adaptive", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exponent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strength", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "density", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fresnel", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "albinos", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "finish", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "method", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "omega", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fixed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spacing", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "u_steps", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "v_steps", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "offset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hollow", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gather", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mortar", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "count", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "once", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "orient", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "phase", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "open", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ior", len)) { i = len;
/* Light Types and options*/
- else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tightness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spotlight", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "parallel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radius", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tightness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spotlight", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "parallel", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "radius", len)) { i = len;
/* Camera Types and options*/
- else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "miller_cylindrical", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lambert_azimuthal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ultra_wide_angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_direction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_location ", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "van_der_grinten", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aitoff_hammer", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "smyth_craster", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "orthographic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_right", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blur_samples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "plate_carree", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "perspective", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mesh_camera", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "focal_point", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "balthasart", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "confidence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "parallaxe", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hobo_dyer", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_up", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "panoramic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "eckert_vi", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "eckert_iv", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mollweide", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aperture", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "behrmann", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "variance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "stereo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "icosa", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tetra", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "octa", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mercator", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "omnimax", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fisheye", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "edwards", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "peters", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gall", len)) i = len;
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "miller_cylindrical", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lambert_azimuthal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ultra_wide_angle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_direction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_location ", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "van_der_grinten", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aitoff_hammer", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "smyth_craster", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "orthographic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_right", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "blur_samples", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "plate_carree", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "perspective", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mesh_camera", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "focal_point", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "balthasart", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "confidence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "parallaxe", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hobo_dyer", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_up", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "panoramic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "eckert_vi", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "eckert_iv", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mollweide", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aperture", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "behrmann", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "variance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "stereo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "icosa", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tetra", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "octa", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mercator", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "omnimax", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fisheye", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "edwards", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "peters", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gall", len)) { i = len;
+ } else { i = 0;
+}
/* If next source char is an identifier (eg. 'i' in "definite") no match */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
@@ -706,43 +710,44 @@ static int txtfmt_pov_find_bool(const char *string)
/* clang-format off */
/* Built-in Constants */
- if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "off", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "true", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "yes", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "on", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pi", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tau", len)) { i = len;
/* Encodings */
- else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bt2020", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bt709", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bt2020", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bt709", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) { i = len;
/* Filetypes */
- else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "iff", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "png", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sys", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tga", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ttf", len)) i = len;
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "df3", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "iff", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "png", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sys", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tga", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ttf", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
@@ -757,11 +762,12 @@ static char txtfmt_pov_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
- if ((txtfmt_pov_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL;
- else if ((txtfmt_pov_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD;
- else if ((txtfmt_pov_find_reserved_keywords(str)) != -1) fmt = FMT_TYPE_RESERVED;
- else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) fmt = FMT_TYPE_DIRECTIVE;
- else fmt = FMT_TYPE_DEFAULT;
+ if ((txtfmt_pov_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
+ } else if ((txtfmt_pov_find_keyword(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
+ } else if ((txtfmt_pov_find_reserved_keywords(str)) != -1) { fmt = FMT_TYPE_RESERVED;
+ } else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) { fmt = FMT_TYPE_DIRECTIVE;
+ } else { fmt = FMT_TYPE_DEFAULT;
+}
/* clang-format on */
@@ -810,8 +816,9 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -835,8 +842,9 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = 0;
+ }
*fmt = FMT_TYPE_STRING;
}
@@ -897,10 +905,11 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_pov_format_identifier()' */
- if ((i = txtfmt_pov_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL;
- else if ((i = txtfmt_pov_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD;
- else if ((i = txtfmt_pov_find_reserved_keywords(str)) != -1) prev = FMT_TYPE_RESERVED;
- else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) prev = FMT_TYPE_DIRECTIVE;
+ if ((i = txtfmt_pov_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
+ } else if ((i = txtfmt_pov_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+ } else if ((i = txtfmt_pov_find_reserved_keywords(str)) != -1) { prev = FMT_TYPE_RESERVED;
+ } else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) { prev = FMT_TYPE_DIRECTIVE;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c
index 0dbf2b1bdd3..04f4b992cc6 100644
--- a/source/blender/editors/space_text/text_format_pov_ini.c
+++ b/source/blender/editors/space_text/text_format_pov_ini.c
@@ -49,49 +49,50 @@ static int txtfmt_ini_find_keyword(const char *string)
/* clang-format off */
/* Language Directives */
- if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "range", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "render", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "undef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "write", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
-
- else if (STR_LITERAL_STARTSWITH(string, "I", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "S", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "A", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Q", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "U", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "F", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "C", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "N", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "P", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "T", len)) i = len;
-
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "declare", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "default", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "version", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "warning", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "include", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "append", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "debug", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "error", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "local", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "macro", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "range", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "render", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "switch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "undef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "write", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "case", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "read", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "end", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+
+ } else if (STR_LITERAL_STARTSWITH(string, "I", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "S", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "A", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Q", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "U", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "F", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "C", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "N", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "P", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "T", len)) { i = len;
+
+ } else { i = 0;
+}
/* clang-format on */
@@ -110,200 +111,201 @@ static int txtfmt_ini_find_reserved(const char *string)
* list is from...
* http://www.povray.org/documentation/view/3.7.0/212/
*/
- if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "HideWhenMainMinimized", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Confidence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "UseExtensions", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ReadWriteSourceDir", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionLeft", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionTop", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionRight", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionBottom", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionX", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionY", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Subset_Start_Frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Subset_End_Frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "UseToolbar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "UseTooltips", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Frame_Step", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Cyclic_Animation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Field_Render", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Odd_Field", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Start_Column", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Start_Row", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "End_Column", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "End_Row", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Test_Abort_Count", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Test_Abort", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Continue_Trace", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Display", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Version", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pause_When_Done", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Verbose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Preview_Start_Size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Preview_End_Size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Output_to_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Input_File_Name", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Output_File_Name", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Output_File_Type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Output_Alpha", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Bits_Per_Color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Compression", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Dither_Method", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Include_Header", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Library_Path", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Debug_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Render_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Statistic_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Warning_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Warning_Level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "All_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Debug_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Render_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Statistic_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Warning_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "All_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Quality", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Bounding_Threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Bounding", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Light_Buffer", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Vista_Buffer", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Remove_Bounds", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Split_Unions", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Glare_Desaturation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Sampling_Method", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Stochastic_Seed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Jitter_Amount", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Jitter", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "CheckNewVersion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RunCount", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "CommandLine", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "TextColour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "WarningColour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ErrorColour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "BackgroundColour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "DropToEditor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastRenderName", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastRenderPath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastQueuePath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SecondaryINISection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "BetaVersionNo64", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastBitmapName", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastBitmapPath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastINIPath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SecondaryINIFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "BackgroundFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SaveSettingsOnExit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "TileBackground", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "HideNewUserHelp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SendSystemInfo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ItsAboutTime", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastPath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band0Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band1Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band2Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band3Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band4Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ShowCmd", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Transparency", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Use8BitMode", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "MakeActive", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "KeepAboveMain", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "AutoClose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "PreserveBitmap", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "FontSize", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "FontWeight", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "KeepMessages", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "AlertSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Completion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Priority", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "DutyCycle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "AlertOnCompletion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "AutoRender", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "PreventSleep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NoShelloutWait", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SystemNoActive", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NoShellOuts", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "VideoSource", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SceneFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "OutputFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "IniOutputFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "CurrentDirectory", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SourceFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Rendering", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderwinClose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Append_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Warning Level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Height", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Font", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "HideWhenMainMinimized", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Confidence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "UseExtensions", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ReadWriteSourceDir", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionLeft", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionTop", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionRight", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionBottom", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionX", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionY", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Subset_Start_Frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Subset_End_Frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "UseToolbar", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "UseTooltips", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Frame_Step", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Cyclic_Animation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Field_Render", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Odd_Field", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Start_Column", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Start_Row", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "End_Column", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "End_Row", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Test_Abort_Count", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Test_Abort", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Continue_Trace", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Display", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Version", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pause_When_Done", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Verbose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Preview_Start_Size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Preview_End_Size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Output_to_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Input_File_Name", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Output_File_Name", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Output_File_Type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Output_Alpha", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Bits_Per_Color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Compression", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Dither_Method", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Include_Header", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Library_Path", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Debug_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Fatal_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Render_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Statistic_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Warning_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Warning_Level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "All_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Debug_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Fatal_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Render_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Statistic_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Warning_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "All_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Quality", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Bounding_Threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Bounding", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Light_Buffer", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Vista_Buffer", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Remove_Bounds", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Split_Unions", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Glare_Desaturation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Sampling_Method", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Stochastic_Seed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Jitter_Amount", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Jitter", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "CheckNewVersion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RunCount", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "CommandLine", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "TextColour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "WarningColour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ErrorColour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "BackgroundColour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "DropToEditor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastRenderName", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastRenderPath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastQueuePath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SecondaryINISection", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "BetaVersionNo64", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastBitmapName", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastBitmapPath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastINIPath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SecondaryINIFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "BackgroundFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SaveSettingsOnExit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "TileBackground", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "HideNewUserHelp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SendSystemInfo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ItsAboutTime", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastPath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band0Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band1Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band2Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band3Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band4Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ShowCmd", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Transparency", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Use8BitMode", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "MakeActive", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "KeepAboveMain", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "AutoClose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "PreserveBitmap", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "FontSize", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "FontWeight", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "KeepMessages", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "AlertSound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Completion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Priority", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "DutyCycle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "AlertOnCompletion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "AutoRender", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "PreventSleep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NoShelloutWait", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SystemNoActive", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NoShellOuts", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "VideoSource", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SceneFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "OutputFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "IniOutputFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "CurrentDirectory", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SourceFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Rendering", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RenderwinClose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Append_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Warning Level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Height", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Font", len)) { i = len;
/* Filetypes */
- else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "iff", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "png", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sys", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tga", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "df3", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "iff", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "png", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sys", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tga", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) { i = len;
/* Encodings */
- else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) i = len;
-
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) { i = len;
+
+ } else { i = 0;
+}
/* clang-format on */
@@ -319,21 +321,22 @@ static int txtfmt_ini_find_bool(const char *string)
/* clang-format off */
/* Built-in Constants */
- if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%o", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%s", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%n", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%k", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%h", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%w", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "off", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "true", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "yes", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "on", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pi", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tau", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%o", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%s", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%n", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%k", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%h", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%w", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
@@ -344,12 +347,15 @@ static int txtfmt_ini_find_bool(const char *string)
static char txtfmt_pov_ini_format_identifier(const char *str)
{
char fmt;
- if ((txtfmt_ini_find_keyword(str)) != -1)
+ if ((txtfmt_ini_find_keyword(str)) != -1) {
fmt = FMT_TYPE_KEYWORD;
- else if ((txtfmt_ini_find_reserved(str)) != -1)
+ }
+ else if ((txtfmt_ini_find_reserved(str)) != -1) {
fmt = FMT_TYPE_RESERVED;
- else
+ }
+ else {
fmt = FMT_TYPE_DEFAULT;
+ }
return fmt;
}
@@ -395,8 +401,9 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -420,8 +427,9 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = 0;
+ }
*fmt = FMT_TYPE_STRING;
}
@@ -475,8 +483,9 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_ini_format_identifier()' */
- if ((i = txtfmt_ini_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD;
- else if ((i = txtfmt_ini_find_reserved(str)) != -1) prev = FMT_TYPE_RESERVED;
+ if ((i = txtfmt_ini_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+ } else if ((i = txtfmt_ini_find_reserved(str)) != -1) { prev = FMT_TYPE_RESERVED;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c
index 68e42335546..98eeee61c3a 100644
--- a/source/blender/editors/space_text/text_format_py.c
+++ b/source/blender/editors/space_text/text_format_py.c
@@ -58,43 +58,45 @@ static int txtfmt_py_find_builtinfunc(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "and", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "as", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "assert", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "async", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "await", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "continue", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "del", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "elif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "except", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "finally", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "from", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "global", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "import", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "in", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "is", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "nonlocal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "not", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "or", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pass", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "raise", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "try", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "with", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "yield", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "and", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "as", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "async", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "await", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "continue", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "del", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "elif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "except", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "finally", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "from", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "global", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "import", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "in", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "is", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "nonlocal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "not", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "or", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pass", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "raise", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "try", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "with", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "yield", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -112,15 +114,17 @@ static int txtfmt_py_find_specialvar(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "def", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "class", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "def", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "class", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -151,16 +155,18 @@ static int txtfmt_py_find_bool(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "None", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "True", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "False", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "None", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "True", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "False", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -171,10 +177,11 @@ static char txtfmt_py_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
- if ((txtfmt_py_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL;
- else if ((txtfmt_py_find_builtinfunc(str)) != -1) fmt = FMT_TYPE_KEYWORD;
- else if ((txtfmt_py_find_decorator(str)) != -1) fmt = FMT_TYPE_RESERVED;
- else fmt = FMT_TYPE_DEFAULT;
+ if ((txtfmt_py_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
+ } else if ((txtfmt_py_find_builtinfunc(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
+ } else if ((txtfmt_py_find_decorator(str)) != -1) { fmt = FMT_TYPE_RESERVED;
+ } else { fmt = FMT_TYPE_DEFAULT;
+}
/* clang-format on */
return fmt;
@@ -222,8 +229,9 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -247,8 +255,9 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = FMT_CONT_NOP;
+ }
}
*fmt = FMT_TYPE_STRING;
@@ -311,9 +320,10 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_py_format_identifier()' */
- if ((i = txtfmt_py_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL;
- else if ((i = txtfmt_py_find_builtinfunc(str)) != -1) prev = FMT_TYPE_KEYWORD;
- else if ((i = txtfmt_py_find_decorator(str)) != -1) prev = FMT_TYPE_DIRECTIVE;
+ if ((i = txtfmt_py_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
+ } else if ((i = txtfmt_py_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+ } else if ((i = txtfmt_py_find_decorator(str)) != -1) { prev = FMT_TYPE_DIRECTIVE;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index 435a6fd67de..e2d2bb5ed64 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -45,15 +45,17 @@ static ARegion *text_has_properties_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar)
+ if (ar) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "properties region");
@@ -71,29 +73,6 @@ static bool text_properties_poll(bContext *C)
return (CTX_wm_space_text(C) != NULL);
}
-static int text_properties_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = text_has_properties_region(sa);
-
- if (ar)
- ED_region_toggle_hidden(C, ar);
-
- return OPERATOR_FINISHED;
-}
-
-void TEXT_OT_properties(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Toggle Sidebar";
- ot->description = "Toggle the properties region visibility";
- ot->idname = "TEXT_OT_properties";
-
- /* api callbacks */
- ot->exec = text_properties_exec;
- ot->poll = text_properties_poll;
-}
-
static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
@@ -101,8 +80,9 @@ static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
SpaceText *st = CTX_wm_space_text(C);
if (ar) {
- if (ar->flag & RGN_FLAG_HIDDEN)
+ if (ar->flag & RGN_FLAG_HIDDEN) {
ED_region_toggle_hidden(C, ar);
+ }
/* cannot send a button activate yet for case when region wasn't visible yet */
/* flag gets checked and cleared in main draw callback */
@@ -195,13 +175,30 @@ void TEXT_OT_start_find(wmOperatorType *ot)
uiPopupMenu *pup;
pup = UI_popup_menu_begin(C, IFACE_("Text"), ICON_NONE);
- uiItemEnumO(layout, "TEXT_OT_move", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Top of File"),
- 0, "type", FILE_TOP);
- uiItemEnumO(layout, "TEXT_OT_move", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Bottom of File"),
- 0, "type", FILE_BOTTOM);
- uiItemEnumO(layout, "TEXT_OT_move", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Page Up"), 0, "type", PREV_PAGE);
- uiItemEnumO(layout, "TEXT_OT_move", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Page Down"),
- 0, "type", NEXT_PAGE);
+ uiItemEnumO(layout,
+ "TEXT_OT_move",
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Top of File"),
+ 0,
+ "type",
+ FILE_TOP);
+ uiItemEnumO(layout,
+ "TEXT_OT_move",
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Bottom of File"),
+ 0,
+ "type",
+ FILE_BOTTOM);
+ uiItemEnumO(layout,
+ "TEXT_OT_move",
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Page Up"),
+ 0,
+ "type",
+ PREV_PAGE);
+ uiItemEnumO(layout,
+ "TEXT_OT_move",
+ CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Page Down"),
+ 0,
+ "type",
+ NEXT_PAGE);
UI_popup_menu_end(C, pup);
}
#endif
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index cf28f3d317c..aab5069f919 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -145,8 +145,6 @@ void TEXT_OT_selection_set(struct wmOperatorType *ot);
void TEXT_OT_cursor_set(struct wmOperatorType *ot);
void TEXT_OT_line_number(struct wmOperatorType *ot);
-void TEXT_OT_properties(struct wmOperatorType *ot);
-
/* find = find indicated text */
void TEXT_OT_find(struct wmOperatorType *ot);
void TEXT_OT_find_set_selected(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index c069fc600e8..7b6e0ff8771 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -61,6 +61,83 @@
static void txt_screen_clamp(SpaceText *st, ARegion *ar);
+/************************ util ***************************/
+
+/**
+ * Tests if the given character represents a start of a new line or the
+ * indentation part of a line.
+ * \param c: The current character.
+ * \param r_last_state: A pointer to a flag representing the last state. The
+ * flag may be modified.
+ */
+static void test_line_start(char c, bool *r_last_state)
+{
+ if (c == '\n') {
+ *r_last_state = true;
+ }
+ else if (!ELEM(c, '\t', ' ')) {
+ *r_last_state = false;
+ }
+}
+
+/**
+ * This function converts the indentation tabs from a buffer to spaces.
+ * \param buf: A pointer to a cstring.
+ * \param tab_size: The size, in spaces, of the tab character.
+ */
+static char *buf_tabs_to_spaces(const char *in_buf, const int tab_size)
+{
+ /* Get the number of tab characters in buffer. */
+ bool line_start = true;
+ int num_tabs = 0;
+
+ for (int in_offset = 0; in_buf[in_offset]; in_offset++) {
+ /* Verify if is an indentation whitespace character. */
+ test_line_start(in_buf[in_offset], &line_start);
+
+ if (in_buf[in_offset] == '\t' && line_start) {
+ num_tabs++;
+ }
+ }
+
+ /* Allocate output before with extra space for expanded tabs. */
+ const int out_size = strlen(in_buf) + num_tabs * (tab_size - 1);
+ char *out_buf = MEM_mallocN(out_size * sizeof(char), __func__);
+
+ /* Fill output buffer. */
+ int spaces_until_tab = 0;
+ int out_offset = 0;
+ line_start = true;
+
+ for (int in_offset = 0; in_buf[in_offset]; in_offset++) {
+ /* Verify if is an indentation whitespace character. */
+ test_line_start(in_buf[in_offset], &line_start);
+
+ if (in_buf[in_offset] == '\t' && line_start) {
+ /* Calculate tab size so it fills until next indentation. */
+ int num_spaces = tab_size - (spaces_until_tab % tab_size);
+ spaces_until_tab = 0;
+
+ /* Write to buffer. */
+ memset(&out_buf[out_offset], ' ', num_spaces);
+ out_offset += num_spaces;
+ }
+ else {
+ if (in_buf[in_offset] == ' ') {
+ spaces_until_tab++;
+ }
+ else if (in_buf[in_offset] == '\n') {
+ spaces_until_tab = 0;
+ }
+
+ out_buf[out_offset++] = in_buf[in_offset];
+ }
+ }
+
+ out_buf[out_offset] = '\0';
+ return out_buf;
+}
+
/************************ poll ***************************/
BLI_INLINE int text_pixel_x_to_column(SpaceText *st, const int x)
@@ -78,8 +155,9 @@ static bool text_edit_poll(bContext *C)
{
Text *text = CTX_data_edit_text(C);
- if (!text)
+ if (!text) {
return 0;
+ }
if (ID_IS_LINKED(text)) {
// BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data");
@@ -94,8 +172,9 @@ bool text_space_edit_poll(bContext *C)
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
- if (!st || !text)
+ if (!st || !text) {
return 0;
+ }
if (ID_IS_LINKED(text)) {
// BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data");
@@ -111,11 +190,13 @@ static bool text_region_edit_poll(bContext *C)
Text *text = CTX_data_edit_text(C);
ARegion *ar = CTX_wm_region(C);
- if (!st || !text)
+ if (!st || !text) {
return 0;
+ }
- if (!ar || ar->regiontype != RGN_TYPE_WINDOW)
+ if (!ar || ar->regiontype != RGN_TYPE_WINDOW) {
return 0;
+ }
if (ID_IS_LINKED(text)) {
// BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data");
@@ -129,8 +210,9 @@ static bool text_region_edit_poll(bContext *C)
void text_update_line_edited(TextLine *line)
{
- if (!line)
+ if (!line) {
return;
+ }
/* we just free format here, and let it rebuild during draw */
if (line->format) {
@@ -143,8 +225,9 @@ void text_update_edited(Text *text)
{
TextLine *line;
- for (line = text->lines.first; line; line = line->next)
+ for (line = text->lines.first; line; line = line->next) {
text_update_line_edited(line);
+ }
}
/******************* new operator *********************/
@@ -226,13 +309,15 @@ static int text_open_exec(bContext *C, wmOperator *op)
text = BKE_text_load_ex(bmain, str, BKE_main_blendfile_path(bmain), internal);
if (!text) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
return OPERATOR_CANCELLED;
}
- if (!op->customdata)
+ if (!op->customdata) {
text_open_init(C, op);
+ }
/* hook into UI */
pprop = op->customdata;
@@ -266,8 +351,9 @@ static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
Text *text = CTX_data_edit_text(C);
const char *path = (text && text->name) ? text->name : BKE_main_blendfile_path(bmain);
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return text_open_exec(C, op);
+ }
text_open_init(C, op);
RNA_string_set(op->ptr, "filepath", path);
@@ -299,7 +385,7 @@ void TEXT_OT_open(wmOperatorType *ot)
FILE_OPENFILE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA); //XXX TODO, relative_path
+ FILE_SORT_ALPHA); // XXX TODO, relative_path
RNA_def_boolean(
ot->srna, "internal", 0, "Make internal", "Make text file internal after loading");
}
@@ -323,8 +409,9 @@ static int text_reload_exec(bContext *C, wmOperator *op)
}
#ifdef WITH_PYTHON
- if (text->compiled)
+ if (text->compiled) {
BPY_text_free_code(text);
+ }
#endif
text_update_edited(text);
@@ -446,8 +533,9 @@ static bool text_save_poll(bContext *C)
{
Text *text = CTX_data_edit_text(C);
- if (!text_edit_poll(C))
+ if (!text_edit_poll(C)) {
return 0;
+ }
return (text->name != NULL && !(text->flags & TXT_ISMEM));
}
@@ -532,13 +620,15 @@ static int text_save_as_exec(bContext *C, wmOperator *op)
Text *text = CTX_data_edit_text(C);
char str[FILE_MAX];
- if (!text)
+ if (!text) {
return OPERATOR_CANCELLED;
+ }
RNA_string_get(op->ptr, "filepath", str);
- if (text->name)
+ if (text->name) {
MEM_freeN(text->name);
+ }
text->name = BLI_strdup(str);
text->flags &= ~TXT_ISMEM;
@@ -556,15 +646,19 @@ static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
Text *text = CTX_data_edit_text(C);
const char *str;
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return text_save_as_exec(C, op);
+ }
- if (text->name)
+ if (text->name) {
str = text->name;
- else if (text->flags & TXT_ISMEM)
+ }
+ else if (text->flags & TXT_ISMEM) {
str = text->id.name + 2;
- else
+ }
+ else {
str = BKE_main_blendfile_path(bmain);
+ }
RNA_string_set(op->ptr, "filepath", str);
WM_event_add_fileselect(C, op);
@@ -591,7 +685,7 @@ void TEXT_OT_save_as(wmOperatorType *ot)
FILE_SAVE,
WM_FILESEL_FILEPATH,
FILE_DEFAULTDISPLAY,
- FILE_SORT_ALPHA); //XXX TODO, relative_path
+ FILE_SORT_ALPHA); // XXX TODO, relative_path
}
/******************* run script operator *********************/
@@ -689,9 +783,10 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS
for (con = pchan->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_PYTHON) {
bPythonConstraint *data = con->data;
- if (data->text == text) BPY_pyconstraint_update(ob, con);
+ if (data->text == text) {
+ BPY_pyconstraint_update(ob, con);
+ }
update = 1;
-
}
}
}
@@ -699,7 +794,9 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS
for (con = ob->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_PYTHON) {
bPythonConstraint *data = con->data;
- if (data->text == text) BPY_pyconstraint_update(ob, con);
+ if (data->text == text) {
+ BPY_pyconstraint_update(ob, con);
+ }
update = 1;
}
}
@@ -737,12 +834,21 @@ static int text_paste_exec(bContext *C, wmOperator *op)
buf = WM_clipboard_text_get(selection, &buf_len);
- if (!buf)
+ if (!buf) {
return OPERATOR_CANCELLED;
+ }
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
TextUndoBuf *utxt = ED_text_undo_push_init(C);
+
+ /* Convert clipboard content indentation to spaces if specified */
+ if (text->flags & TXT_TABSTOSPACES) {
+ char *new_buf = buf_tabs_to_spaces(buf, TXT_TABSIZE);
+ MEM_freeN(buf);
+ buf = new_buf;
+ }
+
txt_insert_buf(text, utxt, buf);
text_update_edited(text);
@@ -752,8 +858,9 @@ static int text_paste_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
- if (CTX_wm_space_text(C)->live_edit)
+ if (CTX_wm_space_text(C)->live_edit) {
text_run_script(C, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -821,8 +928,9 @@ static void txt_copy_clipboard(Text *text)
{
char *buf;
- if (!txt_has_sel(text))
+ if (!txt_has_sel(text)) {
return;
+ }
buf = txt_sel_to_buf(text);
@@ -870,8 +978,9 @@ static int text_cut_exec(bContext *C, wmOperator *UNUSED(op))
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
- if (CTX_wm_space_text(C)->live_edit)
+ if (CTX_wm_space_text(C)->live_edit) {
text_run_script(C, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -994,8 +1103,9 @@ static int text_line_break_exec(bContext *C, wmOperator *UNUSED(op))
}
if (text->curl) {
- if (text->curl->prev)
+ if (text->curl->prev) {
text_update_line_edited(text->curl->prev);
+ }
text_update_line_edited(text->curl);
}
@@ -1127,8 +1237,9 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
flatten_string_free(&fs);
MEM_freeN(tmp->line);
- if (tmp->format)
+ if (tmp->format) {
MEM_freeN(tmp->format);
+ }
/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
tmp->line = new_line;
@@ -1156,8 +1267,9 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
/* a + 0 we already know to be ' ' char... */
for (j = 1;
(j < tab_len) && (a + j < text_check_line_len) && (text_check_line[a + j] == ' ');
- j++)
+ j++) {
;
+ }
if (j == tab_len) {
/* We found a set of spaces that can be replaced by a tab... */
@@ -1200,8 +1312,9 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
#endif
MEM_freeN(tmp->line);
- if (tmp->format)
+ if (tmp->format) {
MEM_freeN(tmp->format);
+ }
/* Put new_line in the tmp->line spot
* still need to try and set the curc correctly. */
@@ -1341,8 +1454,9 @@ static int move_lines_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
- if (CTX_wm_space_text(C)->live_edit)
+ if (CTX_wm_space_text(C)->live_edit) {
text_run_script(C, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -1431,14 +1545,16 @@ static int text_get_cursor_rel(SpaceText *st, ARegion *ar, TextLine *linein, int
if (found) {
/* exact cursor position was found, check if it's */
/* still on needed line (hasn't been wrapped) */
- if (selc > endj && !chop)
+ if (selc > endj && !chop) {
selc = endj;
+ }
loop = 0;
break;
}
- if (chop)
+ if (chop) {
endj = j;
+ }
start = end;
end += max;
@@ -1452,8 +1568,9 @@ static int text_get_cursor_rel(SpaceText *st, ARegion *ar, TextLine *linein, int
}
}
else if (ch == '\0') {
- if (!found)
+ if (!found) {
selc = linein->len;
+ }
loop = 0;
break;
}
@@ -1551,8 +1668,9 @@ static int cursor_skip_find_line(
*linep = (*linep)->prev;
}
else { /* moving bottom */
- if (*rell - visible_lines < 0)
+ if (*rell - visible_lines < 0) {
break;
+ }
if (!(*linep)->next) {
*rell = visible_lines - 1;
@@ -1616,14 +1734,16 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel)
*charp = endj;
if (j >= oldc) {
- if (ch == '\0')
+ if (ch == '\0') {
*charp = txt_utf8_column_to_offset((*linep)->line, start);
+ }
loop = 0;
break;
}
- if (chop)
+ if (chop) {
endj = j;
+ }
start = end;
end += max;
@@ -1644,8 +1764,9 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, const bool sel)
@@ -1694,14 +1815,17 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, const bool sel)
if (i + columns - start > max) {
end = MIN2(end, i);
- if (chop)
+ if (chop) {
endj = BLI_str_prev_char_utf8((*linep)->line + j) - (*linep)->line;
+ }
if (endj >= oldc) {
- if (ch == '\0')
+ if (ch == '\0') {
*charp = (*linep)->len;
- else
+ }
+ else {
*charp = endj;
+ }
loop = 0;
break;
}
@@ -1724,8 +1848,9 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static void txt_wrap_move_up(SpaceText *st, ARegion *ar, const bool sel)
@@ -1764,8 +1889,9 @@ static void txt_wrap_move_up(SpaceText *st, ARegion *ar, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static void txt_wrap_move_down(SpaceText *st, ARegion *ar, const bool sel)
@@ -1802,8 +1928,9 @@ static void txt_wrap_move_down(SpaceText *st, ARegion *ar, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
/* Moves the cursor vertically by the specified number of lines.
@@ -1830,8 +1957,9 @@ static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, const
int rell, relc;
/* find line and offsets inside it needed to set cursor position */
- if (cursor_skip_find_line(st, ar, lines, linep, charp, &rell, &relc))
+ if (cursor_skip_find_line(st, ar, lines, linep, charp, &rell, &relc)) {
*charp = text_get_cursor_rel(st, ar, *linep, rell, relc);
+ }
}
else {
while (lines > 0 && (*linep)->next) {
@@ -1844,11 +1972,13 @@ static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, const
}
}
- if (*charp > (*linep)->len)
+ if (*charp > (*linep)->len) {
*charp = (*linep)->len;
+ }
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static int text_move_cursor(bContext *C, int type, bool select)
@@ -1858,28 +1988,33 @@ static int text_move_cursor(bContext *C, int type, bool select)
ARegion *ar = CTX_wm_region(C);
/* ensure we have the right region, it's optional */
- if (ar && ar->regiontype != RGN_TYPE_WINDOW)
+ if (ar && ar->regiontype != RGN_TYPE_WINDOW) {
ar = NULL;
+ }
switch (type) {
case LINE_BEGIN:
if (!select) {
txt_sel_clear(text);
}
- if (st && st->wordwrap && ar)
+ if (st && st->wordwrap && ar) {
txt_wrap_move_bol(st, ar, select);
- else
+ }
+ else {
txt_move_bol(text, select);
+ }
break;
case LINE_END:
if (!select) {
txt_sel_clear(text);
}
- if (st && st->wordwrap && ar)
+ if (st && st->wordwrap && ar) {
txt_wrap_move_eol(st, ar, select);
- else
+ }
+ else {
txt_move_eol(text, select);
+ }
break;
case FILE_TOP:
@@ -1925,31 +2060,39 @@ static int text_move_cursor(bContext *C, int type, bool select)
break;
case PREV_LINE:
- if (st && st->wordwrap && ar)
+ if (st && st->wordwrap && ar) {
txt_wrap_move_up(st, ar, select);
- else
+ }
+ else {
txt_move_up(text, select);
+ }
break;
case NEXT_LINE:
- if (st && st->wordwrap && ar)
+ if (st && st->wordwrap && ar) {
txt_wrap_move_down(st, ar, select);
- else
+ }
+ else {
txt_move_down(text, select);
+ }
break;
case PREV_PAGE:
- if (st)
+ if (st) {
cursor_skip(st, ar, st->text, -st->viewlines, select);
- else
+ }
+ else {
cursor_skip(NULL, NULL, text, -10, select);
+ }
break;
case NEXT_PAGE:
- if (st)
+ if (st) {
cursor_skip(st, ar, st->text, st->viewlines, select);
- else
+ }
+ else {
cursor_skip(NULL, NULL, text, 10, select);
+ }
break;
}
@@ -2018,12 +2161,15 @@ static int text_jump_exec(bContext *C, wmOperator *op)
int line = RNA_int_get(op->ptr, "line");
short nlines = txt_get_span(text->lines.first, text->lines.last) + 1;
- if (line < 1)
+ if (line < 1) {
txt_move_toline(text, 1, 0);
- else if (line > nlines)
+ }
+ else if (line > nlines) {
txt_move_toline(text, nlines - 1, 0);
- else
+ }
+ else {
txt_move_toline(text, line - 1, 0);
+ }
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
@@ -2076,10 +2222,12 @@ static int text_delete_exec(bContext *C, wmOperator *op)
/* behavior could be changed here,
* but for now just don't jump words when we have a selection */
if (txt_has_sel(text)) {
- if (type == DEL_PREV_WORD)
+ if (type == DEL_PREV_WORD) {
type = DEL_PREV_CHAR;
- else if (type == DEL_NEXT_WORD)
+ }
+ else if (type == DEL_NEXT_WORD) {
type = DEL_NEXT_CHAR;
+ }
}
TextUndoBuf *utxt = ED_text_undo_push_init(C);
@@ -2135,8 +2283,9 @@ static int text_delete_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
- if (st->live_edit)
+ if (st->live_edit) {
text_run_script(C, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -2246,8 +2395,9 @@ static int text_scroll_exec(bContext *C, wmOperator *op)
int lines = RNA_int_get(op->ptr, "lines");
- if (lines == 0)
+ if (lines == 0) {
return OPERATOR_CANCELLED;
+ }
txt_screen_skip(st, ar, lines * U.wheellinescroll);
@@ -2304,8 +2454,9 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
st->left += scroll_steps[0];
- if (st->left < 0)
+ if (st->left < 0) {
st->left = 0;
+ }
}
ED_area_tag_redraw(CTX_wm_area(C));
@@ -2331,8 +2482,9 @@ static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case MOUSEMOVE:
- if (tsc->zone == SCROLLHANDLE_BAR)
+ if (tsc->zone == SCROLLHANDLE_BAR) {
text_scroll_apply(C, op, event);
+ }
break;
case LEFTMOUSE:
case RIGHTMOUSE:
@@ -2362,8 +2514,9 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
SpaceText *st = CTX_wm_space_text(C);
TextScroll *tsc;
- if (RNA_struct_property_is_set(op->ptr, "lines"))
+ if (RNA_struct_property_is_set(op->ptr, "lines")) {
return text_scroll_exec(C, op);
+ }
tsc = MEM_callocN(sizeof(TextScroll), "TextScroll");
tsc->first = 1;
@@ -2425,11 +2578,13 @@ static bool text_region_scroll_poll(bContext *C)
Text *text = CTX_data_edit_text(C);
ARegion *ar = CTX_wm_region(C);
- if (!st || !text)
+ if (!st || !text) {
return 0;
+ }
- if (!ar || ar->regiontype != RGN_TYPE_WINDOW)
+ if (!ar || ar->regiontype != RGN_TYPE_WINDOW) {
return 0;
+ }
return 1;
}
@@ -2442,8 +2597,9 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
const int *mval = event->mval;
int zone = -1;
- if (RNA_struct_property_is_set(op->ptr, "lines"))
+ if (RNA_struct_property_is_set(op->ptr, "lines")) {
return text_scroll_exec(C, op);
+ }
/* verify we are in the right zone */
if (mval[0] > st->txtbar.xmin && mval[0] < st->txtbar.xmax) {
@@ -2452,10 +2608,12 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
zone = SCROLLHANDLE_BAR;
}
else if (mval[1] > TXT_SCROLL_SPACE && mval[1] < ar->winy - TXT_SCROLL_SPACE) {
- if (mval[1] < st->txtbar.ymin)
+ if (mval[1] < st->txtbar.ymin) {
zone = SCROLLHANDLE_MIN_OUTSIDE;
- else
+ }
+ else {
zone = SCROLLHANDLE_MAX_OUTSIDE;
+ }
}
}
@@ -2539,13 +2697,16 @@ static int flatten_column_to_offset(SpaceText *st, const char *str, int index)
int i = 0, j = 0, col;
while (*(str + j)) {
- if (str[j] == '\t')
+ if (str[j] == '\t') {
col = st->tabnumber - i % st->tabnumber;
- else
+ }
+ else {
col = BLI_str_utf8_char_width_safe(str + j);
+ }
- if (i + col > index)
+ if (i + col > index) {
break;
+ }
i += col;
j += BLI_str_utf8_size_safe(str + j);
@@ -2632,18 +2793,21 @@ static void text_cursor_set_to_pos_wrapped(
if (found) {
/* exact cursor position was found, check if it's still on needed line
* (hasn't been wrapped) */
- if (charp > endj && !chop && ch != '\0')
+ if (charp > endj && !chop && ch != '\0') {
charp = endj;
+ }
break;
}
- if (chop)
+ if (chop) {
endj = j;
+ }
start = end;
end += max;
- if (j < linep->len)
+ if (j < linep->len) {
y--;
+ }
chop = true;
if (y == 0 && i + columns - start > x) {
@@ -2704,13 +2868,16 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con
text_update_character_width(st);
y = (ar->winy - 2 - y) / (st->lheight_dpi + TXT_LINE_SPACING);
- if (st->showlinenrs)
+ if (st->showlinenrs) {
x -= TXT_OFFSET + TEXTXLOC;
- else
+ }
+ else {
x -= TXT_OFFSET;
+ }
- if (x < 0)
+ if (x < 0) {
x = 0;
+ }
x = text_pixel_x_to_column(st, x) + st->left;
if (st->wordwrap) {
@@ -2734,25 +2901,30 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con
if (y > 0) {
while (y-- != 0) {
- if ((*linep)->next)
+ if ((*linep)->next) {
*linep = (*linep)->next;
+ }
}
}
else if (y < 0) {
while (y++ != 0) {
- if ((*linep)->prev)
+ if ((*linep)->prev) {
*linep = (*linep)->prev;
+ }
}
}
w = flatten_width(st, (*linep)->line);
- if (x < w)
+ if (x < w) {
*charp = flatten_column_to_offset(st, (*linep)->line, x);
- else
+ }
+ else {
*charp = (*linep)->len;
+ }
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static void text_cursor_timer_ensure(bContext *C, SetSelection *ssel)
@@ -2839,8 +3011,9 @@ static int text_set_selection_invoke(bContext *C, wmOperator *op, const wmEvent
SpaceText *st = CTX_wm_space_text(C);
SetSelection *ssel;
- if (event->mval[0] >= st->txtbar.xmin)
+ if (event->mval[0] >= st->txtbar.xmin) {
return OPERATOR_PASS_THROUGH;
+ }
op->customdata = MEM_callocN(sizeof(SetSelection), "SetCursor");
ssel = op->customdata;
@@ -2919,8 +3092,9 @@ static int text_cursor_set_invoke(bContext *C, wmOperator *op, const wmEvent *ev
{
SpaceText *st = CTX_wm_space_text(C);
- if (event->mval[0] >= st->txtbar.xmin)
+ if (event->mval[0] >= st->txtbar.xmin) {
return OPERATOR_PASS_THROUGH;
+ }
RNA_int_set(op->ptr, "x", event->mval[0]);
RNA_int_set(op->ptr, "y", event->mval[1]);
@@ -2959,18 +3133,23 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm
text_update_character_width(st);
- if (!st->showlinenrs)
+ if (!st->showlinenrs) {
return OPERATOR_PASS_THROUGH;
+ }
- if (!(mval[0] > 2 && mval[0] < (TXT_OFFSET + TEXTXLOC) && mval[1] > 2 && mval[1] < ar->winy - 2))
+ if (!(mval[0] > 2 && mval[0] < (TXT_OFFSET + TEXTXLOC) && mval[1] > 2 &&
+ mval[1] < ar->winy - 2)) {
return OPERATOR_PASS_THROUGH;
+ }
- if (!(event->ascii >= '0' && event->ascii <= '9'))
+ if (!(event->ascii >= '0' && event->ascii <= '9')) {
return OPERATOR_PASS_THROUGH;
+ }
time = PIL_check_seconds_timer();
- if (last_jump < time - 1)
+ if (last_jump < time - 1) {
jump_to = 0;
+ }
jump_to *= 10;
jump_to += (int)(event->ascii - '0');
@@ -3028,8 +3207,9 @@ static int text_insert_exec(bContext *C, wmOperator *op)
MEM_freeN(str);
- if (!done)
+ if (!done) {
return OPERATOR_CANCELLED;
+ }
text_update_line_edited(text->curl);
@@ -3072,8 +3252,9 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ret = text_insert_exec(C, op);
/* run the script while editing, evil but useful */
- if (ret == OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit)
+ if (ret == OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit) {
text_run_script(C, NULL);
+ }
return ret;
}
@@ -3116,21 +3297,25 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
int found = 0;
char *tmp;
- if (!st->findstr[0])
+ if (!st->findstr[0]) {
return OPERATOR_CANCELLED;
+ }
flags = st->flags;
- if (flags & ST_FIND_ALL)
+ if (flags & ST_FIND_ALL) {
flags &= ~ST_FIND_WRAP;
+ }
/* Replace current */
if (mode != TEXT_FIND && txt_has_sel(text)) {
tmp = txt_sel_to_buf(text);
- if (flags & ST_MATCH_CASE)
+ if (flags & ST_MATCH_CASE) {
found = STREQ(st->findstr, tmp);
- else
+ }
+ else {
found = BLI_strcasecmp(st->findstr, tmp) == 0;
+ }
if (found) {
if (mode == TEXT_REPLACE) {
@@ -3155,17 +3340,20 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
}
else if (flags & ST_FIND_ALL) {
- if (text->id.next)
+ if (text->id.next) {
text = st->text = text->id.next;
- else
+ }
+ else {
text = st->text = bmain->texts.first;
+ }
txt_move_toline(text, 0, 0);
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
}
else {
- if (!found)
+ if (!found) {
BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr);
+ }
}
return OPERATOR_FINISHED;
@@ -3222,8 +3410,9 @@ static int text_find_set_selected_exec(bContext *C, wmOperator *op)
BLI_strncpy(st->findstr, tmp, ST_MAX_FIND_STR);
MEM_freeN(tmp);
- if (!st->findstr[0])
+ if (!st->findstr[0]) {
return OPERATOR_FINISHED;
+ }
return text_find_and_replace(C, op, TEXT_FIND);
}
diff --git a/source/blender/editors/space_topbar/CMakeLists.txt b/source/blender/editors/space_topbar/CMakeLists.txt
index 71e61a07ff7..d56e1da334d 100644
--- a/source/blender/editors/space_topbar/CMakeLists.txt
+++ b/source/blender/editors/space_topbar/CMakeLists.txt
@@ -25,8 +25,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
index 46a86bcbc86..8b290009a97 100644
--- a/source/blender/editors/space_topbar/space_topbar.c
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -71,10 +71,6 @@ static SpaceLink *topbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sc
ar->alignment = RGN_ALIGN_RIGHT | RGN_SPLIT_PREV;
/* main regions */
- ar = MEM_callocN(sizeof(ARegion), "right aligned main region for topbar");
- BLI_addtail(&stopbar->regionbase, ar);
- ar->regiontype = RGN_TYPE_WINDOW;
- ar->alignment = RGN_ALIGN_RIGHT;
ar = MEM_callocN(sizeof(ARegion), "main region of topbar");
BLI_addtail(&stopbar->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index 279c6913064..dc375958eb4 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -28,10 +28,10 @@ set(INC
../../makesdna
../../makesrna
../../render/extern/include
- ../../windowmanager
../../depsgraph
- ../../../../intern/guardedalloc
+ ../../windowmanager
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
../../../../intern/smoke/extern
)
@@ -64,7 +64,6 @@ set(SRC
view3d_project.c
view3d_select.c
view3d_snap.c
- view3d_toolbar.c
view3d_utils.c
view3d_view.c
view3d_walk.c
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index c304642c4c3..638c77fc3cb 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -348,51 +348,6 @@ void draw_object_select_id(Depsgraph *depsgraph,
GPU_matrix_set(rv3d->viewmat);
}
-void draw_object_depth(RegionView3D *rv3d, Object *ob)
-{
- GPU_matrix_mul(ob->obmat);
- GPU_depth_test(true);
-
- const float(*world_clip_planes)[4] = NULL;
- if (rv3d->rflag & RV3D_CLIPPING) {
- ED_view3d_clipping_local(rv3d, ob->obmat);
- world_clip_planes = rv3d->clip_local;
- }
-
- switch (ob->type) {
- case OB_MESH: {
- GPUBatch *batch;
-
- Mesh *me = ob->data;
-
- if (ob->mode & OB_MODE_EDIT) {
- batch = DRW_mesh_batch_cache_get_edit_triangles(me);
- }
- else {
- batch = DRW_mesh_batch_cache_get_surface(me);
- }
-
- DRW_mesh_batch_cache_create_requested(ob, me, NULL, false, true);
-
- DRW_opengl_context_enable();
- const eGPUShaderConfig sh_cfg = world_clip_planes ? GPU_SHADER_CFG_CLIPPED :
- GPU_SHADER_CFG_DEFAULT;
- GPU_batch_program_set_builtin_with_config(batch, GPU_SHADER_3D_DEPTH_ONLY, sh_cfg);
- if (world_clip_planes != NULL) {
- bbs_world_clip_planes_from_rv3d(batch, world_clip_planes);
- }
-
- GPU_batch_draw(batch);
- DRW_opengl_context_disable();
- } break;
- case OB_CURVE:
- case OB_SURF:
- break;
- }
-
- GPU_matrix_set(rv3d->viewmat);
-}
-
void ED_draw_object_facemap(Depsgraph *depsgraph,
Object *ob,
const float col[4],
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 434f379c6fe..9ee7bb3066d 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -82,75 +82,6 @@
/* ******************** manage regions ********************* */
-ARegion *view3d_has_buttons_region(ScrArea *sa)
-{
- ARegion *ar, *arnew;
-
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) {
- return ar;
- }
-
- /* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
-
- /* is error! */
- if (ar == NULL) {
- return NULL;
- }
-
- arnew = MEM_callocN(sizeof(ARegion), "buttons for view3d");
-
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
-
- arnew->flag = RGN_FLAG_HIDDEN;
-
- return arnew;
-}
-
-ARegion *view3d_has_tools_region(ScrArea *sa)
-{
- ARegion *ar, *artool = NULL, *arhead;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_TOOLS) {
- artool = ar;
- }
- }
-
- /* tool region hide/unhide also hides props */
- if (artool) {
- return artool;
- }
-
- if (artool == NULL) {
- /* add subdiv level; after header */
- for (arhead = sa->regionbase.first; arhead; arhead = arhead->next) {
- if (arhead->regiontype == RGN_TYPE_HEADER) {
- break;
- }
- }
-
- /* is error! */
- if (arhead == NULL) {
- return NULL;
- }
-
- artool = MEM_callocN(sizeof(ARegion), "tools for view3d");
-
- BLI_insertlinkafter(&sa->regionbase, arhead, artool);
- artool->regiontype = RGN_TYPE_TOOLS;
- artool->alignment = RGN_ALIGN_LEFT;
- artool->flag = RGN_FLAG_HIDDEN;
- }
-
- return artool;
-}
-
-/* ****************************************************** */
-
/* function to always find a regionview3d context inside 3D window */
RegionView3D *ED_view3d_context_rv3d(bContext *C)
{
@@ -331,13 +262,17 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
v3d->overlay.texture_paint_mode_opacity = 1.0f;
v3d->overlay.weight_paint_mode_opacity = 1.0f;
v3d->overlay.vertex_paint_mode_opacity = 1.0f;
+ /* Intentionally different to vertex/paint mode,
+ * we typically want to see shading too. */
+ v3d->overlay.sculpt_mode_mask_opacity = 0.75f;
+
v3d->overlay.edit_flag = V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS |
V3D_OVERLAY_EDIT_SHARP | V3D_OVERLAY_EDIT_FREESTYLE_EDGE |
V3D_OVERLAY_EDIT_FREESTYLE_FACE | V3D_OVERLAY_EDIT_EDGES |
V3D_OVERLAY_EDIT_CREASES | V3D_OVERLAY_EDIT_BWEIGHTS |
V3D_OVERLAY_EDIT_CU_HANDLES | V3D_OVERLAY_EDIT_CU_NORMALS;
- v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;
+ v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR | V3D_SHOW_ORTHO_GRID;
v3d->flag = V3D_SELECT_OUTLINE;
v3d->flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_ANNOTATION;
@@ -362,6 +297,14 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
v3d->vertex_opacity = 1.0f;
v3d->gp_flag |= V3D_GP_SHOW_EDIT_LINES;
+ /* tool header */
+ ar = MEM_callocN(sizeof(ARegion), "tool header for view3d");
+
+ BLI_addtail(&v3d->regionbase, ar);
+ ar->regiontype = RGN_TYPE_TOOL_HEADER;
+ ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+ ar->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for view3d");
@@ -1189,6 +1132,34 @@ static void view3d_header_region_listener(wmWindow *UNUSED(win),
}
break;
}
+
+ /* From topbar, which ones are needed? split per header? */
+ /* Disable for now, re-enable if neede, or remove - campbell. */
+#if 0
+ /* context changes */
+ switch (wmn->category) {
+ case NC_WM:
+ if (wmn->data == ND_HISTORY) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_SCENE:
+ if (wmn->data == ND_MODE) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_VIEW3D) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_GPENCIL:
+ if (wmn->data == ND_DATA) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ }
+#endif
}
static void view3d_header_region_message_subscribe(const struct bContext *UNUSED(C),
@@ -1558,6 +1529,17 @@ void ED_spacetype_view3d(void)
art->draw = view3d_tools_region_draw;
BLI_addhead(&st->regiontypes, art);
+ /* regions: tool header */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tool header region");
+ art->regionid = RGN_TYPE_TOOL_HEADER;
+ art->prefsizey = HEADERY;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
+ art->listener = view3d_header_region_listener;
+ art->init = view3d_header_region_init;
+ art->draw = view3d_header_region_draw;
+ art->message_subscribe = view3d_header_region_message_subscribe;
+ BLI_addhead(&st->regiontypes, art);
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype view3d header region");
art->regionid = RGN_TYPE_HEADER;
@@ -1566,7 +1548,7 @@ void ED_spacetype_view3d(void)
art->listener = view3d_header_region_listener;
art->init = view3d_header_region_init;
art->draw = view3d_header_region_draw;
- art->message_subscribe = view3d_header_region_message_subscribe;
+ art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header;
BLI_addhead(&st->regiontypes, art);
/* regions: hud */
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index abe36b1d563..3d3c73ad27c 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -147,9 +147,11 @@ static float compute_scale_factor(const float ve_median, const float median)
}
}
-/* Apply helpers.
- * Note: In case we only have one element, copy directly the value instead of applying the diff or scale factor.
- * Avoids some glitches when going e.g. from 3 to 0.0001 (see T37327).
+/**
+ * Apply helpers.
+ * \note In case we only have one element,
+ * copy directly the value instead of applying the diff or scale factor.
+ * Avoids some glitches when going e.g. from 3 to 0.0001 (see T37327).
*/
static void apply_raw_diff(float *val, const int tot, const float ve_median, const float median)
{
@@ -1064,7 +1066,7 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d
0,
"");
UI_block_align_begin(block);
- const float lim = 10000;
+ const float lim = FLT_MAX;
for (int i = 0; i < 3; i++) {
uiBut *but;
char text[3] = {'X' + i, ':', '\0'};
@@ -1603,7 +1605,7 @@ void view3d_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel object");
strcpy(pt->idname, "VIEW3D_PT_transform");
strcpy(pt->label, N_("Transform")); /* XXX C panels unavailable through RNA bpy.types! */
- strcpy(pt->category, "View");
+ strcpy(pt->category, "Item");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw = view3d_panel_transform;
pt->poll = view3d_panel_transform_poll;
@@ -1612,7 +1614,7 @@ void view3d_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel vgroup");
strcpy(pt->idname, "VIEW3D_PT_vgroup");
strcpy(pt->label, N_("Vertex Weights")); /* XXX C panels unavailable through RNA bpy.types! */
- strcpy(pt->category, "View");
+ strcpy(pt->category, "Item");
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw = view3d_panel_vgroup;
pt->poll = view3d_panel_vgroup_poll;
@@ -1628,31 +1630,6 @@ void view3d_buttons_register(ARegionType *art)
WM_menutype_add(mt);
}
-static int view3d_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = view3d_has_buttons_region(sa);
-
- if (ar) {
- ED_region_toggle_hidden(C, ar);
- }
-
- return OPERATOR_FINISHED;
-}
-
-void VIEW3D_OT_properties(wmOperatorType *ot)
-{
- ot->name = "Toggle Sidebar";
- ot->description = "Toggle the properties region visibility";
- ot->idname = "VIEW3D_OT_properties";
-
- ot->exec = view3d_properties_toggle_exec;
- ot->poll = ED_operator_view3d_active;
-
- /* flags */
- ot->flag = 0;
-}
-
static int view3d_object_mode_menu(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c
index c8059c25e15..0045094542f 100644
--- a/source/blender/editors/space_view3d/view3d_camera_control.c
+++ b/source/blender/editors/space_view3d/view3d_camera_control.c
@@ -23,10 +23,11 @@
* or other details.
* Typical view-control usage:
*
- * - acquire a view-control (#ED_view3d_cameracontrol_acquire).
- * - modify ``rv3d->ofs``, ``rv3d->viewquat``.
- * - update the view data (#ED_view3d_cameracontrol_acquire) - within a loop which draws the viewport.
- * - finish and release the view-control (#ED_view3d_cameracontrol_release),
+ * - Acquire a view-control (#ED_view3d_cameracontrol_acquire).
+ * - Modify ``rv3d->ofs``, ``rv3d->viewquat``.
+ * - Update the view data (#ED_view3d_cameracontrol_acquire) -
+ * within a loop which draws the viewport.
+ * - Finish and release the view-control (#ED_view3d_cameracontrol_release),
* either keeping the current view or restoring the initial view.
*
* Notes:
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 4610111aafa..8c5f1c16438 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -700,7 +700,8 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
/* draw */
immUniformThemeColorShade(TH_VIEW_OVERLAY, 100);
- /* TODO Was using UI_draw_roundbox_4fv(false, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f, color).
+ /* TODO Was using:
+ * UI_draw_roundbox_4fv(false, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f, color);
* We'll probably need a new imm_draw_line_roundbox_dashed dor that - though in practice the
* 2.0f round corner effect was nearly not visible anyway... */
imm_draw_box_wire_2d(shdr_pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
@@ -757,7 +758,6 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a
short flag = v3d->flag;
float glalphaclip = U.glalphaclip;
- int obcenter_dia = U.obcenter_dia;
/* temp set drawtype to solid */
/* Setting these temporarily is not nice */
v3d->flag &= ~V3D_SELECT_OUTLINE;
@@ -765,8 +765,6 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a
/* not that nice but means we wont zoom into billboards */
U.glalphaclip = alphaoverride ? 0.5f : glalphaclip;
- U.obcenter_dia = 0;
-
/* Tools may request depth outside of regular drawing code. */
UI_Theme_Store(&theme_state);
UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
@@ -796,7 +794,6 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a
U.glalphaclip = glalphaclip;
v3d->flag = flag;
- U.obcenter_dia = obcenter_dia;
UI_Theme_Restore(&theme_state);
}
@@ -967,7 +964,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d)
immVertex3fv(pos, end);
# if 0
- color[3] = 0.2f + fabsf(rv3d->rot_angle); /* modulate opacity with angle */
+ color[3] = 0.2f + fabsf(rv3d->rot_angle); /* modulate opacity with angle */
/* ^^ neat idea, but angle is frame-rate dependent, so it's usually close to 0.2 */
# endif
@@ -1450,6 +1447,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar)
view3d_draw_view(C, ar);
+ DRW_cache_free_old_batches(bmain);
GPU_free_images_old(bmain);
GPU_pass_cache_garbage_collect();
@@ -1822,6 +1820,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph,
*/
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
Scene *scene,
+ View3DShading *shading_override,
int drawtype,
Object *camera,
int width,
@@ -1844,22 +1843,25 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
ar.regiontype = RGN_TYPE_WINDOW;
v3d.camera = camera;
+ View3DShading *source_shading_settings = &scene->display.shading;
+ if (draw_flags & V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS && shading_override != NULL) {
+ source_shading_settings = shading_override;
+ }
+ memcpy(&v3d.shading, source_shading_settings, sizeof(View3DShading));
v3d.shading.type = drawtype;
+
+ if (drawtype == OB_MATERIAL) {
+ v3d.shading.flag = V3D_SHADING_SCENE_WORLD | V3D_SHADING_SCENE_LIGHTS;
+ }
+
v3d.flag2 = V3D_HIDE_OVERLAYS;
- if (draw_flags & V3D_OFSDRAW_USE_GPENCIL) {
+ if (draw_flags & V3D_OFSDRAW_SHOW_ANNOTATION) {
v3d.flag2 |= V3D_SHOW_ANNOTATION;
}
v3d.shading.background_type = V3D_SHADING_BACKGROUND_WORLD;
- if (draw_flags & V3D_OFSDRAW_USE_CAMERA_DOF) {
- if (camera->type == OB_CAMERA) {
- v3d.fx_settings.dof = &((Camera *)camera->data)->gpu_dof;
- v3d.fx_settings.fx_flag |= GPU_FX_FLAG_DOF;
- }
- }
-
rv3d.persp = RV3D_CAMOB;
copy_m4_m4(rv3d.viewinv, v3d.camera->obmat);
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 85bc0fba36b..b0cee18f8e3 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -219,12 +219,6 @@ static void validate_object_select_id(struct Depsgraph *depsgraph,
G.f &= ~G_FLAG_BACKBUFSEL;
}
-void view3d_opengl_read_pixels(
- ARegion *ar, int x, int y, int w, int h, int format, int type, void *data)
-{
- glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data);
-}
-
/* TODO: Creating, attaching texture, and destroying a framebuffer is quite slow.
* Calling this function should be avoided during interactive drawing. */
static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void *data)
@@ -234,7 +228,6 @@ static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void
GPUFrameBuffer *tmp_fb = GPU_framebuffer_create();
GPU_framebuffer_texture_attach(tmp_fb, dtxl->depth, 0, 0);
GPU_framebuffer_bind(tmp_fb);
- glDisable(GL_SCISSOR_TEST);
glReadPixels(rect->xmin,
rect->ymin,
@@ -244,9 +237,7 @@ static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void
GL_FLOAT,
data);
- glEnable(GL_SCISSOR_TEST);
GPU_framebuffer_restore();
-
GPU_framebuffer_free(tmp_fb);
}
@@ -269,29 +260,11 @@ void ED_view3d_backbuf_depth_validate(ViewContext *vc)
{
if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
ARegion *ar = vc->ar;
- RegionView3D *rv3d = ar->regiondata;
Object *obact_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact);
if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE) != 0)) {
- GPU_scissor(ar->winrct.xmin,
- ar->winrct.ymin,
- BLI_rcti_size_x(&ar->winrct),
- BLI_rcti_size_y(&ar->winrct));
-
- GPU_depth_test(true);
- GPU_clear(GPU_DEPTH_BIT);
-
- if (rv3d->rflag & RV3D_CLIPPING) {
- ED_view3d_clipping_set(rv3d);
- }
-
- draw_object_depth(rv3d, obact_eval);
-
- if (rv3d->rflag & RV3D_CLIPPING) {
- ED_view3d_clipping_disable();
- }
-
- GPU_depth_test(false);
+ GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0);
+ DRW_draw_depth_object(vc->ar, viewport, obact_eval);
}
vc->v3d->flag &= ~V3D_INVALID_BACKBUF;
@@ -374,7 +347,7 @@ uint ED_view3d_select_id_read_nearest(struct ViewContext *UNUSED(vc),
uint *r_dist)
{
/* Create region around mouse cursor. This must be square and have an odd
- * width, the spiralling algorithm does not work with arbitrary rectangles. */
+ * width, the spiraling algorithm does not work with arbitrary rectangles. */
rcti rect;
BLI_rcti_init_pt_radius(&rect, mval, *r_dist);
rect.xmax += 1;
@@ -855,9 +828,15 @@ void ED_view3d_depth_update(ARegion *ar)
}
if (d->damaged) {
- view3d_opengl_read_pixels(ar, 0, 0, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths);
+ GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0);
+ rcti r = {
+ .xmin = 0,
+ .xmax = d->w,
+ .ymin = 0,
+ .ymax = d->h,
+ };
+ view3d_opengl_read_Z_pixels(viewport, &r, d->depths);
glGetDoublev(GL_DEPTH_RANGE, d->depth_range);
-
d->damaged = false;
}
}
@@ -943,7 +922,8 @@ void ED_view3d_screen_datamask(const bContext *C,
/**
* Store values from #RegionView3D, set when drawing.
- * This is needed when we draw with to a viewport using a different matrix (offscreen drawing for example).
+ * This is needed when we draw with to a viewport using a different matrix
+ * (offscreen drawing for example).
*
* Values set by #ED_view3d_update_viewmat should be handled here.
*/
@@ -1015,8 +995,8 @@ void ED_scene_draw_fps(Scene *scene, int xoffset, int *yoffset)
if (tot) {
fpsi->redrawtime_index = (fpsi->redrawtime_index + 1) % REDRAW_FRAME_AVERAGE;
- //fpsi->redrawtime_index++;
- //if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) {
+ // fpsi->redrawtime_index++;
+ // if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) {
// fpsi->redrawtime = 0;
//}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 1d2d361d868..80153a38128 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -1046,7 +1046,8 @@ static float view3d_ndof_pan_speed_calc(RegionView3D *rv3d)
/**
* Zoom and pan in the same function since sometimes zoom is interpreted as dolly (pan forward).
*
- * \param has_zoom: zoom, otherwise dolly, often `!rv3d->is_persp` since it doesn't make sense to dolly in ortho.
+ * \param has_zoom: zoom, otherwise dolly,
+ * often `!rv3d->is_persp` since it doesn't make sense to dolly in ortho.
*/
static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof,
ScrArea *sa,
@@ -1068,9 +1069,8 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof,
/* zoom with Z */
/* Zoom!
- * velocity should be proportional to the linear velocity attained by rotational motion of same strength
- * [got that?]
- * proportional to arclength = radius * angle
+ * velocity should be proportional to the linear velocity attained by rotational motion
+ * of same strength [got that?] proportional to `arclength = radius * angle`.
*/
pan_vec[2] = 0.0f;
@@ -1646,7 +1646,8 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf)
#if 0
WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM);
WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM);
- WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE);
+ WM_modalkeymap_add_item(
+ keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE);
#endif
/* assign map to operators */
@@ -1843,7 +1844,8 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf)
}
/**
- * \param zoom_xy: Optionally zoom to window location (coords compatible w/ #wmEvent.x, y). Use when not NULL.
+ * \param zoom_xy: Optionally zoom to window location
+ * (coords compatible w/ #wmEvent.x, y). Use when not NULL.
*/
static void view_zoom_to_window_xy_camera(
Scene *scene, Depsgraph *depsgraph, View3D *v3d, ARegion *ar, float dfac, const int zoom_xy[2])
@@ -1891,7 +1893,8 @@ static void view_zoom_to_window_xy_camera(
}
/**
- * \param zoom_xy: Optionally zoom to window location (coords compatible w/ #wmEvent.x, y). Use when not NULL.
+ * \param zoom_xy: Optionally zoom to window location
+ * (coords compatible w/ #wmEvent.x, y). Use when not NULL.
*/
static void view_zoom_to_window_xy_3d(ARegion *ar, float dfac, const int zoom_xy[2])
{
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.c b/source/blender/editors/space_view3d/view3d_gizmo_armature.c
index ae186505456..3ea127b364f 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_armature.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.c
@@ -85,13 +85,13 @@ static void gizmo_bbone_offset_get(const wmGizmo *UNUSED(gz),
if (bh->index == 0) {
bh->co[1] = pchan->bone->ease1 / BBONE_SCALE_Y;
- bh->co[0] = pchan->curveInX;
- bh->co[2] = pchan->curveInY;
+ bh->co[0] = pchan->curve_in_x;
+ bh->co[2] = pchan->curve_in_y;
}
else {
bh->co[1] = -pchan->bone->ease2 / BBONE_SCALE_Y;
- bh->co[0] = pchan->curveOutX;
- bh->co[2] = pchan->curveOutY;
+ bh->co[0] = pchan->curve_out_x;
+ bh->co[2] = pchan->curve_out_y;
}
copy_v3_v3(value, bh->co);
}
@@ -110,13 +110,13 @@ static void gizmo_bbone_offset_set(const wmGizmo *UNUSED(gz),
if (bh->index == 0) {
pchan->bone->ease1 = max_ff(0.0f, bh->co[1] * BBONE_SCALE_Y);
- pchan->curveInX = bh->co[0];
- pchan->curveInY = bh->co[2];
+ pchan->curve_in_x = bh->co[0];
+ pchan->curve_in_y = bh->co[2];
}
else {
pchan->bone->ease2 = max_ff(0.0f, -bh->co[1] * BBONE_SCALE_Y);
- pchan->curveOutX = bh->co[0];
- pchan->curveOutY = bh->co[2];
+ pchan->curve_out_x = bh->co[0];
+ pchan->curve_out_y = bh->co[2];
}
}
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
index f98a87e84a8..5af6fd8b04b 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
@@ -259,8 +259,7 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
navgroup->state.rv3d.is_camera = (rv3d->persp == RV3D_CAMOB);
navgroup->state.rv3d.viewlock = rv3d->viewlock;
- const bool show_rotate = (((rv3d->viewlock & RV3D_LOCKED) == 0) &&
- (navgroup->state.rv3d.is_camera == false));
+ const bool show_rotate = (rv3d->viewlock & RV3D_LOCKED) == 0;
const bool show_fixed_offset = navgroup->state.rv3d.is_camera;
const float icon_size = GIZMO_SIZE;
const float icon_offset = (icon_size * 0.52f) * GIZMO_OFFSET_FAC * UI_DPI_FAC;
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index fd306619577..9075909a6fe 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -134,8 +134,6 @@ void draw_object_select_id(struct Depsgraph *depsgraph,
struct Object *ob,
short select_mode);
-void draw_object_depth(RegionView3D *rv3d, struct Object *ob);
-
int view3d_effective_drawtype(const struct View3D *v3d);
/* view3d_draw.c */
@@ -234,7 +232,6 @@ void viewzoom_modal_keymap(struct wmKeyConfig *keyconf);
void viewdolly_modal_keymap(struct wmKeyConfig *keyconf);
/* view3d_buttons.c */
-void VIEW3D_OT_properties(struct wmOperatorType *ot);
void VIEW3D_OT_object_mode_pie_or_toggle(struct wmOperatorType *ot);
void view3d_buttons_register(struct ARegionType *art);
@@ -267,9 +264,6 @@ void VIEW3D_OT_snap_cursor_to_selected(struct wmOperatorType *ot);
void VIEW3D_OT_snap_cursor_to_active(struct wmOperatorType *ot);
/* space_view3d.c */
-struct ARegion *view3d_has_buttons_region(struct ScrArea *sa);
-struct ARegion *view3d_has_tools_region(struct ScrArea *sa);
-
extern const char *view3d_context_dir[]; /* doc access */
/* view3d_widgets.c */
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 4e33005ebc0..e5a145b0411 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -199,9 +199,7 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_copybuffer);
WM_operatortype_append(VIEW3D_OT_pastebuffer);
- WM_operatortype_append(VIEW3D_OT_properties);
WM_operatortype_append(VIEW3D_OT_object_mode_pie_or_toggle);
- WM_operatortype_append(VIEW3D_OT_toolshelf);
WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid);
WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor);
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c
index 6932e94e78d..b81b7e0109e 100644
--- a/source/blender/editors/space_view3d/view3d_project.c
+++ b/source/blender/editors/space_view3d/view3d_project.c
@@ -455,7 +455,8 @@ bool ED_view3d_win_to_ray_clipped(struct Depsgraph *depsgraph,
* \param r_ray_start: The world-space point where the ray intersects the window plane.
* \param r_ray_normal: The normalized world-space direction of towards mval.
*
- * \note Ignores view near/far clipping, to take this into account use #ED_view3d_win_to_ray_clipped.
+ * \note Ignores view near/far clipping,
+ * to take this into account use #ED_view3d_win_to_ray_clipped.
*/
void ED_view3d_win_to_ray(const ARegion *ar,
const float mval[2],
@@ -498,7 +499,10 @@ void ED_view3d_global_to_vector(const RegionView3D *rv3d, const float coord[3],
/* very similar to ED_view3d_win_to_3d() but has no advantage, de-duplicating */
#if 0
-bool view3d_get_view_aligned_coordinate(ARegion *ar, float fp[3], const int mval[2], const bool do_fallback)
+bool view3d_get_view_aligned_coordinate(ARegion *ar,
+ float fp[3],
+ const int mval[2],
+ const bool do_fallback)
{
RegionView3D *rv3d = ar->regiondata;
float dvec[3];
@@ -508,8 +512,7 @@ bool view3d_get_view_aligned_coordinate(ARegion *ar, float fp[3], const int mval
ret = ED_view3d_project_int_global(ar, fp, mval_cpy, V3D_PROJ_TEST_NOP);
if (ret == V3D_PROJ_RET_OK) {
- const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]),
- (float)(mval_cpy[1] - mval[1])};
+ const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]), (float)(mval_cpy[1] - mval[1])};
const float zfac = ED_view3d_calc_zfac(rv3d, fp, NULL);
ED_view3d_win_to_delta(ar, mval_f, dvec, zfac);
sub_v3_v3(fp, dvec);
@@ -554,8 +557,9 @@ void ED_view3d_win_to_3d(const View3D *v3d,
copy_v3_v3(ray_origin, rv3d->viewinv[3]);
ED_view3d_win_to_vector(ar, mval, ray_direction);
- /* note, we could use isect_line_plane_v3() however we want the intersection to be infront of the
- * view no matter what, so apply the unsigned factor instead */
+ /* note, we could use isect_line_plane_v3()
+ * however we want the intersection to be infront of the view no matter what,
+ * so apply the unsigned factor instead */
plane_from_point_normal_v3(plane, depth_pt, rv3d->viewinv[2]);
isect_ray_plane_v3(ray_origin, ray_direction, plane, &lambda, false);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index c0f2e563365..2ce23486476 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1080,9 +1080,8 @@ static void do_lasso_select_node(int mcords[][2], short moves, const eSelectOp s
ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent);
const bool is_select = node->flag & SELECT;
- const bool is_inside = (
- BLI_rcti_isect_pt_v(&rect, node_cent) &&
- BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1]));
+ const bool is_inside = (BLI_rcti_isect_pt_v(&rect, node_cent) &&
+ BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1]));
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
SET_FLAG_FROM_TEST(node->flag, sel_op_result, SELECT);
@@ -1912,8 +1911,7 @@ static bool ed_object_select_pick(bContext *C,
}
}
- basact->flag |= BASE_SELECTED;
- BKE_scene_object_base_flag_sync_from_base(basact);
+ ED_object_base_select(basact, BA_SELECT);
retval = true;
@@ -1946,8 +1944,7 @@ static bool ed_object_select_pick(bContext *C,
/* we make the armature selected:
* not-selected active object in posemode won't work well for tools */
- basact->flag |= BASE_SELECTED;
- BKE_scene_object_base_flag_sync_from_base(basact);
+ ED_object_base_select(basact, BA_SELECT);
retval = true;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object);
@@ -2038,8 +2035,8 @@ static bool ed_object_select_pick(bContext *C,
}
/* Set special modes for grease pencil
- The grease pencil modes are not real modes, but a hack to make the interface
- consistent, so need some tricks to keep UI synchronized */
+ * The grease pencil modes are not real modes, but a hack to make the interface
+ * consistent, so need some tricks to keep UI synchronized */
// XXX: This stuff needs reviewing (Aligorith)
if (false && (((oldbasact) && oldbasact->object->type == OB_GPENCIL) ||
(basact->object->type == OB_GPENCIL))) {
@@ -2214,7 +2211,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
}
}
- /* passthrough allows tweaks
+ /* Pass-through allows tweaks
* FINISHED to signal one operator worked
* */
if (retval) {
@@ -2252,9 +2249,6 @@ void VIEW3D_OT_select(wmOperatorType *ot)
/* properties */
WM_operator_properties_mouse_select(ot);
- prop = RNA_def_boolean(
- ot->srna, "deselect_all", 0, "Deselect", "Deselect all when nothing under the cursor");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(
ot->srna,
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 5aa19cc8a51..fb121aa716b 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -233,9 +233,11 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
/** Snaps the selection as a whole (use_offset=true) or each selected object to the given location.
*
- * \param snap_target_global: a location in global space to snap to (eg. 3D cursor or active object).
- * \param use_offset: if the selected objects should maintain their relative offsets and be snapped by the selection
- * pivot point (median, active), or if every object origin should be snapped to the given location.
+ * \param snap_target_global: a location in global space to snap to
+ * (eg. 3D cursor or active object).
+ * \param use_offset: if the selected objects should maintain their relative offsets
+ * and be snapped by the selection pivot point (median, active),
+ * or if every object origin should be snapped to the given location.
*/
static int snap_selected_to_location(bContext *C,
const float snap_target_global[3],
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
deleted file mode 100644
index 9357d3e05ee..00000000000
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2009 Blender Foundation.
- * All rights reserved.
- */
-
-/** \file
- * \ingroup spview3d
- */
-
-#include <string.h>
-#include <stdio.h>
-#include <math.h>
-#include <float.h>
-
-#include "DNA_scene_types.h"
-
-#include "BLI_utildefines.h"
-
-#include "BKE_context.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "ED_screen.h"
-
-#include "view3d_intern.h" /* own include */
-
-/* ********** operator to open/close toolshelf region */
-
-static int view3d_toolshelf_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = view3d_has_tools_region(sa);
-
- if (ar) {
- ED_region_toggle_hidden(C, ar);
- }
-
- return OPERATOR_FINISHED;
-}
-
-void VIEW3D_OT_toolshelf(wmOperatorType *ot)
-{
- ot->name = "Toggle Toolbar";
- ot->description = "Toggles tool shelf display";
- ot->idname = "VIEW3D_OT_toolshelf";
-
- ot->exec = view3d_toolshelf_toggle_exec;
- ot->poll = ED_operator_view3d_active;
-
- /* flags */
- ot->flag = 0;
-}
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 3f078e35046..91313657f59 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -1143,7 +1143,8 @@ float ED_view3d_radius_to_dist_ortho(const float lens, const float radius)
* \param ar: Can be NULL if \a use_aspect is false.
* \param persp: Allow the caller to tell what kind of perspective to use (ortho/view/camera)
* \param use_aspect: Increase the distance to account for non 1:1 view aspect.
- * \param radius: The radius will be fitted exactly, typically pre-scaled by a margin (#VIEW3D_MARGIN).
+ * \param radius: The radius will be fitted exactly,
+ * typically pre-scaled by a margin (#VIEW3D_MARGIN).
*/
float ED_view3d_radius_to_dist(const View3D *v3d,
const ARegion *ar,
@@ -1435,7 +1436,8 @@ void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], float
/**
* Set the object transformation from RegionView3D members.
- * \param depsgraph: The depsgraph to get the evaluated object parent for the transformation calculation.
+ * \param depsgraph: The depsgraph to get the evaluated object parent
+ * for the transformation calculation.
* \param ob: The object which has the transformation assigned.
* \param ofs: The view offset, normally from RegionView3D.ofs.
* \param quat: The view rotation, quaternion normally from RegionView3D.viewquat.
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index e313ed39c49..2454358b687 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -146,7 +146,7 @@ void ED_view3d_smooth_view_ex(
}
sms.org_view = rv3d->view;
- /* sms.to_camera = false; */ /* initizlized to zero anyway */
+ /* sms.to_camera = false; */ /* initialized to zero anyway */
/* note on camera locking, this is a little confusing but works ok.
* we may be changing the view 'as if' there is no active camera, but in fact
@@ -739,9 +739,16 @@ void view3d_winmatrix_set(Depsgraph *depsgraph, ARegion *ar, const View3D *v3d,
rv3d->is_persp = !is_ortho;
#if 0
- printf("%s: %d %d %f %f %f %f %f %f\n", __func__, winx, winy,
- viewplane.xmin, viewplane.ymin, viewplane.xmax, viewplane.ymax,
- clipsta, clipend);
+ printf("%s: %d %d %f %f %f %f %f %f\n",
+ __func__,
+ winx,
+ winy,
+ viewplane.xmin,
+ viewplane.ymin,
+ viewplane.xmax,
+ viewplane.ymax,
+ clipsta,
+ clipend);
#endif
if (rect) { /* picking */
@@ -858,8 +865,8 @@ void view3d_viewmatrix_set(Depsgraph *depsgraph,
vec[2] = 0.0f;
if (rect_scale) {
- /* Since 'RegionView3D.winmat' has been calculated and this function doesn't take the 'ARegion'
- * we don't know about the region size.
+ /* Since 'RegionView3D.winmat' has been calculated and this function doesn't take the
+ * 'ARegion' we don't know about the region size.
* Use 'rect_scale' when drawing a sub-region to apply 2D offset,
* scaled by the difference between the sub-region and the region size.
*/
@@ -1223,7 +1230,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
if (local_view_bit == 0) {
/* TODO(dfelinto): We can kick one of the other 3D views out of local view
- specially if it is not being used. */
+ * specially if it is not being used. */
BKE_report(reports, RPT_ERROR, "No more than 16 local views");
ok = false;
}
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index 05e0659637b..9696f0fb315 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -27,10 +27,10 @@ set(INC
../../makesdna
../../makesrna
../../render/extern/include
- ../../windowmanager
../../depsgraph
- ../../../../intern/guardedalloc
+ ../../windowmanager
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 944c6436dfb..81405b55ac2 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -96,7 +96,8 @@
#include "transform.h"
-/* Disabling, since when you type you know what you are doing, and being able to set it to zero is handy. */
+/* Disabling, since when you type you know what you are doing,
+ * and being able to set it to zero is handy. */
// #define USE_NUM_NO_ZERO
static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg);
@@ -585,30 +586,33 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
}
else {
/* Do we need more refined tags? */
- if (t->flag & T_POSE)
+ if (t->flag & T_POSE) {
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
- else
+ }
+ else {
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
+ }
/* For real-time animation record - send notifiers recognized by animation editors */
// XXX: is this notifier a lame duck?
- if ((t->animtimer) && IS_AUTOKEY_ON(t->scene))
+ if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
+ }
}
}
else if (t->spacetype == SPACE_ACTION) {
- //SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
+ // SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_GRAPH) {
- //SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
+ // SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_NLA) {
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL);
}
else if (t->spacetype == SPACE_NODE) {
- //ED_area_tag_redraw(t->sa);
+ // ED_area_tag_redraw(t->sa);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
}
else if (t->spacetype == SPACE_SEQ) {
@@ -663,8 +667,9 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
/* if autokeying is enabled, send notifiers that keyframes were added */
- if (IS_AUTOKEY_ON(t->scene))
+ if (IS_AUTOKEY_ON(t->scene)) {
WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ }
/* redraw UV editor */
if (ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE) &&
@@ -1045,8 +1050,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
else if (event->type == MOUSEMOVE) {
- if (t->modifiers & MOD_CONSTRAINT_SELECT)
+ if (t->modifiers & MOD_CONSTRAINT_SELECT) {
t->con.mode |= CON_SELECT;
+ }
copy_v2_v2_int(t->mval, event->mval);
@@ -1380,8 +1386,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
if ((t->flag & T_NO_CONSTRAINT) == 0) {
/* exception for switching to dolly, or trackball, in camera view */
if (t->flag & T_CAMERA) {
- if (t->mode == TFM_TRANSLATION)
+ if (t->mode == TFM_TRANSLATION) {
setLocalConstraint(t, (CON_AXIS2), IFACE_("along local Z"));
+ }
else if (t->mode == TFM_ROTATION) {
restoreTransObjects(t);
initTrackball(t);
@@ -1486,8 +1493,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
case PADPLUSKEY:
if (event->alt && t->flag & T_PROP_EDIT) {
t->prop_size *= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
- if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
+ if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->clip_end);
+ }
calculatePropRatio(t);
t->redraw = TREDRAW_HARD;
handled = true;
@@ -1769,8 +1777,9 @@ static bool helpline_poll(bContext *C)
{
ARegion *ar = CTX_wm_region(C);
- if (ar && ar->regiontype == RGN_TYPE_WINDOW)
+ if (ar && ar->regiontype == RGN_TYPE_WINDOW) {
return 1;
+ }
return 0;
}
@@ -2092,20 +2101,16 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
- /* convert flag to enum */
- switch (t->flag & T_PROP_EDIT_ALL) {
- case T_PROP_EDIT:
- proportional = PROP_EDIT_ON;
- break;
- case (T_PROP_EDIT | T_PROP_CONNECTED):
- proportional = PROP_EDIT_CONNECTED;
- break;
- case (T_PROP_EDIT | T_PROP_PROJECTED):
- proportional = PROP_EDIT_PROJECTED;
- break;
- default:
- proportional = PROP_EDIT_OFF;
- break;
+ if (t->flag & T_PROP_EDIT_ALL) {
+ if (t->flag & T_PROP_EDIT) {
+ proportional |= PROP_EDIT_USE;
+ }
+ if (t->flag & T_PROP_CONNECTED) {
+ proportional |= PROP_EDIT_CONNECTED;
+ }
+ if (t->flag & T_PROP_PROJECTED) {
+ proportional |= PROP_EDIT_PROJECTED;
+ }
}
// If modal, save settings back in scene if not set as operator argument
@@ -2114,18 +2119,23 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
/* skip saving proportional edit if it was not actually used */
if (!(t->options & CTX_NO_PET)) {
- if ((prop = RNA_struct_find_property(op->ptr, "proportional")) &&
+ if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit")) &&
!RNA_property_is_set(op->ptr, prop)) {
- if (t->spacetype == SPACE_GRAPH)
+ if (t->spacetype == SPACE_GRAPH) {
ts->proportional_fcurve = proportional;
- else if (t->spacetype == SPACE_ACTION)
+ }
+ else if (t->spacetype == SPACE_ACTION) {
ts->proportional_action = proportional;
- else if (t->obedit_type != -1)
- ts->proportional = proportional;
- else if (t->options & CTX_MASK)
- ts->proportional_mask = (proportional != PROP_EDIT_OFF);
- else
- ts->proportional_objects = (proportional != PROP_EDIT_OFF);
+ }
+ else if (t->obedit_type != -1) {
+ ts->proportional_edit = proportional;
+ }
+ else if (t->options & CTX_MASK) {
+ ts->proportional_mask = proportional != 0;
+ }
+ else {
+ ts->proportional_objects = proportional != 0;
+ }
}
if ((prop = RNA_struct_find_property(op->ptr, "proportional_size"))) {
@@ -2163,8 +2173,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
- if ((prop = RNA_struct_find_property(op->ptr, "proportional"))) {
- RNA_property_enum_set(op->ptr, prop, proportional);
+ if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
+ RNA_property_boolean_set(op->ptr, prop, proportional & PROP_EDIT_USE);
+ RNA_boolean_set(op->ptr, "use_proportional_connected", proportional & PROP_EDIT_CONNECTED);
+ RNA_boolean_set(op->ptr, "use_proportional_projected", proportional & PROP_EDIT_PROJECTED);
RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
RNA_float_set(op->ptr, "proportional_size", t->prop_size);
}
@@ -2341,8 +2353,9 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* Needed to translate tweak events to mouse buttons. */
t->launch_event = event ? WM_userdef_event_type_from_keymap_type(event->type) : -1;
- // XXX Remove this when wm_operator_call_internal doesn't use window->eventstate (which can have type = 0)
- // For gizmo only, so assume LEFTMOUSE
+ /* XXX Remove this when wm_operator_call_internal doesn't use window->eventstate
+ * (which can have type = 0) */
+ /* For gizmo only, so assume LEFTMOUSE. */
if (t->launch_event == 0) {
t->launch_event = LEFTMOUSE;
}
@@ -2365,7 +2378,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
else if (t->spacetype == SPACE_IMAGE) {
t->draw_handle_view = ED_region_draw_cb_activate(
t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
- //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
t->draw_handle_cursor = WM_paint_cursor_activate(
CTX_wm_manager(C), SPACE_TYPE_ANY, RGN_TYPE_ANY, helpline_poll, drawHelpline, t);
}
@@ -2376,7 +2388,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
CTX_wm_manager(C), SPACE_TYPE_ANY, RGN_TYPE_ANY, helpline_poll, drawHelpline, t);
}
else if (t->spacetype == SPACE_NODE) {
- /*t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);*/
t->draw_handle_view = ED_region_draw_cb_activate(
t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
t->draw_handle_cursor = WM_paint_cursor_activate(
@@ -2385,14 +2396,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
else if (t->spacetype == SPACE_GRAPH) {
t->draw_handle_view = ED_region_draw_cb_activate(
t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
- //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
t->draw_handle_cursor = WM_paint_cursor_activate(
CTX_wm_manager(C), SPACE_TYPE_ANY, RGN_TYPE_ANY, helpline_poll, drawHelpline, t);
}
else if (t->spacetype == SPACE_ACTION) {
t->draw_handle_view = ED_region_draw_cb_activate(
t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
- //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
t->draw_handle_cursor = WM_paint_cursor_activate(
CTX_wm_manager(C), SPACE_TYPE_ANY, RGN_TYPE_ANY, helpline_poll, drawHelpline, t);
}
@@ -2588,10 +2597,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* same as TFM_TIME_EXTEND, but we need the mode info for later
* so that duplicate-culling will work properly
*/
- if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA))
+ if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
initTranslation(t);
- else
+ }
+ else {
initTimeTranslate(t);
+ }
t->mode = mode;
break;
case TFM_TIME_EXTEND:
@@ -2600,10 +2611,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
* (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
* depending on which editor this was called from
*/
- if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA))
+ if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
initTranslation(t);
- else
+ }
+ else {
initTimeTranslate(t);
+ }
break;
case TFM_BAKE_TIME:
initBakeTime(t);
@@ -2678,7 +2691,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
- /* Don't write into the values when non-modal because they are already set from operator redo values. */
+ /* Don't write into the values when non-modal because they are already set from operator redo
+ * values. */
if (t->flag & T_MODAL) {
/* Setup the mouse input with initial values. */
applyMouseInput(t, &t->mouse, t->mouse.imval, t->values);
@@ -2687,8 +2701,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
if ((prop = RNA_struct_find_property(op->ptr, "preserve_clnor"))) {
if ((t->flag & T_EDIT) && t->obedit_type == OB_MESH) {
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if ((((Mesh *)(tc->obedit->data))->flag & ME_AUTOSMOOTH)) {
BMEditMesh *em = NULL; // BKE_editmesh_from_object(t->obedit);
bool do_skip = false;
@@ -2781,8 +2794,7 @@ int transformEnd(bContext *C, TransInfo *t)
}
else {
if (t->flag & T_CLNOR_REBUILD) {
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BM_lnorspace_rebuild(em->bm, true);
}
@@ -2811,32 +2823,41 @@ int transformEnd(bContext *C, TransInfo *t)
static void protectedTransBits(short protectflag, float vec[3])
{
- if (protectflag & OB_LOCK_LOCX)
+ if (protectflag & OB_LOCK_LOCX) {
vec[0] = 0.0f;
- if (protectflag & OB_LOCK_LOCY)
+ }
+ if (protectflag & OB_LOCK_LOCY) {
vec[1] = 0.0f;
- if (protectflag & OB_LOCK_LOCZ)
+ }
+ if (protectflag & OB_LOCK_LOCZ) {
vec[2] = 0.0f;
+ }
}
static void protectedSizeBits(short protectflag, float size[3])
{
- if (protectflag & OB_LOCK_SCALEX)
+ if (protectflag & OB_LOCK_SCALEX) {
size[0] = 1.0f;
- if (protectflag & OB_LOCK_SCALEY)
+ }
+ if (protectflag & OB_LOCK_SCALEY) {
size[1] = 1.0f;
- if (protectflag & OB_LOCK_SCALEZ)
+ }
+ if (protectflag & OB_LOCK_SCALEZ) {
size[2] = 1.0f;
+ }
}
static void protectedRotateBits(short protectflag, float eul[3], const float oldeul[3])
{
- if (protectflag & OB_LOCK_ROTX)
+ if (protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
}
/* this function only does the delta rotation */
@@ -2845,19 +2866,24 @@ static void protectedAxisAngleBits(
short protectflag, float axis[3], float *angle, float oldAxis[3], float oldAngle)
{
/* check that protection flags are set */
- if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
+ if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) {
return;
+ }
if (protectflag & OB_LOCK_ROT4D) {
/* axis-angle getting limited as 4D entities that they are... */
- if (protectflag & OB_LOCK_ROTW)
+ if (protectflag & OB_LOCK_ROTW) {
*angle = oldAngle;
- if (protectflag & OB_LOCK_ROTX)
+ }
+ if (protectflag & OB_LOCK_ROTX) {
axis[0] = oldAxis[0];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
axis[1] = oldAxis[1];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
axis[2] = oldAxis[2];
+ }
}
else {
/* axis-angle get limited with euler... */
@@ -2866,16 +2892,20 @@ static void protectedAxisAngleBits(
axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, axis, *angle);
axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, oldAxis, oldAngle);
- if (protectflag & OB_LOCK_ROTX)
+ if (protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
eulO_to_axis_angle(axis, angle, eul, EULER_ORDER_DEFAULT);
- /* when converting to axis-angle, we need a special exception for the case when there is no axis */
+ /* When converting to axis-angle,
+ * we need a special exception for the case when there is no axis. */
if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) {
/* for now, rotate around y-axis then (so that it simply becomes the roll) */
axis[1] = 1.0f;
@@ -2887,19 +2917,24 @@ static void protectedAxisAngleBits(
static void protectedQuaternionBits(short protectflag, float quat[4], const float oldquat[4])
{
/* check that protection flags are set */
- if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
+ if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) {
return;
+ }
if (protectflag & OB_LOCK_ROT4D) {
/* quaternions getting limited as 4D entities that they are... */
- if (protectflag & OB_LOCK_ROTW)
+ if (protectflag & OB_LOCK_ROTW) {
quat[0] = oldquat[0];
- if (protectflag & OB_LOCK_ROTX)
+ }
+ if (protectflag & OB_LOCK_ROTX) {
quat[1] = oldquat[1];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
quat[2] = oldquat[2];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
quat[3] = oldquat[3];
+ }
}
else {
/* quaternions get limited with euler... (compatibility mode) */
@@ -2912,12 +2947,15 @@ static void protectedQuaternionBits(short protectflag, float quat[4], const floa
quat_to_eul(eul, nquat);
quat_to_eul(oldeul, noldquat);
- if (protectflag & OB_LOCK_ROTX)
+ if (protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
eul_to_quat(quat, eul);
@@ -2958,24 +2996,28 @@ static void constraintTransLim(TransInfo *t, TransData *td)
ListBase targets = {NULL, NULL};
/* only consider constraint if enabled */
- if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))
+ if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) {
continue;
- if (con->enforce == 0.0f)
+ }
+ if (con->enforce == 0.0f) {
continue;
+ }
/* only use it if it's tagged for this purpose (and the right type) */
if (con->type == CONSTRAINT_TYPE_LOCLIMIT) {
bLocLimitConstraint *data = con->data;
- if ((data->flag2 & LIMIT_TRANSFORM) == 0)
+ if ((data->flag2 & LIMIT_TRANSFORM) == 0) {
continue;
+ }
cti = ctiLoc;
}
else if (con->type == CONSTRAINT_TYPE_DISTLIMIT) {
bDistLimitConstraint *data = con->data;
- if ((data->flag & LIMITDIST_TRANSFORM) == 0)
+ if ((data->flag & LIMITDIST_TRANSFORM) == 0) {
continue;
+ }
cti = ctiDist;
}
@@ -3051,22 +3093,26 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
/* Evaluate valid constraints */
for (con = td->con; con; con = con->next) {
/* only consider constraint if enabled */
- if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))
+ if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) {
continue;
- if (con->enforce == 0.0f)
+ }
+ if (con->enforce == 0.0f) {
continue;
+ }
/* we're only interested in Limit-Rotation constraints */
if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
bRotLimitConstraint *data = con->data;
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM) == 0)
+ if ((data->flag2 & LIMIT_TRANSFORM) == 0) {
continue;
+ }
/* skip incompatible spacetypes */
- if (!ELEM(con->ownspace, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL))
+ if (!ELEM(con->ownspace, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL)) {
continue;
+ }
/* only do conversion if necessary, to preserve quats and eulers */
if (do_limit == false) {
@@ -3128,8 +3174,9 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
}
else {
/* Reset val if SINGLESIZE but using a constraint */
- if (td->flag & TD_SINGLESIZE)
+ if (td->flag & TD_SINGLESIZE) {
return;
+ }
/* separate out sign to apply back later */
for (i = 0; i < 3; i++) {
@@ -3143,18 +3190,21 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* Evaluate valid constraints */
for (con = td->con; con; con = con->next) {
/* only consider constraint if enabled */
- if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))
+ if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) {
continue;
- if (con->enforce == 0.0f)
+ }
+ if (con->enforce == 0.0f) {
continue;
+ }
/* we're only interested in Limit-Scale constraints */
if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
bSizeLimitConstraint *data = con->data;
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM) == 0)
+ if ((data->flag2 & LIMIT_TRANSFORM) == 0) {
continue;
+ }
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
@@ -3184,8 +3234,9 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
}
else {
/* Reset val if SINGLESIZE but using a constraint */
- if (td->flag & TD_SINGLESIZE)
+ if (td->flag & TD_SINGLESIZE) {
return;
+ }
/* extrace scale from matrix and apply back sign */
mat4_to_size(td->ext->size, cob.matrix);
@@ -3240,7 +3291,7 @@ static void initBend(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
- //copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
+ // copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
if ((t->flag & T_OVERRIDE_CENTER) == 0) {
calculateCenterCursor(t, t->center_global);
}
@@ -3364,8 +3415,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
}
/* TODO(campbell): xform, compensate object center. */
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
float warp_sta_local[3];
@@ -3391,11 +3441,13 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
float delta[3];
float fac, fac_scaled;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (UNLIKELY(values.angle == 0.0f)) {
copy_v3_v3(td->loc, td->iloc);
@@ -3579,10 +3631,12 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
unit_m3(smat);
// Custom data signals shear direction
- if (t->custom.mode.data == NULL)
+ if (t->custom.mode.data == NULL) {
smat[1][0] = value;
- else
+ }
+ else {
smat[0][1] = value;
+ }
copy_v3_v3(axismat_inv[0], t->orient_matrix[t->orient_axis_ortho]);
copy_v3_v3(axismat_inv[2], t->orient_matrix[t->orient_axis]);
@@ -3591,17 +3645,18 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
mul_m3_series(totmat, axismat_inv, smat, axismat);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
const float *center, *co;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (t->flag & T_EDIT) {
mul_m3_series(tmat, td->smtx, totmat, td->mtx);
@@ -3774,12 +3829,15 @@ static void TransMat3ToSize(float mat[3][3], float smat[3][3], float size[3])
mat3_to_rot_size(rmat, size, mat);
/* first tried with dotproduct... but the sign flip is crucial */
- if (dot_v3v3(rmat[0], smat[0]) < 0.0f)
+ if (dot_v3v3(rmat[0], smat[0]) < 0.0f) {
size[0] = -size[0];
- if (dot_v3v3(rmat[1], smat[1]) < 0.0f)
+ }
+ if (dot_v3v3(rmat[1], smat[1]) < 0.0f) {
size[1] = -size[1];
- if (dot_v3v3(rmat[2], smat[2]) < 0.0f)
+ }
+ if (dot_v3v3(rmat[2], smat[2]) < 0.0f) {
size[2] = -size[2];
+ }
}
static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3])
@@ -3844,8 +3902,9 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f
}
else {
/* Reset val if SINGLESIZE but using a constraint */
- if (td->flag & TD_SINGLESIZE)
+ if (td->flag & TD_SINGLESIZE) {
*td->val = td->ival;
+ }
td->ext->size[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor);
td->ext->size[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor);
@@ -3857,18 +3916,22 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f
}
/* For individual element center, Editmode need to use iloc */
- if (t->flag & T_POINTS)
+ if (t->flag & T_POINTS) {
sub_v3_v3v3(vec, td->iloc, center);
- else
+ }
+ else {
sub_v3_v3v3(vec, td->center, center);
+ }
mul_m3_v3(tmat, vec);
add_v3_v3(vec, center);
- if (t->flag & T_POINTS)
+ if (t->flag & T_POINTS) {
sub_v3_v3(vec, td->iloc);
- else
+ }
+ else {
sub_v3_v3(vec, td->center);
+ }
/* grease pencil falloff */
if (t->options & CTX_GPENCIL_STROKES) {
@@ -3947,15 +4010,16 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
copy_m3_m3(t->mat, mat); // used in gizmo
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
ElementResize(t, tc, td, mat);
}
@@ -3969,11 +4033,11 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
t->con.applySize(t, NULL, NULL, mat);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++)
+ for (i = 0; i < tc->data_len; i++, td++) {
ElementResize(t, tc, td, mat);
+ }
/* In proportional edit it can happen that */
/* vertices in the radius of the brush end */
@@ -4057,18 +4121,19 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
headerResize(t, size, str);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
float tmat[3][3], smat[3][3];
float fsize[3];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (t->flag & T_EDIT) {
mul_m3_m3m3(smat, mat, td->mtx);
@@ -4123,8 +4188,7 @@ static void initToSphere(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
// Calculate average radius
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
t->val += len_v3v3(tc->center_local, td->iloc);
@@ -4164,16 +4228,17 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("To Sphere: %.4f %s"), ratio, t->proptext);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
float tratio;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
sub_v3_v3v3(vec, td->iloc, tc->center_local);
@@ -4227,8 +4292,9 @@ static void initRotation(TransInfo *t)
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
- if (t->flag & T_2D_EDIT)
+ if (t->flag & T_2D_EDIT) {
t->flag |= T_NO_CONSTRAINT;
+ }
}
/* Used by Transform Rotation and Transform Normal Rotation */
@@ -4519,16 +4585,17 @@ static void applyRotationValue(TransInfo *t, float angle, float axis[3])
axis_angle_normalized_to_mat3(mat, axis, angle);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (t->con.applyRot) {
t->con.applyRot(t, tc, td, axis, NULL);
@@ -4562,7 +4629,8 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
applySnapping(t, &final);
- /* Used to clamp final result in [-PI, PI[ range, no idea why, inheritance from 2.4x area, see T48998. */
+ /* Used to clamp final result in [-PI, PI[ range, no idea why,
+ * inheritance from 2.4x area, see T48998. */
applyNumInput(&t->num, &final);
t->values[0] = final;
@@ -4620,15 +4688,16 @@ static void applyTrackballValue(TransInfo *t,
angle = normalize_v3(axis);
axis_angle_normalized_to_mat3(mat, axis, angle);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (t->flag & T_PROP_EDIT) {
axis_angle_normalized_to_mat3(mat, axis, td->factor * angle);
@@ -4762,8 +4831,7 @@ static void initNormalRotation(TransInfo *t)
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
@@ -4785,8 +4853,7 @@ static void applyNormalRotation(TransInfo *t, const int UNUSED(mval[2]))
t->con.applyRot(t, NULL, NULL, axis_final, NULL);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
@@ -4964,13 +5031,16 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
if (t->flag & T_AUTOIK) {
short chainlen = t->settings->autoik_chainlen;
- if (chainlen)
+ if (chainlen) {
BLI_snprintf(autoik, NUM_STR_REP_LEN, IFACE_("AutoIK-Len: %d"), chainlen);
- else
+ }
+ else {
autoik[0] = '\0';
+ }
}
- else
+ else {
autoik[0] = '\0';
+ }
if (t->con.mode & CON_APPLY) {
switch (t->num.idx_max) {
@@ -5073,8 +5143,7 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
/* The ideal would be "apply_snap_align_rotation" only when a snap point is found
* so, maybe inside this function is not the best place to apply this rotation.
* but you need "handle snapping rotation before doing the translation" (really?) */
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
float pivot[3];
if (apply_snap_align_rotation) {
@@ -5087,11 +5156,13 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
TransData *td = tc->data;
for (int i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
float rotate_offset[3] = {0};
bool use_rotate_offset = false;
@@ -5104,10 +5175,12 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
const float *original_normal;
/* In pose mode, we want to align normals with Y axis of bones... */
- if (t->flag & T_POSE)
+ if (t->flag & T_POSE) {
original_normal = td->axismtx[1];
- else
+ }
+ else {
original_normal = td->axismtx[2];
+ }
rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal);
}
@@ -5154,8 +5227,9 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
protectedTransBits(td->protectflag, tvec);
- if (td->loc)
+ if (td->loc) {
add_v3_v3v3(td->loc, td->iloc, tvec);
+ }
constraintTransLim(t, td);
}
@@ -5294,16 +5368,17 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0));
/* done with header string */
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
float tdistance; /* temp dist */
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
/* get the final offset */
tdistance = distance * td->factor;
@@ -5377,15 +5452,16 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Tilt: %.2f° %s"), RAD2DEGF(final), t->proptext);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival + final * td->factor;
@@ -5455,22 +5531,24 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %3f"), ratio);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival * ratio;
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
- if (*td->val <= 0.0f)
+ if (*td->val <= 0.0f) {
*td->val = 0.001f;
+ }
}
}
}
@@ -5542,43 +5620,49 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
if (ratio > 1.0f) {
initial_feather = true;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
- if (td->ival >= 0.001f)
+ if (td->ival >= 0.001f) {
initial_feather = false;
+ }
}
}
}
/* apply shrink/fatten */
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (td = tc->data, i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
- if (initial_feather)
+ if (initial_feather) {
*td->val = td->ival + (ratio - 1.0f) * 0.01f;
- else
+ }
+ else {
*td->val = td->ival * ratio;
+ }
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
- if (*td->val <= 0.0f)
+ if (*td->val <= 0.0f) {
*td->val = 0.001f;
+ }
}
}
}
@@ -5645,22 +5729,24 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %3f"), ratio);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival * ratio;
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
- if (*td->val <= 0.0f)
+ if (*td->val <= 0.0f) {
*td->val = 0.001f;
+ }
}
}
}
@@ -5725,15 +5811,16 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Opacity: %3f"), ratio);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival * ratio;
@@ -5805,15 +5892,16 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
t->con.applyRot(t, NULL, NULL, axis_global, NULL);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
sub_v3_v3v3(vec, tc->center_local, td->center);
if (t->con.applyRot && t->con.mode & CON_APPLY) {
@@ -5891,32 +5979,38 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
outputNumInput(&(t->num), c, &t->scene->unit);
- if (weight >= 0.0f)
+ if (weight >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: +%s %s"), c, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: %s %s"), c, t->proptext);
+ }
}
else {
/* default header print */
- if (weight >= 0.0f)
+ if (weight >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: +%.3f %s"), weight, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: %.3f %s"), weight, t->proptext);
+ }
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
if (td->val) {
*td->val = td->ival + weight * td->factor;
- if (*td->val < 0.0f)
+ if (*td->val < 0.0f) {
*td->val = 0.0f;
- if (*td->val > 1.0f)
+ }
+ if (*td->val > 1.0f) {
*td->val = 1.0f;
+ }
}
}
}
@@ -5975,35 +6069,42 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
outputNumInput(&(t->num), c, &t->scene->unit);
- if (crease >= 0.0f)
+ if (crease >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Crease: +%s %s"), c, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Crease: %s %s"), c, t->proptext);
+ }
}
else {
/* default header print */
- if (crease >= 0.0f)
+ if (crease >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Crease: +%.3f %s"), crease, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Crease: %.3f %s"), crease, t->proptext);
+ }
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival + crease * td->factor;
- if (*td->val < 0.0f)
+ if (*td->val < 0.0f) {
*td->val = 0.0f;
- if (*td->val > 1.0f)
+ }
+ if (*td->val > 1.0f) {
*td->val = 1.0f;
+ }
}
}
}
@@ -6058,10 +6159,11 @@ static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRA
/* hmm... perhaps the y-axis values don't need to be shown? */
if (t->con.mode & CON_APPLY) {
- if (t->num.idx_max == 0)
+ if (t->num.idx_max == 0) {
BLI_snprintf(
str, UI_MAX_DRAW_STR, IFACE_("ScaleB: %s%s %s"), &tvec[0], t->con.text, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str,
UI_MAX_DRAW_STR,
IFACE_("ScaleB: %s : %s : %s%s %s"),
@@ -6070,6 +6172,7 @@ static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRA
&tvec[NUM_STR_REP_LEN * 2],
t->con.text,
t->proptext);
+ }
}
else {
BLI_snprintf(str,
@@ -6130,15 +6233,16 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
headerBoneSize(t, size, str);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
ElementBoneSize(t, tc, td, mat);
}
@@ -6201,22 +6305,25 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Envelope: %3f"), ratio);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
/* if the old/original value was 0.0f, then just use ratio */
- if (td->ival)
+ if (td->ival) {
*td->val = td->ival * ratio;
- else
+ }
+ else {
*td->val = ratio;
+ }
}
}
}
@@ -6365,7 +6472,8 @@ static void slide_origdata_create_data(TransDataContainer *tc,
for (i = 0; i < tc->data_len; i++, td++) {
BMVert *eve = td->extra;
- /* Check the vertex has been used since both sides of the mirror may be selected & sliding. */
+ /* Check the vertex has been used since both sides
+ * of the mirror may be selected & sliding. */
if (eve && !BLI_ghash_haskey(sod->origverts, eve)) {
sv_mirror->v = eve;
copy_v3_v3(sv_mirror->co_orig_3d, eve->co);
@@ -6498,13 +6606,11 @@ static void slide_origdata_interp_data_vert(SlideOrigData *sod,
float(*faces_center)[3] = BLI_array_alloca(faces_center, l_num);
BMLoop *l;
- BM_ITER_ELEM_INDEX(l, &liter, sv->v, BM_LOOPS_OF_VERT, j)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, sv->v, BM_LOOPS_OF_VERT, j) {
BM_face_calc_center_median(l->f, faces_center[j]);
}
- BM_ITER_ELEM_INDEX(l, &liter, sv->v, BM_LOOPS_OF_VERT, j)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, sv->v, BM_LOOPS_OF_VERT, j) {
BMFace *f_copy = BLI_ghash_lookup(sod->origfaces, l->f);
float f_copy_center[3];
BMIter liter_other;
@@ -6513,8 +6619,7 @@ static void slide_origdata_interp_data_vert(SlideOrigData *sod,
BM_face_calc_center_median(f_copy, f_copy_center);
- BM_ITER_ELEM_INDEX(l_other, &liter_other, sv->v, BM_LOOPS_OF_VERT, j_other)
- {
+ BM_ITER_ELEM_INDEX (l_other, &liter_other, sv->v, BM_LOOPS_OF_VERT, j_other) {
BM_face_interp_multires_ex(bm,
l_other->f,
f_copy,
@@ -6731,7 +6836,8 @@ static BMLoop *get_next_loop(
cross_v3_v3v3(vec_accum, l_tmp->f->no, tdir);
#if 0
/* rough guess, we can do better! */
- normalize_v3_length(vec_accum, (BM_edge_calc_length(e_prev) + BM_edge_calc_length(e_next)) / 2.0f);
+ normalize_v3_length(vec_accum,
+ (BM_edge_calc_length(e_prev) + BM_edge_calc_length(e_next)) / 2.0f);
#else
/* be clever, check the opposite ngon edge to slide into.
* this gives best results */
@@ -6863,8 +6969,9 @@ static void calcEdgeSlide_mval_range(TransInfo *t,
float dist_sq;
int j, l_nr;
- if (BM_elem_flag_test(e_other, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(e_other, BM_ELEM_SELECT)) {
continue;
+ }
/* This test is only relevant if object is not wire-drawn! See [#32068]. */
if (use_occlude_geometry &&
@@ -7106,15 +7213,18 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
v = NULL;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG))
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
break;
+ }
}
- if (!v)
+ if (!v) {
break;
+ }
- if (!v->e)
+ if (!v->e) {
continue;
+ }
v_first = v;
@@ -7129,8 +7239,9 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
break;
}
- if (!BM_elem_flag_test(BM_edge_other_vert(e, v), BM_ELEM_TAG))
+ if (!BM_elem_flag_test(BM_edge_other_vert(e, v), BM_ELEM_TAG)) {
break;
+ }
v = BM_edge_other_vert(e, v);
} while (e != v_first->e);
@@ -7284,10 +7395,12 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
else {
if (l_a || l_b) {
/* find the opposite loop if it was missing previously */
- if (l_a == NULL && l_b && (l_b->radial_next != l_b))
+ if (l_a == NULL && l_b && (l_b->radial_next != l_b)) {
l_a = l_b->radial_next;
- else if (l_b == NULL && l_a && (l_a->radial_next != l_a))
+ }
+ else if (l_b == NULL && l_a && (l_a->radial_next != l_a)) {
l_b = l_a->radial_next;
+ }
}
else if (e->l != NULL) {
/* if there are non-contiguous faces, we can still recover
@@ -7560,8 +7673,7 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t
void projectEdgeSlideData(TransInfo *t, bool is_final)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
EdgeSlideData *sld = tc->custom.mode.data;
SlideOrigData *sod = &sld->orig_data;
@@ -7589,8 +7701,9 @@ void freeEdgeSlideVerts(TransInfo *UNUSED(t),
{
EdgeSlideData *sld = custom_data->data;
- if (!sld)
+ if (!sld) {
return;
+ }
freeEdgeSlideTempFaces(sld);
@@ -7631,14 +7744,12 @@ static void initEdgeSlide_ex(
}
if (use_double_side) {
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
ok |= createEdgeSlideVerts_double_side(t, tc);
}
}
else {
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
ok |= createEdgeSlideVerts_single_side(t, tc);
}
}
@@ -7648,8 +7759,7 @@ static void initEdgeSlide_ex(
return;
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
sld = tc->custom.mode.data;
if (!sld) {
continue;
@@ -7784,12 +7894,14 @@ static void drawEdgeSlide(TransInfo *t)
GPU_point_size(ctrl_size);
immBegin(GPU_PRIM_POINTS, 1);
if (slp->flipped) {
- if (curr_sv->v_side[1])
+ if (curr_sv->v_side[1]) {
immVertex3fv(pos, curr_sv->v_side[1]->co);
+ }
}
else {
- if (curr_sv->v_side[0])
+ if (curr_sv->v_side[0]) {
immVertex3fv(pos, curr_sv->v_side[0]->co);
+ }
}
immEnd();
@@ -7861,8 +7973,7 @@ static void doEdgeSlide(TransInfo *t, float perc)
if (is_clamp) {
const int side_index = (perc < 0.0f);
const float perc_final = fabsf(perc);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
EdgeSlideData *sld = tc->custom.mode.data;
TransDataEdgeSlideVert *sv = sld->sv;
for (int i = 0; i < sld->totsv; i++, sv++) {
@@ -7875,8 +7986,7 @@ static void doEdgeSlide(TransInfo *t, float perc)
const float perc_init = fabsf(perc) *
((sld_active->curr_side_unclamp == (perc < 0.0f)) ? 1 : -1);
const int side_index = sld_active->curr_side_unclamp;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
EdgeSlideData *sld = tc->custom.mode.data;
TransDataEdgeSlideVert *sv = sld->sv;
for (int i = 0; i < sld->totsv; i++, sv++) {
@@ -7896,12 +8006,14 @@ static void doEdgeSlide(TransInfo *t, float perc)
}
else {
/**
- * Implementation note, even mode ignores the starting positions and uses only the
- * a/b verts, this could be changed/improved so the distance is still met but the verts are moved along
- * their original path (which may not be straight), however how it works now is OK and matches 2.4x - Campbell
+ * Implementation note, even mode ignores the starting positions and uses
+ * only the a/b verts, this could be changed/improved so the distance is
+ * still met but the verts are moved along their original path (which may not be straight),
+ * however how it works now is OK and matches 2.4x - Campbell
*
- * \note len_v3v3(curr_sv->dir_side[0], curr_sv->dir_side[1])
- * is the same as the distance between the original vert locations, same goes for the lines below.
+ * \note `len_v3v3(curr_sv->dir_side[0], curr_sv->dir_side[1])`
+ * is the same as the distance between the original vert locations,
+ * same goes for the lines below.
*/
TransDataEdgeSlideVert *curr_sv = &sld_active->sv[sld_active->curr_sv_index];
const float curr_length_perc = curr_sv->edge_len *
@@ -7910,8 +8022,7 @@ static void doEdgeSlide(TransInfo *t, float perc)
float co_a[3];
float co_b[3];
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
EdgeSlideData *sld = tc->custom.mode.data;
TransDataEdgeSlideVert *sv = sld->sv;
for (int i = 0; i < sld->totsv; i++, sv++) {
@@ -8215,8 +8326,7 @@ static bool createVertSlideVerts(TransInfo *t, TransDataContainer *tc)
void projectVertSlideData(TransInfo *t, bool is_final)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
VertSlideData *sld = tc->custom.mode.data;
SlideOrigData *sod = &sld->orig_data;
if (sod->use_origfaces == true) {
@@ -8241,8 +8351,9 @@ void freeVertSlideVerts(TransInfo *UNUSED(t),
{
VertSlideData *sld = custom_data->data;
- if (!sld)
+ if (!sld) {
return;
+ }
freeVertSlideTempFaces(sld);
@@ -8284,8 +8395,7 @@ static void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use
}
bool ok = false;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
ok |= createVertSlideVerts(t, tc);
VertSlideData *sld = tc->custom.mode.data;
if (sld) {
@@ -8504,8 +8614,7 @@ static void doVertSlide(TransInfo *t, float perc)
slp->perc = perc;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
VertSlideData *sld = tc->custom.mode.data;
TransDataVertSlideVert *svlist = sld->sv, *sv;
int i;
@@ -8653,15 +8762,16 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
}
/* set roll values */
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
*(td->val) = td->ival - final;
}
@@ -8727,35 +8837,42 @@ static void applyBakeTime(TransInfo *t, const int mval[2])
outputNumInput(&(t->num), c, &t->scene->unit);
- if (time >= 0.0f)
+ if (time >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Time: +%s %s"), c, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Time: %s %s"), c, t->proptext);
+ }
}
else {
/* default header print */
- if (time >= 0.0f)
+ if (time >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Time: +%.3f %s"), time, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Time: %.3f %s"), time, t->proptext);
+ }
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival + time * td->factor;
- if (td->ext->size && *td->val < *td->ext->size)
+ if (td->ext->size && *td->val < *td->ext->size) {
*td->val = *td->ext->size;
- if (td->ext->quat && *td->val > *td->ext->quat)
+ }
+ if (td->ext->quat && *td->val > *td->ext->quat) {
*td->val = *td->ext->quat;
+ }
}
}
}
@@ -8807,15 +8924,16 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), IFACE_("Mirror%s"), t->con.text);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
ElementResize(t, tc, td, mat);
}
@@ -8830,15 +8948,16 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
size_to_mat3(mat, size);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
ElementResize(t, tc, td, mat);
}
@@ -8846,10 +8965,12 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- if (t->flag & T_2D_EDIT)
+ if (t->flag & T_2D_EDIT) {
ED_area_status_text(t->sa, IFACE_("Select a mirror axis (X, Y)"));
- else
+ }
+ else {
ED_area_status_text(t->sa, IFACE_("Select a mirror axis (X, Y, Z)"));
+ }
}
}
/** \} */
@@ -8874,19 +8995,20 @@ static void applyAlign(TransInfo *t, const int UNUSED(mval[2]))
float center[3];
int i;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
/* saving original center */
copy_v3_v3(center, tc->center_local);
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
float mat[3][3], invmat[3][3];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
/* around local centers */
if (t->flag & (T_OBJECT | T_POSE)) {
@@ -8973,15 +9095,16 @@ static void applySeqSlideValue(TransInfo *t, const float val[2])
{
int i;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor);
}
@@ -9037,20 +9160,23 @@ static short getAnimEdit_SnapMode(TransInfo *t)
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
- if (saction)
+ if (saction) {
autosnap = saction->autosnap;
+ }
}
else if (t->spacetype == SPACE_GRAPH) {
SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
- if (sipo)
+ if (sipo) {
autosnap = sipo->autosnap;
+ }
}
else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
- if (snla)
+ if (snla) {
autosnap = snla->autosnap;
+ }
}
else {
autosnap = SACTSNAP_OFF;
@@ -9060,10 +9186,12 @@ static short getAnimEdit_SnapMode(TransInfo *t)
* - when toggling on, prefer nearest frame over 1.0 frame increments
*/
if (t->modifiers & MOD_SNAP_INVERT) {
- if (autosnap)
+ if (autosnap) {
autosnap = SACTSNAP_OFF;
- else
+ }
+ else {
autosnap = SACTSNAP_FRAME;
+ }
}
return autosnap;
@@ -9082,10 +9210,12 @@ static void doAnimEdit_SnapFrame(
double val;
/* convert frame to nla-action time (if needed) */
- if (adt)
+ if (adt) {
val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
- else
+ }
+ else {
val = *(td->val);
+ }
/* do the snapping to nearest frame/second */
if (autosnap == SACTSNAP_FRAME) {
@@ -9096,35 +9226,42 @@ static void doAnimEdit_SnapFrame(
}
/* convert frame out of nla-action time */
- if (adt)
+ if (adt) {
*(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
*(td->val) = val;
+ }
}
/* snap key to nearest marker? */
else if (autosnap == SACTSNAP_MARKER) {
float val;
/* convert frame to nla-action time (if needed) */
- if (adt)
+ if (adt) {
val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
- else
+ }
+ else {
val = *(td->val);
+ }
/* snap to nearest marker */
// TODO: need some more careful checks for where data comes from
val = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val);
/* convert frame out of nla-action time */
- if (adt)
+ if (adt) {
*(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
*(td->val) = val;
+ }
}
- /* if the handles are to be moved too (as side-effect of keyframes moving, to keep the general effect)
- * offset them by the same amount so that the general angles are maintained (i.e. won't change while
- * handles are free-to-roam and keyframes are snap-locked)
+ /* If the handles are to be moved too
+ * (as side-effect of keyframes moving, to keep the general effect)
+ * offset them by the same amount so that the general angles are maintained
+ * (i.e. won't change while handles are free-to-roam and keyframes are snap-locked).
*/
if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) {
td2d->h1[0] = td2d->ih1[0] + *td->val - td->ival;
@@ -9197,14 +9334,18 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR])
val = (float)((double)val / secf);
}
- if (autosnap == SACTSNAP_FRAME)
+ if (autosnap == SACTSNAP_FRAME) {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%d.00 (%.4f)", (int)val, val);
- else if (autosnap == SACTSNAP_SECOND)
+ }
+ else if (autosnap == SACTSNAP_SECOND) {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%d.00 sec (%.4f)", (int)val, val);
- else if (autosnap == SACTSNAP_TSTEP)
+ }
+ else if (autosnap == SACTSNAP_TSTEP) {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f sec", val);
- else
+ }
+ else {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", val);
+ }
}
ofs += BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("DeltaX: %s"), &tvec[0]);
@@ -9225,11 +9366,11 @@ static void applyTimeTranslateValue(TransInfo *t)
float deltax, val /* , valprev */;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
TransData2D *td2d = tc->data_2d;
- /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
+ /* It doesn't matter whether we apply to t->data or
+ * t->data2d, but t->data2d is more convenient. */
for (i = 0; i < tc->data_len; i++, td++, td2d++) {
/* it is assumed that td->extra is a pointer to the AnimData,
* whose active action is where this keyframe comes from
@@ -9334,21 +9475,23 @@ static void initTimeSlide(TransInfo *t)
float min = 999999999.0f, max = -999999999.0f;
int i;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
float val = *(td->val);
/* strip/action time to global (mapped) time */
- if (adt)
+ if (adt) {
val = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_MAP);
+ }
- if (min > val)
+ if (min > val) {
min = val;
- if (max < val)
+ }
+ if (max < val) {
max = val;
+ }
}
}
@@ -9415,9 +9558,9 @@ static void applyTimeSlideValue(TransInfo *t, float sval)
saction->timeslide = cvalf;
}
- /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ /* It doesn't matter whether we apply to t->data or
+ * t->data2d, but t->data2d is more convenient. */
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
/* it is assumed that td->extra is a pointer to the AnimData,
@@ -9548,10 +9691,12 @@ static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR])
{
char tvec[NUM_STR_REP_LEN * 3];
- if (hasNumInput(&t->num))
+ if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec, &t->scene->unit);
- else
+ }
+ else {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", t->values[0]);
+ }
BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("ScaleX: %s"), &tvec[0]);
}
@@ -9564,8 +9709,7 @@ static void applyTimeScaleValue(TransInfo *t)
const short autosnap = getAnimEdit_SnapMode(t);
const double secf = FPS;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
TransData2D *td2d = tc->data_2d;
for (i = 0; i < tc->data_len; i++, td++, td2d++) {
@@ -9588,8 +9732,9 @@ static void applyTimeScaleValue(TransInfo *t)
fac = ((fac - 1.0f) * td->factor) + 1;
/* check if any need to apply nla-mapping */
- if (adt)
+ if (adt) {
startx = BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
+ }
/* now, calculate the new value */
*(td->val) = ((td->ival - startx) * fac) + startx;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 6451d82e45c..50fc1a276b9 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -824,9 +824,10 @@ enum {
TD_BEZTRIPLE = 1 << 12,
/** when this is set, don't apply translation changes to this element */
TD_NO_LOC = 1 << 13,
- /** for Graph Editor autosnap, indicates that point should not undergo autosnapping */
+ /** For Graph Editor autosnap, indicates that point should not undergo autosnapping */
TD_NOTIMESNAP = 1 << 14,
- /** for Graph Editor - curves that can only have int-values need their keyframes tagged with this */
+ /** For Graph Editor - curves that can only have int-values
+ * need their keyframes tagged with this. */
TD_INTVALUES = 1 << 15,
/** For editmode mirror, clamp to x = 0 */
TD_MIRROR_EDGE = 1 << 16,
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 27d6e597931..ee08eb20ea3 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -129,14 +129,17 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3])
snapGridIncrement(t, vec);
if (t->flag & T_NULL_ONE) {
- if (!(t->con.mode & CON_AXIS0))
+ if (!(t->con.mode & CON_AXIS0)) {
vec[0] = 1.0f;
+ }
- if (!(t->con.mode & CON_AXIS1))
+ if (!(t->con.mode & CON_AXIS1)) {
vec[1] = 1.0f;
+ }
- if (!(t->con.mode & CON_AXIS2))
+ if (!(t->con.mode & CON_AXIS2)) {
vec[2] = 1.0f;
+ }
}
if (applyNumInput(&t->num, vec)) {
@@ -219,11 +222,14 @@ static void axisProjection(const TransInfo *t,
if (angle < DEG2RADF(5.0f)) {
project_v3_v3v3(vec, in, t->viewinv[1]);
factor = dot_v3v3(t->viewinv[1], vec) * 2.0f;
- /* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */
- if (factor < 0.0f)
+ /* Since camera distance is quite relative, use quadratic relationship.
+ * holding shift can compensate. */
+ if (factor < 0.0f) {
factor *= -factor;
- else
+ }
+ else {
factor *= factor;
+ }
/* -factor makes move down going backwards */
normalize_v3_v3_length(out, axis, -factor);
@@ -266,12 +272,15 @@ static void axisProjection(const TransInfo *t,
/* possible some values become nan when
* viewpoint and object are both zero */
- if (!isfinite(out[0]))
+ if (!isfinite(out[0])) {
out[0] = 0.0f;
- if (!isfinite(out[1]))
+ }
+ if (!isfinite(out[1])) {
out[1] = 0.0f;
- if (!isfinite(out[2]))
+ }
+ if (!isfinite(out[2])) {
out[2] = 0.0f;
+ }
}
}
}
@@ -740,12 +749,15 @@ void drawConstraint(TransInfo *t)
{
TransCon *tc = &(t->con);
- if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE))
+ if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) {
return;
- if (!(tc->mode & CON_APPLY))
+ }
+ if (!(tc->mode & CON_APPLY)) {
return;
- if (t->flag & T_NO_CONSTRAINT)
+ }
+ if (t->flag & T_NO_CONSTRAINT) {
return;
+ }
if (tc->drawExtra) {
tc->drawExtra(t);
@@ -763,8 +775,9 @@ void drawConstraint(TransInfo *t)
drawLine(t, t->center_global, tc->mtx[2], 'Z', 0);
depth_test_enabled = GPU_depth_test_enabled();
- if (depth_test_enabled)
+ if (depth_test_enabled) {
GPU_depth_test(false);
+ }
const uint shdr_pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -787,8 +800,9 @@ void drawConstraint(TransInfo *t)
immUnbindProgram();
- if (depth_test_enabled)
+ if (depth_test_enabled) {
GPU_depth_test(true);
+ }
}
if (tc->mode & CON_AXIS0) {
@@ -840,8 +854,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
}
depth_test_enabled = GPU_depth_test_enabled();
- if (depth_test_enabled)
+ if (depth_test_enabled) {
GPU_depth_test(false);
+ }
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -854,8 +869,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
immUnbindProgram();
- if (depth_test_enabled)
+ if (depth_test_enabled) {
GPU_depth_test(true);
+ }
GPU_matrix_pop();
}
@@ -873,8 +889,7 @@ static void drawObjectConstraint(TransInfo *t)
int i;
float tmp_axismtx[3][3];
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
float co[3];
@@ -990,8 +1005,9 @@ void selectConstraint(TransInfo *t)
void postSelectConstraint(TransInfo *t)
{
- if (!(t->con.mode & CON_SELECT))
+ if (!(t->con.mode & CON_SELECT)) {
return;
+ }
t->con.mode &= ~CON_AXIS0;
t->con.mode &= ~CON_AXIS1;
@@ -1150,14 +1166,17 @@ bool isLockConstraint(TransInfo *t)
{
int mode = t->con.mode;
- if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1))
+ if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1)) {
return true;
+ }
- if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2))
+ if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2)) {
return true;
+ }
- if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2))
+ if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2)) {
return true;
+ }
return false;
}
@@ -1174,21 +1193,24 @@ int getConstraintSpaceDimension(TransInfo *t)
{
int n = 0;
- if (t->con.mode & CON_AXIS0)
+ if (t->con.mode & CON_AXIS0) {
n++;
+ }
- if (t->con.mode & CON_AXIS1)
+ if (t->con.mode & CON_AXIS1) {
n++;
+ }
- if (t->con.mode & CON_AXIS2)
+ if (t->con.mode & CON_AXIS2) {
n++;
+ }
return n;
/*
- * Someone willing to do it cryptically could do the following instead:
- *
- * return t->con & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
- *
- * Based on the assumptions that the axis flags are one after the other and start at 1
- */
+ * Someone willing to do it cryptically could do the following instead:
+ *
+ * return t->con & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
+ *
+ * Based on the assumptions that the axis flags are one after the other and start at 1
+ */
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index b682617f348..6c1da5ae825 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -146,12 +146,15 @@ static int trans_data_compare_dist(const void *a, const void *b)
const TransData *td_a = (const TransData *)a;
const TransData *td_b = (const TransData *)b;
- if (td_a->dist < td_b->dist)
+ if (td_a->dist < td_b->dist) {
return -1;
- else if (td_a->dist > td_b->dist)
+ }
+ else if (td_a->dist > td_b->dist) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static int trans_data_compare_rdist(const void *a, const void *b)
@@ -159,12 +162,15 @@ static int trans_data_compare_rdist(const void *a, const void *b)
const TransData *td_a = (const TransData *)a;
const TransData *td_b = (const TransData *)b;
- if (td_a->rdist < td_b->rdist)
+ if (td_a->rdist < td_b->rdist) {
return -1;
- else if (td_a->rdist > td_b->rdist)
+ }
+ else if (td_a->rdist > td_b->rdist) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static void sort_trans_data_dist_container(const TransInfo *t, TransDataContainer *tc)
@@ -187,8 +193,7 @@ static void sort_trans_data_dist_container(const TransInfo *t, TransDataContaine
}
void sort_trans_data_dist(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
sort_trans_data_dist_container(t, tc);
}
}
@@ -222,8 +227,7 @@ static void sort_trans_data_container(TransDataContainer *tc)
}
static void sort_trans_data(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
sort_trans_data_container(tc);
}
}
@@ -248,8 +252,7 @@ static void set_prop_dist(TransInfo *t, const bool with_dist)
}
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *tob = tc->data;
for (a = 0; a < tc->data_len; a++, tob++) {
@@ -453,8 +456,7 @@ static void createTransCursor_view3d(TransInfo *t)
static void createTransEdge(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
TransData *td = NULL;
@@ -467,10 +469,12 @@ static void createTransEdge(TransInfo *t)
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
countsel++;
- if (is_prop_edit)
+ }
+ if (is_prop_edit) {
count++;
+ }
}
}
@@ -496,7 +500,7 @@ static void createTransEdge(TransInfo *t)
BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_BWEIGHT);
cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT);
}
- else { //if (t->mode == TFM_CREASE) {
+ else { // if (t->mode == TFM_CREASE) {
BLI_assert(t->mode == TFM_CREASE);
BM_mesh_cd_flag_ensure(em->bm, BKE_mesh_from_object(tc->obedit), ME_CDFLAG_EDGE_CREASE);
cd_edge_float_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE);
@@ -512,10 +516,12 @@ static void createTransEdge(TransInfo *t)
mid_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
td->loc = NULL;
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -542,10 +548,12 @@ static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan)
if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce != 0.0f)) {
bKinematicConstraint *data = con->data;
- if (data->tar == NULL)
+ if (data->tar == NULL) {
return data;
- if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)
+ }
+ if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0) {
return data;
+ }
}
}
return NULL;
@@ -569,18 +577,21 @@ static short apply_targetless_ik(Object *ob)
segcount = 0;
/* exclude tip from chain? */
- if (!(data->flag & CONSTRAINT_IK_TIP))
+ if (!(data->flag & CONSTRAINT_IK_TIP)) {
parchan = pchan->parent;
- else
+ }
+ else {
parchan = pchan;
+ }
/* Find the chain's root & count the segments needed */
for (; parchan; parchan = parchan->parent) {
chanlist[segcount] = parchan;
segcount++;
- if (segcount == data->rootbone || segcount > 255)
+ if (segcount == data->rootbone || segcount > 255) {
break; // 255 is weak
+ }
}
for (; segcount; segcount--) {
Bone *bone;
@@ -600,32 +611,19 @@ static short apply_targetless_ik(Object *ob)
/* apply and decompose, doesn't work for constraints or non-uniform scale well */
{
float rmat3[3][3], qrmat[3][3], imat3[3][3], smat[3][3];
-
copy_m3_m4(rmat3, rmat);
/* rotation */
/* [#22409] is partially caused by this, as slight numeric error introduced during
* the solving process leads to locked-axis values changing. However, we cannot modify
* the values here, or else there are huge discrepancies between IK-solver (interactive)
- * and applied poses.
- */
- if (parchan->rotmode > 0)
- mat3_to_eulO(parchan->eul, parchan->rotmode, rmat3);
- else if (parchan->rotmode == ROT_MODE_AXISANGLE)
- mat3_to_axis_angle(parchan->rotAxis, &parchan->rotAngle, rmat3);
- else
- mat3_to_quat(parchan->quat, rmat3);
+ * and applied poses. */
+ BKE_pchan_mat3_to_rot(parchan, rmat3, false);
/* for size, remove rotation */
/* causes problems with some constraints (so apply only if needed) */
if (data->flag & CONSTRAINT_IK_STRETCH) {
- if (parchan->rotmode > 0)
- eulO_to_mat3(qrmat, parchan->eul, parchan->rotmode);
- else if (parchan->rotmode == ROT_MODE_AXISANGLE)
- axis_angle_to_mat3(qrmat, parchan->rotAxis, parchan->rotAngle);
- else
- quat_to_mat3(qrmat, parchan->quat);
-
+ BKE_pchan_rot_to_mat3(parchan, qrmat);
invert_m3_m3(imat3, qrmat);
mul_m3_m3m3(smat, rmat3, imat3);
mat3_to_size(parchan->size, smat);
@@ -711,10 +709,12 @@ static void add_pose_transdata(
float rpmat[3][3];
BKE_bone_parent_transform_calc_from_pchan(pchan, &bpt);
- if (t->mode == TFM_TRANSLATION)
+ if (t->mode == TFM_TRANSLATION) {
copy_m3_m4(pmat, bpt.loc_mat);
- else
+ }
+ else {
copy_m3_m4(pmat, bpt.rotscale_mat);
+ }
/* Grrr! Exceptional case: When translating pose bones that are either Hinge or NoLocal,
* and want align snapping, we just need both loc_mat and rotscale_mat.
@@ -831,16 +831,19 @@ int count_set_pose_transflags(Object *ob,
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
bone = pchan->bone;
if (PBONE_VISIBLE(arm, bone)) {
- if ((bone->flag & BONE_SELECTED))
+ if ((bone->flag & BONE_SELECTED)) {
bone->flag |= BONE_TRANSFORM;
- else
+ }
+ else {
bone->flag &= ~BONE_TRANSFORM;
+ }
bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM;
bone->flag &= ~BONE_TRANSFORM_CHILD;
}
- else
+ else {
bone->flag &= ~BONE_TRANSFORM;
+ }
}
/* make sure no bone can be transformed when a parent is transformed */
@@ -848,8 +851,9 @@ int count_set_pose_transflags(Object *ob,
if (!ELEM(mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
bone = pchan->bone;
- if (bone->flag & BONE_TRANSFORM)
+ if (bone->flag & BONE_TRANSFORM) {
bone_children_clear_transflag(mode, around, &bone->childbase);
+ }
}
}
/* now count, and check if we have autoIK or have to switch from translate to rotate */
@@ -947,8 +951,7 @@ void transform_autoik_update(TransInfo *t, short mode)
/* apply to all pose-channels */
bool changed = false;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
/* sanity checks (don't assume t->poseobj is set, or that it is an armature) */
if (ELEM(NULL, tc->poseobj, tc->poseobj->pose)) {
@@ -997,8 +1000,9 @@ static void pose_grab_with_ik_clear(Main *bmain, Object *ob)
continue;
}
pchan->constflag |= PCHAN_HAS_IK;
- if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0))
+ if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) {
pchan->constflag |= PCHAN_HAS_TARGET;
+ }
}
}
}
@@ -1017,8 +1021,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
bConstraint *con;
/* Sanity check */
- if (pchan == NULL)
+ if (pchan == NULL) {
return 0;
+ }
/* Rule: not if there's already an IK on this channel */
for (con = pchan->constraints.first; con; con = con->next) {
@@ -1040,12 +1045,15 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
for (; pchan; pchan = pchan->parent) {
/* here, we set ik-settings for bone from pchan->protectflag */
// XXX: careful with quats/axis-angle rotations where we're locking 4d components
- if (pchan->protectflag & OB_LOCK_ROTX)
+ if (pchan->protectflag & OB_LOCK_ROTX) {
pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
- if (pchan->protectflag & OB_LOCK_ROTY)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTY) {
pchan->ikflag |= BONE_IK_NO_YDOF_TEMP;
- if (pchan->protectflag & OB_LOCK_ROTZ)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTZ) {
pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP;
+ }
}
}
@@ -1053,8 +1061,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
}
}
- if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f))
+ if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) {
return 0;
+ }
}
}
@@ -1068,8 +1077,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
/* if exists, use values from last targetless (but disabled) IK-constraint as base */
*data = *targetless;
}
- else
+ else {
data->flag = CONSTRAINT_IK_TIP;
+ }
data->flag |= CONSTRAINT_IK_TEMP | CONSTRAINT_IK_AUTO | CONSTRAINT_IK_POS;
copy_v3_v3(data->grabtarget, pchan->pose_tail);
@@ -1081,21 +1091,26 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
do {
/* here, we set ik-settings for bone from pchan->protectflag */
// XXX: careful with quats/axis-angle rotations where we're locking 4d components
- if (pchan->protectflag & OB_LOCK_ROTX)
+ if (pchan->protectflag & OB_LOCK_ROTX) {
pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
- if (pchan->protectflag & OB_LOCK_ROTY)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTY) {
pchan->ikflag |= BONE_IK_NO_YDOF_TEMP;
- if (pchan->protectflag & OB_LOCK_ROTZ)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTZ) {
pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP;
+ }
/* now we count this pchan as being included */
data->rootbone++;
/* continue to parent, but only if we're connected to it */
- if (pchan->bone->flag & BONE_CONNECTED)
+ if (pchan->bone->flag & BONE_CONNECTED) {
pchan = pchan->parent;
- else
+ }
+ else {
pchan = NULL;
+ }
} while (pchan);
/* make a copy of maximum chain-length */
@@ -1119,8 +1134,9 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone)
}
if (wentdeeper == 0) {
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name);
- if (pchan)
+ if (pchan) {
added += pose_grab_with_ik_add(pchan);
+ }
}
return added;
@@ -1134,8 +1150,9 @@ static short pose_grab_with_ik(Main *bmain, Object *ob)
Bone *bonec;
short tot_ik = 0;
- if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0)
+ if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0) {
return 0;
+ }
arm = ob->data;
@@ -1150,18 +1167,21 @@ static short pose_grab_with_ik(Main *bmain, Object *ob)
break;
}
}
- if ((pchan->bone->flag & BONE_CONNECTED) == 0 && (bonec == NULL))
+ if ((pchan->bone->flag & BONE_CONNECTED) == 0 && (bonec == NULL)) {
continue;
+ }
/* rule: if selected Bone is not a root bone, it gets a temporal IK */
if (pchan->parent) {
/* only adds if there's no IK yet (and no parent bone was selected) */
for (parent = pchan->parent; parent; parent = parent->parent) {
- if (parent->bone->flag & BONE_SELECTED)
+ if (parent->bone->flag & BONE_SELECTED) {
break;
+ }
}
- if (parent == NULL)
+ if (parent == NULL) {
tot_ik += pose_grab_with_ik_add(pchan);
+ }
}
else {
/* rule: go over the children and add IK to the tips */
@@ -1193,8 +1213,7 @@ static void createTransPose(TransInfo *t)
bool has_translate_rotate_buf[2] = {false, false};
bool *has_translate_rotate = (t->mode == TFM_TRANSLATION) ? has_translate_rotate_buf : NULL;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Object *ob = tc->poseobj;
bArmature *arm;
@@ -1240,8 +1259,7 @@ static void createTransPose(TransInfo *t)
}
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->data_len == 0) {
continue;
}
@@ -1288,10 +1306,18 @@ static void createTransPose(TransInfo *t)
void restoreBones(TransDataContainer *tc)
{
- bArmature *arm = tc->obedit->data;
+ bArmature *arm;
BoneInitData *bid = tc->custom.type.data;
EditBone *ebo;
+ if (tc->obedit) {
+ arm = tc->obedit->data;
+ }
+ else {
+ BLI_assert(tc->poseobj != NULL);
+ arm = tc->poseobj->data;
+ }
+
while (bid->bone) {
ebo = bid->bone;
@@ -1331,8 +1357,7 @@ static void createTransArmatureVerts(TransInfo *t)
{
t->data_len_all = 0;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
EditBone *ebo, *eboflip;
bArmature *arm = tc->obedit->data;
ListBase *edbo = arm->edbo;
@@ -1345,25 +1370,30 @@ static void createTransArmatureVerts(TransInfo *t)
if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
- if (ebo->flag & BONE_SELECTED)
+ if (ebo->flag & BONE_SELECTED) {
tc->data_len++;
+ }
}
else if (t->mode == TFM_BONE_ROLL) {
- if (ebo->flag & BONE_SELECTED)
+ if (ebo->flag & BONE_SELECTED) {
tc->data_len++;
+ }
}
else {
- if (ebo->flag & BONE_TIPSEL)
+ if (ebo->flag & BONE_TIPSEL) {
tc->data_len++;
- if (ebo->flag & BONE_ROOTSEL)
+ }
+ if (ebo->flag & BONE_ROOTSEL) {
tc->data_len++;
+ }
}
}
if (mirror && (data_len_prev < tc->data_len)) {
eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo);
- if (eboflip)
+ if (eboflip) {
total_mirrored++;
+ }
}
}
if (!tc->data_len) {
@@ -1385,8 +1415,7 @@ static void createTransArmatureVerts(TransInfo *t)
transform_around_single_fallback(t);
t->data_len_all = -1;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (!tc->data_len) {
continue;
}
@@ -1507,8 +1536,9 @@ static void createTransArmatureVerts(TransInfo *t)
td->loc = ebo->tail;
td->flag = TD_SELECTED;
- if (ebo->flag & BONE_EDITMODE_LOCKED)
+ if (ebo->flag & BONE_EDITMODE_LOCKED) {
td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
+ }
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1531,8 +1561,9 @@ static void createTransArmatureVerts(TransInfo *t)
copy_v3_v3(td->center, td->iloc);
td->loc = ebo->head;
td->flag = TD_SELECTED;
- if (ebo->flag & BONE_EDITMODE_LOCKED)
+ if (ebo->flag & BONE_EDITMODE_LOCKED) {
td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
+ }
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1579,8 +1610,7 @@ static void createTransArmatureVerts(TransInfo *t)
static void createTransMBallVerts(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
MetaBall *mb = (MetaBall *)tc->obedit->data;
MetaElem *ml;
TransData *td;
@@ -1591,10 +1621,12 @@ static void createTransMBallVerts(TransInfo *t)
/* count totals */
for (ml = mb->editelems->first; ml; ml = ml->next) {
- if (ml->flag & SELECT)
+ if (ml->flag & SELECT) {
countsel++;
- if (is_prop_edit)
+ }
+ if (is_prop_edit) {
count++;
+ }
}
/* note: in prop mode we need at least 1 selected */
@@ -1602,10 +1634,12 @@ static void createTransMBallVerts(TransInfo *t)
continue;
}
- if (is_prop_edit)
+ if (is_prop_edit) {
tc->data_len = count;
- else
+ }
+ else {
tc->data_len = countsel;
+ }
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(MBall EditMode)");
tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension),
@@ -1622,10 +1656,12 @@ static void createTransMBallVerts(TransInfo *t)
quat_to_mat3(td->axismtx, ml->quat);
- if (ml->flag & SELECT)
+ if (ml->flag & SELECT) {
td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
- else
+ }
+ else {
td->flag = TD_USEQUAT;
+ }
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1766,8 +1802,7 @@ static void createTransCurveVerts(TransInfo *t)
t->data_len_all = 0;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Curve *cu = tc->obedit->data;
BLI_assert(cu->editnurb != NULL);
BezTriple *bezt;
@@ -1796,18 +1831,21 @@ static void createTransCurveVerts(TransInfo *t)
if (bezt_tx & SEL_F3) {
countsel++;
}
- if (is_prop_edit)
+ if (is_prop_edit) {
count += 3;
+ }
}
}
}
else {
for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
if (bp->hide == 0) {
- if (is_prop_edit)
+ if (is_prop_edit) {
count++;
- if (bp->f1 & SELECT)
+ }
+ if (bp->f1 & SELECT) {
countsel++;
+ }
}
}
}
@@ -1818,10 +1856,12 @@ static void createTransCurveVerts(TransInfo *t)
continue;
}
- if (is_prop_edit)
+ if (is_prop_edit) {
tc->data_len = count;
- else
+ }
+ else {
tc->data_len = countsel;
+ }
tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Curve EditMode)");
t->data_len_all += tc->data_len;
@@ -1830,8 +1870,7 @@ static void createTransCurveVerts(TransInfo *t)
transform_around_single_fallback(t);
t->data_len_all = -1;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->data_len == 0) {
continue;
}
@@ -1890,16 +1929,20 @@ static void createTransCurveVerts(TransInfo *t)
1 :
0]);
if (hide_handles) {
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
}
else {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
}
td->ext = NULL;
td->val = NULL;
@@ -1921,10 +1964,12 @@ static void createTransCurveVerts(TransInfo *t)
copy_v3_v3(td->iloc, bezt->vec[1]);
td->loc = bezt->vec[1];
copy_v3_v3(td->center, td->loc);
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
td->ext = NULL;
/* TODO - make points scale */
@@ -1946,12 +1991,13 @@ static void createTransCurveVerts(TransInfo *t)
copy_m3_m3(td->axismtx, axismtx);
}
- if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0)
+ if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0) {
/* If the middle is selected but the sides arnt, this is needed */
if (hdata == NULL) {
/* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandles(td, bezt);
}
+ }
td++;
tail++;
@@ -1965,16 +2011,20 @@ static void createTransCurveVerts(TransInfo *t)
1 :
2]);
if (hide_handles) {
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
}
else {
- if (bezt->f3 & SELECT)
+ if (bezt->f3 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
}
td->ext = NULL;
td->val = NULL;
@@ -2001,11 +2051,12 @@ static void createTransCurveVerts(TransInfo *t)
head = tail;
}
}
- if (is_prop_edit && head != tail)
+ if (is_prop_edit && head != tail) {
calc_distanceCurveVerts(head, tail - 1);
+ }
- /* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles
- * but for now just don't change handle types */
+ /* TODO - in the case of tilt and radius we can also avoid allocating the
+ * initTransDataCurveHandles but for now just don't change handle types */
if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT, TFM_DUMMY) == 0) {
/* sets the handles based on their selection,
* do this after the data is copied to the TransData */
@@ -2041,10 +2092,12 @@ static void createTransCurveVerts(TransInfo *t)
copy_v3_v3(td->iloc, bp->vec);
td->loc = bp->vec;
copy_v3_v3(td->center, td->loc);
- if (bp->f1 & SELECT)
+ if (bp->f1 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
td->ext = NULL;
if (t->mode == TFM_CURVE_SHRINKFATTEN || t->mode == TFM_RESIZE) {
@@ -2073,8 +2126,9 @@ static void createTransCurveVerts(TransInfo *t)
head = tail;
}
}
- if (is_prop_edit && head != tail)
+ if (is_prop_edit && head != tail) {
calc_distanceCurveVerts(head, tail - 1);
+ }
}
}
}
@@ -2087,8 +2141,7 @@ static void createTransCurveVerts(TransInfo *t)
static void createTransLatticeVerts(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Lattice *latt = ((Lattice *)tc->obedit->data)->editlatt->latt;
TransData *td = NULL;
@@ -2102,22 +2155,27 @@ static void createTransLatticeVerts(TransInfo *t)
a = latt->pntsu * latt->pntsv * latt->pntsw;
while (a--) {
if (bp->hide == 0) {
- if (bp->f1 & SELECT)
+ if (bp->f1 & SELECT) {
countsel++;
- if (is_prop_edit)
+ }
+ if (is_prop_edit) {
count++;
+ }
}
bp++;
}
/* note: in prop mode we need at least 1 selected */
- if (countsel == 0)
+ if (countsel == 0) {
return;
+ }
- if (is_prop_edit)
+ if (is_prop_edit) {
tc->data_len = count;
- else
+ }
+ else {
tc->data_len = countsel;
+ }
tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Lattice EditMode)");
copy_m3_m4(mtx, tc->obedit->obmat);
@@ -2155,8 +2213,7 @@ static void createTransLatticeVerts(TransInfo *t)
/* ******************* particle edit **************** */
static void createTransParticleVerts(bContext *C, TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = NULL;
TransDataExtension *tx;
@@ -2171,8 +2228,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
int count = 0, hasselected = 0;
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
- if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH)
+ if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) {
return;
+ }
psys = edit->psys;
@@ -2187,8 +2245,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
hasselected = 1;
transformparticle = 1;
}
- else if (is_prop_edit)
+ else if (is_prop_edit) {
transformparticle = 1;
+ }
}
}
}
@@ -2200,17 +2259,20 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
}
/* note: in prop mode we need at least 1 selected */
- if (hasselected == 0)
+ if (hasselected == 0) {
return;
+ }
tc->data_len = count;
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Particle Mode)");
- if (t->mode == TFM_BAKE_TIME)
+ if (t->mode == TFM_BAKE_TIME) {
tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension),
"Particle_TransExtension");
- else
+ }
+ else {
tx = tc->data_ext = NULL;
+ }
unit_m4(mat);
@@ -2220,8 +2282,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
TransData *head, *tail;
head = tail = td;
- if (!(point->flag & PEP_TRANSFORM))
+ if (!(point->flag & PEP_TRANSFORM)) {
continue;
+ }
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
@@ -2235,23 +2298,27 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
mul_m4_v3(mat, key->world_co);
td->loc = key->world_co;
}
- else
+ else {
td->loc = key->co;
+ }
copy_v3_v3(td->iloc, td->loc);
copy_v3_v3(td->center, td->loc);
- if (key->flag & PEK_SELECT)
+ if (key->flag & PEK_SELECT) {
td->flag |= TD_SELECTED;
- else if (!is_prop_edit)
+ }
+ else if (!is_prop_edit) {
td->flag |= TD_SKIP;
+ }
unit_m3(td->mtx);
unit_m3(td->smtx);
/* don't allow moving roots */
- if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR)))
+ if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR))) {
td->protectflag |= OB_LOCK_LOC;
+ }
td->ob = ob;
td->ext = tx;
@@ -2260,32 +2327,37 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
td->ival = *(key->time);
/* abuse size and quat for min/max values */
td->flag |= TD_NO_EXT;
- if (k == 0)
+ if (k == 0) {
tx->size = NULL;
- else
+ }
+ else {
tx->size = (key - 1)->time;
+ }
- if (k == point->totkey - 1)
+ if (k == point->totkey - 1) {
tx->quat = NULL;
- else
+ }
+ else {
tx->quat = (key + 1)->time;
+ }
}
td++;
- if (tx)
+ if (tx) {
tx++;
+ }
tail++;
}
- if (is_prop_edit && head != tail)
+ if (is_prop_edit && head != tail) {
calc_distanceCurveVerts(head, tail - 1);
+ }
}
}
}
void flushTransParticles(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Scene *scene = t->scene;
ViewLayer *view_layer = t->view_layer;
Object *ob = OBACT(view_layer);
@@ -2302,8 +2374,9 @@ void flushTransParticles(TransInfo *t)
* back to particle local space (only for hair particles) */
td = tc->data;
for (i = 0, point = edit->points; i < edit->totpoint; i++, point++, td++) {
- if (!(point->flag & PEP_TRANSFORM))
+ if (!(point->flag & PEP_TRANSFORM)) {
continue;
+ }
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
@@ -2322,8 +2395,9 @@ void flushTransParticles(TransInfo *t)
}
}
}
- else
+ else {
point->flag |= PEP_EDIT_RECALC;
+ }
}
PE_update_object(t->depsgraph, scene, OBACT(view_layer), 1);
@@ -2679,9 +2753,9 @@ static void VertsToTransData(TransInfo *t,
BLI_assert(BM_elem_flag_test(eve, BM_ELEM_HIDDEN) == 0);
td->flag = 0;
- //if (key)
+ // if (key)
// td->loc = key->co;
- //else
+ // else
td->loc = eve->co;
copy_v3_v3(td->iloc, td->loc);
@@ -2739,8 +2813,7 @@ static void VertsToTransData(TransInfo *t,
static void createTransEditVerts(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *tob = NULL;
TransDataExtension *tx = NULL;
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
@@ -2784,7 +2857,8 @@ static void createTransEditVerts(TransInfo *t)
/**
* Quick check if we can transform.
*
- * \note ignore modes here, even in edge/face modes, transform data is created by selected vertices.
+ * \note ignore modes here, even in edge/face modes,
+ * transform data is created by selected vertices.
* \note in prop mode we need at least 1 selected.
*/
if (bm->totvertsel == 0) {
@@ -2838,7 +2912,8 @@ static void createTransEditVerts(TransInfo *t)
}
if (is_island_center) {
- /* In this specific case, near-by vertices will need to know the island of the nearest connected vertex. */
+ /* In this specific case, near-by vertices will need to know
+ * the island of the nearest connected vertex. */
const bool calc_single_islands = ((prop_mode & T_PROP_CONNECTED) &&
(t->around == V3D_AROUND_LOCAL_ORIGINS) &&
(em->selectmode & SCE_SELECT_VERTEX));
@@ -2874,8 +2949,9 @@ static void createTransEditVerts(TransInfo *t)
mappedcos = BKE_crazyspace_get_mapped_editverts(t->depsgraph, t->scene, tc->obedit);
quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats");
BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !prop_mode);
- if (mappedcos)
+ if (mappedcos) {
MEM_freeN(mappedcos);
+ }
}
if (defcos) {
@@ -2914,12 +2990,14 @@ static void createTransEditVerts(TransInfo *t)
/* Do not use the island center in case we are using islands
* only to get axis for snap/rotate to normal... */
VertsToTransData(t, tob, tx, em, eve, bweight, v_island, is_snap_rotate);
- if (tx)
+ if (tx) {
tx++;
+ }
/* selected */
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
tob->flag |= TD_SELECTED;
+ }
if (prop_mode) {
if (prop_mode & T_PROP_CONNECTED) {
@@ -2932,20 +3010,24 @@ static void createTransEditVerts(TransInfo *t)
}
/* CrazySpace */
- if (defmats || (quats && BM_elem_flag_test(eve, BM_ELEM_TAG))) {
+ const bool use_quats = quats && BM_elem_flag_test(eve, BM_ELEM_TAG);
+ if (use_quats || defmats) {
float mat[3][3], qmat[3][3], imat[3][3];
- /* use both or either quat and defmat correction */
- if (quats && BM_elem_flag_test(eve, BM_ELEM_TAG)) {
+ /* Use both or either quat and defmat correction. */
+ if (use_quats) {
quat_to_mat3(qmat, quats[BM_elem_index_get(eve)]);
- if (defmats)
+ if (defmats) {
mul_m3_series(mat, defmats[a], qmat, mtx);
- else
+ }
+ else {
mul_m3_m3m3(mat, mtx, qmat);
+ }
}
- else
+ else {
mul_m3_m3m3(mat, mtx, defmats[a]);
+ }
invert_m3_m3(imat, mat);
@@ -2959,7 +3041,7 @@ static void createTransEditVerts(TransInfo *t)
/* Mirror? */
if ((mirror > 0 && tob->iloc[0] > 0.0f) || (mirror < 0 && tob->iloc[0] < 0.0f)) {
- BMVert *vmir = EDBM_verts_mirror_get(em, eve); //t->obedit, em, eve, tob->iloc, a);
+ BMVert *vmir = EDBM_verts_mirror_get(em, eve); // t->obedit, em, eve, tob->iloc, a);
if (vmir && vmir != eve) {
tob->extra = vmir;
}
@@ -2985,14 +3067,18 @@ static void createTransEditVerts(TransInfo *t)
cleanup:
/* crazy space free */
- if (quats)
+ if (quats) {
MEM_freeN(quats);
- if (defmats)
+ }
+ if (defmats) {
MEM_freeN(defmats);
- if (dists)
+ }
+ if (dists) {
MEM_freeN(dists);
- if (dists_index)
+ }
+ if (dists_index) {
MEM_freeN(dists_index);
+ }
if (tc->mirror.axis_flag) {
EDBM_verts_mirror_cache_end(em);
@@ -3005,8 +3091,7 @@ void flushTransNodes(TransInfo *t)
{
const float dpi_fac = UI_DPI_FAC;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
int a;
TransData *td;
TransData2D *td2d;
@@ -3063,8 +3148,9 @@ BLI_INLINE void trans_update_seq(Scene *sce, Sequence *seq, int old_start, int s
BKE_sequence_calc_disp(sce, seq);
}
- if (sel_flag == SELECT)
+ if (sel_flag == SELECT) {
BKE_sequencer_offset_animdata(sce, seq, seq->start - old_start);
+ }
}
void flushTransSeq(TransInfo *t)
@@ -3128,8 +3214,9 @@ void flushTransSeq(TransInfo *t)
break;
}
- /* Update *previous* seq! Else, we would update a seq after its first transform, and if it has more than one
- * (like e.g. SEQ_LEFTSEL and SEQ_RIGHTSEL), the others are not updated! See T38469.
+ /* Update *previous* seq! Else, we would update a seq after its first transform,
+ * and if it has more than one (like e.g. SEQ_LEFTSEL and SEQ_RIGHTSEL),
+ * the others are not updated! See T38469.
*/
if (seq != seq_prev) {
if (seq_prev) {
@@ -3253,8 +3340,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0;
const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = NULL;
TransData2D *td2d = NULL;
@@ -3349,8 +3435,9 @@ static void createTransUVs(bContext *C, TransInfo *t)
* treated just as if they were 3d verts */
tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransObData2D(UV Editing)");
- if (sima->flag & SI_CLIP_UV)
+ if (sima->flag & SI_CLIP_UV) {
t->flag |= T_CLIP_UV;
+ }
td = tc->data;
td2d = tc->data_2d;
@@ -3358,16 +3445,18 @@ static void createTransUVs(bContext *C, TransInfo *t)
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
BMLoop *l;
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
const bool selected = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
MLoopUV *luv;
const float *center = NULL;
- if (!is_prop_edit && !selected)
+ if (!is_prop_edit && !selected) {
continue;
+ }
if (is_prop_connected || is_island_center) {
UvElement *element = BM_uv_element_get(elementmap, efa, l);
@@ -3419,8 +3508,7 @@ void flushTransUVs(TransInfo *t)
const bool use_pixel_snap = ((sima->pixel_snap_mode != SI_PIXEL_SNAP_DISABLED) &&
(t->state != TRANS_CANCEL));
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData2D *td;
int a;
float aspect_inv[2], size[2];
@@ -3471,8 +3559,7 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
max[0] = t->aspect[0];
max[1] = t->aspect[1];
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td;
int a;
@@ -3482,34 +3569,48 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
}
if (resize) {
- if (min[0] < 0.0f && t->center_global[0] > 0.0f && t->center_global[0] < t->aspect[0] * 0.5f)
+ if (min[0] < 0.0f && t->center_global[0] > 0.0f &&
+ t->center_global[0] < t->aspect[0] * 0.5f) {
vec[0] *= t->center_global[0] / (t->center_global[0] - min[0]);
- else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0])
+ }
+ else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0]) {
vec[0] *= (t->center_global[0] - t->aspect[0]) / (t->center_global[0] - max[0]);
- else
+ }
+ else {
clipx = 0;
+ }
- if (min[1] < 0.0f && t->center_global[1] > 0.0f && t->center_global[1] < t->aspect[1] * 0.5f)
+ if (min[1] < 0.0f && t->center_global[1] > 0.0f &&
+ t->center_global[1] < t->aspect[1] * 0.5f) {
vec[1] *= t->center_global[1] / (t->center_global[1] - min[1]);
- else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1])
+ }
+ else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1]) {
vec[1] *= (t->center_global[1] - t->aspect[1]) / (t->center_global[1] - max[1]);
- else
+ }
+ else {
clipy = 0;
+ }
}
else {
- if (min[0] < 0.0f)
+ if (min[0] < 0.0f) {
vec[0] -= min[0];
- else if (max[0] > t->aspect[0])
+ }
+ else if (max[0] > t->aspect[0]) {
vec[0] -= max[0] - t->aspect[0];
- else
+ }
+ else {
clipx = 0;
+ }
- if (min[1] < 0.0f)
+ if (min[1] < 0.0f) {
vec[1] -= min[1];
- else if (max[1] > t->aspect[1])
+ }
+ else if (max[1] > t->aspect[1]) {
vec[1] -= max[1] - t->aspect[1];
- else
+ }
+ else {
clipy = 0;
+ }
}
}
@@ -3518,15 +3619,16 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
void clipUVData(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (int a = 0; a < tc->data_len; a++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if ((td->flag & TD_SKIP) || (!td->loc))
+ if ((td->flag & TD_SKIP) || (!td->loc)) {
continue;
+ }
td->loc[0] = min_ff(max_ff(0.0f, td->loc[0]), t->aspect[0]);
td->loc[1] = min_ff(max_ff(0.0f, td->loc[1]), t->aspect[1]);
@@ -3540,14 +3642,17 @@ void clipUVData(TransInfo *t)
static bool FrameOnMouseSide(char side, float frame, float cframe)
{
/* both sides, so it doesn't matter */
- if (side == 'B')
+ if (side == 'B') {
return true;
+ }
/* only on the named side */
- if (side == 'R')
+ if (side == 'R') {
return (frame >= cframe);
- else
+ }
+ else {
return (frame <= cframe);
+ }
}
/* ********************* NLA EDITOR ************************* */
@@ -3569,8 +3674,9 @@ static void createTransNlaData(bContext *C, TransInfo *t)
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
/* determine what type of data we are operating on */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
snla = (SpaceNla *)ac.sl;
/* filter data */
@@ -3604,10 +3710,12 @@ static void createTransNlaData(bContext *C, TransInfo *t)
/* transition strips can't get directly transformed */
if (strip->type != NLASTRIP_TYPE_TRANSITION) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
- if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA))
+ if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) {
count++;
- if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA))
+ }
+ if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) {
count++;
+ }
}
}
}
@@ -3746,13 +3854,16 @@ static void createTransNlaData(bContext *C, TransInfo *t)
td++;
}
- /* if both handles were used, skip the next tdn (i.e. leave it blank) since the counting code is dumb...
- * otherwise, just advance to the next one...
+ /* If both handles were used, skip the next tdn (i.e. leave it blank)
+ * since the counting code is dumb.
+ * Otherwise, just advance to the next one.
*/
- if (tdn->handle == 2)
+ if (tdn->handle == 2) {
tdn += 2;
- else
+ }
+ else {
tdn++;
+ }
}
}
}
@@ -3770,10 +3881,12 @@ static int gpf_cmp_frame(void *thunk, const void *a, const void *b)
const bGPDframe *frame_a = a;
const bGPDframe *frame_b = b;
- if (frame_a->framenum < frame_b->framenum)
+ if (frame_a->framenum < frame_b->framenum) {
return -1;
- if (frame_a->framenum > frame_b->framenum)
+ }
+ if (frame_a->framenum > frame_b->framenum) {
return 1;
+ }
*((bool *)thunk) = true;
/* selected last */
if ((frame_a->flag & GP_FRAME_SELECT) && ((frame_b->flag & GP_FRAME_SELECT) == 0)) {
@@ -3787,10 +3900,12 @@ static int masklay_shape_cmp_frame(void *thunk, const void *a, const void *b)
const MaskLayerShape *frame_a = a;
const MaskLayerShape *frame_b = b;
- if (frame_a->frame < frame_b->frame)
+ if (frame_a->frame < frame_b->frame) {
return -1;
- if (frame_a->frame > frame_b->frame)
+ }
+ if (frame_a->frame > frame_b->frame) {
return 1;
+ }
*((bool *)thunk) = true;
/* selected last */
if ((frame_a->flag & MASK_SHAPE_SELECT) && ((frame_b->flag & MASK_SHAPE_SELECT) == 0)) {
@@ -3883,8 +3998,9 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
0);
/* sanity checks */
- if ((fcu->totvert == 0) || (fcu->bezt == NULL))
+ if ((fcu->totvert == 0) || (fcu->bezt == NULL)) {
return;
+ }
/* 1) Identify selected keyframes, and average the values on those
* in case there are collisions due to multiple keys getting scaled
@@ -4017,8 +4133,9 @@ static void posttrans_action_clean(bAnimContext *ac, bAction *act)
posttrans_fcurve_clean(ale->key_data, false); /* only use handles in graph editor */
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
- else
+ else {
posttrans_fcurve_clean(ale->key_data, false); /* only use handles in graph editor */
+ }
}
/* free temp data */
@@ -4033,25 +4150,29 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra, bool is_prop_ed
BezTriple *bezt;
int i, count = 0, count_all = 0;
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return count;
+ }
/* only include points that occur on the right side of cfra */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
/* no need to adjust the handle selection since they are assumed
* selected (like graph editor with SIPO_NOHANDLES) */
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
count++;
+ }
count_all++;
}
}
- if (is_prop_edit && count > 0)
+ if (is_prop_edit && count > 0) {
return count_all;
- else
+ }
+ else {
return count;
+ }
}
/* fully select selected beztriples, but only include if it's on the right side of cfra */
@@ -4060,22 +4181,26 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_p
bGPDframe *gpf;
int count = 0, count_all = 0;
- if (gpl == NULL)
+ if (gpl == NULL) {
return count;
+ }
/* only include points that occur on the right side of cfra */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) {
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
count++;
+ }
count_all++;
}
}
- if (is_prop_edit && count > 0)
+ if (is_prop_edit && count > 0) {
return count_all;
- else
+ }
+ else {
return count;
+ }
}
/* fully select selected beztriples, but only include if it's on the right side of cfra */
@@ -4084,23 +4209,27 @@ static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra, boo
MaskLayerShape *masklayer_shape;
int count = 0, count_all = 0;
- if (masklay == NULL)
+ if (masklay == NULL) {
return count;
+ }
/* only include points that occur on the right side of cfra */
for (masklayer_shape = masklay->splines_shapes.first; masklayer_shape;
masklayer_shape = masklayer_shape->next) {
if (FrameOnMouseSide(side, (float)masklayer_shape->frame, cfra)) {
- if (masklayer_shape->flag & MASK_SHAPE_SELECT)
+ if (masklayer_shape->flag & MASK_SHAPE_SELECT) {
count++;
+ }
count_all++;
}
}
- if (is_prop_edit && count > 0)
+ if (is_prop_edit && count > 0) {
return count_all;
- else
+ }
+ else {
return count;
+ }
}
/* This function assigns the information to transdata */
@@ -4139,8 +4268,9 @@ static TransData *ActionFCurveToTransData(TransData *td,
TransData2D *td2d = *td2dv;
int i;
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return td;
+ }
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* only add selected keyframes (for now, proportional edit is not enabled) */
@@ -4150,8 +4280,9 @@ static TransData *ActionFCurveToTransData(TransData *td,
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
TimeToTransData(td, bezt->vec[1], adt, ypos);
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
td->flag |= TD_SELECTED;
+ }
/*set flags to move handles as necessary*/
td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2;
@@ -4297,14 +4428,17 @@ static void createTransActionData(bContext *C, TransInfo *t)
float ypos = 1.0f / ((ysize / xsize) * (xmask / ymask)) * BLI_rctf_cent_y(&t->ar->v2d.cur);
/* determine what type of data we are operating on */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
/* filter data */
- if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
+ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
- else
+ }
+ else {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
+ }
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* which side of the current frame should be allowed */
@@ -4327,19 +4461,25 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
- if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
+ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
adt_count = count_fcurve_keys(ale->key_data, t->frame_side, cfra, is_prop_edit);
- else if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ else if (ale->type == ANIMTYPE_GPLAYER) {
adt_count = count_gplayer_frames(ale->data, t->frame_side, cfra, is_prop_edit);
- else if (ale->type == ANIMTYPE_MASKLAYER)
+ }
+ else if (ale->type == ANIMTYPE_MASKLAYER) {
adt_count = count_masklayer_frames(ale->data, t->frame_side, cfra, is_prop_edit);
- else
+ }
+ else {
BLI_assert(0);
+ }
if (adt_count > 0) {
count += adt_count;
@@ -4372,8 +4512,9 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* loop 2: build transdata array */
for (ale = anim_data.first; ale; ale = ale->next) {
- if (is_prop_edit && !ale->tag)
+ if (is_prop_edit && !ale->tag) {
continue;
+ }
cfra = (float)CFRA;
@@ -4417,14 +4558,17 @@ static void createTransActionData(bContext *C, TransInfo *t)
AnimData *adt;
/* F-Curve may not have any keyframes */
- if (!ale->tag)
+ if (!ale->tag) {
continue;
+ }
adt = ANIM_nla_mapping_get(&ac, ale);
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
if (ale->type == ANIMTYPE_GPLAYER) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
@@ -4500,8 +4644,9 @@ static void createTransActionData(bContext *C, TransInfo *t)
if (bezt_iter->f2 & SELECT) {
if (FrameOnMouseSide(t->frame_side, (float)bezt_iter->vec[1][0], cfra)) {
float val = fabs(bezt->vec[1][0] - bezt_iter->vec[1][0]);
- if (val < min)
+ if (val < min) {
min = val;
+ }
}
}
}
@@ -4601,13 +4746,16 @@ static void bezt_to_transdata(TransData *td,
td->flag |= TD_SELECTED;
td->dist = 0.0f;
}
- else
+ else {
td->dist = FLT_MAX;
+ }
- if (ishandle)
+ if (ishandle) {
td->flag |= TD_NOTIMESNAP;
- if (intvals)
+ }
+ if (intvals) {
td->flag |= TD_INTVALUES;
+ }
/* copy space-conversion matrices for dealing with non-uniform scales */
copy_m3_m3(td->mtx, mtx);
@@ -4676,8 +4824,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS;
/* determine what type of data we are operating on */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
anim_map_flag |= ANIM_get_normalization_flags(&ac);
@@ -4699,7 +4848,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
t->frame_side = 'B';
}
- /* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */
+ /* Loop 1: count how many BezTriples (specifically their verts)
+ * are selected (or should be edited). */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
@@ -4708,18 +4858,22 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
bool selected = false;
/* F-Curve may not have any keyframes */
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
- /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
+ /* Only include BezTriples whose 'keyframe'
+ * occurs on the same side of the current frame as mouse. */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
const bool sel2 = (bezt->f2 & SELECT) != 0;
@@ -4728,8 +4882,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (is_prop_edit) {
curvecount += 3;
- if (sel2 || sel1 || sel3)
+ if (sel2 || sel1 || sel3) {
selected = true;
+ }
}
else {
if (!is_translation_mode || !(sel2)) {
@@ -4771,7 +4926,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
tc->data_len = count;
tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData (Graph Editor)");
- /* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */
+ /* For each 2d vert a 3d vector is allocated,
+ * so that they can be treated just as if they were 3d verts. */
tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransData2D (Graph Editor)");
tc->custom.type.data = MEM_callocN(tc->data_len * sizeof(TransDataGraph), "TransDataGraph");
tc->custom.type.use_free = true;
@@ -4795,10 +4951,12 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
mul_v3_fl(mtx[1], yscale);
/* smtx is global (i.e. view) to data conversion */
- if (IS_EQF(xscale, 0.0f) == 0)
+ if (IS_EQF(xscale, 0.0f) == 0) {
mul_v3_fl(smtx[0], 1.0f / xscale);
- if (IS_EQF(yscale, 0.0f) == 0)
+ }
+ if (IS_EQF(yscale, 0.0f) == 0) {
mul_v3_fl(smtx[1], 1.0f / yscale);
+ }
}
/* loop 2: build transdata arrays */
@@ -4810,16 +4968,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
float cfra;
/* F-Curve may not have any keyframes */
- if (fcu->bezt == NULL || (is_prop_edit && ale->tag == 0))
+ if (fcu->bezt == NULL || (is_prop_edit && ale->tag == 0)) {
continue;
+ }
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
unit_scale = ANIM_unit_mapping_get_factor(
ac.scene, ale->id, ale->key_data, anim_map_flag, &offset);
@@ -4907,8 +5068,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
if (sel3) {
- if (hdata == NULL)
+ if (hdata == NULL) {
hdata = initTransDataCurveHandles(td, bezt);
+ }
bezt_to_transdata(td++,
td2d++,
tdg++,
@@ -4932,16 +5094,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (sel2 && !use_local_center) {
/* move handles relative to center */
if (is_translation_mode) {
- if (sel1)
+ if (sel1) {
td->flag |= TD_MOVEHANDLE1;
- if (sel3)
+ }
+ if (sel3) {
td->flag |= TD_MOVEHANDLE2;
+ }
}
/* if handles were not selected, store their selection status */
if (!(sel1) || !(sel3)) {
- if (hdata == NULL)
+ if (hdata == NULL) {
hdata = initTransDataCurveHandles(td, bezt);
+ }
}
bezt_to_transdata(td++,
@@ -4958,7 +5123,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
unit_scale,
offset);
}
- /* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...):
+ /* Special hack (must be done after #initTransDataCurveHandles(),
+ * as that stores handle settings to restore...):
+ *
* - Check if we've got entire BezTriple selected and we're scaling/rotating that point,
* then check if we're using auto-handles.
* - If so, change them auto-handles to aligned handles so that handles get affected too
@@ -4989,16 +5156,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
float cfra;
/* F-Curve may not have any keyframes */
- if (fcu->bezt == NULL || (ale->tag == 0))
+ if (fcu->bezt == NULL || (ale->tag == 0)) {
continue;
+ }
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
/* only include BezTriples whose 'keyframe' occurs on the
* same side of the current frame as mouse (if applicable) */
@@ -5062,8 +5232,9 @@ static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert, const short UNUS
int i;
/* allocate memory for this array */
- if (totvert == 0 || bezts == NULL)
+ if (totvert == 0 || bezts == NULL) {
return NULL;
+ }
bezm = bezms = MEM_callocN(sizeof(BeztMap) * totvert, "BeztMaps");
/* assign beztriples to beztmaps */
@@ -5154,34 +5325,41 @@ static void beztmap_to_data(
td = tc->data;
for (j = 0; j < tc->data_len; j++, td2d++, td++) {
/* skip item if already marked */
- if (adjusted[j] != 0)
+ if (adjusted[j] != 0) {
continue;
+ }
/* update all transdata pointers, no need to check for selections etc,
* since only points that are really needed were created as transdata
*/
if (td2d->loc2d == bezm->bezt->vec[0]) {
- if (bezm->swapHs == 1)
+ if (bezm->swapHs == 1) {
td2d->loc2d = (bezts + bezm->newIndex)->vec[2];
- else
+ }
+ else {
td2d->loc2d = (bezts + bezm->newIndex)->vec[0];
+ }
adjusted[j] = 1;
}
else if (td2d->loc2d == bezm->bezt->vec[2]) {
- if (bezm->swapHs == 1)
+ if (bezm->swapHs == 1) {
td2d->loc2d = (bezts + bezm->newIndex)->vec[0];
- else
+ }
+ else {
td2d->loc2d = (bezts + bezm->newIndex)->vec[2];
+ }
adjusted[j] = 1;
}
else if (td2d->loc2d == bezm->bezt->vec[1]) {
td2d->loc2d = (bezts + bezm->newIndex)->vec[1];
/* if only control point is selected, the handle pointers need to be updated as well */
- if (td2d->h1)
+ if (td2d->h1) {
td2d->h1 = (bezts + bezm->newIndex)->vec[0];
- if (td2d->h2)
+ }
+ if (td2d->h2) {
td2d->h2 = (bezts + bezm->newIndex)->vec[2];
+ }
adjusted[j] = 1;
}
@@ -5288,18 +5466,22 @@ void flushTransGraphData(TransInfo *t)
}
/* we need to unapply the nla-mapping from the time in some situations */
- if (adt)
+ if (adt) {
td2d->loc2d[0] = BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
td2d->loc2d[0] = td2d->loc[0];
+ }
- /* Time-stepping auto-snapping modes don't get applied for Graph Editor transforms,
+ /** Time-stepping auto-snapping modes don't get applied for Graph Editor transforms,
* as these use the generic transform modes which don't account for this sort of thing.
* These ones aren't affected by NLA mapping, so we do this after the conversion...
*
- * NOTE: We also have to apply to td->loc, as that's what the handle-adjustment step below looks
- * to, otherwise we get "swimming handles"
- * NOTE: We don't do this when canceling transforms, or else these changes don't go away
+ * \note We also have to apply to td->loc,
+ * as that's what the handle-adjustment step below looks to,
+ * otherwise we get "swimming handles".
+ *
+ * \note We don't do this when canceling transforms, or else these changes don't go away.
*/
if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0 &&
ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP)) {
@@ -5318,10 +5500,12 @@ void flushTransGraphData(TransInfo *t)
}
/* if int-values only, truncate to integers */
- if (td->flag & TD_INTVALUES)
+ if (td->flag & TD_INTVALUES) {
td2d->loc2d[1] = floorf(td2d->loc[1] * inv_unit_scale - tdg->offset + 0.5f);
- else
+ }
+ else {
td2d->loc2d[1] = td2d->loc[1] * inv_unit_scale - tdg->offset;
+ }
if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) {
td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0];
@@ -5366,12 +5550,15 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
/* for meta's we only ever need to extend their children, no matter what depth
* just check the meta's are in the bounds */
- if (t->frame_side == 'R' && right <= cfra)
+ if (t->frame_side == 'R' && right <= cfra) {
*recursive = false;
- else if (t->frame_side == 'L' && left >= cfra)
+ }
+ else if (t->frame_side == 'L' && left >= cfra) {
*recursive = false;
- else
+ }
+ else {
*recursive = true;
+ }
*count = 1;
*flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
@@ -5388,8 +5575,9 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
} /* ignore */
else if (left > cfra) {
} /* keep the selection */
- else
+ else {
*flag |= SEQ_RIGHTSEL;
+ }
}
else {
if (left >= cfra) {
@@ -5397,8 +5585,9 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
} /* ignore */
else if (right < cfra) {
} /* keep the selection */
- else
+ else {
*flag |= SEQ_LEFTSEL;
+ }
}
}
}
@@ -5474,8 +5663,9 @@ static int SeqTransCount(TransInfo *t, Sequence *parent, ListBase *seqbase, int
for (seq = seqbase->first; seq; seq = seq->next) {
seq->depth = depth;
- /* seq->tmp is used by seq_tx_get_final_{left, right} to check sequence's range and clamp to it if needed.
- * it's first place where digging into sequences tree, so store link to parent here */
+ /* 'seq->tmp' is used by seq_tx_get_final_{left, right}
+ * to check sequence's range and clamp to it if needed.
+ * It's first place where digging into sequences tree, so store link to parent here. */
seq->tmp = parent;
SeqTransInfo(t, seq, &recursive, &count, &flag); /* ignore the flag */
@@ -5672,8 +5862,9 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
if (overlap) {
bool has_effect_root = false, has_effect_any = false;
- for (seq = seqbasep->first; seq; seq = seq->next)
+ for (seq = seqbasep->first; seq; seq = seq->next) {
seq->tmp = NULL;
+ }
td = tc->data;
for (a = 0, seq_prev = NULL; a < tc->data_len; a++, td++, seq_prev = seq) {
@@ -5767,12 +5958,15 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
for (seq = seqbasep->first; seq; seq = seq->next) {
/* We might want to build a list of effects that need to be updated during transform */
if (seq->type & SEQ_TYPE_EFFECT) {
- if (seq->seq1 && seq->seq1->flag & SELECT)
+ if (seq->seq1 && seq->seq1->flag & SELECT) {
BKE_sequence_calc(t->scene, seq);
- else if (seq->seq2 && seq->seq2->flag & SELECT)
+ }
+ else if (seq->seq2 && seq->seq2->flag & SELECT) {
BKE_sequence_calc(t->scene, seq);
- else if (seq->seq3 && seq->seq3->flag & SELECT)
+ }
+ else if (seq->seq3 && seq->seq3->flag & SELECT) {
BKE_sequence_calc(t->scene, seq);
+ }
}
}
@@ -5783,8 +5977,9 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
for (a = 0; a < tc->data_len; a++, td++) {
seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev) && (seq->depth == 0)) {
- if (seq->flag & SEQ_OVERLAP)
+ if (seq->flag & SEQ_OVERLAP) {
BKE_sequence_base_shuffle(seqbasep, seq, t->scene);
+ }
BKE_sequence_calc_disp(t->scene, seq);
}
@@ -5878,8 +6073,9 @@ static void createTransSeqData(bContext *C, TransInfo *t)
SeqTransDataBounds(t, ed->seqbasep, ts);
/* set the snap mode based on how close the mouse is at the end/start points */
- if (abs(xmouse - ts->max) > abs(xmouse - ts->min))
+ if (abs(xmouse - ts->max) > abs(xmouse - ts->min)) {
ts->snap_left = true;
+ }
#undef XXX_DURIAN_ANIM_TX_HACK
}
@@ -5920,23 +6116,26 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list)
bChildOfConstraint *data = (bChildOfConstraint *)con->data;
if ((data->flag & CHILDOF_LOCX) && (data->flag & CHILDOF_LOCY) &&
- (data->flag & CHILDOF_LOCZ))
+ (data->flag & CHILDOF_LOCZ)) {
return true;
+ }
}
else if (con->type == CONSTRAINT_TYPE_ROTLIKE) {
/* CopyRot constraint only does this when rotating, and offset is on */
bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data;
- if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION))
+ if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION)) {
return true;
+ }
}
else if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
/* Transform constraint needs it for rotation at least (r.57309),
* but doing so when translating may also mess things up [#36203]
*/
- if (t->mode == TFM_ROTATION)
+ if (t->mode == TFM_ROTATION) {
return true;
+ }
/* ??? (t->mode == TFM_SCALE) ? */
}
}
@@ -5996,8 +6195,9 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
constinv = constraints_list_needinv(t, &ob->constraints);
/* disable constraints inversion for dummy pass */
- if (t->mode == TFM_DUMMY)
+ if (t->mode == TFM_DUMMY) {
skip_invert = true;
+ }
/* NOTE: This is not really following copy-on-write design and we should not
* be re-evaluating the evaluated object. But as the comment above mentioned
@@ -6186,8 +6386,9 @@ static void set_trans_object_base_flags(TransInfo *t)
static bool mark_children(Object *ob)
{
- if (ob->flag & (SELECT | BA_TRANSFORM_CHILD))
+ if (ob->flag & (SELECT | BA_TRANSFORM_CHILD)) {
return true;
+ }
if (ob->parent) {
if (mark_children(ob->parent)) {
@@ -6213,7 +6414,7 @@ static int count_proportional_objects(TransInfo *t)
(t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL))) {
/* Mark all parents. */
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- if (BASE_SELECTED_EDITABLE(v3d, base)) {
+ if (BASE_SELECTED_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
Object *parent = base->object->parent;
/* flag all parents */
while (parent != NULL) {
@@ -6226,7 +6427,8 @@ static int count_proportional_objects(TransInfo *t)
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
/* all base not already selected or marked that is editable */
if ((base->object->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
- (base->flag & BASE_SELECTED) == 0 && (BASE_EDITABLE(v3d, base))) {
+ (base->flag & BASE_SELECTED) == 0 &&
+ (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) {
mark_children(base->object);
}
}
@@ -6235,10 +6437,11 @@ static int count_proportional_objects(TransInfo *t)
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
Object *ob = base->object;
/* If base is not selected, not a parent of selection or not a child of
- * selection and it is editable.
+ * selection and it is editable and selectable.
*/
if ((ob->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
- (base->flag & BASE_SELECTED) == 0 && (BASE_EDITABLE(v3d, base))) {
+ (base->flag & BASE_SELECTED) == 0 &&
+ (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) {
flush_trans_object_base_deps_flag(depsgraph, ob);
total += 1;
}
@@ -6257,7 +6460,7 @@ static void clear_trans_object_base_flags(TransInfo *t)
for (base = view_layer->object_bases.first; base; base = base->next) {
if (base->flag_legacy & BA_WAS_SEL) {
- base->flag |= BASE_SELECTED;
+ ED_object_base_select(base, BA_SELECT);
}
base->flag_legacy &= ~(BA_WAS_SEL | BA_SNAP_FIX_DEPS_FIASCO | BA_TEMP_TAG |
@@ -6265,10 +6468,14 @@ static void clear_trans_object_base_flags(TransInfo *t)
}
}
-/* auto-keyframing feature - for objects
- * tmode: should be a transform mode
+/**
+ * Auto-keyframing feature - for objects
+ *
+ * \param tmode: A transform mode.
+ *
+ * \note Context may not always be available,
+ * so must check before using it as it's a luxury for a few cases.
*/
-// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Object *ob, int tmode)
{
Main *bmain = CTX_data_main(C);
@@ -6292,8 +6499,9 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec
ANIM_relative_keyingset_add_source(&dsources, id, NULL, NULL);
if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) {
- /* only insert into active keyingset
- * NOTE: we assume here that the active Keying Set does not need to have its iterator overridden
+ /* Only insert into active keyingset
+ * NOTE: we assume here that the active Keying Set
+ * does not need to have its iterator overridden.
*/
ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
}
@@ -6332,8 +6540,9 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec
}
else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) {
if (scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) {
- if (ob != OBACT(view_layer))
+ if (ob != OBACT(view_layer)) {
do_loc = true;
+ }
}
else if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CURSOR) {
do_loc = true;
@@ -6345,8 +6554,9 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec
}
else if (tmode == TFM_RESIZE) {
if (scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) {
- if (ob != OBACT(view_layer))
+ if (ob != OBACT(view_layer)) {
do_loc = true;
+ }
}
else if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CURSOR) {
do_loc = true;
@@ -6398,11 +6608,16 @@ bool motionpath_need_update_object(Scene *scene, Object *ob)
return false;
}
-/* auto-keyframing feature - for poses/pose-channels
- * tmode: should be a transform mode
+/**
+ * Auto-keyframing feature - for poses/pose-channels
+ *
+ * \param tmode: A transform mode.
+ *
* targetless_ik: has targetless ik been done on any channels?
+ *
+ * \note Context may not always be available,
+ * so must check before using it as it's a luxury for a few cases.
*/
-// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short targetless_ik)
{
Main *bmain = CTX_data_main(C);
@@ -6430,8 +6645,9 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
*/
flag = ANIM_get_keyframing_flags(scene, 1);
- if (targetless_ik)
+ if (targetless_ik) {
flag |= INSERTKEY_MATRIX;
+ }
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone->flag & BONE_TRANSFORM) {
@@ -6474,8 +6690,9 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
flag);
}
- if (pchanName)
+ if (pchanName) {
MEM_freeN(pchanName);
+ }
}
}
}
@@ -6484,12 +6701,15 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
else if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) {
bool do_loc = false, do_rot = false, do_scale = false;
- /* filter the conditions when this happens (assume that curarea->spacetype==SPACE_VIE3D) */
+ /* Filter the conditions when this happens
+ * (assume that 'curarea->spacetype == SPACE_VIEW3D'). */
if (tmode == TFM_TRANSLATION) {
- if (targetless_ik)
+ if (targetless_ik) {
do_rot = true;
- else
+ }
+ else {
do_loc = true;
+ }
}
else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) {
if (ELEM(scene->toolsettings->transform_pivot_point,
@@ -6620,7 +6840,7 @@ static void special_aftertrans_update__mask(bContext *C, TransInfo *t)
if (t->scene->nodetree) {
/* tracks can be used for stabilization nodes,
* flush update for such nodes */
- //if (nodeUpdateID(t->scene->nodetree, &mask->id))
+ // if (nodeUpdateID(t->scene->nodetree, &mask->id))
{
WM_event_add_notifier(C, NC_MASK | ND_DATA, &mask->id);
}
@@ -6647,8 +6867,9 @@ static void special_aftertrans_update__node(bContext *C, TransInfo *t)
bNode *node, *node_next;
for (node = ntree->nodes.first; node; node = node_next) {
node_next = node->next;
- if (node->flag & NODE_SELECT)
+ if (node->flag & NODE_SELECT) {
nodeRemoveNode(bmain, ntree, node, true);
+ }
}
}
}
@@ -6658,8 +6879,7 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
{
/* so automerge supports mirror */
if ((t->scene->toolsettings->automerge) && ((t->flag & T_EDIT) && t->obedit_type == OB_MESH)) {
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BMesh *bm = em->bm;
@@ -6698,10 +6918,11 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
}
/* inserting keys, pointcache, redraw events... */
-/*
- * note: sequencer freeing has its own function now because of a conflict with transform's order of freeing (campbell)
- * Order changed, the sequencer stuff should go back in here
- * */
+/**
+ * \note Sequencer freeing has its own function now because of a conflict
+ * with transform's order of freeing (campbell).
+ * Order changed, the sequencer stuff should go back in here
+ */
void special_aftertrans_update(bContext *C, TransInfo *t)
{
Main *bmain = CTX_data_main(t->context);
@@ -6730,8 +6951,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* really slow -joeedh */
projectEdgeSlideData(t, true);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
EdgeSlideData *sld = tc->custom.mode.data;
/* Free temporary faces to avoid auto-merging and deleting
@@ -6742,8 +6962,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else if (t->mode == TFM_VERT_SLIDE) {
/* as above */
projectVertSlideData(t, true);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
VertSlideData *sld = tc->custom.mode.data;
freeVertSlideTempFaces(sld);
}
@@ -6784,9 +7003,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* for some reason EXTEND is changed into TRANSLATE, so use frame_side instead */
if (t->mode == TFM_SEQ_SLIDE) {
- if (t->frame_side == 'B')
+ if (t->frame_side == 'B') {
ED_markers_post_apply_transform(
&t->scene->markers, t->scene, TFM_TIME_TRANSLATE, t->values[0], t->frame_side);
+ }
}
else if (ELEM(t->frame_side, 'L', 'R')) {
ED_markers_post_apply_transform(
@@ -6824,8 +7044,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
bAnimContext ac;
/* initialize relevant anim-context 'context' data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
ob = ac.obact;
@@ -6855,8 +7076,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
posttrans_fcurve_clean(fcu, false); /* only use handles in graph editor */
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
}
- else
+ else {
posttrans_fcurve_clean(fcu, false); /* only use handles in graph editor */
+ }
}
}
@@ -6867,11 +7089,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* Depending on the lock status, draw necessary views */
// fixme... some of this stuff is not good
if (ob) {
- if (ob->pose || BKE_key_from_object(ob))
+ if (ob->pose || BKE_key_from_object(ob)) {
DEG_id_tag_update(&ob->id,
ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
- else
+ }
+ else {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ }
}
/* 3 cases here for curve cleanups:
@@ -6900,17 +7124,21 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// XXX: BAD! this get gpencil datablocks directly from main db...
// but that's how this currently works :/
for (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- if (ID_REAL_USERS(gpd))
+ if (ID_REAL_USERS(gpd)) {
posttrans_gpd_clean(gpd);
+ }
}
}
}
else if (ac.datatype == ANIMCONT_MASK) {
/* remove duplicate frames and also make sure points are in order! */
/* 3 cases here for curve cleanups:
- * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
- * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed
- * 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these
+ * 1) NOTRANSKEYCULL on:
+ * Cleanup of duplicates shouldn't be done.
+ * 2) canceled == 0:
+ * User confirmed the transform, so duplicates should be removed.
+ * 3) Canceled + duplicate:
+ * User canceled the transform, but we made duplicates, so get rid of these.
*/
if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 && ((canceled == 0) || (duplicate))) {
Mask *mask;
@@ -6918,8 +7146,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// XXX: BAD! this get gpencil datablocks directly from main db...
// but that's how this currently works :/
for (mask = bmain->masks.first; mask; mask = mask->id.next) {
- if (ID_REAL_USERS(mask))
+ if (ID_REAL_USERS(mask)) {
posttrans_mask_clean(mask);
+ }
}
}
}
@@ -6932,7 +7161,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
#if 0
if (ELEM(t->frame_side, 'L', 'R')) { /* TFM_TIME_EXTEND */
/* same as below */
- ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->values[0], t->frame_side);
+ ED_markers_post_apply_transform(
+ ED_context_get_markers(C), t->scene, t->mode, t->values[0], t->frame_side);
}
else /* TFM_TIME_TRANSLATE */
#endif
@@ -6948,8 +7178,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
/* make sure all F-Curves are set correctly */
- if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
+ if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
ANIM_editkeyframes_refresh(&ac);
+ }
/* clear flag that was set for time-slide drawing */
saction->flag &= ~SACTION_MOVING;
@@ -6960,8 +7191,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0;
/* initialize relevant anim-context 'context' data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
if (ac.datatype) {
ListBase anim_data = {NULL, NULL};
@@ -6988,8 +7220,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
posttrans_fcurve_clean(fcu, use_handle);
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
}
- else
+ else {
posttrans_fcurve_clean(fcu, use_handle);
+ }
}
}
@@ -7002,15 +7235,17 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* Note: if the refresh is really needed after cancel then some way
* has to be added to not update handle types (see bug 22289).
*/
- if (!canceled)
+ if (!canceled) {
ANIM_editkeyframes_refresh(&ac);
+ }
}
else if (t->spacetype == SPACE_NLA) {
bAnimContext ac;
/* initialize relevant anim-context 'context' data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
if (ac.datatype) {
ListBase anim_data = {NULL, NULL};
@@ -7039,8 +7274,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
else if (t->flag & T_EDIT) {
if (t->obedit_type == OB_MESH) {
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
/* table needs to be created for each edit command, since vertices can move etc */
ED_mesh_mirror_spatial_table(tc->obedit, em, NULL, NULL, 'e');
@@ -7053,8 +7287,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* Handle the exception where for TFM_BONESIZE in edit mode we pretend to be
* in pose mode (to use bone orientation matrix),
* in that case we don't do operations like autokeyframing. */
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
ob = tc->poseobj;
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
@@ -7062,8 +7295,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else if (t->flag & T_POSE) {
GSet *motionpath_updates = BLI_gset_ptr_new("motionpath updates");
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
bArmature *arm;
bPoseChannel *pchan;
@@ -7086,19 +7318,22 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
/* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
- if (!canceled && t->mode == TFM_TRANSLATION)
+ if (!canceled && t->mode == TFM_TRANSLATION) {
targetless_ik = apply_targetless_ik(ob);
+ }
else {
/* not forget to clear the auto flag */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
bKinematicConstraint *data = has_targetless_ik(pchan);
- if (data)
+ if (data) {
data->flag &= ~CONSTRAINT_IK_AUTO;
+ }
}
}
- if (t->mode == TFM_TRANSLATION)
+ if (t->mode == TFM_TRANSLATION) {
pose_grab_with_ik_clear(bmain, ob);
+ }
/* automatic inserting of keys and unkeyed tagging -
* only if transform wasn't canceled (or TFM_DUMMY) */
@@ -7154,11 +7389,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
PTCacheID *pid;
ob = td->ob;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
/* flag object caches as outdated */
BKE_ptcache_ids_from_object(&pidlist, ob, t->scene, MAX_DUPLI_RECUR);
@@ -7171,8 +7408,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
BLI_freelistN(&pidlist);
/* pointcache refresh */
- if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED))
+ if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED)) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
/* Needed for proper updating of "quick cached" dynamics. */
/* Creates troubles for moving animated objects without */
@@ -7190,13 +7428,14 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* restore rigid body transform */
if (ob->rigidbody_object && canceled) {
float ctime = BKE_scene_frame_get(t->scene);
- if (BKE_rigidbody_check_sim_running(t->scene->rigidbody_world, ctime))
+ if (BKE_rigidbody_check_sim_running(t->scene->rigidbody_world, ctime)) {
BKE_rigidbody_aftertrans_update(ob,
td->ext->oloc,
td->ext->orot,
td->ext->oquat,
td->ext->orotAxis,
td->ext->orotAngle);
+ }
}
}
@@ -7288,9 +7527,10 @@ static void createTransObject(bContext *C, TransInfo *t)
Object *ob = base->object;
/* if base is not selected, not a parent of selection
- * or not a child of selection and it is editable */
+ * or not a child of selection and it is editable and selectable */
if ((ob->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
- (base->flag & BASE_SELECTED) == 0 && BASE_EDITABLE(v3d, base)) {
+ (base->flag & BASE_SELECTED) == 0 && BASE_EDITABLE(v3d, base) &&
+ BASE_SELECTABLE(v3d, base)) {
td->protectflag = ob->protectflag;
td->ext = tx;
td->ext->rotOrder = ob->rotmode;
@@ -7481,14 +7721,15 @@ static void markerToTransDataInit(TransData *td,
copy_v2_v2(tdt->srelative, rel);
}
- if (off)
+ if (off) {
copy_v2_v2(tdt->soffset, off);
+ }
td->flag = 0;
td->loc = td2d->loc;
copy_v3_v3(td->iloc, td->loc);
- //copy_v3_v3(td->center, td->loc);
+ // copy_v3_v3(td->center, td->loc);
td->flag |= TD_INDIVIDUAL_SCALE;
td->center[0] = marker->pos[0] * aspect[0];
td->center[1] = marker->pos[1] * aspect[1];
@@ -7634,8 +7875,9 @@ static void transDataTrackingFree(TransInfo *UNUSED(t),
{
if (custom_data->data) {
TransDataTracking *tdt = custom_data->data;
- if (tdt->smarkers)
+ if (tdt->smarkers) {
MEM_freeN(tdt->smarkers);
+ }
MEM_freeN(tdt);
custom_data->data = NULL;
@@ -7665,14 +7907,17 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
tc->data_len++; /* offset */
- if (track->flag & SELECT)
+ if (track->flag & SELECT) {
tc->data_len++;
+ }
- if (track->pat_flag & SELECT)
+ if (track->pat_flag & SELECT) {
tc->data_len += 4;
+ }
- if (track->search_flag & SELECT)
+ if (track->search_flag & SELECT) {
tc->data_len += 2;
+ }
}
track = track->next;
@@ -7684,8 +7929,9 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
}
}
- if (tc->data_len == 0)
+ if (tc->data_len == 0) {
return;
+ }
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransTracking TransData");
td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D),
@@ -7813,22 +8059,26 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
marker = &track->markers[i];
prev_marker = &track->markers[i - 1];
- if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED))
+ if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) {
continue;
+ }
- if (marker->flag & MARKER_GRAPH_SEL_X)
+ if (marker->flag & MARKER_GRAPH_SEL_X) {
tc->data_len += 1;
+ }
- if (marker->flag & MARKER_GRAPH_SEL_Y)
+ if (marker->flag & MARKER_GRAPH_SEL_Y) {
tc->data_len += 1;
+ }
}
}
track = track->next;
}
- if (tc->data_len == 0)
+ if (tc->data_len == 0) {
return;
+ }
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransTracking TransData");
td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D),
@@ -7845,8 +8095,9 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
marker = &track->markers[i];
prev_marker = &track->markers[i - 1];
- if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED))
+ if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) {
continue;
+ }
if (marker->flag & MARKER_GRAPH_SEL_X) {
markerToTransCurveDataInit(
@@ -7882,13 +8133,15 @@ static void createTransTrackingData(bContext *C, TransInfo *t)
tc->data_len = 0;
- if (!clip)
+ if (!clip) {
return;
+ }
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
- if (width == 0 || height == 0)
+ if (width == 0 || height == 0) {
return;
+ }
if (ar->regiontype == RGN_TYPE_PREVIEW) {
/* transformation was called from graph editor */
@@ -7916,14 +8169,17 @@ static void cancelTransTracking(TransInfo *t)
marker->flag = tdt->flag;
- if (track->flag & SELECT)
+ if (track->flag & SELECT) {
i++;
+ }
- if (track->pat_flag & SELECT)
+ if (track->pat_flag & SELECT) {
i += 4;
+ }
- if (track->search_flag & SELECT)
+ if (track->search_flag & SELECT) {
i += 2;
+ }
}
else if (tdt->mode == transDataTracking_ModeCurves) {
MovieTrackingTrack *track = tdt->track;
@@ -7934,8 +8190,9 @@ static void cancelTransTracking(TransInfo *t)
marker = &track->markers[a];
prev_marker = &track->markers[a - 1];
- if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED))
+ if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) {
continue;
+ }
if (marker->flag & (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)) {
marker->flag = tdt->flag;
@@ -7961,8 +8218,9 @@ void flushTransTracking(TransInfo *t)
TransDataTracking *tdt;
int a;
- if (t->state == TRANS_CANCEL)
+ if (t->state == TRANS_CANCEL) {
cancelTransTracking(t);
+ }
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
@@ -7981,8 +8239,9 @@ void flushTransTracking(TransInfo *t)
if (t->flag & T_ALT_TRANSFORM) {
if (t->mode == TFM_RESIZE) {
- if (tdt->area != TRACK_AREA_PAT)
+ if (tdt->area != TRACK_AREA_PAT) {
continue;
+ }
}
else if (t->mode == TFM_TRANSLATION) {
if (tdt->area == TRACK_AREA_POINT && tdt->relative) {
@@ -7991,8 +8250,9 @@ void flushTransTracking(TransInfo *t)
if (!tdt->smarkers) {
tdt->smarkers = MEM_callocN(sizeof(*tdt->smarkers) * tdt->markersnr,
"flushTransTracking markers");
- for (a = 0; a < tdt->markersnr; a++)
+ for (a = 0; a < tdt->markersnr; a++) {
copy_v2_v2(tdt->smarkers[a], tdt->markers[a].pos);
+ }
}
sub_v2_v2v2(d, loc2d, tdt->soffset);
@@ -8000,8 +8260,9 @@ void flushTransTracking(TransInfo *t)
sub_v2_v2v2(d2, loc2d, tdt->srelative);
- for (a = 0; a < tdt->markersnr; a++)
+ for (a = 0; a < tdt->markersnr; a++) {
add_v2_v2v2(tdt->markers[a].pos, tdt->smarkers[a], d2);
+ }
negate_v2_v2(td2d->loc2d, d);
}
@@ -8012,8 +8273,9 @@ void flushTransTracking(TransInfo *t)
td2d->loc2d[0] = loc2d[0];
td2d->loc2d[1] = loc2d[1];
- if (tdt->relative)
+ if (tdt->relative) {
sub_v2_v2(td2d->loc2d, tdt->relative);
+ }
}
}
else if (tdt->mode == transDataTracking_ModeCurves) {
@@ -8260,8 +8522,9 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
tc->data_len = 0;
- if (!mask)
+ if (!mask) {
return;
+ }
if (t->spacetype == SPACE_CLIP) {
SpaceClip *sc = t->sa->spacedata.first;
@@ -8305,8 +8568,9 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
}
}
- if (is_prop_edit)
+ if (is_prop_edit) {
count += 3;
+ }
}
}
}
@@ -8518,8 +8782,9 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t)
tc->data_len = 0;
- if (!paint || !paint->brush || !paint->brush->paint_curve)
+ if (!paint || !paint->brush || !paint->brush->paint_curve) {
return;
+ }
br = paint->brush;
pc = br->paint_curve;
@@ -8531,16 +8796,19 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t)
continue;
}
else {
- if (pcp->bez.f1 & SELECT)
+ if (pcp->bez.f1 & SELECT) {
total++;
- if (pcp->bez.f3 & SELECT)
+ }
+ if (pcp->bez.f3 & SELECT) {
total++;
+ }
}
}
}
- if (!total)
+ if (!total) {
return;
+ }
tc->data_len = total;
td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransData2D");
@@ -8638,8 +8906,9 @@ static void createTransGPencil(bContext *C, TransInfo *t)
*/
tc->data_len = 0;
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* initialize falloff curve */
if (is_multiedit) {
@@ -8675,8 +8944,9 @@ static void createTransGPencil(bContext *C, TransInfo *t)
/* Proportional Editing... */
if (is_prop_edit_connected) {
/* connected only - so only if selected */
- if (gps->flag & GP_STROKE_SELECT)
+ if (gps->flag & GP_STROKE_SELECT) {
tc->data_len += gps->totpoints;
+ }
}
else {
/* everything goes - connection status doesn't matter */
@@ -8691,8 +8961,9 @@ static void createTransGPencil(bContext *C, TransInfo *t)
// TODO: 2D vs 3D?
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- if (pt->flag & GP_SPOINT_SELECT)
+ if (pt->flag & GP_SPOINT_SELECT) {
tc->data_len++;
+ }
}
}
}
@@ -8745,7 +9016,9 @@ static void createTransGPencil(bContext *C, TransInfo *t)
/* undo matrix */
invert_m4_m4(inverse_diff_mat, diff_mat);
- /* Make a new frame to work on if the layer's frame and the current scene frame don't match up
+ /* Make a new frame to work on if the layer's frame
+ * and the current scene frame don't match up.
+ *
* - This is useful when animating as it saves that "uh-oh" moment when you realize you've
* spent too much time editing the wrong frame...
*/
@@ -8971,8 +9244,7 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->options & CTX_EDGE) {
/* Multi object editing. */
initTransDataContainers_FromObjectData(t, ob, NULL, 0);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
tc->data_ext = NULL;
}
t->flag |= T_EDIT;
@@ -9051,7 +9323,7 @@ void createTransData(bContext *C, TransInfo *t)
if (t->data_len_all && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
/* don't do that, distance has been set in createTransActionData already */
- //set_prop_dist(t, false);
+ // set_prop_dist(t, false);
sort_trans_data_dist(t);
}
}
@@ -9127,8 +9399,7 @@ void createTransData(bContext *C, TransInfo *t)
/* Multi object editing. */
initTransDataContainers_FromObjectData(t, ob, NULL, 0);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
tc->data_ext = NULL;
}
if (t->obedit_type == OB_MESH) {
@@ -9179,16 +9450,17 @@ void createTransData(bContext *C, TransInfo *t)
t->flag |= T_POSE;
t->obedit_type = -1;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
tc->poseobj = tc->obedit;
tc->obedit = NULL;
}
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
- // XXX this is currently limited to active armature only...
- // XXX active-layer checking isn't done as that should probably be checked through context instead
+ /* XXX this is currently limited to active armature only... */
+
+ /* XXX active-layer checking isn't done
+ * as that should probably be checked through context instead. */
/* Multi object editing. */
initTransDataContainers_FromObjectData(t, ob, NULL, 0);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 46e8447efc6..8ddc5461e9a 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -126,8 +126,7 @@ void getViewVector(const TransInfo *t, const float coord[3], float vec[3])
static void clipMirrorModifier(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Object *ob = tc->obedit;
ModifierData *md = ob->modifiers.first;
float tolerance[3] = {0.0f, 0.0f, 0.0f};
@@ -168,13 +167,16 @@ static void clipMirrorModifier(TransInfo *t)
int clip;
float loc[3], iloc[3];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
- if (td->loc == NULL)
+ }
+ if (td->loc == NULL) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
copy_v3_v3(loc, td->loc);
copy_v3_v3(iloc, td->iloc);
@@ -221,20 +223,22 @@ static void clipMirrorModifier(TransInfo *t)
/* assumes obedit set to mesh object */
static void editbmesh_apply_to_mirror(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->mirror.axis_flag) {
TransData *td = tc->data;
BMVert *eve;
int i;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
- if (td->loc == NULL)
+ }
+ if (td->loc == NULL) {
break;
- if (td->flag & TD_SKIP)
+ }
+ if (td->flag & TD_SKIP) {
continue;
+ }
eve = td->extra;
if (eve) {
@@ -257,8 +261,9 @@ static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer)
ScreenAnimData *sad = (animtimer) ? animtimer->customdata : NULL;
/* sanity checks */
- if (ELEM(NULL, scene, id, sad))
+ if (ELEM(NULL, scene, id, sad)) {
return;
+ }
/* check if we need a new strip if:
* - if animtimer is running
@@ -331,12 +336,14 @@ static bool fcu_test_selected(FCurve *fcu)
BezTriple *bezt = fcu->bezt;
unsigned int i;
- if (bezt == NULL) /* ignore baked */
+ if (bezt == NULL) { /* ignore baked */
return 0;
+ }
for (i = 0; i < fcu->totvert; i++, bezt++) {
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
return 1;
+ }
}
return 0;
@@ -374,7 +381,8 @@ static void recalcData_actedit(TransInfo *t)
}
if (ac.datatype != ANIMCONT_MASK) {
- /* get animdata blocks visible in editor, assuming that these will be the ones where things changed */
+ /* Get animdata blocks visible in editor,
+ * assuming that these will be the ones where things changed. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -431,25 +439,30 @@ static void recalcData_graphedit(TransInfo *t)
FCurve *fcu = (FCurve *)ale->key_data;
/* ignore FC-Curves without any selected verts */
- if (!fcu_test_selected(fcu))
+ if (!fcu_test_selected(fcu)) {
continue;
+ }
/* watch it: if the time is wrong: do not correct handles yet */
- if (test_time_fcurve(fcu))
+ if (test_time_fcurve(fcu)) {
dosort++;
- else
+ }
+ else {
calchandles_fcurve(fcu);
+ }
/* set refresh tags for objects using this animation,
* BUT only if realtime updates are enabled
*/
- if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0)
+ if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0) {
ANIM_list_elem_update(CTX_data_main(t->context), t->scene, ale);
+ }
}
/* do resort and other updates? */
- if (dosort)
+ if (dosort) {
remake_graph_transdata(t, &anim_data);
+ }
/* now free temp channels */
ANIM_animdata_freelist(&anim_data);
@@ -466,9 +479,9 @@ static void recalcData_nla(TransInfo *t)
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
TransDataNla *tdn = tc->custom.type.data;
- /* for each strip we've got, perform some additional validation of the values that got set before
- * using RNA to set the value (which does some special operations when setting these values to make
- * sure that everything works ok)
+ /* For each strip we've got, perform some additional validation of the values
+ * that got set before using RNA to set the value (which does some special
+ * operations when setting these values to make sure that everything works ok).
*/
for (i = 0; i < tc->data_len; i++, tdn++) {
NlaStrip *strip = tdn->strip;
@@ -477,14 +490,16 @@ static void recalcData_nla(TransInfo *t)
int delta_y1, delta_y2;
/* if this tdn has no handles, that means it is just a dummy that should be skipped */
- if (tdn->handle == 0)
+ if (tdn->handle == 0) {
continue;
+ }
/* set refresh tags for objects using this animation,
* BUT only if realtime updates are enabled
*/
- if ((snla->flag & SNLA_NOREALTIMEUPDATES) == 0)
+ if ((snla->flag & SNLA_NOREALTIMEUPDATES) == 0) {
ANIM_id_update(CTX_data_main(t->context), tdn->id);
+ }
/* if canceling transform, just write the values without validating, then move on */
if (t->state == TRANS_CANCEL) {
@@ -495,21 +510,24 @@ static void recalcData_nla(TransInfo *t)
/* start */
strip->start = tdn->h1[0];
- if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
+ if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) {
strip->prev->end = tdn->h1[0];
+ }
/* end */
strip->end = tdn->h2[0];
- if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION))
+ if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION)) {
strip->next->start = tdn->h2[0];
+ }
/* flush transforms to child strips (since this should be a meta) */
BKE_nlameta_flush_transforms(strip);
/* restore to original track (if needed) */
if (tdn->oldTrack != tdn->nlt) {
- /* just append to end of list for now, since strips get sorted in special_aftertrans_update() */
+ /* Just append to end of list for now,
+ * since strips get sorted in special_aftertrans_update(). */
BLI_remlink(&tdn->nlt->strips, strip);
BLI_addtail(&tdn->oldTrack->strips, strip);
}
@@ -530,8 +548,9 @@ static void recalcData_nla(TransInfo *t)
if ((pExceeded && nExceeded) || (iter == 4)) {
/* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise)
- * - simply crop strip to fit within the bounds of the strips bounding it
- * - if there were no neighbors, clear the transforms (make it default to the strip's current values)
+ * - Simply crop strip to fit within the bounds of the strips bounding it
+ * - If there were no neighbors, clear the transforms
+ * (make it default to the strip's current values).
*/
if (strip->prev && strip->next) {
tdn->h1[0] = strip->prev->end;
@@ -556,8 +575,9 @@ static void recalcData_nla(TransInfo *t)
tdn->h1[0] += offset;
tdn->h2[0] += offset;
}
- else /* all is fine and well */
+ else { /* all is fine and well */
break;
+ }
}
/* handle auto-snapping
@@ -567,7 +587,7 @@ static void recalcData_nla(TransInfo *t)
switch (snla->autosnap) {
case SACTSNAP_FRAME: /* snap to nearest frame */
case SACTSNAP_STEP: /* frame step - this is basically the same,
- * since we don't have any remapping going on */
+ * since we don't have any remapping going on */
{
tdn->h1[0] = floorf(tdn->h1[0] + 0.5f);
tdn->h2[0] = floorf(tdn->h2[0] + 0.5f);
@@ -576,7 +596,7 @@ static void recalcData_nla(TransInfo *t)
case SACTSNAP_SECOND: /* snap to nearest second */
case SACTSNAP_TSTEP: /* second step - this is basically the same,
- * since we don't have any remapping going on */
+ * since we don't have any remapping going on */
{
/* This case behaves differently from the rest, since lengths of strips
* may not be multiples of a second. If we just naively resize adjust
@@ -621,8 +641,9 @@ static void recalcData_nla(TransInfo *t)
/* flush transforms to child strips (since this should be a meta) */
BKE_nlameta_flush_transforms(strip);
- /* now, check if we need to try and move track
- * - we need to calculate both, as only one may have been altered by transform if only 1 handle moved
+ /* Now, check if we need to try and move track:
+ * - we need to calculate both,
+ * as only one may have been altered by transform if only 1 handle moved.
*/
delta_y1 = ((int)tdn->h1[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex);
delta_y2 = ((int)tdn->h2[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex);
@@ -632,8 +653,9 @@ static void recalcData_nla(TransInfo *t)
int delta = (delta_y2) ? delta_y2 : delta_y1;
int n;
- /* move in the requested direction, checking at each layer if there's space for strip to pass through,
- * stopping on the last track available or that we're able to fit in
+ /* Move in the requested direction,
+ * checking at each layer if there's space for strip to pass through,
+ * stopping on the last track available or that we're able to fit in.
*/
if (delta > 0) {
for (track = tdn->nlt->next, n = 0; (track) && (n < delta); track = track->next, n++) {
@@ -646,8 +668,9 @@ static void recalcData_nla(TransInfo *t)
tdn->nlt = track;
tdn->trackIndex++;
}
- else /* can't move any further */
+ else { /* can't move any further */
break;
+ }
}
}
else {
@@ -664,8 +687,9 @@ static void recalcData_nla(TransInfo *t)
tdn->nlt = track;
tdn->trackIndex--;
}
- else /* can't move any further */
+ else { /* can't move any further */
break;
+ }
}
}
}
@@ -694,11 +718,11 @@ static void recalcData_image(TransInfo *t)
SpaceImage *sima = t->sa->spacedata.first;
flushTransUVs(t);
- if (sima->flag & SI_LIVE_UNWRAP)
+ if (sima->flag & SI_LIVE_UNWRAP) {
ED_uvedit_live_unwrap_re_solve();
+ }
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->data_len) {
DEG_id_tag_update(tc->obedit->data, 0);
}
@@ -725,20 +749,25 @@ static void recalcData_spaceclip(TransInfo *t)
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (t->mode == TFM_TRANSLATION) {
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) {
BKE_tracking_marker_clamp(marker, CLAMP_PAT_POS);
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
+ }
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) {
BKE_tracking_marker_clamp(marker, CLAMP_SEARCH_POS);
+ }
}
else if (t->mode == TFM_RESIZE) {
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) {
BKE_tracking_marker_clamp(marker, CLAMP_PAT_DIM);
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
+ }
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) {
BKE_tracking_marker_clamp(marker, CLAMP_SEARCH_DIM);
+ }
}
else if (t->mode == TFM_ROTATION) {
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) {
BKE_tracking_marker_clamp(marker, CLAMP_PAT_POS);
+ }
}
}
@@ -765,8 +794,7 @@ static void recalcData_objects(TransInfo *t)
applyProject(t);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Curve *cu = tc->obedit->data;
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
Nurb *nu = nurbs->first;
@@ -796,8 +824,7 @@ static void recalcData_objects(TransInfo *t)
applyProject(t);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Lattice *la = tc->obedit->data;
DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */
if (la->editlatt->latt->flag & LT_OUTSIDE) {
@@ -823,8 +850,7 @@ static void recalcData_objects(TransInfo *t)
projectVertSlideData(t, false);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
EDBM_mesh_normals_update(em);
@@ -837,8 +863,7 @@ static void recalcData_objects(TransInfo *t)
applyProject(t);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
bArmature *arm = tc->obedit->data;
ListBase *edbo = arm->edbo;
EditBone *ebo, *ebo_parent;
@@ -853,14 +878,16 @@ static void recalcData_objects(TransInfo *t)
/* If this bone has a parent tip that has been moved */
if (ebo_parent->flag & BONE_TIPSEL) {
copy_v3_v3(ebo->head, ebo_parent->tail);
- if (t->mode == TFM_BONE_ENVELOPE)
+ if (t->mode == TFM_BONE_ENVELOPE) {
ebo->rad_head = ebo_parent->rad_tail;
+ }
}
/* If this bone has a parent tip that has NOT been moved */
else {
copy_v3_v3(ebo_parent->tail, ebo->head);
- if (t->mode == TFM_BONE_ENVELOPE)
+ if (t->mode == TFM_BONE_ENVELOPE) {
ebo_parent->rad_tail = ebo->rad_head;
+ }
}
}
@@ -871,8 +898,9 @@ static void recalcData_objects(TransInfo *t)
ebo->rad_tail = 0.10f * ebo->length;
ebo->dist = 0.25f * ebo->length;
if (ebo->parent) {
- if (ebo->rad_head > ebo->parent->rad_tail)
+ if (ebo->rad_head > ebo->parent->rad_tail) {
ebo->rad_head = ebo->parent->rad_tail;
+ }
}
}
else if (t->mode != TFM_BONE_ENVELOPE) {
@@ -933,19 +961,34 @@ static void recalcData_objects(TransInfo *t)
if (t->state != TRANS_CANCEL) {
applyProject(t);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->data_len) {
DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */
}
}
}
}
+ else if (t->flag & T_POSE && (t->mode == TFM_BONESIZE)) {
+ /* Handle the exception where for TFM_BONESIZE in edit mode we pretend to be
+ * in pose mode (to use bone orientation matrix),
+ * in that case we have to do mirroring as well. */
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+ Object *ob = tc->poseobj;
+ bArmature *arm = ob->data;
+ if (arm->flag & ARM_MIRROR_EDIT) {
+ if (t->state != TRANS_CANCEL) {
+ ED_armature_edit_transform_mirror_update(ob);
+ }
+ else {
+ restoreBones(tc);
+ }
+ }
+ }
+ }
else if (t->flag & T_POSE) {
GSet *motionpath_updates = BLI_gset_ptr_new("motionpath updates");
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
Object *ob = tc->poseobj;
bArmature *arm = ob->data;
@@ -955,7 +998,9 @@ static void recalcData_objects(TransInfo *t)
*
* context is needed for keying set poll() functions.
*/
- // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
+
+ /* TODO: autokeyframe calls need some setting to specify to add samples
+ * (FPoints) instead of keyframes? */
if ((t->animtimer) && (t->context) && IS_AUTOKEY_ON(t->scene)) {
int targetless_ik =
(t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
@@ -1001,24 +1046,26 @@ static void recalcData_objects(TransInfo *t)
applyProject(t);
}
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (int i = 0; i < tc->data_len; i++, td++) {
Object *ob = td->ob;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
/* if animtimer is running, and the object already has animation data,
* check if the auto-record feature means that we should record 'samples'
* (i.e. uneditable animation values)
*/
- // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
+ /* TODO: autokeyframe calls need some setting to specify to add samples
+ * (FPoints) instead of keyframes? */
if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
animrecord_check_state(t->scene, &ob->id, t->animtimer);
autokeyframe_object(t->context, t->scene, t->view_layer, ob, t->mode);
@@ -1031,8 +1078,9 @@ static void recalcData_objects(TransInfo *t)
*/
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
- if (t->flag & T_TEXTURE)
+ if (t->flag & T_TEXTURE) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
}
}
@@ -1063,19 +1111,16 @@ static void recalcData_sequencer(TransInfo *t)
if (seq != seq_prev) {
if (BKE_sequence_tx_fullupdate_test(seq)) {
- /* A few effect strip types need a complete recache on transform. */
BKE_sequence_invalidate_cache(t->scene, seq);
}
else {
- BKE_sequence_invalidate_dependent(t->scene, seq);
+ BKE_sequence_invalidate_cache(t->scene, seq);
}
}
seq_prev = seq;
}
- BKE_sequencer_preprocessed_cache_cleanup();
-
flushTransSeq(t);
}
@@ -1194,16 +1239,17 @@ void resetTransRestrictions(TransInfo *t)
static int initTransInfo_edit_pet_to_flag(const int proportional)
{
- switch (proportional) {
- case PROP_EDIT_ON:
- return T_PROP_EDIT;
- case PROP_EDIT_CONNECTED:
- return T_PROP_EDIT | T_PROP_CONNECTED;
- case PROP_EDIT_PROJECTED:
- return T_PROP_EDIT | T_PROP_PROJECTED;
- default:
- return 0;
+ int flag = 0;
+ if (proportional & PROP_EDIT_USE) {
+ flag |= T_PROP_EDIT;
+ }
+ if (proportional & PROP_EDIT_CONNECTED) {
+ flag |= T_PROP_CONNECTED;
+ }
+ if (proportional & PROP_EDIT_PROJECTED) {
+ flag |= T_PROP_PROJECTED;
}
+ return flag;
}
void initTransDataContainers_FromObjectData(TransInfo *t,
@@ -1515,10 +1561,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->view = &ar->v2d;
t->around = sclip->around;
- if (ED_space_clip_check_show_trackedit(sclip))
+ if (ED_space_clip_check_show_trackedit(sclip)) {
t->options |= CTX_MOVIECLIP;
- else if (ED_space_clip_check_show_maskedit(sclip))
+ }
+ else if (ED_space_clip_check_show_maskedit(sclip)) {
t->options |= CTX_MASK;
+ }
}
else {
if (ar) {
@@ -1604,9 +1652,19 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
/* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */
- if (op && (prop = RNA_struct_find_property(op->ptr, "proportional"))) {
+ if (op && (prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
if (RNA_property_is_set(op->ptr, prop)) {
- t->flag |= initTransInfo_edit_pet_to_flag(RNA_property_enum_get(op->ptr, prop));
+ int proportional = 0;
+ if (RNA_property_boolean_get(op->ptr, prop)) {
+ proportional |= PROP_EDIT_USE;
+ if (RNA_boolean_get(op->ptr, "use_proportional_connected")) {
+ proportional |= PROP_EDIT_CONNECTED;
+ }
+ if (RNA_boolean_get(op->ptr, "use_proportional_projected")) {
+ proportional |= PROP_EDIT_PROJECTED;
+ }
+ }
+ t->flag |= initTransInfo_edit_pet_to_flag(proportional);
}
else {
/* use settings from scene only if modal */
@@ -1619,16 +1677,16 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_action);
}
else if (t->obedit_type != -1) {
- t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional);
+ t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_edit);
}
else if (t->options & CTX_GPENCIL_STROKES) {
- t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional);
+ t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_edit);
}
else if (t->options & CTX_MASK) {
if (ts->proportional_mask) {
t->flag |= T_PROP_EDIT;
- if (ts->proportional == PROP_EDIT_CONNECTED) {
+ if (ts->proportional_edit & PROP_EDIT_CONNECTED) {
t->flag |= T_PROP_CONNECTED;
}
}
@@ -1718,8 +1776,7 @@ static void freeTransCustomDataContainer(TransInfo *t,
void freeTransCustomDataForMode(TransInfo *t)
{
freeTransCustomData(t, NULL, &t->custom.mode);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
freeTransCustomData(t, tc, &tc->custom.mode);
}
}
@@ -1727,14 +1784,18 @@ void freeTransCustomDataForMode(TransInfo *t)
/* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */
void postTrans(bContext *C, TransInfo *t)
{
- if (t->draw_handle_view)
+ if (t->draw_handle_view) {
ED_region_draw_cb_exit(t->ar->type, t->draw_handle_view);
- if (t->draw_handle_apply)
+ }
+ if (t->draw_handle_apply) {
ED_region_draw_cb_exit(t->ar->type, t->draw_handle_apply);
- if (t->draw_handle_pixel)
+ }
+ if (t->draw_handle_pixel) {
ED_region_draw_cb_exit(t->ar->type, t->draw_handle_pixel);
- if (t->draw_handle_cursor)
+ }
+ if (t->draw_handle_cursor) {
WM_paint_cursor_end(CTX_wm_manager(C), t->draw_handle_cursor);
+ }
if (t->flag & T_MODAL_CURSOR_SET) {
WM_cursor_modal_restore(CTX_wm_window(C));
@@ -1742,15 +1803,13 @@ void postTrans(bContext *C, TransInfo *t)
/* Free all custom-data */
freeTransCustomDataContainer(t, NULL, &t->custom);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
freeTransCustomDataContainer(t, tc, &tc->custom);
}
/* postTrans can be called when nothing is selected, so data is NULL already */
if (t->data_len_all != 0) {
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
/* free data malloced per trans-data */
if (ELEM(t->obedit_type, OB_CURVE, OB_SURF) || (t->spacetype == SPACE_GRAPH)) {
TransData *td = tc->data;
@@ -1778,8 +1837,9 @@ void postTrans(bContext *C, TransInfo *t)
}
else {
SpaceImage *sima = t->sa->spacedata.first;
- if (sima->flag & SI_LIVE_UNWRAP)
+ if (sima->flag & SI_LIVE_UNWRAP) {
ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL);
+ }
}
}
else if (t->spacetype == SPACE_VIEW3D) {
@@ -1856,8 +1916,7 @@ static void restoreElement(TransData *td)
void restoreTransObjects(TransInfo *t)
{
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td;
TransData2D *td2d;
@@ -1893,8 +1952,7 @@ void calculateCenterLocal(TransInfo *t, const float center_global[3])
{
/* setting constraint center */
/* note, init functions may over-ride t->center */
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->use_local_mat) {
mul_v3_m4v3(tc->center_local, tc->imat, center_global);
}
@@ -1986,8 +2044,7 @@ void calculateCenterMedian(TransInfo *t, float r_center[3])
float partial[3] = {0.0f, 0.0f, 0.0f};
int total = 0;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
for (int i = 0; i < tc->data_len; i++) {
if (tc->data[i].flag & TD_SELECTED) {
if (!(tc->data[i].flag & TD_NOCENTER)) {
@@ -2015,8 +2072,7 @@ void calculateCenterBound(TransInfo *t, float r_center[3])
float max[3], min[3];
bool changed = false;
INIT_MINMAX(min, max);
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
for (int i = 0; i < tc->data_len; i++) {
if (tc->data[i].flag & TD_SELECTED) {
if (!(tc->data[i].flag & TD_NOCENTER)) {
@@ -2094,12 +2150,15 @@ static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[
calculateCenterMedian(t, r_center);
break;
case V3D_AROUND_CURSOR:
- if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP))
+ if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
calculateCenterCursor2D(t, r_center);
- else if (t->spacetype == SPACE_GRAPH)
+ }
+ else if (t->spacetype == SPACE_GRAPH) {
calculateCenterCursorGraph2D(t, r_center);
- else
+ }
+ else {
calculateCenterCursor(t, r_center);
+ }
break;
case V3D_AROUND_LOCAL_ORIGINS:
/* Individual element center uses median center for helpline and such */
@@ -2160,7 +2219,8 @@ void calculateCenter(TransInfo *t)
}
if (t->spacetype == SPACE_VIEW3D) {
- /* ED_view3d_calc_zfac() defines a factor for perspective depth correction, used in ED_view3d_win_to_delta() */
+ /* ED_view3d_calc_zfac() defines a factor for perspective depth correction,
+ * used in ED_view3d_win_to_delta() */
/* zfac is only used convertViewVec only in cases operator was invoked in RGN_TYPE_WINDOW
* and never used in other cases.
@@ -2204,8 +2264,7 @@ void calculatePropRatio(TransInfo *t)
if (t->flag & T_PROP_EDIT) {
const char *pet_id = NULL;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
if (td->flag & TD_SELECTED) {
@@ -2231,18 +2290,21 @@ void calculatePropRatio(TransInfo *t)
/* Use rdist for falloff calculations, it is the real distance */
td->flag &= ~TD_NOACTION;
- if (connected)
+ if (connected) {
dist = (t->prop_size - td->dist) / t->prop_size;
- else
+ }
+ else {
dist = (t->prop_size - td->rdist) / t->prop_size;
+ }
/*
* Clamp to positive numbers.
* Certain corner cases with connectivity and individual centers
* can give values of rdist larger than propsize.
*/
- if (dist < 0.0f)
+ if (dist < 0.0f) {
dist = 0.0f;
+ }
switch (t->prop_mode) {
case PROP_SHARP:
@@ -2316,8 +2378,7 @@ void calculatePropRatio(TransInfo *t)
}
}
else {
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
td->factor = 1.0;
diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c
index f5b8f19ed02..1015b47c304 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -231,8 +231,9 @@ void ED_widgetgroup_gizmo2d_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgro
PointerRNA *ptr = WM_gizmo_operator_set(axis, 0, ot_translate, NULL);
bool constraint[3] = {0};
constraint[(axis_idx + 1) % 2] = 1;
- if (RNA_struct_find_property(ptr, "constraint_axis"))
+ if (RNA_struct_find_property(ptr, "constraint_axis")) {
RNA_boolean_set_array(ptr, "constraint_axis", constraint);
+ }
RNA_boolean_set(ptr, "release_confirm", 1);
}
MAN2D_ITER_AXES_END;
@@ -385,8 +386,9 @@ bool ED_widgetgroup_gizmo2d_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzg
/* check if there's a selected poly */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 1fde0006c2b..50610f1b3da 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -116,7 +116,7 @@ static struct {
/* Regular range */
{0.02f, 0.1f},
/* Use a different range because we flip the dot product,
- * also the view aligned planes are harder to see so hiding early is preferred. */
+ * also the view aligned planes are harder to see so hiding early is preferred. */
{0.175f, 0.25f},
};
@@ -352,7 +352,8 @@ static void gizmo_get_axis_color(const int axis_idx,
else {
bool is_plane = false;
const int axis_idx_norm = gizmo_orientation_axis(axis_idx, &is_plane);
- /* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */
+ /* Get alpha fac based on axis angle,
+ * to fade axis out when hiding it because it points towards view. */
if (axis_idx_norm < 3) {
const float idot_min = g_tw_axis_range[is_plane].min;
const float idot_max = g_tw_axis_range[is_plane].max;
@@ -484,26 +485,35 @@ static void calc_tw_center_with_matrix(struct TransformBounds *tbounds,
static void protectflag_to_drawflags(short protectflag, short *drawflags)
{
- if (protectflag & OB_LOCK_LOCX)
+ if (protectflag & OB_LOCK_LOCX) {
*drawflags &= ~MAN_TRANS_X;
- if (protectflag & OB_LOCK_LOCY)
+ }
+ if (protectflag & OB_LOCK_LOCY) {
*drawflags &= ~MAN_TRANS_Y;
- if (protectflag & OB_LOCK_LOCZ)
+ }
+ if (protectflag & OB_LOCK_LOCZ) {
*drawflags &= ~MAN_TRANS_Z;
+ }
- if (protectflag & OB_LOCK_ROTX)
+ if (protectflag & OB_LOCK_ROTX) {
*drawflags &= ~MAN_ROT_X;
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
*drawflags &= ~MAN_ROT_Y;
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
*drawflags &= ~MAN_ROT_Z;
+ }
- if (protectflag & OB_LOCK_SCALEX)
+ if (protectflag & OB_LOCK_SCALEX) {
*drawflags &= ~MAN_SCALE_X;
- if (protectflag & OB_LOCK_SCALEY)
+ }
+ if (protectflag & OB_LOCK_SCALEY) {
*drawflags &= ~MAN_SCALE_Y;
- if (protectflag & OB_LOCK_SCALEZ)
+ }
+ if (protectflag & OB_LOCK_SCALEZ) {
*drawflags &= ~MAN_SCALE_Z;
+ }
}
/* for pose mode */
@@ -1054,8 +1064,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
if (edit) {
point = edit->points;
for (a = 0; a < edit->totpoint; a++, point++) {
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
continue;
+ }
for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) {
if (ek->flag & PEK_SELECT) {
@@ -1066,8 +1077,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
}
/* selection center */
- if (totsel)
+ if (totsel) {
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
+ }
}
}
else {
@@ -1075,8 +1087,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
/* we need the one selected object, if its not active */
base = BASACT(view_layer);
ob = OBACT(view_layer);
- if (base && ((base->flag & BASE_SELECTED) == 0))
+ if (base && ((base->flag & BASE_SELECTED) == 0)) {
ob = NULL;
+ }
for (base = view_layer->object_bases.first; base; base = base->next) {
if (!BASE_SELECTED_EDITABLE(v3d, base)) {
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 46f6e576cf4..6ebed88878f 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -223,8 +223,9 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const double mval[2
float dphi;
dphi = saacos((float)deler);
- if ((dx1 * dy2 - dx2 * dy1) > 0.0)
+ if ((dx1 * dy2 - dx2 * dy1) > 0.0) {
dphi = -dphi;
+ }
/* If the angle is zero, because of lack of precision close to the 1.0 value in acos
* approximate the angle with the opposite side of the normalized triangle
@@ -244,8 +245,9 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const double mval[2
dy = dy1 - dy2;
dphi = sqrt(dx * dx + dy * dy);
- if ((dx1 * dy2 - dx2 * dy1) > 0.0)
+ if ((dx1 * dy2 - dx2 * dy1) > 0.0) {
dphi = -dphi;
+ }
}
data->angle += ((double)dphi) * (mi->precision ? (double)mi->precision_factor : 1.0);
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 14d904fdc6d..8606cd19c96 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -230,8 +230,9 @@ static bool delete_orientation_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (ED_operator_areaactive(C) == 0)
+ if (ED_operator_areaactive(C) == 0) {
return 0;
+ }
return ((scene->orientation_slots[SCE_ORIENT_DEFAULT].type >= V3D_ORIENT_CUSTOM) &&
(scene->orientation_slots[SCE_ORIENT_DEFAULT].index_custom != -1));
@@ -403,8 +404,9 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
// in other words, 2D deltas are no longer good enough!
// disable until individual 'transformers' behave better
- if (event->type == NDOF_MOTION)
+ if (event->type == NDOF_MOTION) {
return OPERATOR_PASS_THROUGH;
+ }
#endif
/* XXX insert keys are called here, and require context */
@@ -545,10 +547,9 @@ static bool transform_poll_property(const bContext *UNUSED(C),
/* Proportional Editing. */
{
- PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "proportional");
- if (prop_pet && (prop_pet != prop) &&
- (RNA_property_enum_get(op->ptr, prop_pet) == PROP_EDIT_OFF)) {
- if (STRPREFIX(prop_id, "proportional")) {
+ PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "use_proportional_edit");
+ if (prop_pet && (prop_pet != prop) && (RNA_property_boolean_get(op->ptr, prop_pet) == false)) {
+ if (STRPREFIX(prop_id, "proportional") || STRPREFIX(prop_id, "use_proportional")) {
return false;
}
}
@@ -608,12 +609,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
}
if (flags & P_PROPORTIONAL) {
- RNA_def_enum(ot->srna,
- "proportional",
- rna_enum_proportional_editing_items,
- 0,
- "Proportional Editing",
- "");
+ RNA_def_boolean(ot->srna, "use_proportional_edit", 0, "Proportional Editing", "");
prop = RNA_def_enum(ot->srna,
"proportional_edit_falloff",
rna_enum_proportional_falloff_items,
@@ -631,6 +627,9 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
"",
0.001f,
100.0f);
+
+ RNA_def_boolean(ot->srna, "use_proportional_connected", 0, "Connected", "");
+ RNA_def_boolean(ot->srna, "use_proportional_projected", 0, "Projected (2D)", "");
}
if (flags & P_SNAP) {
@@ -975,7 +974,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "To Sphere";
- //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()"
+ // added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()"
ot->description = "Move selected vertices outward in a spherical shape around mesh center";
ot->idname = OP_TOSPHERE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
@@ -1161,7 +1160,7 @@ static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot)
static void TRANSFORM_OT_rotate_normal(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Normal Rotate";
+ ot->name = "Rotate Normals";
ot->description = "Rotate split normal of selected items";
ot->idname = OP_NORMAL_ROTATION;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 18b19d903c4..e16579aba64 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -100,8 +100,9 @@ static TransformOrientation *createViewSpace(bContext *C,
RegionView3D *rv3d = CTX_wm_region_view3d(C);
float mat[3][3];
- if (!rv3d)
+ if (!rv3d) {
return NULL;
+ }
copy_m3_m4(mat, rv3d->viewinv);
normalize_m3(mat);
@@ -129,8 +130,9 @@ static TransformOrientation *createObjectSpace(bContext *C,
Object *ob;
float mat[3][3];
- if (base == NULL)
+ if (base == NULL) {
return NULL;
+ }
ob = base->object;
@@ -309,12 +311,15 @@ void BIF_createTransformOrientation(bContext *C,
Object *obedit = CTX_data_edit_object(C);
Object *ob = CTX_data_active_object(C);
if (obedit) {
- if (obedit->type == OB_MESH)
+ if (obedit->type == OB_MESH) {
ts = createMeshSpace(C, reports, name, overwrite);
- else if (obedit->type == OB_ARMATURE)
+ }
+ else if (obedit->type == OB_ARMATURE) {
ts = createBoneSpace(C, reports, name, overwrite);
- else if (obedit->type == OB_CURVE)
+ }
+ else if (obedit->type == OB_CURVE) {
ts = createCurveSpace(C, reports, name, overwrite);
+ }
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
ts = createBoneSpace(C, reports, name, overwrite);
@@ -587,8 +592,7 @@ static unsigned int bm_mesh_edges_select_get_n(BMesh *bm, BMEdge **elems, const
static unsigned int bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const unsigned int n)
{
return bm_mesh_elems_select_get_n__internal(
- bm, (BMElem **)elems, min_ii(n, bm->totfacesel),
- BM_FACES_OF_MESH, BM_FACE);
+ bm, (BMElem **)elems, min_ii(n, bm->totfacesel), BM_FACES_OF_MESH, BM_FACE);
}
#endif
@@ -781,8 +785,10 @@ int getTransformOrientation_ex(const bContext *C,
if (BM_vert_edge_pair(v, &e_pair[0], &e_pair[1])) {
bool v_pair_swap = false;
- BMVert *v_pair[2] = {BM_edge_other_vert(e_pair[0], v),
- BM_edge_other_vert(e_pair[1], v)};
+ BMVert *v_pair[2] = {
+ BM_edge_other_vert(e_pair[0], v),
+ BM_edge_other_vert(e_pair[1], v),
+ };
float dir_pair[2][3];
if (BM_edge_is_boundary(e_pair[0])) {
@@ -867,12 +873,15 @@ int getTransformOrientation_ex(const bContext *C,
#define SEL_F3 (1 << 2)
if (use_handle) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
flag |= SEL_F1;
- if (bezt->f2 & SELECT)
+ }
+ if (bezt->f2 & SELECT) {
flag |= SEL_F2;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
flag |= SEL_F3;
+ }
}
else {
flag = (bezt->f2 & SELECT) ? (SEL_F1 | SEL_F2 | SEL_F3) : 0;
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index d9cc9e3fcee..58a50da9846 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -152,8 +152,9 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
{
unsigned char col[4], selectedCol[4], activeCol[4];
- if (!activeSnap(t))
+ if (!activeSnap(t)) {
return;
+ }
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
col[3] = 128;
@@ -289,21 +290,23 @@ void applyProject(TransInfo *t)
float tvec[3];
int i;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
float iloc[3], loc[3], no[3];
float mval_fl[2];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
- if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f))
+ if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) {
continue;
+ }
copy_v3_v3(iloc, td->loc);
if (tc->use_local_mat) {
@@ -357,7 +360,7 @@ void applyProject(TransInfo *t)
}
}
- //XXX constraintTransLim(t, td);
+ // XXX constraintTransLim(t, td);
}
}
}
@@ -369,12 +372,14 @@ void applyGridAbsolute(TransInfo *t)
GearsType grid_action;
int i;
- if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID))))
+ if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
return;
+ }
grid_action = BIG_GEARS;
- if (t->modifiers & MOD_PRECISION)
+ if (t->modifiers & MOD_PRECISION) {
grid_action = SMALL_GEARS;
+ }
switch (grid_action) {
case NO_GEARS:
@@ -388,24 +393,27 @@ void applyGridAbsolute(TransInfo *t)
break;
}
/* early exit on unusable grid size */
- if (grid_size == 0.0f)
+ if (grid_size == 0.0f) {
return;
+ }
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td;
for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
float iloc[3], loc[3], tvec[3];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
- if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f))
+ if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) {
continue;
+ }
copy_v3_v3(iloc, td->loc);
if (tc->use_local_mat) {
@@ -543,8 +551,9 @@ static void initSnappingMode(TransInfo *t)
}
else {
/* force project off when not supported */
- if ((ts->snap_mode & SCE_SNAP_MODE_FACE) == 0)
+ if ((ts->snap_mode & SCE_SNAP_MODE_FACE) == 0) {
t->tsnap.project = 0;
+ }
t->tsnap.mode = ts->snap_mode;
}
@@ -582,7 +591,8 @@ static void initSnappingMode(TransInfo *t)
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
(obedit_type == -1)) // Object Mode
{
- /* In "Edit Strokes" mode, Snap tool can perform snap to selected or active objects (see T49632)
+ /* In "Edit Strokes" mode,
+ * snap tool can perform snap to selected or active objects (see T49632)
* TODO: perform self snap in gpencil_strokes */
t->tsnap.modeSelect = (((t->options & (CTX_GPENCIL_STROKES | CTX_CURSOR)) != 0) ?
SNAP_ALL :
@@ -852,10 +862,12 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3])
if (t->spacetype == SPACE_NODE) {
char border = t->tsnap.snapNodeBorder;
- if (border & (NODE_LEFT | NODE_RIGHT))
+ if (border & (NODE_LEFT | NODE_RIGHT)) {
vec[0] = point[0] - t->tsnap.snapTarget[0];
- if (border & (NODE_BOTTOM | NODE_TOP))
+ }
+ if (border & (NODE_BOTTOM | NODE_TOP)) {
vec[1] = point[1] - t->tsnap.snapTarget[1];
+ }
}
else {
if (t->spacetype == SPACE_VIEW3D) {
@@ -922,10 +934,12 @@ static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3])
cross_v3_v3v3(tmp, start, end);
- if (dot_v3v3(tmp, axis) < 0.0f)
+ if (dot_v3v3(tmp, axis) < 0.0f) {
angle = -acosf(dot_v3v3(start, end));
- else
+ }
+ else {
angle = acosf(dot_v3v3(start, end));
+ }
}
else {
float mtx[3][3];
@@ -1063,23 +1077,31 @@ static void TargetSnapOffset(TransInfo *t, TransData *td)
float height = BLI_rctf_size_y(&node->totr);
#ifdef USE_NODE_CENTER
- if (border & NODE_LEFT)
+ if (border & NODE_LEFT) {
t->tsnap.snapTarget[0] -= 0.5f * width;
- if (border & NODE_RIGHT)
+ }
+ if (border & NODE_RIGHT) {
t->tsnap.snapTarget[0] += 0.5f * width;
- if (border & NODE_BOTTOM)
+ }
+ if (border & NODE_BOTTOM) {
t->tsnap.snapTarget[1] -= 0.5f * height;
- if (border & NODE_TOP)
+ }
+ if (border & NODE_TOP) {
t->tsnap.snapTarget[1] += 0.5f * height;
+ }
#else
- if (border & NODE_LEFT)
+ if (border & NODE_LEFT) {
t->tsnap.snapTarget[0] -= 0.0f;
- if (border & NODE_RIGHT)
+ }
+ if (border & NODE_RIGHT) {
t->tsnap.snapTarget[0] += width;
- if (border & NODE_BOTTOM)
+ }
+ if (border & NODE_BOTTOM) {
t->tsnap.snapTarget[1] -= height;
- if (border & NODE_TOP)
+ }
+ if (border & NODE_TOP) {
t->tsnap.snapTarget[1] += 0.0f;
+ }
#endif
}
}
@@ -1123,8 +1145,7 @@ static void TargetSnapMedian(TransInfo *t)
t->tsnap.snapTarget[1] = 0;
t->tsnap.snapTarget[2] = 0;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
int i;
float v[3];
@@ -1160,8 +1181,7 @@ static void TargetSnapClosest(TransInfo *t)
/* Object mode */
if (t->flag & T_OBJECT) {
int i;
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (td = tc->data, i = 0; i < tc->data_len && td->flag & TD_SELECTED; i++, td++) {
struct BoundBox *bb = BKE_object_boundbox_get(td->ob);
@@ -1206,8 +1226,7 @@ static void TargetSnapClosest(TransInfo *t)
}
}
else {
- FOREACH_TRANS_DATA_CONTAINER(t, tc)
- {
+ FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
int i;
for (i = 0; i < tc->data_len && td->flag & TD_SELECTED; i++, td++) {
@@ -1506,8 +1525,9 @@ void snapSequenceBounds(TransInfo *t, const int mval[2])
int mframe;
TransSeq *ts = TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->custom.type.data;
/* reuse increment, strictly speaking could be another snap mode, but leave as is */
- if (!(t->modifiers & MOD_SNAP_INVERT))
+ if (!(t->modifiers & MOD_SNAP_INVERT)) {
return;
+ }
/* convert to frame range */
UI_view2d_region_to_view(&t->ar->v2d, mval[0], mval[1], &xmouse, &ymouse);
@@ -1515,8 +1535,9 @@ void snapSequenceBounds(TransInfo *t, const int mval[2])
/* now find the closest sequence */
frame = BKE_sequencer_find_next_prev_edit(t->scene, mframe, SEQ_SIDE_BOTH, true, false, true);
- if (!ts->snap_left)
+ if (!ts->snap_left) {
frame = frame - (ts->max - ts->min);
+ }
t->values[0] = frame - ts->min;
}
@@ -1542,24 +1563,11 @@ static void applyGridIncrement(
/* custom aspect for fcurve */
if (t->spacetype == SPACE_GRAPH) {
View2D *v2d = &t->ar->v2d;
- View2DGrid *grid;
+ Scene *scene = t->scene;
SpaceGraph *sipo = t->sa->spacedata.first;
- int unity = V2D_UNIT_VALUES;
- int unitx = (sipo->flag & SIPO_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE;
-
- /* grid */
- grid = UI_view2d_grid_calc(t->scene,
- v2d,
- unitx,
- V2D_GRID_NOCLAMP,
- unity,
- V2D_GRID_NOCLAMP,
- t->ar->winx,
- t->ar->winy);
-
- UI_view2d_grid_size(grid, &asp_local[0], &asp_local[1]);
- UI_view2d_grid_free(grid);
-
+ asp_local[0] = UI_view2d_grid_resolution_x__frames_or_seconds(
+ v2d, scene, sipo->flag & SIPO_DRAWTIME);
+ asp_local[1] = UI_view2d_grid_resolution_y__values(v2d);
asp = asp_local;
}
}
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 93f89c1919e..829365367ee 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -826,7 +826,8 @@ static void raycast_obj_cb(
* Read/Write Args
* ---------------
*
- * \param ray_depth: maximum depth allowed for r_co, elements deeper than this value will be ignored.
+ * \param ray_depth: maximum depth allowed for r_co,
+ * elements deeper than this value will be ignored.
*
* Output Args
* -----------
@@ -887,7 +888,8 @@ static bool snap_bound_box_check_dist(float min[3],
float mval[2],
float dist_px_sq)
{
- /* In vertex and edges you need to get the pixel distance from ray to BoundBox, see: T46099, T46816 */
+ /* In vertex and edges you need to get the pixel distance from ray to BoundBox,
+ * see: T46099, T46816 */
struct DistProjectedAABBPrecalc data_precalc;
dist_squared_to_projected_aabb_precalc(&data_precalc, lpmat, win_size, mval);
@@ -951,11 +953,12 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree
const MEdge *ed = &medge[mloop[lt->tri[j]].e];
unsigned int tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v};
if (ELEM(ed->v1, tri_edge[0], tri_edge[1]) && ELEM(ed->v2, tri_edge[0], tri_edge[1])) {
- //printf("real edge found\n");
+ // printf("real edge found\n");
v_index[j] = mloop[lt->tri[j]].e;
}
- else
+ else {
v_index[j] = -1;
+ }
}
}
@@ -1626,7 +1629,8 @@ static short snapCurve(SnapData *snapdata,
nu->bezt[u].vec[1],
&dist_px_sq,
r_loc);
- /* don't snap if handle is selected (moving), or if it is aligning to a moving handle */
+ /* Don't snap if handle is selected (moving),
+ * or if it is aligning to a moving handle. */
if (!(nu->bezt[u].f1 & SELECT) &&
!(nu->bezt[u].h1 & HD_ALIGN && nu->bezt[u].f3 & SELECT)) {
has_snap |= test_projected_vert_dist(&neasrest_precalc,
diff --git a/source/blender/editors/undo/CMakeLists.txt b/source/blender/editors/undo/CMakeLists.txt
index 7c1a074bb13..0f4152c9128 100644
--- a/source/blender/editors/undo/CMakeLists.txt
+++ b/source/blender/editors/undo/CMakeLists.txt
@@ -24,8 +24,8 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/clog
+ ../../../../intern/guardedalloc
)
set(SRC
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 08f1a13e0c2..49b5cada04a 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -476,15 +476,16 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
if ((WM_operator_repeat_check(C, op)) && (WM_operator_poll(C, op->type)) &&
/* note, undo/redo cant run if there are jobs active,
- * check for screen jobs only so jobs like material/texture/world preview
- * (which copy their data), wont stop redo, see [#29579]],
- *
- * note, - WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this */
+ * check for screen jobs only so jobs like material/texture/world preview
+ * (which copy their data), wont stop redo, see [#29579]],
+ *
+ * note, - WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this */
(WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY) == 0)) {
int retval;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("redo_cb: operator redo %s\n", op->type->name);
+ }
WM_operator_free_all_after(wm, op);
@@ -511,8 +512,9 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
retval = WM_operator_repeat(C, op);
if ((retval & OPERATOR_FINISHED) == 0) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("redo_cb: operator redo failed: %s, return %d\n", op->type->name, retval);
+ }
ED_undo_redo(C);
}
else {
diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c
index 36ce38091d4..0f495d64b29 100644
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@ -115,7 +115,8 @@ static void memfile_undosys_step_decode(struct bContext *C,
static void memfile_undosys_step_free(UndoStep *us_p)
{
- /* To avoid unnecessary slow down, free backwards (so we don't need to merge when clearing all). */
+ /* To avoid unnecessary slow down, free backwards
+ * (so we don't need to merge when clearing all). */
MemFileUndoStep *us = (MemFileUndoStep *)us_p;
if (us_p->next != NULL) {
UndoStep *us_next_p = BKE_undosys_step_same_type_next(us_p);
@@ -149,7 +150,8 @@ void ED_memfile_undosys_type(UndoType *ut)
* \{ */
/**
- * Ideally we wouldn't need to export global undo internals, there are some cases where it's needed though.
+ * Ideally we wouldn't need to export global undo internals,
+ * there are some cases where it's needed though.
*/
static struct MemFile *ed_undosys_step_get_memfile(UndoStep *us_p)
{
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index a1893d8e6f1..3b49784d5eb 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -22,14 +22,14 @@ set(INC
../../blentranslation
../../bmesh
../../depsgraph
- ../../imbuf
../../gpu
+ ../../imbuf
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/clog
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/util/ed_transverts.c b/source/blender/editors/util/ed_transverts.c
index 4cc74bec7d9..f054d09094d 100644
--- a/source/blender/editors/util/ed_transverts.c
+++ b/source/blender/editors/util/ed_transverts.c
@@ -74,8 +74,9 @@ void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
while (a--) {
if (bezt->hide == 0) {
bool skip_handle = false;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
skip_handle = (mode & TM_SKIP_HANDLES) != 0;
+ }
if ((bezt->f1 & SELECT) && !skip_handle) {
BLI_assert(tv->loc == bezt->vec[0]);
@@ -131,8 +132,9 @@ void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
add_v3_v3(ebo->tail, diffvec);
a++;
- if (a < tvs->transverts_tot)
+ if (a < tvs->transverts_tot) {
tv++;
+ }
}
}
}
@@ -150,14 +152,16 @@ void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
}
}
}
- if (arm->flag & ARM_MIRROR_EDIT)
+ if (arm->flag & ARM_MIRROR_EDIT) {
ED_armature_edit_transform_mirror_update(obedit);
+ }
}
else if (obedit->type == OB_LATTICE) {
Lattice *lt = obedit->data;
- if (lt->editlatt->latt->flag & LT_OUTSIDE)
+ if (lt->editlatt->latt->flag & LT_OUTSIDE) {
outside_lattice(lt->editlatt->latt);
+ }
}
}
@@ -247,8 +251,9 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const
}
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve) == TM_INDEX_ON)
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) {
tvs->transverts_tot++;
+ }
}
}
else {
@@ -270,8 +275,9 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const
}
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve) == TM_INDEX_ON)
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) {
tvs->transverts_tot++;
+ }
}
}
/* for any of the 3 loops above which all dirty the indices */
@@ -363,10 +369,12 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
for (nu = nurbs->first; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER)
+ if (nu->type == CU_BEZIER) {
totmalloc += 3 * nu->pntsu;
- else
+ }
+ else {
totmalloc += nu->pntsu * nu->pntsv;
+ }
}
tv = tvs->transverts = MEM_callocN(totmalloc * sizeof(TransVert), __func__);
@@ -378,8 +386,9 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const
while (a--) {
if (bezt->hide == 0) {
bool skip_handle = false;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
skip_handle = (mode & TM_SKIP_HANDLES) != 0;
+ }
if ((bezt->f1 & SELECT) && !skip_handle) {
copy_v3_v3(tv->oldloc, bezt->vec[0]);
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 503910d1734..df1906ea8a8 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -271,20 +271,24 @@ void apply_keyb_grid(
int shift, int ctrl, float *val, float fac1, float fac2, float fac3, int invert)
{
/* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */
- if (invert)
+ if (invert) {
ctrl = !ctrl;
+ }
if (ctrl && shift) {
- if (fac3 != 0.0f)
+ if (fac3 != 0.0f) {
*val = fac3 * floorf(*val / fac3 + 0.5f);
+ }
}
else if (ctrl) {
- if (fac2 != 0.0f)
+ if (fac2 != 0.0f) {
*val = fac2 * floorf(*val / fac2 + 0.5f);
+ }
}
else {
- if (fac1 != 0.0f)
+ if (fac1 != 0.0f) {
*val = fac1 * floorf(*val / fac1 + 0.5f);
+ }
}
}
@@ -326,7 +330,7 @@ void unpack_menu(bContext *C,
break;
case PF_EQUAL:
BLI_snprintf(line, sizeof(line), IFACE_("Use %s (identical)"), local_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
@@ -334,13 +338,13 @@ void unpack_menu(bContext *C,
break;
case PF_DIFFERS:
BLI_snprintf(line, sizeof(line), IFACE_("Use %s (differs)"), local_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
BLI_snprintf(line, sizeof(line), IFACE_("Overwrite %s"), local_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
RNA_string_set(&props_ptr, "id", id_name);
@@ -352,27 +356,27 @@ void unpack_menu(bContext *C,
switch (checkPackedFile(BKE_main_blendfile_path(bmain), abs_name, pf)) {
case PF_NOFILE:
BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), abs_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_EQUAL:
BLI_snprintf(line, sizeof(line), IFACE_("Use %s (identical)"), abs_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
break;
case PF_DIFFERS:
BLI_snprintf(line, sizeof(line), IFACE_("Use %s (differs)"), abs_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
BLI_snprintf(line, sizeof(line), IFACE_("Overwrite %s"), abs_name);
- //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
+ // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &props_ptr);
RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
RNA_string_set(&props_ptr, "id", id_name);
@@ -391,8 +395,10 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
{
wmWindow *win = CTX_wm_window(C);
const float *mval_src = (float *)arg_info;
- const float mval_dst[2] = {win->eventstate->x - ar->winrct.xmin,
- win->eventstate->y - ar->winrct.ymin};
+ const float mval_dst[2] = {
+ win->eventstate->x - ar->winrct.xmin,
+ win->eventstate->y - ar->winrct.ymin,
+ };
const uint shdr_pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 0ab37d61ce4..8abd8db53c1 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -452,7 +452,8 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
utf8_buf = ascii;
break;
#if 0
- /* Those keys are not directly accessible in all layouts, preventing to generate matching events.
+ /* Those keys are not directly accessible in all layouts,
+ * preventing to generate matching events.
* So we use a hack (ascii value) instead, see below.
*/
case EQUALKEY:
diff --git a/source/blender/editors/util/select_utils.c b/source/blender/editors/util/select_utils.c
index 13c623a2860..a26579b0d84 100644
--- a/source/blender/editors/util/select_utils.c
+++ b/source/blender/editors/util/select_utils.c
@@ -115,8 +115,8 @@ bool ED_select_similar_compare_float_tree(const KDTree_1d *tree,
case SIM_CMP_GT:
/* Compare against the shortest edge. */
/* -FLT_MAX leads to some precision issues and the wrong edge being selected.
- * For example, in a tree with 1, 2 and 3, which is stored squared as 1, 4, 9, it returns as the nearest
- * length/node the "4" instead of "1". */
+ * For example, in a tree with 1, 2 and 3, which is stored squared as 1, 4, 9,
+ * it returns as the nearest length/node the "4" instead of "1". */
nearest_edge_length = -1.0f;
break;
case SIM_CMP_LT:
diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt
index 240cfd382a4..d2ba9ab9591 100644
--- a/source/blender/editors/uvedit/CMakeLists.txt
+++ b/source/blender/editors/uvedit/CMakeLists.txt
@@ -26,9 +26,9 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
- ../../../../intern/guardedalloc
../../../../intern/eigen
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index 16620436029..1482fea456d 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -69,8 +69,9 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im
zero_v2(center);
BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -100,8 +101,9 @@ static void uvedit_translate(
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -203,8 +205,9 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event)
float center[2], delta[2];
int imx, imy;
- if (event != B_UVEDIT_VERTEX)
+ if (event != B_UVEDIT_VERTEX) {
return;
+ }
em = BKE_editmesh_from_object(obedit);
@@ -255,6 +258,8 @@ void ED_uvedit_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel uv");
strcpy(pt->idname, "IMAGE_PT_uv");
strcpy(pt->label, N_("UV Vertex")); /* XXX C panels unavailable through RNA bpy.types! */
+ /* Could be 'Item' matching 3D view, avoid new tab for two buttons. */
+ strcpy(pt->category, "Image");
pt->draw = image_panel_uv;
pt->poll = image_panel_uv_poll;
BLI_addtail(&art->paneltypes, pt);
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 5ff90097840..804b9c22104 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -72,15 +72,19 @@ static int draw_uvs_face_check(const ToolSettings *ts)
{
/* checks if we are selecting only faces */
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode == SCE_SELECT_FACE)
+ if (ts->selectmode == SCE_SELECT_FACE) {
return 2;
- else if (ts->selectmode & SCE_SELECT_FACE)
+ }
+ else if (ts->selectmode & SCE_SELECT_FACE) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
- else
+ else {
return (ts->uv_selectmode == UV_SELECT_FACE);
+ }
}
/* ------------------------- */
@@ -461,8 +465,9 @@ static void draw_uv_shadows_get(
{
*show_shadow = *show_texpaint = false;
- if (ED_space_image_show_render(sima) || (sima->flag & SI_NO_DRAW_TEXPAINT))
+ if (ED_space_image_show_render(sima) || (sima->flag & SI_NO_DRAW_TEXPAINT)) {
return;
+ }
if ((sima->mode == SI_MODE_PAINT) && obedit && obedit->type == OB_MESH) {
struct BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -474,14 +479,12 @@ static void draw_uv_shadows_get(
}
void ED_uvedit_draw_main(SpaceImage *sima,
- ARegion *ar,
Scene *scene,
ViewLayer *view_layer,
Object *obedit,
Object *obact,
Depsgraph *depsgraph)
{
- ToolSettings *toolsettings = scene->toolsettings;
bool show_uvedit, show_uvshadow, show_texpaint_uvshadow;
show_uvedit = ED_space_image_show_uvedit(sima, obedit);
@@ -504,8 +507,5 @@ void ED_uvedit_draw_main(SpaceImage *sima,
else {
draw_uvs_texpaint(scene, obact, depsgraph);
}
-
- if (show_uvedit && !(toolsettings->use_uv_sculpt))
- ED_image_draw_cursor(ar, sima->cursor);
}
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 291dbdf6942..30ded60bd84 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -114,11 +114,13 @@ bool ED_uvedit_test(Object *obedit)
BMEditMesh *em;
int ret;
- if (!obedit)
+ if (!obedit) {
return 0;
+ }
- if (obedit->type != OB_MESH)
+ if (obedit->type != OB_MESH) {
return 0;
+ }
em = BKE_editmesh_from_object(obedit);
ret = EDBM_uv_check(em);
@@ -126,15 +128,6 @@ bool ED_uvedit_test(Object *obedit)
return ret;
}
-static bool ED_operator_uvedit_can_uv_sculpt(struct bContext *C)
-{
- SpaceImage *sima = CTX_wm_space_image(C);
- ToolSettings *toolsettings = CTX_data_tool_settings(C);
- Object *obedit = CTX_data_edit_object(C);
-
- return ED_space_image_show_uvedit(sima, obedit) && !(toolsettings->use_uv_sculpt);
-}
-
static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
{
Object *ob = CTX_data_active_object(C);
@@ -142,8 +135,9 @@ static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
if (ob && ob->type == OB_MESH) {
Mesh *me = ob->data;
- if (CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL)
+ if (CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL) {
return 1;
+ }
}
return 0;
@@ -172,8 +166,9 @@ bool ED_object_get_active_image(Object *ob,
bNode *node = (ntree) ? nodeGetActiveTexture(ntree) : NULL;
if (node && is_image_texture_node(node)) {
- if (r_ima)
+ if (r_ima) {
*r_ima = (Image *)node->id;
+ }
if (r_iuser) {
if (node->type == SH_NODE_TEX_IMAGE) {
*r_iuser = &((NodeTexImage *)node->storage)->iuser;
@@ -185,21 +180,27 @@ bool ED_object_get_active_image(Object *ob,
*r_iuser = NULL;
}
}
- if (r_node)
+ if (r_node) {
*r_node = node;
- if (r_ntree)
+ }
+ if (r_ntree) {
*r_ntree = ntree;
+ }
return true;
}
- if (r_ima)
+ if (r_ima) {
*r_ima = NULL;
- if (r_iuser)
+ }
+ if (r_iuser) {
*r_iuser = NULL;
- if (r_node)
+ }
+ if (r_node) {
*r_node = node;
- if (r_ntree)
+ }
+ if (r_ntree) {
*r_ntree = ntree;
+ }
return false;
}
@@ -263,10 +264,12 @@ static void uvedit_vertex_select_tagged(BMEditMesh *em,
bool uvedit_face_visible_nolocal_ex(const ToolSettings *ts, BMFace *efa)
{
- if (ts->uv_flag & UV_SYNC_SELECTION)
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0);
- else
+ }
+ else {
return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0 && BM_elem_flag_test(efa, BM_ELEM_SELECT));
+ }
}
bool uvedit_face_visible_nolocal(Scene *scene, BMFace *efa)
{
@@ -301,8 +304,9 @@ bool uvedit_face_select_test_ex(const ToolSettings *ts, BMFace *efa, const int c
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- if (!(luv->flag & MLOOPUV_VERTSEL))
+ if (!(luv->flag & MLOOPUV_VERTSEL)) {
return false;
+ }
}
return true;
@@ -432,10 +436,12 @@ void uvedit_edge_select_enable(
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, true);
- else if (ts->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
BM_edge_select_set(em->bm, l->e, true);
+ }
else {
BM_vert_select_set(em->bm, l->e->v1, true);
BM_vert_select_set(em->bm, l->e->v2, true);
@@ -465,10 +471,12 @@ void uvedit_edge_select_disable(BMEditMesh *em,
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, false);
- else if (ts->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
BM_edge_select_set(em->bm, l->e, false);
+ }
else {
BM_vert_select_set(em->bm, l->e->v1, false);
BM_vert_select_set(em->bm, l->e->v2, false);
@@ -488,10 +496,12 @@ void uvedit_edge_select_disable(BMEditMesh *em,
bool uvedit_uv_select_test_ex(const ToolSettings *ts, BMLoop *l, const int cd_loop_uv_offset)
{
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
return BM_elem_flag_test_bool(l->f, BM_ELEM_SELECT);
- else
+ }
+ else {
return BM_elem_flag_test_bool(l->v, BM_ELEM_SELECT);
+ }
}
else {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -524,10 +534,12 @@ void uvedit_uv_select_enable(
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, true);
- else
+ }
+ else {
BM_vert_select_set(em->bm, l->v, true);
+ }
if (do_history) {
BM_select_history_remove(em->bm, (BMElem *)l->v);
@@ -544,10 +556,12 @@ void uvedit_uv_select_disable(BMEditMesh *em, Scene *scene, BMLoop *l, const int
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, false);
- else
+ }
+ else {
BM_vert_select_set(em->bm, l->v, false);
+ }
}
else {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -623,8 +637,9 @@ bool ED_uvedit_minmax_multi(Scene *scene,
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -679,8 +694,9 @@ static bool ED_uvedit_median_multi(
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -756,8 +772,7 @@ bool uv_find_nearest_edge(
if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
}
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
luv_next = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
@@ -901,8 +916,7 @@ bool uv_find_nearest_vert(Scene *scene,
BMIter liter;
BMLoop *l;
int i;
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
float dist_test_sq;
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (penalty_dist != 0.0f && uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1024,14 +1038,16 @@ static void uv_select_edgeloop_vertex_loop_flag(UvMapVert *first)
int count = 0;
for (iterv = first; iterv; iterv = iterv->next) {
- if (iterv->separate && iterv != first)
+ if (iterv->separate && iterv != first) {
break;
+ }
count++;
}
- if (count < 5)
+ if (count < 5) {
first->flag = 1;
+ }
}
static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa, BMLoop *l)
@@ -1040,10 +1056,12 @@ static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa
first = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
for (iterv = first; iterv; iterv = iterv->next) {
- if (iterv->separate)
+ if (iterv->separate) {
first = iterv;
- if (iterv->poly_index == BM_elem_index_get(efa))
+ }
+ if (iterv->poly_index == BM_elem_index_get(efa)) {
return first;
+ }
}
return NULL;
@@ -1060,18 +1078,21 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em,
/* count number of faces this edge has */
for (iterv1 = first1; iterv1; iterv1 = iterv1->next) {
- if (iterv1->separate && iterv1 != first1)
+ if (iterv1->separate && iterv1 != first1) {
break;
+ }
for (iterv2 = first2; iterv2; iterv2 = iterv2->next) {
- if (iterv2->separate && iterv2 != first2)
+ if (iterv2->separate && iterv2 != first2) {
break;
+ }
if (iterv1->poly_index == iterv2->poly_index) {
/* if face already tagged, don't do this edge */
efa = BM_face_at_index(em->bm, iterv1->poly_index);
- if (BM_elem_flag_test(efa, BM_ELEM_TAG))
+ if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
return false;
+ }
tot++;
break;
@@ -1079,19 +1100,23 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em,
}
}
- if (*totface == 0) /* start edge */
+ if (*totface == 0) { /* start edge */
*totface = tot;
- else if (tot != *totface) /* check for same number of faces as start edge */
+ }
+ else if (tot != *totface) { /* check for same number of faces as start edge */
return false;
+ }
/* tag the faces */
for (iterv1 = first1; iterv1; iterv1 = iterv1->next) {
- if (iterv1->separate && iterv1 != first1)
+ if (iterv1->separate && iterv1 != first1) {
break;
+ }
for (iterv2 = first2; iterv2; iterv2 = iterv2->next) {
- if (iterv2->separate && iterv2 != first2)
+ if (iterv2->separate && iterv2 != first2) {
break;
+ }
if (iterv1->poly_index == iterv2->poly_index) {
efa = BM_face_at_index(em->bm, iterv1->poly_index);
@@ -1158,10 +1183,12 @@ static int uv_select_edgeloop(Scene *scene,
uvedit_face_visible_test(scene, obedit, ima, efa)) {
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
/* check face not hidden and not tagged */
- if (!(iterv_curr = uv_select_edgeloop_vertex_map_get(vmap, efa, l)))
+ if (!(iterv_curr = uv_select_edgeloop_vertex_map_get(vmap, efa, l))) {
continue;
- if (!(iterv_next = uv_select_edgeloop_vertex_map_get(vmap, efa, l->next)))
+ }
+ if (!(iterv_next = uv_select_edgeloop_vertex_map_get(vmap, efa, l->next))) {
continue;
+ }
/* check if vertex is tagged and has right valence */
if (iterv_curr->flag || iterv_next->flag) {
@@ -1255,8 +1282,9 @@ static void uv_select_linked_multi(Scene *scene,
* keeping island-select working as is. */
vmap = BM_uv_vert_map_create(em->bm, limit, !select_faces, false);
- if (vmap == NULL)
+ if (vmap == NULL) {
return;
+ }
stack = MEM_mallocN(sizeof(*stack) * (em->bm->totface + 1), "UvLinkStack");
flag = MEM_callocN(sizeof(*flag) * em->bm->totface, "UvLinkFlag");
@@ -1306,8 +1334,7 @@ static void uv_select_linked_multi(Scene *scene,
efa = BM_face_at_index(em->bm, a);
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
/* make_uv_vert_map_EM sets verts tmp.l to the indices */
vlist = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
@@ -1315,15 +1342,18 @@ static void uv_select_linked_multi(Scene *scene,
startv = vlist;
for (iterv = vlist; iterv; iterv = iterv->next) {
- if (iterv->separate)
+ if (iterv->separate) {
startv = iterv;
- if (iterv->poly_index == a)
+ }
+ if (iterv->poly_index == a) {
break;
+ }
}
for (iterv = startv; iterv; iterv = iterv->next) {
- if ((startv != iterv) && (iterv->separate))
+ if ((startv != iterv) && (iterv->separate)) {
break;
+ }
else if (!flag[iterv->poly_index]) {
flag[iterv->poly_index] = 1;
stack[stacksize] = iterv->poly_index;
@@ -1410,8 +1440,9 @@ static float *uv_sel_co_from_eve(
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_ELEM (l, &liter, eve, BM_LOOPS_OF_VERT) {
- if (!uvedit_face_visible_test(scene, obedit, ima, l->f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, l->f)) {
continue;
+ }
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1623,8 +1654,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
BMLoop *l;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1656,8 +1688,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
BMLoop *l;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1675,8 +1708,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
BMLoop *l;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1701,8 +1735,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
/* tag verts with a selected UV */
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
BM_ITER_ELEM (l, &liter, eve, BM_LOOPS_OF_VERT) {
- if (!uvedit_face_visible_test(scene, obedit, ima, l->f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, l->f)) {
continue;
+ }
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
BM_elem_flag_enable(eve, BM_ELEM_TAG);
@@ -1778,23 +1813,28 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
eUVWeldAlign tool_local = tool;
if (tool_local == UV_STRAIGHTEN_X) {
- if (uv_start[1] == uv_end[1])
+ if (uv_start[1] == uv_end[1]) {
tool_local = UV_STRAIGHTEN;
- else
+ }
+ else {
a = (uv_end[0] - uv_start[0]) / (uv_end[1] - uv_start[1]);
+ }
}
else if (tool_local == UV_STRAIGHTEN_Y) {
- if (uv_start[0] == uv_end[0])
+ if (uv_start[0] == uv_end[0]) {
tool_local = UV_STRAIGHTEN;
- else
+ }
+ else {
a = (uv_end[1] - uv_start[1]) / (uv_end[0] - uv_start[0]);
+ }
}
/* go over all verts except for endpoints */
for (i = 0; i < BLI_array_len(eve_line); i++) {
BM_ITER_ELEM (l, &liter, eve_line[i], BM_LOOPS_OF_VERT) {
- if (!uvedit_face_visible_test(scene, obedit, ima, l->f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, l->f)) {
continue;
+ }
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1802,12 +1842,15 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
* new_y = (y2 - y1) / (x2 - x1) * (x - x1) + y1
* Maybe this should be a BLI func? Or is it already existing?
* Could use interp_v2_v2v2, but not sure it's worth it here...*/
- if (tool_local == UV_STRAIGHTEN_X)
+ if (tool_local == UV_STRAIGHTEN_X) {
luv->uv[0] = a * (luv->uv[1] - uv_start[1]) + uv_start[0];
- else if (tool_local == UV_STRAIGHTEN_Y)
+ }
+ else if (tool_local == UV_STRAIGHTEN_Y) {
luv->uv[1] = a * (luv->uv[0] - uv_start[0]) + uv_start[1];
- else
+ }
+ else {
closest_to_line_segment_v2(luv->uv, luv->uv, uv_start, uv_end);
+ }
changed = true;
}
}
@@ -2160,7 +2203,7 @@ static int uv_remove_doubles_exec(bContext *C, wmOperator *op)
static void UV_OT_remove_doubles(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Remove Doubles UV";
+ ot->name = "Merge UVs by Distance";
ot->description =
"Selected UV vertices that are within a radius of each other are welded together";
ot->idname = "UV_OT_remove_doubles";
@@ -2294,8 +2337,9 @@ static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, int
}
else {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2384,25 +2428,33 @@ static bool uv_sticky_select(
/* this function test if some vertex needs to selected
* in addition to the existing ones due to sticky select */
- if (sticky == SI_STICKY_DISABLE)
+ if (sticky == SI_STICKY_DISABLE) {
return false;
+ }
for (i = 0; i < hitlen; i++) {
if (hitv[i] == v) {
if (sticky == SI_STICKY_LOC) {
- if (fabsf(hituv[i][0] - uv[0]) < limit[0] && fabsf(hituv[i][1] - uv[1]) < limit[1])
+ if (fabsf(hituv[i][0] - uv[0]) < limit[0] && fabsf(hituv[i][1] - uv[1]) < limit[1]) {
return true;
+ }
}
- else if (sticky == SI_STICKY_VERTEX)
+ else if (sticky == SI_STICKY_VERTEX) {
return true;
+ }
}
}
return false;
}
-static int uv_mouse_select_multi(
- bContext *C, Object **objects, uint objects_len, const float co[2], bool extend, bool loop)
+static int uv_mouse_select_multi(bContext *C,
+ Object **objects,
+ uint objects_len,
+ const float co[2],
+ const bool extend,
+ const bool deselect_all,
+ const bool loop)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
SpaceImage *sima = CTX_wm_space_image(C);
@@ -2416,6 +2468,7 @@ static int uv_mouse_select_multi(
UvNearestHit hit = UV_NEAREST_HIT_INIT;
int i, selectmode, sticky, sync, *hitv = NULL;
bool select = true;
+ bool found_item = false;
/* 0 == don't flush, 1 == sel, -1 == desel; only use when selection sync is enabled */
int flush = 0;
int hitlen = 0;
@@ -2439,12 +2492,15 @@ static int uv_mouse_select_multi(
if (ts->uv_flag & UV_SYNC_SELECTION) {
sync = 1;
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
selectmode = UV_SELECT_FACE;
- else if (ts->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
selectmode = UV_SELECT_EDGE;
- else
+ }
+ else {
selectmode = UV_SELECT_VERTEX;
+ }
sticky = SI_STICKY_DISABLE;
}
@@ -2457,80 +2513,86 @@ static int uv_mouse_select_multi(
/* find nearest element */
if (loop) {
/* find edge */
- if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
- return OPERATOR_CANCELLED;
- }
-
- hitlen = 0;
+ found_item = uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit);
}
else if (selectmode == UV_SELECT_VERTEX) {
/* find vertex */
- if (!uv_find_nearest_vert_multi(scene, ima, objects, objects_len, co, penalty_dist, &hit)) {
- return OPERATOR_CANCELLED;
- }
+ found_item = uv_find_nearest_vert_multi(
+ scene, ima, objects, objects_len, co, penalty_dist, &hit);
+ found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist);
- /* mark 1 vertex as being hit */
- hitv = BLI_array_alloca(hitv, hit.efa->len);
- hituv = BLI_array_alloca(hituv, hit.efa->len);
- copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF);
+ if (found_item) {
+ /* mark 1 vertex as being hit */
+ hitv = BLI_array_alloca(hitv, hit.efa->len);
+ hituv = BLI_array_alloca(hituv, hit.efa->len);
+ copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF);
- hitv[hit.lindex] = BM_elem_index_get(hit.l->v);
- hituv[hit.lindex] = hit.luv->uv;
+ hitv[hit.lindex] = BM_elem_index_get(hit.l->v);
+ hituv[hit.lindex] = hit.luv->uv;
- hitlen = hit.efa->len;
+ hitlen = hit.efa->len;
+ }
}
else if (selectmode == UV_SELECT_EDGE) {
/* find edge */
- if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
- return OPERATOR_CANCELLED;
- }
+ found_item = uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit);
+ found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist);
- /* mark 2 edge vertices as being hit */
- hitv = BLI_array_alloca(hitv, hit.efa->len);
- hituv = BLI_array_alloca(hituv, hit.efa->len);
- copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF);
+ if (found_item) {
+ /* mark 2 edge vertices as being hit */
+ hitv = BLI_array_alloca(hitv, hit.efa->len);
+ hituv = BLI_array_alloca(hituv, hit.efa->len);
+ copy_vn_i(hitv, hit.efa->len, 0xFFFFFFFF);
- hitv[hit.lindex] = BM_elem_index_get(hit.l->v);
- hitv[(hit.lindex + 1) % hit.efa->len] = BM_elem_index_get(hit.l->next->v);
- hituv[hit.lindex] = hit.luv->uv;
- hituv[(hit.lindex + 1) % hit.efa->len] = hit.luv_next->uv;
+ hitv[hit.lindex] = BM_elem_index_get(hit.l->v);
+ hitv[(hit.lindex + 1) % hit.efa->len] = BM_elem_index_get(hit.l->next->v);
+ hituv[hit.lindex] = hit.luv->uv;
+ hituv[(hit.lindex + 1) % hit.efa->len] = hit.luv_next->uv;
- hitlen = hit.efa->len;
+ hitlen = hit.efa->len;
+ }
}
else if (selectmode == UV_SELECT_FACE) {
/* find face */
- if (!uv_find_nearest_face_multi(scene, ima, objects, objects_len, co, &hit)) {
- return OPERATOR_CANCELLED;
- }
+ found_item = uv_find_nearest_face_multi(scene, ima, objects, objects_len, co, &hit);
+ found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist);
- BMEditMesh *em = BKE_editmesh_from_object(hit.ob);
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ if (found_item) {
+ BMEditMesh *em = BKE_editmesh_from_object(hit.ob);
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- /* make active */
- BM_mesh_active_face_set(em->bm, hit.efa);
+ /* make active */
+ BM_mesh_active_face_set(em->bm, hit.efa);
- /* mark all face vertices as being hit */
+ /* mark all face vertices as being hit */
- hitv = BLI_array_alloca(hitv, hit.efa->len);
- hituv = BLI_array_alloca(hituv, hit.efa->len);
- BM_ITER_ELEM_INDEX(l, &liter, hit.efa, BM_LOOPS_OF_FACE, i)
- {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- hituv[i] = luv->uv;
- hitv[i] = BM_elem_index_get(l->v);
- }
+ hitv = BLI_array_alloca(hitv, hit.efa->len);
+ hituv = BLI_array_alloca(hituv, hit.efa->len);
+ BM_ITER_ELEM_INDEX (l, &liter, hit.efa, BM_LOOPS_OF_FACE, i) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ hituv[i] = luv->uv;
+ hitv[i] = BM_elem_index_get(l->v);
+ }
- hitlen = hit.efa->len;
+ hitlen = hit.efa->len;
+ }
}
else if (selectmode == UV_SELECT_ISLAND) {
- if (!uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit)) {
- return OPERATOR_CANCELLED;
- }
-
- hitlen = 0;
+ found_item = uv_find_nearest_edge_multi(scene, ima, objects, objects_len, co, &hit);
+ found_item = found_item && (!deselect_all || hit.dist_sq < penalty_dist);
}
- else {
- hitlen = 0;
+
+ if (!found_item) {
+ if (deselect_all) {
+ uv_select_all_perform_multi(scene, ima, objects, objects_len, SEL_DESELECT);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ uv_select_tag_update_for_object(depsgraph, ts, obedit);
+ }
+
+ return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED;
+ }
return OPERATOR_CANCELLED;
}
@@ -2589,14 +2651,16 @@ static int uv_mouse_select_multi(
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (uv_sticky_select(
- limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
+ limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+ }
}
}
@@ -2625,17 +2689,20 @@ static int uv_mouse_select_multi(
/* select sticky uvs */
if (sticky != SI_STICKY_DISABLE) {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if (sticky == SI_STICKY_DISABLE)
+ if (sticky == SI_STICKY_DISABLE) {
continue;
+ }
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (uv_sticky_select(
- limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
+ limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
uvedit_uv_select_enable(em, scene, l, false, cd_loop_uv_offset);
+ }
flush = 1;
}
@@ -2649,8 +2716,10 @@ static int uv_mouse_select_multi(
/* before bmesh */
#if 0
if (ts->selectmode != SCE_SELECT_FACE) {
- if (flush == 1) EDBM_select_flush(em);
- else if (flush == -1) EDBM_deselect_flush(em);
+ if (flush == 1)
+ EDBM_select_flush(em);
+ else if (flush == -1)
+ EDBM_deselect_flush(em);
}
#else
if (flush != 0) {
@@ -2677,13 +2746,14 @@ static int uv_mouse_select_multi(
return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED;
}
-static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loop)
+static int uv_mouse_select(
+ bContext *C, const float co[2], const bool extend, const bool deselect_all, const bool loop)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
view_layer, ((View3D *)NULL), &objects_len);
- int ret = uv_mouse_select_multi(C, objects, objects_len, co, extend, loop);
+ int ret = uv_mouse_select_multi(C, objects, objects_len, co, extend, deselect_all, loop);
MEM_freeN(objects);
return ret;
}
@@ -2691,13 +2761,13 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo
static int uv_select_exec(bContext *C, wmOperator *op)
{
float co[2];
- bool extend, loop;
RNA_float_get_array(op->ptr, "location", co);
- extend = RNA_boolean_get(op->ptr, "extend");
- loop = false;
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
+ const bool loop = false;
- return uv_mouse_select(C, co, extend, loop);
+ return uv_mouse_select(C, co, extend, deselect_all, loop);
}
static int uv_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2725,11 +2795,19 @@ static void UV_OT_select(wmOperatorType *ot)
ot->poll = ED_operator_uvedit; /* requires space image */
/* properties */
+ PropertyRNA *prop;
RNA_def_boolean(ot->srna,
"extend",
0,
"Extend",
"Extend selection rather than clearing the existing selection");
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
RNA_def_float_vector(
ot->srna,
"location",
@@ -2752,13 +2830,13 @@ static void UV_OT_select(wmOperatorType *ot)
static int uv_select_loop_exec(bContext *C, wmOperator *op)
{
float co[2];
- bool extend, loop;
RNA_float_get_array(op->ptr, "location", co);
- extend = RNA_boolean_get(op->ptr, "extend");
- loop = true;
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool deselect_all = false;
+ const bool loop = true;
- return uv_mouse_select(C, co, extend, loop);
+ return uv_mouse_select(C, co, extend, deselect_all, loop);
}
static int uv_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2810,7 +2888,7 @@ static void UV_OT_select_loop(wmOperatorType *ot)
/** \name Select Linked Operator
* \{ */
-static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent *event, int pick)
+static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent *event, bool pick)
{
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
@@ -2897,7 +2975,7 @@ static int uv_select_linked_internal(bContext *C, wmOperator *op, const wmEvent
static int uv_select_linked_exec(bContext *C, wmOperator *op)
{
- return uv_select_linked_internal(C, op, NULL, 0);
+ return uv_select_linked_internal(C, op, NULL, false);
}
static void UV_OT_select_linked(wmOperatorType *ot)
@@ -2911,6 +2989,9 @@ static void UV_OT_select_linked(wmOperatorType *ot)
/* api callbacks */
ot->exec = uv_select_linked_exec;
ot->poll = ED_operator_uvedit; /* requires space image */
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
@@ -2921,12 +3002,12 @@ static void UV_OT_select_linked(wmOperatorType *ot)
static int uv_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- return uv_select_linked_internal(C, op, event, 1);
+ return uv_select_linked_internal(C, op, event, true);
}
static int uv_select_linked_pick_exec(bContext *C, wmOperator *op)
{
- return uv_select_linked_internal(C, op, NULL, 1);
+ return uv_select_linked_internal(C, op, NULL, true);
}
static void UV_OT_select_linked_pick(wmOperatorType *ot)
@@ -2935,7 +3016,9 @@ static void UV_OT_select_linked_pick(wmOperatorType *ot)
ot->name = "Select Linked Pick";
ot->description = "Select all UV vertices linked under the mouse";
ot->idname = "UV_OT_select_linked_pick";
- ot->flag = OPTYPE_UNDO;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* api callbacks */
ot->invoke = uv_select_linked_pick_invoke;
@@ -2975,8 +3058,8 @@ static void UV_OT_select_linked_pick(wmOperatorType *ot)
/**
* \note This is based on similar use case to #MESH_OT_split(), which has a similar effect
* but in this case they are not joined to begin with (only having the behavior of being joined)
- * so its best to call this #uv_select_split() instead of just split(), but assigned to the same key
- * as #MESH_OT_split - Campbell.
+ * so its best to call this #uv_select_split() instead of just split(), but assigned to the same
+ * key as #MESH_OT_split - Campbell.
*/
static int uv_select_split_exec(bContext *C, wmOperator *op)
{
@@ -3129,11 +3212,13 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene,
vlist_iter = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
while (vlist_iter) {
- if (vlist_iter->separate)
+ if (vlist_iter->separate) {
start_vlist = vlist_iter;
+ }
- if (efa_index == vlist_iter->poly_index)
+ if (efa_index == vlist_iter->poly_index) {
break;
+ }
vlist_iter = vlist_iter->next;
}
@@ -3141,8 +3226,9 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene,
vlist_iter = start_vlist;
while (vlist_iter) {
- if (vlist_iter != start_vlist && vlist_iter->separate)
+ if (vlist_iter != start_vlist && vlist_iter->separate) {
break;
+ }
if (efa_index != vlist_iter->poly_index) {
BMLoop *l_other;
@@ -3161,10 +3247,12 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene,
/**
* Flush the selection from face tags based on sticky and selection modes.
*
- * needed because settings the selection a face is done in a number of places but it also needs to respect
- * the sticky modes for the UV verts, so dealing with the sticky modes is best done in a separate function.
+ * needed because settings the selection a face is done in a number of places but it also
+ * needs to respect the sticky modes for the UV verts, so dealing with the sticky modes
+ * is best done in a separate function.
*
- * \note! This function is very similar to #uv_select_flush_from_tag_loop, be sure to update both upon changing.
+ * \note This function is very similar to #uv_select_flush_from_tag_loop,
+ * be sure to update both upon changing.
*/
static void uv_select_flush_from_tag_face(SpaceImage *sima,
Scene *scene,
@@ -3245,10 +3333,12 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima,
/**
* Flush the selection from loop tags based on sticky and selection modes.
*
- * needed because settings the selection a face is done in a number of places but it also needs to respect
- * the sticky modes for the UV verts, so dealing with the sticky modes is best done in a separate function.
+ * needed because settings the selection a face is done in a number of places but it also needs
+ * to respect the sticky modes for the UV verts, so dealing with the sticky modes is best done
+ * in a separate function.
*
- * \note! This function is very similar to #uv_select_flush_from_tag_loop, be sure to update both upon changing.
+ * \note This function is very similar to #uv_select_flush_from_tag_loop,
+ * be sure to update both upon changing.
*/
static void uv_select_flush_from_tag_loop(SpaceImage *sima,
Scene *scene,
@@ -3413,8 +3503,9 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -3824,8 +3915,9 @@ static int uv_snap_cursor_exec(bContext *C, wmOperator *op)
}
}
- if (!changed)
+ if (!changed) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, sima);
@@ -3873,8 +3965,9 @@ static bool uv_snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, cons
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -3900,8 +3993,9 @@ static bool uv_snap_uvs_offset(Scene *scene, Image *ima, Object *obedit, const f
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -3989,8 +4083,9 @@ static bool uv_snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit
h = (float)height;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -4327,8 +4422,9 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
}
}
}
- if (!swap)
+ if (!swap) {
uvedit_face_select_disable(scene, em, efa, cd_loop_uv_offset);
+ }
}
}
else if (em->selectmode == SCE_SELECT_FACE) {
@@ -4343,8 +4439,9 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (UV_SEL_TEST(luv, !swap)) {
BM_vert_select_set(em->bm, l->v, false);
- if (!swap)
+ if (!swap) {
luv->flag &= ~MLOOPUV_VERTSEL;
+ }
}
}
}
@@ -4352,8 +4449,9 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
}
/* flush vertex selection changes */
- if (em->selectmode != SCE_SELECT_FACE)
+ if (em->selectmode != SCE_SELECT_FACE) {
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX | SCE_SELECT_EDGE);
+ }
BM_select_history_validate(em->bm);
@@ -4537,8 +4635,9 @@ static int uv_set_2d_cursor_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima = CTX_wm_space_image(C);
- if (!sima)
+ if (!sima) {
return OPERATOR_CANCELLED;
+ }
RNA_float_get_array(op->ptr, "location", sima->cursor);
@@ -4648,20 +4747,23 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
UvMapVert *mv2cache = NULL, *mv2sep = NULL;
mvinit1 = vmap->vert[BM_elem_index_get(editedge->v1)];
- if (mark_seams)
+ if (mark_seams) {
BM_elem_flag_disable(editedge, BM_ELEM_SEAM);
+ }
for (mv1 = mvinit1; mv1 && !faces_separated; mv1 = mv1->next) {
- if (mv1->separate && commonFaces)
+ if (mv1->separate && commonFaces) {
v1coincident = 0;
+ }
separated2 = 0;
efa1 = BM_face_at_index(bm, mv1->poly_index);
mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)];
for (mv2 = mvinit2; mv2; mv2 = mv2->next) {
- if (mv2->separate)
+ if (mv2->separate) {
mv2sep = mv2;
+ }
efa2 = BM_face_at_index(bm, mv2->poly_index);
if (efa1 == efa2) {
@@ -4672,11 +4774,13 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
/* flag seam unless proved to be coincident with previous hit */
separated2 = 1;
for (mviter = mv2cache; mviter; mviter = mviter->next) {
- if (mviter->separate && mviter != mv2cache)
+ if (mviter->separate && mviter != mv2cache) {
break;
+ }
/* coincident with previous hit, do not flag seam */
- if (mviter == mv2)
+ if (mviter == mv2) {
separated2 = 0;
+ }
}
}
/* First hit case, store the hit in the cache */
@@ -4685,8 +4789,9 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
commonFaces = 1;
}
}
- else
+ else {
separated1 = 1;
+ }
if (separated1 || separated2) {
faces_separated = 1;
@@ -4697,10 +4802,12 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
}
if (faces_separated) {
- if (mark_seams)
+ if (mark_seams) {
BM_elem_flag_enable(editedge, BM_ELEM_SEAM);
- if (mark_sharp)
+ }
+ if (mark_sharp) {
BM_elem_flag_disable(editedge, BM_ELEM_SMOOTH);
+ }
}
}
@@ -4897,7 +5004,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
wmKeyMap *keymap;
keymap = WM_keymap_ensure(keyconf, "UV Editor", 0, 0);
- keymap->poll = ED_operator_uvedit_can_uv_sculpt;
+ keymap->poll = ED_operator_uvedit;
}
/** \} */
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 69183d02ab9..10b2df48f2f 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -255,8 +255,9 @@ static PHash *phash_new(PHashLink **list, int sizehint)
ph->cursize_id = 0;
ph->list = list;
- while (PHashSizes[ph->cursize_id] < sizehint)
+ while (PHashSizes[ph->cursize_id] < sizehint) {
ph->cursize_id++;
+ }
ph->cursize = PHashSizes[ph->cursize_id];
ph->buckets = (PHashLink **)MEM_callocN(ph->cursize * sizeof(*ph->buckets), "PHashBuckets");
@@ -316,11 +317,14 @@ static PHashLink *phash_lookup(PHash *ph, PHashKey key)
PHashLink *link;
uintptr_t hash = PHASH_hash(ph, key);
- for (link = ph->buckets[hash]; link; link = link->next)
- if (link->key == key)
+ for (link = ph->buckets[hash]; link; link = link->next) {
+ if (link->key == key) {
return link;
- else if (PHASH_hash(ph, link->key) != hash)
+ }
+ else if (PHASH_hash(ph, link->key) != hash) {
return NULL;
+ }
+ }
return link;
}
@@ -329,11 +333,14 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link)
{
uintptr_t hash = PHASH_hash(ph, key);
- for (link = link->next; link; link = link->next)
- if (link->key == key)
+ for (link = link->next; link; link = link->next) {
+ if (link->key == key) {
return link;
- else if (PHASH_hash(ph, link->key) != hash)
+ }
+ else if (PHASH_hash(ph, link->key) != hash) {
return NULL;
+ }
+ }
return link;
}
@@ -362,12 +369,15 @@ static float p_vec_angle(float *v1, float *v2, float *v3)
{
float dot = p_vec_angle_cos(v1, v2, v3);
- if (dot <= -1.0f)
+ if (dot <= -1.0f) {
return (float)M_PI;
- else if (dot >= 1.0f)
+ }
+ else if (dot >= 1.0f) {
return 0.0f;
- else
+ }
+ else {
return acosf(dot);
+ }
}
static float p_vec2_angle(float *v1, float *v2, float *v3)
@@ -523,8 +533,9 @@ static PBool p_intersect_line_2d_dir(float *v1, float *dir1, float *v2, float *d
div = dir2[0] * dir1[1] - dir2[1] * dir1[0];
- if (div == 0.0f)
+ if (div == 0.0f) {
return P_FALSE;
+ }
lmbda = ((v1[1] - v2[1]) * dir1[0] - (v1[0] - v2[0]) * dir1[1]) / div;
isect[0] = v1[0] + lmbda * dir2[0];
@@ -645,8 +656,9 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
e = v->edge;
do {
if (e->orig_uv) {
- if (e->flag & PEDGE_SELECT)
+ if (e->flag & PEDGE_SELECT) {
v->flag |= PVERT_SELECT;
+ }
if (e->flag & PEDGE_PIN) {
pinuv[0] += e->orig_uv[0] * handle->aspx;
@@ -765,10 +777,12 @@ static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], PE
{
PVert *v = (PVert *)phash_lookup(handle->hash_verts, key);
- if (v)
+ if (v) {
return v;
- else
+ }
+ else {
return p_vert_add(handle, key, co, e);
+ }
}
static PVert *p_vert_copy(PChart *chart, PVert *v)
@@ -791,10 +805,12 @@ static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys)
PEdge *e = (PEdge *)phash_lookup(handle->hash_edges, key);
while (e) {
- if ((e->vert->u.key == vkeys[0]) && (e->next->vert->u.key == vkeys[1]))
+ if ((e->vert->u.key == vkeys[0]) && (e->next->vert->u.key == vkeys[1])) {
return e;
- else if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0]))
+ }
+ else if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0])) {
return e;
+ }
e = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)e);
}
@@ -811,12 +827,14 @@ static int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2,
while (e) {
if ((e->vert->u.key == vkeys[i1]) && (e->next->vert->u.key == vkeys[i2])) {
- if (e->next->next->vert->u.key == vkeys[i3])
+ if (e->next->next->vert->u.key == vkeys[i3]) {
return P_TRUE;
+ }
}
else if ((e->vert->u.key == vkeys[i2]) && (e->next->vert->u.key == vkeys[i1])) {
- if (e->next->next->vert->u.key == vkeys[i3])
+ if (e->next->next->vert->u.key == vkeys[i3]) {
return P_TRUE;
+ }
}
e = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)e);
@@ -881,8 +899,9 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl
PHashKey key1 = e->vert->u.key;
PHashKey key2 = e->next->vert->u.key;
- if (e->flag & PEDGE_SEAM)
+ if (e->flag & PEDGE_SEAM) {
return P_FALSE;
+ }
key = PHASH_edge(key1, key2);
pe = (PEdge *)phash_lookup(handle->hash_edges, key);
@@ -925,8 +944,9 @@ static PBool p_edge_connect_pair(PHandle *handle, PEdge *e, PEdge ***stack, PBoo
PEdge *pair = NULL;
if (!e->pair && p_edge_has_pair(handle, e, &pair, impl)) {
- if (e->vert == pair->vert)
+ if (e->vert == pair->vert) {
p_face_flip(pair->face);
+ }
e->pair = pair;
pair->pair = e;
@@ -952,8 +972,9 @@ static int p_connect_pairs(PHandle *handle, PBool impl)
/* connect pairs, count edges, set vertex-edge pointer to a pairless edge */
for (first = chart->faces; first; first = first->nextlink) {
- if (first->flag & PFACE_CONNECTED)
+ if (first->flag & PFACE_CONNECTED) {
continue;
+ }
*stack = first->edge;
stack++;
@@ -970,12 +991,15 @@ static int p_connect_pairs(PHandle *handle, PBool impl)
/* assign verts to charts so we can sort them later */
f->u.chart = ncharts;
- if (!p_edge_connect_pair(handle, e, &stack, impl))
+ if (!p_edge_connect_pair(handle, e, &stack, impl)) {
e->vert->edge = e;
- if (!p_edge_connect_pair(handle, e1, &stack, impl))
+ }
+ if (!p_edge_connect_pair(handle, e1, &stack, impl)) {
e1->vert->edge = e1;
- if (!p_edge_connect_pair(handle, e2, &stack, impl))
+ }
+ if (!p_edge_connect_pair(handle, e2, &stack, impl)) {
e2->vert->edge = e2;
+ }
}
ncharts++;
@@ -996,18 +1020,21 @@ static void p_split_vert(PChart *chart, PEdge *e)
chart->flag |= PCHART_HAS_PINS;
}
- if (e->flag & PEDGE_VERTEX_SPLIT)
+ if (e->flag & PEDGE_VERTEX_SPLIT) {
return;
+ }
/* rewind to start */
lastwe = e;
- for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we))
+ for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we)) {
lastwe = we;
+ }
/* go over all edges in wheel */
for (we = lastwe; we; we = p_wheel_edge_next(we)) {
- if (we->flag & PEDGE_VERTEX_SPLIT)
+ if (we->flag & PEDGE_VERTEX_SPLIT) {
break;
+ }
we->flag |= PEDGE_VERTEX_SPLIT;
@@ -1046,8 +1073,9 @@ static PChart **p_split_charts(PHandle *handle, PChart *chart, int ncharts)
PFace *f, *nextf;
int i;
- for (i = 0; i < ncharts; i++)
+ for (i = 0; i < ncharts; i++) {
charts[i] = p_chart_new(handle);
+ }
f = chart->faces;
while (f) {
@@ -1133,21 +1161,27 @@ static PFace *p_face_add_construct(PHandle *handle,
e3->orig_uv = uv[i3];
if (pin) {
- if (pin[i1])
+ if (pin[i1]) {
e1->flag |= PEDGE_PIN;
- if (pin[i2])
+ }
+ if (pin[i2]) {
e2->flag |= PEDGE_PIN;
- if (pin[i3])
+ }
+ if (pin[i3]) {
e3->flag |= PEDGE_PIN;
+ }
}
if (select) {
- if (select[i1])
+ if (select[i1]) {
e1->flag |= PEDGE_SELECT;
- if (select[i2])
+ }
+ if (select[i2]) {
e2->flag |= PEDGE_SELECT;
- if (select[i3])
+ }
+ if (select[i3]) {
e3->flag |= PEDGE_SELECT;
+ }
}
/* insert into hash */
@@ -1205,12 +1239,14 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys
* triangles, resulting in two identical triangles. for example in
* suzanne's nose. */
if (dir) {
- if (p_face_exists(handle, vkeys, 0, 1, 2) || p_face_exists(handle, vkeys, 0, 2, 3))
+ if (p_face_exists(handle, vkeys, 0, 1, 2) || p_face_exists(handle, vkeys, 0, 2, 3)) {
return !dir;
+ }
}
else {
- if (p_face_exists(handle, vkeys, 0, 1, 3) || p_face_exists(handle, vkeys, 1, 2, 3))
+ if (p_face_exists(handle, vkeys, 0, 1, 3) || p_face_exists(handle, vkeys, 1, 2, 3)) {
return !dir;
+ }
}
return dir;
@@ -1223,17 +1259,21 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
PEdge *e, *be;
float len, maxlen = -1.0;
- if (nboundaries)
+ if (nboundaries) {
*nboundaries = 0;
- if (outer)
+ }
+ if (outer) {
*outer = NULL;
+ }
for (e = chart->edges; e; e = e->nextlink) {
- if (e->pair || (e->flag & PEDGE_DONE))
+ if (e->pair || (e->flag & PEDGE_DONE)) {
continue;
+ }
- if (nboundaries)
+ if (nboundaries) {
(*nboundaries)++;
+ }
len = 0.0f;
@@ -1250,8 +1290,9 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
}
}
- for (e = chart->edges; e; e = e->nextlink)
+ for (e = chart->edges; e; e = e->nextlink) {
e->flag &= ~PEDGE_DONE;
+ }
}
static float p_edge_boundary_angle(PEdge *e)
@@ -1364,8 +1405,9 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
for (e = chart->edges; e; e = e->nextlink) {
/* enext = e->nextlink; - as yet unused */
- if (e->pair || (e->flag & PEDGE_FILLED))
+ if (e->pair || (e->flag & PEDGE_FILLED)) {
continue;
+ }
nedges = 0;
be = e;
@@ -1375,8 +1417,9 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
nedges++;
} while (be != e);
- if (e != outer)
+ if (e != outer) {
p_chart_fill_boundary(chart, e, nedges);
+ }
}
}
@@ -1393,7 +1436,12 @@ static int p_polygon_point_in(float *cp1, float *cp2, float *p)
return (p_area_signed(cp1, cp2, p) >= 0.0f);
}
-static void p_polygon_kernel_clip(float (*oldpoints)[2], int noldpoints, float (*newpoints)[2], int *nnewpoints, float *cp1, float *cp2)
+static void p_polygon_kernel_clip(float (*oldpoints)[2],
+ int noldpoints,
+ float (*newpoints)[2],
+ int *nnewpoints,
+ float *cp1,
+ float *cp2)
{
float *p2, *p1, isect[2];
int i, p2in, p1in;
@@ -1438,7 +1486,7 @@ static void p_polygon_kernel_clip(float (*oldpoints)[2], int noldpoints, float (
static void p_polygon_kernel_center(float (*points)[2], int npoints, float *center)
{
int i, size, nnewpoints = npoints;
- float (*oldpoints)[2], (*newpoints)[2], *p1, *p2;
+ float(*oldpoints)[2], (*newpoints)[2], *p1, *p2;
size = npoints * 3;
oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonOldPoints");
@@ -1477,7 +1525,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent
newpoints = MEM_mallocN(sizeof(float) * 2 * size, "newpoints");
}
else {
- float (*sw_points)[2] = oldpoints;
+ float(*sw_points)[2] = oldpoints;
oldpoints = newpoints;
newpoints = sw_points;
}
@@ -1616,7 +1664,7 @@ static void p_vert_harmonic_insert(PVert *v)
* weights fails */
int npoints = 0, i;
- float (*points)[2];
+ float(*points)[2];
e = v->edge;
do {
@@ -1939,8 +1987,7 @@ static PBool p_collapse_allowed(PEdge *edge, PEdge *pair)
if (oldv->flag & PVERT_PIN)
return P_FALSE;
- return (p_collapse_allowed_topologic(edge, pair) &&
- p_collapse_allowed_geometric(edge, pair));
+ return (p_collapse_allowed_topologic(edge, pair) && p_collapse_allowed_geometric(edge, pair));
}
static float p_collapse_cost(PEdge *edge, PEdge *pair)
@@ -2346,8 +2393,9 @@ static void p_abf_setup_system(PAbfSystem *sys)
sys->bstar = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFbstar");
sys->dstar = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFdstar");
- for (i = 0; i < sys->ninterior; i++)
+ for (i = 0; i < sys->ninterior; i++) {
sys->lambdaLength[i] = 1.0;
+ }
sys->minangle = 1.0 * M_PI / 180.0;
sys->maxangle = (float)M_PI - sys->minangle;
@@ -2400,16 +2448,18 @@ static float p_abf_compute_sin_product(PAbfSystem *sys, PVert *v, int aid)
sin1 *= sys->cosine[e1->u.id];
sin2 = 0.0;
}
- else
+ else {
sin1 *= sys->sine[e1->u.id];
+ }
if (aid == e2->u.id) {
/* see above */
sin1 = 0.0;
sin2 *= sys->cosine[e2->u.id];
}
- else
+ else {
sin2 *= sys->sine[e2->u.id];
+ }
e = e->next->next->pair;
} while (e && (e != v->edge));
@@ -2500,8 +2550,9 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
context = EIG_linear_solver_new(0, nvar, 1);
- for (i = 0; i < nvar; i++)
+ for (i = 0; i < nvar; i++) {
EIG_linear_solver_right_hand_side_add(context, 0, i, sys->bInterior[i]);
+ }
for (f = chart->faces; f; f = f->nextlink) {
float wi1, wi2, wi3, b, si, beta[3], j2[3][3], W[3][3];
@@ -2611,29 +2662,37 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
for (i = 0; i < 3; i++) {
int r = vid[i];
- if (r == -1)
+ if (r == -1) {
continue;
+ }
for (j = 0; j < 6; j++) {
int c = vid[j];
- if (c == -1)
+ if (c == -1) {
continue;
+ }
- if (i == 0)
+ if (i == 0) {
EIG_linear_solver_matrix_add(context, r, c, j2[0][i] * row1[j]);
- else
+ }
+ else {
EIG_linear_solver_matrix_add(context, r + ninterior, c, j2[0][i] * row1[j]);
+ }
- if (i == 1)
+ if (i == 1) {
EIG_linear_solver_matrix_add(context, r, c, j2[1][i] * row2[j]);
- else
+ }
+ else {
EIG_linear_solver_matrix_add(context, r + ninterior, c, j2[1][i] * row2[j]);
+ }
- if (i == 2)
+ if (i == 2) {
EIG_linear_solver_matrix_add(context, r, c, j2[2][i] * row3[j]);
- else
+ }
+ else {
EIG_linear_solver_matrix_add(context, r + ninterior, c, j2[2][i] * row3[j]);
+ }
}
}
}
@@ -2689,10 +2748,12 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
/* clamp */
e = f->edge;
do {
- if (sys->alpha[e->u.id] > (float)M_PI)
+ if (sys->alpha[e->u.id] > (float)M_PI) {
sys->alpha[e->u.id] = (float)M_PI;
- else if (sys->alpha[e->u.id] < 0.0f)
+ }
+ else if (sys->alpha[e->u.id] < 0.0f) {
sys->alpha[e->u.id] = 0.0f;
+ }
} while (e != f->edge);
}
@@ -2724,8 +2785,9 @@ static PBool p_chart_abf_solve(PChart *chart)
v->flag |= PVERT_INTERIOR;
v->u.id = sys.ninterior++;
}
- else
+ else {
v->flag &= ~PVERT_INTERIOR;
+ }
}
for (f = chart->faces; f; f = f->nextlink) {
@@ -2751,18 +2813,24 @@ static PBool p_chart_abf_solve(PChart *chart)
e3 = e2->next;
p_face_angles(f, &a1, &a2, &a3);
- if (a1 < sys.minangle)
+ if (a1 < sys.minangle) {
a1 = sys.minangle;
- else if (a1 > sys.maxangle)
+ }
+ else if (a1 > sys.maxangle) {
a1 = sys.maxangle;
- if (a2 < sys.minangle)
+ }
+ if (a2 < sys.minangle) {
a2 = sys.minangle;
- else if (a2 > sys.maxangle)
+ }
+ else if (a2 > sys.maxangle) {
a2 = sys.maxangle;
- if (a3 < sys.minangle)
+ }
+ if (a3 < sys.minangle) {
a3 = sys.minangle;
- else if (a3 > sys.maxangle)
+ }
+ else if (a3 > sys.maxangle) {
a3 = sys.maxangle;
+ }
sys.alpha[e1->u.id] = sys.beta[e1->u.id] = a1;
sys.alpha[e2->u.id] = sys.beta[e2->u.id] = a2;
@@ -2804,8 +2872,9 @@ static PBool p_chart_abf_solve(PChart *chart)
/* lastnorm = norm; */ /* UNUSED */
- if (norm < limit)
+ if (norm < limit) {
break;
+ }
if (!p_abf_matrix_invert(&sys, chart)) {
param_warning("ABF failed to invert matrix");
@@ -2902,12 +2971,14 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
if ((be->vert->flag & PVERT_SPLIT) ||
(lastbe->vert->flag & nextbe->vert->flag & PVERT_SPLIT)) {
if (!cure) {
- if (be == outer)
+ if (be == outer) {
firste1 = be;
+ }
cure = be;
}
- else
+ else {
curlen += p_edge_length(lastbe);
+ }
}
else if (cure) {
if (curlen > maxlen) {
@@ -2940,8 +3011,9 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
}
}
- if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen))
+ if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen)) {
return P_FALSE;
+ }
/* find pin1 in the split vertices */
be1 = maxe1;
@@ -3050,12 +3122,14 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
for (v = chart->verts; v; v = v->nextlink) {
if (v->flag & PVERT_PIN) {
npins++;
- if (v->flag & PVERT_SELECT)
+ if (v->flag & PVERT_SELECT) {
select = P_TRUE;
+ }
}
- if (!(v->flag & PVERT_SELECT))
+ if (!(v->flag & PVERT_SELECT)) {
deselect = P_TRUE;
+ }
}
if ((live && (!select || !deselect)) || (npins == 1)) {
@@ -3068,8 +3142,9 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
#endif
if (abf) {
- if (!p_chart_abf_solve(chart))
+ if (!p_chart_abf_solve(chart)) {
param_warning("ABF solving failed: falling back to LSCM.\n");
+ }
}
if (npins <= 1) {
@@ -3087,8 +3162,9 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
chart->u.lscm.pin2 = pin2;
}
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
v->u.id = id++;
+ }
chart->u.lscm.context = EIG_linear_least_squares_solver_new(
2 * chart->nfaces, 2 * chart->nverts, 1);
@@ -3109,9 +3185,11 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
/* TODO: make loading pins work for simplify/complexify. */
#endif
- for (v = chart->verts; v; v = v->nextlink)
- if (v->flag & PVERT_PIN)
+ for (v = chart->verts; v; v = v->nextlink) {
+ if (v->flag & PVERT_PIN) {
p_vert_load_pin_select_uvs(handle, v); /* reload for live */
+ }
+ }
if (chart->u.lscm.pin1) {
EIG_linear_solver_variable_lock(context, 2 * pin1->u.id);
@@ -3148,10 +3226,12 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
if ((v1->flag & PVERT_PIN) && (v2->flag & PVERT_PIN) && (v3->flag & PVERT_PIN)) {
float area = p_face_uv_area_signed(f);
- if (area > 0.0f)
+ if (area > 0.0f) {
area_pinned_up += area;
- else
+ }
+ else {
area_pinned_down -= area;
+ }
}
}
@@ -3172,8 +3252,9 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
a2 = *(alpha++);
a3 = *(alpha++);
}
- else
+ else {
p_face_angles(f, &a1, &a2, &a3);
+ }
if (flip_faces) {
SWAP(float, a2, a3);
@@ -3236,8 +3317,9 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
static void p_chart_lscm_end(PChart *chart)
{
- if (chart->u.lscm.context)
+ if (chart->u.lscm.context) {
EIG_linear_solver_delete(chart->u.lscm.context);
+ }
if (chart->u.lscm.abf_alpha) {
MEM_freeN(chart->u.lscm.abf_alpha);
@@ -3257,11 +3339,14 @@ static void p_stretch_pin_boundary(PChart *chart)
{
PVert *v;
- for (v = chart->verts; v; v = v->nextlink)
- if (v->edge->pair == NULL)
+ for (v = chart->verts; v; v = v->nextlink) {
+ if (v->edge->pair == NULL) {
v->flag |= PVERT_PIN;
- else
+ }
+ else {
v->flag &= ~PVERT_PIN;
+ }
+ }
}
static float p_face_stretch(PFace *f)
@@ -3274,8 +3359,9 @@ static float p_face_stretch(PFace *f)
area = p_face_uv_area_signed(f);
- if (area <= 0.0f) /* flipped face -> infinite stretch */
+ if (area <= 0.0f) { /* flipped face -> infinite stretch */
return 1e10f;
+ }
w = 1.0f / (2.0f * area);
@@ -3311,8 +3397,9 @@ static float p_face_stretch(PFace *f)
c = dot_v3v3(Pt, Pt);
T = sqrtf(0.5f * (a + c));
- if (f->flag & PFACE_FILLED)
+ if (f->flag & PFACE_FILLED) {
T *= 0.2f;
+ }
return T;
}
@@ -3339,8 +3426,9 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
float orig_uv[2], dir[2], random_angle, trusted_radius;
for (v = chart->verts; v; v = v->nextlink) {
- if ((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT))
+ if ((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT)) {
continue;
+ }
orig_stretch = p_stretch_compute_vertex(v);
orig_uv[0] = v->uv[0];
@@ -3390,8 +3478,9 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
}
/* no luck, stretch has increased, reset to old values */
- if (stretch >= orig_stretch)
+ if (stretch >= orig_stretch) {
copy_v2_v2(v->uv, orig_uv);
+ }
}
}
@@ -3402,18 +3491,23 @@ static int p_compare_geometric_uv(const void *a, const void *b)
const PVert *v1 = *(const PVert *const *)a;
const PVert *v2 = *(const PVert *const *)b;
- if (v1->uv[0] < v2->uv[0])
+ if (v1->uv[0] < v2->uv[0]) {
return -1;
+ }
else if (v1->uv[0] == v2->uv[0]) {
- if (v1->uv[1] < v2->uv[1])
+ if (v1->uv[1] < v2->uv[1]) {
return -1;
- else if (v1->uv[1] == v2->uv[1])
+ }
+ else if (v1->uv[1] == v2->uv[1]) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
- else
+ else {
return 1;
+ }
}
static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int *right)
@@ -3427,8 +3521,9 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
p_chart_boundaries(chart, NULL, &be);
- if (!be)
+ if (!be) {
return P_FALSE;
+ }
e = be;
do {
@@ -3451,10 +3546,12 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
ulen = llen = 0;
for (p = points, i = 0; i < npoints; i++, p++) {
- while ((ulen > 1) && (p_area_signed(U[ulen - 2]->uv, (*p)->uv, U[ulen - 1]->uv) <= 0))
+ while ((ulen > 1) && (p_area_signed(U[ulen - 2]->uv, (*p)->uv, U[ulen - 1]->uv) <= 0)) {
ulen--;
- while ((llen > 1) && (p_area_signed(L[llen - 2]->uv, (*p)->uv, L[llen - 1]->uv) >= 0))
+ }
+ while ((llen > 1) && (p_area_signed(L[llen - 2]->uv, (*p)->uv, L[llen - 1]->uv) >= 0)) {
llen--;
+ }
U[ulen] = *p;
ulen++;
@@ -3463,12 +3560,14 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
}
npoints = 0;
- for (p = points, i = 0; i < ulen; i++, p++, npoints++)
+ for (p = points, i = 0; i < ulen; i++, p++, npoints++) {
*p = U[i];
+ }
/* the first and last point in L are left out, since they are also in U */
- for (i = llen - 2; i > 0; i--, p++, npoints++)
+ for (i = llen - 2; i > 0; i--, p++, npoints++) {
*p = L[i];
+ }
*verts = points;
*nverts = npoints;
@@ -3490,14 +3589,17 @@ static float p_rectangle_area(float *p1, float *dir, float *p2, float *p3, float
orthodir[0] = dir[1];
orthodir[1] = -dir[0];
- if (!p_intersect_line_2d_dir(p1, dir, p2, orthodir, corner1))
+ if (!p_intersect_line_2d_dir(p1, dir, p2, orthodir, corner1)) {
return 1e10;
+ }
- if (!p_intersect_line_2d_dir(p1, dir, p4, orthodir, corner2))
+ if (!p_intersect_line_2d_dir(p1, dir, p4, orthodir, corner2)) {
return 1e10;
+ }
- if (!p_intersect_line_2d_dir(p3, dir, p4, orthodir, corner3))
+ if (!p_intersect_line_2d_dir(p3, dir, p4, orthodir, corner3)) {
return 1e10;
+ }
return len_v2v2(corner1, corner2) * len_v2v2(corner2, corner3);
}
@@ -3513,8 +3615,9 @@ static float p_chart_minimum_area_angle(PChart *chart)
PVert **points, *p1, *p2, *p3, *p4, *p1n;
/* compute convex hull */
- if (!p_chart_convex_hull(chart, &points, &npoints, &right))
+ if (!p_chart_convex_hull(chart, &points, &npoints, &right)) {
return 0.0;
+ }
/* find left/top/right/bottom points, and compute angle for each point */
angles = MEM_mallocN(sizeof(float) * npoints, "PMinAreaAngles");
@@ -3573,11 +3676,12 @@ static float p_chart_minimum_area_angle(PChart *chart)
i_min = 0;
mina = 1e10;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
if (a[i] < mina) {
mina = a[i];
i_min = i;
}
+ }
rotated += mina;
nextidx = (idx[i_min] + 1) % npoints;
@@ -3614,8 +3718,9 @@ static float p_chart_minimum_area_angle(PChart *chart)
}
/* try keeping rotation as small as possible */
- if (minangle > (float)(M_PI / 4))
+ if (minangle > (float)(M_PI / 4)) {
minangle -= (float)(M_PI / 2.0);
+ }
MEM_freeN(angles);
MEM_freeN(points);
@@ -3708,8 +3813,9 @@ static SmoothNode *p_node_new(
node->tri = tri;
node->ntri = ntri;
- if (ntri <= 10 || depth >= 15)
+ if (ntri <= 10 || depth >= 15) {
return node;
+ }
t1 = MEM_mallocN(sizeof(*t1) * ntri, "PNodeTri1");
t2 = MEM_mallocN(sizeof(*t2) * ntri, "PNodeTri1");
@@ -3757,12 +3863,15 @@ static SmoothNode *p_node_new(
static void p_node_delete(SmoothNode *node)
{
- if (node->c1)
+ if (node->c1) {
p_node_delete(node->c1);
- if (node->c2)
+ }
+ if (node->c2) {
p_node_delete(node->c2);
- if (node->tri)
+ }
+ if (node->tri) {
MEM_freeN(node->tri);
+ }
}
static PBool p_node_intersect(SmoothNode *node, float co[2])
@@ -3770,17 +3879,21 @@ static PBool p_node_intersect(SmoothNode *node, float co[2])
int i;
if (node->tri) {
- for (i = 0; i < node->ntri; i++)
- if (p_triangle_inside(node->tri[i], co))
+ for (i = 0; i < node->ntri; i++) {
+ if (p_triangle_inside(node->tri[i], co)) {
return P_TRUE;
+ }
+ }
return P_FALSE;
}
else {
- if (co[node->axis] < node->split)
+ if (co[node->axis] < node->split) {
return p_node_intersect(node->c1, co);
- else
+ }
+ else {
return p_node_intersect(node->c2, co);
+ }
}
}
@@ -3791,12 +3904,15 @@ static int p_compare_float(const void *a_, const void *b_)
const float a = *(const float *)a_;
const float b = *(const float *)b_;
- if (a < b)
+ if (a < b) {
return -1;
- else if (a == b)
+ }
+ else if (a == b) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
static float p_smooth_median_edge_length(PChart *chart)
@@ -3807,8 +3923,9 @@ static float p_smooth_median_edge_length(PChart *chart)
int i;
/* ok, so i'm lazy */
- for (i = 0, e = chart->edges; e; e = e->nextlink, i++)
+ for (i = 0, e = chart->edges; e; e = e->nextlink, i++) {
lengths[i] = p_edge_length(e);
+ }
qsort(lengths, i, sizeof(float), p_compare_float);
@@ -3841,14 +3958,16 @@ static void p_smooth(PChart *chart)
SmoothNode *root;
MemArena *arena;
- if (nedges == 0)
+ if (nedges == 0) {
return;
+ }
p_chart_uv_bbox(chart, minv, maxv);
median = p_smooth_median_edge_length(chart) * 0.10f;
- if (median == 0.0f)
+ if (median == 0.0f) {
return;
+ }
invmedian = 1.0f / median;
@@ -3901,8 +4020,9 @@ static void p_smooth(PChart *chart)
gridx = gridx * 2 + 1;
gridy = gridy * 2 + 1;
- if ((gridx <= 2) || (gridy <= 2))
+ if ((gridx <= 2) || (gridy <= 2)) {
return;
+ }
edgesx = gridx - 1;
edgesy = gridy - 1;
@@ -3918,20 +4038,27 @@ static void p_smooth(PChart *chart)
vedges = MEM_mallocN(sizeof(float) * esize, "PSmoothVEdges");
if (!nodes || !nodesx || !nodesy || !oldnodesx || !oldnodesy || !hedges || !vedges) {
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
- if (nodesx)
+ }
+ if (nodesx) {
MEM_freeN(nodesx);
- if (nodesy)
+ }
+ if (nodesy) {
MEM_freeN(nodesy);
- if (oldnodesx)
+ }
+ if (oldnodesx) {
MEM_freeN(oldnodesx);
- if (oldnodesy)
+ }
+ if (oldnodesy) {
MEM_freeN(oldnodesy);
- if (hedges)
+ }
+ if (hedges) {
MEM_freeN(hedges);
- if (vedges)
+ }
+ if (vedges) {
MEM_freeN(vedges);
+ }
// printf("Not enough memory for area smoothing grid");
return;
@@ -4058,12 +4185,14 @@ static void p_smooth(PChart *chart)
}
}
- if (d < dlimit)
+ if (d < dlimit) {
break;
+ }
}
- if (moved < climit)
+ if (moved < climit) {
break;
+ }
}
MEM_freeN(oldnodesx);
@@ -4080,10 +4209,12 @@ static void p_smooth(PChart *chart)
MEM_freeN(nodesx);
MEM_freeN(nodesy);
- if (triangles)
+ if (triangles) {
MEM_freeN(triangles);
- if (tri)
+ }
+ if (tri) {
MEM_freeN(tri);
+ }
// printf("Not enough memory for area smoothing grid");
return;
@@ -4145,9 +4276,11 @@ static void p_smooth(PChart *chart)
arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "param smooth arena");
root = p_node_new(arena, tri, esize * 2, minv, maxv, 0);
- for (v = chart->verts; v; v = v->nextlink)
- if (!p_node_intersect(root, v->uv))
+ for (v = chart->verts; v; v = v->nextlink) {
+ if (!p_node_intersect(root, v->uv)) {
param_warning("area smoothing error: couldn't find mapping triangle\n");
+ }
+ }
p_node_delete(root);
BLI_memarena_free(arena);
@@ -4193,11 +4326,13 @@ void param_delete(ParamHandle *handle)
param_assert((phandle->state == PHANDLE_STATE_ALLOCATED) ||
(phandle->state == PHANDLE_STATE_CONSTRUCTED));
- for (i = 0; i < phandle->ncharts; i++)
+ for (i = 0; i < phandle->ncharts; i++) {
p_chart_delete(phandle->charts[i]);
+ }
- if (phandle->charts)
+ if (phandle->charts) {
MEM_freeN(phandle->charts);
+ }
if (phandle->construction_chart) {
p_chart_delete(phandle->construction_chart);
@@ -4319,8 +4454,9 @@ void param_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
param_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
e = p_edge_lookup(phandle, vkeys);
- if (e)
+ if (e) {
e->flag |= PEDGE_SEAM;
+ }
}
void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
@@ -4357,11 +4493,13 @@ void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
phandle->charts[j] = chart;
j++;
- if (fill && (nboundaries > 1))
+ if (fill && (nboundaries > 1)) {
p_chart_fill_boundaries(chart, outer);
+ }
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
p_vert_load_pin_select_uvs(handle, v);
+ }
}
phandle->ncharts = j;
@@ -4379,8 +4517,9 @@ void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
phandle->state = PHANDLE_STATE_LSCM;
for (i = 0; i < phandle->ncharts; i++) {
- for (f = phandle->charts[i]->faces; f; f = f->nextlink)
+ for (f = phandle->charts[i]->faces; f; f = f->nextlink) {
p_face_backup_uvs(f);
+ }
p_chart_lscm_begin(phandle->charts[i], (PBool)live, (PBool)abf);
}
}
@@ -4400,11 +4539,13 @@ void param_lscm_solve(ParamHandle *handle)
if (chart->u.lscm.context) {
result = p_chart_lscm_solve(phandle, chart);
- if (result && !(chart->flag & PCHART_HAS_PINS))
+ if (result && !(chart->flag & PCHART_HAS_PINS)) {
p_chart_rotate_minimum_area(chart);
+ }
- if (!result || (chart->u.lscm.pin1))
+ if (!result || (chart->u.lscm.pin1)) {
p_chart_lscm_end(chart);
+ }
}
}
}
@@ -4443,8 +4584,9 @@ void param_stretch_begin(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
v->flag &= ~PVERT_PIN; /* don't use user-defined pins */
+ }
p_stretch_pin_boundary(chart);
@@ -4499,8 +4641,9 @@ void param_smooth_area(ParamHandle *handle)
PChart *chart = phandle->charts[i];
PVert *v;
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
v->flag &= ~PVERT_PIN;
+ }
p_smooth(chart);
}
@@ -4553,16 +4696,18 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
PHandle *phandle = (PHandle *)handle;
- if (phandle->ncharts == 0)
+ if (phandle->ncharts == 0) {
return;
+ }
/* this could be its own function */
if (do_rotate) {
param_pack_rotate(handle, ignore_pinned);
}
- if (phandle->aspx != phandle->aspy)
+ if (phandle->aspx != phandle->aspy) {
param_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy);
+ }
/* we may not use all these boxes */
boxarray = MEM_mallocN(phandle->ncharts * sizeof(BoxPack), "BoxPack box");
@@ -4588,8 +4733,9 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
box->h = chart->u.pack.size[1] + trans[1];
box->index = i; /* warning this index skips PCHART_HAS_PINS boxes */
- if (margin > 0.0f)
+ if (margin > 0.0f) {
area += (double)sqrtf(box->w * box->h);
+ }
}
if (margin > 0.0f) {
@@ -4618,10 +4764,12 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
BLI_box_pack_2d(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height);
- if (tot_height > tot_width)
+ if (tot_height > tot_width) {
scale = 1.0f / tot_height;
- else
+ }
+ else {
scale = 1.0f / tot_width;
+ }
for (i = 0; i < phandle->ncharts - unpacked; i++) {
box = boxarray + i;
@@ -4634,8 +4782,9 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
}
MEM_freeN(boxarray);
- if (phandle->aspx != phandle->aspy)
+ if (phandle->aspx != phandle->aspy) {
param_scale(handle, phandle->aspx, phandle->aspy);
+ }
}
void param_average(ParamHandle *handle, bool ignore_pinned)
@@ -4647,8 +4796,9 @@ void param_average(ParamHandle *handle, bool ignore_pinned)
float minv[2], maxv[2], trans[2];
PHandle *phandle = (PHandle *)handle;
- if (phandle->ncharts == 0)
+ if (phandle->ncharts == 0) {
return;
+ }
for (i = 0; i < phandle->ncharts; i++) {
PFace *f;
@@ -4725,13 +4875,16 @@ void param_flush(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- if ((phandle->state == PHANDLE_STATE_LSCM) && !chart->u.lscm.context)
+ if ((phandle->state == PHANDLE_STATE_LSCM) && !chart->u.lscm.context) {
continue;
+ }
- if (phandle->blend == 0.0f)
+ if (phandle->blend == 0.0f) {
p_flush_uvs(phandle, chart);
- else
+ }
+ else {
p_flush_uvs_blend(phandle, chart, phandle->blend);
+ }
}
}
@@ -4745,7 +4898,8 @@ void param_flush_restore(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- for (f = chart->faces; f; f = f->nextlink)
+ for (f = chart->faces; f; f = f->nextlink) {
p_face_restore_uvs(f);
+ }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 71a3fdf055e..b938f963d9a 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -466,11 +466,13 @@ static void stitch_calculate_island_snapping(StitchState *state,
float rotation_mat[2][2];
/* check to avoid divide by 0 */
- if (island_stitch_data[i].num_rot_elements > 1)
+ if (island_stitch_data[i].num_rot_elements > 1) {
island_stitch_data[i].rotation /= island_stitch_data[i].num_rot_elements;
+ }
- if (island_stitch_data[i].num_rot_elements_neg > 1)
+ if (island_stitch_data[i].num_rot_elements_neg > 1) {
island_stitch_data[i].rotation_neg /= island_stitch_data[i].num_rot_elements_neg;
+ }
if (island_stitch_data[i].numOfElements > 1) {
island_stitch_data[i].medianPoint[0] /= island_stitch_data[i].numOfElements;
@@ -609,8 +611,9 @@ static void stitch_island_calculate_vert_rotation(UvElement *element,
int rot_elem = 0, rot_elem_neg = 0;
BMLoop *l;
- if (element->island == ssc->static_island && !ssc->midpoints)
+ if (element->island == ssc->static_island && !ssc->midpoints) {
return;
+ }
l = element->l;
@@ -625,8 +628,9 @@ static void stitch_island_calculate_vert_rotation(UvElement *element,
float normal[2];
/* only calculate rotation against static island uv verts */
- if (!ssc->midpoints && element_iter->island != ssc->static_island)
+ if (!ssc->midpoints && element_iter->island != ssc->static_island) {
continue;
+ }
index_tmp1 = element_iter - state->element_map->buf;
index_tmp1 = state->map[index_tmp1];
@@ -717,8 +721,9 @@ static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState *
for (i = 0; i < state->total_separate_edges; i++) {
UvEdge *edge = edges + i;
- if (edge->first)
+ if (edge->first) {
continue;
+ }
/* only boundary edges can be stitched. Yes. Sorry about that :p */
if (edge->flag & STITCH_BOUNDARY) {
@@ -736,10 +741,12 @@ static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState *
UvElement *iter2 = NULL;
/* check to see if other vertex of edge belongs to same vertex as */
- if (BM_elem_index_get(iter1->l->next->v) == elemindex2)
+ if (BM_elem_index_get(iter1->l->next->v) == elemindex2) {
iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->next);
- else if (BM_elem_index_get(iter1->l->prev->v) == elemindex2)
+ }
+ else if (BM_elem_index_get(iter1->l->prev->v) == elemindex2) {
iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->prev);
+ }
if (iter2) {
int index1 = map[iter1 - first_element];
@@ -852,8 +859,9 @@ static void stitch_setup_face_preview_for_uv_group(UvElement *element,
StitchPreviewer *preview = state->stitch_preview;
/* static island does not change so returning immediately */
- if (ssc->snap_islands && !ssc->midpoints && ssc->static_island == element->island)
+ if (ssc->snap_islands && !ssc->midpoints && ssc->static_island == element->island) {
return;
+ }
if (ssc->snap_islands) {
island_stitch_data[element->island].addedForPreview = 1;
@@ -892,8 +900,9 @@ static void stitch_validate_uv_stitchability(UvElement *element,
for (; element_iter; element_iter = element_iter->next) {
if (element_iter->separate) {
- if (element_iter == element)
+ if (element_iter == element) {
continue;
+ }
if (stitch_check_uvs_state_stitchable(element, element_iter, ssc, state)) {
if ((element_iter->island == ssc->static_island) ||
(element->island == ssc->static_island)) {
@@ -930,8 +939,9 @@ static void stitch_validate_edge_stitchability(UvEdge *edge,
UvEdge *edge_iter = edge->first;
for (; edge_iter; edge_iter = edge_iter->next) {
- if (edge_iter == edge)
+ if (edge_iter == edge) {
continue;
+ }
if (stitch_check_edges_state_stitchable(edge, edge_iter, ssc, state)) {
if ((edge_iter->element->island == ssc->static_island) ||
(edge->element->island == ssc->static_island)) {
@@ -1029,8 +1039,9 @@ static int stitch_process_data(StitchStateContainer *ssc,
/* cleanup previous preview */
stitch_preview_delete(state->stitch_preview);
preview = state->stitch_preview = stitch_preview_init();
- if (preview == NULL)
+ if (preview == NULL) {
return 0;
+ }
preview_position = MEM_mallocN(bm->totface * sizeof(*preview_position),
"stitch_face_preview_position");
@@ -1248,8 +1259,7 @@ static int stitch_process_data(StitchStateContainer *ssc,
int face_preview_pos = preview_position[index].data_position;
if (face_preview_pos != STITCH_NO_PREVIEW) {
preview->uvs_per_polygon[preview_position[index].polycount_position] = efa->len;
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
copy_v2_v2(preview->preview_polys + face_preview_pos + i * 2, luv->uv);
}
@@ -1260,8 +1270,7 @@ static int stitch_process_data(StitchStateContainer *ssc,
BMLoop *fl = BM_FACE_FIRST_LOOP(efa);
MLoopUV *fuv = CustomData_bmesh_get(&bm->ldata, fl->head.data, CD_MLOOPUV);
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
if (i < numoftris) {
/* using next since the first uv is already accounted for */
BMLoop *lnext = l->next;
@@ -1316,8 +1325,9 @@ static int stitch_process_data(StitchStateContainer *ssc,
copy_v2_v2(final_position[i].uv, luv->uv);
final_position[i].count = 1;
- if (ssc->snap_islands && element->island == ssc->static_island && !stitch_midpoints)
+ if (ssc->snap_islands && element->island == ssc->static_island && !stitch_midpoints) {
continue;
+ }
element_iter = state->element_map->vert[BM_elem_index_get(l->v)];
@@ -1366,8 +1376,10 @@ static int stitch_process_data(StitchStateContainer *ssc,
state->uvs[edge->uv1]->flag |= STITCH_STITCHABLE;
state->uvs[edge->uv2]->flag |= STITCH_STITCHABLE;
- if (ssc->snap_islands && edge->element->island == ssc->static_island && !stitch_midpoints)
+ if (ssc->snap_islands && edge->element->island == ssc->static_island &&
+ !stitch_midpoints) {
continue;
+ }
for (edge_iter = edge->first; edge_iter; edge_iter = edge_iter->next) {
if (stitch_check_edges_state_stitchable(edge, edge_iter, ssc, state)) {
@@ -1414,8 +1426,9 @@ static int stitch_process_data(StitchStateContainer *ssc,
l = element->l;
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- /* accumulate each islands' translation from stitchable elements. it is important to do here
- * because in final pass MTFaces get modified and result is zero. */
+ /* accumulate each islands' translation from stitchable elements.
+ * It is important to do here because in final pass MTFaces
+ * get modified and result is zero. */
island_stitch_data[element->island].translation[0] += final_position[i].uv[0] -
luv->uv[0];
island_stitch_data[element->island].translation[1] += final_position[i].uv[1] -
@@ -1468,8 +1481,9 @@ static int stitch_process_data(StitchStateContainer *ssc,
l = element->l;
luv = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MLOOPUV);
- /* accumulate each islands' translation from stitchable elements. it is important to do here
- * because in final pass MTFaces get modified and result is zero. */
+ /* accumulate each islands' translation from stitchable elements.
+ * it is important to do here because in final pass MTFaces
+ * get modified and result is zero. */
island_stitch_data[element->island].translation[0] += final_position[i].uv[0] -
luv->uv[0];
island_stitch_data[element->island].translation[1] += final_position[i].uv[1] -
@@ -1587,8 +1601,9 @@ static void stitch_select_edge(UvEdge *edge, StitchState *state, int always_sele
for (eiter = edge->first; eiter; eiter = eiter->next) {
if (eiter->flag & STITCH_SELECTED) {
int i;
- if (always_select)
+ if (always_select) {
continue;
+ }
eiter->flag &= ~STITCH_SELECTED;
for (i = 0; i < state->selection_size; i++) {
@@ -1622,8 +1637,9 @@ static void stitch_select_uv(UvElement *element, StitchState *state, int always_
/* only separators go to selection */
if (element_iter->flag & STITCH_SELECTED) {
int i;
- if (always_select)
+ if (always_select) {
continue;
+ }
element_iter->flag &= ~STITCH_SELECTED;
for (i = 0; i < state->selection_size; i++) {
@@ -1660,8 +1676,9 @@ static void stitch_set_selection_mode(StitchState *state, const char from_stitch
UvElement *element1 = state->uvs[edge->uv1];
UvElement *element2 = state->uvs[edge->uv2];
- if ((element1->flag & STITCH_SELECTED) && (element2->flag & STITCH_SELECTED))
+ if ((element1->flag & STITCH_SELECTED) && (element2->flag & STITCH_SELECTED)) {
stitch_select_edge(edge, state, true);
+ }
}
/* unselect selected uvelements */
@@ -1770,8 +1787,9 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
/* Preview Polys */
if (stitch_preview->preview_polys) {
- for (int i = 0; i < stitch_preview->num_polys; i++)
+ for (int i = 0; i < stitch_preview->num_polys; i++) {
num_line += stitch_preview->uvs_per_polygon[i];
+ }
num_tri = num_line - 2 * stitch_preview->num_polys;
@@ -2143,8 +2161,7 @@ static StitchState *stitch_init(bContext *C,
"uv_stitch_selection_stack");
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
UvElement *element = BM_uv_element_get(state->element_map, efa, l);
if (element) {
@@ -2238,8 +2255,9 @@ static bool goto_next_island(StitchStateContainer *ssc)
static int stitch_init_all(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
- if (!ar)
+ if (!ar) {
return 0;
+ }
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -2261,10 +2279,12 @@ static int stitch_init_all(bContext *C, wmOperator *op)
}
else {
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_VERTEX)
+ if (ts->selectmode & SCE_SELECT_VERTEX) {
ssc->mode = STITCH_VERT;
- else
+ }
+ else {
ssc->mode = STITCH_EDGE;
+ }
}
else {
if (ts->uv_selectmode & UV_SELECT_VERTEX) {
@@ -2386,8 +2406,9 @@ static int stitch_init_all(bContext *C, wmOperator *op)
static int stitch_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (!stitch_init_all(C, op))
+ if (!stitch_init_all(C, op)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_modal_handler(C, op);
@@ -2470,8 +2491,9 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
MEM_freeN(objs_selection_count);
}
- if (sa)
+ if (sa) {
ED_workspace_status_text(C, NULL);
+ }
ED_region_draw_cb_exit(CTX_wm_region(C)->type, ssc->draw_handle);
@@ -2505,8 +2527,9 @@ static int stitch_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- if (!stitch_init_all(C, op))
+ if (!stitch_init_all(C, op)) {
return OPERATOR_CANCELLED;
+ }
if (stitch_process_data_all((StitchStateContainer *)op->customdata, scene, 1)) {
stitch_exit(C, op, 1);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 0caa478ffa9..85393925802 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -84,10 +84,12 @@ static void modifier_unwrap_state(Object *obedit, Scene *scene, bool *r_use_subs
/* subsurf will take the modifier settings only if modifier is first or right after mirror */
if (subsurf) {
- if (md && md->type == eModifierType_Subsurf)
+ if (md && md->type == eModifierType_Subsurf) {
subsurf = true;
- else
+ }
+ else {
subsurf = false;
+ }
}
*r_use_subsurf = subsurf;
@@ -105,14 +107,17 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *UNUSED(scene), Object *obed
SpaceImage *sima;
int cd_loop_uv_offset;
- if (ED_uvedit_test(obedit))
+ if (ED_uvedit_test(obedit)) {
return 1;
+ }
- if (em && em->bm->totface && !CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV))
+ if (em && em->bm->totface && !CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV)) {
ED_mesh_uv_texture_add(obedit->data, NULL, true, true);
+ }
- if (!ED_uvedit_test(obedit))
+ if (!ED_uvedit_test(obedit)) {
return 0;
+ }
cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
@@ -129,10 +134,12 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *UNUSED(scene), Object *obed
ima = sima->image;
if (ima) {
- if (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE)
+ if (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) {
ima = NULL;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -176,19 +183,23 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, const UnwrapOpti
* so we can cancel the operator early */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
}
- else if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ else if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
break;
+ }
}
- if (options->topology_from_uvs && !l)
+ if (options->topology_from_uvs && !l) {
continue;
+ }
return true;
}
@@ -251,8 +262,7 @@ static void construct_param_handle_face_add(
/* let parametrizer split the ngon, it can make better decisions
* about which split is best for unwrapping than scanfill */
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
vkeys[i] = (ParamKey)BM_elem_index_get(l->v);
@@ -287,8 +297,9 @@ static ParamHandle *construct_param_handle(Scene *scene,
ED_uvedit_get_aspect(scene, ob, bm, &aspx, &aspy);
- if (aspx != aspy)
+ if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
+ }
}
/* we need the vert indices */
@@ -433,8 +444,9 @@ static void texface_from_original_index(BMFace *efa,
*pin = 0;
*select = 1;
- if (index == ORIGINDEX_NONE)
+ if (index == ORIGINDEX_NONE) {
return;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (BM_elem_index_get(l->v) == index) {
@@ -447,8 +459,11 @@ static void texface_from_original_index(BMFace *efa,
}
}
-/* unwrap handle initialization for subsurf aware-unwrapper. The many modifications required to make the original function(see above)
- * work justified the existence of a new function. */
+/**
+ * Unwrap handle initialization for subsurf aware-unwrapper.
+ * The many modifications required to make the original function(see above)
+ * work justified the existence of a new function.
+ */
static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
Object *ob,
BMEditMesh *em,
@@ -493,8 +508,9 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
ED_uvedit_get_aspect(scene, ob, em->bm, &aspx, &aspy);
- if (aspx != aspy)
+ if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
+ }
}
/* number of subdivisions to perform */
@@ -529,8 +545,9 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
BM_mesh_elem_table_ensure(em->bm, BM_EDGE | BM_FACE);
/* map subsurfed faces to original editFaces */
- for (i = 0; i < numOfFaces; i++)
+ for (i = 0; i < numOfFaces; i++) {
faceMap[i] = BM_face_at_index(em->bm, origPolyIndices[i]);
+ }
edgeMap = MEM_mallocN(numOfEdges * sizeof(BMEdge *), "unwrap_edit_edge_map");
@@ -551,8 +568,9 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
BMFace *origFace = faceMap[i];
if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
- if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN)) {
continue;
+ }
}
else {
if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN) ||
@@ -576,7 +594,8 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
co[2] = subsurfedVerts[mloop[2].v].co;
co[3] = subsurfedVerts[mloop[3].v].co;
- /* This is where all the magic is done. If the vertex exists in the, we pass the original uv pointer to the solver, thus
+ /* This is where all the magic is done.
+ * If the vertex exists in the, we pass the original uv pointer to the solver, thus
* flushing the solution to the edit mesh. */
texface_from_original_index(origFace,
origVertIndices[mloop[0].v],
@@ -675,8 +694,9 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op)
ms->lasttime = PIL_check_seconds_timer();
param_stretch_begin(ms->handle);
- if (ms->blend != 0.0f)
+ if (ms->blend != 0.0f) {
param_stretch_blend(ms->handle, ms->blend);
+ }
op->customdata = ms;
@@ -735,13 +755,16 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel)
ED_area_status_text(sa, NULL);
ED_workspace_status_text(C, NULL);
- if (ms->timer)
+ if (ms->timer) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), ms->timer);
+ }
- if (cancel)
+ if (cancel) {
param_flush_restore(ms->handle);
- else
+ }
+ else {
param_flush(ms->handle);
+ }
param_stretch_end(ms->handle);
param_delete(ms->handle);
@@ -767,12 +790,14 @@ static int minimize_stretch_exec(bContext *C, wmOperator *op)
{
int i, iterations;
- if (!minimize_stretch_init(C, op))
+ if (!minimize_stretch_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
iterations = RNA_int_get(op->ptr, "iterations");
- for (i = 0; i < iterations; i++)
+ for (i = 0; i < iterations; i++) {
minimize_stretch_iteration(C, op, false);
+ }
minimize_stretch_exit(C, op, false);
return OPERATOR_FINISHED;
@@ -782,8 +807,9 @@ static int minimize_stretch_invoke(bContext *C, wmOperator *op, const wmEvent *U
{
MinStretch *ms;
- if (!minimize_stretch_init(C, op))
+ if (!minimize_stretch_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
minimize_stretch_iteration(C, op, true);
@@ -961,10 +987,12 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (RNA_struct_property_is_set(op->ptr, "margin"))
+ if (RNA_struct_property_is_set(op->ptr, "margin")) {
scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin");
- else
+ }
+ else {
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
+ }
uvedit_pack_islands_multi(scene, objects, objects_len, &options, rotate, ignore_pinned);
@@ -1078,10 +1106,12 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
.correct_aspect = (scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT) == 0,
};
- if (use_subsurf)
+ if (use_subsurf) {
handle = construct_param_handle_subsurfed(scene, obedit, em, &options);
- else
+ }
+ else {
handle = construct_param_handle(scene, obedit, em->bm, &options);
+ }
param_lscm_begin(handle, PARAM_TRUE, abf);
@@ -1116,8 +1146,9 @@ void ED_uvedit_live_unwrap_end(short cancel)
if (g_live_unwrap.handles) {
for (int i = 0; i < g_live_unwrap.len; i++) {
param_lscm_end(g_live_unwrap.handles[i]);
- if (cancel)
+ if (cancel) {
param_flush_restore(g_live_unwrap.handles[i]);
+ }
param_delete(g_live_unwrap.handles[i]);
}
MEM_freeN(g_live_unwrap.handles);
@@ -1229,10 +1260,12 @@ static void uv_map_rotation_matrix_ex(float result[4][4],
float sideangle = 0.0f, upangle = 0.0f;
/* get rotation of the current view matrix */
- if (rv3d)
+ if (rv3d) {
copy_m4_m4(viewmatrix, rv3d->viewmat);
- else
+ }
+ else {
unit_m4(viewmatrix);
+ }
/* but shifting */
copy_v4_fl(viewmatrix[3], 0.0f);
@@ -1297,17 +1330,21 @@ static void uv_map_transform(bContext *C, wmOperator *op, float rotmat[4][4])
}
else {
upangledeg = 0.0f;
- if (align == POLAR_ZY)
+ if (align == POLAR_ZY) {
sideangledeg = 0.0f;
- else
+ }
+ else {
sideangledeg = 90.0f;
+ }
}
/* be compatible to the "old" sphere/cylinder mode */
- if (direction == ALIGN_TO_OBJECT)
+ if (direction == ALIGN_TO_OBJECT) {
unit_m4(rotmat);
- else
+ }
+ else {
uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius);
+ }
}
static void uv_transform_properties(wmOperatorType *ot, int radius)
@@ -1340,7 +1377,7 @@ static void uv_transform_properties(wmOperatorType *ot, int radius)
VIEW_ON_EQUATOR,
"Align",
"How to determine rotation around the pole");
- if (radius)
+ if (radius) {
RNA_def_float(ot->srna,
"radius",
1.0f,
@@ -1350,6 +1387,7 @@ static void uv_transform_properties(wmOperatorType *ot, int radius)
"Radius of the sphere or cylinder",
0.0001f,
100.0f);
+ }
}
static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
@@ -1364,15 +1402,17 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
ED_uvedit_get_aspect(scene, ob, em->bm, &aspx, &aspy);
- if (aspx == aspy)
+ if (aspx == aspy) {
return;
+ }
if (aspx > aspy) {
scale = aspy / aspx;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1384,8 +1424,9 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
scale = aspx / aspy;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1439,14 +1480,16 @@ static void uv_map_clip_correct_multi(Scene *scene,
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
/* correct for image aspect ratio */
- if (correct_aspect)
+ if (correct_aspect) {
correct_uv_aspect(scene, ob, em);
+ }
if (scale_to_bounds) {
/* find uv limits */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1457,8 +1500,9 @@ static void uv_map_clip_correct_multi(Scene *scene,
else if (clip_to_bounds) {
/* clipping and wrapping */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1474,10 +1518,12 @@ static void uv_map_clip_correct_multi(Scene *scene,
dx = (max[0] - min[0]);
dy = (max[1] - min[1]);
- if (dx > 0.0f)
+ if (dx > 0.0f) {
dx = 1.0f / dx;
- if (dy > 0.0f)
+ }
+ if (dy > 0.0f) {
dy = 1.0f / dy;
+ }
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -1486,8 +1532,9 @@ static void uv_map_clip_correct_multi(Scene *scene,
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1519,10 +1566,12 @@ static void uvedit_unwrap(Scene *scene, Object *obedit, const UnwrapOptions *opt
modifier_unwrap_state(obedit, scene, &use_subsurf);
ParamHandle *handle;
- if (use_subsurf)
+ if (use_subsurf) {
handle = construct_param_handle_subsurfed(scene, obedit, em, options);
- else
+ }
+ else {
handle = construct_param_handle(scene, obedit, em->bm, options);
+ }
param_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
param_lscm_solve(handle);
@@ -1652,31 +1701,41 @@ static int unwrap_exec(bContext *C, wmOperator *op)
}
/* remember last method for live unwrap */
- if (RNA_struct_property_is_set(op->ptr, "method"))
+ if (RNA_struct_property_is_set(op->ptr, "method")) {
scene->toolsettings->unwrapper = method;
- else
+ }
+ else {
RNA_enum_set(op->ptr, "method", scene->toolsettings->unwrapper);
+ }
/* remember packing margin */
- if (RNA_struct_property_is_set(op->ptr, "margin"))
+ if (RNA_struct_property_is_set(op->ptr, "margin")) {
scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin");
- else
+ }
+ else {
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
+ }
- if (options.fill_holes)
+ if (options.fill_holes) {
scene->toolsettings->uvcalc_flag |= UVCALC_FILLHOLES;
- else
+ }
+ else {
scene->toolsettings->uvcalc_flag &= ~UVCALC_FILLHOLES;
+ }
- if (options.correct_aspect)
+ if (options.correct_aspect) {
scene->toolsettings->uvcalc_flag &= ~UVCALC_NO_ASPECT_CORRECT;
- else
+ }
+ else {
scene->toolsettings->uvcalc_flag |= UVCALC_NO_ASPECT_CORRECT;
+ }
- if (use_subsurf)
+ if (use_subsurf) {
scene->toolsettings->uvcalc_flag |= UVCALC_USESUBSURF;
- else
+ }
+ else {
scene->toolsettings->uvcalc_flag &= ~UVCALC_USESUBSURF;
+ }
/* execute unwrap */
uvedit_unwrap_multi(scene, objects, objects_len, &options);
@@ -1745,11 +1804,13 @@ static int uv_from_view_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
PropertyRNA *prop;
prop = RNA_struct_find_property(op->ptr, "camera_bounds");
- if (!RNA_property_is_set(op->ptr, prop))
+ if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (camera != NULL));
+ }
prop = RNA_struct_find_property(op->ptr, "correct_aspect");
- if (!RNA_property_is_set(op->ptr, prop))
+ if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (camera == NULL));
+ }
return uv_from_view_exec(C, op);
}
@@ -1805,8 +1866,9 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
uv_map_rotation_matrix_ex(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f, objects_pos_offset);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1825,8 +1887,9 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
if (uci) {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1842,8 +1905,9 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
copy_m4_m4(rotmat, obedit->obmat);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1883,8 +1947,9 @@ static bool uv_from_view_poll(bContext *C)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
- if (!ED_operator_uvmap(C))
+ if (!ED_operator_uvmap(C)) {
return 0;
+ }
return (rv3d != NULL);
}
@@ -1977,8 +2042,9 @@ static void uv_sphere_project(float target[2],
map_to_sphere(&target[0], &target[1], pv[0], pv[1], pv[2]);
/* split line is always zero */
- if (target[0] >= 1.0f)
+ if (target[0] >= 1.0f) {
target[0] -= 1.0f;
+ }
}
static void uv_map_mirror(BMEditMesh *em, BMFace *efa)
@@ -1992,22 +2058,24 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa)
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
uvs[i] = luv->uv;
}
mi = 0;
- for (i = 1; i < efa->len; i++)
- if (uvs[i][0] > uvs[mi][0])
+ for (i = 1; i < efa->len; i++) {
+ if (uvs[i][0] > uvs[mi][0]) {
mi = i;
+ }
+ }
for (i = 0; i < efa->len; i++) {
if (i != mi) {
dx = uvs[mi][0] - uvs[i][0];
- if (dx > 0.5f)
+ if (dx > 0.5f) {
uvs[i][0] += 1.0f;
+ }
}
}
}
@@ -2045,8 +2113,9 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
uv_map_transform_center(scene, v3d, obedit, em, center, NULL);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2100,8 +2169,9 @@ static void uv_cylinder_project(float target[2],
map_to_tube(&target[0], &target[1], pv[0], pv[1], pv[2]);
/* split line is always zero */
- if (target[0] >= 1.0f)
+ if (target[0] >= 1.0f) {
target[0] -= 1.0f;
+ }
}
static int cylinder_project_exec(bContext *C, wmOperator *op)
@@ -2137,8 +2207,9 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
uv_map_transform_center(scene, v3d, obedit, em, center, NULL);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2207,8 +2278,9 @@ static void uvedit_unwrap_cube_project(BMesh *bm,
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
/* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
- if (use_select && !BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (use_select && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
axis_dominant_v3(&cox, &coy, efa->no);
@@ -2338,6 +2410,7 @@ void ED_uvedit_add_simple_uvs(Main *bmain, Scene *scene, Object *ob)
BM_mesh_bm_to_me(bmain, bm, me, (&(struct BMeshToMeshParams){0}));
BM_mesh_free(bm);
- if (sync_selection)
+ if (sync_selection) {
scene->toolsettings->uv_flag |= UV_SYNC_SELECTION;
+ }
}
diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp
index 8248266bbf5..ab1da79a77f 100644
--- a/source/blender/freestyle/intern/application/AppCanvas.cpp
+++ b/source/blender/freestyle/intern/application/AppCanvas.cpp
@@ -135,8 +135,18 @@ void AppCanvas::readColorPixels(int x, int y, int w, int h, RGBImage &oImage) co
float yfac = ((float)recty) / ((float)(ymax - ymin));
#if 0
if (G.debug & G_DEBUG_FREESTYLE) {
- printf("readColorPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y,
- xsch, ysch, xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+ printf("readColorPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n",
+ w,
+ h,
+ x,
+ y,
+ xsch,
+ ysch,
+ xmax - xmin,
+ ymax - ymin,
+ rectx,
+ recty,
+ (int)(xfac * 100.0f));
}
#endif
int ii, jj;
@@ -173,8 +183,18 @@ void AppCanvas::readDepthPixels(int x, int y, int w, int h, GrayImage &oImage) c
float yfac = ((float)recty) / ((float)(ymax - ymin));
#if 0
if (G.debug & G_DEBUG_FREESTYLE) {
- printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y,
- xsch, ysch, xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
+ printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n",
+ w,
+ h,
+ x,
+ y,
+ xsch,
+ ysch,
+ xmax - xmin,
+ ymax - ymin,
+ rectx,
+ recty,
+ (int)(xfac * 100.0f));
}
#endif
int ii, jj;
diff --git a/source/blender/freestyle/intern/application/AppView.h b/source/blender/freestyle/intern/application/AppView.h
index 0b029895b8c..deb099349cb 100644
--- a/source/blender/freestyle/intern/application/AppView.h
+++ b/source/blender/freestyle/intern/application/AppView.h
@@ -43,7 +43,7 @@ class AppView {
virtual ~AppView();
public:
- //inherited
+ // inherited
inline unsigned int width()
{
return _width;
@@ -246,7 +246,7 @@ class AppView {
protected:
float _Fovy;
- //The root node container
+ // The root node container
NodeGroup _RootNode;
NodeDrawingStyle *_ModelRootNode;
NodeDrawingStyle *_SilhouetteRootNode;
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index e6066123a33..4d5ffda5f38 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -76,8 +76,8 @@ Controller::Controller()
{
const string sep(Config::DIR_SEP.c_str());
#if 0
- const string filename = Config::Path::getInstance()->getHomeDir() + sep + Config::OPTIONS_DIR + sep +
- Config::OPTIONS_CURRENT_DIRS_FILE;
+ const string filename = Config::Path::getInstance()->getHomeDir() + sep + Config::OPTIONS_DIR +
+ sep + Config::OPTIONS_CURRENT_DIRS_FILE;
_current_dirs = new ConfigIO(filename, Config::APPLICATION_NAME + "CurrentDirs", true);
#endif
@@ -179,7 +179,7 @@ Controller::~Controller()
_ProgressBar = NULL;
}
- //delete _current_dirs;
+ // delete _current_dirs;
}
void Controller::setView(AppView *iView)
@@ -300,7 +300,7 @@ int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph
_RootNode->AddChild(new NodeViewLayer(*re->scene, *view_layer));
sceneHashFunc.reset();
- //blenderScene->accept(sceneHashFunc);
+ // blenderScene->accept(sceneHashFunc);
_RootNode->accept(sceneHashFunc);
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "Scene hash : " << sceneHashFunc.toString() << endl;
@@ -337,7 +337,7 @@ int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph
}
soc QFileInfo qfi(iFileName);
- soc string basename((const char*)qfi.fileName().toAscii().data());
+ soc string basename((const char *)qfi.fileName().toAscii().data());
char cleaned[FILE_MAX];
BLI_strncpy(cleaned, iFileName, FILE_MAX);
BLI_cleanup_file(NULL, cleaned);
@@ -626,38 +626,38 @@ void Controller::ComputeViewMap()
void Controller::ComputeSteerableViewMap()
{
-#if 0 //soc
+#if 0 // soc
if ((!_Canvas) || (!_ViewMap))
return;
// Build 4 nodes containing the edges in the 4 directions
NodeGroup *ng[Canvas::NB_STEERABLE_VIEWMAP];
unsigned i;
- real c = 32.0f/255.0f; // see SteerableViewMap::readSteerableViewMapPixel() for information about this 32.
+ real c =
+ 32.0f /
+ 255.0f; // see SteerableViewMap::readSteerableViewMapPixel() for information about this 32.
for (i = 0; i < Canvas::NB_STEERABLE_VIEWMAP; ++i) {
ng[i] = new NodeGroup;
}
NodeShape *completeNS = new NodeShape;
- completeNS->material().setDiffuse(c,c,c,1);
- ng[Canvas::NB_STEERABLE_VIEWMAP-1]->AddChild(completeNS);
+ completeNS->material().setDiffuse(c, c, c, 1);
+ ng[Canvas::NB_STEERABLE_VIEWMAP - 1]->AddChild(completeNS);
SteerableViewMap *svm = _Canvas->getSteerableViewMap();
svm->Reset();
- ViewMap::fedges_container& fedges = _ViewMap->FEdges();
+ ViewMap::fedges_container &fedges = _ViewMap->FEdges();
LineRep *fRep;
NodeShape *ns;
- for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end();
- f != fend;
- ++f)
- {
+ for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend;
+ ++f) {
if ((*f)->viewedge()->qi() != 0)
continue;
fRep = new LineRep((*f)->vertexA()->point2d(), (*f)->vertexB()->point2d());
- completeNS->AddRep(fRep); // add to the complete map anyway
+ completeNS->AddRep(fRep); // add to the complete map anyway
double *oweights = svm->AddFEdge(*f);
for (i = 0; i < (Canvas::NB_STEERABLE_VIEWMAP - 1); ++i) {
ns = new NodeShape;
- double wc = oweights[i]*c;
+ double wc = oweights[i] * c;
if (oweights[i] == 0)
continue;
ns->material().setDiffuse(wc, wc, wc, 1);
@@ -713,7 +713,6 @@ void Controller::ComputeSteerableViewMap()
# endif
}
-
svm->buildImagesPyramids(img, false, 0, 1.0f);
#endif
}
@@ -1085,10 +1084,11 @@ void Controller::displayDensityCurves(int x, int y)
// display the curves
#if 0
for (i = 0; i < nbCurves; ++i)
- _pDensityCurvesWindow->setOrientationCurve(i, Vec2d(0, 0), Vec2d(nbPoints, 1), curves[i], "scale", "density");
+ _pDensityCurvesWindow->setOrientationCurve(
+ i, Vec2d(0, 0), Vec2d(nbPoints, 1), curves[i], "scale", "density");
for (i = 1; i <= 8; ++i)
- _pDensityCurvesWindow->setLevelCurve(i, Vec2d(0, 0), Vec2d(nbCurves, 1), curvesDirection[i],
- "orientation", "density");
+ _pDensityCurvesWindow->setLevelCurve(
+ i, Vec2d(0, 0), Vec2d(nbCurves, 1), curvesDirection[i], "orientation", "density");
_pDensityCurvesWindow->show();
#endif
}
diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h
index be8553c73e1..613ea2cb45c 100644
--- a/source/blender/freestyle/intern/application/Controller.h
+++ b/source/blender/freestyle/intern/application/Controller.h
@@ -58,7 +58,7 @@ class Controller {
void setPassZ(float *buf, int width, int height);
void setContext(bContext *C);
- //soc
+ // soc
void init_options();
int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph);
@@ -94,10 +94,22 @@ class Controller {
vector<ViewEdge *>::iterator vedges_end);
#if 0
- NodeGroup *debugNode() {return _DebugNode;}
- AppView *view() {return _pView;}
- NodeGroup *debugScene() {return _DebugNode;}
- Grid& grid() {return _Grid;}
+ NodeGroup *debugNode()
+ {
+ return _DebugNode;
+ }
+ AppView *view()
+ {
+ return _pView;
+ }
+ NodeGroup *debugScene()
+ {
+ return _DebugNode;
+ }
+ Grid &grid()
+ {
+ return _Grid;
+ }
#endif
void toggleVisibilityAlgo();
@@ -163,15 +175,15 @@ class Controller {
private:
// Main Window:
- //AppMainWindow *_pMainWindow;
+ // AppMainWindow *_pMainWindow;
// List of models currently loaded
vector<string> _ListOfModels;
// Current directories
- //ConfigIO* _current_dirs;
+ // ConfigIO* _current_dirs;
- //View
+ // View
// 3D
AppView *_pView;
@@ -183,7 +195,7 @@ class Controller {
RenderMonitor *_pRenderMonitor;
- //Model
+ // Model
// Drawing Structure
NodeGroup *_RootNode;
@@ -192,7 +204,7 @@ class Controller {
#if 0
// Silhouette structure:
- std::vector<SShape*> _SShapes;
+ std::vector<SShape *> _SShapes;
NodeGroup *_SRoot;
// Silhouette
@@ -205,7 +217,7 @@ class Controller {
#endif
// debug
- //NodeUser<ViewMap> *_ViewMapNode; // FIXME
+ // NodeUser<ViewMap> *_ViewMapNode; // FIXME
// Chronometer:
Chronometer _Chrono;
@@ -217,7 +229,7 @@ class Controller {
int _edgeTesselationNature;
FastGrid _Grid;
- //HashGrid _Grid;
+ // HashGrid _Grid;
BBox<Vec3r> _Scene3dBBox;
unsigned int _SceneNumFaces;
@@ -229,9 +241,9 @@ class Controller {
int _render_count;
- //AppStyleWindow *_pStyleWindow;
- //AppOptionsWindow *_pOptionsWindow;
- //AppDensityCurvesWindow *_pDensityCurvesWindow;
+ // AppStyleWindow *_pStyleWindow;
+ // AppOptionsWindow *_pOptionsWindow;
+ // AppDensityCurvesWindow *_pDensityCurvesWindow;
ViewMapBuilder::visibility_algo _VisibilityAlgo;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index 6b14c9ec70f..06a356dd232 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -77,9 +77,9 @@ NodeGroup *BlenderFileLoader::Load()
#if 0
if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "Frustum: l " << _viewplane_left << " r " << _viewplane_right
- << " b " << _viewplane_bottom << " t " << _viewplane_top
- << " n " << _z_near << " f " << _z_far << endl;
+ cout << "Frustum: l " << _viewplane_left << " r " << _viewplane_right << " b "
+ << _viewplane_bottom << " t " << _viewplane_top << " n " << _z_near << " f " << _z_far
+ << endl;
}
#endif
@@ -143,7 +143,9 @@ int BlenderFileLoader::countClippedFaces(float v1[3], float v2[3], float v3[3],
}
#if 0
if (G.debug & G_DEBUG_FREESTYLE) {
- printf("%d %s\n", i, (clip[i] == NOT_CLIPPED) ? "not" : (clip[i] == CLIPPED_BY_NEAR) ? "near" : "far");
+ printf("%d %s\n",
+ i,
+ (clip[i] == NOT_CLIPPED) ? "not" : (clip[i] == CLIPPED_BY_NEAR) ? "near" : "far");
}
#endif
sum += clip[i];
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
index 5fe98fba0d0..dc6677bdcf4 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
@@ -98,7 +98,10 @@ class BlenderFileLoader {
#if 0
/*! Gets the smallest edge size read */
- inline real minEdgeSize() {return _minEdgeSize;}
+ inline real minEdgeSize()
+ {
+ return _minEdgeSize;
+ }
#endif
/*! Modifiers */
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 47e2fef33e3..082ed34c353 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -190,7 +190,7 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer()
char *name = ob->id.name;
#if 0
if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "removing " << name[0] << name[1] << ":" << (name+2) << endl;
+ cout << "removing " << name[0] << name[1] << ":" << (name + 2) << endl;
}
#endif
switch (ob->type) {
@@ -598,7 +598,8 @@ int BlenderStrokeRenderer::get_stroke_count() const
void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
{
#if 0
- Object *object_mesh = BKE_object_add(freestyle_bmain, freestyle_scene, (ViewLayer *)freestyle_scene->view_layers.first, OB_MESH);
+ Object *object_mesh = BKE_object_add(
+ freestyle_bmain, freestyle_scene, (ViewLayer *)freestyle_scene->view_layers.first, OB_MESH);
DEG_relations_tag_update(freestyle_bmain);
#else
Object *object_mesh = NewMesh();
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 63ff4cc5457..7ef3e23d379 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -384,9 +384,10 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
bool logical_and = ((lineset->flags & FREESTYLE_LINESET_FE_AND) != 0);
// negation operator
if (lineset->flags & FREESTYLE_LINESET_FE_NOT) {
- // convert an Exclusive condition into an Inclusive equivalent using De Morgan's laws:
- // NOT (X OR Y) --> (NOT X) AND (NOT Y)
- // NOT (X AND Y) --> (NOT X) OR (NOT Y)
+ // convert an Exclusive condition into an
+ // Inclusive equivalent using De Morgan's laws:
+ // - NOT (X OR Y) --> (NOT X) AND (NOT Y)
+ // - NOT (X AND Y) --> (NOT X) OR (NOT Y)
for (int i = 0; i < num_edge_types; i++)
conditions[i].value *= -1;
logical_and = !logical_and;
diff --git a/source/blender/freestyle/intern/geometry/FastGrid.h b/source/blender/freestyle/intern/geometry/FastGrid.h
index e2345d4831c..a3b20661fa6 100644
--- a/source/blender/freestyle/intern/geometry/FastGrid.h
+++ b/source/blender/freestyle/intern/geometry/FastGrid.h
@@ -28,7 +28,8 @@ namespace Freestyle {
/*! Class to define a regular grid used for ray casting computations
* We don't use a hashtable here. The grid is explicitly stored for faster computations.
- * However, this might result in significant increase in memory usage (compared to the regular grid)
+ * However, this might result in significant increase in memory usage
+ * (compared to the regular grid).
*/
class FastGrid : public Grid {
public:
@@ -43,8 +44,9 @@ class FastGrid : public Grid {
clear();
}
- /*! clears the grid
- * Deletes all the cells, clears the hashtable, resets size, size of cell, number of cells.
+ /*!
+ * clears the grid
+ * Deletes all the cells, clears the hashtable, resets size, size of cell, number of cells.
*/
virtual void clear();
diff --git a/source/blender/freestyle/intern/geometry/FitCurve.cpp b/source/blender/freestyle/intern/geometry/FitCurve.cpp
index b0408826763..368c3d2f46c 100644
--- a/source/blender/freestyle/intern/geometry/FitCurve.cpp
+++ b/source/blender/freestyle/intern/geometry/FitCurve.cpp
@@ -181,8 +181,8 @@ static BezierCurve GenerateBezier(
alpha_l = det_X_C1 / det_C0_C1;
alpha_r = det_C0_X / det_C0_C1;
- /* If alpha negative, use the Wu/Barsky heuristic (see text) (if alpha is 0, you get coincident control points
- * that lead to divide by zero in any subsequent NewtonRaphsonRootFind() call).
+ /* If alpha negative, use the Wu/Barsky heuristic (see text) (if alpha is 0, you get coincident
+ * control points that lead to divide by zero in any subsequent NewtonRaphsonRootFind() call).
*/
if (alpha_l < 1.0e-6 || alpha_r < 1.0e-6) {
double dist = V2DistanceBetween2Points(&d[last], &d[first]) / 3.0;
@@ -194,8 +194,9 @@ static BezierCurve GenerateBezier(
return bezCurve;
}
- /* First and last control points of the Bezier curve are positioned exactly at the first and last data points
- * Control points 1 and 2 are positioned an alpha distance out on the tangent vectors, left and right, respectively
+ /* First and last control points of the Bezier curve are positioned exactly at the first and last
+ * data points Control points 1 and 2 are positioned an alpha distance out on the tangent
+ * vectors, left and right, respectively
*/
bezCurve[0] = d[first];
bezCurve[3] = d[last];
diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.h b/source/blender/freestyle/intern/geometry/GeomCleaner.h
index b34828f87a9..253d3553010 100644
--- a/source/blender/freestyle/intern/geometry/GeomCleaner.h
+++ b/source/blender/freestyle/intern/geometry/GeomCleaner.h
@@ -45,20 +45,24 @@ class GeomCleaner {
/*! Sorts an array of Indexed vertices
* iVertices
- * Array of vertices to sort. It is organized as a float series of vertex coordinates: XYZXYZXYZ...
+ * Array of vertices to sort.
+ * It is organized as a float series of vertex coordinates: XYZXYZXYZ...
* iVSize
* The size of iVertices array.
* iIndices
- * The array containing the vertex indices (used to refer to the vertex coordinates in an indexed face). Each
- * element is an unsignedeger multiple of 3.
+ * The array containing the vertex indices
+ * (used to refer to the vertex coordinates in an indexed face).
+ * Each element is an unsignedeger multiple of 3.
* iISize
* The size of iIndices array
* oVertices
- * Output of sorted vertices. A vertex v1 precedes another one v2 in this array if v1.x<v2.x,
- * or v1.x=v2.x && v1.y < v2.y or v1.x=v2.y && v1.y=v2.y && v1.z < v2.z.
+ * Output of sorted vertices.
+ * A vertex v1 precedes another one v2 in this array
+ * if v1.x<v2.x, or v1.x=v2.x && v1.y < v2.y or v1.x=v2.y && v1.y=v2.y && v1.z < v2.z.
* The array is organized as a 3-float serie giving the vertices coordinates: XYZXYZXYZ...
* oIndices
- * Output corresponding to the iIndices array but reorganized in order to match the sorted vertex array.
+ * Output corresponding to the iIndices array but reorganized in
+ * order to match the sorted vertex array.
*/
static void SortIndexedVertexArray(const float *iVertices,
unsigned iVSize,
@@ -67,13 +71,16 @@ class GeomCleaner {
float **oVertices,
unsigned **oIndices);
- /*! Compress a SORTED indexed vertex array by eliminating multiple appearing occurences of a single vertex.
+ /*! Compress a SORTED indexed vertex array by eliminating multiple
+ * appearing occurences of a single vertex.
* iVertices
- * The SORTED vertex array to compress. It is organized as a float series of vertex coordinates: XYZXYZXYZ...
+ * The SORTED vertex array to compress.
+ * It is organized as a float series of vertex coordinates: XYZXYZXYZ...
* iVSize
* The size of iVertices array.
* iIndices
- * The array containing the vertex indices (used to refer to the vertex coordinates in an indexed face).
+ * The array containing the vertex indices
+ * (used to refer to the vertex coordinates in an indexed face).
* Each element is an unsignedeger multiple of 3.
* iISize
* The size of iIndices array
@@ -100,7 +107,8 @@ class GeomCleaner {
* iVSize
* The size of iVertices array.
* iIndices
- * The array containing the vertex indices (used to refer to the vertex coordinates in an indexed face).
+ * The array containing the vertex indices
+ * (used to refer to the vertex coordinates in an indexed face).
* Each element is an unsignedeger multiple of 3.
* iISize
* The size of iIndices array
@@ -120,15 +128,16 @@ class GeomCleaner {
unsigned *oVSize,
unsigned **oIndices);
- /*! Cleans an indexed vertex array. (Identical to SortAndCompress except that we use here a hash table
- * to create the new array.)
+ /*! Cleans an indexed vertex array.
+ * (Identical to SortAndCompress except that we use here a hash table to create the new array.)
* iVertices
* The vertex array to sort then compress. It is organized as a float series of
* vertex coordinates: XYZXYZXYZ...
* iVSize
* The size of iVertices array.
* iIndices
- * The array containing the vertex indices (used to refer to the vertex coordinates in an indexed face).
+ * The array containing the vertex indices
+ * (used to refer to the vertex coordinates in an indexed face).
* Each element is an unsignedeger multiple of 3.
* iISize
* The size of iIndices array
@@ -154,9 +163,10 @@ class GeomCleaner {
};
/*! Binary operators */
-//inline bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2);
+// inline bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2);
-/*! Class Indexed Vertex. Used to represent an indexed vertex by storing the vertex coordinates as well as its index */
+/*! Class Indexed Vertex. Used to represent an indexed vertex by storing the vertex coordinates as
+ * well as its index */
class IndexedVertex {
private:
Vec3f _Vector;
@@ -223,7 +233,7 @@ class IndexedVertex {
return _Vector[i];
}
- //friend inline bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2);
+ // friend inline bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2);
inline bool operator<(const IndexedVertex &v) const
{
return (_Vector < v._Vector);
@@ -240,7 +250,7 @@ class IndexedVertex {
};
#if 0
-bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2)
+bool operator<(const IndexedVertex &iv1, const IndexedVertex &iv2)
{
return iv1.operator<(iv2);
}
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
index 2ac83526268..bec6ed27cc4 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
@@ -88,8 +88,8 @@ intersection_test intersect2dSeg2dSeg(
r1 = a2 * p1[0] + b2 * p1[1] + c2;
r2 = a2 * p2[0] + b2 * p2[1] + c2;
- // Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line segment,
- // the line segments do not intersect.
+ // Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line
+ // segment, the line segments do not intersect.
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0)
return (DONT_INTERSECT);
@@ -172,8 +172,8 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
r1 = a2 * p1[0] + b2 * p1[1] + c2;
r2 = a2 * p2[0] + b2 * p2[1] + c2;
- // Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line segment,
- // the line segments do not intersect.
+ // Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line
+ // segment, the line segments do not intersect.
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0)
return (DONT_INTERSECT);
@@ -202,8 +202,8 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
// 2001-03-05: released the code in its first version
// 2001-06-18: changed the order of the tests, faster
//
-// Acknowledgement: Many thanks to Pierre Terdiman for suggestions and discussions on how to optimize code.
-// Thanks to David Hunt for finding a ">="-bug!
+// Acknowledgement: Many thanks to Pierre Terdiman for suggestions and discussions on how to
+// optimize code. Thanks to David Hunt for finding a ">="-bug!
#define X 0
#define Y 1
@@ -337,10 +337,10 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
// This internal procedure is defined below.
bool overlapPlaneBox(Vec3r &normal, real d, Vec3r &maxbox);
-// Use separating axis theorem to test overlap between triangle and box need to test for overlap in these directions:
-// 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle we do not even need to test these)
-// 2) normal of the triangle
-// 3) crossproduct(edge from tri, {x,y,z}-directin) this gives 3x3=9 more tests
+// Use separating axis theorem to test overlap between triangle and box need to test for overlap in
+// these directions: 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle we
+// do not even need to test these) 2) normal of the triangle 3) crossproduct(edge from tri,
+// {x,y,z}-directin) this gives 3x3=9 more tests
bool overlapTriangleBox(Vec3r &boxcenter, Vec3r &boxhalfsize, Vec3r triverts[3])
{
Vec3r v0, v1, v2, normal, e0, e1, e2;
@@ -382,8 +382,8 @@ bool overlapTriangleBox(Vec3r &boxcenter, Vec3r &boxhalfsize, Vec3r triverts[3])
// Bullet 1:
// first test overlap in the {x,y,z}-directions
- // find min, max of the triangle each direction, and test for overlap in that direction -- this is equivalent
- // to testing a minimal AABB around the triangle against the AABB
+ // find min, max of the triangle each direction, and test for overlap in that direction -- this
+ // is equivalent to testing a minimal AABB around the triangle against the AABB
// test in X-direction
FINDMINMAX(v0[X], v1[X], v2[X], min, max);
@@ -664,7 +664,7 @@ void fromWorldToImage(const Vec3r &p, Vec3r &q, const real transform[4][4], cons
// winX:
q[0] = viewport[0] + viewport[2] * (q[0] + 1.0) / 2.0;
- //winY:
+ // winY:
q[1] = viewport[1] + viewport[3] * (q[1] + 1.0) / 2.0;
}
@@ -709,10 +709,10 @@ void fromCameraToWorld(const Vec3r &p, Vec3r &q, const real model_view_matrix[4]
/////////////////////////////////////////////////////////////////////////////
// Copyright 2001, softSurfer (www.softsurfer.com)
-// This code may be freely used and modified for any purpose providing that this copyright notice is included with it.
-// SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage resulting
-// from its use.
-// Users of this code must verify correctness for their application.
+// This code may be freely used and modified for any purpose providing that this copyright notice
+// is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for
+// any real or imagined damage resulting from its use. Users of this code must verify correctness
+// for their application.
#define PERP(u, v) ((u)[0] * (v)[1] - (u)[1] * (v)[0]) // 2D perp product
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.h b/source/blender/freestyle/intern/geometry/GeomUtils.h
index 42ef9612074..c469f10cc49 100644
--- a/source/blender/freestyle/intern/geometry/GeomUtils.h
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.h
@@ -105,7 +105,8 @@ bool include2dSeg2dArea(const Vec2r &min, const Vec2r &max, const Vec2r &A, cons
/*! Box-triangle overlap test, adapted from Tomas Akenine-Möller code */
bool overlapTriangleBox(Vec3r &boxcenter, Vec3r &boxhalfsize, Vec3r triverts[3]);
-/*! Fast, Minimum Storage Ray-Triangle Intersection, adapted from Tomas Möller and Ben Trumbore code. */
+/*! Fast, Minimum Storage Ray-Triangle Intersection, adapted from Tomas Möller and Ben Trumbore
+ * code. */
bool intersectRayTriangle(const Vec3r &orig,
const Vec3r &dir,
const Vec3r &v0,
@@ -126,7 +127,8 @@ intersection_test intersectRayPlane(const Vec3r &orig,
const real epsilon = M_EPSILON); // the epsilon to use
/*! Intersection Ray-Bounding box (axis aligned).
- * Adapted from Williams et al, "An Efficient Robust Ray-Box Intersection Algorithm", JGT 10:1 (2005), pp. 49-54.
+ * Adapted from Williams et al, "An Efficient Robust Ray-Box Intersection Algorithm", JGT 10:1
+ * (2005), pp. 49-54.
*/
bool intersectRayBBox(const Vec3r &orig,
const Vec3r &dir, // ray origin and direction
diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp
index 6a95e540c79..aeb82d56009 100644
--- a/source/blender/freestyle/intern/geometry/Grid.cpp
+++ b/source/blender/freestyle/intern/geometry/Grid.cpp
@@ -49,10 +49,10 @@ void firstIntersectionGridVisitor::examineOccluder(Polygon3r *occ)
{
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
Vec3r v1(((occ)->getVertices())[0]);
Vec3d normal((occ)->getNormal());
- //soc unused - double d = -(v1 * normal);
+ // soc unused - double d = -(v1 * normal);
double tmp_u, tmp_v, tmp_t;
if ((occ)->rayIntersect(ray_org_, ray_dir_, tmp_t, tmp_u, tmp_v)) {
@@ -63,7 +63,8 @@ void firstIntersectionGridVisitor::examineOccluder(Polygon3r *occ)
current_cell_->getOrigin() + cell_size_)) {
#if 0
Vec3d bboxdiag(_scene3d->bbox().getMax() - _scene3d->bbox().getMin());
- if ((t > 1.0e-06 * (min(min(bboxdiag.x(), bboxdiag.y()), bboxdiag.z()))) && (t < raylength)) {
+ if ((t > 1.0e-06 * (min(min(bboxdiag.x(), bboxdiag.y()), bboxdiag.z()))) &&
+ (t < raylength)) {
#else
if (tmp_t < t_) {
#endif
@@ -166,8 +167,9 @@ void Grid::insertOccluder(Polygon3r *occluder)
getCellCoordinates(min, imin);
// We are now going to fill in the cells overlapping with the polygon bbox.
- // If the polygon is a triangle (most of cases), we also check for each of these cells if it is overlapping with
- // the triangle in order to only fill in the ones really overlapping the triangle.
+ // If the polygon is a triangle (most of cases), we also check for each of these cells if it is
+ // overlapping with the triangle in order to only fill in the ones really overlapping the
+ // triangle.
unsigned i, x, y, z;
vector<Vec3r>::const_iterator it;
@@ -238,8 +240,8 @@ bool Grid::nextRayCell(Vec3u &current_cell, Vec3u &next_cell)
t_min = FLT_MAX; // init tmin with handle of the case where one or 2 _u[i] = 0.
unsigned coord = 0; // predominant coord(0=x, 1=y, 2=z)
- // using a parametric equation of a line : B = A + t u, we find the tx, ty and tz respectively coresponding
- // to the intersections with the plans:
+ // using a parametric equation of a line : B = A + t u, we find the tx, ty and tz respectively
+ // coresponding to the intersections with the plans:
// x = _cell_size[0], y = _cell_size[1], z = _cell_size[2]
for (i = 0; i < 3; i++) {
if (_ray_dir[i] == 0)
@@ -317,8 +319,8 @@ Polygon3r *Grid::castRayToFindFirstIntersection(
firstIntersectionGridVisitor visitor(orig, dir, _cell_size);
castRayInternal(visitor);
// ARB: This doesn't work, because occluders are unordered within any cell
- // visitor.occluder() will be an occluder, but we have no guarantee it will be the *first* occluder.
- // I assume that is the reason this code is not actually used for FindOccludee.
+ // visitor.occluder() will be an occluder, but we have no guarantee it will be the *first*
+ // occluder. I assume that is the reason this code is not actually used for FindOccludee.
occluder = visitor.occluder();
t = visitor.t_;
u = visitor.u_;
@@ -336,7 +338,7 @@ void Grid::initRay(const Vec3r &orig, const Vec3r &end, unsigned timestamp)
for (unsigned i = 0; i < 3; i++) {
_current_cell[i] = (unsigned)floor((orig[i] - _orig[i]) / _cell_size[i]);
- //soc unused - unsigned u = _current_cell[i];
+ // soc unused - unsigned u = _current_cell[i];
_pt[i] = orig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
}
//_ray_occluders.clear();
@@ -357,7 +359,7 @@ bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timesta
if (box.inside(orig)) {
for (unsigned int i = 0; i < 3; i++) {
_current_cell[i] = (unsigned int)floor((orig[i] - _orig[i]) / _cell_size[i]);
- //soc unused - unsigned u = _current_cell[i];
+ // soc unused - unsigned u = _current_cell[i];
_pt[i] = orig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
}
}
@@ -371,7 +373,7 @@ bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timesta
_current_cell[i] = (unsigned)floor((newOrig[i] - _orig[i]) / _cell_size[i]);
if (_current_cell[i] == _cells_nb[i])
_current_cell[i] = _cells_nb[i] - 1;
- //soc unused - unsigned u = _current_cell[i];
+ // soc unused - unsigned u = _current_cell[i];
_pt[i] = newOrig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
}
}
diff --git a/source/blender/freestyle/intern/geometry/Grid.h b/source/blender/freestyle/intern/geometry/Grid.h
index a2b64a446b6..67aae73a578 100644
--- a/source/blender/freestyle/intern/geometry/Grid.h
+++ b/source/blender/freestyle/intern/geometry/Grid.h
@@ -92,7 +92,7 @@ class Cell {
class GridVisitor {
public:
- virtual ~GridVisitor(){}; //soc
+ virtual ~GridVisitor(){}; // soc
virtual void discoverCell(Cell * /*cell*/)
{
@@ -143,7 +143,7 @@ class allOccludersGridVisitor : public GridVisitor {
* The occluder and the intersection information are stored and accessible.
*/
class firstIntersectionGridVisitor : public GridVisitor {
- //soc - changed order to remove warnings
+ // soc - changed order to remove warnings
public:
double u_, v_, t_;
@@ -217,7 +217,8 @@ class Grid {
*/
virtual void configure(const Vec3r &orig, const Vec3r &size, unsigned nb);
- /*! returns a vector of integer containing the coordinates of the cell containing the point passed as argument
+ /*! returns a vector of integer containing the coordinates of the cell containing the point
+ * passed as argument
* p
* The point for which we're looking the cell
*/
@@ -241,8 +242,8 @@ class Grid {
/*! returns the cell whose coordinates are pased as argument */
virtual Cell *getCell(const Vec3u &coord) = 0;
- /*! returns the cell containing the point passed as argument. If the cell is empty (contains no occluder),
- * NULL is returned
+ /*! returns the cell containing the point passed as argument.
+ * If the cell is empty (contains no occluder), NULL is returned:
* p
* The point for which we're looking the cell
*/
@@ -253,7 +254,8 @@ class Grid {
return getCell(coord);
}
- /*! Retrieves the x,y,z coordinates of the origin of the cell whose coordinates (i,j,k) is passed as argument
+ /*! Retrieves the x,y,z coordinates of the origin of the cell whose coordinates (i,j,k)
+ * is passed as argument:
* cell_coord
* i,j,k integer coordinates for the cell
* orig
@@ -265,7 +267,7 @@ class Grid {
orig[i] = _orig[i] + cell_coord[i] * _cell_size[i];
}
- /*! Retrieves the box corresponding to the cell whose coordinates are passed as argument.
+ /*! Retrieves the box corresponding to the cell whose coordinates are passed as argument:
* cell_coord
* i,j,k integer coordinates for the cell
* min_out
@@ -280,9 +282,8 @@ class Grid {
}
/*! inserts a convex polygon occluder
- * This method is quite coarse insofar as it adds all cells intersecting the polygon bounding box
- * convex_poly
- * The list of 3D points constituting a convex polygon
+ * This method is quite coarse insofar as it adds all cells intersecting the polygon bounding
+ * box convex_poly The list of 3D points constituting a convex polygon
*/
void insertOccluder(Polygon3r *convex_poly);
@@ -301,8 +302,8 @@ class Grid {
// Prepares to cast ray without generating OccludersSet
void initAcceleratedRay(const Vec3r &orig, const Vec3r &end, unsigned timestamp);
- /*! Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a given direction.
- * Returns the list of occluders contained in the cells intersected by this ray
+ /*! Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a
+ * given direction. Returns the list of occluders contained in the cells intersected by this ray
* Starts with a call to InitRay.
*/
void castInfiniteRay(const Vec3r &orig,
@@ -313,9 +314,9 @@ class Grid {
// Prepares to cast ray without generating OccludersSet.
bool initAcceleratedInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timestamp);
- /*! Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a given direction.
- * Returns the first intersection (occluder,t,u,v) or null.
- * Starts with a call to InitRay.
+ /*! Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a
+ * given direction. Returns the first intersection (occluder,t,u,v) or null. Starts with a call
+ * to InitRay.
*/
Polygon3r *castRayToFindFirstIntersection(
const Vec3r &orig, const Vec3r &dir, double &t, double &u, double &v, unsigned timestamp);
@@ -344,7 +345,7 @@ class Grid {
return _cell_size;
}
- //ARB profiling only:
+ // ARB profiling only:
inline OccludersSet *getOccluders()
{
return &_occluders;
@@ -392,12 +393,13 @@ class Grid {
Vec3r _ray_dir; // direction vector for the ray
Vec3u _current_cell; // The current cell being processed (designated by its 3 coordinates)
- Vec3r
- _pt; // Points corresponding to the incoming and outgoing intersections of one cell with the ray
+ Vec3r _pt; // Points corresponding to the incoming and outgoing intersections of one cell with
+ // the ray
real _t_end; // To know when we are at the end of the ray
real _t;
- //OccludersSet _ray_occluders; // Set storing the occluders contained in the cells traversed by a ray
+ // OccludersSet _ray_occluders; // Set storing the occluders contained in the cells traversed by
+ // a ray
OccludersSet _occluders; // List of all occluders inserted in the grid
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.cpp b/source/blender/freestyle/intern/geometry/GridHelpers.cpp
index 1f87bb7b76a..a83dc385758 100644
--- a/source/blender/freestyle/intern/geometry/GridHelpers.cpp
+++ b/source/blender/freestyle/intern/geometry/GridHelpers.cpp
@@ -26,14 +26,15 @@ namespace Freestyle {
void GridHelpers::getDefaultViewProscenium(real viewProscenium[4])
{
// Get proscenium boundary for culling
- // bufferZone determines the amount by which the area processed should exceed the actual image area.
- // This is intended to avoid visible artifacts generated along the proscenium edge.
- // Perhaps this is no longer needed now that entire view edges are culled at once, since that theoretically
- // should eliminate visible artifacts.
- // To the extent it is still useful, bufferZone should be put into the UI as configurable percentage value
+ // bufferZone determines the amount by which the area processed should exceed the actual image
+ // area. This is intended to avoid visible artifacts generated along the proscenium edge. Perhaps
+ // this is no longer needed now that entire view edges are culled at once, since that
+ // theoretically should eliminate visible artifacts. To the extent it is still useful, bufferZone
+ // should be put into the UI as configurable percentage value
const real bufferZone = 0.05;
// borderZone describes a blank border outside the proscenium, but still inside the image area.
- // Only intended for exposing possible artifacts along or outside the proscenium edge during debugging.
+ // Only intended for exposing possible artifacts along or outside the proscenium edge during
+ // debugging.
const real borderZone = 0.0;
viewProscenium[0] = g_freestyle.viewport[2] * (borderZone - bufferZone);
viewProscenium[1] = g_freestyle.viewport[2] * (1.0f - borderZone + bufferZone);
diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.h b/source/blender/freestyle/intern/geometry/GridHelpers.h
index 8a7503350a3..3f3c669cb57 100644
--- a/source/blender/freestyle/intern/geometry/GridHelpers.h
+++ b/source/blender/freestyle/intern/geometry/GridHelpers.h
@@ -126,8 +126,8 @@ class Transform {
inline bool insideProscenium(const real proscenium[4], const Polygon3r &polygon)
{
- // N.B. The bounding box check is redundant for inserting occluders into cells, because the cell selection code
- // in insertOccluders has already guaranteed that the bounding boxes will overlap.
+ // N.B. The bounding box check is redundant for inserting occluders into cells, because the cell
+ // selection code in insertOccluders has already guaranteed that the bounding boxes will overlap.
// First check the viewport edges, since they are the easiest case
// Check if the bounding box is entirely outside the proscenium
Vec3r bbMin, bbMax;
diff --git a/source/blender/freestyle/intern/geometry/Polygon.h b/source/blender/freestyle/intern/geometry/Polygon.h
index ad8a947d21d..739f880443c 100644
--- a/source/blender/freestyle/intern/geometry/Polygon.h
+++ b/source/blender/freestyle/intern/geometry/Polygon.h
@@ -211,8 +211,8 @@ class Polygon3r : public Polygon<Vec3r> {
real epsilon = M_EPSILON) const
{
#if 0
- if (_vertices.size() < 3)
- return false;
+ if (_vertices.size() < 3)
+ return false;
#endif
return GeomUtils::intersectRayTriangle(
orig, dir, _vertices[0], _vertices[1], _vertices[2], t, u, v, epsilon);
diff --git a/source/blender/freestyle/intern/geometry/SweepLine.h b/source/blender/freestyle/intern/geometry/SweepLine.h
index 04797bc8998..36094bf5086 100644
--- a/source/blender/freestyle/intern/geometry/SweepLine.h
+++ b/source/blender/freestyle/intern/geometry/SweepLine.h
@@ -188,8 +188,8 @@ template<class T, class Point> class Segment {
# pragma warning(pop)
#endif
-/*! defines a binary function that can be overload by the user to specify at each condition the intersection
- * between 2 edges must be computed
+/*! defines a binary function that can be overload by the user to specify at each condition the
+ * intersection between 2 edges must be computed
*/
template<class T1, class T2> struct binary_rule {
binary_rule()
@@ -226,8 +226,8 @@ template<class T, class Point> class SweepLine {
inline void process(Point &p,
vector<Segment<T, Point> *> &segments,
#if 0
- binary_rule<Segment<T, Point>,Segment<T, Point> >& binrule = \
- binary_rule<Segment<T, Point>, Segment<T, Point> >(),
+ binary_rule<Segment<T, Point>, Segment<T, Point>> &binrule =
+ binary_rule<Segment<T, Point>, Segment<T, Point>>(),
#else
binary_rule<Segment<T, Point>, Segment<T, Point>> &binrule,
#endif
@@ -249,8 +249,8 @@ template<class T, class Point> class SweepLine {
inline void add(Segment<T, Point> *S,
#if 0
- binary_rule<Segment<T, Point>, Segment<T, Point> >& binrule = \
- binary_rule<Segment<T, Point>, Segment<T, Point> >(),
+ binary_rule<Segment<T, Point>, Segment<T, Point>> &binrule =
+ binary_rule<Segment<T, Point>, Segment<T, Point>>(),
#else
binary_rule<Segment<T, Point>, Segment<T, Point>> &binrule,
#endif
diff --git a/source/blender/freestyle/intern/geometry/VecMat.h b/source/blender/freestyle/intern/geometry/VecMat.h
index 22fcd3aef41..b9cf604fed7 100644
--- a/source/blender/freestyle/intern/geometry/VecMat.h
+++ b/source/blender/freestyle/intern/geometry/VecMat.h
@@ -796,24 +796,22 @@ template<class T, unsigned N> class SquareMatrix : public Matrix<T, N, N> {
/////////////////////////////////////////////////////////////////////////////
#if 0
-template <class T, unsigned N>
-inline Vec<T, N> operator+(const Vec<T, N>& v1, const Vec<T, N>& v2)
+template<class T, unsigned N> inline Vec<T, N> operator+(const Vec<T, N> &v1, const Vec<T, N> &v2)
{
Vec<T, N> res(v1);
res += v2;
return res;
}
-template <class T, unsigned N>
-inline Vec<T, N> operator-(const Vec<T, N>& v1, const Vec<T, N>& v2)
+template<class T, unsigned N> inline Vec<T, N> operator-(const Vec<T, N> &v1, const Vec<T, N> &v2)
{
Vec<T, N> res(v1);
res -= v2;
return res;
}
-template <class T, unsigned N>
-inline Vec<T, N> operator*(const Vec<T, N>& v, const typename Vec<T, N>::value_type r)
+template<class T, unsigned N>
+inline Vec<T, N> operator*(const Vec<T, N> &v, const typename Vec<T, N>::value_type r)
{
Vec<T, N> res(v);
res *= r;
@@ -830,8 +828,8 @@ inline Vec<T, N> operator*(const typename Vec<T, N>::value_type r, const Vec<T,
}
#if 0
-template <class T, unsigned N>
-inline Vec<T, N> operator/(const Vec<T, N>& v, const typename Vec<T, N>::value_type r)
+template<class T, unsigned N>
+inline Vec<T, N> operator/(const Vec<T, N> &v, const typename Vec<T, N>::value_type r)
{
Vec<T, N> res(v);
if (r)
@@ -840,8 +838,8 @@ inline Vec<T, N> operator/(const Vec<T, N>& v, const typename Vec<T, N>::value_t
}
// dot product
-template <class T, unsigned N>
-inline typename Vec<T, N>::value_type operator*(const Vec<T, N>& v1, const Vec<T, N>& v2)
+template<class T, unsigned N>
+inline typename Vec<T, N>::value_type operator*(const Vec<T, N> &v1, const Vec<T, N> &v2)
{
typename Vec<T, N>::value_type sum = 0;
for (unsigned int i = 0; i < N; i++)
@@ -850,10 +848,10 @@ inline typename Vec<T, N>::value_type operator*(const Vec<T, N>& v1, const Vec<T
}
// cross product for 3D Vectors
-template <typename T>
-inline Vec3<T> operator^(const Vec<T, 3>& v1, const Vec<T, 3>& v2)
+template<typename T> inline Vec3<T> operator^(const Vec<T, 3> &v1, const Vec<T, 3> &v2)
{
- Vec3<T> res(v1[1] * v2[2] - v1[2] * v2[1], v1[2] * v2[0] - v1[0] * v2[2], v1[0] * v2[1] - v1[1] * v2[0]);
+ Vec3<T> res(
+ v1[1] * v2[2] - v1[2] * v2[1], v1[2] * v2[0] - v1[0] * v2[2], v1[0] * v2[1] - v1[1] * v2[0]);
return res;
}
#endif
diff --git a/source/blender/freestyle/intern/geometry/matrix_util.h b/source/blender/freestyle/intern/geometry/matrix_util.h
index 65e2fee84f3..f42e043ca97 100644
--- a/source/blender/freestyle/intern/geometry/matrix_util.h
+++ b/source/blender/freestyle/intern/geometry/matrix_util.h
@@ -41,19 +41,19 @@ namespace OGF {
namespace MatrixUtil {
/**
- * computes the eigen values and eigen vectors of a semi definite symmetric matrix
- *
- * \param mat: The matrix stored in column symmetric storage, i.e.
- * matrix = { m11, m12, m22, m13, m23, m33, m14, m24, m34, m44 ... }
- * size = n(n+1)/2
- *
- * \param eigen_vec: (return) = { v1, v2, v3, ..., vn }
- * where vk = vk0, vk1, ..., vkn
- * size = n^2, must be allocated by caller
- *
- * \param eigen_val: (return) are in decreasing order
- * size = n, must be allocated by caller
- */
+ * computes the eigen values and eigen vectors of a semi definite symmetric matrix
+ *
+ * \param mat: The matrix stored in column symmetric storage, i.e.
+ * matrix = { m11, m12, m22, m13, m23, m33, m14, m24, m34, m44 ... }
+ * size = n(n+1)/2
+ *
+ * \param eigen_vec: (return) = { v1, v2, v3, ..., vn }
+ * where vk = vk0, vk1, ..., vkn
+ * size = n^2, must be allocated by caller
+ *
+ * \param eigen_val: (return) are in decreasing order
+ * size = n, must be allocated by caller
+ */
void semi_definite_symmetric_eigen(const double *mat, int n, double *eigen_vec, double *eigen_val);
} // namespace MatrixUtil
diff --git a/source/blender/freestyle/intern/image/GaussianFilter.h b/source/blender/freestyle/intern/image/GaussianFilter.h
index 5b74e622c33..e6824fcb81e 100644
--- a/source/blender/freestyle/intern/image/GaussianFilter.h
+++ b/source/blender/freestyle/intern/image/GaussianFilter.h
@@ -46,7 +46,8 @@ class GaussianFilter {
float _sigma;
float *_mask;
int _bound;
- // the real mask size (must be odd)(the size of the mask we store is ((_maskSize+1)/2)*((_maskSize+1)/2))
+ // the real mask size (must be odd)(the size of the mask we store is
+ // ((_maskSize+1)/2)*((_maskSize+1)/2))
int _maskSize;
int _storedMaskSize; // (_maskSize+1)/2)
@@ -56,13 +57,13 @@ class GaussianFilter {
GaussianFilter &operator=(const GaussianFilter &);
virtual ~GaussianFilter();
- /*! Returns the value for pixel x,y of image "map" after a gaussian blur, made using the sigma value.
- * The sigma value determines the mask size (~ 2 x sigma).
- * \param map:
- * The image we wish to work on. The Map template must implement the following methods:
- * - float pixel(unsigned int x,unsigned int y) const;
- * - unsigned width() const;
- * - unsigned height() const;
+ /*! Returns the value for pixel x,y of image "map" after a gaussian blur, made using the sigma
+ * value. The sigma value determines the mask size (~ 2 x sigma).
+ * \param map: The image we wish to work on.
+ * The Map template must implement the following methods:
+ * - float pixel(unsigned int x,unsigned int y) const;
+ * - unsigned width() const;
+ * - unsigned height() const;
* \param x:
* The abscissa of the pixel where we want to evaluate the gaussian blur.
* \param y:
@@ -127,8 +128,8 @@ template<class Map> float GaussianFilter::getSmoothedPixel(Map *map, int x, int
{
float sum = 0.0f;
float L = 0.0f;
- int w = (int)map->width(); //soc
- int h = (int)map->height(); //soc
+ int w = (int)map->width(); // soc
+ int h = (int)map->height(); // soc
// Current pixel is x,y
// Sum surrounding pixels L value:
@@ -145,7 +146,7 @@ template<class Map> float GaussianFilter::getSmoothedPixel(Map *map, int x, int
sum += m;
}
}
- //L /= sum;
+ // L /= sum;
return L;
}
diff --git a/source/blender/freestyle/intern/image/Image.h b/source/blender/freestyle/intern/image/Image.h
index 344766bfa63..b854e411a83 100644
--- a/source/blender/freestyle/intern/image/Image.h
+++ b/source/blender/freestyle/intern/image/Image.h
@@ -35,9 +35,10 @@ namespace Freestyle {
//
///////////////////////////////////////////////////////////////////////////////
-/*! This class allows the storing of part of an image, while allowing a normal access to its pixel values.
- * You can for example only a rectangle of sw*sh, whose lower-left corner is at (ox, oy), of an image of
- * size w*h, and access these pixels using x,y coordinates specified in the whole image coordinate system.
+/*! This class allows the storing of part of an image, while allowing a normal access to its pixel
+ * values. You can for example only a rectangle of sw*sh, whose lower-left corner is at (ox, oy),
+ * of an image of size w*h, and access these pixels using x,y coordinates specified in the whole
+ * image coordinate system.
*/
class FrsImage {
public:
@@ -209,7 +210,8 @@ class RGBImage : public FrsImage {
/*! Builds an RGB partial image from the useful part buffer.
* \param rgb:
* The array of size 3*sw*sh containing the RGB values of the sw*sh pixels we need to stored.
- * These sw*sh pixels constitute a rectangular part of a bigger RGB image containing w*h pixels.
+ * These sw*sh pixels constitute a rectangular part of a bigger
+ * RGB image containing w*h pixels.
* \param w:
* The width of the complete image
* \param h:
@@ -346,7 +348,8 @@ class GrayImage : public FrsImage {
/*! Builds a partial image from the useful part buffer.
* \param lvl:
* The array of size sw*sh containing the gray values of the sw*sh pixels we need to stored.
- * These sw*sh pixels constitute a rectangular part of a bigger gray image containing w*h pixels.
+ * These sw*sh pixels constitute a rectangular part of a bigger
+ * gray image containing w*h pixels.
* \param w:
* The width of the complete image
* \param h:
diff --git a/source/blender/freestyle/intern/image/ImagePyramid.cpp b/source/blender/freestyle/intern/image/ImagePyramid.cpp
index caf469328b5..e5b4053fbf4 100644
--- a/source/blender/freestyle/intern/image/ImagePyramid.cpp
+++ b/source/blender/freestyle/intern/image/ImagePyramid.cpp
@@ -30,9 +30,9 @@ using namespace std;
namespace Freestyle {
#if 0
-ImagePyramid::ImagePyramid(const GrayImage& level0, unsigned nbLevels)
+ImagePyramid::ImagePyramid(const GrayImage &level0, unsigned nbLevels)
{
- BuildPyramid(level0,nbLevels);
+ BuildPyramid(level0, nbLevels);
}
#endif
@@ -153,7 +153,7 @@ void GaussianPyramid::BuildPyramid(GrayImage *level0, unsigned nbLevels)
unsigned w = pLevel->width();
unsigned h = pLevel->height();
if (nbLevels != 0) {
- for (unsigned int i = 0; i < nbLevels; ++i) { //soc
+ for (unsigned int i = 0; i < nbLevels; ++i) { // soc
w = pLevel->width() >> 1;
h = pLevel->height() >> 1;
GrayImage *img = new GrayImage(w, h);
diff --git a/source/blender/freestyle/intern/image/ImagePyramid.h b/source/blender/freestyle/intern/image/ImagePyramid.h
index 0e388fdf20c..8c6a8bcdff4 100644
--- a/source/blender/freestyle/intern/image/ImagePyramid.h
+++ b/source/blender/freestyle/intern/image/ImagePyramid.h
@@ -43,7 +43,7 @@ class ImagePyramid {
{
}
ImagePyramid(const ImagePyramid &iBrother);
- //ImagePyramid(const GrayImage& level0, unsigned nbLevels);
+ // ImagePyramid(const GrayImage& level0, unsigned nbLevels);
virtual ~ImagePyramid();
/*! Builds the pyramid.
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
index 2068fe820d0..2169ee18166 100644
--- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
+++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
@@ -31,7 +31,7 @@ extern "C" {
//------------------------INSTANCE METHODS ----------------------------------
-//ViewMapGradientNormBP1D(int level, IntegrationType iType=MEAN, float sampling=2.0)
+// ViewMapGradientNormBP1D(int level, IntegrationType iType=MEAN, float sampling=2.0)
static char ViewMapGradientNormBP1D___doc__[] =
"Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > "
@@ -82,7 +82,7 @@ static int ViewMapGradientNormBP1D___init__(BPy_ViewMapGradientNormBP1D *self,
return 0;
}
-/*-----------------------BPy_ViewMapGradientNormBP1D type definition ------------------------------*/
+/*-----------------------BPy_ViewMapGradientNormBP1D type definition ----------------------------*/
PyTypeObject ViewMapGradientNormBP1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ViewMapGradientNormBP1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
index e685491f682..8a5bb0b17ff 100644
--- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp
@@ -136,7 +136,7 @@ static int CurvePoint_init(BPy_CurvePoint *self, PyObject *args, PyObject *kwds)
return 0;
}
-///bool operator== (const CurvePoint &b)
+/// bool operator== (const CurvePoint &b)
/*----------------------CurvePoint get/setters ----------------------------*/
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
index f25435b421c..189d41e78a3 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp
@@ -161,7 +161,7 @@ static void ChainPredicateIterator_dealloc(BPy_ChainPredicateIterator *self)
ChainingIterator_Type.tp_dealloc((PyObject *)self);
}
-/*-----------------------BPy_ChainPredicateIterator type definition ------------------------------*/
+/*-----------------------BPy_ChainPredicateIterator type definition ----------------------------*/
PyTypeObject ChainPredicateIterator_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ChainPredicateIterator", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
index 6a4af0f8053..d72e830e293 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp
@@ -31,8 +31,8 @@ extern "C" {
//------------------------INSTANCE METHODS ----------------------------------
-// ChainSilhouetteIterator (bool restrict_to_selection=true, ViewEdge *begin=NULL, bool orientation=true)
-// ChainSilhouetteIterator (const ChainSilhouetteIterator &brother)
+// ChainSilhouetteIterator (bool restrict_to_selection=true, ViewEdge *begin=NULL, bool
+// orientation=true) ChainSilhouetteIterator (const ChainSilhouetteIterator &brother)
PyDoc_STRVAR(ChainSilhouetteIterator_doc,
"Class hierarchy: :class:`freestyle.types.Iterator` >\n"
@@ -117,7 +117,7 @@ static int ChainSilhouetteIterator_init(BPy_ChainSilhouetteIterator *self,
return 0;
}
-/*-----------------------BPy_ChainSilhouetteIterator type definition ------------------------------*/
+/*-----------------------BPy_ChainSilhouetteIterator type definition ----------------------------*/
PyTypeObject ChainSilhouetteIterator_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ChainSilhouetteIterator", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
index 3cb114a0037..21e3e821214 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
@@ -137,7 +137,7 @@ static PyGetSetDef BPy_orientedViewEdgeIterator_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-/*-----------------------BPy_orientedViewEdgeIterator type definition ------------------------------*/
+/*-----------------------BPy_orientedViewEdgeIterator type definition ---------------------------*/
PyTypeObject orientedViewEdgeIterator_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "orientedViewEdgeIterator", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
index 7ee1372aa22..9a37acbd788 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
@@ -63,7 +63,7 @@ static int BackboneStretcherShader___init__(BPy_BackboneStretcherShader *self,
return 0;
}
-/*-----------------------BPy_BackboneStretcherShader type definition ------------------------------*/
+/*-----------------------BPy_BackboneStretcherShader type definition ----------------------------*/
PyTypeObject BackboneStretcherShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "BackboneStretcherShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
index 8acb1215980..35a94a1620d 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.h
@@ -31,7 +31,8 @@ extern "C" {
extern PyTypeObject CalligraphicShader_Type;
-#define BPy_CalligraphicShader_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&CalligraphicShader_Type)
+#define BPy_CalligraphicShader_Check(v) \
+ (PyObject_IsInstance((PyObject *)v, (PyObject *)&CalligraphicShader_Type)
/*---------------------------Python BPy_CalligraphicShader structure definition----------*/
typedef struct {
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
index c226cc0df25..5177d275a10 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
@@ -62,7 +62,7 @@ static int ConstantThicknessShader___init__(BPy_ConstantThicknessShader *self,
return 0;
}
-/*-----------------------BPy_ConstantThicknessShader type definition ------------------------------*/
+/*-----------------------BPy_ConstantThicknessShader type definition ----------------------------*/
PyTypeObject ConstantThicknessShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ConstantThicknessShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
index 22a67c65df8..4afe148c066 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
@@ -68,7 +68,7 @@ static int ConstrainedIncreasingThicknessShader___init__(
return 0;
}
-/*-----------------------BPy_ConstrainedIncreasingThicknessShader type definition ------------------------------*/
+/*-----------------------BPy_ConstrainedIncreasingThicknessShader type definition ---------------*/
PyTypeObject ConstrainedIncreasingThicknessShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ConstrainedIncreasingThicknessShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
index 907355ea69c..04912499c04 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.h
@@ -34,7 +34,8 @@ extern PyTypeObject ConstrainedIncreasingThicknessShader_Type;
#define BPy_ConstrainedIncreasingThicknessShader_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&ConstrainedIncreasingThicknessShader_Type))
-/*---------------------------Python BPy_ConstrainedIncreasingThicknessShader structure definition----------*/
+/*---------------------------Python BPy_ConstrainedIncreasingThicknessShader structure
+ * definition----------*/
typedef struct {
BPy_StrokeShader py_ss;
} BPy_ConstrainedIncreasingThicknessShader;
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
index bc0bc5bd721..57d8f3201b1 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
@@ -70,15 +70,17 @@ static int IncreasingColorShader___init__(BPy_IncreasingColorShader *self,
PyObject *args,
PyObject *kwds)
{
- static const char *kwlist[] = {"red_min",
- "green_min",
- "blue_min",
- "alpha_min",
- "red_max",
- "green_max",
- "blue_max",
- "alpha_max",
- NULL};
+ static const char *kwlist[] = {
+ "red_min",
+ "green_min",
+ "blue_min",
+ "alpha_min",
+ "red_max",
+ "green_max",
+ "blue_max",
+ "alpha_max",
+ NULL,
+ };
float f1, f2, f3, f4, f5, f6, f7, f8;
if (!PyArg_ParseTupleAndKeywords(
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
index 324f1c1a40b..b791fc598df 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
@@ -68,7 +68,7 @@ static int IncreasingThicknessShader___init__(BPy_IncreasingThicknessShader *sel
return 0;
}
-/*-----------------------BPy_IncreasingThicknessShader type definition ------------------------------*/
+/*-----------------------BPy_IncreasingThicknessShader type definition --------------------------*/
PyTypeObject IncreasingThicknessShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "IncreasingThicknessShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
index 273e41a7b9f..7eb20d47539 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
@@ -69,7 +69,7 @@ static int PolygonalizationShader___init__(BPy_PolygonalizationShader *self,
return 0;
}
-/*-----------------------BPy_PolygonalizationShader type definition ------------------------------*/
+/*-----------------------BPy_PolygonalizationShader type definition -----------------------------*/
PyTypeObject PolygonalizationShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "PolygonalizationShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
index 72d5799412f..51a0c670d75 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
@@ -71,15 +71,17 @@ static char SmoothingShader___doc__[] =
static int SmoothingShader___init__(BPy_SmoothingShader *self, PyObject *args, PyObject *kwds)
{
- static const char *kwlist[] = {"num_iterations",
- "factor_point",
- "factor_curvature",
- "factor_curvature_difference",
- "aniso_point",
- "aniso_normal",
- "aniso_curvature",
- "carricature_factor",
- NULL};
+ static const char *kwlist[] = {
+ "num_iterations",
+ "factor_point",
+ "factor_curvature",
+ "factor_curvature_difference",
+ "aniso_point",
+ "aniso_normal",
+ "aniso_curvature",
+ "carricature_factor",
+ NULL,
+ };
int i1 = 100;
double d2 = 0.1, d3 = 0.0, d4 = 0.2, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 1.0;
diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
index 3d76d71bab6..e8183b41d05 100644
--- a/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
+++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureStepShader.cpp
@@ -62,7 +62,7 @@ static int StrokeTextureStepShader___init__(BPy_StrokeTextureStepShader *self,
return 0;
}
-/*-----------------------BPy_StrokeTextureStepShader type definition ------------------------------*/
+/*-----------------------BPy_StrokeTextureStepShader type definition ----------------------------*/
PyTypeObject StrokeTextureStepShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "StrokeTextureStepShader", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
index 76dbe2ef023..f6292f0086a 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp
@@ -115,7 +115,7 @@ static PyObject *UnaryFunction0DEdgeNature___call__(BPy_UnaryFunction0DEdgeNatur
return BPy_Nature_from_Nature(self->uf0D_edgenature->result);
}
-/*-----------------------BPy_UnaryFunction0DEdgeNature type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DEdgeNature type definition --------------------------*/
PyTypeObject UnaryFunction0DEdgeNature_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DEdgeNature", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
index a375ac506f0..63f9ff0deb8 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp
@@ -114,7 +114,7 @@ static PyObject *UnaryFunction0DMaterial___call__(BPy_UnaryFunction0DMaterial *s
return BPy_FrsMaterial_from_FrsMaterial(self->uf0D_material->result);
}
-/*-----------------------BPy_UnaryFunction0DMaterial type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DMaterial type definition ----------------------------*/
PyTypeObject UnaryFunction0DMaterial_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DMaterial", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
index 756e5cde3ce..65d8d630fce 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp
@@ -115,7 +115,7 @@ static PyObject *UnaryFunction0DUnsigned___call__(BPy_UnaryFunction0DUnsigned *s
return PyLong_FromLong(self->uf0D_unsigned->result);
}
-/*-----------------------BPy_UnaryFunction0DUnsigned type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DUnsigned type definition ----------------------------*/
PyTypeObject UnaryFunction0DUnsigned_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DUnsigned", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
index 039727f4fab..d908b3fa6ed 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
@@ -124,7 +124,7 @@ static PyObject *UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVect
return list;
}
-/*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ---------------------*/
PyTypeObject UnaryFunction0DVectorViewShape_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DVectorViewShape", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
index 22cf50ce5a2..586f7ec40e5 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.h
@@ -37,13 +37,15 @@ extern PyTypeObject UnaryFunction0DVectorViewShape_Type;
#define BPy_UnaryFunction0DVectorViewShape_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction0DVectorViewShape_Type))
-/*---------------------------Python BPy_UnaryFunction0DVectorViewShape structure definition----------*/
+/*---------------------------Python BPy_UnaryFunction0DVectorViewShape structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction0D py_uf0D;
UnaryFunction0D<std::vector<ViewShape *>> *uf0D_vectorviewshape;
} BPy_UnaryFunction0DVectorViewShape;
-/*---------------------------Python BPy_UnaryFunction0DVectorViewShape visible prototypes-----------*/
+/*---------------------------Python BPy_UnaryFunction0DVectorViewShape visible
+ * prototypes-----------*/
int UnaryFunction0DVectorViewShape_Init(PyObject *module);
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
index 1df3be084c0..8c04d8eabaa 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp
@@ -121,7 +121,7 @@ static PyObject *UnaryFunction0DViewShape___call__(BPy_UnaryFunction0DViewShape
return BPy_ViewShape_from_ViewShape(*(self->uf0D_viewshape->result));
}
-/*-----------------------BPy_UnaryFunction0DViewShape type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction0DViewShape type definition ---------------------------*/
PyTypeObject UnaryFunction0DViewShape_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction0DViewShape", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
index 623ec4db50e..ec3755987d1 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.cpp
@@ -64,7 +64,7 @@ static int VertexOrientation2DF0D___init__(BPy_VertexOrientation2DF0D *self,
return 0;
}
-/*-----------------------BPy_VertexOrientation2DF0D type definition ------------------------------*/
+/*-----------------------BPy_VertexOrientation2DF0D type definition -----------------------------*/
PyTypeObject VertexOrientation2DF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "VertexOrientation2DF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
index 6ed52014719..d5e073b5802 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_Vec3f/BPy_VertexOrientation3DF0D.cpp
@@ -64,7 +64,7 @@ static int VertexOrientation3DF0D___init__(BPy_VertexOrientation3DF0D *self,
return 0;
}
-/*-----------------------BPy_VertexOrientation3DF0D type definition ------------------------------*/
+/*-----------------------BPy_VertexOrientation3DF0D type definition -----------------------------*/
PyTypeObject VertexOrientation3DF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "VertexOrientation3DF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
index ce8852a2b6c..2db536d2a90 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetCurvilinearAbscissaF0D.cpp
@@ -62,7 +62,7 @@ static int GetCurvilinearAbscissaF0D___init__(BPy_GetCurvilinearAbscissaF0D *sel
return 0;
}
-/*-----------------------BPy_GetCurvilinearAbscissaF0D type definition ------------------------------*/
+/*-----------------------BPy_GetCurvilinearAbscissaF0D type definition --------------------------*/
PyTypeObject GetCurvilinearAbscissaF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetCurvilinearAbscissaF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
index 3cf5efc59d7..21e05323b07 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_GetViewMapGradientNormF0D.cpp
@@ -67,7 +67,7 @@ static int GetViewMapGradientNormF0D___init__(BPy_GetViewMapGradientNormF0D *sel
return 0;
}
-/*-----------------------BPy_GetViewMapGradientNormF0D type definition ------------------------------*/
+/*-----------------------BPy_GetViewMapGradientNormF0D type definition --------------------------*/
PyTypeObject GetViewMapGradientNormF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetViewMapGradientNormF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
index a70cf817b46..506aa15e245 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.cpp
@@ -65,7 +65,7 @@ static int ReadCompleteViewMapPixelF0D___init__(BPy_ReadCompleteViewMapPixelF0D
return 0;
}
-/*-----------------------BPy_ReadCompleteViewMapPixelF0D type definition ------------------------------*/
+/*-----------------------BPy_ReadCompleteViewMapPixelF0D type definition ------------------------*/
PyTypeObject ReadCompleteViewMapPixelF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ReadCompleteViewMapPixelF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
index 6ccfd9764c5..48d36543ca0 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadCompleteViewMapPixelF0D.h
@@ -34,7 +34,8 @@ extern PyTypeObject ReadCompleteViewMapPixelF0D_Type;
#define BPy_ReadCompleteViewMapPixelF0D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&ReadCompleteViewMapPixelF0D_Type))
-/*---------------------------Python BPy_ReadCompleteViewMapPixelF0D structure definition----------*/
+/*---------------------------Python BPy_ReadCompleteViewMapPixelF0D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction0DFloat py_uf0D_float;
} BPy_ReadCompleteViewMapPixelF0D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
index 3dec389f1f1..0eee141f15f 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.cpp
@@ -69,7 +69,7 @@ static int ReadSteerableViewMapPixelF0D___init__(BPy_ReadSteerableViewMapPixelF0
return 0;
}
-/*-----------------------BPy_ReadSteerableViewMapPixelF0D type definition ------------------------------*/
+/*-----------------------BPy_ReadSteerableViewMapPixelF0D type definition -----------------------*/
PyTypeObject ReadSteerableViewMapPixelF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ReadSteerableViewMapPixelF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
index c0c62a50941..3cff99be633 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_float/BPy_ReadSteerableViewMapPixelF0D.h
@@ -34,7 +34,8 @@ extern PyTypeObject ReadSteerableViewMapPixelF0D_Type;
#define BPy_ReadSteerableViewMapPixelF0D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&ReadSteerableViewMapPixelF0D_Type))
-/*---------------------------Python BPy_ReadSteerableViewMapPixelF0D structure definition----------*/
+/*---------------------------Python BPy_ReadSteerableViewMapPixelF0D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction0DFloat py_uf0D_float;
} BPy_ReadSteerableViewMapPixelF0D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
index f35f6ad7814..0b6a116fa65 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.cpp
@@ -67,7 +67,7 @@ static int QuantitativeInvisibilityF0D___init__(BPy_QuantitativeInvisibilityF0D
return 0;
}
-/*-----------------------BPy_QuantitativeInvisibilityF0D type definition ------------------------------*/
+/*-----------------------BPy_QuantitativeInvisibilityF0D type definition ------------------------*/
PyTypeObject QuantitativeInvisibilityF0D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "QuantitativeInvisibilityF0D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
index 933deb706ee..dd64fb40d85 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction0D/UnaryFunction0D_unsigned_int/BPy_QuantitativeInvisibilityF0D.h
@@ -34,7 +34,8 @@ extern PyTypeObject QuantitativeInvisibilityF0D_Type;
#define BPy_QuantitativeInvisibilityF0D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&QuantitativeInvisibilityF0D_Type))
-/*---------------------------Python BPy_QuantitativeInvisibilityF0D structure definition----------*/
+/*---------------------------Python BPy_QuantitativeInvisibilityF0D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction0DUnsigned py_uf0D_unsigned;
} BPy_QuantitativeInvisibilityF0D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
index 2bcda9718c3..262fdbc68c6 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
@@ -166,7 +166,7 @@ static PyGetSetDef BPy_UnaryFunction1DEdgeNature_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-/*-----------------------BPy_UnaryFunction1DEdgeNature type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction1DEdgeNature type definition --------------------------*/
PyTypeObject UnaryFunction1DEdgeNature_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DEdgeNature", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
index a28448314cd..37d37db51e4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
@@ -166,7 +166,7 @@ static PyGetSetDef BPy_UnaryFunction1DUnsigned_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-/*-----------------------BPy_UnaryFunction1DUnsigned type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction1DUnsigned type definition ----------------------------*/
PyTypeObject UnaryFunction1DUnsigned_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DUnsigned", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
index f7a80a270b6..eb4974e64fe 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
@@ -190,7 +190,7 @@ static PyGetSetDef BPy_UnaryFunction1DVectorViewShape_getseters[] = {
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-/*-----------------------BPy_UnaryFunction1DVectorViewShape type definition ------------------------------*/
+/*-----------------------BPy_UnaryFunction1DVectorViewShape type definition ---------------------*/
PyTypeObject UnaryFunction1DVectorViewShape_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "UnaryFunction1DVectorViewShape", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
index 92889ddbfd9..2869b364ea6 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.h
@@ -37,13 +37,15 @@ extern PyTypeObject UnaryFunction1DVectorViewShape_Type;
#define BPy_UnaryFunction1DVectorViewShape_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&UnaryFunction1DVectorViewShape_Type))
-/*---------------------------Python BPy_UnaryFunction1DVectorViewShape structure definition----------*/
+/*---------------------------Python BPy_UnaryFunction1DVectorViewShape structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1D py_uf1D;
UnaryFunction1D<std::vector<ViewShape *>> *uf1D_vectorviewshape;
} BPy_UnaryFunction1DVectorViewShape;
-/*---------------------------Python BPy_UnaryFunction1DVectorViewShape visible prototypes-----------*/
+/*---------------------------Python BPy_UnaryFunction1DVectorViewShape visible
+ * prototypes-----------*/
int UnaryFunction1DVectorViewShape_Init(PyObject *module);
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
index 419ea1f54a9..4b2f444f719 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
@@ -84,7 +84,7 @@ static int GetCompleteViewMapDensityF1D___init__(BPy_GetCompleteViewMapDensityF1
return 0;
}
-/*-----------------------BPy_GetCompleteViewMapDensityF1D type definition ------------------------------*/
+/*-----------------------BPy_GetCompleteViewMapDensityF1D type definition -----------------------*/
PyTypeObject GetCompleteViewMapDensityF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetCompleteViewMapDensityF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
index c0a78e89551..dacfb33553e 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject GetCompleteViewMapDensityF1D_Type;
#define BPy_GetCompleteViewMapDensityF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&GetCompleteViewMapDensityF1D_Type))
-/*---------------------------Python BPy_GetCompleteViewMapDensityF1D structure definition----------*/
+/*---------------------------Python BPy_GetCompleteViewMapDensityF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DDouble py_uf1D_double;
} BPy_GetCompleteViewMapDensityF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
index 58290f6b45f..8b31c31a4a4 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
@@ -91,7 +91,7 @@ static int GetDirectionalViewMapDensityF1D___init__(BPy_GetDirectionalViewMapDen
return 0;
}
-/*-----------------------BPy_GetDirectionalViewMapDensityF1D type definition ------------------------------*/
+/*-----------------------BPy_GetDirectionalViewMapDensityF1D type definition --------------------*/
PyTypeObject GetDirectionalViewMapDensityF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetDirectionalViewMapDensityF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
index d78ffe84381..b039fadcdca 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject GetDirectionalViewMapDensityF1D_Type;
#define BPy_GetDirectionalViewMapDensityF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&GetDirectionalViewMapDensityF1D_Type))
-/*---------------------------Python BPy_GetDirectionalViewMapDensityF1D structure definition----------*/
+/*---------------------------Python BPy_GetDirectionalViewMapDensityF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DDouble py_uf1D_double;
} BPy_GetDirectionalViewMapDensityF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
index a112dee15c7..615faed2282 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
@@ -81,7 +81,7 @@ static int GetSteerableViewMapDensityF1D___init__(BPy_GetSteerableViewMapDensity
return 0;
}
-/*-----------------------BPy_GetSteerableViewMapDensityF1D type definition ------------------------------*/
+/*-----------------------BPy_GetSteerableViewMapDensityF1D type definition ----------------------*/
PyTypeObject GetSteerableViewMapDensityF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetSteerableViewMapDensityF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
index c4881a79649..47f168af2a8 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.h
@@ -33,7 +33,8 @@ extern PyTypeObject GetSteerableViewMapDensityF1D_Type;
#define BPy_GetSteerableViewMapDensityF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&GetSteerableViewMapDensityF1D_Type))
-/*---------------------------Python BPy_GetSteerableViewMapDensityF1D structure definition----------*/
+/*---------------------------Python BPy_GetSteerableViewMapDensityF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DDouble py_uf1D_double;
} BPy_GetSteerableViewMapDensityF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
index b2bb2947be7..7e77e79af63 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
@@ -81,7 +81,7 @@ static int GetViewMapGradientNormF1D___init__(BPy_GetViewMapGradientNormF1D *sel
return 0;
}
-/*-----------------------BPy_GetViewMapGradientNormF1D type definition ------------------------------*/
+/*-----------------------BPy_GetViewMapGradientNormF1D type definition --------------------------*/
PyTypeObject GetViewMapGradientNormF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "GetViewMapGradientNormF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
index f955c90842a..bce95e50048 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp
@@ -72,7 +72,7 @@ static int QuantitativeInvisibilityF1D___init__(BPy_QuantitativeInvisibilityF1D
return 0;
}
-/*-----------------------BPy_QuantitativeInvisibilityF1D type definition ------------------------------*/
+/*-----------------------BPy_QuantitativeInvisibilityF1D type definition ------------------------*/
PyTypeObject QuantitativeInvisibilityF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "QuantitativeInvisibilityF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
index 35cd9e779bd..0d4d118995b 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject QuantitativeInvisibilityF1D_Type;
#define BPy_QuantitativeInvisibilityF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&QuantitativeInvisibilityF1D_Type))
-/*---------------------------Python BPy_QuantitativeInvisibilityF1D structure definition----------*/
+/*---------------------------Python BPy_QuantitativeInvisibilityF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DUnsigned py_uf1D_unsigned;
} BPy_QuantitativeInvisibilityF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
index 3aa694a5739..04d724b7862 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.cpp
@@ -59,7 +59,7 @@ static int IncrementChainingTimeStampF1D___init__(BPy_IncrementChainingTimeStamp
return 0;
}
-/*-----------------------BPy_IncrementChainingTimeStampF1D type definition ------------------------------*/
+/*-----------------------BPy_IncrementChainingTimeStampF1D type definition ----------------------*/
PyTypeObject IncrementChainingTimeStampF1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "IncrementChainingTimeStampF1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
index 3030528a49b..0d74b1f7756 100644
--- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
+++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_void/BPy_IncrementChainingTimeStampF1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject IncrementChainingTimeStampF1D_Type;
#define BPy_IncrementChainingTimeStampF1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&IncrementChainingTimeStampF1D_Type))
-/*---------------------------Python BPy_IncrementChainingTimeStampF1D structure definition----------*/
+/*---------------------------Python BPy_IncrementChainingTimeStampF1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryFunction1DVoid py_uf1D_void;
} BPy_IncrementChainingTimeStampF1D;
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
index f3b6a71585f..fb42b29f9ee 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
@@ -62,7 +62,7 @@ static int EqualToChainingTimeStampUP1D___init__(BPy_EqualToChainingTimeStampUP1
return 0;
}
-/*-----------------------BPy_EqualToChainingTimeStampUP1D type definition ------------------------------*/
+/*-----------------------BPy_EqualToChainingTimeStampUP1D type definition -----------------------*/
PyTypeObject EqualToChainingTimeStampUP1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "EqualToChainingTimeStampUP1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
index eab08c6588d..e2ba8b7709b 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject EqualToChainingTimeStampUP1D_Type;
#define BPy_EqualToChainingTimeStampUP1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&EqualToChainingTimeStampUP1D_Type))
-/*---------------------------Python BPy_EqualToChainingTimeStampUP1D structure definition----------*/
+/*---------------------------Python BPy_EqualToChainingTimeStampUP1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryPredicate1D py_up1D;
} BPy_EqualToChainingTimeStampUP1D;
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
index 885ecb16695..907a86477e3 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
@@ -66,7 +66,7 @@ static int QuantitativeInvisibilityUP1D___init__(BPy_QuantitativeInvisibilityUP1
return 0;
}
-/*-----------------------BPy_QuantitativeInvisibilityUP1D type definition ------------------------------*/
+/*-----------------------BPy_QuantitativeInvisibilityUP1D type definition -----------------------*/
PyTypeObject QuantitativeInvisibilityUP1D_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "QuantitativeInvisibilityUP1D", /* tp_name */
diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
index 879c6c5b7be..bbb1dce5ed1 100644
--- a/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
+++ b/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.h
@@ -34,7 +34,8 @@ extern PyTypeObject QuantitativeInvisibilityUP1D_Type;
#define BPy_QuantitativeInvisibilityUP1D_Check(v) \
(PyObject_IsInstance((PyObject *)v, (PyObject *)&QuantitativeInvisibilityUP1D_Type))
-/*---------------------------Python BPy_QuantitativeInvisibilityUP1D structure definition----------*/
+/*---------------------------Python BPy_QuantitativeInvisibilityUP1D structure
+ * definition----------*/
typedef struct {
BPy_UnaryPredicate1D py_up1D;
} BPy_QuantitativeInvisibilityUP1D;
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
index 83672199e37..2a38e6ffcc6 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
@@ -99,13 +99,11 @@ class IndexedFaceSet : public Rep {
* iMISize
* The size of iMIndices
* iTIndices
- * The Texture coordinates indices (per vertex). The integers contained in this array must be multiple of 2.
- * iTISize
- * The size of iMIndices
- * iCopy
- * 0 : the arrays are not copied. The pointers passed as arguments are used. IndexedFaceSet takes these
- * arrays desallocation in charge.
- * 1 : the arrays are copied. The caller is in charge of the arrays, passed as arguments desallocation.
+ * The Texture coordinates indices (per vertex). The integers contained in this array must
+ * be multiple of 2. iTISize The size of iMIndices iCopy 0 : the arrays are not copied. The
+ * pointers passed as arguments are used. IndexedFaceSet takes these arrays desallocation in
+ * charge. 1 : the arrays are copied. The caller is in charge of the arrays, passed as arguments
+ * desallocation.
*/
IndexedFaceSet(float *iVertices,
unsigned iVSize,
diff --git a/source/blender/freestyle/intern/scene_graph/Node.h b/source/blender/freestyle/intern/scene_graph/Node.h
index a9424fe14d2..2e0e94ed5de 100644
--- a/source/blender/freestyle/intern/scene_graph/Node.h
+++ b/source/blender/freestyle/intern/scene_graph/Node.h
@@ -19,7 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Abstract class for scene graph nodes. Inherits from BaseObject which defines the addRef release mechanism.
+ * \brief Abstract class for scene graph nodes. Inherits from BaseObject which defines the addRef
+ * release mechanism.
*/
#include "SceneVisitor.h"
diff --git a/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp b/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp
index 30d05ee571c..ae87b77aee7 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp
@@ -48,7 +48,7 @@ NodeCamera::NodeCamera(CameraType camera_type) : camera_type_(camera_type)
}
#if 0 /* UNUSED, gives warning in gcc */
-NodeCamera::NodeCamera(const NodeCamera& iBrother) : camera_type_(iBrother.camera_type_)
+NodeCamera::NodeCamera(const NodeCamera &iBrother) : camera_type_(iBrother.camera_type_)
{
memcpy(modelview_matrix_, iBrother.modelview_matrix_, 16 * sizeof(double));
memcpy(projection_matrix_, iBrother.projection_matrix_, 16 * sizeof(double));
diff --git a/source/blender/freestyle/intern/scene_graph/NodeCamera.h b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
index c3c93fa1f88..2878e7a834e 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeCamera.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
@@ -47,7 +47,7 @@ class NodeCamera : public Node {
/*! Default matrices: Identity for both projection and modelview. */
NodeCamera(CameraType camera_type = GENERIC);
#if 0 /* UNUSED, gives warning in gcc */
- NodeCamera(const NodeCamera& iBrother);
+ NodeCamera(const NodeCamera &iBrother);
#endif
virtual ~NodeCamera()
diff --git a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp
index 2564a462407..75acccef666 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp
@@ -16,7 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from NodeGroup.
+ * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from
+ * NodeGroup.
*/
#include "NodeDrawingStyle.h"
diff --git a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
index ea617a912f6..f1dfad06250 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
@@ -19,7 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from NodeGroup.
+ * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from
+ * NodeGroup.
*/
#include "DrawingStyle.h"
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
index 204e5e1c60e..7ea495c4166 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
@@ -17,7 +17,8 @@
/** \file
* \ingroup freestyle
* \brief Class to represent a group node. This node can contains several children.
- * \brief It also contains a transform matrix indicating the transform state of the underlying children.
+ * \brief It also contains a transform matrix indicating the transform state of the underlying
+ * children.
*/
#include "NodeGroup.h"
@@ -36,10 +37,9 @@ void NodeGroup::AddChild(Node *iChild)
int NodeGroup::destroy()
{
/*! Node::destroy makes a release on the object and then returns the reference counter.
- * If the reference counter is equal to 0, that means that nobody else is linking this node group and
- * that we can destroy the whole underlying tree.
- * Else, one or several Node link this node group, and we only returns the reference counter
- * decremented by Node::destroy();
+ * If the reference counter is equal to 0, that means that nobody else is linking this node
+ * group and that we can destroy the whole underlying tree. Else, one or several Node link this
+ * node group, and we only returns the reference counter decremented by Node::destroy();
*/
int refThis = Node::destroy();
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.h b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
index 89f81cc2b13..f40deb13a3e 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeGroup.h
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
@@ -20,7 +20,8 @@
/** \file
* \ingroup freestyle
* \brief Class to represent a group node. This node can contains several children.
- * \brief It also contains a transform matrix indicating the transform state of the underlying children.
+ * \brief It also contains a transform matrix indicating the transform state of the underlying
+ * children.
*/
#include <vector>
diff --git a/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp b/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
index 69179eb6c84..5452c233e2c 100644
--- a/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
+++ b/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
@@ -35,7 +35,7 @@ void NodeTransform::Translate(real x, real y, real z)
void NodeTransform::Rotate(real iAngle, real x, real y, real z)
{
- //Normalize the x,y,z vector;
+ // Normalize the x,y,z vector;
real norm = (real)sqrt(x * x + y * y + z * z);
if (0 == norm)
return;
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.cpp b/source/blender/freestyle/intern/scene_graph/Rep.cpp
index 94f6e1fa9d3..5b49243faef 100644
--- a/source/blender/freestyle/intern/scene_graph/Rep.cpp
+++ b/source/blender/freestyle/intern/scene_graph/Rep.cpp
@@ -16,7 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Base class for all shapes. Inherits from BasicObjects for references counter management (addRef, release).
+ * \brief Base class for all shapes. Inherits from BasicObjects for references counter management
+ * (addRef, release).
*/
#include "Rep.h"
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.h b/source/blender/freestyle/intern/scene_graph/Rep.h
index 7b5e752ea07..22078422af6 100644
--- a/source/blender/freestyle/intern/scene_graph/Rep.h
+++ b/source/blender/freestyle/intern/scene_graph/Rep.h
@@ -19,7 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Base class for all shapes. Inherits from BasicObjects for references counter management (addRef, release).
+ * \brief Base class for all shapes.
+ * Inherits from BasicObjects for references counter management (addRef, release).
*/
#include <string>
@@ -111,8 +112,8 @@ class Rep : public BaseObject {
}
/*! Computes the rep bounding box.
- * Each Inherited rep must compute its bbox depending on the way the data are stored. So, each inherited class
- * must overload this method
+ * Each Inherited rep must compute its bbox depending on the way the data are stored. So, each
+ * inherited class must overload this method
*/
virtual void ComputeBBox() = 0;
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
index 24c710bd163..dcab48fd12f 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.h
@@ -38,15 +38,15 @@ namespace Functions0D {
// DensityF0D
/*! Returns the density of the (result) image evaluated at an Interface0D.
- * This density is evaluated using a pixels square window around the evaluation point and integrating
- * these values using a gaussian.
+ * This density is evaluated using a pixels square window around the evaluation point and
+ * integrating these values using a gaussian.
*/
class DensityF0D : public UnaryFunction0D<double> {
public:
/*! Builds the functor from the gaussian sigma value.
* \param sigma:
- * sigma indicates the x value for which the gaussian function is 0.5. It leads to the window size value.
- * (the larger, the smoother)
+ * sigma indicates the x value for which the gaussian function is 0.5.
+ * It leads to the window size value. (the larger, the smoother)
*/
DensityF0D(double sigma = 2) : UnaryFunction0D<double>()
{
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
index eadc8993dc6..fd97138c91b 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.cpp
@@ -104,14 +104,14 @@ int GetSteerableViewMapDensityF1D::operator()(Interface1D &inter)
int GetDirectionalViewMapDensityF1D::operator()(Interface1D &inter)
{
- //soc unsigned size;
+ // soc unsigned size;
result = integrate(_fun, inter.pointsBegin(_sampling), inter.pointsEnd(_sampling), _integration);
return 0;
}
int GetCompleteViewMapDensityF1D::operator()(Interface1D &inter)
{
- //soc unsigned size;
+ // soc unsigned size;
/* Id id = inter.getId(); */ /* UNUSED */
result = integrate(_fun, inter.pointsBegin(_sampling), inter.pointsEnd(_sampling), _integration);
return 0;
diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
index 76a70d4f50d..a1fd3fb2665 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions1D.h
@@ -37,8 +37,9 @@ namespace Functions1D {
// DensityF1D
/*! Returns the density evaluated for an Interface1D.
- * The density is evaluated for a set of points along the Interface1D (using the DensityF0D functor) with a
- * user-defined sampling and then integrated into a single value using a user-defined integration method.
+ * The density is evaluated for a set of points along the Interface1D (using the DensityF0D
+ * functor) with a user-defined sampling and then integrated into a single value using a
+ * user-defined integration method.
*/
class DensityF1D : public UnaryFunction1D<double> {
private:
@@ -51,9 +52,9 @@ class DensityF1D : public UnaryFunction1D<double> {
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
- * The resolution used to sample the chain: the corresponding 0D function is evaluated at each sample point and
- * the result is obtained by combining the resulting values into a single one, following the method specified
- * by iType.
+ * The resolution used to sample the chain: the corresponding 0D function is evaluated at each
+ * sample point and the result is obtained by combining the resulting values into a single one,
+ * following the method specified by iType.
*/
DensityF1D(double sigma = 2, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType), _fun(sigma)
@@ -86,8 +87,9 @@ class DensityF1D : public UnaryFunction1D<double> {
// LocalAverageDepthF1D
/*! Returns the average depth evaluated for an Interface1D.
- * The average depth is evaluated for a set of points along the Interface1D (using the LocalAverageDepthF0D functor)
- * with a user-defined sampling and then integrated into a single value using a user-defined integration method.
+ * The average depth is evaluated for a set of points along the Interface1D (using the
+ * LocalAverageDepthF0D functor) with a user-defined sampling and then integrated into a single
+ * value using a user-defined integration method.
*/
class LocalAverageDepthF1D : public UnaryFunction1D<double> {
public:
@@ -121,8 +123,9 @@ class LocalAverageDepthF1D : public UnaryFunction1D<double> {
// GetCompleteViewMapDensity
/*! Returns the density evaluated for an Interface1D in the complete viewmap image.
- * The density is evaluated for a set of points along the Interface1D (using the ReadCompleteViewMapPixelF0D functor)
- * and then integrated into a single value using a user-defined integration method.
+ * The density is evaluated for a set of points along the Interface1D (using the
+ * ReadCompleteViewMapPixelF0D functor) and then integrated into a single value using a
+ * user-defined integration method.
*/
class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
public:
@@ -162,7 +165,8 @@ class GetCompleteViewMapDensityF1D : public UnaryFunction1D<double> {
// GetDirectionalViewMapDensity
/*! Returns the density evaluated for an Interface1D in of the steerable viewmaps image.
* The direction telling which Directional map to choose is explicitly specified by the user.
- * The density is evaluated for a set of points along the Interface1D (using the ReadSteerableViewMapPixelF0D functor)
+ * The density is evaluated for a set of points along the Interface1D
+ * (using the ReadSteerableViewMapPixelF0D functor)
* and then integrated into a single value using a user-defined integration method.
*/
class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
@@ -175,9 +179,9 @@ class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
- * The resolution used to sample the chain: the corresponding 0D function is evaluated at each sample point and
- * the result is obtained by combining the resulting values into a single one, following the method specified
- * by iType.
+ * The resolution used to sample the chain: the corresponding 0D function is evaluated at
+ * each sample point and the result is obtained by combining the resulting values into a
+ * single one, following the method specified by iType.
*/
GetDirectionalViewMapDensityF1D(unsigned iOrientation,
unsigned level,
@@ -203,8 +207,8 @@ class GetDirectionalViewMapDensityF1D : public UnaryFunction1D<double> {
};
// GetSteerableViewMapDensityF1D
-/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is evaluated
- * in the proper steerable ViewMap depending on its oorientation.
+/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
+ * evaluated in the proper steerable ViewMap depending on its oorientation.
*/
class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
private:
@@ -218,9 +222,9 @@ class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
- * The resolution used to sample the chain: the corresponding 0D function is evaluated at each sample point and
- * the result is obtained by combining the resulting values into a single one, following the method specified
- * by iType.
+ * The resolution used to sample the chain: the corresponding 0D function is evaluated at each
+ * sample point and the result is obtained by combining the resulting values into a single one,
+ * following the method specified by iType.
*/
GetSteerableViewMapDensityF1D(int level, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType)
@@ -245,8 +249,8 @@ class GetSteerableViewMapDensityF1D : public UnaryFunction1D<double> {
};
// GetViewMapGradientNormF1D
-/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is evaluated in
- * the proper steerable ViewMap depending on its oorientation.
+/*! Returns the density of the viewmap for a given Interface1D. The density of each FEdge is
+ * evaluated in the proper steerable ViewMap depending on its oorientation.
*/
class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
private:
@@ -261,9 +265,9 @@ class GetViewMapGradientNormF1D : public UnaryFunction1D<double> {
* \param iType:
* The integration method used to compute a single value from a set of values.
* \param sampling:
- * The resolution used to sample the chain: the corresponding 0D function is evaluated at each sample point and
- * the result is obtained by combining the resulting values into a single one, following the method specified
- * by iType.
+ * The resolution used to sample the chain: the corresponding 0D function is evaluated at each
+ * sample point and the result is obtained by combining the resulting values into a single
+ * one, following the method specified by iType.
*/
GetViewMapGradientNormF1D(int level, IntegrationType iType = MEAN, float sampling = 2.0f)
: UnaryFunction1D<double>(iType), _func(level)
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
index a7883187066..6a0d3b0b793 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.cpp
@@ -261,7 +261,7 @@ void Smoother::iteration()
edgeStopping(diffC2, _anisoCurvature) *
diffC2; //_factorCurvatureDifference;
motionCurvature *= _factorCurvatureDifference;
- //motionCurvature = _factorCurvatureDifference * (diffC1 + diffC2);
+ // motionCurvature = _factorCurvatureDifference * (diffC1 + diffC2);
if (_safeTest)
_vertex[i] = Vec2r(_vertex[i] + (motionNormal + motionCurvature) * _normal[i]);
Vec2r v1(_vertex[i - 1] - _vertex[i]);
@@ -283,7 +283,7 @@ void Smoother::iteration()
edgeStopping(diffC2, _anisoCurvature) *
diffC2; //_factorCurvatureDifference;
motionCurvature *= _factorCurvatureDifference;
- //motionCurvature = _factorCurvatureDifference * (diffC1 + diffC2);
+ // motionCurvature = _factorCurvatureDifference * (diffC1 + diffC2);
_vertex[0] = Vec2r(_vertex[0] + (motionNormal + motionCurvature) * _normal[0]);
_vertex[_nbVertices - 1] = _vertex[0];
}
diff --git a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
index 17b180531a2..8f05db28194 100644
--- a/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/AdvancedStrokeShaders.h
@@ -27,9 +27,9 @@
namespace Freestyle {
/*! [ Thickness Shader ].
- * Assigns thicknesses to the stroke vertices so that the stroke looks like made with a calligraphic tool.
- * i.e. The stroke will be the thickest in a main direction, the thinest in the direction perpendicular to this one,
- * and an interpolation inbetween.
+ * Assigns thicknesses to the stroke vertices so that the stroke looks like made with a
+ * calligraphic tool. i.e. The stroke will be the thickest in a main direction, the thinest in the
+ * direction perpendicular to this one, and an interpolation inbetween.
*/
class CalligraphicShader : public StrokeShader {
public:
@@ -103,9 +103,9 @@ class SpatialNoiseShader : public StrokeShader {
/*! [ Geometry Shader ].
* Smoothes the stroke.
* (Moves the vertices to make the stroke smoother).
- * Uses curvature flow to converge towards a curve of constant curvature. The diffusion method we use is anisotropic
- * to prevent the diffusion accross corners.
- * \see \htmlonly <a href=/smoothing/smoothing.html>smoothing/smoothing.html</a> \endhtmlonly
+ * Uses curvature flow to converge towards a curve of constant curvature. The diffusion method we
+ * use is anisotropic to prevent the diffusion accross corners. \see \htmlonly <a
+ * href=/smoothing/smoothing.html>smoothing/smoothing.html</a> \endhtmlonly
*/
class SmoothingShader : public StrokeShader {
public:
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index 15541c1f438..9bdad9f1b32 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -57,7 +57,8 @@ int ConstantThicknessShader::shade(Stroke &stroke) const
int i = 0;
int size = stroke.strokeVerticesSize();
for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
- // XXX What's the use of i here? And is not the thickness always overriden by the last line of the loop?
+ // XXX What's the use of i here? And is not the thickness always overriden by the last line of
+ // the loop?
if ((1 == i) || (size - 2 == i))
v->attribute().setThickness(_thickness / 4.0, _thickness / 4.0);
if ((0 == i) || (size - 1 == i))
@@ -74,7 +75,8 @@ int ConstantExternThicknessShader::shade(Stroke &stroke) const
int i = 0;
int size = stroke.strokeVerticesSize();
for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
- // XXX What's the use of i here? And is not the thickness always overriden by the last line of the loop?
+ // XXX What's the use of i here? And is not the thickness always overriden by the last line of
+ // the loop?
if ((1 == i) || (size - 2 == i))
v->attribute().setThickness(_thickness / 2.0, 0);
if ((0 == i) || (size - 1 == i))
@@ -109,7 +111,8 @@ int ConstrainedIncreasingThicknessShader::shade(Stroke &stroke) const
StrokeInternal::StrokeVertexIterator v, vend;
for (i = 0, v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend;
++v, ++i) {
- // XXX Why not using an if/else here? Else, if last condition is true, everything else is computed for nothing!
+ // XXX Why not using an if/else here? Else, if last condition is true, everything else is
+ // computed for nothing!
float t;
if (i < (float)n / 2.0f)
t = (1.0 - (float)i / (float)n) * _ThicknessMin + (float)i / (float)n * maxT;
@@ -140,7 +143,8 @@ int LengthDependingThicknessShader::shade(Stroke &stroke) const
int i = 0;
int size = stroke.strokeVerticesSize();
for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
- // XXX What's the use of i here? And is not the thickness always overriden by the last line of the loop?
+ // XXX What's the use of i here? And is not the thickness always overriden by the last line of
+ // the loop?
if ((1 == i) || (size - 2 == i))
v->attribute().setThickness(thickness / 4.0, thickness / 4.0);
if ((0 == i) || (size - 1 == i))
@@ -337,7 +341,7 @@ int SamplingShader::shade(Stroke &stroke) const
int ExternalContourStretcherShader::shade(Stroke &stroke) const
{
- //float l = stroke.getLength2D();
+ // float l = stroke.getLength2D();
Interface0DIterator it;
Functions0D::Normal2DF0D fun;
StrokeVertex *sv;
@@ -362,7 +366,7 @@ int BezierCurveShader::shade(Stroke &stroke) const
// Build the Bezier curve from this set of data points:
vector<Vec2d> data;
StrokeInternal::StrokeVertexIterator v = stroke.strokeVerticesBegin(), vend;
- data.push_back(Vec2d(v->x(), v->y())); //first one
+ data.push_back(Vec2d(v->x(), v->y())); // first one
StrokeInternal::StrokeVertexIterator previous = v;
++v;
for (vend = stroke.strokeVerticesEnd(); v != vend; ++v) {
@@ -562,7 +566,7 @@ int PolygonalizationShader::shade(Stroke &stroke) const
Vec2d u = (*cp)->B - (*cp)->A;
Vec2d n(u[1], -u[0]);
n.normalize();
- //Vec2d n(0, 0);
+ // Vec2d n(0, 0);
float offset = ((*cp)->_error);
StrokeInternal::StrokeVertexIterator v;
for (v = a; v != b; ++v) {
@@ -653,7 +657,7 @@ int TipRemoverShader::shade(Stroke &stroke) const
// Resample so that our new stroke have the same number of vertices than before
stroke.Resample(originalSize);
- if ((int)stroke.strokeVerticesSize() != originalSize) //soc
+ if ((int)stroke.strokeVerticesSize() != originalSize) // soc
cerr << "Warning: resampling problem" << endl;
// assign old attributes to new stroke vertices:
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index e128817ffa5..db5738449e6 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -81,9 +81,9 @@ class ConstantThicknessShader : public StrokeShader {
};
/* [ Thickness Shader ].
- * Assigns an absolute constant external thickness to every vertices of the Stroke. The external thickness of a point
- * is its thickness from the point to the strip border in the direction pointing outside the object the
- * Stroke delimitates.
+ * Assigns an absolute constant external thickness to every vertices of the Stroke. The external
+ * thickness of a point is its thickness from the point to the strip border in the direction
+ * pointing outside the object the Stroke delimitates.
*/
class ConstantExternThicknessShader : public StrokeShader {
public:
@@ -108,10 +108,10 @@ class ConstantExternThicknessShader : public StrokeShader {
};
/*! [ Thickness Shader ].
- * Assigns thicknesses values such as the thickness increases from a thickness value A to a thickness value B between
- * the first vertex to the midpoint vertex and then decreases from B to a A between this midpoint vertex
- * and the last vertex.
- * The thickness is linearly interpolated from A to B.
+ * Assigns thicknesses values such as the thickness increases from a thickness value A to a
+ * thickness value B between the first vertex to the midpoint vertex and then decreases from B to a
+ * A between this midpoint vertex and the last vertex. The thickness is linearly interpolated from
+ * A to B.
*/
class IncreasingThicknessShader : public StrokeShader {
public:
@@ -146,8 +146,8 @@ class IncreasingThicknessShader : public StrokeShader {
};
/*! [ Thickness shader ].
- * Same as previous but here we allow the user to control the ratio thickness/length so that we don't get
- * fat short lines
+ * Same as previous but here we allow the user to control the ratio thickness/length so that we
+ * don't get fat short lines
*/
class ConstrainedIncreasingThicknessShader : public StrokeShader {
private:
@@ -288,8 +288,8 @@ class ConstantColorShader : public StrokeShader {
/*! [ Color Shader ].
* Assigns a varying color to the stroke.
- * The user specifies 2 colors A and B. The stroke color will change linearly from A to B between the
- * first and the last vertex.
+ * The user specifies 2 colors A and B. The stroke color will change linearly from A to B between
+ * the first and the last vertex.
*/
class IncreasingColorShader : public StrokeShader {
private:
@@ -346,7 +346,8 @@ class IncreasingColorShader : public StrokeShader {
};
/* [ Color Shader ].
- * Assigns a color to the stroke depending on the material of the shape to which ot belongs to. (Disney shader)
+ * Assigns a color to the stroke depending on the material of the shape to which ot belongs to.
+ * (Disney shader)
*/
class MaterialColorShader : public StrokeShader {
private:
@@ -399,7 +400,8 @@ class ColorNoiseShader : public StrokeShader {
//
///////////////////////////////////////////////////////////////////////////////
/*! [ Geometry Shader ].
- * Stretches the stroke at its two extremities and following the respective directions: v(1)v(0) and v(n-1)v(n).
+ * Stretches the stroke at its two extremities and following the respective directions: v(1)v(0)
+ * and v(n-1)v(n).
*/
class BackboneStretcherShader : public StrokeShader {
private:
@@ -471,9 +473,9 @@ class ExternalContourStretcherShader : public StrokeShader {
// Bezier curve stroke shader
/*! [ Geometry Shader ].
- * Transforms the stroke backbone geometry so that it corresponds to a Bezier Curve approximation of the
- * original backbone geometry.
- * \see \htmlonly <a href=bezier/bezier.html>bezier/bezier.html</a> \endhtmlonly
+ * Transforms the stroke backbone geometry so that it corresponds to a Bezier Curve approximation
+ * of the original backbone geometry. \see \htmlonly <a
+ * href=bezier/bezier.html>bezier/bezier.html</a> \endhtmlonly
*/
class BezierCurveShader : public StrokeShader {
private:
@@ -501,8 +503,9 @@ class BezierCurveShader : public StrokeShader {
/*! [ Geometry Shader ].
* Shader to modify the Stroke geometry so that it looks more "polygonal".
- * The basic idea is to start from the minimal stroke approximation consisting in a line joining the first vertex
- * to the last one and to subdivide using the original stroke vertices until a certain error is reached.
+ * The basic idea is to start from the minimal stroke approximation consisting in a line joining
+ * the first vertex to the last one and to subdivide using the original stroke vertices until a
+ * certain error is reached.
*/
class PolygonalizationShader : public StrokeShader {
private:
@@ -511,9 +514,9 @@ class PolygonalizationShader : public StrokeShader {
public:
/*! Builds the shader.
* \param iError:
- * The error we want our polygonal approximation to have with respect to the original geometry.
- * The smaller, the closer the new stroke to the orinal one.
- * This error corresponds to the maximum distance between the new stroke and the old one.
+ * The error we want our polygonal approximation to have with respect to the original
+ * geometry. The smaller, the closer the new stroke to the orinal one. This error corresponds to
+ * the maximum distance between the new stroke and the old one.
*/
PolygonalizationShader(float iError) : StrokeShader()
{
@@ -542,8 +545,9 @@ class GuidingLinesShader : public StrokeShader {
public:
/*! Builds a Guiding Lines shader
* \param iOffset:
- * The line that replaces the stroke is initially in the middle of the initial stroke "bbox".
- * iOffset is the value of the displacement which is applied to this line along its normal.
+ * The line that replaces the stroke is initially in the middle of the initial stroke
+ * "bbox". iOffset is the value of the displacement which is applied to this line along its
+ * normal.
*/
GuidingLinesShader(float iOffset) : StrokeShader()
{
diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp
index b497b470492..95bbafc0aa0 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.cpp
+++ b/source/blender/freestyle/intern/stroke/Canvas.cpp
@@ -38,8 +38,8 @@
#include "BKE_global.h"
-//soc #include <qimage.h>
-//soc #include <QString>
+// soc #include <qimage.h>
+// soc #include <QString>
extern "C" {
#include "IMB_imbuf.h"
@@ -325,7 +325,7 @@ void Canvas::loadMap(const char *iFileName,
filePath = iFileName;
}
-#if 0 //soc
+#if 0 // soc
QImage *qimg;
QImage newMap(filePath.c_str());
if (newMap.isNull()) {
@@ -402,7 +402,7 @@ void Canvas::loadMap(const char *iFileName,
GaussianPyramid *pyramid = new GaussianPyramid(tmp, iNbLevels, iSigma);
int ow = pyramid->width(0);
int oh = pyramid->height(0);
- string base(iMapName); //soc
+ string base(iMapName); // soc
for (int i = 0; i < pyramid->getNumberOfLevels(); ++i) {
// save each image:
#if 0
@@ -410,19 +410,19 @@ void Canvas::loadMap(const char *iFileName,
h = pyramid.height(i);
#endif
- //soc QImage qtmp(ow, oh, QImage::Format_RGB32);
+ // soc QImage qtmp(ow, oh, QImage::Format_RGB32);
ImBuf *qtmp = IMB_allocImBuf(ow, oh, 32, IB_rect);
- //int k = (1 << i);
+ // int k = (1 << i);
for (y = 0; y < oh; ++y) {
for (x = 0; x < ow; ++x) {
int c = pyramid->pixel(x, y, i); // 255 * pyramid->pixel(x, y, i);
- //soc qtmp.setPixel(x, y, qRgb(c, c, c));
+ // soc qtmp.setPixel(x, y, qRgb(c, c, c));
pix = (char *)qtmp->rect + y * rowbytes + x * 4;
pix[0] = pix[1] = pix[2] = c;
}
}
- //soc qtmp.save(base + QString::number(i) + ".bmp", "BMP");
+ // soc qtmp.save(base + QString::number(i) + ".bmp", "BMP");
stringstream filename;
filename << base;
filename << i << ".bmp";
@@ -443,7 +443,7 @@ void Canvas::loadMap(const char *iFileName,
#endif
_maps[iMapName] = pyramid;
- //newMap->save("toto.bmp", "BMP");
+ // newMap->save("toto.bmp", "BMP");
}
float Canvas::readMapPixel(const char *iMapName, int level, int x, int y)
diff --git a/source/blender/freestyle/intern/stroke/Canvas.h b/source/blender/freestyle/intern/stroke/Canvas.h
index e059bb07eda..2a0ebbe17c5 100644
--- a/source/blender/freestyle/intern/stroke/Canvas.h
+++ b/source/blender/freestyle/intern/stroke/Canvas.h
@@ -137,8 +137,8 @@ class Canvas {
}
/* Maps management */
- /*! Loads an image map. The map will be scaled (without preserving the ratio in order to fit the actual
- * canvas size.).
+ /*! Loads an image map. The map will be scaled
+ * (without preserving the ratio in order to fit the actual canvas size.).
* The image must be a gray values image...
* \param iFileName:
* The name of the image file
@@ -160,9 +160,11 @@ class Canvas {
* \param level:
* The level of the pyramid from which the pixel must be read.
* \param x:
- * The abscissa of the desired pixel specified in level0 coordinate system. The origin is the lower left corner.
+ * The abscissa of the desired pixel specified in level0 coordinate system.
+ * The origin is the lower left corner.
* \param y:
- * The ordinate of the desired pixel specified in level0 coordinate system. The origin is the lower left corner.
+ * The ordinate of the desired pixel specified in level0 coordinate system.
+ * The origin is the lower left corner.
*/
float readMapPixel(const char *iMapName, int level, int x, int y);
diff --git a/source/blender/freestyle/intern/stroke/Chain.cpp b/source/blender/freestyle/intern/stroke/Chain.cpp
index 32b3ec2de31..d4cc4fd68c3 100644
--- a/source/blender/freestyle/intern/stroke/Chain.cpp
+++ b/source/blender/freestyle/intern/stroke/Chain.cpp
@@ -76,7 +76,7 @@ void Chain::push_viewedge_back(ViewEdge *iViewEdge, bool orientation)
} while ((v != vend) && (v != vfirst));
if (v == vfirst) {
- //Add last one:
+ // Add last one:
current = (*v)->point2d();
Curve::push_vertex_back(*v);
//_Length += (current - previous).norm();
@@ -138,7 +138,7 @@ void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
} while ((v != vend) && (v != vfirst));
if (v == vfirst) {
- //Add last one:
+ // Add last one:
current = (*v)->point2d();
Curve::push_vertex_front(*v);
//_Length += (current - previous).norm();
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
index de6c50fe571..551b9aa4043 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
@@ -143,10 +143,11 @@ int ChainSilhouetteIterator::traverse(const AdjacencyIterator &ait)
return 0;
}
if (nextVertex->getNature() & Nature::NON_T_VERTEX) {
- //soc NonTVertex *nontvertex = (NonTVertex*)nextVertex;
+ // soc NonTVertex *nontvertex = (NonTVertex*)nextVertex;
ViewEdge *newEdge(0);
// we'll try to chain the edges by keeping the same nature...
- // the preseance order is : SILHOUETTE, BORDER, CREASE, MATERIAL_BOUNDARY, EDGE_MARK, SUGGESTIVE, VALLEY, RIDGE
+ // the preseance order is : SILHOUETTE, BORDER, CREASE, MATERIAL_BOUNDARY, EDGE_MARK,
+ // SUGGESTIVE, VALLEY, RIDGE
Nature::EdgeNature natures[8] = {
Nature::SILHOUETTE,
Nature::BORDER,
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.h b/source/blender/freestyle/intern/stroke/ChainingIterators.h
index 57a73c64b3d..52da85ccc58 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.h
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.h
@@ -32,7 +32,7 @@
#include "../view_map/ViewMapIterators.h"
#include "../view_map/ViewMapAdvancedIterators.h"
-//using namespace ViewEdgeInternal;
+// using namespace ViewEdgeInternal;
namespace Freestyle {
@@ -98,7 +98,8 @@ class AdjacencyIterator : public Iterator {
return _internalIterator.isBegin();
}
- /*! Returns true if the current ViewEdge is coming towards the iteration vertex. False otherwise. */
+ /*! Returns true if the current ViewEdge is coming towards the iteration vertex.
+ * False otherwise. */
bool isIncoming() const;
/*! Returns a *pointer* to the pointed ViewEdge. */
@@ -144,14 +145,15 @@ class AdjacencyIterator : public Iterator {
* It makes the works of chaining rules description easier.
* The two main methods that need to overloaded are traverse() and init().
* traverse() tells which ViewEdge to follow, among the adjacent ones.
- * If you specify restriction rules (such as "Chain only ViewEdges of the selection"), they will be included
- * in the adjacency iterator. (i.e, the adjacent iterator will only stop on "valid" edges).
+ * If you specify restriction rules (such as "Chain only ViewEdges of the selection"),
+ * they will be included in the adjacency iterator.
+ * (i.e, the adjacent iterator will only stop on "valid" edges).
*/
class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
protected:
bool _restrictToSelection;
bool _restrictToUnvisited;
- bool _increment; //true if we're currently incrementing, false when decrementing
+ bool _increment; // true if we're currently incrementing, false when decrementing
public:
ViewEdge *result;
@@ -159,13 +161,15 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
/*! Builds a Chaining Iterator from the first ViewEdge used for iteration and its orientation.
* \param iRestrictToSelection:
- * Indicates whether to force the chaining to stay within the set of selected ViewEdges or not.
+ * Indicates whether to force the chaining to stay within
+ * the set of selected ViewEdges or not.
* \param iRestrictToUnvisited:
* Indicates whether a ViewEdge that has already been chained must be ignored ot not.
* \param begin:
* The ViewEdge from which to start the chain.
* \param orientation:
- * The direction to follow to explore the graph. If true, the direction indicated by the first ViewEdge is used.
+ * The direction to follow to explore the graph. If true,
+ * the direction indicated by the first ViewEdge is used.
*/
ChainingIterator(bool iRestrictToSelection = true,
bool iRestrictToUnvisited = true,
@@ -200,17 +204,19 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
*/
virtual int init();
- /*! This method iterates over the potential next ViewEdges and returns the one that will be followed next.
- * returns the next ViewEdge to follow or 0 when the end of the chain is reached.
+ /*! This method iterates over the potential next ViewEdges and returns the one that will be
+ * followed next. returns the next ViewEdge to follow or 0 when the end of the chain is reached.
* \param it:
* The iterator over the ViewEdges adjacent to the end vertex of the current ViewEdge.
- * The Adjacency iterator reflects the restriction rules by only iterating over the valid ViewEdges.
+ * The Adjacency iterator reflects the restriction rules by only iterating over the valid
+ * ViewEdges.
*/
virtual int traverse(const AdjacencyIterator &it);
/* accessors */
- /*! Returns true if the orientation of the current ViewEdge corresponds to its natural orientation */
- //inline bool getOrientation() const {}
+ /*! Returns true if the orientation of the current ViewEdge corresponds to its natural
+ * orientation */
+ // inline bool getOrientation() const {}
/*! Returns the vertex which is the next crossing */
inline ViewVertex *getVertex()
@@ -251,20 +257,23 @@ class ChainingIterator : public ViewEdgeInternal::ViewEdgeIterator {
/*! A ViewEdge Iterator used to follow ViewEdges the most naturally.
* For example, it will follow visible ViewEdges of same nature.
- * As soon, as the nature or the visibility changes, the iteration stops (by setting the pointed ViewEdge to 0).
- * In the case of an iteration over a set of ViewEdge that are both Silhouette and Crease, there will be a precedence
- * of the silhouette over the crease criterion.
+ * As soon, as the nature or the visibility changes, the iteration stops (by setting the pointed
+ * ViewEdge to 0). In the case of an iteration over a set of ViewEdge that are both Silhouette
+ * and Crease, there will be a precedence of the silhouette over the crease criterion.
*/
class ChainSilhouetteIterator : public ChainingIterator {
public:
- /*! Builds a ChainSilhouetteIterator from the first ViewEdge used for iteration and its orientation.
+ /*! Builds a ChainSilhouetteIterator from the first ViewEdge used for iteration and its
+ * orientation.
* \param iRestrictToSelection:
- * Indicates whether to force the chaining to stay within the set of selected ViewEdges or not.
+ * Indicates whether to force the chaining to stay within the set of selected ViewEdges or
+ * not.
* \param begin:
* The ViewEdge from where to start the iteration.
* \param orientation:
- * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending ViewVertex of begin.
- * If false, we'll search over the ViewEdges surrounding the ending ViewVertex of begin.
+ * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending
+ * ViewVertex of begin. If false, we'll search over the ViewEdges surrounding the ending
+ * ViewVertex of begin.
*/
ChainSilhouetteIterator(bool iRestrictToSelection = true,
ViewEdge *begin = NULL,
@@ -284,7 +293,8 @@ class ChainSilhouetteIterator : public ChainingIterator {
return "ChainSilhouetteIterator";
}
- /*! This method iterates over the potential next ViewEdges and returns the one that will be followed next.
+ /*! This method iterates over the potential next ViewEdges and returns the one that will be
+ * followed next.
* When reaching the end of a chain, 0 is returned.
*/
virtual int traverse(const AdjacencyIterator &it);
@@ -301,13 +311,14 @@ class ChainSilhouetteIterator : public ChainingIterator {
//
///////////////////////////////////////////////////////////
-/*! A "generic" user-controlled ViewEdge iterator. This iterator is in particular built from a unary predicate and
- * a binary predicate.
- * First, the unary predicate is evaluated for all potential next ViewEdges in order to only keep the ones respecting
- * a certain constraint.
- * Then, the binary predicate is evaluated on the current ViewEdge together with each ViewEdge of the previous
- * selection. The first ViewEdge respecting both the unary predicate and the binary predicate is kept as the next one.
- * If none of the potential next ViewEdge respects these 2 predicates, 0 is returned.
+/*! A "generic" user-controlled ViewEdge iterator. This iterator is in particular built from a
+ * unary predicate and a binary predicate.
+ * First, the unary predicate is evaluated for all potential next ViewEdges in order to only
+ * keep the ones respecting a certain constraint.
+ * Then, the binary predicate is evaluated on the current ViewEdge together with each ViewEdge
+ * of the previous selection. The first ViewEdge respecting both the unary predicate and the
+ * binary predicate is kept as the next one. If none of the potential next ViewEdge respects
+ * these 2 predicates, 0 is returned.
*/
class ChainPredicateIterator : public ChainingIterator {
protected:
@@ -318,14 +329,16 @@ class ChainPredicateIterator : public ChainingIterator {
public:
/*! Builds a ChainPredicateIterator from a starting ViewEdge and its orientation.
* \param iRestrictToSelection:
- * Indicates whether to force the chaining to stay within the set of selected ViewEdges or not.
+ * Indicates whether to force the chaining to stay
+ * within the set of selected ViewEdges or not.
* \param iRestrictToUnvisited:
* Indicates whether a ViewEdge that has already been chained must be ignored ot not.
* \param begin:
* The ViewEdge from where to start the iteration.
* \param orientation:
- * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending ViewVertex of begin.
- * If false, we'll search over the ViewEdges surrounding the ending ViewVertex of begin.
+ * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending
+ * ViewVertex of begin. If false, we'll search over the ViewEdges surrounding the ending
+ * ViewVertex of begin.
*/
ChainPredicateIterator(bool iRestrictToSelection = true,
bool iRestrictToUnvisited = true,
@@ -337,21 +350,24 @@ class ChainPredicateIterator : public ChainingIterator {
_unary_predicate = 0;
}
- /*! Builds a ChainPredicateIterator from a unary predicate, a binary predicate, a starting ViewEdge and
- * its orientation.
+ /*! Builds a ChainPredicateIterator from a unary predicate, a binary predicate, a starting
+ * ViewEdge and its orientation.
* \param iRestrictToSelection:
- * Indicates whether to force the chaining to stay within the set of selected ViewEdges or not.
+ * Indicates whether to force the chaining to stay
+ * within the set of selected ViewEdges or not.
* \param iRestrictToUnvisited:
* Indicates whether a ViewEdge that has already been chained must be ignored ot not.
* \param upred:
* The unary predicate that the next ViewEdge must satisfy.
* \param bpred:
- * The binary predicate that the next ViewEdge must satisfy together with the actual pointed ViewEdge.
+ * The binary predicate that the next ViewEdge must satisfy together with the actual pointed
+ * ViewEdge.
* \param begin:
* The ViewEdge from where to start the iteration.
* \param orientation:
- * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending ViewVertex of begin.
- * If false, we'll search over the ViewEdges surrounding the ending ViewVertex of begin.
+ * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending
+ * ViewVertex of begin. If false, we'll search over the ViewEdges surrounding the ending
+ * ViewVertex of begin.
*/
ChainPredicateIterator(UnaryPredicate1D &upred,
BinaryPredicate1D &bpred,
@@ -385,8 +401,8 @@ class ChainPredicateIterator : public ChainingIterator {
return "ChainPredicateIterator";
}
- /*! This method iterates over the potential next ViewEdges and returns the one that will be followed next.
- * When reaching the end of a chain, 0 is returned.
+ /*! This method iterates over the potential next ViewEdges and returns the one that will be
+ * followed next. When reaching the end of a chain, 0 is returned.
*/
virtual int traverse(const AdjacencyIterator &it);
diff --git a/source/blender/freestyle/intern/stroke/Curve.cpp b/source/blender/freestyle/intern/stroke/Curve.cpp
index f7309252aaf..fe617646442 100644
--- a/source/blender/freestyle/intern/stroke/Curve.cpp
+++ b/source/blender/freestyle/intern/stroke/Curve.cpp
@@ -253,12 +253,18 @@ FEdge *CurvePoint::getFEdge(Interface0D &inter)
if (G.debug & G_DEBUG_FREESTYLE) {
printf("__A 0x%p p (%f, %f)\n", __A, __A->getPoint2D().x(), __A->getPoint2D().y());
printf("__B 0x%p p (%f, %f)\n", __B, __B->getPoint2D().x(), __B->getPoint2D().y());
- printf("iVertexB->A() 0x%p p (%f, %f)\n", iVertexB->A(), iVertexB->A()->getPoint2D().x(),
- iVertexB->A()->getPoint2D().y());
- printf("iVertexB->B() 0x%p p (%f, %f)\n", iVertexB->B(), iVertexB->B()->getPoint2D().x(),
- iVertexB->B()->getPoint2D().y());
+ printf("iVertexB->A() 0x%p p (%f, %f)\n",
+ iVertexB->A(),
+ iVertexB->A()->getPoint2D().x(),
+ iVertexB->A()->getPoint2D().y());
+ printf("iVertexB->B() 0x%p p (%f, %f)\n",
+ iVertexB->B(),
+ iVertexB->B()->getPoint2D().x(),
+ iVertexB->B()->getPoint2D().y());
printf("_t2d %f p (%f, %f)\n", _t2d, getPoint2D().x(), getPoint2D().y());
- printf("iVertexB->t2d() %f p (%f, %f)\n", iVertexB->t2d(), iVertexB->getPoint2D().x(),
+ printf("iVertexB->t2d() %f p (%f, %f)\n",
+ iVertexB->t2d(),
+ iVertexB->getPoint2D().x(),
iVertexB->getPoint2D().y());
}
#endif
@@ -315,7 +321,6 @@ float CurvePoint::shape_importance() const
return __A->shape_importance();
}
-
const unsigned CurvePoint::qi() const
{
if (__A == 0)
@@ -404,18 +409,18 @@ real CurvePoint::z_discontinuity() const
#if 0
float CurvePoint::local_average_depth() const
{
- return local_average_depth_function<CurvePoint >(this);
+ return local_average_depth_function<CurvePoint>(this);
}
float CurvePoint::local_depth_variance() const
{
- return local_depth_variance_function<CurvePoint >(this);
+ return local_depth_variance_function<CurvePoint>(this);
}
real CurvePoint::local_average_density(float sigma) const
{
//return local_average_density<CurvePoint >(this);
- return density_function<CurvePoint >(this);
+ return density_function<CurvePoint>(this);
}
Vec3r shaded_color() const;
@@ -484,7 +489,7 @@ real CurvePoint::curvatureFredo() const
return ((1 - _t2d) * __A->curvatureFredo() + _t2d * __B->curvatureFredo());
}
-Vec2d CurvePoint::directionFredo () const
+Vec2d CurvePoint::directionFredo() const
{
if (__A == 0)
return __B->directionFredo();
@@ -522,7 +527,7 @@ Curve::point_iterator Curve::points_begin(float step)
++second;
return point_iterator(
_Vertices.begin(), second, _Vertices.begin(), _Vertices.end(), _nSegments, step, 0.0f, 0.0f);
- //return point_iterator(_Vertices.begin(), second, _nSegments, step, 0.0f, 0.0f);
+ // return point_iterator(_Vertices.begin(), second, _nSegments, step, 0.0f, 0.0f);
}
Curve::const_point_iterator Curve::points_begin(float step) const
@@ -531,7 +536,7 @@ Curve::const_point_iterator Curve::points_begin(float step) const
++second;
return const_point_iterator(
_Vertices.begin(), second, _Vertices.begin(), _Vertices.end(), _nSegments, step, 0.0f, 0.0f);
- //return const_point_iterator(_Vertices.begin(), second, _nSegments, step, 0.0f, 0.0f);
+ // return const_point_iterator(_Vertices.begin(), second, _nSegments, step, 0.0f, 0.0f);
}
Curve::point_iterator Curve::points_end(float step)
@@ -544,7 +549,7 @@ Curve::point_iterator Curve::points_end(float step)
step,
1.0f,
_Length);
- //return point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.0f, _Length);
+ // return point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.0f, _Length);
}
Curve::const_point_iterator Curve::points_end(float step) const
@@ -557,7 +562,8 @@ Curve::const_point_iterator Curve::points_end(float step) const
step,
1.0f,
_Length);
- //return const_point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.0f, _Length);
+ // return const_point_iterator(_Vertices.end(), _Vertices.end(), _nSegments, step, 1.0f,
+ // _Length);
}
// Adavnced Iterators access
@@ -676,10 +682,9 @@ Vec3r Curve::orientation2d(point_iterator it) const
return (*it)->orientation2d();
}
-template <class BaseVertex>
-Vec3r Curve::orientation2d(int iCombination) const
+template<class BaseVertex> Vec3r Curve::orientation2d(int iCombination) const
{
- return edge_orientation2d_function<Curve >(this, iCombination);
+ return edge_orientation2d_function<Curve>(this, iCombination);
}
Vec3r Curve::orientation3d(point_iterator it) const
@@ -689,7 +694,7 @@ Vec3r Curve::orientation3d(point_iterator it) const
Vec3r Curve::orientation3d(int iCombination) const
{
- return edge_orientation3d_function<Curve >(this, iCombination);
+ return edge_orientation3d_function<Curve>(this, iCombination);
}
real curvature2d(point_iterator it) const
@@ -702,7 +707,7 @@ real curvature2d(int iCombination = 0) const;
Material Curve::material() const
{
const_vertex_iterator v = vertices_begin(), vend = vertices_end();
- const Material& mat = (*v)->material();
+ const Material &mat = (*v)->material();
for (; v != vend; ++v) {
if ((*v)->material() != mat)
Exception::raiseException();
@@ -747,7 +752,7 @@ bool Curve::occluders_empty() const
return empty;
}
-const Polygon3r& occludee() const
+const Polygon3r &occludee() const
{
return *(_FEdgeA->aFace());
}
@@ -789,7 +794,6 @@ int Curve::shape_id() const
return id.first;
}
-
const SShape *Curve::shape() const
{
const_vertex_iterator v = vertices_begin(), vend = vertices_end();
@@ -801,14 +805,12 @@ const SShape *Curve::shape() const
return sshape;
}
-
occluder_container::const_iterator Curve::occluders_begin() const
{
const_vertex_iterator v = vertices_begin();
return (*v)->occluders_begin();
}
-
occluder_container::const_iterator Curve::occluders_end() const
{
const_vertex_iterator v = vertices_end();
@@ -835,7 +837,7 @@ float Curve::local_average_depth(int iCombination) const
return local_average_depth_edge_function<Curve>(this, iCombination);
}
-float Curve::local_depth_variance(int iCombination ) const
+float Curve::local_depth_variance(int iCombination) const
{
return local_depth_variance_edge_function<Curve>(this, iCombination);
# if 0
@@ -846,7 +848,7 @@ float Curve::local_depth_variance(int iCombination ) const
# endif
}
-real Curve::local_average_density(float sigma, int iCombination ) const
+real Curve::local_average_density(float sigma, int iCombination) const
{
return density_edge_function<Curve>(this, iCombination);
# if 0
@@ -860,7 +862,7 @@ real Curve::local_average_density(float sigma, int iCombination ) const
/* UNUSED */
// #define EPS_CURVA_DIR 0.01
-void Curve::computeCurvatureAndOrientation ()
+void Curve::computeCurvatureAndOrientation()
{
const_vertex_iterator v = vertices_begin(), vend = vertices_end(), v2, prevV, v0;
Vec2d p0, p1, p2;
@@ -874,7 +876,7 @@ void Curve::computeCurvatureAndOrientation ()
p1 = Vec2d(p[0], p[1]);
Vec2d prevDir(p1 - p0);
- for (; v! = vend; ++v) {
+ for (; v ! = vend; ++v) {
v2 = v;
++v2;
if (v2 == vend)
diff --git a/source/blender/freestyle/intern/stroke/Curve.h b/source/blender/freestyle/intern/stroke/Curve.h
index 234f9df0e48..b84ce45fb6d 100644
--- a/source/blender/freestyle/intern/stroke/Curve.h
+++ b/source/blender/freestyle/intern/stroke/Curve.h
@@ -55,10 +55,10 @@ using namespace Geometry;
/*! Class to represent a point of a curve.
* A CurvePoint can be any point of a 1D curve (it doesn't have to be a vertex of the curve).
- * Any Interface1D is built upon ViewEdges, themselves built upon FEdges. Therefore, a curve is basically
- * a polyline made of a list SVertex.
- * Thus, a CurvePoint is built by lineraly interpolating two SVertex.
- * CurvePoint can be used as virtual points while querying 0D information along a curve at a given resolution.
+ * Any Interface1D is built upon ViewEdges, themselves built upon FEdges. Therefore, a curve is
+ * basically a polyline made of a list SVertex. Thus, a CurvePoint is built by lineraly
+ * interpolating two SVertex. CurvePoint can be used as virtual points while querying 0D
+ * information along a curve at a given resolution.
*/
class CurvePoint : public Interface0D {
public: // Implementation of Interface0D
@@ -188,7 +188,7 @@ class CurvePoint : public Interface0D {
SVertex *__A;
SVertex *__B;
float _t2d;
- //float _t3d;
+ // float _t3d;
Vec3r _Point2d;
Vec3r _Point3d;
@@ -216,7 +216,7 @@ class CurvePoint : public Interface0D {
*/
CurvePoint(CurvePoint *iA, CurvePoint *iB, float t2d);
- //CurvePoint(SVertex *iA, SVertex *iB, float t2d, float t3d);
+ // CurvePoint(SVertex *iA, SVertex *iB, float t2d, float t3d);
/*! Copy Constructor. */
CurvePoint(const CurvePoint &iBrother);
@@ -302,12 +302,12 @@ class CurvePoint : public Interface0D {
}
Vec3r normal() const;
- //FrsMaterial material() const;
- //Id shape_id() const;
+ // FrsMaterial material() const;
+ // Id shape_id() const;
const SShape *shape() const;
- //float shape_importance() const;
+ // float shape_importance() const;
- //const unsigned qi() const;
+ // const unsigned qi() const;
occluder_container::const_iterator occluders_begin() const;
occluder_container::const_iterator occluders_end() const;
bool occluders_empty() const;
@@ -525,7 +525,7 @@ class Curve : public Interface1D {
int occluders_size() const;
bool occluders_empty() const;
- const Polygon3r& occludee() const
+ const Polygon3r &occludee() const
{
return *(_FEdgeA->aFace());
}
@@ -564,25 +564,25 @@ class Curve : public Interface1D {
CurveInternal::CurvePointIterator curveVerticesEnd();
// Iterators access
- /*! Returns an Interface0DIterator pointing onto the first vertex of the Curve and that can iterate
- * over the \a vertices of the Curve.
+ /*! Returns an Interface0DIterator pointing onto the first vertex of the Curve and that can
+ * iterate over the \a vertices of the Curve.
*/
virtual Interface0DIterator verticesBegin();
- /*! Returns an Interface0DIterator pointing after the last vertex of the Curve and that can iterate
- * over the \a vertices of the Curve.
+ /*! Returns an Interface0DIterator pointing after the last vertex of the Curve and that can
+ * iterate over the \a vertices of the Curve.
*/
virtual Interface0DIterator verticesEnd();
- /*! Returns an Interface0DIterator pointing onto the first point of the Curve and that can iterate
- * over the \a points of the Curve at any resolution.
- * At each iteration a virtual temporary CurvePoint is created.
+ /*! Returns an Interface0DIterator pointing onto the first point of the Curve and that can
+ * iterate over the \a points of the Curve at any resolution. At each iteration a virtual
+ * temporary CurvePoint is created.
*/
virtual Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an Interface0DIterator pointing after the last point of the Curve and that can iterate
- * over the \a points of the Curve at any resolution.
- * At each iteration a virtual temporary CurvePoint is created.
+ /*! Returns an Interface0DIterator pointing after the last point of the Curve and that can
+ * iterate over the \a points of the Curve at any resolution. At each iteration a virtual
+ * temporary CurvePoint is created.
*/
virtual Interface0DIterator pointsEnd(float t = 0.0f);
diff --git a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
index 3cd55facd15..5cbdd26be57 100644
--- a/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveAdvancedIterators.h
@@ -50,8 +50,8 @@ class CurvePoint_nonconst_traits : public Nonconst_traits<CurvePoint *> {
/* */
/**********************************/
-/*! iterator on a curve. Allows an iterating outside initial vertices. A CurvePoint is instanciated an returned
- * when the iterator is dereferenced.
+/*! iterator on a curve. Allows an iterating outside initial vertices. A CurvePoint is
+ * instanciated an returned when the iterator is dereferenced.
*/
template<class Traits>
class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Traits> {
@@ -66,7 +66,7 @@ class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Tr
typedef __point_iterator<CurvePoint_const_traits> const_iterator;
#if 0
- typedef Vertex vertex_type ;
+ typedef Vertex vertex_type;
typedef vertex_container_iterator vertex_iterator_type;
typedef CurvePoint<Vertex> Point;
typedef Point point_type;
@@ -76,7 +76,8 @@ class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Tr
# if defined(__GNUC__) && (__GNUC__ < 3)
typedef bidirectional_iterator<CurvePoint<Vertex>, ptrdiff_t> bidirectional_point_iterator;
# else
- typedef iterator<bidirectional_iterator_tag, CurvePoint<Vertex>, ptrdiff_t> bidirectional_point_iterator;
+ typedef iterator<bidirectional_iterator_tag, CurvePoint<Vertex>, ptrdiff_t>
+ bidirectional_point_iterator;
# endif
#endif
friend class Curve;
@@ -85,7 +86,7 @@ class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Tr
friend class __point_iterator<CurvePoint_nonconst_traits>;
friend class iterator;
#endif
- //protected:
+ // protected:
public:
float _CurvilinearLength;
float _step;
@@ -168,7 +169,7 @@ class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Tr
delete _Point;
}
- //protected: //FIXME
+ // protected: //FIXME
public:
inline __point_iterator(vertex_container_iterator iA,
vertex_container_iterator iB,
@@ -306,7 +307,7 @@ class __point_iterator : public IteratorBase<Traits, BidirectionalIteratorTag_Tr
else {
_t = 1.0f; // AB is a null segment, we're directly at its end
}
- //if normAB ~= 0, we don't change these values
+ // if normAB ~= 0, we don't change these values
if (_t >= 1) {
_CurvilinearLength -= normAB * (_t - 1);
if (_currentn == _n - 1) {
diff --git a/source/blender/freestyle/intern/stroke/CurveIterators.h b/source/blender/freestyle/intern/stroke/CurveIterators.h
index 428ea022dfd..b05c9838a3b 100644
--- a/source/blender/freestyle/intern/stroke/CurveIterators.h
+++ b/source/blender/freestyle/intern/stroke/CurveIterators.h
@@ -187,7 +187,7 @@ class CurvePointIterator : public Interface0DIteratorNested {
return false;
}
- //protected:
+ // protected:
virtual int increment()
{
if ((_currentn == _n - 1) && (_t == 1.0f)) {
@@ -223,7 +223,7 @@ class CurvePointIterator : public Interface0DIteratorNested {
else {
_t = 1.0f; // AB is a null segment, we're directly at its end
}
- //if normAB ~= 0, we don't change these values
+ // if normAB ~= 0, we don't change these values
if (_t >= 1) {
_CurvilinearLength -= normAB * (_t - 1);
if (_currentn == _n - 1) {
@@ -241,7 +241,7 @@ class CurvePointIterator : public Interface0DIteratorNested {
virtual int decrement()
{
- if (_t == 0.0f) { //we're at the beginning of the edge
+ if (_t == 0.0f) { // we're at the beginning of the edge
_t = 1.0f;
--_currentn;
--__A;
diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp
index 2c8a83e2518..0374e605ff2 100644
--- a/source/blender/freestyle/intern/stroke/Operators.cpp
+++ b/source/blender/freestyle/intern/stroke/Operators.cpp
@@ -206,7 +206,9 @@ error:
}
#if 0
-void Operators::bidirectionalChain(ViewEdgeIterator& it, UnaryPredicate1D& pred, UnaryFunction1D_void& modifier)
+void Operators::bidirectionalChain(ViewEdgeIterator &it,
+ UnaryPredicate1D &pred,
+ UnaryFunction1D_void &modifier)
{
if (_current_view_edges_set.empty())
return;
@@ -217,12 +219,11 @@ void Operators::bidirectionalChain(ViewEdgeIterator& it, UnaryPredicate1D& pred,
for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
it_edge != _current_view_edges_set.end();
- ++it_edge)
- {
+ ++it_edge) {
if (pred(**it_edge))
continue;
- edge = dynamic_cast<ViewEdge*>(*it_edge);
+ edge = dynamic_cast<ViewEdge *>(*it_edge);
it.setBegin(edge);
it.setCurrentEdge(edge);
@@ -253,7 +254,7 @@ void Operators::bidirectionalChain(ViewEdgeIterator& it, UnaryPredicate1D& pred,
_current_set = &_current_chains_set;
}
-void Operators::bidirectionalChain(ViewEdgeIterator& it, UnaryPredicate1D& pred)
+void Operators::bidirectionalChain(ViewEdgeIterator &it, UnaryPredicate1D &pred)
{
if (_current_view_edges_set.empty())
return;
@@ -267,18 +268,17 @@ void Operators::bidirectionalChain(ViewEdgeIterator& it, UnaryPredicate1D& pred)
for (I1DContainer::iterator it_edge = _current_view_edges_set.begin();
it_edge != _current_view_edges_set.end();
- ++it_edge)
- {
+ ++it_edge) {
if (pred(**it_edge) || pred_ts(**it_edge))
continue;
- edge = dynamic_cast<ViewEdge*>(*it_edge);
+ edge = dynamic_cast<ViewEdge *>(*it_edge);
it.setBegin(edge);
it.setCurrentEdge(edge);
Chain *new_chain = new Chain(id);
++id;
-# if 0 //FIXME
+# if 0 // FIXME
ViewEdgeIterator it_back(it);
--it_back;
# endif
@@ -835,13 +835,13 @@ static int __recursiveSplit(Chain *_curve,
CurveInternal::CurvePointIterator split = second;
Interface0DIterator it0d = it.castToInterface0DIterator();
#if 0
- real _min = func(it0d);
+ real _min = func(it0d);
++it;
#endif
real _min = FLT_MAX;
++it;
real mean = 0.f;
- //soc unused - real variance = 0.0f;
+ // soc unused - real variance = 0.0f;
unsigned count = 0;
CurveInternal::CurvePointIterator next = it;
++next;
@@ -865,7 +865,7 @@ static int __recursiveSplit(Chain *_curve,
}
mean /= (float)count;
- //if ((!bsplit) || (mean - _min > mean)) { // we didn't find any minimum
+ // if ((!bsplit) || (mean - _min > mean)) { // we didn't find any minimum
if (!bsplit) { // we didn't find any minimum
newChains.push_back(_curve);
return 0;
@@ -1210,7 +1210,7 @@ inline int applyShading(Stroke &stroke, vector<StrokeShader *> &shaders)
int Operators::create(UnaryPredicate1D &pred, vector<StrokeShader *> shaders)
{
- //Canvas* canvas = Canvas::getInstance();
+ // Canvas* canvas = Canvas::getInstance();
if (!_current_set) {
cerr << "Warning: current set empty" << endl;
return 0;
@@ -1229,7 +1229,7 @@ int Operators::create(UnaryPredicate1D &pred, vector<StrokeShader *> shaders)
delete stroke;
goto error;
}
- //canvas->RenderStroke(stroke);
+ // canvas->RenderStroke(stroke);
new_strokes_set.push_back(stroke);
}
}
diff --git a/source/blender/freestyle/intern/stroke/Operators.h b/source/blender/freestyle/intern/stroke/Operators.h
index 9d63108a813..2da9d30f172 100644
--- a/source/blender/freestyle/intern/stroke/Operators.h
+++ b/source/blender/freestyle/intern/stroke/Operators.h
@@ -43,8 +43,9 @@
namespace Freestyle {
/*! Class defining the operators used in a style module.
- * There are 4 classes of operators: Selection, Chaining, Splitting and Creating. All these operators are
- * user controlled in the scripting language through Functors, Predicates and Shaders that are taken as arguments.
+ * There are 4 classes of operators: Selection, Chaining, Splitting and Creating.
+ * All these operators are user controlled in the scripting language through Functors, Predicates
+ * and Shaders that are taken as arguments.
*/
class Operators {
@@ -63,7 +64,8 @@ class Operators {
static int select(UnaryPredicate1D &pred);
/*! Builds a set of chains from the current set of ViewEdges.
- * Each ViewEdge of the current list starts a new chain. The chaining operator then iterates over the ViewEdges
+ * Each ViewEdge of the current list starts a new chain.
+ * The chaining operator then iterates over the ViewEdges
* of the ViewMap using the user specified iterator.
* This operator only iterates using the increment operator and is therefore unidirectional.
* \param it:
@@ -71,19 +73,22 @@ class Operators {
* \param pred:
* The predicate on the ViewEdge that expresses the stopping condition.
* \param modifier:
- * A function that takes a ViewEdge as argument and that is used to modify the processed ViewEdge
- * state (the timestamp incrementation is a typical illustration of such a modifier)
+ * A function that takes a ViewEdge as argument and that is used to modify the
+ * processed ViewEdge state (the timestamp incrementation is a typical illustration of
+ * such a modifier)
*/
static int chain(ViewEdgeInternal::ViewEdgeIterator &it,
UnaryPredicate1D &pred,
UnaryFunction1D_void &modifier);
/*! Builds a set of chains from the current set of ViewEdges.
- * Each ViewEdge of the current list starts a new chain. The chaining operator then iterates over the ViewEdges
+ * Each ViewEdge of the current list starts a new chain. The chaining operator then iterates
+ * over the ViewEdges
* of the ViewMap using the user specified iterator.
* This operator only iterates using the increment operator and is therefore unidirectional.
- * This chaining operator is different from the previous one because it doesn't take any modifier as argument.
- * Indeed, the time stamp (insuring that a ViewEdge is processed one time) is automatically managed in this case.
+ * This chaining operator is different from the previous one because it doesn't take any
+ * modifier as argument. Indeed, the time stamp (insuring that a ViewEdge is processed one time)
+ * is automatically managed in this case.
* \param it:
* The iterator on the ViewEdges of the ViewMap. It contains the chaining rule.
* \param pred:
@@ -92,13 +97,14 @@ class Operators {
static int chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &pred);
/*! Builds a set of chains from the current set of ViewEdges.
- * Each ViewEdge of the current list potentially starts a new chain. The chaining operator then iterates over
- * the ViewEdges of the ViewMap using the user specified iterator.
- * This operator iterates both using the increment and decrement operators and is therefore bidirectional.
- * This operator works with a ChainingIterator which contains the chaining rules. It is this last one which can
- * be told to chain only edges that belong to the selection or not to process twice a ViewEdge during the chaining.
- * Each time a ViewEdge is added to a chain, its chaining time stamp is incremented. This allows you to keep track
- * of the number of chains to which a ViewEdge belongs to.
+ * Each ViewEdge of the current list potentially starts a new chain. The chaining operator then
+ * iterates over the ViewEdges of the ViewMap using the user specified iterator.
+ * This operator iterates both using the increment and decrement operators and is therefore
+ * bidirectional. This operator works with a ChainingIterator which contains the chaining rules.
+ * It is this last one which can be told to chain only edges that belong to the selection or not
+ * to process twice a ViewEdge during the chaining. Each time a ViewEdge is added to a chain,
+ * its chaining time stamp is incremented. This allows you to keep track of the number of chains
+ * to which a ViewEdge belongs to.
* \param it:
* The ChainingIterator on the ViewEdges of the ViewMap. It contains the chaining rule.
* \param pred:
@@ -106,16 +112,17 @@ class Operators {
*/
static int bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred);
- /*! The only difference with the above bidirectional chaining algorithm is that we don't need to pass a stopping
- * criterion. This might be desirable when the stopping criterion is already contained in the iterator definition.
- * Builds a set of chains from the current set of ViewEdges.
- * Each ViewEdge of the current list potentially starts a new chain. The chaining operator then iterates over
- * the ViewEdges of the ViewMap using the user specified iterator.
- * This operator iterates both using the increment and decrement operators and is therefore bidirectional.
- * This operator works with a ChainingIterator which contains the chaining rules. It is this last one which can be
- * told to chain only edges that belong to the selection or not to process twice a ViewEdge during the chaining.
- * Each time a ViewEdge is added to a chain, its chaining time stamp is incremented. This allows you to keep track
- * of the number of chains to which a ViewEdge belongs to.
+ /*! The only difference with the above bidirectional chaining algorithm is that we don't need to
+ * pass a stopping criterion. This might be desirable when the stopping criterion is already
+ * contained in the iterator definition. Builds a set of chains from the current set of
+ * ViewEdges. Each ViewEdge of the current list potentially starts a new chain. The chaining
+ * operator then iterates over the ViewEdges of the ViewMap using the user specified iterator.
+ * This operator iterates both using the increment and decrement operators and is therefore
+ * bidirectional. This operator works with a ChainingIterator which contains the chaining rules.
+ * It is this last one which can be told to chain only edges that belong to the selection or not
+ * to process twice a ViewEdge during the chaining. Each time a ViewEdge is added to a chain,
+ * its chaining time stamp is incremented. This allows you to keep track of the number of chains
+ * to which a ViewEdge belongs to.
* \param it:
* The ChainingIterator on the ViewEdges of the ViewMap. It contains the chaining rule.
*/
@@ -123,8 +130,8 @@ class Operators {
/*! Splits each chain of the current set of chains in a sequential way.
* The points of each chain are processed (with a specified sampling) sequentially.
- * Each time a user specified starting condition is verified, a new chain begins and ends as soon as a
- * user-defined stopping predicate is verified.
+ * Each time a user specified starting condition is verified, a new chain begins and ends as
+ * soon as a user-defined stopping predicate is verified.
* This allows chains overlapping rather than chains partitioning.
* The first point of the initial chain is the first point of one of the resulting chains.
* The splitting ends when no more chain can start.
@@ -133,30 +140,32 @@ class Operators {
* \param stoppingPred:
* The predicate on a point that expresses the stopping condition
* \param sampling:
- * The resolution used to sample the chain for the predicates evaluation. (The chain is not actually
- * resampled, a virtual point only progresses along the curve using this resolution)
+ * The resolution used to sample the chain for the predicates evaluation.
+ * (The chain is not actually resampled, a virtual point only progresses along the
+ * curve using this resolution)
*/
static int sequentialSplit(UnaryPredicate0D &startingPred,
UnaryPredicate0D &stoppingPred,
float sampling = 0.0f);
/*! Splits each chain of the current set of chains in a sequential way.
- * The points of each chain are processed (with a specified sampling) sequentially and each time a user
- * specified condition is verified, the chain is split into two chains.
+ * The points of each chain are processed (with a specified sampling) sequentially and each time
+ * a user specified condition is verified, the chain is split into two chains.
* The resulting set of chains is a partition of the initial chain
* \param pred:
* The predicate on a point that expresses the splitting condition
* \param sampling:
- * The resolution used to sample the chain for the predicate evaluation. (The chain is not actually
- * resampled, a virtual point only progresses along the curve using this resolution)
+ * The resolution used to sample the chain for the predicate evaluation.
+ * (The chain is not actually resampled, a virtual point only progresses along the
+ * curve using this resolution)
*/
static int sequentialSplit(UnaryPredicate0D &pred, float sampling = 0.0f);
/*! Splits the current set of chains in a recursive way.
- * We process the points of each chain (with a specified sampling) to find the point minimizing a specified
- * function. The chain is split in two at this point and the two new chains are processed in the same way.
- * The recursivity level is controlled through a predicate 1D that expresses a stopping condition
- * on the chain that is about to be processed.
+ * We process the points of each chain (with a specified sampling) to find the point
+ * minimizing a specified function. The chain is split in two at this point and the two new
+ * chains are processed in the same way. The recursivity level is controlled through a
+ * predicate 1D that expresses a stopping condition on the chain that is about to be processed.
* \param func:
* The Unary Function evaluated at each point of the chain.
* The splitting point is the point minimizing this function
@@ -165,42 +174,45 @@ class Operators {
* This predicate is evaluated for each curve before it actually gets split.
* If pred(chain) is true, the curve won't be split anymore.
* \param sampling:
- * The resolution used to sample the chain for the predicates evaluation. (The chain is not actually
- * resampled, a virtual point only progresses along the curve using this resolution)
+ * The resolution used to sample the chain for the predicates evaluation. (The chain
+ * is not actually resampled, a virtual point only progresses along the curve using
+ * this resolution)
*/
static int recursiveSplit(UnaryFunction0D<double> &func,
UnaryPredicate1D &pred,
float sampling = 0);
/*! Splits the current set of chains in a recursive way.
- * We process the points of each chain (with a specified sampling) to find the point minimizing a specified
- * function. The chain is split in two at this point and the two new chains are processed in the same way.
- * The user can specify a 0D predicate to make a first selection on the points that can potentially be split.
- * A point that doesn't verify the 0D predicate won't be candidate in realizing the min.
- * The recursivity level is controlled through a predicate 1D that expresses a stopping condition
- * on the chain that is about to be processed.
+ * We process the points of each chain (with a specified sampling) to find the point minimizing
+ * a specified function. The chain is split in two at this point and the two new chains are
+ * processed in the same way. The user can specify a 0D predicate to make a first selection on
+ * the points that can potentially be split. A point that doesn't verify the 0D predicate
+ * won't be candidate in realizing the min. The recursivity level is controlled through a
+ * predicate 1D that expresses a stopping condition on the chain that is about to be processed.
* \param func:
* The Unary Function evaluated at each point of the chain.
* The splitting point is the point minimizing this function
* \param pred0d:
- * The Unary Predicate 0D used to select the candidate points where the split can occur.
- * For example, it is very likely that would rather have your chain splitting around its middle point
- * than around one of its extremities. A 0D predicate working on the curvilinear abscissa allows
- * to add this kind of constraints.
+ * The Unary Predicate 0D used to select the candidate points where the split can
+ * occur. For example, it is very likely that would rather have your chain splitting
+ * around its middle point than around one of its extremities. A 0D predicate working
+ * on the curvilinear abscissa allows to add this kind of constraints.
* \param pred:
* The Unary Predicate ex pressing the recursivity stopping condition.
* This predicate is evaluated for each curve before it actually gets split.
* If pred(chain) is true, the curve won't be split anymore.
* \param sampling:
- * The resolution used to sample the chain for the predicates evaluation. (The chain is not actually
- * resampled, a virtual point only progresses along the curve using this resolution)
+ * The resolution used to sample the chain for the predicates evaluation. (The chain
+ * is not actually resampled, a virtual point only progresses along the curve using
+ * this resolution)
*/
static int recursiveSplit(UnaryFunction0D<double> &func,
UnaryPredicate0D &pred0d,
UnaryPredicate1D &pred,
float sampling = 0.0f);
- /*! Sorts the current set of chains (or viewedges) according to the comparison predicate given as argument.
+ /*! Sorts the current set of chains (or viewedges)
+ * according to the comparison predicate given as argument.
* \param pred:
* The binary predicate used for the comparison
*/
diff --git a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp
index 20dac647cdc..e7428c795fc 100644
--- a/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/stroke/PSStrokeRenderer.cpp
@@ -70,8 +70,8 @@ void PSStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
svRep[2] = *(v[2]);
color[0] = svRep[0]->color();
- //color[1] = svRep[1]->color();
- //color[2] = svRep[2]->color();
+ // color[1] = svRep[1]->color();
+ // color[2] = svRep[2]->color();
_ofstream << "newpath" << endl;
_ofstream << (color[0])[0] << " " << (color[0])[1] << " " << (color[0])[2] << " setrgbcolor"
diff --git a/source/blender/freestyle/intern/stroke/Predicates0D.h b/source/blender/freestyle/intern/stroke/Predicates0D.h
index f511c0ceade..90b6d99f2db 100644
--- a/source/blender/freestyle/intern/stroke/Predicates0D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates0D.h
@@ -65,8 +65,8 @@ class UnaryPredicate0D {
/*! The () operator. Must be overload by inherited classes.
* \param it:
- * The Interface0DIterator pointing onto the Interface0D at which we wish to evaluate the predicate.
- * \return true if the condition is satisfied, false otherwise.
+ * The Interface0DIterator pointing onto the Interface0D at which we wish to evaluate the
+ * predicate. \return true if the condition is satisfied, false otherwise.
*/
virtual int operator()(Interface0DIterator &it);
diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h
index be70907b51b..3560f29ee36 100644
--- a/source/blender/freestyle/intern/stroke/Predicates1D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates1D.h
@@ -183,8 +183,8 @@ class FalseUP1D : public UnaryPredicate1D {
};
// QuantitativeInvisibilityUP1D
-/*! Returns true if the Quantitative Invisibility evaluated at an Interface1D, using the QuantitativeInvisibilityF1D
- * functor, equals a certain user-defined value.
+/*! Returns true if the Quantitative Invisibility evaluated at an Interface1D, using the
+ * QuantitativeInvisibilityF1D functor, equals a certain user-defined value.
*/
class QuantitativeInvisibilityUP1D : public UnaryPredicate1D {
public:
@@ -344,7 +344,8 @@ class EqualToChainingTimeStampUP1D : public UnaryPredicate1D {
};
// ShapeUP1D
-/*! Returns true if the shape to which the Interface1D belongs to has the same Id as the one specified by the user. */
+/*! Returns true if the shape to which the Interface1D belongs to has the same Id as the one
+ * specified by the user. */
class ShapeUP1D : public UnaryPredicate1D {
private:
Id _id;
@@ -487,7 +488,8 @@ class FalseBP1D : public BinaryPredicate1D {
};
// Length2DBP1D
-/*! Returns true if the 2D length of the Interface1D i1 is less than the 2D length of the Interface1D i2. */
+/*! Returns true if the 2D length of the Interface1D i1 is less than the 2D length of the
+ * Interface1D i2. */
class Length2DBP1D : public BinaryPredicate1D {
public:
/*! Returns the string "Length2DBP1D" */
@@ -538,7 +540,8 @@ class SameShapeIdBP1D : public BinaryPredicate1D {
};
// ViewMapGradientNormBP1D
-/*! Returns true if the evaluation of the Gradient norm Function is higher for Interface1D i1 than for i2. */
+/*! Returns true if the evaluation of the Gradient norm Function is higher for Interface1D i1 than
+ * for i2. */
class ViewMapGradientNormBP1D : public BinaryPredicate1D {
private:
Functions1D::GetViewMapGradientNormF1D _func;
diff --git a/source/blender/freestyle/intern/stroke/QInformationMap.h b/source/blender/freestyle/intern/stroke/QInformationMap.h
index 99393a8949c..d3a4218f9d7 100644
--- a/source/blender/freestyle/intern/stroke/QInformationMap.h
+++ b/source/blender/freestyle/intern/stroke/QInformationMap.h
@@ -38,7 +38,7 @@ class QInformationMap : public InformationMap {
QInformationMap(const QInformationMap &);
QInformationMap &operator=(const QInformationMap &);
- //float getSmoothedPixel(int x, int y, float sigma = 0.2f);1
+ // float getSmoothedPixel(int x, int y, float sigma = 0.2f);1
virtual float getMean(int x, int y);
virtual void retrieveMeanAndVariance(int x, int y, float &oMean, float &oVariance);
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index 7b6e53138bb..ff0cd64fdaa 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -484,7 +484,7 @@ void Stroke::setLength(float iLength)
float Stroke::ComputeSampling(int iNVertices)
{
- if (iNVertices <= (int)_Vertices.size()) //soc
+ if (iNVertices <= (int)_Vertices.size()) // soc
return _sampling;
float sampling = _Length / (float)(iNVertices - _Vertices.size() + 1);
@@ -563,7 +563,7 @@ int Stroke::Resample(int iNPoints)
if (s->_resampled == false) {
if ((!checkEveryone) && (s->_length < meanlength))
continue;
- //resample
+ // resample
s->_n = s->_n + 1;
s->_sampling = s->_length / (float)(s->_n + 1);
s->_resampled = resampled = true;
@@ -577,10 +577,11 @@ int Stroke::Resample(int iNPoints)
checkEveryone = true;
}
if (N < NPointsToAdd) {
- // fatal error, likely because _Length is inconsistent with the stroke length computed with the vertices
+ // fatal error, likely because _Length is inconsistent with the stroke length computed with the
+ // vertices
return -1;
}
- //actually resample:
+ // actually resample:
for (vector<StrokeSegment>::iterator s = strokeSegments.begin(), send = strokeSegments.end();
s != send;
++s) {
@@ -617,7 +618,7 @@ int Stroke::Resample(int iNPoints)
int Stroke::Resample(float iSampling)
{
- //cerr << "old size :" << strokeVerticesSize() << endl;
+ // cerr << "old size :" << strokeVerticesSize() << endl;
if (iSampling == 0)
return 0;
if (iSampling >= _sampling)
@@ -625,7 +626,7 @@ int Stroke::Resample(float iSampling)
_sampling = iSampling;
// Resample...
- //real curvilinearLength = 0.0f;
+ // real curvilinearLength = 0.0f;
vertex_container newVertices;
real t = 0.0f;
const real limit = 0.99;
@@ -641,17 +642,17 @@ int Stroke::Resample(float iSampling)
Vec2r vec_tmp(b - a);
real norm_var = vec_tmp.norm();
if (norm_var <= _sampling) {
- //curvilinearLength += norm_var;
+ // curvilinearLength += norm_var;
++it;
++next;
continue;
}
- //curvilinearLength += _sampling;
+ // curvilinearLength += _sampling;
t = _sampling / norm_var;
while (t < limit) {
newVertex = new StrokeVertex(&(*it), &(*next), t);
- //newVertex->setCurvilinearAbscissa(curvilinearLength);
+ // newVertex->setCurvilinearAbscissa(curvilinearLength);
newVertices.push_back(newVertex);
t = t + _sampling / norm_var;
}
@@ -798,7 +799,7 @@ Stroke::vertex_iterator Stroke::vertices_begin(float sampling)
if ((sampling != 0) && (sampling < _sampling))
Resample(sampling);
return vertex_iterator(_Vertices.begin(), _Vertices.begin(), _Vertices.end());
- //return _Vertices.begin();
+ // return _Vertices.begin();
}
#if 0
@@ -834,7 +835,6 @@ Stroke::vertex_container::reverse_iterator Stroke::vertices_last(float sampling)
return _Vertices.rbegin();
}
-
inline Vec3r shaded_color(int iCombination = 0) const;
inline Vec<3, real> Stroke::orientation2d(const_vertex_iterator it) const
@@ -871,7 +871,7 @@ Material Stroke::material() const
int Stroke::qi() const
{
const_vertex_iterator v = vertices_begin(), vend = vertices_end();
- int qi_= (*v)->qi();
+ int qi_ = (*v)->qi();
for (; v != vend; ++v) {
if ((*v)->qi() != qi_)
Exception::raiseException();
@@ -965,10 +965,9 @@ float Stroke::shape_importance(int iCombination) const
return shape_importance_edge_function<Stroke>(*this, iCombination);
}
-
-float Stroke::local_average_depth(int iCombination ) const
+float Stroke::local_average_depth(int iCombination) const
{
- return local_average_depth_edge_function<Stroke >(*this, iCombination);
+ return local_average_depth_edge_function<Stroke>(*this, iCombination);
}
float Stroke::local_depth_variance(int iCombination) const
@@ -976,7 +975,7 @@ float Stroke::local_depth_variance(int iCombination) const
return local_depth_variance_edge_function<Stroke>(*this, iCombination);
}
-real Stroke::local_average_density(float sigma , int iCombination ) const
+real Stroke::local_average_density(float sigma, int iCombination) const
{
return density_edge_function<Stroke>(*this, iCombination);
}
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index 3eae5e91b6a..ec722516d2a 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -143,8 +143,8 @@ class StrokeAttribute {
}
/*! Returns the attribute's thickness.
- * \return an array of 2 floats. the first value is the thickness on the right of the vertex when following
- * the stroke, the second one is the thickness on the left.
+ * \return an array of 2 floats. the first value is the thickness on the right of the vertex
+ * when following the stroke, the second one is the thickness on the left.
*/
inline const float *getThickness() const
{
@@ -163,7 +163,8 @@ class StrokeAttribute {
return _thickness[1];
}
- /*! Returns the thickness on the right and on the left of the vertex when following the stroke. */
+ /*! Returns the thickness on the right and on the left of the vertex when following the stroke.
+ */
inline Vec2f getThicknessRL() const
{
return Vec2f(_thickness[0], _thickness[1]);
@@ -462,8 +463,8 @@ class StrokeVertex : public CurvePoint {
_CurvilignAbscissa = iAbscissa;
}
- /*! sets the Stroke's length (it's only a value stored by the Stroke Vertex, it won't change the real
- * Stroke's length.)
+ /*! sets the Stroke's length (it's only a value stored by the Stroke Vertex, it won't change the
+ * real Stroke's length.)
*/
inline void setStrokeLength(float iLength)
{
@@ -498,7 +499,8 @@ class StrokeVertexIterator;
/*! Class to define a stroke.
* A stroke is made of a set of 2D vertices (StrokeVertex), regularly spaced out.
* This set of vertices defines the stroke's backbone geometry.
- * Each of these stroke vertices defines the stroke's shape and appearance at this vertex position.
+ * Each of these stroke vertices defines the stroke's shape and appearance at this vertex
+ * position.
*/
class Stroke : public Interface1D {
public: // Implementation of Interface1D
@@ -532,7 +534,7 @@ class Stroke : public Interface1D {
const_vertex_iterator;
public:
- //typedef StrokeVertex vertex_type;
+ // typedef StrokeVertex vertex_type;
private:
vertex_container _Vertices; //! The stroke's backbone vertices
@@ -575,8 +577,8 @@ class Stroke : public Interface1D {
Stroke &operator=(const Stroke &iBrother);
/*! Compute the sampling needed to get iNVertices vertices.
- * If the specified number of vertices is less than the actual number of vertices, the actual sampling value
- * is returned. (To remove Vertices, use the RemoveVertex() method of this class).
+ * If the specified number of vertices is less than the actual number of vertices, the actual
+ * sampling value is returned. (To remove Vertices, use the RemoveVertex() method of this class).
* \param iNVertices:
* The number of StrokeVertices we eventually want in our Stroke.
* \return the sampling that must be used in the Resample(float) method.
@@ -586,11 +588,10 @@ class Stroke : public Interface1D {
float ComputeSampling(int iNVertices);
/*! Resampling method.
- * Resamples the curve so that it eventually has iNPoints. That means it is going to add iNPoints-vertices_size,
- * if vertices_size is the number of points we already have.
- * If vertices_size >= iNPoints, no resampling is done.
- * \param iNPoints:
- * The number of vertices we eventually want in our stroke.
+ * Resamples the curve so that it eventually has iNPoints. That means it is going to add
+ * iNPoints-vertices_size, if vertices_size is the number of points we already have. If
+ * vertices_size >= iNPoints, no resampling is done. \param iNPoints: The number of vertices we
+ * eventually want in our stroke.
*/
int Resample(int iNPoints);
@@ -838,11 +839,9 @@ class Stroke : public Interface1D {
const_vertex_iterator vertices_end() const;
vertex_iterator vertices_end();
- /*! Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can specify a sampling
- * value to resample the Stroke on the fly if needed.
- * \param t:
- * The resampling value with which we want our Stroke to be resampled.
- * If 0 is specified, no resampling is done.
+ /*! Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can
+ * specify a sampling value to resample the Stroke on the fly if needed. \param t: The resampling
+ * value with which we want our Stroke to be resampled. If 0 is specified, no resampling is done.
*/
StrokeInternal::StrokeVertexIterator strokeVerticesBegin(float t = 0.0f);
diff --git a/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h b/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
index e9d4659f320..ccf5773a4c8 100644
--- a/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
+++ b/source/blender/freestyle/intern/stroke/StrokeAdvancedIterators.h
@@ -51,7 +51,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
typedef vertex_iterator_base<vertex_nonconst_traits> iterator;
typedef vertex_iterator_base<vertex_const_traits> const_iterator;
- //protected:
+ // protected:
public:
vertex_container_iterator _it;
vertex_container_iterator _begin;
@@ -59,7 +59,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
public:
friend class Stroke;
- //friend class vertex_iterator;
+ // friend class vertex_iterator;
inline vertex_iterator_base() : parent_class()
{
@@ -79,7 +79,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
_end = iBrother._end;
}
- //protected: //FIXME
+ // protected: //FIXME
public:
inline vertex_iterator_base(vertex_container_iterator it,
vertex_container_iterator begin,
diff --git a/source/blender/freestyle/intern/stroke/StrokeIterators.h b/source/blender/freestyle/intern/stroke/StrokeIterators.h
index 1999b028424..624f2a03877 100644
--- a/source/blender/freestyle/intern/stroke/StrokeIterators.h
+++ b/source/blender/freestyle/intern/stroke/StrokeIterators.h
@@ -34,15 +34,14 @@ namespace StrokeInternal {
/////////////////////////////////////////////////
/*! Class defining an iterator designed to iterate over the StrokeVertex of a Stroke.
- * An instance of a StrokeVertexIterator can only be obtained from a Stroke by calling strokeVerticesBegin() or
- * strokeVerticesEnd().
- * It is iterating over the same vertices as an Interface0DIterator.
- * The difference resides in the object access. Indeed, an Interface0DIterator allows only an access to an
- * Interface0D whereas we could need to access the specialized StrokeVertex type. In this case, one
- * should use a StrokeVertexIterator.
- * The castToInterface0DIterator() method is useful to get an Interface0DIterator from a StrokeVertexIterator in
- * order to call any functions of the type UnaryFunction0D.
- * \attention In the scripting language, you must call \code it2 = StrokeVertexIterator(it1) \endcode instead of
+ * An instance of a StrokeVertexIterator can only be obtained from a Stroke by calling
+ * strokeVerticesBegin() or strokeVerticesEnd(). It is iterating over the same vertices as an
+ * Interface0DIterator. The difference resides in the object access. Indeed, an Interface0DIterator
+ * allows only an access to an Interface0D whereas we could need to access the specialized
+ * StrokeVertex type. In this case, one should use a StrokeVertexIterator. The
+ * castToInterface0DIterator() method is useful to get an Interface0DIterator from a
+ * StrokeVertexIterator in order to call any functions of the type UnaryFunction0D. \attention In
+ * the scripting language, you must call \code it2 = StrokeVertexIterator(it1) \endcode instead of
* \code it2 = it1 \endcode where \a it1 and \a it2 are 2 StrokeVertexIterator.
* Otherwise, incrementing \a it1 will also increment \a it2.
*/
@@ -84,9 +83,9 @@ class StrokeVertexIterator : public Interface0DIteratorNested {
}
/*! operator=
- * \attention In the scripting language, you must call \code it2 = StrokeVertexIterator(it1) \endcode instead of
- * \code it2 = it1 \endcode where \a it1 and \a it2 are 2 StrokeVertexIterator.
- * Otherwise, incrementing \a it1 will also increment \a it2.
+ * \attention In the scripting language, you must call \code it2 = StrokeVertexIterator(it1)
+ * \endcode instead of \code it2 = it1 \endcode where \a it1 and \a it2 are 2
+ * StrokeVertexIterator. Otherwise, incrementing \a it1 will also increment \a it2.
*/
StrokeVertexIterator &operator=(const StrokeVertexIterator &vi)
{
diff --git a/source/blender/freestyle/intern/stroke/StrokeRenderer.h b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
index 03e6893b578..79767b48d83 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRenderer.h
@@ -116,7 +116,8 @@ class TextureManager {
/* */
/**********************************/
-/*! Class to render a stroke. Creates a triangle strip and stores it strip is lazily created at the first rendering */
+/*! Class to render a stroke. Creates a triangle strip and stores it strip is lazily created at the
+ * first rendering */
class StrokeRenderer {
public:
StrokeRenderer();
@@ -130,7 +131,7 @@ class StrokeRenderer {
// lazy, checks if it has already been done
static bool loadTextures();
- //static unsigned int getTextureIndex(unsigned int index);
+ // static unsigned int getTextureIndex(unsigned int index);
static TextureManager *_textureManager;
#ifdef WITH_CXX_GUARDEDALLOC
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
index 026a7b2fc8f..a6c00f66056 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
@@ -105,7 +105,7 @@ static bool notValid(Vec2r p)
}
#if 0
-static real crossP(const Vec2r& A, const Vec2r& B)
+static real crossP(const Vec2r &A, const Vec2r &B)
{
return A[0] * B[1] - A[1] * B[0];
}
@@ -113,7 +113,7 @@ static real crossP(const Vec2r& A, const Vec2r& B)
void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
{
- //computeParameterization();
+ // computeParameterization();
if (iStrokeVertices.size() < 2) {
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "Warning: strip has less than 2 vertices" << endl;
@@ -134,11 +134,11 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
StrokeVertex *sv, *sv2, *svPrev;
int orientationErrors = 0;
- //special case of first vertex
+ // special case of first vertex
v2 = v = iStrokeVertices.begin();
++v2;
sv = *v;
- vPrev = v; //in case the stroke has only 2 vertices;
+ vPrev = v; // in case the stroke has only 2 vertices;
sv2 = *v2;
Vec2r dir(sv2->getPoint() - sv->getPoint());
Vec2r orthDir(-dir[1], dir[0]);
@@ -195,7 +195,7 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
svPrev = (*vPrev);
Vec2r p(sv->getPoint()), p2(sv2->getPoint()), pPrev(svPrev->getPoint());
- //direction and orthogonal vector to the next segment
+ // direction and orthogonal vector to the next segment
Vec2r dir(p2 - p);
float dirNorm = dir.norm();
dir.normalize();
@@ -215,7 +215,7 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
}
}
- //direction and orthogonal vector to the previous segment
+ // direction and orthogonal vector to the previous segment
Vec2r dirPrev(p - pPrev);
float dirPrevNorm = dirPrev.norm();
dirPrev.normalize();
@@ -287,7 +287,7 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
}
} // end of for
- //special case of last vertex
+ // special case of last vertex
sv = *v;
sv2 = *vPrev;
dir = Vec2r(sv->getPoint() - sv2->getPoint());
@@ -342,7 +342,7 @@ void Strip::createStrip(const vector<StrokeVertex *> &iStrokeVertices)
#endif
_averageThickness /= float(iStrokeVertices.size() - 2);
- //I did not use the first and last vertex for the average
+ // I did not use the first and last vertex for the average
if (iStrokeVertices.size() < 3)
_averageThickness = 0.5 * (thicknessLast[1] + thicknessLast[0] + thickness[0] + thickness[1]);
@@ -379,7 +379,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
}
}
- //return;
+ // return;
if (iStrokeVertices.size() < 2)
return;
int i = 0, j;
@@ -389,7 +389,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
bool singu1 = false, singu2 = false;
int timeSinceSingu1 = 0, timeSinceSingu2 = 0;
- //special case of first vertex
+ // special case of first vertex
v = iStrokeVertices.begin();
for (vend = iStrokeVertices.end(); v != vend; v++) {
v2 = v;
@@ -416,7 +416,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
int toto = i - timeSinceSingu1;
if (toto < 0)
cerr << "Stephane dit \"Toto\"" << endl;
- //traverse all the vertices of the singularity and average them
+ // traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu1; j <= i; j++)
avP = Vec2r(avP + _vertices[2 * j]->point2d());
@@ -437,7 +437,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
int toto = i - timeSinceSingu2;
if (toto < 0)
cerr << "Stephane dit \"Toto\"" << endl;
- //traverse all the vertices of the singularity and average them
+ // traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu2; j <= i; j++)
avP = Vec2r(avP + _vertices[2 * j + 1]->point2d());
@@ -453,7 +453,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
}
if (singu1) {
- //traverse all the vertices of the singularity and average them
+ // traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu1; j < i; j++)
avP = Vec2r(avP + _vertices[2 * j]->point2d());
@@ -462,7 +462,7 @@ void Strip::cleanUpSingularities(const vector<StrokeVertex *> &iStrokeVertices)
_vertices[2 * j]->setPoint2d(avP);
}
if (singu2) {
- //traverse all the vertices of the singularity and average them
+ // traverse all the vertices of the singularity and average them
Vec2r avP(0.0, 0.0);
for (j = i - timeSinceSingu2; j < i; j++)
avP = Vec2r(avP + _vertices[2 * j + 1]->point2d());
@@ -498,8 +498,8 @@ void Strip::setVertexColor(const vector<StrokeVertex *> &iStrokeVertices)
_vertices[i]->setAlpha(sv->attribute().getAlpha());
i++;
#if 0
- cerr << "col=("<<sv->attribute().getColor()[0] << ", "
- << sv->attribute().getColor()[1] << ", " << sv->attribute().getColor()[2] << ")" << endl;
+ cerr << "col=(" << sv->attribute().getColor()[0] << ", " << sv->attribute().getColor()[1]
+ << ", " << sv->attribute().getColor()[2] << ")" << endl;
#endif
}
}
@@ -545,8 +545,8 @@ void Strip::computeTexCoordWithTips(const vector<StrokeVertex *> &iStrokeVertice
fact = (float(tiles) + 0.5) / l;
#if 0
- cerr << "l=" << l << " tiles=" << tiles << " _averageThicnkess="
- << _averageThickness << " strokeLength=" << (*v)->strokeLength() << endl;
+ cerr << "l=" << l << " tiles=" << tiles << " _averageThicnkess=" << _averageThickness
+ << " strokeLength=" << (*v)->strokeLength() << endl;
#endif
vector<StrokeVertexRep *>::iterator currentSV = _vertices.begin();
@@ -690,7 +690,7 @@ void Strip::computeTexCoordWithTips(const vector<StrokeVertex *> &iStrokeVertice
for (i = 0; i < _sizeStrip; i++)
cerr << "(" << _texCoord[i][0] << ", " << _texCoord[i][1] << ") ";
- cerr << endl;
+ cerr << endl;
Vec2r vec_tmp;
for (i = 0; i < _sizeStrip / 2; i++)
@@ -718,7 +718,7 @@ StrokeRep::StrokeRep()
if (ptm)
_textureId = ptm->getDefaultTextureId();
#if 0
- _averageTextureAlpha = 0.5; //default value
+ _averageTextureAlpha = 0.5; //default value
if (_strokeType == OIL_STROKE)
_averageTextureAlpha = 0.75;
if (_strokeType >= NO_BLEND_STROKE)
@@ -749,7 +749,7 @@ StrokeRep::StrokeRep(Stroke *iStroke)
}
#if 0
- _averageTextureAlpha = 0.5; //default value
+ _averageTextureAlpha = 0.5; //default value
if (_strokeType == OIL_STROKE)
_averageTextureAlpha = 0.75;
if (_strokeType >= NO_BLEND_STROKE)
@@ -760,7 +760,7 @@ StrokeRep::StrokeRep(Stroke *iStroke)
StrokeRep::StrokeRep(const StrokeRep &iBrother)
{
- //soc unused - int i = 0;
+ // soc unused - int i = 0;
_stroke = iBrother._stroke;
_strokeType = iBrother._strokeType;
_textureId = iBrother._textureId;
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h
index 5d58b10184f..a6d5c20624e 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.h
@@ -266,11 +266,12 @@ class StrokeRep {
{
_material = mat;
}
- /*
+#if 0
inline void setMTex(int idx, MTex *mtex_ptr)
{
_mtex[idx] = mtex_ptr;
- }*/
+ }
+#endif
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeRep")
diff --git a/source/blender/freestyle/intern/stroke/StrokeShader.h b/source/blender/freestyle/intern/stroke/StrokeShader.h
index 3f312395559..7b1f12a8c9d 100644
--- a/source/blender/freestyle/intern/stroke/StrokeShader.h
+++ b/source/blender/freestyle/intern/stroke/StrokeShader.h
@@ -44,20 +44,17 @@ class Stroke;
* Any Stroke Shader must inherit from this class and overload the shade() method.
* A StrokeShader is designed to modify any Stroke's attribute such as Thickness, Color,
* Geometry, Texture, Blending mode...
- * The basic way to achieve this operation consists in iterating over the StrokeVertices of the Stroke
- * and to modify each one's StrokeAttribute.
- * Here is a python code example of such an iteration:
- * \code
- * it = ioStroke.strokeVerticesBegin()
- * while not it.isEnd():
- * att = it.getObject().attribute()
+ * The basic way to achieve this operation consists in iterating over the StrokeVertices of the
+ * Stroke and to modify each one's StrokeAttribute. Here is a python code example of such an
+ * iteration: \code it = ioStroke.strokeVerticesBegin() while not it.isEnd(): att =
+ * it.getObject().attribute()
* ## perform here any attribute modification
* it.increment()
* \endcode
* Here is a C++ code example of such an iteration:
* \code
- * for (StrokeInternal::StrokeVertexIterator v = ioStroke.strokeVerticesBegin(), vend = ioStroke.strokeVerticesEnd();
- * v != vend;
+ * for (StrokeInternal::StrokeVertexIterator v = ioStroke.strokeVerticesBegin(), vend =
+ * ioStroke.strokeVerticesEnd(); v != vend;
* ++v)
* {
* StrokeAttribute& att = v->attribute();
diff --git a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
index e135f83cfef..8d2e554a67b 100644
--- a/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeTesselator.cpp
@@ -72,7 +72,7 @@ NodeGroup *StrokeTesselator::Tesselate(StrokeVertexIterator begin, StrokeVertexI
NodeGroup *group = new NodeGroup;
NodeShape *tshape = new NodeShape;
group->AddChild(tshape);
- //tshape->material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
+ // tshape->material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
tshape->setFrsMaterial(_FrsMaterial);
for (StrokeVertexIterator c = begin, cend = end; c != cend; c++) {
diff --git a/source/blender/freestyle/intern/system/PointerSequence.h b/source/blender/freestyle/intern/system/PointerSequence.h
index 015033beeb4..d136632f060 100644
--- a/source/blender/freestyle/intern/system/PointerSequence.h
+++ b/source/blender/freestyle/intern/system/PointerSequence.h
@@ -23,23 +23,25 @@
*
* PointerSequence
*
- * Produces a wrapped version of a sequence type (std::vector, std::deque, std::list) that will take ownership of
- * pointers that it stores. Those pointers will be deleted in its destructor.
+ * Produces a wrapped version of a sequence type (std::vector, std::deque, std::list) that will
+ * take ownership of pointers that it stores. Those pointers will be deleted in its destructor.
*
- * Because the contained pointers are wholly owned by the sequence, you cannot make a copy of the sequence.
- * Making a copy would result in a double free.
+ * Because the contained pointers are wholly owned by the sequence, you cannot make a copy of the
+ * sequence. Making a copy would result in a double free.
*
- * This is a no-frills class that provides no additional facilities. The user is responsible for managing any
- * pointers that are removed from the list, and for making sure that any pointers contained in the class are not
- * deleted elsewhere. Because this class does no reference counting, the user must also make sure that any pointer
- * appears only once in the sequence.
+ * This is a no-frills class that provides no additional facilities. The user is responsible for
+ * managing any pointers that are removed from the list, and for making sure that any pointers
+ * contained in the class are not deleted elsewhere. Because this class does no reference
+ * counting, the user must also make sure that any pointer appears only once in the sequence.
*
* If more sophisticated facilities are needed, use tr1::shared_ptr or boost::shared_ptr.
- * This class is only intended to allow one to eke by in projects where tr1 or boost are not available.
+ * This class is only intended to allow one to eke by in projects where tr1 or boost are not
+ * available.
*
- * Usage: The template takes two parameters, the standard container, and the class held in the container. This is a
- * limitation of C++ templates, where T::iterator is not a type when T is a template parameter. If anyone knows a way
- * around this limitation, then the second parameter can be eliminated.
+ * Usage: The template takes two parameters, the standard container, and the class held in the
+ * container. This is a limitation of C++ templates, where T::iterator is not a type when T is a
+ * template parameter. If anyone knows a way around this limitation, then the second parameter can
+ * be eliminated.
*
* Example:
* PointerSequence<vector<Widget*>, Widget*> v;
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h
index bcb36d8d6b5..1fed6a00463 100644
--- a/source/blender/freestyle/intern/system/PythonInterpreter.h
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.h
@@ -31,7 +31,7 @@ extern "C" {
#include "StringUtils.h"
#include "Interpreter.h"
-//soc
+// soc
extern "C" {
#include "MEM_guardedalloc.h"
diff --git a/source/blender/freestyle/intern/system/StringUtils.cpp b/source/blender/freestyle/intern/system/StringUtils.cpp
index 027491a790f..99ec9aed632 100644
--- a/source/blender/freestyle/intern/system/StringUtils.cpp
+++ b/source/blender/freestyle/intern/system/StringUtils.cpp
@@ -19,7 +19,7 @@
* \brief String utilities
*/
-//soc #include <qfileinfo.h>
+// soc #include <qfileinfo.h>
#include "FreestyleConfig.h"
#include "StringUtils.h"
diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.h b/source/blender/freestyle/intern/view_map/BoxGrid.h
index 83c379102f5..35b5e4d6b55 100644
--- a/source/blender/freestyle/intern/view_map/BoxGrid.h
+++ b/source/blender/freestyle/intern/view_map/BoxGrid.h
@@ -58,9 +58,9 @@ class BoxGrid {
Polygon3r poly;
Polygon3r cameraSpacePolygon;
real shallowest, deepest;
- // N.B. We could, of course, store face in poly's userdata member, like the old ViewMapBuilder code does.
- // However, code comments make it clear that userdata is deprecated, so we avoid the temptation
- // to save 4 or 8 bytes.
+ // N.B. We could, of course, store face in poly's userdata member, like the old ViewMapBuilder
+ // code does. However, code comments make it clear that userdata is deprecated, so we avoid the
+ // temptation to save 4 or 8 bytes.
WFace *face;
#ifdef WITH_CXX_GUARDEDALLOC
@@ -84,24 +84,27 @@ class BoxGrid {
void indexPolygons();
real boundary[4];
- //deque<OccluderData*> faces;
+ // deque<OccluderData*> faces;
vector<OccluderData *> faces;
};
public:
/* Iterator needs to allow the user to avoid full 3D comparison in two cases:
*
- * (1) Where (*current)->deepest < target[2], where the occluder is unambiguously in front of the target point.
+ * (1) Where (*current)->deepest < target[2], where the occluder is unambiguously in front of the
+ * target point.
*
- * (2) Where (*current)->shallowest > target[2], where the occluder is unambiguously in back of the target point.
+ * (2) Where (*current)->shallowest > target[2], where the occluder is unambiguously in back of
+ * the target point.
*
- * In addition, when used by OptimizedFindOccludee, Iterator should stop iterating as soon as it has an
- * occludee candidate and (*current)->shallowest > candidate[2], because at that point forward no new occluder
- * could possibly be a better occludee.
+ * In addition, when used by OptimizedFindOccludee, Iterator should stop iterating as soon as it
+ * has an occludee candidate and (*current)->shallowest > candidate[2], because at that point
+ * forward no new occluder could possibly be a better occludee.
*/
class Iterator {
public:
- // epsilon is not used in this class, but other grids with the same interface may need an epsilon
+ // epsilon is not used in this class, but other grids with the same interface may need an
+ // epsilon
explicit Iterator(BoxGrid &grid, Vec3r &center, real epsilon = 1.0e-06);
~Iterator();
void initBeforeTarget();
@@ -122,7 +125,7 @@ class BoxGrid {
Vec3r _target;
bool _foundOccludee;
real _occludeeDepth;
- //deque<OccluderData*>::iterator _current, _occludeeCandidate;
+ // deque<OccluderData*>::iterator _current, _occludeeCandidate;
vector<OccluderData *>::iterator _current, _occludeeCandidate;
#ifdef WITH_CXX_GUARDEDALLOC
@@ -171,7 +174,7 @@ class BoxGrid {
void getCellCoordinates(const Vec3r &point, unsigned &x, unsigned &y);
typedef PointerSequence<vector<Cell *>, Cell *> cellContainer;
- //typedef PointerSequence<deque<OccluderData*>, OccluderData*> occluderContainer;
+ // typedef PointerSequence<deque<OccluderData*>, OccluderData*> occluderContainer;
typedef PointerSequence<vector<OccluderData *>, OccluderData *> occluderContainer;
unsigned _cellsX, _cellsY;
float _cellSize;
@@ -222,8 +225,8 @@ inline bool BoxGrid::Iterator::testOccluder(bool wantOccludee)
{
// End-of-list is not even a valid iterator position
if (_current == _cell->faces.end()) {
- // Returning true seems strange, but it will break us out of whatever loop is calling testOccluder,
- // and _current = _cell->face.end() will make the calling routine give up.
+ // Returning true seems strange, but it will break us out of whatever loop is calling
+ // testOccluder, and _current = _cell->face.end() will make the calling routine give up.
return true;
}
#if BOX_GRID_LOGGING
diff --git a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
index 214852001b6..8e10d06d623 100644
--- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
+++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp
@@ -35,8 +35,8 @@ CulledOccluderSource::CulledOccluderSource(const GridHelpers::Transform &t,
{
cullViewEdges(viewMap, extensiveFEdgeSearch);
- // If we have not found any visible FEdges during our cull, then there is nothing to iterate over.
- // Short-circuit everything.
+ // If we have not found any visible FEdges during our cull, then there is nothing to iterate
+ // over. Short-circuit everything.
valid = gridSpaceOccluderProsceniumInitialized;
if (valid && !testCurrent()) {
@@ -107,8 +107,8 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
// Non-displayable view edges will be skipped over during visibility calculation.
- // View edges will be culled according to their position w.r.t. the viewport proscenium (viewport + 5% border,
- // or some such).
+ // View edges will be culled according to their position w.r.t. the viewport proscenium (viewport
+ // + 5% border, or some such).
// Get proscenium boundary for culling
real viewProscenium[4];
@@ -123,17 +123,16 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
cout << "Origin: [" << prosceniumOrigin[0] << ", " << prosceniumOrigin[1] << "]" << endl;
}
- // A separate occluder proscenium will also be maintained, starting out the same as the viewport proscenium, and
- // expanding as necessary so that it encompasses the center point of at least one feature edge in each
- // retained view edge.
- // The occluder proscenium will be used later to cull occluding triangles before they are inserted into the Grid.
- // The occluder proscenium starts out the same size as the view proscenium
+ // A separate occluder proscenium will also be maintained, starting out the same as the viewport
+ // proscenium, and expanding as necessary so that it encompasses the center point of at least one
+ // feature edge in each retained view edge. The occluder proscenium will be used later to cull
+ // occluding triangles before they are inserted into the Grid. The occluder proscenium starts out
+ // the same size as the view proscenium
GridHelpers::getDefaultViewProscenium(occluderProscenium);
- // XXX Freestyle is inconsistent in its use of ViewMap::viewedges_container and vector<ViewEdge*>::iterator.
- // Probably all occurences of vector<ViewEdge*>::iterator should be replaced ViewMap::viewedges_container
- // throughout the code.
- // For each view edge
+ // XXX Freestyle is inconsistent in its use of ViewMap::viewedges_container and
+ // vector<ViewEdge*>::iterator. Probably all occurences of vector<ViewEdge*>::iterator should be
+ // replaced ViewMap::viewedges_container throughout the code. For each view edge
ViewMap::viewedges_container::iterator ve, veend;
for (ve = viewMap.ViewEdges().begin(), veend = viewMap.ViewEdges().end(); ve != veend; ve++) {
@@ -154,8 +153,8 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
// All ViewEdges start culled
(*ve)->setIsInImage(false);
- // For simple visibility calculation: mark a feature edge that is known to have a center point inside
- // the occluder proscenium. Cull all other feature edges.
+ // For simple visibility calculation: mark a feature edge that is known to have a center point
+ // inside the occluder proscenium. Cull all other feature edges.
do {
// All FEdges start culled
fe->setIsInImage(false);
@@ -190,8 +189,8 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
fe = fe->nextEdge();
} while (fe != NULL && fe != festart && !(bestOccluderTargetFound && (*ve)->isInImage()));
- // Either we have run out of FEdges, or we already have the one edge we need to determine visibility
- // Cull all remaining edges.
+ // Either we have run out of FEdges, or we already have the one edge we need to determine
+ // visibility Cull all remaining edges.
while (fe != NULL && fe != festart) {
fe->setIsInImage(false);
fe = fe->nextEdge();
@@ -229,14 +228,14 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
// For "Normal" or "Fast" style visibility computation only:
- // For more detailed visibility calculation, make a second pass through the view map, marking all feature edges
- // with center points inside the final occluder proscenium. All of these feature edges can be considered during
- // visibility calculation.
+ // For more detailed visibility calculation, make a second pass through the view map, marking all
+ // feature edges with center points inside the final occluder proscenium. All of these feature
+ // edges can be considered during visibility calculation.
- // So far we have only found one FEdge per ViewEdge. The "Normal" and "Fast" styles of visibility computation
- // want to consider many FEdges for each ViewEdge.
- // Here we re-scan the view map to find any usable FEdges that we skipped on the first pass, or that have become
- // usable because the occluder proscenium has been expanded since the edge was visited on the first pass.
+ // So far we have only found one FEdge per ViewEdge. The "Normal" and "Fast" styles of visibility
+ // computation want to consider many FEdges for each ViewEdge. Here we re-scan the view map to
+ // find any usable FEdges that we skipped on the first pass, or that have become usable because
+ // the occluder proscenium has been expanded since the edge was visited on the first pass.
if (extensiveFEdgeSearch) {
// For each view edge,
for (ve = viewMap.ViewEdges().begin(), veend = viewMap.ViewEdges().end(); ve != veend; ve++) {
@@ -259,9 +258,9 @@ void CulledOccluderSource::cullViewEdges(ViewMap &viewMap, bool extensiveFEdgeSe
}
// Up until now, all calculations have been done in camera space.
- // However, the occluder source's iteration and the grid that consumes the occluders both work in gridspace,
- // so we need a version of the occluder proscenium in gridspace.
- // Set the gridspace occlude proscenium
+ // However, the occluder source's iteration and the grid that consumes the occluders both work in
+ // gridspace, so we need a version of the occluder proscenium in gridspace. Set the gridspace
+ // occlude proscenium
}
void CulledOccluderSource::expandGridSpaceOccluderProscenium(FEdge *fe)
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
index bb2b95be84e..6c144807e35 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
@@ -184,7 +184,7 @@ void FEdgeXDetector::computeCurvatures(WXVertex *vertex)
// CURVATURE LAYER
// store all the curvature datas for each vertex
- //soc unused - real K1, K2
+ // soc unused - real K1, K2
real cos2theta, sin2theta;
Vec3r e1, n, v;
// one vertex curvature info :
@@ -206,8 +206,8 @@ void FEdgeXDetector::computeCurvatures(WXVertex *vertex)
ncycle.end();
C->K1 = ncycle.kmin();
C->K2 = ncycle.kmax();
- C->e1 = ncycle.Kmax(); //ncycle.kmin() * ncycle.Kmax();
- C->e2 = ncycle.Kmin(); //ncycle.kmax() * ncycle.Kmin();
+ C->e1 = ncycle.Kmax(); // ncycle.kmin() * ncycle.Kmax();
+ C->e2 = ncycle.Kmin(); // ncycle.kmax() * ncycle.Kmin();
real absK1 = fabs(C->K1);
_meanK1 += absK1;
@@ -320,8 +320,8 @@ void FEdgeXDetector::ProcessSilhouetteEdge(WXEdge *iEdge)
if ((fA->front()) ^
(fB->front())) { // fA->visible XOR fB->visible (true if one is 0 and the other is 1)
- // The only edges we want to set as silhouette edges in this way are the ones with 2 different normals
- // for 1 vertex for these two faces
+ // The only edges we want to set as silhouette edges in this way are the ones with 2 different
+ // normals for 1 vertex for these two faces
//--------------------
// In reality we only test the normals for 1 of the 2 vertices.
if (fA->GetVertexNormal(iEdge->GetaVertex()) == fB->GetVertexNormal(iEdge->GetaVertex()))
@@ -392,7 +392,7 @@ void FEdgeXDetector::ProcessCreaseEdge(WXEdge *iEdge)
void FEdgeXDetector::processRidgesAndValleysShape(WXShape *iWShape)
{
// Don't forget to add the built layer to the face at the end of the ProcessFace:
- //iFace->AddSmoothLayer(faceLayer);
+ // iFace->AddSmoothLayer(faceLayer);
if (!_computeViewIndependent)
return;
@@ -425,8 +425,7 @@ void FEdgeXDetector::ProcessRidgeFace(WXFace *iFace)
if (flayer->nPosDotP() != numVertices) {
if ((fabs(flayer->dotP(0)) < threshold) && (fabs(flayer->dotP(1)) < threshold) &&
- (fabs(flayer->dotP(2)) < threshold))
- {
+ (fabs(flayer->dotP(2)) < threshold)) {
flayer->ReplaceDotP(0, 0);
flayer->ReplaceDotP(1, 0);
flayer->ReplaceDotP(2, 0);
@@ -443,7 +442,7 @@ void FEdgeXDetector::ProcessRidgeFace(WXFace *iFace)
WVertex *v;
Vec3r v1v2;
real t;
- vector<WXFaceLayer*> SmoothLayers;
+ vector<WXFaceLayer *> SmoothLayers;
WXFaceLayer *faceLayer;
Face_Curvature_Info *layer_info;
real K1_a(0), K1_b(0);
@@ -451,7 +450,7 @@ void FEdgeXDetector::ProcessRidgeFace(WXFace *iFace)
// find the ridge layer of the face
iFace->retrieveSmoothLayers(Nature::RIDGE, SmoothLayers);
- if ( SmoothLayers.size()!=1 )
+ if (SmoothLayers.size() != 1)
return;
faceLayer = SmoothLayers[0];
// retrieve the curvature info of this layer
@@ -461,27 +460,28 @@ void FEdgeXDetector::ProcessRidgeFace(WXFace *iFace)
for (int i = 0; i < numVertices; i++) {
v = iFace->GetVertex(i);
// vec_curvature_info[i] contains the curvature info of this vertex
- Vec3r e2 = layer_info->vec_curvature_info[i]->K2*layer_info->vec_curvature_info[i]->e2;
- Vec3r e1 = layer_info->vec_curvature_info[i]->K1*layer_info->vec_curvature_info[i]->e1;
+ Vec3r e2 = layer_info->vec_curvature_info[i]->K2 * layer_info->vec_curvature_info[i]->e2;
+ Vec3r e1 = layer_info->vec_curvature_info[i]->K1 * layer_info->vec_curvature_info[i]->e1;
e2.normalize();
WVertex::face_iterator fit = v->faces_begin();
WVertex::face_iterator fitend = v->faces_end();
for (; fit != fitend; ++fit) {
- WXFace *wxf = dynamic_cast<WXFace*>(*fit);
+ WXFace *wxf = dynamic_cast<WXFace *>(*fit);
WOEdge *oppositeEdge;
if (!(wxf->getOppositeEdge(v, oppositeEdge)))
continue;
v1v2 = oppositeEdge->GetbVertex()->GetVertex() - oppositeEdge->GetaVertex()->GetVertex();
GeomUtils::intersection_test res;
- res = GeomUtils::intersectRayPlane(oppositeEdge->GetaVertex()->GetVertex(), v1v2, e2, -(v->GetVertex()*e2),
- t, 1.0e-06);
+ res = GeomUtils::intersectRayPlane(
+ oppositeEdge->GetaVertex()->GetVertex(), v1v2, e2, -(v->GetVertex() * e2), t, 1.0e-06);
if ((res == GeomUtils::DO_INTERSECT) && (t >= 0.0) && (t <= 1.0)) {
- vector<WXFaceLayer*> second_ridge_layer;
+ vector<WXFaceLayer *> second_ridge_layer;
wxf->retrieveSmoothLayers(Nature::RIDGE, second_ridge_layer);
if (second_ridge_layer.size() != 1)
continue;
- Face_Curvature_Info *second_layer_info = (Face_Curvature_Info*)second_ridge_layer[0]->userdata;
+ Face_Curvature_Info *second_layer_info =
+ (Face_Curvature_Info *)second_ridge_layer[0]->userdata;
unsigned index1 = wxf->GetIndex(oppositeEdge->GetaVertex());
unsigned index2 = wxf->GetIndex(oppositeEdge->GetbVertex());
@@ -566,10 +566,9 @@ void FEdgeXDetector::ProcessSuggestiveContourFace(WXFace *iFace)
#if 0 // FIXME: find a more clever way to compute the threshold
real threshold = _meanKr;
- if (faceLayer->nPosDotP()!=numVertices) {
+ if (faceLayer->nPosDotP() != numVertices) {
if ((fabs(faceLayer->dotP(0)) < threshold) && (fabs(faceLayer->dotP(1)) < threshold) &&
- (fabs(faceLayer->dotP(2)) < threshold))
- {
+ (fabs(faceLayer->dotP(2)) < threshold)) {
faceLayer->ReplaceDotP(0, 0);
faceLayer->ReplaceDotP(1, 0);
faceLayer->ReplaceDotP(2, 0);
@@ -672,7 +671,8 @@ void FEdgeXDetector::postProcessSuggestiveContourFace(WXFace *iFace)
}
// At that point, we have the derivatives for each vertex of iFace.
- // All we have to do now is to use linear interpolation to compute the values at the extremities of the smooth edge.
+ // All we have to do now is to use linear interpolation to compute the values at the extremities
+ // of the smooth edge.
WXSmoothEdge *sc_edge = sc_layer->getSmoothEdge();
WOEdge *sc_oedge = sc_edge->woea();
t = sc_edge->ta();
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
index 61e0c9267a1..9df0b4bb4bd 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
@@ -89,8 +89,9 @@ class FEdgeXDetector {
/*! Sets the minimum angle for detecting crease edges
* \param angle:
- * The angular threshold in degrees (between 0 and 180) for detecting crease edges. An edge is considered
- * a crease edge if the angle between two faces sharing the edge is smaller than the given threshold.
+ * The angular threshold in degrees (between 0 and 180) for detecting crease edges. An edge is
+ * considered a crease edge if the angle between two faces sharing the edge is smaller than the
+ * given threshold.
*/
// XXX angle should be in radian...
inline void setCreaseAngle(float angle)
@@ -209,9 +210,9 @@ class FEdgeXDetector {
protected:
Vec3f _Viewpoint;
#if 0
- real _bbox_diagonal; // diagonal of the current processed shape bbox
+ real _bbox_diagonal; // diagonal of the current processed shape bbox
#endif
- //oldtmp values
+ // oldtmp values
bool _computeViewIndependent;
real _meanK1;
real _meanKr;
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.cpp b/source/blender/freestyle/intern/view_map/Functions0D.cpp
index 5b04b66eeeb..2a9a654981a 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.cpp
+++ b/source/blender/freestyle/intern/view_map/Functions0D.cpp
@@ -343,7 +343,7 @@ int GetOccludersF0D::operator()(Interface0DIterator &iter)
set<ViewShape *> occluders;
getOccludersF0D(iter, occluders);
result.clear();
- //vsOccluders.insert(vsOccluders.begin(), occluders.begin(), occluders.end());
+ // vsOccluders.insert(vsOccluders.begin(), occluders.begin(), occluders.end());
for (set<ViewShape *>::iterator it = occluders.begin(), itend = occluders.end(); it != itend;
++it) {
result.push_back((*it));
diff --git a/source/blender/freestyle/intern/view_map/Functions0D.h b/source/blender/freestyle/intern/view_map/Functions0D.h
index ecf94b29d60..7149c1909fd 100644
--- a/source/blender/freestyle/intern/view_map/Functions0D.h
+++ b/source/blender/freestyle/intern/view_map/Functions0D.h
@@ -55,9 +55,9 @@ using namespace Geometry;
/*! Base class for Unary Functions (functors) working on Interface0DIterator.
* A unary function will be used by calling its operator() on an Interface0DIterator.
- * \attention In the scripting language, there exists several prototypes depending on the returned value type.
- * For example, you would inherit from a UnaryFunction0DDouble if you wish to define a function that returns a double.
- * The different existing prototypes are:
+ * \attention In the scripting language, there exists several prototypes depending on the returned
+ * value type. For example, you would inherit from a UnaryFunction0DDouble if you wish to define a
+ * function that returns a double. The different existing prototypes are:
* - UnaryFunction0DDouble
* - UnaryFunction0DEdgeNature
* - UnaryFunction0DFloat
@@ -284,8 +284,9 @@ class GetParameterF0D : public UnaryFunction0D<float> {
};
// VertexOrientation2DF0D
-/*! Returns a Vec2r giving the 2D oriented tangent to the 1D element to which the Interface0DIterator& belongs to and
- * evaluated at the Interface0D pointed by this Interface0DIterator&.
+/*! Returns a Vec2r giving the 2D oriented tangent to the 1D element to which the
+ * Interface0DIterator& belongs to and evaluated at the Interface0D pointed by this
+ * Interface0DIterator&.
*/
class VertexOrientation2DF0D : public UnaryFunction0D<Vec2f> {
public:
@@ -300,8 +301,9 @@ class VertexOrientation2DF0D : public UnaryFunction0D<Vec2f> {
};
// VertexOrientation3DF0D
-/*! Returns a Vec3r giving the 3D oriented tangent to the 1D element to which the Interface0DIterator& belongs to and
- * evaluated at the Interface0D pointed by this Interface0DIterator&.
+/*! Returns a Vec3r giving the 3D oriented tangent to the 1D element to which the
+ * Interface0DIterator& belongs to and evaluated at the Interface0D pointed by this
+ * Interface0DIterator&.
*/
class VertexOrientation3DF0D : public UnaryFunction0D<Vec3f> {
public:
@@ -316,8 +318,9 @@ class VertexOrientation3DF0D : public UnaryFunction0D<Vec3f> {
};
// Curvature2DAngleF0D
-/*! Returns a real giving the 2D curvature (as an angle) of the 1D element to which the Interface0DIterator&
- * belongs to and evaluated at the Interface0D pointed by this Interface0DIterator&.
+/*! Returns a real giving the 2D curvature (as an angle) of the 1D element to which the
+ * Interface0DIterator& belongs to and evaluated at the Interface0D pointed by this
+ * Interface0DIterator&.
*/
class Curvature2DAngleF0D : public UnaryFunction0D<double> {
public:
@@ -332,9 +335,10 @@ class Curvature2DAngleF0D : public UnaryFunction0D<double> {
};
// ZDiscontinuity
-/*! Returns a real giving the distance between and Interface0D and the shape that lies behind (occludee).
- * This distance is evaluated in the camera space and normalized between 0 and 1. Therefore, if no object is occluded
- * by the shape to which the Interface0D belongs to, 1 is returned.
+/*! Returns a real giving the distance between and Interface0D and the shape that lies behind
+ * (occludee). This distance is evaluated in the camera space and normalized between 0 and 1.
+ * Therefore, if no object is occluded by the shape to which the Interface0D belongs to, 1 is
+ * returned.
*/
class ZDiscontinuityF0D : public UnaryFunction0D<double> {
public:
@@ -349,8 +353,9 @@ class ZDiscontinuityF0D : public UnaryFunction0D<double> {
};
// Normal2DF0D
-/*! Returns a Vec2f giving the normalized 2D normal to the 1D element to which the Interface0DIterator& belongs to and
- * evaluated at the Interface0D pointed by this Interface0DIterator&.
+/*! Returns a Vec2f giving the normalized 2D normal to the 1D element to which the
+ * Interface0DIterator& belongs to and evaluated at the Interface0D pointed by this
+ * Interface0DIterator&.
*/
class Normal2DF0D : public UnaryFunction0D<Vec2f> {
public:
@@ -367,11 +372,11 @@ class Normal2DF0D : public UnaryFunction0D<Vec2f> {
// MaterialF0D
/*! Returns the material of the object evaluated at the Interface0D.
* This evaluation can be ambiguous (in the case of a TVertex for example.
- * This functor tries to remove this ambiguity using the context offered by the 1D element to which the
- * Interface0DIterator& belongs to and by arbitrary choosing the material of the face that lies on its left when
- * following the 1D element if there are two different materials on each side of the point.
- * However, there still can be problematic cases, and the user willing to deal with this cases in a specific way
- * should implement its own getMaterial functor.
+ * This functor tries to remove this ambiguity using the context offered by the 1D element to
+ * which the Interface0DIterator& belongs to and by arbitrary choosing the material of the face
+ * that lies on its left when following the 1D element if there are two different materials on each
+ * side of the point. However, there still can be problematic cases, and the user willing to deal
+ * with this cases in a specific way should implement its own getMaterial functor.
*/
class MaterialF0D : public UnaryFunction0D<FrsMaterial> {
public:
@@ -388,10 +393,10 @@ class MaterialF0D : public UnaryFunction0D<FrsMaterial> {
// ShapeIdF0D
/*! Returns the Id of the Shape the Interface0D belongs to.
* This evaluation can be ambiguous (in the case of a TVertex for example).
- * This functor tries to remove this ambiguity using the context offered by the 1D element to which the
- * Interface0DIterator& belongs to.
- * However, there still can be problematic cases, and the user willing to deal with this cases in a specific way
- * should implement its own getShapeIdF0D functor.
+ * This functor tries to remove this ambiguity using the context offered by the 1D element to
+ * which the Interface0DIterator& belongs to. However, there still can be problematic cases, and
+ * the user willing to deal with this cases in a specific way should implement its own
+ * getShapeIdF0D functor.
*/
class ShapeIdF0D : public UnaryFunction0D<Id> {
public:
@@ -408,10 +413,10 @@ class ShapeIdF0D : public UnaryFunction0D<Id> {
// QiF0D
/*! Returns the quantitative invisibility of this Interface0D.
* This evaluation can be ambiguous (in the case of a TVertex for example).
- * This functor tries to remove this ambiguity using the context offered by the 1D element to which the
- * Interface0DIterator& belongs to.
- * However, there still can be problematic cases, and the user willing to deal with this cases in a specific way
- * should implement its own getQIF0D functor.
+ * This functor tries to remove this ambiguity using the context offered by the 1D element to
+ * which the Interface0DIterator& belongs to. However, there still can be problematic cases, and
+ * the user willing to deal with this cases in a specific way should implement its own getQIF0D
+ * functor.
*/
class QuantitativeInvisibilityF0D : public UnaryFunction0D<unsigned int> {
public:
diff --git a/source/blender/freestyle/intern/view_map/Functions1D.h b/source/blender/freestyle/intern/view_map/Functions1D.h
index 581ab9c459a..20aa9f2a27f 100644
--- a/source/blender/freestyle/intern/view_map/Functions1D.h
+++ b/source/blender/freestyle/intern/view_map/Functions1D.h
@@ -45,9 +45,9 @@ namespace Freestyle {
/*! Base class for Unary Functions (functors) working on Interface1D.
* A unary function will be used by calling its operator() on an Interface1D.
- * \attention In the scripting language, there exists several prototypes depending on the returned value type.
- * For example, you would inherit from a UnaryFunction1DDouble if you wish to define a function that returns a double.
- * The different existing prototypes are:
+ * \attention In the scripting language, there exists several prototypes depending on the returned
+ * value type. For example, you would inherit from a UnaryFunction1DDouble if you wish to define a
+ * function that returns a double. The different existing prototypes are:
* - UnaryFunction1DDouble
* - UnaryFunction1DEdgeNature
* - UnaryFunction1DFloat
@@ -73,8 +73,8 @@ template<class T> class UnaryFunction1D {
/*! Builds a UnaryFunction1D from an integration type.
* \param iType:
- * In case the result for the Interface1D would be obtained by evaluating a 0D function over the different
- * Interface0D of the Interface1D, \a iType tells which integration method to use.
+ * In case the result for the Interface1D would be obtained by evaluating a 0D function over
+ * the different Interface0D of the Interface1D, \a iType tells which integration method to use.
* The default integration method is the MEAN.
*/
UnaryFunction1D(IntegrationType iType)
@@ -379,9 +379,10 @@ class Orientation3DF1D : public UnaryFunction1D<Vec3f> {
};
// ZDiscontinuityF1D
-/*! Returns a real giving the distance between and Interface1D and the shape that lies behind (occludee).
- * This distance is evaluated in the camera space and normalized between 0 and 1. Therefore, if no object is occluded
- * by the shape to which the Interface1D belongs to, 1 is returned.
+/*! Returns a real giving the distance between and Interface1D and the shape that lies behind
+ * (occludee). This distance is evaluated in the camera space and normalized between 0 and 1.
+ * Therefore, if no object is occluded by the shape to which the Interface1D belongs to, 1 is
+ * returned.
*/
class ZDiscontinuityF1D : public UnaryFunction1D<double> {
private:
@@ -408,9 +409,9 @@ class ZDiscontinuityF1D : public UnaryFunction1D<double> {
// QuantitativeInvisibilityF1D
/*! Returns the Quantitative Invisibility of an Interface1D element.
- * If the Interface1D is a ViewEdge, then there is no ambiguity concerning the result. But, if the Interface1D
- * results of a chaining (chain, stroke), then it might be made of several 1D elements of different
- * Quantitative Invisibilities.
+ * If the Interface1D is a ViewEdge, then there is no ambiguity concerning the result. But, if the
+ * Interface1D results of a chaining (chain, stroke), then it might be made of several 1D elements
+ * of different Quantitative Invisibilities.
*/
class QuantitativeInvisibilityF1D : public UnaryFunction1D<unsigned> {
private:
@@ -438,8 +439,9 @@ class QuantitativeInvisibilityF1D : public UnaryFunction1D<unsigned> {
// CurveNatureF1D
/*! Returns the nature of the Interface1D (silhouette, ridge, crease...).
* Except if the Interface1D is a ViewEdge, this result might be ambiguous.
- * Indeed, the Interface1D might result from the gathering of several 1D elements, each one being of a different
- * nature. An integration method, such as the MEAN, might give, in this case, irrelevant results.
+ * Indeed, the Interface1D might result from the gathering of several 1D elements, each one being
+ * of a different nature. An integration method, such as the MEAN, might give, in this case,
+ * irrelevant results.
*/
class CurveNatureF1D : public UnaryFunction1D<Nature::EdgeNature> {
private:
diff --git a/source/blender/freestyle/intern/view_map/GridDensityProvider.h b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
index dacdb345c86..8d6ba521dde 100644
--- a/source/blender/freestyle/intern/view_map/GridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
@@ -110,7 +110,8 @@ class GridDensityProvider {
Vec3r p6 = transform(Vec3r(xM, ym, zM));
Vec3r p7 = transform(Vec3r(xM, yM, zm));
Vec3r p8 = transform(Vec3r(xM, yM, zM));
- // Determine the proscenium face according to the min and max values of the transformed x and y coordinates
+ // Determine the proscenium face according to the min and max values of the transformed x and y
+ // coordinates
proscenium[0] = std::min(std::min(std::min(p1.x(), p2.x()), std::min(p3.x(), p4.x())),
std::min(std::min(p5.x(), p6.x()), std::min(p7.x(), p8.x())));
proscenium[1] = std::max(std::max(std::max(p1.x(), p2.x()), std::max(p3.x(), p4.x())),
diff --git a/source/blender/freestyle/intern/view_map/Interface0D.h b/source/blender/freestyle/intern/view_map/Interface0D.h
index bab996d9308..3d50e978147 100644
--- a/source/blender/freestyle/intern/view_map/Interface0D.h
+++ b/source/blender/freestyle/intern/view_map/Interface0D.h
@@ -95,7 +95,8 @@ class Interface0D {
/*! Returns the 2D point. */
virtual Geometry::Vec2r getPoint2D() const;
- /*! Returns the FEdge that lies between this Interface0D and the Interface0D given as argument. */
+ /*! Returns the FEdge that lies between this Interface0D and the Interface0D given as argument.
+ */
virtual FEdge *getFEdge(Interface0D &);
/*! Returns the Id of the point. */
@@ -175,8 +176,8 @@ class Interface0DIteratorNested : public Iterator {
/*! Class defining an iterator over Interface0D elements.
* An instance of this iterator is always obtained from a 1D element.
- * \attention In the scripting language, you must call \code it2 = Interface0DIterator(it1) \endcode instead of
- * \code it2 = it1 \endcode where \a it1 and \a it2 are 2 Interface0DIterator.
+ * \attention In the scripting language, you must call \code it2 = Interface0DIterator(it1)
+ * \endcode instead of \code it2 = it1 \endcode where \a it1 and \a it2 are 2 Interface0DIterator.
* Otherwise, incrementing \a it1 will also increment \a it2.
*/
class Interface0DIterator : public Iterator {
@@ -200,9 +201,9 @@ class Interface0DIterator : public Iterator {
}
/*! Operator =
- * \attention In the scripting language, you must call \code it2 = Interface0DIterator(it1) \endcode instead of
- * \code it2 = it1 \endcode where \a it1 and \a it2 are 2 Interface0DIterator.
- * Otherwise, incrementing \a it1 will also increment \a it2.
+ * \attention In the scripting language, you must call \code it2 = Interface0DIterator(it1)
+ * \endcode instead of \code it2 = it1 \endcode where \a it1 and \a it2 are 2
+ * Interface0DIterator. Otherwise, incrementing \a it1 will also increment \a it2.
*/
Interface0DIterator &operator=(const Interface0DIterator &it)
{
@@ -280,16 +281,16 @@ class Interface0DIterator : public Iterator {
return _iterator->decrement();
}
- /*! Returns true if the pointed Interface0D is the first of the 1D element containing the points over which
- * we're iterating.
+ /*! Returns true if the pointed Interface0D is the first of the 1D element containing the points
+ * over which we're iterating.
*/
virtual bool isBegin() const
{
return _iterator->isBegin();
}
- /*! Returns true if the pointed Interface0D is after the after the last point of the 1D element we're
- * iterating from. */
+ /*! Returns true if the pointed Interface0D is after the after the last point of the 1D element
+ * we're iterating from. */
virtual bool isEnd() const
{
return _iterator->isEnd();
diff --git a/source/blender/freestyle/intern/view_map/Interface1D.h b/source/blender/freestyle/intern/view_map/Interface1D.h
index e56a58096f8..e47a5ad8f31 100644
--- a/source/blender/freestyle/intern/view_map/Interface1D.h
+++ b/source/blender/freestyle/intern/view_map/Interface1D.h
@@ -42,24 +42,28 @@ using namespace std;
namespace Freestyle {
// Integration method
-/*! The different integration methods that can be invoked to integrate into a single value the set of values obtained
- * from each 0D element of a 1D element.
+/*! The different integration methods that can be invoked to integrate into a single value the set
+ * of values obtained from each 0D element of a 1D element.
*/
typedef enum {
- MEAN, /*!< The value computed for the 1D element is the mean of the values obtained for the 0D elements.*/
- MIN, /*!< The value computed for the 1D element is the minimum of the values obtained for the 0D elements.*/
- MAX, /*!< The value computed for the 1D element is the maximum of the values obtained for the 0D elements.*/
- FIRST, /*!< The value computed for the 1D element is the first of the values obtained for the 0D elements.*/
- LAST, /*!< The value computed for the 1D element is the last of the values obtained for the 0D elements.*/
+ MEAN, /*!< The value computed for the 1D element is the mean of the values obtained for the 0D
+ elements.*/
+ MIN, /*!< The value computed for the 1D element is the minimum of the values obtained for the 0D
+ elements.*/
+ MAX, /*!< The value computed for the 1D element is the maximum of the values obtained for the 0D
+ elements.*/
+ FIRST, /*!< The value computed for the 1D element is the first of the values obtained for the 0D
+ elements.*/
+ LAST, /*!< The value computed for the 1D element is the last of the values obtained for the 0D
+ elements.*/
} IntegrationType;
/*! Returns a single value from a set of values evaluated at each 0D element of this 1D element.
* \param fun:
* The UnaryFunction0D used to compute a value at each Interface0D.
* \param it:
- * The Interface0DIterator used to iterate over the 0D elements of this 1D element. The integration will occur
- * over the 0D elements starting from the one pointed by it.
- * \param it_end:
+ * The Interface0DIterator used to iterate over the 0D elements of this 1D element. The
+ * integration will occur over the 0D elements starting from the one pointed by it. \param it_end:
* The Interface0DIterator pointing the end of the 0D elements of the 1D element.
* \param integration_type:
* The integration method used to compute a single value from a set of values.
@@ -148,19 +152,17 @@ class Interface1D {
/*! Returns an iterator over the Interface1D vertices, pointing after the last vertex. */
virtual Interface0DIterator verticesEnd();
- /*! Returns an iterator over the Interface1D points, pointing to the first point. The difference with
- * verticesBegin() is that here we can iterate over points of the 1D element at a any given sampling.
- * Indeed, for each iteration, a virtual point is created.
- * \param t:
- * The sampling with which we want to iterate over points of this 1D element.
+ /*! Returns an iterator over the Interface1D points, pointing to the first point. The difference
+ * with verticesBegin() is that here we can iterate over points of the 1D element at a any given
+ * sampling. Indeed, for each iteration, a virtual point is created. \param t: The sampling with
+ * which we want to iterate over points of this 1D element.
*/
virtual Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an iterator over the Interface1D points, pointing after the last point. The difference with
- * verticesEnd() is that here we can iterate over points of the 1D element at a any given sampling.
- * Indeed, for each iteration, a virtual point is created.
- * \param t:
- * The sampling with which we want to iterate over points of this 1D element.
+ /*! Returns an iterator over the Interface1D points, pointing after the last point. The
+ * difference with verticesEnd() is that here we can iterate over points of the 1D element at a
+ * any given sampling. Indeed, for each iteration, a virtual point is created. \param t: The
+ * sampling with which we want to iterate over points of this 1D element.
*/
virtual Interface0DIterator pointsEnd(float t = 0.0f);
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.cpp b/source/blender/freestyle/intern/view_map/Silhouette.cpp
index 73bf38107cd..15fe55874ca 100644
--- a/source/blender/freestyle/intern/view_map/Silhouette.cpp
+++ b/source/blender/freestyle/intern/view_map/Silhouette.cpp
@@ -286,15 +286,15 @@ real FEdge::z_discontinuity() const
Vec3r bbox_size_vec(box.getMax() - box.getMin());
real bboxsize = bbox_size_vec.norm();
if (occludee_empty()) {
- //return FLT_MAX;
+ // return FLT_MAX;
return 1.0;
- //return bboxsize;
+ // return bboxsize;
}
#if 0
real result;
z_discontinuity_functor<SVertex> _functor;
- Evaluate<SVertex, z_discontinuity_functor<SVertex> >(&_functor, iCombination, result);
+ Evaluate<SVertex, z_discontinuity_functor<SVertex>>(&_functor, iCombination, result);
#endif
Vec3r middle((_VertexB->point3d() - _VertexA->point3d()));
middle /= 2;
@@ -302,11 +302,11 @@ real FEdge::z_discontinuity() const
real res = disc_vec.norm() / bboxsize;
return res;
- //return fabs((middle.z() - _occludeeIntersection.z()));
+ // return fabs((middle.z() - _occludeeIntersection.z()));
}
#if 0
-float FEdge::local_average_depth(int iCombination ) const
+float FEdge::local_average_depth(int iCombination) const
{
float result;
local_average_depth_functor<SVertex> functor;
@@ -315,7 +315,7 @@ float FEdge::local_average_depth(int iCombination ) const
return result;
}
-float FEdge::local_depth_variance(int iCombination ) const
+float FEdge::local_depth_variance(int iCombination) const
{
float result;
@@ -326,7 +326,7 @@ float FEdge::local_depth_variance(int iCombination ) const
return result;
}
-real FEdge::local_average_density( float sigma, int iCombination) const
+real FEdge::local_average_density(float sigma, int iCombination) const
{
float result;
@@ -337,7 +337,7 @@ real FEdge::local_average_density( float sigma, int iCombination) const
return result;
}
-Vec3r FEdge::normal(int& oException /* = Exception::NO_EXCEPTION */)
+Vec3r FEdge::normal(int &oException /* = Exception::NO_EXCEPTION */)
{
Vec3r Na = _VertexA->normal(oException);
if (oException != Exception::NO_EXCEPTION)
@@ -352,7 +352,7 @@ Vec3r FEdge::curvature2d_as_vector(int iCombination) const
{
Vec3r result;
curvature2d_as_vector_functor<SVertex> _functor;
- Evaluate<Vec3r, curvature2d_as_vector_functor<SVertex> >(&_functor, iCombination, result);
+ Evaluate<Vec3r, curvature2d_as_vector_functor<SVertex>>(&_functor, iCombination, result);
return result;
}
@@ -360,7 +360,7 @@ real FEdge::curvature2d_as_angle(int iCombination) const
{
real result;
curvature2d_as_angle_functor<SVertex> _functor;
- Evaluate<real, curvature2d_as_angle_functor<SVertex> >(&_functor, iCombination, result);
+ Evaluate<real, curvature2d_as_angle_functor<SVertex>>(&_functor, iCombination, result);
return result;
}
#endif
diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h
index 510aedf6cbf..b5bbe66e51e 100644
--- a/source/blender/freestyle/intern/view_map/Silhouette.h
+++ b/source/blender/freestyle/intern/view_map/Silhouette.h
@@ -303,7 +303,8 @@ class SVertex : public Interface0D {
_Point2D = iPoint2D;
}
- /*! Adds a normal to the Svertex's set of normals. If the same normal is already in the set, nothing changes. */
+ /*! Adds a normal to the Svertex's set of normals. If the same normal is already in the set,
+ * nothing changes. */
inline void AddNormal(const Vec3r &iNormal)
{
_Normals.insert(iNormal); // if iNormal in the set already exists, nothing is done
@@ -333,12 +334,12 @@ class SVertex : public Interface0D {
_directionFredo = d;
}
- real curvatureFredo ()
+ real curvatureFredo()
{
return _curvatureFredo;
}
- const Vec2r directionFredo ()
+ const Vec2r directionFredo()
{
return _directionFredo;
}
@@ -420,7 +421,7 @@ class SVertex : public Interface0D {
return *(_Normals.begin());
}
- //Material material() const ;
+ // Material material() const ;
Id shape_id() const;
const SShape *shape() const;
float shape_importance() const;
@@ -462,13 +463,12 @@ class SVertex : public Interface0D {
class ViewEdge;
/*! Base Class for feature edges.
- * This FEdge can represent a silhouette, a crease, a ridge/valley, a border or a suggestive contour.
- * For silhouettes, the FEdge is oriented such as, the visible face lies on the left of the edge.
- * For borders, the FEdge is oriented such as, the face lies on the left of the edge.
- * An FEdge can represent an initial edge of the mesh or runs accross a face of the initial mesh depending
- * on the smoothness or sharpness of the mesh.
- * This class is specialized into a smooth and a sharp version since their properties slightly vary from
- * one to the other.
+ * This FEdge can represent a silhouette, a crease, a ridge/valley, a border or a suggestive
+ * contour. For silhouettes, the FEdge is oriented such as, the visible face lies on the left of
+ * the edge. For borders, the FEdge is oriented such as, the face lies on the left of the edge. An
+ * FEdge can represent an initial edge of the mesh or runs accross a face of the initial mesh
+ * depending on the smoothness or sharpness of the mesh. This class is specialized into a smooth
+ * and a sharp version since their properties slightly vary from one to the other.
*/
class FEdge : public Interface1D {
public: // Implementation of Interface0D
@@ -509,13 +509,13 @@ class FEdge : public Interface1D {
SVertex *_VertexB;
Id _Id;
Nature::EdgeNature _Nature;
- //vector<Polygon3r> _Occluders; // visibility // NOT HANDLED BY THE COPY CONSTRUCTOR!!
+ // vector<Polygon3r> _Occluders; // visibility // NOT HANDLED BY THE COPY CONSTRUCTOR!!
FEdge *_NextEdge; // next edge on the chain
FEdge *_PreviousEdge;
ViewEdge *_ViewEdge;
- // Sometimes we need to deport the visibility computation onto another edge. For example the exact edges use
- // edges of the mesh to compute their visibility
+ // Sometimes we need to deport the visibility computation onto another edge. For example the
+ // exact edges use edges of the mesh to compute their visibility
Polygon3r _aFace; // The occluded face which lies on the right of a silhouette edge
Vec3r _occludeeIntersection;
@@ -657,7 +657,7 @@ class FEdge : public Interface1D {
int invisibility() const;
#if 0
- inline const vector<Polygon3r>& occluders() const
+ inline const vector<Polygon3r> &occluders() const
{
return _Occluders;
}
@@ -765,7 +765,7 @@ class FEdge : public Interface1D {
}
#if 0
- inline void AddOccluder(Polygon3r& iPolygon)
+ inline void AddOccluder(Polygon3r &iPolygon)
{
_Occluders.push_back(iPolygon);
}
@@ -783,12 +783,12 @@ class FEdge : public Interface1D {
_hasVisibilityPoint = iBool;
}
- inline void setVisibilityPointA(const Vec3r& iPoint)
+ inline void setVisibilityPointA(const Vec3r &iPoint)
{
_VisibilityPointA = iPoint;
}
- inline void setVisibilityPointB(const Vec3r& iPoint)
+ inline void setVisibilityPointB(const Vec3r &iPoint)
{
_VisibilityPointB = iPoint;
}
@@ -868,7 +868,7 @@ class FEdge : public Interface1D {
/* Information access interface */
- //Material material() const;
+ // Material material() const;
Id shape_id() const;
const SShape *shape() const;
float shape_importance() const;
@@ -891,7 +891,7 @@ class FEdge : public Interface1D {
const SShape *occluded_shape() const;
#if 0
- inline const bool occludee_empty() const
+ inline const bool occludee_empty() const
{
return _occludeeEmpty;
}
@@ -904,12 +904,14 @@ class FEdge : public Interface1D {
inline float local_average_depth(int iCombination = 0) const;
inline float local_depth_variance(int iCombination = 0) const;
inline real local_average_density(float sigma = 2.3f, int iCombination = 0) const;
- inline Vec3r shaded_color(int iCombination = 0) const {}
+ inline Vec3r shaded_color(int iCombination = 0) const
+ {
+ }
#endif
int viewedge_nature() const;
- //float viewedge_length() const;
+ // float viewedge_length() const;
inline Vec3r orientation2d() const
{
@@ -940,16 +942,16 @@ class FEdge : public Interface1D {
/*! Returns an iterator over the 2 (!) SVertex pointing after the last SVertex. */
virtual inline Interface0DIterator verticesEnd();
- /*! Returns an iterator over the FEdge points, pointing to the first point. The difference with verticesBegin()
- * is that here we can iterate over points of the FEdge at a any given sampling.
+ /*! Returns an iterator over the FEdge points, pointing to the first point. The difference with
+ * verticesBegin() is that here we can iterate over points of the FEdge at a any given sampling.
* Indeed, for each iteration, a virtual point is created.
* \param t:
* The sampling with which we want to iterate over points of this FEdge.
*/
virtual inline Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an iterator over the FEdge points, pointing after the last point. The difference with verticesEnd()
- * is that here we can iterate over points of the FEdge at a any given sampling.
+ /*! Returns an iterator over the FEdge points, pointing after the last point. The difference with
+ * verticesEnd() is that here we can iterate over points of the FEdge at a any given sampling.
* Indeed, for each iteration, a virtual point is created.
* \param t:
* The sampling with which we want to iterate over points of this FEdge.
@@ -1275,8 +1277,8 @@ class FEdgeSharp : public FEdge {
#endif
};
-/*! Class defining a smooth edge. This kind of edge typically runs across a face of the input mesh. It can be
- * a silhouette, a ridge or valley, a suggestive contour.
+/*! Class defining a smooth edge. This kind of edge typically runs across a face of the input mesh.
+ * It can be a silhouette, a ridge or valley, a suggestive contour.
*/
class FEdgeSmooth : public FEdge {
protected:
@@ -1400,7 +1402,8 @@ class FEdgeSmooth : public FEdge {
/* */
/**********************************/
-/*! Class to define a feature shape. It is the gathering of feature elements from an identified input shape */
+/*! Class to define a feature shape. It is the gathering of feature elements from an identified
+ * input shape */
class SShape {
private:
vector<FEdge *> _chains; // list of fedges that are chains starting points.
@@ -1576,10 +1579,10 @@ class SShape {
}
/*! Splits an edge into several edges.
- * The edge's vertices are passed rather than the edge itself. This way, all feature edges (SILHOUETTE,
- * CREASE, BORDER) are splitted in the same time.
- * The processed edges are flagged as done (using the userdata flag).One single new vertex is created whereas
- * several splitted edges might created for the different kinds of edges. These new elements are added to the lists
+ * The edge's vertices are passed rather than the edge itself. This way, all feature edges
+ * (SILHOUETTE, CREASE, BORDER) are splitted in the same time. The processed edges are flagged as
+ * done (using the userdata flag).One single new vertex is created whereas several splitted edges
+ * might created for the different kinds of edges. These new elements are added to the lists
* maintained by the shape.
* New chains are also created.
* ioA
@@ -1587,12 +1590,11 @@ class SShape {
* ioB
* The second vertex for the edge that gets splitted
* iParameters
- * A vector containing 2D real vectors indicating the parameters giving the intersections coordinates in
- * 3D and in 2D. These intersections points must be sorted from B to A.
- * Each parameter defines the intersection point I as I=A+T*AB. T<0 and T>1 are then incorrect insofar as
- * they give intersections points that lie outside the segment.
- * ioNewEdges
- * The edges that are newly created (the initial edges are not included) are added to this list.
+ * A vector containing 2D real vectors indicating the parameters giving the intersections
+ * coordinates in 3D and in 2D. These intersections points must be sorted from B to A. Each
+ * parameter defines the intersection point I as I=A+T*AB. T<0 and T>1 are then incorrect insofar
+ * as they give intersections points that lie outside the segment. ioNewEdges The edges that are
+ * newly created (the initial edges are not included) are added to this list.
*/
inline void SplitEdge(FEdge *fe, const vector<Vec2r> &iParameters, vector<FEdge *> &ioNewEdges)
{
@@ -1635,7 +1637,7 @@ class SShape {
for (vector<SVertex *>::iterator sv = intersections.begin(), svend = intersections.end();
sv != svend;
sv++) {
- //SVertex *svA = fe->vertexA();
+ // SVertex *svA = fe->vertexA();
SVertex *svB = fe->vertexB();
// We split edge AB into AA' and A'B. A' and A'B are created.
@@ -1676,7 +1678,7 @@ class SShape {
fe->setId(id);
// update edge AA' for the next pointing edge
- //ioEdge->setNextEdge(newEdge);
+ // ioEdge->setNextEdge(newEdge);
(fe)->setNextEdge(NULL);
// update vertex pointing edges list:
@@ -1688,17 +1690,13 @@ class SShape {
}
}
- /* splits an edge into 2 edges. The new vertex and edge are added to the sshape list of vertices and edges
- * a new chain is also created.
- * returns the new edge.
- * ioEdge
- * The edge that gets splitted
- * newpoint
- * x,y,z coordinates of the new point.
+ /* splits an edge into 2 edges. The new vertex and edge are added to the sshape list of vertices
+ * and edges a new chain is also created. returns the new edge. ioEdge The edge that gets
+ * splitted newpoint x,y,z coordinates of the new point.
*/
inline FEdge *SplitEdgeIn2(FEdge *ioEdge, SVertex *ioNewVertex)
{
- //soc unused - SVertex *A = ioEdge->vertexA();
+ // soc unused - SVertex *A = ioEdge->vertexA();
SVertex *B = ioEdge->vertexB();
// We split edge AB into AA' and A'B. A' and A'B are created.
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
index 7d105a662b8..1d0ac8634dd 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
@@ -16,8 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to perform all geometric operations dedicated to silhouette. That, for example, implies that
- * this geom engine has as member data the viewpoint, transformations, projections...
+ * \brief Class to perform all geometric operations dedicated to silhouette. That, for example,
+ * implies that this geom engine has as member data the viewpoint, transformations, projections...
*/
#include <cstring>
@@ -150,7 +150,8 @@ real SilhouetteGeomEngine::ImageToWorldParameter(FEdge *fe, real t)
if (_isOrthographicProjection)
return t;
- // we need to compute for each parameter t the corresponding parameter T which gives the intersection in 3D.
+ // we need to compute for each parameter t the corresponding parameter T which gives the
+ // intersection in 3D.
real T;
// suffix w for world, c for camera, r for retina, i for image
@@ -262,7 +263,8 @@ real SilhouetteGeomEngine::ImageToWorldParameter(FEdge *fe, real t)
}
#if 0
if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "SilhouetteGeomEngine::ImageToWorldParameter(): #iters = " << i << ", dist = " << dist << "\n";
+ cout << "SilhouetteGeomEngine::ImageToWorldParameter(): #iters = " << i
+ << ", dist = " << dist << "\n";
}
#endif
if (i == max_iters && G.debug & G_DEBUG_FREESTYLE) {
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
index 306eb3a55be..79d863e81e7 100644
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
@@ -19,8 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to perform all geometric operations dedicated to silhouette. That, for example, implies that
- * this geom engine has as member data the viewpoint, transformations, projections...
+ * \brief Class to perform all geometric operations dedicated to silhouette. That, for example,
+ * implies that this geom engine has as member data the viewpoint, transformations, projections...
*/
#include <vector>
diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
index 1a7f01d288f..0c6e9741fbd 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp
@@ -187,9 +187,9 @@ void SphericalGrid::distributePolygons(OccluderSource &source)
}
}
catch (...) {
- // If an exception was thrown, _faces.push_back() cannot have succeeded. Occluder is not owned by anyone,
- // and must be deleted. If the exception was thrown before or during new OccluderData(), then
- // occluder is NULL, and this delete is harmless.
+ // If an exception was thrown, _faces.push_back() cannot have succeeded. Occluder is not
+ // owned by anyone, and must be deleted. If the exception was thrown before or during new
+ // OccluderData(), then occluder is NULL, and this delete is harmless.
delete occluder;
throw;
}
diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.h b/source/blender/freestyle/intern/view_map/SphericalGrid.h
index ae00c270c1d..c32ceb09805 100644
--- a/source/blender/freestyle/intern/view_map/SphericalGrid.h
+++ b/source/blender/freestyle/intern/view_map/SphericalGrid.h
@@ -24,8 +24,9 @@
#define SPHERICAL_GRID_LOGGING 0
-// I would like to avoid using deque because including ViewMap.h and <deque> or <vector> separately results in
-// redefinitions of identifiers. ViewMap.h already includes <vector> so it should be a safe fall-back.
+// I would like to avoid using deque because including ViewMap.h and <deque> or <vector> separately
+// results in redefinitions of identifiers. ViewMap.h already includes <vector> so it should be a
+// safe fall-back.
//#include <vector>
//#include <deque>
@@ -57,9 +58,9 @@ class SphericalGrid {
Polygon3r poly;
Polygon3r cameraSpacePolygon;
real shallowest, deepest;
- // N.B. We could, of course, store face in poly's userdata member, like the old ViewMapBuilder code does.
- // However, code comments make it clear that userdata is deprecated, so we avoid the temptation to save
- // 4 or 8 bytes.
+ // N.B. We could, of course, store face in poly's userdata member, like the old ViewMapBuilder
+ // code does. However, code comments make it clear that userdata is deprecated, so we avoid the
+ // temptation to save 4 or 8 bytes.
WFace *face;
#ifdef WITH_CXX_GUARDEDALLOC
@@ -70,8 +71,8 @@ class SphericalGrid {
private:
struct Cell {
// Can't store Cell in a vector without copy and assign
- //Cell(const Cell& other);
- //Cell& operator=(const Cell& other);
+ // Cell(const Cell& other);
+ // Cell& operator=(const Cell& other);
explicit Cell();
~Cell();
@@ -83,25 +84,28 @@ class SphericalGrid {
void indexPolygons();
real boundary[4];
- //deque<OccluderData*> faces;
+ // deque<OccluderData*> faces;
vector<OccluderData *> faces;
};
public:
/*! Iterator needs to allow the user to avoid full 3D comparison in two cases:
*
- * (1) Where (*current)->deepest < target[2], where the occluder is unambiguously in front of the target point.
+ * (1) Where (*current)->deepest < target[2], where the occluder is unambiguously in front of
+ * the target point.
*
- * (2) Where (*current)->shallowest > target[2], where the occluder is unambiguously in back of the target point.
+ * (2) Where (*current)->shallowest > target[2], where the occluder is unambiguously in back of
+ * the target point.
*
- * In addition, when used by OptimizedFindOccludee, Iterator should stop iterating as soon as it has an occludee
- * candidate and (*current)->shallowest > candidate[2], because at that point forward no new occluder could
- * possibly be a better occludee.
+ * In addition, when used by OptimizedFindOccludee, Iterator should stop iterating as soon as it
+ * has an occludee candidate and (*current)->shallowest > candidate[2], because at that point
+ * forward no new occluder could possibly be a better occludee.
*/
class Iterator {
public:
- // epsilon is not used in this class, but other grids with the same interface may need an epsilon
+ // epsilon is not used in this class, but other grids with the same interface may need an
+ // epsilon
explicit Iterator(SphericalGrid &grid, Vec3r &center, real epsilon = 1.0e-06);
~Iterator();
void initBeforeTarget();
@@ -122,7 +126,7 @@ class SphericalGrid {
Vec3r _target;
bool _foundOccludee;
real _occludeeDepth;
- //deque<OccluderData*>::iterator _current, _occludeeCandidate;
+ // deque<OccluderData*>::iterator _current, _occludeeCandidate;
vector<OccluderData *>::iterator _current, _occludeeCandidate;
#ifdef WITH_CXX_GUARDEDALLOC
@@ -171,7 +175,7 @@ class SphericalGrid {
void getCellCoordinates(const Vec3r &point, unsigned &x, unsigned &y);
typedef PointerSequence<vector<Cell *>, Cell *> cellContainer;
- //typedef PointerSequence<deque<OccluderData*>, OccluderData*> occluderContainer;
+ // typedef PointerSequence<deque<OccluderData*>, OccluderData*> occluderContainer;
typedef PointerSequence<vector<OccluderData *>, OccluderData *> occluderContainer;
unsigned _cellsX, _cellsY;
float _cellSize;
@@ -222,8 +226,8 @@ inline bool SphericalGrid::Iterator::testOccluder(bool wantOccludee)
{
// End-of-list is not even a valid iterator position
if (_current == _cell->faces.end()) {
- // Returning true seems strange, but it will break us out of whatever loop is calling testOccluder, and
- // _current=_cell->face.end() will make the calling routine give up.
+ // Returning true seems strange, but it will break us out of whatever loop is calling
+ // testOccluder, and _current=_cell->face.end() will make the calling routine give up.
return true;
}
#if SPHERICAL_GRID_LOGGING
@@ -286,15 +290,17 @@ inline bool SphericalGrid::Iterator::testOccluder(bool wantOccludee)
return false;
}
- // We've done all the corner cutting we can. Let the caller work out whether or not the geometry is correct.
+ // We've done all the corner cutting we can. Let the caller work out whether or not the geometry
+ // is correct.
return true;
}
inline void SphericalGrid::Iterator::reportDepth(Vec3r origin, Vec3r u, real t)
{
- // The reported depth is the length of a ray in camera space. We need to convert it into the distance from viewpoint
- // If origin is the viewpoint, depth == t. A future optimization could allow the caller to tell us if origin is
- // viewponit or target, at the cost of changing the OptimizedGrid API.
+ // The reported depth is the length of a ray in camera space. We need to convert it into the
+ // distance from viewpoint If origin is the viewpoint, depth == t. A future optimization could
+ // allow the caller to tell us if origin is viewponit or target, at the cost of changing the
+ // OptimizedGrid API.
real depth = (origin + u * t).norm();
#if SPHERICAL_GRID_LOGGING
if (G.debug & G_DEBUG_FREESTYLE) {
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
index 94541b2c312..d1f9a5b41bd 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp
@@ -16,7 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Convenient access to the steerable ViewMap to which any element of the ViewMap belongs to.
+ * \brief Convenient access to the steerable ViewMap to which any element of the ViewMap belongs
+ * to.
*/
#include <sstream>
@@ -146,7 +147,7 @@ double *SteerableViewMap::AddFEdge(FEdge *iFEdge)
unsigned SteerableViewMap::getSVMNumber(const Vec2f &orient)
{
Vec2f dir(orient);
- //soc unsigned res = 0;
+ // soc unsigned res = 0;
real norm = dir.norm();
if (norm < 1.0e-6) {
return _nbOrientations + 1;
@@ -211,11 +212,11 @@ float SteerableViewMap::readSteerableViewMapPixel(unsigned iOrientation, int iLe
}
if ((x < 0) || (x >= pyramid->width()) || (y < 0) || (y >= pyramid->height()))
return 0;
- //float v = pyramid->pixel(x, pyramid->height() - 1 - y, iLevel) * 255.0f;
- // We encode both the directionality and the lines counting on 8 bits (because of frame buffer). Thus, we allow
- // until 8 lines to pass through the same pixel, so that we can discretize the Pi/_nbOrientations angle into
- // 32 slices. Therefore, for example, in the vertical direction, a vertical line will have the value 32 on
- // each pixel it passes through.
+ // float v = pyramid->pixel(x, pyramid->height() - 1 - y, iLevel) * 255.0f;
+ // We encode both the directionality and the lines counting on 8 bits (because of frame buffer).
+ // Thus, we allow until 8 lines to pass through the same pixel, so that we can discretize the
+ // Pi/_nbOrientations angle into 32 slices. Therefore, for example, in the vertical direction, a
+ // vertical line will have the value 32 on each pixel it passes through.
float v = pyramid->pixel(x, pyramid->height() - 1 - y, iLevel) / 32.0f;
return v;
}
@@ -243,31 +244,31 @@ void SteerableViewMap::saveSteerableViewMap() const
int ow = _imagesPyramids[i]->width(0);
int oh = _imagesPyramids[i]->height(0);
- //soc QString base("SteerableViewMap");
+ // soc QString base("SteerableViewMap");
string base("SteerableViewMap");
stringstream filename;
- for (int j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) { //soc
+ for (int j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) { // soc
float coeff = 1.0f; // 1 / 255.0f; // 100 * 255; // * pow(2, j);
- //soc QImage qtmp(ow, oh, QImage::Format_RGB32);
+ // soc QImage qtmp(ow, oh, QImage::Format_RGB32);
ImBuf *ibuf = IMB_allocImBuf(ow, oh, 32, IB_rect);
int rowbytes = ow * 4;
char *pix;
- for (int y = 0; y < oh; ++y) { //soc
- for (int x = 0; x < ow; ++x) { //soc
+ for (int y = 0; y < oh; ++y) { // soc
+ for (int x = 0; x < ow; ++x) { // soc
int c = (int)(coeff * _imagesPyramids[i]->pixel(x, y, j));
if (c > 255)
c = 255;
- //int c = (int)(_imagesPyramids[i]->pixel(x, y, j));
+ // int c = (int)(_imagesPyramids[i]->pixel(x, y, j));
- //soc qtmp.setPixel(x, y, qRgb(c, c, c));
+ // soc qtmp.setPixel(x, y, qRgb(c, c, c));
pix = (char *)ibuf->rect + y * rowbytes + x * 4;
pix[0] = pix[1] = pix[2] = c;
}
}
- //soc qtmp.save(base+QString::number(i)+"-"+QString::number(j)+".png", "PNG");
+ // soc qtmp.save(base+QString::number(i)+"-"+QString::number(j)+".png", "PNG");
filename << base;
filename << i << "-" << j << ".png";
ibuf->ftype = IMB_FTYPE_PNG;
@@ -279,7 +280,7 @@ void SteerableViewMap::saveSteerableViewMap() const
GrayImage *img = _imagesPyramids[i]->getLevel(j);
int ow = img->width();
int oh = img->height();
- float coeff = 1.0f; // 100 * 255; // * pow(2, j);
+ float coeff = 1.0f; // 100 * 255; // * pow(2, j);
QImage qtmp(ow, oh, 32);
for (unsigned int y = 0; y < oh; ++y) {
for (unsigned int x = 0; x < ow; ++x) {
diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.h b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
index 16f57f39737..537f07f44f4 100644
--- a/source/blender/freestyle/intern/view_map/SteerableViewMap.h
+++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.h
@@ -19,7 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Convenient access to the steerable ViewMap to which any element of the ViewMap belongs to.
+ * \brief Convenient access to the steerable ViewMap to which any element of the ViewMap belongs
+ * to.
*/
#include <map>
@@ -42,8 +43,8 @@ class FEdge;
class ImagePyramid;
class GrayImage;
-/*! This class checks for every FEdge in which steerable it belongs and stores the mapping allowing to retrieve
- * this information from the FEdge Id.
+/*! This class checks for every FEdge in which steerable it belongs and stores the mapping
+ * allowing to retrieve this information from the FEdge Id.
*/
class SteerableViewMap {
protected:
@@ -66,8 +67,8 @@ class SteerableViewMap {
virtual void Reset();
/*! Adds a FEdge to steerable VM.
- * Returns the nbOrientations weights corresponding to the FEdge contributions to the nbOrientations
- * directional maps.
+ * Returns the nbOrientations weights corresponding to the FEdge contributions to the
+ * nbOrientations directional maps.
*/
double *AddFEdge(FEdge *iFEdge);
@@ -86,12 +87,14 @@ class SteerableViewMap {
*/
unsigned getSVMNumber(unsigned id);
- /*! Builds _nbOrientations+1 pyramids of images from the _nbOrientations+1 base images of the steerable viewmap.
+ /*! Builds _nbOrientations+1 pyramids of images from the _nbOrientations+1 base images of the
+ * steerable viewmap.
* \param steerableBases:
* The _nbOrientations+1 images constituting the basis for the steerable pyramid.
* \param copy:
* If false, the data is not duplicated, and Canvas deals with the memory management of these
- * _nbOrientations+1 images. If true, data is copied, and it's up to the caller to delete the images.
+ * _nbOrientations+1 images. If true, data is copied, and it's up to the caller to delete
+ * the images.
* \param iNbLevels:
* The number of levels desired for each pyramid.
* If iNbLevels == 0, the complete pyramid is built.
@@ -116,13 +119,16 @@ class SteerableViewMap {
* \param iLevel:
* The level of the pyramid we want to read
* \param x:
- * The abscissa of the desired pixel specified in level0 coordinate system. The origin is the lower left corner.
+ * The abscissa of the desired pixel specified in level0 coordinate system.
+ * The origin is the lower left corner.
* \param y:
- * The ordinate of the desired pixel specified in level0 coordinate system. The origin is the lower left corner.
+ * The ordinate of the desired pixel specified in level0 coordinate system.
+ * The origin is the lower left corner.
*/
float readSteerableViewMapPixel(unsigned iOrientation, int iLevel, int x, int y);
- /*! Reads a pixel in the one of the level of the pyramid containing the images of the complete ViewMap.
+ /*! Reads a pixel in the one of the level of the pyramid containing the images
+ * of the complete ViewMap.
* Returns a value between 0 and 1.
* Equivalent to : readSteerableViewMapPixel(nbOrientations, x, y)
*/
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
index 8896918e60d..8715f4f52d9 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp
@@ -79,8 +79,8 @@ void ViewEdgeXBuilder::BuildViewEdges(WXShape *iWShape,
continue;
if (stopSmoothViewEdge((*sl))) // has it been parsed already ?
continue;
- // here we know that we're dealing with a face layer that has not been processed yet and that contains
- // a smooth edge.
+ // here we know that we're dealing with a face layer that has not been processed yet and that
+ // contains a smooth edge.
/* vedge =*//* UNUSED */ BuildSmoothViewEdge(OWXFaceLayer(*sl, true));
}
}
@@ -89,7 +89,7 @@ void ViewEdgeXBuilder::BuildViewEdges(WXShape *iWShape,
//----------------------------------
// Reset all userdata for WXEdge structure
//----------------------------------------
- //iWShape->ResetUserData();
+ // iWShape->ResetUserData();
WXEdge *wxe;
vector<WEdge *> &wedges = iWShape->getEdgeList();
@@ -229,7 +229,7 @@ ViewEdge *ViewEdgeXBuilder::BuildSharpViewEdge(const OWXEdge &iWEdge)
while (!stopSharpViewEdge(currentWEdge.e)) {
edgesChain.push_back(currentWEdge);
++size;
- currentWEdge.e->userdata = (void *)1; // processed
+ currentWEdge.e->userdata = (void *)1; // processed
// Find the next edge!
currentWEdge = FindNextWEdge(currentWEdge);
}
@@ -239,7 +239,7 @@ ViewEdge *ViewEdgeXBuilder::BuildSharpViewEdge(const OWXEdge &iWEdge)
while (!stopSharpViewEdge(currentWEdge.e)) {
edgesChain.push_front(currentWEdge);
++size;
- currentWEdge.e->userdata = (void *)1; // processed
+ currentWEdge.e->userdata = (void *)1; // processed
// Find the previous edge!
currentWEdge = FindPreviousWEdge(currentWEdge);
}
@@ -339,7 +339,8 @@ OWXFaceLayer ViewEdgeXBuilder::FindNextFaceLayer(const OWXFaceLayer &iFaceLayer)
nextFace = dynamic_cast<WXFace *>(iFaceLayer.fl->getFace()->GetBordingFace(woeend));
if (!nextFace)
return OWXFaceLayer(NULL, true);
- // if the next face layer has either no smooth edge or no smooth edge of same nature, no next face
+ // if the next face layer has either no smooth edge or no smooth edge of same nature, no next
+ // face
if (!nextFace->hasSmoothEdges())
return OWXFaceLayer(NULL, true);
vector<WXFaceLayer *> sameNatureLayers;
@@ -411,7 +412,8 @@ OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer &iFaceLa
previousFace = dynamic_cast<WXFace *>(iFaceLayer.fl->getFace()->GetBordingFace(woebegin));
if (0 == previousFace)
return OWXFaceLayer(NULL, true);
- // if the next face layer has either no smooth edge or no smooth edge of same nature, no next face
+ // if the next face layer has either no smooth edge or no smooth edge of same nature, no next
+ // face
if (!previousFace->hasSmoothEdges())
return OWXFaceLayer(NULL, true);
vector<WXFaceLayer *> sameNatureLayers;
@@ -688,7 +690,7 @@ FEdge *ViewEdgeXBuilder::BuildSharpFEdge(FEdge *feprevious, const OWXEdge &iwe)
_pCurrentSShape->AddEdge(fe);
va->AddFEdge(fe);
vb->AddFEdge(fe);
- //Add normals:
+ // Add normals:
va->AddNormal(normalA);
va->AddNormal(normalB);
vb->AddNormal(normalA);
diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
index 6f3604a1029..26f114497c0 100644
--- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.h
@@ -28,7 +28,8 @@
#if 0 // soc
# if defined(__GNUC__) && (__GNUC__ >= 3)
-//hash_map is not part of the C++ standard anymore; hash_map.h has been kept though for backward compatibility
+/* hash_map is not part of the C++ standard anymore;
+ * hash_map.h has been kept though for backward compatibility */
# include <hash_map.h>
# else
# include <hash_map>
@@ -278,9 +279,9 @@ class ViewEdgeXBuilder {
/*! instanciate a ViewVertex from a SVertex, if it doesn't exist yet */
ViewVertex *MakeViewVertex(SVertex *iSVertex);
- //oldtmp values
- //IdHashTable _hashtable;
- //VVIdHashTable _multivertexHashTable;
+ // oldtmp values
+ // IdHashTable _hashtable;
+ // VVIdHashTable _multivertexHashTable;
SVertexMap _SVertexMap;
SShape *_pCurrentSShape;
ViewShape *_pCurrentVShape;
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.cpp b/source/blender/freestyle/intern/view_map/ViewMap.cpp
index 7c72e44fc10..0b352be1a89 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMap.cpp
@@ -155,8 +155,8 @@ TVertex *ViewMap::CreateTVertex(const Vec3r &iA3D,
SVertex *Ia = shapeA->CreateSVertex(iA3D, iA2D, iFEdgeA->vertexA()->getId());
SVertex *Ib = shapeB->CreateSVertex(iB3D, iB2D, iFEdgeB->vertexA()->getId());
- // depending on which of these 2 svertices is the nearest from the viewpoint, we're going to build the TVertex
- // by giving them in an order or another (the first one must be the nearest)
+ // depending on which of these 2 svertices is the nearest from the viewpoint, we're going to
+ // build the TVertex by giving them in an order or another (the first one must be the nearest)
real dista = Ia->point2D()[2];
real distb = Ib->point2D()[2];
@@ -185,8 +185,8 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
NonTVertex *vva = dynamic_cast<NonTVertex *>(iVertex->viewvertex());
if (vva)
return vva;
- // because it is not already a ViewVertex, this SVertex must have only 2 FEdges. The incoming one still belongs
- // to ioEdge, the outgoing one now belongs to newVEdge
+ // because it is not already a ViewVertex, this SVertex must have only 2 FEdges. The incoming one
+ // still belongs to ioEdge, the outgoing one now belongs to newVEdge
const vector<FEdge *> &fedges = iVertex->fedges();
if (fedges.size() != 2) {
cerr << "ViewMap warning: Can't split the ViewEdge" << endl;
@@ -235,7 +235,7 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
ViewEdge *newVEdge = new ViewEdge(vva, ioEdge->B(), fbegin, ioEdge->fedgeB(), vshape);
newVEdge->setId(Id(ioEdge->getId().getFirst(), ioEdge->getId().getSecond() + 1));
newVEdge->setNature(ioEdge->getNature());
- //newVEdge->UpdateFEdges(); // done in the ViewEdge constructor
+ // newVEdge->UpdateFEdges(); // done in the ViewEdge constructor
// Update old ViewEdge
ioEdge->setB(vva);
ioEdge->setFEdgeB(fend);
@@ -253,7 +253,7 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
vvb->Replace(ioEdge, newVEdge);
// update ViewShape
- //vshape->AddEdge(newVEdge);
+ // vshape->AddEdge(newVEdge);
// update SShape
vshape->sshape()->AddChain(fbegin);
// update ViewMap
@@ -271,7 +271,7 @@ ViewVertex *ViewMap::InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newV
}
#if 0
-FEdge *ViewMap::Connect(FEdge *ioEdge, SVertex *ioVertex, vector<ViewEdge*>& oNewVEdges)
+FEdge *ViewMap::Connect(FEdge *ioEdge, SVertex *ioVertex, vector<ViewEdge *> &oNewVEdges)
{
SShape *sshape = ioEdge->shape();
FEdge *newFEdge = sshape->SplitEdgeIn2(ioEdge, ioVertex);
@@ -421,25 +421,27 @@ void TVertex::Replace(ViewEdge *iOld, ViewEdge *iNew)
/*! iterators access */
ViewVertex::edge_iterator TVertex::edges_begin()
{
- //return edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, _FrontEdgeA);
+ // return edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, _FrontEdgeA);
return edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), _sortedEdges.begin());
}
ViewVertex::const_edge_iterator TVertex::edges_begin() const
{
- //return const_edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, _FrontEdgeA);
+ // return const_edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, _FrontEdgeA);
return const_edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), _sortedEdges.begin());
}
ViewVertex::edge_iterator TVertex::edges_end()
{
- //return edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, directedViewEdge(0,true));
+ // return edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB,
+ // directedViewEdge(0,true));
return edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), _sortedEdges.end());
}
ViewVertex::const_edge_iterator TVertex::edges_end() const
{
- //return const_edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB, directedViewEdge(0, true));
+ // return const_edge_iterator(_FrontEdgeA, _FrontEdgeB, _BackEdgeA, _BackEdgeB,
+ // directedViewEdge(0, true));
return const_edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), _sortedEdges.end());
}
diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h
index b25e13d990f..9b1eab0d905 100644
--- a/source/blender/freestyle/intern/view_map/ViewMap.h
+++ b/source/blender/freestyle/intern/view_map/ViewMap.h
@@ -75,8 +75,8 @@ class ViewMap {
fedges_container _FEdges; // feature edges (embedded edges)
svertices_container _SVertices; // embedded vertices
BBox<Vec3r> _scene3DBBox;
- // Mapping between the WShape or VShape id to the VShape index in the _VShapes vector. Used in the method
- // viewShape(int id) to access a shape from its id.
+ // Mapping between the WShape or VShape id to the VShape index in the _VShapes vector. Used in
+ // the method viewShape(int id) to access a shape from its id.
id_to_index_map _shapeIdToIndex;
public:
@@ -222,16 +222,15 @@ class ViewMap {
FEdge *iFEdgeB,
const Id &id);
- /* Updates the structures to take into account the fact that a SVertex must now be considered as a ViewVertex
- * iVertex
- * The SVertex on top of which the ViewVertex is built (it is necessarily a NonTVertex because it is a SVertex)
- * newViewEdges
- * The new ViewEdges that must be add to the ViewMap
+ /* Updates the structures to take into account the fact that a SVertex must now be considered as
+ * a ViewVertex iVertex The SVertex on top of which the ViewVertex is built (it is necessarily a
+ * NonTVertex because it is a SVertex) newViewEdges The new ViewEdges that must be add to the
+ * ViewMap
*/
ViewVertex *InsertViewVertex(SVertex *iVertex, vector<ViewEdge *> &newViewEdges);
/* connects a FEdge to the graph trough a SVertex */
- //FEdge *Connect(FEdge *ioEdge, SVertex *ioVertex);
+ // FEdge *Connect(FEdge *ioEdge, SVertex *ioVertex);
/* Clean temporary FEdges created by chaining */
virtual void Clean();
@@ -262,11 +261,12 @@ class orientedViewEdgeIterator;
} // namespace ViewVertexInternal
/*! Class to define a view vertex.
- * A view vertex is a feature vertex corresponding to a point of the image graph, where the characteristics of an
- * edge might change (nature, visibility, ...).
- * A ViewVertex can be of two kinds: a TVertex when it corresponds to the intersection between two ViewEdges or a
- * NonTVertex when it corresponds to a vertex of the initial input mesh (it is the case for vertices such as corners
- * for example). Thus, this class can be specialized into two classes, the TVertex class and the NonTVertex class.
+ * A view vertex is a feature vertex corresponding to a point of the image graph, where the
+ * characteristics of an edge might change (nature, visibility, ...). A ViewVertex can be of two
+ * kinds: a TVertex when it corresponds to the intersection between two ViewEdges or a NonTVertex
+ * when it corresponds to a vertex of the initial input mesh (it is the case for vertices such as
+ * corners for example). Thus, this class can be specialized into two classes, the TVertex class
+ * and the NonTVertex class.
*/
class ViewVertex : public Interface0D {
public: // Implementation of Interface0D
@@ -348,8 +348,8 @@ class ViewVertex : public Interface0D {
public:
/* iterators access */
- // allows iteration on the edges that comes from/goes to this vertex in CCW order (order defined in 2D in the
- // image plan)
+ // allows iteration on the edges that comes from/goes to this vertex in CCW order (order defined
+ // in 2D in the image plan)
virtual edge_iterator edges_begin() = 0;
virtual const_edge_iterator edges_begin() const = 0;
virtual edge_iterator edges_end() = 0;
@@ -358,13 +358,14 @@ class ViewVertex : public Interface0D {
virtual const_edge_iterator edges_iterator(ViewEdge *iEdge) const = 0;
// Iterator access
- /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to the first
- * ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order over these ViewEdges
- * and to get the orientation for each ViewEdge (incoming/outgoing).
+ /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to
+ * the first ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order
+ * over these ViewEdges and to get the orientation for each ViewEdge (incoming/outgoing).
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesBegin() = 0;
- /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after the last ViewEdge.
+ /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after
+ * the last ViewEdge.
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd() = 0;
@@ -477,7 +478,8 @@ class TVertex : public ViewVertex {
directedViewEdge _FrontEdgeB;
directedViewEdge _BackEdgeA;
directedViewEdge _BackEdgeB;
- Id _Id; // id to identify t vertices . these id will be negative in order not to be mixed with NonTVertex ids.
+ Id _Id; // id to identify t vertices . these id will be negative in order not to be mixed with
+ // NonTVertex ids.
edge_pointers_container
_sortedEdges; // the list of the four ViewEdges, ordered in CCW order (in the image plan)
@@ -606,8 +608,8 @@ class TVertex : public ViewVertex {
virtual void Replace(ViewEdge *iOld, ViewEdge *iNew);
/*! returns the mate edge of iEdgeA.
- * For example, if iEdgeA is frontEdgeA, then frontEdgeB is returned. If iEdgeA is frontEdgeB then frontEdgeA
- * is returned. Same for back edges
+ * For example, if iEdgeA is frontEdgeA, then frontEdgeB is returned. If iEdgeA is frontEdgeB
+ * then frontEdgeA is returned. Same for back edges
*/
virtual ViewEdge *mate(ViewEdge *iEdgeA)
{
@@ -630,13 +632,14 @@ class TVertex : public ViewVertex {
virtual edge_iterator edges_iterator(ViewEdge *iEdge);
virtual const_edge_iterator edges_iterator(ViewEdge *iEdge) const;
- /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to the first
- * ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order over these ViewEdges
- * and to get the orientation for each ViewEdge (incoming/outgoing).
+ /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to
+ * the first ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order
+ * over these ViewEdges and to get the orientation for each ViewEdge (incoming/outgoing).
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesBegin();
- /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after the last ViewEdge.
+ /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after
+ * the last ViewEdge.
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd();
@@ -847,13 +850,14 @@ class NonTVertex : public ViewVertex {
virtual edge_iterator edges_iterator(ViewEdge *iEdge);
virtual const_edge_iterator edges_iterator(ViewEdge *iEdge) const;
- /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to the first
- * ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order over these ViewEdges
- * and to get the orientation for each ViewEdge (incoming/outgoing).
+ /*! Returns an iterator over the ViewEdges that goes to or comes from this ViewVertex pointing to
+ * the first ViewEdge of the list. The orientedViewEdgeIterator allows to iterate in CCW order
+ * over these ViewEdges and to get the orientation for each ViewEdge (incoming/outgoing).
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesBegin();
- /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after the last ViewEdge.
+ /*! Returns an orientedViewEdgeIterator over the ViewEdges around this ViewVertex, pointing after
+ * the last ViewEdge.
*/
virtual ViewVertexInternal::orientedViewEdgeIterator edgesEnd();
@@ -891,8 +895,8 @@ template<class Traits> class vertex_iterator_base;
} // end of namespace ViewEdgeInternal
-/*! Class defining a ViewEdge. A ViewEdge in an edge of the image graph. it connects two ViewVertex.
- * It is made by connecting a set of FEdges.
+/*! Class defining a ViewEdge. A ViewEdge in an edge of the image graph. it connects two
+ * ViewVertex. It is made by connecting a set of FEdges.
*/
class ViewEdge : public Interface1D {
public: // Implementation of Interface0D
@@ -937,9 +941,9 @@ class ViewEdge : public Interface1D {
FEdge *_FEdgeB; // last edge of the embedded fedges chain
Id _Id;
unsigned _ChainingTimeStamp;
- // The silhouette view edge separates 2 2D spaces. The one on the left is necessarly the Shape _Shape (the one to
- // which this edge belongs to) and _aShape is the one on its right
- // NOT HANDLED BY THE COPY CONSTRUCTOR
+ // The silhouette view edge separates 2 2D spaces. The one on the left is necessarly the Shape
+ // _Shape (the one to which this edge belongs to) and _aShape is the one on its right NOT HANDLED
+ // BY THE COPY CONSTRUCTOR
ViewShape *_aShape;
int _qi;
vector<ViewShape *> _Occluders;
@@ -1016,7 +1020,7 @@ class ViewEdge : public Interface1D {
UpdateFEdges(); // tells every FEdge between iFEdgeA and iFEdgeB that this is theit ViewEdge
}
- //soc protected:
+ // soc protected:
/*! Copy constructor. */
inline ViewEdge(ViewEdge &iBrother)
{
@@ -1091,9 +1095,8 @@ class ViewEdge : public Interface1D {
return _Shape;
}
- /*! Returns the shape that is occluded by the ViewShape to which this ViewEdge belongs to. If no object is occluded,
- * NULL is returned.
- * \return The occluded ViewShape.
+ /*! Returns the shape that is occluded by the ViewShape to which this ViewEdge belongs to. If no
+ * object is occluded, NULL is returned. \return The occluded ViewShape.
*/
inline ViewShape *aShape()
{
@@ -1316,7 +1319,7 @@ class ViewEdge : public Interface1D {
return false;
}
- //inline real z_discontinuity(int iCombination = 0) const;
+ // inline real z_discontinuity(int iCombination = 0) const;
inline Id shape_id() const
{
@@ -1353,25 +1356,25 @@ class ViewEdge : public Interface1D {
vertex_iterator vertices_end();
// Iterator access (Interface1D)
- /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this ViewEdge.
- * The returned Interface0DIterator points to the first SVertex of the ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this
+ * ViewEdge. The returned Interface0DIterator points to the first SVertex of the ViewEdge.
*/
virtual Interface0DIterator verticesBegin();
- /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this ViewEdge.
- * The returned Interface0DIterator points after the last SVertex of the ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this
+ * ViewEdge. The returned Interface0DIterator points after the last SVertex of the ViewEdge.
*/
virtual Interface0DIterator verticesEnd();
- /*! Returns an Interface0DIterator to iterate over the points of this ViewEdge at a given resolution.
- * The returned Interface0DIterator points on the first Point of the ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the points of this ViewEdge at a given
+ * resolution. The returned Interface0DIterator points on the first Point of the ViewEdge.
* \param t:
* the sampling value.
*/
virtual Interface0DIterator pointsBegin(float t = 0.0f);
- /*! Returns an Interface0DIterator to iterate over the points of this ViewEdge at a given resolution.
- * The returned Interface0DIterator points after the last Point of the ViewEdge.
+ /*! Returns an Interface0DIterator to iterate over the points of this ViewEdge at a given
+ * resolution. The returned Interface0DIterator points after the last Point of the ViewEdge.
* \param t:
* the sampling value.
*/
@@ -1390,7 +1393,8 @@ class ViewEdge : public Interface1D {
/* */
/**********************************/
-/*! Class gathering the elements of the ViewMap (ViewVertex, ViewEdge) that are issued from the same input shape. */
+/*! Class gathering the elements of the ViewMap (ViewVertex, ViewEdge) that are issued from the
+ * same input shape. */
class ViewShape {
private:
vector<ViewVertex *> _Vertices;
@@ -1520,11 +1524,10 @@ class ViewShape {
* The FEdge that gets splitted
* iViewVertices
* The view vertices corresponding to the different intersections for the edge fe.
- * This list need to be sorted such as the first view vertex is the farther away from fe->vertexA.
- * ioNewEdges
- * The feature edges that are newly created (the initial edges are not included) are added to this list.
- * ioNewViewEdges
- * The view edges that are newly created (the initial edges are not included) are added to this list.
+ * This list need to be sorted such as the first view vertex is the farther away from
+ * fe->vertexA. ioNewEdges The feature edges that are newly created (the initial edges are not
+ * included) are added to this list. ioNewViewEdges The view edges that are newly created (the
+ * initial edges are not included) are added to this list.
*/
inline void SplitEdge(FEdge *fe,
const vector<TVertex *> &iViewVertices,
@@ -1608,7 +1611,8 @@ class ViewShape {
//_SShape->AddNewEdge(iEdge->fedge());
}
- /* removes the view edge iViewEdge in the View Shape and the associated FEdge chain entry in the underlying SShape
+ /* removes the view edge iViewEdge in the View Shape and the associated FEdge chain entry in the
+ * underlying SShape
*/
void RemoveEdge(ViewEdge *iViewEdge);
@@ -1681,28 +1685,30 @@ void ViewShape::SplitEdge(FEdge *fe,
ViewEdge *newVEdge;
if ((vva == 0) || (vvb == 0)) { // that means we're dealing with a closed viewedge (loop)
- // remove the chain that was starting by the fedge A of vEdge (which is different from fe !!!!)
+ // remove the chain that was starting by the fedge A of vEdge (which is different from fe
+ // !!!!)
shape->RemoveEdgeFromChain(vEdge->fedgeA());
// we set
vEdge->setA(*vv);
vEdge->setB(*vv);
vEdge->setFEdgeA(newEdge);
- //FEdge *previousEdge = newEdge->previousEdge();
+ // FEdge *previousEdge = newEdge->previousEdge();
vEdge->setFEdgeB(fe);
newVEdge = vEdge;
vEdge->fedgeA()->setViewEdge(newVEdge);
}
else {
- // while we create the view edge, it updates the "ViewEdge" pointer of every underlying FEdges to this.
+ // while we create the view edge, it updates the "ViewEdge" pointer of every underlying
+ // FEdges to this.
newVEdge = new ViewEdge((*vv), vvb); //, newEdge, vEdge->fedgeB());
newVEdge->setNature((fe)->getNature());
newVEdge->setFEdgeA(newEdge);
- //newVEdge->setFEdgeB(fe);
+ // newVEdge->setFEdgeB(fe);
// If our original viewedge is made of one FEdge, then
if ((vEdge->fedgeA() == vEdge->fedgeB()) || (fe == vEdge->fedgeB()))
newVEdge->setFEdgeB(newEdge);
else
- newVEdge->setFEdgeB(vEdge->fedgeB()); //MODIF
+ newVEdge->setFEdgeB(vEdge->fedgeB()); // MODIF
Id *newId = vEdge->splittingId();
if (newId == 0) {
@@ -1728,7 +1734,7 @@ void ViewShape::SplitEdge(FEdge *fe,
// we split the view edge:
vEdge->setB((*vv));
- vEdge->setFEdgeB(fe); //MODIF
+ vEdge->setFEdgeB(fe); // MODIF
// Update fedges so that they point to the new viewedge:
newVEdge->UpdateFEdges();
@@ -1761,7 +1767,7 @@ inline Vec3r ViewEdge::orientation2d(int iCombination) const
return edge_orientation2d_function<ViewEdge>(*this, iCombination);
}
-inline Vec3r ViewEdge::orientation3d(int iCombination) const
+inline Vec3r ViewEdge::orientation3d(int iCombination) const
{
return edge_orientation3d_function<ViewEdge>(*this, iCombination);
}
@@ -1771,7 +1777,7 @@ inline real ViewEdge::z_discontinuity(int iCombination) const
return z_discontinuity_edge_function<ViewEdge>(*this, iCombination);
}
-inline float ViewEdge::local_average_depth(int iCombination ) const
+inline float ViewEdge::local_average_depth(int iCombination) const
{
return local_average_depth_edge_function<ViewEdge>(*this, iCombination);
}
diff --git a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
index 2c09bde487b..63343c33c4f 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
@@ -165,11 +165,12 @@ class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
{
}
- //protected://FIXME
+ // protected://FIXME
public:
#if 0
- inline edge_iterator_base(value_type ifeA, value_type ifeB, value_type ibeA, value_type ibeB, value_type iter)
- : parent_class()
+ inline edge_iterator_base(
+ value_type ifeA, value_type ifeB, value_type ibeA, value_type ibeB, value_type iter)
+ : parent_class()
{
_Nature = Nature::T_VERTEX;
_feA = ifeA;
@@ -207,7 +208,7 @@ class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
{
if (_Nature & Nature::T_VERTEX)
return (_tvertex_iter == _tbegin);
- //return (_tvertex_iter == _feA);
+ // return (_tvertex_iter == _feA);
else
return (_nontvertex_iter == _begin);
}
@@ -215,7 +216,7 @@ class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
virtual bool end() const
{
if (_Nature & Nature::T_VERTEX)
- //return (_tvertex_iter.first == 0);
+ // return (_tvertex_iter.first == 0);
return (_tvertex_iter == _tend);
else
return (_nontvertex_iter == _end);
@@ -256,7 +257,7 @@ class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
virtual reference operator*() const
{
if (_Nature & Nature::T_VERTEX)
- //return _tvertex_iter;
+ // return _tvertex_iter;
return **_tvertex_iter;
else
return (*_nontvertex_iter);
@@ -361,8 +362,8 @@ class edge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_
public:
mutable value_type _ViewEdge;
- //friend class edge_iterator_base<Nonconst_traits<ViewEdge*> >;
- //friend class edge_iterator_base<Const_traits<ViewEdge*> >;
+ // friend class edge_iterator_base<Nonconst_traits<ViewEdge*> >;
+ // friend class edge_iterator_base<Const_traits<ViewEdge*> >;
value_type _first;
bool _orientation;
typedef IteratorBase<Traits, BidirectionalIteratorTag_Traits> parent_class;
@@ -391,7 +392,7 @@ class edge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_
_orientation = iBrother._orientation;
}
- //protected://FIXME
+ // protected://FIXME
public:
inline edge_iterator_base(value_type iEdge, bool orientation = true) : parent_class()
{
@@ -549,7 +550,7 @@ class fedge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag
_FEdgeB = iBrother._FEdgeB;
}
- //protected://FIXME
+ // protected://FIXME
public:
inline fedge_iterator_base(value_type iEdge, value_type iFEdgeB) : parent_class()
{
@@ -686,7 +687,7 @@ class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTa
_PreviousFEdge = iBrother._PreviousFEdge;
}
- //protected://FIXME
+ // protected://FIXME
public:
inline vertex_iterator_base(value_type iVertex, FEdge *iPreviousFEdge, FEdge *iNextFEdge)
: parent_class()
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index ed0f5c9b0bd..f990b7bd63a 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -125,7 +125,7 @@ static void findOccludee(FEdge *fe,
else {
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
if (GeomUtils::COINCIDENT ==
GeomUtils::intersectRayPlane(origin, edgeDir, p->getNormal(), d, t, epsilon)) {
#if LOGGING
@@ -255,8 +255,9 @@ static int computeVisibility(ViewMap *viewMap,
I occluders(grid, center, epsilon);
for (occluders.initBeforeTarget(); occluders.validBeforeTarget(); occluders.nextOccluder()) {
- // If we're dealing with an exact silhouette, check whether we must take care of this occluder of not.
- // (Indeed, we don't consider the occluders that share at least one vertex with the face containing this edge).
+ // If we're dealing with an exact silhouette, check whether we must take care of this occluder
+ // of not. (Indeed, we don't consider the occluders that share at least one vertex with the
+ // face containing this edge).
//-----------
oface = occluders.getWFace();
Polygon3r *p = occluders.getCameraSpacePolygon();
@@ -324,8 +325,8 @@ static int computeVisibility(ViewMap *viewMap,
continue;
WFace *sface = (*ie)->GetbFace();
- //WFace *sfacea = (*ie)->GetaFace();
- //if ((sface == oface) || (sfacea == oface))
+ // WFace *sfacea = (*ie)->GetaFace();
+ // if ((sface == oface) || (sfacea == oface))
if (sface == oface) {
skipFace = true;
break;
@@ -346,7 +347,7 @@ static int computeVisibility(ViewMap *viewMap,
else {
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
if (GeomUtils::COINCIDENT ==
GeomUtils::intersectRayPlane(origin, edgeDir, p->getNormal(), d, t, epsilon)) {
#if LOGGING
@@ -412,11 +413,12 @@ static int computeVisibility(ViewMap *viewMap,
// computeCumulativeVisibility returns the lowest x such that the majority of FEdges have QI <= x
//
-// This was probably the original intention of the "normal" algorithm on which computeDetailedVisibility is based.
-// But because the "normal" algorithm chooses the most popular QI, without considering any other values, a ViewEdge
-// with FEdges having QIs of 0, 21, 22, 23, 24 and 25 will end up having a total QI of 0, even though most of the
-// FEdges are heavily occluded. computeCumulativeVisibility will treat this case as a QI of 22 because 3 out of
-// 6 occluders have QI <= 22.
+// This was probably the original intention of the "normal" algorithm on which
+// computeDetailedVisibility is based. But because the "normal" algorithm chooses the most popular
+// QI, without considering any other values, a ViewEdge with FEdges having QIs of 0, 21, 22, 23, 24
+// and 25 will end up having a total QI of 0, even though most of the FEdges are heavily occluded.
+// computeCumulativeVisibility will treat this case as a QI of 22 because 3 out of 6 occluders have
+// QI <= 22.
template<typename G, typename I>
static void computeCumulativeVisibility(ViewMap *ioViewMap,
@@ -513,7 +515,7 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
continue;
}
if ((maxCard < qiMajority)) {
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: change &wFace to wFace and use reference in called function
tmpQI = computeVisibility<G, I>(
ioViewMap, fe, grid, epsilon, *ve, &wFace, &foundOccluders);
#if LOGGING
@@ -522,11 +524,11 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
}
#endif
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -536,8 +538,8 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: change &wFace to wFace and use reference in called function
findOccludee<G, I>(fe, grid, epsilon, *ve, &wFace);
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
@@ -589,8 +591,8 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap,
}
}
// occluders --
- // I would rather not have to go through the effort of creating this set and then copying out its contents.
- // Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>?
+ // I would rather not have to go through the effort of creating this set and then copying out
+ // its contents. Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>?
for (set<ViewShape *>::iterator o = foundOccluders.begin(), oend = foundOccluders.end();
o != oend;
++o) {
@@ -710,7 +712,7 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
continue;
}
if ((maxCard < qiMajority)) {
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: change &wFace to wFace and use reference in called function
tmpQI = computeVisibility<G, I>(
ioViewMap, fe, grid, epsilon, *ve, &wFace, &foundOccluders);
#if LOGGING
@@ -719,11 +721,11 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
}
#endif
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -733,8 +735,8 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: change &wFace to wFace and use reference in called function
findOccludee<G, I>(fe, grid, epsilon, *ve, &wFace);
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
@@ -779,8 +781,8 @@ static void computeDetailedVisibility(ViewMap *ioViewMap,
// qi --
(*ve)->setQI(maxIndex);
// occluders --
- // I would rather not have to go through the effort of creating this this set and then copying out its contents.
- // Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>?
+ // I would rather not have to go through the effort of creating this this set and then copying
+ // out its contents. Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>?
for (set<ViewShape *>::iterator o = foundOccluders.begin(), oend = foundOccluders.end();
o != oend;
++o) {
@@ -877,15 +879,15 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
}
if (even_test) {
if ((maxCard < qiMajority)) {
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: change &wFace to wFace and use reference in called function
tmpQI = computeVisibility<G, I>(
ioViewMap, fe, grid, epsilon, *ve, &wFace, &foundOccluders);
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -895,8 +897,8 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon)
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
- //ARB: change &wFace to wFace and use reference in called function
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: change &wFace to wFace and use reference in called function
findOccludee<G, I>(fe, grid, epsilon, *ve, &wFace);
}
@@ -1008,7 +1010,8 @@ void ViewMapBuilder::BuildGrid(WingedEdge &we, const BBox<Vec3r> &bbox, unsigned
Vec3r size;
for (unsigned int i = 0; i < 3; i++) {
size[i] = fabs(bbox.getMax()[i] - bbox.getMin()[i]);
- // let make the grid 1/10 bigger to avoid numerical errors while computing triangles/cells intersections.
+ // let make the grid 1/10 bigger to avoid numerical errors while computing triangles/cells
+ // intersections.
size[i] += size[i] / 10.0;
if (size[i] == 0) {
if (_global.debug & G_DEBUG_FREESTYLE) {
@@ -1083,8 +1086,8 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
// Non-displayable view edges will be skipped over during visibility calculation.
- // View edges will be culled according to their position w.r.t. the viewport proscenium (viewport + 5% border,
- // or some such).
+ // View edges will be culled according to their position w.r.t. the viewport proscenium (viewport
+ // + 5% border, or some such).
// Get proscenium boundary for culling
GridHelpers::getDefaultViewProscenium(viewProscenium);
@@ -1098,17 +1101,16 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
cout << "Origin: [" << prosceniumOrigin[0] << ", " << prosceniumOrigin[1] << "]" << endl;
}
- // A separate occluder proscenium will also be maintained, starting out the same as the viewport proscenium, and
- // expanding as necessary so that it encompasses the center point of at least one feature edge in each retained view
- // edge.
- // The occluder proscenium will be used later to cull occluding triangles before they are inserted into the Grid.
- // The occluder proscenium starts out the same size as the view proscenium
+ // A separate occluder proscenium will also be maintained, starting out the same as the viewport
+ // proscenium, and expanding as necessary so that it encompasses the center point of at least one
+ // feature edge in each retained view edge. The occluder proscenium will be used later to cull
+ // occluding triangles before they are inserted into the Grid. The occluder proscenium starts out
+ // the same size as the view proscenium
GridHelpers::getDefaultViewProscenium(occluderProscenium);
- // N.B. Freestyle is inconsistent in its use of ViewMap::viewedges_container and vector<ViewEdge*>::iterator.
- // Probably all occurences of vector<ViewEdge*>::iterator should be replaced ViewMap::viewedges_container
- // throughout the code.
- // For each view edge
+ // N.B. Freestyle is inconsistent in its use of ViewMap::viewedges_container and
+ // vector<ViewEdge*>::iterator. Probably all occurences of vector<ViewEdge*>::iterator should be
+ // replaced ViewMap::viewedges_container throughout the code. For each view edge
ViewMap::viewedges_container::iterator ve, veend;
for (ve = ioViewMap->ViewEdges().begin(), veend = ioViewMap->ViewEdges().end(); ve != veend;
@@ -1130,8 +1132,8 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
// All ViewEdges start culled
(*ve)->setIsInImage(false);
- // For simple visibility calculation: mark a feature edge that is known to have a center point inside the
- // occluder proscenium. Cull all other feature edges.
+ // For simple visibility calculation: mark a feature edge that is known to have a center point
+ // inside the occluder proscenium. Cull all other feature edges.
do {
// All FEdges start culled
fe->setIsInImage(false);
@@ -1165,15 +1167,15 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
fe = fe->nextEdge();
} while (fe && fe != festart && !(bestOccluderTargetFound && (*ve)->isInImage()));
- // Either we have run out of FEdges, or we already have the one edge we need to determine visibility
- // Cull all remaining edges.
+ // Either we have run out of FEdges, or we already have the one edge we need to determine
+ // visibility Cull all remaining edges.
while (fe && fe != festart) {
fe->setIsInImage(false);
fe = fe->nextEdge();
}
- // If bestOccluderTarget was not found inside the occluder proscenium, we need to expand the occluder
- // proscenium to include it.
+ // If bestOccluderTarget was not found inside the occluder proscenium, we need to expand the
+ // occluder proscenium to include it.
if ((*ve)->isInImage() && bestOccluderTarget != NULL && !bestOccluderTargetFound) {
// Expand occluder proscenium to enclose bestOccluderTarget
Vec3r point = bestOccluderTarget->center2d();
@@ -1204,14 +1206,15 @@ void ViewMapBuilder::CullViewEdges(ViewMap *ioViewMap,
// For "Normal" or "Fast" style visibility computation only:
- // For more detailed visibility calculation, make a second pass through the view map, marking all feature edges
- // with center points inside the final occluder proscenium. All of these feature edges can be considered during
- // visibility calculation.
+ // For more detailed visibility calculation, make a second pass through the view map, marking all
+ // feature edges with center points inside the final occluder proscenium. All of these feature
+ // edges can be considered during visibility calculation.
- // So far we have only found one FEdge per ViewEdge. The "Normal" and "Fast" styles of visibility computation
- // want to consider many FEdges for each ViewEdge.
- // Here we re-scan the view map to find any usable FEdges that we skipped on the first pass, or that have become
- // usable because the occluder proscenium has been expanded since the edge was visited on the first pass.
+ // So far we have only found one FEdge per ViewEdge. The "Normal" and "Fast" styles of
+ // visibility computation want to consider many FEdges for each ViewEdge. Here we re-scan the
+ // view map to find any usable FEdges that we skipped on the first pass, or that have become
+ // usable because the occluder proscenium has been expanded since the edge was visited on the
+ // first pass.
if (extensiveFEdgeSearch) {
// For each view edge,
for (ve = ioViewMap->ViewEdges().begin(), veend = ioViewMap->ViewEdges().end(); ve != veend;
@@ -1431,7 +1434,7 @@ void ViewMapBuilder::ComputeEdgesVisibility(ViewMap *ioViewMap,
real epsilon)
{
#if 0
- iAlgo = ray_casting; // for testing algorithms equivalence
+ iAlgo = ray_casting; // for testing algorithms equivalence
#endif
switch (iAlgo) {
case ray_casting:
@@ -1465,15 +1468,15 @@ void ViewMapBuilder::ComputeEdgesVisibility(ViewMap *ioViewMap,
ComputeDetailedVisibility(ioViewMap, we, bbox, epsilon, true, factory);
}
catch (...) {
- // Last resort catch to make sure RAII semantics hold for OptimizedGrid. Can be replaced with
- // try...catch block around main() if the program as a whole is converted to RAII
+ // Last resort catch to make sure RAII semantics hold for OptimizedGrid. Can be replaced
+ // with try...catch block around main() if the program as a whole is converted to RAII
- // This is the little-mentioned caveat of RAII: RAII does not work unless destructors are always
- // called, but destructors are only called if all exceptions are caught (or std::terminate() is
- // replaced).
+ // This is the little-mentioned caveat of RAII: RAII does not work unless destructors are
+ // always called, but destructors are only called if all exceptions are caught (or
+ // std::terminate() is replaced).
- // We don't actually handle the exception here, so re-throw it now that our destructors have had a
- // chance to run.
+ // We don't actually handle the exception here, so re-throw it now that our destructors
+ // have had a chance to run.
throw;
}
break;
@@ -1591,11 +1594,11 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
cout << "\tFEdge: visibility " << tmpQI << endl;
}
#endif
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -1605,7 +1608,7 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
FindOccludee(fe, _Grid, epsilon, &aFace, timestamp++);
#if LOGGING
if (_global.debug & G_DEBUG_FREESTYLE) {
@@ -1626,7 +1629,8 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo
#endif
}
else {
- //ARB: We are arbitrarily using the last observed value for occludee (almost always the value observed
+ // ARB: We are arbitrarily using the last observed value for occludee (almost always the
+ // value observed
// for the edge before festart). Is that meaningful?
// ...in fact, _occludeeEmpty seems to be unused.
fe->setOccludeeEmpty(true);
@@ -1736,11 +1740,11 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep
if ((maxCard < qiMajority)) {
tmpQI = ComputeRayCastingVisibility(fe, _Grid, epsilon, occluders, &aFace, timestamp++);
- //ARB: This is an error condition, not an alert condition.
+ // ARB: This is an error condition, not an alert condition.
// Some sort of recovery or abort is necessary.
if (tmpQI >= 256) {
cerr << "Warning: too many occluding levels" << endl;
- //ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
+ // ARB: Wild guess: instead of aborting or corrupting memory, treat as tmpQI == 255
tmpQI = 255;
}
@@ -1750,7 +1754,7 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep
}
}
else {
- //ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
+ // ARB: FindOccludee is redundant if ComputeRayCastingVisibility has been called
FindOccludee(fe, _Grid, epsilon, &aFace, timestamp++);
}
@@ -1780,7 +1784,7 @@ void ViewMapBuilder::ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real ep
++p;
#if 0
for (; p != pend; ++p) {
- WFace *f = (WFace*)((*p)->userdata);
+ WFace *f = (WFace *)((*p)->userdata);
ViewShape *vs = ioViewMap->viewShape(f->GetVertex(0)->shape()->GetId());
if (vs != vshape) {
sameShape = false;
@@ -1895,7 +1899,7 @@ void ViewMapBuilder::FindOccludee(FEdge *fe,
for (p = occluders.begin(), pend = occluders.end(); p != pend; p++) {
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
oface = (WFace *)(*p)->userdata;
Vec3r v1(((*p)->getVertices())[0]);
Vec3r normal((*p)->getNormal());
@@ -2022,7 +2026,7 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
(center.z() < gridOrigin.z()) || (center.x() > gridExtremity.x()) ||
(center.y() > gridExtremity.y()) || (center.z() > gridExtremity.z())) {
cerr << "Warning: point is out of the grid for fedge " << fe->getId() << endl;
- //return 0;
+ // return 0;
}
#if 0
@@ -2030,9 +2034,9 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
Vec3r B(fe->vertexB()->point2d());
int viewport[4];
SilhouetteGeomEngine::retrieveViewport(viewport);
- if ((A.x() < viewport[0]) || (A.x() > viewport[2]) || (A.y() < viewport[1]) || (A.y() > viewport[3]) ||
- (B.x() < viewport[0]) || (B.x() > viewport[2]) || (B.y() < viewport[1]) || (B.y() > viewport[3]))
- {
+ if ((A.x() < viewport[0]) || (A.x() > viewport[2]) || (A.y() < viewport[1]) ||
+ (A.y() > viewport[3]) || (B.x() < viewport[0]) || (B.x() > viewport[2]) ||
+ (B.y() < viewport[1]) || (B.y() > viewport[3])) {
cerr << "Warning: point is out of the grid for fedge " << fe->getId() << endl;
//return 0;
}
@@ -2073,8 +2077,9 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
face->RetrieveVertexList(faceVertices);
for (p = occluders.begin(), pend = occluders.end(); p != pend; p++) {
- // If we're dealing with an exact silhouette, check whether we must take care of this occluder of not.
- // (Indeed, we don't consider the occluders that share at least one vertex with the face containing this edge).
+ // If we're dealing with an exact silhouette, check whether we must take care of this occluder
+ // of not. (Indeed, we don't consider the occluders that share at least one vertex with the
+ // face containing this edge).
//-----------
oface = (WFace *)(*p)->userdata;
#if LOGGING
@@ -2126,8 +2131,8 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
continue;
WFace *sface = (*ie)->GetbFace();
- //WFace *sfacea = (*ie)->GetaFace();
- //if ((sface == oface) || (sfacea == oface)) {
+ // WFace *sfacea = (*ie)->GetaFace();
+ // if ((sface == oface) || (sfacea == oface)) {
if (sface == oface) {
skipFace = true;
break;
@@ -2148,7 +2153,7 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe,
else {
// check whether the edge and the polygon plane are coincident:
//-------------------------------------------------------------
- //first let us compute the plane equation.
+ // first let us compute the plane equation.
if (GeomUtils::COINCIDENT ==
GeomUtils::intersectRayPlane(origin, edgeDir, normal, d, t, epsilon)) {
@@ -2206,10 +2211,10 @@ void ViewMapBuilder::ComputeIntersections(ViewMap *ioViewMap,
}
#if 0
if (_global.debug & G_DEBUG_FREESTYLE) {
- ViewMap::viewvertices_container& vvertices = ioViewMap->ViewVertices();
+ ViewMap::viewvertices_container &vvertices = ioViewMap->ViewVertices();
for (ViewMap::viewvertices_container::iterator vv = vvertices.begin(), vvend = vvertices.end();
- vv != vvend; ++vv)
- {
+ vv != vvend;
+ ++vv) {
if ((*vv)->getNature() == Nature::T_VERTEX) {
TVertex *tvertex = (TVertex *)(*vv);
cout << "TVertex " << tvertex->getId() << " has :" << endl;
@@ -2295,8 +2300,10 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi
unsigned fEdgesSize = ioViewMap->FEdges().size();
#if 0
if (_global.debug & G_DEBUG_FREESTYLE) {
- ViewMap::fedges_container& fedges = ioViewMap->FEdges();
- for (ViewMap::fedges_container::const_iterator f = fedges.begin(), end = fedges.end(); f != end; ++f) {
+ ViewMap::fedges_container &fedges = ioViewMap->FEdges();
+ for (ViewMap::fedges_container::const_iterator f = fedges.begin(), end = fedges.end();
+ f != end;
+ ++f) {
cout << (*f)->aMaterialIndex() << "-" << (*f)->bMaterialIndex() << endl;
}
}
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
index 0e3dbf9148e..eac5b348555 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.h
@@ -57,7 +57,7 @@ using namespace Geometry;
class ViewMapBuilder {
private:
ViewMap *_ViewMap; // result
- //SilhouetteGeomEngine _GeomEngine;
+ // SilhouetteGeomEngine _GeomEngine;
ProgressBar *_pProgressBar;
RenderMonitor *_pRenderMonitor;
Vec3r _viewpoint;
@@ -117,8 +117,8 @@ class ViewMapBuilder {
/*! Compute Cusps */
void computeCusps(ViewMap *ioViewMap);
- /*! Detects cusps (for a single ViewEdge) among SVertices and builds a ViewVertex on top of each cusp SVertex
- * We use a hysteresis approach to avoid noise.
+ /*! Detects cusps (for a single ViewEdge) among SVertices and builds a ViewVertex on top of each
+ * cusp SVertex We use a hysteresis approach to avoid noise.
*/
void DetectCusps(ViewEdge *ioEdge);
@@ -174,10 +174,9 @@ class ViewMapBuilder {
* ioViewMap
* The view map. It is modified by the method.
* The list of all features edges of the scene.
- * Each time an intersection is found, the 2 intersecting edges are splitted (creating 2 new vertices)
- * At the end, this list is updated with the adding of all new created edges (resulting from splitting).
- * iAlgo
- * The algo to use for computing the intersections
+ * Each time an intersection is found, the 2 intersecting edges are splitted (creating 2 new
+ * vertices) At the end, this list is updated with the adding of all new created edges (resulting
+ * from splitting). iAlgo The algo to use for computing the intersections
*/
void ComputeIntersections(ViewMap *ioViewMap,
intersection_algo iAlgo = sweep_line,
@@ -221,14 +220,11 @@ class ViewMapBuilder {
/*! Computes intersections on all edges of the scene using a sweep line algorithm */
void ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsilon = 1.0e-6);
- /*! Computes the 2D scene silhouette edges visibility using a ray casting. On each edge, a ray is cast
- * to check its quantitative invisibility. The list of occluders are each time stored in the tested edge.
- * ioViewMap
- * The view map.
- * The 2D scene silhouette edges as FEdges.
- * These edges have already been splitted at their intersections points.
- * Thus, these edges do not intersect anymore.
- * The visibility corresponding to each edge of ioScene is set is this edge.
+ /*! Computes the 2D scene silhouette edges visibility using a ray casting. On each edge, a ray is
+ * cast to check its quantitative invisibility. The list of occluders are each time stored in the
+ * tested edge. ioViewMap The view map. The 2D scene silhouette edges as FEdges. These edges have
+ * already been splitted at their intersections points. Thus, these edges do not intersect
+ * anymore. The visibility corresponding to each edge of ioScene is set is this edge.
*/
void ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
void ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
@@ -257,10 +253,10 @@ class ViewMapBuilder {
* The epsilon used for computation
* oShapeId
* fe is the border (in 2D) between 2 2D spaces.
- * if fe is a silhouette, One of these 2D spaces is occupied by the shape to which fe belongs (on its left)
- * and the other one is either occupied by another shape or empty or occupied by the same shape.
- * We use this ray csating operation to determine which shape lies on fe's right.
- * The result is the shape id stored in oShapeId
+ * if fe is a silhouette, One of these 2D spaces is occupied by the shape to which fe
+ * belongs (on its left) and the other one is either occupied by another shape or empty or
+ * occupied by the same shape. We use this ray csating operation to determine which shape lies on
+ * fe's right. The result is the shape id stored in oShapeId
*/
int ComputeRayCastingVisibility(FEdge *fe,
Grid *iGrid,
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
index 65336f593c7..24ed798709a 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapIO.cpp
@@ -801,8 +801,8 @@ static int save(ostream &out, SVertex *sv)
WRITE_IF_NON_NULL(sv->viewvertex());
// Normals (List)
- // Note: the 'size()' method of a set doesn't seem to return the actual size of the given set, so we have to
- // hack it...
+ // Note: the 'size()' method of a set doesn't seem to return the actual size of the given set, so
+ // we have to hack it...
set<Vec3r>::const_iterator i;
for (i = sv->normals().begin(), tmp = 0; i != sv->normals().end(); i++, tmp++)
;
@@ -955,7 +955,7 @@ int load(istream &in, ViewMap *vm, ProgressBar *pb)
if (!vm)
return 1;
- //soc unused - unsigned tmp;
+ // soc unused - unsigned tmp;
int err = 0;
Internal::g_vm = vm;
diff --git a/source/blender/freestyle/intern/view_map/ViewMapIterators.h b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
index 7182c5d3362..0fb5438a153 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapIterators.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapIterators.h
@@ -46,10 +46,9 @@ namespace Freestyle {
namespace ViewVertexInternal {
-/*! Class representing an iterator over oriented ViewEdges around a ViewVertex. This iterator allows a CCW iteration
- * (in the image plane).
- * An instance of an orientedViewEdgeIterator can only be obtained from a ViewVertex by calling edgesBegin()
- * or edgesEnd().
+/*! Class representing an iterator over oriented ViewEdges around a ViewVertex. This iterator
+ * allows a CCW iteration (in the image plane). An instance of an orientedViewEdgeIterator can only
+ * be obtained from a ViewVertex by calling edgesBegin() or edgesEnd().
*/
class orientedViewEdgeIterator : public Iterator {
public:
@@ -127,7 +126,8 @@ class orientedViewEdgeIterator : public Iterator {
}
public:
- /*! Tells whether the ViewEdge pointed by this iterator is the first one of the iteration list or not. */
+ /*! Tells whether the ViewEdge pointed by this iterator is the first one of the iteration list or
+ * not. */
virtual bool isBegin() const
{
if (_Nature & Nature::T_VERTEX)
@@ -136,7 +136,8 @@ class orientedViewEdgeIterator : public Iterator {
return (_nontvertex_iter == _begin);
}
- /*! Tells whether the ViewEdge pointed by this iterator is after the last one of the iteration list or not. */
+ /*! Tells whether the ViewEdge pointed by this iterator is after the last one of the iteration
+ * list or not. */
virtual bool isEnd() const
{
if (_Nature & Nature::T_VERTEX)
@@ -186,7 +187,7 @@ class orientedViewEdgeIterator : public Iterator {
virtual ViewVertex::directedViewEdge &operator*() const
{
if (_Nature & Nature::T_VERTEX)
- //return _tvertex_iter;
+ // return _tvertex_iter;
return **_tvertex_iter;
else
return (*_nontvertex_iter);
@@ -406,8 +407,8 @@ class SVertexIterator : public Interface0DIteratorNested {
///////////////////////////////////////////////////////////
/*! Base class for iterators over ViewEdges of the ViewMap Graph.
- * Basically the "increment()" operator of this class should be able to take the decision of "where" (on which
- * ViewEdge) to go when pointing on a given ViewEdge.
+ * Basically the "increment()" operator of this class should be able to take the decision of
+ * "where" (on which ViewEdge) to go when pointing on a given ViewEdge.
* ::Caution::: the dereferencing operator returns a *pointer* to the pointed ViewEdge.
*/
class ViewEdgeIterator : public Iterator {
@@ -416,8 +417,9 @@ class ViewEdgeIterator : public Iterator {
* \param begin:
* The ViewEdge from where to start the iteration.
* \param orientation:
- * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending ViewVertex of begin.
- * If false, we'll search over the ViewEdges surrounding the ending ViewVertex of begin.
+ * If true, we'll look for the next ViewEdge among the ViewEdges that surround the ending
+ * ViewVertex of begin. If false, we'll search over the ViewEdges surrounding the ending
+ * ViewVertex of begin.
*/
ViewEdgeIterator(ViewEdge *begin = NULL, bool orientation = true)
{
diff --git a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
index 2173ea42fab..f8ae885f5d7 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
+++ b/source/blender/freestyle/intern/view_map/ViewMapTesselator.h
@@ -57,11 +57,12 @@ class ViewMapTesselator {
{
}
- /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup from a ViewMap */
+ /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup
+ * from a ViewMap */
NodeGroup *Tesselate(ViewMap *iViewMap);
- /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup from a set of
- * view edges
+ /*! Builds a set of lines rep contained under a a NodeShape, itself contained under a NodeGroup
+ * from a set of view edges
*/
template<class ViewEdgesIterator>
NodeGroup *Tesselate(ViewEdgesIterator begin, ViewEdgesIterator end);
@@ -156,7 +157,7 @@ NodeGroup *ViewMapTesselator::Tesselate(ViewEdgesIterator begin, ViewEdgesIterat
NodeGroup *group = new NodeGroup;
NodeShape *tshape = new NodeShape;
group->AddChild(tshape);
- //tshape->frs_material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
+ // tshape->frs_material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
tshape->setFrsMaterial(_FrsMaterial);
LineRep *line;
@@ -165,7 +166,8 @@ NodeGroup *ViewMapTesselator::Tesselate(ViewEdgesIterator begin, ViewEdgesIterat
FEdge *nextFEdge, *currentEdge;
int id = 0;
- //for (vector<ViewEdge*>::const_iterator c = viewedges.begin(), cend = viewedges.end(); c != cend; c++)
+ // for (vector<ViewEdge*>::const_iterator c = viewedges.begin(), cend = viewedges.end(); c !=
+ // cend; c++)
for (ViewEdgesIterator c = begin, cend = end; c != cend; c++) {
#if 0
if ((*c)->qi() > 0) {
@@ -189,25 +191,25 @@ NodeGroup *ViewMapTesselator::Tesselate(ViewEdgesIterator begin, ViewEdgesIterat
// there might be chains containing a single element
if (0 == (firstEdge)->nextEdge()) {
line->setStyle(LineRep::LINES);
- //line->AddVertex((*c)->vertexA()->point3D());
- //line->AddVertex((*c)->vertexB()->point3D());
+ // line->AddVertex((*c)->vertexA()->point3D());
+ // line->AddVertex((*c)->vertexB()->point3D());
AddVertexToLine(line, firstEdge->vertexA());
AddVertexToLine(line, firstEdge->vertexB());
}
else {
line->setStyle(LineRep::LINE_STRIP);
- //firstEdge = (*c);
+ // firstEdge = (*c);
nextFEdge = firstEdge;
currentEdge = firstEdge;
do {
- //line->AddVertex(nextFEdge->vertexA()->point3D());
+ // line->AddVertex(nextFEdge->vertexA()->point3D());
AddVertexToLine(line, nextFEdge->vertexA());
currentEdge = nextFEdge;
nextFEdge = nextFEdge->nextEdge();
} while ((nextFEdge != NULL) && (nextFEdge != firstEdge));
// Add the last vertex
- //line->AddVertex(currentEdge->vertexB()->point3D());
+ // line->AddVertex(currentEdge->vertexB()->point3D());
AddVertexToLine(line, currentEdge->vertexB());
}
diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.cpp b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
index b42c3f9b0e6..4fb92e35b40 100644
--- a/source/blender/freestyle/intern/winged_edge/Curvature.cpp
+++ b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
@@ -78,7 +78,8 @@ static real cotan(WVertex *vo, WVertex *v1, WVertex *v2)
udotv = u * v;
denom = sqrt(u.squareNorm() * v.squareNorm() - udotv * udotv);
- /* denom can be zero if u==v. Returning 0 is acceptable, based on the callers of this function below. */
+ /* denom can be zero if u==v. Returning 0 is acceptable, based on the callers of this function
+ * below. */
if (denom == 0.0)
return 0.0;
return (udotv / denom);
@@ -109,9 +110,9 @@ static real angle_from_cotan(WVertex *vo, WVertex *v1, WVertex *v2)
* Computes the Discrete Mean Curvature Normal approximation at @v.
* The mean curvature at @v is half the magnitude of the vector @Kh.
*
- * Note: the normal computed is not unit length, and may point either into or out of the surface, depending on
- * the curvature at @v. It is the responsibility of the caller of the function to use the mean curvature normal
- * appropriately.
+ * Note: the normal computed is not unit length, and may point either into or out of the surface,
+ * depending on the curvature at @v. It is the responsibility of the caller of the function to use
+ * the mean curvature normal appropriately.
*
* This approximation is from the paper:
* Discrete Differential-Geometry Operators for Triangulated 2-Manifolds
@@ -119,8 +120,8 @@ static real angle_from_cotan(WVertex *vo, WVertex *v1, WVertex *v2)
* VisMath '02, Berlin (Germany)
* http://www-grail.usc.edu/pubs.html
*
- * Returns: %true if the operator could be evaluated, %false if the evaluation failed for some reason (@v is
- * boundary or is the endpoint of a non-manifold edge.)
+ * Returns: %true if the operator could be evaluated, %false if the evaluation failed for some
+ * reason (@v is boundary or is the endpoint of a non-manifold edge.)
*/
bool gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &Kh)
{
@@ -144,7 +145,7 @@ bool gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &Kh)
WOEdge *e = (*itE)->getPrevOnFace();
#if 0
if ((e->GetaVertex() == v) || (e->GetbVertex() == v))
- cerr<< "BUG ";
+ cerr << "BUG ";
#endif
WVertex *v1 = e->GetaVertex();
WVertex *v2 = e->GetbVertex();
@@ -181,8 +182,8 @@ bool gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &Kh)
* VisMath '02, Berlin (Germany)
* http://www-grail.usc.edu/pubs.html
*
- * Returns: %true if the operator could be evaluated, %false if the evaluation failed for some reason (@v is
- * boundary or is the endpoint of a non-manifold edge.)
+ * Returns: %true if the operator could be evaluated, %false if the evaluation failed for some
+ * reason (@v is boundary or is the endpoint of a non-manifold edge.)
*/
bool gts_vertex_gaussian_curvature(WVertex *v, real *Kg)
{
@@ -223,7 +224,8 @@ bool gts_vertex_gaussian_curvature(WVertex *v, real *Kg)
* @K1: first principal curvature.
* @K2: second principal curvature.
*
- * Computes the principal curvatures at a point given the mean and Gaussian curvatures at that point.
+ * Computes the principal curvatures at a point given the mean and Gaussian curvatures at that
+ * point.
*
* The mean curvature can be computed as one-half the magnitude of the vector computed by
* gts_vertex_mean_curvature_normal().
@@ -275,12 +277,12 @@ static void eigenvector(real a, real b, real c, Vec3r e)
* @e1: first principal curvature direction (direction of largest curvature).
* @e2: second principal curvature direction.
*
- * Computes the principal curvature directions at a point given @Kh and @Kg, the mean curvature normal and
- * Gaussian curvatures at that point, computed with gts_vertex_mean_curvature_normal() and
- * gts_vertex_gaussian_curvature(), respectively.
+ * Computes the principal curvature directions at a point given @Kh and @Kg, the mean curvature
+ * normal and Gaussian curvatures at that point, computed with gts_vertex_mean_curvature_normal()
+ * and gts_vertex_gaussian_curvature(), respectively.
*
- * Note that this computation is very approximate and tends to be unstable. Smoothing of the surface or the principal
- * directions may be necessary to achieve reasonable results.
+ * Note that this computation is very approximate and tends to be unstable. Smoothing of the
+ * surface or the principal directions may be necessary to achieve reasonable results.
*/
void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, Vec3r &e2)
{
@@ -306,8 +308,8 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
Kh.normalize();
}
else {
- /* This vertex is a point of zero mean curvature (flat or saddle point). Compute a normal by averaging
- * the adjacent triangles
+ /* This vertex is a point of zero mean curvature (flat or saddle point). Compute a normal by
+ * averaging the adjacent triangles
*/
N[0] = N[1] = N[2] = 0.0;
@@ -354,8 +356,9 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
continue;
e = *itE;
- /* since this vertex passed the tests in gts_vertex_mean_curvature_normal(), this should be true. */
- //g_assert(gts_edge_face_number (e, s) == 2);
+ /* since this vertex passed the tests in gts_vertex_mean_curvature_normal(), this should be
+ * true. */
+ // g_assert(gts_edge_face_number (e, s) == 2);
/* identify the two triangles bordering e in s */
f1 = e->GetaFace();
@@ -365,17 +368,18 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
* B = [ a b ; b c ].
* The computations here are from section 5 of [Meyer et al 2002].
*
- * The first step is to calculate the linear equations governing the values of (a,b,c). These can be computed
- * by setting the derivatives of the error E to zero (section 5.3).
+ * The first step is to calculate the linear equations governing the values of (a,b,c). These
+ * can be computed by setting the derivatives of the error E to zero (section 5.3).
*
- * Since a + c = norm(Kh), we only compute the linear equations for dE/da and dE/db. (NB: [Meyer et al 2002]
- * has the equation a + b = norm(Kh), but I'm almost positive this is incorrect).
+ * Since a + c = norm(Kh), we only compute the linear equations for dE/da and dE/db. (NB:
+ * [Meyer et al 2002] has the equation a + b = norm(Kh), but I'm almost positive this is
+ * incorrect).
*
- * Note that the w_ij (defined in section 5.2) are all scaled by (1/8*A_mixed). We drop this uniform scale
- * factor because the solution of the linear equations doesn't rely on it.
+ * Note that the w_ij (defined in section 5.2) are all scaled by (1/8*A_mixed). We drop this
+ * uniform scale factor because the solution of the linear equations doesn't rely on it.
*
- * The terms of the linear equations are xterm_dy with x in {a,b,c} and y in {a,b}. There are also const_dy
- * terms that are the constant factors in the equations.
+ * The terms of the linear equations are xterm_dy with x in {a,b,c} and y in {a,b}. There are
+ * also const_dy terms that are the constant factors in the equations.
*/
/* find the vector from v along edge e */
@@ -389,8 +393,9 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
/* section 5.2 */
- /* I don't like performing a minimization where some of the weights can be negative (as can be the case
- * if f1 or f2 are obtuse). To ensure all-positive weights, we check for obtuseness. */
+ /* I don't like performing a minimization where some of the weights can be negative (as can be
+ * the case if f1 or f2 are obtuse). To ensure all-positive weights, we check for obtuseness.
+ */
weight = 0.0;
if (!triangle_obtuse(v, f1)) {
weight += ve2 *
@@ -471,12 +476,14 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
eig[1] = 0.0;
}
- /* Although the eigenvectors of B are good estimates of the principal directions, it seems that which one is
- * attached to which curvature direction is a bit arbitrary. This may be a bug in my implementation, or just
- * a side-effect of the inaccuracy of B due to the discrete nature of the sampling.
+ /* Although the eigenvectors of B are good estimates of the principal directions, it seems that
+ * which one is attached to which curvature direction is a bit arbitrary. This may be a bug in my
+ * implementation, or just a side-effect of the inaccuracy of B due to the discrete nature of the
+ * sampling.
*
- * To overcome this behavior, we'll evaluate which assignment best matches the given eigenvectors by comparing
- * the curvature estimates computed above and the curvatures calculated from the discrete differential operators.
+ * To overcome this behavior, we'll evaluate which assignment best matches the given eigenvectors
+ * by comparing the curvature estimates computed above and the curvatures calculated from the
+ * discrete differential operators.
*/
gts_vertex_principal_curvatures(0.5 * normKh, Kg, &K1, &K2);
@@ -534,8 +541,8 @@ namespace OGF {
#if 0
inline static real angle(WOEdge *h)
{
- const Vec3r& n1 = h->GetbFace()->GetNormal();
- const Vec3r& n2 = h->GetaFace()->GetNormal();
+ const Vec3r &n1 = h->GetbFace()->GetNormal();
+ const Vec3r &n2 = h->GetaFace()->GetNormal();
const Vec3r v = h->GetVec();
real sine = (n1 ^ n2) * v / v.norm();
if (sine >= 1.0) {
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
index 629e8ffe901..3dc574515c1 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
@@ -103,7 +103,7 @@ WFace *WVertex::face_iterator::operator*()
}
#if 0
-bool WVertex::isBoundary () const
+bool WVertex::isBoundary() const
{
return _Border;
}
@@ -293,7 +293,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
// Adds the edge to the face
AddEdge(woea);
(*it1)->setNumberOfOEdges((*it1)->GetNumberOfOEdges() + 1);
- //sets these vertices as border:
+ // sets these vertices as border:
v1->setBorder(true);
v2->setBorder(true);
return woea;
@@ -307,7 +307,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
// Adds the edge to the face
AddEdge(woeb);
(*it1)->setNumberOfOEdges((*it1)->GetNumberOfOEdges() + 1);
- //sets these vertices as border:
+ // sets these vertices as border:
v1->setBorder(true);
v2->setBorder(true);
return woeb;
@@ -334,7 +334,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
}
}
- //DEBUG:
+ // DEBUG:
if (true == exist) { // The invert edge already exists
// Retrieves the corresponding edge
edge = pInvertEdge->GetOwner();
@@ -347,7 +347,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
}
else { // The invert edge does not exist yet
// we must create a new edge
- //edge = new WEdge;
+ // edge = new WEdge;
edge = instanciateEdge();
// updates the a,b vertex edges list:
@@ -365,7 +365,7 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
cerr << "Warning: edge " << this << " null with vertex " << v1->GetId() << endl;
edge->AddOEdge(pOEdge);
- //edge->setNumberOfOEdges(edge->GetNumberOfOEdges() + 1);
+ // edge->setNumberOfOEdges(edge->GetNumberOfOEdges() + 1);
// Add this face (the b face)
pOEdge->setbFace(this);
@@ -468,7 +468,7 @@ WShape::WShape(WShape &iBrother)
vector<WVertex *> &vertexList = iBrother.getVertexList();
vector<WVertex *>::iterator v = vertexList.begin(), vend = vertexList.end();
for (; v != vend; ++v) {
- //WVertex *newVertex = new WVertex(*(*v));
+ // WVertex *newVertex = new WVertex(*(*v));
WVertex *newVertex = (*v)->duplicate();
newVertex->setShape(this);
@@ -478,7 +478,7 @@ WShape::WShape(WShape &iBrother)
vector<WEdge *> &edgeList = iBrother.getEdgeList();
vector<WEdge *>::iterator e = edgeList.begin(), eend = edgeList.end();
for (; e != eend; ++e) {
- //WEdge *newEdge = new WEdge(*(*e));
+ // WEdge *newEdge = new WEdge(*(*e));
WEdge *newEdge = (*e)->duplicate();
AddEdge(newEdge);
}
@@ -486,7 +486,7 @@ WShape::WShape(WShape &iBrother)
vector<WFace *> &faceList = iBrother.GetFaceList();
vector<WFace *>::iterator f = faceList.begin(), fend = faceList.end();
for (; f != fend; ++f) {
- //WFace *newFace = new WFace(*(*f));
+ // WFace *newFace = new WFace(*(*f));
WFace *newFace = (*f)->duplicate();
AddFace(newFace);
}
@@ -539,8 +539,8 @@ WShape::WShape(WShape &iBrother)
WOEdge *current = oedgeList[i];
oedgedata *currentoedata = (oedgedata *)current->userdata;
newoedgelist.push_back(currentoedata->_copy);
- //oedgeList[i] = currentoedata->_copy;
- //oedgeList[i] = ((oedgedata *)(oedgeList[i]->userdata))->_copy;
+ // oedgeList[i] = currentoedata->_copy;
+ // oedgeList[i] = ((oedgedata *)(oedgeList[i]->userdata))->_copy;
}
(*f)->setEdgeList(newoedgelist);
}
@@ -662,11 +662,11 @@ WFace *WShape::MakeFace(vector<WVertex *> &iVertexList,
for (; va != iVertexList.end(); va = vb) {
++vb;
// Adds va to the vertex list:
- //face->AddVertex(*va);
+ // face->AddVertex(*va);
WOEdge *oedge;
if (*va == iVertexList.back())
- oedge = face->MakeEdge(*va, iVertexList.front()); //for the last (closing) edge
+ oedge = face->MakeEdge(*va, iVertexList.front()); // for the last (closing) edge
else
oedge = face->MakeEdge(*va, *vb);
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h
index 79c6a24e6d9..1a141629c6d 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.h
@@ -178,7 +178,7 @@ class WVertex {
{
}
#endif
- virtual ~incoming_edge_iterator(){}; //soc
+ virtual ~incoming_edge_iterator(){}; // soc
protected:
friend class WVertex;
@@ -237,7 +237,7 @@ class WVertex {
// dereferencing
virtual WOEdge *operator*();
- //virtual WOEdge **operator->();
+ // virtual WOEdge **operator->();
protected:
virtual void increment();
@@ -266,7 +266,7 @@ class WVertex {
{
}
#endif
- virtual ~face_iterator(){}; //soc
+ virtual ~face_iterator(){}; // soc
protected:
friend class WVertex;
@@ -321,7 +321,7 @@ class WVertex {
// dereferencing
virtual WFace *operator*();
- //virtual WOEdge **operator->();
+ // virtual WOEdge **operator->();
protected:
inline void increment()
@@ -368,10 +368,10 @@ class WEdge;
class WOEdge {
protected:
#if 0
- WOEdge *_paCWEdge; // edge reached when traveling clockwise on aFace from the edge
- WOEdge *_pbCWEdge; // edge reached when traveling clockwise on bFace from the edge
- WOEdge *_paCCWEdge; // edge reached when traveling counterclockwise on aFace from the edge
- WOEdge *_pbCCWEdge; // edge reached when traveling counterclockwise on bFace from the edge
+ WOEdge *_paCWEdge; // edge reached when traveling clockwise on aFace from the edge
+ WOEdge *_pbCWEdge; // edge reached when traveling clockwise on bFace from the edge
+ WOEdge *_paCCWEdge; // edge reached when traveling counterclockwise on aFace from the edge
+ WOEdge *_pbCCWEdge; // edge reached when traveling counterclockwise on bFace from the edge
#endif
WVertex *_paVertex; // starting vertex
WVertex *_pbVertex; // ending vertex
@@ -401,7 +401,7 @@ class WOEdge {
userdata = NULL;
}
- virtual ~WOEdge(){}; //soc
+ virtual ~WOEdge(){}; // soc
/*! copy constructor */
WOEdge(WOEdge &iBrother);
@@ -1099,7 +1099,7 @@ class WShape {
}
#if 0
- inline void bbox(Vec3f& min, Vec3f& max)
+ inline void bbox(Vec3f &min, Vec3f &max)
{
min = _min;
max = _max;
@@ -1160,7 +1160,7 @@ class WShape {
}
#if 0
- inline void setBBox(const Vec3f& min, const Vec3f& max)
+ inline void setBBox(const Vec3f &min, const Vec3f &max)
{
_min = min;
_max = max;
@@ -1196,10 +1196,9 @@ class WShape {
/*! adds a new face to the shape
* returns the built face.
* iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed to be
- * already stored when calling MakeFace.
- * The order in which the vertices are stored in the list determines the face's edges orientation and (so) the
- * face orientation.
+ * List of face's vertices. These vertices are not added to the WShape vertex list; they are
+ * supposed to be already stored when calling MakeFace. The order in which the vertices are
+ * stored in the list determines the face's edges orientation and (so) the face orientation.
* iMaterialIndex
* The material index for this face
*/
@@ -1207,21 +1206,16 @@ class WShape {
vector<bool> &iFaceEdgeMarksList,
unsigned iMaterialIndex);
- /*! adds a new face to the shape. The difference with the previous method is that this one is designed
- * to build a WingedEdge structure for which there are per vertex normals, opposed to per face normals.
- * returns the built face.
- * iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed to be
- * already stored when calling MakeFace.
- * The order in which the vertices are stored in the list determines the face's edges orientation and (so) the
- * face orientation.
- * iMaterialIndex
- * The materialIndex for this face
+ /*! adds a new face to the shape. The difference with the previous method is that this one is
+ * designed to build a WingedEdge structure for which there are per vertex normals, opposed to
+ * per face normals. returns the built face. iVertexList List of face's vertices. These vertices
+ * are not added to the WShape vertex list; they are supposed to be already stored when calling
+ * MakeFace. The order in which the vertices are stored in the list determines the face's edges
+ * orientation and (so) the face orientation. iMaterialIndex The materialIndex for this face
* iNormalsList
- * The list of normals, iNormalsList[i] corresponding to the normal of the vertex iVertexList[i] for that face.
- * iTexCoordsList
- * The list of tex coords, iTexCoordsList[i] corresponding to the normal of the vertex iVertexList[i] for
- * that face.
+ * The list of normals, iNormalsList[i] corresponding to the normal of the vertex
+ * iVertexList[i] for that face. iTexCoordsList The list of tex coords, iTexCoordsList[i]
+ * corresponding to the normal of the vertex iVertexList[i] for that face.
*/
virtual WFace *MakeFace(vector<WVertex *> &iVertexList,
vector<Vec3f> &iNormalsList,
@@ -1275,7 +1269,9 @@ class WShape {
_max = _VertexList[0]->GetVertex();
Vec3f v;
- for (vector<WVertex *>::iterator wv = _VertexList.begin(), wvend = _VertexList.end(); wv != wvend; wv++) {
+ for (vector<WVertex *>::iterator wv = _VertexList.begin(), wvend = _VertexList.end();
+ wv != wvend;
+ wv++) {
for (unsigned int i = 0; i < 3; i++) {
v = (*wv)->GetVertex();
if (v[i] < _min[i])
@@ -1298,16 +1294,17 @@ class WShape {
#endif
protected:
- /*! Builds the face passed as argument (which as already been allocated)
- * iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed to be
- * already stored when calling MakeFace.
- * The order in which the vertices are stored in the list determines the face's edges orientation and (so) the
- * face orientation.
- * iMaterialIndex
- * The material index for this face
- * face
- * The Face that is filled in
+ /*!
+ * Builds the face passed as argument (which as already been allocated)
+ * - iVertexList
+ * List of face's vertices. These vertices are not added to the WShape vertex list;
+ * they are supposed to be already stored when calling MakeFace.
+ * The order in which the vertices are stored in the list determines
+ * the face's edges orientation and (so) the face orientation.
+ * - iMaterialIndex
+ * The material index for this face
+ * - face
+ * The Face that is filled in
*/
virtual WFace *MakeFace(vector<WVertex *> &iVertexList,
vector<bool> &iFaceEdgeMarksList,
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
index fcac2b386ea..2e36790563e 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
@@ -91,8 +91,9 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
return 0;
// let us determine which cusp edge corresponds to the starting:
- // We can do that because we defined that a silhouette edge had the back facing part on its right.
- // So if the WOEdge woea is such that woea[0].dotp > 0 and woea[1].dotp < 0, it is the starting edge.
+ // We can do that because we defined that a silhouette edge had the back facing part on its
+ // right. So if the WOEdge woea is such that woea[0].dotp > 0 and woea[1].dotp < 0, it is the
+ // starting edge.
//-------------------------------------------
if (_DotP[cuspEdgesIndices[0]] > 0.0f) {
@@ -114,7 +115,8 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
ok = true;
}
else if (_nNullDotP == 1) {
- // that means that we have exactly one of the 2 extremities of our silhouette edge is a vertex of the mesh
+ // that means that we have exactly one of the 2 extremities of our silhouette edge is a vertex
+ // of the mesh
if ((_nPosDotP == 2) || (_nPosDotP == 0)) {
_pSmoothEdge = NULL;
return _pSmoothEdge;
@@ -190,9 +192,11 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
for (int i = 0; i < numberOfEdges(); i++) {
WSFace *bface = (WSFace *)GetBordingFace(i);
if (bface) {
- if ((front()) ^ (bface->front())) { // fA->front XOR fB->front (true if one is 0 and the other is 1)
+ if ((front()) ^
+ (bface->front())) { // fA->front XOR fB->front (true if one is 0 and the other is 1)
// that means that the edge i of the face is a silhouette edge
- // CHECK FIRST WHETHER THE EXACTSILHOUETTEEDGE HAS NOT YET BEEN BUILT ON THE OTHER FACE (1 is enough).
+ // CHECK FIRST WHETHER THE EXACTSILHOUETTEEDGE HAS
+ // NOT YET BEEN BUILT ON THE OTHER FACE (1 is enough).
if (((WSExactFace *)bface)->exactSilhouetteEdge()) {
// that means that this silhouette edge has already been built
return ((WSExactFace *)bface)->exactSilhouetteEdge();
@@ -200,7 +204,7 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
// Else we must build it
WOEdge *woea, *woeb;
float ta, tb;
- if (!front()) { // is it in the right order ?
+ if (!front()) { // is it in the right order ?
// the order of the WOEdge index is wrong
woea = _OEdgeList[(i + 1) % numberOfEdges()];
if (0 == i)
@@ -288,7 +292,9 @@ WFace *WXShape::MakeFace(vector<WVertex *> &iVertexList,
#if 0
Vec3f center;
- for (vector<WVertex *>::iterator wv = iVertexList.begin(), wvend = iVertexList.end(); wv != wvend; ++wv) {
+ for (vector<WVertex *>::iterator wv = iVertexList.begin(), wvend = iVertexList.end();
+ wv != wvend;
+ ++wv) {
center += (*wv)->GetVertex();
}
center /= (float)iVertexList.size();
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h
index 63c2ef4f52b..0f1b8d77c59 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h
@@ -108,8 +108,8 @@ class WXEdge : public WEdge {
WXNature _nature;
// 0: the order doesn't matter. 1: the order is the orginal one. -1: the order is not good
short _order;
- // A front facing edge is an edge for which the bording face which is the nearest from the viewpoint is front.
- // A back facing edge is the opposite.
+ // A front facing edge is an edge for which the bording face which is the nearest from the
+ // viewpoint is front. A back facing edge is the opposite.
bool _front;
public:
@@ -322,13 +322,13 @@ class WXFaceLayer {
public:
void *userdata;
WXFace *_pWXFace;
- // in case of silhouette: the values obtained when computing the normal-view direction dot product. _DotP[i] is
- // this value for the vertex i for that face.
+ // in case of silhouette: the values obtained when computing the normal-view direction dot
+ // product. _DotP[i] is this value for the vertex i for that face.
vector<float> _DotP;
WXSmoothEdge *_pSmoothEdge;
WXNature _Nature;
- //oldtmp values
+ // oldtmp values
// count the number of positive dot products for vertices.
// if this number is != 0 and !=_DotP.size() -> it is a silhouette fac
unsigned _nPosDotP;
@@ -435,14 +435,16 @@ class WXFaceLayer {
}
}
- /*! If one of the face layer vertex has a DotP equal to 0, this method returns the vertex where it happens */
+ /*! If one of the face layer vertex has a DotP equal to 0, this method returns the vertex where
+ * it happens */
unsigned int Get0VertexIndex() const;
- /*! In case one of the edge of the triangle is a smooth edge, this method allows to retrieve the concerned edge */
+ /*! In case one of the edge of the triangle is a smooth edge, this method allows to retrieve the
+ * concerned edge */
unsigned int GetSmoothEdgeIndex() const;
- /*! retrieves the edges of the triangle for which the signs are different (a null value is not considered) for
- * the dotp values at each edge extrimity
+ /*! retrieves the edges of the triangle for which the signs are different (a null value is not
+ * considered) for the dotp values at each edge extrimity
*/
void RetrieveCuspEdgesIndices(vector<int> &oCuspEdges);
@@ -492,8 +494,8 @@ class WXFace : public WFace {
bool _front; // flag to tell whether the face is front facing or back facing
float _dotp; // value obtained when computing the normal-viewpoint dot product
- vector<WXFaceLayer *>
- _SmoothLayers; // The data needed to store one or several smooth edges that traverse the face
+ vector<WXFaceLayer *> _SmoothLayers; // The data needed to store one or several smooth edges
+ // that traverse the face
public:
inline WXFace() : WFace()
@@ -696,13 +698,13 @@ class WXFace : public WFace {
class WXShape : public WShape {
#if 0
-public:
+ public:
typedef WXShape type_name;
#endif
protected:
- bool
- _computeViewIndependent; // flag to indicate whether the view independent stuff must be computed or not
+ bool _computeViewIndependent; // flag to indicate whether the view independent stuff must be
+ // computed or not
public:
inline WXShape() : WShape()
@@ -742,29 +744,35 @@ public:
return new WXFace;
}
- /*! adds a new face to the shape returns the built face.
- * iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed
- * to be already stored when calling MakeFace. The order in which the vertices are stored in the list
- * determines the face's edges orientation and (so) the face orientation.
+ /*!
+ * Adds a new face to the shape returns the built face.
+ * - iVertexList
+ * List of face's vertices.
+ * These vertices are not added to the WShape vertex list; they are
+ * supposed to be already stored when calling MakeFace. The order in which the vertices are
+ * stored in the list determines the face's edges orientation and (so) the face orientation.
*/
virtual WFace *MakeFace(vector<WVertex *> &iVertexList,
vector<bool> &iFaceEdgeMarksList,
unsigned iMaterialIndex);
- /*! adds a new face to the shape. The difference with the previous method is that this one is designed to build
- * a WingedEdge structure for which there are per vertex normals, opposed to per face normals.
- * returns the built face.
- * iVertexList
- * List of face's vertices. These vertices are not added to the WShape vertex list; they are supposed to be
- * already stored when calling MakeFace.
- * The order in which the vertices are stored in the list determines the face's edges orientation and (so) the
- * face orientation.
- * iNormalsList
- * The list of normals, iNormalsList[i] corresponding to the normal of the vertex iVertexList[i] for that face.
- * iTexCoordsList
- * The list of tex coords, iTexCoordsList[i] corresponding to the normal of the vertex iVertexList[i] for
- * that face.
+ /*!
+ * Adds a new face to the shape.
+ * The difference with the previous method is that this one is designed to build a WingedEdge
+ * structure for which there are per vertex normals, opposed to per face normals.
+ * returns the built face.
+ *
+ * - iVertexList:
+ * List of face's vertices. These vertices are not added to the WShape vertex list;
+ * they are supposed to be already stored when calling MakeFace.
+ * The order in which the vertices are stored in the list determines
+ * the face's edges orientation and (so) the face orientation.
+ * - iNormalsList:
+ * The list of normals, iNormalsList[i]
+ * corresponding to the normal of the vertex iVertexList[i] for that face.
+ * - iTexCoordsList:
+ * The list of tex coords, iTexCoordsList[i]
+ * corresponding to the normal of the vertex iVertexList[i] for that face.
*/
virtual WFace *MakeFace(vector<WVertex *> &iVertexList,
vector<Vec3f> &iNormalsList,
@@ -781,7 +789,7 @@ public:
((WXEdge *)(*we))->Reset();
}
- //Reset faces:
+ // Reset faces:
vector<WFace *> &wfaces = GetFaceList();
for (vector<WFace *>::iterator wf = wfaces.begin(), wfend = wfaces.end(); wf != wfend; ++wf) {
((WXFace *)(*wf))->Reset();
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
index fb0b6a9b63f..a34f2272200 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
@@ -16,8 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Class inherited from WingedEdgeBuilder and designed to build a WX (WingedEdge + extended info
- * (silhouette etc...)) structure from a polygonal model
+ * \brief Class inherited from WingedEdgeBuilder and designed to build a WX (WingedEdge + extended
+ * info (silhouette etc...)) structure from a polygonal model
*/
#include "WXEdge.h"
@@ -37,7 +37,7 @@ void WXEdgeBuilder::visitIndexedFaceSet(IndexedFaceSet &ifs)
shape->setId(ifs.getId().getFirst());
shape->setName(ifs.getName());
shape->setLibraryPath(ifs.getLibraryPath());
- //ifs.setId(shape->GetId());
+ // ifs.setId(shape->GetId());
}
void WXEdgeBuilder::buildWVertices(WShape &shape, const float *vertices, unsigned vsize)
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
index e98832f4fba..08189c5010e 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.h
@@ -19,8 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Class inherited from WingedEdgeBuilder and designed to build a WX (WingedEdge + extended info
- * (silhouette etc...)) structure from a polygonal model
+ * \brief Class inherited from WingedEdgeBuilder and designed to build a WX (WingedEdge + extended
+ * info (silhouette etc...)) structure from a polygonal model
*/
#include "WingedEdgeBuilder.h"
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
index 977eb2b4d57..f190d78014d 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
@@ -16,8 +16,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to render a WingedEdge data structure from a polyhedral data structure organized in nodes
- * of a scene graph
+ * \brief Class to render a WingedEdge data structure from a polyhedral data structure organized in
+ * nodes of a scene graph
*/
#include <set>
@@ -42,12 +42,12 @@ void WingedEdgeBuilder::visitIndexedFaceSet(IndexedFaceSet &ifs)
return;
}
shape->setId(ifs.getId().getFirst());
- //ifs.setId(shape->GetId());
+ // ifs.setId(shape->GetId());
}
void WingedEdgeBuilder::visitNodeShape(NodeShape &ns)
{
- //Sets the current material to iShapeode->material:
+ // Sets the current material to iShapeode->material:
_current_frs_material = &(ns.frs_material());
}
@@ -81,7 +81,7 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs)
{
unsigned int vsize = ifs.vsize();
unsigned int nsize = ifs.nsize();
- //soc unused - unsigned tsize = ifs.tsize();
+ // soc unused - unsigned tsize = ifs.tsize();
const float *vertices = ifs.vertices();
const float *normals = ifs.normals();
@@ -256,7 +256,7 @@ void WingedEdgeBuilder::buildTriangleStrip(const float * /*vertices*/,
{
unsigned nDoneVertices = 2; // number of vertices already treated
unsigned nTriangle = 0; // number of the triangle currently being treated
- //int nVertex = 0; // vertex number
+ // int nVertex = 0; // vertex number
WShape *currentShape = _current_wshape; // the current shape being built
vector<WVertex *> triangleVertices;
@@ -265,9 +265,9 @@ void WingedEdgeBuilder::buildTriangleStrip(const float * /*vertices*/,
vector<bool> triangleFaceEdgeMarks;
while (nDoneVertices < nvertices) {
- //clear the vertices list:
+ // clear the vertices list:
triangleVertices.clear();
- //Then rebuild it:
+ // Then rebuild it:
if (0 == nTriangle % 2) { // if nTriangle is even
triangleVertices.push_back(currentShape->getVertexList()[vindices[nTriangle] / 3]);
triangleVertices.push_back(currentShape->getVertexList()[vindices[nTriangle + 1] / 3]);
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
index 606e8561401..a4aa08d50b6 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
@@ -19,8 +19,8 @@
/** \file
* \ingroup freestyle
- * \brief Class to render a WingedEdge data structure from a polyhedral data structure organized in nodes
- * of a scene graph
+ * \brief Class to render a WingedEdge data structure
+ * from a polyhedral data structure organized in nodes of a scene graph.
*/
#include "WEdge.h"
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt
index 6c7f2bb3685..41543448a15 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -22,17 +22,17 @@
set(INC
.
intern
+ ../blenfont
../blenkernel
../blenlib
- ../blenfont
+ ../bmesh
../depsgraph
../makesdna
../makesrna
- ../bmesh
../render/extern/include
../../../intern/elbeem/extern
- ../../../intern/guardedalloc
../../../intern/eigen
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
index aad8805c294..1ef1068ee52 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
@@ -126,8 +126,9 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
bGPdata *gpd = (bGPdata *)ob->data;
int oldframe = (int)DEG_get_ctime(depsgraph);
- if (mmd->object == NULL)
+ if (mmd->object == NULL) {
return;
+ }
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index 5f7f8165ed2..d72ace7a191 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -74,7 +74,8 @@ static bool dependsOnTime(GpencilModifierData *UNUSED(md))
/* Build Modifier - Stroke generation logic
*
* There are two modes for how the strokes are sequenced (at a macro-level):
- * - Sequential Mode - Strokes appear/disappear one after the other. Only a single one changes at a time.
+ * - Sequential Mode - Strokes appear/disappear one after the other. Only a single one changes at a
+ * time.
* - Concurrent Mode - Multiple strokes appear/disappear at once.
*
* Assumptions:
@@ -121,8 +122,10 @@ static void reduce_stroke_points(bGPDstroke *gps,
/* Which end should points be removed from */
// TODO: free stroke weights
switch (transition) {
- case GP_BUILD_TRANSITION_GROW: /* Show in forward order = Remove ungrown-points from end of stroke */
- case GP_BUILD_TRANSITION_SHRINK: /* Hide in reverse order = Remove dead-points from end of stroke */
+ case GP_BUILD_TRANSITION_GROW: /* Show in forward order =
+ * Remove ungrown-points from end of stroke. */
+ case GP_BUILD_TRANSITION_SHRINK: /* Hide in reverse order =
+ * Remove dead-points from end of stroke. */
{
/* copy over point data */
memcpy(new_points, gps->points, sizeof(bGPDspoint) * num_points);
@@ -353,7 +356,8 @@ static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
}
case GP_BUILD_TIMEALIGN_END: /* all end on same frame */
{
- /* Build effect occurs over 1.0 - relative_len, to 1.0 (i.e. over the end of the range) */
+ /* Build effect occurs over 1.0 - relative_len, to 1.0 (i.e. over the end of the range)
+ */
const float start_fac = 1.0f - relative_len;
if (fac >= start_fac) {
@@ -408,7 +412,7 @@ static void generateStrokes(GpencilModifierData *md,
const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW);
const float ctime = DEG_get_ctime(depsgraph);
- //printf("GP Build Modifier - %f\n", ctime);
+ // printf("GP Build Modifier - %f\n", ctime);
/* Early exit if it's an empty frame */
if (gpf->strokes.first == NULL) {
@@ -463,7 +467,8 @@ static void generateStrokes(GpencilModifierData *md,
}
/* Early exit if current frame is outside start/end bounds */
- /* NOTE: If we're beyond the next/prev frames (if existent), then we wouldn't have this problem anyway... */
+ /* NOTE: If we're beyond the next/prev frames (if existent), then we wouldn't have this problem
+ * anyway... */
if (ctime < start_frame) {
/* Before Start - Animation hasn't started. Display initial state. */
if (reverse) {
@@ -501,7 +506,7 @@ static void generateStrokes(GpencilModifierData *md,
/* Determine how far along we are between the keyframes */
float fac = (ctime - start_frame) / (end_frame - start_frame);
- //printf(" Progress on %d = %f (%f - %f)\n", gpf->framenum, fac, start_frame, end_frame);
+ // printf(" Progress on %d = %f (%f - %f)\n", gpf->framenum, fac, start_frame, end_frame);
/* Time management mode */
switch (mmd->mode) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
index ed2dfb0d15b..c1a49183a66 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
@@ -113,12 +113,14 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
Material *mat = give_current_material(ob, gps->mat_nr + 1);
- if (mat == NULL)
+ if (mat == NULL) {
continue;
+ }
MaterialGPencilStyle *gp_style = mat->gp_style;
/* skip stroke if it doesn't have color info */
- if (ELEM(NULL, gp_style))
+ if (ELEM(NULL, gp_style)) {
continue;
+ }
copy_v4_v4(gps->runtime.tmp_stroke_rgba, gp_style->stroke_rgba);
copy_v4_v4(gps->runtime.tmp_fill_rgba, gp_style->fill_rgba);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
index 9876be951ae..daca46c3a9a 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
@@ -271,8 +271,9 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
bGPdata *gpd = ob->data;
int oldframe = (int)DEG_get_ctime(depsgraph);
- if (mmd->object == NULL)
+ if (mmd->object == NULL) {
return;
+ }
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
index de0ecd5cda5..da2b4214da1 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
@@ -117,8 +117,9 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
bGPdata *gpd = ob->data;
int oldframe = (int)DEG_get_ctime(depsgraph);
- if (mmd->object == NULL)
+ if (mmd->object == NULL) {
return;
+ }
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
index 2e374ba1acd..a3052b4f6b6 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
@@ -165,7 +165,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
static bool isDisabled(GpencilModifierData *UNUSED(md), int UNUSED(userRenderParams))
{
- //MirrorGpencilModifierData *mmd = (MirrorGpencilModifierData *)md;
+ // MirrorGpencilModifierData *mmd = (MirrorGpencilModifierData *)md;
return false;
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
index 0d01d1dc794..587cf527118 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
@@ -134,12 +134,14 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
Material *mat = give_current_material(ob, gps->mat_nr + 1);
- if (mat == NULL)
+ if (mat == NULL) {
continue;
+ }
MaterialGPencilStyle *gp_style = mat->gp_style;
/* skip stroke if it doesn't have color info */
- if (ELEM(NULL, gp_style))
+ if (ELEM(NULL, gp_style)) {
continue;
+ }
copy_v4_v4(gps->runtime.tmp_stroke_rgba, gp_style->stroke_rgba);
copy_v4_v4(gps->runtime.tmp_fill_rgba, gp_style->fill_rgba);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
index e422c6d5598..289cae955ba 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
@@ -122,12 +122,14 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
Material *mat = give_current_material(ob, gps->mat_nr + 1);
- if (mat == NULL)
+ if (mat == NULL) {
continue;
+ }
MaterialGPencilStyle *gp_style = mat->gp_style;
/* skip stroke if it doesn't have color info */
- if (ELEM(NULL, gp_style))
+ if (ELEM(NULL, gp_style)) {
continue;
+ }
copy_v4_v4(gps->runtime.tmp_stroke_rgba, gp_style->stroke_rgba);
copy_v4_v4(gps->runtime.tmp_fill_rgba, gp_style->fill_rgba);
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index f949a79d039..5a42c4d3d1b 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -31,10 +31,10 @@ set(INC
../blenkernel
../blenlib
../bmesh
+ ../draw
../imbuf
../makesdna
../makesrna
- ../draw
../editors/include
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index b9397a61ea4..856148563f2 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -157,7 +157,6 @@ void GPU_draw_primitive(GPUPrimType, int v_count);
/* Can multiple batches share a GPUVertBuf? Use ref count? */
-
/* We often need a batch with its own data, to be created and discarded together. */
/* WithOwn variants reduce number of system allocations. */
@@ -179,7 +178,10 @@ typedef struct BatchWithOwnVertexBufferAndElementList {
GPUBatch *create_BatchWithOwnVertexBuffer(GPUPrimType, GPUVertFormat *, uint v_len, GPUIndexBuf *);
GPUBatch *create_BatchWithOwnElementList(GPUPrimType, GPUVertBuf *, uint prim_len);
-GPUBatch *create_BatchWithOwnVertexBufferAndElementList(GPUPrimType, GPUVertFormat *, uint v_len, uint prim_len);
+GPUBatch *create_BatchWithOwnVertexBufferAndElementList(GPUPrimType,
+ GPUVertFormat *,
+ uint v_len,
+ uint prim_len);
/* verts: shared, own */
/* elem: none, shared, own */
GPUBatch *create_BatchInGeneral(GPUPrimType, VertexBufferStuff, ElementListStuff);
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 895887c2588..20047174bb1 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -35,6 +35,7 @@ struct MLoop;
struct MLoopTri;
struct MPoly;
struct MVert;
+struct MLoopCol;
struct PBVH;
/* Buffers for drawing from PBVH grids. */
@@ -57,6 +58,7 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading);
enum {
GPU_PBVH_BUFFERS_SHOW_MASK = (1 << 1),
+ GPU_PBVH_BUFFERS_SHOW_VCOL = (1 << 1),
};
void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
@@ -64,6 +66,7 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
const int *vert_indices,
int totvert,
const float *vmask,
+ const struct MLoopCol *vcol,
const int (*face_vert_indices)[3],
const int update_flags);
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index 30a6020f74a..a8e5e9d0e04 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -47,9 +47,10 @@ void immBegin(GPUPrimType, uint vertex_len);
void immBeginAtMost(GPUPrimType, uint max_vertex_len);
void immEnd(void); /* finishes and draws. */
-/* ImmBegin a batch, then use standard immFunctions as usual. */
-/* ImmEnd will finalize the batch instead of drawing. */
-/* Then you can draw it as many times as you like! Partially replaces the need for display lists. */
+/* immBegin a batch, then use standard immFunctions as usual. */
+/* immEnd will finalize the batch instead of drawing. */
+/* Then you can draw it as many times as you like!
+ * Partially replaces the need for display lists. */
GPUBatch *immBeginBatch(GPUPrimType, uint vertex_len);
GPUBatch *immBeginBatchAtMost(GPUPrimType, uint vertex_len);
diff --git a/source/blender/gpu/GPU_legacy_stubs.h b/source/blender/gpu/GPU_legacy_stubs.h
index f26765a28f0..c666ff73bc6 100644
--- a/source/blender/gpu/GPU_legacy_stubs.h
+++ b/source/blender/gpu/GPU_legacy_stubs.h
@@ -148,8 +148,8 @@ _GL_VOID DO_NOT_USE_glClientActiveTexture(GLenum texture) _GL_VOID_RET
#define DO_NOT_USE_GL_SOURCE2_RGB 0
/**
- * Functions
- */
+ * Functions
+ */
_GL_VOID DO_NOT_USE_glAccum(GLenum op, GLfloat value) _GL_VOID_RET _GL_VOID
DO_NOT_USE_glAlphaFunc(GLenum func, GLclampf ref) _GL_VOID_RET _GL_BOOL
DO_NOT_USE_glAreTexturesResident(GLsizei n,
diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h
index 24a76c13e01..67fb2bb2bd4 100644
--- a/source/blender/gpu/GPU_matrix.h
+++ b/source/blender/gpu/GPU_matrix.h
@@ -123,7 +123,8 @@ const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3];
void GPU_matrix_bind(const struct GPUShaderInterface *);
bool GPU_matrix_dirty_get(void); /* since last bind */
-/* Python API needs to be able to inspect the stack so errors raise exceptions instead of crashing. */
+/* Python API needs to be able to inspect the stack so errors raise exceptions
+ * instead of crashing. */
#ifdef USE_GPU_PY_MATRIX_API
int GPU_matrix_stack_level_get_model_view(void);
int GPU_matrix_stack_level_get_projection(void);
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index d7addeb87b4..d174aafacce 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -239,7 +239,8 @@ typedef enum eGPUBuiltinShader {
*/
GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA,
/**
- * Draw round points with a constant size and an outline. Take a 2D position and a color for each vertex.
+ * Draw round points with a constant size and an outline.
+ * Take a 2D position and a color for each vertex.
*
* \param size: uniform float
* \param outlineWidth: uniform float
@@ -249,7 +250,8 @@ typedef enum eGPUBuiltinShader {
*/
GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA,
/**
- * Draw round points with a constant size and an outline. Take a 2D position and a color for each vertex.
+ * Draw round points with a constant size and an outline.
+ * Take a 2D position and a color for each vertex.
*
* \param size: in float
* \param color: in vec4
@@ -302,7 +304,8 @@ typedef enum eGPUBuiltinShader {
*/
GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR,
/**
- * Draw round points with a constant size and an outline. Take a 3D position and a color for each vertex.
+ * Draw round points with a constant size and an outline.
+ * Take a 3D position and a color for each vertex.
*
* \param size: in float
* \param color: in vec4
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h
index 021def5b265..7f1934431cf 100644
--- a/source/blender/gpu/GPU_vertex_format.h
+++ b/source/blender/gpu/GPU_vertex_format.h
@@ -91,12 +91,13 @@ void GPU_vertformat_alias_add(GPUVertFormat *, const char *alias);
int GPU_vertformat_attr_id_get(const GPUVertFormat *, const char *name);
/**
- * This makes the "virtual" attributes with suffixes "0", "1", "2" to access triangle data in the vertex
- * shader.
+ * This makes the "virtual" attributes with suffixes "0", "1", "2"
+ * to access triangle data in the vertex shader.
*
* IMPORTANT:
* - Call this before creating the vertex buffer and after creating all attributes
- * - Only first vertex out of 3 has the correct information. Use flat output with GL_FIRST_VERTEX_CONVENTION.
+ * - Only first vertex out of 3 has the correct information.
+ * Use flat output with #GL_FIRST_VERTEX_CONVENTION.
*/
void GPU_vertformat_triple_load(GPUVertFormat *format);
diff --git a/source/blender/gpu/GPU_viewport.h b/source/blender/gpu/GPU_viewport.h
index 23e5ee28533..198a9ec98e2 100644
--- a/source/blender/gpu/GPU_viewport.h
+++ b/source/blender/gpu/GPU_viewport.h
@@ -42,6 +42,7 @@ typedef struct ViewportMemoryPool {
struct BLI_mempool *shgroups;
struct BLI_mempool *uniforms;
struct BLI_mempool *passes;
+ struct BLI_mempool *images;
} ViewportMemoryPool;
/* All FramebufferLists are just the same pointers with different names */
diff --git a/source/blender/gpu/intern/gpu_attr_binding.c b/source/blender/gpu/intern/gpu_attr_binding.c
index 6cd350df505..e280b77f661 100644
--- a/source/blender/gpu/intern/gpu_attr_binding.c
+++ b/source/blender/gpu/intern/gpu_attr_binding.c
@@ -73,7 +73,8 @@ void get_attr_locations(const GPUVertFormat *format,
const GPUShaderInput *input = GPU_shaderinterface_attr(shaderface, a->name[n_idx]);
#if TRUST_NO_ONE
assert(input != NULL);
- /* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */
+ /* TODO: make this a recoverable runtime error?
+ * indicates mismatch between vertex format and program. */
#endif
write_attr_location(binding, a_idx, input->location);
}
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 636a48c1623..f179f9ef22c 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -194,8 +194,9 @@ int GPU_batch_vertbuf_add_ex(GPUBatch *batch, GPUVertBuf *verts, bool own_vbo)
#endif
batch->verts[v] = verts;
/* TODO: mark dirty so we can keep attribute bindings up-to-date */
- if (own_vbo)
+ if (own_vbo) {
batch->owns_flag |= (1 << v);
+ }
return v;
}
}
@@ -211,14 +212,18 @@ static GLuint batch_vao_get(GPUBatch *batch)
{
/* Search through cache */
if (batch->is_dynamic_vao_count) {
- for (int i = 0; i < batch->dynamic_vaos.count; ++i)
- if (batch->dynamic_vaos.interfaces[i] == batch->interface)
+ for (int i = 0; i < batch->dynamic_vaos.count; ++i) {
+ if (batch->dynamic_vaos.interfaces[i] == batch->interface) {
return batch->dynamic_vaos.vao_ids[i];
+ }
+ }
}
else {
- for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i)
- if (batch->static_vaos.interfaces[i] == batch->interface)
+ for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) {
+ if (batch->static_vaos.interfaces[i] == batch->interface) {
return batch->static_vaos.vao_ids[i];
+ }
+ }
}
/* Set context of this batch.
@@ -239,9 +244,11 @@ static GLuint batch_vao_get(GPUBatch *batch)
GLuint new_vao = 0;
if (!batch->is_dynamic_vao_count) {
int i; /* find first unused slot */
- for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i)
- if (batch->static_vaos.vao_ids[i] == 0)
+ for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) {
+ if (batch->static_vaos.vao_ids[i] == 0) {
break;
+ }
+ }
if (i < GPU_BATCH_VAO_STATIC_LEN) {
batch->static_vaos.interfaces[i] = batch->interface;
@@ -267,9 +274,11 @@ static GLuint batch_vao_get(GPUBatch *batch)
if (batch->is_dynamic_vao_count) {
int i; /* find first unused slot */
- for (i = 0; i < batch->dynamic_vaos.count; ++i)
- if (batch->dynamic_vaos.vao_ids[i] == 0)
+ for (i = 0; i < batch->dynamic_vaos.count; ++i) {
+ if (batch->dynamic_vaos.vao_ids[i] == 0) {
break;
+ }
+ }
if (i == batch->dynamic_vaos.count) {
/* Not enough place, realloc the array. */
@@ -362,8 +371,9 @@ static void create_bindings(GPUVertBuf *verts,
for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) {
const GPUShaderInput *input = GPU_shaderinterface_attr(interface, a->name[n_idx]);
- if (input == NULL)
+ if (input == NULL) {
continue;
+ }
if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) {
#if TRUST_NO_ONE
@@ -420,7 +430,8 @@ static void batch_update_program_bindings(GPUBatch *batch, uint v_first)
void GPU_batch_program_use_begin(GPUBatch *batch)
{
/* NOTE: use_program & done_using_program are fragile, depend on staying in sync with
- * the GL context's active program. use_program doesn't mark other programs as "not used". */
+ * the GL context's active program.
+ * use_program doesn't mark other programs as "not used". */
/* TODO: make not fragile (somehow) */
if (!batch->program_in_use) {
@@ -539,10 +550,12 @@ static void primitive_restart_enable(const GPUIndexBuf *el)
GLuint restart_index = (GLuint)0xFFFFFFFF;
#if GPU_TRACK_INDEX_RANGE
- if (el->index_type == GPU_INDEX_U8)
+ if (el->index_type == GPU_INDEX_U8) {
restart_index = (GLuint)0xFF;
- else if (el->index_type == GPU_INDEX_U16)
+ }
+ else if (el->index_type == GPU_INDEX_U16) {
restart_index = (GLuint)0xFFFF;
+ }
#endif
glPrimitiveRestartIndex(restart_index);
@@ -556,13 +569,16 @@ static void primitive_restart_disable(void)
static void *elem_offset(const GPUIndexBuf *el, int v_first)
{
#if GPU_TRACK_INDEX_RANGE
- if (el->index_type == GPU_INDEX_U8)
+ if (el->index_type == GPU_INDEX_U8) {
return (GLubyte *)0 + v_first;
- else if (el->index_type == GPU_INDEX_U16)
+ }
+ else if (el->index_type == GPU_INDEX_U16) {
return (GLushort *)0 + v_first;
- else
+ }
+ else {
#endif
return (GLuint *)0 + v_first;
+ }
}
void GPU_batch_draw(GPUBatch *batch)
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 0b5b2e469a0..9290d073295 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -91,7 +91,7 @@ struct GPU_PBVH_Buffers {
};
static struct {
- uint pos, nor, msk;
+ uint pos, nor, msk, col;
} g_vbo_id = {0};
/** \} */
@@ -104,10 +104,12 @@ static struct {
* Return is false it indicates that the memory map failed. */
static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len)
{
+ /* Keep so we can test #GPU_USAGE_DYNAMIC buffer use.
+ * Not that format initialization match in both blocks.
+ * Do this to keep braces balanced - otherwise indentation breaks. */
+#if 0
if (buffers->vert_buf == NULL) {
- /* Initialize vertex buffer */
- /* match 'VertexBufferFormat' */
-
+ /* Initialize vertex buffer (match 'VertexBufferFormat'). */
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
g_vbo_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -115,7 +117,6 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len)
&format, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
g_vbo_id.msk = GPU_vertformat_attr_add(&format, "msk", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
}
-#if 0
buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_DYNAMIC);
GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
}
@@ -123,896 +124,955 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len)
GPU_vertbuf_data_resize(buffers->vert_buf, vert_len);
}
#else
+ if (buffers->vert_buf == NULL) {
+ /* Initialize vertex buffer (match 'VertexBufferFormat'). */
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ g_vbo_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ g_vbo_id.nor = GPU_vertformat_attr_add(
+ &format, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ /* TODO: Do not allocate these `.msk` and `.col` when they are not used. */
+ g_vbo_id.msk = GPU_vertformat_attr_add(&format, "msk", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
+ g_vbo_id.col = GPU_vertformat_attr_add(
+ &format, "c", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ }
buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STATIC);
}
GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
#endif
- return buffers->vert_buf->data != NULL;
- }
+ return buffers->vert_buf->data != NULL;
+}
- static void gpu_pbvh_batch_init(GPU_PBVH_Buffers * buffers, GPUPrimType prim)
- {
- /* force flushing to the GPU */
- if (buffers->vert_buf->data) {
- GPU_vertbuf_use(buffers->vert_buf);
- }
+static void gpu_pbvh_batch_init(GPU_PBVH_Buffers *buffers, GPUPrimType prim)
+{
+ /* force flushing to the GPU */
+ if (buffers->vert_buf->data) {
+ GPU_vertbuf_use(buffers->vert_buf);
+ }
- if (buffers->triangles == NULL) {
- buffers->triangles = GPU_batch_create(prim,
- buffers->vert_buf,
- /* can be NULL */
- buffers->index_buf);
- }
+ if (buffers->triangles == NULL) {
+ buffers->triangles = GPU_batch_create(prim,
+ buffers->vert_buf,
+ /* can be NULL if buffer is empty */
+ buffers->index_buf);
+ }
- if ((buffers->triangles_fast == NULL) && buffers->index_buf_fast) {
- buffers->triangles_fast = GPU_batch_create(prim, buffers->vert_buf, buffers->index_buf_fast);
- }
+ if ((buffers->triangles_fast == NULL) && buffers->index_buf_fast) {
+ buffers->triangles_fast = GPU_batch_create(prim, buffers->vert_buf, buffers->index_buf_fast);
+ }
- if (buffers->lines == NULL) {
- BLI_assert(buffers->index_lines_buf != NULL);
- buffers->lines = GPU_batch_create(
- GPU_PRIM_LINES, buffers->vert_buf, buffers->index_lines_buf);
- }
+ if (buffers->lines == NULL) {
+ buffers->lines = GPU_batch_create(GPU_PRIM_LINES,
+ buffers->vert_buf,
+ /* can be NULL if buffer is empty */
+ buffers->index_lines_buf);
+ }
- if ((buffers->lines_fast == NULL) && buffers->index_lines_buf_fast) {
- buffers->lines_fast = GPU_batch_create(
- GPU_PRIM_LINES, buffers->vert_buf, buffers->index_lines_buf_fast);
- }
+ if ((buffers->lines_fast == NULL) && buffers->index_lines_buf_fast) {
+ buffers->lines_fast = GPU_batch_create(
+ GPU_PRIM_LINES, buffers->vert_buf, buffers->index_lines_buf_fast);
}
+}
- /** \} */
+/** \} */
- /* -------------------------------------------------------------------- */
- /** \name Mesh PBVH
+/* -------------------------------------------------------------------- */
+/** \name Mesh PBVH
* \{ */
- void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers * buffers,
- const MVert *mvert,
- const int *vert_indices,
- int totvert,
- const float *vmask,
- const int(*face_vert_indices)[3],
- const int update_flags)
- {
- const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
- bool empty_mask = true;
+void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
+ const MVert *mvert,
+ const int *vert_indices,
+ int totvert,
+ const float *vmask,
+ const MLoopCol *vcol,
+ const int (*face_vert_indices)[3],
+ const int update_flags)
+{
+ const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
+ const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0;
+ bool empty_mask = true;
- {
- int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3));
+ {
+ int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3));
- /* Build VBO */
- if (gpu_pbvh_vert_buf_data_set(buffers, totelem)) {
- /* Vertex data is shared if smooth-shaded, but separate
+ /* Build VBO */
+ if (gpu_pbvh_vert_buf_data_set(buffers, totelem)) {
+ /* Vertex data is shared if smooth-shaded, but separate
* copies are made for flat shading because normals
* shouldn't be shared. */
- if (buffers->smooth) {
- for (uint i = 0; i < totvert; ++i) {
- const MVert *v = &mvert[vert_indices[i]];
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, i, v->co);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, i, v->no);
- }
+ if (buffers->smooth) {
+ for (uint i = 0; i < totvert; ++i) {
+ const MVert *v = &mvert[vert_indices[i]];
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, i, v->co);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, i, v->no);
+ }
- if (vmask && show_mask) {
- for (uint i = 0; i < buffers->face_indices_len; i++) {
- const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
- for (uint j = 0; j < 3; j++) {
- int vidx = face_vert_indices[i][j];
- int v_index = buffers->mloop[lt->tri[j]].v;
- float fmask = vmask[v_index];
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vidx, &fmask);
- empty_mask = empty_mask && (fmask == 0.0f);
- }
+ if (vmask && show_mask) {
+ for (uint i = 0; i < buffers->face_indices_len; i++) {
+ const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
+ for (uint j = 0; j < 3; j++) {
+ int vidx = face_vert_indices[i][j];
+ int v_index = buffers->mloop[lt->tri[j]].v;
+ float fmask = vmask[v_index];
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vidx, &fmask);
+ empty_mask = empty_mask && (fmask == 0.0f);
}
}
}
- else {
- /* calculate normal for each polygon only once */
- uint mpoly_prev = UINT_MAX;
- short no[3];
- int vbo_index = 0;
+ if (vcol && show_vcol) {
for (uint i = 0; i < buffers->face_indices_len; i++) {
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
- const uint vtri[3] = {
- buffers->mloop[lt->tri[0]].v,
- buffers->mloop[lt->tri[1]].v,
- buffers->mloop[lt->tri[2]].v,
- };
-
- if (paint_is_face_hidden(lt, mvert, buffers->mloop))
- continue;
-
- /* Face normal and mask */
- if (lt->poly != mpoly_prev) {
- const MPoly *mp = &buffers->mpoly[lt->poly];
- float fno[3];
- BKE_mesh_calc_poly_normal(mp, &buffers->mloop[mp->loopstart], mvert, fno);
- normal_float_to_short_v3(no, fno);
- mpoly_prev = lt->poly;
+ for (int j = 0; j < 3; j++) {
+ const int loop_index = lt->tri[j];
+ const int vidx = face_vert_indices[i][j];
+ const uchar *elem = &vcol[loop_index].r;
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, elem);
}
+ }
+ }
+ }
+ else {
+ /* calculate normal for each polygon only once */
+ uint mpoly_prev = UINT_MAX;
+ short no[3];
+ int vbo_index = 0;
+
+ for (uint i = 0; i < buffers->face_indices_len; i++) {
+ const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
+ const uint vtri[3] = {
+ buffers->mloop[lt->tri[0]].v,
+ buffers->mloop[lt->tri[1]].v,
+ buffers->mloop[lt->tri[2]].v,
+ };
+
+ if (paint_is_face_hidden(lt, mvert, buffers->mloop)) {
+ continue;
+ }
- float fmask = 0.0f;
- if (vmask && show_mask) {
- fmask = (vmask[vtri[0]] + vmask[vtri[1]] + vmask[vtri[2]]) / 3.0f;
- }
+ /* Face normal and mask */
+ if (lt->poly != mpoly_prev) {
+ const MPoly *mp = &buffers->mpoly[lt->poly];
+ float fno[3];
+ BKE_mesh_calc_poly_normal(mp, &buffers->mloop[mp->loopstart], mvert, fno);
+ normal_float_to_short_v3(no, fno);
+ mpoly_prev = lt->poly;
+ }
- for (uint j = 0; j < 3; j++) {
- const MVert *v = &mvert[vtri[j]];
+ float fmask = 0.0f;
+ if (vmask && show_mask) {
+ fmask = (vmask[vtri[0]] + vmask[vtri[1]] + vmask[vtri[2]]) / 3.0f;
+ }
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, v->co);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index, &fmask);
+ for (uint j = 0; j < 3; j++) {
+ const MVert *v = &mvert[vtri[j]];
- vbo_index++;
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, v->co);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index, &fmask);
+
+ if (vcol && show_vcol) {
+ const uint loop_index = lt->tri[j];
+ const uchar *elem = &vcol[loop_index].r;
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, elem);
}
- empty_mask = empty_mask && (fmask == 0.0f);
+ vbo_index++;
}
- }
- gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
+ empty_mask = empty_mask && (fmask == 0.0f);
+ }
}
- }
- buffers->show_mask = !empty_mask;
- buffers->mvert = mvert;
+ gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
+ }
}
- GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int(*face_vert_indices)[3],
- const MPoly *mpoly,
- const MLoop *mloop,
- const MLoopTri *looptri,
- const MVert *mvert,
- const int *face_indices,
- const int face_indices_len)
- {
- GPU_PBVH_Buffers *buffers;
- int i, tottri;
+ buffers->show_mask = !empty_mask;
+ buffers->mvert = mvert;
+}
+
+GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
+ const MPoly *mpoly,
+ const MLoop *mloop,
+ const MLoopTri *looptri,
+ const MVert *mvert,
+ const int *face_indices,
+ const int face_indices_len)
+{
+ GPU_PBVH_Buffers *buffers;
+ int i, tottri;
- buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
+ buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
- /* smooth or flat for all */
- buffers->smooth = mpoly[looptri[face_indices[0]].poly].flag & ME_SMOOTH;
+ /* smooth or flat for all */
+ buffers->smooth = mpoly[looptri[face_indices[0]].poly].flag & ME_SMOOTH;
- buffers->show_mask = false;
+ buffers->show_mask = false;
- /* Count the number of visible triangles */
- for (i = 0, tottri = 0; i < face_indices_len; ++i) {
- const MLoopTri *lt = &looptri[face_indices[i]];
- if (!paint_is_face_hidden(lt, mvert, mloop))
- tottri++;
+ /* Count the number of visible triangles */
+ for (i = 0, tottri = 0; i < face_indices_len; ++i) {
+ const MLoopTri *lt = &looptri[face_indices[i]];
+ if (!paint_is_face_hidden(lt, mvert, mloop)) {
+ tottri++;
}
+ }
- if (tottri == 0) {
- buffers->tot_tri = 0;
+ if (tottri == 0) {
+ buffers->tot_tri = 0;
- buffers->mpoly = mpoly;
- buffers->mloop = mloop;
- buffers->looptri = looptri;
- buffers->face_indices = face_indices;
- buffers->face_indices_len = 0;
+ buffers->mpoly = mpoly;
+ buffers->mloop = mloop;
+ buffers->looptri = looptri;
+ buffers->face_indices = face_indices;
+ buffers->face_indices_len = 0;
- return buffers;
- }
+ return buffers;
+ }
- GPU_BATCH_DISCARD_SAFE(buffers->triangles);
- GPU_BATCH_DISCARD_SAFE(buffers->lines);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
+ GPU_BATCH_DISCARD_SAFE(buffers->triangles);
+ GPU_BATCH_DISCARD_SAFE(buffers->lines);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
- /* An element index buffer is used for smooth shading, but flat
+ /* An element index buffer is used for smooth shading, but flat
* shading requires separate vertex normals so an index buffer
* can't be used there. */
- if (buffers->smooth) {
- /* Fill the triangle and line buffers. */
- GPUIndexBufBuilder elb, elb_lines;
- GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX);
- GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, INT_MAX);
+ if (buffers->smooth) {
+ /* Fill the triangle and line buffers. */
+ GPUIndexBufBuilder elb, elb_lines;
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX);
+ GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, INT_MAX);
- for (i = 0; i < face_indices_len; ++i) {
- const MLoopTri *lt = &looptri[face_indices[i]];
+ for (i = 0; i < face_indices_len; ++i) {
+ const MLoopTri *lt = &looptri[face_indices[i]];
- /* Skip hidden faces */
- if (paint_is_face_hidden(lt, mvert, mloop))
- continue;
+ /* Skip hidden faces */
+ if (paint_is_face_hidden(lt, mvert, mloop)) {
+ continue;
+ }
- GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i]));
+ GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i]));
- /* TODO skip "non-real" edges. */
- GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][0], face_vert_indices[i][1]);
- GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][1], face_vert_indices[i][2]);
- GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][2], face_vert_indices[i][0]);
- }
- buffers->index_buf = GPU_indexbuf_build(&elb);
- buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
+ /* TODO skip "non-real" edges. */
+ GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][0], face_vert_indices[i][1]);
+ GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][1], face_vert_indices[i][2]);
+ GPU_indexbuf_add_line_verts(&elb_lines, face_vert_indices[i][2], face_vert_indices[i][0]);
}
- else {
- /* Fill the only the line buffer. */
- GPUIndexBufBuilder elb_lines;
- GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, INT_MAX);
-
- for (i = 0; i < face_indices_len; ++i) {
- const MLoopTri *lt = &looptri[face_indices[i]];
+ buffers->index_buf = GPU_indexbuf_build(&elb);
+ buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
+ }
+ else {
+ /* Fill the only the line buffer. */
+ GPUIndexBufBuilder elb_lines;
+ GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, INT_MAX);
- /* Skip hidden faces */
- if (paint_is_face_hidden(lt, mvert, mloop))
- continue;
+ for (i = 0; i < face_indices_len; ++i) {
+ const MLoopTri *lt = &looptri[face_indices[i]];
- /* TODO skip "non-real" edges. */
- GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 0, i * 3 + 1);
- GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 1, i * 3 + 2);
- GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 2, i * 3 + 0);
+ /* Skip hidden faces */
+ if (paint_is_face_hidden(lt, mvert, mloop)) {
+ continue;
}
- buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
+
+ /* TODO skip "non-real" edges. */
+ GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 0, i * 3 + 1);
+ GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 1, i * 3 + 2);
+ GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 2, i * 3 + 0);
}
+ buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
+ }
- buffers->tot_tri = tottri;
+ buffers->tot_tri = tottri;
- buffers->mpoly = mpoly;
- buffers->mloop = mloop;
- buffers->looptri = looptri;
+ buffers->mpoly = mpoly;
+ buffers->mloop = mloop;
+ buffers->looptri = looptri;
- buffers->face_indices = face_indices;
- buffers->face_indices_len = face_indices_len;
+ buffers->face_indices = face_indices;
+ buffers->face_indices_len = face_indices_len;
- return buffers;
- }
+ return buffers;
+}
- /** \} */
+/** \} */
- /* -------------------------------------------------------------------- */
- /** \name Grid PBVH
+/* -------------------------------------------------------------------- */
+/** \name Grid PBVH
* \{ */
- static void gpu_pbvh_grid_fill_index_buffers(GPU_PBVH_Buffers * buffers,
- int *grid_indices,
- uint visible_quad_len,
- int totgrid,
- int gridsize)
- {
- GPUIndexBufBuilder elb, elb_lines;
- GPUIndexBufBuilder elb_fast, elb_lines_fast;
-
- GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, 2 * visible_quad_len, INT_MAX);
- GPU_indexbuf_init(&elb_fast, GPU_PRIM_TRIS, 2 * totgrid, INT_MAX);
- GPU_indexbuf_init(
- &elb_lines, GPU_PRIM_LINES, 2 * totgrid * gridsize * (gridsize - 1), INT_MAX);
- GPU_indexbuf_init(&elb_lines_fast, GPU_PRIM_LINES, 4 * totgrid, INT_MAX);
-
- if (buffers->smooth) {
- uint offset = 0;
- const uint grid_vert_len = gridsize * gridsize;
- for (int i = 0; i < totgrid; i++, offset += grid_vert_len) {
- uint v0, v1, v2, v3;
- bool grid_visible = false;
-
- BLI_bitmap *gh = buffers->grid_hidden[grid_indices[i]];
-
- for (int j = 0; j < gridsize - 1; ++j) {
- for (int k = 0; k < gridsize - 1; ++k) {
- /* Skip hidden grid face */
- if (gh && paint_is_grid_face_hidden(gh, gridsize, k, j)) {
- continue;
- }
- /* Indices in a Clockwise QUAD disposition. */
- v0 = offset + j * gridsize + k;
- v1 = v0 + 1;
- v2 = v1 + gridsize;
- v3 = v2 - 1;
+static void gpu_pbvh_grid_fill_index_buffers(
+ GPU_PBVH_Buffers *buffers, int *grid_indices, uint visible_quad_len, int totgrid, int gridsize)
+{
+ GPUIndexBufBuilder elb, elb_lines;
+ GPUIndexBufBuilder elb_fast, elb_lines_fast;
+
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, 2 * visible_quad_len, INT_MAX);
+ GPU_indexbuf_init(&elb_fast, GPU_PRIM_TRIS, 2 * totgrid, INT_MAX);
+ GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, 2 * totgrid * gridsize * (gridsize - 1), INT_MAX);
+ GPU_indexbuf_init(&elb_lines_fast, GPU_PRIM_LINES, 4 * totgrid, INT_MAX);
+
+ if (buffers->smooth) {
+ uint offset = 0;
+ const uint grid_vert_len = gridsize * gridsize;
+ for (int i = 0; i < totgrid; i++, offset += grid_vert_len) {
+ uint v0, v1, v2, v3;
+ bool grid_visible = false;
+
+ BLI_bitmap *gh = buffers->grid_hidden[grid_indices[i]];
+
+ for (int j = 0; j < gridsize - 1; ++j) {
+ for (int k = 0; k < gridsize - 1; ++k) {
+ /* Skip hidden grid face */
+ if (gh && paint_is_grid_face_hidden(gh, gridsize, k, j)) {
+ continue;
+ }
+ /* Indices in a Clockwise QUAD disposition. */
+ v0 = offset + j * gridsize + k;
+ v1 = v0 + 1;
+ v2 = v1 + gridsize;
+ v3 = v2 - 1;
- GPU_indexbuf_add_tri_verts(&elb, v0, v2, v1);
- GPU_indexbuf_add_tri_verts(&elb, v0, v3, v2);
+ GPU_indexbuf_add_tri_verts(&elb, v0, v2, v1);
+ GPU_indexbuf_add_tri_verts(&elb, v0, v3, v2);
- GPU_indexbuf_add_line_verts(&elb_lines, v0, v1);
- GPU_indexbuf_add_line_verts(&elb_lines, v0, v3);
+ GPU_indexbuf_add_line_verts(&elb_lines, v0, v1);
+ GPU_indexbuf_add_line_verts(&elb_lines, v0, v3);
- if (j + 2 == gridsize) {
- GPU_indexbuf_add_line_verts(&elb_lines, v2, v3);
- }
- grid_visible = true;
+ if (j + 2 == gridsize) {
+ GPU_indexbuf_add_line_verts(&elb_lines, v2, v3);
}
- GPU_indexbuf_add_line_verts(&elb_lines, v1, v2);
+ grid_visible = true;
}
+ GPU_indexbuf_add_line_verts(&elb_lines, v1, v2);
+ }
- if (grid_visible) {
- /* Grid corners */
- v0 = offset;
- v1 = offset + gridsize - 1;
- v2 = offset + grid_vert_len - 1;
- v3 = offset + grid_vert_len - gridsize;
+ if (grid_visible) {
+ /* Grid corners */
+ v0 = offset;
+ v1 = offset + gridsize - 1;
+ v2 = offset + grid_vert_len - 1;
+ v3 = offset + grid_vert_len - gridsize;
- GPU_indexbuf_add_tri_verts(&elb_fast, v0, v2, v1);
- GPU_indexbuf_add_tri_verts(&elb_fast, v0, v3, v2);
+ GPU_indexbuf_add_tri_verts(&elb_fast, v0, v2, v1);
+ GPU_indexbuf_add_tri_verts(&elb_fast, v0, v3, v2);
- GPU_indexbuf_add_line_verts(&elb_lines_fast, v0, v1);
- GPU_indexbuf_add_line_verts(&elb_lines_fast, v1, v2);
- GPU_indexbuf_add_line_verts(&elb_lines_fast, v2, v3);
- GPU_indexbuf_add_line_verts(&elb_lines_fast, v3, v0);
- }
+ GPU_indexbuf_add_line_verts(&elb_lines_fast, v0, v1);
+ GPU_indexbuf_add_line_verts(&elb_lines_fast, v1, v2);
+ GPU_indexbuf_add_line_verts(&elb_lines_fast, v2, v3);
+ GPU_indexbuf_add_line_verts(&elb_lines_fast, v3, v0);
}
}
- else {
- uint offset = 0;
- const uint grid_vert_len = SQUARE(gridsize - 1) * 4;
- for (int i = 0; i < totgrid; i++, offset += grid_vert_len) {
- bool grid_visible = false;
-
- BLI_bitmap *gh = buffers->grid_hidden[grid_indices[i]];
-
- uint v0, v1, v2, v3;
- for (int j = 0; j < gridsize - 1; j++) {
- for (int k = 0; k < gridsize - 1; k++) {
- /* Skip hidden grid face */
- if (gh && paint_is_grid_face_hidden(gh, gridsize, k, j)) {
- continue;
- }
- /* VBO data are in a Clockwise QUAD disposition. */
- v0 = offset + (j * (gridsize - 1) + k) * 4;
- v1 = v0 + 1;
- v2 = v0 + 2;
- v3 = v0 + 3;
+ }
+ else {
+ uint offset = 0;
+ const uint grid_vert_len = SQUARE(gridsize - 1) * 4;
+ for (int i = 0; i < totgrid; i++, offset += grid_vert_len) {
+ bool grid_visible = false;
+
+ BLI_bitmap *gh = buffers->grid_hidden[grid_indices[i]];
+
+ uint v0, v1, v2, v3;
+ for (int j = 0; j < gridsize - 1; j++) {
+ for (int k = 0; k < gridsize - 1; k++) {
+ /* Skip hidden grid face */
+ if (gh && paint_is_grid_face_hidden(gh, gridsize, k, j)) {
+ continue;
+ }
+ /* VBO data are in a Clockwise QUAD disposition. */
+ v0 = offset + (j * (gridsize - 1) + k) * 4;
+ v1 = v0 + 1;
+ v2 = v0 + 2;
+ v3 = v0 + 3;
- GPU_indexbuf_add_tri_verts(&elb, v0, v2, v1);
- GPU_indexbuf_add_tri_verts(&elb, v0, v3, v2);
+ GPU_indexbuf_add_tri_verts(&elb, v0, v2, v1);
+ GPU_indexbuf_add_tri_verts(&elb, v0, v3, v2);
- GPU_indexbuf_add_line_verts(&elb_lines, v0, v1);
- GPU_indexbuf_add_line_verts(&elb_lines, v0, v3);
+ GPU_indexbuf_add_line_verts(&elb_lines, v0, v1);
+ GPU_indexbuf_add_line_verts(&elb_lines, v0, v3);
- if (j + 2 == gridsize) {
- GPU_indexbuf_add_line_verts(&elb_lines, v2, v3);
- }
- grid_visible = true;
+ if (j + 2 == gridsize) {
+ GPU_indexbuf_add_line_verts(&elb_lines, v2, v3);
}
- GPU_indexbuf_add_line_verts(&elb_lines, v1, v2);
+ grid_visible = true;
}
+ GPU_indexbuf_add_line_verts(&elb_lines, v1, v2);
+ }
- if (grid_visible) {
- /* Grid corners */
- v0 = offset;
- v1 = offset + (gridsize - 1) * 4 - 3;
- v2 = offset + grid_vert_len - 2;
- v3 = offset + grid_vert_len - (gridsize - 1) * 4 + 3;
+ if (grid_visible) {
+ /* Grid corners */
+ v0 = offset;
+ v1 = offset + (gridsize - 1) * 4 - 3;
+ v2 = offset + grid_vert_len - 2;
+ v3 = offset + grid_vert_len - (gridsize - 1) * 4 + 3;
- GPU_indexbuf_add_tri_verts(&elb_fast, v0, v2, v1);
- GPU_indexbuf_add_tri_verts(&elb_fast, v0, v3, v2);
+ GPU_indexbuf_add_tri_verts(&elb_fast, v0, v2, v1);
+ GPU_indexbuf_add_tri_verts(&elb_fast, v0, v3, v2);
- GPU_indexbuf_add_line_verts(&elb_lines_fast, v0, v1);
- GPU_indexbuf_add_line_verts(&elb_lines_fast, v1, v2);
- GPU_indexbuf_add_line_verts(&elb_lines_fast, v2, v3);
- GPU_indexbuf_add_line_verts(&elb_lines_fast, v3, v0);
- }
+ GPU_indexbuf_add_line_verts(&elb_lines_fast, v0, v1);
+ GPU_indexbuf_add_line_verts(&elb_lines_fast, v1, v2);
+ GPU_indexbuf_add_line_verts(&elb_lines_fast, v2, v3);
+ GPU_indexbuf_add_line_verts(&elb_lines_fast, v3, v0);
}
}
-
- buffers->index_buf = GPU_indexbuf_build(&elb);
- buffers->index_buf_fast = GPU_indexbuf_build(&elb_fast);
- buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
- buffers->index_lines_buf_fast = GPU_indexbuf_build(&elb_lines_fast);
}
- void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers * buffers,
- CCGElem * *grids,
- const DMFlagMat *grid_flag_mats,
- int *grid_indices,
- int totgrid,
- const CCGKey *key,
- const int update_flags)
- {
- const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
- bool empty_mask = true;
- int i, j, k, x, y;
+ buffers->index_buf = GPU_indexbuf_build(&elb);
+ buffers->index_buf_fast = GPU_indexbuf_build(&elb_fast);
+ buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
+ buffers->index_lines_buf_fast = GPU_indexbuf_build(&elb_lines_fast);
+}
+
+void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
+ CCGElem **grids,
+ const DMFlagMat *grid_flag_mats,
+ int *grid_indices,
+ int totgrid,
+ const CCGKey *key,
+ const int update_flags)
+{
+ const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
+ const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0;
+ bool empty_mask = true;
+ int i, j, k, x, y;
- const bool smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH;
+ const bool smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH;
+ static char vcol[4] = {255, 255, 255, 255};
- /* Build VBO */
- const int has_mask = key->has_mask;
-
- uint vert_per_grid = (smooth) ? key->grid_area : (SQUARE(key->grid_size - 1) * 4);
- uint vert_count = totgrid * vert_per_grid;
-
- if (buffers->smooth != smooth) {
- buffers->smooth = smooth;
- GPU_BATCH_DISCARD_SAFE(buffers->triangles);
- GPU_BATCH_DISCARD_SAFE(buffers->triangles_fast);
- GPU_BATCH_DISCARD_SAFE(buffers->lines);
- GPU_BATCH_DISCARD_SAFE(buffers->lines_fast);
-
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf_fast);
+ /* Build VBO */
+ const int has_mask = key->has_mask;
+
+ uint vert_per_grid = (smooth) ? key->grid_area : (SQUARE(key->grid_size - 1) * 4);
+ uint vert_count = totgrid * vert_per_grid;
+
+ if (buffers->smooth != smooth) {
+ buffers->smooth = smooth;
+ GPU_BATCH_DISCARD_SAFE(buffers->triangles);
+ GPU_BATCH_DISCARD_SAFE(buffers->triangles_fast);
+ GPU_BATCH_DISCARD_SAFE(buffers->lines);
+ GPU_BATCH_DISCARD_SAFE(buffers->lines_fast);
+
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf_fast);
+ }
+
+ if (buffers->index_buf == NULL) {
+ uint visible_quad_len = BKE_pbvh_count_grid_quads(
+ (BLI_bitmap **)buffers->grid_hidden, grid_indices, totgrid, key->grid_size);
+
+ /* totally hidden node, return here to avoid BufferData with zero below. */
+ if (visible_quad_len == 0) {
+ return;
}
- if (buffers->index_buf == NULL) {
- uint visible_quad_len = BKE_pbvh_count_grid_quads(
- (BLI_bitmap **)buffers->grid_hidden, grid_indices, totgrid, key->grid_size);
+ gpu_pbvh_grid_fill_index_buffers(
+ buffers, grid_indices, visible_quad_len, totgrid, key->grid_size);
+ }
- /* totally hidden node, return here to avoid BufferData with zero below. */
- if (visible_quad_len == 0) {
- return;
- }
+ uint vbo_index_offset = 0;
+ /* Build VBO */
+ if (gpu_pbvh_vert_buf_data_set(buffers, vert_count)) {
+ GPUIndexBufBuilder elb_lines;
- gpu_pbvh_grid_fill_index_buffers(
- buffers, grid_indices, visible_quad_len, totgrid, key->grid_size);
+ if (buffers->index_lines_buf == NULL) {
+ GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, totgrid * key->grid_area * 2, vert_count);
}
- uint vbo_index_offset = 0;
- /* Build VBO */
- if (gpu_pbvh_vert_buf_data_set(buffers, vert_count)) {
- GPUIndexBufBuilder elb_lines;
+ for (i = 0; i < totgrid; ++i) {
+ CCGElem *grid = grids[grid_indices[i]];
+ int vbo_index = vbo_index_offset;
- if (buffers->index_lines_buf == NULL) {
- GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, totgrid * key->grid_area * 2, vert_count);
- }
+ if (buffers->smooth) {
+ for (y = 0; y < key->grid_size; y++) {
+ for (x = 0; x < key->grid_size; x++) {
+ CCGElem *elem = CCG_grid_elem(key, grid, x, y);
+ GPU_vertbuf_attr_set(
+ buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem));
+
+ short no_short[3];
+ normal_float_to_short_v3(no_short, CCG_elem_no(key, elem));
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short);
+
+ if (has_mask && show_mask) {
+ float fmask = *CCG_elem_mask(key, elem);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index, &fmask);
+ empty_mask = empty_mask && (fmask == 0.0f);
+ }
- for (i = 0; i < totgrid; ++i) {
- CCGElem *grid = grids[grid_indices[i]];
- int vbo_index = vbo_index_offset;
-
- if (buffers->smooth) {
- for (y = 0; y < key->grid_size; y++) {
- for (x = 0; x < key->grid_size; x++) {
- CCGElem *elem = CCG_grid_elem(key, grid, x, y);
- GPU_vertbuf_attr_set(
- buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem));
-
- short no_short[3];
- normal_float_to_short_v3(no_short, CCG_elem_no(key, elem));
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short);
-
- if (has_mask && show_mask) {
- float fmask = *CCG_elem_mask(key, elem);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index, &fmask);
- empty_mask = empty_mask && (fmask == 0.0f);
- }
- vbo_index += 1;
+ if (show_vcol) {
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, &vcol);
}
+
+ vbo_index += 1;
}
- vbo_index_offset += key->grid_area;
}
- else {
- for (j = 0; j < key->grid_size - 1; j++) {
- for (k = 0; k < key->grid_size - 1; k++) {
- CCGElem *elems[4] = {
- CCG_grid_elem(key, grid, k, j),
- CCG_grid_elem(key, grid, k + 1, j),
- CCG_grid_elem(key, grid, k + 1, j + 1),
- CCG_grid_elem(key, grid, k, j + 1),
- };
- float *co[4] = {
- CCG_elem_co(key, elems[0]),
- CCG_elem_co(key, elems[1]),
- CCG_elem_co(key, elems[2]),
- CCG_elem_co(key, elems[3]),
- };
-
- float fno[3];
- short no_short[3];
- /* Note: Clockwise indices ordering, that's why we invert order here. */
- normal_quad_v3(fno, co[3], co[2], co[1], co[0]);
- normal_float_to_short_v3(no_short, fno);
-
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index + 0, co[0]);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index + 0, no_short);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index + 1, co[1]);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index + 1, no_short);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index + 2, co[2]);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index + 2, no_short);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index + 3, co[3]);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index + 3, no_short);
-
- if (has_mask && show_mask) {
- float fmask = (*CCG_elem_mask(key, elems[0]) + *CCG_elem_mask(key, elems[1]) +
- *CCG_elem_mask(key, elems[2]) + *CCG_elem_mask(key, elems[3])) *
- 0.25f;
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index + 0, &fmask);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index + 1, &fmask);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index + 2, &fmask);
- GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index + 3, &fmask);
- empty_mask = empty_mask && (fmask == 0.0f);
- }
- vbo_index += 4;
+ vbo_index_offset += key->grid_area;
+ }
+ else {
+ for (j = 0; j < key->grid_size - 1; j++) {
+ for (k = 0; k < key->grid_size - 1; k++) {
+ CCGElem *elems[4] = {
+ CCG_grid_elem(key, grid, k, j),
+ CCG_grid_elem(key, grid, k + 1, j),
+ CCG_grid_elem(key, grid, k + 1, j + 1),
+ CCG_grid_elem(key, grid, k, j + 1),
+ };
+ float *co[4] = {
+ CCG_elem_co(key, elems[0]),
+ CCG_elem_co(key, elems[1]),
+ CCG_elem_co(key, elems[2]),
+ CCG_elem_co(key, elems[3]),
+ };
+
+ float fno[3];
+ short no_short[3];
+ /* Note: Clockwise indices ordering, that's why we invert order here. */
+ normal_quad_v3(fno, co[3], co[2], co[1], co[0]);
+ normal_float_to_short_v3(no_short, fno);
+
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index + 0, co[0]);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index + 0, no_short);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index + 1, co[1]);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index + 1, no_short);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index + 2, co[2]);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index + 2, no_short);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index + 3, co[3]);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index + 3, no_short);
+
+ if (has_mask && show_mask) {
+ float fmask = (*CCG_elem_mask(key, elems[0]) + *CCG_elem_mask(key, elems[1]) +
+ *CCG_elem_mask(key, elems[2]) + *CCG_elem_mask(key, elems[3])) *
+ 0.25f;
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index + 0, &fmask);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index + 1, &fmask);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index + 2, &fmask);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.msk, vbo_index + 3, &fmask);
+ empty_mask = empty_mask && (fmask == 0.0f);
}
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 0, &vcol);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 1, &vcol);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 2, &vcol);
+ GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 3, &vcol);
+ vbo_index += 4;
}
- vbo_index_offset += SQUARE(key->grid_size - 1) * 4;
}
+ vbo_index_offset += SQUARE(key->grid_size - 1) * 4;
}
-
- gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
}
- buffers->grids = grids;
- buffers->grid_indices = grid_indices;
- buffers->totgrid = totgrid;
- buffers->grid_flag_mats = grid_flag_mats;
- buffers->gridkey = *key;
- buffers->show_mask = !empty_mask;
-
- //printf("node updated %p\n", buffers);
+ gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
}
- GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(int totgrid, BLI_bitmap **grid_hidden)
- {
- GPU_PBVH_Buffers *buffers;
+ buffers->grids = grids;
+ buffers->grid_indices = grid_indices;
+ buffers->totgrid = totgrid;
+ buffers->grid_flag_mats = grid_flag_mats;
+ buffers->gridkey = *key;
+ buffers->show_mask = !empty_mask;
- buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
- buffers->grid_hidden = grid_hidden;
- buffers->totgrid = totgrid;
+ // printf("node updated %p\n", buffers);
+}
- buffers->show_mask = false;
+GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(int totgrid, BLI_bitmap **grid_hidden)
+{
+ GPU_PBVH_Buffers *buffers;
- return buffers;
- }
+ buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
+ buffers->grid_hidden = grid_hidden;
+ buffers->totgrid = totgrid;
+
+ buffers->show_mask = false;
+
+ return buffers;
+}
#undef FILL_QUAD_BUFFER
- /** \} */
+/** \} */
- /* -------------------------------------------------------------------- */
- /** \name BMesh PBVH
+/* -------------------------------------------------------------------- */
+/** \name BMesh PBVH
* \{ */
- /* Output a BMVert into a VertexBufferFormat array
+/* Output a BMVert into a VertexBufferFormat array
*
* The vertex is skipped if hidden, otherwise the output goes into
* index '*v_index' in the 'vert_data' array and '*v_index' is
* incremented.
*/
- static void gpu_bmesh_vert_to_buffer_copy__gwn(BMVert * v,
- GPUVertBuf * vert_buf,
- int *v_index,
- const float fno[3],
- const float *fmask,
- const int cd_vert_mask_offset,
- const bool show_mask,
- bool *empty_mask)
- {
- if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
-
- /* Set coord, normal, and mask */
- GPU_vertbuf_attr_set(vert_buf, g_vbo_id.pos, *v_index, v->co);
+static void gpu_bmesh_vert_to_buffer_copy__gwn(BMVert *v,
+ GPUVertBuf *vert_buf,
+ int *v_index,
+ const float fno[3],
+ const float *fmask,
+ const int cd_vert_mask_offset,
+ const bool show_mask,
+ const bool show_vcol,
+ bool *empty_mask)
+{
+ if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
- short no_short[3];
- normal_float_to_short_v3(no_short, fno ? fno : v->no);
- GPU_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short);
+ /* Set coord, normal, and mask */
+ GPU_vertbuf_attr_set(vert_buf, g_vbo_id.pos, *v_index, v->co);
- if (show_mask) {
- float effective_mask = fmask ? *fmask : BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset);
- GPU_vertbuf_attr_set(vert_buf, g_vbo_id.msk, *v_index, &effective_mask);
- *empty_mask = *empty_mask && (effective_mask == 0.0f);
- }
+ short no_short[3];
+ normal_float_to_short_v3(no_short, fno ? fno : v->no);
+ GPU_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short);
- /* Assign index for use in the triangle index buffer */
- /* note: caller must set: bm->elem_index_dirty |= BM_VERT; */
- BM_elem_index_set(v, (*v_index)); /* set_dirty! */
+ if (show_mask) {
+ float effective_mask = fmask ? *fmask : BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset);
+ GPU_vertbuf_attr_set(vert_buf, g_vbo_id.msk, *v_index, &effective_mask);
+ *empty_mask = *empty_mask && (effective_mask == 0.0f);
+ }
- (*v_index)++;
+ if (show_vcol) {
+ static char vcol[4] = {255, 255, 255, 255};
+ GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col, *v_index, &vcol);
}
+
+ /* Assign index for use in the triangle index buffer */
+ /* note: caller must set: bm->elem_index_dirty |= BM_VERT; */
+ BM_elem_index_set(v, (*v_index)); /* set_dirty! */
+
+ (*v_index)++;
}
+}
- /* Return the total number of vertices that don't have BM_ELEM_HIDDEN set */
- static int gpu_bmesh_vert_visible_count(GSet * bm_unique_verts, GSet * bm_other_verts)
- {
- GSetIterator gs_iter;
- int totvert = 0;
+/* Return the total number of vertices that don't have BM_ELEM_HIDDEN set */
+static int gpu_bmesh_vert_visible_count(GSet *bm_unique_verts, GSet *bm_other_verts)
+{
+ GSetIterator gs_iter;
+ int totvert = 0;
- GSET_ITER (gs_iter, bm_unique_verts) {
- BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
- if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN))
- totvert++;
+ GSET_ITER (gs_iter, bm_unique_verts) {
+ BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
+ if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
+ totvert++;
}
- GSET_ITER (gs_iter, bm_other_verts) {
- BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
- if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN))
- totvert++;
+ }
+ GSET_ITER (gs_iter, bm_other_verts) {
+ BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
+ if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
+ totvert++;
}
-
- return totvert;
}
- /* Return the total number of visible faces */
- static int gpu_bmesh_face_visible_count(GSet * bm_faces)
- {
- GSetIterator gh_iter;
- int totface = 0;
+ return totvert;
+}
+
+/* Return the total number of visible faces */
+static int gpu_bmesh_face_visible_count(GSet *bm_faces)
+{
+ GSetIterator gh_iter;
+ int totface = 0;
- GSET_ITER (gh_iter, bm_faces) {
- BMFace *f = BLI_gsetIterator_getKey(&gh_iter);
+ GSET_ITER (gh_iter, bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gh_iter);
- if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN))
- totface++;
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
+ totface++;
}
-
- return totface;
}
- /* Creates a vertex buffer (coordinate, normal, color) and, if smooth
+ return totface;
+}
+
+/* Creates a vertex buffer (coordinate, normal, color) and, if smooth
* shading, an element index buffer. */
- void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers * buffers,
- BMesh * bm,
- GSet * bm_faces,
- GSet * bm_unique_verts,
- GSet * bm_other_verts,
- const int update_flags)
- {
- const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
- int tottri, totvert, maxvert = 0;
- bool empty_mask = true;
+void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
+ BMesh *bm,
+ GSet *bm_faces,
+ GSet *bm_unique_verts,
+ GSet *bm_other_verts,
+ const int update_flags)
+{
+ const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
+ const bool show_vcol = (update_flags & GPU_PBVH_BUFFERS_SHOW_VCOL) != 0;
+ int tottri, totvert, maxvert = 0;
+ bool empty_mask = true;
- /* TODO, make mask layer optional for bmesh buffer */
- const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
+ /* TODO, make mask layer optional for bmesh buffer */
+ const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK);
- /* Count visible triangles */
- tottri = gpu_bmesh_face_visible_count(bm_faces);
+ /* Count visible triangles */
+ tottri = gpu_bmesh_face_visible_count(bm_faces);
- if (buffers->smooth) {
- /* Smooth needs to recreate index buffer, so we have to invalidate the batch. */
- GPU_BATCH_DISCARD_SAFE(buffers->triangles);
- GPU_BATCH_DISCARD_SAFE(buffers->lines);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
- /* Count visible vertices */
- totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts);
- }
- else {
- GPU_BATCH_DISCARD_SAFE(buffers->lines);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
- totvert = tottri * 3;
- }
+ if (buffers->smooth) {
+ /* Smooth needs to recreate index buffer, so we have to invalidate the batch. */
+ GPU_BATCH_DISCARD_SAFE(buffers->triangles);
+ GPU_BATCH_DISCARD_SAFE(buffers->lines);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
+ /* Count visible vertices */
+ totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts);
+ }
+ else {
+ GPU_BATCH_DISCARD_SAFE(buffers->lines);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
+ totvert = tottri * 3;
+ }
- if (!tottri) {
- buffers->tot_tri = 0;
- return;
- }
+ if (!tottri) {
+ buffers->tot_tri = 0;
+ return;
+ }
- /* Fill vertex buffer */
- if (gpu_pbvh_vert_buf_data_set(buffers, totvert)) {
- int v_index = 0;
+ /* Fill vertex buffer */
+ if (gpu_pbvh_vert_buf_data_set(buffers, totvert)) {
+ int v_index = 0;
- if (buffers->smooth) {
- GSetIterator gs_iter;
+ if (buffers->smooth) {
+ GSetIterator gs_iter;
- /* Vertices get an index assigned for use in the triangle
+ /* Vertices get an index assigned for use in the triangle
* index buffer */
- bm->elem_index_dirty |= BM_VERT;
-
- GSET_ITER (gs_iter, bm_unique_verts) {
- gpu_bmesh_vert_to_buffer_copy__gwn(BLI_gsetIterator_getKey(&gs_iter),
- buffers->vert_buf,
- &v_index,
- NULL,
- NULL,
- cd_vert_mask_offset,
- show_mask,
- &empty_mask);
- }
+ bm->elem_index_dirty |= BM_VERT;
- GSET_ITER (gs_iter, bm_other_verts) {
- gpu_bmesh_vert_to_buffer_copy__gwn(BLI_gsetIterator_getKey(&gs_iter),
- buffers->vert_buf,
- &v_index,
- NULL,
- NULL,
- cd_vert_mask_offset,
- show_mask,
- &empty_mask);
- }
+ GSET_ITER (gs_iter, bm_unique_verts) {
+ gpu_bmesh_vert_to_buffer_copy__gwn(BLI_gsetIterator_getKey(&gs_iter),
+ buffers->vert_buf,
+ &v_index,
+ NULL,
+ NULL,
+ cd_vert_mask_offset,
+ show_mask,
+ show_vcol,
+ &empty_mask);
+ }
- maxvert = v_index;
+ GSET_ITER (gs_iter, bm_other_verts) {
+ gpu_bmesh_vert_to_buffer_copy__gwn(BLI_gsetIterator_getKey(&gs_iter),
+ buffers->vert_buf,
+ &v_index,
+ NULL,
+ NULL,
+ cd_vert_mask_offset,
+ show_mask,
+ show_vcol,
+ &empty_mask);
}
- else {
- GSetIterator gs_iter;
- GPUIndexBufBuilder elb_lines;
- GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, totvert);
+ maxvert = v_index;
+ }
+ else {
+ GSetIterator gs_iter;
- GSET_ITER (gs_iter, bm_faces) {
- BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
+ GPUIndexBufBuilder elb_lines;
+ GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, totvert);
- BLI_assert(f->len == 3);
+ GSET_ITER (gs_iter, bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
- if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
- BMVert *v[3];
- float fmask = 0.0f;
- int i;
+ BLI_assert(f->len == 3);
- BM_face_as_array_vert_tri(f, v);
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
+ BMVert *v[3];
+ float fmask = 0.0f;
+ int i;
- /* Average mask value */
- for (i = 0; i < 3; i++) {
- fmask += BM_ELEM_CD_GET_FLOAT(v[i], cd_vert_mask_offset);
- }
- fmask /= 3.0f;
-
- GPU_indexbuf_add_line_verts(&elb_lines, v_index + 0, v_index + 1);
- GPU_indexbuf_add_line_verts(&elb_lines, v_index + 1, v_index + 2);
- GPU_indexbuf_add_line_verts(&elb_lines, v_index + 2, v_index + 0);
-
- for (i = 0; i < 3; i++) {
- gpu_bmesh_vert_to_buffer_copy__gwn(v[i],
- buffers->vert_buf,
- &v_index,
- f->no,
- &fmask,
- cd_vert_mask_offset,
- show_mask,
- &empty_mask);
- }
+ BM_face_as_array_vert_tri(f, v);
+
+ /* Average mask value */
+ for (i = 0; i < 3; i++) {
+ fmask += BM_ELEM_CD_GET_FLOAT(v[i], cd_vert_mask_offset);
+ }
+ fmask /= 3.0f;
+
+ GPU_indexbuf_add_line_verts(&elb_lines, v_index + 0, v_index + 1);
+ GPU_indexbuf_add_line_verts(&elb_lines, v_index + 1, v_index + 2);
+ GPU_indexbuf_add_line_verts(&elb_lines, v_index + 2, v_index + 0);
+
+ for (i = 0; i < 3; i++) {
+ gpu_bmesh_vert_to_buffer_copy__gwn(v[i],
+ buffers->vert_buf,
+ &v_index,
+ f->no,
+ &fmask,
+ cd_vert_mask_offset,
+ show_mask,
+ show_vcol,
+ &empty_mask);
}
}
-
- buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
- buffers->tot_tri = tottri;
}
- /* gpu_bmesh_vert_to_buffer_copy sets dirty index values */
- bm->elem_index_dirty |= BM_VERT;
- }
- else {
- /* Memory map failed */
- return;
+ buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
+ buffers->tot_tri = tottri;
}
- if (buffers->smooth) {
- /* Fill the triangle buffer */
- GPUIndexBufBuilder elb, elb_lines;
- GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, maxvert);
- GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, maxvert);
-
- /* Fill triangle index buffer */
- {
- GSetIterator gs_iter;
+ /* gpu_bmesh_vert_to_buffer_copy sets dirty index values */
+ bm->elem_index_dirty |= BM_VERT;
+ }
+ else {
+ /* Memory map failed */
+ return;
+ }
- GSET_ITER (gs_iter, bm_faces) {
- BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
+ if (buffers->smooth) {
+ /* Fill the triangle buffer */
+ GPUIndexBufBuilder elb, elb_lines;
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, maxvert);
+ GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, maxvert);
- if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
- BMVert *v[3];
+ /* Fill triangle index buffer */
+ {
+ GSetIterator gs_iter;
- BM_face_as_array_vert_tri(f, v);
+ GSET_ITER (gs_iter, bm_faces) {
+ BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
- uint idx[3] = {
- BM_elem_index_get(v[0]), BM_elem_index_get(v[1]), BM_elem_index_get(v[2])};
- GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
+ if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
+ BMVert *v[3];
- GPU_indexbuf_add_line_verts(&elb_lines, idx[0], idx[1]);
- GPU_indexbuf_add_line_verts(&elb_lines, idx[1], idx[2]);
- GPU_indexbuf_add_line_verts(&elb_lines, idx[2], idx[0]);
- }
- }
+ BM_face_as_array_vert_tri(f, v);
- buffers->tot_tri = tottri;
+ uint idx[3] = {
+ BM_elem_index_get(v[0]), BM_elem_index_get(v[1]), BM_elem_index_get(v[2])};
+ GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]);
- if (buffers->index_buf == NULL) {
- buffers->index_buf = GPU_indexbuf_build(&elb);
- }
- else {
- GPU_indexbuf_build_in_place(&elb, buffers->index_buf);
+ GPU_indexbuf_add_line_verts(&elb_lines, idx[0], idx[1]);
+ GPU_indexbuf_add_line_verts(&elb_lines, idx[1], idx[2]);
+ GPU_indexbuf_add_line_verts(&elb_lines, idx[2], idx[0]);
}
+ }
+
+ buffers->tot_tri = tottri;
- buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
+ if (buffers->index_buf == NULL) {
+ buffers->index_buf = GPU_indexbuf_build(&elb);
}
+ else {
+ GPU_indexbuf_build_in_place(&elb, buffers->index_buf);
+ }
+
+ buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines);
}
+ }
- buffers->show_mask = !empty_mask;
+ buffers->show_mask = !empty_mask;
- gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
- }
+ gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS);
+}
- /** \} */
+/** \} */
- /* -------------------------------------------------------------------- */
- /** \name Generic
+/* -------------------------------------------------------------------- */
+/** \name Generic
* \{ */
- GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading)
- {
- GPU_PBVH_Buffers *buffers;
+GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading)
+{
+ GPU_PBVH_Buffers *buffers;
- buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
- buffers->use_bmesh = true;
- buffers->smooth = smooth_shading;
- buffers->show_mask = true;
+ buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
+ buffers->use_bmesh = true;
+ buffers->smooth = smooth_shading;
+ buffers->show_mask = true;
- return buffers;
- }
+ return buffers;
+}
- GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers * buffers, bool fast, bool wires)
- {
- if (wires) {
- return (fast && buffers->lines_fast) ? buffers->lines_fast : buffers->lines;
- }
- else {
- return (fast && buffers->triangles_fast) ? buffers->triangles_fast : buffers->triangles;
- }
+GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast, bool wires)
+{
+ if (wires) {
+ return (fast && buffers->lines_fast) ? buffers->lines_fast : buffers->lines;
}
-
- bool GPU_pbvh_buffers_has_mask(GPU_PBVH_Buffers * buffers)
- {
- return buffers->show_mask;
+ else {
+ return (fast && buffers->triangles_fast) ? buffers->triangles_fast : buffers->triangles;
}
+}
- void GPU_pbvh_buffers_free(GPU_PBVH_Buffers * buffers)
- {
- if (buffers) {
- GPU_BATCH_DISCARD_SAFE(buffers->lines);
- GPU_BATCH_DISCARD_SAFE(buffers->lines_fast);
- GPU_BATCH_DISCARD_SAFE(buffers->triangles);
- GPU_BATCH_DISCARD_SAFE(buffers->triangles_fast);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf_fast);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast);
- GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
- GPU_VERTBUF_DISCARD_SAFE(buffers->vert_buf);
-
- MEM_freeN(buffers);
- }
+bool GPU_pbvh_buffers_has_mask(GPU_PBVH_Buffers *buffers)
+{
+ return buffers->show_mask;
+}
+
+void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers)
+{
+ if (buffers) {
+ GPU_BATCH_DISCARD_SAFE(buffers->lines);
+ GPU_BATCH_DISCARD_SAFE(buffers->lines_fast);
+ GPU_BATCH_DISCARD_SAFE(buffers->triangles);
+ GPU_BATCH_DISCARD_SAFE(buffers->triangles_fast);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf_fast);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_lines_buf);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast);
+ GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf);
+ GPU_VERTBUF_DISCARD_SAFE(buffers->vert_buf);
+
+ MEM_freeN(buffers);
}
+}
- /** \} */
+/** \} */
- /* -------------------------------------------------------------------- */
- /** \name Debug
+/* -------------------------------------------------------------------- */
+/** \name Debug
* \{ */
- /* debug function, draws the pbvh BB */
- void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, uint pos)
- {
- if (leaf)
- immUniformColor4f(0.0, 1.0, 0.0, 0.5);
- else
- immUniformColor4f(1.0, 0.0, 0.0, 0.5);
+/* debug function, draws the pbvh BB */
+void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, uint pos)
+{
+ if (leaf) {
+ immUniformColor4f(0.0, 1.0, 0.0, 0.5);
+ }
+ else {
+ immUniformColor4f(1.0, 0.0, 0.0, 0.5);
+ }
- /* TODO(merwin): revisit this after we have mutable VertexBuffers
+ /* TODO(merwin): revisit this after we have mutable VertexBuffers
* could keep a static batch & index buffer, change the VBO contents per draw
*/
- immBegin(GPU_PRIM_LINES, 24);
+ immBegin(GPU_PRIM_LINES, 24);
- /* top */
- immVertex3f(pos, min[0], min[1], max[2]);
- immVertex3f(pos, min[0], max[1], max[2]);
+ /* top */
+ immVertex3f(pos, min[0], min[1], max[2]);
+ immVertex3f(pos, min[0], max[1], max[2]);
- immVertex3f(pos, min[0], max[1], max[2]);
- immVertex3f(pos, max[0], max[1], max[2]);
+ immVertex3f(pos, min[0], max[1], max[2]);
+ immVertex3f(pos, max[0], max[1], max[2]);
- immVertex3f(pos, max[0], max[1], max[2]);
- immVertex3f(pos, max[0], min[1], max[2]);
+ immVertex3f(pos, max[0], max[1], max[2]);
+ immVertex3f(pos, max[0], min[1], max[2]);
- immVertex3f(pos, max[0], min[1], max[2]);
- immVertex3f(pos, min[0], min[1], max[2]);
+ immVertex3f(pos, max[0], min[1], max[2]);
+ immVertex3f(pos, min[0], min[1], max[2]);
- /* bottom */
- immVertex3f(pos, min[0], min[1], min[2]);
- immVertex3f(pos, min[0], max[1], min[2]);
+ /* bottom */
+ immVertex3f(pos, min[0], min[1], min[2]);
+ immVertex3f(pos, min[0], max[1], min[2]);
- immVertex3f(pos, min[0], max[1], min[2]);
- immVertex3f(pos, max[0], max[1], min[2]);
+ immVertex3f(pos, min[0], max[1], min[2]);
+ immVertex3f(pos, max[0], max[1], min[2]);
- immVertex3f(pos, max[0], max[1], min[2]);
- immVertex3f(pos, max[0], min[1], min[2]);
+ immVertex3f(pos, max[0], max[1], min[2]);
+ immVertex3f(pos, max[0], min[1], min[2]);
- immVertex3f(pos, max[0], min[1], min[2]);
- immVertex3f(pos, min[0], min[1], min[2]);
+ immVertex3f(pos, max[0], min[1], min[2]);
+ immVertex3f(pos, min[0], min[1], min[2]);
- /* sides */
- immVertex3f(pos, min[0], min[1], min[2]);
- immVertex3f(pos, min[0], min[1], max[2]);
+ /* sides */
+ immVertex3f(pos, min[0], min[1], min[2]);
+ immVertex3f(pos, min[0], min[1], max[2]);
- immVertex3f(pos, min[0], max[1], min[2]);
- immVertex3f(pos, min[0], max[1], max[2]);
+ immVertex3f(pos, min[0], max[1], min[2]);
+ immVertex3f(pos, min[0], max[1], max[2]);
- immVertex3f(pos, max[0], max[1], min[2]);
- immVertex3f(pos, max[0], max[1], max[2]);
+ immVertex3f(pos, max[0], max[1], min[2]);
+ immVertex3f(pos, max[0], max[1], max[2]);
- immVertex3f(pos, max[0], min[1], min[2]);
- immVertex3f(pos, max[0], min[1], max[2]);
+ immVertex3f(pos, max[0], min[1], min[2]);
+ immVertex3f(pos, max[0], min[1], max[2]);
- immEnd();
- }
+ immEnd();
+}
- /** \} */
+/** \} */
- void GPU_pbvh_fix_linking()
- {
- }
+void GPU_pbvh_fix_linking()
+{
+}
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 458c0d5da85..a77bba5ab86 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -81,8 +81,9 @@ static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs, GPUVertAtt
BLI_hash_mm2a_add(&hm2a, (uchar *)name, strlen(name));
}
}
- if (defs)
+ if (defs) {
BLI_hash_mm2a_add(&hm2a, (uchar *)defs, strlen(defs));
+ }
return BLI_hash_mm2a_end(&hm2a);
}
@@ -180,8 +181,9 @@ static GPUShader *FUNCTION_LIB = NULL;
static int gpu_str_prefix(const char *str, const char *prefix)
{
while (*str && *prefix) {
- if (*str != *prefix)
+ if (*str != *prefix) {
return 0;
+ }
str++;
prefix++;
@@ -196,8 +198,9 @@ static char *gpu_str_skip_token(char *str, char *token, int max)
/* skip a variable/function name */
while (*str) {
- if (ELEM(*str, ' ', '(', ')', ',', ';', '\t', '\n', '\r'))
+ if (ELEM(*str, ' ', '(', ')', ',', ';', '\t', '\n', '\r')) {
break;
+ }
else {
if (token && len < max - 1) {
*token = *str;
@@ -208,16 +211,19 @@ static char *gpu_str_skip_token(char *str, char *token, int max)
}
}
- if (token)
+ if (token) {
*token = '\0';
+ }
/* skip the next special characters:
* note the missing ')' */
while (*str) {
- if (ELEM(*str, ' ', '(', ',', ';', '\t', '\n', '\r'))
+ if (ELEM(*str, ' ', '(', ',', ';', '\t', '\n', '\r')) {
str++;
- else
+ }
+ else {
break;
+ }
}
return str;
@@ -240,12 +246,15 @@ static void gpu_parse_functions_string(GHash *hash, char *code)
while (*code && *code != ')') {
/* test if it's an input or output */
qual = FUNCTION_QUAL_IN;
- if (gpu_str_prefix(code, "out "))
+ if (gpu_str_prefix(code, "out ")) {
qual = FUNCTION_QUAL_OUT;
- if (gpu_str_prefix(code, "inout "))
+ }
+ if (gpu_str_prefix(code, "inout ")) {
qual = FUNCTION_QUAL_INOUT;
- if ((qual != FUNCTION_QUAL_IN) || gpu_str_prefix(code, "in "))
+ }
+ if ((qual != FUNCTION_QUAL_IN) || gpu_str_prefix(code, "in ")) {
code = gpu_str_skip_token(code, NULL, 0);
+ }
/* test for type */
type = GPU_NONE;
@@ -368,8 +377,9 @@ void gpu_codegen_exit(void)
{
extern Material defmaterial; /* render module abuse... */
- if (defmaterial.gpumaterial.first)
+ if (defmaterial.gpumaterial.first) {
GPU_material_free(&defmaterial.gpumaterial);
+ }
if (FUNCTION_HASH) {
BLI_ghash_free(FUNCTION_HASH, NULL, MEM_freeN);
@@ -407,46 +417,62 @@ static void codegen_convert_datatype(DynStr *ds, int from, int to, const char *t
BLI_dynstr_append(ds, name);
}
else if (to == GPU_FLOAT) {
- if (from == GPU_VEC4)
+ if (from == GPU_VEC4) {
BLI_dynstr_appendf(ds, "convert_rgba_to_float(%s)", name);
- else if (from == GPU_VEC3)
+ }
+ else if (from == GPU_VEC3) {
BLI_dynstr_appendf(ds, "(%s.r + %s.g + %s.b) / 3.0", name, name, name);
- else if (from == GPU_VEC2)
+ }
+ else if (from == GPU_VEC2) {
BLI_dynstr_appendf(ds, "%s.r", name);
+ }
}
else if (to == GPU_VEC2) {
- if (from == GPU_VEC4)
+ if (from == GPU_VEC4) {
BLI_dynstr_appendf(ds, "vec2((%s.r + %s.g + %s.b) / 3.0, %s.a)", name, name, name, name);
- else if (from == GPU_VEC3)
+ }
+ else if (from == GPU_VEC3) {
BLI_dynstr_appendf(ds, "vec2((%s.r + %s.g + %s.b) / 3.0, 1.0)", name, name, name);
- else if (from == GPU_FLOAT)
+ }
+ else if (from == GPU_FLOAT) {
BLI_dynstr_appendf(ds, "vec2(%s, 1.0)", name);
+ }
}
else if (to == GPU_VEC3) {
- if (from == GPU_VEC4)
+ if (from == GPU_VEC4) {
BLI_dynstr_appendf(ds, "%s.rgb", name);
- else if (from == GPU_VEC2)
+ }
+ else if (from == GPU_VEC2) {
BLI_dynstr_appendf(ds, "vec3(%s.r, %s.r, %s.r)", name, name, name);
- else if (from == GPU_FLOAT)
+ }
+ else if (from == GPU_FLOAT) {
BLI_dynstr_appendf(ds, "vec3(%s, %s, %s)", name, name, name);
+ }
}
else if (to == GPU_VEC4) {
- if (from == GPU_VEC3)
+ if (from == GPU_VEC3) {
BLI_dynstr_appendf(ds, "vec4(%s, 1.0)", name);
- else if (from == GPU_VEC2)
+ }
+ else if (from == GPU_VEC2) {
BLI_dynstr_appendf(ds, "vec4(%s.r, %s.r, %s.r, %s.g)", name, name, name, name);
- else if (from == GPU_FLOAT)
+ }
+ else if (from == GPU_FLOAT) {
BLI_dynstr_appendf(ds, "vec4(%s, %s, %s, 1.0)", name, name, name);
+ }
}
else if (to == GPU_CLOSURE) {
- if (from == GPU_VEC4)
+ if (from == GPU_VEC4) {
BLI_dynstr_appendf(ds, "closure_emission(%s.rgb)", name);
- else if (from == GPU_VEC3)
+ }
+ else if (from == GPU_VEC3) {
BLI_dynstr_appendf(ds, "closure_emission(%s.rgb)", name);
- else if (from == GPU_VEC2)
+ }
+ else if (from == GPU_VEC2) {
BLI_dynstr_appendf(ds, "closure_emission(%s.rrr)", name);
- else if (from == GPU_FLOAT)
+ }
+ else if (from == GPU_FLOAT) {
BLI_dynstr_appendf(ds, "closure_emission(vec3(%s, %s, %s))", name, name, name);
+ }
}
else {
BLI_dynstr_append(ds, name);
@@ -461,69 +487,96 @@ static void codegen_print_datatype(DynStr *ds, const eGPUType type, float *data)
for (i = 0; i < type; i++) {
BLI_dynstr_appendf(ds, "%.12f", data[i]);
- if (i == type - 1)
+ if (i == type - 1) {
BLI_dynstr_append(ds, ")");
- else
+ }
+ else {
BLI_dynstr_append(ds, ", ");
+ }
}
}
static int codegen_input_has_texture(GPUInput *input)
{
- if (input->link)
+ if (input->link) {
return 0;
- else
+ }
+ else {
return (input->source == GPU_SOURCE_TEX);
+ }
}
const char *GPU_builtin_name(eGPUBuiltin builtin)
{
- if (builtin == GPU_VIEW_MATRIX)
+ if (builtin == GPU_VIEW_MATRIX) {
return "unfviewmat";
- else if (builtin == GPU_OBJECT_MATRIX)
+ }
+ else if (builtin == GPU_OBJECT_MATRIX) {
return "unfobmat";
- else if (builtin == GPU_INVERSE_VIEW_MATRIX)
+ }
+ else if (builtin == GPU_INVERSE_VIEW_MATRIX) {
return "unfinvviewmat";
- else if (builtin == GPU_INVERSE_OBJECT_MATRIX)
+ }
+ else if (builtin == GPU_INVERSE_OBJECT_MATRIX) {
return "unfinvobmat";
- else if (builtin == GPU_INVERSE_NORMAL_MATRIX)
+ }
+ else if (builtin == GPU_INVERSE_NORMAL_MATRIX) {
return "unfinvnormat";
- else if (builtin == GPU_LOC_TO_VIEW_MATRIX)
+ }
+ else if (builtin == GPU_LOC_TO_VIEW_MATRIX) {
return "unflocaltoviewmat";
- else if (builtin == GPU_INVERSE_LOC_TO_VIEW_MATRIX)
+ }
+ else if (builtin == GPU_INVERSE_LOC_TO_VIEW_MATRIX) {
return "unfinvlocaltoviewmat";
- else if (builtin == GPU_VIEW_POSITION)
+ }
+ else if (builtin == GPU_VIEW_POSITION) {
return "varposition";
- else if (builtin == GPU_VIEW_NORMAL)
+ }
+ else if (builtin == GPU_VIEW_NORMAL) {
return "varnormal";
- else if (builtin == GPU_OBCOLOR)
+ }
+ else if (builtin == GPU_OBCOLOR) {
return "unfobcolor";
- else if (builtin == GPU_AUTO_BUMPSCALE)
+ }
+ else if (builtin == GPU_AUTO_BUMPSCALE) {
return "unfobautobumpscale";
- else if (builtin == GPU_CAMERA_TEXCO_FACTORS)
+ }
+ else if (builtin == GPU_CAMERA_TEXCO_FACTORS) {
return "unfcameratexfactors";
- else if (builtin == GPU_PARTICLE_SCALAR_PROPS)
+ }
+ else if (builtin == GPU_PARTICLE_SCALAR_PROPS) {
return "unfparticlescalarprops";
- else if (builtin == GPU_PARTICLE_LOCATION)
+ }
+ else if (builtin == GPU_PARTICLE_LOCATION) {
return "unfparticleco";
- else if (builtin == GPU_PARTICLE_VELOCITY)
+ }
+ else if (builtin == GPU_PARTICLE_VELOCITY) {
return "unfparticlevel";
- else if (builtin == GPU_PARTICLE_ANG_VELOCITY)
+ }
+ else if (builtin == GPU_PARTICLE_ANG_VELOCITY) {
return "unfparticleangvel";
- else if (builtin == GPU_OBJECT_INFO)
+ }
+ else if (builtin == GPU_OBJECT_INFO) {
return "unfobjectinfo";
- else if (builtin == GPU_VOLUME_DENSITY)
+ }
+ else if (builtin == GPU_VOLUME_DENSITY) {
return "sampdensity";
- else if (builtin == GPU_VOLUME_FLAME)
+ }
+ else if (builtin == GPU_VOLUME_FLAME) {
return "sampflame";
- else if (builtin == GPU_VOLUME_TEMPERATURE)
+ }
+ else if (builtin == GPU_VOLUME_TEMPERATURE) {
return "unftemperature";
- else if (builtin == GPU_BARYCENTRIC_TEXCO)
+ }
+ else if (builtin == GPU_BARYCENTRIC_TEXCO) {
return "unfbarycentrictex";
- else if (builtin == GPU_BARYCENTRIC_DIST)
+ }
+ else if (builtin == GPU_BARYCENTRIC_DIST) {
return "unfbarycentricdist";
- else
+ }
+ else {
return "";
+ }
}
/* assign only one texid per buffer to avoid sampling the same texture twice */
@@ -706,32 +759,45 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
}
else if (input->source == GPU_SOURCE_BUILTIN) {
/* TODO(fclem) get rid of that. */
- if (input->builtin == GPU_INVERSE_VIEW_MATRIX)
+ if (input->builtin == GPU_INVERSE_VIEW_MATRIX) {
BLI_dynstr_append(ds, "viewinv");
- else if (input->builtin == GPU_VIEW_MATRIX)
+ }
+ else if (input->builtin == GPU_VIEW_MATRIX) {
BLI_dynstr_append(ds, "viewmat");
- else if (input->builtin == GPU_CAMERA_TEXCO_FACTORS)
+ }
+ else if (input->builtin == GPU_CAMERA_TEXCO_FACTORS) {
BLI_dynstr_append(ds, "camtexfac");
- else if (input->builtin == GPU_LOC_TO_VIEW_MATRIX)
+ }
+ else if (input->builtin == GPU_LOC_TO_VIEW_MATRIX) {
BLI_dynstr_append(ds, "localtoviewmat");
- else if (input->builtin == GPU_INVERSE_LOC_TO_VIEW_MATRIX)
+ }
+ else if (input->builtin == GPU_INVERSE_LOC_TO_VIEW_MATRIX) {
BLI_dynstr_append(ds, "invlocaltoviewmat");
- else if (input->builtin == GPU_BARYCENTRIC_DIST)
+ }
+ else if (input->builtin == GPU_BARYCENTRIC_DIST) {
BLI_dynstr_append(ds, "barycentricDist");
- else if (input->builtin == GPU_BARYCENTRIC_TEXCO)
+ }
+ else if (input->builtin == GPU_BARYCENTRIC_TEXCO) {
BLI_dynstr_append(ds, "barytexco");
- else if (input->builtin == GPU_OBJECT_MATRIX)
+ }
+ else if (input->builtin == GPU_OBJECT_MATRIX) {
BLI_dynstr_append(ds, "objmat");
- else if (input->builtin == GPU_INVERSE_OBJECT_MATRIX)
+ }
+ else if (input->builtin == GPU_INVERSE_OBJECT_MATRIX) {
BLI_dynstr_append(ds, "objinv");
- else if (input->builtin == GPU_INVERSE_NORMAL_MATRIX)
+ }
+ else if (input->builtin == GPU_INVERSE_NORMAL_MATRIX) {
BLI_dynstr_append(ds, "norinv");
- else if (input->builtin == GPU_VIEW_POSITION)
+ }
+ else if (input->builtin == GPU_VIEW_POSITION) {
BLI_dynstr_append(ds, "viewposition");
- else if (input->builtin == GPU_VIEW_NORMAL)
+ }
+ else if (input->builtin == GPU_VIEW_NORMAL) {
BLI_dynstr_append(ds, "facingnormal");
- else
+ }
+ else {
BLI_dynstr_append(ds, GPU_builtin_name(input->builtin));
+ }
}
else if (input->source == GPU_SOURCE_STRUCT) {
BLI_dynstr_appendf(ds, "strct%d", input->id);
@@ -751,8 +817,9 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
for (output = node->outputs.first; output; output = output->next) {
BLI_dynstr_appendf(ds, "tmp%d", output->id);
- if (output->next)
+ if (output->next) {
BLI_dynstr_append(ds, ", ");
+ }
}
BLI_dynstr_append(ds, ");\n");
@@ -778,11 +845,13 @@ static char *code_generate_fragment(GPUMaterial *material,
codegen_set_unique_ids(nodes);
*rbuiltins = builtins = codegen_process_uniforms_functions(material, ds, nodes);
- if (builtins & GPU_BARYCENTRIC_TEXCO)
+ if (builtins & GPU_BARYCENTRIC_TEXCO) {
BLI_dynstr_append(ds, "in vec2 barycentricTexCo;\n");
+ }
- if (builtins & GPU_BARYCENTRIC_DIST)
+ if (builtins & GPU_BARYCENTRIC_DIST) {
BLI_dynstr_append(ds, "flat in vec3 barycentricDist;\n");
+ }
BLI_dynstr_append(ds, "Closure nodetree_exec(void)\n{\n");
@@ -798,33 +867,50 @@ static char *code_generate_fragment(GPUMaterial *material,
BLI_dynstr_append(ds, "#endif\n");
}
/* TODO(fclem) get rid of that. */
- if (builtins & GPU_VIEW_MATRIX)
+ if (builtins & GPU_VIEW_MATRIX) {
BLI_dynstr_append(ds, "\t#define viewmat ViewMatrix\n");
- if (builtins & GPU_CAMERA_TEXCO_FACTORS)
+ }
+ if (builtins & GPU_CAMERA_TEXCO_FACTORS) {
BLI_dynstr_append(ds, "\t#define camtexfac CameraTexCoFactors\n");
- if (builtins & GPU_OBJECT_MATRIX)
+ }
+ if (builtins & GPU_OBJECT_MATRIX) {
BLI_dynstr_append(ds, "\t#define objmat ModelMatrix\n");
- if (builtins & GPU_INVERSE_OBJECT_MATRIX)
+ }
+ if (builtins & GPU_INVERSE_OBJECT_MATRIX) {
BLI_dynstr_append(ds, "\t#define objinv ModelMatrixInverse\n");
- if (builtins & GPU_INVERSE_NORMAL_MATRIX)
+ }
+ if (builtins & GPU_INVERSE_NORMAL_MATRIX) {
BLI_dynstr_append(ds, "\t#define norinv NormalMatrixInverse\n");
- if (builtins & GPU_INVERSE_VIEW_MATRIX)
+ }
+ if (builtins & GPU_INVERSE_VIEW_MATRIX) {
BLI_dynstr_append(ds, "\t#define viewinv ViewMatrixInverse\n");
- if (builtins & GPU_LOC_TO_VIEW_MATRIX)
+ }
+ if (builtins & GPU_LOC_TO_VIEW_MATRIX) {
BLI_dynstr_append(ds, "\t#define localtoviewmat ModelViewMatrix\n");
- if (builtins & GPU_INVERSE_LOC_TO_VIEW_MATRIX)
+ }
+ if (builtins & GPU_INVERSE_LOC_TO_VIEW_MATRIX) {
BLI_dynstr_append(ds, "\t#define invlocaltoviewmat ModelViewMatrixInverse\n");
- if (builtins & GPU_VIEW_NORMAL)
+ }
+ if (builtins & GPU_VIEW_NORMAL) {
+ BLI_dynstr_append(ds, "#ifdef HAIR_SHADER\n");
+ BLI_dynstr_append(ds, "\tvec3 n;\n");
+ BLI_dynstr_append(ds, "\tworld_normals_get(n);\n");
+ BLI_dynstr_append(ds, "\tvec3 facingnormal = transform_direction(ViewMatrix, n);\n");
+ BLI_dynstr_append(ds, "#else\n");
BLI_dynstr_append(ds, "\tvec3 facingnormal = gl_FrontFacing? viewNormal: -viewNormal;\n");
- if (builtins & GPU_VIEW_POSITION)
+ BLI_dynstr_append(ds, "#endif\n");
+ }
+ if (builtins & GPU_VIEW_POSITION) {
BLI_dynstr_append(ds, "\t#define viewposition viewPosition\n");
+ }
codegen_declare_tmps(ds, nodes);
codegen_call_functions(ds, nodes, output);
BLI_dynstr_append(ds, "}\n");
- /* XXX This cannot go into gpu_shader_material.glsl because main() would be parsed and generate error */
+ /* XXX This cannot go into gpu_shader_material.glsl because main()
+ * would be parsed and generate error */
/* Old glsl mode compat. */
BLI_dynstr_append(ds, "#ifndef NODETREE_EXEC\n");
BLI_dynstr_append(ds, "out vec4 fragColor;\n");
@@ -840,7 +926,8 @@ static char *code_generate_fragment(GPUMaterial *material,
BLI_dynstr_free(ds);
#if 0
- if (G.debug & G_DEBUG) printf("%s\n", code);
+ if (G.debug & G_DEBUG)
+ printf("%s\n", code);
#endif
return code;
@@ -1107,7 +1194,8 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
BLI_dynstr_free(ds);
#if 0
- if (G.debug & G_DEBUG) printf("%s\n", code);
+ if (G.debug & G_DEBUG)
+ printf("%s\n", code);
#endif
return code;
@@ -1264,8 +1352,9 @@ void GPU_code_generate_glsl_lib(void)
DynStr *ds;
/* only initialize the library once */
- if (glsl_material_library)
+ if (glsl_material_library) {
return;
+ }
ds = BLI_dynstr_new();
@@ -1290,8 +1379,9 @@ void GPU_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListB
BLI_listbase_clear(inputs);
- if (!shader)
+ if (!shader) {
return;
+ }
for (node = nodes->first; node; node = node->next) {
int z = 0;
@@ -1305,8 +1395,9 @@ void GPU_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListB
continue;
}
- if (input->source == GPU_SOURCE_TEX)
+ if (input->source == GPU_SOURCE_TEX) {
BLI_snprintf(input->shadername, sizeof(input->shadername), "samp%d", input->texid);
+ }
else {
BLI_snprintf(input->shadername, sizeof(input->shadername), "unf%d", input->id);
}
@@ -1337,12 +1428,14 @@ static void gpu_node_link_free(GPUNodeLink *link)
{
link->users--;
- if (link->users < 0)
+ if (link->users < 0) {
fprintf(stderr, "GPU_node_link_free: negative refcount\n");
+ }
if (link->users == 0) {
- if (link->output)
+ if (link->output) {
link->output->link = NULL;
+ }
MEM_freeN(link);
}
}
@@ -1371,8 +1464,9 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
if ((STR_ELEM(name, "set_value", "set_rgb", "set_rgba")) && (input->type == type)) {
input = MEM_dupallocN(outnode->inputs.first);
- if (input->link)
+ if (input->link) {
input->link->users++;
+ }
BLI_addtail(&node->inputs, input);
return;
}
@@ -1537,8 +1631,9 @@ void GPU_inputs_free(ListBase *inputs)
GPUInput *input;
for (input = inputs->first; input; input = input->next) {
- if (input->link)
+ if (input->link) {
gpu_node_link_free(input->link);
+ }
}
BLI_freelistN(inputs);
@@ -1550,11 +1645,12 @@ static void gpu_node_free(GPUNode *node)
GPU_inputs_free(&node->inputs);
- for (output = node->outputs.first; output; output = output->next)
+ for (output = node->outputs.first; output; output = output->next) {
if (output->link) {
output->link->output = NULL;
gpu_node_link_free(output->link);
}
+ }
BLI_freelistN(&node->outputs);
MEM_freeN(node);
@@ -1752,19 +1848,23 @@ bool GPU_stack_link(GPUMaterial *material,
linkptr = va_arg(params, GPUNodeLink **);
gpu_node_output(node, function->paramtype[i], linkptr);
}
- else
+ else {
totout--;
+ }
}
else {
if (totin == 0) {
link = va_arg(params, GPUNodeLink *);
- if (link->socket)
+ if (link->socket) {
gpu_node_input_socket(NULL, NULL, node, link->socket, -1);
- else
+ }
+ else {
gpu_node_input_link(node, link, function->paramtype[i]);
+ }
}
- else
+ else {
totin--;
+ }
}
}
va_end(params);
@@ -1789,25 +1889,30 @@ static void gpu_nodes_tag(GPUNodeLink *link)
GPUNode *node;
GPUInput *input;
- if (!link->output)
+ if (!link->output) {
return;
+ }
node = link->output->node;
- if (node->tag)
+ if (node->tag) {
return;
+ }
node->tag = true;
- for (input = node->inputs.first; input; input = input->next)
- if (input->link)
+ for (input = node->inputs.first; input; input = input->next) {
+ if (input->link) {
gpu_nodes_tag(input->link);
+ }
+ }
}
void GPU_nodes_prune(ListBase *nodes, GPUNodeLink *outlink)
{
GPUNode *node, *next;
- for (node = nodes->first; node; node = node->next)
+ for (node = nodes->first; node; node = node->next) {
node->tag = false;
+ }
gpu_nodes_tag(outlink);
@@ -2066,8 +2171,9 @@ void GPU_pass_cache_garbage_collect(void)
const int shadercollectrate = 60; /* hardcoded for now. */
int ctime = (int)PIL_check_seconds_timer();
- if (ctime < shadercollectrate + lasttime)
+ if (ctime < shadercollectrate + lasttime) {
return;
+ }
lasttime = ctime;
diff --git a/source/blender/gpu/intern/gpu_context.cpp b/source/blender/gpu/intern/gpu_context.cpp
index 8e489fbac39..4bfc44327c2 100644
--- a/source/blender/gpu/intern/gpu_context.cpp
+++ b/source/blender/gpu/intern/gpu_context.cpp
@@ -49,7 +49,8 @@ extern "C" {
extern int BLI_thread_is_main(void); /* Blender-specific function */
}
-static bool thread_is_main() {
+static bool thread_is_main()
+{
/* "main" here means the GL context's thread */
return BLI_thread_is_main();
}
diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c
index d8eaab424a9..8293aae5dfa 100644
--- a/source/blender/gpu/intern/gpu_debug.c
+++ b/source/blender/gpu/intern/gpu_debug.c
@@ -258,6 +258,7 @@ void GPU_string_marker(const char *buf)
void GPU_print_error_debug(const char *str)
{
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
fprintf(stderr, "GPU: %s\n", str);
+ }
}
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index fec96b18dac..edc2f2171a5 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -98,8 +98,9 @@ static int smaller_power_of_2_limit(int num)
int reslimit = (U.glreslimit != 0) ? min_ii(U.glreslimit, GPU_max_texture_size()) :
GPU_max_texture_size();
/* take texture clamping into account */
- if (num > reslimit)
+ if (num > reslimit) {
return reslimit;
+ }
return power_of_2_min_i(num);
}
@@ -149,10 +150,12 @@ static GLenum gpu_get_mipmap_filter(bool mag)
/* linearmipmap is off by default *when mipmapping is off,
* use unfiltered display */
if (mag) {
- if (GTS.domipmap)
+ if (GTS.domipmap) {
return GL_LINEAR;
- else
+ }
+ else {
return GL_NEAREST;
+ }
}
else {
if (GTS.domipmap) {
@@ -177,8 +180,9 @@ void GPU_set_anisotropic(Main *bmain, float value)
/* Clamp value to the maximum value the graphics card supports */
const float max = GPU_max_texture_anisotropy();
- if (value > max)
+ if (value > max) {
value = max;
+ }
GTS.anisotropic = value;
}
@@ -193,10 +197,12 @@ float GPU_get_anisotropic(void)
static GPUTexture **gpu_get_image_gputexture(Image *ima, GLenum textarget)
{
- if (textarget == GL_TEXTURE_2D)
+ if (textarget == GL_TEXTURE_2D) {
return &ima->gputexture[TEXTARGET_TEXTURE_2D];
- else if (textarget == GL_TEXTURE_CUBE_MAP)
+ }
+ else if (textarget == GL_TEXTURE_CUBE_MAP) {
return &ima->gputexture[TEXTARGET_TEXTURE_CUBE_MAP];
+ }
return NULL;
}
@@ -324,15 +330,18 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget
/* mark as non-color data texture */
if (bindcode) {
- if (is_data)
+ if (is_data) {
ima->gpuflag |= IMA_GPU_IS_DATA;
- else
+ }
+ else {
ima->gpuflag &= ~IMA_GPU_IS_DATA;
+ }
}
/* clean up */
- if (srgb_frect)
+ if (srgb_frect) {
MEM_freeN(srgb_frect);
+ }
BKE_image_release_ibuf(ima, ibuf, NULL);
@@ -348,13 +357,15 @@ static void **gpu_gen_cube_map(
int h = recth / 2;
int w = rectw / 3;
- if ((use_high_bit_depth && frect == NULL) || (!use_high_bit_depth && rect == NULL) || w != h)
+ if ((use_high_bit_depth && frect == NULL) || (!use_high_bit_depth && rect == NULL) || w != h) {
return sides;
+ }
/* PosX, NegX, PosY, NegY, PosZ, NegZ */
sides = MEM_mallocN(sizeof(void *) * 6, "");
- for (int i = 0; i < 6; i++)
+ for (int i = 0; i < 6; i++) {
sides[i] = MEM_mallocN(block_size * w * h, "");
+ }
/* divide image into six parts */
/* ______________________
@@ -402,10 +413,12 @@ static void **gpu_gen_cube_map(
static void gpu_del_cube_map(void **cube_map)
{
int i;
- if (cube_map == NULL)
+ if (cube_map == NULL) {
return;
- for (i = 0; i < 6; i++)
+ }
+ for (i = 0; i < 6; i++) {
MEM_freeN(cube_map[i]);
+ }
MEM_freeN(cube_map);
}
@@ -459,8 +472,9 @@ void GPU_create_gl_tex(uint *bind,
if (GPU_get_mipmap() && mipmap) {
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
- if (ima)
+ if (ima) {
ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
+ }
}
else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -474,8 +488,8 @@ void GPU_create_gl_tex(uint *bind,
GLenum informat = use_high_bit_depth ? GL_RGBA16F : GL_RGBA8;
GLenum type = use_high_bit_depth ? GL_FLOAT : GL_UNSIGNED_BYTE;
- if (cube_map)
- for (int i = 0; i < 6; i++)
+ if (cube_map) {
+ for (int i = 0; i < 6; i++) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
0,
informat,
@@ -485,6 +499,8 @@ void GPU_create_gl_tex(uint *bind,
GL_RGBA,
type,
cube_map[i]);
+ }
+ }
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
@@ -492,8 +508,9 @@ void GPU_create_gl_tex(uint *bind,
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
- if (ima)
+ if (ima) {
ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
+ }
}
else {
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -509,13 +526,15 @@ void GPU_create_gl_tex(uint *bind,
}
}
- if (GLEW_EXT_texture_filter_anisotropic)
+ if (GLEW_EXT_texture_filter_anisotropic) {
glTexParameterf(textarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
+ }
glBindTexture(textarget, 0);
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
}
/**
@@ -533,12 +552,15 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf)
height = ibuf->y;
if (GLEW_EXT_texture_compression_s3tc) {
- if (ibuf->dds_data.fourcc == FOURCC_DXT1)
+ if (ibuf->dds_data.fourcc == FOURCC_DXT1) {
format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- else if (ibuf->dds_data.fourcc == FOURCC_DXT3)
+ }
+ else if (ibuf->dds_data.fourcc == FOURCC_DXT3) {
format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
- else if (ibuf->dds_data.fourcc == FOURCC_DXT5)
+ }
+ else if (ibuf->dds_data.fourcc == FOURCC_DXT5) {
format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
+ }
}
if (format == 0) {
@@ -556,15 +578,18 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
- if (GLEW_EXT_texture_filter_anisotropic)
+ if (GLEW_EXT_texture_filter_anisotropic) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
+ }
blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16;
for (i = 0; i < ibuf->dds_data.nummipmaps && (width || height); ++i) {
- if (width == 0)
+ if (width == 0) {
width = 1;
- if (height == 0)
+ }
+ if (height == 0) {
height = 1;
+ }
size = ((width + 3) / 4) * ((height + 3) / 4) * blocksize;
@@ -612,8 +637,9 @@ void GPU_create_gl_tex_compressed(
* re-uploaded to OpenGL */
void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
{
- if (!GTS.domipmap)
+ if (!GTS.domipmap) {
return;
+ }
GTS.texpaint = !mipmap;
@@ -628,11 +654,13 @@ void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
GPU_texture_unbind(ima->gputexture[TEXTARGET_TEXTURE_2D]);
}
}
- else
+ else {
GPU_free_image(ima);
+ }
}
- else
+ else {
ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
+ }
}
}
else {
@@ -645,8 +673,9 @@ void GPU_paint_set_mipmap(Main *bmain, bool mipmap)
GPU_texture_unbind(ima->gputexture[TEXTARGET_TEXTURE_2D]);
}
}
- else
+ else {
ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
+ }
}
}
}
@@ -672,10 +701,12 @@ static bool gpu_check_scaled_image(
y *= yratio;
/* ...but take back if we are over the limit! */
- if (rectw + x > x_limit)
+ if (rectw + x > x_limit) {
rectw--;
- if (recth + y > y_limit)
+ }
+ if (recth + y > y_limit) {
recth--;
+ }
GPU_texture_bind(ima->gputexture[TEXTARGET_TEXTURE_2D], 0);
@@ -1028,28 +1059,34 @@ static GPUTexture *create_flame_texture(SmokeDomainSettings *sds, int highres)
void GPU_free_smoke(SmokeModifierData *smd)
{
if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
- if (smd->domain->tex)
+ if (smd->domain->tex) {
GPU_texture_free(smd->domain->tex);
+ }
smd->domain->tex = NULL;
- if (smd->domain->tex_shadow)
+ if (smd->domain->tex_shadow) {
GPU_texture_free(smd->domain->tex_shadow);
+ }
smd->domain->tex_shadow = NULL;
- if (smd->domain->tex_flame)
+ if (smd->domain->tex_flame) {
GPU_texture_free(smd->domain->tex_flame);
+ }
smd->domain->tex_flame = NULL;
- if (smd->domain->tex_flame_coba)
+ if (smd->domain->tex_flame_coba) {
GPU_texture_free(smd->domain->tex_flame_coba);
+ }
smd->domain->tex_flame_coba = NULL;
- if (smd->domain->tex_coba)
+ if (smd->domain->tex_coba) {
GPU_texture_free(smd->domain->tex_coba);
+ }
smd->domain->tex_coba = NULL;
- if (smd->domain->tex_field)
+ if (smd->domain->tex_field) {
GPU_texture_free(smd->domain->tex_field);
+ }
smd->domain->tex_field = NULL;
}
}
@@ -1143,14 +1180,17 @@ void GPU_create_smoke_velocity(SmokeModifierData *smd)
void GPU_free_smoke_velocity(SmokeModifierData *smd)
{
if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
- if (smd->domain->tex_velocity_x)
+ if (smd->domain->tex_velocity_x) {
GPU_texture_free(smd->domain->tex_velocity_x);
+ }
- if (smd->domain->tex_velocity_y)
+ if (smd->domain->tex_velocity_y) {
GPU_texture_free(smd->domain->tex_velocity_y);
+ }
- if (smd->domain->tex_velocity_z)
+ if (smd->domain->tex_velocity_z) {
GPU_texture_free(smd->domain->tex_velocity_z);
+ }
smd->domain->tex_velocity_x = NULL;
smd->domain->tex_velocity_y = NULL;
@@ -1159,34 +1199,37 @@ void GPU_free_smoke_velocity(SmokeModifierData *smd)
}
static LinkNode *image_free_queue = NULL;
+static ThreadMutex img_queue_mutex = BLI_MUTEX_INITIALIZER;
static void gpu_queue_image_for_free(Image *ima)
{
- BLI_thread_lock(LOCK_OPENGL);
+ BLI_mutex_lock(&img_queue_mutex);
BLI_linklist_prepend(&image_free_queue, ima);
- BLI_thread_unlock(LOCK_OPENGL);
+ BLI_mutex_unlock(&img_queue_mutex);
}
void GPU_free_unused_buffers(Main *bmain)
{
- if (!BLI_thread_is_main())
+ if (!BLI_thread_is_main()) {
return;
+ }
- BLI_thread_lock(LOCK_OPENGL);
+ BLI_mutex_lock(&img_queue_mutex);
/* images */
for (LinkNode *node = image_free_queue; node; node = node->next) {
Image *ima = node->link;
/* check in case it was freed in the meantime */
- if (bmain && BLI_findindex(&bmain->images, ima) != -1)
+ if (bmain && BLI_findindex(&bmain->images, ima) != -1) {
GPU_free_image(ima);
+ }
}
BLI_linklist_free(image_free_queue, NULL);
image_free_queue = NULL;
- BLI_thread_unlock(LOCK_OPENGL);
+ BLI_mutex_unlock(&img_queue_mutex);
}
static void gpu_free_image_immediate(Image *ima)
@@ -1242,12 +1285,14 @@ void GPU_free_images_old(Main *bmain)
* Run garbage collector once for every collecting period of time
* if textimeout is 0, that's the option to NOT run the collector
*/
- if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime)
+ if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime) {
return;
+ }
/* of course not! */
- if (G.is_rendering)
+ if (G.is_rendering) {
return;
+ }
lasttime = ctime;
@@ -1280,8 +1325,9 @@ static void gpu_disable_multisample(void)
int samples = 0;
glGetIntegerv(GL_SAMPLES, &samples);
- if (samples == 0)
+ if (samples == 0) {
toggle_ok = false;
+ }
}
if (toggle_ok) {
diff --git a/source/blender/gpu/intern/gpu_element.c b/source/blender/gpu/intern/gpu_element.c
index 9fcc9821227..0b7f37af522 100644
--- a/source/blender/gpu/intern/gpu_element.c
+++ b/source/blender/gpu/intern/gpu_element.c
@@ -180,12 +180,15 @@ static uint index_range(const uint values[], uint value_len, uint *min_out, uint
uint max_value = values[0];
for (uint i = 1; i < value_len; ++i) {
const uint value = values[i];
- if (value == GPU_PRIM_RESTART)
+ if (value == GPU_PRIM_RESTART) {
continue;
- else if (value < min_value)
+ }
+ else if (value < min_value) {
min_value = value;
- else if (value > max_value)
+ }
+ else if (value > max_value) {
max_value = value;
+ }
}
*min_out = min_value;
*max_out = max_value;
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 860a64a1297..57734686b23 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -232,10 +232,12 @@ void gpu_extensions_init(void)
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &GG.maxtexlayers);
glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &GG.maxcubemapsize);
- if (GLEW_EXT_texture_filter_anisotropic)
+ if (GLEW_EXT_texture_filter_anisotropic) {
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &GG.max_anisotropy);
- else
+ }
+ else {
GG.max_anisotropy = 1.0f;
+ }
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &GG.maxubobinds);
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &GG.maxubosize);
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index bd4572cc643..62fb02931ab 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -112,10 +112,12 @@ static GLenum convert_buffer_bits_to_gl(eGPUFrameBufferBits bits)
static GPUTexture *framebuffer_get_depth_tex(GPUFrameBuffer *fb)
{
- if (fb->attachments[GPU_FB_DEPTH_ATTACHMENT].tex)
+ if (fb->attachments[GPU_FB_DEPTH_ATTACHMENT].tex) {
return fb->attachments[GPU_FB_DEPTH_ATTACHMENT].tex;
- else
+ }
+ else {
return fb->attachments[GPU_FB_DEPTH_STENCIL_ATTACHMENT].tex;
+ }
}
static GPUTexture *framebuffer_get_color_tex(GPUFrameBuffer *fb, int slot)
@@ -140,7 +142,7 @@ static void gpu_print_framebuffer_error(GLenum status, char err_out[256])
format_status(INCOMPLETE_ATTACHMENT) format_status(INCOMPLETE_MISSING_ATTACHMENT)
format_status(UNSUPPORTED)
#if 0 /* for OpenGL ES only */
- format_status(INCOMPLETE_DIMENSIONS)
+ format_status(INCOMPLETE_DIMENSIONS)
#else /* for desktop GL only */
format_status(INCOMPLETE_DRAW_BUFFER) format_status(INCOMPLETE_READ_BUFFER)
format_status(INCOMPLETE_MULTISAMPLE) format_status(UNDEFINED)
@@ -409,10 +411,12 @@ static void gpu_framebuffer_update_attachments(GPUFrameBuffer *fb)
/* Update draw buffers (color targets)
* This state is saved in the FBO */
- if (numslots)
+ if (numslots) {
glDrawBuffers(numslots, gl_attachments);
- else
+ }
+ else {
glDrawBuffer(GL_NONE);
+ }
}
/**
@@ -497,11 +501,13 @@ static GPUFrameBuffer *gpuPopFrameBuffer(void)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
{
- if (fb->object == 0)
+ if (fb->object == 0) {
gpu_framebuffer_init(fb);
+ }
- if (GPU_framebuffer_active_get() != fb)
+ if (GPU_framebuffer_active_get() != fb) {
glBindFramebuffer(GL_FRAMEBUFFER, fb->object);
+ }
gpu_framebuffer_current_set(fb);
@@ -523,8 +529,9 @@ void GPU_framebuffer_bind(GPUFrameBuffer *fb)
}
#endif
- if (fb->multisample)
+ if (fb->multisample) {
glEnable(GL_MULTISAMPLE);
+ }
glViewport(0, 0, fb->width, fb->height);
}
@@ -544,8 +551,9 @@ bool GPU_framebuffer_bound(GPUFrameBuffer *fb)
bool GPU_framebuffer_check_valid(GPUFrameBuffer *fb, char err_out[256])
{
- if (!GPU_framebuffer_bound(fb))
+ if (!GPU_framebuffer_bound(fb)) {
GPU_framebuffer_bind(fb);
+ }
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
@@ -562,7 +570,8 @@ bool GPU_framebuffer_check_valid(GPUFrameBuffer *fb, char err_out[256])
#define CHECK_FRAMEBUFFER_IS_BOUND(_fb) \
BLI_assert(GPU_framebuffer_bound(_fb)); \
- UNUSED_VARS_NDEBUG(_fb);
+ UNUSED_VARS_NDEBUG(_fb); \
+ ((void)0)
/* Needs to be done after binding. */
void GPU_framebuffer_viewport_set(GPUFrameBuffer *fb, int x, int y, int w, int h)
@@ -716,7 +725,8 @@ void GPU_framebuffer_blit(GPUFrameBuffer *fb_read,
/**
* Use this if you need to custom downsample your texture and use the previous mip level as input.
- * This function only takes care of the correct texture handling. It execute the callback for each texture level.
+ * This function only takes care of the correct texture handling.
+ * It execute the callback for each texture level.
*/
void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *fb,
int max_lvl,
@@ -766,8 +776,9 @@ void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *fb,
glViewport(0, 0, current_dim[0], current_dim[1]);
callback(userData, i);
- if (current_dim[0] == 1 && current_dim[1] == 1)
+ if (current_dim[0] == 1 && current_dim[1] == 1) {
break;
+ }
}
for (GPUAttachmentType type = 0; type < GPU_FB_MAX_ATTACHEMENT; ++type) {
@@ -842,12 +853,15 @@ GPUOffScreen *GPU_offscreen_create(
void GPU_offscreen_free(GPUOffScreen *ofs)
{
- if (ofs->fb)
+ if (ofs->fb) {
GPU_framebuffer_free(ofs->fb);
- if (ofs->color)
+ }
+ if (ofs->color) {
GPU_texture_free(ofs->color);
- if (ofs->depth)
+ }
+ if (ofs->depth) {
GPU_texture_free(ofs->depth);
+ }
MEM_freeN(ofs);
}
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index a1708fffa9c..2fa7ee5fb32 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -141,8 +141,9 @@ void immBindProgram(GLuint program, const GPUShaderInterface *shaderface)
imm.bound_program = program;
imm.shader_interface = shaderface;
- if (!imm.vertex_format.packed)
+ if (!imm.vertex_format.packed) {
VertexFormat_pack(&imm.vertex_format);
+ }
glUseProgram(program);
get_attr_locations(&imm.vertex_format, &imm.attr_binding, shaderface);
@@ -634,7 +635,9 @@ static void immEndVertex(void) /* and move on to the next vertex */
if ((imm.unassigned_attr_bits >> a_idx) & 1) {
const GPUVertAttr *a = &imm.vertex_format.attrs[a_idx];
- /* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */
+#if 0
+ printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx);
+#endif
GLubyte *data = imm.vertex_data + a->offset;
memcpy(data, data - imm.vertex_format.stride, a->sz);
@@ -711,9 +714,9 @@ void immVertex2iv(uint attr_id, const int data[2])
# endif
#else
/* NOTE: It is possible to have uniform fully optimized out from the shader.
- * In this case we can't assert failure or allow NULL-pointer dereference.
- * TODO(sergey): How can we detect existing-but-optimized-out uniform but still
- * catch typos in uniform names passed to immUniform*() functions? */
+ * In this case we can't assert failure or allow NULL-pointer dereference.
+ * TODO(sergey): How can we detect existing-but-optimized-out uniform but still
+ * catch typos in uniform names passed to immUniform*() functions? */
# define GET_UNIFORM \
const GPUShaderInput *uniform = GPU_shaderinterface_uniform_ensure(imm.shader_interface, \
name); \
diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c
index 310320673d0..322ac3be8e2 100644
--- a/source/blender/gpu/intern/gpu_init_exit.c
+++ b/source/blender/gpu/intern/gpu_init_exit.c
@@ -42,8 +42,9 @@ static bool initialized = false;
void GPU_init(void)
{
/* can't avoid calling this multiple times, see wm_window_ghostwindow_add */
- if (initialized)
+ if (initialized) {
return;
+ }
initialized = true;
@@ -52,8 +53,9 @@ void GPU_init(void)
gpu_codegen_init();
gpu_framebuffer_module_init();
- if (G.debug & G_DEBUG_GPU)
+ if (G.debug & G_DEBUG_GPU) {
gpu_debug_init();
+ }
gpu_batch_init();
@@ -72,8 +74,9 @@ void GPU_exit(void)
gpu_batch_exit();
- if (G.debug & G_DEBUG_GPU)
+ if (G.debug & G_DEBUG_GPU) {
gpu_debug_exit();
+ }
gpu_framebuffer_module_exit();
gpu_codegen_exit();
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index cae60351bd5..1a668a48eed 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -163,8 +163,9 @@ GPUTexture **gpu_material_ramp_texture_row_set(GPUMaterial *mat,
static void gpu_material_ramp_texture_build(GPUMaterial *mat)
{
- if (mat->coba_builder == NULL)
+ if (mat->coba_builder == NULL) {
return;
+ }
GPUColorBandBuilder *builder = mat->coba_builder;
@@ -523,8 +524,9 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material,
int sample_len,
GPUTexture **tex_profile)
{
- if (!material->sss_enabled)
+ if (!material->sss_enabled) {
return NULL;
+ }
if (material->sss_dirty || (material->sss_samples != sample_len)) {
GPUSssKernelData kd;
@@ -577,8 +579,9 @@ void GPU_material_vertex_attrs(GPUMaterial *material, GPUVertAttrLayers *r_attrs
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link)
{
- if (!material->outlink)
+ if (!material->outlink) {
material->outlink = link;
+ }
}
void gpu_material_add_node(GPUMaterial *material, GPUNode *node)
@@ -596,8 +599,9 @@ eGPUMaterialStatus GPU_material_status(GPUMaterial *mat)
bool GPU_material_do_color_management(GPUMaterial *mat)
{
- if (!BKE_scene_check_color_management_enabled(mat->scene))
+ if (!BKE_scene_check_color_management_enabled(mat->scene)) {
return false;
+ }
return true;
}
@@ -768,11 +772,13 @@ void GPU_materials_free(Main *bmain)
World *wo;
extern Material defmaterial;
- for (ma = bmain->materials.first; ma; ma = ma->id.next)
+ for (ma = bmain->materials.first; ma; ma = ma->id.next) {
GPU_material_free(&ma->gpumaterial);
+ }
- for (wo = bmain->worlds.first; wo; wo = wo->id.next)
+ for (wo = bmain->worlds.first; wo; wo = wo->id.next) {
GPU_material_free(&wo->gpumaterial);
+ }
GPU_material_free(&defmaterial.gpumaterial);
}
diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c
index 667ee7f6e47..5d65861c1e2 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.c
@@ -330,36 +330,35 @@ static void mat4_frustum_set(
static void mat4_look_from_origin(float m[4][4], float lookdir[3], float camup[3])
{
/* This function is loosely based on Mesa implementation.
- *
- * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
- * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice including the dates of first publication and
- * either this permission notice or a reference to
- * http://oss.sgi.com/projects/FreeB/
- * shall be included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of Silicon Graphics, Inc.
- * shall not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization from
- * Silicon Graphics, Inc.
- */
-
+ *
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * shall be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
float side[3];
normalize_v3(lookdir);
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c
index 4cfedc0708b..010087e5536 100644
--- a/source/blender/gpu/intern/gpu_select.c
+++ b/source/blender/gpu/intern/gpu_select.c
@@ -69,7 +69,8 @@ static GPUSelectState g_select_state = {0};
void GPU_select_begin(uint *buffer, uint bufsize, const rcti *input, char mode, int oldhits)
{
if (mode == GPU_SELECT_NEAREST_SECOND_PASS) {
- /* In the case hits was '-1', don't start the second pass since it's not going to give useful results.
+ /* In the case hits was '-1',
+ * don't start the second pass since it's not going to give useful results.
* As well as buffer overflow in 'gpu_select_query_load_id'. */
BLI_assert(oldhits != -1);
}
@@ -99,7 +100,8 @@ void GPU_select_begin(uint *buffer, uint bufsize, const rcti *input, char mode,
}
/**
- * loads a new selection id and ends previous query, if any. In second pass of selection it also returns
+ * loads a new selection id and ends previous query, if any.
+ * In second pass of selection it also returns
* if id has been hit on the first pass already.
* Thus we can skip drawing un-hit objects.
*
@@ -108,8 +110,9 @@ void GPU_select_begin(uint *buffer, uint bufsize, const rcti *input, char mode,
bool GPU_select_load_id(uint id)
{
/* if no selection mode active, ignore */
- if (!g_select_state.select_is_active)
+ if (!g_select_state.select_is_active) {
return true;
+ }
switch (g_select_state.algorithm) {
case ALGO_GL_QUERY: {
@@ -117,7 +120,7 @@ bool GPU_select_load_id(uint id)
}
default: /* ALGO_GL_PICK */
{
- return gpu_select_pick_load_id(id);
+ return gpu_select_pick_load_id(id, false);
}
}
}
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 46e450d455e..939279d82ff 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -318,7 +318,8 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c
if (mode == GPU_SELECT_PICK_ALL) {
/* Note that other depth settings (such as #GL_LEQUAL) work too,
* since the depth is always cleared.
- * Noting this for cases when depth picking is used where drawing calls change depth settings. */
+ * Noting this for cases when depth picking is used where
+ * drawing calls change depth settings. */
glDepthFunc(GL_ALWAYS);
}
else {
@@ -348,7 +349,10 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c
/* set initial 'far' value */
#if 0
- glReadPixels(UNPACK4(ps->gl.clip_readpixels), GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, ps->gl.rect_depth->buf);
+ glReadPixels(UNPACK4(ps->gl.clip_readpixels),
+ GL_DEPTH_COMPONENT,
+ GL_UNSIGNED_INT,
+ ps->gl.rect_depth->buf);
#else
for (uint i = 0; i < rect_len; i++) {
ps->gl.rect_depth->buf[i] = DEPTH_MAX;
@@ -472,10 +476,17 @@ static void gpu_select_load_id_pass_nearest(const DepthBufCache *rect_prev,
}
}
-bool gpu_select_pick_load_id(uint id)
+bool gpu_select_pick_load_id(uint id, bool end)
{
GPUPickState *ps = &g_pick_state;
+
if (ps->gl.is_init) {
+ if (id == ps->gl.prev_id && !end) {
+ /* No need to read if we are still drawing for the same id since
+ * all these depths will be merged / de-duplicated in the end. */
+ return true;
+ }
+
const uint rect_len = ps->src.rect_len;
glReadPixels(UNPACK4(ps->gl.clip_readpixels),
GL_DEPTH_COMPONENT,
@@ -532,7 +543,7 @@ uint gpu_select_pick_end(void)
if (ps->is_cached == false) {
if (ps->gl.is_init) {
/* force finishing last pass */
- gpu_select_pick_load_id(ps->gl.prev_id);
+ gpu_select_pick_load_id(ps->gl.prev_id, true);
}
gpuPopAttr();
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
diff --git a/source/blender/gpu/intern/gpu_select_private.h b/source/blender/gpu/intern/gpu_select_private.h
index bc40e58ba96..a0619bd4293 100644
--- a/source/blender/gpu/intern/gpu_select_private.h
+++ b/source/blender/gpu/intern/gpu_select_private.h
@@ -28,7 +28,7 @@
/* gpu_select_pick */
void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, char mode);
-bool gpu_select_pick_load_id(uint id);
+bool gpu_select_pick_load_id(uint id, bool end);
uint gpu_select_pick_end(void);
void gpu_select_pick_cache_begin(void);
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index dd8035e2618..3d5b0dda5e4 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -266,20 +266,26 @@ static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH])
static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH])
{
/* some useful defines to detect GPU type */
- if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY))
+ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
strcat(defines, "#define GPU_ATI\n");
- else if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY))
+ }
+ else if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY)) {
strcat(defines, "#define GPU_NVIDIA\n");
- else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY))
+ }
+ else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) {
strcat(defines, "#define GPU_INTEL\n");
+ }
/* some useful defines to detect OS type */
- if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_WIN, GPU_DRIVER_ANY))
+ if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_WIN, GPU_DRIVER_ANY)) {
strcat(defines, "#define OS_WIN\n");
- else if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY))
+ }
+ else if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY)) {
strcat(defines, "#define OS_MAC\n");
- else if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_UNIX, GPU_DRIVER_ANY))
+ }
+ else if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_UNIX, GPU_DRIVER_ANY)) {
strcat(defines, "#define OS_UNIX\n");
+ }
return;
}
@@ -371,12 +377,15 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
/* At least a vertex shader and a fragment shader are required. */
BLI_assert((fragcode != NULL) && (vertexcode != NULL));
- if (vertexcode)
+ if (vertexcode) {
shader->vertex = glCreateShader(GL_VERTEX_SHADER);
- if (fragcode)
+ }
+ if (fragcode) {
shader->fragment = glCreateShader(GL_FRAGMENT_SHADER);
- if (geocode)
+ }
+ if (geocode) {
shader->geometry = glCreateShader(GL_GEOMETRY_SHADER);
+ }
shader->program = glCreateProgram();
@@ -400,8 +409,9 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
source[num_source++] = standard_extensions;
source[num_source++] = standard_defines;
- if (defines)
+ if (defines) {
source[num_source++] = defines;
+ }
source[num_source++] = vertexcode;
gpu_dump_shaders(source, num_source, DEBUG_SHADER_VERTEX);
@@ -430,10 +440,12 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
source[num_source++] = standard_extensions;
source[num_source++] = standard_defines;
- if (defines)
+ if (defines) {
source[num_source++] = defines;
- if (libcode)
+ }
+ if (libcode) {
source[num_source++] = libcode;
+ }
source[num_source++] = fragcode;
gpu_dump_shaders(source, num_source, DEBUG_SHADER_FRAGMENT);
@@ -462,8 +474,9 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
source[num_source++] = standard_extensions;
source[num_source++] = standard_defines;
- if (defines)
+ if (defines) {
source[num_source++] = defines;
+ }
source[num_source++] = geocode;
gpu_dump_shaders(source, num_source, DEBUG_SHADER_GEOMETRY);
@@ -495,14 +508,18 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
if (!status) {
glGetProgramInfoLog(shader->program, sizeof(log), &length, log);
/* print attached shaders in pipeline order */
- if (vertexcode)
+ if (vertexcode) {
shader_print_errors("linking", log, &vertexcode, 1);
- if (geocode)
+ }
+ if (geocode) {
shader_print_errors("linking", log, &geocode, 1);
- if (libcode)
+ }
+ if (libcode) {
shader_print_errors("linking", log, &libcode, 1);
- if (fragcode)
+ }
+ if (fragcode) {
shader_print_errors("linking", log, &fragcode, 1);
+ }
GPU_shader_free(shader);
return NULL;
@@ -557,10 +574,10 @@ static const char *string_join_array_maybe_alloc(const char **str_arr, bool *r_i
* Example:
* \code{.c}
* sh = GPU_shader_create_from_arrays({
- * .vert = (const char *[]){shader_lib_glsl, shader_vert_glsl, NULL},
- * .geom = (const char *[]){shader_geom_glsl, NULL},
- * .frag = (const char *[]){shader_frag_glsl, NULL},
- * .defs = (const char *[]){"#define DEFINE\n", test ? "#define OTHER_DEFINE\n" : "", NULL},
+ * .vert = (const char *[]){shader_lib_glsl, shader_vert_glsl, NULL},
+ * .geom = (const char *[]){shader_geom_glsl, NULL},
+ * .frag = (const char *[]){shader_frag_glsl, NULL},
+ * .defs = (const char *[]){"#define DEFINE\n", test ? "#define OTHER_DEFINE\n" : "", NULL},
* });
* \endcode
*/
@@ -631,23 +648,28 @@ void GPU_shader_transform_feedback_disable(GPUShader *UNUSED(shader))
void GPU_shader_free(GPUShader *shader)
{
-#if 0 /* Would be nice to have, but for now the Deferred compilation
+#if 0 /* Would be nice to have, but for now the Deferred compilation \
* does not have a GPUContext. */
BLI_assert(GPU_context_active_get() != NULL);
#endif
BLI_assert(shader);
- if (shader->vertex)
+ if (shader->vertex) {
glDeleteShader(shader->vertex);
- if (shader->geometry)
+ }
+ if (shader->geometry) {
glDeleteShader(shader->geometry);
- if (shader->fragment)
+ }
+ if (shader->fragment) {
glDeleteShader(shader->fragment);
- if (shader->program)
+ }
+ if (shader->program) {
glDeleteProgram(shader->program);
+ }
- if (shader->interface)
+ if (shader->interface) {
GPU_shaderinterface_discard(shader->interface);
+ }
MEM_freeN(shader);
}
@@ -693,8 +715,9 @@ int GPU_shader_get_program(GPUShader *shader)
void GPU_shader_uniform_float(GPUShader *UNUSED(shader), int location, float value)
{
- if (location == -1)
+ if (location == -1) {
return;
+ }
glUniform1f(location, value);
}
@@ -702,43 +725,56 @@ void GPU_shader_uniform_float(GPUShader *UNUSED(shader), int location, float val
void GPU_shader_uniform_vector(
GPUShader *UNUSED(shader), int location, int length, int arraysize, const float *value)
{
- if (location == -1 || value == NULL)
+ if (location == -1 || value == NULL) {
return;
+ }
- if (length == 1)
+ if (length == 1) {
glUniform1fv(location, arraysize, value);
- else if (length == 2)
+ }
+ else if (length == 2) {
glUniform2fv(location, arraysize, value);
- else if (length == 3)
+ }
+ else if (length == 3) {
glUniform3fv(location, arraysize, value);
- else if (length == 4)
+ }
+ else if (length == 4) {
glUniform4fv(location, arraysize, value);
- else if (length == 9)
+ }
+ else if (length == 9) {
glUniformMatrix3fv(location, arraysize, 0, value);
- else if (length == 16)
+ }
+ else if (length == 16) {
glUniformMatrix4fv(location, arraysize, 0, value);
+ }
}
void GPU_shader_uniform_vector_int(
GPUShader *UNUSED(shader), int location, int length, int arraysize, const int *value)
{
- if (location == -1)
+ if (location == -1) {
return;
+ }
- if (length == 1)
+ if (length == 1) {
glUniform1iv(location, arraysize, value);
- else if (length == 2)
+ }
+ else if (length == 2) {
glUniform2iv(location, arraysize, value);
- else if (length == 3)
+ }
+ else if (length == 3) {
glUniform3iv(location, arraysize, value);
- else if (length == 4)
+ }
+ else if (length == 4) {
glUniform4iv(location, arraysize, value);
+ }
}
void GPU_shader_uniform_int(GPUShader *UNUSED(shader), int location, int value)
{
- if (location == -1)
+ if (location == -1) {
return;
+ }
glUniform1i(location, value);
}
@@ -764,8 +800,9 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText
return;
}
- if (location == -1)
+ if (location == -1) {
return;
+ }
glUniform1i(location, number);
}
@@ -1297,7 +1334,8 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader,
}
}
else if (shader == GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR) {
- /* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */
+ /* Dashed need geometry shader, which are not supported by legacy OpenGL,
+ * fallback to solid lines. */
/* TODO: remove after switch to core profile (maybe) */
if (!GLEW_VERSION_3_2) {
stages_legacy.vert = datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl;
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index afe5e381334..61f86e70898 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -43,8 +43,8 @@
#include "gpu_context_private.h"
static struct GPUTextureGlobal {
- GPUTexture *
- invalid_tex_1D; /* texture used in place of invalid textures (not loaded correctly, missing) */
+ /** Texture used in place of invalid textures (not loaded correctly, missing). */
+ GPUTexture *invalid_tex_1D;
GPUTexture *invalid_tex_2D;
GPUTexture *invalid_tex_3D;
} GG = {NULL, NULL, NULL};
@@ -490,8 +490,9 @@ static float *GPU_texture_rescale_3d(
nfpixels[offset * 4 + 2] = fpixels[offset_orig * 4 + 2];
nfpixels[offset * 4 + 3] = fpixels[offset_orig * 4 + 3];
}
- else
+ else {
nfpixels[offset] = fpixels[offset_orig];
+ }
}
}
}
@@ -511,32 +512,37 @@ static bool gpu_texture_check_capacity(
* So manually check the maximum size and maximum number of layers. */
switch (proxy) {
case GL_PROXY_TEXTURE_2D_ARRAY:
- if ((tex->d < 0) || (tex->d > GPU_max_texture_layers()))
+ if ((tex->d < 0) || (tex->d > GPU_max_texture_layers())) {
return false;
+ }
break;
case GL_PROXY_TEXTURE_1D_ARRAY:
- if ((tex->h < 0) || (tex->h > GPU_max_texture_layers()))
+ if ((tex->h < 0) || (tex->h > GPU_max_texture_layers())) {
return false;
+ }
break;
}
switch (proxy) {
case GL_PROXY_TEXTURE_3D:
- if ((tex->d < 0) || (tex->d > GPU_max_texture_size()))
+ if ((tex->d < 0) || (tex->d > GPU_max_texture_size())) {
return false;
+ }
ATTR_FALLTHROUGH;
case GL_PROXY_TEXTURE_2D:
case GL_PROXY_TEXTURE_2D_ARRAY:
- if ((tex->h < 0) || (tex->h > GPU_max_texture_size()))
+ if ((tex->h < 0) || (tex->h > GPU_max_texture_size())) {
return false;
+ }
ATTR_FALLTHROUGH;
case GL_PROXY_TEXTURE_1D:
case GL_PROXY_TEXTURE_1D_ARRAY:
- if ((tex->w < 0) || (tex->w > GPU_max_texture_size()))
+ if ((tex->w < 0) || (tex->w > GPU_max_texture_size())) {
return false;
+ }
ATTR_FALLTHROUGH;
}
@@ -592,12 +598,15 @@ static bool gpu_texture_try_alloc(GPUTexture *tex,
tex->d /= 2;
/* really unlikely to happen but keep this just in case */
- if (tex->w == 0)
+ if (tex->w == 0) {
break;
- if (tex->h == 0 && proxy != GL_PROXY_TEXTURE_1D)
+ }
+ if (tex->h == 0 && proxy != GL_PROXY_TEXTURE_1D) {
break;
- if (tex->d == 0 && proxy == GL_PROXY_TEXTURE_3D)
+ }
+ if (tex->d == 0 && proxy == GL_PROXY_TEXTURE_3D) {
break;
+ }
ret = gpu_texture_check_capacity(tex, proxy, internalformat, data_format, data_type);
} while (ret == false);
@@ -654,16 +663,20 @@ GPUTexture *GPU_texture_create_nD(int w,
tex->format_flag = 0;
if (n == 2) {
- if (d == 0)
+ if (d == 0) {
tex->target_base = tex->target = GL_TEXTURE_2D;
- else
+ }
+ else {
tex->target_base = tex->target = GL_TEXTURE_2D_ARRAY;
+ }
}
else if (n == 1) {
- if (h == 0)
+ if (h == 0) {
tex->target_base = tex->target = GL_TEXTURE_1D;
- else
+ }
+ else {
tex->target_base = tex->target = GL_TEXTURE_1D_ARRAY;
+ }
}
else if (n == 3) {
tex->target_base = tex->target = GL_TEXTURE_3D;
@@ -676,8 +689,9 @@ GPUTexture *GPU_texture_create_nD(int w,
gpu_validate_data_format(tex_format, gpu_data_format);
- if (samples && n == 2 && d == 0)
+ if (samples && n == 2 && d == 0) {
tex->target = GL_TEXTURE_2D_MULTISAMPLE;
+ }
GLenum internalformat = gpu_get_gl_internalformat(tex_format);
GLenum data_format = gpu_get_gl_dataformat(tex_format, &tex->format_flag);
@@ -703,14 +717,17 @@ GPUTexture *GPU_texture_create_nD(int w,
GLenum proxy = GL_PROXY_TEXTURE_2D;
if (n == 2) {
- if (d > 1)
+ if (d > 1) {
proxy = GL_PROXY_TEXTURE_2D_ARRAY;
+ }
}
else if (n == 1) {
- if (h == 0)
+ if (h == 0) {
proxy = GL_PROXY_TEXTURE_1D;
- else
+ }
+ else {
proxy = GL_PROXY_TEXTURE_1D_ARRAY;
+ }
}
else if (n == 3) {
proxy = GL_PROXY_TEXTURE_3D;
@@ -761,8 +778,9 @@ GPUTexture *GPU_texture_create_nD(int w,
tex->target == GL_TEXTURE_1D_ARRAY) {
if (samples) {
glTexImage2DMultisample(tex->target, samples, internalformat, tex->w, tex->h, true);
- if (pix)
+ if (pix) {
glTexSubImage2D(tex->target, 0, 0, 0, tex->w, tex->h, data_format, data_type, pix);
+ }
}
else {
glTexImage2D(tex->target, 0, internalformat, tex->w, tex->h, 0, data_format, data_type, pix);
@@ -776,8 +794,9 @@ GPUTexture *GPU_texture_create_nD(int w,
tex->target, 0, internalformat, tex->w, tex->h, tex->d, 0, data_format, data_type, pix);
}
- if (rescaled_pixels)
+ if (rescaled_pixels) {
MEM_freeN(rescaled_pixels);
+ }
/* Texture Parameters */
if (GPU_texture_stencil(tex) || /* Does not support filtering */
@@ -978,7 +997,8 @@ GPUTexture *GPU_texture_create_buffer(eGPUTextureFormat tex_format, const GLuint
ELEM(tex_format, GPU_RG16F, GPU_RG32F) ||
ELEM(tex_format, GPU_RG8I, GPU_RG16I, GPU_RG32I) ||
ELEM(tex_format, GPU_RG8UI, GPU_RG16UI, GPU_RG32UI) ||
- //ELEM(tex_format, GPU_RGB32F, GPU_RGB32I, GPU_RGB32UI) || /* Not available until gl 4.0 */
+ /* Not available until gl 4.0 */
+ // ELEM(tex_format, GPU_RGB32F, GPU_RGB32I, GPU_RGB32UI) ||
ELEM(tex_format, GPU_RGBA8, GPU_RGBA16) || ELEM(tex_format, GPU_RGBA16F, GPU_RGBA32F) ||
ELEM(tex_format, GPU_RGBA8I, GPU_RGBA16I, GPU_RGBA32I) ||
ELEM(tex_format, GPU_RGBA8UI, GPU_RGBA16UI, GPU_RGBA32UI))) {
@@ -1029,10 +1049,12 @@ GPUTexture *GPU_texture_from_bindcode(int textarget, int bindcode)
GLenum gettarget;
- if (textarget == GL_TEXTURE_2D)
+ if (textarget == GL_TEXTURE_2D) {
gettarget = GL_TEXTURE_2D;
- else
+ }
+ else {
gettarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ }
glBindTexture(textarget, tex->bindcode);
glGetTexLevelParameteriv(gettarget, 0, GL_TEXTURE_WIDTH, &w);
@@ -1050,8 +1072,9 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap)
GPUTexture *tex = prv->gputexture[0];
GLuint bindcode = 0;
- if (tex)
+ if (tex) {
bindcode = tex->bindcode;
+ }
/* this binds a texture, so that's why we restore it to 0 */
if (bindcode == 0) {
@@ -1524,12 +1547,15 @@ void GPU_invalid_tex_bind(int mode)
void GPU_invalid_tex_free(void)
{
- if (GG.invalid_tex_1D)
+ if (GG.invalid_tex_1D) {
GPU_texture_free(GG.invalid_tex_1D);
- if (GG.invalid_tex_2D)
+ }
+ if (GG.invalid_tex_2D) {
GPU_texture_free(GG.invalid_tex_2D);
- if (GG.invalid_tex_3D)
+ }
+ if (GG.invalid_tex_3D) {
GPU_texture_free(GG.invalid_tex_3D);
+ }
}
void GPU_texture_bind(GPUTexture *tex, int number)
@@ -1555,18 +1581,21 @@ void GPU_texture_bind(GPUTexture *tex, int number)
glActiveTexture(GL_TEXTURE0 + number);
- if (tex->bindcode != 0)
+ if (tex->bindcode != 0) {
glBindTexture(tex->target, tex->bindcode);
- else
+ }
+ else {
GPU_invalid_tex_bind(tex->target_base);
+ }
tex->number = number;
}
void GPU_texture_unbind(GPUTexture *tex)
{
- if (tex->number == -1)
+ if (tex->number == -1) {
return;
+ }
glActiveTexture(GL_TEXTURE0 + tex->number);
glBindTexture(tex->target, 0);
@@ -1598,7 +1627,8 @@ void GPU_texture_generate_mipmap(GPUTexture *tex)
if (GPU_texture_depth(tex)) {
/* Some drivers have bugs when using glGenerateMipmap with depth textures (see T56789).
* In this case we just create a complete texture with mipmaps manually without downsampling.
- * You must initialize the texture levels using other methods like GPU_framebuffer_recursive_downsample(). */
+ * You must initialize the texture levels using other methods like
+ * GPU_framebuffer_recursive_downsample(). */
int levels = 1 + floor(log2(max_ii(tex->w, tex->h)));
eGPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex->format);
for (int i = 1; i < levels; ++i) {
@@ -1616,8 +1646,9 @@ void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare)
WARN_NOT_BOUND(tex);
/* Could become an assertion ? (fclem) */
- if (!GPU_texture_depth(tex))
+ if (!GPU_texture_depth(tex)) {
return;
+ }
GLenum mode = (use_compare) ? GL_COMPARE_REF_TO_TEXTURE : GL_NONE;
@@ -1664,10 +1695,12 @@ void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat)
glActiveTexture(GL_TEXTURE0 + tex->number);
glTexParameteri(tex->target_base, GL_TEXTURE_WRAP_S, repeat);
- if (tex->target_base != GL_TEXTURE_1D)
+ if (tex->target_base != GL_TEXTURE_1D) {
glTexParameteri(tex->target_base, GL_TEXTURE_WRAP_T, repeat);
- if (tex->target_base == GL_TEXTURE_3D)
+ }
+ if (tex->target_base == GL_TEXTURE_3D) {
glTexParameteri(tex->target_base, GL_TEXTURE_WRAP_R, repeat);
+ }
}
static GLenum gpu_get_gl_filterfunction(eGPUFilterFunction filter)
@@ -1702,8 +1735,9 @@ void GPU_texture_free(GPUTexture *tex)
{
tex->refcount--;
- if (tex->refcount < 0)
+ if (tex->refcount < 0) {
fprintf(stderr, "GPUTexture: negative refcount\n");
+ }
if (tex->refcount == 0) {
for (int i = 0; i < GPU_TEX_MAX_FBO_ATTACHED; ++i) {
@@ -1712,8 +1746,9 @@ void GPU_texture_free(GPUTexture *tex)
}
}
- if (tex->bindcode)
+ if (tex->bindcode) {
GPU_tex_free(tex->bindcode);
+ }
gpu_texture_memory_footprint_remove(tex);
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c
index 651e3c1aaa7..d7766c51f38 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.c
@@ -65,7 +65,7 @@ static void gpu_uniformbuffer_inputs_sort(struct ListBase *inputs);
/* Only support up to this type, if you want to extend it, make sure the
* padding logic is correct for the new types. */
-#define MAX_UBO_GPU_TYPE GPU_VEC4
+#define MAX_UBO_GPU_TYPE GPU_MAT4
static void gpu_uniformbuffer_initialize(GPUUniformBuffer *ubo, const void *data)
{
@@ -243,7 +243,7 @@ static eGPUType get_padded_gpu_type(LinkData *link)
}
/**
- * Returns 1 if the first item shold be after second item.
+ * Returns 1 if the first item should be after second item.
* We make sure the vec4 uniforms come first.
*/
static int inputs_cmp(const void *a, const void *b)
@@ -255,11 +255,11 @@ static int inputs_cmp(const void *a, const void *b)
/**
* Make sure we respect the expected alignment of UBOs.
- * vec4, pad vec3 as vec4, then vec2, then floats.
+ * mat4, vec4, pad vec3 as vec4, then vec2, then floats.
*/
static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
{
- /* Order them as vec4, vec3, vec2, float. */
+ /* Order them as mat4, vec4, vec3, vec2, float. */
BLI_listbase_sort(inputs, inputs_cmp);
/* Creates a lookup table for the different types; */
@@ -268,6 +268,17 @@ static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
for (LinkData *link = inputs->first; link; link = link->next) {
GPUInput *input = link->data;
+
+ if (input->type == GPU_MAT3) {
+ /* Alignment for mat3 is not handled currently, so not supported */
+ BLI_assert(!"mat3 not supported in UBO");
+ continue;
+ }
+ else if (input->type > MAX_UBO_GPU_TYPE) {
+ BLI_assert(!"GPU type not supported in UBO");
+ continue;
+ }
+
if (input->type == cur_type) {
continue;
}
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 74c2959ee00..558b3f025a8 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -265,7 +265,8 @@ void GPU_viewport_size_get(const GPUViewport *viewport, int size[2])
/**
* Special case, this is needed for when we have a viewport without a frame-buffer output
- * (occlusion queries for eg) but still need to set the size since it may be used for other calculations.
+ * (occlusion queries for eg)
+ * but still need to set the size since it may be used for other calculations.
*/
void GPU_viewport_size_set(GPUViewport *viewport, const int size[2])
{
@@ -499,8 +500,9 @@ void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect)
{
DefaultFramebufferList *dfbl = viewport->fbl;
- if (dfbl->default_fb == NULL)
+ if (dfbl->default_fb == NULL) {
return;
+ }
DefaultTextureList *dtxl = viewport->txl;
@@ -630,6 +632,15 @@ void GPU_viewport_free(GPUViewport *viewport)
if (viewport->vmempool.passes != NULL) {
BLI_mempool_destroy(viewport->vmempool.passes);
}
+ if (viewport->vmempool.images != NULL) {
+ BLI_mempool_iter iter;
+ GPUTexture **tex;
+ BLI_mempool_iternew(viewport->vmempool.images, &iter);
+ while ((tex = BLI_mempool_iterstep(&iter))) {
+ GPU_texture_free(*tex);
+ }
+ BLI_mempool_destroy(viewport->vmempool.images);
+ }
DRW_instance_data_list_free(viewport->idatalist);
MEM_freeN(viewport->idatalist);
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl
index 185a4c8c59f..a29335046f2 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl
@@ -1,6 +1,7 @@
/*
- * Fragment Shader for dashed lines, with uniform multi-color(s), or any single-color, and any thickness.
+ * Fragment Shader for dashed lines, with uniform multi-color(s),
+ * or any single-color, and any thickness.
*
* Dashed is performed in screen space.
*/
@@ -10,7 +11,8 @@ uniform float dash_width;
/* Simple mode, discarding non-dash parts (so no need for blending at all). */
uniform float dash_factor; /* if > 1.0, solid line. */
-/* More advanced mode, allowing for complex, multi-colored patterns. Enabled when colors_len > 0. */
+/* More advanced mode, allowing for complex, multi-colored patterns.
+ * Enabled when colors_len > 0. */
/* Note: max number of steps/colors in pattern is 32! */
uniform int colors_len; /* Enabled if > 0, 1 for solid line. */
uniform vec4 colors[32];
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl
index 11f67172e89..584a179a9ac 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl
@@ -1,6 +1,7 @@
/*
- * Geometry Shader for dashed lines, with uniform multi-color(s), or any single-color, and unary thickness.
+ * Geometry Shader for dashed lines, with uniform multi-color(s),
+ * or any single-color, and unary thickness.
*
* Dashed is performed in screen space.
*/
@@ -9,7 +10,8 @@
uniform mat4 ModelViewProjectionMatrix;
uniform vec2 viewport_size;
-/* Uniforms from fragment shader, used here to optimize out useless computation in case of solid line. */
+/* Uniforms from fragment shader,
+ * used here to optimize out useless computation in case of solid line. */
uniform float dash_factor; /* if > 1.0, solid line. */
uniform int colors_len; /* Enabled if > 0, 1 for solid line. */
@@ -58,6 +60,6 @@ void main()
EndPrimitive();
- /* Note: we could also use similar approach as diag_stripes_frag, but this would give us dashed 'anchored'
- * to the screen, and not to one end of the line... */
+ /* Note: we could also use similar approach as diag_stripes_frag,
+ * but this would give us dashed 'anchored' to the screen, and not to one end of the line... */
}
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl
index 933a0976c6e..8b5a5cd8c9a 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl
@@ -1,7 +1,7 @@
/*
- * Vertex Shader for dashed lines with 2D coordinates, with uniform multi-colors or uniform single-color,
- * and unary thickness.
+ * Vertex Shader for dashed lines with 2D coordinates,
+ * with uniform multi-colors or uniform single-color, and unary thickness.
*
* Dashed is performed in screen space.
*/
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl
index 434917f8052..336f310837e 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl
@@ -8,7 +8,8 @@ uniform vec2 viewport_size;
/* Width of the generated 'line'. */
uniform float width; /* in pixels, screen space. */
-/* Uniforms from fragment shader, used here to optimize out useless computation in case of solid line. */
+/* Uniforms from fragment shader,
+ * used here to optimize out useless computation in case of solid line. */
uniform float dash_factor; /* if > 1.0, solid line. */
uniform int colors_len; /* Enabled if > 0, 1 for solid line. */
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl
index 9fe63c65054..28c91343771 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl
@@ -1,7 +1,7 @@
/*
- * Vertex Shader for dashed lines with 3D coordinates, with uniform multi-colors or uniform single-color,
- * and unary thickness.
+ * Vertex Shader for dashed lines with 3D coordinates,
+ * with uniform multi-colors or uniform single-color, and unary thickness.
*
* Legacy version, without geometry shader support, always produce solid lines!
*/
@@ -19,7 +19,8 @@ void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
- /* Hack - prevent stupid GLSL compiler to optimize out unused viewport_size uniform, which gives crash! */
+ /* Hack - prevent stupid GLSL compiler to optimize out unused viewport_size uniform,
+ * which gives crash! */
distance_along_line = viewport_size.x * 0.000001f - viewport_size.x * 0.0000009f;
color_geom = color;
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl
index 47ca09b5e72..7c317ecfb8c 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl
@@ -1,7 +1,7 @@
/*
- * Vertex Shader for dashed lines with 3D coordinates, with uniform multi-colors or uniform single-color,
- * and unary thickness.
+ * Vertex Shader for dashed lines with 3D coordinates,
+ * with uniform multi-colors or uniform single-color, and unary thickness.
*
* Dashed is performed in screen space.
*/
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 545629dbfa0..cf7a83e8a87 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -1190,7 +1190,8 @@ void convert_metallic_to_specular_tinted(vec3 basecol,
vec3 principled_sheen(float NV, vec3 basecol_tint, float sheen_tint)
{
float f = 1.0 - NV;
- /* Temporary fix for T59784. Normal map seems to contain NaNs for tangent space normal maps, therefore we need to clamp value. */
+ /* Temporary fix for T59784. Normal map seems to contain NaNs for tangent space normal maps,
+ * therefore we need to clamp value. */
f = clamp(f, 0.0, 1.0);
/* Empirical approximation (manual curve fitting). Can be refined. */
float sheen = f * f * f * 0.077 + f * 0.01 + 0.00026;
@@ -2770,7 +2771,9 @@ float noise_perlin(float x, float y, float z)
noise_v[1] = noise_nerp(v, noise_u[0], noise_u[1]);
- return noise_scale3(noise_nerp(w, noise_v[0], noise_v[1]));
+ float r = noise_scale3(noise_nerp(w, noise_v[0], noise_v[1]));
+
+ return (isinf(r)) ? 0.0 : r;
}
float noise(vec3 p)
@@ -3404,7 +3407,7 @@ void world_normals_get(out vec3 N)
/* Shade as a cylinder. */
cos_theta = hairThickTime / hairThickness;
}
- float sin_theta = sqrt(max(0.0, 1.0f - cos_theta * cos_theta));
+ float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta));
N = normalize(worldNormal * sin_theta + B * cos_theta);
# else
N = gl_FrontFacing ? worldNormal : -worldNormal;
@@ -3425,15 +3428,18 @@ void node_eevee_specular(vec4 diffuse,
out Closure result)
{
vec3 out_diff, out_spec, ssr_spec;
- eevee_closure_default(normal,
- diffuse.rgb,
- specular.rgb,
- int(ssr_id),
- roughness,
- occlusion,
- out_diff,
- out_spec,
- ssr_spec);
+ eevee_closure_default_clearcoat(normal,
+ diffuse.rgb,
+ specular.rgb,
+ int(ssr_id),
+ roughness,
+ clearcoat_normal,
+ clearcoat * 0.25,
+ clearcoat_roughness,
+ occlusion,
+ out_diff,
+ out_spec,
+ ssr_spec);
vec3 vN = normalize(mat3(ViewMatrix) * normal);
result = CLOSURE_DEFAULT;
diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h
index ade3113f041..0b118a25c13 100644
--- a/source/blender/ikplugin/BIK_api.h
+++ b/source/blender/ikplugin/BIK_api.h
@@ -68,9 +68,18 @@ void BIK_clear_cache(struct bPose *pose);
void BIK_update_param(struct bPose *pose);
void BIK_test_constraint(struct Object *ob, struct bConstraint *cons);
// not yet implemented
-// int BIK_get_constraint_param(struct bPose *pose, struct bConstraint *cons, int id, BIK_ParamValue *value);
-// int BIK_get_channel_param(struct bPose *pose, struct bPoseChannel *pchan, int id, BIK_ParamValue *value);
-// int BIK_get_solver_param(struct bPose *pose, struct bPoseChannel *pchan, int id, BIK_ParamValue *value);
+// int BIK_get_constraint_param(struct bPose *pose,
+// struct bConstraint *cons,
+// int id,
+// BIK_ParamValue *value);
+// int BIK_get_channel_param(struct bPose *pose,
+// struct bPoseChannel *pchan,
+// int id,
+// BIK_ParamValue *value);
+// int BIK_get_solver_param(struct bPose *pose,
+// struct bPoseChannel *pchan,
+// int id,
+// BIK_ParamValue *value);
// number of solver available
// 0 = iksolver
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index 5615cc4ea31..9ae8855bc85 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -47,7 +47,8 @@
/* ********************** THE IK SOLVER ******************* */
/* allocates PoseTree, and links that to root bone/channel */
-/* Note: detecting the IK chain is duplicate code... in drawarmature.c and in transform_conversions.c */
+/* Note: detecting the IK chain is duplicate code...
+ * in drawarmature.c and in transform_conversions.c */
static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_tip)
{
bPoseChannel *curchan, *pchan_root = NULL, *chanlist[256], **oldchan;
@@ -575,7 +576,8 @@ void iksolver_execute_tree(struct Depsgraph *depsgraph,
for (a = 0; a < tree->totchannel; a++) {
if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag
BKE_pose_where_is_bone(depsgraph, scene, ob, tree->pchan[a], ctime, 1);
- /* tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() */
+ /* Tell blender that this channel was controlled by IK,
+ * it's cleared on each BKE_pose_where_is(). */
tree->pchan[a]->flag |= POSE_CHAIN;
}
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index f20ecc3c11d..e05385feb17 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -89,16 +89,16 @@ struct IK_Target {
iTaSC::ConstraintSet *constraint;
struct bConstraint *blenderConstraint;
struct bPoseChannel *rootChannel;
- Object *owner; //for auto IK
+ Object *owner; // for auto IK
ErrorCallback errorCallback;
std::string targetName;
std::string constraintName;
unsigned short controlType;
- short channel; //index in IK channel array of channel on which this target is defined
- short ee; //end effector number
- bool simulation; //true when simulation mode is used (update feedback)
- bool eeBlend; //end effector affected by enforce blending
- float eeRest[4][4]; //end effector initial pose relative to armature
+ short channel; // index in IK channel array of channel on which this target is defined
+ short ee; // end effector number
+ bool simulation; // true when simulation mode is used (update feedback)
+ bool eeBlend; // end effector affected by enforce blending
+ float eeRest[4][4]; // end effector initial pose relative to armature
IK_Target()
{
@@ -289,7 +289,8 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
/* create a target */
target = (PoseTarget *)MEM_callocN(sizeof(PoseTarget), "posetarget");
target->con = con;
- // by contruction there can be only one tree per channel and each channel can be part of at most one tree.
+ // by contruction there can be only one tree per channel
+ // and each channel can be part of at most one tree.
tree = (PoseTree *)pchan_root->iktree.first;
if (tree == NULL) {
@@ -377,7 +378,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
static bool is_cartesian_constraint(bConstraint *con)
{
- //bKinematicConstraint* data=(bKinematicConstraint *)con->data;
+ // bKinematicConstraint* data=(bKinematicConstraint *)con->data;
return true;
}
@@ -483,7 +484,7 @@ static void RemoveEulerAngleFromMatrix(KDL::Rotation &R, double angle, int axis)
}
#if 0
-static void GetEulerXZY(const KDL::Rotation& R, double& X, double& Z, double& Y)
+static void GetEulerXZY(const KDL::Rotation &R, double &X, double &Z, double &Y)
{
if (fabs(R(0, 1)) > 1.0 - KDL::epsilon) {
X = -KDL::sign(R(0, 1)) * KDL::atan2(R(1, 2), R(1, 0));
@@ -497,7 +498,7 @@ static void GetEulerXZY(const KDL::Rotation& R, double& X, double& Z, double& Y)
}
}
-static void GetEulerXYZ(const KDL::Rotation& R, double& X, double& Y, double& Z)
+static void GetEulerXYZ(const KDL::Rotation &R, double &X, double &Y, double &Z)
{
if (fabs(R(0, 2)) > 1.0 - KDL::epsilon) {
X = KDL::sign(R(0, 2)) * KDL::atan2(-R(1, 0), R(1, 1));
@@ -656,7 +657,8 @@ static bool base_callback(const iTaSC::Timestamp &timestamp,
1.0);
// convert to armature space
mul_m4_m4m4(polemat, imat, mat);
- // get the target in world space (was computed before as target object are defined before base object)
+ // get the target in world space
+ // (was computed before as target object are defined before base object).
iktarget->target->getPose().getValue(mat[0]);
// convert to armature space
mul_m4_m4m4(goalmat, imat, mat);
@@ -849,11 +851,13 @@ static bool joint_callback(const iTaSC::Timestamp &timestamp,
float rmat[3][3];
if (chan->rotmode > 0) {
- /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
+ /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation
+ * orders) */
eulO_to_mat3(rmat, chan->eul, chan->rotmode);
}
else if (chan->rotmode == ROT_MODE_AXISANGLE) {
- /* axis-angle - stored in quaternion data, but not really that great for 3D-changing orientations */
+ /* axis-angle - stored in quaternion data,
+ * but not really that great for 3D-changing orientations */
axis_angle_to_mat3(rmat, &chan->quat[1], chan->quat[0]);
}
else {
@@ -936,7 +940,8 @@ static int convert_channels(struct Depsgraph *depsgraph,
// joint angles and can't be applied to the iTaSC armature dynamically
if (!(pchan->flag & POSE_DONE))
BKE_pose_where_is_bone(depsgraph, ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
- // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is()
+ // tell blender that this channel was controlled by IK,
+ // it's cleared on each BKE_pose_where_is()
pchan->flag |= (POSE_DONE | POSE_CHAIN);
/* set DoF flag */
@@ -1645,8 +1650,9 @@ static void execute_scene(struct Depsgraph *depsgraph,
IK_Channel *ikchan;
if (ikparam->flag & ITASC_SIMULATION) {
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) {
- // In simulation mode we don't allow external contraint to change our bones, mark the channel done
- // also tell Blender that this channel is part of IK tree (cleared on each BKE_pose_where_is()
+ // In simulation mode we don't allow external contraint to change our bones, mark the channel
+ // done also tell Blender that this channel is part of IK tree
+ // (cleared on each BKE_pose_where_is()
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
}
@@ -1656,7 +1662,8 @@ static void execute_scene(struct Depsgraph *depsgraph,
for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) {
if (!(ikchan->pchan->flag & POSE_DONE))
BKE_pose_where_is_bone(depsgraph, blscene, ikscene->blArmature, ikchan->pchan, ctime, 1);
- // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is()
+ // tell blender that this channel was controlled by IK,
+ // it's cleared on each BKE_pose_where_is()
ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN);
ikchan->jointValid = 0;
}
@@ -1906,8 +1913,8 @@ void itasc_update_param(struct bPose *pose)
CONSTRAINT_ID_ALL, iTaSC::Armature::ID_JOINT, iTaSC::ACT_FEEDBACK, ikparam->feedback);
}
else {
- // in animation mode timestep is 1s by convention =>
- // qmax becomes radiant and feedback becomes fraction of error gap corrected in one iteration
+ // in animation mode timestep is 1s by convention => qmax becomes radiant and feedback
+ // becomes fraction of error gap corrected in one iteration.
ikscene->scene->setParam(iTaSC::Scene::MIN_TIMESTEP, 1.0);
ikscene->scene->setParam(iTaSC::Scene::MAX_TIMESTEP, 1.0);
ikscene->solver->setParam(iTaSC::Solver::DLS_QMAX, 0.52);
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h
index 5978066f4a8..620f8984d9f 100644
--- a/source/blender/imbuf/IMB_colormanagement.h
+++ b/source/blender/imbuf/IMB_colormanagement.h
@@ -318,7 +318,8 @@ bool IMB_colormanagement_setup_glsl_draw_from_space(
bool IMB_colormanagement_setup_glsl_draw_ctx(const struct bContext *C,
float dither,
bool predivide);
-/* Same as setup_glsl_draw_from_space, but color management settings are guessing from a given context */
+/* Same as setup_glsl_draw_from_space,
+ * but color management settings are guessing from a given context. */
bool IMB_colormanagement_setup_glsl_draw_from_space_ctx(const struct bContext *C,
struct ColorSpace *colorspace,
float dither,
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 27eb6a5eee5..f8df14cf317 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -173,6 +173,13 @@ bool addzbufImBuf(struct ImBuf *ibuf);
bool addzbuffloatImBuf(struct ImBuf *ibuf);
/**
+ * Approximate size of ImBuf in memory
+ *
+ * \attention Defined in allocimbuf.c
+ */
+size_t IMB_get_size_in_memory(struct ImBuf *ibuf);
+
+/**
*
* \attention Defined in rectop.c
*/
@@ -272,18 +279,20 @@ void IMB_rectblend_threaded(struct ImBuf *dbuf,
*/
typedef enum IMB_Timecode_Type {
- IMB_TC_NONE = 0, /* don't use timecode files at all */
-
- IMB_TC_RECORD_RUN = 1, /* use images in the order as they are recorded
- * (currently, this is the only one implemented
- * and is a sane default) */
-
- IMB_TC_FREE_RUN = 2, /* use global timestamp written by recording
- * device (prosumer camcorders e.g. can do that) */
- IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN = 4, /* interpolate a global timestamp using the
- * record date and time written by recording
- * device (*every* consumer camcorder can do
- * that :) )*/
+ /** Don't use timecode files at all. */
+ IMB_TC_NONE = 0,
+ /** use images in the order as they are recorded
+ * (currently, this is the only one implemented
+ * and is a sane default) */
+ IMB_TC_RECORD_RUN = 1,
+ /** Use global timestamp written by recording
+ * device (prosumer camcorders e.g. can do that). */
+ IMB_TC_FREE_RUN = 2,
+ /** Interpolate a global timestamp using the
+ * record date and time written by recording
+ * device (*every* consumer camcorder can do
+ * that :) )*/
+ IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN = 4,
IMB_TC_RECORD_RUN_NO_GAPS = 8,
IMB_TC_MAX_SLOT = 4,
} IMB_Timecode_Type;
@@ -470,7 +479,8 @@ bool IMB_isfloat(struct ImBuf *ibuf);
/* create char buffer, color corrected if necessary, for ImBufs that lack one */
void IMB_rect_from_float(struct ImBuf *ibuf);
/* Create char buffer for part of the image, color corrected if necessary,
- * Changed part will be stored in buffer. This is expected to be used for texture painting updates */
+ * Changed part will be stored in buffer.
+ * This is expected to be used for texture painting updates */
void IMB_partial_rect_from_float(
struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h, bool is_data);
void IMB_float_from_rect(struct ImBuf *ibuf);
@@ -658,7 +668,8 @@ void IMB_rectfill_area(struct ImBuf *ibuf,
struct ColorManagedDisplay *display);
void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value);
-/* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */
+/* This should not be here, really,
+ * we needed it for operating on render data, IMB_rectfill_area calls it. */
void buf_rectfill_area(unsigned char *rect,
float *rectf,
int width,
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index d6bebe197c4..0f2529e261a 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -223,7 +223,7 @@ typedef struct ImBuf {
int refcounter;
/* some parameters to pass along for packing images */
- /** Compressed image only used with png currently */
+ /** Compressed image only used with png and exr currently */
unsigned char *encodedbuffer;
/** Size of data written to encodedbuffer */
unsigned int encodedsize;
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 2c253f7f0e6..fe24ccc99a9 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -96,8 +96,9 @@ void imb_freemipmapImBuf(ImBuf *ibuf)
/* any free rect frees mipmaps to be sure, creation is in render on first request */
void imb_freerectfloatImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
if (ibuf->rect_float && (ibuf->mall & IB_rectfloat)) {
MEM_freeN(ibuf->rect_float);
@@ -113,11 +114,13 @@ void imb_freerectfloatImBuf(ImBuf *ibuf)
/* any free rect frees mipmaps to be sure, creation is in render on first request */
void imb_freerectImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
- if (ibuf->rect && (ibuf->mall & IB_rect))
+ if (ibuf->rect && (ibuf->mall & IB_rect)) {
MEM_freeN(ibuf->rect);
+ }
ibuf->rect = NULL;
imb_freemipmapImBuf(ibuf);
@@ -129,8 +132,9 @@ void imb_freetilesImBuf(ImBuf *ibuf)
{
int tx, ty;
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
if (ibuf->tiles && (ibuf->mall & IB_tiles)) {
for (ty = 0; ty < ibuf->ytiles; ty++) {
@@ -151,11 +155,13 @@ void imb_freetilesImBuf(ImBuf *ibuf)
static void freeencodedbufferImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
- if (ibuf->encodedbuffer && (ibuf->mall & IB_mem))
+ if (ibuf->encodedbuffer && (ibuf->mall & IB_mem)) {
MEM_freeN(ibuf->encodedbuffer);
+ }
ibuf->encodedbuffer = NULL;
ibuf->encodedbuffersize = 0;
@@ -165,11 +171,13 @@ static void freeencodedbufferImBuf(ImBuf *ibuf)
void IMB_freezbufImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
- if (ibuf->zbuf && (ibuf->mall & IB_zbuf))
+ if (ibuf->zbuf && (ibuf->mall & IB_zbuf)) {
MEM_freeN(ibuf->zbuf);
+ }
ibuf->zbuf = NULL;
ibuf->mall &= ~IB_zbuf;
@@ -177,11 +185,13 @@ void IMB_freezbufImBuf(ImBuf *ibuf)
void IMB_freezbuffloatImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
- if (ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat))
+ if (ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat)) {
MEM_freeN(ibuf->zbuf_float);
+ }
ibuf->zbuf_float = NULL;
ibuf->mall &= ~IB_zbuffloat;
@@ -212,9 +222,8 @@ void IMB_freeImBuf(ImBuf *ibuf)
colormanage_cache_free(ibuf);
if (ibuf->dds_data.data != NULL) {
- free(
- ibuf->dds_data
- .data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
+ /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
+ free(ibuf->dds_data.data);
}
MEM_freeN(ibuf);
}
@@ -256,8 +265,9 @@ ImBuf *IMB_makeSingleUser(ImBuf *ibuf)
bool addzbufImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return false;
+ }
IMB_freezbufImBuf(ibuf);
@@ -272,8 +282,9 @@ bool addzbufImBuf(ImBuf *ibuf)
bool addzbuffloatImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return false;
+ }
IMB_freezbuffloatImBuf(ibuf);
@@ -288,13 +299,15 @@ bool addzbuffloatImBuf(ImBuf *ibuf)
bool imb_addencodedbufferImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return false;
+ }
freeencodedbufferImBuf(ibuf);
- if (ibuf->encodedbuffersize == 0)
+ if (ibuf->encodedbuffersize == 0) {
ibuf->encodedbuffersize = 10000;
+ }
ibuf->encodedsize = 0;
@@ -312,8 +325,9 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
unsigned int newsize, encodedsize;
void *newbuffer;
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return false;
+ }
if (ibuf->encodedbuffersize < ibuf->encodedsize) {
printf("%s: error in parameters\n", __func__);
@@ -321,12 +335,14 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
}
newsize = 2 * ibuf->encodedbuffersize;
- if (newsize < 10000)
+ if (newsize < 10000) {
newsize = 10000;
+ }
newbuffer = MEM_mallocN(newsize, __func__);
- if (newbuffer == NULL)
+ if (newbuffer == NULL) {
return false;
+ }
if (ibuf->encodedbuffer) {
memcpy(newbuffer, ibuf->encodedbuffer, ibuf->encodedsize);
@@ -363,11 +379,13 @@ void *imb_alloc_pixels(
bool imb_addrectfloatImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return false;
+ }
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
+ }
ibuf->channels = 4;
if ((ibuf->rect_float = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(float), __func__))) {
@@ -382,12 +400,15 @@ bool imb_addrectfloatImBuf(ImBuf *ibuf)
/* question; why also add zbuf? */
bool imb_addrectImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return false;
+ }
- /* don't call imb_freerectImBuf, it frees mipmaps, this call is used only too give float buffers display */
- if (ibuf->rect && (ibuf->mall & IB_rect))
+ /* Don't call imb_freerectImBuf, it frees mipmaps,
+ * this call is used only too give float buffers display. */
+ if (ibuf->rect && (ibuf->mall & IB_rect)) {
MEM_freeN(ibuf->rect);
+ }
ibuf->rect = NULL;
if ((ibuf->rect = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(unsigned char), __func__))) {
@@ -411,8 +432,9 @@ struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect,
{
ImBuf *ibuf = NULL;
- if (!(rect || rectf))
+ if (!(rect || rectf)) {
return NULL;
+ }
ibuf = IMB_allocImBuf(w, h, 32, 0);
@@ -432,13 +454,16 @@ struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect,
bool imb_addtilesImBuf(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return false;
+ }
- if (!ibuf->tiles)
+ if (!ibuf->tiles) {
if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int *) * ibuf->xtiles * ibuf->ytiles,
- "imb_tiles")))
+ "imb_tiles"))) {
ibuf->mall |= IB_tiles;
+ }
+ }
return (ibuf->tiles != NULL);
}
@@ -511,37 +536,47 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
int flags = 0;
int a, x, y;
- if (ibuf1 == NULL)
+ if (ibuf1 == NULL) {
return NULL;
+ }
- if (ibuf1->rect)
+ if (ibuf1->rect) {
flags |= IB_rect;
- if (ibuf1->rect_float)
+ }
+ if (ibuf1->rect_float) {
flags |= IB_rectfloat;
- if (ibuf1->zbuf)
+ }
+ if (ibuf1->zbuf) {
flags |= IB_zbuf;
- if (ibuf1->zbuf_float)
+ }
+ if (ibuf1->zbuf_float) {
flags |= IB_zbuffloat;
+ }
x = ibuf1->x;
y = ibuf1->y;
ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags);
- if (ibuf2 == NULL)
+ if (ibuf2 == NULL) {
return NULL;
+ }
- if (flags & IB_rect)
+ if (flags & IB_rect) {
memcpy(ibuf2->rect, ibuf1->rect, ((size_t)x) * y * sizeof(int));
+ }
- if (flags & IB_rectfloat)
+ if (flags & IB_rectfloat) {
memcpy(
ibuf2->rect_float, ibuf1->rect_float, ((size_t)ibuf1->channels) * x * y * sizeof(float));
+ }
- if (flags & IB_zbuf)
+ if (flags & IB_zbuf) {
memcpy(ibuf2->zbuf, ibuf1->zbuf, ((size_t)x) * y * sizeof(int));
+ }
- if (flags & IB_zbuffloat)
+ if (flags & IB_zbuffloat) {
memcpy(ibuf2->zbuf_float, ibuf1->zbuf_float, ((size_t)x) * y * sizeof(float));
+ }
if (ibuf1->encodedbuffer) {
ibuf2->encodedbuffersize = ibuf1->encodedbuffersize;
@@ -562,8 +597,9 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
tbuf.encodedbuffer = ibuf2->encodedbuffer;
tbuf.zbuf = ibuf2->zbuf;
tbuf.zbuf_float = ibuf2->zbuf_float;
- for (a = 0; a < IMB_MIPMAP_LEVELS; a++)
+ for (a = 0; a < IMB_MIPMAP_LEVELS; a++) {
tbuf.mipmap[a] = NULL;
+ }
tbuf.dds_data.data = NULL;
/* set malloc flag */
@@ -582,12 +618,41 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
return (ibuf2);
}
+size_t IMB_get_size_in_memory(ImBuf *ibuf)
+{
+ int a;
+ size_t size = 0, channel_size = 0;
+
+ size += sizeof(ImBuf);
+
+ if (ibuf->rect)
+ channel_size += sizeof(char);
+
+ if (ibuf->rect_float)
+ channel_size += sizeof(float);
+
+ size += channel_size * ibuf->x * ibuf->y * ibuf->channels;
+
+ if (ibuf->miptot) {
+ for (a = 0; a < ibuf->miptot; a++) {
+ if (ibuf->mipmap[a])
+ size += IMB_get_size_in_memory(ibuf->mipmap[a]);
+ }
+ }
+
+ if (ibuf->tiles) {
+ size += sizeof(unsigned int) * ibuf->ytiles * ibuf->xtiles;
+ }
+
+ return size;
+}
+
#if 0 /* remove? - campbell */
/* support for cache limiting */
static void imbuf_cache_destructor(void *data)
{
- ImBuf *ibuf = (ImBuf *) data;
+ ImBuf *ibuf = (ImBuf *)data;
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
@@ -598,13 +663,13 @@ static void imbuf_cache_destructor(void *data)
ibuf->c_handle = NULL;
}
-
static MEM_CacheLimiterC **get_imbuf_cache_limiter(void)
{
static MEM_CacheLimiterC *c = NULL;
- if (!c)
+ if (!c) {
c = new_MEM_CacheLimiter(imbuf_cache_destructor, NULL);
+ }
return &c;
}
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 13813fb23b3..483ccc9ea9d 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -87,7 +87,7 @@
# include <libswscale/swscale.h>
# include "ffmpeg_compat.h"
-#endif //WITH_FFMPEG
+#endif // WITH_FFMPEG
int ismovie(const char *UNUSED(filepath))
{
@@ -124,8 +124,9 @@ static int an_stringdec(const char *string, char *head, char *tail, unsigned sho
nume = len;
for (i = len - 1; i >= 0; i--) {
- if (string[i] == PATHSEPARATOR)
+ if (string[i] == PATHSEPARATOR) {
break;
+ }
if (isdigit(string[i])) {
if (found) {
nums = i;
@@ -137,8 +138,9 @@ static int an_stringdec(const char *string, char *head, char *tail, unsigned sho
}
}
else {
- if (found)
+ if (found) {
break;
+ }
}
}
if (found) {
@@ -167,10 +169,12 @@ static void free_anim_avi(struct anim *anim)
int i;
# endif
- if (anim == NULL)
+ if (anim == NULL) {
return;
- if (anim->avi == NULL)
+ }
+ if (anim->avi == NULL) {
return;
+ }
AVI_close(anim->avi);
MEM_freeN(anim->avi);
@@ -227,16 +231,18 @@ void IMB_free_anim(struct anim *anim)
void IMB_close_anim(struct anim *anim)
{
- if (anim == NULL)
+ if (anim == NULL) {
return;
+ }
IMB_free_anim(anim);
}
void IMB_close_anim_proxies(struct anim *anim)
{
- if (anim == NULL)
+ if (anim == NULL) {
return;
+ }
IMB_free_indices(anim);
}
@@ -253,8 +259,9 @@ struct IDProperty *IMB_anim_load_metadata(struct anim *anim)
while (true) {
entry = av_dict_get(anim->pFormatCtx->metadata, "", entry, AV_DICT_IGNORE_SUFFIX);
- if (entry == NULL)
+ if (entry == NULL) {
break;
+ }
/* Delay creation of the property group until there is actual metadata to put in there. */
IMB_metadata_ensure(&anim->metadata);
@@ -413,7 +420,14 @@ static int startavi(struct anim *anim)
anim->curposition = 0;
anim->preseek = 0;
- /* printf("x:%d y:%d size:%d interl:%d dur:%d\n", anim->x, anim->y, anim->framesize, anim->interlacing, anim->duration);*/
+# if 0
+ printf("x:%d y:%d size:%d interl:%d dur:%d\n",
+ anim->x,
+ anim->y,
+ anim->framesize,
+ anim->interlacing,
+ anim->duration);
+# endif
return 0;
}
@@ -439,7 +453,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
if (lpbi) {
ibuf = IMB_ibImageFromMemory(
(const unsigned char *)lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
- //Oh brother...
+ // Oh brother...
}
}
}
@@ -496,8 +510,9 @@ static int startffmpeg(struct anim *anim)
const int *inv_table;
# endif
- if (anim == NULL)
+ if (anim == NULL) {
return (-1);
+ }
streamcount = anim->streamindex;
@@ -964,14 +979,16 @@ static int match_format(const char *name, AVFormatContext *pFormatCtx)
const char *names = pFormatCtx->iformat->name;
- if (!name || !names)
+ if (!name || !names) {
return 0;
+ }
namelen = strlen(name);
while ((p = strchr(names, ','))) {
len = MAX2(p - names, namelen);
- if (!BLI_strncasecmp(name, names, len))
+ if (!BLI_strncasecmp(name, names, len)) {
return 1;
+ }
names = p + 1;
}
return !BLI_strcasecmp(name, names);
@@ -1008,8 +1025,9 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ
int new_frame_index = 0; /* To quiet gcc barking... */
int old_frame_index = 0; /* To quiet gcc barking... */
- if (anim == NULL)
+ if (anim == NULL) {
return (0);
+ }
av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: pos=%d\n", position);
@@ -1171,8 +1189,9 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ
static void free_anim_ffmpeg(struct anim *anim)
{
- if (anim == NULL)
+ if (anim == NULL) {
return;
+ }
if (anim->pCodecCtx) {
avcodec_close(anim->pCodecCtx);
@@ -1215,8 +1234,9 @@ static ImBuf *anim_getnew(struct anim *anim)
{
struct ImBuf *ibuf = NULL;
- if (anim == NULL)
+ if (anim == NULL) {
return (NULL);
+ }
free_anim_movie(anim);
@@ -1228,8 +1248,9 @@ static ImBuf *anim_getnew(struct anim *anim)
free_anim_ffmpeg(anim);
#endif
- if (anim->curtype != 0)
+ if (anim->curtype != 0) {
return (NULL);
+ }
anim->curtype = imb_get_anim_type(anim->name);
switch (anim->curtype) {
@@ -1241,8 +1262,9 @@ static ImBuf *anim_getnew(struct anim *anim)
}
break;
case ANIM_MOVIE:
- if (startmovie(anim))
+ if (startmovie(anim)) {
return (NULL);
+ }
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0); /* fake */
break;
#ifdef WITH_AVI
@@ -1256,8 +1278,9 @@ static ImBuf *anim_getnew(struct anim *anim)
#endif
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
- if (startffmpeg(anim))
+ if (startffmpeg(anim)) {
return (0);
+ }
ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
break;
#endif
@@ -1289,8 +1312,9 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
unsigned short digits;
int pic;
int filter_y;
- if (anim == NULL)
+ if (anim == NULL) {
return (NULL);
+ }
filter_y = (anim->ib_flags & IB_animdeinterlace);
@@ -1305,10 +1329,12 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
ibuf = NULL;
}
- if (position < 0)
+ if (position < 0) {
return (NULL);
- if (position >= anim->duration)
+ }
+ if (position >= anim->duration) {
return (NULL);
+ }
}
else {
struct anim *proxy = IMB_anim_open_proxy(anim, preview_size);
@@ -1340,23 +1366,26 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
#ifdef WITH_AVI
case ANIM_AVI:
ibuf = avi_fetchibuf(anim, position);
- if (ibuf)
+ if (ibuf) {
anim->curposition = position;
+ }
break;
#endif
#ifdef WITH_FFMPEG
case ANIM_FFMPEG:
ibuf = ffmpeg_fetchibuf(anim, position, tc);
- if (ibuf)
+ if (ibuf) {
anim->curposition = position;
+ }
filter_y = 0; /* done internally */
break;
#endif
}
if (ibuf) {
- if (filter_y)
+ if (filter_y) {
IMB_filtery(ibuf);
+ }
BLI_snprintf(ibuf->name, sizeof(ibuf->name), "%s.%04d", anim->name, anim->curposition + 1);
}
return (ibuf);
diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c
index f5c12c916f0..ae3ac624e3b 100644
--- a/source/blender/imbuf/intern/bmp.c
+++ b/source/blender/imbuf/intern/bmp.c
@@ -33,8 +33,8 @@
#include "IMB_colormanagement.h"
#include "IMB_colormanagement_intern.h"
-/* some code copied from article on microsoft.com, copied
- * here for enhanced BMP support in the future
+/* Some code copied from article on microsoft.com,
+ * copied here for enhanced BMP support in the future:
* http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0197/mfcp1/mfcp1.htm&nav=/msj/0197/newnav.htm
*/
@@ -125,8 +125,9 @@ struct ImBuf *imb_bmp_decode(const unsigned char *mem,
(void)size; /* unused */
- if (checkbmp(mem) == 0)
+ if (checkbmp(mem) == 0) {
return (NULL);
+ }
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@@ -310,8 +311,9 @@ int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags)
data = (uchar *)ibuf->rect;
ofile = BLI_fopen(name, "wb");
- if (!ofile)
+ if (!ofile) {
return 0;
+ }
putShortLSB(19778, ofile); /* "BM" */
putIntLSB(bytesize + BMP_FILEHEADER_SIZE + sizeof(infoheader), ofile); /* Total file size */
@@ -335,17 +337,21 @@ int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags)
for (size_t y = 0; y < ibuf->y; y++) {
for (size_t x = 0; x < ibuf->x; x++) {
ptr = (x + y * ibuf->x) * 4;
- if (putc(data[ptr + 2], ofile) == EOF)
+ if (putc(data[ptr + 2], ofile) == EOF) {
return 0;
- if (putc(data[ptr + 1], ofile) == EOF)
+ }
+ if (putc(data[ptr + 1], ofile) == EOF) {
return 0;
- if (putc(data[ptr], ofile) == EOF)
+ }
+ if (putc(data[ptr], ofile) == EOF) {
return 0;
+ }
}
/* add padding here */
for (size_t t = 0; t < extrabytes; t++) {
- if (putc(0, ofile) == EOF)
+ if (putc(0, ofile) == EOF) {
return 0;
+ }
}
}
if (ofile) {
diff --git a/source/blender/imbuf/intern/cache.c b/source/blender/imbuf/intern/cache.c
index e6244364ba8..01c588daedd 100644
--- a/source/blender/imbuf/intern/cache.c
+++ b/source/blender/imbuf/intern/cache.c
@@ -155,8 +155,9 @@ void imb_tile_cache_tile_free(ImBuf *ibuf, int tx, int ty)
if (gtile) {
/* in case another thread is loading this */
- while (gtile->loading)
+ while (gtile->loading) {
;
+ }
BLI_ghash_remove(GLOBAL_CACHE.tilehash, gtile, NULL, NULL);
BLI_remlink(&GLOBAL_CACHE.tiles, gtile);
@@ -209,17 +210,21 @@ void imb_tile_cache_exit(void)
int a;
if (GLOBAL_CACHE.initialized) {
- for (gtile = GLOBAL_CACHE.tiles.first; gtile; gtile = gtile->next)
+ for (gtile = GLOBAL_CACHE.tiles.first; gtile; gtile = gtile->next) {
imb_global_cache_tile_unload(gtile);
+ }
- for (a = 0; a < GLOBAL_CACHE.totthread; a++)
+ for (a = 0; a < GLOBAL_CACHE.totthread; a++) {
imb_thread_cache_exit(&GLOBAL_CACHE.thread_cache[a]);
+ }
- if (GLOBAL_CACHE.memarena)
+ if (GLOBAL_CACHE.memarena) {
BLI_memarena_free(GLOBAL_CACHE.memarena);
+ }
- if (GLOBAL_CACHE.tilehash)
+ if (GLOBAL_CACHE.tilehash) {
BLI_ghash_free(GLOBAL_CACHE.tilehash, NULL, NULL);
+ }
BLI_mutex_end(&GLOBAL_CACHE.mutex);
@@ -236,8 +241,9 @@ void IMB_tile_cache_params(int totthread, int maxmem)
totthread++;
/* lazy initialize cache */
- if (GLOBAL_CACHE.totthread == totthread && GLOBAL_CACHE.maxmem == maxmem)
+ if (GLOBAL_CACHE.totthread == totthread && GLOBAL_CACHE.maxmem == maxmem) {
return;
+ }
imb_tile_cache_exit();
@@ -252,8 +258,9 @@ void IMB_tile_cache_params(int totthread, int maxmem)
GLOBAL_CACHE.maxmem = maxmem * 1024 * 1024;
GLOBAL_CACHE.totthread = totthread;
- for (a = 0; a < totthread; a++)
+ for (a = 0; a < totthread; a++) {
imb_thread_cache_init(&GLOBAL_CACHE.thread_cache[a]);
+ }
BLI_mutex_init(&GLOBAL_CACHE.mutex);
}
@@ -269,8 +276,9 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf,
BLI_mutex_lock(&GLOBAL_CACHE.mutex);
- if (replacetile)
+ if (replacetile) {
replacetile->refcount--;
+ }
/* find tile in global cache */
lookuptile.ibuf = ibuf;
@@ -286,8 +294,9 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf,
BLI_mutex_unlock(&GLOBAL_CACHE.mutex);
- while (gtile->loading)
+ while (gtile->loading) {
;
+ }
}
else {
/* not found, let's load it from disk */
@@ -295,9 +304,11 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf,
/* first check if we hit the memory limit */
if (GLOBAL_CACHE.maxmem && GLOBAL_CACHE.totmem > GLOBAL_CACHE.maxmem) {
/* find an existing tile to unload */
- for (gtile = GLOBAL_CACHE.tiles.last; gtile; gtile = gtile->prev)
- if (gtile->refcount == 0 && gtile->loading == 0)
+ for (gtile = GLOBAL_CACHE.tiles.last; gtile; gtile = gtile->prev) {
+ if (gtile->refcount == 0 && gtile->loading == 0) {
break;
+ }
+ }
}
if (gtile) {
@@ -312,8 +323,9 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf,
gtile = GLOBAL_CACHE.unused.first;
BLI_remlink(&GLOBAL_CACHE.unused, gtile);
}
- else
+ else {
gtile = BLI_memarena_alloc(GLOBAL_CACHE.memarena, sizeof(ImGlobalTile));
+ }
}
/* setup new tile */
@@ -355,8 +367,9 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache,
/* test if it is already in our thread local cache */
if ((ttile = cache->tiles.first)) {
/* check last used tile before going to hash */
- if (ttile->ibuf == ibuf && ttile->tx == tx && ttile->ty == ty)
+ if (ttile->ibuf == ibuf && ttile->tx == tx && ttile->ty == ty) {
return ibuf->tiles[toffs];
+ }
/* find tile in hash */
lookuptile.ibuf = ibuf;
@@ -419,8 +432,9 @@ void IMB_tiles_to_rect(ImBuf *ibuf)
mipbuf->mall |= IB_rect;
mipbuf->flags |= IB_rect;
}
- else
+ else {
break;
+ }
}
for (ty = 0; ty < mipbuf->ytiles; ty++) {
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index 8f3829ee91e..77c04fd3358 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -77,8 +77,9 @@ static struct ImBuf *imb_load_dpx_cineon(const unsigned char *mem,
logImageClose(image);
ibuf->ftype = use_cineon ? IMB_FTYPE_CINEON : IMB_FTYPE_DPX;
- if (flags & IB_alphamode_detect)
+ if (flags & IB_alphamode_detect) {
ibuf->flags |= IB_alphamode_premul;
+ }
return ibuf;
}
@@ -104,14 +105,18 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
return 0;
}
- if (ibuf->foptions.flag & CINEON_10BIT)
+ if (ibuf->foptions.flag & CINEON_10BIT) {
bitspersample = 10;
- else if (ibuf->foptions.flag & CINEON_12BIT)
+ }
+ else if (ibuf->foptions.flag & CINEON_12BIT) {
bitspersample = 12;
- else if (ibuf->foptions.flag & CINEON_16BIT)
+ }
+ else if (ibuf->foptions.flag & CINEON_16BIT) {
bitspersample = 16;
- else
+ }
+ else {
bitspersample = 8;
+ }
logImage = logImageCreate(filename,
use_cineon,
@@ -149,8 +154,9 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
MEM_freeN(fbuf);
}
else {
- if (ibuf->rect == NULL)
+ if (ibuf->rect == NULL) {
IMB_rect_from_float(ibuf);
+ }
fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float),
"fbuf in imb_save_dpx_cineon");
@@ -192,8 +198,9 @@ ImBuf *imb_load_cineon(const unsigned char *mem,
int flags,
char colorspace[IM_MAX_SPACE])
{
- if (imb_is_cineon(mem))
+ if (imb_is_cineon(mem)) {
return imb_load_dpx_cineon(mem, size, 1, flags, colorspace);
+ }
return NULL;
}
@@ -212,7 +219,8 @@ ImBuf *imb_load_dpx(const unsigned char *mem,
int flags,
char colorspace[IM_MAX_SPACE])
{
- if (imb_is_dpx(mem))
+ if (imb_is_dpx(mem)) {
return imb_load_dpx_cineon(mem, size, 0, flags, colorspace);
+ }
return NULL;
}
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index 79f419e747c..63014919dfb 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -146,8 +146,9 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
unsigned int dataOffset;
if (cineon == NULL) {
- if (verbose)
+ if (verbose) {
printf("Cineon: Failed to malloc cineon file structure.\n");
+ }
return NULL;
}
@@ -161,8 +162,9 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
/* byteStuff is then the filename */
cineon->file = BLI_fopen(filename, "rb");
if (cineon->file == NULL) {
- if (verbose)
+ if (verbose) {
printf("Cineon: Failed to open file \"%s\".\n", filename);
+ }
logImageClose(cineon);
return NULL;
}
@@ -178,8 +180,9 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
}
if (logimage_fread(&header, sizeof(header), 1, cineon) == 0) {
- if (verbose)
+ if (verbose) {
printf("Cineon: Not enough data for header in \"%s\".\n", byteStuff);
+ }
logImageClose(cineon);
return NULL;
}
@@ -187,13 +190,15 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
/* endianness determination */
if (header.fileHeader.magic_num == swap_uint(CINEON_FILE_MAGIC, 1)) {
cineon->isMSB = 1;
- if (verbose)
+ if (verbose) {
printf("Cineon: File is MSB.\n");
+ }
}
else if (header.fileHeader.magic_num == CINEON_FILE_MAGIC) {
cineon->isMSB = 0;
- if (verbose)
+ if (verbose) {
printf("Cineon: File is LSB.\n");
+ }
}
else {
if (verbose) {
@@ -209,8 +214,9 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
cineon->height = swap_uint(header.imageHeader.element[0].lines_per_image, cineon->isMSB);
if (cineon->width == 0 || cineon->height == 0) {
- if (verbose)
+ if (verbose) {
printf("Cineon: Wrong image dimension: %dx%d\n", cineon->width, cineon->height);
+ }
logImageClose(cineon);
return NULL;
}
@@ -218,13 +224,16 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
cineon->depth = header.imageHeader.elements_per_image;
cineon->srcFormat = format_Cineon;
- if (header.imageHeader.interleave == 0)
+ if (header.imageHeader.interleave == 0) {
cineon->numElements = 1;
- else if (header.imageHeader.interleave == 2)
+ }
+ else if (header.imageHeader.interleave == 2) {
cineon->numElements = header.imageHeader.elements_per_image;
+ }
else {
- if (verbose)
+ if (verbose) {
printf("Cineon: Data interleave not supported: %d\n", header.imageHeader.interleave);
+ }
logImageClose(cineon);
return NULL;
}
@@ -255,8 +264,9 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
}
}
else {
- if (verbose)
+ if (verbose) {
printf("Cineon: Cineon image depth unsupported: %d\n", cineon->depth);
+ }
logImageClose(cineon);
return NULL;
}
@@ -290,28 +300,34 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
default:
/* Not supported */
- if (verbose)
+ if (verbose) {
printf("Cineon: packing unsupported: %d\n", header.imageHeader.packing);
+ }
logImageClose(cineon);
return NULL;
}
- if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32)
+ if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32) {
cineon->element[i].refLowData = 0;
+ }
- if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32)
+ if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32) {
cineon->element[i].refHighData = (unsigned int)cineon->element[i].maxValue;
+ }
if (cineon->element[i].refLowQuantity == CINEON_UNDEFINED_R32 ||
- isnan(cineon->element[i].refLowQuantity))
+ isnan(cineon->element[i].refLowQuantity)) {
cineon->element[i].refLowQuantity = 0.0f;
+ }
if (cineon->element[i].refHighQuantity == CINEON_UNDEFINED_R32 ||
isnan(cineon->element[i].refHighQuantity)) {
- if (cineon->element[i].transfer == transfer_PrintingDensity)
+ if (cineon->element[i].transfer == transfer_PrintingDensity) {
cineon->element[i].refHighQuantity = 2.048f;
- else
+ }
+ else {
cineon->element[i].refHighQuantity = cineon->element[i].maxValue;
+ }
}
cineon->element[i].dataOffset = dataOffset;
@@ -357,15 +373,17 @@ LogImageFile *cineonCreate(
LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
if (cineon == NULL) {
- if (verbose)
+ if (verbose) {
printf("cineon: Failed to malloc cineon file structure.\n");
+ }
return NULL;
}
/* Only 10 bits Cineon are supported */
if (bitsPerSample != 10) {
- if (verbose)
+ if (verbose) {
printf("cineon: Only 10 bits Cineon are supported.\n");
+ }
logImageClose(cineon);
return NULL;
}
@@ -391,15 +409,18 @@ LogImageFile *cineonCreate(
cineon->gamma = 1.7f;
shortFilename = strrchr(filename, '/');
- if (shortFilename == NULL)
+ if (shortFilename == NULL) {
shortFilename = filename;
- else
+ }
+ else {
shortFilename++;
+ }
cineon->file = BLI_fopen(filename, "wb");
if (cineon->file == NULL) {
- if (verbose)
+ if (verbose) {
printf("cineon: Couldn't open file %s\n", filename);
+ }
logImageClose(cineon);
return NULL;
}
@@ -407,8 +428,9 @@ LogImageFile *cineonCreate(
fillCineonMainHeader(cineon, &header, shortFilename, creator);
if (fwrite(&header, sizeof(header), 1, cineon->file) == 0) {
- if (verbose)
+ if (verbose) {
printf("cineon: Couldn't write image header\n");
+ }
logImageClose(cineon);
return NULL;
}
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index 8c0cd88f256..00d59643967 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -143,8 +143,9 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
int i;
if (dpx == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX: Failed to malloc dpx file structure.\n");
+ }
return NULL;
}
@@ -158,8 +159,9 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
/* byteStuff is then the filename */
dpx->file = BLI_fopen(filename, "rb");
if (dpx->file == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX: Failed to open file \"%s\".\n", filename);
+ }
logImageClose(dpx);
return NULL;
}
@@ -175,8 +177,9 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
}
if (logimage_fread(&header, sizeof(header), 1, dpx) == 0) {
- if (verbose)
+ if (verbose) {
printf("DPX: Not enough data for header in \"%s\".\n", byteStuff);
+ }
logImageClose(dpx);
return NULL;
}
@@ -184,13 +187,15 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
/* endianness determination */
if (header.fileHeader.magic_num == swap_uint(DPX_FILE_MAGIC, 1)) {
dpx->isMSB = 1;
- if (verbose)
+ if (verbose) {
printf("DPX: File is MSB.\n");
+ }
}
else if (header.fileHeader.magic_num == DPX_FILE_MAGIC) {
dpx->isMSB = 0;
- if (verbose)
+ if (verbose) {
printf("DPX: File is LSB.\n");
+ }
}
else {
if (verbose) {
@@ -204,8 +209,9 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
dpx->numElements = swap_ushort(header.imageHeader.elements_per_image, dpx->isMSB);
size_t max_elements = sizeof(header.imageHeader.element) / sizeof(header.imageHeader.element[0]);
if (dpx->numElements == 0 || dpx->numElements >= max_elements) {
- if (verbose)
+ if (verbose) {
printf("DPX: Wrong number of elements: %d\n", dpx->numElements);
+ }
logImageClose(dpx);
return NULL;
}
@@ -214,8 +220,9 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
dpx->height = swap_uint(header.imageHeader.lines_per_element, dpx->isMSB);
if (dpx->width == 0 || dpx->height == 0) {
- if (verbose)
+ if (verbose) {
printf("DPX: Wrong image dimension: %dx%d\n", dpx->width, dpx->height);
+ }
logImageClose(dpx);
return NULL;
}
@@ -262,8 +269,9 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
}
if (dpx->depth == 0 || dpx->depth > 4) {
- if (verbose)
+ if (verbose) {
printf("DPX: Unsupported image depth: %d\n", dpx->depth);
+ }
logImageClose(dpx);
return NULL;
}
@@ -272,10 +280,11 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
if (dpx->element[i].bitsPerSample != 1 && dpx->element[i].bitsPerSample != 8 &&
dpx->element[i].bitsPerSample != 10 && dpx->element[i].bitsPerSample != 12 &&
dpx->element[i].bitsPerSample != 16) {
- if (verbose)
+ if (verbose) {
printf("DPX: Unsupported bitsPerSample for elements %d: %d\n",
i,
dpx->element[i].bitsPerSample);
+ }
logImageClose(dpx);
return NULL;
}
@@ -284,20 +293,23 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
dpx->element[i].packing = swap_ushort(header.imageHeader.element[i].packing, dpx->isMSB);
if (dpx->element[i].packing > 2) {
- if (verbose)
+ if (verbose) {
printf("DPX: Unsupported packing for element %d: %d\n", i, dpx->element[i].packing);
+ }
logImageClose(dpx);
return NULL;
}
/* Sometimes, the offset is not set correctly in the header */
dpx->element[i].dataOffset = swap_uint(header.imageHeader.element[i].data_offset, dpx->isMSB);
- if (dpx->element[i].dataOffset == 0 && dpx->numElements == 1)
+ if (dpx->element[i].dataOffset == 0 && dpx->numElements == 1) {
dpx->element[i].dataOffset = swap_uint(header.fileHeader.offset, dpx->isMSB);
+ }
if (dpx->element[i].dataOffset == 0) {
- if (verbose)
+ if (verbose) {
printf("DPX: Image header is corrupted.\n");
+ }
logImageClose(dpx);
return NULL;
}
@@ -321,23 +333,28 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
case descriptor_RGB:
case descriptor_RGBA:
case descriptor_ABGR:
- if (dpx->element[i].refLowData == DPX_UNDEFINED_U32)
+ if (dpx->element[i].refLowData == DPX_UNDEFINED_U32) {
dpx->element[i].refLowData = 0;
+ }
- if (dpx->element[i].refHighData == DPX_UNDEFINED_U32)
+ if (dpx->element[i].refHighData == DPX_UNDEFINED_U32) {
dpx->element[i].refHighData = (unsigned int)dpx->element[i].maxValue;
+ }
if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 ||
- isnan(dpx->element[i].refLowQuantity))
+ isnan(dpx->element[i].refLowQuantity)) {
dpx->element[i].refLowQuantity = 0.0f;
+ }
if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 ||
isnan(dpx->element[i].refHighQuantity)) {
if (dpx->element[i].transfer == transfer_PrintingDensity ||
- dpx->element[i].transfer == transfer_Logarithmic)
+ dpx->element[i].transfer == transfer_Logarithmic) {
dpx->element[i].refHighQuantity = 2.048f;
- else
+ }
+ else {
dpx->element[i].refHighQuantity = dpx->element[i].maxValue;
+ }
}
break;
@@ -348,19 +365,23 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
case descriptor_CbYCr:
case descriptor_CbYACrYA:
case descriptor_CbYCrA:
- if (dpx->element[i].refLowData == DPX_UNDEFINED_U32)
+ if (dpx->element[i].refLowData == DPX_UNDEFINED_U32) {
dpx->element[i].refLowData = 16.0f / 255.0f * dpx->element[i].maxValue;
+ }
- if (dpx->element[i].refHighData == DPX_UNDEFINED_U32)
+ if (dpx->element[i].refHighData == DPX_UNDEFINED_U32) {
dpx->element[i].refHighData = 235.0f / 255.0f * dpx->element[i].maxValue;
+ }
if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 ||
- isnan(dpx->element[i].refLowQuantity))
+ isnan(dpx->element[i].refLowQuantity)) {
dpx->element[i].refLowQuantity = 0.0f;
+ }
if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 ||
- isnan(dpx->element[i].refHighQuantity))
+ isnan(dpx->element[i].refHighQuantity)) {
dpx->element[i].refHighQuantity = 0.7f;
+ }
break;
@@ -425,8 +446,9 @@ LogImageFile *dpxCreate(const char *filename,
LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
if (dpx == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX: Failed to malloc dpx file structure.\n");
+ }
return NULL;
}
@@ -451,8 +473,9 @@ LogImageFile *dpxCreate(const char *filename,
break;
default:
- if (verbose)
+ if (verbose) {
printf("DPX: bitsPerSample not supported: %d\n", bitsPerSample);
+ }
logImageClose(dpx);
return NULL;
}
@@ -481,32 +504,41 @@ LogImageFile *dpxCreate(const char *filename,
dpx->element[0].refLowData = 0;
dpx->element[0].refHighData = dpx->element[0].maxValue;
- if (referenceWhite > 0)
+ if (referenceWhite > 0) {
dpx->referenceWhite = referenceWhite;
- else
+ }
+ else {
dpx->referenceWhite = 685.0f / 1023.0f * dpx->element[0].maxValue;
+ }
- if (referenceBlack > 0)
+ if (referenceBlack > 0) {
dpx->referenceBlack = referenceBlack;
- else
+ }
+ else {
dpx->referenceBlack = 95.0f / 1023.0f * dpx->element[0].maxValue;
+ }
- if (gamma > 0.0f)
+ if (gamma > 0.0f) {
dpx->gamma = gamma;
- else
+ }
+ else {
dpx->gamma = 1.7f;
+ }
shortFilename = strrchr(filename, '/');
- if (shortFilename == NULL)
+ if (shortFilename == NULL) {
shortFilename = filename;
- else
+ }
+ else {
shortFilename++;
+ }
dpx->file = BLI_fopen(filename, "wb");
if (dpx->file == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX: Couldn't open file %s\n", filename);
+ }
logImageClose(dpx);
return NULL;
}
@@ -514,8 +546,9 @@ LogImageFile *dpxCreate(const char *filename,
fillDpxMainHeader(dpx, &header, shortFilename, creator);
if (fwrite(&header, sizeof(header), 1, dpx->file) == 0) {
- if (verbose)
+ if (verbose) {
printf("DPX: Couldn't write image header\n");
+ }
logImageClose(dpx);
return NULL;
}
@@ -524,8 +557,9 @@ LogImageFile *dpxCreate(const char *filename,
* 6044 = 8092 - sizeof(DpxMainHeader) */
memset(&pad, 0, 6044);
if (fwrite(&pad, 6044, 1, dpx->file) == 0) {
- if (verbose)
+ if (verbose) {
printf("DPX: Couldn't write image header\n");
+ }
logImageClose(dpx);
return NULL;
}
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c
index 2169665cf78..5d1623374d4 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.c
+++ b/source/blender/imbuf/intern/cineon/logImageCore.c
@@ -105,8 +105,9 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon)
(void)cineon;
- if (f == NULL)
+ if (f == NULL) {
return NULL;
+ }
if (fread(&magicNum, sizeof(unsigned int), 1, f) != 1) {
fclose(f);
@@ -115,20 +116,24 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon)
fclose(f);
- if (logImageIsDpx(&magicNum))
+ if (logImageIsDpx(&magicNum)) {
return dpxOpen((const unsigned char *)filename, 0, 0);
- else if (logImageIsCineon(&magicNum))
+ }
+ else if (logImageIsCineon(&magicNum)) {
return cineonOpen((const unsigned char *)filename, 0, 0);
+ }
return NULL;
}
LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size)
{
- if (logImageIsDpx(buffer))
+ if (logImageIsDpx(buffer)) {
return dpxOpen(buffer, 1, size);
- else if (logImageIsCineon(buffer))
+ }
+ else if (logImageIsCineon(buffer)) {
return cineonOpen(buffer, 1, size);
+ }
return NULL;
}
@@ -146,9 +151,10 @@ LogImageFile *logImageCreate(const char *filename,
const char *creator)
{
/* referenceWhite, referenceBlack and gamma values are only supported for DPX file */
- if (cineon)
+ if (cineon) {
return cineonCreate(filename, width, height, bitsPerSample, creator);
- else
+ }
+ else {
return dpxCreate(filename,
width,
height,
@@ -159,6 +165,7 @@ LogImageFile *logImageCreate(const char *filename,
referenceBlack,
gamma,
creator);
+ }
return NULL;
}
@@ -196,16 +203,20 @@ size_t getRowLength(size_t width, LogImageElement logElement)
return ((width * logElement.depth - 1) / 4 + 1) * 4;
case 10:
- if (logElement.packing == 0)
+ if (logElement.packing == 0) {
return ((width * logElement.depth * 10 - 1) / 32 + 1) * 4;
- else if (logElement.packing == 1 || logElement.packing == 2)
+ }
+ else if (logElement.packing == 1 || logElement.packing == 2) {
return ((width * logElement.depth - 1) / 3 + 1) * 4;
+ }
break;
case 12:
- if (logElement.packing == 0)
+ if (logElement.packing == 0) {
return ((width * logElement.depth * 12 - 1) / 32 + 1) * 4;
- else if (logElement.packing == 1 || logElement.packing == 2)
+ }
+ else if (logElement.packing == 1 || logElement.packing == 2) {
return width * logElement.depth * 2;
+ }
break;
case 16:
return width * logElement.depth * 2;
@@ -224,8 +235,9 @@ int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
elementData = (float *)imb_alloc_pixels(
logImage->width, logImage->height, logImage->depth, sizeof(float), __func__);
- if (elementData == NULL)
+ if (elementData == NULL) {
return 1;
+ }
if (convertRGBAToLogElement(
data, elementData, logImage, logImage->element[0], dataIsLinearRGB) != 0) {
@@ -266,19 +278,22 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement,
row = (unsigned char *)MEM_mallocN(rowLength, __func__);
if (row == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Cannot allocate row.\n");
+ }
return 1;
}
memset(row, 0, rowLength);
for (size_t y = 0; y < logImage->height; y++) {
- for (size_t x = 0; x < logImage->width * logImage->depth; x++)
+ for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
row[x] = (unsigned char)float_uint(data[y * logImage->width * logImage->depth + x], 255);
+ }
if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Error while writing file.\n");
+ }
MEM_freeN(row);
return 1;
}
@@ -295,8 +310,9 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement,
row = (unsigned int *)MEM_mallocN(rowLength, __func__);
if (row == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Cannot allocate row.\n");
+ }
return 1;
}
@@ -316,8 +332,9 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement,
offset = 22;
}
}
- if (pixel != 0)
+ if (pixel != 0) {
row[index] = swap_uint(pixel, logImage->isMSB);
+ }
if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
if (verbose) {
@@ -338,20 +355,23 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement,
row = (unsigned short *)MEM_mallocN(rowLength, __func__);
if (row == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Cannot allocate row.\n");
+ }
return 1;
}
for (size_t y = 0; y < logImage->height; y++) {
- for (size_t x = 0; x < logImage->width * logImage->depth; x++)
+ for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
row[x] = swap_ushort(
((unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 4095)) << 4,
logImage->isMSB);
+ }
if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Error while writing file.\n");
+ }
MEM_freeN(row);
return 1;
}
@@ -367,20 +387,23 @@ static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement,
row = (unsigned short *)MEM_mallocN(rowLength, __func__);
if (row == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Cannot allocate row.\n");
+ }
return 1;
}
for (size_t y = 0; y < logImage->height; y++) {
- for (size_t x = 0; x < logImage->width * logImage->depth; x++)
+ for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
row[x] = swap_ushort(
(unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 65535),
logImage->isMSB);
+ }
if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Error while writing file.\n");
+ }
MEM_freeN(row);
return 1;
}
@@ -416,28 +439,35 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
elementData[i] = imb_alloc_pixels(
logImage->width, logImage->height, logImage->element[i].depth, sizeof(float), __func__);
if (elementData[i] == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Cannot allocate memory for elementData[%d]\n.", i);
- for (j = 0; j < i; j++)
- if (elementData[j] != NULL)
+ }
+ for (j = 0; j < i; j++) {
+ if (elementData[j] != NULL) {
MEM_freeN(elementData[j]);
+ }
+ }
return 1;
}
elementData_ptr[i] = elementData[i];
/* Load data */
if (logImageElementGetData(logImage, logImage->element[i], elementData[i]) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Cannot read elementData[%d]\n.", i);
- for (j = 0; j < i; j++)
- if (elementData[j] != NULL)
+ }
+ for (j = 0; j < i; j++) {
+ if (elementData[j] != NULL) {
MEM_freeN(elementData[j]);
+ }
+ }
return 1;
}
}
- if (logImage->element[i].descriptor == descriptor_Alpha)
+ if (logImage->element[i].descriptor == descriptor_Alpha) {
hasAlpha = 1;
+ }
}
/* only one element, easy case, no need to do anything */
@@ -461,28 +491,34 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
switch (logImage->element[i].descriptor) {
case descriptor_Red:
case descriptor_RGB:
- if (hasAlpha == 0)
+ if (hasAlpha == 0) {
mergedElement.descriptor = descriptor_RGB;
- else
+ }
+ else {
mergedElement.descriptor = descriptor_RGBA;
+ }
sortedElementData[0] = i;
break;
case descriptor_Green:
- if (hasAlpha == 0)
+ if (hasAlpha == 0) {
mergedElement.descriptor = descriptor_RGB;
- else
+ }
+ else {
mergedElement.descriptor = descriptor_RGBA;
+ }
sortedElementData[1] = i;
break;
case descriptor_Blue:
- if (hasAlpha == 0)
+ if (hasAlpha == 0) {
mergedElement.descriptor = descriptor_RGB;
- else
+ }
+ else {
mergedElement.descriptor = descriptor_RGBA;
+ }
sortedElementData[2] = i;
break;
@@ -493,57 +529,77 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
break;
case descriptor_Luminance:
- if (mergedElement.descriptor == -1)
- if (hasAlpha == 0)
+ if (mergedElement.descriptor == -1) {
+ if (hasAlpha == 0) {
mergedElement.descriptor = descriptor_Luminance;
- else
+ }
+ else {
mergedElement.descriptor = descriptor_YA;
+ }
+ }
else if (mergedElement.descriptor == descriptor_Chrominance) {
- if (mergedElement.depth == 2)
+ if (mergedElement.depth == 2) {
mergedElement.descriptor = descriptor_CbYCrY;
- else if (mergedElement.depth == 3)
- if (hasAlpha == 0)
+ }
+ else if (mergedElement.depth == 3) {
+ if (hasAlpha == 0) {
mergedElement.descriptor = descriptor_CbYCr;
- else
+ }
+ else {
mergedElement.descriptor = descriptor_CbYACrYA;
- else if (mergedElement.depth == 4)
+ }
+ }
+ else if (mergedElement.depth == 4) {
mergedElement.descriptor = descriptor_CbYCrA;
+ }
}
/* Y component always in 1 except if it's alone or with alpha */
- if (mergedElement.depth == 1 || (mergedElement.depth == 2 && hasAlpha == 1))
+ if (mergedElement.depth == 1 || (mergedElement.depth == 2 && hasAlpha == 1)) {
sortedElementData[0] = i;
- else
+ }
+ else {
sortedElementData[1] = i;
+ }
break;
case descriptor_Chrominance:
- if (mergedElement.descriptor == -1)
+ if (mergedElement.descriptor == -1) {
mergedElement.descriptor = descriptor_Chrominance;
+ }
else if (mergedElement.descriptor == descriptor_Luminance) {
- if (mergedElement.depth == 2)
+ if (mergedElement.depth == 2) {
mergedElement.descriptor = descriptor_CbYCrY;
- else if (mergedElement.depth == 3)
- if (hasAlpha == 0)
+ }
+ else if (mergedElement.depth == 3) {
+ if (hasAlpha == 0) {
mergedElement.descriptor = descriptor_CbYCr;
- else
+ }
+ else {
mergedElement.descriptor = descriptor_CbYACrYA;
- else if (mergedElement.depth == 4)
+ }
+ }
+ else if (mergedElement.depth == 4) {
mergedElement.descriptor = descriptor_CbYCrA;
+ }
}
/* Cb and Cr always in 0 or 2 */
- if (sortedElementData[0] == -1)
+ if (sortedElementData[0] == -1) {
sortedElementData[0] = i;
- else
+ }
+ else {
sortedElementData[2] = i;
+ }
break;
case descriptor_CbYCr:
- if (hasAlpha == 0)
+ if (hasAlpha == 0) {
mergedElement.descriptor = descriptor_CbYCr;
- else
+ }
+ else {
mergedElement.descriptor = descriptor_CbYCrA;
+ }
sortedElementData[0] = i;
break;
@@ -568,25 +624,32 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
mergedData = (float *)imb_alloc_pixels(
logImage->width, logImage->height, mergedElement.depth, sizeof(float), __func__);
if (mergedData == NULL) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Cannot allocate mergedData.\n");
- for (i = 0; i < logImage->numElements; i++)
- if (elementData[i] != NULL)
+ }
+ for (i = 0; i < logImage->numElements; i++) {
+ if (elementData[i] != NULL) {
MEM_freeN(elementData[i]);
+ }
+ }
return 1;
}
sampleIndex = 0;
while (sampleIndex < logImage->width * logImage->height * mergedElement.depth) {
- for (i = 0; i < logImage->numElements; i++)
- for (j = 0; j < logImage->element[sortedElementData[i]].depth; j++)
+ for (i = 0; i < logImage->numElements; i++) {
+ for (j = 0; j < logImage->element[sortedElementData[i]].depth; j++) {
mergedData[sampleIndex++] = *(elementData_ptr[sortedElementData[i]]++);
+ }
+ }
}
/* Done with elements data, clean-up */
- for (i = 0; i < logImage->numElements; i++)
- if (elementData[i] != NULL)
+ for (i = 0; i < logImage->numElements; i++) {
+ if (elementData[i] != NULL) {
MEM_freeN(elementData[i]);
+ }
+ }
returnValue = convertLogElementToRGBA(
mergedData, data, logImage, mergedElement, dataIsLinearRGB);
@@ -605,17 +668,21 @@ static int logImageElementGetData(LogImageFile *logImage, LogImageElement logEle
return logImageElementGetData8(logImage, logElement, data);
case 10:
- if (logElement.packing == 0)
+ if (logElement.packing == 0) {
return logImageElementGetData10Packed(logImage, logElement, data);
- else if (logElement.packing == 1 || logElement.packing == 2)
+ }
+ else if (logElement.packing == 1 || logElement.packing == 2) {
return logImageElementGetData10(logImage, logElement, data);
+ }
break;
case 12:
- if (logElement.packing == 0)
+ if (logElement.packing == 0) {
return logImageElementGetData12Packed(logImage, logElement, data);
- else if (logElement.packing == 1 || logElement.packing == 2)
+ }
+ else if (logElement.packing == 1 || logElement.packing == 2) {
return logImageElementGetData12(logImage, logElement, data);
+ }
break;
case 16:
@@ -631,8 +698,9 @@ static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logEl
/* seek at the right place */
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset);
+ }
return 1;
}
@@ -640,14 +708,16 @@ static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logEl
for (size_t y = 0; y < logImage->height; y++) {
for (size_t x = 0; x < logImage->width * logElement.depth; x += 32) {
if (logimage_read_uint(&pixel, logImage) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: EOF reached\n");
+ }
return 1;
}
pixel = swap_uint(pixel, logImage->isMSB);
- for (int offset = 0; offset < 32 && x + offset < logImage->width; offset++)
+ for (int offset = 0; offset < 32 && x + offset < logImage->width; offset++) {
data[y * logImage->width * logElement.depth + x + offset] = (float)((pixel >> offset) &
0x01);
+ }
}
}
return 0;
@@ -662,15 +732,17 @@ static int logImageElementGetData8(LogImageFile *logImage, LogImageElement logEl
for (size_t y = 0; y < logImage->height; y++) {
/* 8 bits are 32-bits padded so we need to seek at each row */
if (logimage_fseek(logImage, logElement.dataOffset + y * rowLength, SEEK_SET) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Couldn't seek at %d\n", (int)(logElement.dataOffset + y * rowLength));
+ }
return 1;
}
for (size_t x = 0; x < logImage->width * logElement.depth; x++) {
if (logimage_read_uchar(&pixel, logImage) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: EOF reached\n");
+ }
return 1;
}
data[y * logImage->width * logElement.depth + x] = (float)pixel / 255.0f;
@@ -687,8 +759,9 @@ static int logImageElementGetData10(LogImageFile *logImage,
/* seek to data */
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset);
+ }
return 1;
}
@@ -698,14 +771,17 @@ static int logImageElementGetData10(LogImageFile *logImage,
for (size_t x = 0; x < logImage->width * logElement.depth; x++) {
/* we need to read the next long */
if (offset >= 30) {
- if (logElement.packing == 1)
+ if (logElement.packing == 1) {
offset = 2;
- else if (logElement.packing == 2)
+ }
+ else if (logElement.packing == 2) {
offset = 0;
+ }
if (logimage_read_uint(&pixel, logImage) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: EOF reached\n");
+ }
return 1;
}
pixel = swap_uint(pixel, logImage->isMSB);
@@ -722,14 +798,17 @@ static int logImageElementGetData10(LogImageFile *logImage,
for (size_t x = 0; x < logImage->width * logElement.depth; x++) {
/* we need to read the next long */
if (offset < 0) {
- if (logElement.packing == 1)
+ if (logElement.packing == 1) {
offset = 22;
- else if (logElement.packing == 2)
+ }
+ else if (logElement.packing == 2) {
offset = 20;
+ }
if (logimage_read_uint(&pixel, logImage) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: EOF reached\n");
+ }
return 1;
}
pixel = swap_uint(pixel, logImage->isMSB);
@@ -755,9 +834,10 @@ static int logImageElementGetData10Packed(LogImageFile *logImage,
for (size_t y = 0; y < logImage->height; y++) {
/* seek to data */
if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Couldn't seek at %u\n",
(unsigned int)(y * rowLength + logElement.dataOffset));
+ }
return 1;
}
@@ -784,8 +864,9 @@ static int logImageElementGetData10Packed(LogImageFile *logImage,
if (offset == 0) {
/* we need to read the next long */
if (logimage_read_uint(&pixel, logImage) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: EOF reached\n");
+ }
return 1;
}
pixel = swap_uint(pixel, logImage->isMSB);
@@ -808,8 +889,9 @@ static int logImageElementGetData12(LogImageFile *logImage,
/* seek to data */
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset);
+ }
return 1;
}
@@ -818,16 +900,19 @@ static int logImageElementGetData12(LogImageFile *logImage,
for (sampleIndex = 0; sampleIndex < numSamples; sampleIndex++) {
if (logimage_read_ushort(&pixel, logImage) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: EOF reached\n");
+ }
return 1;
}
pixel = swap_ushort(pixel, logImage->isMSB);
- if (logElement.packing == 1) /* padded to the right */
+ if (logElement.packing == 1) { /* padded to the right */
data[sampleIndex] = (float)(pixel >> 4) / 4095.0f;
- else if (logElement.packing == 2) /* padded to the left */
+ }
+ else if (logElement.packing == 2) { /* padded to the left */
data[sampleIndex] = (float)pixel / 4095.0f;
+ }
}
return 0;
}
@@ -843,9 +928,10 @@ static int logImageElementGetData12Packed(LogImageFile *logImage,
for (size_t y = 0; y < logImage->height; y++) {
/* seek to data */
if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Couldn't seek at %u\n",
(unsigned int)(y * rowLength + logElement.dataOffset));
+ }
return 1;
}
@@ -872,8 +958,9 @@ static int logImageElementGetData12Packed(LogImageFile *logImage,
if (offset == 0) {
/* we need to read the next long */
if (logimage_read_uint(&pixel, logImage) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: EOF reached\n");
+ }
return 1;
}
pixel = swap_uint(pixel, logImage->isMSB);
@@ -896,15 +983,17 @@ static int logImageElementGetData16(LogImageFile *logImage,
/* seek to data */
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset);
+ }
return 1;
}
for (sampleIndex = 0; sampleIndex < numSamples; sampleIndex++) {
if (logimage_read_ushort(&pixel, logImage) != 0) {
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: EOF reached\n");
+ }
return 1;
}
pixel = swap_ushort(pixel, logImage->isMSB);
@@ -999,11 +1088,12 @@ static float *getLinToLogLut(LogImageFile *logImage, LogImageElement logElement)
negativeFilmGamma * logImage->gamma / 1.7f));
offset = gain - logElement.maxValue;
- for (i = 0; i < lutsize; i++)
+ for (i = 0; i < lutsize; i++) {
lut[i] = (logImage->referenceWhite +
log10f(powf((i + offset) / gain, 1.7f / logImage->gamma)) /
(step / negativeFilmGamma)) /
logElement.maxValue;
+ }
return lut;
}
@@ -1040,18 +1130,21 @@ static float *getLogToLinLut(LogImageFile *logImage, LogImageElement logElement)
kneeGain = (logElement.maxValue - kneeOffset) / powf(5 * softClip, softClip / 100);
for (i = 0; i < lutsize; i++) {
- if (i < logImage->referenceBlack)
+ if (i < logImage->referenceBlack) {
lut[i] = 0.0f;
- else if (i > breakPoint)
+ }
+ else if (i > breakPoint) {
lut[i] = (powf(i - breakPoint, softClip / 100) * kneeGain + kneeOffset) /
logElement.maxValue;
- else
+ }
+ else {
lut[i] = (powf(10,
((float)i - logImage->referenceWhite) * step / negativeFilmGamma *
logImage->gamma / 1.7f) *
gain -
offset) /
logElement.maxValue;
+ }
}
return lut;
@@ -1067,10 +1160,12 @@ static float *getLinToSrgbLut(LogImageElement logElement)
for (i = 0; i < lutsize; i++) {
col = (float)i / logElement.maxValue;
- if (col < 0.0031308f)
+ if (col < 0.0031308f) {
lut[i] = (col < 0.0f) ? 0.0f : col * 12.92f;
- else
+ }
+ else {
lut[i] = 1.055f * powf(col, 1.0f / 2.4f) - 0.055f;
+ }
}
return lut;
@@ -1086,10 +1181,12 @@ static float *getSrgbToLinLut(LogImageElement logElement)
for (i = 0; i < lutsize; i++) {
col = (float)i / logElement.maxValue;
- if (col < 0.04045f)
+ if (col < 0.04045f) {
lut[i] = (col < 0.0f) ? 0.0f : col * (1.0f / 12.92f);
- else
+ }
+ else {
lut[i] = powf((col + 0.055f) * (1.0f / 1.055f), 2.4f);
+ }
}
return lut;
@@ -1123,10 +1220,12 @@ static int convertRGBA_RGB(float *src,
case transfer_PrintingDensity: {
float *lut;
- if (elementIsSource == 1)
+ if (elementIsSource == 1) {
lut = getLogToLinLut(logImage, logElement);
- else
+ }
+ else {
lut = getLinToLogLut(logImage, logElement);
+ }
for (i = 0; i < logImage->width * logImage->height; i++) {
*(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
@@ -1141,8 +1240,9 @@ static int convertRGBA_RGB(float *src,
}
default:
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Unknown transfer %d.\n", logElement.transfer);
+ }
return 1;
}
}
@@ -1175,10 +1275,12 @@ static int convertRGB_RGBA(float *src,
case transfer_PrintingDensity: {
float *lut;
- if (elementIsSource == 1)
+ if (elementIsSource == 1) {
lut = getLogToLinLut(logImage, logElement);
- else
+ }
+ else {
lut = getLinToLogLut(logImage, logElement);
+ }
for (i = 0; i < logImage->width * logImage->height; i++) {
*(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
@@ -1193,8 +1295,9 @@ static int convertRGB_RGBA(float *src,
}
default:
- if (verbose)
+ if (verbose) {
printf("DPX/Cineon: Unknown transfer %d.\n", logElement.transfer);
+ }
return 1;
}
}
@@ -1220,10 +1323,12 @@ static int convertRGBA_RGBA(float *src,
case transfer_PrintingDensity: {
float *lut;
- if (elementIsSource == 1)
+ if (elementIsSource == 1) {
lut = getLogToLinLut(logImage, logElement);
- else
+ }
+ else {
lut = getLinToLogLut(logImage, logElement);
+ }
for (i = 0; i < logImage->width * logImage->height; i++) {
*(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
@@ -1270,10 +1375,12 @@ static int convertABGR_RGBA(float *src,
case transfer_PrintingDensity: {
float *lut;
- if (elementIsSource == 1)
+ if (elementIsSource == 1) {
lut = getLogToLinLut(logImage, logElement);
- else
+ }
+ else {
lut = getLinToLogLut(logImage, logElement);
+ }
for (i = 0; i < logImage->width * logImage->height; i++) {
src_ptr += 4;
@@ -1304,8 +1411,9 @@ static int convertCbYCr_RGBA(float *src,
float *src_ptr = src;
float *dst_ptr = dst;
- if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
return 1;
+ }
refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1335,8 +1443,9 @@ static int convertCbYCrA_RGBA(float *src,
float *src_ptr = src;
float *dst_ptr = dst;
- if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
return 1;
+ }
refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1367,8 +1476,9 @@ static int convertCbYCrY_RGBA(float *src,
float *src_ptr = src;
float *dst_ptr = dst;
- if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
return 1;
+ }
refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1418,8 +1528,9 @@ static int convertCbYACrYA_RGBA(float *src,
float *src_ptr = src;
float *dst_ptr = dst;
- if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
return 1;
+ }
refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1471,8 +1582,9 @@ static int convertLuminance_RGBA(float *src,
float *src_ptr = src;
float *dst_ptr = dst;
- if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
return 1;
+ }
refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1496,8 +1608,9 @@ static int convertYA_RGBA(float *src,
float *src_ptr = src;
float *dst_ptr = dst;
- if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
+ if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
return 1;
+ }
refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1561,8 +1674,9 @@ static int convertLogElementToRGBA(
return 1;
}
- if (rvalue == 1)
+ if (rvalue == 1) {
return 1;
+ }
else if (dstIsLinearRGB) {
/* convert data from sRGB to Linear RGB via lut */
float *lut = getSrgbToLinLut(logElement);
@@ -1594,8 +1708,9 @@ static int convertRGBAToLogElement(
/* we need to convert src to sRGB */
srgbSrc = (float *)imb_alloc_pixels(
logImage->width, logImage->height, 4, sizeof(float), __func__);
- if (srgbSrc == NULL)
+ if (srgbSrc == NULL) {
return 1;
+ }
memcpy(srgbSrc, src, 4 * (size_t)logImage->width * (size_t)logImage->height * sizeof(float));
srgbSrc_ptr = srgbSrc;
@@ -1611,8 +1726,9 @@ static int convertRGBAToLogElement(
}
MEM_freeN(lut);
}
- else
+ else {
srgbSrc = src;
+ }
/* Convert linear RGBA data in src to format described by logElement in dst */
switch (logElement.descriptor) {
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.h b/source/blender/imbuf/intern/cineon/logImageCore.h
index e01c2e0f117..80e32ffe77e 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.h
+++ b/source/blender/imbuf/intern/cineon/logImageCore.h
@@ -43,7 +43,8 @@ extern "C" {
* Image structure
*/
-/* There are some differences between DPX and Cineon so we need to know from what type of file the datas come from */
+/* There are some differences between DPX and Cineon
+ * so we need to know from what type of file the datas come from. */
enum format {
format_DPX,
format_Cineon,
@@ -212,18 +213,22 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
BLI_INLINE unsigned short swap_ushort(unsigned short x, int swap)
{
- if (swap != 0)
+ if (swap != 0) {
return (x >> 8) | (x << 8);
- else
+ }
+ else {
return x;
+ }
}
BLI_INLINE unsigned int swap_uint(unsigned int x, int swap)
{
- if (swap != 0)
+ if (swap != 0) {
return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
- else
+ }
+ else {
return x;
+ }
}
BLI_INLINE float swap_float(float x, int swap)
@@ -241,40 +246,50 @@ BLI_INLINE float swap_float(float x, int swap)
dat2.b[3] = dat1.b[0];
return dat2.f;
}
- else
+ else {
return x;
+ }
}
/* Other */
BLI_INLINE unsigned int clamp_uint(unsigned int x, unsigned int low, unsigned int high)
{
- if (x > high)
+ if (x > high) {
return high;
- else if (x < low)
+ }
+ else if (x < low) {
return low;
- else
+ }
+ else {
return x;
+ }
}
BLI_INLINE float clamp_float(float x, float low, float high)
{
- if (x > high)
+ if (x > high) {
return high;
- else if (x < low)
+ }
+ else if (x < low) {
return low;
- else
+ }
+ else {
return x;
+ }
}
BLI_INLINE unsigned int float_uint(float value, unsigned int max)
{
- if (value < 0.0f)
+ if (value < 0.0f) {
return 0;
- else if (value > (1.0f - 0.5f / (float)max))
+ }
+ else if (value > (1.0f - 0.5f / (float)max)) {
return max;
- else
+ }
+ else {
return (unsigned int)(((float)max * value) + 0.5f);
+ }
}
#ifdef __cplusplus
diff --git a/source/blender/imbuf/intern/cineon/logmemfile.c b/source/blender/imbuf/intern/cineon/logmemfile.c
index d7ab2855ea3..91351d309de 100644
--- a/source/blender/imbuf/intern/cineon/logmemfile.c
+++ b/source/blender/imbuf/intern/cineon/logmemfile.c
@@ -31,23 +31,27 @@
int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin)
{
- if (logFile->file)
+ if (logFile->file) {
fseek(logFile->file, offset, origin);
+ }
else { /* we're seeking in memory */
if (origin == SEEK_SET) {
- if (offset > logFile->memBufferSize)
+ if (offset > logFile->memBufferSize) {
return 1;
+ }
logFile->memCursor = logFile->memBuffer + offset;
}
else if (origin == SEEK_END) {
- if (offset > logFile->memBufferSize)
+ if (offset > logFile->memBufferSize) {
return 1;
+ }
logFile->memCursor = (logFile->memBuffer + logFile->memBufferSize) - offset;
}
else if (origin == SEEK_CUR) {
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
- if (pos + offset > logFile->memBufferSize)
+ if (pos + offset > logFile->memBufferSize) {
return 1;
+ }
logFile->memCursor += offset;
}
@@ -57,8 +61,9 @@ int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin)
int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile *logFile)
{
- if (logFile->file)
+ if (logFile->file) {
return fwrite(buffer, size, count, logFile->file);
+ }
else { /* we're writing to memory */
/* do nothing as this isn't supported yet */
return count;
@@ -81,8 +86,9 @@ int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *
total_size = size * count;
}
- if (total_size != 0)
+ if (total_size != 0) {
memcpy(buf, logFile->memCursor, total_size);
+ }
return count;
}
@@ -91,8 +97,9 @@ int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *
int logimage_read_uchar(unsigned char *x, LogImageFile *logFile)
{
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
- if (pos + sizeof(unsigned char) > logFile->memBufferSize)
+ if (pos + sizeof(unsigned char) > logFile->memBufferSize) {
return 1;
+ }
*x = *(unsigned char *)logFile->memCursor;
logFile->memCursor += sizeof(unsigned char);
@@ -102,8 +109,9 @@ int logimage_read_uchar(unsigned char *x, LogImageFile *logFile)
int logimage_read_ushort(unsigned short *x, LogImageFile *logFile)
{
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
- if (pos + sizeof(unsigned short) > logFile->memBufferSize)
+ if (pos + sizeof(unsigned short) > logFile->memBufferSize) {
return 1;
+ }
*x = *(unsigned short *)logFile->memCursor;
logFile->memCursor += sizeof(unsigned short);
@@ -113,8 +121,9 @@ int logimage_read_ushort(unsigned short *x, LogImageFile *logFile)
int logimage_read_uint(unsigned int *x, LogImageFile *logFile)
{
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
- if (pos + sizeof(unsigned int) > logFile->memBufferSize)
+ if (pos + sizeof(unsigned int) > logFile->memBufferSize) {
return 1;
+ }
*x = *(unsigned int *)logFile->memCursor;
logFile->memCursor += sizeof(unsigned int);
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index ac35cc10920..f31d4ede693 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -233,16 +233,18 @@ typedef struct ColormanageCache {
static struct MovieCache *colormanage_moviecache_get(const ImBuf *ibuf)
{
- if (!ibuf->colormanage_cache)
+ if (!ibuf->colormanage_cache) {
return NULL;
+ }
return ibuf->colormanage_cache->moviecache;
}
static ColormanageCacheData *colormanage_cachedata_get(const ImBuf *ibuf)
{
- if (!ibuf->colormanage_cache)
+ if (!ibuf->colormanage_cache) {
return NULL;
+ }
return ibuf->colormanage_cache->data;
}
@@ -266,8 +268,9 @@ static bool colormanage_hashcmp(const void *av, const void *bv)
static struct MovieCache *colormanage_moviecache_ensure(ImBuf *ibuf)
{
- if (!ibuf->colormanage_cache)
+ if (!ibuf->colormanage_cache) {
ibuf->colormanage_cache = MEM_callocN(sizeof(ColormanageCache), "imbuf colormanage cache");
+ }
if (!ibuf->colormanage_cache->moviecache) {
struct MovieCache *moviecache;
@@ -285,8 +288,9 @@ static struct MovieCache *colormanage_moviecache_ensure(ImBuf *ibuf)
static void colormanage_cachedata_set(ImBuf *ibuf, ColormanageCacheData *data)
{
- if (!ibuf->colormanage_cache)
+ if (!ibuf->colormanage_cache) {
ibuf->colormanage_cache = MEM_callocN(sizeof(ColormanageCache), "imbuf colormanage cache");
+ }
ibuf->colormanage_cache->data = data;
}
@@ -332,8 +336,8 @@ static ImBuf *colormanage_cache_get_ibuf(ImBuf *ibuf,
struct MovieCache *moviecache = colormanage_moviecache_get(ibuf);
if (!moviecache) {
- /* if there's no moviecache it means no color management was applied on given image buffer before */
-
+ /* If there's no moviecache it means no color management was applied
+ * on given image buffer before. */
return NULL;
}
@@ -425,7 +429,8 @@ static void colormanage_cache_put(ImBuf *ibuf,
cache_ibuf->mall |= IB_rect;
cache_ibuf->flags |= IB_rect;
- /* store data which is needed to check whether cached buffer could be used for color managed display settings */
+ /* Store data which is needed to check whether cached buffer
+ * could be used for color managed display settings. */
cache_data = MEM_callocN(sizeof(ColormanageCacheData), "color manage cache imbuf data");
cache_data->look = view_settings->look;
cache_data->exposure = view_settings->exposure;
@@ -460,8 +465,9 @@ static void colormanage_role_color_space_name_get(OCIO_ConstConfigRcPtr *config,
ociocs = OCIO_configGetColorSpace(config, role);
- if (!ociocs && backup_role)
+ if (!ociocs && backup_role) {
ociocs = OCIO_configGetColorSpace(config, backup_role);
+ }
if (ociocs) {
const char *name = OCIO_colorSpaceGetName(ociocs);
@@ -584,11 +590,13 @@ static void colormanage_free_config(void)
ColorSpace *colorspace_next = colorspace->next;
/* free precomputer processors */
- if (colorspace->to_scene_linear)
+ if (colorspace->to_scene_linear) {
OCIO_processorRelease((OCIO_ConstProcessorRcPtr *)colorspace->to_scene_linear);
+ }
- if (colorspace->from_scene_linear)
+ if (colorspace->from_scene_linear) {
OCIO_processorRelease((OCIO_ConstProcessorRcPtr *)colorspace->from_scene_linear);
+ }
/* free color space itself */
MEM_freeN(colorspace);
@@ -604,11 +612,13 @@ static void colormanage_free_config(void)
ColorManagedDisplay *display_next = display->next;
/* free precomputer processors */
- if (display->to_scene_linear)
+ if (display->to_scene_linear) {
OCIO_processorRelease((OCIO_ConstProcessorRcPtr *)display->to_scene_linear);
+ }
- if (display->from_scene_linear)
+ if (display->from_scene_linear) {
OCIO_processorRelease((OCIO_ConstProcessorRcPtr *)display->from_scene_linear);
+ }
/* free list of views */
BLI_freelistN(&display->views);
@@ -699,26 +709,33 @@ void colormanagement_init(void)
void colormanagement_exit(void)
{
- if (global_glsl_state.processor)
+ if (global_glsl_state.processor) {
OCIO_processorRelease(global_glsl_state.processor);
+ }
- if (global_glsl_state.curve_mapping)
+ if (global_glsl_state.curve_mapping) {
curvemapping_free(global_glsl_state.curve_mapping);
+ }
- if (global_glsl_state.curve_mapping_settings.lut)
+ if (global_glsl_state.curve_mapping_settings.lut) {
MEM_freeN(global_glsl_state.curve_mapping_settings.lut);
+ }
- if (global_glsl_state.ocio_glsl_state)
+ if (global_glsl_state.ocio_glsl_state) {
OCIO_freeOGLState(global_glsl_state.ocio_glsl_state);
+ }
- if (global_glsl_state.transform_ocio_glsl_state)
+ if (global_glsl_state.transform_ocio_glsl_state) {
OCIO_freeOGLState(global_glsl_state.transform_ocio_glsl_state);
+ }
- if (global_color_picking_state.processor_to)
+ if (global_color_picking_state.processor_to) {
OCIO_processorRelease(global_color_picking_state.processor_to);
+ }
- if (global_color_picking_state.processor_from)
+ if (global_color_picking_state.processor_from) {
OCIO_processorRelease(global_color_picking_state.processor_from);
+ }
memset(&global_glsl_state, 0, sizeof(global_glsl_state));
memset(&global_color_picking_state, 0, sizeof(global_color_picking_state));
@@ -766,8 +783,9 @@ void IMB_colormanagement_display_settings_from_ctx(
*display_settings_r = &scene->display_settings;
if (sima && sima->image) {
- if ((sima->image->flag & IMA_VIEW_AS_RENDER) == 0)
+ if ((sima->image->flag & IMA_VIEW_AS_RENDER) == 0) {
*view_settings_r = NULL;
+ }
}
}
@@ -795,8 +813,9 @@ static ColorSpace *display_transform_get_colorspace(
const char *colorspace_name = IMB_colormanagement_get_display_colorspace_name(view_settings,
display_settings);
- if (colorspace_name)
+ if (colorspace_name) {
return colormanage_colorspace_get_named(colorspace_name);
+ }
return NULL;
}
@@ -1037,8 +1056,9 @@ void colormanage_imbuf_make_linear(ImBuf *ibuf, const char *from_colorspace)
if (ibuf->rect_float) {
const char *to_colorspace = global_role_scene_linear;
- if (ibuf->rect)
+ if (ibuf->rect) {
imb_freerectImBuf(ibuf);
+ }
IMB_colormanagement_transform(
ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, true);
@@ -1084,13 +1104,15 @@ static void colormanage_check_view_settings(ColorManagedDisplaySettings *display
if (view_settings->view_transform[0] == '\0') {
display = colormanage_display_get_named(display_settings->display_device);
- if (display)
+ if (display) {
default_view = colormanage_view_get_default(display);
+ }
- if (default_view)
+ if (default_view) {
BLI_strncpy(view_settings->view_transform,
default_view->name,
sizeof(view_settings->view_transform));
+ }
}
else {
ColorManagedView *view = colormanage_view_get_named(view_settings->view_transform);
@@ -1098,8 +1120,9 @@ static void colormanage_check_view_settings(ColorManagedDisplaySettings *display
if (!view) {
display = colormanage_display_get_named(display_settings->display_device);
- if (display)
+ if (display) {
default_view = colormanage_view_get_default(display);
+ }
if (default_view) {
printf("Color management: %s view \"%s\" not found, setting default \"%s\".\n",
@@ -1223,13 +1246,15 @@ void IMB_colormanagement_validate_settings(const ColorManagedDisplaySettings *di
for (view_link = display->views.first; view_link; view_link = view_link->next) {
ColorManagedView *view = view_link->data;
- if (STREQ(view->name, view_settings->view_transform))
+ if (STREQ(view->name, view_settings->view_transform)) {
break;
+ }
}
- if (view_link == NULL && default_view)
+ if (view_link == NULL && default_view) {
BLI_strncpy(
view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform));
+ }
}
const char *IMB_colormanagement_role_colorspace_name_get(int role)
@@ -1260,10 +1285,12 @@ void IMB_colormanagement_check_is_data(ImBuf *ibuf, const char *name)
{
ColorSpace *colorspace = colormanage_colorspace_get_named(name);
- if (colorspace && colorspace->is_data)
+ if (colorspace && colorspace->is_data) {
ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
- else
+ }
+ else {
ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
+ }
}
void IMB_colormanagement_assign_float_colorspace(ImBuf *ibuf, const char *name)
@@ -1272,10 +1299,12 @@ void IMB_colormanagement_assign_float_colorspace(ImBuf *ibuf, const char *name)
ibuf->float_colorspace = colorspace;
- if (colorspace && colorspace->is_data)
+ if (colorspace && colorspace->is_data) {
ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
- else
+ }
+ else {
ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
+ }
}
void IMB_colormanagement_assign_rect_colorspace(ImBuf *ibuf, const char *name)
@@ -1284,10 +1313,12 @@ void IMB_colormanagement_assign_rect_colorspace(ImBuf *ibuf, const char *name)
ibuf->rect_colorspace = colorspace;
- if (colorspace && colorspace->is_data)
+ if (colorspace && colorspace->is_data) {
ibuf->colormanage_flag |= IMB_COLORMANAGE_IS_DATA;
- else
+ }
+ else {
ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
+ }
}
const char *IMB_colormanagement_get_float_colorspace(ImBuf *ibuf)
@@ -1368,17 +1399,21 @@ static void display_buffer_init_handle(void *handle_v,
handle->cm_processor = init_data->cm_processor;
- if (init_data->buffer)
+ if (init_data->buffer) {
handle->buffer = init_data->buffer + offset;
+ }
- if (init_data->byte_buffer)
+ if (init_data->byte_buffer) {
handle->byte_buffer = init_data->byte_buffer + offset;
+ }
- if (init_data->display_buffer)
+ if (init_data->display_buffer) {
handle->display_buffer = init_data->display_buffer + offset;
+ }
- if (init_data->display_buffer_byte)
+ if (init_data->display_buffer_byte) {
handle->display_buffer_byte = init_data->display_buffer_byte + display_buffer_byte_offset;
+ }
handle->width = ibuf->x;
@@ -1619,8 +1654,9 @@ static bool is_ibuf_rect_in_display_space(ImBuf *ibuf,
return false;
}
- if (to_colorspace && STREQ(from_colorspace, to_colorspace))
+ if (to_colorspace && STREQ(from_colorspace, to_colorspace)) {
return true;
+ }
}
return false;
@@ -1645,8 +1681,9 @@ static void colormanage_display_buffer_process_ex(
skip_transform = is_ibuf_rect_in_display_space(ibuf, view_settings, display_settings);
}
- if (skip_transform == false)
+ if (skip_transform == false) {
cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings);
+ }
display_buffer_apply_threaded(ibuf,
ibuf->rect_float,
@@ -1655,8 +1692,9 @@ static void colormanage_display_buffer_process_ex(
display_buffer_byte,
cm_processor);
- if (cm_processor)
+ if (cm_processor) {
IMB_colormanagement_processor_free(cm_processor);
+ }
}
static void colormanage_display_buffer_process(ImBuf *ibuf,
@@ -1798,7 +1836,8 @@ static void processor_transform_apply_threaded(unsigned char *byte_buffer,
/*********************** Color space transformation functions *************************/
-/* convert the whole buffer from specified by name color space to another - internal implementation */
+/* Convert the whole buffer from specified by name color space to another -
+ * internal implementation. */
static void colormanagement_transform_ex(unsigned char *byte_buffer,
float *float_buffer,
int width,
@@ -1986,8 +2025,9 @@ void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpac
processor = colorspace_to_scene_linear_processor(colorspace);
- if (processor)
+ if (processor) {
OCIO_processorApplyRGB(processor, pixel);
+ }
}
/* same as above, but converts colors in opposite direction */
@@ -2003,8 +2043,9 @@ void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], ColorSpac
processor = colorspace_from_scene_linear_processor(colorspace);
- if (processor)
+ if (processor) {
OCIO_processorApplyRGB(processor, pixel);
+ }
}
void IMB_colormanagement_colorspace_to_scene_linear_v4(float pixel[4],
@@ -2022,10 +2063,12 @@ void IMB_colormanagement_colorspace_to_scene_linear_v4(float pixel[4],
processor = colorspace_to_scene_linear_processor(colorspace);
if (processor) {
- if (predivide)
+ if (predivide) {
OCIO_processorApplyRGBA_predivide(processor, pixel);
- else
+ }
+ else {
OCIO_processorApplyRGBA(processor, pixel);
+ }
}
}
@@ -2057,10 +2100,12 @@ void IMB_colormanagement_colorspace_to_scene_linear(float *buffer,
(size_t)channels * sizeof(float),
(size_t)channels * sizeof(float) * width);
- if (predivide)
+ if (predivide) {
OCIO_processorApply_predivide(processor, img);
- else
+ }
+ else {
OCIO_processorApply(processor, img);
+ }
OCIO_PackedImageDescRelease(img);
}
@@ -2146,8 +2191,9 @@ void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManaged
processor = display_from_scene_linear_processor(display);
- if (processor)
+ if (processor) {
OCIO_processorApplyRGB(processor, pixel);
+ }
}
/* same as above, but converts color in opposite direction */
@@ -2157,8 +2203,9 @@ void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], ColorManaged
processor = display_to_scene_linear_processor(display);
- if (processor)
+ if (processor) {
OCIO_processorApplyRGB(processor, pixel);
+ }
}
void IMB_colormanagement_pixel_to_display_space_v4(
@@ -2197,8 +2244,9 @@ static void colormanagement_imbuf_make_display_space(
const ColorManagedDisplaySettings *display_settings,
bool make_byte)
{
- if (!ibuf->rect && make_byte)
+ if (!ibuf->rect && make_byte) {
imb_addrectImBuf(ibuf);
+ }
colormanage_display_buffer_process_ex(
ibuf, ibuf->rect_float, (unsigned char *)ibuf->rect, view_settings, display_settings);
@@ -2249,8 +2297,9 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
colormanaged_ibuf = IMB_dupImBuf(ibuf);
}
else {
- /* render pipeline is constructing image buffer itself, but it's re-using byte and float buffers from render result
- * make copy of this buffers here sine this buffers would be transformed to other color space here
+ /* Render pipeline is constructing image buffer itself,
+ * but it's re-using byte and float buffers from render result make copy of this buffers
+ * here sine this buffers would be transformed to other color space here.
*/
if (ibuf->rect && (ibuf->mall & IB_rect) == 0) {
@@ -2313,8 +2362,9 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
*/
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
if (type->save && type->ftype(type, colormanaged_ibuf)) {
- if ((type->flag & IM_FTYPE_FLOAT) == 0)
+ if ((type->flag & IM_FTYPE_FLOAT) == 0) {
make_byte = true;
+ }
break;
}
@@ -2397,8 +2447,9 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf,
*cache_handle = NULL;
- if (!ibuf->x || !ibuf->y)
+ if (!ibuf->x || !ibuf->y) {
return NULL;
+ }
if (view_settings) {
applied_view_settings = view_settings;
@@ -2414,8 +2465,9 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf,
* let's just use if
*/
if (ibuf->rect_float == NULL && ibuf->rect_colorspace && ibuf->channels == 4) {
- if (is_ibuf_rect_in_display_space(ibuf, applied_view_settings, display_settings))
+ if (is_ibuf_rect_in_display_space(ibuf, applied_view_settings, display_settings)) {
return (unsigned char *)ibuf->rect;
+ }
}
colormanage_view_settings_to_cache(ibuf, &cache_view_settings, applied_view_settings);
@@ -2555,8 +2607,9 @@ ColorManagedDisplay *colormanage_display_get_default(void)
{
const char *display_name = colormanage_display_get_default_name();
- if (display_name[0] == '\0')
+ if (display_name[0] == '\0') {
return NULL;
+ }
return colormanage_display_get_named(display_name);
}
@@ -2588,8 +2641,9 @@ ColorManagedDisplay *colormanage_display_get_named(const char *name)
ColorManagedDisplay *display;
for (display = global_displays.first; display; display = display->next) {
- if (STREQ(display->name, name))
+ if (STREQ(display->name, name)) {
return display;
+ }
}
return NULL;
@@ -2642,8 +2696,9 @@ ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name)
const char *IMB_colormanagement_display_get_none_name(void)
{
- if (colormanage_display_get_named("None") != NULL)
+ if (colormanage_display_get_named("None") != NULL) {
return "None";
+ }
return colormanage_display_get_default_name();
}
@@ -2672,8 +2727,9 @@ ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay *displa
{
const char *name = colormanage_view_get_default_name(display);
- if (!name || name[0] == '\0')
+ if (!name || name[0] == '\0') {
return NULL;
+ }
return colormanage_view_get_named(name);
}
@@ -2699,8 +2755,9 @@ ColorManagedView *colormanage_view_get_named(const char *name)
ColorManagedView *view;
for (view = global_views.first; view; view = view->next) {
- if (STREQ(view->name, name))
+ if (STREQ(view->name, name)) {
return view;
+ }
}
return NULL;
@@ -2755,11 +2812,13 @@ const char *IMB_colormanagement_view_get_default_name(const char *display_name)
ColorManagedDisplay *display = colormanage_display_get_named(display_name);
ColorManagedView *view = NULL;
- if (display)
+ if (display) {
view = colormanage_view_get_default(display);
+ }
- if (view)
+ if (view) {
return view->name;
+ }
return NULL;
}
@@ -2808,16 +2867,19 @@ ColorSpace *colormanage_colorspace_add(const char *name,
colorspace->is_data = is_data;
for (prev_space = global_colorspaces.first; prev_space; prev_space = prev_space->next) {
- if (BLI_strcasecmp(prev_space->name, colorspace->name) > 0)
+ if (BLI_strcasecmp(prev_space->name, colorspace->name) > 0) {
break;
+ }
prev_space->index = counter++;
}
- if (!prev_space)
+ if (!prev_space) {
BLI_addtail(&global_colorspaces, colorspace);
- else
+ }
+ else {
BLI_insertlinkbefore(&global_colorspaces, prev_space, colorspace);
+ }
colorspace->index = counter++;
for (; prev_space; prev_space = prev_space->next) {
@@ -2834,8 +2896,9 @@ ColorSpace *colormanage_colorspace_get_named(const char *name)
ColorSpace *colorspace;
for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) {
- if (STREQ(colorspace->name, name))
+ if (STREQ(colorspace->name, name)) {
return colorspace;
+ }
}
return NULL;
@@ -3067,8 +3130,9 @@ void IMB_colormanagement_colorspace_items_add(EnumPropertyItem **items, int *tot
for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) {
EnumPropertyItem item;
- if (!colorspace->is_invertible)
+ if (!colorspace->is_invertible) {
continue;
+ }
item.value = colorspace->index;
item.name = colorspace->name;
@@ -3124,8 +3188,9 @@ static void partial_buffer_update_rect(ImBuf *ibuf,
* (this is only needed to apply dither, in other cases we'll convert
* byte buffer to display directly)
*/
- if (!cm_processor)
+ if (!cm_processor) {
channels = 4;
+ }
display_buffer_float = MEM_callocN((size_t)channels * width * height * sizeof(float),
"display buffer for dither");
@@ -3499,8 +3564,9 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new(
}
display_space = display_transform_get_colorspace(applied_view_settings, display_settings);
- if (display_space)
+ if (display_space) {
cm_processor->is_data_result = display_space->is_data;
+ }
cm_processor->processor = create_display_buffer_processor(applied_view_settings->look,
applied_view_settings->view_transform,
@@ -3535,30 +3601,36 @@ ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *f
void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4])
{
- if (cm_processor->curve_mapping)
+ if (cm_processor->curve_mapping) {
curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel);
+ }
- if (cm_processor->processor)
+ if (cm_processor->processor) {
OCIO_processorApplyRGBA(cm_processor->processor, pixel);
+ }
}
void IMB_colormanagement_processor_apply_v4_predivide(ColormanageProcessor *cm_processor,
float pixel[4])
{
- if (cm_processor->curve_mapping)
+ if (cm_processor->curve_mapping) {
curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel);
+ }
- if (cm_processor->processor)
+ if (cm_processor->processor) {
OCIO_processorApplyRGBA_predivide(cm_processor->processor, pixel);
+ }
}
void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3])
{
- if (cm_processor->curve_mapping)
+ if (cm_processor->curve_mapping) {
curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel);
+ }
- if (cm_processor->processor)
+ if (cm_processor->processor) {
OCIO_processorApplyRGB(cm_processor->processor, pixel);
+ }
}
void IMB_colormanagement_processor_apply_pixel(struct ColormanageProcessor *cm_processor,
@@ -3614,10 +3686,12 @@ void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor,
(size_t)channels * sizeof(float),
(size_t)channels * sizeof(float) * width);
- if (predivide)
+ if (predivide) {
OCIO_processorApply_predivide(cm_processor->processor, img);
- else
+ }
+ else {
OCIO_processorApply(cm_processor->processor, img);
+ }
OCIO_PackedImageDescRelease(img);
}
@@ -3643,10 +3717,12 @@ void IMB_colormanagement_processor_apply_byte(
void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor)
{
- if (cm_processor->curve_mapping)
+ if (cm_processor->curve_mapping) {
curvemapping_free(cm_processor->curve_mapping);
- if (cm_processor->processor)
+ }
+ if (cm_processor->processor) {
OCIO_processorRelease(cm_processor->processor);
+ }
MEM_freeN(cm_processor);
}
@@ -3761,8 +3837,9 @@ static void update_glsl_display_processor(const ColorManagedViewSettings *view_s
}
/* Free old processor, if any. */
- if (global_glsl_state.processor)
+ if (global_glsl_state.processor) {
OCIO_processorRelease(global_glsl_state.processor);
+ }
/* We're using display OCIO processor, no RGB curves yet. */
global_glsl_state.processor = create_display_buffer_processor(global_glsl_state.look,
@@ -3789,7 +3866,7 @@ bool IMB_colormanagement_support_glsl_draw(const ColorManagedViewSettings *UNUSE
* When there's no need to apply transform on 2D textures, use
* IMB_colormanagement_finish_glsl_draw().
*
- * This is low-level function, use glaDrawImBuf_glsl_ctx if you
+ * This is low-level function, use ED_draw_imbuf_ctx if you
* only need to display given image buffer
*/
bool IMB_colormanagement_setup_glsl_draw_from_space(
@@ -3843,7 +3920,10 @@ bool IMB_colormanagement_setup_glsl_draw(const ColorManagedViewSettings *view_se
view_settings, display_settings, NULL, dither, predivide);
}
-/* Same as setup_glsl_draw_from_space, but color management settings are guessing from a given context */
+/**
+ * Same as setup_glsl_draw_from_space,
+ * but color management settings are guessing from a given context.
+ */
bool IMB_colormanagement_setup_glsl_draw_from_space_ctx(const bContext *C,
struct ColorSpace *from_colorspace,
float dither,
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp
index 9211f6a7ba6..b1ca6221753 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.cpp
+++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp
@@ -53,9 +53,9 @@
#include <ColorBlock.h>
#include <BlockDXT.h>
-/*----------------------------------------------------------------------------
- BlockDXT1
-----------------------------------------------------------------------------*/
+/* ---------------------------------------------------------------------------
+ * BlockDXT1
+ * --------------------------------------------------------------------------*/
uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
{
@@ -262,9 +262,9 @@ inline void BlockDXT1::flip2()
swap(row[0], row[1]);
}
-/*----------------------------------------------------------------------------
- BlockDXT3
-----------------------------------------------------------------------------*/
+/* ---------------------------------------------------------------------------
+ * BlockDXT3
+ * ---------------------------------------------------------------------------*/
void BlockDXT3::decodeBlock(ColorBlock *block) const
{
@@ -328,9 +328,9 @@ void BlockDXT3::flip2()
color.flip2();
}
-/*----------------------------------------------------------------------------
- BlockDXT5
-----------------------------------------------------------------------------*/
+/* ---------------------------------------------------------------------------
+ * BlockDXT5
+ * ---------------------------------------------------------------------------*/
void AlphaBlockDXT5::evaluatePalette(uint8 alpha[8]) const
{
@@ -610,8 +610,9 @@ void mem_read(Stream &mem, BlockDXT1 &block)
void mem_read(Stream &mem, AlphaBlockDXT3 &block)
{
- for (unsigned int i = 0; i < 4; i++)
+ for (unsigned int i = 0; i < 4; i++) {
mem_read(mem, block.row[i]);
+ }
}
void mem_read(Stream &mem, BlockDXT3 &block)
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h
index c13fa42dcdc..b167fba71a2 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.h
+++ b/source/blender/imbuf/intern/dds/BlockDXT.h
@@ -138,22 +138,22 @@ struct AlphaBlockDXT5 {
struct {
uint64 alpha0 : 8; // 8
uint64 alpha1 : 8; // 16
- uint64 bits0 : 3; // 3 - 19
+ uint64 bits0 : 3; // 3 - 19
uint64 bits1 : 3; // 6 - 22
uint64 bits2 : 3; // 9 - 25
- uint64 bits3 : 3; // 12 - 28
- uint64 bits4 : 3; // 15 - 31
- uint64 bits5 : 3; // 18 - 34
- uint64 bits6 : 3; // 21 - 37
- uint64 bits7 : 3; // 24 - 40
- uint64 bits8 : 3; // 27 - 43
+ uint64 bits3 : 3; // 12 - 28
+ uint64 bits4 : 3; // 15 - 31
+ uint64 bits5 : 3; // 18 - 34
+ uint64 bits6 : 3; // 21 - 37
+ uint64 bits7 : 3; // 24 - 40
+ uint64 bits8 : 3; // 27 - 43
uint64 bits9 : 3; // 30 - 46
uint64 bitsA : 3; // 33 - 49
- uint64 bitsB : 3; // 36 - 52
- uint64 bitsC : 3; // 39 - 55
- uint64 bitsD : 3; // 42 - 58
- uint64 bitsE : 3; // 45 - 61
- uint64 bitsF : 3; // 48 - 64
+ uint64 bitsB : 3; // 36 - 52
+ uint64 bitsC : 3; // 39 - 55
+ uint64 bitsD : 3; // 42 - 58
+ uint64 bitsE : 3; // 45 - 61
+ uint64 bitsF : 3; // 48 - 64
};
uint64 u;
};
diff --git a/source/blender/imbuf/intern/dds/Color.h b/source/blender/imbuf/intern/dds/Color.h
index 16432ffa715..36e2615759b 100644
--- a/source/blender/imbuf/intern/dds/Color.h
+++ b/source/blender/imbuf/intern/dds/Color.h
@@ -47,9 +47,20 @@ class Color32 {
{
setRGBA(R, G, B, A);
}
- //Color32(unsigned char c[4]) { setRGBA(c[0], c[1], c[2], c[3]); }
- //Color32(float R, float G, float B) { setRGBA(uint(R*255), uint(G*255), uint(B*255), 0xFF); }
- //Color32(float R, float G, float B, float A) { setRGBA(uint(R*255), uint(G*255), uint(B*255), uint(A*255)); }
+#if 0
+ Color32(unsigned char c[4])
+ {
+ setRGBA(c[0], c[1], c[2], c[3]);
+ }
+ Color32(float R, float G, float B)
+ {
+ setRGBA(uint(R * 255), uint(G * 255), uint(B * 255), 0xFF);
+ }
+ Color32(float R, float G, float B, float A)
+ {
+ setRGBA(uint(R * 255), uint(G * 255), uint(B * 255), uint(A * 255));
+ }
+#endif
Color32(unsigned int U) : u(U)
{
}
diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp
index 73397cd036e..581d740c97c 100644
--- a/source/blender/imbuf/intern/dds/ColorBlock.cpp
+++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp
@@ -32,17 +32,18 @@
#include <Common.h>
#if 0
- // Get approximate luminance.
- inline static uint colorLuminance(Color32 c)
- {
- return c.r + c.g + c.b;
- }
+// Get approximate luminance.
+inline static uint colorLuminance(Color32 c)
+{
+ return c.r + c.g + c.b;
+}
- // Get the euclidean distance between the given colors.
- inline static uint colorDistance(Color32 c0, Color32 c1)
- {
- return (c0.r - c1.r) * (c0.r - c1.r) + (c0.g - c1.g) * (c0.g - c1.g) + (c0.b - c1.b) * (c0.b - c1.b);
- }
+// Get the euclidean distance between the given colors.
+inline static uint colorDistance(Color32 c0, Color32 c1)
+{
+ return (c0.r - c1.r) * (c0.r - c1.r) + (c0.g - c1.g) * (c0.g - c1.g) +
+ (c0.b - c1.b) * (c0.b - c1.b);
+}
#endif
/// Default constructor.
@@ -129,16 +130,21 @@ void ColorBlock::init(uint w, uint h, const float *data, uint x, uint y)
static inline uint8 component(Color32 c, uint i)
{
- if (i == 0)
+ if (i == 0) {
return c.r;
- if (i == 1)
+ }
+ if (i == 1) {
return c.g;
- if (i == 2)
+ }
+ if (i == 2) {
return c.b;
- if (i == 3)
+ }
+ if (i == 3) {
return c.a;
- if (i == 4)
+ }
+ if (i == 4) {
return 0xFF;
+ }
return 0;
}
@@ -173,18 +179,16 @@ bool ColorBlock::isSingleColorNoAlpha() const
{
Color32 c;
int i;
- for (i = 0; i < 16; i++)
- {
- if (m_color[i].a != 0) c = m_color[i];
+ for (i = 0; i < 16; i++) {
+ if (m_color[i].a != 0)
+ c = m_color[i];
}
Color32 mask(0xFF, 0xFF, 0xFF, 0x00);
uint u = c.u & mask.u;
- for (; i < 16; i++)
- {
- if (u != (m_color[i].u & mask.u))
- {
+ for (; i < 16; i++) {
+ if (u != (m_color[i].u & mask.u)) {
return false;
}
}
@@ -200,16 +204,15 @@ uint ColorBlock::countUniqueColors() const
uint count = 0;
// @@ This does not have to be o(n^2)
- for (int i = 0; i < 16; i++)
- {
+ for (int i = 0; i < 16; i++) {
bool unique = true;
for (int j = 0; j < i; j++) {
- if ( m_color[i] != m_color[j] ) {
+ if (m_color[i] != m_color[j]) {
unique = false;
}
}
- if ( unique ) {
+ if (unique) {
count++;
}
}
@@ -240,8 +243,9 @@ Color32 ColorBlock::averageColor() const
bool ColorBlock::hasAlpha() const
{
for (uint i = 0; i < 16; i++) {
- if (m_color[i].a != 255)
+ if (m_color[i].a != 255) {
return true;
+ }
}
return false;
}
@@ -255,9 +259,9 @@ void ColorBlock::diameterRange(Color32 *start, Color32 *end) const
uint best_dist = 0;
for (int i = 0; i < 16; i++) {
- for (int j = i+1; j < 16; j++) {
+ for (int j = i + 1; j < 16; j++) {
uint dist = colorDistance(m_color[i], m_color[j]);
- if ( dist > best_dist ) {
+ if (dist > best_dist) {
best_dist = dist;
c0 = m_color[i];
c1 = m_color[j];
@@ -277,8 +281,7 @@ void ColorBlock::luminanceRange(Color32 *start, Color32 *end) const
maxLuminance = minLuminance = colorLuminance(m_color[0]);
- for (uint i = 1; i < 16; i++)
- {
+ for (uint i = 1; i < 16; i++) {
uint luminance = colorLuminance(m_color[i]);
if (luminance > maxLuminance) {
@@ -301,14 +304,25 @@ void ColorBlock::boundsRange(Color32 *start, Color32 *end) const
Color32 minColor(255, 255, 255);
Color32 maxColor(0, 0, 0);
- for (uint i = 0; i < 16; i++)
- {
- if (m_color[i].r < minColor.r) { minColor.r = m_color[i].r; }
- if (m_color[i].g < minColor.g) { minColor.g = m_color[i].g; }
- if (m_color[i].b < minColor.b) { minColor.b = m_color[i].b; }
- if (m_color[i].r > maxColor.r) { maxColor.r = m_color[i].r; }
- if (m_color[i].g > maxColor.g) { maxColor.g = m_color[i].g; }
- if (m_color[i].b > maxColor.b) { maxColor.b = m_color[i].b; }
+ for (uint i = 0; i < 16; i++) {
+ if (m_color[i].r < minColor.r) {
+ minColor.r = m_color[i].r;
+ }
+ if (m_color[i].g < minColor.g) {
+ minColor.g = m_color[i].g;
+ }
+ if (m_color[i].b < minColor.b) {
+ minColor.b = m_color[i].b;
+ }
+ if (m_color[i].r > maxColor.r) {
+ maxColor.r = m_color[i].r;
+ }
+ if (m_color[i].g > maxColor.g) {
+ maxColor.g = m_color[i].g;
+ }
+ if (m_color[i].b > maxColor.b) {
+ maxColor.b = m_color[i].b;
+ }
}
// Offset range by 1/16 of the extents
@@ -335,16 +349,31 @@ void ColorBlock::boundsRangeAlpha(Color32 *start, Color32 *end) const
Color32 minColor(255, 255, 255, 255);
Color32 maxColor(0, 0, 0, 0);
- for (uint i = 0; i < 16; i++)
- {
- if (m_color[i].r < minColor.r) { minColor.r = m_color[i].r; }
- if (m_color[i].g < minColor.g) { minColor.g = m_color[i].g; }
- if (m_color[i].b < minColor.b) { minColor.b = m_color[i].b; }
- if (m_color[i].a < minColor.a) { minColor.a = m_color[i].a; }
- if (m_color[i].r > maxColor.r) { maxColor.r = m_color[i].r; }
- if (m_color[i].g > maxColor.g) { maxColor.g = m_color[i].g; }
- if (m_color[i].b > maxColor.b) { maxColor.b = m_color[i].b; }
- if (m_color[i].a > maxColor.a) { maxColor.a = m_color[i].a; }
+ for (uint i = 0; i < 16; i++) {
+ if (m_color[i].r < minColor.r) {
+ minColor.r = m_color[i].r;
+ }
+ if (m_color[i].g < minColor.g) {
+ minColor.g = m_color[i].g;
+ }
+ if (m_color[i].b < minColor.b) {
+ minColor.b = m_color[i].b;
+ }
+ if (m_color[i].a < minColor.a) {
+ minColor.a = m_color[i].a;
+ }
+ if (m_color[i].r > maxColor.r) {
+ maxColor.r = m_color[i].r;
+ }
+ if (m_color[i].g > maxColor.g) {
+ maxColor.g = m_color[i].g;
+ }
+ if (m_color[i].b > maxColor.b) {
+ maxColor.b = m_color[i].b;
+ }
+ if (m_color[i].a > maxColor.a) {
+ maxColor.a = m_color[i].a;
+ }
}
// Offset range by 1/16 of the extents
@@ -374,19 +403,19 @@ void ColorBlock::boundsRangeAlpha(Color32 *start, Color32 *end) const
void ColorBlock::sortColorsByAbsoluteValue()
{
// Dummy selection sort.
- for ( uint a = 0; a < 16; a++ ) {
+ for (uint a = 0; a < 16; a++) {
uint max = a;
Color16 cmax(m_color[a]);
- for ( uint b = a+1; b < 16; b++ ) {
+ for (uint b = a + 1; b < 16; b++) {
Color16 cb(m_color[b]);
- if ( cb.u > cmax.u ) {
+ if (cb.u > cmax.u) {
max = b;
cmax = cb;
}
}
- swap( m_color[a], m_color[max] );
+ swap(m_color[a], m_color[max]);
}
}
#endif
@@ -402,16 +431,15 @@ void ColorBlock::computeRange(Vector3::Arg axis, Color32 *start, Color32 *end) c
float min, max;
min = max = dot(Vector3(m_color[0].r, m_color[0].g, m_color[0].b), axis);
- for (uint i = 1; i < 16; i++)
- {
+ for (uint i = 1; i < 16; i++) {
const Vector3 vec(m_color[i].r, m_color[i].g, m_color[i].b);
float val = dot(vec, axis);
- if ( val < min ) {
+ if (val < min) {
mini = i;
min = val;
}
- else if ( val > max ) {
+ else if (val > max) {
maxi = i;
max = val;
}
@@ -424,7 +452,7 @@ void ColorBlock::computeRange(Vector3::Arg axis, Color32 *start, Color32 *end) c
#if 0
/// Sort colors in the given axis.
-void ColorBlock::sortColors(const Vector3 & axis)
+void ColorBlock::sortColors(const Vector3 &axis)
{
float luma_array[16];
@@ -434,15 +462,15 @@ void ColorBlock::sortColors(const Vector3 & axis)
}
// Dummy selection sort.
- for ( uint a = 0; a < 16; a++ ) {
+ for (uint a = 0; a < 16; a++) {
uint min = a;
- for ( uint b = a+1; b < 16; b++ ) {
- if ( luma_array[b] < luma_array[min] ) {
+ for (uint b = a + 1; b < 16; b++) {
+ if (luma_array[b] < luma_array[min]) {
min = b;
}
}
- swap( luma_array[a], luma_array[min] );
- swap( m_color[a], m_color[min] );
+ swap(luma_array[a], luma_array[min]);
+ swap(m_color[a], m_color[min]);
}
}
#endif
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index 3db9b65c461..3f222a096ac 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -76,7 +76,7 @@ static const uint FOURCC_RXGB = DDS_MAKEFOURCC('R', 'X', 'G', 'B');
static const uint FOURCC_ATI1 = DDS_MAKEFOURCC('A', 'T', 'I', '1');
static const uint FOURCC_ATI2 = DDS_MAKEFOURCC('A', 'T', 'I', '2');
-//static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y');
+// static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y');
static const uint FOURCC_DX10 = DDS_MAKEFOURCC('D', 'X', '1', '0');
@@ -100,25 +100,25 @@ static const uint D3DFMT_X8B8G8R8 = 33;
static const uint D3DFMT_G16R16 = 34;
static const uint D3DFMT_A2R10G10B10 = 35;
-//static const uint D3DFMT_A16B16G16R16 = 36;
+// static const uint D3DFMT_A16B16G16R16 = 36;
// Palette formats.
-//static const uint D3DFMT_A8P8 = 40;
-//static const uint D3DFMT_P8 = 41;
+// static const uint D3DFMT_A8P8 = 40;
+// static const uint D3DFMT_P8 = 41;
// Luminance formats.
static const uint D3DFMT_L8 = 50;
-//static const uint D3DFMT_A8L8 = 51;
-//static const uint D3DFMT_A4L4 = 52;
+// static const uint D3DFMT_A8L8 = 51;
+// static const uint D3DFMT_A4L4 = 52;
static const uint D3DFMT_L16 = 81;
// Floating point formats
-//static const uint D3DFMT_R16F = 111;
-//static const uint D3DFMT_G16R16F = 112;
-//static const uint D3DFMT_A16B16G16R16F = 113;
-//static const uint D3DFMT_R32F = 114;
-//static const uint D3DFMT_G32R32F = 115;
-//static const uint D3DFMT_A32B32G32R32F = 116;
+// static const uint D3DFMT_R16F = 111;
+// static const uint D3DFMT_G16R16F = 112;
+// static const uint D3DFMT_A16B16G16R16F = 113;
+// static const uint D3DFMT_R32F = 114;
+// static const uint D3DFMT_G32R32F = 115;
+// static const uint D3DFMT_A32B32G32R32F = 116;
static const uint DDSD_CAPS = 0x00000001U;
static const uint DDSD_PIXELFORMAT = 0x00001000U;
@@ -479,8 +479,9 @@ void mem_read(Stream &mem, DDSHeader &header)
mem_read(mem, header.pitch);
mem_read(mem, header.depth);
mem_read(mem, header.mipmapcount);
- for (uint i = 0; i < 11; i++)
+ for (uint i = 0; i < 11; i++) {
mem_read(mem, header.reserved[i]);
+ }
mem_read(mem, header.pf);
mem_read(mem, header.caps);
mem_read(mem, header.notused);
@@ -550,8 +551,9 @@ DDSHeader::DDSHeader()
this->pitch = 0;
this->depth = 0;
this->mipmapcount = 0;
- for (uint i = 0; i < 11; i++)
+ for (uint i = 0; i < 11; i++) {
this->reserved[i] = 0;
+ }
// Store version information on the reserved header attributes.
this->reserved[9] = FOURCC_NVTT;
@@ -720,10 +722,12 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
}
// D3DX functions do not like this:
- this->pf.fourcc = 0; //findD3D9Format(bitcount, rmask, gmask, bmask, amask);
- /*if (this->pf.fourcc) {
+ this->pf.fourcc = 0; // findD3D9Format(bitcount, rmask, gmask, bmask, amask);
+#if 0
+ if (this->pf.fourcc) {
this->pf.flags |= DDPF_FOURCC;
- }*/
+ }
+#endif
if (!(bitcount > 0 && bitcount <= 32)) {
printf("DDS: bad bit count, pixel format not set\n");
@@ -738,33 +742,39 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
void DDSHeader::setDX10Format(uint format)
{
- //this->pf.flags = 0;
+ // this->pf.flags = 0;
this->pf.fourcc = FOURCC_DX10;
this->header10.dxgiFormat = format;
}
void DDSHeader::setNormalFlag(bool b)
{
- if (b)
+ if (b) {
this->pf.flags |= DDPF_NORMAL;
- else
+ }
+ else {
this->pf.flags &= ~DDPF_NORMAL;
+ }
}
void DDSHeader::setSrgbFlag(bool b)
{
- if (b)
+ if (b) {
this->pf.flags |= DDPF_SRGB;
- else
+ }
+ else {
this->pf.flags &= ~DDPF_SRGB;
+ }
}
void DDSHeader::setHasAlphaFlag(bool b)
{
- if (b)
+ if (b) {
this->pf.flags |= DDPF_ALPHAPIXELS;
- else
+ }
+ else {
this->pf.flags &= ~DDPF_ALPHAPIXELS;
+ }
}
void DDSHeader::setUserVersion(int version)
@@ -866,8 +876,9 @@ DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem
// some ATI2 compressed normal maps do not have their
// normal flag set, so force it here (the original nvtt don't do
// this, but the decompressor has a -forcenormal flag)
- if (header.pf.fourcc == FOURCC_ATI2)
+ if (header.pf.fourcc == FOURCC_ATI2) {
header.setNormalFlag(true);
+ }
}
DirectDrawSurface::~DirectDrawSurface()
@@ -973,10 +984,12 @@ bool DirectDrawSurface::hasAlpha() const
uint DirectDrawSurface::mipmapCount() const
{
- if (header.flags & DDSD_MIPMAPCOUNT)
+ if (header.flags & DDSD_MIPMAPCOUNT) {
return header.mipmapcount;
- else
+ }
+ else {
return 1;
+ }
}
uint DirectDrawSurface::fourCC() const
@@ -986,26 +999,32 @@ uint DirectDrawSurface::fourCC() const
uint DirectDrawSurface::width() const
{
- if (header.flags & DDSD_WIDTH)
+ if (header.flags & DDSD_WIDTH) {
return header.width;
- else
+ }
+ else {
return 1;
+ }
}
uint DirectDrawSurface::height() const
{
- if (header.flags & DDSD_HEIGHT)
+ if (header.flags & DDSD_HEIGHT) {
return header.height;
- else
+ }
+ else {
return 1;
+ }
}
uint DirectDrawSurface::depth() const
{
- if (header.flags & DDSD_DEPTH)
+ if (header.flags & DDSD_DEPTH) {
return header.depth;
- else
+ }
+ else {
return 1;
+ }
}
bool DirectDrawSurface::isTexture1D() const
@@ -1194,8 +1213,9 @@ static Color32 buildNormal(uint8 x, uint8 y)
float nx = 2 * (x / 255.0f) - 1;
float ny = 2 * (y / 255.0f) - 1;
float nz = 0.0f;
- if (1 - nx * nx - ny * ny > 0)
+ if (1 - nx * nx - ny * ny > 0) {
nz = sqrt(1 - nx * nx - ny * ny);
+ }
uint8 z = CLAMP(int(255.0f * (nz + 1) / 2.0f), 0, 255);
return Color32(x, y, z);
@@ -1207,16 +1227,21 @@ void DirectDrawSurface::readBlock(ColorBlock *rgba)
// Map DX10 block formats to fourcc codes.
if (header.hasDX10Header()) {
- if (header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM)
+ if (header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM) {
fourcc = FOURCC_DXT1;
- if (header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM)
+ }
+ if (header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM) {
fourcc = FOURCC_DXT3;
- if (header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM)
+ }
+ if (header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM) {
fourcc = FOURCC_DXT5;
- if (header.header10.dxgiFormat == DXGI_FORMAT_BC4_UNORM)
+ }
+ if (header.header10.dxgiFormat == DXGI_FORMAT_BC4_UNORM) {
fourcc = FOURCC_ATI1;
- if (header.header10.dxgiFormat == DXGI_FORMAT_BC5_UNORM)
+ }
+ if (header.header10.dxgiFormat == DXGI_FORMAT_BC5_UNORM) {
fourcc = FOURCC_ATI2;
+ }
}
if (fourcc == FOURCC_DXT1) {
@@ -1305,8 +1330,8 @@ uint DirectDrawSurface::blockSize() const
case DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT_BC5_SNORM:
return 16;
- };
- };
+ }
+ }
// Not a block image.
return 0;
@@ -1339,7 +1364,7 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
else {
printf("DDS: mipmap format not supported\n");
return (0);
- };
+ }
}
uint DirectDrawSurface::faceSize() const
@@ -1376,56 +1401,77 @@ uint DirectDrawSurface::offset(const uint face, const uint mipmap)
void DirectDrawSurface::printInfo() const
{
printf("Flags: 0x%.8X\n", header.flags);
- if (header.flags & DDSD_CAPS)
+ if (header.flags & DDSD_CAPS) {
printf("\tDDSD_CAPS\n");
- if (header.flags & DDSD_PIXELFORMAT)
+ }
+ if (header.flags & DDSD_PIXELFORMAT) {
printf("\tDDSD_PIXELFORMAT\n");
- if (header.flags & DDSD_WIDTH)
+ }
+ if (header.flags & DDSD_WIDTH) {
printf("\tDDSD_WIDTH\n");
- if (header.flags & DDSD_HEIGHT)
+ }
+ if (header.flags & DDSD_HEIGHT) {
printf("\tDDSD_HEIGHT\n");
- if (header.flags & DDSD_DEPTH)
+ }
+ if (header.flags & DDSD_DEPTH) {
printf("\tDDSD_DEPTH\n");
- if (header.flags & DDSD_PITCH)
+ }
+ if (header.flags & DDSD_PITCH) {
printf("\tDDSD_PITCH\n");
- if (header.flags & DDSD_LINEARSIZE)
+ }
+ if (header.flags & DDSD_LINEARSIZE) {
printf("\tDDSD_LINEARSIZE\n");
- if (header.flags & DDSD_MIPMAPCOUNT)
+ }
+ if (header.flags & DDSD_MIPMAPCOUNT) {
printf("\tDDSD_MIPMAPCOUNT\n");
+ }
printf("Height: %u\n", header.height);
printf("Width: %u\n", header.width);
printf("Depth: %u\n", header.depth);
- if (header.flags & DDSD_PITCH)
+ if (header.flags & DDSD_PITCH) {
printf("Pitch: %u\n", header.pitch);
- else if (header.flags & DDSD_LINEARSIZE)
+ }
+ else if (header.flags & DDSD_LINEARSIZE) {
printf("Linear size: %u\n", header.pitch);
+ }
printf("Mipmap count: %u\n", header.mipmapcount);
printf("Pixel Format:\n");
printf("\tFlags: 0x%.8X\n", header.pf.flags);
- if (header.pf.flags & DDPF_RGB)
+ if (header.pf.flags & DDPF_RGB) {
printf("\t\tDDPF_RGB\n");
- if (header.pf.flags & DDPF_LUMINANCE)
+ }
+ if (header.pf.flags & DDPF_LUMINANCE) {
printf("\t\tDDPF_LUMINANCE\n");
- if (header.pf.flags & DDPF_FOURCC)
+ }
+ if (header.pf.flags & DDPF_FOURCC) {
printf("\t\tDDPF_FOURCC\n");
- if (header.pf.flags & DDPF_ALPHAPIXELS)
+ }
+ if (header.pf.flags & DDPF_ALPHAPIXELS) {
printf("\t\tDDPF_ALPHAPIXELS\n");
- if (header.pf.flags & DDPF_ALPHA)
+ }
+ if (header.pf.flags & DDPF_ALPHA) {
printf("\t\tDDPF_ALPHA\n");
- if (header.pf.flags & DDPF_PALETTEINDEXED1)
+ }
+ if (header.pf.flags & DDPF_PALETTEINDEXED1) {
printf("\t\tDDPF_PALETTEINDEXED1\n");
- if (header.pf.flags & DDPF_PALETTEINDEXED2)
+ }
+ if (header.pf.flags & DDPF_PALETTEINDEXED2) {
printf("\t\tDDPF_PALETTEINDEXED2\n");
- if (header.pf.flags & DDPF_PALETTEINDEXED4)
+ }
+ if (header.pf.flags & DDPF_PALETTEINDEXED4) {
printf("\t\tDDPF_PALETTEINDEXED4\n");
- if (header.pf.flags & DDPF_PALETTEINDEXED8)
+ }
+ if (header.pf.flags & DDPF_PALETTEINDEXED8) {
printf("\t\tDDPF_PALETTEINDEXED8\n");
- if (header.pf.flags & DDPF_ALPHAPREMULT)
+ }
+ if (header.pf.flags & DDPF_ALPHAPREMULT) {
printf("\t\tDDPF_ALPHAPREMULT\n");
- if (header.pf.flags & DDPF_NORMAL)
+ }
+ if (header.pf.flags & DDPF_NORMAL) {
printf("\t\tDDPF_NORMAL\n");
+ }
if (header.pf.fourcc != 0) {
// Display fourcc code even when DDPF_FOURCC flag not set.
@@ -1456,33 +1502,44 @@ void DirectDrawSurface::printInfo() const
printf("Caps:\n");
printf("\tCaps 1: 0x%.8X\n", header.caps.caps1);
- if (header.caps.caps1 & DDSCAPS_COMPLEX)
+ if (header.caps.caps1 & DDSCAPS_COMPLEX) {
printf("\t\tDDSCAPS_COMPLEX\n");
- if (header.caps.caps1 & DDSCAPS_TEXTURE)
+ }
+ if (header.caps.caps1 & DDSCAPS_TEXTURE) {
printf("\t\tDDSCAPS_TEXTURE\n");
- if (header.caps.caps1 & DDSCAPS_MIPMAP)
+ }
+ if (header.caps.caps1 & DDSCAPS_MIPMAP) {
printf("\t\tDDSCAPS_MIPMAP\n");
+ }
printf("\tCaps 2: 0x%.8X\n", header.caps.caps2);
- if (header.caps.caps2 & DDSCAPS2_VOLUME)
+ if (header.caps.caps2 & DDSCAPS2_VOLUME) {
printf("\t\tDDSCAPS2_VOLUME\n");
+ }
else if (header.caps.caps2 & DDSCAPS2_CUBEMAP) {
printf("\t\tDDSCAPS2_CUBEMAP\n");
- if ((header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) == DDSCAPS2_CUBEMAP_ALL_FACES)
+ if ((header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) == DDSCAPS2_CUBEMAP_ALL_FACES) {
printf("\t\tDDSCAPS2_CUBEMAP_ALL_FACES\n");
+ }
else {
- if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEX)
+ if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEX) {
printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEX\n");
- if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX)
+ }
+ if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) {
printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEX\n");
- if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEY)
+ }
+ if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEY) {
printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEY\n");
- if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY)
+ }
+ if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) {
printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEY\n");
- if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ)
+ }
+ if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) {
printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEZ\n");
- if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ)
+ }
+ if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) {
printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEZ\n");
+ }
}
}
diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp
index 0660d5ce5cc..cf228cea3ea 100644
--- a/source/blender/imbuf/intern/dds/FlipDXT.cpp
+++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp
@@ -173,11 +173,13 @@ int FlipDXTCImage(
unsigned int width, unsigned int height, unsigned int levels, int fourcc, uint8_t *data)
{
// must have valid dimensions
- if (width == 0 || height == 0)
+ if (width == 0 || height == 0) {
return 0;
+ }
// height must be a power-of-two
- if ((height & (height - 1)) != 0)
+ if ((height & (height - 1)) != 0) {
return 0;
+ }
FlipBlockFunction full_block_function;
FlipBlockFunction half_block_function;
@@ -223,8 +225,9 @@ int FlipDXTCImage(
}
else {
// flip each block.
- for (unsigned int i = 0; i < blocks; ++i)
+ for (unsigned int i = 0; i < blocks; ++i) {
full_block_function(data + i * block_bytes);
+ }
// swap each block line in the first half of the image with the
// corresponding one in the second half.
diff --git a/source/blender/imbuf/intern/dds/Image.cpp b/source/blender/imbuf/intern/dds/Image.cpp
index 6f0fff75818..d08a61a5a60 100644
--- a/source/blender/imbuf/intern/dds/Image.cpp
+++ b/source/blender/imbuf/intern/dds/Image.cpp
@@ -51,8 +51,9 @@ void Image::allocate(uint w, uint h)
void Image::free()
{
- if (m_data)
+ if (m_data) {
delete[] m_data;
+ }
m_data = NULL;
}
diff --git a/source/blender/imbuf/intern/dds/Image.h b/source/blender/imbuf/intern/dds/Image.h
index b6191b7e96c..1aa60ef48ca 100644
--- a/source/blender/imbuf/intern/dds/Image.h
+++ b/source/blender/imbuf/intern/dds/Image.h
@@ -30,8 +30,8 @@
#ifndef __IMAGE_H__
#define __IMAGE_H__
-#include <Common.h>
-#include <Color.h>
+#include "Common.h"
+#include "Color.h"
/// 32 bit RGBA image.
class Image {
diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h
index 07912b86f47..47585147dfb 100644
--- a/source/blender/imbuf/intern/dds/PixelFormat.h
+++ b/source/blender/imbuf/intern/dds/PixelFormat.h
@@ -51,7 +51,7 @@
#ifndef __PIXELFORMAT_H__
#define __PIXELFORMAT_H__
-#include <Common.h>
+#include "Common.h"
namespace PixelFormat {
@@ -95,10 +95,10 @@ inline void maskShiftAndSize(uint mask, uint *shift, uint *size)
inline float quantizeCeil(float f, int inbits, int outbits)
{
- //uint i = f * (float(1 << inbits) - 1);
- //i = convert(i, inbits, outbits);
- //float result = float(i) / (float(1 << outbits) - 1);
- //nvCheck(result >= f);
+ // uint i = f * (float(1 << inbits) - 1);
+ // i = convert(i, inbits, outbits);
+ // float result = float(i) / (float(1 << outbits) - 1);
+ // nvCheck(result >= f);
float result;
int offset = 0;
do {
@@ -112,17 +112,17 @@ inline float quantizeCeil(float f, int inbits, int outbits)
}
#if 0
- inline float quantizeRound(float f, int bits)
- {
- float scale = float(1 << bits);
- return fround(f * scale) / scale;
- }
-
- inline float quantizeFloor(float f, int bits)
- {
- float scale = float(1 << bits);
- return floor(f * scale) / scale;
- }
+inline float quantizeRound(float f, int bits)
+{
+ float scale = float(1 << bits);
+ return fround(f * scale) / scale;
+}
+
+inline float quantizeFloor(float f, int bits)
+{
+ float scale = float(1 << bits);
+ return floor(f * scale) / scale;
+}
#endif
} // namespace PixelFormat
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 6a76e231e37..098b695b8a3 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -49,10 +49,12 @@ int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
return (0); /* todo: finish this function */
/* check image buffer */
- if (ibuf == 0)
+ if (ibuf == 0) {
return (0);
- if (ibuf->rect == 0)
+ }
+ if (ibuf->rect == 0) {
return (0);
+ }
/* open file for writing */
std::ofstream fildes;
@@ -76,11 +78,13 @@ int imb_is_a_dds(const unsigned char *mem) // note: use at most first 32 bytes
{
/* heuristic check to see if mem contains a DDS file */
/* header.fourcc == FOURCC_DDS */
- if ((mem[0] != 'D') || (mem[1] != 'D') || (mem[2] != 'S') || (mem[3] != ' '))
+ if ((mem[0] != 'D') || (mem[1] != 'D') || (mem[2] != 'S') || (mem[3] != ' ')) {
return (0);
+ }
/* header.size == 124 */
- if ((mem[4] != 124) || mem[5] || mem[6] || mem[7])
+ if ((mem[4] != 124) || mem[5] || mem[6] || mem[7]) {
return (0);
+ }
return (1);
}
@@ -106,14 +110,16 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
*/
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
- if (!imb_is_a_dds(mem))
+ if (!imb_is_a_dds(mem)) {
return (0);
+ }
/* check if DDS is valid and supported */
if (!dds.isValid()) {
/* no need to print error here, just testing if it is a DDS */
- if (flags & IB_test)
+ if (flags & IB_test) {
return (0);
+ }
printf("DDS: not valid; header follows\n");
dds.printInfo();
@@ -144,18 +150,21 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
}
}
ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0);
- if (ibuf == 0)
+ if (ibuf == 0) {
return (0); /* memory allocation failed */
+ }
ibuf->ftype = IMB_FTYPE_DDS;
ibuf->dds_data.fourcc = dds.fourCC();
ibuf->dds_data.nummipmaps = dds.mipmapCount();
if ((flags & IB_test) == 0) {
- if (!imb_addrectImBuf(ibuf))
+ if (!imb_addrectImBuf(ibuf)) {
return (ibuf);
- if (ibuf->rect == 0)
+ }
+ if (ibuf->rect == 0) {
return (ibuf);
+ }
rect = ibuf->rect;
cp[3] = 0xff; /* default alpha if alpha channel is not present */
@@ -165,8 +174,9 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
cp[0] = pixel.r; /* set R component of col */
cp[1] = pixel.g; /* set G component of col */
cp[2] = pixel.b; /* set B component of col */
- if (dds.hasAlpha())
+ if (dds.hasAlpha()) {
cp[3] = pixel.a; /* set A component of col */
+ }
rect[i] = col;
}
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index fb8dcffe9d4..e4845e56c46 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -119,8 +119,9 @@ void IMB_buffer_byte_from_float(uchar *rect_to,
BLI_assert(profile_to != IB_PROFILE_NONE);
BLI_assert(profile_from != IB_PROFILE_NONE);
- if (dither)
+ if (dither) {
di = create_dither_context(dither);
+ }
for (y = 0; y < height; y++) {
float t = y * inv_height;
@@ -130,8 +131,9 @@ void IMB_buffer_byte_from_float(uchar *rect_to,
const float *from = rect_from + ((size_t)stride_from) * y;
uchar *to = rect_to + ((size_t)stride_to) * y * 4;
- for (x = 0; x < width; x++, from++, to += 4)
+ for (x = 0; x < width; x++, from++, to += 4) {
to[0] = to[1] = to[2] = to[3] = unit_float_to_uchar_clamp(from[0]);
+ }
}
else if (channels_from == 3) {
/* RGB input */
@@ -178,8 +180,9 @@ void IMB_buffer_byte_from_float(uchar *rect_to,
}
}
else if (dither) {
- for (x = 0; x < width; x++, from += 4, to += 4)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
float_to_byte_dither_v4(to, from, di, (float)x * inv_width, t);
+ }
}
else if (predivide) {
for (x = 0; x < width; x++, from += 4, to += 4) {
@@ -188,8 +191,9 @@ void IMB_buffer_byte_from_float(uchar *rect_to,
}
}
else {
- for (x = 0; x < width; x++, from += 4, to += 4)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
rgba_float_to_uchar(to, from);
+ }
}
}
else if (profile_to == IB_PROFILE_SRGB) {
@@ -254,8 +258,9 @@ void IMB_buffer_byte_from_float(uchar *rect_to,
}
}
- if (dither)
+ if (dither) {
clear_dither_context(di);
+ }
}
/* float to byte pixels, output 4-channel RGBA */
@@ -274,8 +279,9 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to,
DitherContext *di = NULL;
float inv_width = 1.0f / width, inv_height = 1.0f / height;
- if (dither)
+ if (dither) {
di = create_dither_context(dither);
+ }
for (y = 0; y < height; y++) {
float t = y * inv_height;
@@ -285,9 +291,11 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to,
const float *from = rect_from + ((size_t)stride_from) * y;
uchar *to = rect_to + ((size_t)stride_to) * y * 4;
- for (x = 0; x < width; x++, from++, to += 4)
- if (*mask++ == FILTER_MASK_USED)
+ for (x = 0; x < width; x++, from++, to += 4) {
+ if (*mask++ == FILTER_MASK_USED) {
to[0] = to[1] = to[2] = to[3] = unit_float_to_uchar_clamp(from[0]);
+ }
+ }
}
else if (channels_from == 3) {
/* RGB input */
@@ -317,9 +325,11 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to,
}
}
else if (dither) {
- for (x = 0; x < width; x++, from += 4, to += 4)
- if (*mask++ == FILTER_MASK_USED)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
+ if (*mask++ == FILTER_MASK_USED) {
float_to_byte_dither_v4(to, from, di, (float)x * inv_width, t);
+ }
+ }
}
else if (predivide) {
for (x = 0; x < width; x++, from += 4, to += 4) {
@@ -330,15 +340,18 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to,
}
}
else {
- for (x = 0; x < width; x++, from += 4, to += 4)
- if (*mask++ == FILTER_MASK_USED)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
+ if (*mask++ == FILTER_MASK_USED) {
rgba_float_to_uchar(to, from);
+ }
+ }
}
}
}
- if (dither)
+ if (dither) {
clear_dither_context(di);
+ }
}
/* byte to float pixels, input and output 4-channel RGBA */
@@ -366,8 +379,9 @@ void IMB_buffer_float_from_byte(float *rect_to,
if (profile_to == profile_from) {
/* no color space conversion */
- for (x = 0; x < width; x++, from += 4, to += 4)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
rgba_uchar_to_float(to, from);
+ }
}
else if (profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert sRGB to linear */
@@ -424,8 +438,9 @@ void IMB_buffer_float_from_float(float *rect_to,
const float *from = rect_from + ((size_t)stride_from) * y;
float *to = rect_to + ((size_t)stride_to) * y * 4;
- for (x = 0; x < width; x++, from++, to += 4)
+ for (x = 0; x < width; x++, from++, to += 4) {
to[0] = to[1] = to[2] = to[3] = from[0];
+ }
}
}
else if (channels_from == 3) {
@@ -470,23 +485,27 @@ void IMB_buffer_float_from_float(float *rect_to,
else if (profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert to sRGB to linear */
if (predivide) {
- for (x = 0; x < width; x++, from += 4, to += 4)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
srgb_to_linearrgb_predivide_v4(to, from);
+ }
}
else {
- for (x = 0; x < width; x++, from += 4, to += 4)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
srgb_to_linearrgb_v4(to, from);
+ }
}
}
else if (profile_to == IB_PROFILE_SRGB) {
/* convert from linear to sRGB */
if (predivide) {
- for (x = 0; x < width; x++, from += 4, to += 4)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
linearrgb_to_srgb_predivide_v4(to, from);
+ }
}
else {
- for (x = 0; x < width; x++, from += 4, to += 4)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
linearrgb_to_srgb_v4(to, from);
+ }
}
}
}
@@ -580,9 +599,11 @@ void IMB_buffer_float_from_float_mask(float *rect_to,
const float *from = rect_from + ((size_t)stride_from) * y;
float *to = rect_to + ((size_t)stride_to) * y * 4;
- for (x = 0; x < width; x++, from++, to += 4)
- if (*mask++ == FILTER_MASK_USED)
+ for (x = 0; x < width; x++, from++, to += 4) {
+ if (*mask++ == FILTER_MASK_USED) {
to[0] = to[1] = to[2] = to[3] = from[0];
+ }
+ }
}
}
else if (channels_from == 3) {
@@ -605,9 +626,11 @@ void IMB_buffer_float_from_float_mask(float *rect_to,
const float *from = rect_from + ((size_t)stride_from) * y * 4;
float *to = rect_to + ((size_t)stride_to) * y * 4;
- for (x = 0; x < width; x++, from += 4, to += 4)
- if (*mask++ == FILTER_MASK_USED)
+ for (x = 0; x < width; x++, from += 4, to += 4) {
+ if (*mask++ == FILTER_MASK_USED) {
copy_v4_v4(to, from);
+ }
+ }
}
}
}
@@ -684,19 +707,23 @@ void IMB_rect_from_float(ImBuf *ibuf)
const char *from_colorspace;
/* verify we have a float buffer */
- if (ibuf->rect_float == NULL)
+ if (ibuf->rect_float == NULL) {
return;
+ }
/* create byte rect if it didn't exist yet */
if (ibuf->rect == NULL) {
- if (imb_addrectImBuf(ibuf) == 0)
+ if (imb_addrectImBuf(ibuf) == 0) {
return;
+ }
}
- if (ibuf->float_colorspace == NULL)
+ if (ibuf->float_colorspace == NULL) {
from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
- else
+ }
+ else {
from_colorspace = ibuf->float_colorspace->name;
+ }
buffer = MEM_dupallocN(ibuf->rect_float);
@@ -801,7 +828,10 @@ static void partial_rect_from_float_thread_do(void *data_v, int start_scanline,
data->is_data);
}
-/* converts from linear float to sRGB byte for part of the texture, buffer will hold the changed part */
+/**
+ * Converts from linear float to sRGB byte for part of the texture,
+ * buffer will hold the changed part.
+ */
void IMB_partial_rect_from_float(
ImBuf *ibuf, float *buffer, int x, int y, int w, int h, bool is_data)
{
@@ -809,12 +839,14 @@ void IMB_partial_rect_from_float(
uchar *rect_byte;
/* verify we have a float buffer */
- if (ibuf->rect_float == NULL || buffer == NULL)
+ if (ibuf->rect_float == NULL || buffer == NULL) {
return;
+ }
/* create byte rect if it didn't exist yet */
- if (ibuf->rect == NULL)
+ if (ibuf->rect == NULL) {
imb_addrectImBuf(ibuf);
+ }
/* do conversion */
rect_float = ibuf->rect_float + (x + ((size_t)y) * ibuf->x) * ibuf->channels;
@@ -843,8 +875,9 @@ void IMB_float_from_rect(ImBuf *ibuf)
float *rect_float;
/* verify if we byte and float buffers */
- if (ibuf->rect == NULL)
+ if (ibuf->rect == NULL) {
return;
+ }
/* allocate float buffer outside of image buffer,
* so work-in-progress color space conversion doesn't
@@ -860,8 +893,9 @@ void IMB_float_from_rect(ImBuf *ibuf)
rect_float = MEM_mapallocN(size, "IMB_float_from_rect");
- if (rect_float == NULL)
+ if (rect_float == NULL) {
return;
+ }
}
/* first, create float buffer in non-linear space */
@@ -899,13 +933,15 @@ void IMB_color_to_bw(ImBuf *ibuf)
size_t i;
if (rct_fl) {
- for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, rct_fl += 4)
+ for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, rct_fl += 4) {
rct_fl[0] = rct_fl[1] = rct_fl[2] = IMB_colormanagement_get_luminance(rct_fl);
+ }
}
if (rct) {
- for (i = ((size_t)ibuf->x * ibuf->y); i > 0; i--, rct += 4)
+ for (i = ((size_t)ibuf->x * ibuf->y); i > 0; i--, rct += 4) {
rct[0] = rct[1] = rct[2] = IMB_colormanagement_get_luminance_byte(rct);
+ }
}
}
diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index 7056e901f65..d1b3bf21e23 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -231,16 +231,20 @@ void imb_filetypes_init(void)
{
const ImFileType *type;
- for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++)
- if (type->init)
+ for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
+ if (type->init) {
type->init();
+ }
+ }
}
void imb_filetypes_exit(void)
{
const ImFileType *type;
- for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++)
- if (type->exit)
+ for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
+ if (type->exit) {
type->exit();
+ }
+ }
}
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index 2d7e90db34e..49e1a66886d 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -129,8 +129,9 @@ void IMB_filtery(struct ImBuf *ibuf)
for (; x > 0; x--) {
if (point) {
- if (ibuf->planes > 24)
+ if (ibuf->planes > 24) {
filtcolum(point, y, skip);
+ }
point++;
filtcolum(point, y, skip);
point++;
@@ -140,8 +141,9 @@ void IMB_filtery(struct ImBuf *ibuf)
point++;
}
if (pointf) {
- if (ibuf->planes > 24)
+ if (ibuf->planes > 24) {
filtcolumf(pointf, y, skip);
+ }
pointf++;
filtcolumf(pointf, y, skip);
pointf++;
@@ -168,8 +170,9 @@ void imb_filterx(struct ImBuf *ibuf)
for (; y > 0; y--) {
if (point) {
- if (ibuf->planes > 24)
+ if (ibuf->planes > 24) {
filtrow(point, x);
+ }
point++;
filtrow(point, x);
point++;
@@ -179,8 +182,9 @@ void imb_filterx(struct ImBuf *ibuf)
point += skip;
}
if (pointf) {
- if (ibuf->planes > 24)
+ if (ibuf->planes > 24) {
filtrowf(pointf, x);
+ }
pointf++;
filtrowf(pointf, x);
pointf++;
@@ -331,10 +335,12 @@ void IMB_mask_filter_extend(char *mask, int width, int height)
row1 = (char *)(temprect + (y - 2) * rowlen);
row2 = row1 + rowlen;
row3 = row2 + rowlen;
- if (y == 1)
+ if (y == 1) {
row1 = row2;
- else if (y == height)
+ }
+ else if (y == height) {
row3 = row2;
+ }
for (x = 0; x < rowlen; x++) {
if (mask[((y - 1) * rowlen) + x] == 0) {
@@ -385,10 +391,12 @@ void IMB_mask_clear(ImBuf *ibuf, char *mask, int val)
static int filter_make_index(const int x, const int y, const int w, const int h)
{
- if (x < 0 || x >= w || y < 0 || y >= h)
+ if (x < 0 || x >= w || y < 0 || y >= h) {
return -1; /* return bad index */
- else
+ }
+ else {
return y * w + x;
+ }
}
static int check_pixel_assigned(
@@ -411,9 +419,11 @@ static int check_pixel_assigned(
return res;
}
-/* if alpha is zero, it checks surrounding pixels and averages color. sets new alphas to 1.0
+/**
+ * if alpha is zero, it checks surrounding pixels and averages color. sets new alphas to 1.0
*
- * When a mask is given, only effect pixels with a mask value of 1, defined as BAKE_MASK_MARGIN in rendercore.c
+ * When a mask is given, only effect pixels with a mask value of 1,
+ * defined as #BAKE_MASK_MARGIN in rendercore.c
* */
void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
{
@@ -438,7 +448,7 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
k = 0;
for (i = -n; i <= n; i++)
for (j = -n; j <= n; j++)
- weight[k++] = sqrt((float) i * i + j * j);
+ weight[k++] = sqrt((float)i * i + j * j);
#endif
weight[0] = 1;
@@ -482,18 +492,21 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
if (check_pixel_assigned(srcbuf, srcmask, tmpindex, depth, is_float)) {
if (is_float) {
- for (c = 0; c < depth; c++)
+ for (c = 0; c < depth; c++) {
tmp[c] = ((const float *)srcbuf)[depth * tmpindex + c];
+ }
}
else {
- for (c = 0; c < depth; c++)
+ for (c = 0; c < depth; c++) {
tmp[c] = (float)((const unsigned char *)srcbuf)[depth * tmpindex + c];
+ }
}
wsum += weight[k];
- for (c = 0; c < depth; c++)
+ for (c = 0; c < depth; c++) {
acc[c] += weight[k] * tmp[c];
+ }
}
}
k++;
@@ -501,12 +514,14 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
}
if (wsum != 0) {
- for (c = 0; c < depth; c++)
+ for (c = 0; c < depth; c++) {
acc[c] /= wsum;
+ }
if (is_float) {
- for (c = 0; c < depth; c++)
+ for (c = 0; c < depth; c++) {
((float *)dstbuf)[depth * index + c] = acc[c];
+ }
}
else {
for (c = 0; c < depth; c++) {
@@ -515,8 +530,9 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
}
}
- if (dstmask != NULL)
+ if (dstmask != NULL) {
dstmask[index] = FILTER_MASK_MARGIN; /* assigned */
+ }
cannot_early_out = 1;
}
}
@@ -533,8 +549,9 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
/* free memory */
MEM_freeN(dstbuf);
- if (dstmask != NULL)
+ if (dstmask != NULL) {
MEM_freeN(dstmask);
+ }
}
/* threadsafe version, only recreates existing maps */
@@ -555,17 +572,20 @@ void IMB_remakemipmap(ImBuf *ibuf, int use_filter)
imb_onehalf_no_alloc(ibuf->mipmap[curmap], nbuf);
IMB_freeImBuf(nbuf);
}
- else
+ else {
imb_onehalf_no_alloc(ibuf->mipmap[curmap], hbuf);
+ }
}
ibuf->miptot = curmap + 2;
hbuf = ibuf->mipmap[curmap];
- if (hbuf)
+ if (hbuf) {
hbuf->miplevel = curmap + 1;
+ }
- if (!hbuf || (hbuf->x <= 2 && hbuf->y <= 2))
+ if (!hbuf || (hbuf->x <= 2 && hbuf->y <= 2)) {
break;
+ }
curmap++;
}
@@ -580,8 +600,9 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter)
imb_freemipmapImBuf(ibuf);
/* no mipmap for non RGBA images */
- if (ibuf->rect_float && ibuf->channels < 4)
+ if (ibuf->rect_float && ibuf->channels < 4) {
return;
+ }
ibuf->miptot = 1;
@@ -592,15 +613,17 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter)
ibuf->mipmap[curmap] = IMB_onehalf(nbuf);
IMB_freeImBuf(nbuf);
}
- else
+ else {
ibuf->mipmap[curmap] = IMB_onehalf(hbuf);
+ }
ibuf->miptot = curmap + 2;
hbuf = ibuf->mipmap[curmap];
hbuf->miplevel = curmap + 1;
- if (hbuf->x < 2 && hbuf->y < 2)
+ if (hbuf->x < 2 && hbuf->y < 2) {
break;
+ }
curmap++;
}
@@ -620,9 +643,11 @@ void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h)
if (planes == 24) { /* put alpha at 255 */
cp = (char *)(rect);
- for (y = 0; y < h; y++)
- for (x = 0; x < w; x++, cp += 4)
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++, cp += 4) {
cp[3] = 255;
+ }
+ }
}
else {
cp = (char *)(rect);
@@ -658,14 +683,17 @@ void IMB_premultiply_rect_float(float *rect_float, int channels, int w, int h)
void IMB_premultiply_alpha(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
- if (ibuf->rect)
+ if (ibuf->rect) {
IMB_premultiply_rect(ibuf->rect, ibuf->planes, ibuf->x, ibuf->y);
+ }
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
IMB_premultiply_rect_float(ibuf->rect_float, ibuf->channels, ibuf->x, ibuf->y);
+ }
}
void IMB_unpremultiply_rect(unsigned int *rect, char planes, int w, int h)
@@ -677,9 +705,11 @@ void IMB_unpremultiply_rect(unsigned int *rect, char planes, int w, int h)
if (planes == 24) { /* put alpha at 255 */
cp = (char *)(rect);
- for (y = 0; y < h; y++)
- for (x = 0; x < w; x++, cp += 4)
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++, cp += 4) {
cp[3] = 255;
+ }
+ }
}
else {
cp = (char *)(rect);
@@ -715,12 +745,15 @@ void IMB_unpremultiply_rect_float(float *rect_float, int channels, int w, int h)
void IMB_unpremultiply_alpha(ImBuf *ibuf)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
- if (ibuf->rect)
+ if (ibuf->rect) {
IMB_unpremultiply_rect(ibuf->rect, ibuf->planes, ibuf->x, ibuf->y);
+ }
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
IMB_unpremultiply_rect_float(ibuf->rect_float, ibuf->channels, ibuf->x, ibuf->y);
+ }
}
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index 58253bde3e3..1f180d0d9c1 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -79,11 +79,13 @@ static void pixel_from_buffer(struct ImBuf *ibuf, unsigned char **outI, float **
{
size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x;
- if (ibuf->rect)
+ if (ibuf->rect) {
*outI = (unsigned char *)ibuf->rect + offset;
+ }
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
*outF = ibuf->rect_float + offset;
+ }
}
/* BICUBIC Interpolation */
@@ -131,7 +133,8 @@ void bilinear_interpolation_color(
/* Note about wrapping, the u/v still needs to be within the image bounds,
* just the interpolation is wrapped.
- * This the same as bilinear_interpolation_color except it wraps rather than using empty and emptyI */
+ * This the same as bilinear_interpolation_color except it wraps
+ * rather than using empty and emptyI. */
void bilinear_interpolation_color_wrap(
struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
{
@@ -153,15 +156,19 @@ void bilinear_interpolation_color_wrap(
}
/* wrap interpolation pixels - main difference from bilinear_interpolation_color */
- if (x1 < 0)
+ if (x1 < 0) {
x1 = in->x + x1;
- if (y1 < 0)
+ }
+ if (y1 < 0) {
y1 = in->y + y1;
+ }
- if (x2 >= in->x)
+ if (x2 >= in->x) {
x2 = x2 - in->x;
- if (y2 >= in->y)
+ }
+ if (y2 >= in->y) {
y2 = y2 - in->y;
+ }
a = u - floorf(u);
b = v - floorf(v);
@@ -235,10 +242,12 @@ void nearest_interpolation_color(
/* sample area entirely outside image? */
if (x1 < 0 || x1 > in->x - 1 || y1 < 0 || y1 > in->y - 1) {
- if (outI)
+ if (outI) {
outI[0] = outI[1] = outI[2] = outI[3] = 0;
- if (outF)
+ }
+ if (outF) {
outF[0] = outF[1] = outF[2] = outF[3] = 0.0f;
+ }
return;
}
@@ -291,10 +300,12 @@ void nearest_interpolation_color_wrap(
y = y % in->y;
/* wrap interpolation pixels - main difference from nearest_interpolation_color */
- if (x < 0)
+ if (x < 0) {
x += in->x;
- if (y < 0)
+ }
+ if (y < 0) {
y += in->y;
+ }
dataI = (unsigned char *)in->rect + ((size_t)in->x) * y * 4 + 4 * x;
if (outI) {
@@ -361,10 +372,12 @@ void IMB_processor_apply_threaded(
int lines_per_current_task;
void *handle = ((char *)handles) + handle_size * i;
- if (i < total_tasks - 1)
+ if (i < total_tasks - 1) {
lines_per_current_task = lines_per_task;
- else
+ }
+ else {
lines_per_current_task = buffer_lines - start_line;
+ }
init_handle(handle, start_line, lines_per_current_task, init_customdata);
diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index 106c04f39f6..e343faa7dc8 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -52,10 +52,12 @@ static const int proxy_sizes[] = {IMB_PROXY_25, IMB_PROXY_50, IMB_PROXY_75, IMB_
static const float proxy_fac[] = {0.25, 0.50, 0.75, 1.00};
#ifdef WITH_FFMPEG
-static int tc_types[] = {IMB_TC_RECORD_RUN,
- IMB_TC_FREE_RUN,
- IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN,
- IMB_TC_RECORD_RUN_NO_GAPS};
+static int tc_types[] = {
+ IMB_TC_RECORD_RUN,
+ IMB_TC_FREE_RUN,
+ IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN,
+ IMB_TC_RECORD_RUN_NO_GAPS,
+};
#endif
#define INDEX_FILE_VERSION 1
@@ -305,8 +307,8 @@ void IMB_indexer_close(struct anim_index *idx)
int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size)
{
switch (pr_size) {
- case IMB_PROXY_NONE: /* if we got here, something is broken anyways,
- * so sane defaults... */
+ case IMB_PROXY_NONE:
+ /* if we got here, something is broken anyways, so sane defaults... */
return 0;
case IMB_PROXY_25:
return 0;
@@ -865,8 +867,9 @@ static void index_rebuild_ffmpeg_proc_decoded_frame(FFmpegIndexBuilderContext *c
if (context->tcs_in_use & tc_types[i]) {
int tc_frameno = context->frameno;
- if (tc_types[i] == IMB_TC_RECORD_RUN_NO_GAPS)
+ if (tc_types[i] == IMB_TC_RECORD_RUN_NO_GAPS) {
tc_frameno = context->frameno_gapless;
+ }
IMB_index_builder_proc_frame(context->indexer[i],
curr_packet->data,
@@ -981,8 +984,8 @@ static AviMovie *alloc_proxy_output_avi(
AviFormat format;
double framerate;
AviMovie *avi;
- short frs_sec = 25; /* it doesn't really matter for proxies,
- * but sane defaults help anyways...*/
+ /* it doesn't really matter for proxies, but sane defaults help anyways...*/
+ short frs_sec = 25;
float frs_sec_base = 1.0;
IMB_anim_get_fps(anim, &frs_sec, &frs_sec_base, false);
@@ -1199,8 +1202,9 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim,
#endif
}
- if (context)
+ if (context) {
context->anim_type = anim->curtype;
+ }
return context;
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index ee1a6b57c26..4b23443933a 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -221,10 +221,12 @@ static void test_endian_zbuf(struct ImBuf *ibuf)
int len;
int *zval;
- if (BIG_LONG(1) == 1)
+ if (BIG_LONG(1) == 1) {
return;
- if (ibuf->zbuf == NULL)
+ }
+ if (ibuf->zbuf == NULL) {
return;
+ }
len = ibuf->x * ibuf->y;
zval = ibuf->zbuf;
@@ -299,8 +301,9 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
if (flags & IB_test) {
ibuf = IMB_allocImBuf(image.xsize, image.ysize, 8 * image.zsize, 0);
- if (ibuf)
+ if (ibuf) {
ibuf->ftype = IMB_FTYPE_IMAGIC;
+ }
return (ibuf);
}
@@ -334,8 +337,9 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
}
cur = starttab[y + z * ysize];
}
- if (badorder)
+ if (badorder) {
break;
+ }
}
if (bpp == 1) {
@@ -344,8 +348,9 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
if (!ibuf) {
goto fail_rle;
}
- if (ibuf->planes > 32)
+ if (ibuf->planes > 32) {
ibuf->planes = 32;
+ }
base = ibuf->rect;
zbase = (uint *)ibuf->zbuf;
@@ -458,8 +463,9 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
if (!ibuf) {
goto fail_uncompressed;
}
- if (ibuf->planes > 32)
+ if (ibuf->planes > 32) {
ibuf->planes = 32;
+ }
base = ibuf->rect;
zbase = (uint *)ibuf->zbuf;
@@ -469,10 +475,12 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors
for (size_t z = 0; z < zsize; z++) {
- if (z < 4)
+ if (z < 4) {
lptr = base;
- else if (z < 8)
+ }
+ else if (z < 8) {
lptr = zbase;
+ }
for (size_t y = 0; y < ysize; y++) {
const uchar *rledat_next = rledat + xsize;
@@ -640,8 +648,9 @@ static int expandrow2(
pixel = (iptr[0] << 8) | (iptr[1] << 0);
iptr = iptr_next;
- if (!(count = (pixel & 0x7f)))
+ if (!(count = (pixel & 0x7f))) {
return false;
+ }
const float *optr_next = optr + count;
EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next);
if (pixel & 0x80) {
@@ -725,8 +734,9 @@ static int expandrow(
EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next);
pixel = *iptr;
iptr = iptr_next;
- if (!(count = (pixel & 0x7f)))
+ if (!(count = (pixel & 0x7f))) {
return false;
+ }
const uchar *optr_next = optr + ((int)count * 4);
EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next);
@@ -809,8 +819,9 @@ static int output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *
goodwrite = 1;
outf = BLI_fopen(name, "wb");
- if (!outf)
+ if (!outf) {
return 0;
+ }
tablen = ysize * zsize * sizeof(int);
@@ -824,10 +835,12 @@ static int output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *
memset(image, 0, sizeof(IMAGE));
image->imagic = IMAGIC;
image->type = RLE(1);
- if (zsize > 1)
+ if (zsize > 1) {
image->dim = 3;
- else
+ }
+ else {
image->dim = 2;
+ }
image->xsize = xsize;
image->ysize = ysize;
image->zsize = zsize;
@@ -862,8 +875,9 @@ static int output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *
pos += len;
}
lptr += xsize;
- if (zptr)
+ if (zptr) {
zptr += xsize;
+ }
}
fseek(outf, HEADER_SIZE, SEEK_SET);
@@ -875,8 +889,9 @@ static int output_iris(uint *lptr, int xsize, int ysize, int zsize, const char *
MEM_freeN(rlebuf);
MEM_freeN(lumbuf);
fclose(outf);
- if (goodwrite)
+ if (goodwrite) {
return 1;
+ }
else {
fprintf(stderr, "output_iris: not enough space for image!!\n");
return 0;
@@ -909,8 +924,9 @@ static int compressrow(uchar *lbuf, uchar *rlebuf, int z, int cnt)
while (iptr < ibufend) {
sptr = iptr;
iptr += 8;
- while ((iptr < ibufend) && ((iptr[-8] != iptr[-4]) || (iptr[-4] != iptr[0])))
+ while ((iptr < ibufend) && ((iptr[-8] != iptr[-4]) || (iptr[-4] != iptr[0]))) {
iptr += 4;
+ }
iptr -= 8;
count = (iptr - sptr) / 4;
while (count) {
@@ -939,8 +955,9 @@ static int compressrow(uchar *lbuf, uchar *rlebuf, int z, int cnt)
sptr = iptr;
cc = *iptr;
iptr += 4;
- while ((iptr < ibufend) && (*iptr == cc))
+ while ((iptr < ibufend) && (*iptr == cc)) {
iptr += 4;
+ }
count = (iptr - sptr) / 4;
while (count) {
todo = count > 126 ? 126 : count;
@@ -959,8 +976,9 @@ int imb_saveiris(struct ImBuf *ibuf, const char *name, int flags)
int ret;
zsize = (ibuf->planes + 7) >> 3;
- if (flags & IB_zbuf && ibuf->zbuf != NULL)
+ if (flags & IB_zbuf && ibuf->zbuf != NULL) {
zsize = 8;
+ }
IMB_convert_rgba_to_abgr(ibuf);
test_endian_zbuf(ibuf);
diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c
index 4863da8ab18..49437e77d8e 100644
--- a/source/blender/imbuf/intern/jp2.c
+++ b/source/blender/imbuf/intern/jp2.c
@@ -435,17 +435,20 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream,
}
i = image->numcomps;
- if (i > 4)
+ if (i > 4) {
i = 4;
+ }
while (i) {
i--;
- if (image->comps[i].prec > 8)
+ if (image->comps[i].prec > 8) {
use_float = true;
+ }
- if (image->comps[i].sgnd)
+ if (image->comps[i].sgnd) {
signed_offsets[i] = 1 << (image->comps[i].prec - 1);
+ }
/* only needed for float images but dosnt hurt to calc this */
float_divs[i] = (1 << image->comps[i].prec) - 1;
@@ -588,10 +591,15 @@ finally:
return ibuf;
}
-//static opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp)
+#if 0
+static opj_image_t *rawtoimage(const char *filename,
+ opj_cparameters_t *parameters,
+ raw_cparameters_t *raw_cp)
+#endif
/* prec can be 8, 12, 16 */
-/* use inline because the float passed can be a function call that would end up being called many times */
+/* Use inline because the float passed can be a function call
+ * that would end up being called many times. */
#if 0
# define UPSAMPLE_8_TO_12(_val) ((_val << 4) | (_val & ((1 << 4) - 1)))
# define UPSAMPLE_8_TO_16(_val) ((_val << 8) + _val)
@@ -628,7 +636,8 @@ BLI_INLINE int DOWNSAMPLE_FLOAT_TO_16BIT(const float _val)
#endif
/*
- * 2048x1080 (2K) at 24 fps or 48 fps, or 4096x2160 (4K) at 24 fps; 3x12 bits per pixel, XYZ color space
+ * 2048x1080 (2K) at 24 fps or 48 fps, or 4096x2160 (4K) at 24 fps;
+ * 3x12 bits per pixel, XYZ color space
*
* - In 2K, for Scope (2.39:1) presentation 2048x858 pixels of the image is used
* - In 2K, for Flat (1.85:1) presentation 1998x1080 pixels of the image is used
@@ -844,8 +853,9 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
if (ibuf->foptions.flag & JP2_CINE) {
- if (ibuf->x == 4096 || ibuf->y == 2160)
+ if (ibuf->x == 4096 || ibuf->y == 2160) {
parameters->cp_cinema = OPJ_CINEMA4K_24;
+ }
else {
if (ibuf->foptions.flag & JP2_CINE_48FPS) {
parameters->cp_cinema = OPJ_CINEMA2K_48;
@@ -870,12 +880,15 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
/* Get settings from the imbuf */
color_space = (ibuf->foptions.flag & JP2_YCC) ? OPJ_CLRSPC_SYCC : OPJ_CLRSPC_SRGB;
- if (ibuf->foptions.flag & JP2_16BIT)
+ if (ibuf->foptions.flag & JP2_16BIT) {
prec = 16;
- else if (ibuf->foptions.flag & JP2_12BIT)
+ }
+ else if (ibuf->foptions.flag & JP2_12BIT) {
prec = 12;
- else
+ }
+ else {
prec = 8;
+ }
/* 32bit images == alpha channel */
/* grayscale not supported yet */
@@ -941,8 +954,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else if (channels_in_float == 3) {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 3)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 3) {
r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(chanel_colormanage_cb(rect_float[1]));
b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(chanel_colormanage_cb(rect_float[2]));
@@ -951,8 +963,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 1)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 1) {
r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = b[i] = r[i];
a[i] = 255;
@@ -971,8 +982,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else if (channels_in_float == 3) {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 3)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 3) {
r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = DOWNSAMPLE_FLOAT_TO_8BIT(chanel_colormanage_cb(rect_float[1]));
b[i] = DOWNSAMPLE_FLOAT_TO_8BIT(chanel_colormanage_cb(rect_float[2]));
@@ -980,8 +990,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 1)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 1) {
r[i] = DOWNSAMPLE_FLOAT_TO_8BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = b[i] = r[i];
}
@@ -1003,8 +1012,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else if (channels_in_float == 3) {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 3)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 3) {
r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(chanel_colormanage_cb(rect_float[1]));
b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(chanel_colormanage_cb(rect_float[2]));
@@ -1013,8 +1021,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 1)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 1) {
r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = b[i] = r[i];
a[i] = 4095;
@@ -1033,8 +1040,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else if (channels_in_float == 3) {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 3)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 3) {
r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = DOWNSAMPLE_FLOAT_TO_12BIT(chanel_colormanage_cb(rect_float[1]));
b[i] = DOWNSAMPLE_FLOAT_TO_12BIT(chanel_colormanage_cb(rect_float[2]));
@@ -1042,8 +1048,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 1)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 1) {
r[i] = DOWNSAMPLE_FLOAT_TO_12BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = b[i] = r[i];
}
@@ -1065,8 +1070,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else if (channels_in_float == 3) {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 3)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 3) {
r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(chanel_colormanage_cb(rect_float[1]));
b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(chanel_colormanage_cb(rect_float[2]));
@@ -1075,8 +1079,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 1)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 1) {
r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = b[i] = r[i];
a[i] = 65535;
@@ -1095,8 +1098,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else if (channels_in_float == 3) {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 3)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 3) {
r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = DOWNSAMPLE_FLOAT_TO_16BIT(chanel_colormanage_cb(rect_float[1]));
b[i] = DOWNSAMPLE_FLOAT_TO_16BIT(chanel_colormanage_cb(rect_float[2]));
@@ -1104,8 +1106,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
PIXEL_LOOPER_END;
}
else {
- PIXEL_LOOPER_BEGIN_CHANNELS(rect_float, 1)
- {
+ PIXEL_LOOPER_BEGIN_CHANNELS (rect_float, 1) {
r[i] = DOWNSAMPLE_FLOAT_TO_16BIT(chanel_colormanage_cb(rect_float[0]));
g[i] = b[i] = r[i];
}
@@ -1187,8 +1188,9 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
cinema_setup_encoder(parameters, image, &img_fol);
}
- if (img_fol.rates)
+ if (img_fol.rates) {
MEM_freeN(img_fol.rates);
+ }
return image;
}
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 6743fe536b1..0822c069755 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -59,8 +59,9 @@ static uchar ibuf_quality;
int imb_is_a_jpeg(const unsigned char *mem)
{
- if ((mem[0] == 0xFF) && (mem[1] == 0xD8))
+ if ((mem[0] == 0xFF) && (mem[1] == 0xD8)) {
return 1;
+ }
return 0;
}
@@ -96,8 +97,8 @@ static void jpeg_error(j_common_ptr cinfo)
#if 0
typedef struct {
- unsigned char *buffer;
- int filled;
+ unsigned char *buffer;
+ int filled;
} buffer_struct;
#endif
@@ -279,8 +280,9 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla
y = cinfo->image_height;
depth = cinfo->num_components;
- if (cinfo->jpeg_color_space == JCS_YCCK)
+ if (cinfo->jpeg_color_space == JCS_YCCK) {
cinfo->out_color_space = JCS_CMYK;
+ }
jpeg_start_decompress(cinfo);
@@ -341,8 +343,9 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla
marker = cinfo->marker_list;
while (marker) {
- if (marker->marker != JPEG_COM)
+ if (marker->marker != JPEG_COM) {
goto next_stamp_marker;
+ }
/*
* JPEG marker strings are not null-terminated,
@@ -426,8 +429,9 @@ ImBuf *imb_load_jpeg(const unsigned char *buffer,
struct my_error_mgr jerr;
ImBuf *ibuf;
- if (!imb_is_a_jpeg(buffer))
+ if (!imb_is_a_jpeg(buffer)) {
return NULL;
+ }
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@@ -554,10 +558,12 @@ static int init_jpeg(FILE *outfile, struct jpeg_compress_struct *cinfo, struct I
int quality;
quality = ibuf->foptions.quality;
- if (quality <= 0)
+ if (quality <= 0) {
quality = jpeg_default_quality;
- if (quality > 100)
+ }
+ if (quality > 100) {
quality = 100;
+ }
jpeg_create_compress(cinfo);
jpeg_stdio_dest(cinfo, outfile);
@@ -566,13 +572,15 @@ static int init_jpeg(FILE *outfile, struct jpeg_compress_struct *cinfo, struct I
cinfo->image_height = ibuf->y;
cinfo->in_color_space = JCS_RGB;
- if (ibuf->planes == 8)
+ if (ibuf->planes == 8) {
cinfo->in_color_space = JCS_GRAYSCALE;
+ }
#if 0
/* just write RGBA as RGB,
* unsupported feature only confuses other s/w */
- if (ibuf->planes == 32) cinfo->in_color_space = JCS_UNKNOWN;
+ if (ibuf->planes == 32)
+ cinfo->in_color_space = JCS_UNKNOWN;
#endif
switch (cinfo->in_color_space) {
case JCS_RGB:
@@ -605,8 +613,9 @@ static int save_stdjpeg(const char *name, struct ImBuf *ibuf)
struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
struct my_error_mgr jerr;
- if ((outfile = BLI_fopen(name, "wb")) == NULL)
+ if ((outfile = BLI_fopen(name, "wb")) == NULL) {
return 0;
+ }
cinfo->err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = jpeg_error;
diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c
index fe6909b0f3f..3cb976a6d9f 100644
--- a/source/blender/imbuf/intern/moviecache.c
+++ b/source/blender/imbuf/intern/moviecache.c
@@ -151,8 +151,9 @@ static void check_unused_keys(MovieCache *cache)
PRINT("%s: cache '%s' remove item %p without buffer\n", __func__, cache->name, item);
}
- if (remove)
+ if (remove) {
BLI_ghash_remove(cache->hash, key, moviecache_keyfree, moviecache_valfree);
+ }
}
}
@@ -185,55 +186,24 @@ static void IMB_moviecache_destructor(void *p)
}
}
-/* approximate size of ImBuf in memory */
-static size_t IMB_get_size_in_memory(ImBuf *ibuf)
+static size_t get_size_in_memory(ImBuf *ibuf)
{
- int a;
- size_t size = 0, channel_size = 0;
-
- /* Persistent images should have no affect on how "normal"
- * images are cached.
- *
- * This is a bit arbitrary, but would make it so only movies
- * and sequences are memory limited, keeping textures in the
- * memory in order to avoid constant file reload on viewport
- * update.
- */
+ /* Keep textures in the memory to avoid constant file reload on viewport update. */
if (ibuf->userflags & IB_PERSISTENT) {
return 0;
}
-
- size += sizeof(ImBuf);
-
- if (ibuf->rect)
- channel_size += sizeof(char);
-
- if (ibuf->rect_float)
- channel_size += sizeof(float);
-
- size += channel_size * ibuf->x * ibuf->y * ibuf->channels;
-
- if (ibuf->miptot) {
- for (a = 0; a < ibuf->miptot; a++) {
- if (ibuf->mipmap[a])
- size += IMB_get_size_in_memory(ibuf->mipmap[a]);
- }
- }
-
- if (ibuf->tiles) {
- size += sizeof(unsigned int) * ibuf->ytiles * ibuf->xtiles;
+ else {
+ return IMB_get_size_in_memory(ibuf);
}
-
- return size;
}
-
static size_t get_item_size(void *p)
{
size_t size = sizeof(MovieCacheItem);
MovieCacheItem *item = (MovieCacheItem *)p;
- if (item->ibuf)
- size += IMB_get_size_in_memory(item->ibuf);
+ if (item->ibuf) {
+ size += get_size_in_memory(item->ibuf);
+ }
return size;
}
@@ -285,8 +255,9 @@ void IMB_moviecache_init(void)
void IMB_moviecache_destruct(void)
{
- if (limitor)
+ if (limitor) {
delete_MEM_CacheLimiter(limitor);
+ }
}
MovieCache *IMB_moviecache_create(const char *name,
@@ -338,8 +309,9 @@ static void do_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf, boo
MovieCacheKey *key;
MovieCacheItem *item;
- if (!limitor)
+ if (!limitor) {
IMB_moviecache_init();
+ }
IMB_refImBuf(ibuf);
@@ -367,8 +339,9 @@ static void do_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf, boo
memcpy(cache->last_userkey, userkey, cache->keysize);
}
- if (need_lock)
+ if (need_lock) {
BLI_mutex_lock(&limitor_lock);
+ }
item->c_handle = MEM_CacheLimiter_insert(limitor, item);
@@ -376,8 +349,9 @@ static void do_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf, boo
MEM_CacheLimiter_enforce_limits(limitor);
MEM_CacheLimiter_unref(item->c_handle);
- if (need_lock)
+ if (need_lock) {
BLI_mutex_unlock(&limitor_lock);
+ }
/* cache limiter can't remove unused keys which points to destroyed values */
check_unused_keys(cache);
@@ -398,7 +372,7 @@ bool IMB_moviecache_put_if_possible(MovieCache *cache, void *userkey, ImBuf *ibu
size_t mem_in_use, mem_limit, elem_size;
bool result = false;
- elem_size = IMB_get_size_in_memory(ibuf);
+ elem_size = get_size_in_memory(ibuf);
mem_limit = MEM_CacheLimiter_get_maximum();
BLI_mutex_lock(&limitor_lock);
@@ -460,11 +434,13 @@ void IMB_moviecache_free(MovieCache *cache)
BLI_mempool_destroy(cache->items_pool);
BLI_mempool_destroy(cache->userkeys_pool);
- if (cache->points)
+ if (cache->points) {
MEM_freeN(cache->points);
+ }
- if (cache->last_userkey)
+ if (cache->last_userkey) {
MEM_freeN(cache->last_userkey);
+ }
MEM_freeN(cache);
}
@@ -500,12 +476,14 @@ void IMB_moviecache_get_cache_segments(
*totseg_r = 0;
*points_r = NULL;
- if (!cache->getdatafp)
+ if (!cache->getdatafp) {
return;
+ }
if (cache->proxy != proxy || cache->render_flags != render_flags) {
- if (cache->points)
+ if (cache->points) {
MEM_freeN(cache->points);
+ }
cache->points = NULL;
}
@@ -529,8 +507,9 @@ void IMB_moviecache_get_cache_segments(
if (item->ibuf) {
cache->getdatafp(key->userkey, &framenr, &curproxy, &curflags);
- if (curproxy == proxy && curflags == render_flags)
+ if (curproxy == proxy && curflags == render_flags) {
frames[a++] = framenr;
+ }
}
}
@@ -538,11 +517,13 @@ void IMB_moviecache_get_cache_segments(
/* count */
for (a = 0; a < totframe; a++) {
- if (a && frames[a] - frames[a - 1] != 1)
+ if (a && frames[a] - frames[a - 1] != 1) {
totseg++;
+ }
- if (a == totframe - 1)
+ if (a == totframe - 1) {
totseg++;
+ }
}
if (totseg) {
@@ -552,16 +533,18 @@ void IMB_moviecache_get_cache_segments(
/* fill */
for (a = 0, b = 0; a < totframe; a++) {
- if (a == 0)
+ if (a == 0) {
points[b++] = frames[a];
+ }
if (a && frames[a] - frames[a - 1] != 1) {
points[b++] = frames[a - 1];
points[b++] = frames[a];
}
- if (a == totframe - 1)
+ if (a == totframe - 1) {
points[b++] = frames[a];
+ }
}
*totseg_r = totseg;
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
index 7b14678ed62..32079e4f290 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
@@ -29,7 +29,7 @@
// NOTE: Keep first, BLI_path_util conflicts with OIIO's format.
#include <memory>
-#include <openimageio_api.h>
+#include "openimageio_api.h"
#include <OpenImageIO/imageio.h>
extern "C" {
@@ -98,16 +98,18 @@ static ImBuf *imb_oiio_load_image(
std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl
<< in->geterror() << std::endl;
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
return NULL;
}
}
catch (const std::exception &exc) {
std::cerr << exc.what() << std::endl;
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
return NULL;
}
@@ -136,16 +138,18 @@ static ImBuf *imb_oiio_load_image_float(
std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl
<< in->geterror() << std::endl;
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
return NULL;
}
}
catch (const std::exception &exc) {
std::cerr << exc.what() << std::endl;
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
return NULL;
}
@@ -153,7 +157,8 @@ static ImBuf *imb_oiio_load_image_float(
/* ImBuf always needs 4 channels */
fill_all_channels((float *)ibuf->rect_float, width, height, components, 1.0f);
- /* note: Photoshop 16 bit files never has alpha with it, so no need to handle associated/unassociated alpha */
+ /* Note: Photoshop 16 bit files never has alpha with it,
+ * so no need to handle associated/unassociated alpha. */
return ibuf;
}
@@ -193,8 +198,9 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
char file_colorspace[IM_MAX_SPACE];
/* load image from file through OIIO */
- if (imb_is_a_photoshop(filename) == 0)
+ if (imb_is_a_photoshop(filename) == 0) {
return (NULL);
+ }
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@@ -218,12 +224,14 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
BLI_strncpy(file_colorspace, ics.c_str(), IM_MAX_SPACE);
/* only use colorspaces exis */
- if (colormanage_colorspace_get_named(file_colorspace))
+ if (colormanage_colorspace_get_named(file_colorspace)) {
strcpy(colorspace, file_colorspace);
- else
+ }
+ else {
std::cerr << __func__ << ": The embed colorspace (\"" << file_colorspace
<< "\") not supported in existent OCIO configuration file. Fallback "
<< "to system default colorspace (\"" << colorspace << "\")." << std::endl;
+ }
width = spec.width;
height = spec.height;
@@ -240,17 +248,20 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
return NULL;
}
- if (is_float)
+ if (is_float) {
ibuf = imb_oiio_load_image_float(in.get(), width, height, components, flags, is_alpha);
- else
+ }
+ else {
ibuf = imb_oiio_load_image(in.get(), width, height, components, flags, is_alpha);
+ }
if (in) {
in->close();
}
- if (!ibuf)
+ if (!ibuf) {
return NULL;
+ }
/* ImBuf always needs 4 channels */
ibuf->ftype = IMB_FTYPE_PSD;
@@ -262,8 +273,9 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
}
catch (const std::exception &exc) {
std::cerr << exc.what() << std::endl;
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
return NULL;
}
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index d0f550feb0d..a98ec2b0f15 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -116,50 +116,49 @@ static void imb_exr_type_by_channels(ChannelList &channels,
/* Memory Input Stream */
-class Mem_IStream : public Imf::IStream {
+class IMemStream : public Imf::IStream {
public:
- Mem_IStream(unsigned char *exrbuf, size_t exrsize)
- : IStream("dummy"), _exrpos(0), _exrsize(exrsize)
+ IMemStream(unsigned char *exrbuf, size_t exrsize)
+ : IStream("<memory>"), _exrpos(0), _exrsize(exrsize)
{
_exrbuf = exrbuf;
}
- virtual bool read(char c[], int n);
- virtual Int64 tellg();
- virtual void seekg(Int64 pos);
- virtual void clear();
- //virtual ~Mem_IStream() {}; // unused
+ virtual ~IMemStream()
+ {
+ }
- private:
- Int64 _exrpos;
- Int64 _exrsize;
- unsigned char *_exrbuf;
-};
+ virtual bool read(char c[], int n)
+ {
+ if (n + _exrpos <= _exrsize) {
+ memcpy(c, (void *)(&_exrbuf[_exrpos]), n);
+ _exrpos += n;
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
-bool Mem_IStream::read(char c[], int n)
-{
- if (n + _exrpos <= _exrsize) {
- memcpy(c, (void *)(&_exrbuf[_exrpos]), n);
- _exrpos += n;
- return true;
+ virtual Int64 tellg()
+ {
+ return _exrpos;
}
- else
- return false;
-}
-Int64 Mem_IStream::tellg()
-{
- return _exrpos;
-}
+ virtual void seekg(Int64 pos)
+ {
+ _exrpos = pos;
+ }
-void Mem_IStream::seekg(Int64 pos)
-{
- _exrpos = pos;
-}
+ virtual void clear()
+ {
+ }
-void Mem_IStream::clear()
-{
-}
+ private:
+ Int64 _exrpos;
+ Int64 _exrsize;
+ unsigned char *_exrbuf;
+};
/* File Input Stream */
@@ -176,14 +175,16 @@ class IFileStream : public Imf::IStream {
ifs.open(filename, std::ios_base::binary);
#endif
- if (!ifs)
+ if (!ifs) {
Iex::throwErrnoExc();
+ }
}
virtual bool read(char c[], int n)
{
- if (!ifs)
+ if (!ifs) {
throw Iex::InputExc("Unexpected end of file.");
+ }
errno = 0;
ifs.read(c, n);
@@ -210,8 +211,9 @@ class IFileStream : public Imf::IStream {
bool check_error()
{
if (!ifs) {
- if (errno)
+ if (errno) {
Iex::throwErrnoExc();
+ }
return false;
}
@@ -222,6 +224,48 @@ class IFileStream : public Imf::IStream {
std::ifstream ifs;
};
+/* Memory Output Stream */
+
+class OMemStream : public OStream {
+ public:
+ OMemStream(ImBuf *ibuf_) : OStream("<memory>"), ibuf(ibuf_), offset(0)
+ {
+ }
+
+ virtual void write(const char c[], int n)
+ {
+ ensure_size(offset + n);
+ memcpy(ibuf->encodedbuffer + offset, c, n);
+ offset += n;
+ ibuf->encodedsize += n;
+ }
+
+ virtual Int64 tellp()
+ {
+ return offset;
+ }
+
+ virtual void seekp(Int64 pos)
+ {
+ offset = pos;
+ ensure_size(offset);
+ }
+
+ private:
+ void ensure_size(Int64 size)
+ {
+ /* if buffer is too small increase it. */
+ while (size > ibuf->encodedbuffersize) {
+ if (!imb_enlargeencodedbufferImBuf(ibuf)) {
+ throw Iex::ErrnoExc("Out of memory.");
+ }
+ }
+ }
+
+ ImBuf *ibuf;
+ Int64 offset;
+};
+
/* File Output Stream */
class OFileStream : public OStream {
@@ -237,8 +281,9 @@ class OFileStream : public OStream {
ofs.open(filename, std::ios_base::binary);
#endif
- if (!ofs)
+ if (!ofs) {
Iex::throwErrnoExc();
+ }
}
virtual void write(const char c[], int n)
@@ -263,8 +308,9 @@ class OFileStream : public OStream {
void check_error()
{
if (!ofs) {
- if (errno)
+ if (errno) {
Iex::throwErrnoExc();
+ }
throw Iex::ErrnoExc("File output failed.");
}
@@ -347,8 +393,9 @@ static void openexr_header_metadata(Header *header, struct ImBuf *ibuf)
}
}
- if (ibuf->ppm[0] > 0.0)
+ if (ibuf->ppm[0] > 0.0) {
addXDensity(*header, ibuf->ppm[0] / 39.3700787); /* 1 meter = 39.3700787 inches */
+ }
}
static void openexr_header_metadata_callback(void *data,
@@ -367,6 +414,7 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags
const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
const int width = ibuf->x;
const int height = ibuf->y;
+ OStream *file_stream = NULL;
try {
Header header(width, height);
@@ -378,16 +426,24 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags
header.channels().insert("R", Channel(HALF));
header.channels().insert("G", Channel(HALF));
header.channels().insert("B", Channel(HALF));
- if (is_alpha)
+ if (is_alpha) {
header.channels().insert("A", Channel(HALF));
- if (is_zbuf) // z we do as float always
+ }
+ if (is_zbuf) {
+ /* z we do as float always */
header.channels().insert("Z", Channel(Imf::FLOAT));
+ }
FrameBuffer frameBuffer;
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
- OFileStream file_stream(name);
- OutputFile file(file_stream, header);
+ if (flags & IB_mem) {
+ file_stream = new OMemStream(ibuf);
+ }
+ else {
+ file_stream = new OFileStream(name);
+ }
+ OutputFile file(*file_stream, header);
/* we store first everything in half array */
std::vector<RGBAZ> pixels(height * width);
@@ -448,11 +504,13 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags
file.writePixels(height);
}
catch (const std::exception &exc) {
+ delete file_stream;
printf("OpenEXR-save: ERROR: %s\n", exc.what());
return false;
}
+ delete file_stream;
return true;
}
@@ -463,6 +521,7 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag
const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
const int width = ibuf->x;
const int height = ibuf->y;
+ OStream *file_stream = NULL;
try {
Header header(width, height);
@@ -474,16 +533,23 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag
header.channels().insert("R", Channel(Imf::FLOAT));
header.channels().insert("G", Channel(Imf::FLOAT));
header.channels().insert("B", Channel(Imf::FLOAT));
- if (is_alpha)
+ if (is_alpha) {
header.channels().insert("A", Channel(Imf::FLOAT));
- if (is_zbuf)
+ }
+ if (is_zbuf) {
header.channels().insert("Z", Channel(Imf::FLOAT));
+ }
FrameBuffer frameBuffer;
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
- OFileStream file_stream(name);
- OutputFile file(file_stream, header);
+ if (flags & IB_mem) {
+ file_stream = new OMemStream(ibuf);
+ }
+ else {
+ file_stream = new OFileStream(name);
+ }
+ OutputFile file(*file_stream, header);
int xstride = sizeof(float) * channels;
int ystride = -xstride * width;
@@ -516,33 +582,36 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag
}
catch (const std::exception &exc) {
printf("OpenEXR-save: ERROR: %s\n", exc.what());
+ delete file_stream;
return false;
}
+ delete file_stream;
return true;
}
int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
{
if (flags & IB_mem) {
- printf("OpenEXR-save: Create EXR in memory CURRENTLY NOT SUPPORTED !\n");
imb_addencodedbufferImBuf(ibuf);
ibuf->encodedsize = 0;
- return (0);
}
- if (ibuf->foptions.flag & OPENEXR_HALF)
+ if (ibuf->foptions.flag & OPENEXR_HALF) {
return (int)imb_save_openexr_half(ibuf, name, flags);
+ }
else {
/* when no float rect, we save as half (16 bits is sufficient) */
- if (ibuf->rect_float == NULL)
+ if (ibuf->rect_float == NULL) {
return (int)imb_save_openexr_half(ibuf, name, flags);
- else
+ }
+ else {
return (int)imb_save_openexr_float(ibuf, name, flags);
+ }
}
}
-/* ********************* Nicer API, MultiLayer and with Tile file support ************************************ */
+/* ******* Nicer API, MultiLayer and with Tile file support ************************************ */
/* naming rules:
* - parse name from right to left
@@ -568,8 +637,10 @@ typedef struct ExrHandle {
int width, height;
int mipmap;
- StringVector *
- multiView; /* it needs to be a pointer due to Windows release builds of EXR2.0 segfault when opening EXR bug */
+ /** It needs to be a pointer due to Windows release builds of EXR2.0
+ * segfault when opening EXR bug. */
+ StringVector *multiView;
+
int parts;
ListBase channels; /* flattened out, ExrChannel */
@@ -648,10 +719,12 @@ static int imb_exr_get_multiView_id(StringVector &views, const std::string &name
{
int count = 0;
for (StringVector::const_iterator i = views.begin(); count < views.size(); ++i) {
- if (name == *i)
+ if (name == *i) {
return count;
- else
+ }
+ else {
count++;
+ }
}
/* no views or wrong name */
@@ -663,19 +736,22 @@ static void imb_exr_get_views(MultiPartInputFile &file, StringVector &views)
if (exr_has_multipart_file(file) == false) {
if (exr_has_multiview(file)) {
StringVector sv = multiView(file.header(0));
- for (StringVector::const_iterator i = sv.begin(); i != sv.end(); ++i)
+ for (StringVector::const_iterator i = sv.begin(); i != sv.end(); ++i) {
views.push_back(*i);
+ }
}
}
else {
for (int p = 0; p < file.parts(); p++) {
std::string view = "";
- if (file.header(p).hasView())
+ if (file.header(p).hasView()) {
view = file.header(p).view();
+ }
- if (imb_exr_get_multiView_id(views, view) == -1)
+ if (imb_exr_get_multiView_id(views, view) == -1) {
views.push_back(view);
+ }
}
}
}
@@ -793,11 +869,13 @@ int IMB_exr_begin_write(void *handle,
imb_exr_type_by_channels(
header.channels(), *data->multiView, &is_singlelayer, &is_multilayer, &is_multiview);
- if (is_multilayer)
+ if (is_multilayer) {
header.insert("BlenderMultiChannel", StringAttribute("Blender V2.55.1 and newer"));
+ }
- if (is_multiview)
+ if (is_multiview) {
addMultiView(header, *data->multiView);
+ }
/* avoid crash/abort when we don't have permission to write here */
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
@@ -981,8 +1059,9 @@ float *IMB_exr_channel_rect(void *handle,
BLI_snprintf(name, sizeof(name), "%s.%s", lay, pass);
}
- else
+ else {
BLI_strncpy(name, passname, EXR_TOT_MAXNAME - 1);
+ }
/* name has to be unique, thus it's a combination of layer, pass, view, and channel */
if (layname && layname[0] != '\0') {
@@ -998,8 +1077,9 @@ float *IMB_exr_channel_rect(void *handle,
echan = (ExrChannel *)BLI_findstring(&data->channels, name, offsetof(ExrChannel, name));
- if (echan)
+ if (echan) {
return echan->rect;
+ }
return NULL;
}
@@ -1009,8 +1089,9 @@ void IMB_exr_clear_channels(void *handle)
ExrHandle *data = (ExrHandle *)handle;
ExrChannel *chan;
- for (chan = (ExrChannel *)data->channels.first; chan; chan = chan->next)
+ for (chan = (ExrChannel *)data->channels.first; chan; chan = chan->next) {
delete chan->m;
+ }
BLI_freelistN(&data->channels);
}
@@ -1094,9 +1175,10 @@ void IMB_exrtile_write_channels(
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
/* eventually we can make the parts' channels to include
- only the current view TODO */
- if (strcmp(viewname, echan->m->view.c_str()) != 0)
+ * only the current view TODO */
+ if (strcmp(viewname, echan->m->view.c_str()) != 0) {
continue;
+ }
exr_printf("%d %-6s %-22s \"%s\"\n",
echan->m->part_number,
@@ -1186,8 +1268,9 @@ void IMB_exr_read_channels(void *handle)
frameBuffer.insert(echan->m->internal_name,
Slice(Imf::FLOAT, (char *)rect, xstride, ystride));
}
- else
+ else {
printf("warning, channel with no rect set %s\n", echan->m->internal_name.c_str());
+ }
}
/* Read pixels. */
@@ -1279,9 +1362,11 @@ void IMB_exr_close(void *handle)
BLI_freelistN(&data->channels);
for (lay = (ExrLayer *)data->layers.first; lay; lay = lay->next) {
- for (pass = (ExrPass *)lay->passes.first; pass; pass = pass->next)
- if (pass->rect)
+ for (pass = (ExrPass *)lay->passes.first; pass; pass = pass->next) {
+ if (pass->rect) {
MEM_freeN(pass->rect);
+ }
+ }
BLI_freelistN(&lay->passes);
}
BLI_freelistN(&data->layers);
@@ -1320,12 +1405,15 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa
echan->chan_id = name[0];
layname[0] = '\0';
- if (ELEM(name[0], 'R', 'G', 'B', 'A'))
+ if (ELEM(name[0], 'R', 'G', 'B', 'A')) {
strcpy(passname, "Combined");
- else if (name[0] == 'Z')
+ }
+ else if (name[0] == 'Z') {
strcpy(passname, "Depth");
- else
+ }
+ else {
strcpy(passname, name);
+ }
return 1;
}
@@ -1396,10 +1484,12 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa
end -= len + 1; /* +1 to skip '.' separator */
/* all preceding tokens combined as layer name */
- if (end > name)
+ if (end > name) {
BLI_strncpy(layname, name, (int)(end - name) + 1);
- else
+ }
+ else {
layname[0] = '\0';
+ }
return 1;
}
@@ -1424,10 +1514,12 @@ static ExrPass *imb_exr_get_pass(ListBase *lb, char *passname)
if (pass == NULL) {
pass = (ExrPass *)MEM_callocN(sizeof(ExrPass), "exr pass");
- if (STREQ(passname, "Combined"))
+ if (STREQ(passname, "Combined")) {
BLI_addhead(lb, pass);
- else
+ }
+ else {
BLI_addtail(lb, pass);
+ }
}
BLI_strncpy(pass->name, passname, EXR_LAY_MAXNAME);
@@ -1495,8 +1587,9 @@ static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream,
BLI_strncpy(pass->view, view, sizeof(pass->view));
BLI_strncpy(pass->internal_name, internal_name, EXR_PASS_MAXNAME);
- if (pass->totchan >= EXR_PASS_MAXCHAN)
+ if (pass->totchan >= EXR_PASS_MAXCHAN) {
break;
+ }
}
}
if (echan) {
@@ -1600,8 +1693,9 @@ static void exr_print_filecontents(MultiPartInputFile &file)
else if (numparts > 1) {
printf("OpenEXR-load: MultiPart file\n");
for (int i = 0; i < numparts; i++) {
- if (file.header(i).hasView())
+ if (file.header(i).hasView()) {
printf("OpenEXR-load: Part %d: view = \"%s\"\n", i, file.header(i).view().c_str());
+ }
}
}
@@ -1671,8 +1765,9 @@ static bool imb_exr_is_multilayer_file(MultiPartInputFile &file)
/* will not include empty layer names */
channels.layers(layerNames);
- if (layerNames.size() > 1)
+ if (layerNames.size() > 1) {
return true;
+ }
if (layerNames.size()) {
/* if layerNames is not empty, it means at least one layer is non-empty,
@@ -1686,8 +1781,9 @@ static bool imb_exr_is_multilayer_file(MultiPartInputFile &file)
std::string layerName = i.name();
size_t pos = layerName.rfind('.');
- if (pos == std::string::npos)
+ if (pos == std::string::npos) {
return true;
+ }
}
}
@@ -1726,8 +1822,8 @@ static void imb_exr_type_by_channels(ChannelList &channels,
* that's what we do here: test whether there're empty layer names together
* with non-empty ones in the file
*/
- for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); i++)
- for (std::set<string>::iterator i = layerNames.begin(); i != layerNames.end(); i++)
+ for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); i++) {
+ for (std::set<string>::iterator i = layerNames.begin(); i != layerNames.end(); i++) {
/* see if any layername differs from a viewname */
if (imb_exr_get_multiView_id(views, *i) == -1) {
std::string layerName = *i;
@@ -1739,6 +1835,8 @@ static void imb_exr_type_by_channels(ChannelList &channels,
return;
}
}
+ }
+ }
}
else {
*r_singlelayer = true;
@@ -1767,15 +1865,19 @@ static bool exr_has_multipart_file(MultiPartInputFile &file)
/* it returns true if the file is multilayer or multiview */
static bool imb_exr_is_multi(MultiPartInputFile &file)
{
- /* multipart files are treated as multilayer in blender - even if they are single layer openexr with multiview */
- if (exr_has_multipart_file(file))
+ /* Multipart files are treated as multilayer in blender -
+ * even if they are single layer openexr with multiview. */
+ if (exr_has_multipart_file(file)) {
return true;
+ }
- if (exr_has_multiview(file))
+ if (exr_has_multiview(file)) {
return true;
+ }
- if (imb_exr_is_multilayer_file(file))
+ if (imb_exr_is_multilayer_file(file)) {
return true;
+ }
return false;
}
@@ -1792,29 +1894,31 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
char colorspace[IM_MAX_SPACE])
{
struct ImBuf *ibuf = NULL;
- Mem_IStream *membuf = NULL;
+ IMemStream *membuf = NULL;
MultiPartInputFile *file = NULL;
- if (imb_is_a_openexr(mem) == 0)
+ if (imb_is_a_openexr(mem) == 0) {
return (NULL);
+ }
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
try {
bool is_multi;
- membuf = new Mem_IStream((unsigned char *)mem, size);
+ membuf = new IMemStream((unsigned char *)mem, size);
file = new MultiPartInputFile(*membuf);
Box2i dw = file->header(0).dataWindow();
const int width = dw.max.x - dw.min.x + 1;
const int height = dw.max.y - dw.min.y + 1;
- //printf("OpenEXR-load: image data window %d %d %d %d\n",
+ // printf("OpenEXR-load: image data window %d %d %d %d\n",
// dw.min.x, dw.min.y, dw.max.x, dw.max.y);
- if (0) // debug
+ if (0) { // debug
exr_print_filecontents(*file);
+ }
is_multi = imb_exr_is_multi(*file);
@@ -1872,7 +1976,8 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
imb_addrectfloatImBuf(ibuf);
- /* inverse correct first pixel for datawindow coordinates (- dw.min.y because of y flip) */
+ /* Inverse correct first pixel for datawindow
+ * coordinates (- dw.min.y because of y flip). */
first = ibuf->rect_float - 4 * (dw.min.x - dw.min.y * width);
/* but, since we read y-flipped (negative y stride) we move to last scanline */
first += 4 * (height - 1) * width;
@@ -1917,12 +2022,14 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
// XXX, ImBuf has no nice way to deal with this.
// ideally IM_rect would be used when the caller wants a rect BUT
// at the moment all functions use IM_rect.
- // Disabling this is ok because all functions should check if a rect exists and create one on demand.
+ // Disabling this is ok because all functions should check
+ // if a rect exists and create one on demand.
//
// Disabling this because the sequencer frees immediate.
//
- // if (flag & IM_rect)
+ // if (flag & IM_rect) {
// IMB_rect_from_float(ibuf);
+ // }
if (!has_rgb && has_luma) {
size_t a;
@@ -1956,15 +2063,17 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
delete file;
}
- if (flags & IB_alphamode_detect)
+ if (flags & IB_alphamode_detect) {
ibuf->flags |= IB_alphamode_premul;
+ }
}
return (ibuf);
}
catch (const std::exception &exc) {
std::cerr << exc.what() << std::endl;
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
delete file;
delete membuf;
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 27cf30c71ba..68504f5c0dc 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -83,7 +83,7 @@ static void WriteData(png_structp png_ptr, png_bytep data, png_size_t length)
{
ImBuf *ibuf = (ImBuf *)png_get_io_ptr(png_ptr);
- /* if buffer is to small increase it. */
+ /* if buffer is too small increase it. */
while (ibuf->encodedsize + length > ibuf->encodedbuffersize) {
imb_enlargeencodedbufferImBuf(ibuf);
}
@@ -154,8 +154,9 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
}
/* for prints */
- if (flags & IB_mem)
+ if (flags & IB_mem) {
name = "<memory>";
+ }
bytesperpixel = (ibuf->planes + 7) >> 3;
if ((bytesperpixel > 4) || (bytesperpixel == 2)) {
@@ -184,10 +185,12 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
/* copy image data */
num_bytes = ((size_t)ibuf->x) * ibuf->y * bytesperpixel;
- if (is_16bit)
+ if (is_16bit) {
pixels16 = MEM_mallocN(num_bytes * sizeof(unsigned short), "png 16bit pixels");
- else
+ }
+ else {
pixels = MEM_mallocN(num_bytes * sizeof(unsigned char), "png 8bit pixels");
+ }
if (pixels == NULL && pixels16 == NULL) {
png_destroy_write_struct(&png_ptr, &info_ptr);
@@ -378,10 +381,12 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
fp = BLI_fopen(name, "wb");
if (!fp) {
png_destroy_write_struct(&png_ptr, &info_ptr);
- if (pixels)
+ if (pixels) {
MEM_freeN(pixels);
- if (pixels16)
+ }
+ if (pixels16) {
MEM_freeN(pixels16);
+ }
printf("imb_savepng: Cannot open file for writing: '%s'\n", name);
return 0;
}
@@ -389,13 +394,11 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
}
#if 0
- png_set_filter(png_ptr, 0,
- PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE |
- PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
- PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
- PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG |
- PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH |
- PNG_ALL_FILTERS);
+ png_set_filter(png_ptr,
+ 0,
+ PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
+ PNG_FILTER_UP | PNG_FILTER_VALUE_UP | PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG |
+ PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH | PNG_ALL_FILTERS);
#endif
png_set_compression_level(png_ptr, compression);
@@ -459,10 +462,12 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
if (row_pointers == NULL) {
printf("imb_savepng: Cannot allocate row-pointers array for file '%s'\n", name);
png_destroy_write_struct(&png_ptr, &info_ptr);
- if (pixels)
+ if (pixels) {
MEM_freeN(pixels);
- if (pixels16)
+ }
+ if (pixels16) {
MEM_freeN(pixels16);
+ }
if (fp) {
fclose(fp);
}
@@ -491,10 +496,12 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
png_write_end(png_ptr, info_ptr);
/* clean up */
- if (pixels)
+ if (pixels) {
MEM_freeN(pixels);
- if (pixels16)
+ }
+ if (pixels16) {
MEM_freeN(pixels16);
+ }
MEM_freeN(row_pointers);
png_destroy_write_struct(&png_ptr, &info_ptr);
@@ -540,8 +547,9 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors
float *to_float;
unsigned int channels;
- if (imb_is_a_png(mem) == 0)
+ if (imb_is_a_png(mem) == 0) {
return (NULL);
+ }
/* both 8 and 16 bit PNGs are default to standard byte colorspace */
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@@ -569,14 +577,18 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
- if (pixels)
+ if (pixels) {
MEM_freeN(pixels);
- if (pixels16)
+ }
+ if (pixels16) {
MEM_freeN(pixels16);
- if (row_pointers)
+ }
+ if (row_pointers) {
MEM_freeN(row_pointers);
- if (ibuf)
+ }
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
return NULL;
}
@@ -620,8 +632,9 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors
if (ibuf) {
ibuf->ftype = IMB_FTYPE_PNG;
- if (bit_depth == 16)
+ if (bit_depth == 16) {
ibuf->foptions.flag |= PNG_16BIT;
+ }
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs)) {
int unit_type;
@@ -793,12 +806,15 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors
}
/* clean up */
- if (pixels)
+ if (pixels) {
MEM_freeN(pixels);
- if (pixels16)
+ }
+ if (pixels16) {
MEM_freeN(pixels16);
- if (row_pointers)
+ }
+ if (row_pointers) {
MEM_freeN(row_pointers);
+ }
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
return (ibuf);
diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c
index e3ab460cce4..58ac966ac30 100644
--- a/source/blender/imbuf/intern/radiance_hdr.c
+++ b/source/blender/imbuf/intern/radiance_hdr.c
@@ -180,10 +180,12 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe)
{
int e;
float d = (fcol[RED] > fcol[GRN]) ? fcol[RED] : fcol[GRN];
- if (fcol[BLU] > d)
+ if (fcol[BLU] > d) {
d = fcol[BLU];
- if (d <= 1e-32f)
+ }
+ if (d <= 1e-32f) {
rgbe[RED] = rgbe[GRN] = rgbe[BLU] = rgbe[EXP] = 0;
+ }
else {
d = (float)frexp(d, &e) * 256.0f / d;
rgbe[RED] = (unsigned char)(fcol[RED] * d);
@@ -198,10 +200,12 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe)
int imb_is_a_hdr(const unsigned char *buf)
{
/* For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead */
- /* update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part */
- //if (strstr((char *)buf, "#?RADIANCE")) return 1;
- if (strstr((char *)buf, "#?"))
+ /* update: actually, the 'RADIANCE' part is just an optional program name,
+ * the magic word is really only the '#?' part */
+ // if (strstr((char *)buf, "#?RADIANCE")) return 1;
+ if (strstr((char *)buf, "#?")) {
return 1;
+ }
// if (strstr((char *)buf, "32-bit_rle_rgbe")) return 1;
return 0;
}
@@ -245,18 +249,21 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem,
ptr = (unsigned char *)strchr((char *)&mem[x + 1], '\n');
ptr++;
- if (flags & IB_test)
+ if (flags & IB_test) {
ibuf = IMB_allocImBuf(width, height, 32, 0);
- else
+ }
+ else {
ibuf = IMB_allocImBuf(width, height, 32, (flags & IB_rect) | IB_rectfloat);
+ }
if (UNLIKELY(ibuf == NULL)) {
return NULL;
}
ibuf->ftype = IMB_FTYPE_RADHDR;
- if (flags & IB_alphamode_detect)
+ if (flags & IB_alphamode_detect) {
ibuf->flags |= IB_alphamode_premul;
+ }
if (flags & IB_test) {
return ibuf;
@@ -283,8 +290,9 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem,
}
}
MEM_freeN(sline);
- if (oriY[0] == '-')
+ if (oriY[0] == '-') {
IMB_flipy(ibuf);
+ }
if (flags & IB_rect) {
IMB_rect_from_float(ibuf);
@@ -292,9 +300,9 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem,
return ibuf;
}
- //else printf("Data not found!\n");
+ // else printf("Data not found!\n");
}
- //else printf("Not a valid radiance HDR file!\n");
+ // else printf("Not a valid radiance HDR file!\n");
return NULL;
}
@@ -345,10 +353,12 @@ static int fwritecolrs(FILE *file, int width, int channels, unsigned char *ibufs
for (beg = j; beg < width; beg += cnt) {
for (cnt = 1; (cnt < 127) && ((beg + cnt) < width) &&
(rgbe_scan[beg + cnt][i] == rgbe_scan[beg][i]);
- cnt++)
+ cnt++) {
;
- if (cnt >= MINRUN)
+ }
+ if (cnt >= MINRUN) {
break; /* long enough */
+ }
}
if (((beg - j) > 1) && ((beg - j) < MINRUN)) {
c2 = j + 1;
@@ -362,11 +372,13 @@ static int fwritecolrs(FILE *file, int width, int channels, unsigned char *ibufs
}
}
while (j < beg) { /* write out non-run */
- if ((c2 = beg - j) > 128)
+ if ((c2 = beg - j) > 128) {
c2 = 128;
+ }
putc((unsigned char)(c2), file);
- while (c2--)
+ while (c2--) {
putc(rgbe_scan[j++][i], file);
+ }
}
if (cnt >= MINRUN) { /* write out run */
putc((unsigned char)(128 + cnt), file);
@@ -411,10 +423,12 @@ int imb_savehdr(struct ImBuf *ibuf, const char *name, int flags)
writeHeader(file, width, height);
- if (ibuf->rect)
+ if (ibuf->rect) {
cp = (unsigned char *)ibuf->rect + ibuf->channels * (height - 1) * width;
- if (ibuf->rect_float)
+ }
+ if (ibuf->rect_float) {
fp = ibuf->rect_float + ibuf->channels * (height - 1) * width;
+ }
for (size_t y = 0; y < height; y++) {
if (fwritecolrs(file, width, ibuf->channels, cp, fp) < 0) {
@@ -422,10 +436,12 @@ int imb_savehdr(struct ImBuf *ibuf, const char *name, int flags)
printf("HDR write error\n");
return 0;
}
- if (cp)
+ if (cp) {
cp -= ibuf->channels * width;
- if (fp)
+ }
+ if (fp) {
fp -= ibuf->channels * width;
+ }
}
fclose(file);
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 34bae007979..e1df5c63093 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -62,10 +62,12 @@ static void imb_handle_alpha(ImBuf *ibuf,
BLI_strncpy(colorspace, effective_colorspace, IM_MAX_SPACE);
}
- if (flags & IB_alphamode_detect)
+ if (flags & IB_alphamode_detect) {
alpha_flags = ibuf->flags & IB_alphamode_premul;
- else
+ }
+ else {
alpha_flags = flags & IB_alphamode_premul;
+ }
if (flags & IB_ignore_alpha) {
IMB_rectfill_alpha(ibuf, 1.0f);
@@ -109,8 +111,9 @@ ImBuf *IMB_ibImageFromMemory(const unsigned char *mem,
return NULL;
}
- if (colorspace)
+ if (colorspace) {
BLI_strncpy(effective_colorspace, colorspace, sizeof(effective_colorspace));
+ }
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
if (type->load) {
@@ -122,8 +125,9 @@ ImBuf *IMB_ibImageFromMemory(const unsigned char *mem,
}
}
- if ((flags & IB_test) == 0)
+ if ((flags & IB_test) == 0) {
fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr);
+ }
return NULL;
}
@@ -137,8 +141,9 @@ static ImBuf *IMB_ibImageFromFile(const char *filepath,
const ImFileType *type;
char effective_colorspace[IM_MAX_SPACE] = "";
- if (colorspace)
+ if (colorspace) {
BLI_strncpy(effective_colorspace, colorspace, sizeof(effective_colorspace));
+ }
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
if (type->load_filepath) {
@@ -150,8 +155,9 @@ static ImBuf *IMB_ibImageFromFile(const char *filepath,
}
}
- if ((flags & IB_test) == 0)
+ if ((flags & IB_test) == 0) {
fprintf(stderr, "%s: unknown fileformat (%s)\n", __func__, descr);
+ }
return NULL;
}
@@ -169,11 +175,13 @@ ImBuf *IMB_loadifffile(
unsigned char *mem;
size_t size;
- if (file == -1)
+ if (file == -1) {
return NULL;
+ }
- if (imb_is_filepath_format(filepath))
+ if (imb_is_filepath_format(filepath)) {
return IMB_ibImageFromFile(filepath, flags, colorspace, descr);
+ }
size = BLI_file_descriptor_size(file);
@@ -189,8 +197,9 @@ ImBuf *IMB_loadifffile(
ibuf = IMB_ibImageFromMemory(mem, size, flags, colorspace, descr);
imb_mmap_lock();
- if (munmap(mem, size))
+ if (munmap(mem, size)) {
fprintf(stderr, "%s: couldn't unmap file %s\n", __func__, descr);
+ }
imb_mmap_unlock();
return ibuf;
@@ -201,11 +210,13 @@ static void imb_cache_filename(char *filename, const char *name, int flags)
/* read .tx instead if it exists and is not older */
if (flags & IB_tilecache) {
BLI_strncpy(filename, name, IMB_FILENAME_SIZE);
- if (!BLI_path_extension_replace(filename, IMB_FILENAME_SIZE, ".tx"))
+ if (!BLI_path_extension_replace(filename, IMB_FILENAME_SIZE, ".tx")) {
return;
+ }
- if (BLI_file_older(name, filename))
+ if (BLI_file_older(name, filename)) {
return;
+ }
}
BLI_strncpy(filename, name, IMB_FILENAME_SIZE);
@@ -222,16 +233,18 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S
imb_cache_filename(filepath_tx, filepath, flags);
file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0);
- if (file == -1)
+ if (file == -1) {
return NULL;
+ }
ibuf = IMB_loadifffile(file, filepath, flags, colorspace, filepath_tx);
if (ibuf) {
BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name));
BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename));
- for (a = 1; a < ibuf->miptot; a++)
+ for (a = 1; a < ibuf->miptot; a++) {
BLI_strncpy(ibuf->mipmap[a - 1]->cachename, filepath_tx, sizeof(ibuf->cachename));
+ }
}
close(file);
@@ -251,8 +264,9 @@ ImBuf *IMB_testiffname(const char *filepath, int flags)
imb_cache_filename(filepath_tx, filepath, flags);
file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0);
- if (file == -1)
+ if (file == -1) {
return NULL;
+ }
ibuf = IMB_loadifffile(file, filepath, flags | IB_test | IB_multilayer, colorspace, filepath_tx);
@@ -272,8 +286,9 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int
unsigned char *mem;
size_t size;
- if (file == -1)
+ if (file == -1) {
return;
+ }
size = BLI_file_descriptor_size(file);
@@ -286,13 +301,16 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int
return;
}
- for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++)
- if (type->load_tile && type->ftype(type, ibuf))
+ for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
+ if (type->load_tile && type->ftype(type, ibuf)) {
type->load_tile(ibuf, mem, size, tx, ty, rect);
+ }
+ }
imb_mmap_lock();
- if (munmap(mem, size))
+ if (munmap(mem, size)) {
fprintf(stderr, "Couldn't unmap memory for %s.\n", ibuf->cachename);
+ }
imb_mmap_unlock();
}
@@ -301,8 +319,9 @@ void imb_loadtile(ImBuf *ibuf, int tx, int ty, unsigned int *rect)
int file;
file = BLI_open(ibuf->cachename, O_BINARY | O_RDONLY, 0);
- if (file == -1)
+ if (file == -1) {
return;
+ }
imb_loadtilefile(ibuf, file, tx, ty, rect);
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index a069e79b337..25390b73737 100644
--- a/source/blender/imbuf/intern/rectop.c
+++ b/source/blender/imbuf/intern/rectop.c
@@ -220,8 +220,9 @@ void IMB_rectclip(ImBuf *dbuf,
{
int tmp;
- if (dbuf == NULL)
+ if (dbuf == NULL) {
return;
+ }
if (*destx < 0) {
*srcx -= *destx;
@@ -245,19 +246,23 @@ void IMB_rectclip(ImBuf *dbuf,
}
tmp = dbuf->x - *destx;
- if (*width > tmp)
+ if (*width > tmp) {
*width = tmp;
+ }
tmp = dbuf->y - *desty;
- if (*height > tmp)
+ if (*height > tmp) {
*height = tmp;
+ }
if (sbuf) {
tmp = sbuf->x - *srcx;
- if (*width > tmp)
+ if (*width > tmp) {
*width = tmp;
+ }
tmp = sbuf->y - *srcy;
- if (*height > tmp)
+ if (*height > tmp) {
*height = tmp;
+ }
}
if ((*height <= 0) || (*width <= 0)) {
@@ -280,8 +285,9 @@ static void imb_rectclip3(ImBuf *dbuf,
{
int tmp;
- if (dbuf == NULL)
+ if (dbuf == NULL) {
return;
+ }
if (*destx < 0) {
*srcx -= *destx;
@@ -322,28 +328,34 @@ static void imb_rectclip3(ImBuf *dbuf,
}
tmp = dbuf->x - *destx;
- if (*width > tmp)
+ if (*width > tmp) {
*width = tmp;
+ }
tmp = dbuf->y - *desty;
- if (*height > tmp)
+ if (*height > tmp) {
*height = tmp;
+ }
if (obuf) {
tmp = obuf->x - *origx;
- if (*width > tmp)
+ if (*width > tmp) {
*width = tmp;
+ }
tmp = obuf->y - *origy;
- if (*height > tmp)
+ if (*height > tmp) {
*height = tmp;
+ }
}
if (sbuf) {
tmp = sbuf->x - *srcx;
- if (*width > tmp)
+ if (*width > tmp) {
*width = tmp;
+ }
tmp = sbuf->y - *srcy;
- if (*height > tmp)
+ if (*height > tmp) {
*height = tmp;
+ }
}
if ((*height <= 0) || (*width <= 0)) {
@@ -408,17 +420,21 @@ void IMB_rectblend(ImBuf *dbuf,
IMB_blend_func func = NULL;
IMB_blend_func_float func_float = NULL;
- if (dbuf == NULL || obuf == NULL)
+ if (dbuf == NULL || obuf == NULL) {
return;
+ }
imb_rectclip3(dbuf, obuf, sbuf, &destx, &desty, &origx, &origy, &srcx, &srcy, &width, &height);
- if (width == 0 || height == 0)
+ if (width == 0 || height == 0) {
return;
- if (sbuf && sbuf->channels != 4)
+ }
+ if (sbuf && sbuf->channels != 4) {
return;
- if (dbuf->channels != 4)
+ }
+ if (dbuf->channels != 4) {
return;
+ }
do_char = (sbuf && sbuf->rect && dbuf->rect && obuf->rect);
do_float = (sbuf && sbuf->rect_float && dbuf->rect_float && obuf->rect_float);
@@ -432,24 +448,29 @@ void IMB_rectblend(ImBuf *dbuf,
orectf = obuf->rect_float + (((size_t)origy) * obuf->x + origx) * 4;
}
- if (dmaskrect)
+ if (dmaskrect) {
dmaskrect += ((size_t)origy) * obuf->x + origx;
+ }
destskip = dbuf->x;
origskip = obuf->x;
if (sbuf) {
- if (do_char)
+ if (do_char) {
srect = sbuf->rect + ((size_t)srcy) * sbuf->x + srcx;
- if (do_float)
+ }
+ if (do_float) {
srectf = sbuf->rect_float + (((size_t)srcy) * sbuf->x + srcx) * 4;
+ }
srcskip = sbuf->x;
- if (cmaskrect)
+ if (cmaskrect) {
cmaskrect += ((size_t)srcy) * sbuf->x + srcx;
+ }
- if (texmaskrect)
+ if (texmaskrect) {
texmaskrect += ((size_t)srcy) * sbuf->x + srcx;
+ }
}
else {
srect = drect;
@@ -509,8 +530,9 @@ void IMB_rectblend(ImBuf *dbuf,
if (do_char) {
dr = drect;
sr = srect;
- for (x = width; x > 0; x--, dr++, sr++)
+ for (x = width; x > 0; x--, dr++, sr++) {
((char *)dr)[3] = ((char *)sr)[3];
+ }
drect += destskip;
srect += srcskip;
}
@@ -518,8 +540,9 @@ void IMB_rectblend(ImBuf *dbuf,
if (do_float) {
drf = drectf;
srf = srectf;
- for (x = width; x > 0; x--, drf += 4, srf += 4)
+ for (x = width; x > 0; x--, drf += 4, srf += 4) {
drf[3] = srf[3];
+ }
drectf += destskip * 4;
srectf += srcskip * 4;
}
@@ -647,16 +670,19 @@ void IMB_rectblend(ImBuf *dbuf,
unsigned char *src = (unsigned char *)sr;
float mask_lim = mask_max * (*cmr);
- if (texmaskrect)
+ if (texmaskrect) {
mask_lim *= ((*tmr++) / 65535.0f);
+ }
if (src[3] && mask_lim) {
float mask;
- if (accumulate)
+ if (accumulate) {
mask = *dmr + mask_lim;
- else
+ }
+ else {
mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f));
+ }
mask = min_ff(mask, 65535.0);
@@ -689,8 +715,9 @@ void IMB_rectblend(ImBuf *dbuf,
unsigned char *src = (unsigned char *)sr;
float mask = (float)mask_max * ((float)(*cmr));
- if (texmaskrect)
+ if (texmaskrect) {
mask *= ((float)(*tmr++) / 65535.0f);
+ }
mask = min_ff(mask, 65535.0);
@@ -715,14 +742,16 @@ void IMB_rectblend(ImBuf *dbuf,
}
cmaskrect += srcskip;
- if (texmaskrect)
+ if (texmaskrect) {
texmaskrect += srcskip;
+ }
}
else {
/* regular blending */
for (x = width; x > 0; x--, dr++, or ++, sr++) {
- if (((unsigned char *)sr)[3])
+ if (((unsigned char *)sr)[3]) {
func((unsigned char *)dr, (unsigned char *) or, (unsigned char *)sr);
+ }
}
}
@@ -747,16 +776,19 @@ void IMB_rectblend(ImBuf *dbuf,
for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4, dmr++, cmr++) {
float mask_lim = mask_max * (*cmr);
- if (texmaskrect)
+ if (texmaskrect) {
mask_lim *= ((*tmr++) / 65535.0f);
+ }
if (srf[3] && mask_lim) {
float mask;
- if (accumulate)
+ if (accumulate) {
mask = min_ff(*dmr + mask_lim, 65535.0);
- else
+ }
+ else {
mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f));
+ }
mask = min_ff(mask, 65535.0);
@@ -781,8 +813,9 @@ void IMB_rectblend(ImBuf *dbuf,
for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4, cmr++) {
float mask = (float)mask_max * ((float)(*cmr));
- if (texmaskrect)
+ if (texmaskrect) {
mask *= ((float)(*tmr++) / 65535.0f);
+ }
mask = min_ff(mask, 65535.0);
@@ -800,14 +833,16 @@ void IMB_rectblend(ImBuf *dbuf,
}
cmaskrect += srcskip;
- if (texmaskrect)
+ if (texmaskrect) {
texmaskrect += srcskip;
+ }
}
else {
/* regular blending */
for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4) {
- if (srf[3] != 0)
+ if (srf[3] != 0) {
func_float(drf, orf, srf);
+ }
}
}
@@ -926,8 +961,9 @@ void IMB_rectfill(ImBuf *drect, const float col[4])
ccol[3] = (int)(col[3] * 255);
num = drect->x * drect->y;
- for (; num > 0; num--)
+ for (; num > 0; num--) {
*rrect++ = *((unsigned int *)ccol);
+ }
}
if (drect->rect_float) {
@@ -958,8 +994,9 @@ void buf_rectfill_area(unsigned char *rect,
float a; /* alpha */
float ai; /* alpha inverted */
float aich; /* alpha, inverted, ai/255.0 - Convert char to float at the same time */
- if ((!rect && !rectf) || (!col) || col[3] == 0.0f)
+ if ((!rect && !rectf) || (!col) || col[3] == 0.0f) {
return;
+ }
/* sanity checks for coords */
CLAMP(x1, 0, width);
@@ -967,12 +1004,15 @@ void buf_rectfill_area(unsigned char *rect,
CLAMP(y1, 0, height);
CLAMP(y2, 0, height);
- if (x1 > x2)
+ if (x1 > x2) {
SWAP(int, x1, x2);
- if (y1 > y2)
+ }
+ if (y1 > y2) {
SWAP(int, y1, y2);
- if (x1 == x2 || y1 == y2)
+ }
+ if (x1 == x2 || y1 == y2) {
return;
+ }
a = col[3];
ai = 1 - a;
@@ -1058,8 +1098,9 @@ void IMB_rectfill_area(ImBuf *ibuf,
int y2,
struct ColorManagedDisplay *display)
{
- if (!ibuf)
+ if (!ibuf) {
return;
+ }
buf_rectfill_area((unsigned char *)ibuf->rect,
ibuf->rect_float,
ibuf->x,
diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c
index 2b200abc852..e387901aaab 100644
--- a/source/blender/imbuf/intern/rotate.c
+++ b/source/blender/imbuf/intern/rotate.c
@@ -34,8 +34,9 @@ void IMB_flipy(struct ImBuf *ibuf)
{
int x, y;
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
if (ibuf->rect) {
unsigned int *top, *bottom, *line;
@@ -89,8 +90,9 @@ void IMB_flipx(struct ImBuf *ibuf)
int x, y, xr, xl, yi;
float px_f[4];
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
+ }
x = ibuf->x;
y = ibuf->y;
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index e57f3bb08f4..28557277d72 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -85,10 +85,12 @@ static void imb_half_x_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
*(destf++) = 0.5f * rf;
}
}
- if (do_rect)
+ if (do_rect) {
_p1 += (ibuf1->x << 2);
- if (do_float)
+ }
+ if (do_float) {
_p1f += (ibuf1->x << 2);
+ }
}
}
@@ -96,17 +98,21 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
- if (ibuf1 == NULL)
+ if (ibuf1 == NULL) {
return (NULL);
- if (ibuf1->rect == NULL && ibuf1->rect_float == NULL)
+ }
+ if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
return (NULL);
+ }
- if (ibuf1->x <= 1)
+ if (ibuf1->x <= 1) {
return (IMB_dupImBuf(ibuf1));
+ }
ibuf2 = IMB_allocImBuf((ibuf1->x) / 2, ibuf1->y, ibuf1->planes, ibuf1->flags);
- if (ibuf2 == NULL)
+ if (ibuf2 == NULL) {
return (NULL);
+ }
imb_half_x_no_alloc(ibuf2, ibuf1);
@@ -119,17 +125,20 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1)
int *p1, *dest, i, col, do_rect, do_float;
float *p1f, *destf;
- if (ibuf1 == NULL)
+ if (ibuf1 == NULL) {
return (NULL);
- if (ibuf1->rect == NULL && ibuf1->rect_float == NULL)
+ }
+ if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
return (NULL);
+ }
do_rect = (ibuf1->rect != NULL);
do_float = (ibuf1->rect_float != NULL);
ibuf2 = IMB_allocImBuf(2 * ibuf1->x, ibuf1->y, ibuf1->planes, ibuf1->flags);
- if (ibuf2 == NULL)
+ if (ibuf2 == NULL) {
return (NULL);
+ }
p1 = (int *)ibuf1->rect;
dest = (int *)ibuf2->rect;
@@ -159,10 +168,12 @@ struct ImBuf *IMB_double_x(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
- if (ibuf1 == NULL)
+ if (ibuf1 == NULL) {
return (NULL);
- if (ibuf1->rect == NULL && ibuf1->rect_float == NULL)
+ }
+ if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
return (NULL);
+ }
ibuf2 = IMB_double_fast_x(ibuf1);
@@ -228,10 +239,12 @@ static void imb_half_y_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
*(destf++) = 0.5f * rf;
}
}
- if (do_rect)
+ if (do_rect) {
_p1 += (ibuf1->x << 3);
- if (do_float)
+ }
+ if (do_float) {
_p1f += (ibuf1->x << 3);
+ }
}
}
@@ -239,17 +252,21 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
- if (ibuf1 == NULL)
+ if (ibuf1 == NULL) {
return (NULL);
- if (ibuf1->rect == NULL && ibuf1->rect_float == NULL)
+ }
+ if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
return (NULL);
+ }
- if (ibuf1->y <= 1)
+ if (ibuf1->y <= 1) {
return (IMB_dupImBuf(ibuf1));
+ }
ibuf2 = IMB_allocImBuf(ibuf1->x, (ibuf1->y) / 2, ibuf1->planes, ibuf1->flags);
- if (ibuf2 == NULL)
+ if (ibuf2 == NULL) {
return (NULL);
+ }
imb_half_y_no_alloc(ibuf2, ibuf1);
@@ -264,17 +281,20 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
int x, y;
int do_rect, do_float;
- if (ibuf1 == NULL)
+ if (ibuf1 == NULL) {
return (NULL);
- if (ibuf1->rect == NULL && ibuf1->rect_float == NULL)
+ }
+ if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
return (NULL);
+ }
do_rect = (ibuf1->rect != NULL);
do_float = (ibuf1->rect_float != NULL);
ibuf2 = IMB_allocImBuf(ibuf1->x, 2 * ibuf1->y, ibuf1->planes, ibuf1->flags);
- if (ibuf2 == NULL)
+ if (ibuf2 == NULL) {
return (NULL);
+ }
p1 = (int *)ibuf1->rect;
dest1 = (int *)ibuf2->rect;
@@ -284,14 +304,16 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
for (y = ibuf1->y; y > 0; y--) {
if (do_rect) {
dest2 = dest1 + ibuf2->x;
- for (x = ibuf2->x; x > 0; x--)
+ for (x = ibuf2->x; x > 0; x--) {
*dest1++ = *dest2++ = *p1++;
+ }
dest1 = dest2;
}
if (do_float) {
dest2f = dest1f + (4 * ibuf2->x);
- for (x = ibuf2->x * 4; x > 0; x--)
+ for (x = ibuf2->x * 4; x > 0; x--) {
*dest1f++ = *dest2f++ = *p1f++;
+ }
dest1f = dest2f;
}
}
@@ -303,10 +325,12 @@ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
- if (ibuf1 == NULL)
+ if (ibuf1 == NULL) {
return (NULL);
- if (ibuf1->rect == NULL)
+ }
+ if (ibuf1->rect == NULL) {
return (NULL);
+ }
ibuf2 = IMB_double_fast_y(ibuf1);
@@ -394,8 +418,9 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
dest += 4;
}
cp1 = cp2;
- if (ibuf1->x & 1)
+ if (ibuf1->x & 1) {
cp1 += 4;
+ }
}
}
@@ -416,8 +441,9 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
destf += 4;
}
p1f = p2f;
- if (ibuf1->x & 1)
+ if (ibuf1->x & 1) {
p1f += 4;
+ }
}
}
}
@@ -426,19 +452,24 @@ ImBuf *IMB_onehalf(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
- if (ibuf1 == NULL)
+ if (ibuf1 == NULL) {
return (NULL);
- if (ibuf1->rect == NULL && ibuf1->rect_float == NULL)
+ }
+ if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) {
return (NULL);
+ }
- if (ibuf1->x <= 1)
+ if (ibuf1->x <= 1) {
return (IMB_half_y(ibuf1));
- if (ibuf1->y <= 1)
+ }
+ if (ibuf1->y <= 1) {
return (IMB_half_x(ibuf1));
+ }
ibuf2 = IMB_allocImBuf((ibuf1->x) / 2, (ibuf1->y) / 2, ibuf1->planes, ibuf1->flags);
- if (ibuf2 == NULL)
+ if (ibuf2 == NULL) {
return (NULL);
+ }
imb_onehalf_no_alloc(ibuf2, ibuf1);
@@ -557,7 +588,8 @@ static void shrink_picture_byte(unsigned char *src,
w = (weight1y * weight1x) >> 16;
- /* ensure correct rounding, without this you get ugly banding, or too low color values (ton) */
+ /* Ensure correct rounding, without this you get ugly banding,
+ * or too low color values (ton). */
dst_line1[x].r += (line[0] * w + 32767) >> 16;
dst_line1[x].g += (line[1] * w + 32767) >> 16;
dst_line1[x].b += (line[2] * w + 32767) >> 16;
@@ -890,19 +922,22 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
nval[0] = nval[1] = nval[2] = nval[3] = 0.0f;
nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
- if (!do_rect && !do_float)
+ if (!do_rect && !do_float) {
return (ibuf);
+ }
if (do_rect) {
_newrect = MEM_mallocN(newx * ibuf->y * sizeof(uchar) * 4, "scaledownx");
- if (_newrect == NULL)
+ if (_newrect == NULL) {
return (ibuf);
+ }
}
if (do_float) {
_newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaledownxf");
if (_newrectf == NULL) {
- if (_newrect)
+ if (_newrect) {
MEM_freeN(_newrect);
+ }
return (ibuf);
}
}
@@ -1028,19 +1063,22 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
nval[0] = nval[1] = nval[2] = nval[3] = 0.0f;
nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f;
- if (!do_rect && !do_float)
+ if (!do_rect && !do_float) {
return (ibuf);
+ }
if (do_rect) {
_newrect = MEM_mallocN(newy * ibuf->x * sizeof(uchar) * 4, "scaledowny");
- if (_newrect == NULL)
+ if (_newrect == NULL) {
return (ibuf);
+ }
}
if (do_float) {
_newrectf = MEM_mallocN(newy * ibuf->x * sizeof(float) * 4, "scaledownyf");
if (_newrectf == NULL) {
- if (_newrect)
+ if (_newrect) {
MEM_freeN(_newrect);
+ }
return (ibuf);
}
}
@@ -1171,23 +1209,27 @@ static ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
val_g = nval_g = diff_g = val_r = nval_r = diff_r = 0;
val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return (NULL);
- if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ }
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
return (ibuf);
+ }
if (ibuf->rect) {
do_rect = true;
_newrect = MEM_mallocN(newx * ibuf->y * sizeof(int), "scaleupx");
- if (_newrect == NULL)
+ if (_newrect == NULL) {
return (ibuf);
+ }
}
if (ibuf->rect_float) {
do_float = true;
_newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaleupxf");
if (_newrectf == NULL) {
- if (_newrect)
+ if (_newrect) {
MEM_freeN(_newrect);
+ }
return (ibuf);
}
}
@@ -1343,23 +1385,27 @@ static ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
val_g = nval_g = diff_g = val_r = nval_r = diff_r = 0;
val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return (NULL);
- if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ }
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
return (ibuf);
+ }
if (ibuf->rect) {
do_rect = true;
_newrect = MEM_mallocN(ibuf->x * newy * sizeof(int), "scaleupy");
- if (_newrect == NULL)
+ if (_newrect == NULL) {
return (ibuf);
+ }
}
if (ibuf->rect_float) {
do_float = true;
_newrectf = MEM_mallocN(ibuf->x * newy * sizeof(float) * 4, "scaleupyf");
if (_newrectf == NULL) {
- if (_newrect)
+ if (_newrect) {
MEM_freeN(_newrect);
+ }
return (ibuf);
}
}
@@ -1572,10 +1618,12 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
*/
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
{
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return false;
- if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ }
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
return false;
+ }
if (newx == ibuf->x && newy == ibuf->y) {
return false;
@@ -1591,14 +1639,18 @@ bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
return true;
}
- if (newx && (newx < ibuf->x))
+ if (newx && (newx < ibuf->x)) {
scaledownx(ibuf, newx);
- if (newy && (newy < ibuf->y))
+ }
+ if (newy && (newy < ibuf->y)) {
scaledowny(ibuf, newy);
- if (newx && (newx > ibuf->x))
+ }
+ if (newx && (newx > ibuf->x)) {
scaleupx(ibuf, newx);
- if (newy && (newy > ibuf->y))
+ }
+ if (newy && (newy > ibuf->y)) {
scaleupy(ibuf, newy);
+ }
return true;
}
@@ -1625,30 +1677,37 @@ bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy
_newrectf = NULL;
newrectf = NULL;
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return false;
- if (ibuf->rect)
+ }
+ if (ibuf->rect) {
do_rect = true;
- if (ibuf->rect_float)
+ }
+ if (ibuf->rect_float) {
do_float = true;
- if (do_rect == false && do_float == false)
+ }
+ if (do_rect == false && do_float == false) {
return false;
+ }
- if (newx == ibuf->x && newy == ibuf->y)
+ if (newx == ibuf->x && newy == ibuf->y) {
return false;
+ }
if (do_rect) {
_newrect = MEM_mallocN(newx * newy * sizeof(int), "scalefastimbuf");
- if (_newrect == NULL)
+ if (_newrect == NULL) {
return false;
+ }
newrect = _newrect;
}
if (do_float) {
_newrectf = MEM_mallocN(newx * newy * sizeof(float) * 4, "scalefastimbuf f");
if (_newrectf == NULL) {
- if (_newrect)
+ if (_newrect) {
MEM_freeN(_newrect);
+ }
return false;
}
newrectf = _newrectf;
@@ -1785,13 +1844,15 @@ void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy)
init_data.newx = newx;
init_data.newy = newy;
- if (ibuf->rect)
+ if (ibuf->rect) {
init_data.byte_buffer = MEM_mallocN(4 * newx * newy * sizeof(char),
"threaded scale byte buffer");
+ }
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
init_data.float_buffer = MEM_mallocN(ibuf->channels * newx * newy * sizeof(float),
"threaded scale float buffer");
+ }
/* actual scaling threads */
IMB_processor_apply_threaded(
diff --git a/source/blender/imbuf/intern/stereoimbuf.c b/source/blender/imbuf/intern/stereoimbuf.c
index 30356fd4e4e..44c311eba9d 100644
--- a/source/blender/imbuf/intern/stereoimbuf.c
+++ b/source/blender/imbuf/intern/stereoimbuf.c
@@ -573,11 +573,13 @@ static void imb_stereo3d_squeeze_ImBuf(ImBuf *ibuf,
const size_t x,
const size_t y)
{
- if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM) == false)
+ if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM) == false) {
return;
+ }
- if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0)
+ if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0) {
return;
+ }
IMB_scaleImBuf_threaded(ibuf, x, y);
}
@@ -587,11 +589,13 @@ static void imb_stereo3d_unsqueeze_ImBuf(ImBuf *ibuf,
const size_t x,
const size_t y)
{
- if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM) == false)
+ if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM) == false) {
return;
+ }
- if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0)
+ if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0) {
return;
+ }
IMB_scaleImBuf_threaded(ibuf, x, y);
}
@@ -602,11 +606,13 @@ static void imb_stereo3d_squeeze_rectf(
ImBuf *ibuf;
size_t width, height;
- if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM) == false)
+ if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM) == false) {
return;
+ }
- if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0)
+ if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0) {
return;
+ }
/* creates temporary imbuf to store the rectf */
IMB_stereo3d_write_dimensions(s3d->display_mode, false, x, y, &width, &height);
@@ -634,11 +640,13 @@ static void imb_stereo3d_squeeze_rect(
ImBuf *ibuf;
size_t width, height;
- if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM) == false)
+ if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM) == false) {
return;
+ }
- if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0)
+ if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0) {
return;
+ }
/* creates temporary imbuf to store the rectf */
IMB_stereo3d_write_dimensions(s3d->display_mode, false, x, y, &width, &height);
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index c80e3a0c07d..f7b7df52e46 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -67,8 +67,9 @@ static int tga_out1(unsigned int data, FILE *file)
uchar *p;
p = (uchar *)&data;
- if (putc(p[0], file) == EOF)
+ if (putc(p[0], file) == EOF) {
return EOF;
+ }
return ~EOF;
}
@@ -77,10 +78,12 @@ static int tga_out2(unsigned int data, FILE *file)
uchar *p;
p = (uchar *)&data;
- if (putc(p[0], file) == EOF)
+ if (putc(p[0], file) == EOF) {
return EOF;
- if (putc(p[1], file) == EOF)
+ }
+ if (putc(p[1], file) == EOF) {
return EOF;
+ }
return ~EOF;
}
@@ -89,12 +92,15 @@ static int tga_out3(unsigned int data, FILE *file)
uchar *p;
p = (uchar *)&data;
- if (putc(p[2], file) == EOF)
+ if (putc(p[2], file) == EOF) {
return EOF;
- if (putc(p[1], file) == EOF)
+ }
+ if (putc(p[1], file) == EOF) {
return EOF;
- if (putc(p[0], file) == EOF)
+ }
+ if (putc(p[0], file) == EOF) {
return EOF;
+ }
return ~EOF;
}
@@ -104,14 +110,18 @@ static int tga_out4(unsigned int data, FILE *file)
p = (uchar *)&data;
/* order = bgra */
- if (putc(p[2], file) == EOF)
+ if (putc(p[2], file) == EOF) {
return EOF;
- if (putc(p[1], file) == EOF)
+ }
+ if (putc(p[1], file) == EOF) {
return EOF;
- if (putc(p[0], file) == EOF)
+ }
+ if (putc(p[0], file) == EOF) {
return EOF;
- if (putc(p[3], file) == EOF)
+ }
+ if (putc(p[3], file) == EOF) {
return EOF;
+ }
return ~EOF;
}
@@ -143,22 +153,26 @@ static bool makebody_tga(ImBuf *ibuf, FILE *file, int (*out)(unsigned int, FILE
copy = rect - rectstart;
copy--;
- if (bytes)
+ if (bytes) {
copy -= 2;
+ }
temp = rect;
rect = rectstart;
while (copy) {
last = copy;
- if (copy >= 128)
+ if (copy >= 128) {
last = 128;
+ }
copy -= last;
- if (fputc(last - 1, file) == EOF)
+ if (fputc(last - 1, file) == EOF) {
return 0;
+ }
do {
- if (out(*rect++, file) == EOF)
+ if (out(*rect++, file) == EOF) {
return 0;
+ }
} while (--last != 0);
}
rectstart = rect;
@@ -169,8 +183,9 @@ static bool makebody_tga(ImBuf *ibuf, FILE *file, int (*out)(unsigned int, FILE
}
else {
while (*rect++ == this) { /* seek for first different byte */
- if (--bytes == 0)
+ if (--bytes == 0) {
break; /* oor end of line */
+ }
}
rect--;
copy = rect - rectstart;
@@ -180,21 +195,25 @@ static bool makebody_tga(ImBuf *ibuf, FILE *file, int (*out)(unsigned int, FILE
while (copy) {
if (copy > 128) {
- if (fputc(255, file) == EOF)
+ if (fputc(255, file) == EOF) {
return 0;
+ }
copy -= 128;
}
else {
if (copy == 1) {
- if (fputc(0, file) == EOF)
+ if (fputc(0, file) == EOF) {
return 0;
+ }
}
- else if (fputc(127 + copy, file) == EOF)
+ else if (fputc(127 + copy, file) == EOF) {
return 0;
+ }
copy = 0;
}
- if (out(last, file) == EOF)
+ if (out(last, file) == EOF) {
return 0;
+ }
}
copy = 1;
}
@@ -208,18 +227,21 @@ static bool dumptarga(struct ImBuf *ibuf, FILE *file)
int size;
uchar *rect;
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return 0;
- if (ibuf->rect == NULL)
+ }
+ if (ibuf->rect == NULL) {
return 0;
+ }
size = ibuf->x * ibuf->y;
rect = (uchar *)ibuf->rect;
if (ibuf->planes <= 8) {
while (size > 0) {
- if (putc(*rect, file) == EOF)
+ if (putc(*rect, file) == EOF) {
return 0;
+ }
size--;
rect += 4;
}
@@ -227,8 +249,9 @@ static bool dumptarga(struct ImBuf *ibuf, FILE *file)
else if (ibuf->planes <= 16) {
while (size > 0) {
putc(rect[0], file);
- if (putc(rect[1], file) == EOF)
+ if (putc(rect[1], file) == EOF) {
return 0;
+ }
size--;
rect += 4;
}
@@ -237,8 +260,9 @@ static bool dumptarga(struct ImBuf *ibuf, FILE *file)
while (size > 0) {
putc(rect[2], file);
putc(rect[1], file);
- if (putc(rect[0], file) == EOF)
+ if (putc(rect[0], file) == EOF) {
return 0;
+ }
size--;
rect += 4;
}
@@ -248,8 +272,9 @@ static bool dumptarga(struct ImBuf *ibuf, FILE *file)
putc(rect[2], file);
putc(rect[1], file);
putc(rect[0], file);
- if (putc(rect[3], file) == EOF)
+ if (putc(rect[3], file) == EOF) {
return 0;
+ }
size--;
rect += 4;
}
@@ -277,8 +302,9 @@ int imb_savetarga(struct ImBuf *ibuf, const char *name, int flags)
buf[2] = 11;
}
- if (ibuf->foptions.flag & RAWTGA)
+ if (ibuf->foptions.flag & RAWTGA) {
buf[2] &= ~8;
+ }
buf[8] = 0;
buf[9] = 0;
@@ -296,8 +322,9 @@ int imb_savetarga(struct ImBuf *ibuf, const char *name, int flags)
buf[17] |= 0x08;
}
fildes = BLI_fopen(name, "wb");
- if (!fildes)
+ if (!fildes) {
return 0;
+ }
if (fwrite(buf, 1, 18, fildes) != 18) {
fclose(fildes);
@@ -344,8 +371,9 @@ static int checktarga(TARGA *tga, const unsigned char *mem)
tga->pixsize = mem[16];
tga->imgdes = mem[17];
- if (tga->maptyp > 1)
+ if (tga->maptyp > 1) {
return 0;
+ }
switch (tga->imgtyp) {
case 1: /* raw cmap */
case 2: /* raw rgb */
@@ -357,16 +385,21 @@ static int checktarga(TARGA *tga, const unsigned char *mem)
default:
return 0;
}
- if (tga->mapsize && tga->mapbits > 32)
+ if (tga->mapsize && tga->mapbits > 32) {
return 0;
- if (tga->xsize <= 0)
+ }
+ if (tga->xsize <= 0) {
return 0;
- if (tga->ysize <= 0)
+ }
+ if (tga->ysize <= 0) {
return 0;
- if (tga->pixsize > 32)
+ }
+ if (tga->pixsize > 32) {
return 0;
- if (tga->pixsize == 0)
+ }
+ if (tga->pixsize == 0) {
return 0;
+ }
return 1;
}
@@ -400,10 +433,12 @@ static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem
unsigned int *rect;
uchar *cp = (uchar *)&col;
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
- if (ibuf->rect == NULL)
+ }
+ if (ibuf->rect == NULL) {
return;
+ }
size = ibuf->x * ibuf->y;
rect = ibuf->rect;
@@ -415,8 +450,9 @@ static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem
while (size > 0) {
count = *mem++;
- if (mem > mem_end)
+ if (mem > mem_end) {
goto partial_load;
+ }
if (count >= 128) {
/*if (count == 128) printf("TARGA: 128 in file !\n");*/
@@ -495,12 +531,14 @@ static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem
*rect++ = col;
count--;
- if (mem > mem_end)
+ if (mem > mem_end) {
goto partial_load;
+ }
}
- if (mem > mem_end)
+ if (mem > mem_end) {
goto partial_load;
+ }
}
}
}
@@ -520,10 +558,12 @@ static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_siz
unsigned int *rect;
uchar *cp = (uchar *)&col;
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return;
- if (ibuf->rect == NULL)
+ }
+ if (ibuf->rect == NULL) {
return;
+ }
size = ibuf->x * ibuf->y;
rect = ibuf->rect;
@@ -533,8 +573,9 @@ static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_siz
cp[1] = cp[2] = 0;
while (size > 0) {
- if (mem > mem_end)
+ if (mem > mem_end) {
goto partial_load;
+ }
if (psize & 2) {
if (psize & 1) {
@@ -592,16 +633,20 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
- if (flags & IB_test)
+ if (flags & IB_test) {
ibuf = IMB_allocImBuf(tga.xsize, tga.ysize, tga.pixsize, 0);
- else
+ }
+ else {
ibuf = IMB_allocImBuf(tga.xsize, tga.ysize, (tga.pixsize + 0x7) & ~0x7, IB_rect);
+ }
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return NULL;
+ }
ibuf->ftype = IMB_FTYPE_TGA;
- if (tga.imgtyp < 4)
+ if (tga.imgtyp < 4) {
ibuf->foptions.flag |= RAWTGA;
+ }
mem = mem + 18 + tga.numid;
cp[0] = 0xff;
@@ -669,26 +714,34 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
case 1:
case 2:
case 3:
- if (tga.pixsize <= 8)
+ if (tga.pixsize <= 8) {
ldtarga(ibuf, mem, mem_size, 0);
- else if (tga.pixsize <= 16)
+ }
+ else if (tga.pixsize <= 16) {
ldtarga(ibuf, mem, mem_size, 1);
- else if (tga.pixsize <= 24)
+ }
+ else if (tga.pixsize <= 24) {
ldtarga(ibuf, mem, mem_size, 2);
- else if (tga.pixsize <= 32)
+ }
+ else if (tga.pixsize <= 32) {
ldtarga(ibuf, mem, mem_size, 3);
+ }
break;
case 9:
case 10:
case 11:
- if (tga.pixsize <= 8)
+ if (tga.pixsize <= 8) {
decodetarga(ibuf, mem, mem_size, 0);
- else if (tga.pixsize <= 16)
+ }
+ else if (tga.pixsize <= 16) {
decodetarga(ibuf, mem, mem_size, 1);
- else if (tga.pixsize <= 24)
+ }
+ else if (tga.pixsize <= 24) {
decodetarga(ibuf, mem, mem_size, 2);
- else if (tga.pixsize <= 32)
+ }
+ else if (tga.pixsize <= 32) {
decodetarga(ibuf, mem, mem_size, 3);
+ }
break;
}
@@ -744,8 +797,9 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
IMB_flipy(ibuf);
}
- if (ibuf->rect)
+ if (ibuf->rect) {
IMB_convert_rgba_to_abgr(ibuf);
+ }
return ibuf;
}
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index fc5bfe42d60..06b8019a24d 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -60,7 +60,7 @@
# define _WIN32_IE 0x0400
# endif
/* For SHGetSpecialFolderPath, has to be done before BLI_winstuff
- * because 'near' is disabled through BLI_windstuff */
+ * because 'near' is disabled through BLI_windstuff */
# include <shlobj.h>
# include <direct.h> /* chdir */
# include "BLI_winstuff.h"
@@ -99,8 +99,9 @@ static bool get_thumb_dir(char *dir, ThumbSize size)
# else
const char *home = BLI_getenv("HOME");
# endif
- if (!home)
+ if (!home) {
return 0;
+ }
s += BLI_strncpy_rlen(s, home, FILE_MAX);
# ifdef USE_FREEDESKTOP
@@ -452,8 +453,9 @@ static ImBuf *thumb_create_ex(const char *file_path,
}
if (size == THB_FAIL) {
img = IMB_allocImBuf(1, 1, 32, IB_rect | IB_metadata);
- if (!img)
+ if (!img) {
return NULL;
+ }
}
else {
if (ELEM(source, THB_SOURCE_IMAGE, THB_SOURCE_BLEND, THB_SOURCE_FONT)) {
@@ -500,8 +502,9 @@ static ImBuf *thumb_create_ex(const char *file_path,
BLI_snprintf(mtime, sizeof(mtime), "%ld", (long int)info.st_mtime);
}
}
- if (!img)
+ if (!img) {
return NULL;
+ }
if (img->x > img->y) {
scaledx = (float)tsize;
@@ -734,7 +737,8 @@ ImBuf *IMB_thumb_manage(const char *org_path, ThumbSize size, ThumbSource source
}
}
- /* Our imbuf **must** have a valid rect (i.e. 8-bits/channels) data, we rely on this in draw code.
+ /* Our imbuf **must** have a valid rect (i.e. 8-bits/channels)
+ * data, we rely on this in draw code.
* However, in some cases we may end loading 16bits PNGs, which generated float buffers.
* This should be taken care of in generation step, but add also a safeguard here! */
if (img) {
diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c
index 20a419d1a16..283bd11dc7d 100644
--- a/source/blender/imbuf/intern/thumbs_blend.c
+++ b/source/blender/imbuf/intern/thumbs_blend.c
@@ -54,8 +54,9 @@ ImBuf *IMB_thumb_load_blend(const char *blen_path, const char *blen_group, const
return ima;
}
- /* Note: we should handle all previews for a same group at once, would avoid reopening .blend file
- * for each and every ID. However, this adds some complexity, so keep it for later. */
+ /* Note: we should handle all previews for a same group at once, would avoid reopening
+ * `.blend` file for each and every ID. However, this adds some complexity,
+ * so keep it for later. */
names = BLO_blendhandle_get_datablock_names(libfiledata, idcode, &nnames);
previews = BLO_blendhandle_get_previews(libfiledata, idcode, &nprevs);
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index 1f2b63a3749..fc0a643fade 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -122,17 +122,21 @@ static tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n)
/* find the actual number of bytes to read (copy) */
nCopy = n;
- if ((tsize_t)mfile->offset >= mfile->size)
+ if ((tsize_t)mfile->offset >= mfile->size) {
nRemaining = 0;
- else
+ }
+ else {
nRemaining = mfile->size - mfile->offset;
+ }
- if (nCopy > nRemaining)
+ if (nCopy > nRemaining) {
nCopy = nRemaining;
+ }
/* on EOF, return immediately and read (copy) nothing */
- if (nCopy <= 0)
+ if (nCopy <= 0) {
return (0);
+ }
/* all set -> do the read (copy) */
srcAddr = (void *)(&(mfile->mem[mfile->offset]));
@@ -330,15 +334,17 @@ static void scanline_separate_16bit(float *rectf,
int chan)
{
int i;
- for (i = 0; i < scanline_w; i++)
+ for (i = 0; i < scanline_w; i++) {
rectf[i * 4 + chan] = sbuf[i] / 65535.0;
+ }
}
static void scanline_separate_32bit(float *rectf, const float *fbuf, int scanline_w, int chan)
{
int i;
- for (i = 0; i < scanline_w; i++)
+ for (i = 0; i < scanline_w; i++) {
rectf[i * 4 + chan] = fbuf[i];
+ }
}
static void imb_read_tiff_resolution(ImBuf *ibuf, TIFF *image)
@@ -453,21 +459,27 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image)
size_t ib_offset = (size_t)ibuf->x * 4 * ((size_t)ibuf->y - ((size_t)row + 1));
if (bitspersample == 32) {
- if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */
+ if (chan == 3 && spp == 3) { /* fill alpha if only RGB TIFF */
copy_vn_fl(fbuf, ibuf->x, 1.0f);
- else if (chan >= spp) /* for grayscale, duplicate first channel into G and B */
+ }
+ else if (chan >= spp) { /* for grayscale, duplicate first channel into G and B */
success |= TIFFReadScanline(image, fbuf, row, 0);
- else
+ }
+ else {
success |= TIFFReadScanline(image, fbuf, row, chan);
+ }
scanline_separate_32bit(tmpibuf->rect_float + ib_offset, fbuf, ibuf->x, chan);
}
else if (bitspersample == 16) {
- if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */
+ if (chan == 3 && spp == 3) { /* fill alpha if only RGB TIFF */
copy_vn_ushort(sbuf, ibuf->x, 65535);
- else if (chan >= spp) /* for grayscale, duplicate first channel into G and B */
+ }
+ else if (chan >= spp) { /* for grayscale, duplicate first channel into G and B */
success |= TIFFReadScanline(image, fbuf, row, 0);
- else
+ }
+ else {
success |= TIFFReadScanline(image, sbuf, row, chan);
+ }
scanline_separate_16bit(tmpibuf->rect_float + ib_offset, sbuf, ibuf->x, chan);
}
}
@@ -476,15 +488,19 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image)
if (success) {
/* Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton) */
- if (bitspersample < 16)
- if (ENDIAN_ORDER == B_ENDIAN)
+ if (bitspersample < 16) {
+ if (ENDIAN_ORDER == B_ENDIAN) {
IMB_convert_rgba_to_abgr(tmpibuf);
+ }
+ }
/* assign rect last */
- if (tmpibuf->rect_float)
+ if (tmpibuf->rect_float) {
ibuf->rect_float = tmpibuf->rect_float;
- else
+ }
+ else {
ibuf->rect = tmpibuf->rect;
+ }
ibuf->mall |= ib_flag;
ibuf->flags |= ib_flag;
@@ -492,10 +508,12 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image)
}
cleanup:
- if (bitspersample == 32)
+ if (bitspersample == 32) {
_TIFFfree(fbuf);
- else if (bitspersample == 16)
+ }
+ else if (bitspersample == 16) {
_TIFFfree(sbuf);
+ }
IMB_freeImBuf(tmpibuf);
@@ -504,8 +522,9 @@ cleanup:
void imb_inittiff(void)
{
- if (!(G.debug & G_DEBUG))
+ if (!(G.debug & G_DEBUG)) {
TIFFSetErrorHandler(NULL);
+ }
}
/**
@@ -537,8 +556,9 @@ ImBuf *imb_loadtiff(const unsigned char *mem,
fprintf(stderr, "imb_loadtiff: size < IMB_TIFF_NCB\n");
return NULL;
}
- if (imb_is_a_tiff(mem) == 0)
+ if (imb_is_a_tiff(mem) == 0) {
return NULL;
+ }
/* both 8 and 16 bit PNGs are default to standard byte colorspace */
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@@ -599,8 +619,9 @@ ImBuf *imb_loadtiff(const unsigned char *mem,
/* create empty mipmap levels in advance */
for (level = 0; level < numlevel; level++) {
- if (!TIFFSetDirectory(image, level))
+ if (!TIFFSetDirectory(image, level)) {
break;
+ }
if (level > 0) {
width = (width > 1) ? width / 2 : 1;
@@ -611,8 +632,9 @@ ImBuf *imb_loadtiff(const unsigned char *mem,
hbuf->ftype = ibuf->ftype;
ibuf->mipmap[level - 1] = hbuf;
}
- else
+ else {
hbuf = ibuf;
+ }
hbuf->flags |= IB_tilecache;
@@ -666,25 +688,29 @@ void imb_loadtiletiff(
/* tiff pixels are bottom to top, tiles are top to bottom */
if (TIFFReadRGBATile(
image, tx * ibuf->tilex, (ibuf->ytiles - 1 - ty) * ibuf->tiley, rect) == 1) {
- if (ibuf->tiley > ibuf->y)
+ if (ibuf->tiley > ibuf->y) {
memmove(rect,
rect + ibuf->tilex * (ibuf->tiley - ibuf->y),
sizeof(int) * ibuf->tilex * ibuf->y);
+ }
}
- else
+ else {
printf("imb_loadtiff: failed to read tiff tile at mipmap level %d\n", ibuf->miplevel);
+ }
}
}
- else
+ else {
printf("imb_loadtiff: mipmap level %d has unexpected size %ux%u instead of %dx%d\n",
ibuf->miplevel,
width,
height,
ibuf->x,
ibuf->y);
+ }
}
- else
+ else {
printf("imb_loadtiff: could not find mipmap level %d\n", ibuf->miplevel);
+ }
/* close the client layer interface to the in-memory file */
TIFFClose(image);
@@ -731,17 +757,22 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
return (0);
}
- if ((ibuf->foptions.flag & TIF_16BIT) && ibuf->rect_float)
+ if ((ibuf->foptions.flag & TIF_16BIT) && ibuf->rect_float) {
bitspersample = 16;
- else
+ }
+ else {
bitspersample = 8;
+ }
- if (ibuf->foptions.flag & TIF_COMPRESS_DEFLATE)
+ if (ibuf->foptions.flag & TIF_COMPRESS_DEFLATE) {
compress_mode = COMPRESSION_DEFLATE;
- else if (ibuf->foptions.flag & TIF_COMPRESS_LZW)
+ }
+ else if (ibuf->foptions.flag & TIF_COMPRESS_LZW) {
compress_mode = COMPRESSION_LZW;
- else if (ibuf->foptions.flag & TIF_COMPRESS_PACKBITS)
+ }
+ else if (ibuf->foptions.flag & TIF_COMPRESS_PACKBITS) {
compress_mode = COMPRESSION_PACKBITS;
+ }
/* open TIFF file for writing */
if (flags & IB_mem) {
@@ -768,10 +799,12 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
/* allocate array for pixel data */
npixels = ibuf->x * ibuf->y;
- if (bitspersample == 16)
+ if (bitspersample == 16) {
pixels16 = (unsigned short *)_TIFFmalloc(npixels * samplesperpixel * sizeof(unsigned short));
- else
+ }
+ else {
pixels = (unsigned char *)_TIFFmalloc(npixels * samplesperpixel * sizeof(unsigned char));
+ }
if (pixels == NULL && pixels16 == NULL) {
fprintf(stderr, "imb_savetiff: could not allocate pixels array.\n");
@@ -796,10 +829,12 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
if (samplesperpixel == 4) {
unsigned short extraSampleTypes[1];
- if (bitspersample == 16)
+ if (bitspersample == 16) {
extraSampleTypes[0] = EXTRASAMPLE_ASSOCALPHA;
- else
+ }
+ else {
extraSampleTypes[0] = EXTRASAMPLE_UNASSALPHA;
+ }
/* RGBA images */
TIFFSetField(image, TIFFTAG_EXTRASAMPLES, 1, extraSampleTypes);
@@ -856,12 +891,14 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
rgb[3] = 1.0f;
}
- for (i = 0; i < samplesperpixel; i++, to_i++)
+ for (i = 0; i < samplesperpixel; i++, to_i++) {
to16[to_i] = unit_float_to_ushort_clamp(rgb[i]);
+ }
}
else {
- for (i = 0; i < samplesperpixel; i++, to_i++, from_i++)
+ for (i = 0; i < samplesperpixel; i++, to_i++, from_i++) {
to[to_i] = from[from_i];
+ }
}
}
}
@@ -892,18 +929,22 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
-1) {
fprintf(stderr, "imb_savetiff: Could not write encoded TIFF.\n");
TIFFClose(image);
- if (pixels)
+ if (pixels) {
_TIFFfree(pixels);
- if (pixels16)
+ }
+ if (pixels16) {
_TIFFfree(pixels16);
+ }
return (1);
}
/* close the TIFF file */
TIFFClose(image);
- if (pixels)
+ if (pixels) {
_TIFFfree(pixels);
- if (pixels16)
+ }
+ if (pixels16) {
_TIFFfree(pixels16);
+ }
return (1);
}
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 50aaa16c3fe..1126a93148d 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -126,16 +126,20 @@ int IMB_ispic_type(const char *name)
BLI_assert(!BLI_path_is_rel(name));
- if (UTIL_DEBUG)
+ if (UTIL_DEBUG) {
printf("%s: loading %s\n", __func__, name);
+ }
- if (BLI_stat(name, &st) == -1)
+ if (BLI_stat(name, &st) == -1) {
return false;
- if (((st.st_mode) & S_IFMT) != S_IFREG)
+ }
+ if (((st.st_mode) & S_IFMT) != S_IFREG) {
return false;
+ }
- if ((fp = BLI_open(name, O_BINARY | O_RDONLY, 0)) == -1)
+ if ((fp = BLI_open(name, O_BINARY | O_RDONLY, 0)) == -1) {
return false;
+ }
memset(buf, 0, sizeof(buf));
if (read(fp, buf, HEADER_SIZE) <= 0) {
@@ -146,8 +150,9 @@ int IMB_ispic_type(const char *name)
close(fp);
/* XXX move this exception */
- if ((BIG_LONG(((int *)buf)[0]) & 0xfffffff0) == 0xffd8ffe0)
+ if ((BIG_LONG(((int *)buf)[0]) & 0xfffffff0) == 0xffd8ffe0) {
return IMB_FTYPE_JPG;
+ }
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
if (type->is_a) {
@@ -223,8 +228,9 @@ void IMB_ffmpeg_init(void)
ffmpeg_last_error[0] = '\0';
- if (G.debug & G_DEBUG_FFMPEG)
+ if (G.debug & G_DEBUG_FFMPEG) {
av_log_set_level(AV_LOG_DEBUG);
+ }
/* set own callback which could store last error to report to UI */
av_log_set_callback(ffmpeg_log_callback);
@@ -259,20 +265,23 @@ static int isffmpeg(const char *filename)
}
if (avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0) {
- if (UTIL_DEBUG)
+ if (UTIL_DEBUG) {
fprintf(stderr, "isffmpeg: av_open_input_file failed\n");
+ }
return 0;
}
if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
- if (UTIL_DEBUG)
+ if (UTIL_DEBUG) {
fprintf(stderr, "isffmpeg: avformat_find_stream_info failed\n");
+ }
avformat_close_input(&pFormatCtx);
return 0;
}
- if (UTIL_DEBUG)
+ if (UTIL_DEBUG) {
av_dump_format(pFormatCtx, 0, filename, 0);
+ }
/* Find the first video stream */
videoStream = -1;
@@ -316,40 +325,51 @@ int imb_get_anim_type(const char *name)
BLI_assert(!BLI_path_is_rel(name));
- if (UTIL_DEBUG)
+ if (UTIL_DEBUG) {
printf("%s: %s\n", __func__, name);
+ }
#ifndef _WIN32
# ifdef WITH_FFMPEG
/* stat test below fails on large files > 4GB */
- if (isffmpeg(name))
+ if (isffmpeg(name)) {
return (ANIM_FFMPEG);
+ }
# endif
- if (BLI_stat(name, &st) == -1)
+ if (BLI_stat(name, &st) == -1) {
return (0);
- if (((st.st_mode) & S_IFMT) != S_IFREG)
+ }
+ if (((st.st_mode) & S_IFMT) != S_IFREG) {
return (0);
+ }
- if (isavi(name))
+ if (isavi(name)) {
return (ANIM_AVI);
+ }
- if (ismovie(name))
+ if (ismovie(name)) {
return (ANIM_MOVIE);
+ }
#else
- if (BLI_stat(name, &st) == -1)
+ if (BLI_stat(name, &st) == -1) {
return (0);
- if (((st.st_mode) & S_IFMT) != S_IFREG)
+ }
+ if (((st.st_mode) & S_IFMT) != S_IFREG) {
return (0);
+ }
- if (ismovie(name))
+ if (ismovie(name)) {
return (ANIM_MOVIE);
+ }
# ifdef WITH_FFMPEG
- if (isffmpeg(name))
+ if (isffmpeg(name)) {
return (ANIM_FFMPEG);
+ }
# endif
- if (isavi(name))
+ if (isavi(name)) {
return (ANIM_AVI);
+ }
#endif
type = IMB_ispic(name);
if (type) {
diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c
index e93df7b73ba..ac3961faf49 100644
--- a/source/blender/imbuf/intern/writeimage.c
+++ b/source/blender/imbuf/intern/writeimage.c
@@ -49,8 +49,9 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
BLI_assert(!BLI_path_is_rel(name));
- if (ibuf == NULL)
+ if (ibuf == NULL) {
return (false);
+ }
ibuf->flags = flags;
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index e8af6cf0d86..2cdbfa06e30 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -113,13 +113,20 @@ enum {
/* IDP_GROUP */
enum {
- IDP_GROUP_SUB_NONE = 0, /* default */
- IDP_GROUP_SUB_MODE_OBJECT = 1, /* object mode settings */
- IDP_GROUP_SUB_MODE_EDIT = 2, /* mesh edit mode settings */
- IDP_GROUP_SUB_ENGINE_RENDER = 3, /* render engine settings */
- IDP_GROUP_SUB_OVERRIDE = 4, /* data override */
- IDP_GROUP_SUB_MODE_PAINT_WEIGHT = 5, /* weight paint mode settings */
- IDP_GROUP_SUB_MODE_PAINT_VERTEX = 6, /* vertex paint mode settings */
+ /** Default. */
+ IDP_GROUP_SUB_NONE = 0,
+ /** Object mode settings. */
+ IDP_GROUP_SUB_MODE_OBJECT = 1,
+ /** Mesh edit mode settings. */
+ IDP_GROUP_SUB_MODE_EDIT = 2,
+ /** Render engine settings. */
+ IDP_GROUP_SUB_ENGINE_RENDER = 3,
+ /** Data override. */
+ IDP_GROUP_SUB_OVERRIDE = 4,
+ /** Weight paint mode settings. */
+ IDP_GROUP_SUB_MODE_PAINT_WEIGHT = 5,
+ /** Vertex paint mode settings. */
+ IDP_GROUP_SUB_MODE_PAINT_VERTEX = 6,
};
/*->flag*/
@@ -146,7 +153,8 @@ typedef struct IDOverrideStaticPropertyOperation {
char _pad0[4];
/* Sub-item references, if needed (for arrays or collections only).
- * We need both reference and local values to allow e.g. insertion into collections (constraints, modifiers...).
+ * We need both reference and local values to allow e.g. insertion into collections
+ * (constraints, modifiers...).
* In collection case, if names are defined, they are used in priority.
* Names are pointers (instead of char[64]) to save some space, NULL when unset.
* Indices are -1 when unset. */
@@ -465,7 +473,8 @@ enum {
/**
* id->tag (runtime-only).
*
- * Those flags belong to three different categories, which have different expected handling in code:
+ * Those flags belong to three different categories,
+ * which have different expected handling in code:
*
* - RESET_BEFORE_USE: piece of code that wants to use such flag
* has to ensure they are properly 'reset' first.
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 3341272c10f..c524f50ff52 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -31,6 +31,7 @@
#include "DNA_listBase.h"
#include "DNA_ID.h"
#include "DNA_view2d_types.h"
+#include "DNA_vec_types.h"
#include "DNA_userdef_types.h" /* ThemeWireColor */
struct Collection;
@@ -183,8 +184,11 @@ struct DualQuat;
struct Mat4;
typedef struct bPoseChannel_Runtime {
+ /* Cached dual quaternion for deformation. */
+ struct DualQuat deform_dual_quat;
+
+ /* B-Bone shape data: copy of the segment count for validation. */
int bbone_segments;
- char _pad[4];
/* Rest and posed matrices for segments. */
struct Mat4 *bbone_rest_mats;
@@ -313,10 +317,11 @@ typedef struct bPoseChannel {
* and are applied on top of the copies in pchan->bone
*/
float roll1, roll2;
- float curveInX, curveInY;
- float curveOutX, curveOutY;
+ float curve_in_x, curve_in_y;
+ float curve_out_x, curve_out_y;
float ease1, ease2;
- float scaleIn, scaleOut;
+ float scale_in_x, scale_in_y;
+ float scale_out_x, scale_out_y;
/** B-Bone custom handles; set on read file or rebuild pose based on pchan->bone data. */
struct bPoseChannel *bbone_prev;
@@ -360,7 +365,7 @@ typedef enum ePchan_Flag {
POSE_IKTREE = (1 << 13),
#if 0
/* has Spline IK */
- POSE_HAS_IKS = (1 << 14),
+ POSE_HAS_IKS = (1 << 14),
#endif
/* spline IK solving */
POSE_IKSPLINE = (1 << 15),
@@ -570,8 +575,8 @@ typedef enum eItasc_Solver {
* ensure that action-groups never end up being the sole 'owner' of a channel.
*
* This is also exploited for bone-groups. Bone-Groups are stored per bPose, and are used
- * primarily to color bones in the 3d-view. There are other benefits too, but those are mostly related
- * to Action-Groups.
+ * primarily to color bones in the 3d-view. There are other benefits too, but those are mostly
+ * related to Action-Groups.
*
* Note that these two uses each have their own RNA 'ActionGroup' and 'BoneGroup'.
*/
@@ -626,13 +631,13 @@ typedef enum eActionGroup_Flag {
/* Action - reusable F-Curve 'bag' (act)
*
- * This contains F-Curves that may affect settings from more than one ID blocktype and/or
- * datablock (i.e. sub-data linked/used directly to the ID block that the animation data is linked to),
- * but with the restriction that the other unrelated data (i.e. data that is not directly used or linked to
- * by the source ID block).
+ * This contains F-Curves that may affect settings from more than one ID blocktype and/or datablock
+ * (i.e. sub-data linked/used directly to the ID block that the animation data is linked to),
+ * but with the restriction that the other unrelated data (i.e. data that is not directly used or
+ * linked to by the source ID block).
*
- * It serves as a 'unit' of reusable animation information (i.e. keyframes/motion data), that
- * affects a group of related settings (as defined by the user).
+ * It serves as a 'unit' of reusable animation information (i.e. keyframes/motion data),
+ * that affects a group of related settings (as defined by the user).
*/
typedef struct bAction {
/** ID-serialisation for relinking. */
@@ -826,11 +831,11 @@ typedef enum eSAction_Flag {
/* draw time in seconds instead of time in frames */
SACTION_DRAWTIME = (1 << 2),
/* don't filter action channels according to visibility */
- //SACTION_NOHIDE = (1 << 3), // XXX deprecated... old animation system
+ // SACTION_NOHIDE = (1 << 3), // XXX deprecated... old animation system
/* don't kill overlapping keyframes after transform */
SACTION_NOTRANSKEYCULL = (1 << 4),
/* don't include keyframes that are out of view */
- //SACTION_HORIZOPTIMISEON = (1 << 5), // XXX deprecated... old irrelevant trick
+ // SACTION_HORIZOPTIMISEON = (1 << 5), // XXX deprecated... old irrelevant trick
/* show pose-markers (local to action) in Action Editor mode */
SACTION_POSEMARKERS_SHOW = (1 << 6),
/* don't draw action channels using group colors (where applicable) */
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 48771410fcc..c76d4895b25 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -456,8 +456,8 @@ typedef enum eDriverVar_Flags {
* the value of some setting semi-procedurally.
*
* Drivers are stored as part of F-Curve data, so that the F-Curve's RNA-path settings (for storing
- * what setting the driver will affect). The order in which they are stored defines the order that they're
- * evaluated in. This order is set by the Depsgraph's sorting stuff.
+ * what setting the driver will affect). The order in which they are stored defines the order that
+ * they're evaluated in. This order is set by the Depsgraph's sorting stuff.
*/
typedef struct ChannelDriver {
/** Targets for this driver (i.e. list of DriverVar). */
@@ -508,7 +508,7 @@ typedef enum eDriver_Flags {
DRIVER_FLAG_DEPRECATED = (1 << 1),
/** Driver does replace value, but overrides (for layering of animation over driver) */
// TODO: this needs to be implemented at some stage or left out...
- //DRIVER_FLAG_LAYERING = (1 << 2),
+ // DRIVER_FLAG_LAYERING = (1 << 2),
/** Use when the expression needs to be recompiled. */
DRIVER_FLAG_RECOMPILE = (1 << 3),
/** The names are cached so they don't need have python unicode versions created each time */
@@ -710,6 +710,11 @@ typedef struct NlaStrip {
/** Settings. */
int flag;
char _pad2[4];
+
+ /* Pointer to an original NLA strip. */
+ struct NlaStrip *orig_strip;
+
+ void *_pad3;
} NlaStrip;
/* NLA Strip Blending Mode */
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 0b1bd23bd9c..483ff3483d3 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -77,11 +77,12 @@ typedef struct Bone {
/** Curved bones settings - these define the "restpose" for a curved bone. */
float roll1, roll2;
- float curveInX, curveInY;
- float curveOutX, curveOutY;
+ float curve_in_x, curve_in_y;
+ float curve_out_x, curve_out_y;
/** Length of bezier handles. */
float ease1, ease2;
- float scaleIn, scaleOut;
+ float scale_in_x, scale_in_y;
+ float scale_out_x, scale_out_y;
/** patch for upward compat, UNUSED!. */
float size[3];
diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h
index de1dac21ea0..47fe7d35596 100644
--- a/source/blender/makesdna/DNA_boid_types.h
+++ b/source/blender/makesdna/DNA_boid_types.h
@@ -117,13 +117,13 @@ typedef struct BoidData {
} BoidData;
// planned for near future
-//typedef enum BoidConditionMode {
+// typedef enum BoidConditionMode {
// eBoidConditionType_Then = 0,
// eBoidConditionType_And = 1,
// eBoidConditionType_Or = 2,
// NUM_BOID_CONDITION_MODES
//} BoidConditionMode;
-//typedef enum BoidConditionType {
+// typedef enum BoidConditionType {
// eBoidConditionType_None = 0,
// eBoidConditionType_Signal = 1,
// eBoidConditionType_NoSignal = 2,
@@ -135,7 +135,7 @@ typedef struct BoidData {
// eBoidConditionType_Touching = 8,
// NUM_BOID_CONDITION_TYPES
//} BoidConditionType;
-//typedef struct BoidCondition {
+// typedef struct BoidCondition {
// struct BoidCondition *next, *prev;
// int state_id;
// short type, mode;
@@ -170,19 +170,19 @@ typedef struct BoidState {
} BoidState;
// planned for near future
-//typedef struct BoidSignal {
+// typedef struct BoidSignal {
// struct BoidSignal *next, *prev;
// float loc[3];
// float volume, falloff;
// int id;
//} BoidSignal;
-//typedef struct BoidSignalDefine {
+// typedef struct BoidSignalDefine {
// struct BoidSignalDefine *next, *prev;
// int id, rt;
// char name[32];
//} BoidSignalDefine;
-//typedef struct BoidSimulationData {
+// typedef struct BoidSimulationData {
// ListBase signal_defines;/* list of defined signals */
// ListBase signals[20]; /* gathers signals from all channels */
// struct KDTree_3d *signaltrees[20];
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index a261ebacc14..6f775e48d58 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -263,6 +263,8 @@ typedef struct Brush {
/** Active sculpt tool. */
char sculpt_tool;
+ /** Active sculpt tool. */
+ char uv_sculpt_tool;
/** Active vertex paint. */
char vertexpaint_tool;
/** Active weight paint. */
@@ -273,7 +275,7 @@ typedef struct Brush {
char mask_tool;
/** Active grease pencil tool. */
char gpencil_tool;
- char _pad0[2];
+ char _pad0[1];
float autosmooth_factor;
@@ -324,7 +326,7 @@ typedef struct PaletteColor {
typedef struct Palette {
ID id;
- /* pointer to individual colours */
+ /** Pointer to individual colors. */
ListBase colors;
int active_color;
@@ -437,6 +439,13 @@ typedef enum eBrushSculptTool {
SCULPT_TOOL_MASK = 19,
} eBrushSculptTool;
+/* Brush.uv_sculpt_tool */
+typedef enum eBrushUVSculptTool {
+ UV_SCULPT_TOOL_GRAB = 0,
+ UV_SCULPT_TOOL_RELAX = 1,
+ UV_SCULPT_TOOL_PINCH = 2,
+} eBrushUVSculptTool;
+
/** When #BRUSH_ACCUMULATE is used */
#define SCULPT_TOOL_HAS_ACCUMULATE(t) \
ELEM(t, \
@@ -462,7 +471,7 @@ typedef enum eBrushSculptTool {
SCULPT_TOOL_LAYER, \
\
/* These brushes could handle dynamic topology, \
- * but user feedback indicates it's better not to */ \
+ * but user feedback indicates it's better not to */ \
SCULPT_TOOL_SMOOTH, \
SCULPT_TOOL_MASK) == 0)
diff --git a/source/blender/makesdna/DNA_cachefile_types.h b/source/blender/makesdna/DNA_cachefile_types.h
index e5f77f70720..bc57202367c 100644
--- a/source/blender/makesdna/DNA_cachefile_types.h
+++ b/source/blender/makesdna/DNA_cachefile_types.h
@@ -30,10 +30,12 @@
extern "C" {
#endif
+struct GSet;
+
/* CacheFile::flag */
enum {
CACHEFILE_DS_EXPAND = (1 << 0),
- CACHEFILE_DIRTY = (1 << 1),
+ CACHEFILE_UNUSED_0 = (1 << 1),
};
/* CacheFile::draw_flag */
@@ -53,9 +55,6 @@ typedef struct CacheFile {
ID id;
struct AnimData *adt;
- struct AbcArchiveHandle *handle;
- void *handle_mutex;
-
/** Paths of the objects inside of the Alembic archive referenced by this CacheFile. */
ListBase object_paths;
@@ -78,6 +77,11 @@ typedef struct CacheFile {
short draw_flag;
char _pad[4];
+
+ /* Runtime */
+ struct AbcArchiveHandle *handle;
+ char handle_filepath[1024];
+ struct GSet *handle_readers;
} CacheFile;
#ifdef __cplusplus
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index 3ca61400e2e..f839f22ec9f 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -593,9 +593,12 @@ typedef struct bObjectSolverConstraint {
/* Transform matrix cache constraint */
typedef struct bTransformCacheConstraint {
struct CacheFile *cache_file;
- struct CacheReader *reader;
/** FILE_MAX. */
char object_path[1024];
+
+ /* Runtime. */
+ struct CacheReader *reader;
+ char reader_object_path[1024];
} bTransformCacheConstraint;
/* ------------------------------------------ */
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 3c63f909efd..bdb3db94c89 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -313,8 +313,8 @@ enum {
#if 0 /* Moved to overlay options in 2.8 */
/* Curve.drawflag */
enum {
- CU_HIDE_HANDLES = 1 << 0,
- CU_HIDE_NORMALS = 1 << 1,
+ CU_HIDE_HANDLES = 1 << 0,
+ CU_HIDE_NORMALS = 1 << 1,
};
#endif
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index 1afb462aaa7..d949b34cb57 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -48,7 +48,6 @@ enum {
MOD_DPAINT_MULALPHA = 1 << 3, /* Multiply color by alpha when saving image */
MOD_DPAINT_DISSOLVE_LOG = 1 << 4, /* Use 1/x for surface dissolve */
MOD_DPAINT_DRY_LOG = 1 << 5, /* Use 1/x for drying paint */
- MOD_DPAINT_PREVIEW = 1 << 6, /* preview this surface on viewport*/
MOD_DPAINT_WAVE_OPEN_BORDERS = 1 << 7, /* passes waves through mesh edges */
MOD_DPAINT_DISP_INCREMENTAL = 1 << 8, /* builds displace on top of earlier values */
@@ -77,12 +76,6 @@ enum {
MOD_DPAINT_EFFECT_DO_SHRINK = 1 << 2, /* do shrink effect */
};
-/* preview_id */
-enum {
- MOD_DPAINT_SURFACE_PREV_PAINT = 0,
- MOD_DPAINT_SURFACE_PREV_WETMAP = 1,
-};
-
/* init_color_type */
enum {
MOD_DPAINT_INITIAL_NONE = 0,
@@ -120,15 +113,11 @@ typedef struct DynamicPaintSurface {
short disp_type, image_fileformat;
/** Ui selection box. */
short effect_ui;
- /** Surface output id to preview. */
- short preview_id;
short init_color_type;
- char _pad0[2];
int flags, effect;
int image_resolution, substeps;
int start_frame, end_frame;
- char _pad[4];
/* initial color */
float init_color[4];
@@ -163,12 +152,6 @@ typedef struct DynamicPaintSurface {
/* canvas flags */
enum {
-/* This should not be needed, having a valid WEIGHT_MCOL layer should be enough.
- * And if not, should be a general flag. But seems unnecessary for now... */
-#if 0
- /** if viewport preview is ready */
- MOD_DPAINT_PREVIEW_READY = 1 << 0,
-#endif
/** surface is already baking, so it wont get updated (loop) */
MOD_DPAINT_BAKING = 1 << 1,
};
@@ -191,7 +174,7 @@ typedef struct DynamicPaintCanvasSettings {
enum {
/** use particle radius */
MOD_DPAINT_PART_RAD = 1 << 0,
- //MOD_DPAINT_USE_MATERIAL = 1 << 1, /* DNA_DEPRECATED */
+ // MOD_DPAINT_USE_MATERIAL = 1 << 1, /* DNA_DEPRECATED */
/** don't increase alpha unless paint alpha is higher than existing */
MOD_DPAINT_ABS_ALPHA = 1 << 2,
/** removes paint */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index f39676f53ad..bb38311cbac 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -136,7 +136,7 @@ typedef enum eGPDpalettecolor_Flag {
typedef struct bGPDpalette {
struct bGPDpalette *next, *prev;
- /** Pointer to individual colours. */
+ /** Pointer to individual colors. */
ListBase colors;
/** Palette name. Must be unique. */
char info[64];
diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h
index 5c9c845005c..1561b44358b 100644
--- a/source/blender/makesdna/DNA_ipo_types.h
+++ b/source/blender/makesdna/DNA_ipo_types.h
@@ -20,9 +20,10 @@
/** \file
* \ingroup DNA
* \deprecated
- * The contents of this file are now officially deprecated. They were used for the 'old' animation system,
- * which has (as of 2.50) been replaced with a completely new system by Joshua Leung (aligorith). All defines,
- * etc. are only still maintained to provide backwards compatibility for old files.
+ * The contents of this file are now officially deprecated.
+ * They were used for the 'old' animation system,
+ * which has (as of 2.50) been replaced with a completely new system by Joshua Leung (aligorith).
+ * All defines, etc. are only still maintained to provide backwards compatibility for old files.
*/
#ifndef __DNA_IPO_TYPES_H__
diff --git a/source/blender/makesdna/DNA_light_types.h b/source/blender/makesdna/DNA_light_types.h
index d3c98f30352..6bd118b7be9 100644
--- a/source/blender/makesdna/DNA_light_types.h
+++ b/source/blender/makesdna/DNA_light_types.h
@@ -96,8 +96,8 @@ typedef struct Light {
/* flag */
#define LA_DS_EXPAND (1 << 0)
/* NOTE: this must have the same value as MA_DS_SHOW_TEXS,
- * otherwise anim-editors will not read correctly
- */
+ * otherwise anim-editors will not read correctly
+ */
#define LA_DS_SHOW_TEXS (1 << 2)
/* type */
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index eacb19822f9..02f8245413d 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -96,7 +96,9 @@ typedef struct MaterialGPencilStyle {
/** Type of gradient. */
int gradient_type;
- char _pad[4];
+
+ /** Factor used to mix texture and stroke color. */
+ float mix_stroke_factor;
} MaterialGPencilStyle;
/* MaterialGPencilStyle->flag */
@@ -111,8 +113,8 @@ typedef enum eMaterialGPencilStyle_Flag {
GP_STYLE_COLOR_ONIONSKIN = (1 << 3),
/* clamp texture */
GP_STYLE_COLOR_TEX_CLAMP = (1 << 4),
- /* mix texture */
- GP_STYLE_COLOR_TEX_MIX = (1 << 5),
+ /* mix fill texture */
+ GP_STYLE_FILL_TEX_MIX = (1 << 5),
/* Flip fill colors */
GP_STYLE_COLOR_FLIP_FILL = (1 << 6),
/* Stroke Texture is a pattern */
@@ -123,6 +125,8 @@ typedef enum eMaterialGPencilStyle_Flag {
GP_STYLE_FILL_SHOW = (1 << 9),
/* Don't rotate dots/boxes */
GP_STYLE_COLOR_LOCK_DOTS = (1 << 10),
+ /* mix stroke texture */
+ GP_STYLE_STROKE_TEX_MIX = (1 << 11),
} eMaterialGPencilStyle_Flag;
typedef enum eMaterialGPencilStyle_Mode {
@@ -212,9 +216,9 @@ typedef struct Material {
/* for dopesheet */
#define MA_DS_EXPAND (1 << 1)
/* for dopesheet (texture stack expander)
- * NOTE: this must have the same value as other texture stacks,
- * otherwise anim-editors will not read correctly
- */
+ * NOTE: this must have the same value as other texture stacks,
+ * otherwise anim-editors will not read correctly
+ */
#define MA_DS_SHOW_TEXS (1 << 2)
/* ramps */
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index a7b061e6d48..8f08b212d6d 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -61,7 +61,8 @@ typedef struct EditMeshData {
} EditMeshData;
/**
- * \warning Typical access is done via #BKE_mesh_runtime_looptri_ensure, #BKE_mesh_runtime_looptri_len.
+ * \warning Typical access is done via
+ * #BKE_mesh_runtime_looptri_ensure, #BKE_mesh_runtime_looptri_len.
*/
struct MLoopTri_Store {
/* WARNING! swapping between array (ready-to-be-used data) and array_wip
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index ee12f47051c..04d060b065d 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -61,8 +61,9 @@ typedef struct MVert {
char flag, bweight;
} MVert;
-/* tessellation vertex color data.
- * at the moment alpha is abused for vertex painting and not used for transparency, note that red and blue are swapped
+/** Tessellation vertex color data.
+ * at the moment alpha is abused for vertex painting and not used for transparency,
+ * note that red and blue are swapped
*/
typedef struct MCol {
unsigned char a, r, g, b;
@@ -87,10 +88,12 @@ typedef struct MLoop {
} MLoop;
/**
- * #MLoopTri's are lightweight triangulation data, for functionality that doesn't support ngons (#MPoly).
+ * #MLoopTri's are lightweight triangulation data,
+ * for functionality that doesn't support ngons (#MPoly).
* This is cache data created from (#MPoly, #MLoop & #MVert arrays).
- * There is no attempt to maintain this data's validity over time, any changes to the underlying mesh
- * invalidate the #MLoopTri array, which will need to be re-calculated.
+ * There is no attempt to maintain this data's validity over time,
+ * any changes to the underlying mesh invalidate the #MLoopTri array,
+ * which will need to be re-calculated.
*
* Users normally access this via #BKE_mesh_runtime_looptri_ensure.
* In rare cases its calculated directly, with #BKE_mesh_recalc_looptri.
@@ -102,7 +105,8 @@ typedef struct MLoop {
*
* Storing loop indices (instead of vertex indices) allows us to
* directly access UV's, vertex-colors as well as vertices.
- * The index of the source polygon is stored as well, giving access to materials and polygon normals.
+ * The index of the source polygon is stored as well,
+ * giving access to materials and polygon normals.
*
* \note This data is runtime only, never written to disk.
*
@@ -148,7 +152,8 @@ typedef struct MLoop {
* };
* \endcode
*
- * It may also be useful to check whether or not two vertices of a triangle form an edge in the underlying mesh.
+ * It may also be useful to check whether or not two vertices of a triangle
+ * form an edge in the underlying mesh.
*
* This can be done by checking the edge of the referenced loop (#MLoop.e),
* the winding of the #MLoopTri and the #MLoop's will always match,
@@ -183,7 +188,7 @@ typedef struct MVertTri {
unsigned int tri[3];
} MVertTri;
-//typedef struct MTexPoly {
+// typedef struct MTexPoly {
// void *_pad;
//} MTexPoly;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 1b85fb26c0e..6a524e03b6e 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1852,12 +1852,15 @@ typedef struct MeshSeqCacheModifierData {
ModifierData modifier;
struct CacheFile *cache_file;
- struct CacheReader *reader;
/** 1024 = FILE_MAX. */
char object_path[1024];
char read_flag;
char _pad[7];
+
+ /* Runtime. */
+ struct CacheReader *reader;
+ char reader_object_path[1024];
} MeshSeqCacheModifierData;
/* MeshSeqCacheModifierData.read_flag */
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 905cd4764ad..226e1d2f841 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -42,12 +42,6 @@ struct bNodeTreeExec;
struct bNodeType;
struct uiBlock;
-/* In writefile.c: write deprecated DNA data,
- * to ensure forward compatibility in 2.6x versions.
- * Will be removed eventually.
- */
-#define USE_NODE_COMPAT_CUSTOMNODES
-
#define NODE_MAXSTR 64
typedef struct bNodeStack {
@@ -264,13 +258,14 @@ typedef struct bNode {
rctf butr;
/** Optional preview area. */
rctf prvr;
- /* XXX TODO
+ /**
+ * XXX TODO
* Node totr size depends on the prvr size, which in turn is determined from preview size.
* In earlier versions bNodePreview was stored directly in nodes, but since now there can be
- * multiple instances using different preview images it is possible that required node size varies between instances.
- * preview_xsize, preview_ysize defines a common reserved size for preview rect for now,
- * could be replaced by more accurate node instance drawing, but that requires removing totr from DNA
- * and replacing all uses with per-instance data.
+ * multiple instances using different preview images it is possible that required node size
+ * varies between instances. preview_xsize, preview_ysize defines a common reserved size for
+ * preview rect for now, could be replaced by more accurate node instance drawing,
+ * but that requires removing totr from DNA and replacing all uses with per-instance data.
*/
/** Reserved size of the preview rect. */
short preview_xsize, preview_ysize;
@@ -315,22 +310,22 @@ typedef struct bNode {
/* node is active texture */
/* note: take care with this flag since its possible it gets
- * `stuck` inside/outside the active group - which makes buttons
- * window texture not update, we try to avoid it by clearing the
- * flag when toggling group editing - Campbell */
+ * `stuck` inside/outside the active group - which makes buttons
+ * window texture not update, we try to avoid it by clearing the
+ * flag when toggling group editing - Campbell */
#define NODE_ACTIVE_TEXTURE (1 << 14)
/* use a custom color for the node */
#define NODE_CUSTOM_COLOR (1 << 15)
/* Node has been initialized
- * This flag indicates the node->typeinfo->init function has been called.
- * In case of undefined type at creation time this can be delayed until
- * until the node type is registered.
- */
+ * This flag indicates the node->typeinfo->init function has been called.
+ * In case of undefined type at creation time this can be delayed until
+ * until the node type is registered.
+ */
#define NODE_INIT (1 << 16)
/* do recalc of output, used to skip recalculation of unwanted
- * composite out nodes when editing tree
- */
+ * composite out nodes when editing tree
+ */
#define NODE_DO_OUTPUT_RECALC (1 << 17)
/* node->update */
@@ -466,10 +461,12 @@ typedef struct bNodeTree {
bNodeInstanceKey active_viewer_key;
char _pad[4];
- /* execution data */
- /* XXX It would be preferable to completely move this data out of the underlying node tree,
- * so node tree execution could finally run independent of the tree itself. This would allow node trees
- * to be merely linked by other data (materials, textures, etc.), as ID data is supposed to.
+ /** Execution data.
+ *
+ * XXX It would be preferable to completely move this data out of the underlying node tree,
+ * so node tree execution could finally run independent of the tree itself.
+ * This would allow node trees to be merely linked by other data (materials, textures, etc.),
+ * as ID data is supposed to.
* Execution data is generated from the tree once at execution start and can then be used
* as long as necessary, even while the tree is being modified.
*/
@@ -507,17 +504,6 @@ typedef struct bNodeTree {
/* tree is localized copy, free when deleting node groups */
/* #define NTREE_IS_LOCALIZED (1 << 5) */
-/* XXX not nice, but needed as a temporary flags
- * for group updates after library linking.
- */
-
-/* changes from r35033 */
-#define NTREE_DO_VERSIONS_GROUP_EXPOSE_2_56_2 (1 << 10)
-/* custom_nodes branch: remove links to node tree sockets */
-#define NTREE_DO_VERSIONS_CUSTOMNODES_GROUP (1 << 11)
-/* custom_nodes branch: create group input/output nodes */
-#define NTREE_DO_VERSIONS_CUSTOMNODES_GROUP_CREATE_INTERFACE (1 << 12)
-
/* ntree->update */
typedef enum eNodeTreeUpdate {
NTREE_UPDATE = 0xFFFF, /* generic update flag (includes all others) */
diff --git a/source/blender/makesdna/DNA_object_enums.h b/source/blender/makesdna/DNA_object_enums.h
index debf4c2ea6c..44aeb5feaff 100644
--- a/source/blender/makesdna/DNA_object_enums.h
+++ b/source/blender/makesdna/DNA_object_enums.h
@@ -23,7 +23,7 @@
#ifndef __DNA_OBJECT_ENUMS_H__
#define __DNA_OBJECT_ENUMS_H__
-/* Object.mode */
+/** #Object.mode */
typedef enum eObjectMode {
OB_MODE_OBJECT = 0,
OB_MODE_EDIT = 1 << 0,
@@ -39,17 +39,18 @@ typedef enum eObjectMode {
OB_MODE_WEIGHT_GPENCIL = 1 << 10,
} eObjectMode;
-/* Any mode where the brush system is used. */
+/** Any mode where the brush system is used. */
#define OB_MODE_ALL_PAINT \
(OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)
#define OB_MODE_ALL_PAINT_GPENCIL \
(OB_MODE_PAINT_GPENCIL | OB_MODE_SCULPT_GPENCIL | OB_MODE_WEIGHT_GPENCIL)
-/* Any mode that uses Object.sculpt. */
+/** Any mode that uses Object.sculpt. */
#define OB_MODE_ALL_SCULPT (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)
-/* Any mode that has data we need to free when switching modes, see: #ED_object_mode_generic_exit */
+/** Any mode that has data we need to free when switching modes,
+ * see: #ED_object_mode_generic_exit */
#define OB_MODE_ALL_MODE_DATA \
(OB_MODE_EDIT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT | OB_MODE_POSE)
diff --git a/source/blender/makesdna/DNA_object_force_types.h b/source/blender/makesdna/DNA_object_force_types.h
index 7b3dfc4f4f3..2207e08558d 100644
--- a/source/blender/makesdna/DNA_object_force_types.h
+++ b/source/blender/makesdna/DNA_object_force_types.h
@@ -239,11 +239,12 @@ typedef struct PointCache {
* buf for now it's the same for all points. Without adaptivity this can effect the perceived
* simulation quite a bit though. If for example particles are colliding with a horizontal
* plane (with high damping) they quickly come to a stop on the plane, however there are still
- * forces acting on the particle (gravity and collisions), so the particle velocity isn't necessarily
- * zero for the whole duration of the frame even if the particle seems stationary. If all simulation
- * frames aren't cached (step > 1) these velocities are interpolated into movement for the non-cached
- * frames. The result will look like the point is oscillating around the collision location. So for
- * now cache step should be set to 1 for accurate reproduction of collisions.
+ * forces acting on the particle (gravity and collisions), so the particle velocity isn't
+ * necessarily zero for the whole duration of the frame even if the particle seems stationary.
+ * If all simulation frames aren't cached (step > 1) these velocities are interpolated into
+ * movement for the non-cached frames.
+ * The result will look like the point is oscillating around the collision location.
+ * So for now cache step should be set to 1 for accurate reproduction of collisions.
*/
int step;
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index dc23a6a1ee2..1aeb4a2f4d2 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -118,11 +118,6 @@ typedef struct LodLevel {
int obhysteresis;
} LodLevel;
-/* Forward declaration for cache bbone deformation information.
- *
- * TODO(sergey): Consider moving it to more appropriate place. */
-struct ObjectBBoneDeform;
-
struct CustomData_MeshMasks;
/* Not saved in file! */
@@ -166,10 +161,6 @@ typedef struct Object_Runtime {
/** Runtime grease pencil drawing data */
struct GpencilBatchCache *gpencil_cache;
-
- struct ObjectBBoneDeform *cached_bbone_deformation;
-
- void *_pad1;
} Object_Runtime;
typedef struct Object {
@@ -582,8 +573,7 @@ enum {
/* **************** BASE ********************* */
-/* also needed for base!!!!! or rather, they interfere....*/
-/* base->flag and ob->flag */
+/* base->flag_legacy */
enum {
BA_WAS_SEL = (1 << 1),
/* NOTE: BA_HAS_RECALC_DATA can be re-used later if freed in readfile.c. */
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index f69c84cb7a1..ff4ada613c5 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -213,7 +213,7 @@ typedef enum eRigidBody_Shape {
RB_SHAPE_TRIMESH,
/* concave mesh approximated using primitives */
- //RB_SHAPE_COMPOUND,
+ // RB_SHAPE_COMPOUND,
} eRigidBody_Shape;
typedef enum eRigidBody_MeshSource {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 28eb481ffd4..baa9b3ed5c3 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -803,11 +803,6 @@ typedef struct RenderProfile {
#define UV_SCULPT_LOCK_BORDERS 1
#define UV_SCULPT_ALL_ISLANDS 2
-/* ToolSettings.uv_sculpt_tool */
-#define UV_SCULPT_TOOL_PINCH 1
-#define UV_SCULPT_TOOL_RELAX 2
-#define UV_SCULPT_TOOL_GRAB 3
-
/* ToolSettings.uv_relax_method */
#define UV_SCULPT_TOOL_RELAX_LAPLACIAN 1
#define UV_SCULPT_TOOL_RELAX_HC 2
@@ -965,11 +960,11 @@ typedef struct Sculpt {
Paint paint;
/* For rotating around a pivot point */
- //float pivot[3]; XXX not used?
+ // float pivot[3]; XXX not used?
int flags;
/* Control tablet input */
- //char tablet_size, tablet_strength; XXX not used?
+ // char tablet_size, tablet_strength; XXX not used?
int radial_symm[3];
/* Maximum edge length for dynamic topology sculpting (in pixels) */
@@ -1467,7 +1462,7 @@ typedef struct ToolSettings {
char snap_target;
char snap_transform_mode_flag;
- char proportional, prop_mode;
+ char proportional_edit, prop_mode;
/** Proportional edit, object mode. */
char proportional_objects;
/** Proportional edit, mask editing. */
@@ -1479,7 +1474,7 @@ typedef struct ToolSettings {
/** Lock marker editing. */
char lock_markers;
- /**aUto normalizing mode in wpain.t*/
+ /** Auto normalizing mode in wpaint. */
char auto_normalize;
/** Paint multiple bones in wpaint. */
char multipaint;
@@ -1488,10 +1483,8 @@ typedef struct ToolSettings {
char vgroupsubset;
/* UV painting */
- char _pad2[1];
- char use_uv_sculpt;
+ char _pad2[3];
char uv_sculpt_settings;
- char uv_sculpt_tool;
char uv_relax_method;
/* XXX: these sculpt_paint_* fields are deprecated, use the
* unified_paint_settings field instead! */
@@ -1816,8 +1809,9 @@ enum {
R_SEQ_UNUSED_0 = (1 << 0), /* cleared */
R_SEQ_UNUSED_1 = (1 << 1), /* cleared */
R_SEQ_UNUSED_2 = (1 << 2), /* cleared */
- R_SEQ_SOLID_TEX = (1 << 3),
- R_SEQ_CAMERA_DOF = (1 << 4),
+ R_SEQ_UNUSED_3 = (1 << 3), /* cleared */
+ R_SEQ_UNUSED_4 = (1 << 4), /* cleared */
+ R_SEQ_OVERRIDE_SCENE_SETTINGS = (1 << 5),
};
/* RenderData.displaymode */
@@ -2078,11 +2072,12 @@ enum {
#define PROP_INVSQUARE 7
#define PROP_MODE_MAX 8
-/* ToolSettings.proportional */
-#define PROP_EDIT_OFF 0
-#define PROP_EDIT_ON 1
-#define PROP_EDIT_CONNECTED 2
-#define PROP_EDIT_PROJECTED 3
+/** #ToolSettings.proportional_edit & similarly named members. */
+enum {
+ PROP_EDIT_USE = (1 << 0),
+ PROP_EDIT_CONNECTED = (1 << 1),
+ PROP_EDIT_PROJECTED = (1 << 2),
+};
/* ToolSettings.weightuser */
enum {
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 48418ee5035..411777333a9 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -166,9 +166,11 @@ typedef struct Panel {
/**
* Notes on Panel Categories:
*
- * - #ARegion.panels_category (#PanelCategoryDyn) is a runtime only list of categories collected during draw.
+ * - #ARegion.panels_category (#PanelCategoryDyn)
+ * is a runtime only list of categories collected during draw.
*
- * - #ARegion.panels_category_active (#PanelCategoryStack) is basically a list of strings (category id's).
+ * - #ARegion.panels_category_active (#PanelCategoryStack)
+ * is basically a list of strings (category id's).
*
* Clicking on a tab moves it to the front of ar->panels_category_active,
* If the context changes so this tab is no longer displayed,
@@ -344,7 +346,7 @@ typedef struct ScrArea {
* runtime variable, updated by executing operators.
*/
short region_active_win;
- char temp, _pad;
+ char _pad[2];
/** Callbacks for this space type. */
struct SpaceType *type;
@@ -471,7 +473,7 @@ enum {
/** #bScreen.flag */
enum {
- SCREEN_COLLAPSE_TOPBAR = 1,
+ SCREEN_DEPRECATED = 1,
SCREEN_COLLAPSE_STATUSBAR = 2,
};
@@ -544,7 +546,7 @@ enum {
#define UI_LIST_AUTO_SIZE_THRESHOLD 1
/* uiList filter flags (dyn_data) */
-/* WARNING! Those values are used by integer RNA too, which does not handle well values > INT_MAX...
+/* WARNING! Those values are used by integer RNA too, which does not handle well values > INT_MAX.
* So please do not use 32nd bit here. */
enum {
UILST_FLT_ITEM = 1 << 30, /* This item has passed the filter process successfully. */
@@ -589,6 +591,7 @@ enum {
/* A place for buttons to trigger execution of something that was set up in other regions. */
RGN_TYPE_EXECUTE = 10,
RGN_TYPE_FOOTER = 11,
+ RGN_TYPE_TOOL_HEADER = 12,
};
/* use for function args */
#define RGN_TYPE_ANY -1
@@ -625,6 +628,9 @@ enum {
/** Size has been clamped (floating regions only). */
RGN_FLAG_SIZE_CLAMP_X = (1 << 5),
RGN_FLAG_SIZE_CLAMP_Y = (1 << 6),
+ /** When the user sets the region is hidden,
+ * needed for floating regions that may be hidden for other reasons. */
+ RGN_FLAG_HIDDEN_BY_USER = (1 << 7),
};
/** #ARegion.do_draw */
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index ba3dee405ad..c21fa2ba64e 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -134,7 +134,7 @@ typedef struct Sequence {
/** SEQ_NAME_MAXSTR - name, set by default and needs to be unique, for RNA paths. */
char name[64];
- /**fLags bitmap (see below) and the type of sequenc.e*/
+ /** Flags bitmap (see below) and the type of sequence. */
int flag, type;
/** The length of the contents of this strip - before handles are applied. */
int len;
@@ -155,7 +155,7 @@ typedef struct Sequence {
int startstill, endstill;
/** Machine: the strip channel, depth the depth in the sequence when dealing with metastrips. */
int machine, depth;
- /** Starting and ending points of the strip in the sequenc.e*/
+ /** Starting and ending points of the strip in the sequence. */
int startdisp, enddisp;
float sat;
float mul, handsize;
@@ -229,6 +229,9 @@ typedef struct Sequence {
/* modifiers */
ListBase modifiers;
+
+ int cache_flag;
+ int _pad2[3];
} Sequence;
typedef struct MetaStack {
@@ -258,6 +261,12 @@ typedef struct Editing {
int over_ofs, over_cfra;
int over_flag, proxy_storage;
rctf over_border;
+
+ struct SeqCache *cache;
+
+ /* Cache control */
+ float recycle_max_cost;
+ int cache_flag;
} Editing;
/* ************* Effect Variable Structs ********* */
@@ -635,4 +644,33 @@ enum {
SEQUENCE_MASK_TIME_ABSOLUTE = 1,
};
+/* Sequence->cache_flag
+ * SEQ_CACHE_STORE_RAW
+ * SEQ_CACHE_STORE_PREPROCESSED
+ * SEQ_CACHE_STORE_COMPOSITE
+ * FINAL_OUT is ignored
+ *
+ * Editing->cache_flag
+ * all entries
+ */
+enum {
+ SEQ_CACHE_STORE_RAW = (1 << 0),
+ SEQ_CACHE_STORE_PREPROCESSED = (1 << 1),
+ SEQ_CACHE_STORE_COMPOSITE = (1 << 2),
+ SEQ_CACHE_STORE_FINAL_OUT = (1 << 3),
+
+ /* For lookup purposes */
+ SEQ_CACHE_ALL_TYPES = SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED |
+ SEQ_CACHE_STORE_COMPOSITE | SEQ_CACHE_STORE_FINAL_OUT,
+
+ SEQ_CACHE_OVERRIDE = (1 << 4),
+
+ /* enable cache visualization overlay in timeline UI */
+ SEQ_CACHE_VIEW_ENABLE = (1 << 5),
+ SEQ_CACHE_VIEW_RAW = (1 << 6),
+ SEQ_CACHE_VIEW_PREPROCESSED = (1 << 7),
+ SEQ_CACHE_VIEW_COMPOSITE = (1 << 8),
+ SEQ_CACHE_VIEW_FINAL_OUT = (1 << 9),
+};
+
#endif /* __DNA_SEQUENCE_TYPES_H__ */
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index 641a1fbf8e3..d795800df2f 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -276,13 +276,13 @@ typedef struct SmokeDomainSettings {
/* flags */
enum {
- /**old style emission*/
+ /** Old style emission. */
MOD_SMOKE_FLOW_ABSOLUTE = (1 << 1),
- /** passes particles speed to the smoke */
+ /** Passes particles speed to the smoke. */
MOD_SMOKE_FLOW_INITVELOCITY = (1 << 2),
- /** use texture to control emission speed */
+ /** Use texture to control emission speed. */
MOD_SMOKE_FLOW_TEXTUREEMIT = (1 << 3),
- /** use specific size for particles instead of closest cell */
+ /** Use specific size for particles instead of closest cell. */
MOD_SMOKE_FLOW_USE_PART_SIZE = (1 << 4),
};
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 8323a64bce1..9e8ece0c6e8 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -774,11 +774,12 @@ typedef enum eFileSel_Params_Flag {
/* sfile->params->rename_flag */
/* Note: short flag. Defined as bitflags, but currently only used as exclusive status markers... */
typedef enum eFileSel_Params_RenameFlag {
- /* Used when we only have the name of the entry we want to rename, but not yet access to its matching file entry. */
+ /** Used when we only have the name of the entry we want to rename,
+ * but not yet access to its matching file entry. */
FILE_PARAMS_RENAME_PENDING = 1 << 0,
- /* We are actually renaming an entry. */
+ /** We are actually renaming an entry. */
FILE_PARAMS_RENAME_ACTIVE = 1 << 1,
- /* Used to scroll to newly renamed entry. */
+ /** Used to scroll to newly renamed entry. */
FILE_PARAMS_RENAME_POSTSCROLL_PENDING = 1 << 2,
FILE_PARAMS_RENAME_POSTSCROLL_ACTIVE = 1 << 3,
} eFileSel_Params_RenameFlag;
@@ -821,10 +822,12 @@ typedef enum eDirEntry_SelectFlag {
/* ***** Related to file browser, but never saved in DNA, only here to help with RNA. ***** */
-/* About Unique identifier.
+/**
+ * About Unique identifier.
+ *
* Stored in a CustomProps once imported.
- * Each engine is free to use it as it likes - it will be the only thing passed to it by blender to identify
- * asset/variant/version (concatenating the three into a single 48 bytes one).
+ * Each engine is free to use it as it likes - it will be the only thing passed to it by blender to
+ * identify asset/variant/version (concatenating the three into a single 48 bytes one).
* Assumed to be 128bits, handled as four integers due to lack of real bytes proptype in RNA :|.
*/
#define ASSET_UUID_LENGTH 16
@@ -918,12 +921,17 @@ typedef struct FileDirEntry {
int act_variant;
} FileDirEntry;
-/* Array of direntries. */
-/* This struct is used in various, different contexts.
- * In Filebrowser UI, it stores the total number of available entries, the number of visible (filtered) entries,
- * and a subset of those in 'entries' ListBase, from idx_start (included) to idx_end (excluded).
- * In AssetEngine context (i.e. outside of 'browsing' context), entries contain all needed data, there is no filtering,
- * so nbr_entries_filtered, entry_idx_start and entry_idx_end should all be set to -1.
+/** Array of direntries.
+ *
+ * This struct is used in various, different contexts.
+ *
+ * In Filebrowser UI, it stores the total number of available entries, the number of visible
+ * (filtered) entries, and a subset of those in 'entries' ListBase, from idx_start (included)
+ * to idx_end (excluded).
+ *
+ * In AssetEngine context (i.e. outside of 'browsing' context), entries contain all needed data,
+ * there is no filtering, so nbr_entries_filtered, entry_idx_start and entry_idx_end
+ * should all be set to -1.
*/
#
#
@@ -1278,10 +1286,12 @@ typedef struct SpaceNode {
/** Mouse pos for drawing socketless link and adding nodes. */
float cursor[2];
- /* XXX nodetree pointer info is all in the path stack now,
- * remove later on and use bNodeTreePath instead. For now these variables are set when pushing/popping
- * from path stack, to avoid having to update all the functions and operators. Can be done when
- * design is accepted and everything is properly tested.
+ /**
+ * XXX nodetree pointer info is all in the path stack now,
+ * remove later on and use bNodeTreePath instead.
+ * For now these variables are set when pushing/popping
+ * from path stack, to avoid having to update all the functions and operators.
+ * Can be done when design is accepted and everything is properly tested.
*/
ListBase treepath;
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 57d685b527c..4a7b46fc154 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -300,12 +300,12 @@ typedef struct ThemeSpace {
char keytype_keyframe_select[4], keytype_extreme_select[4], keytype_breakdown_select[4],
keytype_jitter_select[4], keytype_movehold_select[4];
char keyborder[4], keyborder_select[4];
- char _pad4[4];
+ char _pad4[3];
char console_output[4], console_input[4], console_info[4], console_error[4];
char console_cursor[4], console_select[4];
- char vertex_size, outline_width, facedot_size;
+ char vertex_size, outline_width, obcenter_dia, facedot_size;
char noodle_curving;
/* syntax for textwindow and nodes */
@@ -643,15 +643,14 @@ typedef struct UserDef {
char _pad3[4];
short gizmo_flag, gizmo_size;
short edit_studio_light;
- char _pad6[4];
+ char _pad6[2];
+ short vbotimeout, vbocollectrate;
short textimeout, texcollectrate;
- char _pad14[2];
int memcachelimit;
int prefetchframes;
/** Control the rotation step of the view when PAD2, PAD4, PAD6&PAD8 is use. */
float pad_rot_angle;
- char _pad12[2];
- short obcenter_dia;
+ char _pad12[4];
/** Rotating view icon size. */
short rvisize;
/** Rotating view icon brightness. */
@@ -949,7 +948,8 @@ typedef enum eZoomFrame_Mode {
} eZoomFrame_Mode;
/** Auto-Keying flag
- * #UserDef.autokey_flag (not strictly used when autokeying only - is also used when keyframing these days)
+ * #UserDef.autokey_flag (not strictly used when autokeying only -
+ * is also used when keyframing these days).
* \note #eAutokey_Flag is used with a macro, search for lines like IS_AUTOKEY_FLAG(INSERTAVAIL).
*/
typedef enum eAutokey_Flag {
@@ -992,6 +992,8 @@ typedef enum eDupli_ID_Flags {
USER_DUP_ARM = (1 << 9),
USER_DUP_ACT = (1 << 10),
USER_DUP_PSYS = (1 << 11),
+ USER_DUP_LIGHTPROBE = (1 << 12),
+ USER_DUP_GPENCIL = (1 << 13),
} eDupli_ID_Flags;
/** Max anti alias draw method
@@ -1103,10 +1105,9 @@ typedef enum eMultiSample_Type {
/** #UserDef.image_draw_method */
typedef enum eImageDrawMethod {
- /* IMAGE_DRAW_METHOD_AUTO = 0, */ /* Currently unused */
+ IMAGE_DRAW_METHOD_AUTO = 0,
IMAGE_DRAW_METHOD_GLSL = 1,
IMAGE_DRAW_METHOD_2DTEXTURE = 2,
- IMAGE_DRAW_METHOD_DRAWPIXELS = 3,
} eImageDrawMethod;
/** #UserDef.virtual_pixel */
diff --git a/source/blender/makesdna/DNA_vec_types.h b/source/blender/makesdna/DNA_vec_types.h
index 06e6d881d0e..72a6056e239 100644
--- a/source/blender/makesdna/DNA_vec_types.h
+++ b/source/blender/makesdna/DNA_vec_types.h
@@ -83,4 +83,13 @@ typedef struct rctf {
float ymin, ymax;
} rctf;
+/** dual quaternion. */
+typedef struct DualQuat {
+ float quat[4];
+ float trans[4];
+
+ float scale[4][4];
+ float scale_weight;
+} DualQuat;
+
#endif
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 3e409f36724..d5ac8cc197b 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -200,12 +200,12 @@ typedef struct View3DOverlay {
/** Weight paint mode settings. */
int wpaint_flag;
- char _pad2[4];
/** Alpha for texture, weight, vertex paint overlay. */
float texture_paint_mode_opacity;
float vertex_paint_mode_opacity;
float weight_paint_mode_opacity;
+ float sculpt_mode_mask_opacity;
/** Armature edit/pose mode settings. */
int _pad3;
@@ -432,6 +432,7 @@ enum {
V3D_SHADING_SINGLE_COLOR = 2,
V3D_SHADING_TEXTURE_COLOR = 3,
V3D_SHADING_OBJECT_COLOR = 4,
+ V3D_SHADING_VERTEX_COLOR = 5,
};
/** #View3DShading.background_type */
@@ -525,6 +526,7 @@ enum {
#define V3D_SHOW_X (1 << 1)
#define V3D_SHOW_Y (1 << 2)
#define V3D_SHOW_Z (1 << 3)
+#define V3D_SHOW_ORTHO_GRID (1 << 4)
/** #TransformOrientationSlot.type */
enum {
@@ -579,6 +581,14 @@ enum {
V3D_GIZMO_SHOW_CAMERA_DOF_DIST = (1 << 2),
};
+/** Settings for offscreen rendering */
+enum {
+ V3D_OFSDRAW_NONE = (0),
+ V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 0),
+ V3D_OFSDRAW_SHOW_ANNOTATION = (1 << 1),
+ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS = (1 << 2),
+};
+
#define RV3D_CAMZOOM_MIN -30
#define RV3D_CAMZOOM_MAX 600
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 44526c93815..2b5d81d02a0 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -25,9 +25,6 @@
#include "DNA_scene_types.h"
-/* Currently testing, allow to disable. */
-#define USE_WORKSPACE_TOOL
-
#
#
typedef struct bToolRef_Runtime {
@@ -77,8 +74,10 @@ typedef struct bToolRef {
/**
* \brief Wrapper for bScreen.
*
- * bScreens are IDs and thus stored in a main list-base. We also want to store a list-base of them within the
- * workspace (so each workspace can have its own set of screen-layouts) which would mess with the next/prev pointers.
+ * #bScreens are IDs and thus stored in a main list-base.
+ * We also want to store a list-base of them within the workspace
+ * (so each workspace can have its own set of screen-layouts)
+ * which would mess with the next/prev pointers.
* So we use this struct to wrap a bScreen pointer with another pair of next/prev pointers.
*/
typedef struct WorkSpaceLayout {
@@ -112,28 +111,20 @@ typedef struct WorkSpace {
/** #wmOwnerID. */
ListBase owner_ids;
- /* should be: '#ifdef USE_WORKSPACE_TOOL'. */
-
/** List of #bToolRef */
ListBase tools;
- /**
- * BAD DESIGN WARNING:
- * This is a workaround for the topbar not knowing which tools spec. */
- char tools_space_type;
- /** Type is different for each space-type. */
- char tools_mode;
- char _pad[2];
+ char _pad[4];
int object_mode;
/** Enum eWorkSpaceFlags. */
int flags;
- /* Number for workspace tab reordering in the UI. */
+ /** Number for workspace tab reordering in the UI. */
int order;
- /* Info text from modal operators (runtime). */
+ /** Info text from modal operators (runtime). */
char *status_text;
} WorkSpace;
@@ -163,10 +154,10 @@ typedef struct WorkSpace {
typedef struct WorkSpaceDataRelation {
struct WorkSpaceDataRelation *next, *prev;
- /* the data used to identify the relation
- * (e.g. to find screen-layout (= value) from/for a hook) */
+ /** The data used to identify the relation
+ * (e.g. to find screen-layout (= value) from/for a hook). */
void *parent;
- /* The value for this parent-data/workspace relation */
+ /** The value for this parent-data/workspace relation. */
void *value;
} WorkSpaceDataRelation;
@@ -178,7 +169,7 @@ typedef struct WorkSpaceInstanceHook {
WorkSpace *active;
struct WorkSpaceLayout *act_layout;
- /* Needed because we can't change workspaces/layouts in running handler loop,
+ /** Needed because we can't change workspaces/layouts in running handler loop,
* it would break context. */
WorkSpace *temp_workspace_store;
struct WorkSpaceLayout *temp_layout_store;
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index a1771693005..5143f667083 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -114,8 +114,8 @@ enum {
/* flag */
#define WO_DS_EXPAND (1 << 0)
/* NOTE: this must have the same value as MA_DS_SHOW_TEXS,
- * otherwise anim-editors will not read correctly
- */
+ * otherwise anim-editors will not read correctly
+ */
#define WO_DS_SHOW_TEXS (1 << 2)
#endif
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index a5a98386347..178ef219c4d 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -23,8 +23,8 @@
add_definitions(-DWITH_DNA_GHASH)
blender_include_dirs(
- ../../../../intern/guardedalloc
../../../../intern/atomic
+ ../../../../intern/guardedalloc
../../blenlib
..
)
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index e8af1cbf36e..ad0765a58de 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -94,37 +94,38 @@
* structs. Only needed to keep a file short though...
*
* ALLOWED AND TESTED CHANGES IN STRUCTS:
- * - type change (a char to float will be divided by 255)
- * - location within a struct (everything can be randomly mixed up)
- * - struct within struct (within struct etc), this is recursive
- * - adding new elements, will be default initialized zero
- * - removing elements
- * - change of array sizes
- * - change of a pointer type: when the name doesn't change the contents is copied
+ * - Type change (a char to float will be divided by 255).
+ * - Location within a struct (everything can be randomly mixed up).
+ * - Struct within struct (within struct etc), this is recursive.
+ * - Adding new elements, will be default initialized zero.
+ * - Removing elements.
+ * - Change of array sizes.
+ * - Change of a pointer type: when the name doesn't change the contents is copied.
*
* NOT YET:
- * - array (``vec[3]``) to float struct (``vec3f``)
+ * - array (``vec[3]``) to float struct (``vec3f``).
*
* DONE:
- * - endian compatibility
- * - pointer conversion (32-64 bits)
+ * - Endian compatibility.
+ * - Pointer conversion (32-64 bits).
*
* IMPORTANT:
- * - do not use #defines in structs for array lengths, this cannot be read by the dna functions
- * - do not use uint, but unsigned int instead, ushort and ulong are allowed
- * - only use a long in Blender if you want this to be the size of a pointer. so it is
- * 32 bits or 64 bits, dependent at the cpu architecture
- * - chars are always unsigned
- * - alignment of variables has to be done in such a way, that any system does
+ * - Do not use #defines in structs for array lengths, this cannot be read by the dna functions.
+ * - Do not use uint, but unsigned int instead, ushort and ulong are allowed.
+ * - Only use a long in Blender if you want this to be the size of a pointer. so it is
+ * 32 bits or 64 bits, dependent at the cpu architecture.
+ * - Chars are always unsigned
+ * - Alignment of variables has to be done in such a way, that any system does
* not create 'padding' (gaps) in structures. So make sure that:
- * - short: 2 aligned
- * - int: 4 aligned
- * - float: 4 aligned
- * - double: 8 aligned
- * - long: 8 aligned
- * - int64: 8 aligned
- * - struct: 8 aligned
- * - the sdna functions have several error prints builtin, always check blender running from a console.
+ * - short: 2 aligned.
+ * - int: 4 aligned.
+ * - float: 4 aligned.
+ * - double: 8 aligned.
+ * - long: 8 aligned.
+ * - int64: 8 aligned.
+ * - struct: 8 aligned.
+ * - the sdna functions have several error prints builtin,
+ * always check blender running from a console.
*/
#ifdef __BIG_ENDIAN__
@@ -543,7 +544,8 @@ SDNA *DNA_sdna_from_data(const void *data,
}
/**
- * Using globals is acceptable here, the data is read-only and only changes between Blender versions.
+ * Using globals is acceptable here,
+ * the data is read-only and only changes between Blender versions.
*
* So it is safe to create once and reuse.
*/
@@ -1499,7 +1501,8 @@ static bool DNA_sdna_patch_struct_member_nr(SDNA *sdna,
}
/**
* Replace \a elem_old with \a elem_new for struct \a struct_name
- * handles search & replace, maintaining surrounding non-identifier characters such as pointer & array size.
+ * handles search & replace, maintaining surrounding non-identifier characters
+ * such as pointer & array size.
*/
bool DNA_sdna_patch_struct_member(SDNA *sdna,
const char *struct_name,
diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h
index 3ae572f40cf..b9e0853b1ab 100644
--- a/source/blender/makesdna/intern/dna_rename_defs.h
+++ b/source/blender/makesdna/intern/dna_rename_defs.h
@@ -30,7 +30,8 @@
* - Changes here only change generated code for `makesdna.c` and `makesrna.c`
* without impacting Blender's run-time, besides allowing us to use the new names.
*
- * - Renaming something that has already been renamed can be done by editing the existing rename macro.
+ * - Renaming something that has already been renamed can be done
+ * by editing the existing rename macro.
* All references to the previous destination name can be removed since they're
* never written to disk.
*
@@ -57,6 +58,12 @@ DNA_STRUCT_RENAME(SpaceIpo, SpaceGraph)
DNA_STRUCT_RENAME(SpaceOops, SpaceOutliner)
DNA_STRUCT_RENAME_ELEM(BPoint, alfa, tilt)
DNA_STRUCT_RENAME_ELEM(BezTriple, alfa, tilt)
+DNA_STRUCT_RENAME_ELEM(Bone, scaleIn, scale_in_x)
+DNA_STRUCT_RENAME_ELEM(Bone, scaleOut, scale_out_x)
+DNA_STRUCT_RENAME_ELEM(Bone, curveInX, curve_in_x)
+DNA_STRUCT_RENAME_ELEM(Bone, curveInY, curve_in_y)
+DNA_STRUCT_RENAME_ELEM(Bone, curveOutX, curve_out_x)
+DNA_STRUCT_RENAME_ELEM(Bone, curveOutY, curve_out_y)
DNA_STRUCT_RENAME_ELEM(Camera, YF_dofdist, dof_distance)
DNA_STRUCT_RENAME_ELEM(Camera, clipend, clip_end)
DNA_STRUCT_RENAME_ELEM(Camera, clipsta, clip_start)
@@ -70,6 +77,12 @@ DNA_STRUCT_RENAME_ELEM(ParticleSettings, dup_ob, instance_object)
DNA_STRUCT_RENAME_ELEM(ParticleSettings, dupliweights, instance_weights)
DNA_STRUCT_RENAME_ELEM(View3D, far, clip_end)
DNA_STRUCT_RENAME_ELEM(View3D, near, clip_start)
+DNA_STRUCT_RENAME_ELEM(bPoseChannel, scaleIn, scale_in_x)
+DNA_STRUCT_RENAME_ELEM(bPoseChannel, scaleOut, scale_out_x)
+DNA_STRUCT_RENAME_ELEM(bPoseChannel, curveInX, curve_in_x)
+DNA_STRUCT_RENAME_ELEM(bPoseChannel, curveInY, curve_in_y)
+DNA_STRUCT_RENAME_ELEM(bPoseChannel, curveOutX, curve_out_x)
+DNA_STRUCT_RENAME_ELEM(bPoseChannel, curveOutY, curve_out_y)
DNA_STRUCT_RENAME_ELEM(bTheme, tact, space_action)
DNA_STRUCT_RENAME_ELEM(bTheme, tbuts, space_properties)
DNA_STRUCT_RENAME_ELEM(bTheme, tclip, space_clip)
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index fa7ead3cd96..0ea1ca9c018 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -61,9 +61,8 @@
/* Included the path relative from /source/blender/ here, so we can move */
/* headers around with more freedom. */
static const char *includefiles[] = {
-
/* if you add files here, please add them at the end
- * of makesdna.c (this file) as well */
+ * of makesdna.c (this file) as well */
"DNA_listBase.h",
"DNA_vec_types.h",
"DNA_ID.h",
@@ -466,7 +465,7 @@ static int add_name(const char *str)
}
else if (str[j] == ')') {
DEBUG_PRINTF(3, "offsetting for brace\n");
- ; /* don't get extra offset */
+ /* don't get extra offset */
}
else {
printf("Error during tokening function pointer argument list\n");
@@ -588,8 +587,9 @@ static int preprocess_include(char *maindata, const int maindata_len)
else if (*cp == '\n') {
comment = 0;
}
- if (comment || *cp < 32 || *cp > 128)
+ if (comment || *cp < 32 || *cp > 128) {
*cp = 32;
+ }
cp++;
}
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 33ff3f43c07..a7b111d49da 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1409,7 +1409,8 @@ void _RNA_warning(const char *format, ...) ATTR_PRINTF_FORMAT(1, 2);
/* Equals test. */
-/* Note: In practice, EQ_STRICT and EQ_COMPARE have same behavior currently, and will yield same result. */
+/* Note: In practice, EQ_STRICT and EQ_COMPARE have same behavior currently,
+ * and will yield same result. */
typedef enum eRNACompareMode {
/* Only care about equality, not full comparison. */
RNA_EQ_STRICT, /* set/unset ignored */
@@ -1445,7 +1446,8 @@ typedef enum eRNAOverrideMatch {
} eRNAOverrideMatch;
typedef enum eRNAOverrideMatchResult {
- /* Some new property overrides were created to take into account differences between local and reference. */
+ /* Some new property overrides were created to take into account
+ * differences between local and reference. */
RNA_OVERRIDE_MATCH_RESULT_CREATED = 1 << 0,
/* Some properties were reset to reference values. */
RNA_OVERRIDE_MATCH_RESULT_RESTORED = 1 << 1,
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 706f1ca9e84..59c03cf34b3 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -262,8 +262,18 @@ PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont,
float softmin,
float softmax);
-//PropertyRNA *RNA_def_float_dynamic_array(StructOrFunctionRNA *cont, const char *identifier, float hardmin, float hardmax,
-// const char *ui_name, const char *ui_description, float softmin, float softmax, unsigned int dimension, unsigned short dim_size[]);
+#if 0
+PropertyRNA *RNA_def_float_dynamic_array(StructOrFunctionRNA *cont,
+ const char *identifier,
+ float hardmin,
+ float hardmax,
+ const char *ui_name,
+ const char *ui_description,
+ float softmin,
+ float softmax,
+ unsigned int dimension,
+ unsigned short dim_size[]);
+#endif
PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont,
const char *identifier,
diff --git a/source/blender/makesrna/RNA_documentation.h b/source/blender/makesrna/RNA_documentation.h
index 7999c45f758..cf1cf5fa50e 100644
--- a/source/blender/makesrna/RNA_documentation.h
+++ b/source/blender/makesrna/RNA_documentation.h
@@ -18,5 +18,6 @@
* \ingroup RNA
* \page makesrna makesrna
* \section aboutmakesrna About RNA
- * The \ref RNA module defines and provides the access API to the data, thus encapsulating \ref DNA
+ * The \ref RNA module defines and provides the access API to the data,
+ * thus encapsulating \ref DNA
*/
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 95d3aee634f..119186ff748 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -44,7 +44,6 @@ extern const EnumPropertyItem rna_enum_metaelem_type_items[];
extern const EnumPropertyItem rna_enum_proportional_falloff_items[];
extern const EnumPropertyItem rna_enum_proportional_falloff_curve_only_items[];
-extern const EnumPropertyItem rna_enum_proportional_editing_items[];
extern const EnumPropertyItem rna_enum_snap_target_items[];
extern const EnumPropertyItem rna_enum_snap_element_items[];
extern const EnumPropertyItem rna_enum_snap_node_element_items[];
@@ -115,6 +114,7 @@ extern const EnumPropertyItem rna_enum_operator_return_items[];
extern const EnumPropertyItem rna_enum_operator_property_tags[];
extern const EnumPropertyItem rna_enum_brush_sculpt_tool_items[];
+extern const EnumPropertyItem rna_enum_brush_uv_sculpt_tool_items[];
extern const EnumPropertyItem rna_enum_brush_vertex_tool_items[];
extern const EnumPropertyItem rna_enum_brush_weight_tool_items[];
extern const EnumPropertyItem rna_enum_brush_gpencil_types_items[];
@@ -248,7 +248,12 @@ const EnumPropertyItem *RNA_action_itemf(struct bContext *C,
struct PointerRNA *ptr,
struct PropertyRNA *prop,
bool *r_free);
-// EnumPropertyItem *RNA_action_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
+#if 0
+EnumPropertyItem *RNA_action_local_itemf(struct bContext *C,
+ struct PointerRNA *ptr,
+ struct PropertyRNA *prop,
+ bool *r_free);
+#endif
const EnumPropertyItem *RNA_collection_itemf(struct bContext *C,
struct PointerRNA *ptr,
struct PropertyRNA *prop,
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 961b4b23073..1cc7d772ecc 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -201,19 +201,25 @@ typedef enum PropertyFlag {
* only apply this to types that are derived from an ID ()*/
PROP_ID_SELF_CHECK = (1 << 20),
/* use for...
- * - pointers: in the UI and python so unsetting or setting to None won't work
- * - strings: so our internal generated get/length/set functions know to do NULL checks before access [#30865] */
+ * - pointers: in the UI and python so unsetting or setting to None won't work.
+ * - strings: so our internal generated get/length/set
+ * functions know to do NULL checks before access T30865.
+ */
PROP_NEVER_NULL = (1 << 18),
/* currently only used for UI, this is similar to PROP_NEVER_NULL
* except that the value may be NULL at times, used for ObData, where an Empty's will be NULL
- * but setting NULL on a mesh object is not possible. So, if its not NULL, setting NULL cant be done! */
+ * but setting NULL on a mesh object is not possible.
+ * So, if its not NULL, setting NULL cant be done!
+ */
PROP_NEVER_UNLINK = (1 << 25),
/* Pointers to data that is not owned by the struct.
* Typical example: Bone.parent, Bone.child, etc., and nearly all ID pointers.
- * This is crucial information for processes that walk the whole data of an ID e.g. (like static override).
- * Note that all ID pointers are enforced to this by default, this probably will need to be rechecked
- * (see ugly infamous NodeTrees of mat/tex/scene/etc.). */
+ * This is crucial information for processes that walk the whole data of an ID e.g.
+ * (like static override).
+ * Note that all ID pointers are enforced to this by default,
+ * this probably will need to be rechecked (see ugly infamous NodeTrees of mat/tex/scene/etc.).
+ */
PROP_PTR_NO_OWNERSHIP = (1 << 7),
/* flag contains multiple enums.
@@ -248,7 +254,8 @@ typedef enum PropertyFlag {
PROP_NO_DEG_UPDATE = (1 << 30),
} PropertyFlag;
-/* Flags related to comparing and overriding RNA properties. Make sure enums are updated with these */
+/* Flags related to comparing and overriding RNA properties.
+ * Make sure enums are updated with these */
/* FREE FLAGS: 2, 3, 4, 5, 6, 7, 8, 9, 12 and above. */
typedef enum PropertyOverrideFlag {
/* Means the property can be overridden by a local 'proxy' of some linked datablock. */
@@ -275,7 +282,8 @@ typedef enum ParameterFlag {
PARM_REQUIRED = (1 << 0),
PARM_OUTPUT = (1 << 1),
PARM_RNAPTR = (1 << 2),
- /* This allows for non-breaking API updates, when adding non-critical new parameter to a callback function.
+ /* This allows for non-breaking API updates,
+ * when adding non-critical new parameter to a callback function.
* This way, old py code defining funcs without that parameter would still work.
* WARNING: any parameter after the first PYFUNC_OPTIONAL one will be considered as optional!
* NOTE: only for input parameters!
@@ -295,16 +303,20 @@ typedef struct ListBaseIterator {
typedef struct ArrayIterator {
char *ptr;
- char *endptr; /* past the last valid pointer, only for comparisons, ignores skipped values */
- void *free_ptr; /* will be freed if set */
+ /* Past the last valid pointer, only for comparisons, ignores skipped values. */
+ char *endptr;
+ /* Will be freed if set. */
+ void *free_ptr;
int itemsize;
- /* array length with no skip functions applied, take care not to compare against index from animsys
- * or python indices */
+ /* Array length with no skip functions applied,
+ * take care not to compare against index from animsys or python indices. */
int length;
- /* optional skip function, when set the array as viewed by rna can contain only a subset of the members.
- * this changes indices so quick array index lookups are not possible when skip function is used. */
+ /* Optional skip function,
+ * when set the array as viewed by rna can contain only a subset of the members.
+ * this changes indices so quick array index lookups are not possible when skip function is used.
+ */
IteratorSkipFunc skip;
} ArrayIterator;
@@ -476,10 +488,12 @@ typedef enum FunctionFlag {
* [ReportList *reports],
* <other RNA-defined parameters>);
*/
- /* Pass ID owning 'self' data (i.e. ptr->id.data, might be same as self in case data is an ID...). */
+ /* Pass ID owning 'self' data
+ * (i.e. ptr->id.data, might be same as self in case data is an ID...). */
FUNC_USE_SELF_ID = (1 << 11),
- /* Do not pass the object (DNA struct pointer) from which it is called, used to define static or class functions. */
+ /* Do not pass the object (DNA struct pointer) from which it is called,
+ * used to define static or class functions. */
FUNC_NO_SELF = (1 << 0),
/* Pass RNA type, used to define class functions, only valid when FUNC_NO_SELF is set. */
FUNC_USE_SELF_TYPE = (1 << 1),
@@ -490,11 +504,13 @@ typedef enum FunctionFlag {
FUNC_USE_REPORTS = (1 << 4),
/***** Registering of python subclasses. *****/
- /* This function is part of the registerable class' interface, and can be implemented/redefined in python. */
+ /* This function is part of the registerable class' interface,
+ * and can be implemented/redefined in python. */
FUNC_REGISTER = (1 << 5),
/* Subclasses can choose not to implement this function. */
FUNC_REGISTER_OPTIONAL = FUNC_REGISTER | (1 << 6),
- /* If not set, the python function implementing this call is not allowed to write into data-blocks.
+ /* If not set, the python function implementing this call
+ * is not allowed to write into data-blocks.
* Except for WindowManager and Screen currently, see rna_id_write_error() in bpy_rna.c */
FUNC_ALLOW_WRITE = (1 << 12),
@@ -505,7 +521,8 @@ typedef enum FunctionFlag {
FUNC_EXPORT = (1 << 8),
/* Function has been defined at runtime, not statically in RNA source code. */
FUNC_RUNTIME = (1 << 9),
- /* UNUSED CURRENTLY? Function owns its identifier and description strings, and has to free them when deleted. */
+ /* UNUSED CURRENTLY? Function owns its identifier and description strings,
+ * and has to free them when deleted. */
FUNC_FREE_POINTERS = (1 << 10),
} FunctionFlag;
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index eae47469f10..7c31f078b6d 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -320,13 +320,13 @@ blender_include_dirs(
../../blenfont
../../blenkernel
../../blenlib
- ../../bmesh
../../blentranslation
+ ../../bmesh
../../depsgraph
../../draw
../../gpu
- ../../imbuf
../../ikplugin
+ ../../imbuf
../../makesdna
../../nodes/
../../physics
@@ -334,9 +334,9 @@ blender_include_dirs(
../../editors/include
../../render/extern/include
../../../../intern/cycles/blender
- ../../../../intern/guardedalloc
- ../../../../intern/glew-mx
../../../../intern/atomic
+ ../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
../../../../intern/memutil
../../../../intern/smoke/extern
)
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 30b21e131ed..3e948e2d712 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -73,10 +73,12 @@ static int file_older(const char *file1, const char *file2)
printf("compare: %s %s\n", file1, file2);
}
- if (stat(file1, &st1))
+ if (stat(file1, &st1)) {
return 0;
- if (stat(file2, &st2))
+ }
+ if (stat(file2, &st2)) {
return 0;
+ }
return (st1.st_mtime < st2.st_mtime);
}
@@ -243,12 +245,15 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[])
static const char *rna_safe_id(const char *id)
{
- if (STREQ(id, "default"))
+ if (STREQ(id, "default")) {
return "default_value";
- else if (STREQ(id, "operator"))
+ }
+ else if (STREQ(id, "operator")) {
return "operator_value";
- else if (STREQ(id, "new"))
+ }
+ else if (STREQ(id, "new")) {
return "create";
+ }
else if (STREQ(id, "co_return")) {
/* MSVC2015, C++ uses for coroutines */
return "coord_return";
@@ -272,15 +277,19 @@ static int cmp_property(const void *a, const void *b)
const PropertyRNA *propa = *(const PropertyRNA **)a;
const PropertyRNA *propb = *(const PropertyRNA **)b;
- if (STREQ(propa->identifier, "rna_type"))
+ if (STREQ(propa->identifier, "rna_type")) {
return -1;
- else if (STREQ(propb->identifier, "rna_type"))
+ }
+ else if (STREQ(propb->identifier, "rna_type")) {
return 1;
+ }
- if (STREQ(propa->identifier, "name"))
+ if (STREQ(propa->identifier, "name")) {
return -1;
- else if (STREQ(propb->identifier, "name"))
+ }
+ else if (STREQ(propb->identifier, "name")) {
return 1;
+ }
return strcmp(propa->name, propb->name);
}
@@ -307,15 +316,18 @@ static void rna_sortlist(ListBase *listbase, int (*cmp)(const void *, const void
void **array;
int a, size;
- if (listbase->first == listbase->last)
+ if (listbase->first == listbase->last) {
return;
+ }
- for (size = 0, link = listbase->first; link; link = link->next)
+ for (size = 0, link = listbase->first; link; link = link->next) {
size++;
+ }
array = MEM_mallocN(sizeof(void *) * size, "rna_sortlist");
- for (a = 0, link = listbase->first; link; link = link->next, a++)
+ for (a = 0, link = listbase->first; link; link = link->next, a++) {
array[a] = link;
+ }
qsort(array, size, sizeof(void *), cmp);
@@ -344,29 +356,35 @@ static void rna_print_c_string(FILE *f, const char *str)
fprintf(f, "\"");
for (i = 0; str[i]; i++) {
- for (j = 0; escape[j]; j++)
- if (str[i] == escape[j][0])
+ for (j = 0; escape[j]; j++) {
+ if (str[i] == escape[j][0]) {
break;
+ }
+ }
- if (escape[j])
+ if (escape[j]) {
fprintf(f, "\\%c", escape[j][1]);
- else
+ }
+ else {
fprintf(f, "%c", str[i]);
+ }
}
fprintf(f, "\"");
}
static void rna_print_data_get(FILE *f, PropertyDefRNA *dp)
{
- if (dp->dnastructfromname && dp->dnastructfromprop)
+ if (dp->dnastructfromname && dp->dnastructfromprop) {
fprintf(f,
" %s *data = (%s *)(((%s *)ptr->data)->%s);\n",
dp->dnastructname,
dp->dnastructname,
dp->dnastructfromname,
dp->dnastructfromprop);
- else
+ }
+ else {
fprintf(f, " %s *data = (%s *)(ptr->data);\n", dp->dnastructname, dp->dnastructname);
+ }
}
static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp))
@@ -383,10 +401,12 @@ static void rna_construct_function_name(
static void rna_construct_wrapper_function_name(
char *buffer, int size, const char *structname, const char *propname, const char *type)
{
- if (type == NULL || type[0] == '\0')
+ if (type == NULL || type[0] == '\0') {
snprintf(buffer, size, "%s_%s", structname, propname);
- else
+ }
+ else {
snprintf(buffer, size, "%s_%s_%s", structname, propname, type);
+ }
}
static char *rna_alloc_function_name(const char *structname,
@@ -412,9 +432,11 @@ static StructRNA *rna_find_struct(const char *identifier)
{
StructDefRNA *ds;
- for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
- if (STREQ(ds->srna->identifier, identifier))
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ if (STREQ(ds->srna->identifier, identifier)) {
return ds->srna;
+ }
+ }
return NULL;
}
@@ -423,9 +445,11 @@ static const char *rna_find_type(const char *type)
{
StructDefRNA *ds;
- for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
- if (ds->dnaname && STREQ(ds->dnaname, type))
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ if (ds->dnaname && STREQ(ds->dnaname, type)) {
return ds->srna->identifier;
+ }
+ }
return NULL;
}
@@ -434,9 +458,11 @@ static const char *rna_find_dna_type(const char *type)
{
StructDefRNA *ds;
- for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
- if (STREQ(ds->srna->identifier, type))
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ if (STREQ(ds->srna->identifier, type)) {
return ds->dnaname;
+ }
+ }
return NULL;
}
@@ -469,8 +495,9 @@ static const char *rna_type_type(PropertyRNA *prop)
type = rna_type_type_name(prop);
- if (type)
+ if (type) {
return type;
+ }
return "PointerRNA";
}
@@ -481,8 +508,9 @@ static const char *rna_type_struct(PropertyRNA *prop)
type = rna_type_type_name(prop);
- if (type)
+ if (type) {
return "";
+ }
return "struct ";
}
@@ -493,17 +521,20 @@ static const char *rna_parameter_type_name(PropertyRNA *parm)
type = rna_type_type_name(parm);
- if (type)
+ if (type) {
return type;
+ }
switch (parm->type) {
case PROP_POINTER: {
PointerPropertyRNA *pparm = (PointerPropertyRNA *)parm;
- if (parm->flag_parameter & PARM_RNAPTR)
+ if (parm->flag_parameter & PARM_RNAPTR) {
return "PointerRNA";
- else
+ }
+ else {
return rna_find_dna_type((const char *)pparm->type);
+ }
}
case PROP_COLLECTION: {
return "CollectionListBase";
@@ -519,9 +550,11 @@ static int rna_enum_bitmask(PropertyRNA *prop)
int a, mask = 0;
if (eprop->item) {
- for (a = 0; a < eprop->totitem; a++)
- if (eprop->item[a].identifier[0])
+ for (a = 0; a < eprop->totitem; a++) {
+ if (eprop->item[a].identifier[0]) {
mask |= eprop->item[a].value;
+ }
+ }
}
return mask;
@@ -541,24 +574,31 @@ static const char *rna_function_string(void *func)
static void rna_float_print(FILE *f, float num)
{
- if (num == -FLT_MAX)
+ if (num == -FLT_MAX) {
fprintf(f, "-FLT_MAX");
- else if (num == FLT_MAX)
+ }
+ else if (num == FLT_MAX) {
fprintf(f, "FLT_MAX");
- else if ((ABS(num) < INT64_MAX) && ((int64_t)num == num))
+ }
+ else if ((ABS(num) < INT64_MAX) && ((int64_t)num == num)) {
fprintf(f, "%.1ff", num);
- else
+ }
+ else {
fprintf(f, "%.10ff", num);
+ }
}
static void rna_int_print(FILE *f, int num)
{
- if (num == INT_MIN)
+ if (num == INT_MIN) {
fprintf(f, "INT_MIN");
- else if (num == INT_MAX)
+ }
+ else if (num == INT_MAX) {
fprintf(f, "INT_MAX");
- else
+ }
+ else {
fprintf(f, "%d", num);
+ }
}
static char *rna_def_property_get_func(
@@ -566,8 +606,9 @@ static char *rna_def_property_get_func(
{
char *func;
- if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
+ if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) {
return NULL;
+ }
if (!manualfunc) {
if (!dp->dnastructname || !dp->dnaname) {
@@ -635,18 +676,20 @@ static char *rna_def_property_get_func(
fprintf(f, " }\n");
}
- if (sprop->maxlength)
+ if (sprop->maxlength) {
fprintf(f,
" %s(value, data->%s, %d);\n",
string_copy_func,
dp->dnaname,
sprop->maxlength);
- else
+ }
+ else {
fprintf(f,
" %s(value, data->%s, sizeof(data->%s));\n",
string_copy_func,
dp->dnaname,
dp->dnaname);
+ }
}
fprintf(f, "}\n\n");
break;
@@ -660,16 +703,18 @@ static char *rna_def_property_get_func(
else {
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
rna_print_data_get(f, dp);
- if (dp->dnapointerlevel == 0)
+ if (dp->dnapointerlevel == 0) {
fprintf(f,
" return rna_pointer_inherit_refine(ptr, &RNA_%s, &data->%s);\n",
(const char *)pprop->type,
dp->dnaname);
- else
+ }
+ else {
fprintf(f,
" return rna_pointer_inherit_refine(ptr, &RNA_%s, data->%s);\n",
(const char *)pprop->type,
dp->dnaname);
+ }
}
fprintf(f, "}\n\n");
break;
@@ -697,14 +742,16 @@ static char *rna_def_property_get_func(
}
default:
if (prop->arraydimension) {
- if (prop->flag & PROP_DYNAMIC)
+ if (prop->flag & PROP_DYNAMIC) {
fprintf(f, "void %s(PointerRNA *ptr, %s values[])\n", func, rna_type_type(prop));
- else
+ }
+ else {
fprintf(f,
"void %s(PointerRNA *ptr, %s values[%u])\n",
func,
rna_type_type(prop),
prop->totarraylength);
+ }
fprintf(f, "{\n");
if (manualfunc) {
@@ -798,12 +845,13 @@ static char *rna_def_property_get_func(
rna_int_print(f, rna_enum_bitmask(prop));
fprintf(f, ");\n");
}
- else
+ else {
fprintf(f,
" return (%s)%s(data->%s);\n",
rna_type_type(prop),
(dp->booleannegative) ? "!" : "",
dp->dnaname);
+ }
}
fprintf(f, "}\n\n");
@@ -870,10 +918,12 @@ static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array)
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
if (iprop->hardmin != INT_MIN || iprop->hardmax != INT_MAX || iprop->range) {
- if (array)
+ if (array) {
fprintf(f, "CLAMPIS(values[i], ");
- else
+ }
+ else {
fprintf(f, "CLAMPIS(value, ");
+ }
if (iprop->range) {
fprintf(f, "prop_clamp_min, prop_clamp_max);");
}
@@ -890,10 +940,12 @@ static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array)
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
if (fprop->hardmin != -FLT_MAX || fprop->hardmax != FLT_MAX || fprop->range) {
- if (array)
+ if (array) {
fprintf(f, "CLAMPIS(values[i], ");
- else
+ }
+ else {
fprintf(f, "CLAMPIS(value, ");
+ }
if (fprop->range) {
fprintf(f, "prop_clamp_min, prop_clamp_max);");
}
@@ -907,10 +959,12 @@ static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array)
}
}
- if (array)
+ if (array) {
fprintf(f, "values[i];\n");
- else
+ }
+ else {
fprintf(f, "value;\n");
+ }
}
static char *rna_def_property_set_func(
@@ -918,10 +972,12 @@ static char *rna_def_property_set_func(
{
char *func;
- if (!(prop->flag & PROP_EDITABLE))
+ if (!(prop->flag & PROP_EDITABLE)) {
return NULL;
- if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
+ }
+ if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) {
return NULL;
+ }
if (!manualfunc) {
if (!dp->dnastructname || !dp->dnaname) {
@@ -958,18 +1014,20 @@ static char *rna_def_property_set_func(
fprintf(f, " }\n");
}
- if (sprop->maxlength)
+ if (sprop->maxlength) {
fprintf(f,
" %s(data->%s, value, %d);\n",
string_copy_func,
dp->dnaname,
sprop->maxlength);
- else
+ }
+ else {
fprintf(f,
" %s(data->%s, value, sizeof(data->%s));\n",
string_copy_func,
dp->dnaname,
dp->dnaname);
+ }
}
fprintf(f, "}\n\n");
break;
@@ -1010,14 +1068,16 @@ static char *rna_def_property_set_func(
}
default:
if (prop->arraydimension) {
- if (prop->flag & PROP_DYNAMIC)
+ if (prop->flag & PROP_DYNAMIC) {
fprintf(f, "void %s(PointerRNA *ptr, const %s values[])\n", func, rna_type_type(prop));
- else
+ }
+ else {
fprintf(f,
"void %s(PointerRNA *ptr, const %s values[%u])\n",
func,
rna_type_type(prop),
prop->totarraylength);
+ }
fprintf(f, "{\n");
if (manualfunc) {
@@ -1073,17 +1133,19 @@ static char *rna_def_property_set_func(
f, " data->%s[i] = unit_float_to_uchar_clamp(values[i]);\n", dp->dnaname);
}
else {
- if (dp->dnatype)
+ if (dp->dnatype) {
fprintf(f,
" ((%s *)data->%s)[i] = %s",
dp->dnatype,
dp->dnaname,
(dp->booleannegative) ? "!" : "");
- else
+ }
+ else {
fprintf(f,
" (data->%s)[i] = %s",
dp->dnaname,
(dp->booleannegative) ? "!" : "");
+ }
rna_clamp_value(f, prop, 1);
}
}
@@ -1153,8 +1215,9 @@ static char *rna_def_property_length_func(
{
char *func = NULL;
- if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
+ if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) {
return NULL;
+ }
if (prop->type == PROP_STRING) {
if (!manualfunc) {
@@ -1199,18 +1262,23 @@ static char *rna_def_property_length_func(
fprintf(f, " return %s(ptr);\n", manualfunc);
}
else {
- if (dp->dnaarraylength <= 1 || dp->dnalengthname)
+ if (dp->dnaarraylength <= 1 || dp->dnalengthname) {
rna_print_data_get(f, dp);
+ }
- if (dp->dnaarraylength > 1)
+ if (dp->dnaarraylength > 1) {
fprintf(f, " return ");
- else
+ }
+ else {
fprintf(f, " return (data->%s == NULL) ? 0 : ", dp->dnaname);
+ }
- if (dp->dnalengthname)
+ if (dp->dnalengthname) {
fprintf(f, "data->%s;\n", dp->dnalengthname);
- else
+ }
+ else {
fprintf(f, "%d;\n", dp->dnalengthfixed);
+ }
}
fprintf(f, "}\n\n");
}
@@ -1223,8 +1291,9 @@ static char *rna_def_property_begin_func(
{
char *func, *getfunc;
- if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
+ if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) {
return NULL;
+ }
if (!manualfunc) {
if (!dp->dnastructname || !dp->dnaname) {
@@ -1239,8 +1308,9 @@ static char *rna_def_property_begin_func(
fprintf(f, "void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
fprintf(f, "{\n");
- if (!manualfunc)
+ if (!manualfunc) {
rna_print_data_get(f, dp);
+ }
fprintf(f, "\n memset(iter, 0, sizeof(*iter));\n");
fprintf(f, " iter->parent = *ptr;\n");
@@ -1251,29 +1321,34 @@ static char *rna_def_property_begin_func(
fprintf(f, "\n %s(iter, ptr);\n", manualfunc);
}
else {
- if (dp->dnalengthname)
+ if (dp->dnalengthname) {
fprintf(f,
"\n rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), data->%s, 0, "
"NULL);\n",
dp->dnaname,
dp->dnaname,
dp->dnalengthname);
- else
+ }
+ else {
fprintf(
f,
"\n rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), %d, 0, NULL);\n",
dp->dnaname,
dp->dnaname,
dp->dnalengthfixed);
+ }
}
}
else {
- if (manualfunc)
+ if (manualfunc) {
fprintf(f, "\n %s(iter, ptr);\n", manualfunc);
- else if (dp->dnapointerlevel == 0)
+ }
+ else if (dp->dnapointerlevel == 0) {
fprintf(f, "\n rna_iterator_listbase_begin(iter, &data->%s, NULL);\n", dp->dnaname);
- else
+ }
+ else {
fprintf(f, "\n rna_iterator_listbase_begin(iter, data->%s, NULL);\n", dp->dnaname);
+ }
}
getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
@@ -1297,20 +1372,23 @@ static char *rna_def_property_lookup_int_func(FILE *f,
* so the index can only be checked against the length when there is no 'skip' function. */
char *func;
- if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
+ if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) {
return NULL;
+ }
if (!manualfunc) {
- if (!dp->dnastructname || !dp->dnaname)
+ if (!dp->dnastructname || !dp->dnaname) {
return NULL;
+ }
/* only supported in case of standard next functions */
if (STREQ(nextfunc, "rna_iterator_array_next")) {
}
else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {
}
- else
+ else {
return NULL;
+ }
}
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_int");
@@ -1382,18 +1460,33 @@ static char *rna_def_property_lookup_int_func(FILE *f,
if (dp->dnalengthname || dp->dnalengthfixed) {
if (dp->dnalengthname)
- fprintf(f, "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), data->%s, index);\n",
- item_type, dp->dnaname, dp->dnaname, dp->dnalengthname);
+ fprintf(f,
+ "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), data->%s, "
+ "index);\n",
+ item_type,
+ dp->dnaname,
+ dp->dnaname,
+ dp->dnalengthname);
else
- fprintf(f, "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), %d, index);\n",
- item_type, dp->dnaname, dp->dnaname, dp->dnalengthfixed);
+ fprintf(
+ f,
+ "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), %d, index);\n",
+ item_type,
+ dp->dnaname,
+ dp->dnaname,
+ dp->dnalengthfixed);
}
else {
if (dp->dnapointerlevel == 0)
- fprintf(f, "\n return rna_listbase_lookup_int(ptr, &RNA_%s, &data->%s, index);\n",
- item_type, dp->dnaname);
+ fprintf(f,
+ "\n return rna_listbase_lookup_int(ptr, &RNA_%s, &data->%s, index);\n",
+ item_type,
+ dp->dnaname);
else
- fprintf(f, "\n return rna_listbase_lookup_int(ptr, &RNA_%s, data->%s, index);\n", item_type, dp->dnaname);
+ fprintf(f,
+ "\n return rna_listbase_lookup_int(ptr, &RNA_%s, data->%s, index);\n",
+ item_type,
+ dp->dnaname);
}
#endif
@@ -1414,23 +1507,27 @@ static char *rna_def_property_lookup_string_func(FILE *f,
PropertyRNA *item_name_prop;
const int namebuflen = 1024;
- if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
+ if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) {
return NULL;
+ }
if (!manualfunc) {
- if (!dp->dnastructname || !dp->dnaname)
+ if (!dp->dnastructname || !dp->dnaname) {
return NULL;
+ }
/* only supported for collection items with name properties */
item_srna = rna_find_struct(item_type);
if (item_srna && item_srna->nameproperty) {
item_name_prop = item_srna->nameproperty;
item_name_base = item_srna;
- while (item_name_base->base && item_name_base->base->nameproperty == item_name_prop)
+ while (item_name_base->base && item_name_base->base->nameproperty == item_name_prop) {
item_name_base = item_name_base->base;
+ }
}
- else
+ else {
return NULL;
+ }
}
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_string");
@@ -1515,11 +1612,13 @@ static char *rna_def_property_next_func(FILE *f,
{
char *func, *getfunc;
- if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
+ if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) {
return NULL;
+ }
- if (!manualfunc)
+ if (!manualfunc) {
return NULL;
+ }
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "next");
@@ -1545,15 +1644,17 @@ static char *rna_def_property_end_func(FILE *f,
{
char *func;
- if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
+ if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL) {
return NULL;
+ }
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "end");
fprintf(f, "void %s(CollectionPropertyIterator *iter)\n", func);
fprintf(f, "{\n");
- if (manualfunc)
+ if (manualfunc) {
fprintf(f, " %s(iter);\n", manualfunc);
+ }
fprintf(f, "}\n\n");
return func;
@@ -1561,10 +1662,12 @@ static char *rna_def_property_end_func(FILE *f,
static void rna_set_raw_property(PropertyDefRNA *dp, PropertyRNA *prop)
{
- if (dp->dnapointerlevel != 0)
+ if (dp->dnapointerlevel != 0) {
return;
- if (!dp->dnatype || !dp->dnaname || !dp->dnastructname)
+ }
+ if (!dp->dnatype || !dp->dnaname || !dp->dnastructname) {
return;
+ }
if (STREQ(dp->dnatype, "char")) {
prop->rawtype = PROP_RAW_CHAR;
@@ -1606,8 +1709,9 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
if (!prop->arraydimension) {
- if (!bprop->get && !bprop->set && !dp->booleanbit)
+ if (!bprop->get && !bprop->set && !dp->booleanbit) {
rna_set_raw_property(dp, prop);
+ }
bprop->get = (void *)rna_def_property_get_func(
f, srna, prop, dp, (const char *)bprop->get);
@@ -1626,8 +1730,9 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
if (!prop->arraydimension) {
- if (!iprop->get && !iprop->set)
+ if (!iprop->get && !iprop->set) {
rna_set_raw_property(dp, prop);
+ }
iprop->get = (void *)rna_def_property_get_func(
f, srna, prop, dp, (const char *)iprop->get);
@@ -1635,8 +1740,9 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
f, srna, prop, dp, (const char *)iprop->set);
}
else {
- if (!iprop->getarray && !iprop->setarray)
+ if (!iprop->getarray && !iprop->setarray) {
rna_set_raw_property(dp, prop);
+ }
iprop->getarray = (void *)rna_def_property_get_func(
f, srna, prop, dp, (const char *)iprop->getarray);
@@ -1649,8 +1755,9 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
if (!prop->arraydimension) {
- if (!fprop->get && !fprop->set)
+ if (!fprop->get && !fprop->set) {
rna_set_raw_property(dp, prop);
+ }
fprop->get = (void *)rna_def_property_get_func(
f, srna, prop, dp, (const char *)fprop->get);
@@ -1658,8 +1765,9 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
f, srna, prop, dp, (const char *)fprop->set);
}
else {
- if (!fprop->getarray && !fprop->setarray)
+ if (!fprop->getarray && !fprop->setarray) {
rna_set_raw_property(dp, prop);
+ }
fprop->getarray = (void *)rna_def_property_get_func(
f, srna, prop, dp, (const char *)fprop->getarray);
@@ -1716,11 +1824,12 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
/* test if we can allow raw array access, if it is using our standard
* array get/next function, we can be sure it is an actual array */
- if (cprop->next && cprop->get)
+ if (cprop->next && cprop->get) {
if (STREQ((const char *)cprop->next, "rna_iterator_array_next") &&
STREQ((const char *)cprop->get, "rna_iterator_array_get")) {
prop->flag_internal |= PROP_INTERN_RAW_ARRAY;
}
+ }
cprop->get = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)cprop->get);
cprop->begin = (void *)rna_def_property_begin_func(
@@ -1841,14 +1950,16 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
if (eprop->item && eprop->totitem) {
fprintf(f, "enum {\n");
- for (i = 0; i < eprop->totitem; i++)
- if (eprop->item[i].identifier[0])
+ for (i = 0; i < eprop->totitem; i++) {
+ if (eprop->item[i].identifier[0]) {
fprintf(f,
"\t%s_%s_%s = %d,\n",
srna->identifier,
prop->identifier,
eprop->item[i].identifier,
eprop->item[i].value);
+ }
+ }
fprintf(f, "};\n\n");
}
@@ -1882,14 +1993,17 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR
fprintf(f, "void %sbegin(CollectionPropertyIterator *iter, PointerRNA *ptr);\n", func);
fprintf(f, "void %snext(CollectionPropertyIterator *iter);\n", func);
fprintf(f, "void %send(CollectionPropertyIterator *iter);\n", func);
- if (cprop->length)
+ if (cprop->length) {
fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
- if (cprop->lookupint)
+ }
+ if (cprop->lookupint) {
fprintf(f, "int %slookup_int(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n", func);
- if (cprop->lookupstring)
+ }
+ if (cprop->lookupstring) {
fprintf(f,
"int %slookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n",
func);
+ }
break;
}
}
@@ -2005,13 +2119,15 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
if (eprop->item) {
fprintf(f, "\tenum %s_enum {\n", rna_safe_id(prop->identifier));
- for (i = 0; i < eprop->totitem; i++)
- if (eprop->item[i].identifier[0])
+ for (i = 0; i < eprop->totitem; i++) {
+ if (eprop->item[i].identifier[0]) {
fprintf(f,
"\t\t%s_%s = %d,\n",
rna_safe_id(prop->identifier),
eprop->item[i].identifier,
eprop->item[i].value);
+ }
+ }
fprintf(f, "\t};\n");
}
@@ -2034,11 +2150,13 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
case PROP_POINTER: {
PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
- if (pprop->type)
+ if (pprop->type) {
fprintf(
f, "\tinline %s %s(void);", (const char *)pprop->type, rna_safe_id(prop->identifier));
- else
+ }
+ else {
fprintf(f, "\tinline %s %s(void);", "UnknownType", rna_safe_id(prop->identifier));
+ }
break;
}
case PROP_COLLECTION: {
@@ -2050,7 +2168,7 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
collection_funcs = (char *)cprop->property.srna;
}
- if (cprop->item_type)
+ if (cprop->item_type) {
fprintf(f,
"\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)",
collection_funcs,
@@ -2060,7 +2178,8 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
(cprop->length ? "true" : "false"),
(cprop->lookupint ? "true" : "false"),
(cprop->lookupstring ? "true" : "false"));
- else
+ }
+ else {
fprintf(f,
"\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)",
collection_funcs,
@@ -2070,6 +2189,7 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property
(cprop->length ? "true" : "false"),
(cprop->lookupint ? "true" : "false"),
(cprop->lookupstring ? "true" : "false"));
+ }
break;
}
}
@@ -2107,10 +2227,12 @@ static void rna_def_struct_function_prototype_cpp(FILE *f,
retval_type = rna_parameter_type_cpp_name(dp->prop);
}
- if (namespace && namespace[0])
+ if (namespace && namespace[0]) {
fprintf(f, "\tinline %s %s::%s(", retval_type, namespace, rna_safe_id(func->identifier));
- else
+ }
+ else {
fprintf(f, "\tinline %s %s(", retval_type, rna_safe_id(func->identifier));
+ }
if (func->flag & FUNC_USE_MAIN)
WRITE_PARAM("void *main");
@@ -2122,37 +2244,45 @@ static void rna_def_struct_function_prototype_cpp(FILE *f,
int type, flag, flag_parameter, pout;
const char *ptrstr;
- if (dp->prop == func->c_ret)
+ if (dp->prop == func->c_ret) {
continue;
+ }
type = dp->prop->type;
flag = dp->prop->flag;
flag_parameter = dp->prop->flag_parameter;
pout = (flag_parameter & PARM_OUTPUT);
- if (flag & PROP_DYNAMIC)
+ if (flag & PROP_DYNAMIC) {
ptrstr = pout ? "**" : "*";
- else if (type == PROP_POINTER)
+ }
+ else if (type == PROP_POINTER) {
ptrstr = pout ? "*" : "";
- else if (dp->prop->arraydimension)
+ }
+ else if (dp->prop->arraydimension) {
ptrstr = "*";
- else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
+ }
+ else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
ptrstr = "";
- else
+ }
+ else {
ptrstr = pout ? "*" : "";
+ }
WRITE_COMMA;
- if (flag & PROP_DYNAMIC)
+ if (flag & PROP_DYNAMIC) {
fprintf(
f, "int %s%s_len, ", (flag_parameter & PARM_OUTPUT) ? "*" : "", dp->prop->identifier);
+ }
- if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension)
+ if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension) {
fprintf(f,
"%s %s[%u]",
rna_parameter_type_cpp_name(dp->prop),
rna_safe_id(dp->prop->identifier),
dp->prop->totarraylength);
+ }
else {
fprintf(f,
"%s%s%s%s",
@@ -2164,8 +2294,9 @@ static void rna_def_struct_function_prototype_cpp(FILE *f,
}
fprintf(f, ")");
- if (close_prototype)
+ if (close_prototype) {
fprintf(f, ";\n");
+ }
}
static void rna_def_struct_function_header_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
@@ -2193,51 +2324,60 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
switch (prop->type) {
case PROP_BOOLEAN: {
- if (!prop->arraydimension)
+ if (!prop->arraydimension) {
fprintf(f, "\tBOOLEAN_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
- else if (prop->totarraylength)
+ }
+ else if (prop->totarraylength) {
fprintf(f,
"\tBOOLEAN_ARRAY_PROPERTY(%s, %u, %s)",
srna->identifier,
prop->totarraylength,
rna_safe_id(prop->identifier));
- else if (prop->getlength)
+ }
+ else if (prop->getlength) {
fprintf(f,
"\tBOOLEAN_DYNAMIC_ARRAY_PROPERTY(%s, %s)",
srna->identifier,
rna_safe_id(prop->identifier));
+ }
break;
}
case PROP_INT: {
- if (!prop->arraydimension)
+ if (!prop->arraydimension) {
fprintf(f, "\tINT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
- else if (prop->totarraylength)
+ }
+ else if (prop->totarraylength) {
fprintf(f,
"\tINT_ARRAY_PROPERTY(%s, %u, %s)",
srna->identifier,
prop->totarraylength,
rna_safe_id(prop->identifier));
- else if (prop->getlength)
+ }
+ else if (prop->getlength) {
fprintf(f,
"\tINT_DYNAMIC_ARRAY_PROPERTY(%s, %s)",
srna->identifier,
rna_safe_id(prop->identifier));
+ }
break;
}
case PROP_FLOAT: {
- if (!prop->arraydimension)
+ if (!prop->arraydimension) {
fprintf(f, "\tFLOAT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
- else if (prop->totarraylength)
+ }
+ else if (prop->totarraylength) {
fprintf(f,
"\tFLOAT_ARRAY_PROPERTY(%s, %u, %s)",
srna->identifier,
prop->totarraylength,
rna_safe_id(prop->identifier));
- else if (prop->getlength)
+ }
+ else if (prop->getlength) {
fprintf(f,
"\tFLOAT_DYNAMIC_ARRAY_PROPERTY(%s, %s)",
srna->identifier,
rna_safe_id(prop->identifier));
+ }
break;
}
case PROP_ENUM: {
@@ -2256,18 +2396,20 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
case PROP_POINTER: {
PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
- if (pprop->type)
+ if (pprop->type) {
fprintf(f,
"\tPOINTER_PROPERTY(%s, %s, %s)",
(const char *)pprop->type,
srna->identifier,
rna_safe_id(prop->identifier));
- else
+ }
+ else {
fprintf(f,
"\tPOINTER_PROPERTY(%s, %s, %s)",
"UnknownType",
srna->identifier,
rna_safe_id(prop->identifier));
+ }
break;
}
case PROP_COLLECTION: {
@@ -2275,13 +2417,23 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
if (cprop->type)
- fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", (const char *)cprop->type, srna->identifier,
- prop->identifier, (cprop->length ? "true" : "false"),
- (cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
+ fprintf(f,
+ "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)",
+ (const char *)cprop->type,
+ srna->identifier,
+ prop->identifier,
+ (cprop->length ? "true" : "false"),
+ (cprop->lookupint ? "true" : "false"),
+ (cprop->lookupstring ? "true" : "false"));
else
- fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", "UnknownType", srna->identifier,
- prop->identifier, (cprop->length ? "true" : "false"),
- (cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
+ fprintf(f,
+ "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)",
+ "UnknownType",
+ srna->identifier,
+ prop->identifier,
+ (cprop->length ? "true" : "false"),
+ (cprop->lookupint ? "true" : "false"),
+ (cprop->lookupstring ? "true" : "false"));
#endif
break;
}
@@ -2311,12 +2463,15 @@ static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, Func
if ((func->flag & FUNC_NO_SELF) == 0) {
WRITE_COMMA;
- if (dsrna->dnafromprop)
+ if (dsrna->dnafromprop) {
fprintf(f, "(::%s *) this->ptr.data", dsrna->dnafromname);
- else if (dsrna->dnaname)
+ }
+ else if (dsrna->dnaname) {
fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname);
- else
+ }
+ else {
fprintf(f, "(::%s *) this->ptr.data", srna->identifier);
+ }
}
else if (func->flag & FUNC_USE_SELF_TYPE) {
WRITE_COMMA;
@@ -2334,20 +2489,23 @@ static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, Func
dp = dfunc->cont.properties.first;
for (; dp; dp = dp->next) {
- if (dp->prop == func->c_ret)
+ if (dp->prop == func->c_ret) {
continue;
+ }
WRITE_COMMA;
- if (dp->prop->flag & PROP_DYNAMIC)
+ if (dp->prop->flag & PROP_DYNAMIC) {
fprintf(f, "%s_len, ", dp->prop->identifier);
+ }
- if (dp->prop->type == PROP_POINTER)
- if ((dp->prop->flag_parameter & PARM_RNAPTR) && !(dp->prop->flag & PROP_THICK_WRAP))
+ if (dp->prop->type == PROP_POINTER) {
+ if ((dp->prop->flag_parameter & PARM_RNAPTR) && !(dp->prop->flag & PROP_THICK_WRAP)) {
fprintf(f,
"(::%s *) &%s.ptr",
rna_parameter_type_name(dp->prop),
rna_safe_id(dp->prop->identifier));
+ }
else if (dp->prop->flag_parameter & PARM_OUTPUT) {
if (dp->prop->flag_parameter & PARM_RNAPTR) {
fprintf(f, "&%s->ptr", rna_safe_id(dp->prop->identifier));
@@ -2359,13 +2517,16 @@ static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, Func
rna_safe_id(dp->prop->identifier));
}
}
- else
+ else {
fprintf(f,
"(::%s *) %s.ptr.data",
rna_parameter_type_name(dp->prop),
rna_safe_id(dp->prop->identifier));
- else
+ }
+ }
+ else {
fprintf(f, "%s", rna_safe_id(dp->prop->identifier));
+ }
}
fprintf(f, ");\n");
@@ -2378,8 +2539,9 @@ static void rna_def_struct_function_impl_cpp(FILE *f, StructRNA *srna, FunctionD
FunctionRNA *func = dfunc->func;
- if (!dfunc->call)
+ if (!dfunc->call) {
return;
+ }
rna_def_struct_function_prototype_cpp(f, srna, dfunc, srna->identifier, 0);
@@ -2397,12 +2559,14 @@ static void rna_def_struct_function_impl_cpp(FILE *f, StructRNA *srna, FunctionD
StructRNA *ret_srna = rna_find_struct((const char *)pprop->type);
fprintf(f, "\t\t::%s *retdata = ", rna_parameter_type_name(dp->prop));
rna_def_struct_function_call_impl_cpp(f, srna, dfunc);
- if (ret_srna->flag & STRUCT_ID)
+ if (ret_srna->flag & STRUCT_ID) {
fprintf(f, "\t\tRNA_id_pointer_create((::ID *) retdata, &result);\n");
- else
+ }
+ else {
fprintf(f,
"\t\tRNA_pointer_create((::ID *) ptr.id.data, &RNA_%s, retdata, &result);\n",
(const char *)pprop->type);
+ }
}
else {
fprintf(f, "\t\tresult = ");
@@ -2446,8 +2610,9 @@ static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, Functio
int first;
char funcname[2048];
- if (!dfunc->call)
+ if (!dfunc->call) {
return;
+ }
rna_construct_wrapper_function_name(
funcname, sizeof(funcname), srna->identifier, func->identifier, NULL);
@@ -2456,10 +2621,12 @@ static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, Functio
fprintf(f, "\n{\n");
- if (func->c_ret)
+ if (func->c_ret) {
fprintf(f, "\treturn %s(", dfunc->call);
- else
+ }
+ else {
fprintf(f, "\t%s(", dfunc->call);
+ }
first = 1;
@@ -2484,15 +2651,18 @@ static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, Functio
dparm = dfunc->cont.properties.first;
for (; dparm; dparm = dparm->next) {
- if (dparm->prop == func->c_ret)
+ if (dparm->prop == func->c_ret) {
continue;
+ }
WRITE_COMMA;
- if (dparm->prop->flag & PROP_DYNAMIC)
+ if (dparm->prop->flag & PROP_DYNAMIC) {
fprintf(f, "%s_len, %s", dparm->prop->identifier, dparm->prop->identifier);
- else
+ }
+ else {
fprintf(f, "%s", rna_safe_id(dparm->prop->identifier));
+ }
}
fprintf(f, ");\n");
@@ -2513,8 +2683,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
srna = dsrna->srna;
func = dfunc->func;
- if (!dfunc->call)
+ if (!dfunc->call) {
return;
+ }
funcname = rna_alloc_function_name(srna->identifier, func->identifier, "call");
@@ -2531,12 +2702,15 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
}
if ((func->flag & FUNC_NO_SELF) == 0) {
- if (dsrna->dnafromprop)
+ if (dsrna->dnafromprop) {
fprintf(f, "\tstruct %s *_self;\n", dsrna->dnafromname);
- else if (dsrna->dnaname)
+ }
+ else if (dsrna->dnaname) {
fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
- else
+ }
+ else {
fprintf(f, "\tstruct %s *_self;\n", srna->identifier);
+ }
}
else if (func->flag & FUNC_USE_SELF_TYPE) {
fprintf(f, "\tstruct StructRNA *_type;\n");
@@ -2550,26 +2724,35 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
pout = (flag_parameter & PARM_OUTPUT);
cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
- if (dparm->prop == func->c_ret)
+ if (dparm->prop == func->c_ret) {
ptrstr = cptr || dparm->prop->arraydimension ? "*" : "";
- /* XXX only arrays and strings are allowed to be dynamic, is this checked anywhere? */
- else if (cptr || (flag & PROP_DYNAMIC))
+ /* XXX only arrays and strings are allowed to be dynamic, is this checked anywhere? */
+ }
+ else if (cptr || (flag & PROP_DYNAMIC)) {
ptrstr = pout ? "**" : "*";
- /* fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack, pass a pointer to it */
- else if (type == PROP_POINTER || dparm->prop->arraydimension)
+ /* Fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack,
+ * pass a pointer to it. */
+ }
+ else if (type == PROP_POINTER || dparm->prop->arraydimension) {
ptrstr = "*";
- else if ((type == PROP_POINTER) && (flag_parameter & PARM_RNAPTR) && !(flag & PROP_THICK_WRAP))
+ }
+ else if ((type == PROP_POINTER) && (flag_parameter & PARM_RNAPTR) &&
+ !(flag & PROP_THICK_WRAP)) {
ptrstr = "*";
- /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack,
- * but type name for string props is already (char *), so leave empty */
- else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
+ /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack,
+ * but type name for string props is already (char *), so leave empty */
+ }
+ else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
ptrstr = "";
- else
+ }
+ else {
ptrstr = pout ? "*" : "";
+ }
/* for dynamic parameters we pass an additional int for the length of the parameter */
- if (flag & PROP_DYNAMIC)
+ if (flag & PROP_DYNAMIC) {
fprintf(f, "\tint %s%s_len;\n", pout ? "*" : "", dparm->prop->identifier);
+ }
fprintf(f,
"\t%s%s %s%s;\n",
@@ -2581,8 +2764,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
if (has_data) {
fprintf(f, "\tchar *_data");
- if (func->c_ret)
+ if (func->c_ret) {
fprintf(f, ", *_retdata");
+ }
fprintf(f, ";\n");
fprintf(f, "\t\n");
}
@@ -2593,12 +2777,15 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
}
if ((func->flag & FUNC_NO_SELF) == 0) {
- if (dsrna->dnafromprop)
+ if (dsrna->dnafromprop) {
fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnafromname);
- else if (dsrna->dnaname)
+ }
+ else if (dsrna->dnaname) {
fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnaname);
- else
+ }
+ else {
fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", srna->identifier);
+ }
}
else if (func->flag & FUNC_USE_SELF_TYPE) {
fprintf(f, "\t_type = _ptr->type;\n");
@@ -2616,8 +2803,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
pout = (flag_parameter & PARM_OUTPUT);
cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
- if (dparm->prop == func->c_ret)
+ if (dparm->prop == func->c_ret) {
fprintf(f, "\t_retdata = _data;\n");
+ }
else {
const char *data_str;
if (cptr || (flag & PROP_DYNAMIC)) {
@@ -2641,8 +2829,8 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
valstr = "*";
}
- /* this must be kept in sync with RNA_parameter_dynamic_length_get_data and RNA_parameter_get,
- * we could just call the function directly, but this is faster */
+ /* This must be kept in sync with RNA_parameter_dynamic_length_get_data and
+ * RNA_parameter_get, we could just call the function directly, but this is faster. */
if (flag & PROP_DYNAMIC) {
fprintf(f,
"\t%s_len = %s((ParameterDynAlloc *)_data)->array_tot;\n",
@@ -2655,8 +2843,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
}
fprintf(f, "\t%s = ", dparm->prop->identifier);
- if (!pout)
+ if (!pout) {
fprintf(f, "%s", valstr);
+ }
fprintf(f,
"((%s%s %s)%s);\n",
@@ -2666,15 +2855,17 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
data_str);
}
- if (dparm->next)
+ if (dparm->next) {
fprintf(f, "\t_data += %d;\n", rna_parameter_size(dparm->prop));
+ }
}
if (dfunc->call) {
fprintf(f, "\t\n");
fprintf(f, "\t");
- if (func->c_ret)
+ if (func->c_ret) {
fprintf(f, "%s = ", func->c_ret->identifier);
+ }
fprintf(f, "%s(", dfunc->call);
first = 1;
@@ -2685,52 +2876,61 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
}
if ((func->flag & FUNC_NO_SELF) == 0) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
fprintf(f, "_self");
first = 0;
}
else if (func->flag & FUNC_USE_SELF_TYPE) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
fprintf(f, "_type");
first = 0;
}
if (func->flag & FUNC_USE_MAIN) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
first = 0;
fprintf(f, "CTX_data_main(C)"); /* may have direct access later */
}
if (func->flag & FUNC_USE_CONTEXT) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
first = 0;
fprintf(f, "C");
}
if (func->flag & FUNC_USE_REPORTS) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
first = 0;
fprintf(f, "reports");
}
dparm = dfunc->cont.properties.first;
for (; dparm; dparm = dparm->next) {
- if (dparm->prop == func->c_ret)
+ if (dparm->prop == func->c_ret) {
continue;
+ }
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
first = 0;
- if (dparm->prop->flag & PROP_DYNAMIC)
+ if (dparm->prop->flag & PROP_DYNAMIC) {
fprintf(f, "%s_len, %s", dparm->prop->identifier, dparm->prop->identifier);
- else
+ }
+ else {
fprintf(f, "%s", dparm->prop->identifier);
+ }
}
fprintf(f, ");\n");
@@ -2764,22 +2964,28 @@ static void rna_auto_types(void)
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
/* DNA name for Screen is patched in 2.5, we do the reverse here .. */
if (ds->dnaname) {
- if (STREQ(ds->dnaname, "Screen"))
+ if (STREQ(ds->dnaname, "Screen")) {
ds->dnaname = "bScreen";
- if (STREQ(ds->dnaname, "Group"))
+ }
+ if (STREQ(ds->dnaname, "Group")) {
ds->dnaname = "Collection";
- if (STREQ(ds->dnaname, "GroupObject"))
+ }
+ if (STREQ(ds->dnaname, "GroupObject")) {
ds->dnaname = "CollectionObject";
+ }
}
for (dp = ds->cont.properties.first; dp; dp = dp->next) {
if (dp->dnastructname) {
- if (STREQ(dp->dnastructname, "Screen"))
+ if (STREQ(dp->dnastructname, "Screen")) {
dp->dnastructname = "bScreen";
- if (STREQ(dp->dnastructname, "Group"))
+ }
+ if (STREQ(dp->dnastructname, "Group")) {
dp->dnastructname = "Collection";
- if (STREQ(dp->dnastructname, "GroupObject"))
+ }
+ if (STREQ(dp->dnastructname, "GroupObject")) {
dp->dnastructname = "CollectionObject";
+ }
}
if (dp->dnatype) {
@@ -2787,20 +2993,23 @@ static void rna_auto_types(void)
PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
StructRNA *type;
- if (!pprop->type && !pprop->get)
+ if (!pprop->type && !pprop->get) {
pprop->type = (StructRNA *)rna_find_type(dp->dnatype);
+ }
if (pprop->type) {
type = rna_find_struct((const char *)pprop->type);
- if (type && (type->flag & STRUCT_ID_REFCOUNT))
+ if (type && (type->flag & STRUCT_ID_REFCOUNT)) {
pprop->property.flag |= PROP_ID_REFCOUNT;
+ }
}
}
else if (dp->prop->type == PROP_COLLECTION) {
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
- if (!cprop->item_type && !cprop->get && STREQ(dp->dnatype, "ListBase"))
+ if (!cprop->item_type && !cprop->get && STREQ(dp->dnatype, "ListBase")) {
cprop->item_type = (StructRNA *)rna_find_type(dp->dnatype);
+ }
}
}
}
@@ -2815,11 +3024,13 @@ static void rna_sort(BlenderRNA *brna)
rna_sortlist(&brna->structs, cmp_struct);
rna_sortlist(&DefRNA.structs, cmp_def_struct);
- for (srna = brna->structs.first; srna; srna = srna->cont.next)
+ for (srna = brna->structs.first; srna; srna = srna->cont.next) {
rna_sortlist(&srna->cont.properties, cmp_property);
+ }
- for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
rna_sortlist(&ds->cont.properties, cmp_def_property);
+ }
}
static const char *rna_property_structname(PropertyType type)
@@ -2951,8 +3162,9 @@ static void rna_generate_prototypes(BlenderRNA *brna, FILE *f)
{
StructRNA *srna;
- for (srna = brna->structs.first; srna; srna = srna->cont.next)
+ for (srna = brna->structs.first; srna; srna = srna->cont.next) {
fprintf(f, "extern StructRNA RNA_%s;\n", srna->identifier);
+ }
fprintf(f, "\n");
}
@@ -2964,16 +3176,20 @@ static void rna_generate_blender(BlenderRNA *brna, FILE *f)
"BlenderRNA BLENDER_RNA = {\n"
"\t.structs = {");
srna = brna->structs.first;
- if (srna)
+ if (srna) {
fprintf(f, "&RNA_%s, ", srna->identifier);
- else
+ }
+ else {
fprintf(f, "NULL, ");
+ }
srna = brna->structs.last;
- if (srna)
+ if (srna) {
fprintf(f, "&RNA_%s},\n", srna->identifier);
- else
+ }
+ else {
fprintf(f, "NULL},\n");
+ }
fprintf(f,
"\t.structs_map = NULL,\n"
@@ -2989,25 +3205,28 @@ static void rna_generate_property_prototypes(BlenderRNA *UNUSED(brna), StructRNA
base = srna->base;
while (base) {
fprintf(f, "\n");
- for (prop = base->cont.properties.first; prop; prop = prop->next)
+ for (prop = base->cont.properties.first; prop; prop = prop->next) {
fprintf(f,
"%s%s rna_%s_%s;\n",
"extern ",
rna_property_structname(prop->type),
base->identifier,
prop->identifier);
+ }
base = base->base;
}
- if (srna->cont.properties.first)
+ if (srna->cont.properties.first) {
fprintf(f, "\n");
+ }
- for (prop = srna->cont.properties.first; prop; prop = prop->next)
+ for (prop = srna->cont.properties.first; prop; prop = prop->next) {
fprintf(f,
"%s rna_%s_%s;\n",
rna_property_structname(prop->type),
srna->identifier,
prop->identifier);
+ }
fprintf(f, "\n");
}
@@ -3018,7 +3237,7 @@ static void rna_generate_parameter_prototypes(BlenderRNA *UNUSED(brna),
{
PropertyRNA *parm;
- for (parm = func->cont.properties.first; parm; parm = parm->next)
+ for (parm = func->cont.properties.first; parm; parm = parm->next) {
fprintf(f,
"%s%s rna_%s_%s_%s;\n",
"extern ",
@@ -3026,9 +3245,11 @@ static void rna_generate_parameter_prototypes(BlenderRNA *UNUSED(brna),
srna->identifier,
func->identifier,
parm->identifier);
+ }
- if (func->cont.properties.first)
+ if (func->cont.properties.first) {
fprintf(f, "\n");
+ }
}
static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f)
@@ -3048,8 +3269,9 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna,
rna_generate_parameter_prototypes(brna, base, func, f);
}
- if (base->functions.first)
+ if (base->functions.first) {
fprintf(f, "\n");
+ }
base = base->base;
}
@@ -3060,8 +3282,9 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna,
rna_generate_parameter_prototypes(brna, srna, func, f);
}
- if (srna->functions.first)
+ if (srna->functions.first) {
fprintf(f, "\n");
+ }
}
static void rna_generate_static_parameter_prototypes(FILE *f,
@@ -3083,26 +3306,32 @@ static void rna_generate_static_parameter_prototypes(FILE *f,
/* return type */
for (dparm = dfunc->cont.properties.first; dparm; dparm = dparm->next) {
if (dparm->prop == func->c_ret) {
- if (dparm->prop->arraydimension)
+ if (dparm->prop->arraydimension) {
fprintf(f, "XXX no array return types yet"); /* XXX not supported */
- else if (dparm->prop->type == PROP_POINTER && !(dparm->prop->flag_parameter & PARM_RNAPTR))
+ }
+ else if (dparm->prop->type == PROP_POINTER && !(dparm->prop->flag_parameter & PARM_RNAPTR)) {
fprintf(f, "%s%s *", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
- else
+ }
+ else {
fprintf(f, "%s%s ", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
+ }
break;
}
}
/* void if nothing to return */
- if (!dparm)
+ if (!dparm) {
fprintf(f, "void ");
+ }
/* function name */
- if (name_override == NULL || name_override[0] == '\0')
+ if (name_override == NULL || name_override[0] == '\0') {
fprintf(f, "%s(", dfunc->call);
- else
+ }
+ else {
fprintf(f, "%s(", name_override);
+ }
first = 1;
@@ -3113,40 +3342,48 @@ static void rna_generate_static_parameter_prototypes(FILE *f,
}
if ((func->flag & FUNC_NO_SELF) == 0) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
- if (dsrna->dnafromprop)
+ }
+ if (dsrna->dnafromprop) {
fprintf(f, "struct %s *_self", dsrna->dnafromname);
- else if (dsrna->dnaname)
+ }
+ else if (dsrna->dnaname) {
fprintf(f, "struct %s *_self", dsrna->dnaname);
- else
+ }
+ else {
fprintf(f, "struct %s *_self", srna->identifier);
+ }
first = 0;
}
else if (func->flag & FUNC_USE_SELF_TYPE) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
fprintf(f, "struct StructRNA *_type");
first = 0;
}
if (func->flag & FUNC_USE_MAIN) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
first = 0;
fprintf(f, "Main *bmain");
}
if (func->flag & FUNC_USE_CONTEXT) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
first = 0;
fprintf(f, "bContext *C");
}
if (func->flag & FUNC_USE_REPORTS) {
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
first = 0;
fprintf(f, "ReportList *reports");
}
@@ -3159,49 +3396,60 @@ static void rna_generate_static_parameter_prototypes(FILE *f,
pout = (flag_parameter & PARM_OUTPUT);
cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
- if (dparm->prop == func->c_ret)
+ if (dparm->prop == func->c_ret) {
continue;
+ }
- if (cptr || (flag & PROP_DYNAMIC))
+ if (cptr || (flag & PROP_DYNAMIC)) {
ptrstr = pout ? "**" : "*";
- else if (type == PROP_POINTER || dparm->prop->arraydimension)
+ }
+ else if (type == PROP_POINTER || dparm->prop->arraydimension) {
ptrstr = "*";
- else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
+ }
+ else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
ptrstr = "";
- else
+ }
+ else {
ptrstr = pout ? "*" : "";
+ }
- if (!first)
+ if (!first) {
fprintf(f, ", ");
+ }
first = 0;
- if (flag & PROP_DYNAMIC)
+ if (flag & PROP_DYNAMIC) {
fprintf(f, "int %s%s_len, ", pout ? "*" : "", dparm->prop->identifier);
+ }
- if (!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension)
+ if (!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension) {
fprintf(f,
"%s%s %s[%u]",
rna_type_struct(dparm->prop),
rna_parameter_type_name(dparm->prop),
rna_safe_id(dparm->prop->identifier),
dparm->prop->totarraylength);
- else
+ }
+ else {
fprintf(f,
"%s%s %s%s",
rna_type_struct(dparm->prop),
rna_parameter_type_name(dparm->prop),
ptrstr,
rna_safe_id(dparm->prop->identifier));
+ }
}
/* ensure func(void) if there are no args */
- if (first)
+ if (first) {
fprintf(f, "void");
+ }
fprintf(f, ")");
- if (close_prototype)
+ if (close_prototype) {
fprintf(f, ";\n");
+ }
}
static void rna_generate_static_function_prototypes(BlenderRNA *UNUSED(brna),
@@ -3376,12 +3624,15 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
prop->totarraylength);
for (i = 0; i < prop->totarraylength; i++) {
- if (bprop->defaultarray)
+ if (bprop->defaultarray) {
fprintf(f, "%d", bprop->defaultarray[i]);
- else
+ }
+ else {
fprintf(f, "%d", bprop->defaultvalue);
- if (i != prop->totarraylength - 1)
+ }
+ if (i != prop->totarraylength - 1) {
fprintf(f, ",\n\t");
+ }
}
fprintf(f, "\n};\n\n");
@@ -3401,12 +3652,15 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
prop->totarraylength);
for (i = 0; i < prop->totarraylength; i++) {
- if (iprop->defaultarray)
+ if (iprop->defaultarray) {
fprintf(f, "%d", iprop->defaultarray[i]);
- else
+ }
+ else {
fprintf(f, "%d", iprop->defaultvalue);
- if (i != prop->totarraylength - 1)
+ }
+ if (i != prop->totarraylength - 1) {
fprintf(f, ",\n\t");
+ }
}
fprintf(f, "\n};\n\n");
@@ -3426,12 +3680,15 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
prop->totarraylength);
for (i = 0; i < prop->totarraylength; i++) {
- if (fprop->defaultarray)
+ if (fprop->defaultarray) {
rna_float_print(f, fprop->defaultarray[i]);
- else
+ }
+ else {
rna_float_print(f, fprop->defaultvalue);
- if (i != prop->totarraylength - 1)
+ }
+ if (i != prop->totarraylength - 1) {
fprintf(f, ",\n\t");
+ }
}
fprintf(f, "\n};\n\n");
@@ -3441,7 +3698,8 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
case PROP_POINTER: {
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
- /* XXX This systematically enforces that flag on ID pointers... we'll probably have to revisit. :/ */
+ /* XXX This systematically enforces that flag on ID pointers...
+ * we'll probably have to revisit. :/ */
StructRNA *type = rna_find_struct((const char *)pprop->type);
if (type && (type->flag & STRUCT_ID)) {
prop->flag |= PROP_PTR_NO_OWNERSHIP;
@@ -3451,7 +3709,8 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
case PROP_COLLECTION: {
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
- /* XXX This systematically enforces that flag on ID pointers... we'll probably have to revisit. :/ */
+ /* XXX This systematically enforces that flag on ID pointers...
+ * we'll probably have to revisit. :/ */
StructRNA *type = rna_find_struct((const char *)cprop->item_type);
if (type && (type->flag & STRUCT_ID)) {
prop->flag |= PROP_PTR_NO_OWNERSHIP;
@@ -3469,16 +3728,20 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
strnest,
prop->identifier);
- if (prop->next)
+ if (prop->next) {
fprintf(
f, "\t{(PropertyRNA *)&rna_%s%s_%s, ", srna->identifier, strnest, prop->next->identifier);
- else
+ }
+ else {
fprintf(f, "\t{NULL, ");
- if (prop->prev)
+ }
+ if (prop->prev) {
fprintf(
f, "(PropertyRNA *)&rna_%s%s_%s,\n", srna->identifier, strnest, prop->prev->identifier);
- else
+ }
+ else {
fprintf(f, "NULL,\n");
+ }
fprintf(f, "\t%d, ", prop->magic);
rna_print_c_string(f, prop->identifier);
fprintf(f,
@@ -3517,16 +3780,20 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_function_string(prop->override_store),
rna_function_string(prop->override_apply));
- if (prop->flag_internal & PROP_INTERN_RAW_ACCESS)
+ if (prop->flag_internal & PROP_INTERN_RAW_ACCESS) {
rna_set_raw_offset(f, srna, prop);
- else
+ }
+ else {
fprintf(f, "\t0, -1");
+ }
/* our own type - collections/arrays only */
- if (prop->srna)
+ if (prop->srna) {
fprintf(f, ", &RNA_%s", (const char *)prop->srna);
- else
+ }
+ else {
fprintf(f, ", NULL");
+ }
fprintf(f, "},\n");
@@ -3544,10 +3811,12 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_function_string(bprop->getarray_ex),
rna_function_string(bprop->setarray_ex),
bprop->defaultvalue);
- if (prop->arraydimension && prop->totarraylength)
+ if (prop->arraydimension && prop->totarraylength) {
fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
- else
+ }
+ else {
fprintf(f, "NULL\n");
+ }
break;
}
case PROP_INT: {
@@ -3576,10 +3845,12 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
fprintf(f, ", ");
rna_int_print(f, iprop->defaultvalue);
fprintf(f, ", ");
- if (prop->arraydimension && prop->totarraylength)
+ if (prop->arraydimension && prop->totarraylength) {
fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
- else
+ }
+ else {
fprintf(f, "NULL\n");
+ }
break;
}
case PROP_FLOAT: {
@@ -3610,10 +3881,12 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
fprintf(f, ", ");
rna_float_print(f, fprop->defaultvalue);
fprintf(f, ", ");
- if (prop->arraydimension && prop->totarraylength)
+ if (prop->arraydimension && prop->totarraylength) {
fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
- else
+ }
+ else {
fprintf(f, "NULL\n");
+ }
break;
}
case PROP_STRING: {
@@ -3640,10 +3913,12 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_function_string(eprop->itemf),
rna_function_string(eprop->get_ex),
rna_function_string(eprop->set_ex));
- if (eprop->item)
+ if (eprop->item) {
fprintf(f, "rna_%s%s_%s_items, ", srna->identifier, strnest, prop->identifier);
- else
+ }
+ else {
fprintf(f, "NULL, ");
+ }
fprintf(f, "%d, %d\n", eprop->totitem, eprop->defaultvalue);
break;
}
@@ -3655,10 +3930,12 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_function_string(pprop->set),
rna_function_string(pprop->typef),
rna_function_string(pprop->poll));
- if (pprop->type)
+ if (pprop->type) {
fprintf(f, "&RNA_%s\n", (const char *)pprop->type);
- else
+ }
+ else {
fprintf(f, "NULL\n");
+ }
break;
}
case PROP_COLLECTION: {
@@ -3673,10 +3950,12 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
rna_function_string(cprop->lookupint),
rna_function_string(cprop->lookupstring),
rna_function_string(cprop->assignint));
- if (cprop->item_type)
+ if (cprop->item_type) {
fprintf(f, "&RNA_%s\n", (const char *)cprop->item_type);
- else
+ }
+ else {
fprintf(f, "NULL\n");
+ }
break;
}
}
@@ -3698,51 +3977,61 @@ static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE
fprintf(f, "/* %s */\n", srna->name);
- for (prop = srna->cont.properties.first; prop; prop = prop->next)
+ for (prop = srna->cont.properties.first; prop; prop = prop->next) {
rna_generate_property(f, srna, NULL, prop);
+ }
for (func = srna->functions.first; func; func = func->cont.next) {
- for (parm = func->cont.properties.first; parm; parm = parm->next)
+ for (parm = func->cont.properties.first; parm; parm = parm->next) {
rna_generate_property(f, srna, func->identifier, parm);
+ }
fprintf(f, "%s%s rna_%s_%s_func = {\n", "", "FunctionRNA", srna->identifier, func->identifier);
- if (func->cont.next)
+ if (func->cont.next) {
fprintf(f,
"\t{(FunctionRNA *)&rna_%s_%s_func, ",
srna->identifier,
((FunctionRNA *)func->cont.next)->identifier);
- else
+ }
+ else {
fprintf(f, "\t{NULL, ");
- if (func->cont.prev)
+ }
+ if (func->cont.prev) {
fprintf(f,
"(FunctionRNA *)&rna_%s_%s_func,\n",
srna->identifier,
((FunctionRNA *)func->cont.prev)->identifier);
- else
+ }
+ else {
fprintf(f, "NULL,\n");
+ }
fprintf(f, "\tNULL,\n");
parm = func->cont.properties.first;
- if (parm)
+ if (parm) {
fprintf(f,
"\t{(PropertyRNA *)&rna_%s_%s_%s, ",
srna->identifier,
func->identifier,
parm->identifier);
- else
+ }
+ else {
fprintf(f, "\t{NULL, ");
+ }
parm = func->cont.properties.last;
- if (parm)
+ if (parm) {
fprintf(f,
"(PropertyRNA *)&rna_%s_%s_%s}},\n",
srna->identifier,
func->identifier,
parm->identifier);
- else
+ }
+ else {
fprintf(f, "NULL}},\n");
+ }
fprintf(f, "\t");
rna_print_c_string(f, func->identifier);
@@ -3751,19 +4040,23 @@ static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE
fprintf(f, ",\n");
dfunc = rna_find_function_def(func);
- if (dfunc->gencall)
+ if (dfunc->gencall) {
fprintf(f, "\t%s,\n", dfunc->gencall);
- else
+ }
+ else {
fprintf(f, "\tNULL,\n");
+ }
- if (func->c_ret)
+ if (func->c_ret) {
fprintf(f,
"\t(PropertyRNA *)&rna_%s_%s_%s\n",
srna->identifier,
func->identifier,
func->c_ret->identifier);
- else
+ }
+ else {
fprintf(f, "\tNULL\n");
+ }
fprintf(f, "};\n");
fprintf(f, "\n");
@@ -3771,28 +4064,36 @@ static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE
fprintf(f, "StructRNA RNA_%s = {\n", srna->identifier);
- if (srna->cont.next)
+ if (srna->cont.next) {
fprintf(f, "\t{(ContainerRNA *)&RNA_%s, ", ((StructRNA *)srna->cont.next)->identifier);
- else
+ }
+ else {
fprintf(f, "\t{NULL, ");
- if (srna->cont.prev)
+ }
+ if (srna->cont.prev) {
fprintf(f, "(ContainerRNA *)&RNA_%s,\n", ((StructRNA *)srna->cont.prev)->identifier);
- else
+ }
+ else {
fprintf(f, "NULL,\n");
+ }
fprintf(f, "\tNULL,\n");
prop = srna->cont.properties.first;
- if (prop)
+ if (prop) {
fprintf(f, "\t{(PropertyRNA *)&rna_%s_%s, ", srna->identifier, prop->identifier);
- else
+ }
+ else {
fprintf(f, "\t{NULL, ");
+ }
prop = srna->cont.properties.last;
- if (prop)
+ if (prop) {
fprintf(f, "(PropertyRNA *)&rna_%s_%s}},\n", srna->identifier, prop->identifier);
- else
+ }
+ else {
fprintf(f, "NULL}},\n");
+ }
fprintf(f, "\t");
rna_print_c_string(f, srna->identifier);
fprintf(f, ", NULL, NULL"); /* PyType - Cant initialize here */
@@ -3807,8 +4108,9 @@ static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE
prop = srna->nameproperty;
if (prop) {
base = srna;
- while (base->base && base->base->nameproperty == prop)
+ while (base->base && base->base->nameproperty == prop) {
base = base->base;
+ }
fprintf(f, "\t(PropertyRNA *)&rna_%s_%s, ", base->identifier, prop->identifier);
}
@@ -3818,19 +4120,24 @@ static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE
prop = srna->iteratorproperty;
base = srna;
- while (base->base && base->base->iteratorproperty == prop)
+ while (base->base && base->base->iteratorproperty == prop) {
base = base->base;
+ }
fprintf(f, "(PropertyRNA *)&rna_%s_rna_properties,\n", base->identifier);
- if (srna->base)
+ if (srna->base) {
fprintf(f, "\t&RNA_%s,\n", srna->base->identifier);
- else
+ }
+ else {
fprintf(f, "\tNULL,\n");
+ }
- if (srna->nested)
+ if (srna->nested) {
fprintf(f, "\t&RNA_%s,\n", srna->nested->identifier);
- else
+ }
+ else {
fprintf(f, "\tNULL,\n");
+ }
fprintf(f, "\t%s,\n", rna_function_string(srna->refine));
fprintf(f, "\t%s,\n", rna_function_string(srna->path));
@@ -3846,16 +4153,20 @@ static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE
}
func = srna->functions.first;
- if (func)
+ if (func) {
fprintf(f, "\t{(FunctionRNA *)&rna_%s_%s_func, ", srna->identifier, func->identifier);
- else
+ }
+ else {
fprintf(f, "\t{NULL, ");
+ }
func = srna->functions.last;
- if (func)
+ if (func) {
fprintf(f, "(FunctionRNA *)&rna_%s_%s_func}\n", srna->identifier, func->identifier);
- else
+ }
+ else {
fprintf(f, "NULL}\n");
+ }
fprintf(f, "};\n");
@@ -3978,8 +4289,9 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
fprintf(f, "#include \"rna_prototypes_gen.h\"\n\n");
fprintf(f, "#include \"%s\"\n", filename);
- if (api_filename)
+ if (api_filename) {
fprintf(f, "#include \"%s\"\n", api_filename);
+ }
fprintf(f, "\n");
/* we want the included C files to have warnings enabled but for the generated code
@@ -3997,15 +4309,19 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
}
}
- for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
- if (!filename || ds->filename == filename)
- for (dp = ds->cont.properties.first; dp; dp = dp->next)
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ if (!filename || ds->filename == filename) {
+ for (dp = ds->cont.properties.first; dp; dp = dp->next) {
rna_def_property_funcs(f, ds->srna, dp);
+ }
+ }
+ }
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
if (!filename || ds->filename == filename) {
- for (dp = ds->cont.properties.first; dp; dp = dp->next)
+ for (dp = ds->cont.properties.first; dp; dp = dp->next) {
rna_def_property_wrapper_funcs(f, ds, dp);
+ }
for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
rna_def_function_wrapper_funcs(f, ds, dfunc);
@@ -4016,9 +4332,11 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
}
}
- for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
- if (!filename || ds->filename == filename)
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ if (!filename || ds->filename == filename) {
rna_generate_struct(brna, ds->srna, f);
+ }
+ }
if (STREQ(filename, "rna_ID.c")) {
/* this is ugly, but we cannot have c files compiled for both
@@ -4071,11 +4389,13 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f)
}
fprintf(f, "\n");
- for (dp = ds->cont.properties.first; dp; dp = dp->next)
+ for (dp = ds->cont.properties.first; dp; dp = dp->next) {
rna_def_property_funcs_header(f, ds->srna, dp);
+ }
- for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
+ for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
rna_def_function_funcs_header(f, ds->srna, dfunc);
+ }
}
fprintf(f, "#ifdef __cplusplus\n}\n#endif\n\n");
@@ -4434,17 +4754,21 @@ static void rna_generate_header_class_cpp(StructDefRNA *ds, FILE *f)
"\t%s(const PointerRNA &ptr_arg) :\n\t\t%s(ptr_arg)",
srna->identifier,
(srna->base) ? srna->base->identifier : "Pointer");
- for (dp = ds->cont.properties.first; dp; dp = dp->next)
- if (rna_is_collection_prop(dp->prop))
+ for (dp = ds->cont.properties.first; dp; dp = dp->next) {
+ if (rna_is_collection_prop(dp->prop)) {
fprintf(f, ",\n\t\t%s(ptr_arg)", dp->prop->identifier);
+ }
+ }
fprintf(f, "\n\t\t{}\n\n");
- for (dp = ds->cont.properties.first; dp; dp = dp->next)
+ for (dp = ds->cont.properties.first; dp; dp = dp->next) {
rna_def_property_funcs_header_cpp(f, ds->srna, dp);
+ }
fprintf(f, "\n");
- for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
+ for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
rna_def_struct_function_header_cpp(f, srna, dfunc);
+ }
fprintf(f, "};\n\n");
}
@@ -4490,8 +4814,9 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
if (prop->srna) {
/* store name of structure which first uses custom functions for collections */
- if (first_collection_func_struct == NULL)
+ if (first_collection_func_struct == NULL) {
first_collection_func_struct = ds->srna->identifier;
+ }
if (!rna_is_collection_functions_struct(collection_func_structs, (char *)prop->srna)) {
if (all_collection_func_structs >= max_collection_func_structs) {
@@ -4528,8 +4853,9 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
}
}
- if (!rna_is_collection_functions_struct(collection_func_structs, srna->identifier))
+ if (!rna_is_collection_functions_struct(collection_func_structs, srna->identifier)) {
rna_generate_header_class_cpp(ds, f);
+ }
}
fprintf(f, "} /* namespace BL */\n");
@@ -4548,13 +4874,15 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
srna = ds->srna;
- for (dp = ds->cont.properties.first; dp; dp = dp->next)
+ for (dp = ds->cont.properties.first; dp; dp = dp->next) {
rna_def_property_funcs_impl_cpp(f, ds->srna, dp);
+ }
fprintf(f, "\n");
- for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
+ for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
rna_def_struct_function_impl_cpp(f, srna, dfunc);
+ }
fprintf(f, "\n");
}
@@ -4594,9 +4922,11 @@ static int rna_preprocess(const char *outfile)
fprintf(stderr, "Error: DefRNA.animate left disabled in %s\n", PROCESS_ITEMS[i].filename);
}
- for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
- if (!ds->filename)
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ if (!ds->filename) {
ds->filename = PROCESS_ITEMS[i].filename;
+ }
+ }
}
}
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 8a3cf3be55e..149cd7caf84 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -904,7 +904,8 @@ static void rna_ImagePreview_icon_pixels_float_set(PointerRNA *ptr, const float
static int rna_ImagePreview_icon_id_get(PointerRNA *ptr)
{
- /* Using a callback here allows us to only generate icon matching that preview when icon_id is requested. */
+ /* Using a callback here allows us to only generate icon matching
+ * that preview when icon_id is requested. */
return BKE_icon_preview_ensure(ptr->id.data, (PreviewImage *)(ptr->data));
}
static void rna_ImagePreview_icon_reload(PreviewImage *prv)
@@ -1299,7 +1300,8 @@ static void rna_def_ID_override_static_property(BlenderRNA *brna)
RNA_def_struct_ui_text(
srna, "ID Static Override Property", "Description of an overridden property");
- /* String pointer, we *should* add get/set/etc. But NULL rna_path would be a nasty bug anyway... */
+ /* String pointer, we *should* add get/set/etc.
+ * But NULL rna_path would be a nasty bug anyway. */
prop = RNA_def_string(srna,
"rna_path",
NULL,
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 541c2184a94..d5dfd0b5503 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -133,10 +133,12 @@ void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
while (idtype->refine) {
type = idtype->refine(&tmp);
- if (type == idtype)
+ if (type == idtype) {
break;
- else
+ }
+ else {
idtype = type;
+ }
}
}
@@ -165,10 +167,12 @@ void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
while (r_ptr->type && r_ptr->type->refine) {
StructRNA *rtype = r_ptr->type->refine(r_ptr);
- if (rtype == r_ptr->type)
+ if (rtype == r_ptr->type) {
break;
- else
+ }
+ else {
r_ptr->type = rtype;
+ }
}
}
}
@@ -206,10 +210,12 @@ PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *da
while (result.type->refine) {
type = result.type->refine(&result);
- if (type == result.type)
+ if (type == result.type) {
break;
- else
+ }
+ else {
result.type = type;
+ }
}
return result;
}
@@ -254,14 +260,16 @@ static IDProperty *rna_idproperty_ui_container(PropertyRNA *prop)
IDProperty *idprop;
for (idprop = ((IDProperty *)prop)->prev; idprop; idprop = idprop->prev) {
- if (STREQ(RNA_IDP_UI, idprop->name))
+ if (STREQ(RNA_IDP_UI, idprop->name)) {
break;
+ }
}
if (idprop == NULL) {
for (idprop = ((IDProperty *)prop)->next; idprop; idprop = idprop->next) {
- if (STREQ(RNA_IDP_UI, idprop->name))
+ if (STREQ(RNA_IDP_UI, idprop->name)) {
break;
+ }
}
}
@@ -398,7 +406,10 @@ static IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name)
else {
/* Not sure why that happens sometimes, with nested properties... */
/* Seems to be actually array prop, name is usually "0"... To be sorted out later. */
- // printf("Got unexpected IDProp container when trying to retrieve %s: %d\n", name, group->type);
+#if 0
+ printf(
+ "Got unexpected IDProp container when trying to retrieve %s: %d\n", name, group->type);
+#endif
}
}
@@ -426,10 +437,12 @@ static int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
else {
IDProperty *idprop = (IDProperty *)prop;
- if (idprop->type == IDP_ARRAY)
+ if (idprop->type == IDP_ARRAY) {
return idprop->len;
- else
+ }
+ else {
return 0;
+ }
}
}
@@ -450,18 +463,22 @@ static void rna_ensure_property_multi_array_length(PointerRNA *ptr,
int length[])
{
if (prop->magic == RNA_MAGIC) {
- if (prop->getlength)
+ if (prop->getlength) {
prop->getlength(ptr, length);
- else
+ }
+ else {
memcpy(length, prop->arraylength, prop->arraydimension * sizeof(int));
+ }
}
else {
IDProperty *idprop = (IDProperty *)prop;
- if (idprop->type == IDP_ARRAY)
+ if (idprop->type == IDP_ARRAY) {
length[0] = idprop->len;
- else
+ }
+ else {
length[0] = 0;
+ }
}
}
@@ -474,36 +491,44 @@ static bool rna_idproperty_verify_valid(PointerRNA *ptr, PropertyRNA *prop, IDPr
switch (idprop->type) {
case IDP_IDPARRAY:
- if (prop->type != PROP_COLLECTION)
+ if (prop->type != PROP_COLLECTION) {
return false;
+ }
break;
case IDP_ARRAY:
- if (rna_ensure_property_array_length(ptr, prop) != idprop->len)
+ if (rna_ensure_property_array_length(ptr, prop) != idprop->len) {
return false;
+ }
- if (idprop->subtype == IDP_FLOAT && prop->type != PROP_FLOAT)
+ if (idprop->subtype == IDP_FLOAT && prop->type != PROP_FLOAT) {
return false;
- if (idprop->subtype == IDP_INT && !ELEM(prop->type, PROP_BOOLEAN, PROP_INT, PROP_ENUM))
+ }
+ if (idprop->subtype == IDP_INT && !ELEM(prop->type, PROP_BOOLEAN, PROP_INT, PROP_ENUM)) {
return false;
+ }
break;
case IDP_INT:
- if (!ELEM(prop->type, PROP_BOOLEAN, PROP_INT, PROP_ENUM))
+ if (!ELEM(prop->type, PROP_BOOLEAN, PROP_INT, PROP_ENUM)) {
return false;
+ }
break;
case IDP_FLOAT:
case IDP_DOUBLE:
- if (prop->type != PROP_FLOAT)
+ if (prop->type != PROP_FLOAT) {
return false;
+ }
break;
case IDP_STRING:
- if (prop->type != PROP_STRING)
+ if (prop->type != PROP_STRING) {
return false;
+ }
break;
case IDP_GROUP:
case IDP_ID:
- if (prop->type != PROP_POINTER)
+ if (prop->type != PROP_POINTER) {
return false;
+ }
break;
default:
return false;
@@ -569,10 +594,12 @@ static void *rna_idproperty_check_ex(PropertyRNA **prop,
{
IDProperty *idprop = (IDProperty *)(*prop);
- if (idprop->type == IDP_ARRAY)
+ if (idprop->type == IDP_ARRAY) {
*prop = arraytypemap[(int)(idprop->subtype)];
- else
+ }
+ else {
*prop = typemap[(int)(idprop->type)];
+ }
return idprop;
}
@@ -585,7 +612,8 @@ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr)
return rna_idproperty_check_ex(prop, ptr, false);
}
-/* This function always return the valid, real data pointer, be it a regular RNA property one, or an IDProperty one. */
+/* This function always return the valid, real data pointer, be it a regular RNA property one,
+ * or an IDProperty one. */
PropertyRNA *rna_ensure_property_realdata(PropertyRNA **prop, PointerRNA *ptr)
{
return rna_idproperty_check_ex(prop, ptr, true);
@@ -595,45 +623,53 @@ static PropertyRNA *rna_ensure_property(PropertyRNA *prop)
{
/* the quick version if we don't need the idproperty */
- if (prop->magic == RNA_MAGIC)
+ if (prop->magic == RNA_MAGIC) {
return prop;
+ }
{
IDProperty *idprop = (IDProperty *)prop;
- if (idprop->type == IDP_ARRAY)
+ if (idprop->type == IDP_ARRAY) {
return arraytypemap[(int)(idprop->subtype)];
- else
+ }
+ else {
return typemap[(int)(idprop->type)];
+ }
}
}
static const char *rna_ensure_property_identifier(const PropertyRNA *prop)
{
- if (prop->magic == RNA_MAGIC)
+ if (prop->magic == RNA_MAGIC) {
return prop->identifier;
- else
+ }
+ else {
return ((const IDProperty *)prop)->name;
+ }
}
static const char *rna_ensure_property_description(PropertyRNA *prop)
{
const char *description = NULL;
- if (prop->magic == RNA_MAGIC)
+ if (prop->magic == RNA_MAGIC) {
description = prop->description;
+ }
else {
/* attempt to get the local ID values */
IDProperty *idp_ui = rna_idproperty_ui(prop);
if (idp_ui) {
IDProperty *item = IDP_GetPropertyTypeFromGroup(idp_ui, "description", IDP_STRING);
- if (item)
+ if (item) {
description = IDP_String(item);
+ }
}
- if (description == NULL)
+ if (description == NULL) {
description = ((IDProperty *)prop)->name; /* XXX - not correct */
+ }
}
return description;
@@ -643,10 +679,12 @@ static const char *rna_ensure_property_name(const PropertyRNA *prop)
{
const char *name;
- if (prop->magic == RNA_MAGIC)
+ if (prop->magic == RNA_MAGIC) {
name = prop->name;
- else
+ }
+ else {
name = ((const IDProperty *)prop)->name;
+ }
return name;
}
@@ -675,10 +713,12 @@ const char *RNA_struct_ui_name_raw(const StructRNA *type)
int RNA_struct_ui_icon(const StructRNA *type)
{
- if (type)
+ if (type) {
return type->icon;
- else
+ }
+ else {
return ICON_DOT;
+ }
}
const char *RNA_struct_ui_description(const StructRNA *type)
@@ -754,7 +794,8 @@ bool RNA_struct_idprops_datablock_allowed(const StructRNA *type)
/**
* Whether given type implies datablock usage by IDProperties.
- * This is used to prevent classes allowed to have IDProperties, but not datablock ones, to indirectly use some
+ * This is used to prevent classes allowed to have IDProperties,
+ * but not datablock ones, to indirectly use some
* (e.g. by assigning an IDP_GROUP containing some IDP_ID pointers...).
*/
bool RNA_struct_idprops_contains_datablock(const StructRNA *type)
@@ -782,16 +823,20 @@ bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
{
const StructRNA *base;
- if (srna == &RNA_AnyType)
+ if (srna == &RNA_AnyType) {
return true;
+ }
- if (!type)
+ if (!type) {
return false;
+ }
/* ptr->type is always maximally refined */
- for (base = type; base; base = base->base)
- if (base == srna)
+ for (base = type; base; base = base->base) {
+ if (base == srna) {
return true;
+ }
+ }
return false;
}
@@ -799,7 +844,7 @@ bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
{
if (identifier[0] == '[' && identifier[1] == '"') { /* " (dummy comment to avoid confusing some
- * function lists in text editors) */
+ * function lists in text editors) */
/* id prop lookup, not so common */
PropertyRNA *r_prop = NULL;
PointerRNA r_ptr; /* only support single level props */
@@ -813,8 +858,9 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
PropertyRNA *iterprop = RNA_struct_iterator_property(ptr->type);
PointerRNA propptr;
- if (RNA_property_collection_lookup_string(ptr, iterprop, identifier, &propptr))
+ if (RNA_property_collection_lookup_string(ptr, iterprop, identifier, &propptr)) {
return propptr.data;
+ }
}
return NULL;
@@ -875,7 +921,8 @@ unsigned int RNA_struct_count_properties(StructRNA *srna)
return counter;
}
-/* low level direct access to type->properties, note this ignores parent classes so should be used with care */
+/* Low level direct access to type->properties,
+ * note this ignores parent classes so should be used with care. */
const struct ListBase *RNA_struct_type_properties(StructRNA *srna)
{
return &srna->cont.properties;
@@ -936,8 +983,9 @@ StructRegisterFunc RNA_struct_register(StructRNA *type)
StructUnregisterFunc RNA_struct_unregister(StructRNA *type)
{
do {
- if (type->unreg)
+ if (type->unreg) {
return type->unreg;
+ }
} while ((type = type->base));
return NULL;
@@ -948,8 +996,9 @@ void **RNA_struct_instance(PointerRNA *ptr)
StructRNA *type = ptr->type;
do {
- if (type->instance)
+ if (type->instance) {
return type->instance(ptr);
+ }
} while ((type = type->base));
return NULL;
@@ -979,8 +1028,9 @@ char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, i
{
PropertyRNA *nameprop;
- if (ptr->data && (nameprop = RNA_struct_name_property(ptr->type)))
+ if (ptr->data && (nameprop = RNA_struct_name_property(ptr->type))) {
return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen, r_len);
+ }
return NULL;
}
@@ -1140,8 +1190,9 @@ int RNA_property_array_dimension(PointerRNA *ptr, PropertyRNA *prop, int length[
{
PropertyRNA *rprop = rna_ensure_property(prop);
- if (length)
+ if (length) {
rna_ensure_property_multi_array_length(ptr, prop, length);
+ }
return rprop->arraydimension;
}
@@ -1483,16 +1534,19 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
if (prop->type == PROP_POINTER) {
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
- if (pprop->typef)
+ if (pprop->typef) {
return pprop->typef(ptr);
- else if (pprop->type)
+ }
+ else if (pprop->type) {
return pprop->type;
+ }
}
else if (prop->type == PROP_COLLECTION) {
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
- if (cprop->item_type)
+ if (cprop->item_type) {
return cprop->item_type;
+ }
}
/* ignore other types, RNA_struct_find_nested calls with unchecked props */
@@ -1537,10 +1591,12 @@ void RNA_property_enum_items_ex(bContext *C,
if (!use_static && eprop->itemf && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) {
const EnumPropertyItem *item;
- if (prop->flag & PROP_ENUM_NO_CONTEXT)
+ if (prop->flag & PROP_ENUM_NO_CONTEXT) {
item = eprop->itemf(NULL, ptr, prop, r_free);
- else
+ }
+ else {
item = eprop->itemf(C, ptr, prop, r_free);
+ }
/* any callbacks returning NULL should be fixed */
BLI_assert(item != NULL);
@@ -1557,8 +1613,9 @@ void RNA_property_enum_items_ex(bContext *C,
}
else {
*r_item = eprop->item;
- if (r_totitem)
+ if (r_totitem) {
*r_totitem = eprop->totitem;
+ }
}
}
@@ -1586,8 +1643,9 @@ static void property_enum_translate(PropertyRNA *prop,
bool do_tooltip = BLT_translate_tooltips();
EnumPropertyItem *nitem;
- if (!(do_iface || do_tooltip))
+ if (!(do_iface || do_tooltip)) {
return;
+ }
if (*r_free) {
nitem = *r_item;
@@ -1665,10 +1723,12 @@ void RNA_property_enum_items_gettexted_all(bContext *C,
int i;
bool free = false;
- if (prop->flag & PROP_ENUM_NO_CONTEXT)
+ if (prop->flag & PROP_ENUM_NO_CONTEXT) {
item = eprop->itemf(NULL, ptr, prop, &free);
- else
+ }
+ else {
item = eprop->itemf(C, ptr, prop, &free);
+ }
/* any callbacks returning NULL should be fixed */
BLI_assert(item != NULL);
@@ -1677,7 +1737,8 @@ void RNA_property_enum_items_gettexted_all(bContext *C,
bool exists = false;
int i_fixed;
- /* items that do not exist on list are returned, but have their names/identifiers NULLed out */
+ /* Items that do not exist on list are returned,
+ * but have their names/identifiers NULL'ed out. */
for (i_fixed = 0; item[i_fixed].identifier; i_fixed++) {
if (STREQ(item[i_fixed].identifier, item_array[i].identifier)) {
exists = true;
@@ -1941,8 +2002,9 @@ int RNA_property_enum_bitflag_identifiers(
if (item) {
int result;
result = RNA_enum_bitflag_identifiers(item, value, identifier);
- if (free)
+ if (free) {
MEM_freeN((void *)item);
+ }
return result;
}
@@ -1995,7 +2057,8 @@ bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop)
}
/**
- * Version of #RNA_property_editable that tries to return additional info in \a r_info that can be exposed in UI.
+ * Version of #RNA_property_editable that tries to return additional info in \a r_info
+ * that can be exposed in UI.
*/
bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info)
{
@@ -2062,8 +2125,9 @@ bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index)
flag &= prop->editable(ptr, &dummy_info);
}
- if (prop->itemeditable)
+ if (prop->itemeditable) {
flag &= prop->itemeditable(ptr, index);
+ }
id = ptr->id.data;
@@ -2073,13 +2137,15 @@ bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index)
bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop)
{
/* check that base ID-block can support animation data */
- if (!id_can_have_animdata(ptr->id.data))
+ if (!id_can_have_animdata(ptr->id.data)) {
return false;
+ }
prop = rna_ensure_property(prop);
- if (!(prop->flag & PROP_ANIMATABLE))
+ if (!(prop->flag & PROP_ANIMATABLE)) {
return false;
+ }
return (prop->flag & PROP_EDITABLE) != 0;
}
@@ -2089,15 +2155,18 @@ bool RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop)
int len = 1, index;
bool driven, special;
- if (!prop)
+ if (!prop) {
return false;
+ }
- if (RNA_property_array_check(prop))
+ if (RNA_property_array_check(prop)) {
len = RNA_property_array_length(ptr, prop);
+ }
for (index = 0; index < len; index++) {
- if (rna_get_fcurve(ptr, prop, index, NULL, NULL, &driven, &special))
+ if (rna_get_fcurve(ptr, prop, index, NULL, NULL, &driven, &special)) {
return true;
+ }
}
return false;
@@ -2109,8 +2178,10 @@ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop)
{
if (prop->magic == RNA_MAGIC) {
/* Special handling for insertions of constraints or modifiers... */
- /* TODO Note We may want to add a more generic system to RNA (like a special property in struct of items)
- * if we get more overrideable collections, for now we can live with those special-cases handling I think. */
+ /* TODO Note We may want to add a more generic system to RNA
+ * (like a special property in struct of items)
+ * if we get more overrideable collections,
+ * for now we can live with those special-cases handling I think. */
if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
bConstraint *con = ptr->data;
if (con->flag & CONSTRAINT_STATICOVERRIDE_LOCAL) {
@@ -2123,7 +2194,8 @@ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop)
return true;
}
}
- /* If this is a RNA-defined property (real or 'virtual' IDProp), we want to use RNA prop flag. */
+ /* If this is a RNA-defined property (real or 'virtual' IDProp),
+ * we want to use RNA prop flag. */
return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) &&
(prop->flag_override & PROPOVERRIDE_OVERRIDABLE_STATIC);
}
@@ -2212,8 +2284,9 @@ static void rna_property_update(
}
}
}
- else
+ else {
prop->update(bmain, scene, ptr);
+ }
}
#if 1
@@ -2308,23 +2381,27 @@ void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop)
LinkData *ld;
/* sanity check */
- if (NULL == ptr)
+ if (NULL == ptr) {
return;
+ }
prop = rna_ensure_property(prop);
/* we can only handle update calls with no context args for now (makes animsys updates easier) */
- if ((is_rna == false) || (prop->update == NULL) || (prop->flag & PROP_CONTEXT_UPDATE))
+ if ((is_rna == false) || (prop->update == NULL) || (prop->flag & PROP_CONTEXT_UPDATE)) {
return;
+ }
fn = prop->update;
/* find cache element for which key matches... */
for (uce = rna_updates_cache.first; uce; uce = uce->next) {
- /* just match by id only for now, since most update calls that we'll encounter only really care about this */
+ /* Just match by id only for now,
+ * since most update calls that we'll encounter only really care about this. */
/* TODO: later, the cache might need to have some nesting on L1 to cope better
* with these problems + some tagging to indicate we need this */
- if (uce->ptr.id.data == ptr->id.data)
+ if (uce->ptr.id.data == ptr->id.data) {
break;
+ }
}
if (uce == NULL) {
/* create new instance */
@@ -2338,8 +2415,9 @@ void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop)
/* check on the update func */
for (ld = uce->L2Funcs.first; ld; ld = ld->next) {
/* stop on match - function already cached */
- if (fn == ld->data)
+ if (fn == ld->data) {
return;
+ }
}
/* else... if still here, we need to add it */
BLI_addtail(&uce->L2Funcs, BLI_genericNodeN(fn));
@@ -2390,14 +2468,18 @@ bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
BLI_assert(RNA_property_array_check(prop) == false);
- if ((idprop = rna_idproperty_check(&prop, ptr)))
+ if ((idprop = rna_idproperty_check(&prop, ptr))) {
value = IDP_Int(idprop) != 0;
- else if (bprop->get)
+ }
+ else if (bprop->get) {
value = bprop->get(ptr);
- else if (bprop->get_ex)
+ }
+ else if (bprop->get_ex) {
value = bprop->get_ex(ptr, prop);
- else
+ }
+ else {
value = bprop->defaultvalue;
+ }
BLI_assert(ELEM(value, false, true));
@@ -2433,8 +2515,9 @@ void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
val.i = value;
group = RNA_struct_idprops(ptr, 1);
- if (group)
+ if (group) {
IDP_AddToGroup(group, IDP_New(IDP_INT, &val, prop->identifier));
+ }
}
}
@@ -2471,14 +2554,18 @@ void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, bool *va
}
}
}
- else if (prop->arraydimension == 0)
+ else if (prop->arraydimension == 0) {
values[0] = RNA_property_boolean_get(ptr, prop);
- else if (bprop->getarray)
+ }
+ else if (bprop->getarray) {
bprop->getarray(ptr, values);
- else if (bprop->getarray_ex)
+ }
+ else if (bprop->getarray_ex) {
bprop->getarray_ex(ptr, prop, values);
- else
+ }
+ else {
rna_property_boolean_get_default_array_values(bprop, values);
+ }
}
bool RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
@@ -2530,12 +2617,15 @@ void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const bo
}
rna_idproperty_touch(idprop);
}
- else if (prop->arraydimension == 0)
+ else if (prop->arraydimension == 0) {
RNA_property_boolean_set(ptr, prop, values[0]);
- else if (bprop->setarray)
+ }
+ else if (bprop->setarray) {
bprop->setarray(ptr, values);
- else if (bprop->setarray_ex)
+ }
+ else if (bprop->setarray_ex) {
bprop->setarray_ex(ptr, prop, values);
+ }
else if (prop->flag & PROP_EDITABLE) {
IDPropertyTemplate val = {0};
IDProperty *group;
@@ -2602,10 +2692,12 @@ void RNA_property_boolean_get_default_array(PointerRNA *UNUSED(ptr),
BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
BLI_assert(RNA_property_array_check(prop) != false);
- if (prop->arraydimension == 0)
+ if (prop->arraydimension == 0) {
values[0] = bprop->defaultvalue;
- else
+ }
+ else {
rna_property_boolean_get_default_array_values(bprop, values);
+ }
}
bool RNA_property_boolean_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index)
@@ -2642,14 +2734,18 @@ int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(RNA_property_type(prop) == PROP_INT);
BLI_assert(RNA_property_array_check(prop) == false);
- if ((idprop = rna_idproperty_check(&prop, ptr)))
+ if ((idprop = rna_idproperty_check(&prop, ptr))) {
return IDP_Int(idprop);
- else if (iprop->get)
+ }
+ else if (iprop->get) {
return iprop->get(ptr);
- else if (iprop->get_ex)
+ }
+ else if (iprop->get_ex) {
return iprop->get_ex(ptr, prop);
- else
+ }
+ else {
return iprop->defaultvalue;
+ }
}
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
@@ -2667,10 +2763,12 @@ void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
IDP_Int(idprop) = value;
rna_idproperty_touch(idprop);
}
- else if (iprop->set)
+ else if (iprop->set) {
iprop->set(ptr, value);
- else if (iprop->set_ex)
+ }
+ else if (iprop->set_ex) {
iprop->set_ex(ptr, prop, value);
+ }
else if (prop->flag & PROP_EDITABLE) {
IDPropertyTemplate val = {0};
IDProperty *group;
@@ -2680,8 +2778,9 @@ void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
val.i = value;
group = RNA_struct_idprops(ptr, 1);
- if (group)
+ if (group) {
IDP_AddToGroup(group, IDP_New(IDP_INT, &val, prop->identifier));
+ }
}
}
@@ -2710,19 +2809,25 @@ void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values)
if ((idprop = rna_idproperty_check(&prop, ptr))) {
BLI_assert(idprop->len == RNA_property_array_length(ptr, prop) ||
(prop->flag & PROP_IDPROPERTY));
- if (prop->arraydimension == 0)
+ if (prop->arraydimension == 0) {
values[0] = RNA_property_int_get(ptr, prop);
- else
+ }
+ else {
memcpy(values, IDP_Array(idprop), sizeof(int) * idprop->len);
+ }
}
- else if (prop->arraydimension == 0)
+ else if (prop->arraydimension == 0) {
values[0] = RNA_property_int_get(ptr, prop);
- else if (iprop->getarray)
+ }
+ else if (iprop->getarray) {
iprop->getarray(ptr, values);
- else if (iprop->getarray_ex)
+ }
+ else if (iprop->getarray_ex) {
iprop->getarray_ex(ptr, prop, values);
- else
+ }
+ else {
rna_property_int_get_default_array_values(iprop, values);
+ }
}
void RNA_property_int_get_array_range(PointerRNA *ptr, PropertyRNA *prop, int values[2])
@@ -2799,19 +2904,24 @@ void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *v
if ((idprop = rna_idproperty_check(&prop, ptr))) {
BLI_assert(idprop->len == RNA_property_array_length(ptr, prop) ||
(prop->flag & PROP_IDPROPERTY));
- if (prop->arraydimension == 0)
+ if (prop->arraydimension == 0) {
IDP_Int(idprop) = values[0];
- else
+ }
+ else {
memcpy(IDP_Array(idprop), values, sizeof(int) * idprop->len);
+ }
rna_idproperty_touch(idprop);
}
- else if (prop->arraydimension == 0)
+ else if (prop->arraydimension == 0) {
RNA_property_int_set(ptr, prop, values[0]);
- else if (iprop->setarray)
+ }
+ else if (iprop->setarray) {
iprop->setarray(ptr, values);
- else if (iprop->setarray_ex)
+ }
+ else if (iprop->setarray_ex) {
iprop->setarray_ex(ptr, prop, values);
+ }
else if (prop->flag & PROP_EDITABLE) {
IDPropertyTemplate val = {0};
IDProperty *group;
@@ -2895,10 +3005,12 @@ void RNA_property_int_get_default_array(PointerRNA *UNUSED(ptr), PropertyRNA *pr
BLI_assert(RNA_property_type(prop) == PROP_INT);
BLI_assert(RNA_property_array_check(prop) != false);
- if (prop->arraydimension == 0)
+ if (prop->arraydimension == 0) {
values[0] = iprop->defaultvalue;
- else
+ }
+ else {
rna_property_int_get_default_array_values(iprop, values);
+ }
}
int RNA_property_int_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index)
@@ -2936,17 +3048,22 @@ float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(RNA_property_array_check(prop) == false);
if ((idprop = rna_idproperty_check(&prop, ptr))) {
- if (idprop->type == IDP_FLOAT)
+ if (idprop->type == IDP_FLOAT) {
return IDP_Float(idprop);
- else
+ }
+ else {
return (float)IDP_Double(idprop);
+ }
}
- else if (fprop->get)
+ else if (fprop->get) {
return fprop->get(ptr);
- else if (fprop->get_ex)
+ }
+ else if (fprop->get_ex) {
return fprop->get_ex(ptr, prop);
- else
+ }
+ else {
return fprop->defaultvalue;
+ }
}
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
@@ -2961,10 +3078,12 @@ void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
if ((idprop = rna_idproperty_check(&prop, ptr))) {
RNA_property_float_clamp(ptr, prop, &value);
- if (idprop->type == IDP_FLOAT)
+ if (idprop->type == IDP_FLOAT) {
IDP_Float(idprop) = value;
- else
+ }
+ else {
IDP_Double(idprop) = value;
+ }
rna_idproperty_touch(idprop);
}
@@ -2983,8 +3102,9 @@ void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
val.f = value;
group = RNA_struct_idprops(ptr, 1);
- if (group)
+ if (group) {
IDP_AddToGroup(group, IDP_New(IDP_FLOAT, &val, prop->identifier));
+ }
}
}
@@ -3014,24 +3134,30 @@ void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *val
if ((idprop = rna_idproperty_check(&prop, ptr))) {
BLI_assert(idprop->len == RNA_property_array_length(ptr, prop) ||
(prop->flag & PROP_IDPROPERTY));
- if (prop->arraydimension == 0)
+ if (prop->arraydimension == 0) {
values[0] = RNA_property_float_get(ptr, prop);
+ }
else if (idprop->subtype == IDP_FLOAT) {
memcpy(values, IDP_Array(idprop), sizeof(float) * idprop->len);
}
else {
- for (i = 0; i < idprop->len; i++)
+ for (i = 0; i < idprop->len; i++) {
values[i] = (float)(((double *)IDP_Array(idprop))[i]);
+ }
}
}
- else if (prop->arraydimension == 0)
+ else if (prop->arraydimension == 0) {
values[0] = RNA_property_float_get(ptr, prop);
- else if (fprop->getarray)
+ }
+ else if (fprop->getarray) {
fprop->getarray(ptr, values);
- else if (fprop->getarray_ex)
+ }
+ else if (fprop->getarray_ex) {
fprop->getarray_ex(ptr, prop, values);
- else
+ }
+ else {
rna_property_float_get_default_array_values(fprop, values);
+ }
}
void RNA_property_float_get_array_range(PointerRNA *ptr, PropertyRNA *prop, float values[2])
@@ -3110,23 +3236,27 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const floa
BLI_assert(idprop->len == RNA_property_array_length(ptr, prop) ||
(prop->flag & PROP_IDPROPERTY));
if (prop->arraydimension == 0) {
- if (idprop->type == IDP_FLOAT)
+ if (idprop->type == IDP_FLOAT) {
IDP_Float(idprop) = values[0];
- else
+ }
+ else {
IDP_Double(idprop) = values[0];
+ }
}
else if (idprop->subtype == IDP_FLOAT) {
memcpy(IDP_Array(idprop), values, sizeof(float) * idprop->len);
}
else {
- for (i = 0; i < idprop->len; i++)
+ for (i = 0; i < idprop->len; i++) {
((double *)IDP_Array(idprop))[i] = values[i];
+ }
}
rna_idproperty_touch(idprop);
}
- else if (prop->arraydimension == 0)
+ else if (prop->arraydimension == 0) {
RNA_property_float_set(ptr, prop, values[0]);
+ }
else if (fprop->setarray) {
fprop->setarray(ptr, values);
}
@@ -3221,10 +3351,12 @@ void RNA_property_float_get_default_array(PointerRNA *UNUSED(ptr),
BLI_assert(RNA_property_type(prop) == PROP_FLOAT);
BLI_assert(RNA_property_array_check(prop) != false);
- if (prop->arraydimension == 0)
+ if (prop->arraydimension == 0) {
values[0] = fprop->defaultvalue;
- else
+ }
+ else {
rna_property_float_get_default_array_values(fprop, values);
+ }
}
float RNA_property_float_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index)
@@ -3292,10 +3424,12 @@ char *RNA_property_string_get_alloc(
length = RNA_property_string_length(ptr, prop);
- if (length + 1 < fixedlen)
+ if (length + 1 < fixedlen) {
buf = fixedbuf;
- else
+ }
+ else {
buf = MEM_mallocN(sizeof(char) * (length + 1), "RNA_string_get_alloc");
+ }
#ifndef NDEBUG
/* safety check to ensure the string is actually set */
@@ -3335,12 +3469,15 @@ int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop)
return idprop->len - 1;
}
}
- else if (sprop->length)
+ else if (sprop->length) {
return sprop->length(ptr);
- else if (sprop->length_ex)
+ }
+ else if (sprop->length_ex) {
return sprop->length_ex(ptr, prop);
- else
+ }
+ else {
return strlen(sprop->defaultvalue);
+ }
}
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
@@ -3355,17 +3492,20 @@ void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *val
IDP_AssignString(idprop, value, RNA_property_string_maxlength(prop) - 1);
rna_idproperty_touch(idprop);
}
- else if (sprop->set)
+ else if (sprop->set) {
sprop->set(ptr, value); /* set function needs to clamp its self */
- else if (sprop->set_ex)
+ }
+ else if (sprop->set_ex) {
sprop->set_ex(ptr, prop, value); /* set function needs to clamp its self */
+ }
else if (prop->flag & PROP_EDITABLE) {
IDProperty *group;
group = RNA_struct_idprops(ptr, 1);
- if (group)
+ if (group) {
IDP_AddToGroup(group,
IDP_NewString(value, prop->identifier, RNA_property_string_maxlength(prop)));
+ }
}
}
@@ -3426,10 +3566,12 @@ char *RNA_property_string_get_default_alloc(PointerRNA *ptr,
length = RNA_property_string_default_length(ptr, prop);
- if (length + 1 < fixedlen)
+ if (length + 1 < fixedlen) {
buf = fixedbuf;
- else
+ }
+ else {
buf = MEM_callocN(sizeof(char) * (length + 1), "RNA_string_get_alloc");
+ }
RNA_property_string_get_default(ptr, prop, buf);
@@ -3453,14 +3595,18 @@ int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(RNA_property_type(prop) == PROP_ENUM);
- if ((idprop = rna_idproperty_check(&prop, ptr)))
+ if ((idprop = rna_idproperty_check(&prop, ptr))) {
return IDP_Int(idprop);
- else if (eprop->get)
+ }
+ else if (eprop->get) {
return eprop->get(ptr);
- else if (eprop->get_ex)
+ }
+ else if (eprop->get_ex) {
return eprop->get_ex(ptr, prop);
- else
+ }
+ else {
return eprop->defaultvalue;
+ }
}
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
@@ -3487,8 +3633,9 @@ void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
val.i = value;
group = RNA_struct_idprops(ptr, 1);
- if (group)
+ if (group) {
IDP_AddToGroup(group, IDP_New(IDP_INT, &val, prop->identifier));
+ }
}
}
@@ -3565,10 +3712,12 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
}
/* for groups, data is idprop itself */
- if (pprop->typef)
+ if (pprop->typef) {
return rna_pointer_inherit_refine(ptr, pprop->typef(ptr), idprop);
- else
+ }
+ else {
return rna_pointer_inherit_refine(ptr, pprop->type, idprop);
+ }
}
else if (pprop->get) {
return pprop->get(ptr);
@@ -3642,14 +3791,16 @@ void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop)
val.i = 0;
group = RNA_struct_idprops(ptr, 1);
- if (group)
+ if (group) {
IDP_AddToGroup(group, IDP_New(IDP_GROUP, &val, prop->identifier));
+ }
}
- else
+ else {
printf("%s %s.%s: only supported for id properties.\n",
__func__,
ptr->type->identifier,
prop->identifier);
+ }
}
void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop)
@@ -3665,11 +3816,12 @@ void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop)
IDP_FreeFromGroup(group, idprop);
}
}
- else
+ else {
printf("%s %s.%s: only supported for id properties.\n",
__func__,
ptr->type->identifier,
prop->identifier);
+ }
}
static void rna_property_collection_get_idp(CollectionPropertyIterator *iter)
@@ -3695,14 +3847,17 @@ void RNA_property_collection_begin(PointerRNA *ptr,
iter->parent = *ptr;
iter->prop = prop;
- if (idprop)
+ if (idprop) {
rna_iterator_array_begin(
iter, IDP_IDPArray(idprop), sizeof(IDProperty), idprop->len, 0, NULL);
- else
+ }
+ else {
rna_iterator_array_begin(iter, NULL, sizeof(IDProperty), 0, 0, NULL);
+ }
- if (iter->valid)
+ if (iter->valid) {
rna_property_collection_get_idp(iter);
+ }
iter->idprop = 1;
}
@@ -3719,11 +3874,13 @@ void RNA_property_collection_next(CollectionPropertyIterator *iter)
if (iter->idprop) {
rna_iterator_array_next(iter);
- if (iter->valid)
+ if (iter->valid) {
rna_property_collection_get_idp(iter);
+ }
}
- else
+ else {
cprop->next(iter);
+ }
}
void RNA_property_collection_skip(CollectionPropertyIterator *iter, int num)
@@ -3738,25 +3895,29 @@ void RNA_property_collection_skip(CollectionPropertyIterator *iter, int num)
if (!internal->skip) {
internal->ptr += internal->itemsize * (num - 1);
iter->valid = (internal->ptr < internal->endptr);
- if (iter->valid)
+ if (iter->valid) {
RNA_property_collection_next(iter);
+ }
return;
}
}
/* slow iteration otherwise */
- for (i = 0; i < num && iter->valid; i++)
+ for (i = 0; i < num && iter->valid; i++) {
RNA_property_collection_next(iter);
+ }
}
void RNA_property_collection_end(CollectionPropertyIterator *iter)
{
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)rna_ensure_property(iter->prop);
- if (iter->idprop)
+ if (iter->idprop) {
rna_iterator_array_end(iter);
- else
+ }
+ else {
cprop->end(iter);
+ }
}
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
@@ -3777,8 +3938,9 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
int length = 0;
RNA_property_collection_begin(ptr, prop, &iter);
- for (; iter.valid; RNA_property_collection_next(&iter))
+ for (; iter.valid; RNA_property_collection_next(&iter)) {
length++;
+ }
RNA_property_collection_end(&iter);
return length;
@@ -3798,7 +3960,8 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
item = IDP_New(IDP_GROUP, &val, "");
IDP_AppendArray(idprop, item);
- /* IDP_FreeProperty(item); */ /* IDP_AppendArray does a shallow copy (memcpy), only free memory */
+ /* IDP_AppendArray does a shallow copy (memcpy), only free memory */
+ /* IDP_FreeProperty(item); */
MEM_freeN(item);
rna_idproperty_touch(idprop);
}
@@ -3813,7 +3976,8 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
item = IDP_New(IDP_GROUP, &val, "");
IDP_AppendArray(idprop, item);
- /* IDP_FreeProperty(item); */ /* IDP_AppendArray does a shallow copy (memcpy), only free memory */
+ /* IDP_AppendArray does a shallow copy (memcpy), only free memory */
+ /* IDP_FreeProperty(item); */
MEM_freeN(item);
}
}
@@ -3830,7 +3994,10 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
}
# if 0
else {
- printf("%s %s.%s: not implemented for this property.\n", __func__, ptr->type->identifier, prop->identifier);
+ printf("%s %s.%s: not implemented for this property.\n",
+ __func__,
+ ptr->type->identifier,
+ prop->identifier);
}
# endif
#endif
@@ -3843,8 +4010,9 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
r_ptr->type = cprop->item_type;
rna_pointer_inherit_id(NULL, ptr, r_ptr);
}
- else
+ else {
memset(r_ptr, 0, sizeof(*r_ptr));
+ }
}
}
@@ -3893,7 +4061,10 @@ bool RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key)
}
# if 0
else {
- printf("%s %s.%s: only supported for id properties.\n", __func__, ptr->type->identifier, prop->identifier);
+ printf("%s %s.%s: only supported for id properties.\n",
+ __func__,
+ ptr->type->identifier,
+ prop->identifier);
}
# endif
#endif
@@ -3915,10 +4086,12 @@ bool RNA_property_collection_move(PointerRNA *ptr, PropertyRNA *prop, int key, i
if (key >= 0 && key < len && pos >= 0 && pos < len && key != pos) {
memcpy(&tmp, &array[key], sizeof(IDProperty));
- if (pos < key)
+ if (pos < key) {
memmove(array + pos + 1, array + pos, sizeof(IDProperty) * (key - pos));
- else
+ }
+ else {
memmove(array + key, array + key + 1, sizeof(IDProperty) * (pos - key));
+ }
memcpy(&array[pos], &tmp, sizeof(IDProperty));
}
@@ -3952,16 +4125,19 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, Poi
RNA_property_collection_begin(ptr, prop, &iter);
for (index = 0; iter.valid; RNA_property_collection_next(&iter), index++) {
- if (iter.ptr.data == t_ptr->data)
+ if (iter.ptr.data == t_ptr->data) {
break;
+ }
}
RNA_property_collection_end(&iter);
/* did we find it? */
- if (iter.valid)
+ if (iter.valid) {
return index;
- else
+ }
+ else {
return -1;
+ }
}
int RNA_property_collection_lookup_int(PointerRNA *ptr,
@@ -3991,8 +4167,9 @@ int RNA_property_collection_lookup_int(PointerRNA *ptr,
}
RNA_property_collection_end(&iter);
- if (!iter.valid)
+ if (!iter.valid) {
memset(r_ptr, 0, sizeof(*r_ptr));
+ }
return iter.valid;
}
@@ -4032,17 +4209,20 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr,
found = 1;
}
- if ((char *)&name != nameptr)
+ if ((char *)&name != nameptr) {
MEM_freeN(nameptr);
+ }
- if (found)
+ if (found) {
break;
+ }
}
}
RNA_property_collection_end(&iter);
- if (!iter.valid)
+ if (!iter.valid) {
memset(r_ptr, 0, sizeof(*r_ptr));
+ }
return iter.valid;
}
@@ -4086,8 +4266,9 @@ int RNA_property_collection_raw_array(PointerRNA *ptr,
BLI_assert(RNA_property_type(prop) == PROP_COLLECTION);
if (!(prop->flag_internal & PROP_INTERN_RAW_ARRAY) ||
- !(itemprop->flag_internal & PROP_INTERN_RAW_ACCESS))
+ !(itemprop->flag_internal & PROP_INTERN_RAW_ACCESS)) {
return 0;
+ }
RNA_property_collection_begin(ptr, prop, &iter);
@@ -4107,8 +4288,9 @@ int RNA_property_collection_raw_array(PointerRNA *ptr,
array->len = ((char *)internal->endptr - arrayp) / internal->itemsize;
array->type = itemprop->rawtype;
}
- else
+ else {
memset(array, 0, sizeof(RawArray));
+ }
RNA_property_collection_end(&iter);
@@ -4195,11 +4377,13 @@ static int rna_property_array_length_all_dimensions(PointerRNA *ptr, PropertyRNA
const int dim = RNA_property_array_dimension(ptr, prop, len);
int size;
- if (dim == 0)
+ if (dim == 0) {
return 0;
+ }
- for (size = 1, i = 0; i < dim; i++)
+ for (size = 1, i = 0; i < dim; i++) {
size *= len[i];
+ }
return size;
}
@@ -4272,10 +4456,12 @@ static int rna_raw_access(ReportList *reports,
size = RNA_raw_type_sizeof(out.type) * arraylen;
for (a = 0; a < out.len; a++) {
- if (set)
+ if (set) {
memcpy(outp, inp, size);
- else
+ }
+ else {
memcpy(inp, outp, size);
+ }
inp = (char *)inp + size;
outp = (char *)outp + out.stride;
@@ -4498,8 +4684,9 @@ static int rna_raw_access(ReportList *reports,
}
RNA_PROP_END;
- if (tmparray)
+ if (tmparray) {
MEM_freeN(tmparray);
+ }
return !err;
}
@@ -4508,7 +4695,8 @@ static int rna_raw_access(ReportList *reports,
RawPropertyType RNA_property_raw_type(PropertyRNA *prop)
{
if (prop->rawtype == PROP_RAW_UNSET) {
- /* this property has no raw access, yet we try to provide a raw type to help building the array */
+ /* this property has no raw access,
+ * yet we try to provide a raw type to help building the array. */
switch (prop->type) {
case PROP_BOOLEAN:
return PROP_RAW_BOOLEAN;
@@ -4560,8 +4748,9 @@ void rna_iterator_listbase_begin(CollectionPropertyIterator *iter,
iter->valid = (internal->link != NULL);
- if (skip && iter->valid && skip(iter, internal->link))
+ if (skip && iter->valid && skip(iter, internal->link)) {
rna_iterator_listbase_next(iter);
+ }
}
void rna_iterator_listbase_next(CollectionPropertyIterator *iter)
@@ -4609,8 +4798,9 @@ void rna_iterator_array_begin(CollectionPropertyIterator *iter,
{
ArrayIterator *internal;
- if (ptr == NULL)
+ if (ptr == NULL) {
length = 0;
+ }
else if (length == 0) {
ptr = NULL;
itemsize = 0;
@@ -4626,8 +4816,9 @@ void rna_iterator_array_begin(CollectionPropertyIterator *iter,
iter->valid = (internal->ptr != internal->endptr);
- if (skip && iter->valid && skip(iter, internal->ptr))
+ if (skip && iter->valid && skip(iter, internal->ptr)) {
rna_iterator_array_next(iter);
+ }
}
void rna_iterator_array_next(CollectionPropertyIterator *iter)
@@ -4674,8 +4865,9 @@ void rna_iterator_array_end(CollectionPropertyIterator *iter)
PointerRNA rna_array_lookup_int(
PointerRNA *ptr, StructRNA *type, void *data, int itemsize, int length, int index)
{
- if (index < 0 || index >= length)
+ if (index < 0 || index >= length) {
return PointerRNA_NULL;
+ }
return rna_pointer_inherit_refine(ptr, type, ((char *)data) + index * itemsize);
}
@@ -4693,18 +4885,21 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
if (bracket) {
/* get data between [], check escaping ] with \] */
- if (**path == '[')
+ if (**path == '[') {
(*path)++;
- else
+ }
+ else {
return NULL;
+ }
p = *path;
/* 2 kinds of lookups now, quoted or unquoted */
quote = *p;
- if (quote != '"') /* " - this comment is hack for Aligorith's text editor's sanity */
+ if (quote != '"') { /* " - this comment is hack for Aligorith's text editor's sanity */
quote = 0;
+ }
if (quote == 0) {
while (*p && (*p != ']')) {
@@ -4728,8 +4923,9 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
p++;
}
- if (*p != ']')
+ if (*p != ']') {
return NULL;
+ }
}
else {
/* get data until . or [ */
@@ -4742,22 +4938,26 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
}
/* empty, return */
- if (len == 0)
+ if (len == 0) {
return NULL;
+ }
/* try to use fixed buffer if possible */
- if (len + 1 < fixedlen)
+ if (len + 1 < fixedlen) {
buf = fixedbuf;
- else
+ }
+ else {
buf = MEM_mallocN(sizeof(char) * (len + 1), "rna_path_token");
+ }
/* copy string, taking into account escaped ] */
if (bracket) {
for (p = *path, i = 0, j = 0; i < len; i++, p++) {
if (*p == '\\' && *(p + 1) == quote) {
}
- else
+ else {
buf[j++] = *p;
+ }
}
buf[j] = 0;
@@ -4768,10 +4968,12 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int
}
/* set path to start of next token */
- if (*p == ']')
+ if (*p == ']') {
p++;
- if (*p == '.')
+ }
+ if (*p == '.') {
p++;
+ }
*path = p;
return buf;
@@ -4801,8 +5003,9 @@ static bool rna_path_parse_collection_key(const char **path,
*r_nextptr = *ptr;
/* end of path, ok */
- if (!(**path))
+ if (!(**path)) {
return true;
+ }
if (**path == '[') {
char *token;
@@ -4810,8 +5013,9 @@ static bool rna_path_parse_collection_key(const char **path,
/* resolve the lookup with [] brackets */
token = rna_path_token(path, fixedbuf, sizeof(fixedbuf), 1);
- if (!token)
+ if (!token) {
return false;
+ }
/* check for "" to see if it is a string */
if (rna_token_strip_quotes(token)) {
@@ -4867,8 +5071,9 @@ static bool rna_path_parse_array_index(const char **path,
*r_index = -1;
/* end of path, ok */
- if (!(**path))
+ if (!(**path)) {
return true;
+ }
for (i = 0; i < dim; i++) {
int temp_index = -1;
@@ -4918,16 +5123,18 @@ static bool rna_path_parse_array_index(const char **path,
}
/* out of range */
- if (temp_index < 0 || temp_index >= len[i])
+ if (temp_index < 0 || temp_index >= len[i]) {
return false;
+ }
index_arr[i] = temp_index;
/* end multi index resolve */
}
/* arrays always contain numbers so further values are not valid */
- if (**path)
+ if (**path) {
return false;
+ }
/* flatten index over all dimensions */
{
@@ -4954,13 +5161,15 @@ static bool rna_path_parse_array_index(const char **path,
* \param r_ptr: The final RNA data holding the last property in \a path.
* \param r_prop: The final property of \a r_ptr, from \a path.
* \param r_index: The final index in the \a r_prop, if defined by \a path.
- * \param r_item_ptr: Only valid for Pointer and Collection, return the actual value of the pointer,
- * or of the collection item. Mutually exclusive with \a eval_pointer option.
+ * \param r_item_ptr: Only valid for Pointer and Collection,
+ * return the actual value of the pointer, or of the collection item.
+ * Mutually exclusive with \a eval_pointer option.
* \param r_elements: A list of \a PropertyElemRNA items
- * (pairs of \a PointerRNA, \a PropertyRNA that represent the whole given \a path).
- * \param eval_pointer: If \a true, and \a path leads to a Pointer property, or an item in a Collection property,
- * \a r_ptr will be set to the value of that property, and \a r_prop will be NULL.
- * Mutually exclusive with \a r_item_ptr.
+ * (pairs of \a PointerRNA, \a PropertyRNA that represent the whole given \a path).
+ * \param eval_pointer: If \a true, and \a path leads to a Pointer property,
+ * or an item in a Collection property,
+ * \a r_ptr will be set to the value of that property, and \a r_prop will be NULL.
+ * Mutually exclusive with \a r_item_ptr.
* \return \a true on success, \a false if the path is somehow invalid.
*/
static bool rna_path_parse(PointerRNA *ptr,
@@ -4988,8 +5197,9 @@ static bool rna_path_parse(PointerRNA *ptr,
prop = NULL;
curptr = *ptr;
- if (path == NULL || *path == '\0')
+ if (path == NULL || *path == '\0') {
return false;
+ }
while (*path) {
if (do_item_ptr) {
@@ -5016,8 +5226,9 @@ static bool rna_path_parse(PointerRNA *ptr,
prop = NULL;
if (use_id_prop) { /* look up property name in current struct */
IDProperty *group = RNA_struct_idprops(&curptr, 0);
- if (group && rna_token_strip_quotes(token))
+ if (group && rna_token_strip_quotes(token)) {
prop = (PropertyRNA *)IDP_GetPropertyFromGroup(group, token + 1);
+ }
}
else {
prop = RNA_struct_find_property(&curptr, token);
@@ -5118,21 +5329,24 @@ static bool rna_path_parse(PointerRNA *ptr,
}
/**
- * Resolve the given RNA Path to find the pointer and/or property indicated by fully resolving the path.
+ * Resolve the given RNA Path to find the pointer and/or property
+ * indicated by fully resolving the path.
*
* \note Assumes all pointers provided are valid
* \return True if path can be resolved to a valid "pointer + property" OR "pointer only"
*/
bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
{
- if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, NULL, NULL, true))
+ if (!rna_path_parse(ptr, path, r_ptr, r_prop, NULL, NULL, NULL, true)) {
return false;
+ }
return r_ptr->data != NULL;
}
/**
- * Resolve the given RNA Path to find the pointer and/or property + array index indicated by fully resolving the path.
+ * Resolve the given RNA Path to find the pointer and/or property + array index
+ * indicated by fully resolving the path.
*
* \note Assumes all pointers provided are valid.
* \return True if path can be resolved to a valid "pointer + property" OR "pointer only"
@@ -5140,14 +5354,16 @@ bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prop
bool RNA_path_resolve_full(
PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
{
- if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, true))
+ if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, true)) {
return false;
+ }
return r_ptr->data != NULL;
}
/**
- * Resolve the given RNA Path to find both the pointer AND property indicated by fully resolving the path.
+ * Resolve the given RNA Path to find both the pointer AND property
+ * indicated by fully resolving the path.
*
* This is a convenience method to avoid logic errors and ugly syntax.
* \note Assumes all pointers provided are valid
@@ -5176,20 +5392,23 @@ bool RNA_path_resolve_property(PointerRNA *ptr,
bool RNA_path_resolve_property_full(
PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
{
- if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, false))
+ if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, false)) {
return false;
+ }
return r_ptr->data != NULL && *r_prop != NULL;
}
/**
- * Resolve the given RNA Path to find both the pointer AND property indicated by fully resolving the path,
- * and get the value of the Pointer property (or item of the collection).
+ * Resolve the given RNA Path to find both the pointer AND property
+ * indicated by fully resolving the path, and get the value of the Pointer property
+ * (or item of the collection).
*
- * This is a convenience method to avoid logic errors and ugly syntax, it combines both \a RNA_path_resolve and
- * \a RNA_path_resolve_property in a single call.
+ * This is a convenience method to avoid logic errors and ugly syntax,
+ * it combines both \a RNA_path_resolve and #RNA_path_resolve_property in a single call.
* \note Assumes all pointers provided are valid.
- * \param r_item_pointer: The final Pointer or Collection item value. You must check for its validity before use!
+ * \param r_item_pointer: The final Pointer or Collection item value.
+ * You must check for its validity before use!
* \return True only if both a valid pointer and property are found after resolving the path
*/
bool RNA_path_resolve_property_and_item_pointer(PointerRNA *ptr,
@@ -5207,12 +5426,15 @@ bool RNA_path_resolve_property_and_item_pointer(PointerRNA *ptr,
/**
* Resolve the given RNA Path to find both the pointer AND property (as well as the array index)
- * indicated by fully resolving the path, and get the value of the Pointer property (or item of the collection).
+ * indicated by fully resolving the path,
+ * and get the value of the Pointer property (or item of the collection).
*
- * This is a convenience method to avoid logic errors and ugly syntax, it combines both \a RNA_path_resolve_full and
+ * This is a convenience method to avoid logic errors and ugly syntax,
+ * it combines both \a RNA_path_resolve_full and
* \a RNA_path_resolve_property_full in a single call.
* \note Assumes all pointers provided are valid.
- * \param r_item_pointer: The final Pointer or Collection item value. You must check for its validity before use!
+ * \param r_item_pointer: The final Pointer or Collection item value.
+ * You must check for its validity before use!
* \return True only if both a valid pointer and property are found after resolving the path
*/
bool RNA_path_resolve_property_and_item_pointer_full(PointerRNA *ptr,
@@ -5222,16 +5444,17 @@ bool RNA_path_resolve_property_and_item_pointer_full(PointerRNA *ptr,
int *r_index,
PointerRNA *r_item_ptr)
{
- if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, r_item_ptr, NULL, false))
+ if (!rna_path_parse(ptr, path, r_ptr, r_prop, r_index, r_item_ptr, NULL, false)) {
return false;
+ }
return r_ptr->data != NULL && *r_prop != NULL;
}
/**
* Resolve the given RNA Path into a linked list of PropertyElemRNA's.
*
- * To be used when complex operations over path are needed, like e.g. get relative paths, to avoid too much
- * string operations.
+ * To be used when complex operations over path are needed, like e.g. get relative paths,
+ * to avoid too much string operations.
*
* \return True if there was no error while resolving the path
* \note Assumes all pointers provided are valid
@@ -5253,8 +5476,9 @@ char *RNA_path_append(
/* add .identifier */
if (path) {
BLI_dynstr_append(dynstr, path);
- if (*path)
+ if (*path) {
BLI_dynstr_append(dynstr, ".");
+ }
}
BLI_dynstr_append(dynstr, RNA_property_identifier(prop));
@@ -5300,8 +5524,9 @@ char *RNA_path_back(const char *path)
char *result;
int i;
- if (!path)
+ if (!path) {
return NULL;
+ }
previous = NULL;
current = path;
@@ -5313,31 +5538,37 @@ char *RNA_path_back(const char *path)
token = rna_path_token(&current, fixedbuf, sizeof(fixedbuf), 0);
- if (!token)
+ if (!token) {
return NULL;
- if (token != fixedbuf)
+ }
+ if (token != fixedbuf) {
MEM_freeN(token);
+ }
/* in case of collection we also need to strip off [] */
token = rna_path_token(&current, fixedbuf, sizeof(fixedbuf), 1);
- if (token && token != fixedbuf)
+ if (token && token != fixedbuf) {
MEM_freeN(token);
+ }
- if (!*current)
+ if (!*current) {
break;
+ }
previous = current;
}
- if (!previous)
+ if (!previous) {
return NULL;
+ }
/* copy and strip off last token */
i = previous - path;
result = BLI_strdup(path);
- if (i > 0 && result[i - 1] == '.')
+ if (i > 0 && result[i - 1] == '.') {
i--;
+ }
result[i] = 0;
return result;
@@ -5457,8 +5688,9 @@ static char *rna_idp_path(PointerRNA *ptr,
}
}
}
- if (path)
+ if (path) {
break;
+ }
}
}
}
@@ -5476,9 +5708,11 @@ static char *rna_path_from_ID_to_idpgroup(PointerRNA *ptr)
BLI_assert(ptr->id.data != NULL);
- /* TODO, Support Bones/PoseBones. no pointers stored to the bones from here, only the ID. See example in [#25746]
- * Unless this is added only way to find this is to also search all bones and pose bones
- * of an armature or object */
+ /* TODO, Support Bones/PoseBones. no pointers stored to the bones from here, only the ID.
+ * See example in T25746.
+ * Unless this is added only way to find this is to also search
+ * all bones and pose bones of an armature or object.
+ */
RNA_id_pointer_create(ptr->id.data, &id_ptr);
haystack = RNA_struct_idprops(&id_ptr, false);
@@ -5495,8 +5729,9 @@ char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
{
char *ptrpath = NULL;
- if (!ptr->id.data || !ptr->data)
+ if (!ptr->id.data || !ptr->data) {
return NULL;
+ }
if (!RNA_struct_is_ID(ptr->type)) {
if (ptr->type->path) {
@@ -5513,17 +5748,20 @@ char *RNA_path_from_ID_to_struct(PointerRNA *ptr)
RNA_id_pointer_create(ptr->id.data, &parentptr);
userprop = RNA_struct_find_nested(&parentptr, ptr->type);
- if (userprop)
+ if (userprop) {
ptrpath = BLI_strdup(RNA_property_identifier(userprop));
- else
+ }
+ else {
return NULL; /* can't do anything about this case yet... */
+ }
}
else if (RNA_struct_is_a(ptr->type, &RNA_PropertyGroup)) {
/* special case, easier to deal with here then in ptr->type->path() */
return rna_path_from_ID_to_idpgroup(ptr);
}
- else
+ else {
return NULL;
+ }
}
return ptrpath;
@@ -5583,8 +5821,9 @@ char *RNA_path_from_ID_to_property_index(PointerRNA *ptr,
const char *propname;
char *ptrpath, *path;
- if (!ptr->id.data || !ptr->data)
+ if (!ptr->id.data || !ptr->data) {
return NULL;
+ }
/* path from ID to the struct holding this property */
ptrpath = RNA_path_from_ID_to_struct(ptr);
@@ -5635,7 +5874,8 @@ char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
}
/**
- * \return the path to given ptr/prop from the closest ancestor of given type, if any (else return NULL).
+ * \return the path to given ptr/prop from the closest ancestor of given type,
+ * if any (else return NULL).
*/
char *RNA_path_resolve_from_type_to_property(PointerRNA *ptr,
PropertyRNA *prop,
@@ -5708,7 +5948,8 @@ char *RNA_path_full_struct_py(struct PointerRNA *ptr)
data_path = RNA_path_from_ID_to_struct(ptr);
- /* XXX data_path may be NULL (see #36788), do we want to get the 'bpy.data.foo["bar"].(null)' stuff? */
+ /* XXX data_path may be NULL (see T36788),
+ * do we want to get the 'bpy.data.foo["bar"].(null)' stuff? */
ret = BLI_sprintfN("%s.%s", id_path, data_path);
if (data_path) {
@@ -5856,30 +6097,36 @@ void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_boolean_set(ptr, prop, value);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_boolean_get_array(PointerRNA *ptr, const char *name, bool *values)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_boolean_get_array(ptr, prop, values);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_boolean_set_array(PointerRNA *ptr, const char *name, const bool *values)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_boolean_set_array(ptr, prop, values);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
int RNA_int_get(PointerRNA *ptr, const char *name)
@@ -5899,30 +6146,36 @@ void RNA_int_set(PointerRNA *ptr, const char *name, int value)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_int_set(ptr, prop, value);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_int_get_array(ptr, prop, values);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_int_set_array(ptr, prop, values);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
float RNA_float_get(PointerRNA *ptr, const char *name)
@@ -5942,30 +6195,36 @@ void RNA_float_set(PointerRNA *ptr, const char *name, float value)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_float_set(ptr, prop, value);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_float_get_array(ptr, prop, values);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_float_set_array(ptr, prop, values);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
int RNA_enum_get(PointerRNA *ptr, const char *name)
@@ -5985,10 +6244,12 @@ void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_enum_set(ptr, prop, value);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_enum_set_identifier(bContext *C, PointerRNA *ptr, const char *name, const char *id)
@@ -5997,10 +6258,12 @@ void RNA_enum_set_identifier(bContext *C, PointerRNA *ptr, const char *name, con
if (prop) {
int value;
- if (RNA_property_enum_value(C, ptr, prop, id, &value))
+ if (RNA_property_enum_value(C, ptr, prop, id, &value)) {
RNA_property_enum_set(ptr, prop, value);
- else
+ }
+ else {
printf("%s: %s.%s has no enum id '%s'.\n", __func__, ptr->type->identifier, name, id);
+ }
}
else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
@@ -6132,10 +6395,12 @@ void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_string_set(ptr, prop, value);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
@@ -6168,40 +6433,48 @@ void RNA_pointer_add(PointerRNA *ptr, const char *name)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_pointer_add(ptr, prop);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_collection_begin(PointerRNA *ptr, const char *name, CollectionPropertyIterator *iter)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_collection_begin(ptr, prop, iter);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_collection_add(ptr, prop, r_value);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
void RNA_collection_clear(PointerRNA *ptr, const char *name)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, name);
- if (prop)
+ if (prop) {
RNA_property_collection_clear(ptr, prop);
- else
+ }
+ else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
+ }
}
int RNA_collection_length(PointerRNA *ptr, const char *name)
@@ -6319,11 +6592,13 @@ char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr)
RNA_STRUCT_BEGIN (ptr, prop) {
propname = RNA_property_identifier(prop);
- if (STREQ(propname, "rna_type"))
+ if (STREQ(propname, "rna_type")) {
continue;
+ }
- if (first_time == 0)
+ if (first_time == 0) {
BLI_dynstr_append(dynstr, ", ");
+ }
first_time = 0;
cstring = RNA_property_as_string(C, ptr, prop, -1, INT_MAX);
@@ -6707,8 +6982,9 @@ char *RNA_property_as_string(
RNA_property_collection_next(&collect_iter), i++) {
PointerRNA itemptr = collect_iter.ptr;
- if (i != 0)
+ if (i != 0) {
BLI_dynstr_append(dynstr, ", ");
+ }
/* now get every prop of the collection */
cstring = RNA_pointer_as_string(C, ptr, prop, &itemptr);
@@ -6769,9 +7045,11 @@ PropertyRNA *RNA_function_find_parameter(PointerRNA *UNUSED(ptr),
PropertyRNA *parm;
parm = func->cont.properties.first;
- for (; parm; parm = parm->next)
- if (STREQ(RNA_property_identifier(parm), identifier))
+ for (; parm; parm = parm->next) {
+ if (STREQ(RNA_property_identifier(parm), identifier)) {
break;
+ }
+ }
return parm;
}
@@ -6803,10 +7081,12 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms,
for (parm = func->cont.properties.first; parm; parm = parm->next) {
alloc_size += rna_parameter_size(parm);
- if (parm->flag_parameter & PARM_OUTPUT)
+ if (parm->flag_parameter & PARM_OUTPUT) {
parms->ret_count++;
- else
+ }
+ else {
parms->arg_count++;
+ }
}
parms->data = MEM_callocN(alloc_size, "RNA_parameter_list_create");
@@ -6829,22 +7109,28 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms,
if (!(parm->flag_parameter & PARM_REQUIRED) && !(parm->flag & PROP_DYNAMIC)) {
switch (parm->type) {
case PROP_BOOLEAN:
- if (parm->arraydimension)
+ if (parm->arraydimension) {
rna_property_boolean_get_default_array_values((BoolPropertyRNA *)parm, data);
- else
+ }
+ else {
memcpy(data, &((BoolPropertyRNA *)parm)->defaultvalue, size);
+ }
break;
case PROP_INT:
- if (parm->arraydimension)
+ if (parm->arraydimension) {
rna_property_int_get_default_array_values((IntPropertyRNA *)parm, data);
- else
+ }
+ else {
memcpy(data, &((IntPropertyRNA *)parm)->defaultvalue, size);
+ }
break;
case PROP_FLOAT:
- if (parm->arraydimension)
+ if (parm->arraydimension) {
rna_property_float_get_default_array_values((FloatPropertyRNA *)parm, data);
- else
+ }
+ else {
memcpy(data, &((FloatPropertyRNA *)parm)->defaultvalue, size);
+ }
break;
case PROP_ENUM:
memcpy(data, &((EnumPropertyRNA *)parm)->defaultvalue, size);
@@ -6881,13 +7167,15 @@ void RNA_parameter_list_free(ParameterList *parms)
parm = parms->func->cont.properties.first;
for (tot = 0; parm; parm = parm->next) {
- if (parm->type == PROP_COLLECTION)
+ if (parm->type == PROP_COLLECTION) {
BLI_freelistN((ListBase *)((char *)parms->data + tot));
+ }
else if (parm->flag & PROP_DYNAMIC) {
/* for dynamic arrays and strings, data is a pointer to an array */
ParameterDynAlloc *data_alloc = (void *)(((char *)parms->data) + tot);
- if (data_alloc->array)
+ if (data_alloc->array) {
MEM_freeN(data_alloc->array);
+ }
}
tot += rna_parameter_size(parm);
@@ -6953,9 +7241,11 @@ void RNA_parameter_get(ParameterList *parms, PropertyRNA *parm, void **value)
RNA_parameter_list_begin(parms, &iter);
- for (; iter.valid; RNA_parameter_list_next(&iter))
- if (iter.parm == parm)
+ for (; iter.valid; RNA_parameter_list_next(&iter)) {
+ if (iter.parm == parm) {
break;
+ }
+ }
if (iter.valid) {
if (parm->flag & PROP_DYNAMIC) {
@@ -6979,12 +7269,15 @@ void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void
PropertyRNA *parm;
parm = parms->func->cont.properties.first;
- for (; parm; parm = parm->next)
- if (STREQ(RNA_property_identifier(parm), identifier))
+ for (; parm; parm = parm->next) {
+ if (STREQ(RNA_property_identifier(parm), identifier)) {
break;
+ }
+ }
- if (parm)
+ if (parm) {
RNA_parameter_get(parms, parm, value);
+ }
}
void RNA_parameter_set(ParameterList *parms, PropertyRNA *parm, const void *value)
@@ -6993,9 +7286,11 @@ void RNA_parameter_set(ParameterList *parms, PropertyRNA *parm, const void *valu
RNA_parameter_list_begin(parms, &iter);
- for (; iter.valid; RNA_parameter_list_next(&iter))
- if (iter.parm == parm)
+ for (; iter.valid; RNA_parameter_list_next(&iter)) {
+ if (iter.parm == parm) {
break;
+ }
+ }
if (iter.valid) {
if (parm->flag & PROP_DYNAMIC) {
@@ -7017,8 +7312,9 @@ void RNA_parameter_set(ParameterList *parms, PropertyRNA *parm, const void *valu
break;
}
size *= data_alloc->array_tot;
- if (data_alloc->array)
+ if (data_alloc->array) {
MEM_freeN(data_alloc->array);
+ }
data_alloc->array = MEM_mallocN(size, __func__);
memcpy(data_alloc->array, value, size);
}
@@ -7035,12 +7331,15 @@ void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, cons
PropertyRNA *parm;
parm = parms->func->cont.properties.first;
- for (; parm; parm = parm->next)
- if (STREQ(RNA_property_identifier(parm), identifier))
+ for (; parm; parm = parm->next) {
+ if (STREQ(RNA_property_identifier(parm), identifier)) {
break;
+ }
+ }
- if (parm)
+ if (parm) {
RNA_parameter_set(parms, parm, value);
+ }
}
int RNA_parameter_dynamic_length_get(ParameterList *parms, PropertyRNA *parm)
@@ -7050,12 +7349,15 @@ int RNA_parameter_dynamic_length_get(ParameterList *parms, PropertyRNA *parm)
RNA_parameter_list_begin(parms, &iter);
- for (; iter.valid; RNA_parameter_list_next(&iter))
- if (iter.parm == parm)
+ for (; iter.valid; RNA_parameter_list_next(&iter)) {
+ if (iter.parm == parm) {
break;
+ }
+ }
- if (iter.valid)
+ if (iter.valid) {
len = RNA_parameter_dynamic_length_get_data(parms, parm, iter.data);
+ }
RNA_parameter_list_end(&iter);
@@ -7068,12 +7370,15 @@ void RNA_parameter_dynamic_length_set(ParameterList *parms, PropertyRNA *parm, i
RNA_parameter_list_begin(parms, &iter);
- for (; iter.valid; RNA_parameter_list_next(&iter))
- if (iter.parm == parm)
+ for (; iter.valid; RNA_parameter_list_next(&iter)) {
+ if (iter.parm == parm) {
break;
+ }
+ }
- if (iter.valid)
+ if (iter.valid) {
RNA_parameter_dynamic_length_set_data(parms, parm, iter.data, length);
+ }
RNA_parameter_list_end(&iter);
}
@@ -7120,8 +7425,9 @@ int RNA_function_call_lookup(bContext *C,
func = RNA_struct_find_function(ptr->type, identifier);
- if (func)
+ if (func) {
return RNA_function_call(C, reports, ptr, func, parms);
+ }
return -1;
}
@@ -7173,9 +7479,11 @@ static int rna_function_format_array_length(const char *format, int ofs, int fle
char lenbuf[16];
int idx = 0;
- if (format[ofs++] == '[')
- for (; ofs < flen && format[ofs] != ']' && idx < sizeof(lenbuf) - 1; idx++, ofs++)
+ if (format[ofs++] == '[') {
+ for (; ofs < flen && format[ofs] != ']' && idx < sizeof(lenbuf) - 1; idx++, ofs++) {
lenbuf[idx] = format[ofs];
+ }
+ }
if (ofs < flen && format[ofs + 1] == ']') {
/* XXX put better error reporting for (ofs >= flen) or idx over lenbuf capacity */
@@ -7208,10 +7516,12 @@ static int rna_function_parameter_parse(PointerRNA *ptr,
return -1;
}
- if (len == 0)
+ if (len == 0) {
*((bool *)dest) = *((bool *)src);
- else
+ }
+ else {
memcpy(dest, src, len * sizeof(bool));
+ }
break;
}
@@ -7225,10 +7535,12 @@ static int rna_function_parameter_parse(PointerRNA *ptr,
return -1;
}
- if (len == 0)
+ if (len == 0) {
*((int *)dest) = *((int *)src);
- else
+ }
+ else {
memcpy(dest, src, len * sizeof(int));
+ }
break;
}
@@ -7239,10 +7551,12 @@ static int rna_function_parameter_parse(PointerRNA *ptr,
return -1;
}
- if (len == 0)
+ if (len == 0) {
*((float *)dest) = *((float *)src);
- else
+ }
+ else {
memcpy(dest, src, len * sizeof(float));
+ }
break;
}
@@ -7341,10 +7655,12 @@ static int rna_function_parameter_parse(PointerRNA *ptr,
break;
}
default: {
- if (len == 0)
+ if (len == 0) {
fprintf(stderr, "%s.%s: unknown type for parameter %s\n", tid, fid, pid);
- else
+ }
+ else {
fprintf(stderr, "%s.%s: unknown array type for parameter %s\n", tid, fid, pid);
+ }
return -1;
}
@@ -7466,12 +7782,14 @@ int RNA_function_call_direct_va(bContext *C,
}
}
- if (err != 0)
+ if (err != 0) {
break;
+ }
}
- if (err == 0)
+ if (err == 0) {
err = RNA_function_call(C, reports, ptr, func, &parms);
+ }
/* XXX throw error when more parameters than those needed are passed or leave silent? */
if (err == 0 && pret && ofs < flen && format[ofs++] == 'R') {
@@ -7556,8 +7874,9 @@ int RNA_function_call_direct_va_lookup(bContext *C,
func = RNA_struct_find_function(ptr->type, identifier);
- if (func)
+ if (func) {
return RNA_function_call_direct_va(C, reports, ptr, func, format, args);
+ }
return 0;
}
@@ -7657,7 +7976,8 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
}
default:
- /* FIXME: are there still any cases that haven't been handled? comment out "default" block to check :) */
+ /* FIXME: are there still any cases that haven't been handled?
+ * comment out "default" block to check :) */
return false;
}
}
@@ -7707,13 +8027,14 @@ bool RNA_property_copy(
PropertyRNA *prop_dst = prop;
PropertyRNA *prop_src = prop;
- /* Ensure we get real property data, be it an actual RNA property, or an IDProperty in disguise. */
+ /* Ensure we get real property data,
+ * be it an actual RNA property, or an IDProperty in disguise. */
prop_dst = rna_ensure_property_realdata(&prop_dst, ptr);
prop_src = rna_ensure_property_realdata(&prop_src, fromptr);
/* IDprops: destination may not exist, if source does and is set, try to create it. */
- /* Note: this is sort of quick hack/bandage to fix the issue, we need to rethink how IDProps are handled
- * in 'diff' RNA code completely, imho... */
+ /* Note: this is sort of quick hack/bandage to fix the issue,
+ * we need to rethink how IDProps are handled in 'diff' RNA code completely, imho... */
if (prop_src != NULL && prop_dst == NULL && RNA_property_is_set(fromptr, prop)) {
BLI_assert(prop_src->magic != RNA_MAGIC);
IDProperty *idp_dst = RNA_struct_idprops(ptr, true);
@@ -7786,12 +8107,15 @@ bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACo
PropertyRNA *iterprop;
bool equals = true;
- if (ptr_a == NULL && ptr_b == NULL)
+ if (ptr_a == NULL && ptr_b == NULL) {
return true;
- else if (ptr_a == NULL || ptr_b == NULL)
+ }
+ else if (ptr_a == NULL || ptr_b == NULL) {
return false;
- else if (ptr_a->type != ptr_b->type)
+ }
+ else if (ptr_a->type != ptr_b->type) {
return false;
+ }
iterprop = RNA_struct_iterator_property(ptr_a->type);
@@ -7813,13 +8137,16 @@ bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACo
/** Generic RNA property diff function.
*
- * \note about \a prop and \a prop_a/prop_b parameters: the former is exptected to be an 'un-resolved' one,
- * while the two laters are expected to be fully resolved ones (i.e. to be the IDProps when they should be, etc.).
+ * \note about \a prop and \a prop_a/prop_b parameters:
+ * the former is exptected to be an 'un-resolved' one,
+ * while the two laters are expected to be fully resolved ones
+ * (i.e. to be the IDProps when they should be, etc.).
* When \a prop is given, \a prop_a and \a prop_b should always be NULL, and vice-versa.
* This is necessary, because we cannot perform 'set/unset' checks on resolved properties
* (unset IDProps would merely be NULL then).
*
- * \note When there is no equality, but we cannot determine an order (greater than/lesser than), we return 1.
+ * \note When there is no equality,
+ * but we cannot determine an order (greater than/lesser than), we return 1.
*/
static int rna_property_override_diff(Main *bmain,
PointerRNA *ptr_a,
@@ -7861,7 +8188,8 @@ static int rna_property_override_diff(Main *bmain,
}
if (prop != NULL) {
- /* Ensure we get real property data, be it an actual RNA property, or an IDProperty in disguise. */
+ /* Ensure we get real property data, be it an actual RNA property,
+ * or an IDProperty in disguise. */
prop_a = rna_ensure_property_realdata(&prop_a, ptr_a);
prop_b = rna_ensure_property_realdata(&prop_b, ptr_b);
@@ -7885,7 +8213,8 @@ static int rna_property_override_diff(Main *bmain,
const int len_b = RNA_property_array_length(ptr_b, prop_b);
if (len_a != len_b) {
- /* Do not handle override in that case, we do not support insertion/deletion from arrays for now. */
+ /* Do not handle override in that case,
+ * we do not support insertion/deletion from arrays for now. */
return len_a > len_b ? 1 : -1;
}
@@ -7949,7 +8278,8 @@ static int rna_property_override_diff(Main *bmain,
return diff;
}
-/* Modify local data-block to make it ready for override application (only needed for diff operations, where we use
+/* Modify local data-block to make it ready for override application
+ * (only needed for diff operations, where we use
* the local data-block's data as second operand). */
static bool rna_property_override_operation_store(Main *bmain,
PointerRNA *ptr_local,
@@ -7975,7 +8305,8 @@ static bool rna_property_override_operation_store(Main *bmain,
}
if (len_local != len_reference || len_local != len_storage) {
- /* Do not handle override in that case, we do not support insertion/deletion from arrays for now. */
+ /* Do not handle override in that case,
+ * we do not support insertion/deletion from arrays for now. */
return changed;
}
@@ -8093,7 +8424,8 @@ static bool rna_property_override_operation_apply(Main *bmain,
}
if (len_local != len_reference || (ptr_storage && len_local != len_storage)) {
- /* Do not handle override in that case, we do not support insertion/deletion from arrays for now. */
+ /* Do not handle override in that case,
+ * we do not support insertion/deletion from arrays for now. */
return false;
}
@@ -8119,7 +8451,8 @@ static bool rna_property_override_operation_apply(Main *bmain,
* with respect to given restrictive sets of properties.
* If requested, will generate needed new property overrides, and/or restore values from reference.
*
- * \param r_report_flags: If given, will be set with flags matching actions taken by the function on \a ptr_local.
+ * \param r_report_flags: If given,
+ * will be set with flags matching actions taken by the function on \a ptr_local.
*
* \return True if _resulting_ \a ptr_local does match \a ptr_reference.
*/
@@ -8168,7 +8501,8 @@ bool RNA_struct_override_matches(Main *bmain,
PropertyRNA *prop_local = iter.ptr.data;
PropertyRNA *prop_reference = iter.ptr.data;
- /* Ensure we get real property data, be it an actual RNA property, or an IDProperty in disguise. */
+ /* Ensure we get real property data, be it an actual RNA property,
+ * or an IDProperty in disguise. */
prop_local = rna_ensure_property_realdata(&prop_local, ptr_local);
prop_reference = rna_ensure_property_realdata(&prop_reference, ptr_reference);
@@ -8290,7 +8624,10 @@ bool RNA_struct_override_matches(Main *bmain,
}
else {
/* Too noisy for now, this triggers on runtime props like transform matrices etc. */
- /* BLI_assert(!"We have differences between reference and overriding data on non-editable property."); */
+#if 0
+ BLI_assert(!"We have differences between reference and "
+ "overriding data on non-editable property.");
+#endif
matching = false;
}
}
@@ -8343,7 +8680,8 @@ bool RNA_struct_override_matches(Main *bmain,
return matching;
}
-/** Store needed second operands into \a storage data-block for differential override operations. */
+/** Store needed second operands into \a storage data-block
+ * for differential override operations. */
bool RNA_struct_override_store(Main *bmain,
PointerRNA *ptr_local,
PointerRNA *ptr_reference,
@@ -8365,7 +8703,8 @@ bool RNA_struct_override_store(Main *bmain,
PointerRNA data_storage;
PropertyRNA *prop_storage = NULL;
- /* It is totally OK if this does not success, only a subset of override operations actually need storage. */
+ /* It is totally OK if this does not success,
+ * only a subset of override operations actually need storage. */
if (ptr_storage && (ptr_storage->id.data != NULL)) {
RNA_path_resolve_property(ptr_storage, op->rna_path, &data_storage, &prop_storage);
}
@@ -8441,7 +8780,8 @@ void RNA_struct_override_apply(Main *bmain,
TIMEIT_START_AVERAGED(RNA_struct_override_apply);
#endif
/* Note: Applying insert operations in a separate pass is mandatory.
- * We could optimize this later, but for now, as inneficient as it is, don't think this is a critical point.
+ * We could optimize this later, but for now, as inneficient as it is,
+ * don't think this is a critical point.
*/
bool do_insert = false;
for (int i = 0; i < 2; i++, do_insert = true) {
@@ -8458,7 +8798,8 @@ void RNA_struct_override_apply(Main *bmain,
PointerRNA data_storage, data_item_storage;
PropertyRNA *prop_storage = NULL;
- /* It is totally OK if this does not success, only a subset of override operations actually need storage. */
+ /* It is totally OK if this does not success,
+ * only a subset of override operations actually need storage. */
if (ptr_storage && (ptr_storage->id.data != NULL)) {
RNA_path_resolve_property_and_item_pointer(
ptr_storage, op->rna_path, &data_storage, &prop_storage, &data_item_storage);
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index 36e9fde9a7a..bb3585df24e 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -247,7 +247,8 @@ static void rna_Action_frame_range_get(PointerRNA *ptr, float *values)
calc_action_range(ptr->id.data, values, values + 1, false);
}
-/* used to check if an action (value pointer) is suitable to be assigned to the ID-block that is ptr */
+/* Used to check if an action (value pointer)
+ * is suitable to be assigned to the ID-block that is ptr. */
bool rna_Action_id_poll(PointerRNA *ptr, PointerRNA value)
{
ID *srcId = (ID *)ptr->id.data;
@@ -267,7 +268,8 @@ bool rna_Action_id_poll(PointerRNA *ptr, PointerRNA value)
return 0;
}
-/* used to check if an action (value pointer) can be assigned to Action Editor given current mode */
+/* Used to check if an action (value pointer)
+ * can be assigned to Action Editor given current mode. */
bool rna_Action_actedit_assign_poll(PointerRNA *ptr, PointerRNA value)
{
SpaceAction *saction = (SpaceAction *)ptr->data;
@@ -615,7 +617,14 @@ static void rna_def_action_group(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_EXPANDED);
- RNA_def_property_ui_text(prop, "Expanded", "Action group is expanded");
+ RNA_def_property_ui_text(prop, "Expanded", "Action group is expanded except in graph editor");
+ RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "show_expanded_graph", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_EXPANDED_G);
+ RNA_def_property_ui_text(
+ prop, "Expanded in Graph Editor", "Action group is expanded in graph editor");
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
/* color set */
@@ -769,7 +778,8 @@ static void rna_def_action(BlenderRNA *brna)
prop = RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
RNA_def_property_struct_type(prop, "TimelineMarker");
- /* Use lib exception so the list isn't grayed out; adding/removing is still banned though, see T45689 */
+ /* Use lib exception so the list isn't grayed out;
+ * adding/removing is still banned though, see T45689. */
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
RNA_def_property_ui_text(
prop, "Pose Markers", "Markers specific to this action, for labeling poses");
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 3f92d6f1210..15429ec6b5e 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -48,7 +48,8 @@ const EnumPropertyItem rna_enum_keyingset_path_grouping_items[] = {
{0, NULL, 0, NULL, NULL},
};
-/* It would be cool to get rid of this 'INSERTKEY_' prefix in 'py strings' values, but it would break existing
+/* It would be cool to get rid of this 'INSERTKEY_' prefix in 'py strings' values,
+ * but it would break existing
* exported keyingset... :/
*/
const EnumPropertyItem rna_enum_keying_flag_items[] = {
@@ -225,7 +226,8 @@ static void RKS_GEN_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks,
/* ------ */
-/* XXX: the exact purpose of this is not too clear... maybe we want to revise this at some point? */
+/* XXX: the exact purpose of this is not too clear...
+ * maybe we want to revise this at some point? */
static StructRNA *rna_KeyingSetInfo_refine(PointerRNA *ptr)
{
KeyingSetInfo *ksi = (KeyingSetInfo *)ptr->data;
@@ -263,7 +265,8 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain,
int have_function[3];
/* setup dummy type info to store static properties in */
- /* TODO: perhaps we want to get users to register as if they're using 'KeyingSet' directly instead? */
+ /* TODO: perhaps we want to get users to register
+ * as if they're using 'KeyingSet' directly instead? */
RNA_pointer_create(NULL, &RNA_KeyingSetInfo, &dummyksi, &dummyptr);
/* validate the python class */
@@ -471,7 +474,8 @@ static KS_Path *rna_KeyingSet_paths_add(KeyingSet *keyingset,
KS_Path *ksp = NULL;
short flag = 0;
- /* special case when index = -1, we key the whole array (as with other places where index is used) */
+ /* Special case when index = -1, we key the whole array
+ * (as with other places where index is used). */
if (index == -1) {
flag |= KSP_FLAG_WHOLE_ARRAY;
index = 0;
@@ -507,7 +511,8 @@ static void rna_KeyingSet_paths_remove(KeyingSet *keyingset,
RNA_POINTER_INVALIDATE(ksp_ptr);
/* the active path number will most likely have changed */
- /* TODO: we should get more fancy and actually check if it was removed, but this will do for now */
+ /* TODO: we should get more fancy and actually check if it was removed,
+ * but this will do for now */
keyingset->active_path = 0;
}
@@ -595,7 +600,7 @@ static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_
}
static FCurve *rna_Driver_new(
- ID *id, AnimData *adt, ReportList *reports, const char *rna_path, int array_index)
+ ID *id, AnimData *adt, Main *bmain, ReportList *reports, const char *rna_path, int array_index)
{
if (rna_path[0] == '\0') {
BKE_report(reports, RPT_ERROR, "F-Curve data path empty, invalid argument");
@@ -610,16 +615,20 @@ static FCurve *rna_Driver_new(
short add_mode = 1;
FCurve *fcu = verify_driver_fcurve(id, rna_path, array_index, add_mode);
BLI_assert(fcu != NULL);
+
+ DEG_relations_tag_update(bmain);
+
return fcu;
}
-static void rna_Driver_remove(AnimData *adt, ReportList *reports, FCurve *fcu)
+static void rna_Driver_remove(AnimData *adt, Main *bmain, ReportList *reports, FCurve *fcu)
{
if (!BLI_remlink_safe(&adt->drivers, fcu)) {
BKE_report(reports, RPT_ERROR, "Driver not found in this animation data");
return;
}
free_fcurve(fcu);
+ DEG_relations_tag_update(bmain);
}
static FCurve *rna_Driver_find(AnimData *adt,
@@ -688,8 +697,9 @@ static void rna_def_common_keying_flags(StructRNA *srna, short reg)
"Override Insert Keyframes Default- Only Needed",
"Override default setting to only insert keyframes where they're "
"needed in the relevant F-Curves");
- if (reg)
+ if (reg) {
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ }
prop = RNA_def_property(srna, "use_insertkey_override_visual", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingoverride", INSERTKEY_MATRIX);
@@ -697,8 +707,9 @@ static void rna_def_common_keying_flags(StructRNA *srna, short reg)
prop,
"Override Insert Keyframes Default - Visual",
"Override default setting to insert keyframes based on 'visual transforms'");
- if (reg)
+ if (reg) {
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ }
prop = RNA_def_property(srna, "use_insertkey_override_xyz_to_rgb", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingoverride", INSERTKEY_XYZ2RGB);
@@ -707,8 +718,9 @@ static void rna_def_common_keying_flags(StructRNA *srna, short reg)
"Override F-Curve Colors - XYZ to RGB",
"Override default setting to set color for newly added transformation F-Curves "
"(Location, Rotation, Scale) to be based on the transform axis");
- if (reg)
+ if (reg) {
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ }
/* value to override defaults with */
prop = RNA_def_property(srna, "use_insertkey_needed", PROP_BOOLEAN, PROP_NONE);
@@ -716,15 +728,17 @@ static void rna_def_common_keying_flags(StructRNA *srna, short reg)
RNA_def_property_ui_text(prop,
"Insert Keyframes - Only Needed",
"Only insert keyframes where they're needed in the relevant F-Curves");
- if (reg)
+ if (reg) {
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ }
prop = RNA_def_property(srna, "use_insertkey_visual", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingflag", INSERTKEY_MATRIX);
RNA_def_property_ui_text(
prop, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'");
- if (reg)
+ if (reg) {
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ }
prop = RNA_def_property(srna, "use_insertkey_xyz_to_rgb", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "keyingflag", INSERTKEY_XYZ2RGB);
@@ -732,8 +746,9 @@ static void rna_def_common_keying_flags(StructRNA *srna, short reg)
"F-Curve Colors - XYZ to RGB",
"Color for newly added transformation F-Curves (Location, Rotation, "
"Scale) is based on the transform axis");
- if (reg)
+ if (reg) {
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ }
}
/* --- */
@@ -1010,7 +1025,10 @@ static void rna_def_keyingset(BlenderRNA *brna)
RNA_def_property_string_sdna(prop, NULL, "idname");
RNA_def_property_flag(prop, PROP_REGISTER);
RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC);
- /* RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL); */ /* NOTE: disabled, as ID name shouldn't be editable */
+ /* NOTE: disabled, as ID name shouldn't be editable */
+# if 0
+ RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
+# endif
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
@@ -1115,7 +1133,7 @@ static void rna_api_animdata_drivers(BlenderRNA *brna, PropertyRNA *cprop)
/* AnimData.drivers.new(...) */
func = RNA_def_function(srna, "new", "rna_Driver_new");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS | FUNC_USE_MAIN);
parm = RNA_def_string(func, "data_path", NULL, 0, "Data Path", "F-Curve data path to use");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX);
@@ -1125,7 +1143,7 @@ static void rna_api_animdata_drivers(BlenderRNA *brna, PropertyRNA *cprop)
/* AnimData.drivers.remove(...) */
func = RNA_def_function(srna, "remove", "rna_Driver_remove");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN);
parm = RNA_def_pointer(func, "driver", "FCurve", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
diff --git a/source/blender/makesrna/intern/rna_animviz.c b/source/blender/makesrna/intern/rna_animviz.c
index 7d034068311..17a58a61fb5 100644
--- a/source/blender/makesrna/intern/rna_animviz.c
+++ b/source/blender/makesrna/intern/rna_animviz.c
@@ -40,7 +40,13 @@
const EnumPropertyItem rna_enum_motionpath_bake_location_items[] = {
{MOTIONPATH_BAKE_HEADS, "HEADS", 0, "Heads", "Calculate bone paths from heads"},
{0, "TAILS", 0, "Tails", "Calculate bone paths from tails"},
- //{MOTIONPATH_BAKE_CENTERS, "CENTROID", 0, "Centers", "Calculate bone paths from center of mass"},
+#if 0
+ {MOTIONPATH_BAKE_CENTERS,
+ "CENTROID",
+ 0,
+ "Centers",
+ "Calculate bone paths from center of mass"},
+#endif
{0, NULL, 0, NULL, NULL},
};
@@ -296,9 +302,8 @@ static void rna_def_animviz_paths(BlenderRNA *brna)
/* Readonly Property - Do any motion paths exist/need updating? (Mainly for bone paths) */
prop = RNA_def_property(srna, "has_motion_paths", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "path_bakeflag", MOTIONPATH_BAKE_HAS_PATHS);
- RNA_def_property_clear_flag(
- prop,
- PROP_EDITABLE); /* NOTE: This is really an internal state var for convenience, so don't allow edits! */
+ /* NOTE: This is really an internal state var for convenience, so don't allow edits! */
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(
prop, "Has Motion Paths", "Are there any bone paths that will need updating (read-only)");
}
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 0c8c887d882..5461aaa0f1a 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -588,7 +588,8 @@ static void rna_Armature_transform(struct bArmature *arm, Main *bmain, float *ma
#else
-/* Settings for curved bbone settings - The posemode values get applied over the top of the editmode ones */
+/* Settings for curved bbone settings -
+ * The posemode values get applied over the top of the editmode ones. */
void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
{
# define RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone) \
@@ -605,14 +606,14 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
/* Roll In/Out */
prop = RNA_def_property(srna, "bbone_rollin", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "roll1");
- RNA_def_property_range(prop, -M_PI * 2.0, M_PI * 2.0);
+ RNA_def_property_ui_range(prop, -M_PI * 2, M_PI * 2, 10, 2);
RNA_def_property_ui_text(
prop, "Roll In", "Roll offset for the start of the B-Bone, adjusts twist");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
prop = RNA_def_property(srna, "bbone_rollout", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "roll2");
- RNA_def_property_range(prop, -M_PI * 2.0, M_PI * 2.0);
+ RNA_def_property_ui_range(prop, -M_PI * 2, M_PI * 2, 10, 2);
RNA_def_property_ui_text(
prop, "Roll Out", "Roll offset for the end of the B-Bone, adjusts twist");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
@@ -627,29 +628,29 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
/* Curve X/Y Offsets */
prop = RNA_def_property(srna, "bbone_curveinx", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "curveInX");
- RNA_def_property_range(prop, -5.0f, 5.0f);
+ RNA_def_property_float_sdna(prop, NULL, "curve_in_x");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_ui_text(
prop, "In X", "X-axis handle offset for start of the B-Bone's curve, adjusts curvature");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
prop = RNA_def_property(srna, "bbone_curveiny", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "curveInY");
- RNA_def_property_range(prop, -5.0f, 5.0f);
+ RNA_def_property_float_sdna(prop, NULL, "curve_in_y");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_ui_text(
prop, "In Y", "Y-axis handle offset for start of the B-Bone's curve, adjusts curvature");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
prop = RNA_def_property(srna, "bbone_curveoutx", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "curveOutX");
- RNA_def_property_range(prop, -5.0f, 5.0f);
+ RNA_def_property_float_sdna(prop, NULL, "curve_out_x");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_ui_text(
prop, "Out X", "X-axis handle offset for end of the B-Bone's curve, adjusts curvature");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
prop = RNA_def_property(srna, "bbone_curveouty", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "curveOutY");
- RNA_def_property_range(prop, -5.0f, 5.0f);
+ RNA_def_property_float_sdna(prop, NULL, "curve_out_y");
+ RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_ui_text(
prop, "Out Y", "Y-axis handle offset for end of the B-Bone's curve, adjusts curvature");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
@@ -657,37 +658,61 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
/* Ease In/Out */
prop = RNA_def_property(srna, "bbone_easein", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ease1");
- RNA_def_property_range(prop, -5.0f, 5.0f);
+ RNA_def_property_ui_range(prop, -5.0f, 5.0f, 1, 3);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Ease In", "Length of first Bezier Handle (for B-Bones only)");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
prop = RNA_def_property(srna, "bbone_easeout", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ease2");
- RNA_def_property_range(prop, -5.0f, 5.0f);
+ RNA_def_property_ui_range(prop, -5.0f, 5.0f, 1, 3);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Ease Out", "Length of second Bezier Handle (for B-Bones only)");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
/* Scale In/Out */
- prop = RNA_def_property(srna, "bbone_scalein", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "scaleIn");
- RNA_def_property_range(prop, 0.0f, 5.0f);
+ prop = RNA_def_property(srna, "bbone_scaleinx", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "scale_in_x");
+ RNA_def_property_flag(prop, PROP_PROPORTIONAL);
+ RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, 3);
RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(
- prop,
- "Scale In",
- "Scale factor for start of the B-Bone, adjusts thickness (for tapering effects)");
+ RNA_def_property_ui_text(prop,
+ "Scale In X",
+ "X-axis scale factor for start of the B-Bone, "
+ "adjusts thickness (for tapering effects)");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
- prop = RNA_def_property(srna, "bbone_scaleout", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "scaleOut");
- RNA_def_property_range(prop, 0.0f, 5.0f);
+ prop = RNA_def_property(srna, "bbone_scaleiny", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "scale_in_y");
+ RNA_def_property_flag(prop, PROP_PROPORTIONAL);
+ RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, 3);
RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(
- prop,
- "Scale Out",
- "Scale factor for end of the B-Bone, adjusts thickness (for tapering effects)");
+ RNA_def_property_ui_text(prop,
+ "Scale In Y",
+ "Y-axis scale factor for start of the B-Bone, "
+ "adjusts thickness (for tapering effects)");
+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
+
+ prop = RNA_def_property(srna, "bbone_scaleoutx", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "scale_out_x");
+ RNA_def_property_flag(prop, PROP_PROPORTIONAL);
+ RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, 3);
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop,
+ "Scale Out X",
+ "X-axis scale factor for end of the B-Bone, "
+ "adjusts thickness (for tapering effects)");
+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
+
+ prop = RNA_def_property(srna, "bbone_scaleouty", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "scale_out_y");
+ RNA_def_property_flag(prop, PROP_PROPORTIONAL);
+ RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, 3);
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop,
+ "Scale Out Y",
+ "Y-axis scale factor for end of the B-Bone, "
+ "adjusts thickness (for tapering effects)");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
# undef RNA_DEF_CURVEBONE_UPDATE
@@ -726,29 +751,35 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop);
- if (editbone)
+ if (editbone) {
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_EditBone_name_set");
- else
+ }
+ else {
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Bone_name_set");
+ }
RNA_def_property_update(prop, 0, "rna_Bone_update_renamed");
/* flags */
prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
RNA_def_property_boolean_sdna(prop, NULL, "layer", 1);
RNA_def_property_array(prop, 32);
- if (editbone)
+ if (editbone) {
RNA_def_property_boolean_funcs(prop, NULL, "rna_EditBone_layer_set");
- else
+ }
+ else {
RNA_def_property_boolean_funcs(prop, NULL, "rna_Bone_layer_set");
+ }
RNA_def_property_ui_text(prop, "Layers", "Layers bone exists in");
RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
prop = RNA_def_property(srna, "use_connect", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_CONNECTED);
- if (editbone)
+ if (editbone) {
RNA_def_property_boolean_funcs(prop, NULL, "rna_EditBone_connected_set");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
RNA_def_property_ui_text(
prop, "Connected", "When bone has a parent, bone's head is stuck to the parent's tail");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
@@ -828,10 +859,12 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop = RNA_def_property(srna, "head_radius", PROP_FLOAT, PROP_DISTANCE);
- if (editbone)
+ if (editbone) {
RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
- else
+ }
+ else {
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
+ }
RNA_def_property_float_sdna(prop, NULL, "rad_head");
/* XXX range is 0 to lim, where lim = 10000.0f * MAX2(1.0, view3d->grid); */
/*RNA_def_property_range(prop, 0, 1000); */
@@ -840,10 +873,12 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only)");
prop = RNA_def_property(srna, "tail_radius", PROP_FLOAT, PROP_DISTANCE);
- if (editbone)
+ if (editbone) {
RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
- else
+ }
+ else {
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
+ }
RNA_def_property_float_sdna(prop, NULL, "rad_tail");
/* XXX range is 0 to lim, where lim = 10000.0f * MAX2(1.0, view3d->grid); */
/*RNA_def_property_range(prop, 0, 1000); */
@@ -1108,7 +1143,7 @@ static void rna_def_edit_bone(BlenderRNA *brna)
prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
/*RNA_def_property_float_sdna(prop, NULL, ""); */ /* doesn't access any real data */
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
- //RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_THICK_WRAP); /* no reference to original data */
RNA_def_property_ui_text(
prop,
diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c
index f533a8017de..95c5a31db8e 100644
--- a/source/blender/makesrna/intern/rna_boid.c
+++ b/source/blender/makesrna/intern/rna_boid.c
@@ -75,12 +75,26 @@ const EnumPropertyItem rna_enum_boidrule_type_items[] = {
"Maintain speed, flight level or wander"},
{eBoidRuleType_Fight, "FIGHT", 0, "Fight", "Go to closest enemy and attack when in range"},
#if 0
- {eBoidRuleType_Protect, "PROTECT", 0, "Protect", "Go to enemy closest to target and attack when in range"},
- {eBoidRuleType_Hide, "HIDE", 0, "Hide", "Find a deflector move to it's other side from closest enemy"},
- {eBoidRuleType_FollowPath, "FOLLOW_PATH", 0, "Follow Path",
- "Move along a assigned curve or closest curve in a group"},
- {eBoidRuleType_FollowWall, "FOLLOW_WALL", 0, "Follow Wall",
- "Move next to a deflector object's in direction of it's tangent"},
+ {eBoidRuleType_Protect,
+ "PROTECT",
+ 0,
+ "Protect",
+ "Go to enemy closest to target and attack when in range"},
+ {eBoidRuleType_Hide,
+ "HIDE",
+ 0,
+ "Hide",
+ "Find a deflector move to it's other side from closest enemy"},
+ {eBoidRuleType_FollowPath,
+ "FOLLOW_PATH",
+ 0,
+ "Follow Path",
+ "Move along a assigned curve or closest curve in a group"},
+ {eBoidRuleType_FollowWall,
+ "FOLLOW_WALL",
+ 0,
+ "Follow Wall",
+ "Move next to a deflector object's in direction of it's tangent"},
#endif
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index e2ff6935e43..40c3a75df85 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -94,6 +94,13 @@ const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = {
{0, NULL, 0, NULL, NULL},
};
+const EnumPropertyItem rna_enum_brush_uv_sculpt_tool_items[] = {
+ {UV_SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", "Grab UVs"},
+ {UV_SCULPT_TOOL_RELAX, "RELAX", 0, "Relax", "Relax UVs"},
+ {UV_SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", "Pinch UVs"},
+ {0, NULL, 0, NULL, NULL},
+};
+
const EnumPropertyItem rna_enum_brush_vertex_tool_items[] = {
{VPAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_MIX, "Draw", ""},
{VPAINT_TOOL_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", ""},
@@ -1246,7 +1253,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop,
"Border Opacity Factor",
- "Amount of gradient for Dot strokes (set to 1 for full solid)");
+ "Amount of gradient for Dot and Box strokes (set to 1 for full solid)");
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
/* gradient shape ratio */
@@ -1575,6 +1582,11 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Sculpt Tool", "");
RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon");
+ prop = RNA_def_property(srna, "uv_sculpt_tool", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_brush_uv_sculpt_tool_items);
+ RNA_def_property_ui_text(prop, "Sculpt Tool", "");
+ RNA_def_property_update(prop, 0, "rna_Brush_update_and_reset_icon");
+
prop = RNA_def_property(srna, "vertex_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "vertexpaint_tool");
RNA_def_property_enum_items(prop, rna_enum_brush_vertex_tool_items);
@@ -1840,6 +1852,7 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "blur_kernel_radius", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "blur_kernel_radius");
RNA_def_property_range(prop, 1, 10000);
+ RNA_def_property_int_default(prop, 2);
RNA_def_property_ui_range(prop, 1, 50, 1, -1);
RNA_def_property_ui_text(
prop, "Kernel Radius", "Radius of kernel used for soften and sharpen in pixels");
@@ -2104,6 +2117,10 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_SCULPT);
RNA_def_property_ui_text(prop, "Use Sculpt", "Use this brush in sculpt mode");
+ prop = RNA_def_property(srna, "use_paint_uv_sculpt", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_EDIT);
+ RNA_def_property_ui_text(prop, "Use UV Sculpt", "Use this brush in UV sculpt mode");
+
prop = RNA_def_property(srna, "use_paint_vertex", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_VERTEX_PAINT);
RNA_def_property_ui_text(prop, "Use Vertex", "Use this brush in vertex paint mode");
diff --git a/source/blender/makesrna/intern/rna_cachefile.c b/source/blender/makesrna/intern/rna_cachefile.c
index fb61be69ee6..189a4a7de86 100644
--- a/source/blender/makesrna/intern/rna_cachefile.c
+++ b/source/blender/makesrna/intern/rna_cachefile.c
@@ -45,29 +45,12 @@
# include "../../../alembic/ABC_alembic.h"
# endif
-static void rna_CacheFile_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_CacheFile_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
CacheFile *cache_file = (CacheFile *)ptr->data;
- DEG_id_tag_update(&cache_file->id, 0);
+ DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
-
- UNUSED_VARS(bmain, scene);
-}
-
-static void rna_CacheFile_update_handle(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- CacheFile *cache_file = ptr->data;
-
- if ((cache_file->flag & CACHEFILE_DIRTY) != 0) {
- BKE_cachefile_clean(bmain, cache_file);
- BLI_freelistN(&cache_file->object_paths);
- cache_file->flag &= ~CACHEFILE_DIRTY;
- }
-
- BKE_cachefile_reload(bmain, cache_file);
-
- rna_CacheFile_update(bmain, scene, ptr);
}
static void rna_CacheFile_object_paths_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -76,20 +59,6 @@ static void rna_CacheFile_object_paths_begin(CollectionPropertyIterator *iter, P
rna_iterator_listbase_begin(iter, &cache_file->object_paths, NULL);
}
-static void rna_CacheFile_filename_set(PointerRNA *ptr, const char *value)
-{
- CacheFile *cache_file = ptr->data;
-
- if (STREQ(cache_file->filepath, value)) {
- return;
- }
-
- /* Different file is opened, close all readers. */
- cache_file->flag |= CACHEFILE_DIRTY;
-
- BLI_strncpy(cache_file->filepath, value, sizeof(cache_file->filepath));
-}
-
#else
/* cachefile.object_paths */
@@ -122,9 +91,8 @@ static void rna_def_cachefile(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_FILE);
PropertyRNA *prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_CacheFile_filename_set");
RNA_def_property_ui_text(prop, "File Path", "Path to external displacements file");
- RNA_def_property_update(prop, 0, "rna_CacheFile_update_handle");
+ RNA_def_property_update(prop, 0, "rna_CacheFile_update");
prop = RNA_def_property(srna, "is_sequence", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(
diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c
index ddea98a135a..1f356624f3f 100644
--- a/source/blender/makesrna/intern/rna_camera.c
+++ b/source/blender/makesrna/intern/rna_camera.c
@@ -124,11 +124,10 @@ static void rna_Camera_background_images_clear(Camera *cam)
WM_main_add_notifier(NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, cam);
}
-static void rna_Camera_dof_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
+static void rna_Camera_dof_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
{
/* TODO(sergey): Can be more selective here. */
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
+ BKE_sequencer_cache_cleanup_all(bmain);
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
}
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index b1a2ec32a88..160634307f9 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -788,7 +788,8 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "max_spring_extensions", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "maxspringlen");
RNA_def_property_range(prop, 1.0, 1000.0);
- RNA_def_property_ui_text(prop, "Maximum Spring Extension", "Maximum extension before spring gets cut");
+ RNA_def_property_ui_text(
+ prop, "Maximum Spring Extension", "Maximum extension before spring gets cut");
# endif
}
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c
index 0a1dc503cac..501895eefc8 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -152,8 +152,8 @@ static bool rna_Collection_objects_override_apply(Main *bmain,
return false;
}
- /* XXX TODO We most certainly rather want to have a 'swap object pointer in collection' util in BKE_collection...
- * This is only temp auick dirty test! */
+ /* XXX TODO We most certainly rather want to have a 'swap object pointer in collection'
+ * util in BKE_collection. This is only temp quick dirty test! */
id_us_min(&cob_dst->ob->id);
cob_dst->ob = ob_src;
id_us_plus(&cob_dst->ob->id);
@@ -255,8 +255,8 @@ static bool rna_Collection_children_override_apply(Main *bmain,
return false;
}
- /* XXX TODO We most certainly rather want to have a 'swap object pointer in collection' util in BKE_collection...
- * This is only temp auick dirty test! */
+ /* XXX TODO We most certainly rather want to have a 'swap object pointer in collection'
+ * util in BKE_collection. This is only temp quick dirty test! */
id_us_min(&collchild_dst->collection->id);
collchild_dst->collection = subcoll_src;
id_us_plus(&collchild_dst->collection->id);
@@ -342,7 +342,8 @@ void RNA_def_collections(BlenderRNA *brna)
srna = RNA_def_struct(brna, "Collection", "ID");
RNA_def_struct_ui_text(srna, "Collection", "Collection of Object data-blocks");
RNA_def_struct_ui_icon(srna, ICON_GROUP);
- /* this is done on save/load in readfile.c, removed if no objects are in the collection and not in a scene */
+ /* This is done on save/load in readfile.c,
+ * removed if no objects are in the collection and not in a scene. */
RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
prop = RNA_def_property(srna, "instance_offset", PROP_FLOAT, PROP_TRANSLATION);
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 2e540e8b105..40ee069657c 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -577,10 +577,6 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
BKE_movieclip_reload(bmain, clip);
- /* all sequencers for now, we don't know which scenes are using this clip as a strip */
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
-
WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, &clip->id);
WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, &clip->id);
}
@@ -594,9 +590,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
bool seq_found = false;
if (&scene->sequencer_colorspace_settings != colorspace_settings) {
- SEQ_BEGIN (scene->ed, seq)
- ;
- {
+ SEQ_BEGIN (scene->ed, seq) {
if (seq->strip && &seq->strip->colorspace_settings == colorspace_settings) {
seq_found = true;
break;
@@ -614,23 +608,19 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
}
BKE_sequence_invalidate_cache(scene, seq);
- BKE_sequencer_preprocessed_cache_cleanup_sequence(seq);
}
else {
- SEQ_BEGIN (scene->ed, seq)
- ;
- {
+ SEQ_BEGIN (scene->ed, seq) {
BKE_sequence_free_anim(seq);
}
SEQ_END;
-
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
}
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
}
}
+
+ BKE_sequencer_cache_cleanup_all(bmain);
}
static char *rna_ColorManagedSequencerColorspaceSettings_path(PointerRNA *UNUSED(ptr))
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 743ad6bfa68..c1c235d497b 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -173,10 +173,18 @@ const EnumPropertyItem rna_enum_constraint_type_items[] = {
ICON_CONSTRAINT,
"Pivot",
"Change pivot point for transforms (buggy)"},
- /* {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", ICON_CONSTRAINT_DATA, "Rigid Body Joint",
- "Use to define a Rigid Body Constraint (for Game Engine use only)"}, */
- /* {CONSTRAINT_TYPE_PYTHON, "SCRIPT", ICON_CONSTRAINT_DATA, "Script",
- "Custom constraint(s) written in Python (Not yet implemented)"}, */
+#if 0
+ {CONSTRAINT_TYPE_RIGIDBODYJOINT,
+ "RIGID_BODY_JOINT",
+ ICON_CONSTRAINT_DATA,
+ "Rigid Body Joint",
+ "Use to define a Rigid Body Constraint (for Game Engine use only)"},
+ {CONSTRAINT_TYPE_PYTHON,
+ "SCRIPT",
+ ICON_CONSTRAINT_DATA,
+ "Script",
+ "Custom constraint(s) written in Python (Not yet implemented)"},
+#endif
{CONSTRAINT_TYPE_SHRINKWRAP,
"SHRINKWRAP",
ICON_CONSTRAINT,
@@ -721,22 +729,6 @@ static void rna_Constraint_objectSolver_camera_set(PointerRNA *ptr, PointerRNA v
}
}
-static void rna_Constraint_transformCache_object_path_update(Main *bmain,
- Scene *scene,
- PointerRNA *ptr)
-{
-# ifdef WITH_ALEMBIC
- bConstraint *con = (bConstraint *)ptr->data;
- bTransformCacheConstraint *data = (bTransformCacheConstraint *)con->data;
- Object *ob = (Object *)ptr->id.data;
-
- data->reader = CacheReader_open_alembic_object(
- data->cache_file->handle, data->reader, ob, data->object_path);
-# endif
-
- rna_Constraint_update(bmain, scene, ptr);
-}
-
#else
static const EnumPropertyItem constraint_distance_items[] = {
@@ -2894,7 +2886,7 @@ static void rna_def_constraint_transform_cache(BlenderRNA *brna)
prop,
"Object Path",
"Path to the object in the Alembic archive used to lookup the transform matrix");
- RNA_def_property_update(prop, 0, "rna_Constraint_transformCache_object_path_update");
+ RNA_def_property_update(prop, 0, "rna_Constraint_update");
}
/* base struct for constraints */
@@ -2953,7 +2945,8 @@ void RNA_def_constraint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Expanded", "Constraint's panel is expanded in UI");
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
- /* XXX this is really an internal flag, but it may be useful for some tools to be able to access this... */
+ /* XXX this is really an internal flag,
+ * but it may be useful for some tools to be able to access this... */
prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE);
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index 40f2927077c..75f8b97b99d 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -37,11 +37,8 @@ const EnumPropertyItem rna_enum_context_mode_items[] = {
{CTX_MODE_EDIT_CURVE, "EDIT_CURVE", 0, "Curve Edit", ""},
{CTX_MODE_EDIT_SURFACE, "EDIT_SURFACE", 0, "Surface Edit", ""},
{CTX_MODE_EDIT_TEXT, "EDIT_TEXT", 0, "Edit Edit", ""},
- {CTX_MODE_EDIT_ARMATURE,
- "EDIT_ARMATURE",
- 0,
- "Armature Edit",
- ""}, /* PARSKEL reuse will give issues */
+ /* PARSKEL reuse will give issues */
+ {CTX_MODE_EDIT_ARMATURE, "EDIT_ARMATURE", 0, "Armature Edit", ""},
{CTX_MODE_EDIT_METABALL, "EDIT_METABALL", 0, "Metaball Edit", ""},
{CTX_MODE_EDIT_LATTICE, "EDIT_LATTICE", 0, "Lattice Edit", ""},
{CTX_MODE_POSE, "POSE", 0, "Pose ", ""},
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 448ea1387f4..9c7ad60f378 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -720,7 +720,8 @@ static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr)
Nurb *nu;
ListBase *nurbs = BKE_curve_nurbs_get(cu);
- /* for curve outside editmode will set to -1, should be changed to be allowed outside of editmode. */
+ /* For curve outside editmode will set to -1,
+ * should be changed to be allowed outside of editmode. */
nu = BLI_findlink(nurbs, cu->actnu);
if (nu)
@@ -1311,7 +1312,7 @@ static void rna_def_charinfo(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_wrap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP);
RNA_def_property_ui_text(prop, "Wrap", "");
- RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */
+ RNA_def_property_update(prop, 0, "rna_Curve_update_data");
# endif
prop = RNA_def_property(srna, "use_small_caps", PROP_BOOLEAN, PROP_NONE);
@@ -1780,7 +1781,8 @@ static void rna_def_curve_nurb(BlenderRNA *brna)
{KEY_LINEAR, "LINEAR", 0, "Linear", ""},
{KEY_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
{KEY_BSPLINE, "BSPLINE", 0, "BSpline", ""},
- {KEY_CU_EASE, "EASE", 0, "Ease", ""}, /* todo, define somewhere, not one of BEZT_IPO_* */
+ /* TODO: define somewhere, not one of BEZT_IPO_*. */
+ {KEY_CU_EASE, "EASE", 0, "Ease", ""},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 9972bbaa829..20fbbed572c 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -96,10 +96,12 @@ void rna_addtail(ListBase *listbase, void *vlink)
link->next = NULL;
link->prev = listbase->last;
- if (listbase->last)
+ if (listbase->last) {
((Link *)listbase->last)->next = link;
- if (listbase->first == NULL)
+ }
+ if (listbase->first == NULL) {
listbase->first = link;
+ }
listbase->last = link;
}
@@ -107,15 +109,19 @@ static void rna_remlink(ListBase *listbase, void *vlink)
{
Link *link = vlink;
- if (link->next)
+ if (link->next) {
link->next->prev = link->prev;
- if (link->prev)
+ }
+ if (link->prev) {
link->prev->next = link->next;
+ }
- if (listbase->last == link)
+ if (listbase->last == link) {
listbase->last = link->prev;
- if (listbase->first == link)
+ }
+ if (listbase->first == link) {
listbase->first = link->next;
+ }
}
PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier)
@@ -204,9 +210,11 @@ StructDefRNA *rna_find_struct_def(StructRNA *srna)
}
dsrna = DefRNA.structs.last;
- for (; dsrna; dsrna = dsrna->cont.prev)
- if (dsrna->srna == srna)
+ for (; dsrna; dsrna = dsrna->cont.prev) {
+ if (dsrna->srna == srna) {
return dsrna;
+ }
+ }
return NULL;
}
@@ -224,16 +232,20 @@ PropertyDefRNA *rna_find_struct_property_def(StructRNA *srna, PropertyRNA *prop)
dsrna = rna_find_struct_def(srna);
dprop = dsrna->cont.properties.last;
- for (; dprop; dprop = dprop->prev)
- if (dprop->prop == prop)
+ for (; dprop; dprop = dprop->prev) {
+ if (dprop->prop == prop) {
return dprop;
+ }
+ }
dsrna = DefRNA.structs.last;
for (; dsrna; dsrna = dsrna->cont.prev) {
dprop = dsrna->cont.properties.last;
- for (; dprop; dprop = dprop->prev)
- if (dprop->prop == prop)
+ for (; dprop; dprop = dprop->prev) {
+ if (dprop->prop == prop) {
return dprop;
+ }
+ }
}
return NULL;
@@ -275,16 +287,20 @@ FunctionDefRNA *rna_find_function_def(FunctionRNA *func)
dsrna = rna_find_struct_def(DefRNA.laststruct);
dfunc = dsrna->functions.last;
- for (; dfunc; dfunc = dfunc->cont.prev)
- if (dfunc->func == func)
+ for (; dfunc; dfunc = dfunc->cont.prev) {
+ if (dfunc->func == func) {
return dfunc;
+ }
+ }
dsrna = DefRNA.structs.last;
for (; dsrna; dsrna = dsrna->cont.prev) {
dfunc = dsrna->functions.last;
- for (; dfunc; dfunc = dfunc->cont.prev)
- if (dfunc->func == func)
+ for (; dfunc; dfunc = dfunc->cont.prev) {
+ if (dfunc->func == func) {
return dfunc;
+ }
+ }
}
return NULL;
@@ -306,9 +322,11 @@ PropertyDefRNA *rna_find_parameter_def(PropertyRNA *parm)
dfunc = dsrna->functions.last;
for (; dfunc; dfunc = dfunc->cont.prev) {
dparm = dfunc->cont.properties.last;
- for (; dparm; dparm = dparm->prev)
- if (dparm->prop == parm)
+ for (; dparm; dparm = dparm->prev) {
+ if (dparm->prop == parm) {
return dparm;
+ }
+ }
}
dsrna = DefRNA.structs.last;
@@ -316,9 +334,11 @@ PropertyDefRNA *rna_find_parameter_def(PropertyRNA *parm)
dfunc = dsrna->functions.last;
for (; dfunc; dfunc = dfunc->cont.prev) {
dparm = dfunc->cont.properties.last;
- for (; dparm; dparm = dparm->prev)
- if (dparm->prop == parm)
+ for (; dparm; dparm = dparm->prev) {
+ if (dparm->prop == parm) {
return dparm;
+ }
+ }
}
}
@@ -337,12 +357,14 @@ static ContainerDefRNA *rna_find_container_def(ContainerRNA *cont)
}
ds = rna_find_struct_def((StructRNA *)cont);
- if (ds)
+ if (ds) {
return &ds->cont;
+ }
dfunc = rna_find_function_def((FunctionRNA *)cont);
- if (dfunc)
+ if (dfunc) {
return &dfunc->cont;
+ }
return NULL;
}
@@ -361,26 +383,34 @@ static int rna_member_cmp(const char *name, const char *oname)
int a = 0;
/* compare without pointer or array part */
- while (name[0] == '*')
+ while (name[0] == '*') {
name++;
- while (oname[0] == '*')
+ }
+ while (oname[0] == '*') {
oname++;
+ }
while (1) {
- if (name[a] == '[' && oname[a] == 0)
+ if (name[a] == '[' && oname[a] == 0) {
return 1;
- if (name[a] == '[' && oname[a] == '[')
+ }
+ if (name[a] == '[' && oname[a] == '[') {
return 1;
- if (name[a] == 0)
+ }
+ if (name[a] == 0) {
break;
- if (name[a] != oname[a])
+ }
+ if (name[a] != oname[a]) {
return 0;
+ }
a++;
}
- if (name[a] == 0 && oname[a] == '.')
+ if (name[a] == 0 && oname[a] == '.') {
return 2;
- if (name[a] == 0 && oname[a] == '-' && oname[a + 1] == '>')
+ }
+ if (name[a] == 0 && oname[a] == '-' && oname[a + 1] == '>') {
return 3;
+ }
return (name[a] == oname[a]);
}
@@ -400,8 +430,9 @@ static int rna_find_sdna_member(SDNA *sdna,
}
structnr = DNA_struct_find_nr_wrapper(sdna, structname);
- if (structnr == -1)
+ if (structnr == -1) {
return 0;
+ }
sp = sdna->structs[structnr];
totmember = sp[1];
@@ -415,14 +446,17 @@ static int rna_find_sdna_member(SDNA *sdna,
smember->type = sdna->alias.types[sp[0]];
smember->name = dnaname;
- if (strstr(membername, "["))
+ if (strstr(membername, "[")) {
smember->arraylength = 0;
- else
+ }
+ else {
smember->arraylength = DNA_elem_array_size(smember->name);
+ }
smember->pointerlevel = 0;
- for (b = 0; dnaname[b] == '*'; b++)
+ for (b = 0; dnaname[b] == '*'; b++) {
smember->pointerlevel++;
+ }
return 1;
}
@@ -457,8 +491,13 @@ static int rna_validate_identifier(const char *identifier, char *error, bool pro
{
int a = 0;
- /* list is from...
- * ", ".join(['"%s"' % kw for kw in __import__("keyword").kwlist if kw not in {"False", "None", "True"}])
+ /** List is from:
+ * \code{.py}
+ * ", ".join([
+ * '"%s"' % kw for kw in __import__("keyword").kwlist
+ * if kw not in {"False", "None", "True"}
+ * ])
+ * \endcode
*/
static const char *kwlist[] = {
/* "False", "None", "True", */
@@ -634,13 +673,15 @@ void RNA_define_free(BlenderRNA *UNUSED(brna))
FunctionDefRNA *dfunc;
AllocDefRNA *alloc;
- for (alloc = DefRNA.allocs.first; alloc; alloc = alloc->next)
+ for (alloc = DefRNA.allocs.first; alloc; alloc = alloc->next) {
MEM_freeN(alloc->mem);
+ }
rna_freelistN(&DefRNA.allocs);
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
- for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
+ for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
rna_freelistN(&dfunc->cont.properties);
+ }
rna_freelistN(&ds->cont.properties);
rna_freelistN(&ds->functions);
@@ -741,8 +782,9 @@ void RNA_free(BlenderRNA *brna)
RNA_define_free(brna);
for (srna = brna->structs.first; srna; srna = srna->cont.next) {
- for (func = srna->functions.first; func; func = func->cont.next)
+ for (func = srna->functions.first; func; func = func->cont.next) {
rna_freelistN(&func->cont.properties);
+ }
rna_freelistN(&srna->cont.properties);
rna_freelistN(&srna->functions);
@@ -791,9 +833,11 @@ static StructDefRNA *rna_find_def_struct(StructRNA *srna)
{
StructDefRNA *ds;
- for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
- if (ds->srna == srna)
+ for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
+ if (ds->srna == srna) {
return ds;
+ }
+ }
return NULL;
}
@@ -847,8 +891,9 @@ StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRN
/* may be overwritten later RNA_def_struct_translation_context */
srna->translation_context = BLT_I18NCONTEXT_DEFAULT_BPYRNA;
srna->flag |= STRUCT_UNDO;
- if (!srnafrom)
+ if (!srnafrom) {
srna->icon = ICON_DOT;
+ }
if (DefRNA.preprocess) {
srna->flag |= STRUCT_PUBLIC_NAMESPACE;
@@ -861,15 +906,18 @@ StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRN
ds->srna = srna;
rna_addtail(&DefRNA.structs, ds);
- if (dsfrom)
+ if (dsfrom) {
ds->dnafromname = dsfrom->dnaname;
+ }
}
/* in preprocess, try to find sdna */
- if (DefRNA.preprocess)
+ if (DefRNA.preprocess) {
RNA_def_struct_sdna(srna, srna->identifier);
- else
+ }
+ else {
srna->flag |= STRUCT_RUNTIME;
+ }
if (srnafrom) {
srna->nameproperty = srnafrom->nameproperty;
@@ -954,8 +1002,9 @@ void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
ds = rna_find_def_struct(srna);
- /* there are far too many structs which initialize without valid DNA struct names,
- * this can't be checked without adding an option to disable (tested this and it means changes all over - Campbell) */
+ /* There are far too many structs which initialize without valid DNA struct names,
+ * this can't be checked without adding an option to disable
+ * (tested this and it means changes all over - Campbell) */
#if 0
if (DNA_struct_find_nr_wrapper(DefRNA.sdna, structname) == -1) {
if (!DefRNA.silent) {
@@ -1003,8 +1052,9 @@ void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *pr
CLOG_ERROR(&LOG, "\"%s.%s\", must be a string property.", srna->identifier, prop->identifier);
DefRNA.error = 1;
}
- else
+ else {
srna->nameproperty = prop;
+ }
}
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
@@ -1043,8 +1093,9 @@ void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
return;
}
- if (refine)
+ if (refine) {
srna->refine = (StructRefineFunc)refine;
+ }
}
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
@@ -1054,8 +1105,9 @@ void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
return;
}
- if (idproperties)
+ if (idproperties) {
srna->idproperties = (IDPropertiesFunc)idproperties;
+ }
}
void RNA_def_struct_register_funcs(StructRNA *srna,
@@ -1068,12 +1120,15 @@ void RNA_def_struct_register_funcs(StructRNA *srna,
return;
}
- if (reg)
+ if (reg) {
srna->reg = (StructRegisterFunc)reg;
- if (unreg)
+ }
+ if (unreg) {
srna->unreg = (StructUnregisterFunc)unreg;
- if (instance)
+ }
+ if (instance) {
srna->instance = (StructInstanceFunc)instance;
+ }
}
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
@@ -1083,8 +1138,9 @@ void RNA_def_struct_path_func(StructRNA *srna, const char *path)
return;
}
- if (path)
+ if (path) {
srna->path = (StructPathFunc)path;
+ }
}
void RNA_def_struct_identifier(BlenderRNA *brna, StructRNA *srna, const char *identifier)
@@ -1512,11 +1568,13 @@ void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int le
memcpy(prop->arraylength, length, sizeof(int) * dimension);
prop->totarraylength = length[0];
- for (i = 1; i < dimension; i++)
+ for (i = 1; i < dimension; i++) {
prop->totarraylength *= length[i];
+ }
}
- else
+ else {
memset(prop->arraylength, 0, sizeof(prop->arraylength));
+ }
/* TODO make sure arraylength values are sane */
}
@@ -1532,10 +1590,12 @@ void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *d
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
{
prop->icon = icon;
- if (consecutive != 0)
+ if (consecutive != 0) {
prop->flag |= PROP_ICONS_CONSECUTIVE;
- if (consecutive < 0)
+ }
+ if (consecutive < 0) {
prop->flag |= PROP_ICONS_REVERSE;
+ }
}
/**
@@ -1672,8 +1732,9 @@ void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type)
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
pprop->type = type;
- if (type && (type->flag & STRUCT_ID_REFCOUNT))
+ if (type && (type->flag & STRUCT_ID_REFCOUNT)) {
prop->flag |= PROP_ID_REFCOUNT;
+ }
break;
}
@@ -1703,8 +1764,9 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item
for (i = 0; item[i].identifier; i++) {
eprop->totitem++;
- if (item[i].identifier[0] && item[i].value == eprop->defaultvalue)
+ if (item[i].identifier[0] && item[i].value == eprop->defaultvalue) {
defaultfound = 1;
+ }
}
if (!defaultfound) {
@@ -1913,8 +1975,9 @@ void RNA_def_property_enum_default(PropertyRNA *prop, int value)
}
else {
for (i = 0; i < eprop->totitem; i++) {
- if (eprop->item[i].identifier[0] && eprop->item[i].value == eprop->defaultvalue)
+ if (eprop->item[i].identifier[0] && eprop->item[i].value == eprop->defaultvalue) {
defaultfound = 1;
+ }
}
if (!defaultfound && eprop->totitem) {
@@ -1949,15 +2012,18 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop,
PropertyDefRNA *dp;
dp = rna_find_struct_property_def(DefRNA.laststruct, prop);
- if (dp == NULL)
+ if (dp == NULL) {
return NULL;
+ }
ds = rna_find_struct_def((StructRNA *)dp->cont);
- if (!structname)
+ if (!structname) {
structname = ds->dnaname;
- if (!propname)
+ }
+ if (!propname) {
propname = prop->identifier;
+ }
if (!rna_find_sdna_member(DefRNA.sdna, structname, propname, &smember)) {
if (DefRNA.silent) {
@@ -1967,10 +2033,12 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop,
/* some basic values to survive even with sdna info */
dp->dnastructname = structname;
dp->dnaname = propname;
- if (prop->type == PROP_BOOLEAN)
+ if (prop->type == PROP_BOOLEAN) {
dp->dnaarraylength = 1;
- if (prop->type == PROP_POINTER)
+ }
+ if (prop->type == PROP_POINTER) {
dp->dnapointerlevel = 1;
+ }
return dp;
}
else {
@@ -2055,8 +2123,9 @@ void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop,
dp = rna_find_struct_property_def(DefRNA.laststruct, prop);
- if (dp)
+ if (dp) {
dp->booleannegative = 1;
+ }
}
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
@@ -2110,8 +2179,9 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
}
if (prop->subtype == PROP_UNSIGNED || prop->subtype == PROP_PERCENTAGE ||
- prop->subtype == PROP_FACTOR)
+ prop->subtype == PROP_FACTOR) {
iprop->hardmin = iprop->softmin = 0;
+ }
}
}
@@ -2198,8 +2268,9 @@ void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop,
dp = rna_find_struct_property_def(DefRNA.laststruct, prop);
- if (dp)
+ if (dp) {
dp->enumbitflags = 1;
+ }
}
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
@@ -2299,8 +2370,9 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop,
DNAStructMember smember;
StructDefRNA *ds = rna_find_struct_def((StructRNA *)dp->cont);
- if (!structname)
+ if (!structname) {
structname = ds->dnaname;
+ }
if (lengthpropname[0] == 0 ||
rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember)) {
@@ -2318,10 +2390,12 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop,
cprop->next = (PropCollectionNextFunc) "rna_iterator_array_next";
cprop->end = (PropCollectionEndFunc) "rna_iterator_array_end";
- if (dp->dnapointerlevel >= 2)
+ if (dp->dnapointerlevel >= 2) {
cprop->get = (PropCollectionGetFunc) "rna_iterator_array_dereference_get";
- else
+ }
+ else {
cprop->get = (PropCollectionGetFunc) "rna_iterator_array_get";
+ }
}
else {
if (!DefRNA.silent) {
@@ -2346,8 +2420,9 @@ void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
return;
}
- if (editable)
+ if (editable) {
prop->editable = (EditableFunc)editable;
+ }
}
void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editable)
@@ -2357,8 +2432,9 @@ void RNA_def_property_editable_array_func(PropertyRNA *prop, const char *editabl
return;
}
- if (editable)
+ if (editable) {
prop->itemeditable = (ItemEditableFunc)editable;
+ }
}
/**
@@ -2426,8 +2502,9 @@ void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getleng
return;
}
- if (getlength)
+ if (getlength) {
prop->getlength = (PropArrayLengthGetFunc)getlength;
+ }
}
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
@@ -2444,16 +2521,20 @@ void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const ch
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
if (prop->arraydimension) {
- if (get)
+ if (get) {
bprop->getarray = (PropBooleanArrayGetFunc)get;
- if (set)
+ }
+ if (set) {
bprop->setarray = (PropBooleanArraySetFunc)set;
+ }
}
else {
- if (get)
+ if (get) {
bprop->get = (PropBooleanGetFunc)get;
- if (set)
+ }
+ if (set) {
bprop->set = (PropBooleanSetFunc)set;
+ }
}
break;
}
@@ -2470,17 +2551,20 @@ void RNA_def_property_boolean_funcs_runtime(PropertyRNA *prop,
{
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
- if (getfunc)
+ if (getfunc) {
bprop->get_ex = getfunc;
- if (setfunc)
+ }
+ if (setfunc) {
bprop->set_ex = setfunc;
+ }
if (getfunc || setfunc) {
/* don't save in id properties */
prop->flag &= ~PROP_IDPROPERTY;
- if (!setfunc)
+ if (!setfunc) {
prop->flag &= ~PROP_EDITABLE;
+ }
}
}
@@ -2490,17 +2574,20 @@ void RNA_def_property_boolean_array_funcs_runtime(PropertyRNA *prop,
{
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
- if (getfunc)
+ if (getfunc) {
bprop->getarray_ex = getfunc;
- if (setfunc)
+ }
+ if (setfunc) {
bprop->setarray_ex = setfunc;
+ }
if (getfunc || setfunc) {
/* don't save in id properties */
prop->flag &= ~PROP_IDPROPERTY;
- if (!setfunc)
+ if (!setfunc) {
prop->flag &= ~PROP_EDITABLE;
+ }
}
}
@@ -2521,19 +2608,24 @@ void RNA_def_property_int_funcs(PropertyRNA *prop,
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
if (prop->arraydimension) {
- if (get)
+ if (get) {
iprop->getarray = (PropIntArrayGetFunc)get;
- if (set)
+ }
+ if (set) {
iprop->setarray = (PropIntArraySetFunc)set;
+ }
}
else {
- if (get)
+ if (get) {
iprop->get = (PropIntGetFunc)get;
- if (set)
+ }
+ if (set) {
iprop->set = (PropIntSetFunc)set;
+ }
}
- if (range)
+ if (range) {
iprop->range = (PropIntRangeFunc)range;
+ }
break;
}
default:
@@ -2550,19 +2642,23 @@ void RNA_def_property_int_funcs_runtime(PropertyRNA *prop,
{
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
- if (getfunc)
+ if (getfunc) {
iprop->get_ex = getfunc;
- if (setfunc)
+ }
+ if (setfunc) {
iprop->set_ex = setfunc;
- if (rangefunc)
+ }
+ if (rangefunc) {
iprop->range_ex = rangefunc;
+ }
if (getfunc || setfunc) {
/* don't save in id properties */
prop->flag &= ~PROP_IDPROPERTY;
- if (!setfunc)
+ if (!setfunc) {
prop->flag &= ~PROP_EDITABLE;
+ }
}
}
@@ -2573,19 +2669,23 @@ void RNA_def_property_int_array_funcs_runtime(PropertyRNA *prop,
{
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
- if (getfunc)
+ if (getfunc) {
iprop->getarray_ex = getfunc;
- if (setfunc)
+ }
+ if (setfunc) {
iprop->setarray_ex = setfunc;
- if (rangefunc)
+ }
+ if (rangefunc) {
iprop->range_ex = rangefunc;
+ }
if (getfunc || setfunc) {
/* don't save in id properties */
prop->flag &= ~PROP_IDPROPERTY;
- if (!setfunc)
+ if (!setfunc) {
prop->flag &= ~PROP_EDITABLE;
+ }
}
}
@@ -2606,19 +2706,24 @@ void RNA_def_property_float_funcs(PropertyRNA *prop,
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
if (prop->arraydimension) {
- if (get)
+ if (get) {
fprop->getarray = (PropFloatArrayGetFunc)get;
- if (set)
+ }
+ if (set) {
fprop->setarray = (PropFloatArraySetFunc)set;
+ }
}
else {
- if (get)
+ if (get) {
fprop->get = (PropFloatGetFunc)get;
- if (set)
+ }
+ if (set) {
fprop->set = (PropFloatSetFunc)set;
+ }
}
- if (range)
+ if (range) {
fprop->range = (PropFloatRangeFunc)range;
+ }
break;
}
default:
@@ -2635,19 +2740,23 @@ void RNA_def_property_float_funcs_runtime(PropertyRNA *prop,
{
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
- if (getfunc)
+ if (getfunc) {
fprop->get_ex = getfunc;
- if (setfunc)
+ }
+ if (setfunc) {
fprop->set_ex = setfunc;
- if (rangefunc)
+ }
+ if (rangefunc) {
fprop->range_ex = rangefunc;
+ }
if (getfunc || setfunc) {
/* don't save in id properties */
prop->flag &= ~PROP_IDPROPERTY;
- if (!setfunc)
+ if (!setfunc) {
prop->flag &= ~PROP_EDITABLE;
+ }
}
}
@@ -2658,19 +2767,23 @@ void RNA_def_property_float_array_funcs_runtime(PropertyRNA *prop,
{
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
- if (getfunc)
+ if (getfunc) {
fprop->getarray_ex = getfunc;
- if (setfunc)
+ }
+ if (setfunc) {
fprop->setarray_ex = setfunc;
- if (rangefunc)
+ }
+ if (rangefunc) {
fprop->range_ex = rangefunc;
+ }
if (getfunc || setfunc) {
/* don't save in id properties */
prop->flag &= ~PROP_IDPROPERTY;
- if (!setfunc)
+ if (!setfunc) {
prop->flag &= ~PROP_EDITABLE;
+ }
}
}
@@ -2690,12 +2803,15 @@ void RNA_def_property_enum_funcs(PropertyRNA *prop,
case PROP_ENUM: {
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
- if (get)
+ if (get) {
eprop->get = (PropEnumGetFunc)get;
- if (set)
+ }
+ if (set) {
eprop->set = (PropEnumSetFunc)set;
- if (item)
+ }
+ if (item) {
eprop->itemf = (PropEnumItemFunc)item;
+ }
break;
}
default:
@@ -2712,19 +2828,23 @@ void RNA_def_property_enum_funcs_runtime(PropertyRNA *prop,
{
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
- if (getfunc)
+ if (getfunc) {
eprop->get_ex = getfunc;
- if (setfunc)
+ }
+ if (setfunc) {
eprop->set_ex = setfunc;
- if (itemfunc)
+ }
+ if (itemfunc) {
eprop->itemf = itemfunc;
+ }
if (getfunc || setfunc) {
/* don't save in id properties */
prop->flag &= ~PROP_IDPROPERTY;
- if (!setfunc)
+ if (!setfunc) {
prop->flag &= ~PROP_EDITABLE;
+ }
}
}
@@ -2750,12 +2870,15 @@ void RNA_def_property_string_funcs(PropertyRNA *prop,
case PROP_STRING: {
StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
- if (get)
+ if (get) {
sprop->get = (PropStringGetFunc)get;
- if (length)
+ }
+ if (length) {
sprop->length = (PropStringLengthFunc)length;
- if (set)
+ }
+ if (set) {
sprop->set = (PropStringSetFunc)set;
+ }
break;
}
default:
@@ -2772,19 +2895,23 @@ void RNA_def_property_string_funcs_runtime(PropertyRNA *prop,
{
StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
- if (getfunc)
+ if (getfunc) {
sprop->get_ex = getfunc;
- if (lengthfunc)
+ }
+ if (lengthfunc) {
sprop->length_ex = lengthfunc;
- if (setfunc)
+ }
+ if (setfunc) {
sprop->set_ex = setfunc;
+ }
if (getfunc || setfunc) {
/* don't save in id properties */
prop->flag &= ~PROP_IDPROPERTY;
- if (!setfunc)
+ if (!setfunc) {
prop->flag &= ~PROP_EDITABLE;
+ }
}
}
@@ -2802,14 +2929,18 @@ void RNA_def_property_pointer_funcs(
case PROP_POINTER: {
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
- if (get)
+ if (get) {
pprop->get = (PropPointerGetFunc)get;
- if (set)
+ }
+ if (set) {
pprop->set = (PropPointerSetFunc)set;
- if (typef)
+ }
+ if (typef) {
pprop->typef = (PropPointerTypeFunc)typef;
- if (poll)
+ }
+ if (poll) {
pprop->poll = (PropPointerPollFunc)poll;
+ }
break;
}
default:
@@ -2840,22 +2971,30 @@ void RNA_def_property_collection_funcs(PropertyRNA *prop,
case PROP_COLLECTION: {
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
- if (begin)
+ if (begin) {
cprop->begin = (PropCollectionBeginFunc)begin;
- if (next)
+ }
+ if (next) {
cprop->next = (PropCollectionNextFunc)next;
- if (end)
+ }
+ if (end) {
cprop->end = (PropCollectionEndFunc)end;
- if (get)
+ }
+ if (get) {
cprop->get = (PropCollectionGetFunc)get;
- if (length)
+ }
+ if (length) {
cprop->length = (PropCollectionLengthFunc)length;
- if (lookupint)
+ }
+ if (lookupint) {
cprop->lookupint = (PropCollectionLookupIntFunc)lookupint;
- if (lookupstring)
+ }
+ if (lookupstring) {
cprop->lookupstring = (PropCollectionLookupStringFunc)lookupstring;
- if (assignint)
+ }
+ if (assignint) {
cprop->assignint = (PropCollectionAssignIntFunc)assignint;
+ }
break;
}
default:
@@ -2904,10 +3043,12 @@ PropertyRNA *RNA_def_boolean_array(StructOrFunctionRNA *cont_,
PropertyRNA *prop;
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_NONE);
- if (len != 0)
+ if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_boolean_array_default(prop, default_value);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
return prop;
@@ -2924,10 +3065,12 @@ PropertyRNA *RNA_def_boolean_layer(StructOrFunctionRNA *cont_,
PropertyRNA *prop;
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER);
- if (len != 0)
+ if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_boolean_array_default(prop, default_value);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
return prop;
@@ -2944,10 +3087,12 @@ PropertyRNA *RNA_def_boolean_layer_member(StructOrFunctionRNA *cont_,
PropertyRNA *prop;
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_LAYER_MEMBER);
- if (len != 0)
+ if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_boolean_array_default(prop, default_value);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
return prop;
@@ -2964,10 +3109,12 @@ PropertyRNA *RNA_def_boolean_vector(StructOrFunctionRNA *cont_,
PropertyRNA *prop;
prop = RNA_def_property(cont, identifier, PROP_BOOLEAN, PROP_XYZ); /* XXX */
- if (len != 0)
+ if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_boolean_array_default(prop, default_value);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
return prop;
@@ -2990,8 +3137,9 @@ PropertyRNA *RNA_def_int(StructOrFunctionRNA *cont_,
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, default_value);
- if (hardmin != hardmax)
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3015,12 +3163,15 @@ PropertyRNA *RNA_def_int_vector(StructOrFunctionRNA *cont_,
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_XYZ); /* XXX */
- if (len != 0)
+ if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_int_array_default(prop, default_value);
- if (hardmin != hardmax)
+ }
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3044,12 +3195,15 @@ PropertyRNA *RNA_def_int_array(StructOrFunctionRNA *cont_,
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_INT, PROP_NONE);
- if (len != 0)
+ if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_int_array_default(prop, default_value);
- if (hardmin != hardmax)
+ }
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3069,10 +3223,12 @@ PropertyRNA *RNA_def_string(StructOrFunctionRNA *cont_,
BLI_assert(default_value == NULL || default_value[0]);
prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_NONE);
- if (maxlen != 0)
+ if (maxlen != 0) {
RNA_def_property_string_maxlength(prop, maxlen);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_string_default(prop, default_value);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
return prop;
@@ -3091,10 +3247,12 @@ PropertyRNA *RNA_def_string_file_path(StructOrFunctionRNA *cont_,
BLI_assert(default_value == NULL || default_value[0]);
prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_FILEPATH);
- if (maxlen != 0)
+ if (maxlen != 0) {
RNA_def_property_string_maxlength(prop, maxlen);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_string_default(prop, default_value);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
return prop;
@@ -3113,10 +3271,12 @@ PropertyRNA *RNA_def_string_dir_path(StructOrFunctionRNA *cont_,
BLI_assert(default_value == NULL || default_value[0]);
prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_DIRPATH);
- if (maxlen != 0)
+ if (maxlen != 0) {
RNA_def_property_string_maxlength(prop, maxlen);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_string_default(prop, default_value);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
return prop;
@@ -3135,10 +3295,12 @@ PropertyRNA *RNA_def_string_file_name(StructOrFunctionRNA *cont_,
BLI_assert(default_value == NULL || default_value[0]);
prop = RNA_def_property(cont, identifier, PROP_STRING, PROP_FILENAME);
- if (maxlen != 0)
+ if (maxlen != 0) {
RNA_def_property_string_maxlength(prop, maxlen);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_string_default(prop, default_value);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
return prop;
@@ -3160,8 +3322,9 @@ PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_,
}
prop = RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE);
- if (items)
+ if (items) {
RNA_def_property_enum_items(prop, items);
+ }
RNA_def_property_enum_default(prop, default_value);
RNA_def_property_ui_text(prop, ui_name, ui_description);
@@ -3186,8 +3349,9 @@ PropertyRNA *RNA_def_enum_flag(StructOrFunctionRNA *cont_,
prop = RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_ENUM_FLAG); /* important to run before default set */
- if (items)
+ if (items) {
RNA_def_property_enum_items(prop, items);
+ }
RNA_def_property_enum_default(prop, default_value);
RNA_def_property_ui_text(prop, ui_name, ui_description);
@@ -3217,8 +3381,9 @@ PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont_,
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, default_value);
- if (hardmin != hardmax)
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3242,12 +3407,15 @@ PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont_,
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_XYZ);
- if (len != 0)
+ if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_float_array_default(prop, default_value);
- if (hardmin != hardmax)
+ }
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3299,12 +3467,15 @@ PropertyRNA *RNA_def_float_color(StructOrFunctionRNA *cont_,
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_COLOR);
- if (len != 0)
+ if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_float_array_default(prop, default_value);
- if (hardmin != hardmax)
+ }
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3331,10 +3502,12 @@ PropertyRNA *RNA_def_float_matrix(StructOrFunctionRNA *cont_,
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_MATRIX);
RNA_def_property_multi_array(prop, 2, length);
- if (default_value)
+ if (default_value) {
RNA_def_property_float_array_default(prop, default_value);
- if (hardmin != hardmax)
+ }
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3360,15 +3533,17 @@ PropertyRNA *RNA_def_float_rotation(StructOrFunctionRNA *cont_,
prop = RNA_def_property(cont, identifier, PROP_FLOAT, (len >= 3) ? PROP_EULER : PROP_ANGLE);
if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ if (default_value) {
RNA_def_property_float_array_default(prop, default_value);
+ }
}
else {
/* RNA_def_property_float_default must be called outside */
BLI_assert(default_value == NULL);
}
- if (hardmin != hardmax)
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 10, 3);
@@ -3416,12 +3591,15 @@ PropertyRNA *RNA_def_float_array(StructOrFunctionRNA *cont_,
ASSERT_SOFT_HARD_LIMITS;
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_NONE);
- if (len != 0)
+ if (len != 0) {
RNA_def_property_array(prop, len);
- if (default_value)
+ }
+ if (default_value) {
RNA_def_property_float_array_default(prop, default_value);
- if (hardmin != hardmax)
+ }
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3445,8 +3623,9 @@ PropertyRNA *RNA_def_float_percentage(StructOrFunctionRNA *cont_,
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_PERCENTAGE);
RNA_def_property_float_default(prop, default_value);
- if (hardmin != hardmax)
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3470,8 +3649,9 @@ PropertyRNA *RNA_def_float_factor(StructOrFunctionRNA *cont_,
prop = RNA_def_property(cont, identifier, PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, default_value);
- if (hardmin != hardmax)
+ if (hardmin != hardmax) {
RNA_def_property_range(prop, hardmin, hardmax);
+ }
RNA_def_property_ui_text(prop, ui_name, ui_description);
RNA_def_property_ui_range(prop, softmin, softmax, 1, 3);
@@ -3574,8 +3754,9 @@ static FunctionRNA *rna_def_function(StructRNA *srna, const char *identifier)
rna_addtail(&dsrna->functions, dfunc);
dfunc->func = func;
}
- else
+ else {
func->flag |= FUNC_RUNTIME;
+ }
return func;
}
@@ -3666,8 +3847,9 @@ int rna_parameter_size(PropertyRNA *parm)
int len = parm->totarraylength;
/* XXX in other parts is mentioned that strings can be dynamic as well */
- if (parm->flag & PROP_DYNAMIC)
+ if (parm->flag & PROP_DYNAMIC) {
return sizeof(ParameterDynAlloc);
+ }
if (len > 0) {
switch (ptype) {
@@ -3762,8 +3944,9 @@ void RNA_enum_item_add_separator(EnumPropertyItem **items, int *totitem)
void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
{
- for (; item->identifier; item++)
+ for (; item->identifier; item++) {
RNA_enum_item_add(items, totitem, item);
+ }
}
void RNA_enum_items_add_value(EnumPropertyItem **items,
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c
index 3df4feba024..447318da744 100644
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@ -297,8 +297,8 @@ static PointerRNA rna_Depsgraph_objects_get(CollectionPropertyIterator *iter)
*/
/* XXX Ugly python seems to query next item of an iterator before using current one (see T57558).
- * This forces us to use that nasty ping-pong game between two sets of iterator data, so that previous one remains
- * valid memory for python to access to. Yuck.
+ * This forces us to use that nasty ping-pong game between two sets of iterator data,
+ * so that previous one remains valid memory for python to access to. Yuck.
*/
typedef struct RNA_Depsgraph_Instances_Iterator {
BLI_Iterator iterators[2];
@@ -335,8 +335,10 @@ static void rna_Depsgraph_object_instances_next(CollectionPropertyIterator *iter
di_it->iterators[di_it->counter % 2].data = &di_it->deg_data[di_it->counter % 2];
DEG_iterator_objects_next(&di_it->iterators[di_it->counter % 2]);
/* Dupli_object_current is also temp memory generated during the iterations,
- * it may be freed when last item has been iterated, so we have same issue as with the iterator itself:
- * we need to keep a local copy, which memory remains valid a bit longer, for python accesses to work. */
+ * it may be freed when last item has been iterated,
+ * so we have same issue as with the iterator itself:
+ * we need to keep a local copy, which memory remains valid a bit longer,
+ * for Python accesses to work. */
if (di_it->deg_data[di_it->counter % 2].dupli_object_current != NULL) {
di_it->dupli_object_current[di_it->counter % 2] =
*di_it->deg_data[di_it->counter % 2].dupli_object_current;
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index 85764dec682..92e63b1c778 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -117,20 +117,6 @@ static void rna_DynamicPaintSurface_initialcolortype(Main *bmain, Scene *scene,
rna_DynamicPaint_redoModifier(bmain, scene, ptr);
}
-static void rna_DynamicPaintSurface_changePreview(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- DynamicPaintSurface *act_surface = (DynamicPaintSurface *)ptr->data;
- DynamicPaintSurface *surface = act_surface->canvas->surfaces.first;
-
- /* since only one color surface can show preview at time
- * disable preview on other surfaces. */
- for (; surface; surface = surface->next) {
- if (surface != act_surface)
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- }
- rna_DynamicPaint_redoModifier(bmain, scene, ptr);
-}
-
static void rna_DynamicPaintSurface_uniqueName(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *ptr)
@@ -185,7 +171,10 @@ static PointerRNA rna_PaintSurface_active_get(PointerRNA *ptr)
static void rna_DynamicPaint_surfaces_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
DynamicPaintCanvasSettings *canvas = (DynamicPaintCanvasSettings *)ptr->data;
- /*rna_iterator_array_begin(iter, (void *)canvas->surfaces, sizeof(PaintSurface), canvas->totsur, 0, 0); */
+# if 0
+ rna_iterator_array_begin(
+ iter, (void *)canvas->surfaces, sizeof(PaintSurface), canvas->totsur, 0, 0);
+# endif
rna_iterator_listbase_begin(iter, &canvas->surfaces, NULL);
}
@@ -236,14 +225,6 @@ static bool rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr)
return (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) ? 1 : 0;
}
-/* is some 3D view preview available */
-static bool rna_DynamicPaint_use_color_preview_get(PointerRNA *ptr)
-{
- DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data;
-
- return dynamicPaint_surfaceHasColorPreview(surface);
-}
-
/* does output layer exist*/
static bool rna_DynamicPaint_is_output_exists(DynamicPaintSurface *surface, Object *ob, int index)
{
@@ -351,13 +332,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- /* Surface output preview. currently only paint has multiple outputs */
- static const EnumPropertyItem prop_dynamicpaint_surface_preview[] = {
- {MOD_DPAINT_SURFACE_PREV_PAINT, "PAINT", 0, "Paint", ""},
- {MOD_DPAINT_SURFACE_PREV_WETMAP, "WETMAP", 0, "Wetmap", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
/* Initial color setting */
static const EnumPropertyItem prop_dynamicpaint_init_color_type[] = {
{MOD_DPAINT_INITIAL_NONE, "NONE", 0, "None", ""},
@@ -418,11 +392,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Is Active", "Toggle whether surface is processed or ignored");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
- prop = RNA_def_property(srna, "show_preview", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PREVIEW);
- RNA_def_property_ui_text(prop, "Show Preview", "Display surface preview in 3D-views");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurface_changePreview");
-
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Surface name");
RNA_def_property_update(prop, NC_OBJECT, "rna_DynamicPaintSurface_uniqueName");
@@ -664,13 +633,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT2);
RNA_def_property_ui_text(prop, "Use Output", "Save this output layer");
- prop = RNA_def_property(srna, "preview_id", PROP_ENUM, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_enum_sdna(prop, NULL, "preview_id");
- RNA_def_property_enum_items(prop, prop_dynamicpaint_surface_preview);
- RNA_def_property_ui_text(prop, "Preview", "");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
/* to check if output name exists */
func = RNA_def_function(srna, "output_exists", "rna_DynamicPaint_is_output_exists");
RNA_def_function_ui_description(func, "Checks if surface output layer of given name exists");
@@ -764,15 +726,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_DynamicPaint_is_cache_user_get", NULL);
RNA_def_property_ui_text(prop, "Use Cache", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
-
- /* whether this surface has preview data for 3D view */
- RNA_define_verify_sdna(false);
- prop = RNA_def_property(srna, "use_color_preview", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_DynamicPaint_use_color_preview_get", NULL);
- RNA_def_property_ui_text(
- prop, "Use Color Preview", "Whether this surface has some color preview for 3D view");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_define_verify_sdna(true);
}
static void rna_def_dynamic_paint_canvas_settings(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index d8a687fdb84..c8df01a7dc7 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -310,7 +310,8 @@ static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value)
{
DriverTarget *dtar = (DriverTarget *)ptr->data;
- /* XXX in this case we need to be very careful, as this will require some new dependencies to be added! */
+ /* XXX in this case we need to be very careful,
+ * as this will require some new dependencies to be added! */
if (dtar->rna_path)
MEM_freeN(dtar->rna_path);
@@ -466,7 +467,8 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
}
if (GS(pid->name) == ID_AC && GS(vid->name) == ID_AC) {
- /* the ID given is the action already - usually when F-Curve is obtained from an action's pointer */
+ /* The ID given is the action already -
+ * usually when F-Curve is obtained from an action's pointer. */
act = (bAction *)pid;
}
else {
@@ -506,7 +508,8 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
action_groups_add_channel(act, value.data, fcu);
}
else {
- /* need to add this back, but it can only go at the end of the list (or else will corrupt groups) */
+ /* Need to add this back, but it can only go at the end of the list
+ * (or else will corrupt groups). */
BLI_addtail(&act->curves, fcu);
}
}
@@ -538,8 +541,8 @@ static void rna_FCurve_update_data_relations(Main *bmain,
DEG_relations_tag_update(bmain);
}
-/* RNA update callback for F-Curves to indicate that there are copy-on-write tagging/flushing needed
- * (e.g. for properties that affect how animation gets evaluated)
+/* RNA update callback for F-Curves to indicate that there are copy-on-write tagging/flushing
+ * needed (e.g. for properties that affect how animation gets evaluated).
*/
static void rna_FCurve_update_eval(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
@@ -792,7 +795,8 @@ static void rna_FModifierLimits_minx_range(PointerRNA *UNUSED(ptr),
// FModifier *fcm = (FModifier *)ptr->data;
// FMod_Limits *data = fcm->data;
- /* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */
+ /* No soft-limits on lower bound -
+ * it's too confusing when you can't easily use the slider to set things here. */
*min = MINAFRAMEF;
*max = MAXFRAMEF;
}
@@ -819,7 +823,8 @@ static void rna_FModifierLimits_miny_range(PointerRNA *UNUSED(ptr),
// FModifier *fcm = (FModifier *)ptr->data;
// FMod_Limits *data = fcm->data;
- /* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */
+ /* No soft-limits on lower bound -
+ * it's too confusing when you can't easily use the slider to set things here. */
*min = -FLT_MAX;
*max = FLT_MAX;
}
@@ -1519,7 +1524,7 @@ static void rna_def_fmodifier(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve");
# if 0 /* XXX not used yet */
- /* name */
+ /* name */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
RNA_def_property_ui_text(prop, "Name", "Short description of F-Curve Modifier");
diff --git a/source/blender/makesrna/intern/rna_fcurve_api.c b/source/blender/makesrna/intern/rna_fcurve_api.c
index ea3ad074452..873b3cfa502 100644
--- a/source/blender/makesrna/intern/rna_fcurve_api.c
+++ b/source/blender/makesrna/intern/rna_fcurve_api.c
@@ -46,7 +46,8 @@
static void rna_FCurve_convert_to_samples(FCurve *fcu, ReportList *reports, int start, int end)
{
- /* XXX fcurve_store_samples uses end frame included, which is not consistent with usual behavior in Blender,
+ /* XXX fcurve_store_samples uses end frame included,
+ * which is not consistent with usual behavior in Blender,
* nor python slices, etc. Let have public py API be consistent here at least. */
end--;
if (start > end) {
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c
index 6c91b69fbd8..49b0a344734 100644
--- a/source/blender/makesrna/intern/rna_fluidsim.c
+++ b/source/blender/makesrna/intern/rna_fluidsim.c
@@ -771,8 +771,10 @@ void RNA_def_fluidsim(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Type", "Type of participation in the fluid simulation");
RNA_def_property_update(prop, 0, "rna_FluidSettings_update_type");
- /*prop = RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); */
- /*RNA_def_property_ui_text(prop, "IPO Curves", "IPO curves used by fluid simulation settings"); */
+# if 0
+ prop = RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE);
+ RNA_def_property_ui_text(prop, "IPO Curves", "IPO curves used by fluid simulation settings");
+# endif
/* types */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 05cc12636ef..737dbe36d17 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1044,7 +1044,8 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "End Cap", "Stroke end extreme cap style");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
- /* No fill: The stroke never must fill area and must use fill color as stroke color (this is a special flag for fill brush) */
+ /* No fill: The stroke never must fill area and must use fill color as stroke color
+ * (this is a special flag for fill brush). */
prop = RNA_def_property(srna, "is_nofill_stroke", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_NOFILL);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1818,6 +1819,11 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Surface Offset", "Offset amount when drawing in surface mode");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "is_annotation", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_ANNOTATIONS);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Annotation", "Current datablock is an annotation");
+
/* Nested Structs */
prop = RNA_def_property(srna, "grid", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 076f0d8b85a..d1ae46a74f7 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -1665,8 +1665,9 @@ static void rna_def_modifier_gpencilarmature(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_multi_modifier", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "multi", 0);
RNA_def_property_ui_text(
- prop, "Multi Modifier",
- "Use same input as previous modifier, and mix results using overall vgroup");
+ prop,
+ "Multi Modifier",
+ "Use same input as previous modifier, and mix results using overall vgroup");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
# endif
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index b0030a87dfa..ca75f862b11 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -146,35 +146,23 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, image);
}
-static void rna_Image_pack(Image *image,
- Main *bmain,
- bContext *C,
- ReportList *reports,
- bool as_png,
- const char *data,
- int data_len)
+static void rna_Image_pack(
+ Image *image, Main *bmain, bContext *C, ReportList *reports, const char *data, int data_len)
{
- ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
+ BKE_image_free_packedfiles(image);
- if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
- BKE_report(reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG");
+ if (data) {
+ char *data_dup = MEM_mallocN(sizeof(*data_dup) * (size_t)data_len, __func__);
+ memcpy(data_dup, data, (size_t)data_len);
+ BKE_image_packfiles_from_mem(reports, image, data_dup, (size_t)data_len);
+ }
+ else if (BKE_image_is_dirty(image)) {
+ BKE_image_memorypack(image);
}
else {
- BKE_image_free_packedfiles(image);
- if (as_png) {
- BKE_image_memorypack(image);
- }
- else if (data) {
- char *data_dup = MEM_mallocN(sizeof(*data_dup) * (size_t)data_len, __func__);
- memcpy(data_dup, data, (size_t)data_len);
- BKE_image_packfiles_from_mem(reports, image, data_dup, (size_t)data_len);
- }
- else {
- BKE_image_packfiles(reports, image, ID_BLEND_PATH(bmain, &image->id));
- }
+ BKE_image_packfiles(reports, image, ID_BLEND_PATH(bmain, &image->id));
}
- BKE_image_release_ibuf(image, ibuf, NULL);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, image);
}
@@ -339,8 +327,6 @@ void RNA_api_image(StructRNA *srna)
func = RNA_def_function(srna, "pack", "rna_Image_pack");
RNA_def_function_ui_description(func, "Pack an image as embedded data into the .blend file");
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
- RNA_def_boolean(
- func, "as_png", 0, "as_png", "Pack the image as PNG (needed for generated/dirty images)");
parm = RNA_def_property(func, "data", PROP_STRING, PROP_BYTESTRING);
RNA_def_property_ui_text(parm, "data", "Raw data (bytes, exact content of the embedded file)");
RNA_def_int(func,
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 93409a7d008..92c895bd854 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -156,8 +156,9 @@ typedef void (*PropEnumSetFuncEx)(struct PointerRNA *ptr, struct PropertyRNA *pr
/**
* If \a override is NULL, merely do comparison between prop_a from ptr_a and prop_b from ptr_b,
* following comparison mode given.
- * If \a override and \a rna_path are not NULL, it will add a new override operation for overridable properties
- * that differ and have not yet been overridden (and set accordingly \a r_override_changed if given).
+ * If \a override and \a rna_path are not NULL, it will add a new override operation for
+ * overridable properties that differ and have not yet been overridden
+ * (and set accordingly \a r_override_changed if given).
*
* \note Given PropertyRNA are final (in case of IDProps...).
* \note In non-array cases, \a len values are 0.
@@ -182,8 +183,9 @@ typedef int (*RNAPropOverrideDiff)(struct Main *bmain,
*
* \note Given PropertyRNA are final (in case of IDProps...).
* \note In non-array cases, \a len values are 0.
- * \note Might change given override operation (e.g. change 'add' one into 'sub'), in case computed storage value
- * is out of range (or even change it to basic 'set' operation if nothing else works).
+ * \note Might change given override operation (e.g. change 'add' one into 'sub'),
+ * in case computed storage value is out of range
+ * (or even change it to basic 'set' operation if nothing else works).
*/
typedef bool (*RNAPropOverrideStore)(struct Main *bmain,
struct PointerRNA *ptr_local,
@@ -431,8 +433,8 @@ typedef struct PointerPropertyRNA {
PropPointerGetFunc get;
PropPointerSetFunc set;
PropPointerTypeFunc typef;
- PropPointerPollFunc
- poll; /* unlike operators, 'set' can still run if poll fails, used for filtering display */
+ /** unlike operators, 'set' can still run if poll fails, used for filtering display. */
+ PropPointerPollFunc poll;
struct StructRNA *type;
} PointerPropertyRNA;
@@ -460,8 +462,8 @@ struct StructRNA {
/* unique identifier, keep after 'cont' */
const char *identifier;
- /* python type, this is a subtype of pyrna_struct_Type but used so each struct can have its own type
- * which is useful for subclassing RNA */
+ /** Python type, this is a subtype of #pyrna_struct_Type
+ * but used so each struct can have its own type which is useful for subclassing RNA. */
void *py_type;
void *blender_type;
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index b0760b3377d..1985099e060 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -167,8 +167,9 @@ static void rna_ShapeKey_slider_max_set(PointerRNA *ptr, float value)
# undef SHAPEKEY_SLIDER_TOL
/* ***** Normals accessors for shapekeys. ***** */
-/* Note: with this we may recompute several times the same data, should we want to access verts, then polys, then loops
- * normals... However, such case looks rather unlikely - and not worth adding some kind of caching in KeyBlocks.
+/* Note: with this we may recompute several times the same data, should we want to access verts,
+ * then polys, then loops normals... However,
+ * such case looks rather unlikely - and not worth adding some kind of caching in KeyBlocks.
*/
static Mesh *rna_KeyBlock_normals_get_mesh(PointerRNA *ptr, ID *id)
@@ -722,7 +723,8 @@ static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
*/
end = (float *)((char *)start + (key->elemsize * kb->totelem));
- /* if point's address is less than the end, then it is somewhere between start and end, so in array */
+ /* If point's address is less than the end,
+ * then it is somewhere between start and end, so in array. */
if (end > point) {
/* we've found the owner of the point data */
return kb;
@@ -964,8 +966,8 @@ static void rna_def_keyblock(BlenderRNA *brna)
NULL,
NULL);
- /* XXX multi-dim dynamic arrays are very badly supported by (py)rna currently, those are defined for the day
- * it works better, for now user will get a 1D tuple...
+ /* XXX multi-dim dynamic arrays are very badly supported by (py)rna currently,
+ * those are defined for the day it works better, for now user will get a 1D tuple.
*/
func = RNA_def_function(srna, "normals_vertex_get", "rna_KeyBlock_normals_vert_calc");
RNA_def_function_ui_description(func,
diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c
index 6d82ded02bd..63834c9280c 100644
--- a/source/blender/makesrna/intern/rna_main.c
+++ b/source/blender/makesrna/intern/rna_main.c
@@ -442,8 +442,9 @@ void RNA_def_main(BlenderRNA *brna)
/* collection functions */
func = lists[i].func;
- if (func)
+ if (func) {
func(brna, prop);
+ }
}
RNA_api_main(srna);
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 6ac36ef097e..d5347e77348 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -667,7 +667,7 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(textures, textures, ID_TE)
RNA_MAIN_ID_TAG_FUNCS_DEF(brushes, brushes, ID_BR)
RNA_MAIN_ID_TAG_FUNCS_DEF(worlds, worlds, ID_WO)
RNA_MAIN_ID_TAG_FUNCS_DEF(collections, collections, ID_GR)
-//RNA_MAIN_ID_TAG_FUNCS_DEF(shape_keys, key, ID_KE)
+// RNA_MAIN_ID_TAG_FUNCS_DEF(shape_keys, key, ID_KE)
RNA_MAIN_ID_TAG_FUNCS_DEF(texts, texts, ID_TXT)
RNA_MAIN_ID_TAG_FUNCS_DEF(speakers, speakers, ID_SPK)
RNA_MAIN_ID_TAG_FUNCS_DEF(sounds, sounds, ID_SO)
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index c5b2f70366e..8b27c69604e 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -632,7 +632,7 @@ static void rna_def_maskParent(BlenderRNA *brna)
RNA_def_property_enum_items(prop, mask_id_type_items);
RNA_def_property_enum_default(prop, ID_MC);
RNA_def_property_enum_funcs(prop, NULL, "rna_MaskParent_id_type_set", NULL);
- //RNA_def_property_editable_func(prop, "rna_MaskParent_id_type_editable");
+ // RNA_def_property_editable_func(prop, "rna_MaskParent_id_type_editable");
RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
RNA_def_property_update(prop, 0, "rna_Mask_update_parent");
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 8fb26e47913..d66b4e5be44 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -475,6 +475,13 @@ static void rna_def_material_greasepencil(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Mix", "Mix Adjustment Factor");
RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
+ /* Stroke Mix factor */
+ prop = RNA_def_property(srna, "mix_stroke_factor", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "mix_stroke_factor");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Mix", "Mix Stroke Color");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
+
/* Scale factor for uv coordinates */
prop = RNA_def_property(srna, "pattern_scale", PROP_FLOAT, PROP_COORDS);
RNA_def_property_float_sdna(prop, NULL, "gradient_scale");
@@ -569,9 +576,14 @@ static void rna_def_material_greasepencil(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Clamp", "Do not repeat texture and clamp to one instance only");
RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
- prop = RNA_def_property(srna, "texture_mix", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_COLOR_TEX_MIX);
- RNA_def_property_ui_text(prop, "Mix Texture", "Mix texture image with filling colors");
+ prop = RNA_def_property(srna, "use_fill_texture_mix", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_FILL_TEX_MIX);
+ RNA_def_property_ui_text(prop, "Mix Texture", "Mix texture image with filling color");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
+
+ prop = RNA_def_property(srna, "use_stroke_texture_mix", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_STROKE_TEX_MIX);
+ RNA_def_property_ui_text(prop, "Mix Texture", "Mix texture image with stroke color");
RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
prop = RNA_def_property(srna, "flip", PROP_BOOLEAN, PROP_NONE);
@@ -911,8 +923,9 @@ void rna_def_mtex_common(BlenderRNA *brna,
prop = RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Texture");
RNA_def_property_flag(prop, PROP_EDITABLE);
- if (activeeditable)
+ if (activeeditable) {
RNA_def_property_editable_func(prop, activeeditable);
+ }
RNA_def_property_pointer_funcs(prop, activeget, activeset, NULL, NULL);
RNA_def_property_ui_text(prop, "Active Texture", "Active texture slot being displayed");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, update);
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index a4ad07af6b7..0b4056121b3 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -1002,7 +1002,8 @@ static void rna_Mesh_face_map_remove(struct Mesh *me,
static int rna_MeshPoly_vertices_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
MPoly *mp = (MPoly *)ptr->data;
- /* note, raw access uses dummy item, this _could_ crash, watch out for this, mface uses it but it cant work here */
+ /* note, raw access uses dummy item, this _could_ crash,
+ * watch out for this, mface uses it but it cant work here. */
return (length[0] = mp->totloop);
}
@@ -1030,7 +1031,8 @@ static void rna_MeshPoly_vertices_set(PointerRNA *ptr, const int *values)
/* disabling, some importers don't know the total material count when assigning materials */
# if 0
-static void rna_MeshPoly_material_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
+static void rna_MeshPoly_material_index_range(
+ PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
{
Mesh *me = rna_mesh(ptr);
*min = 0;
@@ -2075,7 +2077,8 @@ static void rna_def_mproperties(BlenderRNA *brna)
prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE); \
RNA_def_property_float_sdna(prop, NULL, "f"); \
RNA_def_property_ui_text(prop, "Value", ""); \
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); \
+ ((void)0)
/* Int */
# define MESH_INT_PROPERTY_LAYER(elemname) \
@@ -2115,7 +2118,8 @@ static void rna_def_mproperties(BlenderRNA *brna)
prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE); \
RNA_def_property_int_sdna(prop, NULL, "i"); \
RNA_def_property_ui_text(prop, "Value", ""); \
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); \
+ ((void)0)
/* String */
# define MESH_STRING_PROPERTY_LAYER(elemname) \
@@ -2162,10 +2166,10 @@ static void rna_def_mproperties(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Value", ""); \
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
- MESH_FLOAT_PROPERTY_LAYER("Vertex")
- MESH_FLOAT_PROPERTY_LAYER("Polygon")
- MESH_INT_PROPERTY_LAYER("Vertex")
- MESH_INT_PROPERTY_LAYER("Polygon")
+ MESH_FLOAT_PROPERTY_LAYER("Vertex");
+ MESH_FLOAT_PROPERTY_LAYER("Polygon");
+ MESH_INT_PROPERTY_LAYER("Vertex");
+ MESH_INT_PROPERTY_LAYER("Polygon");
MESH_STRING_PROPERTY_LAYER("Vertex")
MESH_STRING_PROPERTY_LAYER("Polygon")
# undef MESH_PROPERTY_LAYER
@@ -3041,7 +3045,8 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
RNA_def_property_editable_func(prop, "rna_Mesh_texspace_editable");
- RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_loc_get", "rna_Mesh_texspace_loc_set", NULL);
+ RNA_def_property_float_funcs(
+ prop, "rna_Mesh_texspace_loc_get", "rna_Mesh_texspace_loc_set", NULL);
RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
# endif
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 860c2c3ba89..4f304f97cac 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1049,8 +1049,10 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf(
# if 0 /* XXX Don't think we want this in modifier version... */
if (BKE_object_pose_armature_get(ob_src)) {
- RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_SELECT);
- RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_DEFORM);
+ RNA_enum_items_add_value(
+ &item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_SELECT);
+ RNA_enum_items_add_value(
+ &item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_DEFORM);
}
# endif
@@ -1298,19 +1300,6 @@ static bool rna_SurfaceDeformModifier_is_bound_get(PointerRNA *ptr)
return (((SurfaceDeformModifierData *)ptr->data)->verts != NULL);
}
-static void rna_MeshSequenceCache_object_path_update(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
-# ifdef WITH_ALEMBIC
- MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)ptr->data;
- Object *ob = (Object *)ptr->id.data;
-
- mcmd->reader = CacheReader_open_alembic_object(
- mcmd->cache_file->handle, mcmd->reader, ob, mcmd->object_path);
-# endif
-
- rna_Modifier_update(bmain, scene, ptr);
-}
-
static bool rna_ParticleInstanceModifier_particle_system_poll(PointerRNA *ptr,
const PointerRNA value)
{
@@ -1373,16 +1362,28 @@ static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const c
"Smooth, keep corners",
"UVs are smoothed, corners on discontinuous boundary are kept sharp"},
# if 0
- {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_AND_JUNCTIONS, "PRESERVE_CORNERS_AND_JUNCTIONS", 0,
- "Smooth, keep corners+junctions", "UVs are smoothed, corners on discontinuous boundary and "
+ {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_AND_JUNCTIONS,
+ "PRESERVE_CORNERS_AND_JUNCTIONS",
+ 0,
+ "Smooth, keep corners+junctions",
+ "UVs are smoothed, corners on discontinuous boundary and "
"junctions of 3 or more regions are kept sharp"},
- {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE, "PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE", 0,
- "Smooth, keep corners+junctions+concave", "UVs are smoothed, corners on discontinuous boundary, "
+ {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE,
+ "PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE",
+ 0,
+ "Smooth, keep corners+junctions+concave",
+ "UVs are smoothed, corners on discontinuous boundary, "
"junctions of 3 or more regions and darts and concave corners are kept sharp"},
- {SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES, "PRESERVE_BOUNDARIES", 0,
- "Smooth, keep corners", "UVs are smoothed, boundaries are kept sharp"},
- {SUBSURF_UV_SMOOTH_ALL, "PRESERVE_BOUNDARIES", 0,
- "Smooth all", "UVs and boundaries are smoothed"},
+ {SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES,
+ "PRESERVE_BOUNDARIES",
+ 0,
+ "Smooth, keep corners",
+ "UVs are smoothed, boundaries are kept sharp"},
+ {SUBSURF_UV_SMOOTH_ALL,
+ "PRESERVE_BOUNDARIES",
+ 0,
+ "Smooth all",
+ "UVs and boundaries are smoothed"},
# endif
{0, NULL, 0, NULL, NULL},
};
@@ -2105,13 +2106,15 @@ static void rna_def_modifier_armature(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Bone Envelopes", "Bind Bone envelopes to armature modifier");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop = RNA_def_property(srna, "use_vertex_groups", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Use Vertex Groups", "Bind vertex groups to armature modifier");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION);
@@ -2956,9 +2959,9 @@ static void rna_def_modifier_meshdeform(BlenderRNA *brna)
PropertyRNA *prop;
# if 0
static const EnumPropertyItem prop_mode_items[] = {
- {0, "VOLUME", 0, "Volume", "Bind to volume inside cage mesh"},
- {1, "SURFACE", 0, "Surface", "Bind to surface of cage mesh"},
- {0, NULL, 0, NULL, NULL},
+ {0, "VOLUME", 0, "Volume", "Bind to volume inside cage mesh"},
+ {1, "SURFACE", 0, "Surface", "Bind to surface of cage mesh"},
+ {0, NULL, 0, NULL, NULL},
};
# endif
@@ -4109,7 +4112,8 @@ static void rna_def_modifier_screw(BlenderRNA *brna)
# if 0
prop = RNA_def_property(srna, "use_angle_object", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_OBJECT_ANGLE);
- RNA_def_property_ui_text(prop, "Object Angle", "Use the angle between the objects rather than the fixed angle");
+ RNA_def_property_ui_text(
+ prop, "Object Angle", "Use the angle between the objects rather than the fixed angle");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
# endif
}
@@ -4643,8 +4647,11 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
"Displace",
"Displace existing geometry according to simulation"},
# if 0
- {MOD_OCEAN_GEOM_SIM_ONLY, "SIM_ONLY", 0, "Sim Only",
- "Leaves geometry unchanged, but still runs simulation (to be used from texture)"},
+ {MOD_OCEAN_GEOM_SIM_ONLY,
+ "SIM_ONLY",
+ 0,
+ "Sim Only",
+ "Leaves geometry unchanged, but still runs simulation (to be used from texture)"},
# endif
{0, NULL, 0, NULL, NULL},
};
@@ -5087,7 +5094,7 @@ static void rna_def_modifier_meshseqcache(BlenderRNA *brna)
prop,
"Object Path",
"Path to the object in the Alembic archive used to lookup geometric data");
- RNA_def_property_update(prop, 0, "rna_MeshSequenceCache_object_path_update");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
static const EnumPropertyItem read_flag_items[] = {
{MOD_MESHSEQ_READ_VERT, "VERT", 0, "Vertex", ""},
@@ -5232,7 +5239,9 @@ static void rna_def_modifier_datatransfer(BlenderRNA *brna)
# if 0 /* TODO */
{DT_TYPE_SHAPEKEY, "SHAPEKEYS", 0, "Shapekey(s)", "Transfer active or all shape keys"},
# endif
-# if 0 /* XXX When SkinModifier is enabled, it seems to erase its own CD_MVERT_SKIN layer from final DM :( */
+ /* XXX When SkinModifier is enabled,
+ * it seems to erase its own CD_MVERT_SKIN layer from final DM :( */
+# if 0
{DT_TYPE_SKIN, "SKIN", 0, "Skin Weight", "Transfer skin weights"},
# endif
{DT_TYPE_BWEIGHT_VERT, "BEVEL_WEIGHT_VERT", 0, "Bevel Weight", "Transfer bevel weights"},
@@ -5457,10 +5466,15 @@ static void rna_def_modifier_datatransfer(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
# if 0
- prop = RNA_def_enum(srna, "layers_shapekey_select_src", rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC,
- "Source Layers Selection", "Which layers to transfer, in case of multi-layers types");
+ prop = RNA_def_enum(srna,
+ "layers_shapekey_select_src",
+ rna_enum_dt_layers_select_src_items,
+ DT_LAYERS_ALL_SRC,
+ "Source Layers Selection",
+ "Which layers to transfer, in case of multi-layers types");
RNA_def_property_enum_sdna(prop, NULL, "layers_select_src[DT_MULTILAYER_INDEX_SHAPEKEY]");
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf");
+ RNA_def_property_enum_funcs(
+ prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
# endif
@@ -5498,10 +5512,15 @@ static void rna_def_modifier_datatransfer(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Modifier_update");
# if 0
- prop = RNA_def_enum(srna, "layers_shapekey_select_dst", rna_enum_dt_layers_select_dst_items, DT_LAYERS_NAME_DST,
- "Destination Layers Matching", "How to match source and destination layers");
+ prop = RNA_def_enum(srna,
+ "layers_shapekey_select_dst",
+ rna_enum_dt_layers_select_dst_items,
+ DT_LAYERS_NAME_DST,
+ "Destination Layers Matching",
+ "How to match source and destination layers");
RNA_def_property_enum_sdna(prop, NULL, "layers_select_dst[DT_MULTILAYER_INDEX_SHAPEKEY]");
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf");
+ RNA_def_property_enum_funcs(
+ prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
# endif
diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c
index 7573d2cdc05..c3192b4f850 100644
--- a/source/blender/makesrna/intern/rna_nla.c
+++ b/source/blender/makesrna/intern/rna_nla.c
@@ -138,12 +138,13 @@ static void rna_NlaStrip_start_frame_set(PointerRNA *ptr, float value)
{
NlaStrip *data = (NlaStrip *)ptr->data;
- /* clamp value to lie within valid limits
- * - cannot start past the end of the strip + some flexibility threshold
- * - cannot start before the previous strip (if present) ends
- * -> but if it was a transition, we could go up to the start of the strip + some flexibility threshold
- * as long as we re-adjust the transition afterwards
- * - minimum frame is -MAXFRAME so that we don't get clipping on frame 0
+ /* Clamp value to lie within valid limits:
+ * - Cannot start past the end of the strip + some flexibility threshold.
+ * - Cannot start before the previous strip (if present) ends.
+ * -> But if it was a transition,
+ * we could go up to the start of the strip + some flexibility threshold.
+ * as long as we re-adjust the transition afterwards.
+ * - Minimum frame is -MAXFRAME so that we don't get clipping on frame 0.
*/
if (data->prev) {
if (data->prev->type == NLASTRIP_TYPE_TRANSITION) {
@@ -171,7 +172,8 @@ static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, float value)
* - must not have zero or negative length strip, so cannot start before the first frame
* + some minimum-strip-length threshold
* - cannot end later than the start of the next strip (if present)
- * -> but if it was a transition, we could go up to the start of the end - some flexibility threshold
+ * -> but if it was a transition,
+ * we could go up to the start of the end - some flexibility threshold
* as long as we re-adjust the transition afterwards
*/
if (data->next) {
@@ -210,7 +212,8 @@ static void rna_NlaStrip_scale_set(PointerRNA *ptr, float value)
NlaStrip *data = (NlaStrip *)ptr->data;
/* set scale value */
- /* NOTE: these need to be synced with the values in the property definition in rna_def_nlastrip() */
+ /* NOTE: these need to be synced with the values in the
+ * property definition in rna_def_nlastrip() */
CLAMP(value, 0.0001f, 1000.0f);
data->scale = value;
@@ -223,7 +226,8 @@ static void rna_NlaStrip_repeat_set(PointerRNA *ptr, float value)
NlaStrip *data = (NlaStrip *)ptr->data;
/* set repeat value */
- /* NOTE: these need to be synced with the values in the property definition in rna_def_nlastrip() */
+ /* NOTE: these need to be synced with the values in the
+ * property definition in rna_def_nlastrip() */
CLAMP(value, 0.01f, 1000.0f);
data->repeat = value;
@@ -411,7 +415,8 @@ static NlaStrip *rna_NlaStrip_new(ID *id,
AnimData adt = {NULL};
NlaTrack *nlt, *nlt_p;
- /* 'first' NLA track is found by going back up chain of given track's parents until we fall off */
+ /* 'first' NLA track is found by going back up chain of given
+ * track's parents until we fall off. */
nlt_p = track;
nlt = track;
while ((nlt = nlt->prev) != NULL)
@@ -736,15 +741,15 @@ static void rna_def_nlastrip(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Influence", "Amount the strip contributes to the current result");
/* XXX: Update temporarily disabled so that the property can be edited at all!
- * Even autokey only applies after the curves have been re-evaluated, causing the unkeyed values to be lost
- */
+ * Even autokey only applies after the curves have been re-evaluated,
+ * causing the unkeyed values to be lost. */
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, /*"rna_NlaStrip_update"*/ NULL);
prop = RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_TIME);
RNA_def_property_ui_text(prop, "Strip Time", "Frame of referenced Action to evaluate");
/* XXX: Update temporarily disabled so that the property can be edited at all!
- * Even autokey only applies after the curves have been re-evaluated, causing the unkeyed values to be lost
- */
+ * Even autokey only applies after the curves have been re-evaluated,
+ * causing the unkeyed values to be lost. */
RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, /*"rna_NlaStrip_update"*/ NULL);
/* TODO: should the animated_influence/time settings be animatable themselves? */
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index fb0ee247598..e4270f3854e 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -599,8 +599,8 @@ static void rna_NodeTree_get_from_context(
void *ret1, *ret2, *ret3;
RNA_pointer_create(NULL, ntreetype->ext.srna, NULL, &ptr); /* dummy */
- func =
- &rna_NodeTree_get_from_context_func; /* RNA_struct_find_function(&ptr, "get_from_context"); */
+ /* RNA_struct_find_function(&ptr, "get_from_context"); */
+ func = &rna_NodeTree_get_from_context_func;
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "context", &C);
@@ -1692,7 +1692,8 @@ static bNodeSocket *rna_Node_inputs_new(ID *id,
const char *name,
const char *identifier)
{
- /* Adding an input to a group node is not working, simpler to add it to its underlying nodetree. */
+ /* Adding an input to a group node is not working,
+ * simpler to add it to its underlying nodetree. */
if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id != NULL) {
return rna_NodeTree_inputs_new((bNodeTree *)node->id, bmain, reports, type, name);
}
@@ -1721,7 +1722,8 @@ static bNodeSocket *rna_Node_outputs_new(ID *id,
const char *name,
const char *identifier)
{
- /* Adding an output to a group node is not working, simpler to add it to its underlying nodetree. */
+ /* Adding an output to a group node is not working,
+ * simpler to add it to its underlying nodetree. */
if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id != NULL) {
return rna_NodeTree_outputs_new((bNodeTree *)node->id, bmain, reports, type, name);
}
@@ -2151,8 +2153,8 @@ static void rna_NodeSocketInterface_register_properties(bNodeTree *ntree,
return;
RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, stemp, &ptr);
- func =
- &rna_NodeSocketInterface_register_properties_func; /* RNA_struct_find_function(&ptr, "register_properties"); */
+ /* RNA_struct_find_function(&ptr, "register_properties"); */
+ func = &rna_NodeSocketInterface_register_properties_func;
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "data_rna_type", &data_srna);
@@ -2176,8 +2178,8 @@ static void rna_NodeSocketInterface_init_socket(
RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, stemp, &ptr);
RNA_pointer_create((ID *)ntree, &RNA_Node, node, &node_ptr);
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sock_ptr);
- func =
- &rna_NodeSocketInterface_init_socket_func; /* RNA_struct_find_function(&ptr, "init_socket"); */
+ /* RNA_struct_find_function(&ptr, "init_socket"); */
+ func = &rna_NodeSocketInterface_init_socket_func;
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "node", &node_ptr);
@@ -2205,8 +2207,8 @@ static void rna_NodeSocketInterface_from_socket(bNodeTree *ntree,
RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, stemp, &ptr);
RNA_pointer_create((ID *)ntree, &RNA_Node, node, &node_ptr);
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sock_ptr);
- func =
- &rna_NodeSocketInterface_from_socket_func; /* RNA_struct_find_function(&ptr, "from_socket"); */
+ /* RNA_struct_find_function(&ptr, "from_socket"); */
+ func = &rna_NodeSocketInterface_from_socket_func;
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "node", &node_ptr);
@@ -2595,7 +2597,7 @@ static StructRNA *rna_NodeCustomGroup_register(Main *bmain,
return NULL;
/* this updates the group node instance from the tree's interface */
- nt->verifyfunc = node_group_verify;
+ nt->group_update_func = node_group_update;
nodeRegisterType(nt);
@@ -2619,7 +2621,7 @@ static StructRNA *rna_ShaderNodeCustomGroup_register(Main *bmain,
if (!nt)
return NULL;
- nt->verifyfunc = node_group_verify;
+ nt->group_update_func = node_group_update;
nt->type = NODE_CUSTOM_GROUP;
register_node_type_sh_custom_group(nt);
@@ -2644,7 +2646,7 @@ static StructRNA *rna_CompositorNodeCustomGroup_register(Main *bmain,
if (!nt)
return NULL;
- nt->verifyfunc = node_group_verify;
+ nt->group_update_func = node_group_update;
nt->type = NODE_CUSTOM_GROUP;
register_node_type_cmp_custom_group(nt);
@@ -2827,7 +2829,8 @@ static const EnumPropertyItem *renderresult_layers_add_enum(RenderLayer *rl)
while (rl) {
tmp.identifier = rl->name;
- /* little trick: using space char instead empty string makes the item selectable in the dropdown */
+ /* Little trick: using space char instead empty string
+ * makes the item selectable in the dropdown. */
if (rl->name[0] == '\0')
tmp.name = " ";
else
@@ -2898,7 +2901,8 @@ static const EnumPropertyItem *renderresult_views_add_enum(RenderView *rv)
while (rv) {
tmp.identifier = rv->name;
- /* little trick: using space char instead empty string makes the item selectable in the dropdown */
+ /* Little trick: using space char instead empty string
+ * makes the item selectable in the dropdown. */
if (rv->name[0] == '\0')
tmp.name = " ";
else
@@ -4990,7 +4994,7 @@ static void def_sh_script(StructRNA *srna)
RNA_def_function_ui_description(func, "Find a socket by name");
parm = RNA_def_string(func, "name", NULL, 0, "Socket name", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- /*parm =*/ RNA_def_boolean(func, "is_output", false, "Output", "Whether the socket is an output");
+ /*parm =*/RNA_def_boolean(func, "is_output", false, "Output", "Whether the socket is an output");
parm = RNA_def_pointer(func, "result", "NodeSocket", "", "");
RNA_def_function_return(func, parm);
@@ -5001,7 +5005,7 @@ static void def_sh_script(StructRNA *srna)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_enum(func, "type", node_socket_type_items, SOCK_FLOAT, "Type", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- /*parm =*/ RNA_def_boolean(func, "is_output", false, "Output", "Whether the socket is an output");
+ /*parm =*/RNA_def_boolean(func, "is_output", false, "Output", "Whether the socket is an output");
parm = RNA_def_pointer(func, "result", "NodeSocket", "", "");
RNA_def_function_return(func, parm);
@@ -5335,11 +5339,11 @@ static void def_cmp_image(StructRNA *srna)
# if 0
static const EnumPropertyItem type_items[] = {
- {IMA_SRC_FILE, "IMAGE", 0, "Image", ""},
- {IMA_SRC_MOVIE, "MOVIE", "Movie", ""},
- {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", ""},
- {IMA_SRC_GENERATED, "GENERATED", "Generated", ""},
- {0, NULL, 0, NULL, NULL},
+ {IMA_SRC_FILE, "IMAGE", 0, "Image", ""},
+ {IMA_SRC_MOVIE, "MOVIE", "Movie", ""},
+ {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", ""},
+ {IMA_SRC_GENERATED, "GENERATED", "Generated", ""},
+ {0, NULL, 0, NULL, NULL},
};
# endif
@@ -6891,9 +6895,11 @@ static void def_cmp_bokehblur(StructRNA *srna)
prop = RNA_def_property(srna, "f_stop", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "custom3");
RNA_def_property_range(prop, 0.0f, 128.0f);
- RNA_def_property_ui_text(prop, "F-stop",
- "Amount of focal blur, 128=infinity=perfect focus, half the value doubles "
- "the blur radius");
+ RNA_def_property_ui_text(
+ prop,
+ "F-stop",
+ "Amount of focal blur, 128=infinity=perfect focus, half the value doubles "
+ "the blur radius");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
# endif
@@ -8140,7 +8146,8 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
/* XXX Workaround: Registered functions are not exposed in python by bpy,
* it expects them to be registered from python and use the native implementation.
* However, the standard socket types below are not registering these functions from python,
- * so in order to call them in py scripts we need to overload and replace them with plain C callbacks.
+ * so in order to call them in py scripts we need to overload and
+ * replace them with plain C callbacks.
* These types provide a usable basis for socket types defined in C.
*/
@@ -8217,7 +8224,8 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
/* XXX These types should eventually be registered at runtime.
* Then use the nodeStaticSocketType and nodeStaticSocketInterfaceType functions
- * to get the idname strings from int type and subtype (see node_socket.c, register_standard_node_socket_types).
+ * to get the idname strings from int type and subtype
+ * (see node_socket.c, register_standard_node_socket_types).
*/
rna_def_node_socket_float(brna, "NodeSocketFloat", "NodeSocketInterfaceFloat", PROP_NONE);
@@ -8302,8 +8310,10 @@ static void rna_def_internal_node(BlenderRNA *brna)
/* XXX Workaround: Registered functions are not exposed in python by bpy,
* it expects them to be registered from python and use the native implementation.
+ *
* However, the standard node types are not registering these functions from python,
- * so in order to call them in py scripts we need to overload and replace them with plain C callbacks.
+ * so in order to call them in py scripts we need to overload and
+ * replace them with plain C callbacks.
* This type provides a usable basis for node types defined in C.
*/
@@ -9122,9 +9132,11 @@ static StructRNA *define_specific_node(BlenderRNA *brna,
FunctionRNA *func;
PropertyRNA *parm;
- /* XXX hack, want to avoid "NodeInternal" prefix, so use "Node" in NOD_static_types.h and replace here */
- if (STREQ(base_name, "Node"))
+ /* XXX hack, want to avoid "NodeInternal" prefix,
+ * so use "Node" in NOD_static_types.h and replace here */
+ if (STREQ(base_name, "Node")) {
base_name = "NodeInternal";
+ }
srna = RNA_def_struct(brna, struct_name, base_name);
RNA_def_struct_ui_text(srna, ui_name, ui_desc);
@@ -9137,8 +9149,8 @@ static StructRNA *define_specific_node(BlenderRNA *brna,
RNA_def_function_return(func, parm);
/* Exposes the socket template type lists in RNA for use in scripts
- * Only used in the C nodes and not exposed in the base class to keep the namespace clean for pynodes.
- */
+ * Only used in the C nodes and not exposed in the base class to
+ * keep the namespace clean for py-nodes. */
func = RNA_def_function(srna, "input_template", "rna_NodeInternal_input_template");
RNA_def_function_ui_description(func, "Input socket template");
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_SELF_TYPE);
@@ -9161,8 +9173,9 @@ static StructRNA *define_specific_node(BlenderRNA *brna,
RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
RNA_def_function_return(func, parm);
- if (def_func)
+ if (def_func) {
def_func(srna);
+ }
return srna;
}
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index b36e6490e5f..219445f629f 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -153,11 +153,8 @@ const EnumPropertyItem rna_enum_object_gpencil_type_items[] = {
static const EnumPropertyItem parent_type_items[] = {
{PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"},
{PARSKEL, "ARMATURE", 0, "Armature", ""},
- {PARSKEL,
- "LATTICE",
- 0,
- "Lattice",
- "The object is parented to a lattice"}, /* PARSKEL reuse will give issues */
+ /* PARSKEL reuse will give issues. */
+ {PARSKEL, "LATTICE", 0, "Lattice", "The object is parented to a lattice"},
{PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"},
{PARVERT3, "VERTEX_3", 0, "3 Vertices", ""},
{PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"},
@@ -193,11 +190,8 @@ const EnumPropertyItem rna_enum_metaelem_type_items[] = {
{MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
{MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
{MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
- {MB_ELIPSOID,
- "ELLIPSOID",
- ICON_META_ELLIPSOID,
- "Ellipsoid",
- ""}, /* NOTE: typo at original definition! */
+ /* NOTE: typo at original definition! */
+ {MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""},
{MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -352,8 +346,9 @@ static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
Object *ob = ptr->id.data;
float local_mat[4][4];
- /* localspace matrix is truly relative to the parent, but parameters stored in object are
- * relative to parentinv matrix. Undo the parent inverse part before applying it as local matrix. */
+ /* Localspace matrix is truly relative to the parent,
+ * but parameters stored in object are relative to parentinv matrix.
+ * Undo the parent inverse part before applying it as local matrix. */
if (ob->parent) {
float invmat[4][4];
invert_m4_m4(invmat, ob->parentinv);
@@ -363,7 +358,8 @@ static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
copy_m4_m4(local_mat, (float(*)[4])values);
}
- /* don't use compat so we get predictable rotation, and do not use parenting either, because it's a local matrix! */
+ /* Don't use compat so we get predictable rotation, and do not use parenting either,
+ * because it's a local matrix! */
BKE_object_apply_mat4(ob, local_mat, false, false);
}
@@ -385,6 +381,12 @@ void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene),
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
}
+void rna_Object_internal_update_data_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ DEG_relations_tag_update(bmain);
+ rna_Object_internal_update_data(bmain, scene, ptr);
+}
+
static void rna_Object_active_shape_update(bContext *C, PointerRNA *ptr)
{
Object *ob = ptr->id.data;
@@ -714,9 +716,8 @@ void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result
Object *ob = (Object *)ptr->id.data;
bDeformGroup *dg = defgroup_find_name(ob, value);
if (dg) {
- BLI_strncpy(result,
- value,
- maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */
+ /* No need for BLI_strncpy_utf8, since this matches an existing group. */
+ BLI_strncpy(result, value, maxlen);
return;
}
@@ -798,9 +799,8 @@ void rna_object_fmap_name_set(PointerRNA *ptr, const char *value, char *result,
Object *ob = (Object *)ptr->id.data;
bFaceMap *fmap = BKE_object_facemap_find_name(ob, value);
if (fmap) {
- BLI_strncpy(result,
- value,
- maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */
+ /* No need for BLI_strncpy_utf8, since this matches an existing group. */
+ BLI_strncpy(result, value, maxlen);
return;
}
@@ -1377,8 +1377,8 @@ bool rna_Object_constraints_override_apply(Main *UNUSED(bmain),
/* This handles NULL anchor as expected by adding at head of list. */
BLI_insertlinkafter(&ob_dst->constraints, con_anchor, con_dst);
- /* This should actually *not* be needed in typical cases. However, if overridden source was edited,
- * we *may* have some new conflicting names. */
+ /* This should actually *not* be needed in typical cases.
+ * However, if overridden source was edited, we *may* have some new conflicting names. */
BKE_constraint_unique_name(con_dst, &ob_dst->constraints);
// printf("%s: We inserted a constraint...\n", __func__);
@@ -1466,7 +1466,8 @@ bool rna_Object_modifiers_override_apply(Main *UNUSED(bmain),
/* This handles NULL anchor as expected by adding at head of list. */
BLI_insertlinkafter(&ob_dst->modifiers, mod_anchor, mod_dst);
- /* This should actually *not* be needed in typical cases. However, if overridden source was edited,
+ /* This should actually *not* be needed in typical cases.
+ * However, if overridden source was edited,
* we *may* have some new conflicting names. */
modifier_unique_name(&ob_dst->modifiers, mod_dst);
@@ -1544,16 +1545,20 @@ static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
}
}
-static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name)
+static bDeformGroup *rna_Object_vgroup_new(Object *ob, Main *bmain, const char *name)
{
bDeformGroup *defgroup = BKE_object_defgroup_add_name(ob, name);
+ DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
return defgroup;
}
-static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA *defgroup_ptr)
+static void rna_Object_vgroup_remove(Object *ob,
+ Main *bmain,
+ ReportList *reports,
+ PointerRNA *defgroup_ptr)
{
bDeformGroup *defgroup = defgroup_ptr->data;
if (BLI_findindex(&ob->defbase, defgroup) == -1) {
@@ -1568,13 +1573,15 @@ static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA
BKE_object_defgroup_remove(ob, defgroup);
RNA_POINTER_INVALIDATE(defgroup_ptr);
+ DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
-static void rna_Object_vgroup_clear(Object *ob)
+static void rna_Object_vgroup_clear(Object *ob, Main *bmain)
{
BKE_object_defgroup_remove_all(ob);
+ DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
@@ -1762,7 +1769,8 @@ static void rna_def_vertex_group(BlenderRNA *brna)
RNA_def_struct_name_property(srna, prop);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
/* update data because modifiers may use [#24761] */
- RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
+ RNA_def_property_update(
+ prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data_dependency");
prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
@@ -1868,7 +1876,8 @@ static void rna_def_material_slot(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
/* WARNING! Order is crucial for override to work properly here... :/
- * 'link' must come before material pointer, since it defines where (in object or obdata) that one is set! */
+ * 'link' must come before material pointer,
+ * since it defines where (in object or obdata) that one is set! */
prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, link_items);
RNA_def_property_enum_funcs(
@@ -2164,19 +2173,21 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
/* vertex groups */ /* add_vertex_group */
func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Add vertex group to object");
RNA_def_string(func, "name", "Group", 0, "", "Vertex group name"); /* optional */
parm = RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Delete vertex group from object");
parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Delete all vertex groups from object");
}
@@ -2521,8 +2532,10 @@ static void rna_def_object(BlenderRNA *brna)
/* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
RNA_def_property_float_sdna(prop, NULL, "dquat");
RNA_def_property_float_array_default(prop, rna_default_axis_angle);
- RNA_def_property_ui_text(prop, "Delta Rotation (Axis Angle)",
- "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
+ RNA_def_property_ui_text(
+ prop,
+ "Delta Rotation (Axis Angle)",
+ "Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
# endif
@@ -2646,7 +2659,10 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Constraints", "Constraints affecting the transformation of the object");
RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Object_constraints_override_apply");
- /* RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove"); */
+# if 0
+ RNA_def_property_collection_funcs(
+ prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "constraints__add", "constraints__remove");
+# endif
rna_def_object_constraints(brna, prop);
/* vertex groups */
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 7862671b867..21300f22b95 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -106,12 +106,7 @@ static void rna_Object_select_set(
return;
}
- if (select) {
- BKE_view_layer_base_select(base);
- }
- else {
- base->flag &= ~BASE_SELECTED;
- }
+ ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
Scene *scene = CTX_data_scene(C);
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
@@ -439,8 +434,8 @@ static void rna_Object_shape_key_remove(Object *ob,
}
# if 0
-static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int *indices, int totindex,
- float weight, int assignmode)
+static void rna_Mesh_assign_verts_to_group(
+ Object *ob, bDeformGroup *group, int *indices, int totindex, float weight, int assignmode)
{
if (ob->type != OB_MESH) {
BKE_report(reports, RPT_ERROR, "Object should be of mesh type");
@@ -534,7 +529,8 @@ static void rna_Object_ray_cast(Object *ob,
distmin <= distance)) {
BVHTreeFromMesh treeData = {NULL};
- /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
+ /* No need to managing allocation or freeing of the BVH data.
+ * This is generated and freed as needed. */
BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4);
/* may fail if the mesh has no faces, in that case the ray-cast misses */
@@ -591,7 +587,8 @@ static void rna_Object_closest_point_on_mesh(Object *ob,
return;
}
- /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */
+ /* No need to managing allocation or freeing of the BVH data.
+ * this is generated and freed as needed. */
BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4);
if (treeData.tree == NULL) {
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 157d011eb72..c4f0eb35627 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -524,6 +524,8 @@ static void rna_FieldSettings_type_set(PointerRNA *ptr, int value)
static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
+ DEG_relations_tag_update(bmain);
+
if (particle_id_check(ptr)) {
DEG_id_tag_update((ID *)ptr->id.data,
ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION |
@@ -532,19 +534,8 @@ static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, Point
else {
Object *ob = (Object *)ptr->id.data;
- /* do this before scene sort, that one checks for CU_PATH */
-# if 0 /* XXX */
- if (ob->type == OB_CURVE && ob->pd->forcefield == PFIELD_GUIDE) {
- Curve *cu = ob->data;
- cu->flag |= (CU_PATH | CU_3D);
- do_curvebuts(B_CU3D); /* all curves too */
- }
-# endif
-
rna_FieldSettings_shape_update(bmain, scene, ptr);
- DEG_relations_tag_update(bmain);
-
if (ob->type == OB_CURVE && ob->pd->forcefield == PFIELD_GUIDE)
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
else
@@ -903,8 +894,9 @@ static void rna_def_pointcache_active(BlenderRNA *brna)
/* This first-level RNA pointer also has list of all caches from owning ID.
* Those caches items have exact same content as 'active' one, except for that collection,
* to prevent ugly recursive layout pattern.
- * Note: This shall probably be redone from scratch in a proper way at some point, but for now that will do,
- * and shall not break anything in the API. */
+ *
+ * Note: This shall probably be redone from scratch in a proper way at some point,
+ * but for now that will do, and shall not break anything in the API. */
prop = RNA_def_property(srna, "point_caches", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop,
"rna_Cache_list_begin",
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index cb74055ae83..8c3d16f9c8c 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -281,7 +281,10 @@ static void rna_Particle_uv_on_emitter(ParticleData *particle,
ParticleSystemModifierData *modifier,
float r_uv[2])
{
- /*psys_particle_on_emitter(psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, nor, 0, 0, sd.orco, 0);*/
+# if 0
+ psys_particle_on_emitter(
+ psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, nor, 0, 0, sd.orco, 0);
+# endif
/* get uvco & mcol */
int num = particle->num_dmcache;
@@ -2279,7 +2282,8 @@ static void rna_def_particle_settings(BlenderRNA *brna)
"rna_Particle_reset",
NULL);
- /* fluid particle type can't be checked from the type value in rna as it's not shown in the menu */
+ /* Fluid particle type can't be checked from the type value in RNA
+ * as it's not shown in the menu. */
prop = RNA_def_property(srna, "is_fluid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_PartSettings_is_fluid_get", NULL);
@@ -2790,7 +2794,8 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Particle_reset");
prop = RNA_def_property(srna, "effector_amount", PROP_INT, PROP_UNSIGNED);
- /* in theory PROP_ANIMATABLE perhaps should be cleared, but animating this can give some interesting results! */
+ /* In theory PROP_ANIMATABLE perhaps should be cleared,
+ * but animating this can give some interesting results! */
RNA_def_property_range(prop, 0, 10000); /* 10000 effectors will bel SLOW, but who knows */
RNA_def_property_ui_range(prop, 0, 100, 1, -1);
RNA_def_property_ui_text(
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 4b764529562..1b4a7efbdd8 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -461,8 +461,10 @@ static void rna_pose_bgroup_name_index_get(PointerRNA *ptr, char *value, int ind
grp = BLI_findlink(&pose->agroups, index - 1);
- if (grp) BLI_strncpy(value, grp->name, sizeof(grp->name));
- else value[0] = '\0';
+ if (grp)
+ BLI_strncpy(value, grp->name, sizeof(grp->name));
+ else
+ value[0] = '\0';
}
static int rna_pose_bgroup_name_index_length(PointerRNA *ptr, int index)
@@ -612,7 +614,8 @@ bool rna_PoseChannel_constraints_override_apply(Main *UNUSED(bmain),
/* This handles NULL anchor as expected by adding at head of list. */
BLI_insertlinkafter(&pchan_dst->constraints, con_anchor, con_dst);
- /* This should actually *not* be needed in typical cases. However, if overridden source was edited,
+ /* This should actually *not* be needed in typical cases.
+ * However, if overridden source was edited,
* we *may* have some new conflicting names. */
BKE_constraint_unique_name(con_dst, &pchan_dst->constraints);
@@ -741,7 +744,8 @@ static bPoseChannel *rna_PoseChannel_ensure_own_pchan(Object *ob,
bPoseChannel *ref_pchan)
{
if (ref_ob != ob) {
- /* We are trying to set a pchan from another object! Forbidden, try to find by name, or abort. */
+ /* We are trying to set a pchan from another object! Forbidden,
+ * try to find by name, or abort. */
if (ref_pchan != NULL) {
ref_pchan = BKE_pose_channel_find_name(ob->pose, ref_pchan->name);
}
@@ -976,7 +980,8 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "rotmode");
RNA_def_property_enum_items(prop, rna_enum_object_rotation_mode_items);
RNA_def_property_enum_funcs(prop, NULL, "rna_PoseChannel_rotation_mode_set", NULL);
- /* XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too */
+ /* XXX... disabled, since proxy-locked layers are currently
+ * used for ensuring proxy-syncing too */
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_ui_text(prop, "Rotation Mode", "");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index 242bc63c09f..799705df2b4 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -146,14 +146,6 @@ static const EnumPropertyItem rigidbody_mesh_source_items[] = {
# include "WM_api.h"
-# define RB_FLAG_SET(dest, value, flag) \
- { \
- if (value) \
- dest |= flag; \
- else \
- dest &= ~flag; \
- }
-
/* ******************************** */
static void rna_RigidBodyWorld_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -185,7 +177,7 @@ static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, bool value)
{
RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
- RB_FLAG_SET(rbw->flag, value, RBW_FLAG_USE_SPLIT_IMPULSE);
+ SET_FLAG_FROM_TEST(rbw->flag, value, RBW_FLAG_USE_SPLIT_IMPULSE);
# ifdef WITH_BULLET
if (rbw->shared->physics_world) {
@@ -266,7 +258,7 @@ static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, bool value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
- RB_FLAG_SET(rbo->flag, !value, RBO_FLAG_DISABLED);
+ SET_FLAG_FROM_TEST(rbo->flag, !value, RBO_FLAG_DISABLED);
# ifdef WITH_BULLET
/* update kinematic state if necessary - only needed for active bodies */
@@ -348,7 +340,7 @@ static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, bool value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
- RB_FLAG_SET(rbo->flag, value, RBO_FLAG_KINEMATIC);
+ SET_FLAG_FROM_TEST(rbo->flag, value, RBO_FLAG_KINEMATIC);
# ifdef WITH_BULLET
/* update kinematic state if necessary */
@@ -364,7 +356,7 @@ static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, bool value)
{
RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
- RB_FLAG_SET(rbo->flag, value, RBO_FLAG_USE_DEACTIVATION);
+ SET_FLAG_FROM_TEST(rbo->flag, value, RBO_FLAG_USE_DEACTIVATION);
# ifdef WITH_BULLET
/* update activation state if necessary - only active bodies can be deactivated */
@@ -456,7 +448,7 @@ static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
- RB_FLAG_SET(rbc->flag, value, RBC_FLAG_ENABLED);
+ SET_FLAG_FROM_TEST(rbc->flag, value, RBC_FLAG_ENABLED);
# ifdef WITH_BULLET
if (rbc->physics_constraint) {
@@ -469,7 +461,7 @@ static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
- RB_FLAG_SET(rbc->flag, value, RBC_FLAG_DISABLE_COLLISIONS);
+ SET_FLAG_FROM_TEST(rbc->flag, value, RBC_FLAG_DISABLE_COLLISIONS);
rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
}
@@ -728,7 +720,7 @@ static void rna_RigidBodyCon_use_motor_lin_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
- RB_FLAG_SET(rbc->flag, value, RBC_FLAG_USE_MOTOR_LIN);
+ SET_FLAG_FROM_TEST(rbc->flag, value, RBC_FLAG_USE_MOTOR_LIN);
# ifdef WITH_BULLET
if (rbc->physics_constraint) {
@@ -743,7 +735,7 @@ static void rna_RigidBodyCon_use_motor_ang_set(PointerRNA *ptr, bool value)
{
RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
- RB_FLAG_SET(rbc->flag, value, RBC_FLAG_USE_MOTOR_ANG);
+ SET_FLAG_FROM_TEST(rbc->flag, value, RBC_FLAG_USE_MOTOR_ANG);
# ifdef WITH_BULLET
if (rbc->physics_constraint) {
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index aa5ea62657b..032a1f86fc0 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -1165,7 +1165,8 @@ static bool rna_property_override_diff_propptr_validate_diffing(PointerRNA *prop
/* We do a generic quick first comparison checking for "name" and/or "type" properties.
* We assume that is any of those are false, then we are not handling the same data.
- * This helps a lot in static override case, especially to detect inserted items in collections. */
+ * This helps a lot in static override case, especially to detect inserted items in collections.
+ */
if (!no_prop_name && (is_valid_for_diffing || do_force_name)) {
PropertyRNA *nameprop_a = RNA_struct_name_property(propptr_a->type);
PropertyRNA *nameprop_b = (propptr_b != NULL) ? RNA_struct_name_property(propptr_b->type) :
@@ -1238,7 +1239,8 @@ static int rna_property_override_diff_propptr(Main *bmain,
bool is_id = false;
bool is_null = false;
bool is_type_diff = false;
- /* If false, it means that the whole data itself is different, so no point in going inside of it at all! */
+ /* If false, it means that the whole data itself is different,
+ * so no point in going inside of it at all! */
bool is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(propptr_a,
propptr_b,
no_prop_name,
@@ -1253,8 +1255,8 @@ static int rna_property_override_diff_propptr(Main *bmain,
0);
if (is_id) {
- BLI_assert(
- no_ownership); /* For now, once we deal with nodetrees we'll want to get rid of that one. */
+ /* For now, once we deal with nodetrees we'll want to get rid of that one. */
+ BLI_assert(no_ownership);
}
if (override) {
@@ -1319,7 +1321,8 @@ int rna_property_override_diff_default(Main *bmain,
{
BLI_assert(len_a == len_b);
- /* Note: at this point, we are sure that when len_a is zero, we are not handling an (empty) array. */
+ /* Note: at this point, we are sure that when len_a is zero,
+ * we are not handling an (empty) array. */
const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 &&
rna_path != NULL;
@@ -1543,9 +1546,14 @@ int rna_property_override_diff_default(Main *bmain,
ptr_a, prop_a, fixed_a, sizeof(fixed_a), &len_str_a);
char *value_b = RNA_property_string_get_alloc(
ptr_b, prop_b, fixed_b, sizeof(fixed_b), &len_str_b);
- /* TODO we could do a check on length too, but then we would not have a 'real' string comparison...
+ /* TODO we could do a check on length too,
+ * but then we would not have a 'real' string comparison...
* Maybe behind a eRNAOverrideMatch flag? */
- // const int comp = len_str_a < len_str_b ? -1 : len_str_a > len_str_b ? 1 : strcmp(value_a, value_b);
+# if 0
+ const int comp = len_str_a < len_str_b ?
+ -1 :
+ len_str_a > len_str_b ? 1 : strcmp(value_a, value_b);
+# endif
const int comp = strcmp(value_a, value_b);
if (do_create && comp != 0) {
@@ -1643,7 +1651,8 @@ int rna_property_override_diff_default(Main *bmain,
is_valid_for_insertion = use_insertion;
- /* If false, it means that the whole data itself is different, so no point in going inside of it at all! */
+ /* If false, it means that the whole data itself is different,
+ * so no point in going inside of it at all! */
if (iter_b.valid) {
is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(
&iter_a.ptr,
@@ -1685,11 +1694,19 @@ int rna_property_override_diff_default(Main *bmain,
# if 0
if (rna_path) {
- printf("Checking %s, %s [%d] vs %s [%d]; is_id: %d, diffing: %d; "
- "insert: %d (could be used: %d, do_create: %d)\n",
- rna_path, propname_a ? propname_a : "", idx_a, propname_b ? propname_b : "", idx_b,
- is_id, is_valid_for_diffing, is_valid_for_insertion,
- (RNA_property_override_flag(prop_a) & PROPOVERRIDE_STATIC_INSERTION) != 0, do_create);
+ printf(
+ "Checking %s, %s [%d] vs %s [%d]; is_id: %d, diffing: %d; "
+ "insert: %d (could be used: %d, do_create: %d)\n",
+ rna_path,
+ propname_a ? propname_a : "",
+ idx_a,
+ propname_b ? propname_b : "",
+ idx_b,
+ is_id,
+ is_valid_for_diffing,
+ is_valid_for_insertion,
+ (RNA_property_override_flag(prop_a) & PROPOVERRIDE_STATIC_INSERTION) != 0,
+ do_create);
}
# endif
@@ -1717,7 +1734,8 @@ int rna_property_override_diff_default(Main *bmain,
}
else { /* Based on index... */
if (rna_path) {
- /* In case of indices, we need _a one for insertion, but _b ones for in-depth diffing.
+ /* In case of indices, we need _a one for insertion,
+ * but _b ones for in-depth diffing.
* Insertion always happen once all 'replace' operations have been done,
* otherwise local and reference paths for those would have to be different! */
RNA_PATH_PRINTF("%s[%d]", rna_path, is_valid_for_insertion ? idx_a : idx_b);
@@ -1725,8 +1743,8 @@ int rna_property_override_diff_default(Main *bmain,
}
}
- /* Collections do not support replacement of their data (since they do not support removing),
- * only in *some* cases, insertion.
+ /* Collections do not support replacement of their data
+ * (since they do not support removing), only in *some* cases, insertion.
* We also assume then that _a data is the one where things are inserted. */
if (is_valid_for_insertion && use_insertion) {
bool created;
@@ -1734,8 +1752,8 @@ int rna_property_override_diff_default(Main *bmain,
override, rna_path, &created);
if (is_first_insert) {
- /* We need to clean up all possible existing insertion operations, otherwise we'd end up
- * with a mess of ops everytime something changes. */
+ /* We need to clean up all possible existing insertion operations,
+ * otherwise we'd end up with a mess of ops everytime something changes. */
for (IDOverrideStaticPropertyOperation *opop = op->operations.first; opop != NULL;) {
IDOverrideStaticPropertyOperation *opop_next = opop->next;
if (ELEM(opop->operation,
@@ -1757,7 +1775,12 @@ int rna_property_override_diff_default(Main *bmain,
true,
NULL,
NULL);
- // printf("%s: Adding insertion op override after '%s'/%d\n", rna_path, prev_propname_a, idx_a - 1);
+# if 0
+ printf("%s: Adding insertion op override after '%s'/%d\n",
+ rna_path,
+ prev_propname_a,
+ idx_a - 1);
+# endif
}
else if (is_id || is_valid_for_diffing) {
if (equals || do_create) {
@@ -1870,8 +1893,8 @@ bool rna_property_override_store_default(Main *UNUSED(bmain),
/* XXX TODO About range limits.
* Ideally, it would be great to get rid of RNA range in that specific case.
- * However, this won't be that easy and will add yet another layer of complexity in generated code,
- * not to mention that we could most likely *not* bypass custom setters anyway.
+ * However, this won't be that easy and will add yet another layer of complexity in
+ * generated code, not to mention that we could most likely *not* bypass custom setters anyway.
* So for now, if needed second operand value is not in valid range, we simply fall back
* to a mere REPLACE operation.
* Time will say whether this is acceptable limitation or not. */
@@ -2802,47 +2825,58 @@ static void rna_def_number_property(StructRNA *srna, PropertyType type)
RNA_def_property_boolean_funcs(prop, "rna_NumberProperty_is_array_get", NULL);
RNA_def_property_ui_text(prop, "Is Array", "");
- if (type == PROP_BOOLEAN)
+ if (type == PROP_BOOLEAN) {
return;
+ }
prop = RNA_def_property(srna, "hard_min", type, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- if (type == PROP_INT)
+ if (type == PROP_INT) {
RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_min_get", NULL, NULL);
- else
+ }
+ else {
RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_min_get", NULL, NULL);
+ }
RNA_def_property_ui_text(prop, "Hard Minimum", "Minimum value used by buttons");
prop = RNA_def_property(srna, "hard_max", type, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- if (type == PROP_INT)
+ if (type == PROP_INT) {
RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_max_get", NULL, NULL);
- else
+ }
+ else {
RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_max_get", NULL, NULL);
+ }
RNA_def_property_ui_text(prop, "Hard Maximum", "Maximum value used by buttons");
prop = RNA_def_property(srna, "soft_min", type, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- if (type == PROP_INT)
+ if (type == PROP_INT) {
RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_min_get", NULL, NULL);
- else
+ }
+ else {
RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_min_get", NULL, NULL);
+ }
RNA_def_property_ui_text(prop, "Soft Minimum", "Minimum value used by buttons");
prop = RNA_def_property(srna, "soft_max", type, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- if (type == PROP_INT)
+ if (type == PROP_INT) {
RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_max_get", NULL, NULL);
- else
+ }
+ else {
RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_max_get", NULL, NULL);
+ }
RNA_def_property_ui_text(prop, "Soft Maximum", "Maximum value used by buttons");
prop = RNA_def_property(srna, "step", type, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- if (type == PROP_INT)
+ if (type == PROP_INT) {
RNA_def_property_int_funcs(prop, "rna_IntProperty_step_get", NULL, NULL);
- else
+ }
+ else {
RNA_def_property_float_funcs(prop, "rna_FloatProperty_step_get", NULL, NULL);
+ }
RNA_def_property_ui_text(
prop, "Step", "Step size used by number buttons, for floats 1/100th of the step size");
@@ -2973,11 +3007,13 @@ static void rna_def_pointer_property(StructRNA *srna, PropertyType type)
prop = RNA_def_property(srna, "fixed_type", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Struct");
- if (type == PROP_POINTER)
+ if (type == PROP_POINTER) {
RNA_def_property_pointer_funcs(prop, "rna_PointerProperty_fixed_type_get", NULL, NULL, NULL);
- else
+ }
+ else {
RNA_def_property_pointer_funcs(
prop, "rna_CollectionProperty_fixed_type_get", NULL, NULL, NULL);
+ }
RNA_def_property_ui_text(prop, "Pointer Type", "Fixed pointer type, empty if variable type");
}
@@ -3045,11 +3081,17 @@ void RNA_def_rna(BlenderRNA *brna)
prop = RNA_def_property(srna, "structs", PROP_COLLECTION, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Struct");
- RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next",
- "rna_iterator_listbase_end", "rna_iterator_listbase_get",
+ RNA_def_property_collection_funcs(prop,
+ "rna_BlenderRNA_structs_begin",
+ "rna_iterator_listbase_next",
+ "rna_iterator_listbase_end",
+ "rna_iterator_listbase_get",
/* included for speed, can be removed */
# if 0
- NULL, NULL, NULL, NULL);
+ NULL,
+ NULL,
+ NULL,
+ NULL);
# else
"rna_BlenderRNA_structs_length",
"rna_BlenderRNA_structs_lookup_int",
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index c80abb239a3..6f6699fa81b 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -106,13 +106,6 @@ static const EnumPropertyItem uv_sculpt_relaxation_items[] = {
};
#endif
-const EnumPropertyItem rna_enum_uv_sculpt_tool_items[] = {
- {UV_SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", "Pinch UVs"},
- {UV_SCULPT_TOOL_RELAX, "RELAX", 0, "Relax", "Relax UVs"},
- {UV_SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", "Grab UVs"},
- {0, NULL, 0, NULL, NULL},
-};
-
const EnumPropertyItem rna_enum_snap_target_items[] = {
{SCE_SNAP_TARGET_CLOSEST, "CLOSEST", 0, "Closest", "Snap closest point onto target"},
{SCE_SNAP_TARGET_CENTER, "CENTER", 0, "Center", "Snap transformation center onto target"},
@@ -148,22 +141,6 @@ const EnumPropertyItem rna_enum_proportional_falloff_curve_only_items[] = {
{0, NULL, 0, NULL, NULL},
};
-const EnumPropertyItem rna_enum_proportional_editing_items[] = {
- {PROP_EDIT_OFF, "DISABLED", ICON_PROP_OFF, "Disable", "Proportional Editing disabled"},
- {PROP_EDIT_ON, "ENABLED", ICON_PROP_ON, "Enable", "Proportional Editing enabled"},
- {PROP_EDIT_PROJECTED,
- "PROJECTED",
- ICON_PROP_PROJECTED,
- "Projected (2D)",
- "Proportional Editing using screen space locations"},
- {PROP_EDIT_CONNECTED,
- "CONNECTED",
- ICON_PROP_CON,
- "Connected",
- "Proportional Editing using connected geometry only"},
- {0, NULL, 0, NULL, NULL},
-};
-
/* keep for operators, not used here */
const EnumPropertyItem rna_enum_mesh_select_mode_items[] = {
{SCE_SELECT_VERTEX, "VERTEX", ICON_VERTEXSEL, "Vertex", "Vertex selection mode"},
@@ -713,8 +690,8 @@ static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value)
{
GP_Interpolate_Settings *settings = (GP_Interpolate_Settings *)ptr->data;
- /* NOTE: This cast should be fine, as we have a small + finite set of values (eGP_Interpolate_Type)
- * that should fit well within a char
+ /* NOTE: This cast should be fine, as we have a small + finite set of values
+ * (#eGP_Interpolate_Type) that should fit well within a char.
*/
settings->type = (char)value;
@@ -724,13 +701,6 @@ static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value)
}
}
-static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain,
- Scene *scene,
- PointerRNA *UNUSED(ptr))
-{
- ED_space_image_uv_sculpt_update(bmain, bmain->wm.first, scene);
-}
-
/* Read-only Iterator of all the scene objects. */
static void rna_Scene_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -1009,7 +979,8 @@ static void rna_Scene_all_keyingsets_next(CollectionPropertyIterator *iter)
ListBaseIterator *internal = &iter->internal.listbase;
KeyingSet *ks = (KeyingSet *)internal->link;
- /* if we've run out of links in Scene list, jump over to the builtins list unless we're there already */
+ /* If we've run out of links in Scene list,
+ * jump over to the builtins list unless we're there already. */
if ((ks->next == NULL) && (ks != builtin_keyingsets.last))
internal->link = (Link *)builtin_keyingsets.first;
else
@@ -1143,14 +1114,16 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value)
const int depth_ok = BKE_imtype_valid_depths(imf->imtype);
if ((imf->depth & depth_ok) == 0) {
/* set first available depth */
- char depth_ls[] = {R_IMF_CHAN_DEPTH_32,
- R_IMF_CHAN_DEPTH_24,
- R_IMF_CHAN_DEPTH_16,
- R_IMF_CHAN_DEPTH_12,
- R_IMF_CHAN_DEPTH_10,
- R_IMF_CHAN_DEPTH_8,
- R_IMF_CHAN_DEPTH_1,
- 0};
+ char depth_ls[] = {
+ R_IMF_CHAN_DEPTH_32,
+ R_IMF_CHAN_DEPTH_24,
+ R_IMF_CHAN_DEPTH_16,
+ R_IMF_CHAN_DEPTH_12,
+ R_IMF_CHAN_DEPTH_10,
+ R_IMF_CHAN_DEPTH_8,
+ R_IMF_CHAN_DEPTH_1,
+ 0,
+ };
int i;
for (i = 0; depth_ls[i]; i++) {
@@ -1837,6 +1810,11 @@ static void rna_View3DCursor_rotation_axis_angle_set(PointerRNA *ptr, const floa
copy_v3_v3(cursor->rotation_axis, &value[1]);
}
+static char *rna_View3DCursor_path(PointerRNA *UNUSED(ptr))
+{
+ return BLI_strdup("cursor");
+}
+
static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[], int frame)
{
TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
@@ -1980,22 +1958,21 @@ static void rna_Scene_update_active_object_data(bContext *C, PointerRNA *UNUSED(
}
}
-static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_SceneCamera_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->id.data;
Object *camera = scene->camera;
+ BKE_sequencer_cache_cleanup_all(bmain);
+
if (camera && (camera->type == OB_CAMERA)) {
DEG_id_tag_update(&camera->id, ID_RECALC_GEOMETRY);
}
}
-static void rna_SceneSequencer_update(Main *UNUSED(bmain),
- Scene *UNUSED(scene),
- PointerRNA *UNUSED(ptr))
+static void rna_SceneSequencer_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
+ BKE_sequencer_cache_cleanup(scene);
}
static char *rna_ToolSettings_path(PointerRNA *UNUSED(ptr))
@@ -2149,11 +2126,10 @@ static void rna_GPUDOFSettings_blades_set(PointerRNA *ptr, const int value)
}
}
-static void rna_GPUDOFSettings_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
+static void rna_GPUDOFSettings_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
{
/* TODO(sergey): Can be more selective here. */
- BKE_sequencer_cache_cleanup();
- BKE_sequencer_preprocessed_cache_cleanup();
+ BKE_sequencer_cache_cleanup_all(bmain);
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
}
@@ -2528,6 +2504,7 @@ static void rna_def_view3d_cursor(BlenderRNA *brna)
srna = RNA_def_struct(brna, "View3DCursor", NULL);
RNA_def_struct_sdna(srna, "View3DCursor");
+ RNA_def_struct_path_func(srna, "rna_View3DCursor_path");
RNA_def_struct_ui_text(srna, "3D Cursor", "");
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ_LENGTH);
@@ -2686,11 +2663,8 @@ static void rna_def_tool_settings(BlenderRNA *brna)
ICON_PIVOT_CURSOR,
"3D Cursor",
"Draw stroke at 3D cursor location"},
- {0,
- "VIEW",
- ICON_RESTRICT_VIEW_ON,
- "View",
- "Stick stroke to the view "}, /* weird, GP_PROJECT_VIEWALIGN is inverted */
+ /* Weird, GP_PROJECT_VIEWALIGN is inverted. */
+ {0, "VIEW", ICON_RESTRICT_VIEW_ON, "View", "Stick stroke to the view "},
{GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_VIEW,
"SURFACE",
ICON_FACESEL,
@@ -2763,13 +2737,6 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "particle");
RNA_def_property_ui_text(prop, "Particle Edit", "");
- prop = RNA_def_property(srna, "use_uv_sculpt", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "use_uv_sculpt", 1);
- RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for UV sculpting");
- RNA_def_property_ui_icon(prop, ICON_TPAINT_HLT, 0);
- RNA_def_property_update(
- prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_uv_sculpt_update");
-
prop = RNA_def_property(srna, "uv_sculpt_lock_borders", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uv_sculpt_settings", UV_SCULPT_LOCK_BORDERS);
RNA_def_property_ui_text(prop, "Lock Borders", "Disable editing of boundary edges");
@@ -2778,11 +2745,6 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "uv_sculpt_settings", UV_SCULPT_ALL_ISLANDS);
RNA_def_property_ui_text(prop, "Sculpt All Islands", "Brush operates on all islands");
- prop = RNA_def_property(srna, "uv_sculpt_tool", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "uv_sculpt_tool");
- RNA_def_property_enum_items(prop, rna_enum_uv_sculpt_tool_items);
- RNA_def_property_ui_text(prop, "UV Sculpt Tools", "Select Tools for the UV sculpt brushes");
-
prop = RNA_def_property(srna, "uv_relax_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "uv_relax_method");
RNA_def_property_enum_items(prop, uv_sculpt_relaxation_items);
@@ -2794,19 +2756,29 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
/* Transform */
- prop = RNA_def_property(srna, "proportional_edit", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "proportional");
- RNA_def_property_enum_items(prop, rna_enum_proportional_editing_items);
- RNA_def_property_ui_text(prop,
- "Proportional Editing",
- "Proportional Editing mode, allows transforms with distance fall-off");
+ prop = RNA_def_property(srna, "use_proportional_edit", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "proportional_edit", PROP_EDIT_USE);
+ RNA_def_property_ui_text(prop, "Proportional Editing", "Proportional edit mode");
+ RNA_def_property_ui_icon(prop, ICON_PROP_ON, 0);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
prop = RNA_def_property(srna, "use_proportional_edit_objects", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "proportional_objects", 0);
RNA_def_property_ui_text(
prop, "Proportional Editing Objects", "Proportional editing object mode");
- RNA_def_property_ui_icon(prop, ICON_PROP_OFF, 1);
+ RNA_def_property_ui_icon(prop, ICON_PROP_ON, 0);
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
+
+ prop = RNA_def_property(srna, "use_proportional_projected", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "proportional_edit", PROP_EDIT_PROJECTED);
+ RNA_def_property_ui_text(
+ prop, "Projected from View", "Proportional Editing using screen space locations");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
+
+ prop = RNA_def_property(srna, "use_proportional_connected", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "proportional_edit", PROP_EDIT_CONNECTED);
+ RNA_def_property_ui_text(
+ prop, "Connected Only", "Proportional Editing using connected geometry only");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
prop = RNA_def_property(srna, "use_proportional_edit_mask", PROP_BOOLEAN, PROP_NONE);
@@ -3606,16 +3578,20 @@ void rna_def_view_layer_common(StructRNA *srna, const bool scene)
PropertyRNA *prop;
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- if (scene)
+ if (scene) {
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ViewLayer_name_set");
- else
+ }
+ else {
RNA_def_property_string_sdna(prop, NULL, "name");
+ }
RNA_def_property_ui_text(prop, "Name", "View layer name");
RNA_def_struct_name_property(srna, prop);
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
if (scene) {
prop = RNA_def_property(srna, "material_override", PROP_POINTER, PROP_NONE);
@@ -3647,10 +3623,12 @@ void rna_def_view_layer_common(StructRNA *srna, const bool scene)
prop = RNA_def_property(srna, "use_zmask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_ZMASK);
RNA_def_property_ui_text(prop, "Zmask", "Only render what's in front of the solid z values");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "invert_zmask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_NEG_ZMASK);
@@ -3658,270 +3636,336 @@ void rna_def_view_layer_common(StructRNA *srna, const bool scene)
prop,
"Zmask Negate",
"For Zmask, only render what is behind solid z values instead of in front");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_all_z", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_ALL_Z);
RNA_def_property_ui_text(
prop, "All Z", "Fill in Z values for solid faces in invisible layers, for masking");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_solid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_SOLID);
RNA_def_property_ui_text(prop, "Solid", "Render Solid faces in this Layer");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_halo", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_HALO);
RNA_def_property_ui_text(prop, "Halo", "Render Halos in this Layer (on top of Solid)");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_ztransp", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_ZTRA);
RNA_def_property_ui_text(
prop, "ZTransp", "Render Z-Transparent faces in this Layer (on top of Solid and Halos)");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_sky", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_SKY);
RNA_def_property_ui_text(prop, "Sky", "Render Sky in this Layer");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_ao", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_AO);
RNA_def_property_ui_text(prop, "Ambient Occlusion", "Render Ambient Occlusion in this Layer");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_edge_enhance", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_EDGE);
RNA_def_property_ui_text(
prop, "Edge", "Render Edge-enhance in this Layer (only works for Solid faces)");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_strand", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_STRAND);
RNA_def_property_ui_text(prop, "Strand", "Render Strands in this Layer");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
/* passes */
prop = RNA_def_property(srna, "use_pass_combined", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_COMBINED);
RNA_def_property_ui_text(prop, "Combined", "Deliver full combined RGBA buffer");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_z", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_Z);
RNA_def_property_ui_text(prop, "Z", "Deliver Z values pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_vector", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_VECTOR);
RNA_def_property_ui_text(prop, "Vector", "Deliver speed vector pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_normal", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_NORMAL);
RNA_def_property_ui_text(prop, "Normal", "Deliver normal pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_uv", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_UV);
RNA_def_property_ui_text(prop, "UV", "Deliver texture UV pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_mist", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_MIST);
RNA_def_property_ui_text(prop, "Mist", "Deliver mist factor pass (0.0-1.0)");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_object_index", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_INDEXOB);
RNA_def_property_ui_text(prop, "Object Index", "Deliver object index pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_material_index", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_INDEXMA);
RNA_def_property_ui_text(prop, "Material Index", "Deliver material index pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_shadow", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SHADOW);
RNA_def_property_ui_text(prop, "Shadow", "Deliver shadow pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_ambient_occlusion", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_AO);
RNA_def_property_ui_text(prop, "Ambient Occlusion", "Deliver Ambient Occlusion pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_emit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_EMIT);
RNA_def_property_ui_text(prop, "Emit", "Deliver emission pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_environment", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_ENVIRONMENT);
RNA_def_property_ui_text(prop, "Environment", "Deliver environment lighting pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_diffuse_direct", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_DIRECT);
RNA_def_property_ui_text(prop, "Diffuse Direct", "Deliver diffuse direct pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_diffuse_indirect", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_INDIRECT);
RNA_def_property_ui_text(prop, "Diffuse Indirect", "Deliver diffuse indirect pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_diffuse_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_COLOR);
RNA_def_property_ui_text(prop, "Diffuse Color", "Deliver diffuse color pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_glossy_direct", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_DIRECT);
RNA_def_property_ui_text(prop, "Glossy Direct", "Deliver glossy direct pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_glossy_indirect", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_INDIRECT);
RNA_def_property_ui_text(prop, "Glossy Indirect", "Deliver glossy indirect pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_glossy_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_COLOR);
RNA_def_property_ui_text(prop, "Glossy Color", "Deliver glossy color pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_transmission_direct", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_DIRECT);
RNA_def_property_ui_text(prop, "Transmission Direct", "Deliver transmission direct pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_transmission_indirect", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_INDIRECT);
RNA_def_property_ui_text(prop, "Transmission Indirect", "Deliver transmission indirect pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_transmission_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_COLOR);
RNA_def_property_ui_text(prop, "Transmission Color", "Deliver transmission color pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_subsurface_direct", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBSURFACE_DIRECT);
RNA_def_property_ui_text(prop, "Subsurface Direct", "Deliver subsurface direct pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_subsurface_indirect", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBSURFACE_INDIRECT);
RNA_def_property_ui_text(prop, "Subsurface Indirect", "Deliver subsurface indirect pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
prop = RNA_def_property(srna, "use_pass_subsurface_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SUBSURFACE_COLOR);
RNA_def_property_ui_text(prop, "Subsurface Color", "Deliver subsurface color pass");
- if (scene)
+ if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_pass_update");
- else
+ }
+ else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ }
}
static void rna_def_freestyle_modules(BlenderRNA *brna, PropertyRNA *cprop)
@@ -5530,7 +5574,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_range(prop, 1, SHRT_MAX);
RNA_def_property_ui_range(prop, 1, 100, 10, 1);
RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution");
- RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+ RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneSequencer_update");
prop = RNA_def_property(srna, "tile_x", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "tilex");
@@ -6080,20 +6124,16 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "seq_rend_type");
RNA_def_property_enum_items(prop, rna_enum_shading_type_items);
/* XXX Label and tooltips are obviously wrong! */
- RNA_def_property_ui_text(prop, "Sequencer Preview Shading", "Method to draw in the sequencer view");
-# endif
-
- prop = RNA_def_property(srna, "use_sequencer_gl_textured_solid", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_SOLID_TEX);
RNA_def_property_ui_text(
- prop, "Textured Solid", "Display face-assigned textures in solid draw method");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update");
+ prop, "Sequencer Preview Shading", "Method to draw in the sequencer view");
+# endif
- prop = RNA_def_property(srna, "use_sequencer_gl_dof", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_CAMERA_DOF);
+ prop = RNA_def_property(srna, "use_sequencer_override_scene_strip", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_OVERRIDE_SCENE_SETTINGS);
RNA_def_property_ui_text(prop,
- "Depth of Field",
- "Use depth of field using the values from scene strip active camera");
+ "Override Scene Settings",
+ "Use workbench render settings from the sequencer scene, instead of "
+ "each individual scene used in the strip");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update");
prop = RNA_def_property(srna, "use_single_layer", PROP_BOOLEAN, PROP_NONE);
@@ -7314,7 +7354,8 @@ void RNA_def_scene(BlenderRNA *brna)
# if 0 /* XXX: Is this actually needed? */
prop = RNA_def_property(srna, "use_frame_drop", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_FRAME_DROP);
- RNA_def_property_ui_text(prop, "Frame Dropping", "Play back dropping frames if frame display is too slow");
+ RNA_def_property_ui_text(
+ prop, "Frame Dropping", "Play back dropping frames if frame display is too slow");
RNA_def_property_update(prop, NC_SCENE, NULL);
# endif
@@ -7455,8 +7496,10 @@ void RNA_def_scene(BlenderRNA *brna)
# if 0 /* XXX: Is this actually needed? */
prop = RNA_def_property(srna, "use_audio_sync", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_SYNC);
- RNA_def_property_ui_text(prop, "Audio Sync",
- "Play back and sync with audio clock, dropping frames if frame display is too slow");
+ RNA_def_property_ui_text(
+ prop,
+ "Audio Sync",
+ "Play back and sync with audio clock, dropping frames if frame display is too slow");
RNA_def_property_update(prop, NC_SCENE, NULL);
# endif
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 5913376606b..3de946c1c8f 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -43,6 +43,7 @@ const EnumPropertyItem rna_enum_region_type_items[] = {
{RGN_TYPE_NAV_BAR, "NAVIGATION_BAR", 0, "Navigation Bar", ""},
{RGN_TYPE_EXECUTE, "EXECUTE", 0, "Execute Buttons", ""},
{RGN_TYPE_FOOTER, "FOOTER", 0, "Footer", ""},
+ {RGN_TYPE_TOOL_HEADER, "TOOL_HEADER", 0, "Tool Header", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -148,11 +149,16 @@ static void rna_Area_type_set(PointerRNA *ptr, int value)
static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
{
- wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *win;
bScreen *sc = (bScreen *)ptr->id.data;
ScrArea *sa = (ScrArea *)ptr->data;
+ /* Running update without having called 'set', see: T64049 */
+ if (sa->butspacetype == SPACE_EMPTY) {
+ return;
+ }
+
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win;
/* XXX this call still use context, so we trick it to work in the right context */
for (win = wm->windows.first; win; win = win->next) {
if (sc == WM_window_get_active_screen(win)) {
@@ -550,11 +556,6 @@ static void rna_def_screen(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL);
RNA_def_property_ui_text(prop, "Maximize", "An area is maximized, filling this screen");
- prop = RNA_def_property(srna, "show_topbar", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SCREEN_COLLAPSE_TOPBAR);
- RNA_def_property_ui_text(prop, "Show Top Bar", "Show top bar with tool settings");
- RNA_def_property_update(prop, 0, "rna_Screen_bar_update");
-
prop = RNA_def_property(srna, "show_statusbar", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SCREEN_COLLAPSE_STATUSBAR);
RNA_def_property_ui_text(prop, "Show Status Bar", "Show status bar");
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 19dc16e1c9c..2791c49b3d9 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -365,6 +365,12 @@ static bool rna_Brush_mode_with_tool_poll(PointerRNA *ptr, PointerRNA value)
}
mode = OB_MODE_SCULPT;
}
+ else if (paint_contains_brush_slot(&ts->uvsculpt->paint, tslot, &slot_index)) {
+ if (slot_index != brush->uv_sculpt_tool) {
+ return false;
+ }
+ mode = OB_MODE_EDIT;
+ }
else if (paint_contains_brush_slot(&ts->vpaint->paint, tslot, &slot_index)) {
if (slot_index != brush->vertexpaint_tool) {
return false;
@@ -504,7 +510,8 @@ static void rna_ImaPaint_mode_update(bContext *C, PointerRNA *UNUSED(ptr))
/* of course we need to invalidate here */
BKE_texpaint_slots_refresh_object(scene, ob);
- /* we assume that changing the current mode will invalidate the uv layers so we need to refresh display */
+ /* We assume that changing the current mode will invalidate the uv layers
+ * so we need to refresh display. */
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
}
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index a00d4c99455..0b1e35e3a74 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -175,7 +175,8 @@ static int rna_SequenceEditor_elements_length(PointerRNA *ptr)
/* Hack? copied from sequencer.c::reload_sequence_new_file() */
size_t olen = MEM_allocN_len(seq->strip->stripdata) / sizeof(struct StripElem);
- /* the problem with seq->strip->len and seq->len is that it's discounted from the offset (hard cut trim) */
+ /* The problem with seq->strip->len and seq->len is that it's discounted from the offset
+ * (hard cut trim). */
return (int)olen;
}
@@ -508,8 +509,10 @@ static void rna_Sequence_name_set(PointerRNA *ptr, const char *value)
/* fix all the animation data which may link to this */
- /* don't rename everywhere because these are per scene */
- /* BKE_animdata_fix_paths_rename_all(NULL, "sequence_editor.sequences_all", oldname, seq->name + 2); */
+ /* Don't rename everywhere because these are per scene. */
+# if 0
+ BKE_animdata_fix_paths_rename_all(NULL, "sequence_editor.sequences_all", oldname, seq->name + 2);
+# endif
adt = BKE_animdata_from_id(&scene->id);
if (adt)
BKE_animdata_fix_paths_rename(
@@ -729,7 +732,10 @@ static int rna_Sequence_input_count_get(PointerRNA *ptr)
static void rna_SoundSequence_filename_set(PointerRNA *ptr, const char *value)
{
Sequence *seq = (Sequence *)(ptr->data);
- BLI_split_dirfile(value, seq->strip->dir, seq->strip->stripdata->name, sizeof(seq->strip->dir),
+ BLI_split_dirfile(value,
+ seq->strip->dir,
+ seq->strip->stripdata->name,
+ sizeof(seq->strip->dir),
sizeof(seq->strip->stripdata->name));
}
@@ -1720,6 +1726,31 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting this strip");
rna_def_sequence_modifiers(brna, prop);
+ prop = RNA_def_property(srna, "use_cache_raw", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_RAW);
+ RNA_def_property_ui_text(prop,
+ "Cache Raw",
+ "Cache raw images read from disk, for faster tweaking of strip "
+ "parameters at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_PREPROCESSED);
+ RNA_def_property_ui_text(
+ prop,
+ "Cache Rreprocessed",
+ "Cache preprocessed images, for faster tweaking of effects at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_composite", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_COMPOSITE);
+ RNA_def_property_ui_text(prop,
+ "Cache Composite",
+ "Cache intermediate composited images, for faster tweaking of stacked "
+ "strips at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "override_cache_settings", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_OVERRIDE);
+ RNA_def_property_ui_text(prop, "Override Cache Settings", "Override global cache settings");
+
RNA_api_sequence_strip(srna);
}
@@ -1803,6 +1834,65 @@ static void rna_def_editor(BlenderRNA *brna)
RNA_def_property_string_sdna(prop, NULL, "proxy_dir");
RNA_def_property_ui_text(prop, "Proxy Directory", "");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, "rna_SequenceEditor_update_cache");
+
+ /* cache flags */
+
+ prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_ENABLE);
+ RNA_def_property_ui_text(prop, "Show Cache", "Visualize cached images on the timeline");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "show_cache_final_out", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_FINAL_OUT);
+ RNA_def_property_ui_text(prop, "Final Images", "Visualize cached complete frames");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "show_cache_raw", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_RAW);
+ RNA_def_property_ui_text(prop, "Raw Images", "Visualize cached raw images");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "show_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_PREPROCESSED);
+ RNA_def_property_ui_text(prop, "Preprocessed Images", "Visualize cached preprocessed images");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "show_cache_composite", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_VIEW_COMPOSITE);
+ RNA_def_property_ui_text(prop, "Composite Images", "Visualize cached composite images");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "use_cache_raw", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_RAW);
+ RNA_def_property_ui_text(prop,
+ "Cache Raw",
+ "Cache raw images read from disk, for faster tweaking of strip "
+ "parameters at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_preprocessed", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_PREPROCESSED);
+ RNA_def_property_ui_text(
+ prop,
+ "Cache Preprocessed",
+ "Cache preprocessed images, for faster tweaking of effects at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_composite", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_COMPOSITE);
+ RNA_def_property_ui_text(prop,
+ "Cache Composite",
+ "Cache intermediate composited images, for faster tweaking of stacked "
+ "strips at the cost of memory usage");
+
+ prop = RNA_def_property(srna, "use_cache_final", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", SEQ_CACHE_STORE_FINAL_OUT);
+ RNA_def_property_ui_text(prop, "Cache Final", "Cache final image for each frame");
+
+ prop = RNA_def_property(srna, "recycle_max_cost", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0f, SEQ_CACHE_COST_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, SEQ_CACHE_COST_MAX, 0.1f, 1);
+ RNA_def_property_float_sdna(prop, NULL, "recycle_max_cost");
+ RNA_def_property_ui_text(
+ prop, "Recycle Up To Cost", "Only frames with cost lower than this value will be recycled");
}
static void rna_def_filter_video(StructRNA *srna)
@@ -1954,8 +2044,8 @@ static void rna_def_effect_inputs(StructRNA *srna, int count)
}
# if 0
- if (count == 3) { // not used by any effects (perhaps one day plugins?)
- prop = RNA_def_property(srna, "input_3", PROP_POINTER, PROP_NONE);
+ if (count == 3) { // not used by any effects (perhaps one day plugins?)
+ prop = RNA_def_property(srna, "input_3", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "seq3");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
RNA_def_property_ui_text(prop, "Input 3", "Third input for the effect strip");
@@ -2698,8 +2788,9 @@ static void rna_def_effects(BlenderRNA *brna)
rna_def_effect_inputs(srna, effect->inputs);
- if (effect->func)
+ if (effect->func) {
effect->func(srna);
+ }
}
}
diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c
index 6c610a92093..06c968534cc 100644
--- a/source/blender/makesrna/intern/rna_shader_fx.c
+++ b/source/blender/makesrna/intern/rna_shader_fx.c
@@ -532,7 +532,8 @@ static void rna_def_shader_fx_glow(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Threshold", "Limit to select color for glow effect");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update");
- /* use blur fields to make compatible with blur filter, but only makes public first array element */
+ /* Use blur fields to make compatible with blur filter,
+ * but only makes public first array element. */
prop = RNA_def_property(srna, "radius", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "blur[0]");
RNA_def_property_range(prop, 0, INT_MAX);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index ebfe23942d9..633164238e0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -84,7 +84,13 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
/* Animation */
{0, "", ICON_NONE, "Animation", ""},
- //{SPACE_ACTION, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls (NOTE: Switch to 'Timeline' mode)"}, /* XXX */
+#if 0
+ {SPACE_ACTION,
+ "TIMELINE",
+ ICON_TIME,
+ "Timeline",
+ "Timeline and playback controls (NOTE: Switch to 'Timeline' mode)"}, /* XXX */
+#endif
{SPACE_ACTION, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", "Adjust timing of keyframes"},
{SPACE_GRAPH,
"GRAPH_EDITOR",
@@ -106,12 +112,7 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
"Python Console",
"Interactive programmatic console for "
"advanced editing and script development"},
- {SPACE_INFO,
- "INFO",
- ICON_INFO,
- "Info",
- "Main menu bar and list of error messages "
- "(drag down to expand and display)"},
+ {SPACE_INFO, "INFO", ICON_INFO, "Info", "Log of operations, warnings and error messages"},
/* Special case: Top-bar and Status-bar aren't supposed to be a regular editor for the user. */
{SPACE_TOPBAR,
"TOPBAR",
@@ -191,7 +192,8 @@ const EnumPropertyItem rna_enum_space_graph_mode_items[] = {
}
#ifndef RNA_RUNTIME
-/* XXX: action-editor is currently for object-level only actions, so show that using object-icon hint */
+/* XXX: action-editor is currently for object-level only actions,
+ * so show that using object-icon hint */
static EnumPropertyItem rna_enum_space_action_mode_all_items[] = {
SACT_ITEM_DOPESHEET,
SACT_ITEM_TIMELINE,
@@ -355,6 +357,7 @@ static const EnumPropertyItem rna_enum_shading_color_type_items[] = {
{V3D_SHADING_MATERIAL_COLOR, "MATERIAL", 0, "Material", "Show material color"},
{V3D_SHADING_OBJECT_COLOR, "OBJECT", 0, "Object", "Show object color"},
{V3D_SHADING_RANDOM_COLOR, "RANDOM", 0, "Random", "Show random object color"},
+ {V3D_SHADING_VERTEX_COLOR, "VERTEX", 0, "Vertex", "Show active vertex color"},
{V3D_SHADING_TEXTURE_COLOR, "TEXTURE", 0, "Texture", "Show texture"},
{0, NULL, 0, NULL, NULL},
};
@@ -370,7 +373,8 @@ const EnumPropertyItem rna_enum_clip_editor_mode_items[] = {
{0, NULL, 0, NULL, NULL},
};
-/* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */
+/* Actually populated dynamically trough a function,
+ * but helps for context-less access (e.g. doc, i18n...). */
static const EnumPropertyItem buttons_context_items[] = {
{BCONTEXT_TOOL, "TOOL", ICON_TOOL_SETTINGS, "Tool", "Active Tool and Workspace settings"},
{BCONTEXT_SCENE, "SCENE", ICON_SCENE_DATA, "Scene", "Scene"},
@@ -550,6 +554,160 @@ static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **r_sa, ARe
area_region_from_regiondata(sc, regiondata, r_sa, r_ar);
}
+/* -------------------------------------------------------------------- */
+/** \name Generic Region Flag Access
+ * \{ */
+
+static bool rna_Space_bool_from_region_flag_get_by_type(PointerRNA *ptr,
+ const int region_type,
+ const int region_flag)
+{
+ ScrArea *sa = rna_area_from_space(ptr);
+ ARegion *ar = BKE_area_find_region_type(sa, region_type);
+ if (ar) {
+ return (ar->flag & region_flag);
+ }
+ return false;
+}
+
+static void rna_Space_bool_from_region_flag_set_by_type(PointerRNA *ptr,
+ const int region_type,
+ const int region_flag,
+ bool value)
+{
+ ScrArea *sa = rna_area_from_space(ptr);
+ ARegion *ar = BKE_area_find_region_type(sa, region_type);
+ if (ar) {
+ SET_FLAG_FROM_TEST(ar->flag, value, region_flag);
+ }
+ ED_region_tag_redraw(ar);
+}
+
+static void rna_Space_bool_from_region_flag_update_by_type(bContext *C,
+ PointerRNA *ptr,
+ const int region_type,
+ const int region_flag)
+{
+ ScrArea *sa = rna_area_from_space(ptr);
+ ARegion *ar = BKE_area_find_region_type(sa, region_type);
+ if (ar) {
+ if (region_flag == RGN_FLAG_HIDDEN) {
+ /* Only support animation when the area is in the current context. */
+ if (ar->overlap && (sa == CTX_wm_area(C))) {
+ ED_region_visibility_change_update_animated(C, sa, ar);
+ }
+ else {
+ ED_region_visibility_change_update(C, sa, ar);
+ }
+ }
+ else if (region_flag == RGN_FLAG_HIDDEN_BY_USER) {
+ if (!(ar->flag & RGN_FLAG_HIDDEN_BY_USER) != !(ar->flag & RGN_FLAG_HIDDEN)) {
+ ED_region_toggle_hidden(C, ar);
+
+ if ((ar->flag & RGN_FLAG_HIDDEN_BY_USER) == 0) {
+ ED_area_type_hud_ensure(C, sa);
+ }
+ }
+ }
+ }
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Region Flag Access (Typed Callbacks)
+ * \{ */
+
+/* Header Region. */
+static bool rna_Space_show_region_header_get(PointerRNA *ptr)
+{
+ return !rna_Space_bool_from_region_flag_get_by_type(ptr, RGN_TYPE_HEADER, RGN_FLAG_HIDDEN);
+}
+static void rna_Space_show_region_header_set(PointerRNA *ptr, bool value)
+{
+ rna_Space_bool_from_region_flag_set_by_type(ptr, RGN_TYPE_HEADER, RGN_FLAG_HIDDEN, !value);
+
+ /* Special case, never show the tool properties when the header is invisible. */
+ bool value_for_tool_header = value;
+ if (value == true) {
+ ScrArea *sa = rna_area_from_space(ptr);
+ ARegion *ar_tool_header = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_HEADER);
+ if (ar_tool_header != NULL) {
+ value = !(ar_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER);
+ }
+ }
+ rna_Space_bool_from_region_flag_set_by_type(
+ ptr, RGN_TYPE_TOOL_HEADER, RGN_FLAG_HIDDEN, !value_for_tool_header);
+}
+static void rna_Space_show_region_header_update(bContext *C, PointerRNA *ptr)
+{
+ rna_Space_bool_from_region_flag_update_by_type(C, ptr, RGN_TYPE_HEADER, RGN_FLAG_HIDDEN);
+}
+
+/* Tool Header Region.
+ *
+ * This depends on the 'RGN_TYPE_TOOL_HEADER'
+ */
+static bool rna_Space_show_region_tool_header_get(PointerRNA *ptr)
+{
+ return !rna_Space_bool_from_region_flag_get_by_type(
+ ptr, RGN_TYPE_TOOL_HEADER, RGN_FLAG_HIDDEN_BY_USER);
+}
+static void rna_Space_show_region_tool_header_set(PointerRNA *ptr, bool value)
+{
+ rna_Space_bool_from_region_flag_set_by_type(
+ ptr, RGN_TYPE_TOOL_HEADER, RGN_FLAG_HIDDEN_BY_USER, !value);
+ rna_Space_bool_from_region_flag_set_by_type(ptr, RGN_TYPE_TOOL_HEADER, RGN_FLAG_HIDDEN, !value);
+}
+static void rna_Space_show_region_tool_header_update(bContext *C, PointerRNA *ptr)
+{
+ rna_Space_bool_from_region_flag_update_by_type(C, ptr, RGN_TYPE_TOOL_HEADER, RGN_FLAG_HIDDEN);
+}
+
+/* Tools Region. */
+static bool rna_Space_show_region_toolbar_get(PointerRNA *ptr)
+{
+ return !rna_Space_bool_from_region_flag_get_by_type(ptr, RGN_TYPE_TOOLS, RGN_FLAG_HIDDEN);
+}
+static void rna_Space_show_region_toolbar_set(PointerRNA *ptr, bool value)
+{
+ rna_Space_bool_from_region_flag_set_by_type(ptr, RGN_TYPE_TOOLS, RGN_FLAG_HIDDEN, !value);
+}
+static void rna_Space_show_region_toolbar_update(bContext *C, PointerRNA *ptr)
+{
+ rna_Space_bool_from_region_flag_update_by_type(C, ptr, RGN_TYPE_TOOLS, RGN_FLAG_HIDDEN);
+}
+
+/* UI Region */
+static bool rna_Space_show_region_ui_get(PointerRNA *ptr)
+{
+ return !rna_Space_bool_from_region_flag_get_by_type(ptr, RGN_TYPE_UI, RGN_FLAG_HIDDEN);
+}
+static void rna_Space_show_region_ui_set(PointerRNA *ptr, bool value)
+{
+ rna_Space_bool_from_region_flag_set_by_type(ptr, RGN_TYPE_UI, RGN_FLAG_HIDDEN, !value);
+}
+static void rna_Space_show_region_ui_update(bContext *C, PointerRNA *ptr)
+{
+ rna_Space_bool_from_region_flag_update_by_type(C, ptr, RGN_TYPE_UI, RGN_FLAG_HIDDEN);
+}
+
+/* Redo (HUD) Region */
+static bool rna_Space_show_region_hud_get(PointerRNA *ptr)
+{
+ return !rna_Space_bool_from_region_flag_get_by_type(ptr, RGN_TYPE_HUD, RGN_FLAG_HIDDEN_BY_USER);
+}
+static void rna_Space_show_region_hud_set(PointerRNA *ptr, bool value)
+{
+ rna_Space_bool_from_region_flag_set_by_type(ptr, RGN_TYPE_HUD, RGN_FLAG_HIDDEN_BY_USER, !value);
+}
+static void rna_Space_show_region_hud_update(bContext *C, PointerRNA *ptr)
+{
+ rna_Space_bool_from_region_flag_update_by_type(C, ptr, RGN_TYPE_HUD, RGN_FLAG_HIDDEN_BY_USER);
+}
+
+/** \} */
+
static bool rna_Space_view2d_sync_get(PointerRNA *ptr)
{
ScrArea *sa;
@@ -747,6 +905,12 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value
ED_view3d_from_m4(mat, rv3d->ofs, rv3d->viewquat, &rv3d->dist);
}
+static bool rna_RegionView3D_is_orthographic_side_view_get(PointerRNA *ptr)
+{
+ RegionView3D *rv3d = (RegionView3D *)(ptr->data);
+ return RV3D_VIEW_IS_AXIS(rv3d->view);
+}
+
static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
ID *id = ptr->id.data;
@@ -754,17 +918,6 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA
return;
}
- for (Material *ma = bmain->materials.first; ma; ma = ma->id.next) {
- /* XXX Dependency graph does not support CD mask tracking,
- * so we trigger materials shading for until it's properly supported.
- * This is to ensure material batches are all recreated when switching
- * shading type. In the future DEG should replace this and just tag
- * the meshes itself.
- * This hack just tag BKE_MESH_BATCH_DIRTY_SHADING for every mesh that
- * have a material. (see T55059) */
- DEG_id_tag_update(&ma->id, ID_RECALC_SHADING);
- }
-
View3DShading *shading = ptr->data;
if (shading->type == OB_MATERIAL ||
(shading->type == OB_RENDER &&
@@ -923,6 +1076,8 @@ static const EnumPropertyItem *rna_View3DShading_color_type_itemf(bContext *UNUS
&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_OBJECT_COLOR);
RNA_enum_items_add_value(
&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_RANDOM_COLOR);
+ RNA_enum_items_add_value(
+ &item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_VERTEX_COLOR);
if (shading->light != V3D_LIGHTING_MATCAP) {
RNA_enum_items_add_value(
&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_TEXTURE_COLOR);
@@ -1061,7 +1216,8 @@ static const EnumPropertyItem *rna_SpaceView3D_stereo3d_camera_itemf(bContext *C
static int rna_SpaceView3D_icon_from_show_object_viewport_get(PointerRNA *ptr)
{
const View3D *v3d = (View3D *)ptr->data;
- /* Ignore selection values when view is off, intent is to show if visible objects aren't selectable. */
+ /* Ignore selection values when view is off,
+ * intent is to show if visible objects aren't selectable. */
const int view_value = (v3d->object_type_exclude_viewport != 0);
const int select_value = (v3d->object_type_exclude_select &
~v3d->object_type_exclude_viewport) != 0;
@@ -1649,7 +1805,8 @@ static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr)
* EXCEPTION:
* This callback runs when unlinking actions. In that case, we don't want to
* stash the action, as the user is signalling that they want to detach it.
- * This can be reviewed again later, but it could get annoying if we keep these instead.
+ * This can be reviewed again later,
+ * but it could get annoying if we keep these instead.
*/
if ((adt->action->id.us <= 0) && (saction->action != NULL)) {
/* XXX: Things here get dodgy if this action is only partially completed,
@@ -1725,14 +1882,15 @@ static void rna_SpaceDopeSheetEditor_mode_update(bContext *C, PointerRNA *ptr)
else {
channels_region->flag &= ~RGN_FLAG_HIDDEN;
}
- ED_region_visibility_change_update(C, channels_region);
+ ED_region_visibility_change_update(C, sa, channels_region);
}
}
/* recalculate extents of channel list */
saction->runtime.flag |= SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC;
- /* store current mode as "old mode", so that returning from other editors doesn't always reset to "Action Editor" */
+ /* store current mode as "old mode",
+ * so that returning from other editors doesn't always reset to "Action Editor" */
if (saction->mode != SACTCONT_TIMELINE) {
saction->mode_prev = saction->mode;
}
@@ -2278,6 +2436,45 @@ static const EnumPropertyItem dt_uv_items[] = {
{0, NULL, 0, NULL, NULL},
};
+static void rna_def_space_generic_show_region_toggles(StructRNA *srna, int region_type_mask)
+{
+ PropertyRNA *prop;
+
+# define DEF_SHOW_REGION_PROPERTY(identifier, label, description) \
+ { \
+ prop = RNA_def_property(srna, STRINGIFY(identifier), PROP_BOOLEAN, PROP_NONE); \
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); \
+ RNA_def_property_boolean_funcs(prop, \
+ STRINGIFY(rna_Space_##identifier##_get), \
+ STRINGIFY(rna_Space_##identifier##_set)); \
+ RNA_def_property_ui_text(prop, label, description); \
+ RNA_def_property_update(prop, 0, STRINGIFY(rna_Space_##identifier##_update)); \
+ } \
+ ((void)0)
+
+ if (region_type_mask & (1 << RGN_TYPE_TOOL_HEADER)) {
+ region_type_mask &= ~(1 << RGN_TYPE_TOOL_HEADER);
+ DEF_SHOW_REGION_PROPERTY(show_region_tool_header, "Tool Header", "");
+ }
+ if (region_type_mask & (1 << RGN_TYPE_HEADER)) {
+ region_type_mask &= ~(1 << RGN_TYPE_HEADER);
+ DEF_SHOW_REGION_PROPERTY(show_region_header, "Header", "");
+ }
+ if (region_type_mask & (1 << RGN_TYPE_TOOLS)) {
+ region_type_mask &= ~(1 << RGN_TYPE_TOOLS);
+ DEF_SHOW_REGION_PROPERTY(show_region_toolbar, "Toolbar", "");
+ }
+ if (region_type_mask & (1 << RGN_TYPE_UI)) {
+ region_type_mask &= ~(1 << RGN_TYPE_UI);
+ DEF_SHOW_REGION_PROPERTY(show_region_ui, "Sidebar", "");
+ }
+ if (region_type_mask & (1 << RGN_TYPE_HUD)) {
+ region_type_mask &= ~(1 << RGN_TYPE_HUD);
+ DEF_SHOW_REGION_PROPERTY(show_region_hud, "Adjust Last Operation", "");
+ }
+ BLI_assert(region_type_mask == 0);
+}
+
static void rna_def_space(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2291,7 +2488,8 @@ static void rna_def_space(BlenderRNA *brna)
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "spacetype");
RNA_def_property_enum_items(prop, rna_enum_space_type_items);
- /* When making this editable, take care for the special case of global areas (see rna_Area_type_set). */
+ /* When making this editable, take care for the special case of global areas
+ * (see rna_Area_type_set). */
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Type", "Space data type");
@@ -2300,6 +2498,8 @@ static void rna_def_space(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_Space_view2d_sync_get", "rna_Space_view2d_sync_set");
RNA_def_property_ui_text(prop, "Lock Time to Other Windows", "");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Space_view2d_sync_update");
+
+ rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_HEADER));
}
/* for all spaces that use a mask */
@@ -2799,6 +2999,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rna_enum_shading_color_type_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_View3DShading_color_type_itemf");
RNA_def_property_ui_text(prop, "Color", "Color Type");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "wireframe_color_type", PROP_ENUM, PROP_NONE);
@@ -2931,6 +3132,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Overlays", "Display overlays like gizmos and outlines");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "show_ortho_grid", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_ORTHO_GRID);
+ RNA_def_property_ui_text(prop, "Display Grid", "Show grid in othographic side view");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_FLOOR);
RNA_def_property_ui_text(
@@ -3273,6 +3479,13 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "sculpt_mode_mask_opacity", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "overlay.sculpt_mode_mask_opacity");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop, "Sculpt Mask Opacity", "");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
/* grease pencil paper settings */
prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_ANNOTATION);
@@ -3376,6 +3589,10 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "View3D");
RNA_def_struct_ui_text(srna, "3D View Space", "3D View space data");
+ rna_def_space_generic_show_region_toggles(srna,
+ ((1 << RGN_TYPE_TOOL_HEADER) | (1 << RGN_TYPE_TOOLS) |
+ (1 << RGN_TYPE_UI) | (1 << RGN_TYPE_HUD)));
+
prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_pointer_sdna(prop, NULL, "camera");
@@ -3777,6 +3994,11 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Is Perspective", "");
RNA_def_property_flag(prop, PROP_EDITABLE);
+ prop = RNA_def_property(srna, "is_orthographic_side_view", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "view", 0);
+ RNA_def_property_boolean_funcs(prop, "rna_RegionView3D_is_orthographic_side_view_get", NULL);
+ RNA_def_property_ui_text(prop, "Is Axis Aligned", "Is current view an orthographic side view");
+
/* This isn't directly accessible from the UI, only an operator. */
prop = RNA_def_property(srna, "use_clip_planes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "rflag", RV3D_CLIPPING);
@@ -3875,6 +4097,10 @@ static void rna_def_space_image(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SpaceImage");
RNA_def_struct_ui_text(srna, "Space Image Editor", "Image and UV editor space data");
+ rna_def_space_generic_show_region_toggles(srna,
+ ((1 << RGN_TYPE_TOOL_HEADER) | (1 << RGN_TYPE_TOOLS) |
+ (1 << RGN_TYPE_UI) | (1 << RGN_TYPE_HUD)));
+
/* image */
prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceImageEditor_image_set", NULL, NULL);
@@ -4103,6 +4329,8 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SpaceSeq");
RNA_def_struct_ui_text(srna, "Space Sequence Editor", "Sequence editor space data");
+ rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI));
+
/* view type, fairly important */
prop = RNA_def_property(srna, "view_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "view");
@@ -4245,6 +4473,8 @@ static void rna_def_space_text(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SpaceText");
RNA_def_struct_ui_text(srna, "Space Text Editor", "Text editor space data");
+ rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI));
+
/* text */
prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -4367,6 +4597,8 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SpaceAction");
RNA_def_struct_ui_text(srna, "Space Dope Sheet Editor", "Dope Sheet space data");
+ rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI));
+
/* data */
prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -4545,6 +4777,8 @@ static void rna_def_space_graph(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SpaceGraph");
RNA_def_struct_ui_text(srna, "Space Graph Editor", "Graph Editor space data");
+ rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI));
+
/* mode */
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mode");
@@ -4696,6 +4930,8 @@ static void rna_def_space_nla(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SpaceNla");
RNA_def_struct_ui_text(srna, "Space Nla Editor", "NLA editor space data");
+ rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_UI));
+
/* display */
prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SNLA_DRAWTIME);
@@ -5487,6 +5723,8 @@ static void rna_def_space_node(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SpaceNode");
RNA_def_struct_ui_text(srna, "Space Node Editor", "Node editor space data");
+ rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_TOOLS) | (1 << RGN_TYPE_UI));
+
prop = RNA_def_property(srna, "tree_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, dummy_items);
RNA_def_property_enum_funcs(prop,
@@ -5663,6 +5901,9 @@ static void rna_def_space_clip(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "SpaceClip");
RNA_def_struct_ui_text(srna, "Space Clip Editor", "Clip editor space data");
+ rna_def_space_generic_show_region_toggles(
+ srna, (1 << RGN_TYPE_TOOLS) | (1 << RGN_TYPE_UI) | (1 << RGN_TYPE_HUD));
+
/* movieclip */
prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c
index 5b75937ce72..589f7818b68 100644
--- a/source/blender/makesrna/intern/rna_text.c
+++ b/source/blender/makesrna/intern/rna_text.c
@@ -172,9 +172,7 @@ static void rna_def_text(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_module", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_ISSCRIPT);
RNA_def_property_ui_text(
- prop,
- "Register",
- "Register this text as a module on loading, Text name must end with \".py\"");
+ prop, "Register", "Run this text as a script on loading, Text name must end with \".py\"");
prop = RNA_def_property(srna, "use_tabs_as_spaces", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_TABSTOSPACES);
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index 17e01899e26..1271eef02af 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -1148,7 +1148,8 @@ static void rna_def_texture_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Interpolation", "Interpolate pixels using selected filter");
RNA_def_property_update(prop, 0, "rna_Texture_update");
- /* XXX: I think flip_axis should be a generic Texture property, enabled for all the texture types */
+ /* XXX: I think flip_axis should be a generic Texture property,
+ * enabled for all the texture types. */
prop = RNA_def_property(srna, "use_flip_axis", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_IMAROT);
RNA_def_property_ui_text(prop, "Flip Axis", "Flip the texture's X and Y axis");
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 1941f1bc1b2..faa16f4f146 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -496,8 +496,8 @@ static void uilist_filter_items(uiList *ui_list,
memcpy(flt_data->items_filter_flags, filter_flags, sizeof(int) * len);
if (filter_neworder) {
- /* For sake of simplicity, py filtering is expected to filter all items, but we actually only want
- * reordering data for shown items!
+ /* For sake of simplicity, py filtering is expected to filter all items,
+ * but we actually only want reordering data for shown items!
*/
int items_shown, shown_idx;
int t_idx, t_ni, prev_ni;
@@ -1171,7 +1171,8 @@ static void rna_def_ui_layout(BlenderRNA *brna)
# if 0
prop = RNA_def_property(srna, "keep_aspect", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_UILayout_keep_aspect_get", "rna_UILayout_keep_aspect_set");
+ RNA_def_property_boolean_funcs(
+ prop, "rna_UILayout_keep_aspect_get", "rna_UILayout_keep_aspect_set");
# endif
prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_UNSIGNED);
@@ -1404,8 +1405,8 @@ static void rna_def_uilist(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "filter_flag", UILST_FLT_EXCLUDE);
RNA_def_property_ui_text(prop, "Invert", "Invert filtering (show hidden items, and vice-versa)");
- /* WARNING: This is sort of an abuse, sort-by-alpha is actually a value, should even be an enum in full logic
- * (of two values, sort by index and sort by name).
+ /* WARNING: This is sort of an abuse, sort-by-alpha is actually a value,
+ * should even be an enum in full logic (of two values, sort by index and sort by name).
* But for default UIList, it's nicer (better UI-wise) to show this as a boolean bit-flag option,
* avoids having to define custom setters/getters using UILST_FLT_SORT_MASK to mask out
* actual bitflags on same var, etc.
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index d8e13fda114..7ce9155e3d9 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -65,11 +65,12 @@ const char *rna_translate_ui_text(
/* Else, if an RNA type or property is specified, use its context. */
# if 0
- /* XXX Disabled for now. Unfortunately, their is absolutely no way from py code to get the RNA struct corresponding
- * to the 'data' (in functions like prop() & co), as this is pure runtime data. Hence, messages extraction
- * script can't determine the correct context it should use for such 'text' messages...
- * So for now, one have to explicitly specify the 'text_ctxt' when using prop() etc. functions,
- * if default context is not suitable.
+ /* XXX Disabled for now. Unfortunately, their is absolutely no way from py code to get the RNA
+ * struct corresponding to the 'data' (in functions like prop() & co),
+ * as this is pure runtime data. Hence, messages extraction script can't determine the
+ * correct context it should use for such 'text' messages...
+ * So for now, one have to explicitly specify the 'text_ctxt' when using prop() etc.
+ * functions, if default context is not suitable.
*/
if (prop) {
return BLT_pgettext(RNA_property_translation_context(prop), text);
@@ -878,30 +879,46 @@ void RNA_api_ui_layout(StructRNA *srna)
api_ui_item_op_common(func);
parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_boolean(func, "value", false, "", "Value of the property to call the operator with");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); */
+ parm = RNA_def_boolean(
+ func, "value", false, "", "Value of the property to call the operator with");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
func = RNA_def_function(srna, "operator_int", "uiItemIntO");
api_ui_item_op_common(func);
parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "",
- "Value of the property to call the operator with", INT_MIN, INT_MAX);
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); */
+ parm = RNA_def_int(func,
+ "value",
+ 0,
+ INT_MIN,
+ INT_MAX,
+ "",
+ "Value of the property to call the operator with",
+ INT_MIN,
+ INT_MAX);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
func = RNA_def_function(srna, "operator_float", "uiItemFloatO");
api_ui_item_op_common(func);
parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "",
- "Value of the property to call the operator with", -FLT_MAX, FLT_MAX);
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); */
+ parm = RNA_def_float(func,
+ "value",
+ 0,
+ -FLT_MAX,
+ FLT_MAX,
+ "",
+ "Value of the property to call the operator with",
+ -FLT_MAX,
+ FLT_MAX);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
func = RNA_def_function(srna, "operator_string", "uiItemStringO");
api_ui_item_op_common(func);
parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- parm = RNA_def_string(func, "value", NULL, 0, "", "Value of the property to call the operator with");
+ parm = RNA_def_string(
+ func, "value", NULL, 0, "", "Value of the property to call the operator with");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
# endif
@@ -1457,7 +1474,13 @@ void RNA_api_ui_layout(StructRNA *srna)
func, "Item. A widget to control color managed view settings settings.");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
api_ui_item_rna_common(func);
- /* RNA_def_boolean(func, "show_global_settings", false, "", "Show widgets to control global color management settings"); */
+# if 0
+ RNA_def_boolean(func,
+ "show_global_settings",
+ false,
+ "",
+ "Show widgets to control global color management settings");
+# endif
/* node socket icon */
func = RNA_def_function(srna, "template_node_socket", "uiTemplateNodeSocket");
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 5a017e96fa7..eade12be631 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -1581,7 +1581,7 @@ static void rna_def_userdef_theme_spaces_vertex(StructRNA *srna)
RNA_def_property_ui_text(prop, "Vertex Select", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
- prop = RNA_def_property(srna, "vertex_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "vertex_size", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 32);
RNA_def_property_ui_text(prop, "Vertex Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
@@ -1656,7 +1656,7 @@ static void rna_def_userdef_theme_spaces_face(StructRNA *srna)
RNA_def_property_ui_text(prop, "Face Dot Selected", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
- prop = RNA_def_property(srna, "facedot_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "facedot_size", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 10);
RNA_def_property_ui_text(prop, "Face Dot Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
@@ -1803,7 +1803,7 @@ static void rna_def_userdef_theme_spaces_curves(
RNA_def_property_ui_text(prop, "Handle Vertex Select", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
- prop = RNA_def_property(srna, "handle_vertex_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "handle_vertex_size", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 100);
RNA_def_property_ui_text(prop, "Handle Vertex Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
@@ -1824,7 +1824,7 @@ static void rna_def_userdef_theme_spaces_gpencil(StructRNA *srna)
RNA_def_property_ui_text(prop, "Grease Pencil Vertex Select", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
- prop = RNA_def_property(srna, "gp_vertex_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "gp_vertex_size", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 10);
RNA_def_property_ui_text(prop, "Grease Pencil Vertex Size", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
@@ -2027,10 +2027,17 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
rna_def_userdef_theme_spaces_paint_curves(srna);
- prop = RNA_def_property(srna, "outline_width", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "outline_width", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 1, 5);
RNA_def_property_ui_text(prop, "Outline Width", "");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
+
+ prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL);
+ RNA_def_property_int_sdna(prop, NULL, "obcenter_dia");
+ RNA_def_property_range(prop, 4, 10);
+ RNA_def_property_ui_text(
+ prop, "Object Origin Size", "Diameter in Pixels for Object/Light origin display");
+ RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
}
static void rna_def_userdef_theme_space_graph(BlenderRNA *brna)
@@ -2949,10 +2956,8 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna)
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(
prop, "Keyframe Scale Factor", "Scale factor for adjusting the height of keyframes");
- RNA_def_property_range(
- prop,
- 0.8f,
- 5.0f); /* Note: These limits prevent buttons overlapping (min), and excessive size... (max) */
+ /* Note: These limits prevent buttons overlapping (min), and excessive size... (max) */
+ RNA_def_property_range(prop, 0.8f, 5.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, "rna_userdef_theme_update");
prop = RNA_def_property(srna, "summary", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -4066,7 +4071,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
"Show a small rotating 3D axes in the top right corner of the 3D View");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "mini_axis_size", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "mini_axis_size", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "rvisize");
RNA_def_property_range(prop, 10, 64);
RNA_def_property_ui_text(prop, "Mini Axes Size", "The axes icon's size");
@@ -4103,13 +4108,6 @@ static void rna_def_userdef_view(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Gizmo Size", "Diameter of the gizmo");
RNA_def_property_update(prop, 0, "rna_userdef_update");
- prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL);
- RNA_def_property_int_sdna(prop, NULL, "obcenter_dia");
- RNA_def_property_range(prop, 4, 10);
- RNA_def_property_ui_text(
- prop, "Object Origin Size", "Diameter in Pixels for Object/Light origin display");
- RNA_def_property_update(prop, 0, "rna_userdef_update");
-
/* View2D Grid Displays */
prop = RNA_def_property(srna, "view2d_grid_spacing_min", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "v2d_min_gridsize");
@@ -4474,7 +4472,18 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Duplicate Particle", "Causes particle systems to be duplicated with the object");
- /* currently only used for insert offset (aka auto-offset), maybe also be useful for later stuff though */
+ prop = RNA_def_property(srna, "use_duplicate_lightprobe", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_LIGHTPROBE);
+ RNA_def_property_ui_text(
+ prop, "Duplicate Light Probe", "Causes light probe data to be duplicated with the object");
+
+ prop = RNA_def_property(srna, "use_duplicate_grease_pencil", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "dupflag", USER_DUP_GPENCIL);
+ RNA_def_property_ui_text(
+ prop, "Duplicate GPencil", "Causes grease pencil data to be duplicated with the object");
+
+ /* Currently only used for insert offset (aka auto-offset),
+ * maybe also be useful for later stuff though. */
prop = RNA_def_property(srna, "node_margin", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "node_margin");
RNA_def_property_ui_text(
@@ -4534,21 +4543,21 @@ static void rna_def_userdef_system(BlenderRNA *brna)
};
static const EnumPropertyItem audio_rate_items[] = {
- /* {8000, "RATE_8000", 0, "8 kHz", "Set audio sampling rate to 8000 samples per second"}, */
- /* {11025, "RATE_11025", 0, "11.025 kHz", "Set audio sampling rate to 11025 samples per second"}, */
- /* {16000, "RATE_16000", 0, "16 kHz", "Set audio sampling rate to 16000 samples per second"}, */
- /* {22050, "RATE_22050", 0, "22.05 kHz", "Set audio sampling rate to 22050 samples per second"}, */
- /* {32000, "RATE_32000", 0, "32 kHz", "Set audio sampling rate to 32000 samples per second"}, */
- {44100, "RATE_44100", 0, "44.1 kHz", "Set audio sampling rate to 44100 samples per second"},
- {48000, "RATE_48000", 0, "48 kHz", "Set audio sampling rate to 48000 samples per second"},
- /* {88200, "RATE_88200", 0, "88.2 kHz", "Set audio sampling rate to 88200 samples per second"}, */
- {96000, "RATE_96000", 0, "96 kHz", "Set audio sampling rate to 96000 samples per second"},
- {192000,
- "RATE_192000",
- 0,
- "192 kHz",
- "Set audio sampling rate to 192000 samples per second"},
- {0, NULL, 0, NULL, NULL},
+# if 0
+ {8000, "RATE_8000", 0, "8 kHz", "Set audio sampling rate to 8000 samples per second"},
+ {11025, "RATE_11025", 0, "11.025 kHz", "Set audio sampling rate to 11025 samples per second"},
+ {16000, "RATE_16000", 0, "16 kHz", "Set audio sampling rate to 16000 samples per second"},
+ {22050, "RATE_22050", 0, "22.05 kHz", "Set audio sampling rate to 22050 samples per second"},
+ {32000, "RATE_32000", 0, "32 kHz", "Set audio sampling rate to 32000 samples per second"},
+# endif
+ {44100, "RATE_44100", 0, "44.1 kHz", "Set audio sampling rate to 44100 samples per second"},
+ {48000, "RATE_48000", 0, "48 kHz", "Set audio sampling rate to 48000 samples per second"},
+# if 0
+ {88200, "RATE_88200", 0, "88.2 kHz", "Set audio sampling rate to 88200 samples per second"},
+# endif
+ {96000, "RATE_96000", 0, "96 kHz", "Set audio sampling rate to 96000 samples per second"},
+ {192000, "RATE_192000", 0, "192 kHz", "Set audio sampling rate to 192000 samples per second"},
+ {0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem audio_format_items[] = {
@@ -4580,6 +4589,11 @@ static void rna_def_userdef_system(BlenderRNA *brna)
};
static const EnumPropertyItem image_draw_methods[] = {
+ {IMAGE_DRAW_METHOD_AUTO,
+ "AUTO",
+ 0,
+ "Automatic",
+ "Automatically choose method based on GPU and image"},
{IMAGE_DRAW_METHOD_2DTEXTURE,
"2DTEXTURE",
0,
@@ -4590,11 +4604,6 @@ static void rna_def_userdef_system(BlenderRNA *brna)
0,
"GLSL",
"Use GLSL shaders for display transform and draw image with 2D texture"},
- {IMAGE_DRAW_METHOD_DRAWPIXELS,
- "DRAWPIXELS",
- 0,
- "DrawPixels",
- "Use CPU for display transform and draw image using DrawPixels"},
{0, NULL, 0, NULL, NULL},
};
@@ -4766,6 +4775,23 @@ static void rna_def_userdef_system(BlenderRNA *brna)
"Texture Collection Rate",
"Number of seconds between each run of the GL texture garbage collector");
+ prop = RNA_def_property(srna, "vbo_time_out", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "vbotimeout");
+ RNA_def_property_range(prop, 0, 3600);
+ RNA_def_property_ui_text(
+ prop,
+ "VBO Time Out",
+ "Time since last access of a GL Vertex buffer object in seconds after which it is freed "
+ "(set to 0 to keep vbo allocated)");
+
+ prop = RNA_def_property(srna, "vbo_collection_rate", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "vbocollectrate");
+ RNA_def_property_range(prop, 1, 3600);
+ RNA_def_property_ui_text(
+ prop,
+ "VBO Collection Rate",
+ "Number of seconds between each run of the GL Vertex buffer object garbage collector");
+
/* Select */
prop = RNA_def_property(srna, "use_select_pick_depth", PROP_BOOLEAN, PROP_NONE);
@@ -5069,9 +5095,11 @@ static void rna_def_userdef_input(BlenderRNA *brna)
/* 3D view */
prop = RNA_def_property(srna, "ndof_show_guide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_SHOW_GUIDE);
+
+ /* TODO: update description when fly-mode visuals are in place
+ * ("projected position in fly mode"). */
RNA_def_property_ui_text(
prop, "Show Navigation Guide", "Display the center and axis during rotation");
- /* TODO: update description when fly-mode visuals are in place ("projected position in fly mode")*/
/* 3D view */
prop = RNA_def_property(srna, "ndof_view_navigate_method", PROP_ENUM, PROP_NONE);
@@ -5431,7 +5459,7 @@ void RNA_def_userdef(BlenderRNA *brna)
{USER_SECTION_ANIMATION, "ANIMATION", 0, "Animation", ""},
{0, "", 0, NULL, NULL},
{USER_SECTION_ADDONS, "ADDONS", 0, "Add-ons", ""},
-# if 0 //def WITH_USERDEF_WORKSPACES
+# if 0 // def WITH_USERDEF_WORKSPACES
{0, "", 0, NULL, NULL},
{USER_SECTION_WORKSPACE_CONFIG, "WORKSPACE_CONFIG", 0, "Configuration File", ""},
{USER_SECTION_WORKSPACE_ADDONS, "WORKSPACE_ADDONS", 0, "Add-on Overrides", ""},
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 550f90d7e7d..3f904df6e00 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -420,11 +420,11 @@ const EnumPropertyItem rna_enum_event_type_mask_items[] = {
#if 0
static const EnumPropertyItem keymap_modifiers_items[] = {
- {KM_ANY, "ANY", 0, "Any", ""},
- {0, "NONE", 0, "None", ""},
- {1, "FIRST", 0, "First", ""},
- {2, "SECOND", 0, "Second", ""},
- {0, NULL, 0, NULL, NULL},
+ {KM_ANY, "ANY", 0, "Any", ""},
+ {0, "NONE", 0, "None", ""},
+ {1, "FIRST", 0, "First", ""},
+ {2, "SECOND", 0, "Second", ""},
+ {0, NULL, 0, NULL, NULL},
};
#endif
@@ -847,7 +847,7 @@ static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
{
wmKeyMapItem *kmi = ptr->data;
- return WM_keymap_map_type_get(kmi);
+ return WM_keymap_item_map_type_get(kmi);
}
static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
@@ -1169,7 +1169,7 @@ static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value)
if (!STREQ(idname, kmi->idname)) {
BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname));
- WM_keymap_properties_reset(kmi, NULL);
+ WM_keymap_item_properties_reset(kmi, NULL);
}
}
@@ -1532,7 +1532,8 @@ static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
idname = ot->idname;
WM_operatortype_remove_ptr(ot);
- /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */
+ /* Not to be confused with the RNA_struct_free that WM_operatortype_remove calls,
+ * they are 2 different srna's. */
RNA_struct_free(&BLENDER_RNA, type);
MEM_freeN((void *)idname);
@@ -1728,7 +1729,8 @@ static void rna_KeyMapItem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi
#else /* RNA_RUNTIME */
/**
- * expose ``Operator.options`` as its own type so we can control each flags use (some are read-only).
+ * expose ``Operator.options`` as its own type so we can control each flags use
+ * (some are read-only).
*/
static void rna_def_operator_options_runtime(BlenderRNA *brna)
{
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 3e7d16c636e..e4caeb2a5ae 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -82,7 +82,7 @@ static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
static void rna_keymap_restore_item_to_default(wmKeyMap *km, bContext *C, wmKeyMapItem *kmi)
{
- WM_keymap_restore_item_to_default(C, km, kmi);
+ WM_keymap_item_restore_to_default(C, km, kmi);
}
static void rna_Operator_report(wmOperator *op, int type, const char *msg)
diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c
index b5f9f6102de..a473f97d554 100644
--- a/source/blender/makesrna/intern/rna_wm_gizmo.c
+++ b/source/blender/makesrna/intern/rna_wm_gizmo.c
@@ -752,8 +752,8 @@ static void rna_gizmogroup_invoke_prepare_cb(const bContext *C, wmGizmoGroup *gz
FunctionRNA *func;
RNA_pointer_create(NULL, gzgroup->type->ext.srna, gzgroup, &gzgroup_ptr);
- func =
- &rna_GizmoGroup_invoke_prepare_func; /* RNA_struct_find_function(&wgroupr, "invoke_prepare"); */
+ /* RNA_struct_find_function(&wgroupr, "invoke_prepare"); */
+ func = &rna_GizmoGroup_invoke_prepare_func;
RNA_parameter_list_create(&list, &gzgroup_ptr, func);
RNA_parameter_set_lookup(&list, "context", &C);
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 5e4791b8b7a..6349b5206d6 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -158,9 +158,8 @@ const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(bContext *UNUSED(C),
PropertyRNA *UNUSED(prop),
bool *UNUSED(r_free))
{
- WorkSpace *workspace = ptr->id.data;
-
- switch (workspace->tools_space_type) {
+ bToolRef *tref = ptr->data;
+ switch (tref->space_type) {
case SPACE_VIEW3D:
return rna_enum_context_mode_items;
case SPACE_IMAGE:
@@ -372,19 +371,6 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Tools", "");
rna_def_workspace_tools(brna, prop);
- prop = RNA_def_property(srna, "tools_space_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "tools_space_type");
- RNA_def_property_enum_items(prop, rna_enum_space_type_items);
- RNA_def_property_ui_text(prop, "Active Tool Space", "");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "tools_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "tools_mode");
- RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items);
- RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_WorkSpace_tools_mode_itemf");
- RNA_def_property_ui_text(prop, "Active Tool Mode", "");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_workspace_object_mode_items);
RNA_def_property_ui_text(
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 691a0e369e6..5116fefde94 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -21,17 +21,17 @@
set(INC
.
intern
+ ../blenfont
../blenkernel
../blenlib
- ../blenfont
+ ../bmesh
../depsgraph
../makesdna
../makesrna
- ../bmesh
../render/extern/include
../../../intern/elbeem/extern
- ../../../intern/guardedalloc
../../../intern/eigen
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index ce58fd172a2..72215659915 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -24,11 +24,13 @@
#include <string.h>
#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
+#include "BKE_action.h"
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -55,7 +57,7 @@ static void initData(ModifierData *md)
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#if 0
- const ArmatureModifierData *amd = (const ArmatureModifierData *) md;
+ const ArmatureModifierData *amd = (const ArmatureModifierData *)md;
#endif
ArmatureModifierData *tamd = (ArmatureModifierData *)target;
@@ -91,7 +93,27 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
ArmatureModifierData *amd = (ArmatureModifierData *)md;
if (amd->object != NULL) {
- DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier");
+ /* If not using envelopes,
+ * create relations to individual bones for more rigging flexibility. */
+ if ((amd->deformflag & ARM_DEF_ENVELOPE) == 0 && (amd->object->pose != NULL) &&
+ ELEM(ctx->object->type, OB_MESH, OB_LATTICE, OB_GPENCIL)) {
+ /* If neither vertex groups nor envelopes are used, the modifier has no bone dependencies. */
+ if ((amd->deformflag & ARM_DEF_VGROUP) != 0) {
+ /* Enumerate groups that match existing bones. */
+ LISTBASE_FOREACH (bDeformGroup *, dg, &ctx->object->defbase) {
+ if (BKE_pose_channel_find_name(amd->object->pose, dg->name) != NULL) {
+ /* Can't check BONE_NO_DEFORM because it can be animated. */
+ DEG_add_bone_relation(
+ ctx->node, amd->object, dg->name, DEG_OB_COMP_BONE, "Armature Modifier");
+ }
+ }
+ }
+ }
+ /* Otherwise require the whole pose to be complete. */
+ else {
+ DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier");
+ }
+
DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_TRANSFORM, "Armature Modifier");
}
DEG_add_modifier_to_transform_relation(ctx->node, "Armature Modifier");
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index c909f9dc076..fd6f58a21d4 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -121,12 +121,15 @@ static int svert_sum_cmp(const void *e1, const void *e2)
const SortVertsElem *sv1 = e1;
const SortVertsElem *sv2 = e2;
- if (sv1->sum_co > sv2->sum_co)
+ if (sv1->sum_co > sv2->sum_co) {
return 1;
- else if (sv1->sum_co < sv2->sum_co)
+ }
+ else if (sv1->sum_co < sv2->sum_co) {
return -1;
- else
+ }
+ else {
return 0;
+ }
}
static void svert_from_mvert(SortVertsElem *sv,
@@ -145,7 +148,8 @@ static void svert_from_mvert(SortVertsElem *sv,
/**
* Take as inputs two sets of verts, to be processed for detection of doubles and mapping.
* Each set of verts is defined by its start within mverts array and its num_verts;
- * It builds a mapping for all vertices within source, to vertices within target, or -1 if no double found
+ * It builds a mapping for all vertices within source,
+ * to vertices within target, or -1 if no double found.
* The int doubles_map[num_verts_source] array must have been allocated by caller.
*/
static void dm_mvert_map_doubles(int *doubles_map,
@@ -217,11 +221,13 @@ static void dm_mvert_map_doubles(int *doubles_map,
target_scan_completed = true;
continue;
}
- /* Test target candidates starting at the low bound of possible doubles, ordered in terms of sumco */
+ /* Test target candidates starting at the low bound of possible doubles,
+ * ordered in terms of sumco. */
i_target = i_target_low_bound;
sve_target = sve_target_low_bound;
- /* i_target will scan vertices in the [v_source_sumco - dist3; v_source_sumco + dist3] range */
+ /* i_target will scan vertices in the
+ * [v_source_sumco - dist3; v_source_sumco + dist3] range */
while ((i_target < target_num_verts) && (sve_target->sum_co <= sve_source_sumco + dist3)) {
/* Testing distance for candidate double in target */
@@ -234,8 +240,9 @@ static void dm_mvert_map_doubles(int *doubles_map,
/* If target is already mapped, we only follow that mapping if final target remains
* close enough from current vert (otherwise no mapping at all).
- * Note that if we later find another target closer than this one, then we check it. But if other
- * potential targets are farther, then there will be no mapping at all for this source. */
+ * Note that if we later find another target closer than this one, then we check it.
+ * But if other potential targets are farther,
+ * then there will be no mapping at all for this source. */
while (best_target_vertex != -1 &&
!ELEM(doubles_map[best_target_vertex], -1, best_target_vertex)) {
if (compare_len_v3v3(mverts[sve_source->vertex_num].co,
@@ -441,10 +448,12 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
float obinv[4][4];
float result_mat[4][4];
- if (ctx->object)
+ if (ctx->object) {
invert_m4_m4(obinv, ctx->object->obmat);
- else
+ }
+ else {
unit_m4(obinv);
+ }
mul_m4_series(result_mat, offset, obinv, amd->offset_ob->obmat);
copy_m4_m4(offset, result_mat);
@@ -482,8 +491,9 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
}
}
- if (count < 1)
+ if (count < 1) {
count = 1;
+ }
/* The number of verts, edges, loops, polys, before eventually merging doubles */
result_nverts = chunk_nverts * count + start_cap_nverts + end_cap_nverts;
@@ -714,7 +724,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
for (i = 0; i < result_nverts; i++) {
int new_i = full_doubles_map[i];
if (new_i != -1) {
- /* We have to follow chains of doubles (merge start/end especially is likely to create some),
+ /* We have to follow chains of doubles
+ * (merge start/end especially is likely to create some),
* those are not supported at all by BKE_mesh_merge_verts! */
while (!ELEM(full_doubles_map[new_i], -1, new_i)) {
new_i = full_doubles_map[new_i];
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 32a020a35ff..26b45bbef0d 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -110,38 +110,42 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const int miter_inner = bmd->miter_inner;
const float spread = bmd->spread;
- bm = BKE_mesh_to_bmesh_ex(
- mesh,
- &(struct BMeshCreateParams){0},
- &(struct BMeshFromMeshParams){
- .calc_face_normal = true,
- .add_key_index = false,
- .use_shapekey = false,
- .active_shapekey = 0,
- /* XXX We probably can use CD_MASK_BAREMESH_ORIGDINDEX here instead (also for other modifiers cases)? */
- .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX,
- .emask = CD_MASK_ORIGINDEX,
- .pmask = CD_MASK_ORIGINDEX},
- });
-
- if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0])
+ bm = BKE_mesh_to_bmesh_ex(mesh,
+ &(struct BMeshCreateParams){0},
+ &(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ .add_key_index = false,
+ .use_shapekey = false,
+ .active_shapekey = 0,
+ /* XXX We probably can use CD_MASK_BAREMESH_ORIGDINDEX here instead
+ * (also for other modifiers cases)? */
+ .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX,
+ .emask = CD_MASK_ORIGINDEX,
+ .pmask = CD_MASK_ORIGINDEX},
+ });
+
+ if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0]) {
MOD_get_vgroup(ctx->object, mesh, bmd->defgrp_name, &dvert, &vgroup);
+ }
if (vertex_only) {
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (!BM_vert_is_manifold(v))
+ if (!BM_vert_is_manifold(v)) {
continue;
+ }
if (bmd->lim_flags & MOD_BEVEL_WEIGHT) {
weight = BM_elem_float_data_get(&bm->vdata, v, CD_BWEIGHT);
- if (weight == 0.0f)
+ if (weight == 0.0f) {
continue;
+ }
}
else if (vgroup != -1) {
weight = defvert_array_find_weight_safe(dvert, BM_elem_index_get(v), vgroup);
/* Check is against 0.5 rather than != 0.0 because cascaded bevel modifiers will
* interpolate weights for newly created vertices, and may cause unexpected "selection" */
- if (weight < 0.5f)
+ if (weight < 0.5f) {
continue;
+ }
}
BM_elem_flag_enable(v, BM_ELEM_TAG);
}
@@ -165,14 +169,16 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
if (BM_edge_is_manifold(e)) {
if (bmd->lim_flags & MOD_BEVEL_WEIGHT) {
weight = BM_elem_float_data_get(&bm->edata, e, CD_BWEIGHT);
- if (weight == 0.0f)
+ if (weight == 0.0f) {
continue;
+ }
}
else if (vgroup != -1) {
weight = defvert_array_find_weight_safe(dvert, BM_elem_index_get(e->v1), vgroup);
weight2 = defvert_array_find_weight_safe(dvert, BM_elem_index_get(e->v2), vgroup);
- if (weight < 0.5f || weight2 < 0.5f)
+ if (weight < 0.5f || weight2 < 0.5f) {
continue;
+ }
}
BM_elem_flag_enable(e, BM_ELEM_TAG);
BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 6e6f98e9889..107622e33c0 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -323,8 +323,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* if new mesh returned, return it; otherwise there was
* an error, so delete the modifier object */
- if (result == NULL)
+ if (result == NULL) {
modifier_setError(md, "Cannot execute boolean operation");
+ }
}
return result;
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index 7c8470b26d9..e61f6877d09 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -152,8 +152,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, str
MEdge *medge, *me;
uintptr_t hash_num;
- if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE)
+ if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) {
BLI_array_randomize(edgeMap, sizeof(*edgeMap), numEdge_src, bmd->seed);
+ }
/* get the set of all vert indices that will be in the final mesh,
* mapped to the new indices
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index b0a8a8c955f..0bf1dd8e2b3 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -62,8 +62,9 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
flag = cmd->flag & (MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z);
- if ((cmd->fac == 0.0f) || flag == 0)
+ if ((cmd->fac == 0.0f) || flag == 0) {
return true;
+ }
return false;
}
@@ -120,8 +121,9 @@ static void sphere_do(CastModifierData *cmd,
flag = cmd->flag;
type = cmd->type; /* projection type: sphere or cylinder */
- if (type == MOD_CAST_TYPE_CYLINDER)
+ if (type == MOD_CAST_TYPE_CYLINDER) {
flag &= ~MOD_CAST_Z;
+ }
ctrl_ob = cmd->object;
@@ -144,8 +146,9 @@ static void sphere_do(CastModifierData *cmd,
/* 1) (flag was checked in the "if (ctrl_ob)" block above) */
/* 2) cmd->radius > 0.0f: only the vertices within this radius from
* the center of the effect should be deformed */
- if (cmd->radius > FLT_EPSILON)
+ if (cmd->radius > FLT_EPSILON) {
has_radius = 1;
+ }
/* 3) if we were given a vertex group name,
* only those vertices should be affected */
@@ -164,8 +167,9 @@ static void sphere_do(CastModifierData *cmd,
}
len /= numVerts;
- if (len == 0.0f)
+ if (len == 0.0f) {
len = 10.0f;
+ }
}
for (i = 0; i < numVerts; i++) {
@@ -183,12 +187,14 @@ static void sphere_do(CastModifierData *cmd,
copy_v3_v3(vec, tmp_co);
- if (type == MOD_CAST_TYPE_CYLINDER)
+ if (type == MOD_CAST_TYPE_CYLINDER) {
vec[2] = 0.0f;
+ }
if (has_radius) {
- if (len_v3(vec) > cmd->radius)
+ if (len_v3(vec) > cmd->radius) {
continue;
+ }
}
if (dvert) {
@@ -203,12 +209,15 @@ static void sphere_do(CastModifierData *cmd,
normalize_v3(vec);
- if (flag & MOD_CAST_X)
+ if (flag & MOD_CAST_X) {
tmp_co[0] = fac * vec[0] * len + facm * tmp_co[0];
- if (flag & MOD_CAST_Y)
+ }
+ if (flag & MOD_CAST_Y) {
tmp_co[1] = fac * vec[1] * len + facm * tmp_co[1];
- if (flag & MOD_CAST_Z)
+ }
+ if (flag & MOD_CAST_Z) {
tmp_co[2] = fac * vec[2] * len + facm * tmp_co[2];
+ }
if (ctrl_ob) {
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
@@ -252,8 +261,9 @@ static void cuboid_do(CastModifierData *cmd,
/* 1) (flag was checked in the "if (ctrl_ob)" block above) */
/* 2) cmd->radius > 0.0f: only the vertices within this radius from
* the center of the effect should be deformed */
- if (cmd->radius > FLT_EPSILON)
+ if (cmd->radius > FLT_EPSILON) {
has_radius = 1;
+ }
/* 3) if we were given a vertex group name,
* only those vertices should be affected */
@@ -309,12 +319,15 @@ static void cuboid_do(CastModifierData *cmd,
}
/* we want a symmetric bound box around the origin */
- if (fabsf(min[0]) > fabsf(max[0]))
+ if (fabsf(min[0]) > fabsf(max[0])) {
max[0] = fabsf(min[0]);
- if (fabsf(min[1]) > fabsf(max[1]))
+ }
+ if (fabsf(min[1]) > fabsf(max[1])) {
max[1] = fabsf(min[1]);
- if (fabsf(min[2]) > fabsf(max[2]))
+ }
+ if (fabsf(min[2]) > fabsf(max[2])) {
max[2] = fabsf(min[2]);
+ }
min[0] = -max[0];
min[1] = -max[1];
min[2] = -max[2];
@@ -371,12 +384,15 @@ static void cuboid_do(CastModifierData *cmd,
/* find in which octant this vertex is in */
octant = 0;
- if (tmp_co[0] > 0.0f)
+ if (tmp_co[0] > 0.0f) {
octant += 1;
- if (tmp_co[1] > 0.0f)
+ }
+ if (tmp_co[1] > 0.0f) {
octant += 2;
- if (tmp_co[2] > 0.0f)
+ }
+ if (tmp_co[2] > 0.0f) {
octant += 4;
+ }
/* apex is the bb's vertex at the chosen octant */
copy_v3_v3(apex, bb[octant]);
@@ -400,20 +416,24 @@ static void cuboid_do(CastModifierData *cmd,
/* ok, now we know which coordinate of the vertex to use */
- if (fabsf(tmp_co[coord]) < FLT_EPSILON) /* avoid division by zero */
+ if (fabsf(tmp_co[coord]) < FLT_EPSILON) { /* avoid division by zero */
continue;
+ }
/* finally, this is the factor we wanted, to project the vertex
* to its bounding box (bb) */
fbb = apex[coord] / tmp_co[coord];
/* calculate the new vertex position */
- if (flag & MOD_CAST_X)
+ if (flag & MOD_CAST_X) {
tmp_co[0] = facm * tmp_co[0] + fac * tmp_co[0] * fbb;
- if (flag & MOD_CAST_Y)
+ }
+ if (flag & MOD_CAST_Y) {
tmp_co[1] = facm * tmp_co[1] + fac * tmp_co[1] * fbb;
- if (flag & MOD_CAST_Z)
+ }
+ if (flag & MOD_CAST_Z) {
tmp_co[2] = facm * tmp_co[2] + fac * tmp_co[2] * fbb;
+ }
if (ctrl_ob) {
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 9eeef583e44..3c4dd9f2c56 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -59,8 +59,9 @@ static void initData(ModifierData *md)
clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches);
/* check for alloc failing */
- if (!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache)
+ if (!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache) {
return;
+ }
cloth_init(clmd);
}
@@ -79,8 +80,9 @@ static void deformVerts(ModifierData *md,
if (!clmd->sim_parms || !clmd->coll_parms) {
initData(md);
- if (!clmd->sim_parms || !clmd->coll_parms)
+ if (!clmd->sim_parms || !clmd->coll_parms) {
return;
+ }
}
if (mesh == NULL) {
@@ -156,13 +158,15 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
ClothModifierData *tclmd = (ClothModifierData *)target;
if (tclmd->sim_parms) {
- if (tclmd->sim_parms->effector_weights)
+ if (tclmd->sim_parms->effector_weights) {
MEM_freeN(tclmd->sim_parms->effector_weights);
+ }
MEM_freeN(tclmd->sim_parms);
}
- if (tclmd->coll_parms)
+ if (tclmd->coll_parms) {
MEM_freeN(tclmd->coll_parms);
+ }
BKE_ptcache_free_list(&tclmd->ptcaches);
if (flag & LIB_ID_CREATE_NO_MAIN) {
@@ -177,8 +181,9 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
}
tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms);
- if (clmd->sim_parms->effector_weights)
+ if (clmd->sim_parms->effector_weights) {
tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights);
+ }
tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms);
tclmd->clothObject = NULL;
tclmd->hairdata = NULL;
@@ -202,12 +207,14 @@ static void freeData(ModifierData *md)
cloth_free_modifier_extern(clmd);
if (clmd->sim_parms) {
- if (clmd->sim_parms->effector_weights)
+ if (clmd->sim_parms->effector_weights) {
MEM_freeN(clmd->sim_parms->effector_weights);
+ }
MEM_freeN(clmd->sim_parms);
}
- if (clmd->coll_parms)
+ if (clmd->coll_parms) {
MEM_freeN(clmd->coll_parms);
+ }
if (md->flag & eModifierFlag_SharedCaches) {
BLI_listbase_clear(&clmd->ptcaches);
@@ -217,11 +224,13 @@ static void freeData(ModifierData *md)
}
clmd->point_cache = NULL;
- if (clmd->hairdata)
+ if (clmd->hairdata) {
MEM_freeN(clmd->hairdata);
+ }
- if (clmd->solver_result)
+ if (clmd->solver_result) {
MEM_freeN(clmd->solver_result);
+ }
}
}
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index 59f4a1a93b6..1bbc25643a1 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -141,8 +141,9 @@ static void deformVerts(ModifierData *md,
}
/* check if mesh has changed */
- if (collmd->x && (mvert_num != collmd->mvert_num))
+ if (collmd->x && (mvert_num != collmd->mvert_num)) {
freeData((ModifierData *)collmd);
+ }
if (collmd->time_xnew == -1000) { /* first time */
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index 2a332bc9709..705ffb266c5 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -307,7 +307,8 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd,
/* fast-path */
for (i = 0; i < numVerts; i++) {
struct SmoothingData_Weighted *sd = &smooth_data[i];
- /* divide by sum of all neighbour distances (weighted) and amount of neighbors, (mean average) */
+ /* Divide by sum of all neighbour distances (weighted) and amount of neighbors,
+ * (mean average). */
const float div = sd->edge_length_sum * vertex_edge_count[i];
if (div > eps) {
#if 0
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index 4de99ea6fe6..3235d64cbbb 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -179,8 +179,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
if (((result == me) || (me->mvert == result->mvert) || (me->medge == result->medge)) &&
(dtmd->data_types & DT_TYPES_AFFECT_MESH)) {
- /* We need to duplicate data here, otherwise setting custom normals, edges' shaprness, etc., could
- * modify org mesh, see T43671. */
+ /* We need to duplicate data here, otherwise setting custom normals, edges' shaprness, etc.,
+ * could modify org mesh, see T43671. */
BKE_id_copy_ex(NULL, &me_mod->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
}
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index b0c633b1cdd..50447ae0376 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -284,10 +284,12 @@ static void displaceModifier_do(DisplaceModifierData *dmd,
float local_mat[4][4] = {{0}};
const bool use_global_direction = dmd->space == MOD_DISP_SPACE_GLOBAL;
- if (dmd->texture == NULL && dmd->direction == MOD_DISP_DIR_RGB_XYZ)
+ if (dmd->texture == NULL && dmd->direction == MOD_DISP_DIR_RGB_XYZ) {
return;
- if (dmd->strength == 0.0f)
+ }
+ if (dmd->strength == 0.0f) {
return;
+ }
mvert = mesh->mvert;
MOD_get_vgroup(ob, mesh, dmd->defgrp_name, &dvert, &defgrp_index);
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index ccd71455b21..ce488a224aa 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -129,7 +129,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
ctx->node, ctx->object, surface->effector_weights, true, 0, "Dynamic Paint Field");
}
- /* Actual code uses custom loop over group/scene without layer checks in dynamicPaint_doStep */
+ /* Actual code uses custom loop over group/scene
+ * without layer checks in dynamicPaint_doStep. */
DEG_add_collision_relations(ctx->node,
ctx->object,
surface->brush_group,
@@ -167,7 +168,7 @@ static void foreachTexLink(ModifierData *UNUSED(md),
TexWalkFunc UNUSED(walk),
void *UNUSED(userData))
{
- //walk(userData, ob, md, ""); /* re-enable when possible */
+ // walk(userData, ob, md, ""); /* re-enable when possible */
}
ModifierTypeInfo modifierType_DynamicPaint = {
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index 9c2ad13db94..59d560b9a4a 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -118,8 +118,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *UNUSED(c
Mesh *result;
EdgeSplitModifierData *emd = (EdgeSplitModifierData *)md;
- if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG)))
+ if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG))) {
return mesh;
+ }
result = doEdgeSplit(mesh, emd);
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index f126adbaafd..4ed787810a8 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -63,7 +63,7 @@ static void freeData(ModifierData *md)
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#if 0
- const ExplodeModifierData *emd = (const ExplodeModifierData *) md;
+ const ExplodeModifierData *emd = (const ExplodeModifierData *)md;
#endif
ExplodeModifierData *temd = (ExplodeModifierData *)target;
@@ -129,8 +129,9 @@ static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *p
for (i = 0; i < totvert; i++, dvert++) {
float val = BLI_rng_get_float(rng);
val = (1.0f - emd->protect) * val + emd->protect * 0.5f;
- if (val < defvert_find_weight(dvert, defgrp_index))
+ if (val < defvert_find_weight(dvert, defgrp_index)) {
vertpa[i] = -1;
+ }
}
}
}
@@ -716,8 +717,9 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
BLI_edgehashIterator_free(ehi);
/* count new faces due to splitting */
- for (i = 0, fs = facesplit; i < totface; i++, fs++)
+ for (i = 0, fs = facesplit; i < totface; i++, fs++) {
totfsplit += add_faces[*fs];
+ }
split_m = BKE_mesh_new_nomain_from_template(mesh, totesplit, 0, totface + totfsplit, 0, 0);
@@ -741,7 +743,7 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
* have to stop using tessface - campbell */
facepa = MEM_calloc_arrayN((totface + (totfsplit * 2)), sizeof(int), "explode_facepa");
- //memcpy(facepa, emd->facepa, totface*sizeof(int));
+ // memcpy(facepa, emd->facepa, totface*sizeof(int));
emd->facepa = facepa;
/* create new verts */
@@ -764,7 +766,7 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
/* create new faces */
curdupface = 0; //=totface;
- //curdupin=totesplit;
+ // curdupin=totesplit;
for (i = 0, fs = facesplit; i < totface; i++, fs++) {
mf = &mesh->mface[i];
@@ -1031,12 +1033,15 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
if (facepa[i] != totpart) {
pa = pars + facepa[i];
- if (pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0)
+ if (pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) {
continue;
- if (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0)
+ }
+ if (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) {
continue;
- if (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0)
+ }
+ if (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0) {
continue;
+ }
}
source = mesh->mface[i];
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 3744c527983..0776806f541 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -435,8 +435,10 @@ static Mesh *fluidsim_read_cache(
Object *ob, Mesh *orgmesh, FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
{
int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */
- /* why start with 0 as start frame?? Animations + time are frozen for frame 0 anyway. (See physics_fluid.c for that. - DG */
- /* If we start with frame 0, we need to remap all animation channels, too, because they will all be 1 frame late if using frame-1! - DG */
+ /* why start with 0 as start frame?? Animations + time are frozen for frame 0 anyway.
+ * (See physics_fluid.c for that. - DG) */
+ /* If we start with frame 0, we need to remap all animation channels, too,
+ * because they will all be 1 frame late if using frame-1! - DG */
char targetFile[FILE_MAX];
FluidsimSettings *fss = fluidmd->fss;
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 02682b23490..e27d2786751 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -214,7 +214,8 @@ static void createVertRingMap(const int mvert_tot,
}
/**
- * This method computes the Laplacian Matrix and Differential Coordinates for all vertex in the mesh.
+ * This method computes the Laplacian Matrix and Differential Coordinates
+ * for all vertex in the mesh..
* The Linear system is LV = d
* Where L is Laplacian Matrix, V as the vertices in Mesh, d is the differential coordinates
* The Laplacian Matrix is computes as a
@@ -227,18 +228,21 @@ static void createVertRingMap(const int mvert_tot,
* Where :
* di is the Differential Coordinate i
* sum (Wij) is the sum of all weights between vertex Vi and its vertices neighbors (Vj)
- * sum (Wij * Vj) is the sum of the product between vertex neighbor Vj and weight Wij for all neighborhood.
+ * sum (Wij * Vj) is the sum of the product between vertex neighbor Vj and weight Wij
+ * for all neighborhood.
*
* This Laplacian Matrix is described in the paper:
- * Desbrun M. et.al, Implicit fairing of irregular meshes using diffusion and curvature flow, SIGGRAPH '99, pag 317-324,
- * New York, USA
+ * Desbrun M. et.al, Implicit fairing of irregular meshes using diffusion and curvature flow,
+ * SIGGRAPH '99, pag 317-324, New York, USA
*
- * The computation of Laplace Beltrami operator on Hybrid Triangle/Quad Meshes is described in the paper:
- * Pinzon A., Romero E., Shape Inflation With an Adapted Laplacian Operator For Hybrid Quad/Triangle Meshes,
+ * The computation of Laplace Beltrami operator on Hybrid Triangle/Quad Meshes is described in the
+ * paper: Pinzon A., Romero E., Shape Inflation With an Adapted Laplacian Operator For
+ * Hybrid Quad/Triangle Meshes,
* Conference on Graphics Patterns and Images, SIBGRAPI, 2013
*
* The computation of Differential Coordinates is described in the paper:
- * Sorkine, O. Laplacian Surface Editing. Proceedings of the EUROGRAPHICS/ACM SIGGRAPH Symposium on Geometry Processing,
+ * Sorkine, O. Laplacian Surface Editing.
+ * Proceedings of the EUROGRAPHICS/ACM SIGGRAPH Symposium on Geometry Processing,
* 2004. p. 179-188.
*/
static void initLaplacianMatrix(LaplacianSystem *sys)
@@ -730,8 +734,9 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
bool UNUSED(useRenderParams))
{
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
- if (lmd->anchor_grp_name[0])
+ if (lmd->anchor_grp_name[0]) {
return 0;
+ }
return 1;
}
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 0dfe5f49393..4a86c26cdeb 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -501,8 +501,9 @@ static bool is_disabled(const struct Scene *UNUSED(scene),
flag = smd->flag & (MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z);
/* disable if modifier is off for X, Y and Z or if factor is 0 */
- if (flag == 0)
+ if (flag == 0) {
return 1;
+ }
return 0;
}
@@ -527,8 +528,9 @@ static void deformVerts(ModifierData *md,
{
Mesh *mesh_src;
- if (numVerts == 0)
+ if (numVerts == 0) {
return;
+ }
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
@@ -549,8 +551,9 @@ static void deformVertsEM(ModifierData *md,
{
Mesh *mesh_src;
- if (numVerts == 0)
+ if (numVerts == 0) {
return;
+ }
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index a13e75c76de..3417aaeeb5c 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -105,9 +105,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
/* Overview of Method:
- * 1. Get the vertices that are in the vertexgroup of interest
- * 2. Filter out unwanted geometry (i.e. not in vertexgroup), by populating mappings with new vs old indices
- * 3. Make a new mesh containing only the mapping data
+ * 1. Get the vertices that are in the vertexgroup of interest.
+ * 2. Filter out unwanted geometry (i.e. not in vertexgroup),
+ * by populating mappings with new vs old indices.
+ * 3. Make a new mesh containing only the mapping data.
*/
/* get original number of verts, edges, and faces */
@@ -137,9 +138,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
return mesh;
}
- /* determine whether each vertexgroup is associated with a selected bone or not
- * - each cell is a boolean saying whether bone corresponding to the ith group is selected
- * - groups that don't match a bone are treated as not existing (along with the corresponding ungrouped verts)
+ /* Determine whether each vertexgroup is associated with a selected bone or not:
+ * - Each cell is a boolean saying whether bone corresponding to the ith group is selected.
+ * - Groups that don't match a bone are treated as not existing
+ * (along with the corresponding ungrouped verts).
*/
bone_select_array = MEM_malloc_arrayN((size_t)defbase_tot, sizeof(char), "mask array");
@@ -154,7 +156,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
}
- /* verthash gives mapping from original vertex indices to the new indices (including selected matches only)
+ /* verthash gives mapping from original vertex indices to the new indices
+ * (including selected matches only):
* key = oldindex, value = newindex
*/
vertHash = BLI_ghash_int_new_ex("mask vert gh", (unsigned int)maxVerts);
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index cf1b2daa9cd..e01f07584ee 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -226,12 +226,15 @@ static void meshcache_do(MeshCacheModifierData *mcmd,
if (mcmd->flip_axis) {
float tmat[3][3];
unit_m3(tmat);
- if (mcmd->flip_axis & (1 << 0))
+ if (mcmd->flip_axis & (1 << 0)) {
tmat[0][0] = -1.0f;
- if (mcmd->flip_axis & (1 << 1))
+ }
+ if (mcmd->flip_axis & (1 << 1)) {
tmat[1][1] = -1.0f;
- if (mcmd->flip_axis & (1 << 2))
+ }
+ if (mcmd->flip_axis & (1 << 2)) {
tmat[2][2] = -1.0f;
+ }
mul_m3_m3m3(mat, tmat, mat);
use_matrix = true;
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 9238057f032..d89a47f4cf3 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -62,22 +62,30 @@ static void freeData(ModifierData *md)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
- if (mmd->bindinfluences)
+ if (mmd->bindinfluences) {
MEM_freeN(mmd->bindinfluences);
- if (mmd->bindoffsets)
+ }
+ if (mmd->bindoffsets) {
MEM_freeN(mmd->bindoffsets);
- if (mmd->bindcagecos)
+ }
+ if (mmd->bindcagecos) {
MEM_freeN(mmd->bindcagecos);
- if (mmd->dyngrid)
+ }
+ if (mmd->dyngrid) {
MEM_freeN(mmd->dyngrid);
- if (mmd->dyninfluences)
+ }
+ if (mmd->dyninfluences) {
MEM_freeN(mmd->dyninfluences);
- if (mmd->dynverts)
+ }
+ if (mmd->dynverts) {
MEM_freeN(mmd->dynverts);
- if (mmd->bindweights)
+ }
+ if (mmd->bindweights) {
MEM_freeN(mmd->bindweights); /* deprecated */
- if (mmd->bindcos)
+ }
+ if (mmd->bindcos) {
MEM_freeN(mmd->bindcos); /* deprecated */
+ }
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
@@ -87,22 +95,30 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
modifier_copyData_generic(md, target, flag);
- if (mmd->bindinfluences)
+ if (mmd->bindinfluences) {
tmmd->bindinfluences = MEM_dupallocN(mmd->bindinfluences);
- if (mmd->bindoffsets)
+ }
+ if (mmd->bindoffsets) {
tmmd->bindoffsets = MEM_dupallocN(mmd->bindoffsets);
- if (mmd->bindcagecos)
+ }
+ if (mmd->bindcagecos) {
tmmd->bindcagecos = MEM_dupallocN(mmd->bindcagecos);
- if (mmd->dyngrid)
+ }
+ if (mmd->dyngrid) {
tmmd->dyngrid = MEM_dupallocN(mmd->dyngrid);
- if (mmd->dyninfluences)
+ }
+ if (mmd->dyninfluences) {
tmmd->dyninfluences = MEM_dupallocN(mmd->dyninfluences);
- if (mmd->dynverts)
+ }
+ if (mmd->dynverts) {
tmmd->dynverts = MEM_dupallocN(mmd->dynverts);
- if (mmd->bindweights)
+ }
+ if (mmd->bindweights) {
tmmd->bindweights = MEM_dupallocN(mmd->bindweights); /* deprecated */
- if (mmd->bindcos)
+ }
+ if (mmd->bindcos) {
tmmd->bindcos = MEM_dupallocN(mmd->bindcos); /* deprecated */
+ }
}
static void requiredDataMask(Object *UNUSED(ob),
@@ -256,9 +272,11 @@ static void meshdeform_vert_task(void *__restrict userdata,
float co[3];
float weight, totweight, fac = 1.0f;
- if (mmd->flag & MOD_MDEF_DYNAMIC_BIND)
- if (!mmd->dynverts[iter])
+ if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
+ if (!mmd->dynverts[iter]) {
return;
+ }
+ }
if (dvert) {
fac = defvert_find_weight(&dvert[iter], defgrp_index);
@@ -293,10 +311,12 @@ static void meshdeform_vert_task(void *__restrict userdata,
if (totweight > 0.0f) {
mul_v3_fl(co, fac / totweight);
mul_m3_v3(data->icagemat, co);
- if (G.debug_value != 527)
+ if (G.debug_value != 527) {
add_v3_v3(vertexCos[iter], co);
- else
+ }
+ else {
copy_v3_v3(vertexCos[iter], co);
+ }
}
}
@@ -319,8 +339,9 @@ static void meshdeformModifier_do(ModifierData *md,
static int recursive_bind_sentinel = 0;
- if (mmd->object == NULL || (mmd->bindcagecos == NULL && mmd->bindfunc == NULL))
+ if (mmd->object == NULL || (mmd->bindcagecos == NULL && mmd->bindfunc == NULL)) {
return;
+ }
/* Get cage mesh.
*
@@ -467,8 +488,9 @@ void modifier_mdef_compact_influences(ModifierData *md)
int totinfluence, totvert, totcagevert, a, b;
weights = mmd->bindweights;
- if (!weights)
+ if (!weights) {
return;
+ }
totvert = mmd->totvert;
totcagevert = mmd->totcagevert;
@@ -478,8 +500,9 @@ void modifier_mdef_compact_influences(ModifierData *md)
for (a = 0; a < totcagevert; a++) {
weight = weights[a + b * totcagevert];
- if (weight > MESHDEFORM_MIN_INFLUENCE)
+ if (weight > MESHDEFORM_MIN_INFLUENCE) {
mmd->totinfluence++;
+ }
}
}
@@ -499,8 +522,9 @@ void modifier_mdef_compact_influences(ModifierData *md)
for (a = 0; a < totcagevert; a++) {
weight = weights[a + b * totcagevert];
- if (weight > MESHDEFORM_MIN_INFLUENCE)
+ if (weight > MESHDEFORM_MIN_INFLUENCE) {
totweight += weight;
+ }
}
/* assign weights normalized */
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 7710082150b..760830ffb24 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -18,6 +18,11 @@
* \ingroup modifiers
*/
+#include <string.h>
+
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+
#include "DNA_cachefile_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -47,6 +52,9 @@ static void initData(ModifierData *md)
mcmd->cache_file = NULL;
mcmd->object_path[0] = '\0';
mcmd->read_flag = MOD_MESHSEQ_READ_ALL;
+
+ mcmd->reader = NULL;
+ mcmd->reader_object_path[0] = '\0';
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
@@ -59,6 +67,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
modifier_copyData_generic(md, target, flag);
tmcmd->reader = NULL;
+ tmcmd->reader_object_path[0] = '\0';
}
static void freeData(ModifierData *md)
@@ -66,10 +75,8 @@ static void freeData(ModifierData *md)
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
if (mcmd->reader) {
-#ifdef WITH_ALEMBIC
- CacheReader_free(mcmd->reader);
-#endif
- mcmd->reader = NULL;
+ mcmd->reader_object_path[0] = '\0';
+ BKE_cachefile_reader_free(mcmd->cache_file, &mcmd->reader);
}
}
@@ -93,17 +100,14 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
Mesh *org_mesh = mesh;
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
+ CacheFile *cache_file = mcmd->cache_file;
const float frame = DEG_get_ctime(ctx->depsgraph);
- const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
+ const float time = BKE_cachefile_time_offset(cache_file, frame, FPS);
const char *err_str = NULL;
- CacheFile *cache_file = (CacheFile *)DEG_get_original_id(&mcmd->cache_file->id);
-
- BKE_cachefile_ensure_handle(G.main, cache_file);
-
- if (!mcmd->reader) {
- mcmd->reader = CacheReader_open_alembic_object(
- cache_file->handle, NULL, ctx->object, mcmd->object_path);
+ if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) {
+ STRNCPY(mcmd->reader_object_path, mcmd->object_path);
+ BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path);
if (!mcmd->reader) {
modifier_setError(md, "Could not create Alembic reader for file %s", cache_file->filepath);
return mesh;
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 39b86ca48fd..ba1681b3ac3 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -283,12 +283,13 @@ static Mesh *doMirrorOnAxis(MirrorModifierData *mmd,
CustomData_copy_data(
&result->ldata, &result->ldata, mp->loopstart, mp->loopstart + maxLoops, 1);
- for (j = 1; j < mp->totloop; j++)
+ for (j = 1; j < mp->totloop; j++) {
CustomData_copy_data(&result->ldata,
&result->ldata,
mp->loopstart + j,
mp->loopstart + maxLoops + mp->totloop - j,
1);
+ }
ml2 = ml + mp->loopstart + maxLoops;
e = ml2[0].e;
@@ -321,10 +322,12 @@ static Mesh *doMirrorOnAxis(MirrorModifierData *mmd,
int j = maxLoops;
dmloopuv += j; /* second set of loops only */
for (; j-- > 0; dmloopuv++) {
- if (do_mirr_u)
+ if (do_mirr_u) {
dmloopuv->uv[0] = 1.0f - dmloopuv->uv[0] + mmd->uv_offset[0];
- if (do_mirr_v)
+ }
+ if (do_mirr_v) {
dmloopuv->uv[1] = 1.0f - dmloopuv->uv[1] + mmd->uv_offset[1];
+ }
dmloopuv->uv[0] += mmd->uv_offset_copy[0];
dmloopuv->uv[1] += mmd->uv_offset_copy[1];
}
@@ -342,10 +345,12 @@ static Mesh *doMirrorOnAxis(MirrorModifierData *mmd,
if (flip_map) {
for (i = 0; i < maxVerts; dvert++, i++) {
/* merged vertices get both groups, others get flipped */
- if (do_vtargetmap && (vtargetmap[i] != -1))
+ if (do_vtargetmap && (vtargetmap[i] != -1)) {
defvert_flip_merged(dvert, flip_map, flip_map_len);
- else
+ }
+ else {
defvert_flip(dvert, flip_map, flip_map_len);
+ }
}
MEM_freeN(flip_map);
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 0c5b260eadc..10852ed6148 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -62,13 +62,15 @@ static void generate_vert_coordinates(Mesh *mesh,
}
}
- /* Get size (i.e. deformation of the spheroid generating normals), either from target object, or own geometry. */
+ /* Get size (i.e. deformation of the spheroid generating normals),
+ * either from target object, or own geometry. */
if (r_size != NULL) {
if (ob_center != NULL) {
/* Using 'scale' as 'size' here. The input object is typically an empty
* who's scale is used to define an ellipsoid instead of a simple sphere. */
- /* Not we are not interested in signs here - they are even troublesome actually, due to security clamping! */
+ /* Not we are not interested in signs here - they are even troublesome actually,
+ * due to security clamping! */
abs_v3_v3(r_size, ob_center->scale);
}
else {
@@ -247,7 +249,8 @@ static void normalEditModifier_do_radial(NormalEditModifierData *enmd,
* Then, we want to find out for each vert its (a, b, c) triple (proportional to (A, B, C) one).
*
* Ellipsoid basic equation: ``(x^2/a^2) + (y^2/b^2) + (z^2/c^2) = 1.``
- * Since we want to find (a, b, c) matching this equation and proportional to (A, B, C), we can do:
+ * Since we want to find (a, b, c) matching this equation and proportional to (A, B, C),
+ * we can do:
* <pre>
* m = B / A
* n = C / A
@@ -480,145 +483,149 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
return mesh;
}
- /* XXX TODO ARG GRRR XYQWNMPRXTYY
- * Once we fully switch to Mesh evaluation of modifiers, we can expect to get that flag from the COW copy.
- * But for now, it is lost in the DM intermediate step, so we need to directly check orig object's data. */
+ /* XXX TODO(Rohan Rathi):
+ * Once we fully switch to Mesh evaluation of modifiers,
+ * we can expect to get that flag from the COW copy.
+ * But for now, it is lost in the DM intermediate step,
+ * so we need to directly check orig object's data. */
#if 0
- if (!(mesh->flag & ME_AUTOSMOOTH)) {
+ if (!(mesh->flag & ME_AUTOSMOOTH))
#else
- if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH)) {
+ if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH))
#endif
- modifier_setError((ModifierData *)enmd, "Enable 'Auto Smooth' option in mesh settings");
- return mesh;
-}
+ {
+ modifier_setError((ModifierData *)enmd, "Enable 'Auto Smooth' option in mesh settings");
+ return mesh;
+ }
-Mesh *result;
-if (mesh->medge == ((Mesh *)ob->data)->medge) {
- /* We need to duplicate data here, otherwise setting custom normals (which may also affect sharp edges) could
+ Mesh *result;
+ if (mesh->medge == ((Mesh *)ob->data)->medge) {
+ /* We need to duplicate data here, otherwise setting custom normals
+ * (which may also affect sharp edges) could
* modify org mesh, see T43671. */
- BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
-}
-else {
- result = mesh;
-}
+ BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
+ }
+ else {
+ result = mesh;
+ }
-const int num_verts = result->totvert;
-const int num_edges = result->totedge;
-const int num_loops = result->totloop;
-const int num_polys = result->totpoly;
-MVert *mvert = result->mvert;
-MEdge *medge = result->medge;
-MLoop *mloop = result->mloop;
-MPoly *mpoly = result->mpoly;
+ const int num_verts = result->totvert;
+ const int num_edges = result->totedge;
+ const int num_loops = result->totloop;
+ const int num_polys = result->totpoly;
+ MVert *mvert = result->mvert;
+ MEdge *medge = result->medge;
+ MLoop *mloop = result->mloop;
+ MPoly *mpoly = result->mpoly;
-int defgrp_index;
-MDeformVert *dvert;
+ int defgrp_index;
+ MDeformVert *dvert;
-float (*loopnors)[3] = NULL;
-short (*clnors)[2] = NULL;
+ float(*loopnors)[3] = NULL;
+ short(*clnors)[2] = NULL;
-float (*polynors)[3];
+ float(*polynors)[3];
-CustomData *ldata = &result->ldata;
-if (CustomData_has_layer(ldata, CD_NORMAL)) {
- loopnors = CustomData_get_layer(ldata, CD_NORMAL);
-}
-else {
- loopnors = CustomData_add_layer(ldata, CD_NORMAL, CD_CALLOC, NULL, num_loops);
-}
+ CustomData *ldata = &result->ldata;
+ if (CustomData_has_layer(ldata, CD_NORMAL)) {
+ loopnors = CustomData_get_layer(ldata, CD_NORMAL);
+ }
+ else {
+ loopnors = CustomData_add_layer(ldata, CD_NORMAL, CD_CALLOC, NULL, num_loops);
+ }
-/* Compute poly (always needed) and vert normals. */
-CustomData *pdata = &result->pdata;
-polynors = CustomData_get_layer(pdata, CD_NORMAL);
-if (!polynors) {
- polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, num_polys);
-}
-BKE_mesh_calc_normals_poly(mvert,
- NULL,
- num_verts,
- mloop,
- mpoly,
- num_loops,
- num_polys,
- polynors,
- (result->runtime.cd_dirty_vert & CD_MASK_NORMAL) ? false : true);
-
-result->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
-
-if (use_current_clnors) {
- clnors = CustomData_duplicate_referenced_layer(ldata, CD_CUSTOMLOOPNORMAL, num_loops);
-
- BKE_mesh_normals_loop_split(mvert,
- num_verts,
- medge,
- num_edges,
- mloop,
- loopnors,
- num_loops,
- mpoly,
- (const float(*)[3])polynors,
- num_polys,
- true,
- result->smoothresh,
- NULL,
- clnors,
- NULL);
-}
+ /* Compute poly (always needed) and vert normals. */
+ CustomData *pdata = &result->pdata;
+ polynors = CustomData_get_layer(pdata, CD_NORMAL);
+ if (!polynors) {
+ polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, num_polys);
+ }
+ BKE_mesh_calc_normals_poly(mvert,
+ NULL,
+ num_verts,
+ mloop,
+ mpoly,
+ num_loops,
+ num_polys,
+ polynors,
+ (result->runtime.cd_dirty_vert & CD_MASK_NORMAL) ? false : true);
+
+ result->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
+
+ if (use_current_clnors) {
+ clnors = CustomData_duplicate_referenced_layer(ldata, CD_CUSTOMLOOPNORMAL, num_loops);
+
+ BKE_mesh_normals_loop_split(mvert,
+ num_verts,
+ medge,
+ num_edges,
+ mloop,
+ loopnors,
+ num_loops,
+ mpoly,
+ (const float(*)[3])polynors,
+ num_polys,
+ true,
+ result->smoothresh,
+ NULL,
+ clnors,
+ NULL);
+ }
-if (!clnors) {
- clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, num_loops);
-}
+ if (!clnors) {
+ clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, num_loops);
+ }
-MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index);
-
-if (enmd->mode == MOD_NORMALEDIT_MODE_RADIAL) {
- normalEditModifier_do_radial(enmd,
- ctx,
- ob,
- result,
- clnors,
- loopnors,
- polynors,
- enmd->mix_mode,
- enmd->mix_factor,
- enmd->mix_limit,
- dvert,
- defgrp_index,
- use_invert_vgroup,
- mvert,
- num_verts,
- medge,
- num_edges,
- mloop,
- num_loops,
- mpoly,
- num_polys);
-}
-else if (enmd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) {
- normalEditModifier_do_directional(enmd,
- ctx,
- ob,
- result,
- clnors,
- loopnors,
- polynors,
- enmd->mix_mode,
- enmd->mix_factor,
- enmd->mix_limit,
- dvert,
- defgrp_index,
- use_invert_vgroup,
- mvert,
- num_verts,
- medge,
- num_edges,
- mloop,
- num_loops,
- mpoly,
- num_polys);
-}
+ MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index);
+
+ if (enmd->mode == MOD_NORMALEDIT_MODE_RADIAL) {
+ normalEditModifier_do_radial(enmd,
+ ctx,
+ ob,
+ result,
+ clnors,
+ loopnors,
+ polynors,
+ enmd->mix_mode,
+ enmd->mix_factor,
+ enmd->mix_limit,
+ dvert,
+ defgrp_index,
+ use_invert_vgroup,
+ mvert,
+ num_verts,
+ medge,
+ num_edges,
+ mloop,
+ num_loops,
+ mpoly,
+ num_polys);
+ }
+ else if (enmd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) {
+ normalEditModifier_do_directional(enmd,
+ ctx,
+ ob,
+ result,
+ clnors,
+ loopnors,
+ polynors,
+ enmd->mix_mode,
+ enmd->mix_factor,
+ enmd->mix_limit,
+ dvert,
+ defgrp_index,
+ use_invert_vgroup,
+ mvert,
+ num_verts,
+ medge,
+ num_edges,
+ mloop,
+ num_loops,
+ mpoly,
+ num_polys);
+ }
-return result;
+ return result;
}
static void initData(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 983ea7b4309..cd0046b8a31 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -132,7 +132,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
{
#ifdef WITH_OCEANSIM
# if 0
- const OceanModifierData *omd = (const OceanModifierData *) md;
+ const OceanModifierData *omd = (const OceanModifierData *)md;
# endif
OceanModifierData *tomd = (OceanModifierData *)target;
@@ -434,7 +434,8 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
/* displace the geometry */
- /* Note: tried to parallelized that one and previous foam loop, but gives 20% slower results... odd. */
+ /* Note: tried to parallelized that one and previous foam loop,
+ * but gives 20% slower results... odd. */
{
const int num_verts = result->totvert;
@@ -481,8 +482,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
result = doOcean(md, ctx, mesh);
- if (result != mesh)
+ if (result != mesh) {
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
+ }
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index 718c1e6a038..71913378277 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -80,12 +80,14 @@ static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRend
ParticleSystem *psys;
ModifierData *ob_md;
- if (!pimd->ob)
+ if (!pimd->ob) {
return true;
+ }
psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1);
- if (psys == NULL)
+ if (psys == NULL) {
return true;
+ }
/* If the psys modifier is disabled we cannot use its data.
* First look up the psys modifier from the object, then check if it is enabled.
@@ -96,13 +98,16 @@ static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRend
if (psmd->psys == psys) {
int required_mode;
- if (useRenderParams)
+ if (useRenderParams) {
required_mode = eModifierMode_Render;
- else
+ }
+ else {
required_mode = eModifierMode_Realtime;
+ }
- if (!modifier_isEnabled(scene, ob_md, required_mode))
+ if (!modifier_isEnabled(scene, ob_md, required_mode)) {
return true;
+ }
break;
}
@@ -145,12 +150,15 @@ static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *ps
}
if (pa) {
- if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0)
+ if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) {
return true;
- if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0)
+ }
+ if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) {
return true;
- if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0)
+ }
+ if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) {
return true;
+ }
}
if (pimd->particle_amount == 1.0f) {
@@ -219,8 +227,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
if (pimd->ob) {
psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1);
- if (psys == NULL || psys->totpart == 0)
+ if (psys == NULL || psys->totpart == 0) {
return mesh;
+ }
}
else {
return mesh;
@@ -229,13 +238,16 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
part_start = use_parents ? 0 : psys->totpart;
part_end = 0;
- if (use_parents)
+ if (use_parents) {
part_end += psys->totpart;
- if (use_children)
+ }
+ if (use_children) {
part_end += psys->totchild;
+ }
- if (part_end == 0)
+ if (part_end == 0) {
return mesh;
+ }
sim.depsgraph = ctx->depsgraph;
sim.scene = scene;
@@ -249,8 +261,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
si = size = MEM_calloc_arrayN(part_end, sizeof(float), "particle size array");
if (pimd->flag & eParticleInstanceFlag_Parents) {
- for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++, si++)
+ for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++, si++) {
*si = pa->size;
+ }
}
if (pimd->flag & eParticleInstanceFlag_Children) {
@@ -289,8 +302,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
maxedge = 0;
for (p = part_start; p < part_end; p++) {
- if (particle_skip(pimd, psys, p))
+ if (particle_skip(pimd, psys, p)) {
continue;
+ }
maxvert += totvert;
maxpoly += totpoly;
@@ -336,8 +350,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
float p_random = psys_frand(psys, 77091 + 283 * p);
/* skip particle? */
- if (particle_skip(pimd, psys, p))
+ if (particle_skip(pimd, psys, p)) {
continue;
+ }
/* set vertices coordinates */
for (k = 0; k < totvert; k++) {
@@ -377,8 +392,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
else {
state.time = (mv->co[axis] - min_co) / (max_co - min_co) * pimd->position * (1.0f - ran);
- if (trackneg)
+ if (trackneg) {
state.time = 1.0f - state.time;
+ }
mv->co[axis] = 0.0;
}
@@ -392,8 +408,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
float hairmat[4][4];
float mat[3][3];
- if (p < psys->totpart)
+ if (p < psys->totpart) {
pa = psys->particles + p;
+ }
else {
ChildParticle *cpa = psys->child + (p - psys->totpart);
pa = psys->particles + (between ? cpa->pa[0] : cpa->parent);
@@ -454,8 +471,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
mul_qt_v3(state.rot, mv->co);
- if (pimd->flag & eParticleInstanceFlag_UseSize)
+ if (pimd->flag & eParticleInstanceFlag_UseSize) {
mul_v3_fl(mv->co, size[p]);
+ }
add_v3_v3(mv->co, state.co);
mul_m4_v3(spacemat, mv->co);
@@ -509,8 +527,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
psys->lattice_deform_data = NULL;
}
- if (size)
+ if (size) {
MEM_freeN(size);
+ }
MEM_SAFE_FREE(vert_part_index);
MEM_SAFE_FREE(vert_part_value);
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 547e5facbbe..5d7b380a751 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -62,14 +62,15 @@ static void freeData(ModifierData *md)
/* ED_object_modifier_remove may have freed this first before calling
* modifier_free (which calls this function) */
- if (psmd->psys)
+ if (psmd->psys) {
psmd->psys->flag |= PSYS_DELETE;
+ }
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#if 0
- const ParticleSystemModifierData *psmd = (const ParticleSystemModifierData *) md;
+ const ParticleSystemModifierData *psmd = (const ParticleSystemModifierData *)md;
#endif
ParticleSystemModifierData *tpsmd = (ParticleSystemModifierData *)target;
@@ -101,13 +102,16 @@ static void deformVerts(ModifierData *md,
ParticleSystem *psys = NULL;
/* float cfra = BKE_scene_frame_get(md->scene); */ /* UNUSED */
- if (ctx->object->particlesystem.first)
+ if (ctx->object->particlesystem.first) {
psys = psmd->psys;
- else
+ }
+ else {
return;
+ }
- if (!psys_check_enabled(ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0))
+ if (!psys_check_enabled(ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0)) {
return;
+ }
if (mesh_src == NULL) {
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, vertexCos, numVerts, false, true);
@@ -214,9 +218,12 @@ static void deformVerts(ModifierData *md,
/* disabled particles in editmode for now, until support for proper evaluated mesh
* updates is coded */
#if 0
-static void deformVertsEM(
- ModifierData *md, Object *ob, BMEditMesh *editData,
- Mesh *mesh, float (*vertexCos)[3], int numVerts)
+static void deformVertsEM(ModifierData *md,
+ Object *ob,
+ BMEditMesh *editData,
+ Mesh *mesh,
+ float (*vertexCos)[3],
+ int numVerts)
{
const bool do_temp_mesh = (mesh == NULL);
if (do_temp_mesh) {
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index e2917e2f82a..dd894e86dcc 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -250,8 +250,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const char mpoly_flag = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) ? ME_SMOOTH : 0;
/* don't do anything? */
- if (!totvert)
+ if (!totvert) {
return BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0, 0);
+ }
switch (ltmd->axis) {
case 0:
@@ -316,7 +317,6 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
cross_v3_v3v3(c1, cross2, axis_vec);
cross_v3_v3v3(c2, axis_vec, c1);
-
angle = angle_v3v3(cross1, c2);
cross_v3_v3v3(axis_tmp, cross1, c2);
@@ -324,7 +324,6 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
if (len_v3v3(axis_tmp, axis_vec) > 1.0f)
angle = -angle;
-
}
}
#endif
@@ -346,14 +345,16 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* multiplying the steps is a bit tricky, this works best */
step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1);
- /* will the screw be closed?
- * Note! smaller then FLT_EPSILON * 100 gives problems with float precision so its never closed. */
+ /* Will the screw be closed?
+ * Note! smaller then `FLT_EPSILON * 100`
+ * gives problems with float precision so its never closed. */
if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) &&
fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f)) {
close = 1;
step_tot--;
- if (step_tot < 3)
+ if (step_tot < 3) {
step_tot = 3;
+ }
maxVerts = totvert * step_tot; /* -1 because we're joining back up */
maxEdges = (totvert * step_tot) + /* these are the edges between new verts */
@@ -364,8 +365,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
else {
close = 0;
- if (step_tot < 3)
+ if (step_tot < 3) {
step_tot = 3;
+ }
maxVerts = totvert * step_tot; /* -1 because we're joining back up */
maxEdges = (totvert * (step_tot - 1)) + /* these are the edges between new verts */
@@ -492,7 +494,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
*/
vert_connect = MEM_malloc_arrayN(totvert, sizeof(ScrewVertConnect), "ScrewVertConnect");
- //vert_connect = (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */
+ /* skip the first slice of verts. */
+ // vert_connect = (ScrewVertConnect *) &medge_new[totvert];
vc = vert_connect;
/* Copy Vert Locations */
@@ -604,7 +607,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/*printf("\t\tVERT: %i\n", lt_iter.v);*/
if (lt_iter.v_poin->flag) {
/*printf("\t\t\tBreaking Found end\n");*/
- //endpoints[0] = endpoints[1] = SV_UNUSED;
+ // endpoints[0] = endpoints[1] = SV_UNUSED;
ed_loop_closed = 1; /* circle */
break;
}
@@ -692,8 +695,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
ed_loop_flip = !ed_loop_flip;
#endif
- if (angle < 0.0f)
+ if (angle < 0.0f) {
ed_loop_flip = !ed_loop_flip;
+ }
/* if its closed, we only need 1 loop */
for (j = ed_loop_closed; j < 2; j++) {
@@ -706,8 +710,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* If this is the vert off the best vert and
* the best vert has 2 edges connected too it
* then swap the flip direction */
- if (j == 1 && SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1]))
+ if (j == 1 && SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1])) {
ed_loop_flip = !ed_loop_flip;
+ }
while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) {
/*printf("\tOrdering Vert V %i\n", lt_iter.v);*/
@@ -719,26 +724,34 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/*printf("\t\t\tFlipping 0\n");*/
SWAP(unsigned int, lt_iter.e->v1, lt_iter.e->v2);
}
- /* else {
- printf("\t\t\tFlipping Not 0\n");
- }*/
+#if 0
+ else {
+ printf("\t\t\tFlipping Not 0\n");
+ }
+#endif
}
else if (lt_iter.v == lt_iter.e->v2) {
if (ed_loop_flip == 1) {
/*printf("\t\t\tFlipping 1\n");*/
SWAP(unsigned int, lt_iter.e->v1, lt_iter.e->v2);
}
- /* else {
- printf("\t\t\tFlipping Not 1\n");
- }*/
+#if 0
+ else {
+ printf("\t\t\tFlipping Not 1\n");
+ }
+#endif
+ }
+#if 0
+ else {
+ printf("\t\tIncorrect edge topology");
}
- /* else {
- printf("\t\tIncorrect edge topology");
- }*/
+#endif
}
- /* else {
- printf("\t\tNo Edge at this point\n");
- }*/
+#if 0
+ else {
+ printf("\t\tNo Edge at this point\n");
+ }
+#endif
screwvert_iter_step(&lt_iter);
}
}
@@ -806,8 +819,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
/* we won't be looping on this data again so copy normals here */
- if ((angle < 0.0f) != do_flip)
+ if ((angle < 0.0f) != do_flip) {
negate_v3(vc->no);
+ }
normalize_v3(vc->no);
normal_float_to_short_v3(mvert_new[i].no, vc->no);
@@ -843,8 +857,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
copy_m4_m3(mat, mat3);
- if (screw_ofs)
+ if (screw_ofs) {
madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot - 1)));
+ }
/* copy a slice */
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, (int)varray_stride, (int)totvert);
@@ -1081,7 +1096,6 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
ii = findEd(medge_new, maxEdges, ml_new[3].v, ml_new[0].v);
printf("%d %d\n", ii, ml_new[3].e);
ml_new[3].e = ii;
-
}
}
#endif
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 5667a74bce6..69db6f5565d 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -64,13 +64,16 @@ static void deformMatrices(ModifierData *md,
if (kb && kb->totelem == numVerts && kb != key->refkey) {
int a;
- if (ctx->object->shapeflag & OB_SHAPE_LOCK)
+ if (ctx->object->shapeflag & OB_SHAPE_LOCK) {
scale_m3_fl(scale, 1);
- else
+ }
+ else {
scale_m3_fl(scale, kb->curval);
+ }
- for (a = 0; a < numVerts; a++)
+ for (a = 0; a < numVerts; a++) {
copy_m3_m3(defMats[a], scale);
+ }
}
deformVerts(md, ctx, mesh, vertexCos, numVerts);
@@ -85,8 +88,9 @@ static void deformVertsEM(ModifierData *md,
{
Key *key = BKE_key_from_object(ctx->object);
- if (key && key->type == KEY_RELATIVE)
+ if (key && key->type == KEY_RELATIVE) {
deformVerts(md, ctx, mesh, vertexCos, numVerts);
+ }
}
static void deformMatricesEM(ModifierData *UNUSED(md),
@@ -107,8 +111,9 @@ static void deformMatricesEM(ModifierData *UNUSED(md),
int a;
scale_m3_fl(scale, kb->curval);
- for (a = 0; a < numVerts; a++)
+ for (a = 0; a < numVerts; a++) {
copy_m3_m3(defMats[a], scale);
+ }
}
}
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 3b4d6251c0a..07182d82fdc 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -172,8 +172,9 @@ static bool dependsOnNormals(ModifierData *md)
{
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
- if (smd->target && smd->shrinkType == MOD_SHRINKWRAP_PROJECT)
+ if (smd->target && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) {
return (smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL);
+ }
return false;
}
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index 2434bd514f4..8d511207b9b 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -73,10 +73,12 @@ BLI_INLINE void copy_v3_v3_unmap(float a[3], const float b[3], const uint map[3]
static void axis_limit(const int axis, const float limits[2], float co[3], float dcut[3])
{
float val = co[axis];
- if (limits[0] > val)
+ if (limits[0] > val) {
val = limits[0];
- if (limits[1] < val)
+ }
+ if (limits[1] < val) {
val = limits[1];
+ }
dcut[axis] = co[axis] - val;
co[axis] = val;
@@ -228,13 +230,16 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd,
}
/* Safe-check */
- if (smd->origin == ob)
+ if (smd->origin == ob) {
smd->origin = NULL; /* No self references */
+ }
- if (smd->limit[0] < 0.0f)
+ if (smd->limit[0] < 0.0f) {
smd->limit[0] = 0.0f;
- if (smd->limit[0] > 1.0f)
+ }
+ if (smd->limit[0] > 1.0f) {
smd->limit[0] = 1.0f;
+ }
smd->limit[0] = min_ff(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index ffef1197491..a344141bf4a 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -148,14 +148,16 @@ static bool is_quad_symmetric(BMVert *quad[4], const SkinModifierData *smd)
if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) {
copy_v3_v3(a, quad[2]->co);
a[axis] = -a[axis];
- if (len_squared_v3v3(a, quad[3]->co) < threshold_squared)
+ if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) {
return 1;
+ }
}
else if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) {
copy_v3_v3(a, quad[2]->co);
a[axis] = -a[axis];
- if (len_squared_v3v3(a, quad[1]->co) < threshold_squared)
+ if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) {
return 1;
+ }
}
}
}
@@ -174,13 +176,16 @@ static bool quad_crosses_symmetry_plane(BMVert *quad[4], const SkinModifierData
int i;
for (i = 0; i < 4; i++) {
- if (quad[i]->co[axis] < 0.0f)
+ if (quad[i]->co[axis] < 0.0f) {
left = true;
- else if (quad[i]->co[axis] > 0.0f)
+ }
+ else if (quad[i]->co[axis] > 0.0f) {
right = true;
+ }
- if (left && right)
+ if (left && right) {
return true;
+ }
}
}
}
@@ -196,13 +201,16 @@ static bool skin_frame_find_contained_faces(const Frame *frame, BMFace *fill_fac
/* See if the frame is bisected by a diagonal edge */
diag = BM_edge_exists(frame->verts[0], frame->verts[2]);
- if (!diag)
+ if (!diag) {
diag = BM_edge_exists(frame->verts[1], frame->verts[3]);
+ }
- if (diag)
+ if (diag) {
return BM_edge_face_pair(diag, &fill_faces[0], &fill_faces[1]);
- else
+ }
+ else {
return false;
+ }
}
/* Returns true if hull is successfully built, false otherwise */
@@ -242,8 +250,9 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe)
/* Apply face attributes to hull output */
BMO_ITER (f, &oiter, op.slots_out, "geom.out", BM_FACE) {
BM_face_normal_update(f);
- if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING)
+ if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING) {
BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
+ }
f->mat_nr = so->mat_nr;
}
@@ -292,8 +301,9 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe)
BM_elem_flag_enable(fill_faces[0], BM_ELEM_TAG);
BM_elem_flag_enable(fill_faces[1], BM_ELEM_TAG);
}
- else
+ else {
frame->detached = true;
+ }
}
}
@@ -307,8 +317,9 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe)
break;
}
}
- if (is_wire)
+ if (is_wire) {
BM_elem_flag_enable(e, BM_ELEM_TAG);
+ }
}
BMO_op_finish(bm, &op);
@@ -341,8 +352,9 @@ static void merge_frame_corners(Frame **frames, int totframe)
for (j = 0; j < 4; j++) {
/* Ensure the merge target is not itself a merge target */
- if (frames[i]->merge[j].frame)
+ if (frames[i]->merge[j].frame) {
continue;
+ }
for (k = i + 1; k < totframe; k++) {
BLI_assert(frames[i] != frames[k]);
@@ -352,8 +364,9 @@ static void merge_frame_corners(Frame **frames, int totframe)
/* Compare with each corner of all other frames... */
for (l = 0; l < 4; l++) {
- if (frames[k]->merge[l].frame || frames[k]->merge[l].is_target)
+ if (frames[k]->merge[l].frame || frames[k]->merge[l].is_target) {
continue;
+ }
/* Some additional concerns that could be checked
* further:
@@ -406,10 +419,12 @@ static Frame **collect_hull_frames(
const MEdge *e = &medge[emap[v].indices[nbr]];
f = &frames[BKE_mesh_edge_other_vert(e, v)];
/* Can't have adjacent branch nodes yet */
- if (f->totframe)
+ if (f->totframe) {
hull_frames[i++] = &f->frames[0];
- else
+ }
+ else {
(*tothullframe)--;
+ }
}
return hull_frames;
@@ -425,8 +440,9 @@ static void node_frames_init(SkinNode *nf, int totframe)
memset(nf->frames, 0, sizeof(nf->frames));
nf->flag = 0;
- for (i = 0; i < 2; i++)
+ for (i = 0; i < 2; i++) {
nf->seam_edges[i] = -1;
+ }
}
static void create_frame(
@@ -451,8 +467,9 @@ static void create_frame(
sub_v3_v3v3(frame->co[0], frame->co[0], rz);
mul_v3_v3fl(rx, mat[0], offset);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
add_v3_v3v3(frame->co[i], frame->co[i], rx);
+ }
}
static float half_v2(const float v[2])
@@ -492,15 +509,17 @@ static void end_node_frames(int v,
/* Use incoming edge for orientation */
copy_m3_m3(mat, emat[emap[v].indices[0]].mat);
- if (emat[emap[v].indices[0]].origin != v)
+ if (emat[emap[v].indices[0]].origin != v) {
negate_v3(mat[0]);
+ }
/* End frame */
create_frame(&skin_nodes[v].frames[0], mvert[v].co, rad, mat, 0);
}
- if (nodes[v].flag & MVERT_SKIN_ROOT)
+ if (nodes[v].flag & MVERT_SKIN_ROOT) {
skin_nodes[v].flag |= ROOT;
+ }
}
/* Returns 1 for seam, 0 otherwise */
@@ -520,8 +539,9 @@ static int connection_node_mat(float mat[3][3], int v, const MeshElemMap *emap,
copy_m3_m3(ine, e2->mat);
copy_m3_m3(oute, e1->mat);
}
- else
+ else {
return 1;
+ }
/* Get axis and angle to rotate frame by */
angle = angle_normalized_v3v3(ine[0], oute[0]) / 2.0f;
@@ -560,14 +580,16 @@ static void connection_node_frames(int v,
skin_nodes[v].flag |= SEAM_FRAME;
copy_m3_m3(mat, e1->mat);
- if (e1->origin != v)
+ if (e1->origin != v) {
negate_v3(mat[0]);
+ }
create_frame(&skin_nodes[v].frames[0], mvert[v].co, rad, mat, avg);
skin_nodes[v].seam_edges[0] = emap[v].indices[0];
copy_m3_m3(mat, e2->mat);
- if (e2->origin != v)
+ if (e2->origin != v) {
negate_v3(mat[0]);
+ }
create_frame(&skin_nodes[v].frames[1], mvert[v].co, rad, mat, avg);
skin_nodes[v].seam_edges[1] = emap[v].indices[1];
@@ -588,10 +610,12 @@ static SkinNode *build_frames(
skin_nodes = MEM_calloc_arrayN(totvert, sizeof(SkinNode), "build_frames.skin_nodes");
for (v = 0; v < totvert; v++) {
- if (emap[v].count <= 1)
+ if (emap[v].count <= 1) {
end_node_frames(v, skin_nodes, mvert, nodes, emap, emat);
- else if (emap[v].count == 2)
+ }
+ else if (emap[v].count == 2) {
connection_node_frames(v, skin_nodes, mvert, nodes, emap, emat);
+ }
else {
/* Branch node generates no frames */
}
@@ -654,8 +678,9 @@ static void build_emats_stack(BLI_Stack *stack,
e = stack_elem.e;
/* Skip if edge already visited */
- if (BLI_BITMAP_TEST(visited_e, e))
+ if (BLI_BITMAP_TEST(visited_e, e)) {
return;
+ }
/* Mark edge as visited */
BLI_BITMAP_ENABLE(visited_e, e);
@@ -766,10 +791,12 @@ static int calc_edge_subdivisions(const MVert *mvert,
* the edge (or subdivide just twice if both are branches) */
if ((v1_branch && (evs[0]->flag & MVERT_SKIN_LOOSE)) ||
(v2_branch && (evs[1]->flag & MVERT_SKIN_LOOSE))) {
- if (v1_branch && v2_branch)
+ if (v1_branch && v2_branch) {
return 2;
- else
+ }
+ else {
return 0;
+ }
}
avg_radius = half_v2(evs[0]->radius) + half_v2(evs[1]->radius);
@@ -792,8 +819,9 @@ static int calc_edge_subdivisions(const MVert *mvert,
/* If both ends are branch nodes, two intermediate nodes are
* required */
- if (num_subdivisions < 2 && v1_branch && v2_branch)
+ if (num_subdivisions < 2 && v1_branch && v2_branch) {
num_subdivisions = 2;
+ }
return num_subdivisions;
@@ -907,8 +935,9 @@ static Mesh *subdivide_base(Mesh *orig)
vg = &vgroups[k];
weight = interpf(vg->w2, vg->w1, t);
- if (weight > 0)
+ if (weight > 0) {
defvert_add_index_notest(&outdvert[v], vg->def_nr, weight);
+ }
}
outedge->v1 = u;
@@ -916,8 +945,9 @@ static Mesh *subdivide_base(Mesh *orig)
u = v;
}
- if (vgroups)
+ if (vgroups) {
MEM_freeN(vgroups);
+ }
/* Link up to final vertex */
outedge->v1 = u;
@@ -945,17 +975,20 @@ static void add_poly(SkinOutput *so, BMVert *v1, BMVert *v2, BMVert *v3, BMVert
f = BM_face_create_verts(so->bm, verts, v4 ? 4 : 3, NULL, BM_CREATE_NO_DOUBLE, true);
BM_face_normal_update(f);
- if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING)
+ if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING) {
BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
+ }
f->mat_nr = so->mat_nr;
}
static void connect_frames(SkinOutput *so, BMVert *frame1[4], BMVert *frame2[4])
{
- BMVert *q[4][4] = {{frame2[0], frame2[1], frame1[1], frame1[0]},
- {frame2[1], frame2[2], frame1[2], frame1[1]},
- {frame2[2], frame2[3], frame1[3], frame1[2]},
- {frame2[3], frame2[0], frame1[0], frame1[3]}};
+ BMVert *q[4][4] = {
+ {frame2[0], frame2[1], frame1[1], frame1[0]},
+ {frame2[1], frame2[2], frame1[2], frame1[1]},
+ {frame2[2], frame2[3], frame1[3], frame1[2]},
+ {frame2[3], frame2[0], frame1[0], frame1[3]},
+ };
int i;
bool swap;
@@ -965,9 +998,7 @@ static void connect_frames(SkinOutput *so, BMVert *frame1[4], BMVert *frame2[4])
/* simple method, works mostly */
float p[3], no[3];
sub_v3_v3v3(p, q[3][0]->co, q[0][0]->co);
- normal_quad_v3(no,
- q[0][0]->co, q[0][1]->co,
- q[0][2]->co, q[0][3]->co);
+ normal_quad_v3(no, q[0][0]->co, q[0][1]->co, q[0][2]->co, q[0][3]->co);
swap = dot_v3v3(no, p) > 0;
}
#else
@@ -994,10 +1025,12 @@ static void connect_frames(SkinOutput *so, BMVert *frame1[4], BMVert *frame2[4])
#endif
for (i = 0; i < 4; i++) {
- if (swap)
+ if (swap) {
add_poly(so, q[i][3], q[i][2], q[i][1], q[i][0]);
- else
+ }
+ else {
add_poly(so, q[i][0], q[i][1], q[i][2], q[i][3]);
+ }
}
}
@@ -1048,8 +1081,9 @@ static int isect_ray_poly(const float ray_start[3],
bool hit = false;
BM_ITER_ELEM (v, &iter, f, BM_VERTS_OF_FACE) {
- if (!v_first)
+ if (!v_first) {
v_first = v;
+ }
else if (v_prev != v_first) {
float dist;
bool curhit;
@@ -1079,8 +1113,9 @@ static BMFace *collapse_face_corners(BMesh *bm, BMFace *f, int n, BMVert **orig_
BLI_assert(n >= 3);
BLI_assert(f->len > n);
- if (f->len <= n)
+ if (f->len <= n) {
return f;
+ }
/* Collapse shortest edge for now */
while (f->len > n) {
@@ -1176,10 +1211,11 @@ static BMFace *skin_hole_target_face(BMesh *bm, Frame *frame)
}
f = isect_target_face;
- if (!f || best_center_dist < best_isect_dist / 2)
+ if (!f || best_center_dist < best_isect_dist / 2) {
f = center_target_face;
+ }
- /* This case is unlikely now, but could still happen. Should look
+ /* This case is unlikely now, but could still happen. Should look
* into splitting edges to make new faces. */
#if PRINT_HOLE_INFO
if (!f) {
@@ -1210,8 +1246,9 @@ static void skin_choose_quad_bridge_order(BMVert *a[4], BMVert *b[4], int best_o
float len = 0;
/* Get total edge length for this configuration */
- for (j = 0; j < 4; j++)
+ for (j = 0; j < 4; j++) {
len += len_squared_v3v3(a[j]->co, b[orders[i][j]]->co);
+ }
if (len < shortest_len) {
shortest_len = len;
@@ -1288,8 +1325,9 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f
/* Done with dynamic array, split_face must now be a quad */
BLI_array_free(vert_buf);
BLI_assert(split_face->len == 4);
- if (split_face->len != 4)
+ if (split_face->len != 4) {
return;
+ }
/* Get split face's verts */
// BM_iter_as_array(bm, BM_VERTS_OF_FACE, split_face, (void **)verts, 4);
@@ -1316,8 +1354,9 @@ static void skin_hole_detach_partially_attached_frame(BMesh *bm, Frame *frame)
/* Get/count attached frame corners */
for (i = 0; i < 4; i++) {
- if (!frame->inside_hull[i])
+ if (!frame->inside_hull[i]) {
attached[totattached++] = i;
+ }
}
/* Detach everything */
@@ -1409,10 +1448,12 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd)
if (quad_crosses_symmetry_plane(quad, smd)) {
/* Increase score if the triangles form a
* symmetric quad, otherwise don't use it */
- if (is_quad_symmetric(quad, smd))
+ if (is_quad_symmetric(quad, smd)) {
score *= 10;
- else
+ }
+ else {
continue;
+ }
}
/* Don't use the quad if it's concave */
@@ -1506,8 +1547,9 @@ static void skin_fix_hull_topology(BMesh *bm, SkinNode *skin_nodes, int totvert)
skin_hole_detach_partially_attached_frame(bm, f);
target_face = skin_hole_target_face(bm, f);
- if (target_face)
+ if (target_face) {
skin_fix_hole_no_good_verts(bm, f, target_face);
+ }
}
}
}
@@ -1525,8 +1567,9 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, int totv
int i, order[4];
skin_choose_quad_bridge_order(sn->frames[0].verts, sn->frames[1].verts, order);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
v_order[i] = sn->frames[1].verts[order[i]];
+ }
connect_frames(so, sn->frames[0].verts, v_order);
}
else if (sn->totframe == 2) {
@@ -1577,14 +1620,17 @@ static void skin_output_connections(SkinOutput *so,
BMVert *v_order[4];
int i, order[4];
- if ((a->flag & SEAM_FRAME) && (e != a->seam_edges[0]))
+ if ((a->flag & SEAM_FRAME) && (e != a->seam_edges[0])) {
fr[0]++;
- if ((b->flag & SEAM_FRAME) && (e != b->seam_edges[0]))
+ }
+ if ((b->flag & SEAM_FRAME) && (e != b->seam_edges[0])) {
fr[1]++;
+ }
skin_choose_quad_bridge_order(fr[0]->verts, fr[1]->verts, order);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
v_order[i] = fr[1]->verts[order[i]];
+ }
connect_frames(so, fr[0]->verts, v_order);
}
else {
@@ -1603,8 +1649,9 @@ static void skin_smooth_hulls(BMesh *bm,
BMVert *v;
int i, j, k, skey;
- if (smd->branch_smoothing == 0)
+ if (smd->branch_smoothing == 0) {
return;
+ }
/* Mark all frame vertices */
BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
@@ -1612,8 +1659,9 @@ static void skin_smooth_hulls(BMesh *bm,
for (j = 0; j < skin_nodes[i].totframe; j++) {
Frame *frame = &skin_nodes[i].frames[j];
- for (k = 0; k < 4; k++)
+ for (k = 0; k < 4; k++) {
BM_elem_flag_enable(frame->verts[k], BM_ELEM_TAG);
+ }
}
}
@@ -1633,8 +1681,9 @@ static void skin_smooth_hulls(BMesh *bm,
float weight = smd->branch_smoothing;
int totv = 1;
- if (BM_elem_flag_test(v, BM_ELEM_TAG))
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
weight *= 0.5f;
+ }
copy_v3_v3(avg, v->co);
BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
@@ -1670,8 +1719,9 @@ static bool skin_output_branch_hulls(
int tothullframe;
hull_frames = collect_hull_frames(v, skin_nodes, emap, medge, &tothullframe);
- if (!build_hull(so, hull_frames, tothullframe))
+ if (!build_hull(so, hull_frames, tothullframe)) {
result = false;
+ }
MEM_freeN(hull_frames);
}
@@ -1703,8 +1753,9 @@ static BMesh *build_skin(SkinNode *skin_nodes,
BMO_push(so.bm, NULL);
bmesh_edit_begin(so.bm, 0);
- if (input_dvert)
+ if (input_dvert) {
BM_data_layer_add(so.bm, &so.bm->vdata, CD_MDEFORMVERT);
+ }
/* Check for mergeable frame corners around hulls before
* outputting vertices */
@@ -1712,15 +1763,17 @@ static BMesh *build_skin(SkinNode *skin_nodes,
/* Write out all frame vertices to the mesh */
for (v = 0; v < totvert; ++v) {
- if (skin_nodes[v].totframe)
+ if (skin_nodes[v].totframe) {
output_frames(so.bm, &skin_nodes[v], input_dvert ? &input_dvert[v] : NULL);
+ }
}
/* Update vertex pointers for merged frame corners */
skin_update_merged_vertices(skin_nodes, totvert);
- if (!skin_output_branch_hulls(&so, skin_nodes, totvert, emap, medge))
+ if (!skin_output_branch_hulls(&so, skin_nodes, totvert, emap, medge)) {
modifier_setError(&smd->modifier, "Hull error");
+ }
/* Merge triangles here in the hope of providing better target
* faces for skin_fix_hull_topology() to connect to */
@@ -1807,8 +1860,9 @@ static Mesh *base_skin(Mesh *origmesh, SkinModifierData *smd)
"No valid root vertex found (you need one per mesh island you want to skin)");
}
- if (!bm)
+ if (!bm) {
return NULL;
+ }
result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
@@ -1825,8 +1879,9 @@ static Mesh *final_skin(SkinModifierData *smd, Mesh *mesh)
Mesh *result;
/* Skin node layer is required */
- if (!CustomData_get_layer(&mesh->vdata, CD_MVERT_SKIN))
+ if (!CustomData_get_layer(&mesh->vdata, CD_MVERT_SKIN)) {
return mesh;
+ }
mesh = subdivide_base(mesh);
result = base_skin(mesh, smd);
@@ -1853,8 +1908,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *UNUSED(c
{
Mesh *result;
- if (!(result = final_skin((SkinModifierData *)md, mesh)))
+ if (!(result = final_skin((SkinModifierData *)md, mesh))) {
return mesh;
+ }
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index 60d4c1a01c3..34275d91ee6 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -83,11 +83,13 @@ static void requiredDataMask(Object *UNUSED(ob),
if (smd && (smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
if (smd->flow->source == MOD_SMOKE_FLOW_SOURCE_MESH) {
/* vertex groups */
- if (smd->flow->vgroup_density)
+ if (smd->flow->vgroup_density) {
r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
/* uv layer */
- if (smd->flow->texture_type == MOD_SMOKE_FLOW_TEXTURE_MAP_UV)
+ if (smd->flow->texture_type == MOD_SMOKE_FLOW_TEXTURE_MAP_UV) {
r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
}
}
}
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 08430d0e8f1..59d5b2ccbd2 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -59,8 +59,9 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
flag = smd->flag & (MOD_SMOOTH_X | MOD_SMOOTH_Y | MOD_SMOOTH_Z);
/* disable if modifier is off for X, Y and Z or if factor is 0 */
- if ((smd->fac == 0.0f) || flag == 0)
+ if ((smd->fac == 0.0f) || flag == 0) {
return 1;
+ }
return 0;
}
@@ -88,12 +89,14 @@ static void smoothModifier_do(
float *ftmp, fac, facm;
ftmp = (float *)MEM_calloc_arrayN(numVerts, 3 * sizeof(float), "smoothmodifier_f");
- if (!ftmp)
+ if (!ftmp) {
return;
+ }
uctmp = (unsigned char *)MEM_calloc_arrayN(numVerts, sizeof(unsigned char), "smoothmodifier_uc");
if (!uctmp) {
- if (ftmp)
+ if (ftmp) {
MEM_freeN(ftmp);
+ }
return;
}
@@ -150,23 +153,28 @@ static void smoothModifier_do(
fp = &ftmp[i * 3];
f = defvert_find_weight(dv, defgrp_index);
- if (f <= 0.0f)
+ if (f <= 0.0f) {
continue;
+ }
f *= fac;
fm = 1.0f - f;
/* fp is the sum of uctmp[i] verts, so must be averaged */
facw = 0.0f;
- if (uctmp[i])
+ if (uctmp[i]) {
facw = f / (float)uctmp[i];
+ }
- if (flag & MOD_SMOOTH_X)
+ if (flag & MOD_SMOOTH_X) {
v[0] = fm * v[0] + facw * fp[0];
- if (flag & MOD_SMOOTH_Y)
+ }
+ if (flag & MOD_SMOOTH_Y) {
v[1] = fm * v[1] + facw * fp[1];
- if (flag & MOD_SMOOTH_Z)
+ }
+ if (flag & MOD_SMOOTH_Z) {
v[2] = fm * v[2] + facw * fp[2];
+ }
}
}
else { /* no vertex group */
@@ -179,15 +187,19 @@ static void smoothModifier_do(
/* fp is the sum of uctmp[i] verts, so must be averaged */
facw = 0.0f;
- if (uctmp[i])
+ if (uctmp[i]) {
facw = fac / (float)uctmp[i];
+ }
- if (flag & MOD_SMOOTH_X)
+ if (flag & MOD_SMOOTH_X) {
v[0] = facm * v[0] + facw * fp[0];
- if (flag & MOD_SMOOTH_Y)
+ }
+ if (flag & MOD_SMOOTH_Y) {
v[1] = facm * v[1] + facw * fp[1];
- if (flag & MOD_SMOOTH_Z)
+ }
+ if (flag & MOD_SMOOTH_Z) {
v[2] = facm * v[2] + facw * fp[2];
+ }
}
}
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 9fb2e728dd9..88135b8790b 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -134,8 +134,8 @@ static void mesh_calc_hq_normal(Mesh *mesh, float (*poly_nors)[3], float (*r_ver
#if 0
add_v3_v3v3(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
normalize_v3_length(
- edge_normal,
- angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
+ edge_normal,
+ angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
#else
mid_v3_v3v3_angle_weighted(
edge_normal, poly_nors[edge_ref->p1], poly_nors[edge_ref->p2]);
@@ -380,7 +380,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
/* DO NOT copy here the 'copied' part of loop data, we want to reverse loops
* (so that winding of copied face get reversed, so that normals get reversed
* and point in expected direction...).
- * If we also copy data here, then this data get overwritten (and allocated memory becomes memleak). */
+ * If we also copy data here, then this data get overwritten
+ * (and allocated memory becomes memleak). */
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numPolys);
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, (int)numPolys, (int)numPolys);
@@ -455,8 +456,11 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
ml2 = mloop + mp->loopstart + mesh->totloop;
#if 0
for (j = 0; j < mp->totloop; j++) {
- CustomData_copy_data(&mesh->ldata, &result->ldata, mp->loopstart + j,
- mp->loopstart + (loop_end - j) + mesh->totloop, 1);
+ CustomData_copy_data(&mesh->ldata,
+ &result->ldata,
+ mp->loopstart + j,
+ mp->loopstart + (loop_end - j) + mesh->totloop,
+ 1);
}
#else
/* slightly more involved, keep the first vertex the same for the copy,
@@ -531,10 +535,12 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const unsigned int i = do_shell_align ? i_orig : new_vert_arr[i_orig];
if (dvert) {
MDeformVert *dv = &dvert[i];
- if (defgrp_invert)
+ if (defgrp_invert) {
scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index);
- else
+ }
+ else {
scalar_short_vgroup = defvert_find_weight(dv, defgrp_index);
+ }
scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) *
scalar_short;
}
@@ -565,10 +571,12 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const unsigned int i = do_shell_align ? i_orig : new_vert_arr[i_orig];
if (dvert) {
MDeformVert *dv = &dvert[i];
- if (defgrp_invert)
+ if (defgrp_invert) {
scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index);
- else
+ }
+ else {
scalar_short_vgroup = defvert_find_weight(dv, defgrp_index);
+ }
scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) *
scalar_short;
}
@@ -732,8 +740,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
MEM_freeN(vert_angles);
}
- if (vert_nors)
+ if (vert_nors) {
MEM_freeN(vert_nors);
+ }
/* must recalculate normals with vgroups since they can displace unevenly [#26888] */
if ((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || (smd->flag & MOD_SOLIDIFY_RIM) || dvert) {
@@ -945,11 +954,13 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
MEM_freeN(edge_order);
}
- if (old_vert_arr)
+ if (old_vert_arr) {
MEM_freeN(old_vert_arr);
+ }
- if (poly_nors)
+ if (poly_nors) {
MEM_freeN(poly_nors);
+ }
if (numPolys == 0 && numEdges != 0) {
modifier_setError(md, "Faces needed for useful output");
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index c03b1761251..0b1249e263c 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -64,7 +64,7 @@ static void initData(ModifierData *md)
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
#if 0
- const SubsurfModifierData *smd = (const SubsurfModifierData *) md;
+ const SubsurfModifierData *smd = (const SubsurfModifierData *)md;
#endif
SubsurfModifierData *tsmd = (SubsurfModifierData *)target;
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index 02678879e89..dcc6371e024 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -159,10 +159,12 @@ static void deformVerts(ModifierData *md,
vec = surmd->mesh->mvert[i].co;
mul_m4_v3(ctx->object->obmat, vec);
- if (init)
+ if (init) {
v->co[0] = v->co[1] = v->co[2] = 0.0f;
- else
+ }
+ else {
sub_v3_v3v3(v->co, vec, x->co);
+ }
copy_v3_v3(x->co, vec);
}
@@ -171,10 +173,12 @@ static void deformVerts(ModifierData *md,
surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh");
- if (surmd->mesh->totpoly)
+ if (surmd->mesh->totpoly) {
BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_LOOPTRI, 2);
- else
+ }
+ else {
BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_EDGES, 2);
+ }
}
}
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 2a9fff47e5d..47c0114f02f 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -441,7 +441,8 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
bwdata->bind_polys = bpoly;
- /* Loop over all adjacent edges, and build the SDefBindPoly data for each poly adjacent to those */
+ /* Loop over all adjacent edges,
+ * and build the SDefBindPoly data for each poly adjacent to those. */
for (vedge = vert_edges; vedge; vedge = vedge->next) {
unsigned int edge_ind = vedge->index;
@@ -860,7 +861,8 @@ static void bindVert(void *__restrict userdata,
interp_weights_poly_v2(
sdbind->vert_weights, bpoly->coords_v2, bpoly->numverts, bpoly->point_v2);
- /* Reproject vert based on weights and original poly verts, to reintroduce poly non-planarity */
+ /* Reproject vert based on weights and original poly verts,
+ * to reintroduce poly non-planarity */
zero_v3(point_co_proj);
for (int j = 0; j < bpoly->numverts; j++, loop++) {
madd_v3_v3fl(point_co_proj, bpoly->coords[j], sdbind->vert_weights[j]);
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 7d890b29365..1582c27960e 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -133,7 +133,7 @@ ModifierTypeInfo modifierType_Triangulate = {
/* applyModifier */ applyModifier,
/* initData */ initData,
- /* requiredDataMask */ NULL, //requiredDataMask,
+ /* requiredDataMask */ NULL, // requiredDataMask,
/* freeData */ NULL,
/* isDisabled */ NULL,
/* updateDepsgraph */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index b23dff753f8..1efc1aefae4 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -158,10 +158,12 @@ void MOD_previous_vcos_store(ModifierData *md, float (*vertexCos)[3])
{
while ((md = md->next) && md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData *)md;
- if (amd->multi && amd->prevCos == NULL)
+ if (amd->multi && amd->prevCos == NULL) {
amd->prevCos = MEM_dupallocN(vertexCos);
- else
+ }
+ else {
break;
+ }
}
/* lattice/mesh modifier too */
}
@@ -206,11 +208,13 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob,
}
}
else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
- /* TODO(sybren): get evaluated mesh from depsgraph once that's properly generated for curves. */
+ /* TODO(sybren): get evaluated mesh from depsgraph once
+ * that's properly generated for curves. */
mesh = BKE_mesh_new_nomain_from_curve(ob);
/* Currently, that may not be the case everytime
- * (texts e.g. tend to give issues, also when deforming curve points instead of generated curve geometry... ). */
+ * (texts e.g. tend to give issues,
+ * also when deforming curve points instead of generated curve geometry... ). */
if (mesh != NULL && mesh->totvert != num_verts) {
BKE_id_free(NULL, mesh);
mesh = NULL;
@@ -235,10 +239,12 @@ void MOD_get_vgroup(
*dvert = NULL;
if (*defgrp_index != -1) {
- if (ob->type == OB_LATTICE)
+ if (ob->type == OB_LATTICE) {
*dvert = BKE_lattice_deform_verts_get(ob);
- else if (mesh)
+ }
+ else if (mesh) {
*dvert = mesh->dvert;
+ }
}
}
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 5a9c115dc12..f9eb92cd132 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -68,14 +68,15 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk,
UVProjectModifierData *umd = (UVProjectModifierData *)md;
int i;
- for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i)
+ for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) {
walk(userData, ob, &umd->projectors[i], IDWALK_CB_NOP);
+ }
}
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
{
#if 0
- UVProjectModifierData *umd = (UVProjectModifierData *) md;
+ UVProjectModifierData *umd = (UVProjectModifierData *)md;
#endif
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
@@ -129,13 +130,15 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
}
}
- if (num_projectors == 0)
+ if (num_projectors == 0) {
return mesh;
+ }
/* make sure there are UV Maps available */
- if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV))
+ if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) {
return mesh;
+ }
/* make sure we're using an existing layer */
CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, umd->uvlayer_name, uvname);
@@ -204,13 +207,16 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
coords = BKE_mesh_vertexCos_get(mesh, &numVerts);
/* convert coords to world space */
- for (i = 0, co = coords; i < numVerts; ++i, ++co)
+ for (i = 0, co = coords; i < numVerts; ++i, ++co) {
mul_m4_v3(ob->obmat, *co);
+ }
/* if only one projector, project coords to UVs */
- if (num_projectors == 1 && projectors[0].uci == NULL)
- for (i = 0, co = coords; i < numVerts; ++i, ++co)
+ if (num_projectors == 1 && projectors[0].uci == NULL) {
+ for (i = 0, co = coords; i < numVerts; ++i, ++co) {
mul_project_m4_v3(projectors[0].projmat, *co);
+ }
+ }
mpoly = mesh->mpoly;
mloop = mesh->mloop;
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index 83b9a8e1804..995f3d06fcb 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -226,10 +226,12 @@ static void uv_warp_deps_object_bone_new(struct DepsNodeHandle *node,
const char *bonename)
{
if (object != NULL) {
- if (bonename[0])
+ if (bonename[0]) {
DEG_add_object_relation(node, object, DEG_OB_COMP_EVAL_POSE, "UVWarp Modifier");
- else
+ }
+ else {
DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, "UVWarp Modifier");
+ }
}
}
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 67b91cfd963..6441ab69391 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -178,16 +178,18 @@ static void warpModifier_do(WarpModifierData *wmd,
float(*tex_co)[3] = NULL;
- if (!(wmd->object_from && wmd->object_to))
+ if (!(wmd->object_from && wmd->object_to)) {
return;
+ }
MOD_get_vgroup(ob, mesh, wmd->defgrp_name, &dvert, &defgrp_index);
if (dvert == NULL) {
defgrp_index = -1;
}
- if (wmd->curfalloff == NULL) /* should never happen, but bad lib linking could cause it */
+ if (wmd->curfalloff == NULL) { /* should never happen, but bad lib linking could cause it */
wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ }
if (wmd->curfalloff) {
curvemapping_initialize(wmd->curfalloff);
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index c0b686dd098..d480f3416b1 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -182,10 +182,12 @@ static void waveModifier_do(WaveModifierData *md,
if (x > wmd->lifetime) {
lifefac = x - wmd->lifetime;
- if (lifefac > wmd->damp)
+ if (lifefac > wmd->damp) {
lifefac = 0.0;
- else
+ }
+ else {
lifefac = (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp)));
+ }
}
}
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 2162f223b7a..7fbaa24b579 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -51,7 +51,8 @@ static int modepair_cmp_by_val_inverse(const void *p1, const void *p2)
return (r1->val < r2->val) ? 1 : ((r1->val > r2->val) ? -1 : 0);
}
-/* There will be one of those per vertex (simple case, computing one normal per vertex), or per smooth fan. */
+/* There will be one of those per vertex
+ * (simple case, computing one normal per vertex), or per smooth fan. */
typedef struct WeightedNormalDataAggregateItem {
float normal[3];
@@ -97,8 +98,10 @@ typedef struct WeightedNormalData {
int *loop_to_poly;
} WeightedNormalData;
-/* Check strength of given poly compared to those found so far for that given item (vertex or smooth fan),
- * and reset matching item_data in case we get a stronger new strength. */
+/**
+ * Check strength of given poly compared to those found so far for that given item
+ * (vertex or smooth fan), and reset matching item_data in case we get a stronger new strength.
+ */
static bool check_item_poly_strength(WeightedNormalData *wn_data,
WeightedNormalDataAggregateItem *item_data,
const int mp_index)
@@ -158,7 +161,8 @@ static void aggregate_item_normal(WeightedNormalModifierData *wnmd,
item_data->curr_val = curr_val;
}
- /* Exponentially divided weight for each normal (since a few values will be used by most cases, we cache those). */
+ /* Exponentially divided weight for each normal
+ * (since a few values will be used by most cases, we cache those). */
const int num_loops = item_data->num_loops;
if (num_loops < NUM_CACHED_INVERSE_POWERS_OF_WEIGHT &&
cached_inverse_powers_of_weight[num_loops] == 0.0f) {
@@ -211,7 +215,8 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
if (keep_sharp) {
BLI_bitmap *done_loops = BLI_BITMAP_NEW(numLoops, __func__);
- /* This will give us loop normal spaces, we do not actually care about computed loop_normals for now... */
+ /* This will give us loop normal spaces,
+ * we do not actually care about computed loop_normals for now... */
loop_normals = MEM_calloc_arrayN((size_t)numLoops, sizeof(*loop_normals), __func__);
BKE_mesh_normals_loop_split(mvert,
numVerts,
@@ -329,8 +334,9 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
if (keep_sharp) {
/* Set loop normals for normal computed for each lnor space (smooth fan).
- * Note that loop_normals is already populated with clnors (before this modifier is applied, at start of
- * this function), so no need to recompute them here. */
+ * Note that loop_normals is already populated with clnors
+ * (before this modifier is applied, at start of this function),
+ * so no need to recompute them here. */
for (int ml_index = 0; ml_index < numLoops; ml_index++) {
WeightedNormalDataAggregateItem *item_data = lnors_spacearr.lspacearr[ml_index]->user_data;
if (!is_zero_v3(item_data->normal)) {
@@ -351,12 +357,14 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
clnors);
}
else {
- /* TODO: Ideally, we could add an option to BKE_mesh_normals_loop_custom_[from_vertices_]set() to keep current
- * clnors instead of resetting them to default autocomputed ones, when given new custom normal is zero-vec.
+ /* TODO: Ideally, we could add an option to BKE_mesh_normals_loop_custom_[from_vertices_]set()
+ * to keep current clnors instead of resetting them to default autocomputed ones,
+ * when given new custom normal is zero-vec.
* But this is not exactly trivial change, better to keep this optimization for later...
*/
if (!has_vgroup) {
- /* Note: in theory, we could avoid this extra allocation & copying... But think we can live with it for now,
+ /* Note: in theory, we could avoid this extra allocation & copying...
+ * But think we can live with it for now,
* and it makes code simpler & cleaner. */
float(*vert_normals)[3] = MEM_calloc_arrayN(
(size_t)numVerts, sizeof(*loop_normals), __func__);
@@ -540,118 +548,122 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
WeightedNormalModifierData *wnmd = (WeightedNormalModifierData *)md;
Object *ob = ctx->object;
- /* XXX TODO ARG GRRR XYQWNMPRXTYY
- * Once we fully switch to Mesh evaluation of modifiers, we can expect to get that flag from the COW copy.
- * But for now, it is lost in the DM intermediate step, so we need to directly check orig object's data. */
+ /* XXX TODO(Rohan Rathi):
+ * Once we fully switch to Mesh evaluation of modifiers,
+ * we can expect to get that flag from the COW copy.
+ * But for now, it is lost in the DM intermediate step,
+ * so we need to directly check orig object's data. */
#if 0
- if (!(mesh->flag & ME_AUTOSMOOTH)) {
+ if (!(mesh->flag & ME_AUTOSMOOTH))
#else
- if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH)) {
+ if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH))
#endif
- modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings");
- return mesh;
-}
+ {
+ modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings");
+ return mesh;
+ }
-Mesh *result;
-BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
+ Mesh *result;
+ BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
-const int numVerts = result->totvert;
-const int numEdges = result->totedge;
-const int numLoops = result->totloop;
-const int numPolys = result->totpoly;
+ const int numVerts = result->totvert;
+ const int numEdges = result->totedge;
+ const int numLoops = result->totloop;
+ const int numPolys = result->totpoly;
-MEdge *medge = result->medge;
-MPoly *mpoly = result->mpoly;
-MVert *mvert = result->mvert;
-MLoop *mloop = result->mloop;
+ MEdge *medge = result->medge;
+ MPoly *mpoly = result->mpoly;
+ MVert *mvert = result->mvert;
+ MLoop *mloop = result->mloop;
-/* Right now:
+ /* Right now:
* If weight = 50 then all faces are given equal weight.
* If weight > 50 then more weight given to faces with larger vals (face area / corner angle).
* If weight < 50 then more weight given to faces with lesser vals. However current calculation
* does not converge to min/max.
*/
-float weight = ((float)wnmd->weight) / 50.0f;
-if (wnmd->weight == 100) {
- weight = (float)SHRT_MAX;
-}
-else if (wnmd->weight == 1) {
- weight = 1 / (float)SHRT_MAX;
-}
-else if ((weight - 1) * 25 > 1) {
- weight = (weight - 1) * 25;
-}
+ float weight = ((float)wnmd->weight) / 50.0f;
+ if (wnmd->weight == 100) {
+ weight = (float)SHRT_MAX;
+ }
+ else if (wnmd->weight == 1) {
+ weight = 1 / (float)SHRT_MAX;
+ }
+ else if ((weight - 1) * 25 > 1) {
+ weight = (weight - 1) * 25;
+ }
-CustomData *pdata = &result->pdata;
-float (*polynors)[3] = CustomData_get_layer(pdata, CD_NORMAL);
-if (!polynors) {
- polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys);
- CustomData_set_layer_flag(pdata, CD_NORMAL, CD_FLAG_TEMPORARY);
-}
-BKE_mesh_calc_normals_poly(
- mvert, NULL, numVerts, mloop, mpoly, numLoops, numPolys, polynors, false);
-
-const float split_angle = mesh->smoothresh;
-short (*clnors)[2];
-CustomData *ldata = &result->ldata;
-clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
-
-/* Keep info whether we had clnors, it helps when generating clnor spaces and default normals. */
-const bool has_clnors = clnors != NULL;
-if (!clnors) {
- clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops);
-}
+ CustomData *pdata = &result->pdata;
+ float(*polynors)[3] = CustomData_get_layer(pdata, CD_NORMAL);
+ if (!polynors) {
+ polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys);
+ CustomData_set_layer_flag(pdata, CD_NORMAL, CD_FLAG_TEMPORARY);
+ }
+ BKE_mesh_calc_normals_poly(
+ mvert, NULL, numVerts, mloop, mpoly, numLoops, numPolys, polynors, false);
+
+ const float split_angle = mesh->smoothresh;
+ short(*clnors)[2];
+ CustomData *ldata = &result->ldata;
+ clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
+
+ /* Keep info whether we had clnors,
+ * it helps when generating clnor spaces and default normals. */
+ const bool has_clnors = clnors != NULL;
+ if (!clnors) {
+ clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops);
+ }
-MDeformVert *dvert;
-int defgrp_index;
-MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index);
+ MDeformVert *dvert;
+ int defgrp_index;
+ MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index);
-WeightedNormalData wn_data = {
- .numVerts = numVerts,
- .numEdges = numEdges,
- .numLoops = numLoops,
- .numPolys = numPolys,
+ WeightedNormalData wn_data = {
+ .numVerts = numVerts,
+ .numEdges = numEdges,
+ .numLoops = numLoops,
+ .numPolys = numPolys,
- .mvert = mvert,
- .medge = medge,
+ .mvert = mvert,
+ .medge = medge,
- .mloop = mloop,
- .clnors = clnors,
- .has_clnors = has_clnors,
- .split_angle = split_angle,
+ .mloop = mloop,
+ .clnors = clnors,
+ .has_clnors = has_clnors,
+ .split_angle = split_angle,
- .mpoly = mpoly,
- .polynors = polynors,
- .poly_strength = CustomData_get_layer_named(
- &result->pdata, CD_PROP_INT, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID),
+ .mpoly = mpoly,
+ .polynors = polynors,
+ .poly_strength = CustomData_get_layer_named(
+ &result->pdata, CD_PROP_INT, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID),
- .dvert = dvert,
- .defgrp_index = defgrp_index,
- .use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0,
+ .dvert = dvert,
+ .defgrp_index = defgrp_index,
+ .use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0,
- .weight = weight,
- .mode = wnmd->mode,
-};
+ .weight = weight,
+ .mode = wnmd->mode,
+ };
-switch (wnmd->mode) {
- case MOD_WEIGHTEDNORMAL_MODE_FACE:
- wn_face_area(wnmd, &wn_data);
- break;
- case MOD_WEIGHTEDNORMAL_MODE_ANGLE:
- wn_corner_angle(wnmd, &wn_data);
- break;
- case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE:
- wn_face_with_angle(wnmd, &wn_data);
- break;
-}
+ switch (wnmd->mode) {
+ case MOD_WEIGHTEDNORMAL_MODE_FACE:
+ wn_face_area(wnmd, &wn_data);
+ break;
+ case MOD_WEIGHTEDNORMAL_MODE_ANGLE:
+ wn_corner_angle(wnmd, &wn_data);
+ break;
+ case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE:
+ wn_face_with_angle(wnmd, &wn_data);
+ break;
+ }
-MEM_SAFE_FREE(wn_data.loop_to_poly);
-MEM_SAFE_FREE(wn_data.mode_pair);
-MEM_SAFE_FREE(wn_data.items_data);
+ MEM_SAFE_FREE(wn_data.loop_to_poly);
+ MEM_SAFE_FREE(wn_data.mode_pair);
+ MEM_SAFE_FREE(wn_data.items_data);
-/* Currently Modifier stack assumes there is no poly normal data passed around... */
-CustomData_free_layers(pdata, CD_NORMAL, numPolys);
-return result;
+ /* Currently Modifier stack assumes there is no poly normal data passed around... */
+ CustomData_free_layers(pdata, CD_NORMAL, numPolys);
+ return result;
}
static void initData(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 3e1c2f9bc02..61872cbe464 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -50,8 +50,8 @@
/* Maps new_w weights in place, using either one of the predefined functions, or a custom curve.
* Return values are in new_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
+ * If indices is not NULL, it must be a table of same length as org_w and new_w,
+ * mapping to the real vertex index (in case the weight tables do not cover the whole vertices...).
* cmap might be NULL, in which case curve mapping mode will return unmodified data.
*/
void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cmap, RNG *rng)
@@ -111,9 +111,10 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm
/* Applies new_w weights to org_w ones, using either a texture, vgroup or constant value as factor.
* Return values are in org_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
- * XXX The standard "factor" value is assumed in [0.0, 1.0] range. Else, weird results might appear.
+ * If indices is not NULL, it must be a table of same length as org_w and new_w,
+ * mapping to the real vertex index (in case the weight tables do not cover the whole vertices...).
+ * XXX The standard "factor" value is assumed in [0.0, 1.0] range.
+ * Else, weird results might appear.
*/
void weightvg_do_mask(const ModifierEvalContext *ctx,
const int num,
@@ -135,8 +136,9 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
int i;
/* If influence factor is null, nothing to do! */
- if (fact == 0.0f)
+ if (fact == 0.0f) {
return;
+ }
/* If we want to mask vgroup weights from a texture. */
if (texture != NULL) {
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h
index d73cca935d7..08967b7400d 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.h
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.h
@@ -52,21 +52,9 @@ struct Tex;
*/
#define MOD_WVG_ZEROFLOOR 1.0e-32f
-/* Maps new_w weights in place, using either one of the predefined functions, or a custom curve.
- * Return values are in new_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
- * cmap might be NULL, in which case curve mapping mode will return unmodified data.
- */
void weightvg_do_map(
int num, float *new_w, short mode, struct CurveMapping *cmap, struct RNG *rng);
-/* Applies new_w weights to org_w ones, using either a texture, vgroup or constant value as factor.
- * Return values are in org_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
- * XXX The standard "factor" value is assumed in [0.0, 1.0] range. Else, weird results might appear.
- */
void weightvg_do_mask(const ModifierEvalContext *ctx,
const int num,
const int *indices,
@@ -83,10 +71,6 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
Object *tex_map_object,
const char *tex_uvlayer_name);
-/* Applies weights to given vgroup (defgroup), and optionally add/remove vertices from the group.
- * If indices is not NULL, it must be a table of same length as weights, mapping to the real
- * vertex index (in case the weight table does not cover the whole vertices...).
- */
void weightvg_update_vg(struct MDeformVert *dvert,
int defgrp_idx,
struct MDeformWeight **dws,
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 5f4983af6cc..7e49af4f3bf 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -105,8 +105,9 @@ static bool dependsOnTime(ModifierData *md)
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
- if (wmd->mask_texture)
+ if (wmd->mask_texture) {
return BKE_texture_dependsOnTime(wmd->mask_texture);
+ }
return false;
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index ed2c2e5e940..e509d1464f2 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -55,8 +55,7 @@ static float mix_weight(float weight, float weight2, char mix_mode)
* XXX Don't know why, but the switch version takes many CPU time,
* and produces lag in realtime playback...
*/
- switch (mix_mode)
- {
+ switch (mix_mode) {
case MOD_WVG_MIX_ADD:
return (weight + weight2);
case MOD_WVG_MIX_SUB:
@@ -79,28 +78,37 @@ static float mix_weight(float weight, float weight2, char mix_mode)
return weight2;
}
#endif
- if (mix_mode == MOD_WVG_MIX_SET)
+ if (mix_mode == MOD_WVG_MIX_SET) {
return weight2;
- else if (mix_mode == MOD_WVG_MIX_ADD)
+ }
+ else if (mix_mode == MOD_WVG_MIX_ADD) {
return (weight + weight2);
- else if (mix_mode == MOD_WVG_MIX_SUB)
+ }
+ else if (mix_mode == MOD_WVG_MIX_SUB) {
return (weight - weight2);
- else if (mix_mode == MOD_WVG_MIX_MUL)
+ }
+ else if (mix_mode == MOD_WVG_MIX_MUL) {
return (weight * weight2);
+ }
else if (mix_mode == MOD_WVG_MIX_DIV) {
/* Avoid dividing by zero (or really small values). */
- if (weight2 < 0.0f && weight2 > -MOD_WVG_ZEROFLOOR)
+ if (weight2 < 0.0f && weight2 > -MOD_WVG_ZEROFLOOR) {
weight2 = -MOD_WVG_ZEROFLOOR;
- else if (weight2 >= 0.0f && weight2 < MOD_WVG_ZEROFLOOR)
+ }
+ else if (weight2 >= 0.0f && weight2 < MOD_WVG_ZEROFLOOR) {
weight2 = MOD_WVG_ZEROFLOOR;
+ }
return (weight / weight2);
}
- else if (mix_mode == MOD_WVG_MIX_DIF)
+ else if (mix_mode == MOD_WVG_MIX_DIF) {
return (weight < weight2 ? weight2 - weight : weight - weight2);
- else if (mix_mode == MOD_WVG_MIX_AVG)
+ }
+ else if (mix_mode == MOD_WVG_MIX_AVG) {
return (weight + weight2) * 0.5f;
- else
+ }
+ else {
return weight2;
+ }
}
/**************************************
@@ -141,8 +149,9 @@ static bool dependsOnTime(ModifierData *md)
{
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *)md;
- if (wmd->mask_texture)
+ if (wmd->mask_texture) {
return BKE_texture_dependsOnTime(wmd->mask_texture);
+ }
return false;
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 66b7ddb54d6..9b3bc4678a1 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -79,7 +79,8 @@ typedef struct Vert2GeomData {
float *dist[3];
} Vert2GeomData;
-/* Data which is localized to each computed chunk (i.e. thread-safe, and with continuous subset of index range). */
+/** Data which is localized to each computed chunk
+ * (i.e. thread-safe, and with continuous subset of index range). */
typedef struct Vert2GeomDataChunk {
/* Read-only data */
float last_hit_co[3][3];
@@ -110,8 +111,8 @@ static void vert2geom_task_cb_ex(void *__restrict userdata,
/* Note that we use local proximity heuristics (to reduce the nearest search).
*
* If we already had an hit before in same chunk of tasks (i.e. previous vertex by index),
- * we assume this vertex is going to have a close hit to that other vertex, so we can initiate
- * the "nearest.dist" with the expected value to that last hit.
+ * we assume this vertex is going to have a close hit to that other vertex,
+ * so we can initiate the "nearest.dist" with the expected value to that last hit.
* This will lead in pruning of the search tree.
*/
nearest.dist_sq = data_chunk->is_init[i] ?
@@ -194,12 +195,15 @@ static void get_vert2geom_distance(int numVerts,
settings.userdata_chunk_size = sizeof(data_chunk);
BLI_task_parallel_range(0, numVerts, &data, vert2geom_task_cb_ex, &settings);
- if (dist_v)
+ if (dist_v) {
free_bvhtree_from_mesh(&treeData_v);
- if (dist_e)
+ }
+ if (dist_e) {
free_bvhtree_from_mesh(&treeData_e);
- if (dist_f)
+ }
+ if (dist_f) {
free_bvhtree_from_mesh(&treeData_f);
+ }
}
/**
@@ -245,22 +249,28 @@ static void do_map(
}
else if (max_d > min_d) {
while (i-- > 0) {
- if (weights[i] >= max_d)
+ if (weights[i] >= max_d) {
weights[i] = 1.0f; /* most likely case first */
- else if (weights[i] <= min_d)
+ }
+ else if (weights[i] <= min_d) {
weights[i] = 0.0f;
- else
+ }
+ else {
weights[i] = (weights[i] - min_d) * range_inv;
+ }
}
}
else {
while (i-- > 0) {
- if (weights[i] <= max_d)
+ if (weights[i] <= max_d) {
weights[i] = 1.0f; /* most likely case first */
- else if (weights[i] >= min_d)
+ }
+ else if (weights[i] >= min_d) {
weights[i] = 0.0f;
- else
+ }
+ else {
weights[i] = (weights[i] - min_d) * range_inv;
+ }
}
}
@@ -318,8 +328,9 @@ static bool dependsOnTime(ModifierData *md)
{
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md;
- if (wmd->mask_texture)
+ if (wmd->mask_texture) {
return BKE_texture_dependsOnTime(wmd->mask_texture);
+ }
return 0;
}
@@ -374,8 +385,9 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
{
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md;
/* If no vertex group, bypass. */
- if (wmd->defgrp_name[0] == '\0')
+ if (wmd->defgrp_name[0] == '\0') {
return 1;
+ }
/* If no target object, bypass. */
return (wmd->proximity_ob_target == NULL);
}
@@ -520,10 +532,12 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
get_vert2geom_distance(numIdx, v_cos, dists_v, dists_e, dists_f, target_mesh, &loc2trgt);
for (i = 0; i < numIdx; i++) {
new_w[i] = dists_v ? dists_v[i] : FLT_MAX;
- if (dists_e)
+ if (dists_e) {
new_w[i] = min_ff(dists_e[i], new_w[i]);
- if (dists_f)
+ }
+ if (dists_f) {
new_w[i] = min_ff(dists_f[i], new_w[i]);
+ }
}
MEM_SAFE_FREE(dists_v);
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index b76a87d7132..80afcada4b9 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -33,8 +33,8 @@ set(INC
../makesdna
../makesrna
../render/extern/include
- ../../../intern/guardedalloc
../../../intern/glew-mx
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/nodes/NOD_common.h b/source/blender/nodes/NOD_common.h
index 7bbdc2129cd..26c78eab4ec 100644
--- a/source/blender/nodes/NOD_common.h
+++ b/source/blender/nodes/NOD_common.h
@@ -35,11 +35,11 @@ void register_node_type_group_output(void);
/* internal functions for editor */
struct bNodeSocket *node_group_find_input_socket(struct bNode *groupnode, const char *identifier);
struct bNodeSocket *node_group_find_output_socket(struct bNode *groupnode, const char *identifier);
-void node_group_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
+void node_group_update(struct bNodeTree *ntree, struct bNode *node);
struct bNodeSocket *node_group_input_find_socket(struct bNode *node, const char *identifier);
struct bNodeSocket *node_group_output_find_socket(struct bNode *node, const char *identifier);
-void node_group_input_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
-void node_group_output_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
+void node_group_input_update(struct bNodeTree *ntree, struct bNode *node);
+void node_group_output_update(struct bNodeTree *ntree, struct bNode *node);
#endif /* __NOD_COMMON_H__ */
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 53fdde5baf2..43a70a62350 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -89,8 +89,9 @@ static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node)
static void free_cache(bNodeTree *ntree)
{
bNode *node;
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
free_node_cache(ntree, node);
+ }
}
/* local tree then owns all compbufs */
@@ -109,10 +110,12 @@ static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree)
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (node->id) {
- if (node->flag & NODE_DO_OUTPUT)
+ if (node->flag & NODE_DO_OUTPUT) {
node->new_node->id = (ID *)node->id;
- else
+ }
+ else {
node->new_node->id = NULL;
+ }
}
}
@@ -150,8 +153,9 @@ static void local_merge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree)
* and to achieve much better performance on further calls this context should be
* copied back to original node */
if (lnode->storage) {
- if (lnode->new_node->storage)
+ if (lnode->new_node->storage) {
BKE_tracking_distortion_free(lnode->new_node->storage);
+ }
lnode->new_node->storage = BKE_tracking_distortion_copy(lnode->storage);
}
@@ -243,22 +247,25 @@ void ntreeCompositExecTree(Scene *scene,
/* Update the outputs of the render layer nodes.
* Since the outputs depend on the render engine, this part is a bit complex:
- * - ntreeCompositUpdateRLayers is called and loops over all render layer nodes
- * - Each render layer node calls the update function of the render engine that's used for its scene
- * - The render engine calls RE_engine_register_pass for each pass
- * - RE_engine_register_pass calls ntreeCompositRegisterPass,
- * which calls node_cmp_rlayers_register_pass for every render layer node
+ * - ntreeCompositUpdateRLayers is called and loops over all render layer nodes.
+ * - Each render layer node calls the update function of the
+ * render engine that's used for its scene.
+ * - The render engine calls RE_engine_register_pass for each pass.
+ * - RE_engine_register_pass calls ntreeCompositRegisterPass,.
+ * which calls node_cmp_rlayers_register_pass for every render layer node.
*/
void ntreeCompositUpdateRLayers(bNodeTree *ntree)
{
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_R_LAYERS)
+ if (node->type == CMP_NODE_R_LAYERS) {
node_cmp_rlayers_outputs(ntree, node);
+ }
}
}
@@ -267,12 +274,14 @@ void ntreeCompositRegisterPass(
{
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_R_LAYERS)
+ if (node->type == CMP_NODE_R_LAYERS) {
node_cmp_rlayers_register_pass(ntree, node, scene, view_layer, name, type);
+ }
}
}
@@ -284,125 +293,38 @@ void ntreeCompositTagRender(Scene *curscene)
/* XXX Think using G_MAIN here is valid, since you want to update current file's scene nodes,
* not the ones in temp main generated for rendering?
- * This is still rather weak though, ideally render struct would store own main AND original G_MAIN... */
+ * This is still rather weak though,
+ * ideally render struct would store own main AND original G_MAIN. */
+
for (sce = G_MAIN->scenes.first; sce; sce = sce->id.next) {
if (sce->nodetree) {
bNode *node;
for (node = sce->nodetree->nodes.first; node; node = node->next) {
- if (node->id == (ID *)curscene || node->type == CMP_NODE_COMPOSITE)
+ if (node->id == (ID *)curscene || node->type == CMP_NODE_COMPOSITE) {
nodeUpdate(sce->nodetree, node);
- else if (node->type == CMP_NODE_TEXTURE) /* uses scene sizex/sizey */
+ }
+ else if (node->type == CMP_NODE_TEXTURE) /* uses scene sizex/sizey */ {
nodeUpdate(sce->nodetree, node);
+ }
}
}
}
}
-static int node_animation_properties(bNodeTree *ntree, bNode *node)
-{
- bNodeSocket *sock;
- const ListBase *lb;
- Link *link;
- PointerRNA ptr;
- PropertyRNA *prop;
-
- /* check to see if any of the node's properties have fcurves */
- RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
- lb = RNA_struct_type_properties(ptr.type);
-
- for (link = lb->first; link; link = link->next) {
- prop = (PropertyRNA *)link;
-
- if (RNA_property_animated(&ptr, prop)) {
- nodeUpdate(ntree, node);
- return 1;
- }
- }
-
- /* now check node sockets */
- for (sock = node->inputs.first; sock; sock = sock->next) {
- RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
- prop = RNA_struct_find_property(&ptr, "default_value");
-
- if (RNA_property_animated(&ptr, prop)) {
- nodeUpdate(ntree, node);
- return 1;
- }
- }
-
- return 0;
-}
-
-/* tags nodes that have animation capabilities */
-int ntreeCompositTagAnimated(bNodeTree *ntree)
-{
- bNode *node;
- int tagged = 0;
-
- if (ntree == NULL)
- return 0;
-
- for (node = ntree->nodes.first; node; node = node->next) {
-
- tagged = node_animation_properties(ntree, node);
-
- /* otherwise always tag these node types */
- if (node->type == CMP_NODE_IMAGE) {
- Image *ima = (Image *)node->id;
- if (ima && BKE_image_is_animated(ima)) {
- nodeUpdate(ntree, node);
- tagged = 1;
- }
- }
- else if (node->type == CMP_NODE_TIME) {
- nodeUpdate(ntree, node);
- tagged = 1;
- }
- /* here was tag render layer, but this is called after a render, so re-composites fail */
- else if (node->type == NODE_GROUP) {
- if (ntreeCompositTagAnimated((bNodeTree *)node->id)) {
- nodeUpdate(ntree, node);
- }
- }
- else if (ELEM(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_TRANSFORM)) {
- nodeUpdate(ntree, node);
- tagged = 1;
- }
- else if (node->type == CMP_NODE_MASK) {
- nodeUpdate(ntree, node);
- tagged = 1;
- }
- }
-
- return tagged;
-}
-
-/* called from image window preview */
-void ntreeCompositTagGenerators(bNodeTree *ntree)
-{
- bNode *node;
-
- if (ntree == NULL)
- return;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (ELEM(node->type, CMP_NODE_R_LAYERS, CMP_NODE_IMAGE))
- nodeUpdate(ntree, node);
- }
-}
-
/* XXX after render animation system gets a refresh, this call allows composite to end clean */
void ntreeCompositClearTags(bNodeTree *ntree)
{
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
node->need_exec = 0;
- if (node->type == NODE_GROUP)
+ if (node->type == NODE_GROUP) {
ntreeCompositClearTags((bNodeTree *)node->id);
+ }
}
}
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c
index 1ba81330d72..b6cbffea413 100644
--- a/source/blender/nodes/composite/node_composite_util.c
+++ b/source/blender/nodes/composite/node_composite_util.c
@@ -33,8 +33,8 @@ void cmp_node_update_default(bNodeTree *UNUSED(ntree), bNode *node)
bNodeSocket *sock;
for (sock = node->outputs.first; sock; sock = sock->next) {
if (sock->cache) {
- //free_compbuf(sock->cache);
- //sock->cache = NULL;
+ // free_compbuf(sock->cache);
+ // sock->cache = NULL;
}
}
node->need_exec = 1;
diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
index 8c46349e091..0d599616037 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
@@ -29,8 +29,10 @@ static bNodeSocketTemplate cmp_node_bilateralblur_in[] = {
{SOCK_RGBA, 1, N_("Determinator"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, 0, ""}};
-static bNodeSocketTemplate cmp_node_bilateralblur_out[] = {{SOCK_RGBA, 0, N_("Image")},
- {-1, 0, ""}};
+static bNodeSocketTemplate cmp_node_bilateralblur_out[] = {
+ {SOCK_RGBA, 0, N_("Image")},
+ {-1, 0, ""},
+};
static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode *node)
{
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
index b35d3d73faa..5fa6cf709e6 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
@@ -15,7 +15,6 @@
*
* The Original Code is Copyright (C) 2006 Blender Foundation.
* All rights reserved.
-
*/
/** \file
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
index b0fbade8da4..db0689df775 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
@@ -36,7 +36,8 @@ static bNodeSocketTemplate cmp_node_colorbalance_out[] = {
};
/* Sync functions update formula parameters for other modes, such that the result is comparable.
- * Note that the results are not exactly the same due to differences in color handling (sRGB conversion happens for LGG),
+ * Note that the results are not exactly the same due to differences in color handling
+ * (sRGB conversion happens for LGG),
* but this keeps settings comparable.
*/
diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c
index 78254cc7404..a22835ba85b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_common.c
+++ b/source/blender/nodes/composite/nodes/node_composite_common.c
@@ -53,7 +53,7 @@ void register_node_type_cmp_group(void)
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
- node_type_update(&ntype, NULL, node_group_verify);
+ node_type_group_update(&ntype, node_group_update);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index 729252f0937..68a7e8d1589 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -71,7 +71,8 @@ static void cryptomatte_add(NodeCryptomatte *n, float f)
/* Be aware that token_len still contains any trailing white space. */
token_len = token_end - (n->matte_id + start);
- /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */
+ /* If this has a leading bracket,
+ * assume a raw floating point number and look for the closing bracket. */
if (n->matte_id[start] == '<') {
if (strncmp(n->matte_id + start, number, strlen(number)) == 0) {
/* This number is already there, so continue. */
@@ -152,7 +153,8 @@ static void cryptomatte_remove(NodeCryptomatte *n, float f)
if (token_len == 1) {
skip = true;
}
- /* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */
+ /* If this has a leading bracket,
+ * assume a raw floating point number and look for the closing bracket. */
else if (n->matte_id[start] == '<') {
if (strncmp(n->matte_id + start, number, strlen(number)) == 0) {
/* This number is already there, so skip it. */
@@ -276,8 +278,9 @@ static void node_copy_cryptomatte(bNodeTree *UNUSED(dest_ntree), bNode *dest_nod
NodeCryptomatte *src_nc = src_node->storage;
NodeCryptomatte *dest_nc = MEM_dupallocN(src_nc);
- if (src_nc->matte_id)
+ if (src_nc->matte_id) {
dest_nc->matte_id = MEM_dupallocN(src_nc->matte_id);
+ }
dest_node->storage = dest_nc;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c
index e4a82a35890..8a8df8a5827 100644
--- a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c
+++ b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c
@@ -24,31 +24,18 @@
/* **************** Double Edge Mask ******************** */
static bNodeSocketTemplate cmp_node_doubleedgemask_in[] = {
- {SOCK_FLOAT,
- 1,
- "Inner Mask",
- 0.8f,
- 0.8f,
- 0.8f,
- 1.0f,
- 0.0f,
- 1.0f,
- PROP_NONE}, // inner mask socket definition
- {SOCK_FLOAT,
- 1,
- "Outer Mask",
- 0.8f,
- 0.8f,
- 0.8f,
- 1.0f,
- 0.0f,
- 1.0f,
- PROP_NONE}, // outer mask socket definition
- {-1, 0, ""}, // input socket array terminator
+ /* Inner mask socket definition. */
+ {SOCK_FLOAT, 1, "Inner Mask", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_NONE},
+ /* Outer mask socket definition. */
+ {SOCK_FLOAT, 1, "Outer Mask", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_NONE},
+ /* Input socket array terminator. */
+ {-1, 0, ""},
};
static bNodeSocketTemplate cmp_node_doubleedgemask_out[] = {
- {SOCK_FLOAT, 0, "Mask"}, // output socket definition
- {-1, 0, ""}, // output socket array terminator
+ /* Output socket definition. */
+ {SOCK_FLOAT, 0, "Mask"},
+ /* Output socket array terminator. */
+ {-1, 0, ""},
};
void register_node_type_cmp_doubleedgemask(void)
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index d4278b3b540..e1e23b843a1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -87,11 +87,15 @@ static void cmp_node_image_add_pass_output(bNodeTree *ntree,
if (sock_index < 0) {
/* The first 31 sockets always are the legacy hardcoded sockets.
- * Any dynamically allocated sockets follow afterwards, and are sorted in the order in which they were stored in the RenderResult.
- * Therefore, we remember the index of the last matched socket. New sockets are placed behind the previously traversed one, but always after the first 31. */
+ * Any dynamically allocated sockets follow afterwards,
+ * and are sorted in the order in which they were stored in the RenderResult.
+ * Therefore, we remember the index of the last matched socket.
+ * New sockets are placed behind the previously traversed one,
+ * but always after the first 31. */
int after_index = *prev_index;
- if (is_rlayers && after_index < 30)
+ if (is_rlayers && after_index < 30) {
after_index = 30;
+ }
if (rres_index >= 0) {
sock = node_add_socket_from_template(
@@ -158,10 +162,12 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree,
RenderPass *rpass;
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
int type;
- if (rpass->channels == 1)
+ if (rpass->channels == 1) {
type = SOCK_FLOAT;
- else
+ }
+ else {
type = SOCK_RGBA;
+ }
cmp_node_image_add_pass_output(ntree,
node,
@@ -337,7 +343,8 @@ static void cmp_node_rlayer_create_outputs(bNodeTree *ntree,
&prev_index);
}
-/* XXX make this into a generic socket verification function for dynamic socket replacement (multilayer, groups, static templates) */
+/* XXX make this into a generic socket verification function for dynamic socket replacement
+ * (multilayer, groups, static templates) */
static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rlayer)
{
bNodeSocket *sock, *sock_next;
@@ -345,10 +352,12 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
int sock_index;
/* XXX make callback */
- if (rlayer)
+ if (rlayer) {
cmp_node_rlayer_create_outputs(ntree, node, &available_sockets);
- else
+ }
+ else {
cmp_node_image_create_outputs(ntree, node, &available_sockets);
+ }
/* Get rid of sockets whose passes are not available in the image.
* If sockets that are not available would be deleted, the connections to them would be lost
@@ -358,7 +367,8 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
* Another important detail comes from compatibility with the older socket model, where there
* was a fixed socket per pass type that was just hidden or not. Therefore, older versions expect
* the first 31 passes to belong to a specific pass type.
- * So, we keep those 31 always allocated before the others as well, even if they have no links attached. */
+ * So, we keep those 31 always allocated before the others as well,
+ * even if they have no links attached. */
sock_index = 0;
for (sock = node->outputs.first; sock; sock = sock_next, sock_index++) {
sock_next = sock->next;
@@ -368,8 +378,9 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
else {
bNodeLink *link;
for (link = ntree->links.first; link; link = link->next) {
- if (link->fromsock == sock)
+ if (link->fromsock == sock) {
break;
+ }
}
if (!link && (!rlayer || sock_index > 30)) {
MEM_freeN(sock->storage);
@@ -387,8 +398,9 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
static void cmp_node_image_update(bNodeTree *ntree, bNode *node)
{
/* avoid unnecessary updates, only changes to the image/image user data are of interest */
- if (node->update & NODE_UPDATE_ID)
+ if (node->update & NODE_UPDATE_ID) {
cmp_node_image_verify_outputs(ntree, node, false);
+ }
cmp_node_update_default(ntree, node);
}
@@ -411,8 +423,9 @@ static void node_composit_free_image(bNode *node)
bNodeSocket *sock;
/* free extra socket info */
- for (sock = node->outputs.first; sock; sock = sock->next)
+ for (sock = node->outputs.first; sock; sock = sock->next) {
MEM_freeN(sock->storage);
+ }
MEM_freeN(node->storage);
}
@@ -426,8 +439,9 @@ static void node_composit_copy_image(bNodeTree *UNUSED(dest_ntree),
dest_node->storage = MEM_dupallocN(src_node->storage);
/* copy extra socket info */
- for (sock = src_node->outputs.first; sock; sock = sock->next)
+ for (sock = src_node->outputs.first; sock; sock = sock->next) {
sock->new_sock->storage = MEM_dupallocN(sock->storage);
+ }
}
void register_node_type_cmp_image(void)
@@ -437,7 +451,7 @@ void register_node_type_cmp_image(void)
cmp_node_type_base(&ntype, CMP_NODE_IMAGE, "Image", NODE_CLASS_INPUT, NODE_PREVIEW);
node_type_init(&ntype, node_composit_init_image);
node_type_storage(&ntype, "ImageUser", node_composit_free_image, node_composit_copy_image);
- node_type_update(&ntype, cmp_node_image_update, NULL);
+ node_type_update(&ntype, cmp_node_image_update);
node_type_label(&ntype, node_image_label);
nodeRegisterType(&ntype);
@@ -518,9 +532,11 @@ static bool node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntre
* Render layers node can only be used in local scene->nodetree,
* since it directly links to the scene.
*/
- for (scene = G.main->scenes.first; scene; scene = scene->id.next)
- if (scene->nodetree == ntree)
+ for (scene = G.main->scenes.first; scene; scene = scene->id.next) {
+ if (scene->nodetree == ntree) {
break;
+ }
+ }
return (scene != NULL);
}
@@ -569,7 +585,7 @@ void register_node_type_cmp_rlayers(void)
ntype.initfunc_api = node_composit_init_rlayers;
ntype.poll = node_composit_poll_rlayers;
node_type_storage(&ntype, NULL, node_composit_free_rlayers, node_composit_copy_rlayers);
- node_type_update(&ntype, cmp_node_rlayers_update, NULL);
+ node_type_update(&ntype, cmp_node_rlayers_update);
node_type_init(&ntype, node_cmp_rlayers_outputs);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
index 144fe5c44aa..d4462d937ad 100644
--- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
+++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
@@ -39,10 +39,12 @@ static bNodeSocketTemplate cmp_node_moviedistortion_out[] = {
static void label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
- if (node->custom1 == 0)
+ if (node->custom1 == 0) {
BLI_strncpy(label, IFACE_("Undistortion"), maxlen);
- else
+ }
+ else {
BLI_strncpy(label, IFACE_("Distortion"), maxlen);
+ }
}
static void init(const bContext *C, PointerRNA *ptr)
@@ -55,16 +57,18 @@ static void init(const bContext *C, PointerRNA *ptr)
static void storage_free(bNode *node)
{
- if (node->storage)
+ if (node->storage) {
BKE_tracking_distortion_free(node->storage);
+ }
node->storage = NULL;
}
static void storage_copy(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node)
{
- if (src_node->storage)
+ if (src_node->storage) {
dest_node->storage = BKE_tracking_distortion_copy(src_node->storage);
+ }
}
void register_node_type_cmp_moviedistortion(void)
diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
index 624065fa96d..c700aee1bc1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c
+++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
@@ -46,8 +46,9 @@ static bool unique_path_unique_check(void *arg, const char *name)
for (sock = data->lb->first; sock; sock = sock->next) {
if (sock != data->sock) {
NodeImageMultiFileSocket *sockdata = sock->storage;
- if (STREQ(sockdata->path, name))
+ if (STREQ(sockdata->path, name)) {
return true;
+ }
}
}
return false;
@@ -66,8 +67,9 @@ void ntreeCompositOutputFileUniquePath(ListBase *list,
data.sock = sock;
/* See if we are given an empty string */
- if (ELEM(NULL, sock, defname))
+ if (ELEM(NULL, sock, defname)) {
return;
+ }
sockdata = sock->storage;
BLI_uniquename_cb(
@@ -85,8 +87,9 @@ static bool unique_layer_unique_check(void *arg, const char *name)
for (sock = data->lb->first; sock; sock = sock->next) {
if (sock != data->sock) {
NodeImageMultiFileSocket *sockdata = sock->storage;
- if (STREQ(sockdata->layer, name))
+ if (STREQ(sockdata->layer, name)) {
return true;
+ }
}
}
return false;
@@ -105,8 +108,9 @@ void ntreeCompositOutputFileUniqueLayer(ListBase *list,
data.sock = sock;
/* See if we are given an empty string */
- if (ELEM(NULL, sock, defname))
+ if (ELEM(NULL, sock, defname)) {
return;
+ }
sockdata = sock->storage;
BLI_uniquename_cb(
@@ -137,8 +141,9 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree,
sockdata->format.imtype = R_IMF_IMTYPE_OPENEXR;
}
}
- else
+ else {
BKE_imformat_defaults(&sockdata->format);
+ }
/* use node data format by default */
sockdata->use_node_format = true;
@@ -153,11 +158,13 @@ int ntreeCompositOutputFileRemoveActiveSocket(bNodeTree *ntree, bNode *node)
bNodeSocket *sock = BLI_findlink(&node->inputs, nimf->active_input);
int totinputs = BLI_listbase_count(&node->inputs);
- if (!sock)
+ if (!sock) {
return 0;
+ }
- if (nimf->active_input == totinputs - 1)
+ if (nimf->active_input == totinputs - 1) {
--nimf->active_input;
+ }
/* free format data */
MEM_freeN(sock->storage);
@@ -201,8 +208,9 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
format = &nimf->format;
}
- else
+ else {
BKE_imformat_defaults(&nimf->format);
+ }
/* add one socket by default */
ntreeCompositOutputFileAddSocket(ntree, node, "Image", format);
@@ -273,7 +281,7 @@ void register_node_type_cmp_output_file(void)
node_type_socket_templates(&ntype, NULL, NULL);
ntype.initfunc_api = init_output_file;
node_type_storage(&ntype, "NodeImageMultiFile", free_output_file, copy_output_file);
- node_type_update(&ntype, update_output_file, NULL);
+ node_type_update(&ntype, update_output_file);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c
index 1a0268f2a3e..1304ba4c87a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_scale.c
+++ b/source/blender/nodes/composite/nodes/node_composite_scale.c
@@ -56,7 +56,7 @@ void register_node_type_cmp_scale(void)
cmp_node_type_base(&ntype, CMP_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, 0);
node_type_socket_templates(&ntype, cmp_node_scale_in, cmp_node_scale_out);
- node_type_update(&ntype, node_composite_update_scale, NULL);
+ node_type_update(&ntype, node_composite_update_scale);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
index 82d35dc6118..c850edc49b1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c
@@ -26,11 +26,13 @@
/* **************** SEPARATE YCCA ******************** */
static bNodeSocketTemplate cmp_node_sepycca_in[] = {
{SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {-1, 0, ""}};
-static bNodeSocketTemplate cmp_node_sepycca_out[] = {{SOCK_FLOAT, 0, N_("Y")},
- {SOCK_FLOAT, 0, N_("Cb")},
- {SOCK_FLOAT, 0, N_("Cr")},
- {SOCK_FLOAT, 0, N_("A")},
- {-1, 0, ""}};
+static bNodeSocketTemplate cmp_node_sepycca_out[] = {
+ {SOCK_FLOAT, 0, N_("Y")},
+ {SOCK_FLOAT, 0, N_("Cb")},
+ {SOCK_FLOAT, 0, N_("Cr")},
+ {SOCK_FLOAT, 0, N_("A")},
+ {-1, 0, ""},
+};
static void node_composit_init_mode_sepycca(bNodeTree *UNUSED(ntree), bNode *node)
{
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c
index b3277da2586..045bb1b81ba 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c
@@ -26,11 +26,13 @@
/* **************** SEPARATE YUVA ******************** */
static bNodeSocketTemplate cmp_node_sepyuva_in[] = {
{SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {-1, 0, ""}};
-static bNodeSocketTemplate cmp_node_sepyuva_out[] = {{SOCK_FLOAT, 0, N_("Y")},
- {SOCK_FLOAT, 0, N_("U")},
- {SOCK_FLOAT, 0, N_("V")},
- {SOCK_FLOAT, 0, N_("A")},
- {-1, 0, ""}};
+static bNodeSocketTemplate cmp_node_sepyuva_out[] = {
+ {SOCK_FLOAT, 0, N_("Y")},
+ {SOCK_FLOAT, 0, N_("U")},
+ {SOCK_FLOAT, 0, N_("V")},
+ {SOCK_FLOAT, 0, N_("A")},
+ {-1, 0, ""},
+};
void register_node_type_cmp_sepyuva(void)
{
diff --git a/source/blender/nodes/composite/nodes/node_composite_switchview.c b/source/blender/nodes/composite/nodes/node_composite_switchview.c
index 483185fa76b..12401a8bbdf 100644
--- a/source/blender/nodes/composite/nodes/node_composite_switchview.c
+++ b/source/blender/nodes/composite/nodes/node_composite_switchview.c
@@ -43,8 +43,9 @@ static void cmp_node_switch_view_sanitycheck(bNodeTree *ntree, bNode *node)
{
bNodeSocket *sock;
- if (!BLI_listbase_is_empty(&node->inputs))
+ if (!BLI_listbase_is_empty(&node->inputs)) {
return;
+ }
sock = ntreeCompositSwitchViewAddSocket(ntree, node, "No View");
sock->flag |= SOCK_HIDDEN;
@@ -57,8 +58,9 @@ static void cmp_node_switch_view_update(bNodeTree *ntree, bNode *node)
Scene *scene = (Scene *)node->id;
/* only update when called from the operator button */
- if (node->update != NODE_UPDATE_OPERATOR)
+ if (node->update != NODE_UPDATE_OPERATOR) {
return;
+ }
if (scene == NULL) {
nodeRemoveAllSockets(ntree, node);
@@ -78,10 +80,12 @@ static void cmp_node_switch_view_update(bNodeTree *ntree, bNode *node)
nodeRemoveSocket(ntree, node, sock_del);
}
else {
- if (srv->viewflag & SCE_VIEW_DISABLE)
+ if (srv->viewflag & SCE_VIEW_DISABLE) {
sock->flag |= SOCK_HIDDEN;
- else
+ }
+ else {
sock->flag &= ~SOCK_HIDDEN;
+ }
sock = sock->prev;
}
@@ -91,13 +95,16 @@ static void cmp_node_switch_view_update(bNodeTree *ntree, bNode *node)
for (srv = scene->r.views.first; srv; srv = srv->next) {
sock = BLI_findstring(&node->inputs, srv->name, offsetof(bNodeSocket, name));
- if (sock == NULL)
+ if (sock == NULL) {
sock = ntreeCompositSwitchViewAddSocket(ntree, node, srv->name);
+ }
- if (srv->viewflag & SCE_VIEW_DISABLE)
+ if (srv->viewflag & SCE_VIEW_DISABLE) {
sock->flag |= SOCK_HIDDEN;
- else
+ }
+ else {
sock->flag &= ~SOCK_HIDDEN;
+ }
}
/* make sure there is always one socket */
@@ -122,8 +129,9 @@ static void init_switch_view(const bContext *C, PointerRNA *ptr)
for (nr = 0, srv = rd->views.first; srv; srv = srv->next, nr++) {
sock = ntreeCompositSwitchViewAddSocket(ntree, node, srv->name);
- if ((srv->viewflag & SCE_VIEW_DISABLE))
+ if ((srv->viewflag & SCE_VIEW_DISABLE)) {
sock->flag |= SOCK_HIDDEN;
+ }
}
}
@@ -140,7 +148,7 @@ void register_node_type_cmp_switch_view(void)
ntype.initfunc_api = init_switch_view;
- node_type_update(&ntype, cmp_node_switch_view_update, NULL);
+ node_type_update(&ntype, cmp_node_switch_view_update);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index d9ea6425b01..2b6a89d5e65 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -52,18 +52,22 @@ enum {
bNodeSocket *node_group_find_input_socket(bNode *groupnode, const char *identifier)
{
bNodeSocket *sock;
- for (sock = groupnode->inputs.first; sock; sock = sock->next)
- if (STREQ(sock->identifier, identifier))
+ for (sock = groupnode->inputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->identifier, identifier)) {
return sock;
+ }
+ }
return NULL;
}
bNodeSocket *node_group_find_output_socket(bNode *groupnode, const char *identifier)
{
bNodeSocket *sock;
- for (sock = groupnode->outputs.first; sock; sock = sock->next)
- if (STREQ(sock->identifier, identifier))
+ for (sock = groupnode->outputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->identifier, identifier)) {
return sock;
+ }
+ }
return NULL;
}
@@ -77,13 +81,16 @@ bool node_group_poll_instance(bNode *node, bNodeTree *nodetree)
{
if (node->typeinfo->poll(node->typeinfo, nodetree)) {
bNodeTree *grouptree = (bNodeTree *)node->id;
- if (grouptree)
+ if (grouptree) {
return nodeGroupPoll(nodetree, grouptree);
- else
+ }
+ else {
return true; /* without a linked node tree, group node is always ok */
+ }
}
- else
+ else {
return false;
+ }
}
int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
@@ -94,11 +101,13 @@ int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
/* unspecified node group, generally allowed
* (if anything, should be avoided on operator level)
*/
- if (grouptree == NULL)
+ if (grouptree == NULL) {
return 1;
+ }
- if (nodetree == grouptree)
+ if (nodetree == grouptree) {
return 0;
+ }
for (node = grouptree->nodes.first; node; node = node->next) {
if (node->typeinfo->poll_instance && !node->typeinfo->poll_instance(node, nodetree)) {
@@ -116,20 +125,23 @@ static bNodeSocket *group_verify_socket(
bNodeSocket *sock;
for (sock = verify_lb->first; sock; sock = sock->next) {
- if (STREQ(sock->identifier, iosock->identifier))
+ if (STREQ(sock->identifier, iosock->identifier)) {
break;
+ }
}
if (sock) {
strcpy(sock->name, iosock->name);
- if (iosock->typeinfo->interface_verify_socket)
+ if (iosock->typeinfo->interface_verify_socket) {
iosock->typeinfo->interface_verify_socket(ntree, iosock, gnode, sock, "interface");
+ }
}
else {
sock = nodeAddSocket(ntree, gnode, in_out, iosock->idname, iosock->identifier, iosock->name);
- if (iosock->typeinfo->interface_init_socket)
+ if (iosock->typeinfo->interface_init_socket) {
iosock->typeinfo->interface_init_socket(ntree, iosock, gnode, sock, "interface");
+ }
}
/* remove from list temporarily, to distinguish from orphaned sockets */
@@ -167,18 +179,16 @@ static void group_verify_socket_list(
}
/* make sure all group node in ntree, which use ngroup, are sync'd */
-void node_group_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id)
+void node_group_update(struct bNodeTree *ntree, struct bNode *node)
{
/* check inputs and outputs, and remove or insert them */
- if (id == node->id) {
- if (id == NULL) {
- nodeRemoveAllSockets(ntree, node);
- }
- else {
- bNodeTree *ngroup = (bNodeTree *)node->id;
- group_verify_socket_list(ntree, node, &ngroup->inputs, &node->inputs, SOCK_IN);
- group_verify_socket_list(ntree, node, &ngroup->outputs, &node->outputs, SOCK_OUT);
- }
+ if (node->id == NULL) {
+ nodeRemoveAllSockets(ntree, node);
+ }
+ else {
+ bNodeTree *ngroup = (bNodeTree *)node->id;
+ group_verify_socket_list(ntree, node, &ngroup->inputs, &node->inputs, SOCK_IN);
+ group_verify_socket_list(ntree, node, &ngroup->outputs, &node->outputs, SOCK_OUT);
}
}
@@ -216,8 +226,9 @@ static void node_reroute_update_internal_links(bNodeTree *ntree, bNode *node)
bNodeLink *link;
/* Security check! */
- if (!ntree)
+ if (!ntree) {
return;
+ }
link = MEM_callocN(sizeof(bNodeLink), "internal node link");
link->fromnode = node;
@@ -270,18 +281,22 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
for (link = ntree->links.first; link; link = link->next) {
bNode *fromnode = link->fromnode;
bNode *tonode = link->tonode;
- if (!tonode || !fromnode)
+ if (!tonode || !fromnode) {
continue;
- if (nodeLinkIsHidden(link))
+ }
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
if (flag & REFINE_FORWARD) {
- if (tonode == node && fromnode->type == NODE_REROUTE && !fromnode->done)
+ if (tonode == node && fromnode->type == NODE_REROUTE && !fromnode->done) {
node_reroute_inherit_type_recursive(ntree, fromnode, REFINE_FORWARD);
+ }
}
if (flag & REFINE_BACKWARD) {
- if (fromnode == node && tonode->type == NODE_REROUTE && !tonode->done)
+ if (fromnode == node && tonode->type == NODE_REROUTE && !tonode->done) {
node_reroute_inherit_type_recursive(ntree, tonode, REFINE_BACKWARD);
+ }
}
}
@@ -327,12 +342,15 @@ void ntree_update_reroute_nodes(bNodeTree *ntree)
bNode *node;
/* clear tags */
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
node->done = 0;
+ }
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->type == NODE_REROUTE && !node->done)
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == NODE_REROUTE && !node->done) {
node_reroute_inherit_type_recursive(ntree, node, REFINE_FORWARD | REFINE_BACKWARD);
+ }
+ }
}
static bool node_is_connected_to_output_recursive(bNodeTree *ntree, bNode *node)
@@ -340,19 +358,22 @@ static bool node_is_connected_to_output_recursive(bNodeTree *ntree, bNode *node)
bNodeLink *link;
/* avoid redundant checks, and infinite loops in case of cyclic node links */
- if (node->done)
+ if (node->done) {
return false;
+ }
node->done = 1;
/* main test, done before child loop so it catches output nodes themselves as well */
- if (node->typeinfo->nclass == NODE_CLASS_OUTPUT && node->flag & NODE_DO_OUTPUT)
+ if (node->typeinfo->nclass == NODE_CLASS_OUTPUT && node->flag & NODE_DO_OUTPUT) {
return true;
+ }
/* test all connected nodes, first positive find is sufficient to return true */
for (link = ntree->links.first; link; link = link->next) {
if (link->fromnode == node) {
- if (node_is_connected_to_output_recursive(ntree, link->tonode))
+ if (node_is_connected_to_output_recursive(ntree, link->tonode)) {
return true;
+ }
}
}
return false;
@@ -363,8 +384,9 @@ bool BKE_node_is_connected_to_output(bNodeTree *ntree, bNode *node)
bNode *tnode;
/* clear flags */
- for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
+ for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
tnode->done = 0;
+ }
return node_is_connected_to_output_recursive(ntree, node);
}
@@ -384,31 +406,21 @@ void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree)
static void node_group_input_init(bNodeTree *ntree, bNode *node)
{
- node_group_input_verify(ntree, node, (ID *)ntree);
+ node_group_input_update(ntree, node);
}
bNodeSocket *node_group_input_find_socket(bNode *node, const char *identifier)
{
bNodeSocket *sock;
- for (sock = node->outputs.first; sock; sock = sock->next)
- if (STREQ(sock->identifier, identifier))
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->identifier, identifier)) {
return sock;
- return NULL;
-}
-
-void node_group_input_verify(bNodeTree *ntree, bNode *node, ID *id)
-{
- /* check inputs and outputs, and remove or insert them */
- if (id == (ID *)ntree) {
- /* value_in_out inverted for interface nodes to get correct socket value_property */
- group_verify_socket_list(ntree, node, &ntree->inputs, &node->outputs, SOCK_OUT);
-
- /* add virtual extension socket */
- nodeAddSocket(ntree, node, SOCK_OUT, "NodeSocketVirtual", "__extend__", "");
+ }
}
+ return NULL;
}
-static void node_group_input_update(bNodeTree *ntree, bNode *node)
+void node_group_input_update(bNodeTree *ntree, bNode *node)
{
bNodeSocket *extsock = node->outputs.last;
bNodeLink *link, *linknext, *exposelink;
@@ -422,8 +434,9 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
BLI_listbase_clear(&tmplinks);
for (link = ntree->links.first; link; link = linknext) {
linknext = link->next;
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
if (link->fromsock == extsock) {
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
@@ -453,7 +466,7 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->tonode, exposelink->tosock);
- node_group_input_verify(ntree, node, (ID *)ntree);
+ node_group_input_update(ntree, node);
newsock = node_group_input_find_socket(node, gsock->identifier);
/* redirect links from the extension socket */
@@ -463,6 +476,15 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
}
BLI_freelistN(&tmplinks);
+
+ /* check inputs and outputs, and remove or insert them */
+ {
+ /* value_in_out inverted for interface nodes to get correct socket value_property */
+ group_verify_socket_list(ntree, node, &ntree->inputs, &node->outputs, SOCK_OUT);
+
+ /* add virtual extension socket */
+ nodeAddSocket(ntree, node, SOCK_OUT, "NodeSocketVirtual", "__extend__", "");
+ }
}
void register_node_type_group_input(void)
@@ -473,7 +495,7 @@ void register_node_type_group_input(void)
node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE, 0);
node_type_size(ntype, 140, 80, 400);
node_type_init(ntype, node_group_input_init);
- node_type_update(ntype, node_group_input_update, node_group_input_verify);
+ node_type_update(ntype, node_group_input_update);
ntype->needs_free = 1;
nodeRegisterType(ntype);
@@ -481,31 +503,21 @@ void register_node_type_group_input(void)
static void node_group_output_init(bNodeTree *ntree, bNode *node)
{
- node_group_output_verify(ntree, node, (ID *)ntree);
+ node_group_output_update(ntree, node);
}
bNodeSocket *node_group_output_find_socket(bNode *node, const char *identifier)
{
bNodeSocket *sock;
- for (sock = node->inputs.first; sock; sock = sock->next)
- if (STREQ(sock->identifier, identifier))
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->identifier, identifier)) {
return sock;
- return NULL;
-}
-
-void node_group_output_verify(bNodeTree *ntree, bNode *node, ID *id)
-{
- /* check inputs and outputs, and remove or insert them */
- if (id == (ID *)ntree) {
- /* value_in_out inverted for interface nodes to get correct socket value_property */
- group_verify_socket_list(ntree, node, &ntree->outputs, &node->inputs, SOCK_IN);
-
- /* add virtual extension socket */
- nodeAddSocket(ntree, node, SOCK_IN, "NodeSocketVirtual", "__extend__", "");
+ }
}
+ return NULL;
}
-static void node_group_output_update(bNodeTree *ntree, bNode *node)
+void node_group_output_update(bNodeTree *ntree, bNode *node)
{
bNodeSocket *extsock = node->inputs.last;
bNodeLink *link, *linknext, *exposelink;
@@ -519,8 +531,9 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
BLI_listbase_clear(&tmplinks);
for (link = ntree->links.first; link; link = linknext) {
linknext = link->next;
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
if (link->tosock == extsock) {
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
@@ -551,7 +564,7 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
/* XXX what if connecting virtual to virtual socket?? */
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->fromnode, exposelink->fromsock);
- node_group_output_verify(ntree, node, (ID *)ntree);
+ node_group_output_update(ntree, node);
newsock = node_group_output_find_socket(node, gsock->identifier);
/* redirect links to the extension socket */
@@ -561,6 +574,15 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
}
BLI_freelistN(&tmplinks);
+
+ /* check inputs and outputs, and remove or insert them */
+ {
+ /* value_in_out inverted for interface nodes to get correct socket value_property */
+ group_verify_socket_list(ntree, node, &ntree->outputs, &node->inputs, SOCK_IN);
+
+ /* add virtual extension socket */
+ nodeAddSocket(ntree, node, SOCK_IN, "NodeSocketVirtual", "__extend__", "");
+ }
}
void register_node_type_group_output(void)
@@ -571,7 +593,7 @@ void register_node_type_group_output(void)
node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE, 0);
node_type_size(ntype, 140, 80, 400);
node_type_init(ntype, node_group_output_init);
- node_type_update(ntype, node_group_output_update, node_group_output_verify);
+ node_type_update(ntype, node_group_output_update);
ntype->needs_free = 1;
nodeRegisterType(ntype);
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index ed3dbf4515b..24376e39f3d 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -44,8 +44,9 @@ int node_exec_socket_use_stack(bNodeSocket *sock)
/* for a given socket, find the actual stack entry */
bNodeStack *node_get_socket_stack(bNodeStack *stack, bNodeSocket *sock)
{
- if (stack && sock && sock->stack_index >= 0)
+ if (stack && sock && sock->stack_index >= 0) {
return stack + sock->stack_index;
+ }
return NULL;
}
@@ -74,10 +75,12 @@ static void node_init_input_index(bNodeSocket *sock, int *index)
sock->stack_index = sock->link->fromsock->stack_index;
}
else {
- if (node_exec_socket_use_stack(sock))
+ if (node_exec_socket_use_stack(sock)) {
sock->stack_index = (*index)++;
- else
+ }
+ else {
sock->stack_index = -1;
+ }
}
}
@@ -98,17 +101,21 @@ static void node_init_output_index(bNodeSocket *sock, int *index, ListBase *inte
}
/* if not internally connected, assign a new stack index anyway to avoid bad stack access */
if (!link) {
- if (node_exec_socket_use_stack(sock))
+ if (node_exec_socket_use_stack(sock)) {
sock->stack_index = (*index)++;
- else
+ }
+ else {
sock->stack_index = -1;
+ }
}
}
else {
- if (node_exec_socket_use_stack(sock))
+ if (node_exec_socket_use_stack(sock)) {
sock->stack_index = (*index)++;
- else
+ }
+ else {
sock->stack_index = -1;
+ }
}
}
@@ -119,12 +126,14 @@ static struct bNodeStack *setup_stack(bNodeStack *stack,
bNodeSocket *sock)
{
bNodeStack *ns = node_get_socket_stack(stack, sock);
- if (!ns)
+ if (!ns) {
return NULL;
+ }
/* don't mess with remote socket stacks, these are initialized by other nodes! */
- if (sock->link)
+ if (sock->link) {
return ns;
+ }
ns->sockettype = sock->type;
@@ -160,7 +169,8 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
/* ensure all sock->link pointers and node levels are correct */
/* Using global main here is likely totally wrong, not sure what to do about that one though...
- * We cannot even check ntree is in global main, since most of the time it won't be (thanks to ntree design)!!! */
+ * We cannot even check ntree is in global main,
+ * since most of the time it won't be (thanks to ntree design)!!! */
ntreeUpdateTree(G.main, ntree);
/* get a dependency-sorted list of nodes */
@@ -179,16 +189,19 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
node->stack_index = index;
/* init node socket stack indexes */
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
node_init_input_index(sock, &index);
+ }
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
- for (sock = node->outputs.first; sock; sock = sock->next)
+ for (sock = node->outputs.first; sock; sock = sock->next) {
node_init_output_index(sock, &index, &node->internal_links);
+ }
}
else {
- for (sock = node->outputs.first; sock; sock = sock->next)
+ for (sock = node->outputs.first; sock; sock = sock->next) {
node_init_output_index(sock, &index, NULL);
+ }
}
}
@@ -200,8 +213,9 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
exec->stack = MEM_callocN(exec->stacksize * sizeof(bNodeStack), "bNodeStack");
/* all non-const results are considered inputs */
- for (n = 0; n < exec->stacksize; ++n)
+ for (n = 0; n < exec->stacksize; ++n) {
exec->stack[n].hasinput = 1;
+ }
/* prepare all nodes for execution */
for (n = 0, nodeexec = exec->nodeexec; n < totnodes; ++n, ++nodeexec) {
@@ -211,12 +225,14 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
/* tag inputs */
for (sock = node->inputs.first; sock; sock = sock->next) {
/* disable the node if an input link is invalid */
- if (sock->link && !(sock->link->flag & NODE_LINK_VALID))
+ if (sock->link && !(sock->link->flag & NODE_LINK_VALID)) {
node->need_exec = 0;
+ }
ns = setup_stack(exec->stack, ntree, node, sock);
- if (ns)
+ if (ns) {
ns->hasoutput = 1;
+ }
}
/* tag all outputs */
@@ -228,12 +244,14 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
nodeexec->data.preview = context->previews ?
BKE_node_instance_hash_lookup(context->previews, nodekey) :
NULL;
- if (node->typeinfo->initexecfunc)
+ if (node->typeinfo->initexecfunc) {
nodeexec->data.data = node->typeinfo->initexecfunc(context, node, nodekey);
+ }
}
- if (nodelist)
+ if (nodelist) {
MEM_freeN(nodelist);
+ }
return exec;
}
@@ -243,16 +261,19 @@ void ntree_exec_end(bNodeTreeExec *exec)
bNodeExec *nodeexec;
int n;
- if (exec->stack)
+ if (exec->stack) {
MEM_freeN(exec->stack);
+ }
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
- if (nodeexec->freeexecfunc)
+ if (nodeexec->freeexecfunc) {
nodeexec->freeexecfunc(nodeexec->data.data);
+ }
}
- if (exec->nodeexec)
+ if (exec->nodeexec) {
MEM_freeN(exec->nodeexec);
+ }
MEM_freeN(exec);
}
@@ -304,8 +325,9 @@ bool ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call
* If the mute func is not set, assume the node should never be muted,
* and hence execute it!
*/
- if (node->typeinfo->execfunc && !(node->flag & NODE_MUTED))
+ if (node->typeinfo->execfunc && !(node->flag & NODE_MUTED)) {
node->typeinfo->execfunc(callerdata, thread, node, &nodeexec->data, nsin, nsout);
+ }
}
}
diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h
index 336a8f26ec3..07c12dc7c46 100644
--- a/source/blender/nodes/intern/node_exec.h
+++ b/source/blender/nodes/intern/node_exec.h
@@ -40,11 +40,12 @@ struct bNodeTree;
/* Node execution data */
typedef struct bNodeExec {
- struct bNode *node; /* backpointer to node */
+ /** Backpointer to node. */
+ struct bNode *node;
bNodeExecData data;
- NodeFreeExecFunction
- freeexecfunc; /* free function, stored in exec itself to avoid dangling node pointer access */
+ /** Free function, stored in exec itself to avoid dangling node pointer access. */
+ NodeFreeExecFunction freeexecfunc;
} bNodeExec;
/* Execution Data for each instance of node tree execution */
diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c
index 9fe6e0bcecb..8aeada7bde0 100644
--- a/source/blender/nodes/intern/node_socket.c
+++ b/source/blender/nodes/intern/node_socket.c
@@ -100,8 +100,9 @@ static bNodeSocket *verify_socket_template(
bNodeSocket *sock;
for (sock = socklist->first; sock; sock = sock->next) {
- if (STREQLEN(sock->name, stemp->name, NODE_MAXSTR))
+ if (STREQLEN(sock->name, stemp->name, NODE_MAXSTR)) {
break;
+ }
}
if (sock) {
if (sock->type != stemp->type) {
@@ -182,10 +183,12 @@ void node_verify_socket_templates(bNodeTree *ntree, bNode *node)
* render layer node since it still has fixed sockets too.
*/
if (ntype) {
- if (ntype->inputs && ntype->inputs[0].type >= 0)
+ if (ntype->inputs && ntype->inputs[0].type >= 0) {
verify_socket_template_list(ntree, node, SOCK_IN, &node->inputs, ntype->inputs);
- if (ntype->outputs && ntype->outputs[0].type >= 0 && node->type != CMP_NODE_R_LAYERS)
+ }
+ if (ntype->outputs && ntype->outputs[0].type >= 0 && node->type != CMP_NODE_R_LAYERS) {
verify_socket_template_list(ntree, node, SOCK_OUT, &node->outputs, ntype->outputs);
+ }
}
}
@@ -194,8 +197,9 @@ void node_socket_init_default_value(bNodeSocket *sock)
int type = sock->typeinfo->type;
int subtype = sock->typeinfo->subtype;
- if (sock->default_value)
+ if (sock->default_value) {
return; /* already initialized */
+ }
switch (type) {
case SOCK_FLOAT: {
@@ -264,12 +268,14 @@ void node_socket_init_default_value(bNodeSocket *sock)
void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
{
/* sanity check */
- if (to->type != from->type)
+ if (to->type != from->type) {
return;
+ }
/* make sure both exist */
- if (!from->default_value)
+ if (!from->default_value) {
return;
+ }
node_socket_init_default_value(to);
switch (from->typeinfo->type) {
@@ -339,12 +345,14 @@ static void standard_node_socket_interface_verify_socket(bNodeTree *UNUSED(ntree
const char *UNUSED(data_path))
{
/* sanity check */
- if (sock->type != stemp->typeinfo->type)
+ if (sock->type != stemp->typeinfo->type) {
return;
+ }
/* make sure both exist */
- if (!stemp->default_value)
+ if (!stemp->default_value) {
return;
+ }
node_socket_init_default_value(sock);
switch (stemp->typeinfo->type) {
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index a4a39caf8df..6ad1c9b6925 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -86,7 +86,8 @@ void node_blend_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int ma
void node_image_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
- /* if there is no loaded image, return an empty string, and let nodeLabel() fill in the proper type translation. */
+ /* If there is no loaded image, return an empty string,
+ * and let nodeLabel() fill in the proper type translation. */
BLI_strncpy(label, (node->id) ? node->id->name + 2 : "", maxlen);
}
@@ -131,8 +132,9 @@ static bool node_link_socket_match(bNodeSocket *a, bNodeSocket *b)
/* end of common prefix? */
if (*ca != *cb) {
/* prefix delimited by non-alphabetic char */
- if (isalpha(*ca) || isalpha(*cb))
+ if (isalpha(*ca) || isalpha(*cb)) {
return false;
+ }
break;
}
++prefix_len;
@@ -145,10 +147,12 @@ static int node_count_links(bNodeTree *ntree, bNodeSocket *sock)
bNodeLink *link;
int count = 0;
for (link = ntree->links.first; link; link = link->next) {
- if (link->fromsock == sock)
+ if (link->fromsock == sock) {
++count;
- if (link->tosock == sock)
+ }
+ if (link->tosock == sock) {
++count;
+ }
}
return count;
}
@@ -166,8 +170,9 @@ static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNo
if (!nodeSocketIsHidden(sock) && node_link_socket_match(sock, cur)) {
int link_count = node_count_links(ntree, sock);
/* take +1 into account since we would add a new link */
- if (link_count + 1 <= sock->limit)
+ if (link_count + 1 <= sock->limit) {
return sock; /* found a valid free socket we can swap to */
+ }
}
sock = sock->next ? sock->next : first; /* wrap around the list end */
@@ -181,15 +186,17 @@ void node_insert_link_default(bNodeTree *ntree, bNode *node, bNodeLink *link)
bNodeLink *tlink, *tlink_next;
/* inputs can have one link only, outputs can have unlimited links */
- if (node != link->tonode)
+ if (node != link->tonode) {
return;
+ }
for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
bNodeSocket *new_sock;
tlink_next = tlink->next;
- if (sock != tlink->tosock)
+ if (sock != tlink->tosock) {
continue;
+ }
new_sock = node_find_linkable_socket(ntree, node, sock);
if (new_sock && new_sock != sock) {
@@ -346,22 +353,27 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
bNodeSocket *output, *input;
/* sanity check */
- if (!ntree)
+ if (!ntree) {
return;
+ }
/* use link pointer as a tag for handled sockets (for outputs is unused anyway) */
- for (output = node->outputs.first; output; output = output->next)
+ for (output = node->outputs.first; output; output = output->next) {
output->link = NULL;
+ }
for (link = ntree->links.first; link; link = link->next) {
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
output = link->fromsock;
- if (link->fromnode != node || output->link)
+ if (link->fromnode != node || output->link) {
continue;
- if (nodeSocketIsHidden(output) || output->flag & SOCK_NO_INTERNAL_LINK)
+ }
+ if (nodeSocketIsHidden(output) || output->flag & SOCK_NO_INTERNAL_LINK) {
continue;
+ }
output->link = link; /* not really used, just for tagging handled sockets */
/* look for suitable input */
@@ -380,8 +392,9 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
}
/* clean up */
- for (output = node->outputs.first; output; output = output->next)
+ for (output = node->outputs.first; output; output = output->next) {
output->link = NULL;
+ }
}
/**** Default value RNA access ****/
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 816c56713d0..05ca9394786 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -68,7 +68,8 @@ static bool shader_tree_poll(const bContext *C, bNodeTreeType *UNUSED(treetype))
Scene *scene = CTX_data_scene(C);
const char *engine_id = scene->r.engine;
- /* allow empty engine string too, this is from older versions that didn't have registerable engines yet */
+ /* Allow empty engine string too,
+ * this is from older versions that didn't have registerable engines yet. */
return (engine_id[0] == '\0' || STREQ(engine_id, RE_engine_id_CYCLES) ||
!BKE_scene_use_shading_nodes_custom(scene));
}
@@ -235,8 +236,8 @@ static bNode *ntree_shader_relink_output_from_group(bNodeTree *ntree,
}
/* Need to update tree so all node instances nodes gets proper sockets. */
- node_group_verify(ntree, group_node, &group_ntree->id);
- node_group_output_verify(group_ntree, group_output_node, &group_ntree->id);
+ node_group_update(ntree, group_node);
+ node_group_output_update(group_ntree, group_output_node);
ntreeUpdateTree(G.main, group_ntree);
/* Remove other shader output nodes so that only the new one can be selected as active. */
@@ -408,8 +409,9 @@ static void ntree_shader_unlink_hidden_value_sockets(bNode *group_node, bNodeSoc
for (node = group_ntree->nodes.first; node; node = node->next) {
for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
- if ((sock->flag & SOCK_HIDE_VALUE) == 0)
+ if ((sock->flag & SOCK_HIDE_VALUE) == 0) {
continue;
+ }
/* If socket is linked to a group input node and sockets id match. */
if (sock && sock->link && sock->link->fromnode->type == NODE_GROUP_INPUT) {
if (STREQ(isock->identifier, sock->link->fromsock->identifier)) {
@@ -439,16 +441,18 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
for (group_node = localtree->nodes.first; group_node; group_node = group_node->next) {
- if (!(ELEM(group_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) || group_node->id == NULL)
+ if (!(ELEM(group_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) || group_node->id == NULL) {
continue;
+ }
/* Do it recursively. */
ntree_shader_groups_expand_inputs((bNodeTree *)group_node->id);
bNodeSocket *group_socket = group_node->inputs.first;
for (; group_socket; group_socket = group_socket->next) {
- if (group_socket->link != NULL)
+ if (group_socket->link != NULL) {
continue;
+ }
/* Detect the case where an input is plugged into a hidden value socket.
* In this case we should just remove the link to trigger the socket default override. */
@@ -573,9 +577,10 @@ static void ntree_shader_link_builtin_group_normal(bNodeTree *ntree,
group_ntree, SOCK_IN, "NodeSocketVector", "Normal");
/* Need to update tree so all node instances nodes gets proper sockets. */
bNode *group_input_node = ntreeFindType(group_ntree, NODE_GROUP_INPUT);
- node_group_verify(ntree, group_node, &group_ntree->id);
- if (group_input_node)
- node_group_input_verify(group_ntree, group_input_node, &group_ntree->id);
+ node_group_update(ntree, group_node);
+ if (group_input_node) {
+ node_group_input_update(group_ntree, group_input_node);
+ }
ntreeUpdateTree(G.main, group_ntree);
/* Assumes sockets are always added at the end. */
bNodeSocket *group_node_normal_socket = group_node->inputs.last;
@@ -849,8 +854,9 @@ bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context,
/* allocate the thread stack listbase array */
exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array");
- for (node = exec->nodetree->nodes.first; node; node = node->next)
+ for (node = exec->nodetree->nodes.first; node; node = node->next) {
node->need_exec = 1;
+ }
return exec;
}
@@ -863,8 +869,9 @@ bNodeTreeExec *ntreeShaderBeginExecTree(bNodeTree *ntree)
/* XXX hack: prevent exec data from being generated twice.
* this should be handled by the renderer!
*/
- if (ntree->execdata)
+ if (ntree->execdata) {
return ntree->execdata;
+ }
context.previews = ntree->previews;
@@ -885,9 +892,11 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec)
if (exec->threadstack) {
for (a = 0; a < BLENDER_MAX_THREADS; a++) {
- for (nts = exec->threadstack[a].first; nts; nts = nts->next)
- if (nts->stack)
+ for (nts = exec->threadstack[a].first; nts; nts = nts->next) {
+ if (nts->stack) {
MEM_freeN(nts->stack);
+ }
+ }
BLI_freelistN(&exec->threadstack[a]);
}
@@ -921,8 +930,9 @@ bool ntreeShaderExecTree(bNodeTree *ntree, int thread)
/* ensure execdata is only initialized once */
if (!exec) {
BLI_thread_lock(LOCK_NODES);
- if (!ntree->execdata)
+ if (!ntree->execdata) {
ntree->execdata = ntreeShaderBeginExecTree(ntree);
+ }
BLI_thread_unlock(LOCK_NODES);
exec = ntree->execdata;
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index a29962843af..2e8f81979a8 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -49,10 +49,12 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
const float *from = ns->vec;
if (type_in == SOCK_FLOAT) {
- if (ns->sockettype == SOCK_FLOAT)
+ if (ns->sockettype == SOCK_FLOAT) {
*in = *from;
- else
+ }
+ else {
*in = (from[0] + from[1] + from[2]) / 3.0f;
+ }
}
else if (type_in == SOCK_VECTOR) {
if (ns->sockettype == SOCK_FLOAT) {
@@ -86,7 +88,8 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
memset(gs, 0, sizeof(*gs));
if (ns == NULL) {
- /* node_get_stack() will generate NULL bNodeStack pointers for unknown/unsupported types of sockets... */
+ /* node_get_stack() will generate NULL bNodeStack pointers
+ * for unknown/unsupported types of sockets. */
zero_v4(gs->vec);
gs->link = NULL;
gs->type = GPU_NONE;
@@ -98,18 +101,24 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
nodestack_get_vec(gs->vec, type, ns);
gs->link = ns->data;
- if (type == SOCK_FLOAT)
+ if (type == SOCK_FLOAT) {
gs->type = GPU_FLOAT;
- else if (type == SOCK_INT)
+ }
+ else if (type == SOCK_INT) {
gs->type = GPU_FLOAT; /* HACK: Support as float. */
- else if (type == SOCK_VECTOR)
+ }
+ else if (type == SOCK_VECTOR) {
gs->type = GPU_VEC3;
- else if (type == SOCK_RGBA)
+ }
+ else if (type == SOCK_RGBA) {
gs->type = GPU_VEC4;
- else if (type == SOCK_SHADER)
+ }
+ else if (type == SOCK_SHADER) {
gs->type = GPU_CLOSURE;
- else
+ }
+ else {
gs->type = GPU_NONE;
+ }
gs->hasinput = ns->hasinput && ns->data;
/* XXX Commented out the ns->data check here, as it seems it's not always set,
@@ -133,8 +142,9 @@ static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeS
bNodeSocket *sock;
int i;
- for (sock = sockets->first, i = 0; sock; sock = sock->next, i++)
+ for (sock = sockets->first, i = 0; sock; sock = sock->next, i++) {
node_gpu_stack_from_data(&gs[i], sock->type, ns[i]);
+ }
gs[i].end = true;
}
@@ -144,8 +154,9 @@ static void data_from_gpu_stack_list(ListBase *sockets, bNodeStack **ns, GPUNode
bNodeSocket *sock;
int i;
- for (sock = sockets->first, i = 0; sock; sock = sock->next, i++)
+ for (sock = sockets->first, i = 0; sock; sock = sock->next, i++) {
node_data_from_gpu_stack(ns[i], &gs[i]);
+ }
}
bNode *nodeGetActiveTexture(bNodeTree *ntree)
@@ -154,23 +165,28 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
bNode *node, *tnode, *inactivenode = NULL, *activetexnode = NULL, *activegroup = NULL;
bool hasgroup = false;
- if (!ntree)
+ if (!ntree) {
return NULL;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
if (node->flag & NODE_ACTIVE_TEXTURE) {
activetexnode = node;
/* if active we can return immediately */
- if (node->flag & NODE_ACTIVE)
+ if (node->flag & NODE_ACTIVE) {
return node;
+ }
}
- else if (!inactivenode && node->typeinfo->nclass == NODE_CLASS_TEXTURE)
+ else if (!inactivenode && node->typeinfo->nclass == NODE_CLASS_TEXTURE) {
inactivenode = node;
+ }
else if (node->type == NODE_GROUP) {
- if (node->flag & NODE_ACTIVE)
+ if (node->flag & NODE_ACTIVE) {
activegroup = node;
- else
+ }
+ else {
hasgroup = true;
+ }
}
}
@@ -178,20 +194,23 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
if (activegroup) {
tnode = nodeGetActiveTexture((bNodeTree *)activegroup->id);
/* active node takes priority, so ignore any other possible nodes here */
- if (tnode)
+ if (tnode) {
return tnode;
+ }
}
- if (activetexnode)
+ if (activetexnode) {
return activetexnode;
+ }
if (hasgroup) {
/* node active texture node in this tree, look inside groups */
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP) {
tnode = nodeGetActiveTexture((bNodeTree *)node->id);
- if (tnode && ((tnode->flag & NODE_ACTIVE_TEXTURE) || !inactivenode))
+ if (tnode && ((tnode->flag & NODE_ACTIVE_TEXTURE) || !inactivenode)) {
return tnode;
+ }
}
}
}
@@ -218,8 +237,9 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node
do_it = false;
/* for groups, only execute outputs for edited group */
if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) {
- if ((output_node != NULL) && (node == output_node))
+ if ((output_node != NULL) && (node == output_node)) {
do_it = true;
+ }
}
else {
do_it = true;
@@ -230,8 +250,9 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node
node_get_stack(node, stack, nsin, nsout);
gpu_stack_from_data_list(gpuin, &node->inputs, nsin);
gpu_stack_from_data_list(gpuout, &node->outputs, nsout);
- if (node->typeinfo->gpufunc(mat, node, &nodeexec->data, gpuin, gpuout))
+ if (node->typeinfo->gpufunc(mat, node, &nodeexec->data, gpuin, gpuout)) {
data_from_gpu_stack_list(&node->outputs, nsout, gpuout);
+ }
}
}
}
@@ -261,7 +282,8 @@ void node_shader_gpu_tex_mapping(GPUMaterial *mat,
GPU_link(mat, "mapping", in[0].link, tmat0, tmat1, tmat2, tmat3, tmin, tmax, &in[0].link);
- if (texmap->type == TEXMAP_TYPE_NORMAL)
+ if (texmap->type == TEXMAP_TYPE_NORMAL) {
GPU_link(mat, "texco_norm", in[0].link, &in[0].link);
+ }
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
index 84dda89c47d..f54d2563623 100644
--- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
+++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
@@ -50,8 +50,9 @@ static int node_shader_gpu_ambient_occlusion(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[2].link)
+ if (!in[2].link) {
GPU_link(mat, "world_normals_get", &in[2].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index 489bb8c3557..ec1bb988c1c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -42,7 +42,8 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
{
NodeShaderAttribute *attr = node->storage;
- /* FIXME : if an attribute layer (like vertex color) has one of theses name, it will not work as expected. */
+ /* FIXME : if an attribute layer (like vertex color) has one of theses name,
+ * it will not work as expected. */
if (strcmp(attr->name, "density") == 0) {
return GPU_stack_link(
mat, node, "node_attribute_volume_density", in, out, GPU_builtin(GPU_VOLUME_DENSITY));
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
index dc92af5ee48..117c903a161 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
@@ -67,8 +67,9 @@ static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[4].link)
+ if (!in[4].link) {
GPU_link(mat, "world_normals_get", &in[4].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
index 5ed02a275f1..5d1a8d0990a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
@@ -49,8 +49,9 @@ static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[2].link)
+ if (!in[2].link) {
GPU_link(mat, "world_normals_get", &in[2].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
index 682fddc1f9d..ffeda75d366 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
@@ -55,8 +55,9 @@ static int node_shader_gpu_bsdf_glass(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[3].link)
+ if (!in[3].link) {
GPU_link(mat, "world_normals_get", &in[3].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY | GPU_MATFLAG_REFRACT);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
index 97c1afbbee2..9200a6c468c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
@@ -54,11 +54,13 @@ static int node_shader_gpu_bsdf_glossy(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[2].link)
+ if (!in[2].link) {
GPU_link(mat, "world_normals_get", &in[2].link);
+ }
- if (node->custom1 == SHD_GLOSSY_SHARP)
+ if (node->custom1 == SHD_GLOSSY_SHARP) {
GPU_link(mat, "set_value_zero", &in[1].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
index ce90933fcc4..4f78f2b6a76 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
@@ -129,7 +129,7 @@ void register_node_type_sh_bsdf_hair_principled(void)
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_init(&ntype, node_shader_init_hair_principled);
node_type_storage(&ntype, "", NULL, NULL);
- node_type_update(&ntype, node_shader_update_hair_principled, NULL);
+ node_type_update(&ntype, node_shader_update_hair_principled);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
index e0fda117648..37c35c0adc8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
@@ -196,10 +196,12 @@ static void node_shader_update_principled(bNodeTree *UNUSED(ntree), bNode *node)
for (sock = node->inputs.first; sock; sock = sock->next) {
if (STREQ(sock->name, "Transmission Roughness")) {
- if (distribution == SHD_GLOSSY_GGX)
+ if (distribution == SHD_GLOSSY_GGX) {
sock->flag &= ~SOCK_UNAVAIL;
- else
+ }
+ else {
sock->flag |= SOCK_UNAVAIL;
+ }
}
}
}
@@ -215,7 +217,7 @@ void register_node_type_sh_bsdf_principled(void)
node_type_init(&ntype, node_shader_init_principled);
node_type_storage(&ntype, "", NULL, NULL);
node_type_gpu(&ntype, node_shader_gpu_bsdf_principled);
- node_type_update(&ntype, node_shader_update_principled, NULL);
+ node_type_update(&ntype, node_shader_update_principled);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
index 2d740cab776..4d98c62f95c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
@@ -55,11 +55,13 @@ static int node_shader_gpu_bsdf_refraction(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[3].link)
+ if (!in[3].link) {
GPU_link(mat, "world_normals_get", &in[3].link);
+ }
- if (node->custom1 == SHD_GLOSSY_SHARP)
+ if (node->custom1 == SHD_GLOSSY_SHARP) {
GPU_link(mat, "set_value_zero", &in[1].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_REFRACT);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
index 8ec80be748e..b5faf1df913 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
@@ -50,8 +50,9 @@ static int node_shader_gpu_bsdf_toon(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[3].link)
+ if (!in[3].link) {
GPU_link(mat, "world_normals_get", &in[3].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
index 6e2556d7446..993a5b3d945 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
@@ -48,8 +48,9 @@ static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[1].link)
+ if (!in[1].link) {
GPU_link(mat, "world_normals_get", &in[1].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
index d4cb444cf08..97c2c9bc084 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
@@ -49,8 +49,9 @@ static int node_shader_gpu_bsdf_velvet(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[2].link)
+ if (!in[2].link) {
GPU_link(mat, "world_normals_get", &in[2].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c
index 3f95d31841e..cee4d2505b2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -67,8 +67,9 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc
bNodeTree *ngroup = (bNodeTree *)node->id;
bNodeTreeExec *exec;
- if (!ngroup)
+ if (!ngroup) {
return NULL;
+ }
/* initialize the internal node tree execution */
exec = ntreeShaderBeginExecTree_internal(context, ngroup, key);
@@ -80,8 +81,9 @@ static void group_freeexec(void *nodedata)
{
bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata;
- if (gexec)
+ if (gexec) {
ntreeShaderEndExecTree_internal(gexec);
+ }
}
/* Copy inputs to the internal stack.
@@ -98,8 +100,9 @@ static void group_copy_inputs(bNode *gnode, bNodeStack **in, bNodeStack *gstack)
if (node->type == NODE_GROUP_INPUT) {
for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) {
ns = node_get_socket_stack(gstack, sock);
- if (ns)
+ if (ns) {
copy_stack(ns, in[a]);
+ }
}
}
}
@@ -119,8 +122,9 @@ static void group_move_outputs(bNode *gnode, bNodeStack **out, bNodeStack *gstac
if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) {
for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) {
ns = node_get_socket_stack(gstack, sock);
- if (ns)
+ if (ns) {
move_stack(out[a], ns);
+ }
}
break; /* only one active output node */
}
@@ -137,16 +141,18 @@ static void group_execute(void *data,
bNodeTreeExec *exec = execdata->data;
bNodeThreadStack *nts;
- if (!exec)
+ if (!exec) {
return;
+ }
/* XXX same behavior as trunk: all nodes inside group are executed.
* it's stupid, but just makes it work. compo redesign will do this better.
*/
{
bNode *inode;
- for (inode = exec->nodetree->nodes.first; inode; inode = inode->next)
+ for (inode = exec->nodetree->nodes.first; inode; inode = inode->next) {
inode->need_exec = 1;
+ }
}
nts = ntreeGetThreadStack(exec, thread);
@@ -208,8 +214,9 @@ static int gpu_group_execute(
{
bNodeTreeExec *exec = execdata->data;
- if (!node->id)
+ if (!node->id) {
return 0;
+ }
group_gpu_copy_inputs(node, in, exec->stack);
ntreeExecGPUNodes(exec, mat, NULL);
@@ -238,7 +245,7 @@ void register_node_type_sh_group(void)
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
- node_type_update(&ntype, NULL, node_group_verify);
+ node_type_group_update(&ntype, node_group_update);
node_type_exec(&ntype, group_initexec, group_freeexec, group_execute);
node_type_gpu(&ntype, gpu_group_execute);
diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c
index 802d10def0a..4a17c3432de 100644
--- a/source/blender/nodes/shader/nodes/node_shader_invert.c
+++ b/source/blender/nodes/shader/nodes/node_shader_invert.c
@@ -48,10 +48,12 @@ static void node_shader_exec_invert(void *UNUSED(data),
icol[2] = 1.0f - col[2];
/* if fac, blend result against original input */
- if (fac < 1.0f)
+ if (fac < 1.0f) {
interp_v3_v3v3(out[0]->vec, col, icol, fac);
- else
+ }
+ else {
copy_v3_v3(out[0]->vec, icol);
+ }
}
static int gpu_shader_invert(GPUMaterial *mat,
diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c
index 5af0dd55083..eca0d96f2c8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mapping.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c
@@ -60,24 +60,31 @@ static void node_shader_exec_mapping(void *UNUSED(data),
mul_m4_v3(texmap->mat, vec);
if (texmap->flag & TEXMAP_CLIP_MIN) {
- if (vec[0] < texmap->min[0])
+ if (vec[0] < texmap->min[0]) {
vec[0] = texmap->min[0];
- if (vec[1] < texmap->min[1])
+ }
+ if (vec[1] < texmap->min[1]) {
vec[1] = texmap->min[1];
- if (vec[2] < texmap->min[2])
+ }
+ if (vec[2] < texmap->min[2]) {
vec[2] = texmap->min[2];
+ }
}
if (texmap->flag & TEXMAP_CLIP_MAX) {
- if (vec[0] > texmap->max[0])
+ if (vec[0] > texmap->max[0]) {
vec[0] = texmap->max[0];
- if (vec[1] > texmap->max[1])
+ }
+ if (vec[1] > texmap->max[1]) {
vec[1] = texmap->max[1];
- if (vec[2] > texmap->max[2])
+ }
+ if (vec[2] > texmap->max[2]) {
vec[2] = texmap->max[2];
+ }
}
- if (texmap->type == TEXMAP_TYPE_NORMAL)
+ if (texmap->type == TEXMAP_TYPE_NORMAL) {
normalize_v3(vec);
+ }
}
static void node_shader_init_mapping(bNodeTree *UNUSED(ntree), bNode *node)
@@ -107,8 +114,9 @@ static int gpu_shader_mapping(GPUMaterial *mat,
GPU_stack_link(mat, node, "mapping", in, out, tmat0, tmat1, tmat2, tmat3, tmin, tmax);
- if (texmap->type == TEXMAP_TYPE_NORMAL)
+ if (texmap->type == TEXMAP_TYPE_NORMAL) {
GPU_link(mat, "texco_norm", out[0].link, &out[0].link);
+ }
return true;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index 6e104066a58..70432e04180 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -55,51 +55,66 @@ static void node_shader_exec_math(void *UNUSED(data),
r = a * b;
break;
case NODE_MATH_DIVIDE: {
- if (b == 0) /* We don't want to divide by zero. */
+ if (b == 0) { /* We don't want to divide by zero. */
r = 0.0;
- else
+ }
+ else {
r = a / b;
+ }
break;
}
case NODE_MATH_SIN: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = sinf(a);
- else
+ }
+ else {
r = sinf(b);
+ }
break;
}
case NODE_MATH_COS: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = cosf(a);
- else
+ }
+ else {
r = cosf(b);
+ }
break;
}
case NODE_MATH_TAN: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = tanf(a);
- else
+ }
+ else {
r = tanf(b);
+ }
break;
}
case NODE_MATH_ASIN: {
if (in[0]->hasinput ||
!in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
/* Can't do the impossible... */
- if (a <= 1 && a >= -1)
+ if (a <= 1 && a >= -1) {
r = asinf(a);
- else
+ }
+ else {
r = 0.0;
+ }
}
else {
/* Can't do the impossible... */
- if (b <= 1 && b >= -1)
+ if (b <= 1 && b >= -1) {
r = asinf(b);
- else
+ }
+ else {
r = 0.0;
+ }
}
break;
}
@@ -107,26 +122,33 @@ static void node_shader_exec_math(void *UNUSED(data),
if (in[0]->hasinput ||
!in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
/* Can't do the impossible... */
- if (a <= 1 && a >= -1)
+ if (a <= 1 && a >= -1) {
r = acosf(a);
- else
+ }
+ else {
r = 0.0;
+ }
}
else {
/* Can't do the impossible... */
- if (b <= 1 && b >= -1)
+ if (b <= 1 && b >= -1) {
r = acosf(b);
- else
+ }
+ else {
r = 0.0;
+ }
}
break;
}
case NODE_MATH_ATAN: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = atan(a);
- else
+ }
+ else {
r = atan(b);
+ }
break;
}
case NODE_MATH_POW: {
@@ -137,7 +159,8 @@ static void node_shader_exec_math(void *UNUSED(data),
else {
float y_mod_1 = fabsf(fmodf(b, 1.0f));
- /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
+ /* if input value is not nearly an integer,
+ * fall back to zero, nicer than straight rounding. */
if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
r = powf(a, floorf(b + 0.5f));
}
@@ -150,53 +173,68 @@ static void node_shader_exec_math(void *UNUSED(data),
}
case NODE_MATH_LOG: {
/* Don't want any imaginary numbers... */
- if (a > 0 && b > 0)
+ if (a > 0 && b > 0) {
r = log(a) / log(b);
- else
+ }
+ else {
r = 0.0;
+ }
break;
}
case NODE_MATH_MIN: {
- if (a < b)
+ if (a < b) {
r = a;
- else
+ }
+ else {
r = b;
+ }
break;
}
case NODE_MATH_MAX: {
- if (a > b)
+ if (a > b) {
r = a;
- else
+ }
+ else {
r = b;
+ }
break;
}
case NODE_MATH_ROUND: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = (a < 0) ? (int)(a - 0.5f) : (int)(a + 0.5f);
- else
+ }
+ else {
r = (b < 0) ? (int)(b - 0.5f) : (int)(b + 0.5f);
+ }
break;
}
case NODE_MATH_LESS: {
- if (a < b)
+ if (a < b) {
r = 1.0f;
- else
+ }
+ else {
r = 0.0f;
+ }
break;
}
case NODE_MATH_GREATER: {
- if (a > b)
+ if (a > b) {
r = 1.0f;
- else
+ }
+ else {
r = 0.0f;
+ }
break;
}
case NODE_MATH_MOD: {
- if (b == 0.0f)
+ if (b == 0.0f) {
r = 0.0f;
- else
+ }
+ else {
r = fmod(a, b);
+ }
break;
}
case NODE_MATH_ABS: {
@@ -210,40 +248,54 @@ static void node_shader_exec_math(void *UNUSED(data),
case NODE_MATH_FLOOR: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = floorf(a);
- else
+ }
+ else {
r = floorf(b);
+ }
break;
}
case NODE_MATH_CEIL: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = ceilf(a);
- else
+ }
+ else {
r = ceilf(b);
+ }
break;
}
case NODE_MATH_FRACT: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = a - floorf(a);
- else
+ }
+ else {
r = b - floorf(b);
+ }
break;
}
case NODE_MATH_SQRT: {
if (in[0]->hasinput ||
- !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
- if (a > 0)
+ !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
+ if (a > 0) {
r = sqrt(a);
- else
+ }
+ else {
r = 0.0;
+ }
}
else {
- if (b > 0)
+ if (b > 0) {
r = sqrt(b);
- else
+ }
+ else {
r = 0.0;
+ }
}
break;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
index fcc64707642..d769a219fa0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -60,32 +60,37 @@ static int gpu_shader_normal_map(GPUMaterial *mat,
float d[4] = {0, 0, 0, 0};
- if (in[0].link)
+ if (in[0].link) {
strength = in[0].link;
+ }
else if (node->original) {
bNodeSocket *socket = BLI_findlink(&node->original->inputs, 0);
bNodeSocketValueFloat *socket_data = socket->default_value;
strength = GPU_uniform(&socket_data->value);
}
- else
+ else {
strength = GPU_constant(in[0].vec);
+ }
- if (in[1].link)
+ if (in[1].link) {
realnorm = in[1].link;
+ }
else if (node->original) {
bNodeSocket *socket = BLI_findlink(&node->original->inputs, 1);
bNodeSocketValueRGBA *socket_data = socket->default_value;
realnorm = GPU_uniform(socket_data->value);
}
- else
+ else {
realnorm = GPU_constant(in[1].vec);
+ }
negnorm = GPU_builtin(GPU_VIEW_NORMAL);
GPU_link(mat, "math_max", strength, GPU_constant(d), &strength);
const char *color_to_normal_fnc_name = "color_to_normal_new_shading";
- if (nm->space == SHD_SPACE_BLENDER_OBJECT || nm->space == SHD_SPACE_BLENDER_WORLD)
+ if (nm->space == SHD_SPACE_BLENDER_OBJECT || nm->space == SHD_SPACE_BLENDER_WORLD) {
color_to_normal_fnc_name = "color_to_blender_normal_new_shading";
+ }
switch (nm->space) {
case SHD_SPACE_TANGENT:
GPU_link(mat, "color_to_normal_new_shading", realnorm, &realnorm);
diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
index 2b5c991161d..98d975b55f2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
@@ -27,7 +27,7 @@ static bNodeSocketTemplate outputs[] = {
{SOCK_FLOAT, 0, "Lifetime"},
{SOCK_VECTOR, 0, "Location"},
#if 0 /* quaternion sockets not yet supported */
- { SOCK_QUATERNION, 0, "Rotation" },
+ {SOCK_QUATERNION, 0, "Rotation"},
#endif
{SOCK_FLOAT, 0, "Size"},
{SOCK_VECTOR, 0, "Velocity"},
diff --git a/source/blender/nodes/shader/nodes/node_shader_script.c b/source/blender/nodes/shader/nodes/node_shader_script.c
index 088272bbfb4..29d3fd3ba67 100644
--- a/source/blender/nodes/shader/nodes/node_shader_script.c
+++ b/source/blender/nodes/shader/nodes/node_shader_script.c
@@ -49,8 +49,9 @@ static void node_copy_script(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bN
NodeShaderScript *src_nss = src_node->storage;
NodeShaderScript *dest_nss = MEM_dupallocN(src_nss);
- if (src_nss->bytecode)
+ if (src_nss->bytecode) {
dest_nss->bytecode = MEM_dupallocN(src_nss->bytecode);
+ }
dest_node->storage = dest_nss;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
index a6a2edd5352..f1b4a0e9fe3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
+++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
@@ -57,8 +57,9 @@ static int node_shader_gpu_subsurface_scattering(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[5].link)
+ if (!in[5].link) {
GPU_link(mat, "world_normals_get", &in[5].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_SSS);
@@ -83,10 +84,12 @@ static void node_shader_update_subsurface_scattering(bNodeTree *UNUSED(ntree), b
for (sock = node->inputs.first; sock; sock = sock->next) {
if (STREQ(sock->name, "Sharpness")) {
- if (falloff == SHD_SUBSURFACE_CUBIC)
+ if (falloff == SHD_SUBSURFACE_CUBIC) {
sock->flag &= ~SOCK_UNAVAIL;
- else
+ }
+ else {
sock->flag |= SOCK_UNAVAIL;
+ }
}
}
}
@@ -104,7 +107,7 @@ void register_node_type_sh_subsurface_scattering(void)
node_type_init(&ntype, node_shader_init_subsurface_scattering);
node_type_storage(&ntype, "", NULL, NULL);
node_type_gpu(&ntype, node_shader_gpu_subsurface_scattering);
- node_type_update(&ntype, node_shader_update_subsurface_scattering, NULL);
+ node_type_update(&ntype, node_shader_update_subsurface_scattering);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
index 6af19503800..5512754d9a2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tangent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -53,12 +53,15 @@ static int node_shader_gpu_tangent(GPUMaterial *mat,
else {
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
- if (attr->axis == SHD_TANGENT_AXIS_X)
+ if (attr->axis == SHD_TANGENT_AXIS_X) {
GPU_link(mat, "tangent_orco_x", orco, &orco);
- else if (attr->axis == SHD_TANGENT_AXIS_Y)
+ }
+ else if (attr->axis == SHD_TANGENT_AXIS_Y) {
GPU_link(mat, "tangent_orco_y", orco, &orco);
- else
+ }
+ else {
GPU_link(mat, "tangent_orco_z", orco, &orco);
+ }
return GPU_stack_link(mat,
node,
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
index 6e8516b9886..c3b8bc8bfd0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -48,9 +48,7 @@ static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode *no
BKE_texture_colormapping_default(&tex->base.color_mapping);
tex->color_space = SHD_COLORSPACE_COLOR;
tex->projection = SHD_PROJ_EQUIRECTANGULAR;
- tex->iuser.frames = 1;
- tex->iuser.sfra = 1;
- tex->iuser.ok = 1;
+ BKE_imageuser_default(&tex->iuser);
node->storage = tex;
}
@@ -73,8 +71,9 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat,
int isdata = tex->color_space == SHD_COLORSPACE_NONE;
GPUNodeLink *outalpha;
- if (!ima)
+ if (!ima) {
return GPU_stack_link(mat, node, "node_tex_environment_empty", in, out);
+ }
if (!in[0].link) {
GPU_link(mat, "node_tex_environment_texco", GPU_builtin(GPU_VIEW_POSITION), &in[0].link);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index 55e8e6a0e8f..91d58bc41d0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -58,9 +58,7 @@ static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node)
BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT);
BKE_texture_colormapping_default(&tex->base.color_mapping);
tex->color_space = SHD_COLORSPACE_COLOR;
- tex->iuser.frames = 1;
- tex->iuser.sfra = 1;
- tex->iuser.ok = 1;
+ BKE_imageuser_default(&tex->iuser);
node->storage = tex;
}
@@ -112,13 +110,15 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
do_texco_extend = false;
}
- GPUNodeLink *norm, *col1, *col2, *col3, *input_coords;
+ GPUNodeLink *norm, *col1, *col2, *col3, *input_coords, *gpu_image;
+ GPUNodeLink *vnor, *nor_mat_inv, *blend;
+ GPUNodeLink **texco = &in[0].link;
int isdata = tex->color_space == SHD_COLORSPACE_NONE;
- float blend = tex->projection_blend;
- if (!ima)
+ if (!ima) {
return GPU_stack_link(mat, node, "node_tex_image_empty", in, out);
+ }
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
if ((tex->color_space == SHD_COLORSPACE_COLOR) && ibuf &&
@@ -128,88 +128,75 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
}
BKE_image_release_ibuf(ima, ibuf, NULL);
- if (!in[0].link)
- in[0].link = GPU_attribute(CD_MTFACE, "");
+ if (!*texco) {
+ *texco = GPU_attribute(CD_MTFACE, "");
+ }
node_shader_gpu_tex_mapping(mat, node, in, out);
switch (tex->projection) {
case SHD_PROJ_FLAT:
if (do_texco_clip) {
- GPU_link(mat, "set_rgb", in[0].link, &input_coords);
+ GPU_link(mat, "set_rgb", *texco, &input_coords);
}
if (do_texco_extend) {
- GPU_link(mat, "point_texco_clamp", in[0].link, GPU_image(ima, iuser, isdata), &in[0].link);
+ GPU_link(mat, "point_texco_clamp", *texco, GPU_image(ima, iuser, isdata), texco);
}
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
+
case SHD_PROJ_BOX:
- GPU_link(mat,
- "mat3_mul",
- GPU_builtin(GPU_VIEW_NORMAL),
- GPU_builtin(GPU_INVERSE_NORMAL_MATRIX),
- &norm);
- GPU_link(mat,
- gpu_node_name,
- in[0].link,
- norm,
- GPU_image(ima, iuser, isdata),
- &col1,
- &col2,
- &col3);
+ vnor = GPU_builtin(GPU_VIEW_NORMAL);
+ nor_mat_inv = GPU_builtin(GPU_INVERSE_NORMAL_MATRIX);
+ blend = GPU_uniform(&tex->projection_blend);
+ gpu_image = GPU_image(ima, iuser, isdata);
+
+ GPU_link(mat, "mat3_mul", vnor, nor_mat_inv, &norm);
+ GPU_link(
+ mat, gpu_node_name, *texco, norm, GPU_image(ima, iuser, isdata), &col1, &col2, &col3);
if (do_color_correction) {
GPU_link(mat, "srgb_to_linearrgb", col1, &col1);
GPU_link(mat, "srgb_to_linearrgb", col2, &col2);
GPU_link(mat, "srgb_to_linearrgb", col3, &col3);
}
- GPU_link(mat,
- "node_tex_image_box",
- in[0].link,
- norm,
- col1,
- col2,
- col3,
- GPU_image(ima, iuser, isdata),
- GPU_uniform(&blend),
- &out[0].link,
- &out[1].link);
+ GPU_stack_link(
+ mat, node, "node_tex_image_box", in, out, norm, col1, col2, col3, gpu_image, blend);
break;
+
case SHD_PROJ_SPHERE:
- GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
- GPU_link(mat, "point_map_to_sphere", in[0].link, &in[0].link);
+ GPU_link(mat, "point_texco_remap_square", *texco, texco);
+ GPU_link(mat, "point_map_to_sphere", *texco, texco);
if (do_texco_clip) {
- GPU_link(mat, "set_rgb", in[0].link, &input_coords);
+ GPU_link(mat, "set_rgb", *texco, &input_coords);
}
if (do_texco_extend) {
- GPU_link(mat, "point_texco_clamp", in[0].link, GPU_image(ima, iuser, isdata), &in[0].link);
+ GPU_link(mat, "point_texco_clamp", *texco, GPU_image(ima, iuser, isdata), texco);
}
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
+
case SHD_PROJ_TUBE:
- GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
- GPU_link(mat, "point_map_to_tube", in[0].link, &in[0].link);
+ GPU_link(mat, "point_texco_remap_square", *texco, texco);
+ GPU_link(mat, "point_map_to_tube", *texco, texco);
if (do_texco_clip) {
- GPU_link(mat, "set_rgb", in[0].link, &input_coords);
+ GPU_link(mat, "set_rgb", *texco, &input_coords);
}
if (do_texco_extend) {
- GPU_link(mat, "point_texco_clamp", in[0].link, GPU_image(ima, iuser, isdata), &in[0].link);
+ GPU_link(mat, "point_texco_clamp", *texco, GPU_image(ima, iuser, isdata), texco);
}
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
}
- if (do_texco_clip && (tex->projection != SHD_PROJ_BOX)) {
- GPU_link(mat,
- names_clip[tex->interpolation],
- input_coords,
- GPU_image(ima, iuser, isdata),
- out[0].link,
- &out[0].link,
- &out[1].link);
- }
-
- if (do_color_correction && (tex->projection != SHD_PROJ_BOX)) {
- GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
+ if (tex->projection != SHD_PROJ_BOX) {
+ if (do_texco_clip) {
+ gpu_node_name = names_clip[tex->interpolation];
+ GPU_stack_link(
+ mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata), out[0].link);
+ }
+ if (do_color_correction) {
+ GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
+ }
}
return true;
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
index 15db757a9a1..b1fb0cad4b2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
@@ -62,8 +62,9 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[0].link)
+ if (!in[0].link) {
in[0].link = GPU_attribute(CD_ORCO, "");
+ }
node_shader_gpu_tex_mapping(mat, node, in, out);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
index 99668741f65..e0b4de985d8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
@@ -122,7 +122,7 @@ void register_node_type_sh_tex_voronoi(void)
node_type_storage(
&ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage);
node_type_gpu(&ntype, node_shader_gpu_tex_voronoi);
- node_type_update(&ntype, node_shader_update_tex_voronoi, NULL);
+ node_type_update(&ntype, node_shader_update_tex_voronoi);
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
index 19cc9f2ce55..fe0e7b1d638 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
@@ -28,8 +28,10 @@ static bNodeSocketTemplate sh_node_vect_transform_in[] = {
{SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
{-1, 0, ""}};
-static bNodeSocketTemplate sh_node_vect_transform_out[] = {{SOCK_VECTOR, 0, N_("Vector")},
- {-1, 0, ""}};
+static bNodeSocketTemplate sh_node_vect_transform_out[] = {
+ {SOCK_VECTOR, 0, N_("Vector")},
+ {-1, 0, ""},
+};
static void node_shader_init_vect_transform(bNodeTree *UNUSED(ntree), bNode *node)
{
@@ -102,10 +104,12 @@ static int gpu_shader_vect_transform(GPUMaterial *mat,
NodeShaderVectTransform *nodeprop = (NodeShaderVectTransform *)node->storage;
- if (in[0].hasinput)
+ if (in[0].hasinput) {
inputlink = in[0].link;
- else
+ }
+ else {
inputlink = GPU_constant(in[0].vec);
+ }
fromto = get_gpulink_matrix_from_to(nodeprop->convert_from, nodeprop->convert_to);
@@ -123,11 +127,13 @@ static int gpu_shader_vect_transform(GPUMaterial *mat,
GPU_link(mat, "invert_z", out[0].link, &out[0].link);
}
}
- else
+ else {
GPU_link(mat, "set_rgb", inputlink, &out[0].link);
+ }
- if (nodeprop->type == SHD_VECT_TRANSFORM_TYPE_NORMAL)
+ if (nodeprop->type == SHD_VECT_TRANSFORM_TYPE_NORMAL) {
GPU_link(mat, "vect_normalize", out[0].link, &out[0].link);
+ }
return true;
}
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 76b906f5f22..43deea9c2de 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -65,10 +65,12 @@ static void texture_get_from_context(const bContext *C,
if (snode->texfrom == SNODE_TEX_BRUSH) {
struct Brush *brush = NULL;
- if (ob && (ob->mode & OB_MODE_SCULPT))
+ if (ob && (ob->mode & OB_MODE_SCULPT)) {
brush = BKE_paint_brush(&scene->toolsettings->sculpt->paint);
- else
+ }
+ else {
brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint);
+ }
if (brush) {
*r_from = (ID *)brush;
@@ -175,28 +177,6 @@ void register_node_tree_type_tex(void)
ntreeTypeAdd(tt);
}
-int ntreeTexTagAnimated(bNodeTree *ntree)
-{
- bNode *node;
-
- if (ntree == NULL)
- return 0;
-
- for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == TEX_NODE_CURVE_TIME) {
- nodeUpdate(ntree, node);
- return 1;
- }
- else if (node->type == NODE_GROUP) {
- if (ntreeTexTagAnimated((bNodeTree *)node->id)) {
- return 1;
- }
- }
- }
-
- return 0;
-}
-
bNodeTreeExec *ntreeTexBeginExecTree_internal(bNodeExecContext *context,
bNodeTree *ntree,
bNodeInstanceKey parent_key)
@@ -210,8 +190,9 @@ bNodeTreeExec *ntreeTexBeginExecTree_internal(bNodeExecContext *context,
/* allocate the thread stack listbase array */
exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array");
- for (node = exec->nodetree->nodes.first; node; node = node->next)
+ for (node = exec->nodetree->nodes.first; node; node = node->next) {
node->need_exec = 1;
+ }
return exec;
}
@@ -224,8 +205,9 @@ bNodeTreeExec *ntreeTexBeginExecTree(bNodeTree *ntree)
/* XXX hack: prevent exec data from being generated twice.
* this should be handled by the renderer!
*/
- if (ntree->execdata)
+ if (ntree->execdata) {
return ntree->execdata;
+ }
context.previews = ntree->previews;
@@ -246,11 +228,15 @@ static void tex_free_delegates(bNodeTreeExec *exec)
bNodeStack *ns;
int th, a;
- for (th = 0; th < BLENDER_MAX_THREADS; th++)
- for (nts = exec->threadstack[th].first; nts; nts = nts->next)
- for (ns = nts->stack, a = 0; a < exec->stacksize; a++, ns++)
- if (ns->data && !ns->is_copy)
+ for (th = 0; th < BLENDER_MAX_THREADS; th++) {
+ for (nts = exec->threadstack[th].first; nts; nts = nts->next) {
+ for (ns = nts->stack, a = 0; a < exec->stacksize; a++, ns++) {
+ if (ns->data && !ns->is_copy) {
MEM_freeN(ns->data);
+ }
+ }
+ }
+ }
}
void ntreeTexEndExecTree_internal(bNodeTreeExec *exec)
@@ -262,9 +248,11 @@ void ntreeTexEndExecTree_internal(bNodeTreeExec *exec)
tex_free_delegates(exec);
for (a = 0; a < BLENDER_MAX_THREADS; a++) {
- for (nts = exec->threadstack[a].first; nts; nts = nts->next)
- if (nts->stack)
+ for (nts = exec->threadstack[a].first; nts; nts = nts->next) {
+ if (nts->stack) {
MEM_freeN(nts->stack);
+ }
+ }
BLI_freelistN(&exec->threadstack[a]);
}
@@ -321,8 +309,9 @@ int ntreeTexExecTree(bNodeTree *nodes,
/* ensure execdata is only initialized once */
if (!exec) {
BLI_thread_lock(LOCK_NODES);
- if (!nodes->execdata)
+ if (!nodes->execdata) {
ntreeTexBeginExecTree(nodes);
+ }
BLI_thread_unlock(LOCK_NODES);
exec = nodes->execdata;
@@ -332,11 +321,13 @@ int ntreeTexExecTree(bNodeTree *nodes,
ntreeExecThreadNodes(exec, nts, &data, thread);
ntreeReleaseThreadStack(nts);
- if (texres->nor)
+ if (texres->nor) {
retval |= TEX_NOR;
+ }
retval |= TEX_RGB;
- /* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was set
- * however, the texture code checks this for other reasons (namely, a normal is required for material) */
+ /* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was
+ * set however, the texture code checks this for other reasons
+ * (namely, a normal is required for material). */
texres->nor = nor;
return retval;
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index ba65a692835..844a45f8d8b 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -60,8 +60,9 @@ static void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, sh
if (dg->node->need_exec) {
dg->fn(out, params, dg->node, dg->in, thread);
- if (dg->cdata->do_preview)
+ if (dg->cdata->do_preview) {
tex_do_preview(dg->preview, params->previewco, out, dg->cdata->do_manage);
+ }
}
}
@@ -71,8 +72,9 @@ static void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, sho
if (dg) {
tex_call_delegate(dg, in->vec, params, thread);
- if (in->hasoutput && in->sockettype == SOCK_FLOAT)
+ if (in->hasoutput && in->sockettype == SOCK_FLOAT) {
in->vec[1] = in->vec[2] = in->vec[0];
+ }
}
memcpy(out, in->vec, sz * sizeof(float));
}
@@ -144,11 +146,13 @@ void tex_output(bNode *node,
return;
}
else {
- if (!out->data)
+ if (!out->data) {
/* Freed in tex_end_exec (node.c) */
dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate");
- else
+ }
+ else {
dg = out->data;
+ }
}
dg->cdata = cdata;
diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c
index 9f76c464c12..b8435d3a352 100644
--- a/source/blender/nodes/texture/nodes/node_texture_common.c
+++ b/source/blender/nodes/texture/nodes/node_texture_common.c
@@ -54,8 +54,9 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc
bNodeTree *ngroup = (bNodeTree *)node->id;
void *exec;
- if (!ngroup)
+ if (!ngroup) {
return NULL;
+ }
/* initialize the internal node tree execution */
exec = ntreeTexBeginExecTree_internal(context, ngroup, key);
@@ -130,16 +131,18 @@ static void group_execute(void *data,
bNodeTreeExec *exec = execdata->data;
bNodeThreadStack *nts;
- if (!exec)
+ if (!exec) {
return;
+ }
/* XXX same behavior as trunk: all nodes inside group are executed.
* it's stupid, but just makes it work. compo redesign will do this better.
*/
{
bNode *inode;
- for (inode = exec->nodetree->nodes.first; inode; inode = inode->next)
+ for (inode = exec->nodetree->nodes.first; inode; inode = inode->next) {
inode->need_exec = 1;
+ }
}
nts = ntreeGetThreadStack(exec, thread);
@@ -171,7 +174,7 @@ void register_node_type_tex_group(void)
node_type_socket_templates(&ntype, NULL, NULL);
node_type_size(&ntype, 140, 60, 400);
node_type_label(&ntype, node_group_label);
- node_type_update(&ntype, NULL, node_group_verify);
+ node_type_group_update(&ntype, node_group_update);
node_type_exec(&ntype, group_initexec, group_freeexec, group_execute);
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c
index ae266451671..3c9791578fd 100644
--- a/source/blender/nodes/texture/nodes/node_texture_compose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_compose.c
@@ -39,8 +39,9 @@ static bNodeSocketTemplate outputs[] = {
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
int i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
out[i] = tex_input_value(in[i], p, thread);
+ }
}
static void exec(void *data,
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index a57e2d8f35f..1087d05d040 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.c
@@ -35,8 +35,9 @@ static void time_colorfn(
/* stack order output: fac */
float fac = 0.0f;
- if (node->custom1 < node->custom2)
+ if (node->custom1 < node->custom2) {
fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
+ }
curvemapping_initialize(node->storage);
fac = curvemapping_evaluateF(node->storage, 0, fac);
diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
index c4105083945..513b0bdd647 100644
--- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
+++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
@@ -45,20 +45,26 @@ static void do_hue_sat_fac(
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2);
hsv[0] += (hue - 0.5f);
- if (hsv[0] > 1.0f)
+ if (hsv[0] > 1.0f) {
hsv[0] -= 1.0f;
- else if (hsv[0] < 0.0f)
+ }
+ else if (hsv[0] < 0.0f) {
hsv[0] += 1.0f;
+ }
hsv[1] *= sat;
- if (hsv[1] > 1.0f)
+ if (hsv[1] > 1.0f) {
hsv[1] = 1.0f;
- else if (hsv[1] < 0.0f)
+ }
+ else if (hsv[1] < 0.0f) {
hsv[1] = 0.0f;
+ }
hsv[2] *= val;
- if (hsv[2] > 1.0f)
+ if (hsv[2] > 1.0f) {
hsv[2] = 1.0f;
- else if (hsv[2] < 0.0f)
+ }
+ else if (hsv[2] < 0.0f) {
hsv[2] = 0.0f;
+ }
hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
out[0] = mfac * in[0] + fac * col[0];
diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c
index 5c7b7a56d3a..2ecd66ac6f5 100644
--- a/source/blender/nodes/texture/nodes/node_texture_image.c
+++ b/source/blender/nodes/texture/nodes/node_texture_image.c
@@ -53,24 +53,30 @@ static void colorfn(
px = (int)((x - xoff) * xsize);
py = (int)((y - yoff) * ysize);
- if ((!xsize) || (!ysize))
+ if ((!xsize) || (!ysize)) {
return;
+ }
if (!ibuf->rect_float) {
BLI_thread_lock(LOCK_IMAGE);
- if (!ibuf->rect_float)
+ if (!ibuf->rect_float) {
IMB_float_from_rect(ibuf);
+ }
BLI_thread_unlock(LOCK_IMAGE);
}
- while (px < 0)
+ while (px < 0) {
px += ibuf->x;
- while (py < 0)
+ }
+ while (py < 0) {
py += ibuf->y;
- while (px >= ibuf->x)
+ }
+ while (px >= ibuf->x) {
px -= ibuf->x;
- while (py >= ibuf->y)
+ }
+ while (py >= ibuf->y) {
py -= ibuf->y;
+ }
result = ibuf->rect_float + py * ibuf->x * 4 + px * 4;
copy_v4_v4(out, result);
diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c
index 8b934be3698..2eb32e0addc 100644
--- a/source/blender/nodes/texture/nodes/node_texture_math.c
+++ b/source/blender/nodes/texture/nodes/node_texture_math.c
@@ -53,10 +53,13 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
*out = in0 * in1;
break;
case NODE_MATH_DIVIDE: {
- if (in1 == 0) /* We don't want to divide by zero. */
+ if (in1 == 0) {
+ /* We don't want to divide by zero. */
*out = 0.0;
- else
+ }
+ else {
*out = in0 / in1;
+ }
break;
}
case NODE_MATH_SIN: {
@@ -73,18 +76,22 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
case NODE_MATH_ASIN: {
/* Can't do the impossible... */
- if (in0 <= 1 && in0 >= -1)
+ if (in0 <= 1 && in0 >= -1) {
*out = asinf(in0);
- else
+ }
+ else {
*out = 0.0;
+ }
break;
}
case NODE_MATH_ACOS: {
/* Can't do the impossible... */
- if (in0 <= 1 && in0 >= -1)
+ if (in0 <= 1 && in0 >= -1) {
*out = acosf(in0);
- else
+ }
+ else {
*out = 0.0;
+ }
break;
}
case NODE_MATH_ATAN: {
@@ -109,24 +116,30 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
case NODE_MATH_LOG: {
/* Don't want any imaginary numbers... */
- if (in0 > 0 && in1 > 0)
+ if (in0 > 0 && in1 > 0) {
*out = log(in0) / log(in1);
- else
+ }
+ else {
*out = 0.0;
+ }
break;
}
case NODE_MATH_MIN: {
- if (in0 < in1)
+ if (in0 < in1) {
*out = in0;
- else
+ }
+ else {
*out = in1;
+ }
break;
}
case NODE_MATH_MAX: {
- if (in0 > in1)
+ if (in0 > in1) {
*out = in0;
- else
+ }
+ else {
*out = in1;
+ }
break;
}
case NODE_MATH_ROUND: {
@@ -135,26 +148,32 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
case NODE_MATH_LESS: {
- if (in0 < in1)
+ if (in0 < in1) {
*out = 1.0f;
- else
+ }
+ else {
*out = 0.0f;
+ }
break;
}
case NODE_MATH_GREATER: {
- if (in0 > in1)
+ if (in0 > in1) {
*out = 1.0f;
- else
+ }
+ else {
*out = 0.0f;
+ }
break;
}
case NODE_MATH_MOD: {
- if (in1 == 0.0f)
+ if (in1 == 0.0f) {
*out = 0.0f;
- else
+ }
+ else {
*out = fmod(in0, in1);
+ }
break;
}
@@ -184,10 +203,12 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
case NODE_MATH_SQRT: {
- if (in0 > 0.0f)
+ if (in0 > 0.0f) {
*out = sqrtf(in0);
- else
+ }
+ else {
*out = 0.0f;
+ }
break;
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
index 667b1317ea4..644dcb5fc67 100644
--- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
@@ -45,8 +45,9 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
tex_input_rgba(col2, in[2], p, thread);
/* use alpha */
- if (node->custom2 & 1)
+ if (node->custom2 & 1) {
fac *= col2[3];
+ }
CLAMP(fac, 0.0f, 1.0f);
diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c
index e44bea3ecac..23cd23b4b8d 100644
--- a/source/blender/nodes/texture/nodes/node_texture_output.c
+++ b/source/blender/nodes/texture/nodes/node_texture_output.c
@@ -46,10 +46,12 @@ static void exec(void *data,
TexParams params;
params_from_cdata(&params, cdata);
- if (in[1] && in[1]->hasinput && !in[0]->hasinput)
+ if (in[1] && in[1]->hasinput && !in[0]->hasinput) {
tex_input_rgba(&target->tr, in[1], &params, cdata->thread);
- else
+ }
+ else {
tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
+ }
tex_do_preview(execdata->preview, params.co, &target->tr, cdata->do_manage);
}
else {
@@ -64,10 +66,12 @@ static void exec(void *data,
target->talpha = true;
if (target->nor) {
- if (in[1] && in[1]->hasinput)
+ if (in[1] && in[1]->hasinput) {
tex_input_vec(target->nor, in[1], &params, cdata->thread);
- else
+ }
+ else {
target->nor = NULL;
+ }
}
}
}
@@ -84,8 +88,9 @@ static void unique_name(bNode *node)
new_name[0] = '\0';
i = node;
- while (i->prev)
+ while (i->prev) {
i = i->prev;
+ }
for (; i; i = i->next) {
if (i == node || i->type != TEX_NODE_OUTPUT ||
!STREQ(name, ((TexNodeOutput *)(i->storage))->name)) {
@@ -100,8 +105,9 @@ static void unique_name(bNode *node)
else {
suffix = 0;
new_len = len + 4;
- if (new_len > (sizeof(tno->name) - 1))
+ if (new_len > (sizeof(tno->name) - 1)) {
new_len = (sizeof(tno->name) - 1);
+ }
}
BLI_strncpy(new_name, name, sizeof(tno->name));
@@ -121,8 +127,9 @@ static void assign_index(struct bNode *node)
int index = 1;
tnode = node;
- while (tnode->prev)
+ while (tnode->prev) {
tnode = tnode->prev;
+ }
check_index:
for (; tnode; tnode = tnode->next)
diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c
index 8024ccdc631..b0b646dfd16 100644
--- a/source/blender/nodes/texture/nodes/node_texture_proc.c
+++ b/source/blender/nodes/texture/nodes/node_texture_proc.c
@@ -44,7 +44,8 @@ static bNodeSocketTemplate outputs_color_only[] = {{SOCK_RGBA, 0, N_("Color")},
SOCK_RGBA, 1, "Color 2", 1.0f, 1.0f, 1.0f, 1.0f \
}
-/* Calls multitex and copies the result to the outputs. Called by xxx_exec, which handles inputs. */
+/* Calls multitex and copies the result to the outputs.
+ * Called by xxx_exec, which handles inputs. */
static void do_proc(float *result,
TexParams *p,
const float col1[4],
@@ -59,14 +60,16 @@ static void do_proc(float *result,
if (is_normal) {
texres.nor = result;
}
- else
+ else {
texres.nor = NULL;
+ }
textype = multitex_nodes(
tex, p->co, p->dxt, p->dyt, p->osatex, &texres, thread, 0, p->mtex, NULL);
- if (is_normal)
+ if (is_normal) {
return;
+ }
if (textype & TEX_RGB) {
copy_v4_v4(result, &texres.tr);
@@ -276,8 +279,9 @@ ProcDef(stucci)
BKE_texture_default(tex);
tex->type = node->type - TEX_NODE_PROC;
- if (tex->type == TEX_WOOD)
+ if (tex->type == TEX_WOOD) {
tex->stype = TEX_BANDNOISE;
+ }
}
/* Node type definitions */
diff --git a/source/blender/physics/CMakeLists.txt b/source/blender/physics/CMakeLists.txt
index e40d1de666b..edcfdceb697 100644
--- a/source/blender/physics/CMakeLists.txt
+++ b/source/blender/physics/CMakeLists.txt
@@ -21,8 +21,8 @@
set(INC
.
intern
- ../blenlib
../blenkernel
+ ../blenlib
../depsgraph
../imbuf
../makesdna
diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp
index fa204e8a7f9..f7a9cadc9cf 100644
--- a/source/blender/physics/intern/BPH_mass_spring.cpp
+++ b/source/blender/physics/intern/BPH_mass_spring.cpp
@@ -232,7 +232,7 @@ static void cloth_setup_constraints(ClothModifierData *clmd,
ColliderContacts *ct = &contacts[i];
for (j = 0; j < ct->totcollisions; ++j) {
CollPair *collpair = &ct->collisions[j];
- // float restitution = (1.0f - clmd->coll_parms->damping) * (1.0f - ct->ob->pd->pdef_sbdamp);
+ // float restitution = (1.0f - clmd->coll_parms->damping) * (1.0f - ct->ob->pd->pdef_sbdamp);
float restitution = 0.0f;
int v = collpair->face1;
float impulse[3];
@@ -334,7 +334,7 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob),
sub_v3_v3v3(vec, cos[i], cv->tx);
mul_v3_fl(vec, cv->mass * dt * 20.0f);
add_v3_v3(cv->tv, vec);
- //copy_v3_v3(cv->tx, cos[i]);
+ // copy_v3_v3(cv->tx, cos[i]);
}
MEM_freeN(cos);
@@ -382,8 +382,9 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
k_tension = scaling_tension / (parms->avg_spring_len + FLT_EPSILON);
if (s->type & CLOTH_SPRING_TYPE_SEWING) {
- // TODO: verify, half verified (couldn't see error)
- // sewing springs usually have a large distance at first so clamp the force so we don't get tunnelling through colission objects
+ /* TODO: verify, half verified (couldn't see error)
+ * sewing springs usually have a large distance at first so clamp the force so we don't get
+ * tunnelling through colission objects */
BPH_mass_spring_force_spring_linear(data,
s->ij,
s->kl,
@@ -459,9 +460,9 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
- /* XXX WARNING: angular bending springs for hair apply stiffness factor as an overall factor, unlike cloth springs!
- * this is crap, but needed due to cloth/hair mixing ...
- * max_bend factor is not even used for hair, so ...
+ /* XXX WARNING: angular bending springs for hair apply stiffness factor as an overall factor,
+ * unlike cloth springs! this is crap, but needed due to cloth/hair mixing ... max_bend factor
+ * is not even used for hair, so ...
*/
scaling = s->lin_stiffness * parms->bending;
kb = scaling / (20.0f * (parms->avg_spring_len + FLT_EPSILON));
@@ -469,7 +470,8 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
// Fix for [#45084] for cloth stiffness must have cb proportional to kb
cb = kb * parms->bending_damping;
- /* XXX assuming same restlen for ij and jk segments here, this can be done correctly for hair later */
+ /* XXX assuming same restlen for ij and jk segments here,
+ * this can be done correctly for hair later. */
BPH_mass_spring_force_spring_bending_hair(data, s->ij, s->kl, s->mn, s->target, kb, cb);
# if 0
@@ -480,13 +482,15 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s)
BPH_mass_spring_get_motion_state(data, s->mn, x_mn, v);
BKE_sim_debug_data_add_dot(clmd->debug_data, x_kl, 0.9, 0.9, 0.9, "target", 7980, s->kl);
- BKE_sim_debug_data_add_line(clmd->debug_data, x_kl, x_mn, 0.8, 0.8, 0.8, "target", 7981, s->kl);
+ BKE_sim_debug_data_add_line(
+ clmd->debug_data, x_kl, x_mn, 0.8, 0.8, 0.8, "target", 7981, s->kl);
copy_v3_v3(d, s->target);
- BKE_sim_debug_data_add_vector(clmd->debug_data, x_kl, d, 0.8, 0.8, 0.2, "target", 7982, s->kl);
+ BKE_sim_debug_data_add_vector(
+ clmd->debug_data, x_kl, d, 0.8, 0.8, 0.2, "target", 7982, s->kl);
-// copy_v3_v3(d, s->target_ij);
-// BKE_sim_debug_data_add_vector(clmd->debug_data, x, d, 1, 0.4, 0.4, "target", 7983, s->kl);
+ // copy_v3_v3(d, s->target_ij);
+ // BKE_sim_debug_data_add_vector(clmd->debug_data, x, d, 1, 0.4, 0.4, "target", 7983, s->kl);
}
# endif
#endif
@@ -589,7 +593,8 @@ static void cloth_calc_force(
if (hairdata) {
hair_ij = &hairdata[spring->ij];
hair_kl = &hairdata[spring->kl];
- BPH_mass_spring_force_edge_wind(data, spring->ij, spring->kl, hair_ij->radius, hair_kl->radius, winvec);
+ BPH_mass_spring_force_edge_wind(
+ data, spring->ij, spring->kl, hair_ij->radius, hair_kl->radius, winvec);
}
else
BPH_mass_spring_force_edge_wind(data, spring->ij, spring->kl, 1.0f, 1.0f, winvec);
@@ -842,8 +847,10 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
zero_v3(b);
offset[axis] = shift * clmd->hair_grid_cellsize;
- a[(axis + 1) % 3] = clmd->hair_grid_max[(axis + 1) % 3] - clmd->hair_grid_min[(axis + 1) % 3];
- b[(axis + 2) % 3] = clmd->hair_grid_max[(axis + 2) % 3] - clmd->hair_grid_min[(axis + 2) % 3];
+ a[(axis + 1) % 3] = clmd->hair_grid_max[(axis + 1) % 3] -
+ clmd->hair_grid_min[(axis + 1) % 3];
+ b[(axis + 2) % 3] = clmd->hair_grid_max[(axis + 2) % 3] -
+ clmd->hair_grid_min[(axis + 2) % 3];
BKE_sim_debug_data_clear_category(clmd->debug_data, "grid velocity");
for (j = 0; j < size; ++j) {
@@ -856,23 +863,36 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
BPH_hair_volume_grid_interpolate(grid, x, &gdensity, gvel, gvel_smooth, NULL, NULL);
-// BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity, 0.7, 0.3, 1, "grid density", i, j, 3111);
+ // BKE_sim_debug_data_add_circle(
+ // clmd->debug_data, x, gdensity, 0.7, 0.3, 1,
+ // "grid density", i, j, 3111);
if (!is_zero_v3(gvel) || !is_zero_v3(gvel_smooth)) {
float dvel[3];
sub_v3_v3v3(dvel, gvel_smooth, gvel);
-// BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel, 0.4, 0, 1, "grid velocity", i, j, 3112);
-// BKE_sim_debug_data_add_vector(clmd->debug_data, x, gvel_smooth, 0.6, 1, 1, "grid velocity", i, j, 3113);
- BKE_sim_debug_data_add_vector(clmd->debug_data, x, dvel, 0.4, 1, 0.7, "grid velocity", i, j, 3114);
+ // BKE_sim_debug_data_add_vector(
+ // clmd->debug_data, x, gvel, 0.4, 0, 1,
+ // "grid velocity", i, j, 3112);
+ // BKE_sim_debug_data_add_vector(
+ // clmd->debug_data, x, gvel_smooth, 0.6, 1, 1,
+ // "grid velocity", i, j, 3113);
+ BKE_sim_debug_data_add_vector(
+ clmd->debug_data, x, dvel, 0.4, 1, 0.7, "grid velocity", i, j, 3114);
# if 0
if (gdensity > 0.0f) {
float col0[3] = {0.0, 0.0, 0.0};
float col1[3] = {0.0, 1.0, 0.0};
float col[3];
- interp_v3_v3v3(col, col0, col1, CLAMPIS(gdensity * clmd->sim_parms->density_strength, 0.0, 1.0));
-// BKE_sim_debug_data_add_circle(clmd->debug_data, x, gdensity * clmd->sim_parms->density_strength, 0, 1, 0.4, "grid velocity", i, j, 3115);
-// BKE_sim_debug_data_add_dot(clmd->debug_data, x, col[0], col[1], col[2], "grid velocity", i, j, 3115);
- BKE_sim_debug_data_add_circle(clmd->debug_data, x, 0.01f, col[0], col[1], col[2], "grid velocity", i, j, 3115);
+ interp_v3_v3v3(col, col0, col1,
+ CLAMPIS(gdensity * clmd->sim_parms->density_strength, 0.0, 1.0));
+ // BKE_sim_debug_data_add_circle(
+ // clmd->debug_data, x, gdensity * clmd->sim_parms->density_strength, 0, 1, 0.4,
+ // "grid velocity", i, j, 3115);
+ // BKE_sim_debug_data_add_dot(
+ // clmd->debug_data, x, col[0], col[1], col[2],
+ // "grid velocity", i, j, 3115);
+ BKE_sim_debug_data_add_circle(
+ clmd->debug_data, x, 0.01f, col[0], col[1], col[2], "grid velocity", i, j, 3115);
}
# endif
}
@@ -906,7 +926,8 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
/* gather velocities & density */
if (smoothfac > 0.0f || pressfac > 0.0f) {
- HairVertexGrid *vertex_grid = BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_res, gmin, gmax);
+ HairVertexGrid *vertex_grid = BPH_hair_volume_create_vertex_grid(
+ clmd->sim_parms->voxel_res, gmin, gmax);
vert = cloth->verts;
for (i = 0; i < mvert_num; i++, vert++) {
@@ -932,7 +953,8 @@ static void cloth_calc_volume_force(ClothModifierData *clmd)
/* calculate volumetric forces */
BPH_mass_spring_get_motion_state(data, vert->solver_index, x, v);
- BPH_hair_volume_vertex_grid_forces(vertex_grid, x, v, smoothfac, pressfac, minpress, f, dfdx, dfdv);
+ BPH_hair_volume_vertex_grid_forces(
+ vertex_grid, x, v, smoothfac, pressfac, minpress, f, dfdx, dfdv);
/* apply on hair data */
BPH_mass_spring_force_extern(data, vert->solver_index, f, dfdx, dfdv);
}
@@ -1110,7 +1132,8 @@ int BPH_cloth_solve(
if (clmd->sim_parms->vgroup_mass > 0) {
if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) {
float x[3];
- /* divide by time_scale to prevent pinned vertices' delta locations from being multiplied */
+ /* divide by time_scale to prevent pinned vertices'
+ * delta locations from being multiplied */
interp_v3_v3v3(
x, verts[i].xold, verts[i].xconst, (step + dt) / clmd->sim_parms->time_scale);
BPH_mass_spring_set_position(id, i, x);
diff --git a/source/blender/physics/intern/ConstrainedConjugateGradient.h b/source/blender/physics/intern/ConstrainedConjugateGradient.h
index 0d361f98f4e..4a0a6ab298c 100644
--- a/source/blender/physics/intern/ConstrainedConjugateGradient.h
+++ b/source/blender/physics/intern/ConstrainedConjugateGradient.h
@@ -27,14 +27,16 @@ namespace Eigen {
namespace internal {
/** \internal Low-level conjugate gradient algorithm
- * \param mat: The matrix A
- * \param rhs: The right hand side vector b
- * \param x: On input and initial solution, on output the computed solution.
- * \param precond: A preconditioner being able to efficiently solve for an
- * approximation of Ax=b (regardless of b)
- * \param iters: On input the max number of iteration, on output the number of performed iterations.
- * \param tol_error: On input the tolerance error, on output an estimation of the relative error.
- */
+ * \param mat: The matrix A
+ * \param rhs: The right hand side vector b
+ * \param x: On input and initial solution, on output the computed solution.
+ * \param precond: A preconditioner being able to efficiently solve for an
+ * approximation of Ax=b (regardless of b)
+ * \param iters: On input the max number of iteration,
+ * on output the number of performed iterations.
+ * \param tol_error: On input the tolerance error,
+ * on output an estimation of the relative error.
+ */
template<typename MatrixType,
typename Rhs,
typename Dest,
@@ -59,7 +61,7 @@ EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat,
int n = mat.cols();
- VectorType residual = filter * (rhs - mat * x); //initial residual
+ VectorType residual = filter * (rhs - mat * x); // initial residual
RealScalar rhsNorm2 = (filter * rhs).squaredNorm();
if (rhsNorm2 == 0) {
@@ -78,7 +80,7 @@ EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat,
}
VectorType p(n);
- p = filter * precond.solve(residual); //initial search direction
+ p = filter * precond.solve(residual); // initial search direction
VectorType z(n), tmp(n);
RealScalar absNew = numext::real(
@@ -112,28 +114,26 @@ EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat,
} // namespace internal
#if 0 /* unused */
-template<typename MatrixType>
-struct MatrixFilter
-{
- MatrixFilter() :
- m_cmat(NULL)
+template<typename MatrixType> struct MatrixFilter {
+ MatrixFilter() : m_cmat(NULL)
{
}
- MatrixFilter(const MatrixType &cmat) :
- m_cmat(&cmat)
+ MatrixFilter(const MatrixType &cmat) : m_cmat(&cmat)
{
}
- void setMatrix(const MatrixType &cmat) { m_cmat = &cmat; }
+ void setMatrix(const MatrixType &cmat)
+ {
+ m_cmat = &cmat;
+ }
- template <typename VectorType>
- void apply(VectorType v) const
+ template<typename VectorType> void apply(VectorType v) const
{
v = (*m_cmat) * v;
}
-protected:
+ protected:
const MatrixType *m_cmat;
};
#endif
@@ -157,53 +157,54 @@ struct traits<
} // namespace internal
/** \ingroup IterativeLinearSolvers_Module
- * \brief A conjugate gradient solver for sparse self-adjoint problems with additional constraints
- *
- * This class allows to solve for A.x = b sparse linear problems using a conjugate gradient algorithm.
- * The sparse matrix A must be selfadjoint. The vectors x and b can be either dense or sparse.
- *
- * \tparam _MatrixType the type of the sparse matrix A, can be a dense or a sparse matrix.
- * \tparam _UpLo the triangular part that will be used for the computations. It can be Lower
- * or Upper. Default is Lower.
- * \tparam _Preconditioner the type of the preconditioner. Default is DiagonalPreconditioner
- *
- * The maximal number of iterations and tolerance value can be controlled via the setMaxIterations()
- * and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations
- * and NumTraits<Scalar>::epsilon() for the tolerance.
- *
- * This class can be used as the direct solver classes. Here is a typical usage example:
- * \code
- * int n = 10000;
- * VectorXd x(n), b(n);
- * SparseMatrix<double> A(n,n);
- * // fill A and b
- * ConjugateGradient<SparseMatrix<double> > cg;
- * cg.compute(A);
- * x = cg.solve(b);
- * std::cout << "#iterations: " << cg.iterations() << std::endl;
- * std::cout << "estimated error: " << cg.error() << std::endl;
- * // update b, and solve again
- * x = cg.solve(b);
- * \endcode
- *
- * By default the iterations start with x=0 as an initial guess of the solution.
- * One can control the start using the solveWithGuess() method. Here is a step by
- * step execution example starting with a random guess and printing the evolution
- * of the estimated error:
- * * \code
- * x = VectorXd::Random(n);
- * cg.setMaxIterations(1);
- * int i = 0;
- * do {
- * x = cg.solveWithGuess(b,x);
- * std::cout << i << " : " << cg.error() << std::endl;
- * ++i;
- * } while (cg.info()!=Success && i<100);
- * \endcode
- * Note that such a step by step execution is slightly slower.
- *
- * \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
- */
+ * \brief A conjugate gradient solver for sparse self-adjoint problems with additional constraints
+ *
+ * This class allows to solve for A.x = b sparse linear problems using a conjugate gradient
+ * algorithm. The sparse matrix A must be selfadjoint. The vectors x and b can be either dense or
+ * sparse.
+ *
+ * \tparam _MatrixType the type of the sparse matrix A, can be a dense or a sparse matrix.
+ * \tparam _UpLo the triangular part that will be used for the computations. It can be Lower
+ * or Upper. Default is Lower.
+ * \tparam _Preconditioner the type of the preconditioner. Default is DiagonalPreconditioner
+ *
+ * The maximal number of iterations and tolerance value can be controlled via the
+ * setMaxIterations() and setTolerance() methods. The defaults are the size of the problem for the
+ * maximal number of iterations and NumTraits<Scalar>::epsilon() for the tolerance.
+ *
+ * This class can be used as the direct solver classes. Here is a typical usage example:
+ * \code
+ * int n = 10000;
+ * VectorXd x(n), b(n);
+ * SparseMatrix<double> A(n,n);
+ * // fill A and b
+ * ConjugateGradient<SparseMatrix<double> > cg;
+ * cg.compute(A);
+ * x = cg.solve(b);
+ * std::cout << "#iterations: " << cg.iterations() << std::endl;
+ * std::cout << "estimated error: " << cg.error() << std::endl;
+ * // update b, and solve again
+ * x = cg.solve(b);
+ * \endcode
+ *
+ * By default the iterations start with x=0 as an initial guess of the solution.
+ * One can control the start using the solveWithGuess() method. Here is a step by
+ * step execution example starting with a random guess and printing the evolution
+ * of the estimated error:
+ * * \code
+ * x = VectorXd::Random(n);
+ * cg.setMaxIterations(1);
+ * int i = 0;
+ * do {
+ * x = cg.solveWithGuess(b,x);
+ * std::cout << i << " : " << cg.error() << std::endl;
+ * ++i;
+ * } while (cg.info()!=Success && i<100);
+ * \endcode
+ * Note that such a step by step execution is slightly slower.
+ *
+ * \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
+ */
template<typename _MatrixType, int _UpLo, typename _FilterMatrixType, typename _Preconditioner>
class ConstrainedConjugateGradient
: public IterativeSolverBase<
@@ -232,15 +233,15 @@ class ConstrainedConjugateGradient
}
/** Initialize the solver with matrix \a A for further \c Ax=b solving.
- *
- * This constructor is a shortcut for the default constructor followed
- * by a call to compute().
- *
- * \warning this class stores a reference to the matrix A as well as some
- * precomputed values that depend on it. Therefore, if \a A is changed
- * this class becomes invalid. Call compute() to update it with the new
- * matrix A, or modify a copy of A.
- */
+ *
+ * This constructor is a shortcut for the default constructor followed
+ * by a call to compute().
+ *
+ * \warning this class stores a reference to the matrix A as well as some
+ * precomputed values that depend on it. Therefore, if \a A is changed
+ * this class becomes invalid. Call compute() to update it with the new
+ * matrix A, or modify a copy of A.
+ */
ConstrainedConjugateGradient(const MatrixType &A) : Base(A)
{
}
@@ -259,10 +260,10 @@ class ConstrainedConjugateGradient
}
/** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A
- * \a x0 as an initial solution.
- *
- * \sa compute()
- */
+ * \a x0 as an initial solution.
+ *
+ * \sa compute()
+ */
template<typename Rhs, typename Guess>
inline const internal::solve_retval_with_guess<ConstrainedConjugateGradient, Rhs, Guess>
solveWithGuess(const MatrixBase<Rhs> &b, const Guess &x0) const
diff --git a/source/blender/physics/intern/eigen_utils.h b/source/blender/physics/intern/eigen_utils.h
index 7d56fe1a608..361ebadf5d2 100644
--- a/source/blender/physics/intern/eigen_utils.h
+++ b/source/blender/physics/intern/eigen_utils.h
@@ -140,8 +140,9 @@ typedef Eigen::SparseMatrix<Scalar> lMatrix;
/* Constructor type that provides more convenient handling of Eigen triplets
* for efficient construction of sparse 3x3 block matrices.
- * This should be used for building lMatrix instead of writing to such lMatrix directly (which is very inefficient).
- * After all elements have been defined using the set() method, the actual matrix can be filled using construct().
+ * This should be used for building lMatrix instead of writing to such lMatrix directly (which is
+ * very inefficient). After all elements have been defined using the set() method, the actual
+ * matrix can be filled using construct().
*/
struct lMatrix3fCtor {
lMatrix3fCtor()
diff --git a/source/blender/physics/intern/hair_volume.cpp b/source/blender/physics/intern/hair_volume.cpp
index 878f055af01..a07d1fe8f75 100644
--- a/source/blender/physics/intern/hair_volume.cpp
+++ b/source/blender/physics/intern/hair_volume.cpp
@@ -389,9 +389,14 @@ void BPH_hair_volume_add_vertex(HairGrid *grid, const float x[3], const float v[
}
#if 0
-BLI_INLINE void hair_volume_eval_grid_vertex(
- HairGridVert *vert, const float loc[3], float radius, float dist_scale,
- const float x2[3], const float v2[3], const float x3[3], const float v3[3])
+BLI_INLINE void hair_volume_eval_grid_vertex(HairGridVert *vert,
+ const float loc[3],
+ float radius,
+ float dist_scale,
+ const float x2[3],
+ const float v2[3],
+ const float x3[3],
+ const float v3[3])
{
float closest[3], lambda, dist, weight;
@@ -418,14 +423,31 @@ BLI_INLINE int major_axis_v3(const float v[3])
return a > b ? (a > c ? 0 : 2) : (b > c ? 1 : 2);
}
-BLI_INLINE void hair_volume_add_segment_2D(
- HairGrid *grid,
- const float UNUSED(x1[3]), const float UNUSED(v1[3]), const float x2[3], const float v2[3],
- const float x3[3], const float v3[3], const float UNUSED(x4[3]), const float UNUSED(v4[3]),
- const float UNUSED(dir1[3]), const float dir2[3], const float UNUSED(dir3[3]),
- int resj, int resk, int jmin, int jmax, int kmin, int kmax,
- HairGridVert *vert, int stride_j, int stride_k, const float loc[3], int axis_j, int axis_k,
- int debug_i)
+BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
+ const float UNUSED(x1[3]),
+ const float UNUSED(v1[3]),
+ const float x2[3],
+ const float v2[3],
+ const float x3[3],
+ const float v3[3],
+ const float UNUSED(x4[3]),
+ const float UNUSED(v4[3]),
+ const float UNUSED(dir1[3]),
+ const float dir2[3],
+ const float UNUSED(dir3[3]),
+ int resj,
+ int resk,
+ int jmin,
+ int jmax,
+ int kmin,
+ int kmax,
+ HairGridVert *vert,
+ int stride_j,
+ int stride_k,
+ const float loc[3],
+ int axis_j,
+ int axis_k,
+ int debug_i)
{
const float radius = 1.5f;
const float dist_scale = grid->inv_cellsize;
@@ -439,12 +461,12 @@ BLI_INLINE void hair_volume_add_segment_2D(
CLAMP_MAX(kmax, resk - 1);
HairGridVert *vert_j = vert + jmin * stride_j;
- float loc_j[3] = { loc[0], loc[1], loc[2] };
+ float loc_j[3] = {loc[0], loc[1], loc[2]};
loc_j[axis_j] += (float)jmin;
for (j = jmin; j <= jmax; ++j, vert_j += stride_j, loc_j[axis_j] += 1.0f) {
HairGridVert *vert_k = vert_j + kmin * stride_k;
- float loc_k[3] = { loc_j[0], loc_j[1], loc_j[2] };
+ float loc_k[3] = {loc_j[0], loc_j[1], loc_j[2]};
loc_k[axis_k] += (float)kmin;
for (k = kmin; k <= kmax; ++k, vert_k += stride_k, loc_k[axis_k] += 1.0f) {
@@ -465,7 +487,9 @@ BLI_INLINE void hair_volume_add_segment_2D(
BKE_sim_debug_data_add_dot(x2w, 0.1, 0.1, 0.7, "grid", 649, debug_i, j, k);
BKE_sim_debug_data_add_line(wloc, x2w, 0.3, 0.8, 0.3, "grid", 253, debug_i, j, k);
BKE_sim_debug_data_add_line(wloc, x3w, 0.8, 0.3, 0.3, "grid", 254, debug_i, j, k);
-// BKE_sim_debug_data_add_circle(x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 0.2, "grid", 255, i, j, k);
+ // BKE_sim_debug_data_add_circle(
+ // x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 0.2,
+ // "grid", 255, i, j, k);
}
}
# endif
@@ -478,13 +502,20 @@ BLI_INLINE void hair_volume_add_segment_2D(
* The radius of influence around a segment is assumed to be at most 2*cellsize,
* i.e. only cells containing the segment and their direct neighbors are examined.
*/
-void BPH_hair_volume_add_segment(
- HairGrid *grid,
- const float x1[3], const float v1[3], const float x2[3], const float v2[3],
- const float x3[3], const float v3[3], const float x4[3], const float v4[3],
- const float dir1[3], const float dir2[3], const float dir3[3])
+void BPH_hair_volume_add_segment(HairGrid *grid,
+ const float x1[3],
+ const float v1[3],
+ const float x2[3],
+ const float v2[3],
+ const float x3[3],
+ const float v3[3],
+ const float x4[3],
+ const float v4[3],
+ const float dir1[3],
+ const float dir2[3],
+ const float dir3[3])
{
- const int res[3] = { grid->res[0], grid->res[1], grid->res[2] };
+ const int res[3] = {grid->res[0], grid->res[1], grid->res[2]};
/* find the primary direction from the major axis of the direction vector */
const int axis0 = major_axis_v3(dir2);
@@ -492,7 +523,7 @@ void BPH_hair_volume_add_segment(
const int axis2 = (axis0 + 2) % 3;
/* vertex buffer offset factors along cardinal axes */
- const int strides[3] = { 1, res[0], res[0] * res[1] };
+ const int strides[3] = {1, res[0], res[0] * res[1]};
const int stride0 = strides[axis0];
const int stride1 = strides[axis1];
const int stride2 = strides[axis2];
@@ -505,7 +536,7 @@ void BPH_hair_volume_add_segment(
/* start/end points, so increment along axis0 is always positive */
const float *start = x2[axis0] < x3[axis0] ? x2 : x3;
- const float *end = x2[axis0] < x3[axis0] ? x3 : x2;
+ const float *end = x2[axis0] < x3[axis0] ? x3 : x2;
const float start0 = start[axis0], start1 = start[axis1], start2 = start[axis2];
const float end0 = end[axis0];
@@ -550,11 +581,31 @@ void BPH_hair_volume_add_segment(
loc0[axis1] = 0.0f;
loc0[axis2] = 0.0f;
- hair_volume_add_segment_2D(
- grid, x1, v1, x2, v2, x3, v3, x4, v4, dir1, dir2, dir3,
- res[axis1], res[axis2], jmin - 1, jmax + 2, kmin - 1, kmax + 2,
- vert0, stride1, stride2, loc0, axis1, axis2,
- i);
+ hair_volume_add_segment_2D(grid,
+ x1,
+ v1,
+ x2,
+ v2,
+ x3,
+ v3,
+ x4,
+ v4,
+ dir1,
+ dir2,
+ dir3,
+ res[axis1],
+ res[axis2],
+ jmin - 1,
+ jmax + 2,
+ kmin - 1,
+ kmax + 2,
+ vert0,
+ stride1,
+ stride2,
+ loc0,
+ axis1,
+ axis2,
+ i);
}
}
#else
@@ -769,7 +820,8 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid,
interp_v3_v3v3(col, col0, coln, fac);
}
if (fac > 0.05f)
- BKE_sim_debug_data_add_circle(grid->debug_data, wloc, 0.01f, col[0], col[1], col[2], "grid", 5522, i, j, k);
+ BKE_sim_debug_data_add_circle(
+ grid->debug_data, wloc, 0.01f, col[0], col[1], col[2], "grid", 5522, i, j, k);
}
#endif
}
@@ -895,7 +947,8 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid,
for (j = 0; j < resA[1]; ++j) {
for (i = 0; i < resA[0]; ++i) {
int u = i * strideA0 + j * strideA1 + k * strideA2;
- bool is_margin = MARGIN_i0 || MARGIN_i1 || MARGIN_j0 || MARGIN_j1 || MARGIN_k0 || MARGIN_k1;
+ bool is_margin = MARGIN_i0 || MARGIN_i1 || MARGIN_j0 || MARGIN_j1 || MARGIN_k0 ||
+ MARGIN_k1;
if (i != slice)
continue;
@@ -923,12 +976,15 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid,
interp_v3_v3v3(col, col0, coln, fac);
}
if (fac > 0.05f)
- BKE_sim_debug_data_add_circle(grid->debug_data, wloc, 0.01f, col[0], col[1], col[2], "grid", 5533, i, j, k);
+ BKE_sim_debug_data_add_circle(
+ grid->debug_data, wloc, 0.01f, col[0], col[1], col[2], "grid", 5533, i, j, k);
if (!is_margin) {
float dvel[3];
sub_v3_v3v3(dvel, vert->velocity_smooth, vert->velocity);
-// BKE_sim_debug_data_add_vector(grid->debug_data, wloc, dvel, 1, 1, 1, "grid", 5566, i, j, k);
+ // BKE_sim_debug_data_add_vector(
+ // grid->debug_data, wloc, dvel, 1, 1, 1,
+ // "grid", 5566, i, j, k);
}
if (!is_margin) {
@@ -938,8 +994,11 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid,
float col[3];
interp_v3_v3v3(col, col0, colp, d);
-// if (d > 0.05f)
-// BKE_sim_debug_data_add_dot(grid->debug_data, wloc, col[0], col[1], col[2], "grid", 5544, i, j, k);
+ // if (d > 0.05f) {
+ // BKE_sim_debug_data_add_dot(
+ // grid->debug_data, wloc, col[0], col[1], col[2],
+ // "grid", 5544, i, j, k);
+ // }
}
}
}
@@ -964,7 +1023,8 @@ bool BPH_hair_volume_solve_divergence(HairGrid *grid,
* See https://en.wikipedia.org/wiki/Filter_%28large_eddy_simulation%29
*/
-BLI_INLINE void hair_volume_filter_box_convolute(HairVertexGrid *grid, float invD, const int kernel_size[3], int i, int j, int k)
+BLI_INLINE void hair_volume_filter_box_convolute(
+ HairVertexGrid *grid, float invD, const int kernel_size[3], int i, int j, int k)
{
int res = grid->res;
int p, q, r;
@@ -1109,7 +1169,9 @@ void BPH_hair_volume_grid_geometry(
}
#if 0
-static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd, lfVector *lX, unsigned int numverts)
+static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
+ lfVector *lX,
+ unsigned int numverts)
{
int res = hair_grid_res;
int size = hair_grid_size(res);
diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c
index 622a7093fd4..cdd4d66d485 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -126,7 +126,7 @@ static void print_fvector(float m3[3])
// long float vector float (*)[3]
///////////////////////////
/* print long vector on console: for debug output */
-DO_INLINE void print_lfvector(float(*fLongVector)[3], unsigned int verts)
+DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts)
{
unsigned int i = 0;
for (i = 0; i < verts; i++) {
@@ -325,9 +325,9 @@ static void print_bfmatrix(fmatrix3x3 *m)
for (j = 0; j < 3; ++j) {
for (i = 0; i < 3; ++i) {
-// if (t[k + i + (l + j) * size] != 0.0f) {
-// printf("warning: overwriting value at %d, %d\n", m[q].r, m[q].c);
-// }
+ // if (t[k + i + (l + j) * size] != 0.0f) {
+ // printf("warning: overwriting value at %d, %d\n", m[q].r, m[q].c);
+ // }
if (k == l) {
t[k + i + (k + j) * size] += m[q].m[i][j];
}
@@ -412,7 +412,6 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
*/
}
}
-
}
# endif
@@ -534,8 +533,7 @@ static void print_bfmatrix(fmatrix3x3 *m3)
{
unsigned int i = 0;
- for (i = 0; i < m3[0].vcount + m3[0].scount; i++)
- {
+ for (i = 0; i < m3[0].vcount + m3[0].scount; i++) {
print_fmatrix(m3[i].m);
}
}
@@ -768,8 +766,10 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
}
}
-# if 0 /* this version of the CG algorithm does not work very well with partial constraints (where S has non-zero elements) */
-static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S)
+/* this version of the CG algorithm does not work very well with partial constraints
+ * (where S has non-zero elements). */
+# if 0
+static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S)
{
// Solves for unknown X in equation AX=B
unsigned int conjgrad_loopcount = 0, conjgrad_looplimit = 100;
@@ -831,7 +831,8 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
del_lfvector(r);
// printf("W/O conjgrad_loopcount: %d\n", conjgrad_loopcount);
- return conjgrad_loopcount < conjgrad_looplimit; // true means we reached desired accuracy in given time - ie stable
+ return conjgrad_loopcount <
+ conjgrad_looplimit; // true means we reached desired accuracy in given time - ie stable
}
# endif
@@ -937,22 +938,27 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
unsigned int i = 0;
// Take only the diagonal blocks of A
-// #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
+ // #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT)
for (i = 0; i < lA[0].vcount; i++) {
// block diagonalizer
cp_fmatrix(P[i].m, lA[i].m);
inverse_fmatrix(Pinv[i].m, P[i].m);
-
}
}
# if 0
// version 1.3
-static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv)
+static int cg_filtered_pre(lfVector *dv,
+ fmatrix3x3 *lA,
+ lfVector *lB,
+ lfVector *z,
+ fmatrix3x3 *S,
+ fmatrix3x3 *P,
+ fmatrix3x3 *Pinv)
{
unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit = 100;
float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0;
- float conjgrad_epsilon = 0.0001; // 0.2 is dt for steps=5
+ float conjgrad_epsilon = 0.0001; // 0.2 is dt for steps=5
lfVector *r = create_lfvector(numverts);
lfVector *p = create_lfvector(numverts);
lfVector *s = create_lfvector(numverts);
@@ -978,8 +984,7 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
double start = PIL_check_seconds_timer();
# endif
- while ((deltaNew > delta0) && (iterations < conjgrad_looplimit))
- {
+ while ((deltaNew > delta0) && (iterations < conjgrad_looplimit)) {
iterations++;
mul_bfmatrix_lfvector(s, lA, p);
@@ -1001,7 +1006,6 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
add_lfvector_lfvectorS(p, h, p, deltaNew / deltaOld, numverts);
filter(p, S);
-
}
# ifdef DEBUG_TIME
@@ -1021,7 +1025,14 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
# endif
// version 1.4
-static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector *z, fmatrix3x3 *S, fmatrix3x3 *P, fmatrix3x3 *Pinv, fmatrix3x3 *bigI)
+static int cg_filtered_pre(lfVector *dv,
+ fmatrix3x3 *lA,
+ lfVector *lB,
+ lfVector *z,
+ fmatrix3x3 *S,
+ fmatrix3x3 *P,
+ fmatrix3x3 *Pinv,
+ fmatrix3x3 *bigI)
{
unsigned int numverts = lA[0].vcount, iterations = 0, conjgrad_looplimit = 100;
float delta0 = 0, deltaNew = 0, deltaOld = 0, alpha = 0, tol = 0;
@@ -1084,8 +1095,7 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
tol = (0.01 * 0.2);
- while ((deltaNew > delta0 * tol * tol) && (iterations < conjgrad_looplimit))
- {
+ while ((deltaNew > delta0 * tol * tol) && (iterations < conjgrad_looplimit)) {
iterations++;
mul_bfmatrix_lfvector(s, lA, p);
@@ -1107,7 +1117,6 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
add_lfvector_lfvectorS(p, h, p, deltaNew / deltaOld, numverts);
filter(p, S);
-
}
# ifdef DEBUG_TIME
@@ -1448,7 +1457,8 @@ static float calc_nor_area_tri(float nor[3],
return normalize_v3(nor);
}
-/* XXX does not support force jacobians yet, since the effector system does not provide them either */
+/* XXX does not support force jacobians yet, since the effector system does not provide them either
+ */
void BPH_mass_spring_force_face_wind(
Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
{
@@ -1531,7 +1541,7 @@ void BPH_mass_spring_force_vertex_wind(Implicit_Data *data,
BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, float L, float k)
{
// dir is unit length direction, rest is spring's restlength, k is spring constant.
- //return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k;
+ // return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k;
outerproduct(to, dir, dir);
sub_m3_m3m3(to, I, to);
@@ -1542,13 +1552,18 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
/* unused */
# if 0
-BLI_INLINE void dfdx_damp(float to[3][3], const float dir[3], float length, const float vel[3], float rest, float damping)
+BLI_INLINE void dfdx_damp(float to[3][3],
+ const float dir[3],
+ float length,
+ const float vel[3],
+ float rest,
+ float damping)
{
// inner spring damping vel is the relative velocity of the endpoints.
// return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
- mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest))));
+ mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest))));
}
# endif
@@ -1618,8 +1633,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data,
# if 0
if (length > L) {
if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
- ( ((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen))
- {
+ (((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen)) {
// cut spring!
s->flags |= CSPRING_FLAG_DEACTIVATE;
return false;
@@ -1672,8 +1686,8 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data,
spring_length(data, i, j, extent, dir, &length, vel);
/* This code computes not only the force, but also its derivative.
- Zero derivative effectively disables the spring for the implicit solver.
- Thus length > restlen makes cloth unconstrained at the start of simulation. */
+ * Zero derivative effectively disables the spring for the implicit solver.
+ * Thus length > restlen makes cloth unconstrained at the start of simulation. */
if ((length >= restlen && length > 0) || resist_compress) {
float stretch_force;
@@ -1688,7 +1702,8 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data,
dfdx_spring(dfdx, dir, length, restlen, stiffness_tension);
}
else if (new_compress) {
- /* This is based on the Choi and Ko bending model, which works surprisingly well for compression. */
+ /* This is based on the Choi and Ko bending model,
+ * which works surprisingly well for compression. */
float kb = stiffness_compression;
float cb = kb; /* cb equal to kb seems to work, but a factor can be added if necessary */
@@ -1817,7 +1832,8 @@ BLI_INLINE void spring_angle(Implicit_Data *data,
sub_v3_v3(r_vel_b, vel_e);
}
-/* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps in Cloth Simulation". */
+/* Angular springs roughly based on the bending model proposed by Baraff and Witkin in "Large Steps
+ * in Cloth Simulation". */
bool BPH_mass_spring_force_spring_angular(Implicit_Data *data,
int i,
int j,
diff --git a/source/blender/physics/intern/implicit_eigen.cpp b/source/blender/physics/intern/implicit_eigen.cpp
index 2b9761f0ccc..04ca24e0382 100644
--- a/source/blender/physics/intern/implicit_eigen.cpp
+++ b/source/blender/physics/intern/implicit_eigen.cpp
@@ -182,8 +182,9 @@ typedef Eigen::SparseMatrix<Scalar> lMatrix;
/* Constructor type that provides more convenient handling of Eigen triplets
* for efficient construction of sparse 3x3 block matrices.
- * This should be used for building lMatrix instead of writing to such lMatrix directly (which is very inefficient).
- * After all elements have been defined using the set() method, the actual matrix can be filled using construct().
+ * This should be used for building lMatrix instead of writing to such lMatrix directly (which is
+ * very inefficient). After all elements have been defined using the set() method, the actual
+ * matrix can be filled using construct().
*/
struct lMatrixCtor {
lMatrixCtor()
@@ -814,7 +815,8 @@ static float calc_nor_area_tri(float nor[3],
return normalize_v3(nor);
}
-/* XXX does not support force jacobians yet, since the effector system does not provide them either */
+/* XXX does not support force jacobians yet,
+ * since the effector system does not provide them either. */
void BPH_mass_spring_force_face_wind(
Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3])
{
@@ -855,8 +857,8 @@ void BPH_mass_spring_force_edge_wind(Implicit_Data *data, int v1, int v2, const
BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, float L, float k)
{
- // dir is unit length direction, rest is spring's restlength, k is spring constant.
- //return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k;
+ /* dir is unit length direction, rest is spring's restlength, k is spring constant. */
+ // return ((I - outerprod(dir, dir)) * Min(1.0f, rest / length) - I) * -k;
outerproduct(to, dir, dir);
sub_m3_m3m3(to, I, to);
@@ -867,13 +869,18 @@ BLI_INLINE void dfdx_spring(float to[3][3], const float dir[3], float length, fl
/* unused */
# if 0
-BLI_INLINE void dfdx_damp(float to[3][3], const float dir[3], float length, const float vel[3], float rest, float damping)
+BLI_INLINE void dfdx_damp(float to[3][3],
+ const float dir[3],
+ float length,
+ const float vel[3],
+ float rest,
+ float damping)
{
// inner spring damping vel is the relative velocity of the endpoints.
// return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest)));
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
- mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest))));
+ mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest))));
}
# endif
@@ -940,8 +947,7 @@ BLI_INLINE bool spring_length(Implicit_Data *data,
# if 0
if (length > L) {
if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) &&
- ( ((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen))
- {
+ (((length - L) * 100.0f / L) > clmd->sim_parms->maxspringlen)) {
// cut spring!
s->flags |= CSPRING_FLAG_DEACTIVATE;
return false;
diff --git a/source/blender/python/bmesh/CMakeLists.txt b/source/blender/python/bmesh/CMakeLists.txt
index 14baa08abc1..3875057185a 100644
--- a/source/blender/python/bmesh/CMakeLists.txt
+++ b/source/blender/python/bmesh/CMakeLists.txt
@@ -17,9 +17,9 @@
set(INC
.
- ../../bmesh
../../blenkernel
../../blenlib
+ ../../bmesh
../../depsgraph
../../makesdna
../../../../intern/guardedalloc
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c
index 401dded5188..f9196f7f100 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.c
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.c
@@ -358,8 +358,7 @@ static int bpy_slot_from_py(BMesh *bm,
BMO_slot_buffer_alloc(bmop, bmop->slots_in, slot_name, tot);
i = 0;
- BM_ITER_BPY_BM_SEQ(ele, &iter, ((BPy_BMElemSeq *)value))
- {
+ BM_ITER_BPY_BM_SEQ (ele, &iter, ((BPy_BMElemSeq *)value)) {
slot->data.buf[i] = ele;
i++;
}
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 522927f56e2..eb611e6566a 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -875,10 +875,20 @@ static PyGetSetDef bpy_bmface_getseters[] = {
};
static PyGetSetDef bpy_bmloop_getseters[] = {
- /* generic */
- /* 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},
- // {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN},
+/* generic */
+/* flags are available but not used for loops. */
+#if 0
+ {(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",
(getter)bpy_bm_elem_hflag_get,
(setter)bpy_bm_elem_hflag_set,
@@ -2593,8 +2603,7 @@ static PyObject *bpy_bmelemseq_index_update(BPy_BMElemSeq *self)
int index = 0;
const char htype = bm_iter_itype_htype_map[self->itype];
- BM_ITER_BPY_BM_SEQ(ele, &iter, self)
- {
+ BM_ITER_BPY_BM_SEQ (ele, &iter, self) {
BM_elem_index_set(ele, index); /* set_dirty! */
index++;
}
@@ -2744,8 +2753,7 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
}
i = 0;
- BM_ITER_BPY_BM_SEQ(ele, &iter, self)
- {
+ BM_ITER_BPY_BM_SEQ (ele, &iter, self) {
if (keyfunc != NULL) {
PyObject *py_elem;
PyObject *index;
@@ -3168,8 +3176,7 @@ static Py_ssize_t bpy_bmelemseq_length(BPy_BMElemSeq *self)
BMHeader *ele;
Py_ssize_t tot = 0;
- BM_ITER_BPY_BM_SEQ(ele, &iter, self)
- {
+ BM_ITER_BPY_BM_SEQ (ele, &iter, self) {
tot++;
}
return tot;
@@ -3343,8 +3350,7 @@ static int bpy_bmelemseq_contains(BPy_BMElemSeq *self, PyObject *value)
if (value_bm_ele->bm == self->bm) {
BMElem *ele, *ele_test = value_bm_ele->ele;
BMIter iter;
- BM_ITER_BPY_BM_SEQ(ele, &iter, self)
- {
+ BM_ITER_BPY_BM_SEQ (ele, &iter, self) {
if (ele == ele_test) {
return 1;
}
@@ -4071,9 +4077,8 @@ int bpy_bm_generic_valid_check(BPy_BMGeneric *self)
* the previous action. */
#if 0
if (BM_mesh_validate(self->bm) == false) {
- PyErr_Format(PyExc_ReferenceError,
- "BMesh used by %.200s has become invalid",
- Py_TYPE(self)->tp_name);
+ PyErr_Format(
+ PyExc_ReferenceError, "BMesh used by %.200s has become invalid", Py_TYPE(self)->tp_name);
return -1;
}
#endif
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
index 34a4ec3b1ed..0aa01ddb594 100644
--- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c
@@ -516,7 +516,7 @@ static PySequenceMethods bpy_bmdeformvert_as_sequence = {
NULL, /* sq_repeat */
/* note: if this is set PySequence_Check() returns True,
- * but in this case we dont want to be treated as a seq */
+ * but in this case we dont want to be treated as a seq */
NULL, /* sq_item */
NULL, /* sq_slice */
diff --git a/source/blender/python/generic/CMakeLists.txt b/source/blender/python/generic/CMakeLists.txt
index 3b4182bc795..c878103e19d 100644
--- a/source/blender/python/generic/CMakeLists.txt
+++ b/source/blender/python/generic/CMakeLists.txt
@@ -21,8 +21,8 @@ set(INC
../../blenlib
../../gpu
../../makesdna
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
@@ -33,7 +33,6 @@ set(INC_SYS
set(SRC
bgl.c
blf_py_api.c
- bpy_internal_import.c
bpy_threads.c
idprop_py_api.c
imbuf_py_api.c
@@ -41,7 +40,6 @@ set(SRC
bgl.h
blf_py_api.h
- bpy_internal_import.h
idprop_py_api.h
imbuf_py_api.h
py_capi_utils.h
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 02cad742ed9..23be0d68fb0 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -130,10 +130,17 @@
# define GLclampfP_def(number) Buffer *bgl_buffer##number
#endif
+typedef struct BufferOrOffset {
+ Buffer *buffer;
+ void *offset;
+} BufferOrOffset;
+
#define GLvoidP_str "O&"
-#define GLvoidP_var(number) ((bgl_buffer##number) ? (bgl_buffer##number)->buf.asvoid : NULL)
-#define GLvoidP_ref(number) BGL_BufferOrNoneConverter, &bgl_buffer##number
-#define GLvoidP_def(number) Buffer *bgl_buffer##number
+#define GLvoidP_var(number) \
+ ((bgl_buffer##number.buffer) ? (bgl_buffer##number.buffer)->buf.asvoid : \
+ (bgl_buffer##number.offset))
+#define GLvoidP_ref(number) BGL_BufferOrOffsetConverter, &bgl_buffer##number
+#define GLvoidP_def(number) BufferOrOffset bgl_buffer##number
#define GLsizeiP_str "O!"
#define GLsizeiP_var(number) (bgl_buffer##number)->buf.asvoid
@@ -688,15 +695,29 @@ Buffer *BGL_MakeBuffer(int type, int ndimensions, int *dimensions, void *initbuf
return buffer;
}
-/* Custom converter function so we can support a buffer or NULL. */
-static int BGL_BufferOrNoneConverter(PyObject *object, Buffer **buffer)
+/* Custom converter function so we can support a buffer, an integer or NULL.
+ * Many OpenGL API functions can accept both an actual pointer or an offset
+ * into a buffer that is already bound. */
+static int BGL_BufferOrOffsetConverter(PyObject *object, BufferOrOffset *buffer)
{
if (object == Py_None) {
- *buffer = NULL;
+ buffer->buffer = NULL;
+ buffer->offset = NULL;
+ return 1;
+ }
+ else if (PyNumber_Check(object)) {
+ Py_ssize_t offset = PyNumber_AsSsize_t(object, PyExc_IndexError);
+ if (offset == -1 && PyErr_Occurred()) {
+ return 0;
+ }
+
+ buffer->buffer = NULL;
+ buffer->offset = (void *)offset;
return 1;
}
else if (PyObject_TypeCheck(object, &BGL_bufferType)) {
- *buffer = (Buffer *)object;
+ buffer->buffer = (Buffer *)object;
+ buffer->offset = NULL;
return 1;
}
else {
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
deleted file mode 100644
index 2df828d89e0..00000000000
--- a/source/blender/python/generic/bpy_internal_import.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup pygen
- *
- * This file defines replacements for pythons '__import__' and 'imp.reload'
- * functions which can import from blender textblocks.
- *
- * \note
- * This should eventually be replaced by import hooks (pep 302).
- */
-
-#include <Python.h>
-#include <stddef.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_text_types.h"
-
-#include "BLI_listbase.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_main.h"
-/* UNUSED */
-#include "BKE_text.h" /* txt_to_buf */
-
-#include "py_capi_utils.h"
-
-#include "bpy_internal_import.h" /* own include */
-
-static Main *bpy_import_main = NULL;
-static ListBase bpy_import_main_list;
-
-static PyMethodDef bpy_import_meth;
-static PyMethodDef bpy_reload_meth;
-static PyObject *imp_reload_orig = NULL;
-
-/* 'builtins' is most likely PyEval_GetBuiltins() */
-
-/**
- * \note to the discerning developer, yes - this is nasty
- * monkey-patching our own import into Python's builtin 'imp' module.
- *
- * However Python's alternative is to use import hooks,
- * which are implemented in a way that we can't use our own importer as a
- * fall-back (instead we must try and fail - raise an exception every time).
- * Since importing from blenders text-blocks is not the common case
- * I prefer to use Pythons import by default and fall-back to
- * Blenders - which we can only do by intercepting import calls I'm afraid.
- * - Campbell
- */
-void bpy_import_init(PyObject *builtins)
-{
- PyObject *item;
- PyObject *mod;
-
- PyDict_SetItemString(builtins, "__import__", item = PyCFunction_New(&bpy_import_meth, NULL));
- Py_DECREF(item);
-
- /* move reload here
- * XXX, use import hooks */
- mod = PyImport_ImportModuleLevel("importlib", NULL, NULL, NULL, 0);
- if (mod) {
- PyObject *mod_dict = PyModule_GetDict(mod);
-
- /* blender owns the function */
- imp_reload_orig = PyDict_GetItemString(mod_dict, "reload");
- Py_INCREF(imp_reload_orig);
-
- PyDict_SetItemString(mod_dict, "reload", item = PyCFunction_New(&bpy_reload_meth, NULL));
- Py_DECREF(item);
- Py_DECREF(mod);
- }
- else {
- BLI_assert(!"unable to load 'importlib' module.");
- }
-}
-
-static void free_compiled_text(Text *text)
-{
- if (text->compiled) {
- Py_DECREF((PyObject *)text->compiled);
- }
- text->compiled = NULL;
-}
-
-struct Main *bpy_import_main_get(void)
-{
- return bpy_import_main;
-}
-
-void bpy_import_main_set(struct Main *maggie)
-{
- bpy_import_main = maggie;
-}
-
-/* returns a dummy filename for a textblock so we can tell what file a text block comes from */
-void bpy_text_filename_get(char *fn, size_t fn_len, Text *text)
-{
- BLI_snprintf(
- fn, fn_len, "%s%c%s", ID_BLEND_PATH(bpy_import_main, &text->id), SEP, text->id.name + 2);
-}
-
-bool bpy_text_compile(Text *text)
-{
- char fn_dummy[FILE_MAX];
- PyObject *fn_dummy_py;
- char *buf;
-
- bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
-
- /* if previously compiled, free the object */
- free_compiled_text(text);
-
- fn_dummy_py = PyC_UnicodeFromByte(fn_dummy);
-
- buf = txt_to_buf(text);
- text->compiled = Py_CompileStringObject(buf, fn_dummy_py, Py_file_input, NULL, -1);
- MEM_freeN(buf);
-
- Py_DECREF(fn_dummy_py);
-
- if (PyErr_Occurred()) {
- PyErr_Print();
- PyErr_Clear();
- PySys_SetObject("last_traceback", NULL);
- free_compiled_text(text);
- return false;
- }
- else {
- return true;
- }
-}
-
-PyObject *bpy_text_import(Text *text)
-{
- char modulename[MAX_ID_NAME + 2];
- int len;
-
- if (!text->compiled) {
- if (bpy_text_compile(text) == false) {
- return NULL;
- }
- }
-
- len = strlen(text->id.name + 2);
- BLI_strncpy(modulename, text->id.name + 2, len);
- modulename[len - 3] = '\0'; /* remove .py */
- return PyImport_ExecCodeModule(modulename, text->compiled);
-}
-
-PyObject *bpy_text_import_name(const char *name, int *found)
-{
- Text *text;
- char txtname[MAX_ID_NAME - 2];
- int namelen = strlen(name);
- //XXX Main *maggie = bpy_import_main ? bpy_import_main : G_MAIN;
- Main *maggie = bpy_import_main;
-
- *found = 0;
-
- if (!maggie) {
- printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n");
- return NULL;
- }
-
- /* we know this cant be importable, the name is too long for blender! */
- if (namelen >= (MAX_ID_NAME - 2) - 3) {
- return NULL;
- }
-
- memcpy(txtname, name, namelen);
- memcpy(&txtname[namelen], ".py", 4);
-
- text = BLI_findstring(&maggie->texts, txtname, offsetof(ID, name) + 2);
-
- if (text) {
- *found = 1;
- return bpy_text_import(text);
- }
-
- /* If we still haven't found the module try additional modules form bpy_import_main_list */
- maggie = bpy_import_main_list.first;
- while (maggie && !text) {
- text = BLI_findstring(&maggie->texts, txtname, offsetof(ID, name) + 2);
- maggie = maggie->next;
- }
-
- if (!text) {
- return NULL;
- }
- else {
- *found = 1;
- }
-
- return bpy_text_import(text);
-}
-
-/*
- * find in-memory module and recompile
- */
-
-PyObject *bpy_text_reimport(PyObject *module, int *found)
-{
- Text *text;
- const char *name;
- const char *filepath;
- //XXX Main *maggie = bpy_import_main ? bpy_import_main : G_MAIN;
- Main *maggie = bpy_import_main;
-
- if (!maggie) {
- printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n");
- return NULL;
- }
-
- *found = 0;
-
- /* get name, filename from the module itself */
- if ((name = PyModule_GetName(module)) == NULL) {
- return NULL;
- }
-
- {
- PyObject *module_file = PyModule_GetFilenameObject(module);
- if (module_file == NULL) {
- return NULL;
- }
- filepath = _PyUnicode_AsString(module_file);
- Py_DECREF(module_file);
- if (filepath == NULL) {
- return NULL;
- }
- }
-
- /* look up the text object */
- text = BLI_findstring(&maggie->texts, BLI_path_basename(filepath), offsetof(ID, name) + 2);
-
- /* uh-oh.... didn't find it */
- if (!text) {
- return NULL;
- }
- else {
- *found = 1;
- }
-
- if (bpy_text_compile(text) == false) {
- return NULL;
- }
-
- /* make into a module */
- return PyImport_ExecCodeModule(name, text->compiled);
-}
-
-static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
-{
- PyObject *exception, *err, *tb;
- const char *name;
- int found = 0;
- PyObject *globals = NULL, *locals = NULL, *fromlist = NULL;
- int level = 0; /* relative imports */
- PyObject *newmodule;
-
- static const char *_keywords[] = {"name", "globals", "locals", "fromlist", "level", NULL};
- static _PyArg_Parser _parser = {"s|OOOi:bpy_import_meth", _keywords, 0};
- if (!_PyArg_ParseTupleAndKeywordsFast(
- args, kw, &_parser, &name, &globals, &locals, &fromlist, &level)) {
- return NULL;
- }
-
- /* import existing builtin modules or modules that have been imported already */
- newmodule = PyImport_ImportModuleLevel(name, globals, locals, fromlist, level);
-
- if (newmodule) {
- return newmodule;
- }
-
- PyErr_Fetch(&exception,
- &err,
- &tb); /* get the python error in case we cant import as blender text either */
-
- /* importing from existing modules failed, see if we have this module as blender text */
- newmodule = bpy_text_import_name(name, &found);
-
- if (newmodule) { /* found module as blender text, ignore above exception */
- PyErr_Clear();
- Py_XDECREF(exception);
- Py_XDECREF(err);
- Py_XDECREF(tb);
- /* printf("imported from text buffer...\n"); */
- }
- else if (found ==
- 1) { /* blender text module failed to execute but was found, use its error message */
- Py_XDECREF(exception);
- Py_XDECREF(err);
- Py_XDECREF(tb);
- return NULL;
- }
- else {
- /* no blender text was found that could import the module
- * reuse the original error from PyImport_ImportModuleEx */
- PyErr_Restore(exception, err, tb);
- }
- return newmodule;
-}
-
-/*
- * our reload() module, to handle reloading in-memory scripts
- */
-
-static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
-{
- PyObject *exception, *err, *tb;
- PyObject *newmodule = NULL;
- int found = 0;
-
- /* try reimporting from file */
-
- /* in Py3.3 this just calls imp.reload() which we overwrite, causing recursive calls */
- //newmodule = PyImport_ReloadModule(module);
-
- newmodule = PyObject_CallFunctionObjArgs(imp_reload_orig, module, NULL);
-
- if (newmodule) {
- return newmodule;
- }
-
- /* no file, try importing from memory */
- PyErr_Fetch(&exception, &err, &tb); /*restore for probable later use */
-
- newmodule = bpy_text_reimport(module, &found);
- if (newmodule) { /* found module as blender text, ignore above exception */
- PyErr_Clear();
- Py_XDECREF(exception);
- Py_XDECREF(err);
- Py_XDECREF(tb);
- /* printf("imported from text buffer...\n"); */
- }
- else if (found ==
- 1) { /* blender text module failed to execute but was found, use its error message */
- Py_XDECREF(exception);
- Py_XDECREF(err);
- Py_XDECREF(tb);
- return NULL;
- }
- else {
- /* no blender text was found that could import the module
- * reuse the original error from PyImport_ImportModuleEx */
- PyErr_Restore(exception, err, tb);
- }
-
- return newmodule;
-}
-
-static PyMethodDef bpy_import_meth = {"bpy_import_meth",
- (PyCFunction)blender_import,
- METH_VARARGS | METH_KEYWORDS,
- "blenders import"};
-static PyMethodDef bpy_reload_meth = {
- "bpy_reload_meth", (PyCFunction)blender_reload, METH_O, "blenders reload"};
diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h
deleted file mode 100644
index 2ab535d1018..00000000000
--- a/source/blender/python/generic/bpy_internal_import.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup pygen
- */
-
-/* Note, the BGE needs to use this too, keep it minimal */
-
-#ifndef __BPY_INTERNAL_IMPORT_H__
-#define __BPY_INTERNAL_IMPORT_H__
-
-/* python redefines :/ */
-#ifdef _POSIX_C_SOURCE
-# undef _POSIX_C_SOURCE
-#endif
-
-#ifdef _XOPEN_SOURCE
-# undef _XOPEN_SOURCE
-#endif
-
-struct Text;
-
-void bpy_import_init(PyObject *builtins);
-
-bool bpy_text_compile(struct Text *text);
-PyObject *bpy_text_import(struct Text *text);
-PyObject *bpy_text_import_name(const char *name, int *found);
-PyObject *bpy_text_reimport(PyObject *module, int *found);
-/* void bpy_text_clear_modules(int clear_all);*/ /* Clear user modules */
-
-void bpy_text_filename_get(char *fn, size_t fn_len, struct Text *text);
-
-struct Main *bpy_import_main_get(void);
-void bpy_import_main_set(struct Main *maggie);
-
-#endif /* __BPY_INTERNAL_IMPORT_H__ */
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index d96bef797cb..dd5baaa661c 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -164,12 +164,12 @@ 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)
{
switch (prop->type) {
- case IDP_STRING:
- {
+ case IDP_STRING: {
char *st;
if (!PyUnicode_Check(value)) {
PyErr_SetString(PyExc_TypeError, "expected a string!");
@@ -198,8 +198,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
return 0;
}
- case IDP_INT:
- {
+ case IDP_INT: {
int ivalue = PyLong_AsSsize_t(value);
if (ivalue == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "expected an int type");
@@ -208,8 +207,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
IDP_Int(prop) = ivalue;
break;
}
- case IDP_FLOAT:
- {
+ case IDP_FLOAT: {
float fvalue = (float)PyFloat_AsDouble(value);
if (fvalue == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "expected a float");
@@ -218,8 +216,7 @@ static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject
IDP_Float(self->prop) = fvalue;
break;
}
- case IDP_DOUBLE:
- {
+ case IDP_DOUBLE: {
double dvalue = PyFloat_AsDouble(value);
if (dvalue == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "expected a float");
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 191863a862d..25549c95896 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -37,7 +37,8 @@
#include "BLI_string.h"
#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"
#endif
@@ -273,7 +274,8 @@ void PyC_ObSpitStr(char *result, size_t result_len, PyObject *var)
const PyTypeObject *type = Py_TYPE(var);
PyObject *var_str = PyObject_Repr(var);
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();
}
BLI_snprintf(result,
@@ -765,7 +767,8 @@ void PyC_MainModule_Restore(PyObject *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)
{
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];
- /* 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); */
BLI_strncpy_wchar_from_utf8(
diff --git a/source/blender/python/generic/python_utildefines.h b/source/blender/python/generic/python_utildefines.h
index 40cec436dea..653122c9c33 100644
--- a/source/blender/python/generic/python_utildefines.h
+++ b/source/blender/python/generic/python_utildefines.h
@@ -45,7 +45,8 @@ Py_LOCAL_INLINE(PyObject *) Py_INCREF_RET(PyObject *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)
{
int ret = PyList_Append(op, v);
diff --git a/source/blender/python/gpu/CMakeLists.txt b/source/blender/python/gpu/CMakeLists.txt
index cda866510e3..ca0e6ced42b 100644
--- a/source/blender/python/gpu/CMakeLists.txt
+++ b/source/blender/python/gpu/CMakeLists.txt
@@ -21,8 +21,8 @@ set(INC
../../blenlib
../../gpu
../../makesdna
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index 094052b724f..a9e65413767 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -127,7 +127,8 @@ PyDoc_STRVAR(bpygpu_Batch_vertbuf_add_doc,
" Add another vertex buffer to the Batch.\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"
-" 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"
"\n"
" :param buf: The vertex buffer that will be added to the batch.\n"
diff --git a/source/blender/python/gpu/gpu_py_matrix.c b/source/blender/python/gpu/gpu_py_matrix.c
index 85d65ee4e2c..93cca78bad9 100644
--- a/source/blender/python/gpu/gpu_py_matrix.c
+++ b/source/blender/python/gpu/gpu_py_matrix.c
@@ -505,12 +505,9 @@ static struct PyMethodDef bpygpu_matrix_methods[] = {
/* TODO */
#if 0
- {"rotate", (PyCFunction)bpygpu_matrix_rotate,
- METH_O, bpygpu_matrix_rotate_doc},
- {"rotate_axis", (PyCFunction)bpygpu_matrix_rotate_axis,
- METH_O, bpygpu_matrix_rotate_axis_doc},
- {"look_at", (PyCFunction)bpygpu_matrix_look_at,
- METH_O, bpygpu_matrix_look_at_doc},
+ {"rotate", (PyCFunction)bpygpu_matrix_rotate, METH_O, bpygpu_matrix_rotate_doc},
+ {"rotate_axis", (PyCFunction)bpygpu_matrix_rotate_axis, METH_O, bpygpu_matrix_rotate_axis_doc},
+ {"look_at", (PyCFunction)bpygpu_matrix_look_at, METH_O, bpygpu_matrix_look_at_doc},
#endif
/* Write State */
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index 7eb008efeef..fc945562c98 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenlib
../../blenloader
../../blentranslation
+ ../../depsgraph
../../editors/include
../../gpu
../../imbuf
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index ed576c553e4..92ba7704b19 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -177,7 +177,8 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
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);
return PyC_UnicodeFromByte(path ? path : "");
@@ -274,19 +275,35 @@ static PyObject *bpy_escape_identifier(PyObject *UNUSED(self), PyObject *value)
}
static PyMethodDef meth_bpy_script_paths = {
- "script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc};
-static PyMethodDef meth_bpy_blend_paths = {"blend_paths",
- (PyCFunction)bpy_blend_paths,
- METH_VARARGS | METH_KEYWORDS,
- bpy_blend_paths_doc};
+ "script_paths",
+ (PyCFunction)bpy_script_paths,
+ METH_NOARGS,
+ bpy_script_paths_doc,
+};
+static PyMethodDef meth_bpy_blend_paths = {
+ "blend_paths",
+ (PyCFunction)bpy_blend_paths,
+ METH_VARARGS | METH_KEYWORDS,
+ bpy_blend_paths_doc,
+};
static PyMethodDef meth_bpy_user_resource = {
- "user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS | METH_KEYWORDS, NULL};
-static PyMethodDef meth_bpy_resource_path = {"resource_path",
- (PyCFunction)bpy_resource_path,
- METH_VARARGS | METH_KEYWORDS,
- bpy_resource_path_doc};
+ "user_resource",
+ (PyCFunction)bpy_user_resource,
+ METH_VARARGS | METH_KEYWORDS,
+ NULL,
+};
+static PyMethodDef meth_bpy_resource_path = {
+ "resource_path",
+ (PyCFunction)bpy_resource_path,
+ METH_VARARGS | METH_KEYWORDS,
+ bpy_resource_path_doc,
+};
static PyMethodDef meth_bpy_escape_identifier = {
- "escape_identifier", (PyCFunction)bpy_escape_identifier, METH_O, bpy_escape_identifier_doc};
+ "escape_identifier",
+ (PyCFunction)bpy_escape_identifier,
+ METH_O,
+ bpy_escape_identifier_doc,
+};
static PyObject *bpy_import_test(const char *modname)
{
diff --git a/source/blender/python/intern/bpy_app_ocio.c b/source/blender/python/intern/bpy_app_ocio.c
index 2a56075e00e..9dcadbac2af 100644
--- a/source/blender/python/intern/bpy_app_ocio.c
+++ b/source/blender/python/intern/bpy_app_ocio.c
@@ -40,10 +40,12 @@ static PyStructSequence_Field app_ocio_info_fields[] = {
};
static PyStructSequence_Desc app_ocio_info_desc = {
- (char *)"bpy.app.ocio", /* name */
- (char
- *)"This module contains information about OpenColorIO blender is linked against", /* doc */
- app_ocio_info_fields, /* fields */
+ /* name */
+ (char *)"bpy.app.ocio",
+ /* doc */
+ (char *)"This module contains information about OpenColorIO blender is linked against",
+ /* fields */
+ app_ocio_info_fields,
ARRAY_SIZE(app_ocio_info_fields) - 1,
};
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index 56de6dd1405..a48cd742448 100644
--- a/source/blender/python/intern/bpy_app_translations.c
+++ b/source/blender/python/intern/bpy_app_translations.c
@@ -47,13 +47,16 @@
typedef struct {
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;
- /* A "named tuple" (StructSequence actually...) containing all C-defined contexts. */
+ /** A "named tuple" (StructSequence actually...) containing all C-defined 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;
- /* 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;
} BlenderAppTranslations;
@@ -111,8 +114,8 @@ static void _ghashutil_keyfree(void *ptr)
/***** Python's messages cache *****/
/* 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
- * the later as much as we can!
+ * Changing of locale is not so common, while looking for a message translation is,
+ * 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.
*/
static GHash *_translations_cache = NULL;
@@ -148,7 +151,8 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale)
printf("\n");
# 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);
if (!lang_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;
/* 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_Desc app_translations_contexts_desc = {
diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.c
index db1684a7bca..2ff357896d5 100644
--- a/source/blender/python/intern/bpy_capi_utils.c
+++ b/source/blender/python/intern/bpy_capi_utils.c
@@ -136,7 +136,12 @@ bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const boo
}
#if 0 /* ARG!. workaround for a bug in blenders use of vsnprintf */
- BKE_reportf(reports, RPT_ERROR, "%s\nlocation: %s:%d\n", _PyUnicode_AsString(pystring), filename, lineno);
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "%s\nlocation: %s:%d\n",
+ _PyUnicode_AsString(pystring),
+ filename,
+ lineno);
#else
pystring_format = PyUnicode_FromFormat(
TIP_("%s\nlocation: %s:%d\n"), _PyUnicode_AsString(pystring), filename, lineno);
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index 3457e614708..726599ff06e 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -54,7 +54,10 @@ extern void BPY_update_rna_module(void);
# include <opcode.h>
#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;
#ifdef USE_BYTECODE_WHITELIST
@@ -399,8 +402,10 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
{
PyObject *driver_vars = 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;
PyGILState_STATE gilstate;
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);
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
is_recompile = true;
#endif
diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c
index 41ff630753f..c66cad5f4a3 100644
--- a/source/blender/python/intern/bpy_gizmo_wrap.c
+++ b/source/blender/python/intern/bpy_gizmo_wrap.c
@@ -116,8 +116,9 @@ static void gizmo_properties_init(wmGizmoType *gzt)
/* Extract target property definitions from 'bl_target_properties' */
{
- /* 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 */
+ /* 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. */
PyObject *py_class_dict = py_class->tp_dict;
PyObject *bl_target_properties = PyDict_GetItem(py_class_dict,
bpy_intern_str_bl_target_properties);
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 1b36ded884d..b34a41b5af6 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -63,7 +63,6 @@
#include "BPY_extern.h"
-#include "../generic/bpy_internal_import.h" /* our own imports */
#include "../generic/py_capi_utils.h"
/* inittab initialization functions */
@@ -81,7 +80,8 @@ CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_RNA, "bpy.rna");
/* 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;
// #define TIME_PY_RUN // simple python tests. prints on exit.
@@ -105,7 +105,6 @@ void BPY_context_update(bContext *C)
}
BPy_SetContext(C);
- bpy_import_main_set(CTX_data_main(C));
BPY_modules_update(C); /* can give really bad results if this isn't here */
}
@@ -150,7 +149,6 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
* cant set NULL because of this. but this is very flakey still. */
#if 0
BPy_SetContext(NULL);
- bpy_import_main_set(NULL);
#endif
#ifdef TIME_PY_RUN
@@ -184,7 +182,7 @@ void BPY_modules_update(bContext *C)
#if 0 /* slow, this runs all the time poll, draw etc 100's of time a sec. */
PyObject *mod = PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
PyModule_AddObject(mod, "data", BPY_rna_module());
- PyModule_AddObject(mod, "types", BPY_rna_types()); /* atm this does not need updating */
+ PyModule_AddObject(mod, "types", BPY_rna_types()); /* atm this does not need updating */
#endif
/* refreshes the main struct */
@@ -213,9 +211,9 @@ static PyObject *CCL_initPython(void)
static struct _inittab bpy_internal_modules[] = {
{"mathutils", PyInit_mathutils},
#if 0
- {"mathutils.geometry", PyInit_mathutils_geometry},
- {"mathutils.noise", PyInit_mathutils_noise},
- {"mathutils.kdtree", PyInit_mathutils_kdtree},
+ {"mathutils.geometry", PyInit_mathutils_geometry},
+ {"mathutils.noise", PyInit_mathutils_noise},
+ {"mathutils.kdtree", PyInit_mathutils_kdtree},
#endif
{"_bpy_path", BPyInit__bpy_path},
{"bgl", BPyInit_bgl},
@@ -223,9 +221,9 @@ static struct _inittab bpy_internal_modules[] = {
{"imbuf", BPyInit_imbuf},
{"bmesh", BPyInit_bmesh},
#if 0
- {"bmesh.types", BPyInit_bmesh_types},
- {"bmesh.utils", BPyInit_bmesh_utils},
- {"bmesh.utils", BPyInit_bmesh_geometry},
+ {"bmesh.types", BPyInit_bmesh_types},
+ {"bmesh.utils", BPyInit_bmesh_utils},
+ {"bmesh.utils", BPyInit_bmesh_geometry},
#endif
#ifdef WITH_AUDASPACE
{"aud", AUD_initPython},
@@ -329,8 +327,6 @@ void BPY_python_start(int argc, const char **argv)
/* bpy.* and lets us import it */
BPy_init_modules();
- bpy_import_init(PyEval_GetBuiltins());
-
pyrna_alloc_types();
#ifndef WITH_PYTHON_MODULE
@@ -427,6 +423,12 @@ typedef struct {
} PyModuleObject;
#endif
+/* returns a dummy filename for a textblock so we can tell what file a text block comes from */
+static void bpy_text_filename_get(char *fn, const Main *bmain, size_t fn_len, const Text *text)
+{
+ BLI_snprintf(fn, fn_len, "%s%c%s", ID_BLEND_PATH(bmain, &text->id), SEP, text->id.name + 2);
+}
+
static bool python_script_exec(
bContext *C, const char *fn, struct Text *text, struct ReportList *reports, const bool do_jump)
{
@@ -447,7 +449,7 @@ static bool python_script_exec(
if (text) {
char fn_dummy[FILE_MAXDIR];
- bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
+ bpy_text_filename_get(fn_dummy, bmain_old, sizeof(fn_dummy), text);
if (text->compiled == NULL) { /* if it wasn't already compiled, do it now */
char *buf;
@@ -696,8 +698,6 @@ bool BPY_execute_string_ex(bContext *C, const char *imports[], const char *expr,
PyObject *main_mod = NULL;
PyObject *py_dict, *retval;
bool ok = true;
- Main *
- bmain_back; /* XXX, quick fix for release (Copy Settings crash), needs further investigation */
if (expr[0] == '\0') {
return ok;
@@ -709,9 +709,6 @@ bool BPY_execute_string_ex(bContext *C, const char *imports[], const char *expr,
py_dict = PyC_DefaultNameSpace("<blender string>");
- bmain_back = bpy_import_main_get();
- bpy_import_main_set(CTX_data_main(C));
-
if (imports && (!PyC_NameSpace_ImportArray(py_dict, imports))) {
Py_DECREF(py_dict);
retval = NULL;
@@ -720,8 +717,6 @@ bool BPY_execute_string_ex(bContext *C, const char *imports[], const char *expr,
retval = PyRun_String(expr, use_eval ? Py_eval_input : Py_file_input, py_dict, py_dict);
}
- bpy_import_main_set(bmain_back);
-
if (retval == NULL) {
ok = false;
BPy_errors_to_report(CTX_wm_reports(C));
@@ -774,17 +769,9 @@ void BPY_modules_load_user(bContext *C)
}
}
else {
- PyObject *module = bpy_text_import(text);
-
- if (module == NULL) {
- PyErr_Print();
- PyErr_Clear();
- }
- else {
- Py_DECREF(module);
- }
+ BPY_execute_text(C, text, NULL, false);
- /* check if the script loaded a new file */
+ /* Check if the script loaded a new file. */
if (bmain != CTX_data_main(C)) {
break;
}
@@ -820,7 +807,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
else if (BPy_StructRNA_Check(item)) {
ptr = &(((BPy_StructRNA *)item)->ptr);
- //result->ptr = ((BPy_StructRNA *)item)->ptr;
+ // result->ptr = ((BPy_StructRNA *)item)->ptr;
CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
CTX_data_type_set(result, CTX_DATA_TYPE_POINTER);
done = true;
@@ -841,7 +828,8 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
if (BPy_StructRNA_Check(list_item)) {
#if 0
- CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink), "bpy_context_get");
+ CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink),
+ "bpy_context_get");
link->ptr = ((BPy_StructRNA *)item)->ptr;
BLI_addtail(&result->list, link);
#endif
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 1e979ad1d0b..aef4ab6667a 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -37,7 +37,6 @@
#include "bpy_operator_wrap.h"
#include "bpy_rna.h" /* for setting arg props only - pyrna_py_to_prop() */
#include "bpy_capi_utils.h"
-#include "../generic/bpy_internal_import.h"
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
@@ -298,9 +297,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
{
/* no props */
if (kw != NULL) {
- PyErr_Format(PyExc_AttributeError,
- "Operator \"%s\" does not take any args",
- opname);
+ PyErr_Format(PyExc_AttributeError, "Operator \"%s\" does not take any args", opname);
return NULL;
}
@@ -317,14 +314,12 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
- /* when calling bpy.ops.wm.read_factory_settings() bpy.data's main pointer is freed by clear_globals(),
- * further access will crash blender. setting context is not needed in this case, only calling because this
+ /* When calling bpy.ops.wm.read_factory_settings() bpy.data's main pointer
+ * 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) */
BPY_modules_update(C);
- /* needed for when WM_OT_read_factory_settings us called from within a script */
- bpy_import_main_set(CTX_data_main(C));
-
/* return operator_ret as a bpy enum */
return pyrna_enum_bitfield_to_py(rna_enum_operator_return_items, operator_ret);
}
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 976ed4611b0..8f2f08c7c37 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -45,7 +45,8 @@ static void operator_properties_init(wmOperatorType *ot)
/* Only call this so pyrna_deferred_register_class gives a useful error
* 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);
@@ -56,8 +57,9 @@ static void operator_properties_init(wmOperatorType *ot)
/* set the default property: ot->prop */
{
- /* 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 */
+ /* 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. */
PyObject *py_class_dict = py_class->tp_dict;
PyObject *bl_property = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_property);
const char *prop_id;
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 19315d9f2cc..074d72f094f 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -1382,7 +1382,11 @@ static size_t strswapbufcpy(char *buf, const char **orig)
char *dst = buf;
size_t i = 0;
*orig = buf;
- while ((*dst = *src)) { dst++; src++; i++; }
+ while ((*dst = *src)) {
+ dst++;
+ src++;
+ i++;
+ }
return i + 1; /* include '\0' */
}
#endif
@@ -1541,7 +1545,8 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast,
* immediately after use, so we need to duplicate them, ugh.
* annoying because it works most of the time without this. */
{
- EnumPropertyItem *items_dup = MEM_mallocN((sizeof(EnumPropertyItem) * (seq_len + 1)) + (sizeof(char) * totbuf),
+ EnumPropertyItem *items_dup = MEM_mallocN((sizeof(EnumPropertyItem) * (seq_len + 1)) +
+ (sizeof(char) * totbuf),
"enum_items_from_py2");
EnumPropertyItem *items_ptr = items_dup;
char *buf = ((char *)items_dup) + (sizeof(EnumPropertyItem) * (seq_len + 1));
@@ -2272,7 +2277,10 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
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);
RNA_def_property_array(prop, size);
if (pydef) {
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index cf45d6ca2d9..a87deeabc65 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -189,7 +189,8 @@ static void id_weakref_pool_add(ID *id, BPy_DummyPointerRNA *pyrna)
PyObject *weakref_capsule;
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 */
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:
if (len == 3) { /* euler */
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;
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);
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) {
const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
@@ -1448,11 +1451,14 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
#if 0 /* gives python decoding errors while generating docs :( */
char error_str[256];
- BLI_snprintf(error_str, sizeof(error_str),
+ BLI_snprintf(error_str,
+ sizeof(error_str),
"RNA Warning: Current value \"%d\" "
"matches no enum in '%s', '%s', '%s'",
- val, RNA_struct_identifier(ptr->type),
- ptr_name, RNA_property_identifier(prop));
+ val,
+ RNA_struct_identifier(ptr->type),
+ ptr_name,
+ RNA_property_identifier(prop));
PyErr_Warn(PyExc_RuntimeWarning, error_str);
#endif
@@ -1464,8 +1470,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
ret = PyUnicode_FromString("");
#if 0
- PyErr_Format(PyExc_AttributeError,
- "RNA Error: Current value \"%d\" matches no enum", val);
+ PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val);
ret = NULL;
#endif
}
@@ -1844,7 +1849,8 @@ static int pyrna_py_to_prop(
}
else {
/* 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) {
*((char **)data) = (char *)param;
}
@@ -1900,7 +1906,8 @@ static int pyrna_py_to_prop(
* if the prop is not an operator type and the pyobject is an operator,
* 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.
*/
if ((ptr_type == &RNA_AnyType) && (BPy_StructRNA_Check(value))) {
@@ -1995,8 +2002,9 @@ static int pyrna_py_to_prop(
}
}
else {
- /* 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 */
+ /* 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. */
BLI_assert(value_new == NULL);
if (value == Py_None) {
*((void **)data) = NULL;
@@ -2807,14 +2815,18 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
- if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
- if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) return NULL;
+ if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start))
+ return NULL;
+ if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop))
+ return NULL;
if (start < 0 || stop < 0) {
/* only get the length for negative values */
Py_ssize_t len = (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
- if (start < 0) start += len;
- if (stop < 0) stop += len;
+ if (start < 0)
+ start += len;
+ if (stop < 0)
+ stop += len;
}
if (stop - start <= 0) {
@@ -4181,8 +4193,8 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
ret = NULL;
}
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... */
if (STR_ELEM(name, "__getitem__", "__setitem__") &&
!RNA_struct_idprops_check(self->ptr.type)) {
@@ -4262,9 +4274,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
}
else {
#if 0
- PyErr_Format(PyExc_AttributeError,
- "bpy_struct: attribute \"%.200s\" not found",
- name);
+ PyErr_Format(PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" not found", name);
ret = NULL;
#endif
/* Include this in case this instance is a subtype of a python class
@@ -4308,9 +4318,11 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
* >>> bpy.types.Scene.foo = BoolProperty()
* >>> bpy.types.Scene.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 (ret == NULL) { // || pyrna_is_deferred_prop(ret)
StructRNA *srna = srna_from_self(cls, "StructRNA.__getattr__");
@@ -4420,7 +4432,8 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
}
}
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;
if (C == NULL) {
PyErr_Format(PyExc_AttributeError,
@@ -5101,7 +5114,8 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
}
*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) {
*attr_tot = 1;
}
@@ -5113,21 +5127,22 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
array_tot = RNA_property_array_length(&self->ptr, self->prop);
}
-
target_tot = array_tot * (*attr_tot);
/* rna_access.c - rna_raw_access(...) uses this same method */
if (target_tot != (*tot)) {
PyErr_Format(PyExc_TypeError,
"foreach_get(attr, sequence) sequence length mismatch given %d, needed %d",
- *tot, target_tot);
+ *tot,
+ target_tot);
return -1;
}
#endif
}
- /* 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. */
+ /* 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. */
if (*size == 0 && *attr_tot != 0) {
PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method");
return -1;
@@ -5482,11 +5497,14 @@ static struct PyMethodDef pyrna_struct_methods[] = {
/* experimental */
/* unused for now */
#if 0
- {"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS, NULL},
- {"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS, NULL},
+ {"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS, NULL},
+ {"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS, NULL},
- {"callback_add", (PyCFunction)pyrna_callback_classmethod_add, METH_VARARGS | METH_CLASS, NULL},
- {"callback_remove", (PyCFunction)pyrna_callback_classmethod_remove, METH_VARARGS | METH_CLASS, NULL},
+ {"callback_add", (PyCFunction)pyrna_callback_classmethod_add, METH_VARARGS | METH_CLASS, NULL},
+ {"callback_remove",
+ (PyCFunction)pyrna_callback_classmethod_remove,
+ METH_VARARGS | METH_CLASS,
+ NULL},
#endif
{NULL, NULL, 0, NULL},
};
@@ -5852,7 +5870,10 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
int lineno;
PyC_FileAndNum(&fn, &lineno);
printf("pyrna_func_call > %.200s.%.200s : %.200s:%d\n",
- RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), fn, lineno);
+ RNA_struct_identifier(self_ptr->type),
+ RNA_function_identifier(self_func),
+ fn,
+ lineno);
}
#endif
@@ -5987,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
* 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.
- * (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)) {
PyObject *key, *value;
@@ -6884,7 +6906,8 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *
if ((PyObject *)pyrna != Py_None) {
/* hold a reference to the iterator since it may have
* 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);
}
}
@@ -7015,8 +7038,10 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
/* sanity check, could skip this unless in debug mode */
if (newclass) {
PyObject *base_compare = pyrna_srna_PyBase(srna);
- //PyObject *slots = PyObject_GetAttrString(newclass, "__slots__"); // cant do this because it gets superclasses values!
- //PyObject *bases = PyObject_GetAttrString(newclass, "__bases__"); // can do this but faster not to.
+ /* Can't do this because it gets superclasses values! */
+ // 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_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict,
bpy_intern_str___slots__);
@@ -7062,12 +7087,15 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
pyrna_subtype_set_rna(newclass, srna);
Py_INCREF(newclass);
} /* create a new class instance with the C api
- * mainly for the purposing of matching the C/rna type hierarchy */
+ * mainly for the purposing of matching the C/rna type hierarchy */
else {
/* subclass equivalents
* - class myClass(myBase):
* 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 */
@@ -7090,8 +7118,8 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
/* always use O not N when calling, N causes refcount errors */
#if 0
- newclass = PyObject_CallFunction(metaclass, "s(O) {sss()}",
- idname, py_base, "__module__", "bpy.types", "__slots__");
+ newclass = PyObject_CallFunction(
+ metaclass, "s(O) {sss()}", idname, py_base, "__module__", "bpy.types", "__slots__");
#else
{
/* longhand of the call above */
@@ -7122,7 +7150,8 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
}
#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); */
@@ -7874,7 +7903,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
const int flag = RNA_function_flag(func);
/* 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.
- * 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);
if (!(flag & FUNC_REGISTER)) {
@@ -7899,8 +7929,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
PyErr_Clear();
}
else {
- Py_DECREF(
- item); /* no need to keep a ref, the class owns it (technically we should keep a ref but...) */
+ /* No need to keep a ref, the class owns it (technically we should keep a ref but...). */
+ Py_DECREF(item);
+
if (is_staticmethod) {
if (PyMethod_Check(item) == 0) {
PyErr_Format(PyExc_TypeError,
@@ -8188,7 +8219,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
else {
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' */
if (is_staticmethod) {
@@ -8521,8 +8555,10 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
#if 0
if (RNA_struct_py_type_get(srna)) {
PyErr_Format(PyExc_ValueError,
- "register_class(...): %.200s's parent class %.200s is already registered, this is not allowed",
- ((PyTypeObject *)py_class)->tp_name, RNA_struct_identifier(srna));
+ "register_class(...): %.200s's parent class %.200s is already registered, this "
+ "is not allowed",
+ ((PyTypeObject *)py_class)->tp_name,
+ RNA_struct_identifier(srna));
return NULL;
}
#endif
@@ -8749,7 +8785,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
PyDict_DelItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna);
if (PyErr_Occurred()) {
- PyErr_Clear(); //return NULL;
+ PyErr_Clear(); // return NULL;
}
Py_RETURN_NONE;
@@ -8815,16 +8851,17 @@ PyDoc_STRVAR(
" Note: All arguments are positional only for now.\n"
"\n"
" :param callback:\n"
- " A function that will be called when the region is drawn.\n"
- " It gets the specified arguments as input.\n"
+ " A function that will be called when the region is drawn.\n"
+ " It gets the specified arguments as input.\n"
" :type callback: function\n"
" :param args: Arguments that will be passed to the callback.\n"
" :type args: tuple\n"
- " :param region_type: The region type the callback draws in; usually `'WINDOW'`. "
+ " :param region_type: The region type the callback draws in; usually ``WINDOW``. "
"(:class:`bpy.types.Region.type`)\n"
" :type region_type: str\n"
- " :param draw_type: Usually `POST_PIXEL` for 2D drawing and `POST_VIEW` for 3D drawing. In "
- "some cases `PRE_VIEW` can be used.\n"
+ " :param draw_type: Usually ``POST_PIXEL`` for 2D drawing and ``POST_VIEW`` for 3D drawing. "
+ "In some cases ``PRE_VIEW`` can be used. ``BACKDROP`` can be used for backdrops in the node "
+ "editor.\n"
" :type draw_type: str\n"
" :return: Handler that can be removed later on.\n"
" :rtype: object");
diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h
index 588c3cbf171..cf6bd54d8a5 100644
--- a/source/blender/python/intern/bpy_rna.h
+++ b/source/blender/python/intern/bpy_rna.h
@@ -24,7 +24,10 @@
/* --- bpy build options --- */
#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
/* method to invalidate removed py data, XXX, slow to remove objects, otherwise no overhead */
@@ -146,8 +149,10 @@ typedef struct {
PropertyRNA *prop;
/* 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. */
- int arrayoffset; /* array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n */
+ /** Array dimension, e.g: 0 for face.uv, 2 for face.uv[n][m], etc. */
+ 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;
typedef struct {
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 2cd8c8641bb..79c31c8caad 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -55,6 +55,8 @@
#include "../generic/python_utildefines.h"
+#include "DEG_depsgraph_build.h"
+
/* for keyframes and drivers */
static int pyrna_struct_anim_args_parse_ex(PointerRNA *ptr,
const char *error_prefix,
@@ -586,7 +588,9 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
ret = pyrna_struct_CreatePyObject(&tptr);
}
+ bContext *context = BPy_GetContext();
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ DEG_relations_tag_update(CTX_data_main(context));
}
else {
/* XXX, should be handled by reports, */
@@ -644,7 +648,9 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
return NULL;
}
- WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ bContext *context = BPy_GetContext();
+ WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ DEG_relations_tag_update(CTX_data_main(context));
return PyBool_FromLong(result);
}
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index 7097999201a..9d8fff5dfe4 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -86,7 +86,8 @@ typedef struct ItemConvert_FuncArg {
*/
/* 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,
int dim,
int totdim,
@@ -203,7 +204,10 @@ static int validate_array_type(PyObject *seq,
else if (!check_item_type(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,
"%s expected sequence items of type %s, not %s",
error_prefix,
@@ -283,8 +287,12 @@ static int validate_array_length(PyObject *rvalue,
/* BLI_snprintf(error_str, error_str_size,
* "%s.%s: array length cannot be changed to %d",
* RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot); */
- PyErr_Format(PyExc_ValueError, "%s %s.%s: array length cannot be changed to %d",
- error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot);
+ PyErr_Format(PyExc_ValueError,
+ "%s %s.%s: array length cannot be changed to %d",
+ error_prefix,
+ RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop),
+ tot);
return -1;
}
#else
@@ -883,7 +891,10 @@ PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index)
#if 0
/* XXX this is not used (and never will?) */
/* Given an array property, creates an N-dimensional tuple of values. */
-static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop, int dim, int *index)
+static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr,
+ PropertyRNA *prop,
+ int dim,
+ int *index)
{
PyObject *tuple;
int i, len;
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index b24a28229aa..e44fda1e892 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -54,6 +54,7 @@ static const EnumPropertyItem region_draw_mode_items[] = {
{REGION_DRAW_POST_PIXEL, "POST_PIXEL", 0, "Post Pixel", ""},
{REGION_DRAW_POST_VIEW, "POST_VIEW", 0, "Post View", ""},
{REGION_DRAW_PRE_VIEW, "PRE_VIEW", 0, "Pre View", ""},
+ {REGION_DRAW_BACKDROP, "BACKDROP", 0, "Backdrop", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -135,7 +136,12 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
char *cb_event_str = NULL;
int cb_event;
- if (!PyArg_ParseTuple(args, "OO!|s:bpy_struct.callback_add", &cb_func, &PyTuple_Type, &cb_args, &cb_event_str)) {
+ if (!PyArg_ParseTuple(args,
+ "OO!|s:bpy_struct.callback_add",
+ &cb_func,
+ &PyTuple_Type,
+ &cb_args,
+ &cb_event_str)) {
return NULL;
}
@@ -147,9 +153,8 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) {
if (cb_event_str) {
if (pyrna_enum_value_from_id(
- region_draw_mode_items, cb_event_str,
- &cb_event, "bpy_struct.callback_add()") == -1)
- {
+ region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") ==
+ -1) {
return NULL;
}
}
@@ -157,7 +162,8 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
cb_event = REGION_DRAW_POST_PIXEL;
}
- handle = ED_region_draw_cb_activate(((ARegion *)self->ptr.data)->type, cb_region_draw, (void *)args, cb_event);
+ handle = ED_region_draw_cb_activate(
+ ((ARegion *)self->ptr.data)->type, cb_region_draw, (void *)args, cb_event);
Py_INCREF(args);
}
else {
@@ -181,7 +187,8 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
handle = PyCapsule_GetPointer(py_handle, rna_capsual_id);
if (handle == NULL) {
- PyErr_SetString(PyExc_ValueError, "callback_remove(handle): NULL handle given, invalid or already removed");
+ PyErr_SetString(PyExc_ValueError,
+ "callback_remove(handle): NULL handle given, invalid or already removed");
return NULL;
}
diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index bb7604aea97..dfd7624bd3d 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -34,7 +34,8 @@
#include "BKE_main.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_key_types.h"
@@ -54,20 +55,21 @@
#include "bpy_rna.h"
typedef struct IDUserMapData {
- /* place-holder key only used for lookups to avoid creating new data only for lookups
+ /** Place-holder key only used for lookups to avoid creating new data only for lookups
* (never return its contents) */
PyObject *py_id_key_lookup_only;
- /* we loop over data-blocks that this ID points to (do build a reverse lookup table) */
+ /** We loop over data-blocks that this ID points to (do build a reverse lookup table) */
PyObject *py_id_curr;
ID *id_curr;
- /* filter the values we add into the set */
+ /** Filter the values we add into the set. */
BLI_bitmap *types_bitmap;
- PyObject *user_map; /* set to fill in as we iterate */
- bool
- is_subset; /* true when we're only mapping a subset of all the ID's (subset arg is passed) */
+ /** Set to fill in as we iterate. */
+ PyObject *user_map;
+ /** true when we're only mapping a subset of all the ID's (subset arg is passed). */
+ bool is_subset;
} IDUserMapData;
static int id_code_as_index(const short idcode)
@@ -96,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)) {
- /* 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;
}
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;
}
@@ -225,10 +229,8 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
data_cb.types_bitmap = key_types_bitmap;
- FOREACH_MAIN_LISTBASE_BEGIN(bmain, lb)
- {
- FOREACH_MAIN_LISTBASE_ID_BEGIN(lb, id)
- {
+ FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb) {
+ FOREACH_MAIN_LISTBASE_ID_BEGIN (lb, id) {
/* We cannot skip here in case we have some filter on key types... */
if (key_types_bitmap == NULL && val_types_bitmap != NULL) {
if (!id_check_type(id, val_types_bitmap)) {
@@ -246,14 +248,16 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
if (!data_cb.is_subset &&
/* We do not want to pre-add keys of flitered out types. */
(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)) {
PyObject *key = data_cb.py_id_key_lookup_only;
PyObject *set;
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) {
/* Cannot use our placeholder key here! */
key = pyrna_id_CreatePyObject(id);
@@ -378,10 +382,12 @@ int BPY_rna_id_collection_module(PyObject *mod_par)
PyModule_AddObject(mod_par, "_rna_id_collection_user_map", PyCFunction_New(&user_map, NULL));
- static PyMethodDef batch_remove = {"batch_remove",
- (PyCFunction)bpy_batch_remove,
- METH_VARARGS | METH_KEYWORDS,
- bpy_batch_remove_doc};
+ static PyMethodDef batch_remove = {
+ "batch_remove",
+ (PyCFunction)bpy_batch_remove,
+ METH_VARARGS | METH_KEYWORDS,
+ bpy_batch_remove_doc,
+ };
PyModule_AddObject(
mod_par, "_rna_id_collection_batch_remove", PyCFunction_New(&batch_remove, NULL));
diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c
index b80ea50dd09..645b7e1c7af 100644
--- a/source/blender/python/intern/bpy_utils_units.c
+++ b/source/blender/python/intern/bpy_utils_units.c
@@ -66,8 +66,8 @@ static const char *bpyunits_ucategorie_items[] = {
/**
* 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
- * ``BKE_unit.h``.
+ * This allows us to avoid many handwriting, and above all,
+ * 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_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:
- * - 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).
- * This can be repeated twice (e.g. 1m20cm), and we add ten more spare chars (spaces, trailing '\0'...).
+ * - 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).
+ * 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.
*/
char buf1[64], buf2[64], *str;
diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c
index bf068f99722..56ee36086c4 100644
--- a/source/blender/python/intern/stubs.c
+++ b/source/blender/python/intern/stubs.c
@@ -31,9 +31,8 @@
#endif
/* python, will come back */
-//void BPY_script_exec(void) {}
-//void BPY_python_start(void) {}
-//void BPY_text_free_code(void) {}
+// void BPY_script_exec(void) {}
+// void BPY_python_start(void) {}
void BPY_pyconstraint_exec(struct bPythonConstraint *con,
struct bConstraintOb *cob,
struct ListBase *targets)
diff --git a/source/blender/python/mathutils/CMakeLists.txt b/source/blender/python/mathutils/CMakeLists.txt
index a58260a84f6..cdb562a3233 100644
--- a/source/blender/python/mathutils/CMakeLists.txt
+++ b/source/blender/python/mathutils/CMakeLists.txt
@@ -17,8 +17,8 @@
set(INC
.
- ../../blenlib
../../blenkernel
+ ../../blenlib
../../bmesh
../../depsgraph
../../makesdna
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 32ffa4ad2da..d0fa9f5c565 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -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 */
/* 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]).
- * 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...
+ * LomontRRDCompare4() is an optimized version of Dawson's AlmostEqual2sComplement()
+ * (see [1] and [2]).
+ * 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
- * [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
+ * [1] http://www.randydillon.org/Papers/2007/everfast.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.
*/
#define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31))
@@ -437,7 +440,8 @@ PyObject *mathutils_dynstr_to_py(struct DynStr *ds)
/* 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
static Mathutils_Callback *mathutils_callbacks[MATHUTILS_TOT_CB] = {NULL};
diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h
index 4ec2c869499..8afd60a7324 100644
--- a/source/blender/python/mathutils/mathutils.h
+++ b/source/blender/python/mathutils/mathutils.h
@@ -32,8 +32,8 @@ extern char BaseMathObject_is_frozen_doc[];
extern char BaseMathObject_owner_doc[];
#define BASE_MATH_NEW(struct_name, root_type, base_type) \
- (struct_name *)((base_type ? (base_type)->tp_alloc(base_type, 0) : \
- _PyObject_GC_New(&(root_type))));
+ ((struct_name *)((base_type ? (base_type)->tp_alloc(base_type, 0) : \
+ _PyObject_GC_New(&(root_type)))))
/** BaseMathObject.flag */
enum {
@@ -52,16 +52,17 @@ enum {
#define BASE_MATH_FLAG_DEFAULT 0
#define BASE_MATH_MEMBERS(_data) \
- PyObject_VAR_HEAD float \
- *_data; /* array of data (alias), wrapped status depends on wrapped status */ \
- PyObject * \
- cb_user; /* if this vector references another object, otherwise NULL, \
- * *Note* this owns its reference */ \
- unsigned char cb_type; /* which user funcs do we adhere to, RNA, etc */ \
- unsigned char \
- cb_subtype; /* subtype: location, rotation... \
- * to avoid defining many new functions for every attribute of the same type */ \
- unsigned char flag /* wrapped data type? */
+ /** Array of data (alias), wrapped status depends on wrapped status. */ \
+ PyObject_VAR_HEAD float *_data; \
+ /** If this vector references another object, otherwise NULL, *Note* this owns its reference */ \
+ PyObject *cb_user; \
+ /** Which user funcs do we adhere to, RNA, etc */ \
+ unsigned char cb_type; \
+ /** Subtype: location, rotation... \
+ * to avoid defining many new functions for every attribute of the same type */ \
+ unsigned char cb_subtype; \
+ /** Wrapped data type. */ \
+ unsigned char flag
typedef struct {
BASE_MATH_MEMBERS(data);
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 6ccb3c2a291..7cc9ba50d90 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -1072,7 +1072,8 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat)
if (det == 0.0f) {
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;
switch (self->num_col) {
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index 86da4511a2e..8841519de8a 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -236,7 +236,7 @@ PyDoc_STRVAR(Quaternion_dot_doc,
" :arg other: The other quaternion to perform the dot product with.\n"
" :type other: :class:`Quaternion`\n"
" :return: The dot product.\n"
- " :rtype: :class:`Quaternion`\n");
+ " :rtype: float\n");
static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value)
{
float tquat[QUAT_SIZE];
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 7d73f165c1e..29861c56dc0 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -2377,12 +2377,15 @@ static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(clos
* '((%s | SWIZZLE_VALID_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 * 3))) ' %
+ * '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3))) '
+ * %
* (axis_0_pos, axis_1_pos, axis_2_pos, axis_3_pos))
*
* axises = axises[:-1]
* 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()
* for key, val in items:
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 5fe3536d899..c39954713b1 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -1043,7 +1043,13 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
if (len_squared_v3(n3n1) > eps) {
const float quotient = dot_v3v3(N1, n2n3);
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;
potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) +
(n1n2[0] * N3[3])) *
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt
index da82e606bda..e265197646c 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -25,14 +25,14 @@ set(INC
../blenkernel
../blenlib
../blentranslation
- ../imbuf
../depsgraph
+ ../draw
+ ../gpu
+ ../imbuf
../makesdna
../makesrna
../nodes
../physics
- ../draw
- ../gpu
../../../intern/atomic
../../../intern/guardedalloc
../../../intern/mikktspace
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h
index 0e7399d4a0d..46d2df0acb5 100644
--- a/source/blender/render/extern/include/RE_pipeline.h
+++ b/source/blender/render/extern/include/RE_pipeline.h
@@ -91,24 +91,28 @@ typedef struct RenderPass {
/* a renderlayer is a full image, but with all passes and samples */
/* size of the rects is defined in RenderResult */
-/* after render, the Combined pass is in combined, for renderlayers read from files it is a real pass */
+/* after render, the Combined pass is in combined,
+ * for renderlayers read from files it is a real pass */
typedef struct RenderLayer {
struct RenderLayer *next, *prev;
- /* copy of RenderData */
+ /** copy of RenderData */
char name[RE_MAXNAME];
int layflag, passflag, pass_xor;
/* MULTIVIEW_TODO: acolrect and scolrect are not supported by multiview at the moment.
* If they are really required they should be in RenderView instead */
- float *acolrect; /* 4 float, optional transparent buffer, needs storage for display updates */
- float *scolrect; /* 4 float, optional strand buffer, needs storage for display updates */
- int *display_buffer; /* 4 char, optional color managed display buffer which is used when
- * Save Buffer is enabled to display combined pass of the screen. */
+ /** 4 float, optional transparent buffer, needs storage for display updates */
+ float *acolrect;
+ /** 4 float, optional strand buffer, needs storage for display updates */
+ float *scolrect;
+ /** 4 char, optional color managed display buffer which is used when
+ * Save Buffer is enabled to display combined pass of the screen. */
+ int *display_buffer;
int rectx, recty;
- /* optional saved endresult on disk */
+ /** Optional saved endresult on disk. */
void *exrhandle;
ListBase passes;
@@ -122,8 +126,8 @@ typedef struct RenderResult {
int rectx, recty;
short crop, sample_nr;
- /* the following rect32, rectf and rectz buffers are for temporary storage only, for RenderResult structs
- * created in #RE_AcquireResultImage - which do not have RenderView */
+ /* The following rect32, rectf and rectz buffers are for temporary storage only,
+ * for RenderResult structs created in #RE_AcquireResultImage - which do not have RenderView */
/* optional, 32 bits version of picture, used for ogl render and image curves */
int *rect32;
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 69e2ea991dd..63fd3f1d0bd 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -82,9 +82,10 @@ struct Render {
* to not conflict with writes, so no lock used for that */
ThreadRWMutex resultmutex;
- /* window size, display rect, viewplane */
- int winx, winy; /* buffer width and height with percentage applied
- * without border & crop. convert to long before multiplying together to avoid overflow. */
+ /** Window size, display rect, viewplane.
+ * \note Buffer width and height with percentage applied
+ * without border & crop. convert to long before multiplying together to avoid overflow. */
+ int winx, winy;
rcti disprect; /* part within winx winy */
rctf viewplane; /* mapped on winx winy */
diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h
index d783263c8b8..0dd517ed177 100644
--- a/source/blender/render/intern/include/texture.h
+++ b/source/blender/render/intern/include/texture.h
@@ -31,7 +31,8 @@
texres->tin = 0.0f; \
else if (texres->tin > 1.0f) \
texres->tin = 1.0f; \
- }
+ } \
+ ((void)0)
#define BRICONTRGB \
texres->tr = tex->rfac * ((texres->tr - 0.5f) * tex->contrast + tex->bright - 0.5f); \
@@ -58,7 +59,8 @@
if (texres->tb < 0.0f) \
texres->tb = 0.0f; \
} \
- }
+ } \
+ ((void)0)
struct ImBuf;
struct Image;
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c
index bc0c73fd11f..d7080906d5c 100644
--- a/source/blender/render/intern/source/bake_api.c
+++ b/source/blender/render/intern/source/bake_api.c
@@ -17,19 +17,22 @@
/** \file
* \ingroup render
*
- * \brief The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an
- * array of floats with the result.
+ * \brief The API itself is simple.
+ * Blender sends a populated array of BakePixels to the renderer,
+ * and gets back an array of floats with the result.
*
* \section bake_api Development Notes for External Engines
*
- * The Bake API is fully implemented with Python rna functions. The operator expects/call a function:
+ * The Bake API is fully implemented with Python rna functions.
+ * The operator expects/call a function:
*
* ``def bake(scene, object, pass_type, object_id, pixel_array, num_pixels, depth, result)``
* - scene: current scene (Python object)
* - object: object to render (Python object)
* - pass_type: pass to render (string, e.g., "COMBINED", "AO", "NORMAL", ...)
* - object_id: index of object to bake (to use with the pixel_array)
- * - pixel_array: list of primitive ids and barycentric coordinates to bake(Python object, see bake_pixel)
+ * - pixel_array: list of primitive ids and barycentric coordinates to
+ * `bake(Python object, see bake_pixel)`.
* - num_pixels: size of pixel_array, number of pixels to bake (int)
* - depth: depth of pixels to return (int, assuming always 4 now)
* - result: array to be populated by the engine (float array, PyLong_AsVoidPtr)
@@ -136,8 +139,9 @@ static void store_bake_pixel(void *handle, int x, int y, float u, float v)
void RE_bake_mask_fill(const BakePixel pixel_array[], const size_t num_pixels, char *mask)
{
size_t i;
- if (!mask)
+ if (!mask) {
return;
+ }
/* only extend to pixels outside the mask area */
for (i = 0; i < num_pixels; i++) {
@@ -152,14 +156,17 @@ void RE_bake_margin(ImBuf *ibuf, char *mask, const int margin)
/* margin */
IMB_filter_extend(ibuf, mask, margin);
- if (ibuf->planes != R_IMF_PLANES_RGBA)
+ if (ibuf->planes != R_IMF_PLANES_RGBA) {
/* clear alpha added by filtering */
IMB_rectfill_alpha(ibuf, 1.0f);
+ }
}
/**
- * This function returns the coordinate and normal of a barycentric u,v for a face defined by the primitive_id index.
- * The returned normal is actually the direction from the same barycentric coordinate in the cage to the base mesh
+ * This function returns the coordinate and normal of a barycentric u,v
+ * for a face defined by the primitive_id index.
+ * The returned normal is actually the direction from the same barycentric coordinate
+ * in the cage to the base mesh
* The returned coordinate is the point in the cage mesh
*/
static void calc_point_from_barycentric_cage(TriTessFace *triangles_low,
@@ -201,7 +208,8 @@ static void calc_point_from_barycentric_cage(TriTessFace *triangles_low,
}
/**
- * This function returns the coordinate and normal of a barycentric u,v for a face defined by the primitive_id index.
+ * This function returns the coordinate and normal of a barycentric u,v
+ * for a face defined by the primitive_id index.
* The returned coordinate is extruded along the normal by cage_extrusion
*/
static void calc_point_from_barycentric_extrusion(TriTessFace *triangles,
@@ -684,8 +692,9 @@ void RE_bake_pixels_populate(Mesh *me,
mloopuv = CustomData_get_layer_n(&me->ldata, CD_MTFACE, uv_id);
}
- if (mloopuv == NULL)
+ if (mloopuv == NULL) {
return;
+ }
bd.pixel_array = pixel_array;
bd.zspan = MEM_callocN(sizeof(ZSpan) * bake_images->size, "bake zspan");
@@ -722,8 +731,8 @@ void RE_bake_pixels_populate(Mesh *me,
for (a = 0; a < 3; a++) {
const float *uv = mloopuv[lt->tri[a]].uv;
- /* Note, workaround for pixel aligned UVs which are common and can screw up our intersection tests
- * where a pixel gets in between 2 faces or the middle of a quad,
+ /* Note, workaround for pixel aligned UVs which are common and can screw up our
+ * intersection tests where a pixel gets in between 2 faces or the middle of a quad,
* camera aligned quads also have this problem but they are less common.
* Add a small offset to the UVs, fixes bug #18685 - Campbell */
vec[a][0] = uv[0] * (float)bd.bk_image->width - (0.5f + 0.001f);
@@ -751,8 +760,9 @@ void RE_bake_pixels_populate(Mesh *me,
static void normal_uncompress(float out[3], const float in[3])
{
int i;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++) {
out[i] = 2.0f * in[i] - 1.0f;
+ }
}
static void normal_compress(float out[3],
@@ -796,7 +806,8 @@ static void normal_compress(float out[3],
}
/**
- * This function converts an object space normal map to a tangent space normal map for a given low poly mesh
+ * This function converts an object space normal map
+ * to a tangent space normal map for a given low poly mesh.
*/
void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
const size_t num_pixels,
@@ -842,10 +853,12 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
offset = i * depth;
if (primitive_id == -1) {
- if (depth == 4)
+ if (depth == 4) {
copy_v4_fl4(&result[offset], 0.5f, 0.5f, 1.0f, 1.0f);
- else
+ }
+ else {
copy_v3_fl3(&result[offset], 0.5f, 0.5f, 1.0f);
+ }
continue;
}
@@ -855,10 +868,12 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
for (j = 0; j < 3; j++) {
const TSpace *ts;
- if (is_smooth)
+ if (is_smooth) {
normal_short_to_float_v3(normals[j], triangle->mverts[j]->no);
- else
+ }
+ else {
normal[j] = triangle->normal[j];
+ }
ts = triangle->tspace[j];
copy_v3_v3(tangents[j], ts->tangent);
@@ -870,8 +885,9 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
w = 1.0f - u - v;
/* normal */
- if (is_smooth)
+ if (is_smooth) {
interp_barycentric_tri_v3(normals, u, v, normal);
+ }
/* tangent */
interp_barycentric_tri_v3(tangents, u, v, tangent);
@@ -929,8 +945,9 @@ void RE_bake_normal_world_to_object(const BakePixel pixel_array[],
size_t offset;
float nor[3];
- if (pixel_array[i].primitive_id == -1)
+ if (pixel_array[i].primitive_id == -1) {
continue;
+ }
offset = i * depth;
normal_uncompress(nor, &result[offset]);
@@ -956,8 +973,9 @@ void RE_bake_normal_world_to_world(const BakePixel pixel_array[],
size_t offset;
float nor[3];
- if (pixel_array[i].primitive_id == -1)
+ if (pixel_array[i].primitive_id == -1) {
continue;
+ }
offset = i * depth;
normal_uncompress(nor, &result[offset]);
@@ -980,10 +998,12 @@ void RE_bake_ibuf_clear(Image *image, const bool is_tangent)
ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
BLI_assert(ibuf);
- if (is_tangent)
+ if (is_tangent) {
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
- else
+ }
+ else {
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
+ }
BKE_image_release_ibuf(image, ibuf, lock);
}
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c
index c4eef235b5d..9a955b5e8f5 100644
--- a/source/blender/render/intern/source/external_engine.c
+++ b/source/blender/render/intern/source/external_engine.c
@@ -85,8 +85,9 @@ void RE_engines_exit(void)
BLI_remlink(&R_engines, type);
if (!(type->flag & RE_INTERNAL)) {
- if (type->ext.free)
+ if (type->ext.free) {
type->ext.free(type->ext.data);
+ }
MEM_freeN(type);
}
@@ -106,8 +107,9 @@ RenderEngineType *RE_engines_find(const char *idname)
RenderEngineType *type;
type = BLI_findstring(&R_engines, idname, offsetof(RenderEngineType, idname));
- if (!type)
+ if (!type) {
type = BLI_findstring(&R_engines, "BLENDER_EEVEE", offsetof(RenderEngineType, idname));
+ }
return type;
}
@@ -194,10 +196,12 @@ RenderResult *RE_engine_begin_result(
CLAMP(w, 0, re->result->rectx);
CLAMP(h, 0, re->result->recty);
- if (x + w > re->result->rectx)
+ if (x + w > re->result->rectx) {
w = re->result->rectx - x;
- if (y + h > re->result->recty)
+ }
+ if (y + h > re->result->recty) {
h = re->result->recty - y;
+ }
/* allocate a render result */
disprect.xmin = x;
@@ -229,8 +233,9 @@ RenderResult *RE_engine_begin_result(
pa = get_part_from_result(re, result);
- if (pa)
+ if (pa) {
pa->status = PART_STATUS_IN_PROGRESS;
+ }
}
return result;
@@ -291,8 +296,9 @@ void RE_engine_end_result(
render_result_exr_file_merge(re->result, result, re->viewname);
}
}
- else if (!(re->test_break(re->tbh) && (re->r.scemode & R_BUTS_PREVIEW)))
+ else if (!(re->test_break(re->tbh) && (re->r.scemode & R_BUTS_PREVIEW))) {
render_result_merge(re->result, result);
+ }
/* draw */
if (!re->test_break(re->tbh)) {
@@ -317,8 +323,9 @@ bool RE_engine_test_break(RenderEngine *engine)
{
Render *re = engine->re;
- if (re)
+ if (re) {
return re->test_break(re->tbh);
+ }
return 0;
}
@@ -341,12 +348,15 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char
/* set engine text */
engine->text[0] = '\0';
- if (stats && stats[0] && info && info[0])
+ if (stats && stats[0] && info && info[0]) {
BLI_snprintf(engine->text, sizeof(engine->text), "%s | %s", stats, info);
- else if (info && info[0])
+ }
+ else if (info && info[0]) {
BLI_strncpy(engine->text, info, sizeof(engine->text));
- else if (stats && stats[0])
+ }
+ else if (stats && stats[0]) {
BLI_strncpy(engine->text, stats, sizeof(engine->text));
+ }
}
void RE_engine_update_progress(RenderEngine *engine, float progress)
@@ -373,10 +383,12 @@ void RE_engine_report(RenderEngine *engine, int type, const char *msg)
{
Render *re = engine->re;
- if (re)
+ if (re) {
BKE_report(engine->re->reports, type, msg);
- else if (engine->reports)
+ }
+ else if (engine->reports) {
BKE_report(engine->reports, type, msg);
+ }
}
void RE_engine_set_error_message(RenderEngine *engine, const char *msg)
@@ -410,9 +422,11 @@ float RE_engine_get_camera_shift_x(RenderEngine *engine, Object *camera, bool us
{
Render *re = engine->re;
- /* when using spherical stereo, get camera shift without multiview, leaving stereo to be handled by the engine */
- if (use_spherical_stereo)
+ /* When using spherical stereo, get camera shift without multiview,
+ * leaving stereo to be handled by the engine. */
+ if (use_spherical_stereo) {
re = NULL;
+ }
return BKE_camera_multiview_shift_x(re ? &re->r : NULL, camera, re->viewname);
}
@@ -424,9 +438,11 @@ void RE_engine_get_camera_model_matrix(RenderEngine *engine,
{
Render *re = engine->re;
- /* when using spherical stereo, get model matrix without multiview, leaving stereo to be handled by the engine */
- if (use_spherical_stereo)
+ /* When using spherical stereo, get model matrix without multiview,
+ * leaving stereo to be handled by the engine. */
+ if (use_spherical_stereo) {
re = NULL;
+ }
BKE_camera_multiview_model_matrix(
re ? &re->r : NULL, camera, re->viewname, (float(*)[4])r_modelmat);
@@ -591,8 +607,9 @@ bool RE_bake_engine(Render *re,
engine->depsgraph = depsgraph;
/* update is only called so we create the engine.session */
- if (type->update)
+ if (type->update) {
type->update(engine, re->main, engine->depsgraph);
+ }
type->bake(engine,
engine->depsgraph,
@@ -623,8 +640,9 @@ bool RE_bake_engine(Render *re,
RE_parts_free(re);
BLI_rw_mutex_unlock(&re->partsmutex);
- if (BKE_reports_contain(re->reports, RPT_ERROR))
+ if (BKE_reports_contain(re->reports, RPT_ERROR)) {
G.is_break = true;
+ }
return true;
}
@@ -638,14 +656,18 @@ int RE_engine_render(Render *re, int do_all)
bool persistent_data = (re->r.mode & R_PERSISTENT_DATA) != 0;
/* verify if we can render */
- if (!type->render)
+ if (!type->render) {
return 0;
- if ((re->r.scemode & R_BUTS_PREVIEW) && !(type->flag & RE_USE_PREVIEW))
+ }
+ if ((re->r.scemode & R_BUTS_PREVIEW) && !(type->flag & RE_USE_PREVIEW)) {
return 0;
- if (do_all && !(type->flag & RE_USE_POSTPROCESS))
+ }
+ if (do_all && !(type->flag & RE_USE_POSTPROCESS)) {
return 0;
- if (!do_all && (type->flag & RE_USE_POSTPROCESS))
+ }
+ if (!do_all && (type->flag & RE_USE_POSTPROCESS)) {
return 0;
+ }
/* Lock drawing in UI during data phase. */
if (re->draw_lock) {
@@ -663,11 +685,13 @@ int RE_engine_render(Render *re, int do_all)
if (re->result == NULL || !(re->r.scemode & R_BUTS_PREVIEW)) {
int savebuffers = RR_USE_MEM;
- if (re->result)
+ if (re->result) {
render_result_free(re->result);
+ }
- if ((type->flag & RE_USE_SAVE_BUFFERS) && (re->r.scemode & R_EXR_TILE_FILE))
+ if ((type->flag & RE_USE_SAVE_BUFFERS) && (re->r.scemode & R_EXR_TILE_FILE)) {
savebuffers = RR_USE_EXR;
+ }
re->result = render_result_new(re, &re->disprect, 0, savebuffers, RR_ALL_LAYERS, RR_ALL_VIEWS);
}
BLI_rw_mutex_unlock(&re->resultmutex);
@@ -703,10 +727,12 @@ int RE_engine_render(Render *re, int do_all)
/* TODO: actually link to a parent which shouldn't happen */
engine->re = re;
- if (re->flag & R_ANIMATION)
+ if (re->flag & R_ANIMATION) {
engine->flag |= RE_ENGINE_ANIMATION;
- if (re->r.scemode & R_BUTS_PREVIEW)
+ }
+ if (re->r.scemode & R_BUTS_PREVIEW) {
engine->flag |= RE_ENGINE_PREVIEW;
+ }
engine->camera_override = re->camera_override;
engine->resolution_x = re->winx;
@@ -716,8 +742,9 @@ int RE_engine_render(Render *re, int do_all)
engine->tile_x = re->partx;
engine->tile_y = re->party;
- if (re->result->do_exr_tile)
+ if (re->result->do_exr_tile) {
render_result_exr_file_begin(re, engine);
+ }
/* Clear UI drawing locks. */
if (re->draw_lock) {
@@ -790,12 +817,14 @@ int RE_engine_render(Render *re, int do_all)
RE_parts_free(re);
BLI_rw_mutex_unlock(&re->partsmutex);
- if (BKE_reports_contain(re->reports, RPT_ERROR))
+ if (BKE_reports_contain(re->reports, RPT_ERROR)) {
G.is_break = true;
+ }
#ifdef WITH_FREESTYLE
- if (re->r.mode & R_EDGE_FRS)
+ if (re->r.mode & R_EDGE_FRS) {
RE_RenderFreestyleExternal(re);
+ }
#endif
return 1;
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c
index a9b06edf558..c147794dae7 100644
--- a/source/blender/render/intern/source/imagetexture.c
+++ b/source/blender/render/intern/source/imagetexture.c
@@ -116,21 +116,24 @@ int imagewrap(Tex *tex,
retval = texres->nor ? 3 : 1;
/* quick tests */
- if (ibuf == NULL && ima == NULL)
+ if (ibuf == NULL && ima == NULL) {
return retval;
+ }
if (ima) {
/* hack for icon render */
- if (skip_load_image && !BKE_image_has_loaded_ibuf(ima))
+ if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
return retval;
+ }
ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool);
ima->flag |= IMA_USED_FOR_RENDER;
}
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
@@ -157,15 +160,17 @@ int imagewrap(Tex *tex,
/* pass */
}
else {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
if ((tex->flag & TEX_CHECKER_EVEN) == 0) {
if ((xs + ys) & 1) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
@@ -181,40 +186,48 @@ int imagewrap(Tex *tex,
if (tex->extend == TEX_CLIPCUBE) {
if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y || texvec[2] < -1.0f || texvec[2] > 1.0f) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
else {
if (tex->extend == TEX_EXTEND) {
- if (x >= ibuf->x)
+ if (x >= ibuf->x) {
x = ibuf->x - 1;
- else if (x < 0)
+ }
+ else if (x < 0) {
x = 0;
+ }
}
else {
x = x % ibuf->x;
- if (x < 0)
+ if (x < 0) {
x += ibuf->x;
+ }
}
if (tex->extend == TEX_EXTEND) {
- if (y >= ibuf->y)
+ if (y >= ibuf->y) {
y = ibuf->y - 1;
- else if (y < 0)
+ }
+ else if (y < 0) {
y = 0;
+ }
}
else {
y = y % ibuf->y;
- if (y < 0)
+ if (y < 0) {
y += ibuf->y;
+ }
}
}
@@ -316,8 +329,9 @@ int imagewrap(Tex *tex,
texres->tb *= fx;
}
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
BRICONTRGB;
@@ -338,8 +352,9 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
rf->xmax += (x2 - x1);
}
else {
- if (rf->xmax > x2)
+ if (rf->xmax > x2) {
rf->xmax = x2;
+ }
newrct = stack + *count;
(*count)++;
@@ -348,8 +363,9 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
newrct->ymin = rf->ymin;
newrct->ymax = rf->ymax;
- if (newrct->xmin == newrct->xmax)
+ if (newrct->xmin == newrct->xmax) {
(*count)--;
+ }
rf->xmin = x1;
}
@@ -360,8 +376,9 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
rf->xmax -= (x2 - x1);
}
else {
- if (rf->xmin < x1)
+ if (rf->xmin < x1) {
rf->xmin = x1;
+ }
newrct = stack + *count;
(*count)++;
@@ -370,8 +387,9 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
newrct->ymin = rf->ymin;
newrct->ymax = rf->ymax;
- if (newrct->xmin == newrct->xmax)
+ if (newrct->xmin == newrct->xmax) {
(*count)--;
+ }
rf->xmax = x2;
}
@@ -394,8 +412,9 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
rf->ymax += (y2 - y1);
}
else {
- if (rf->ymax > y2)
+ if (rf->ymax > y2) {
rf->ymax = y2;
+ }
newrct = stack + *count;
(*count)++;
@@ -404,8 +423,9 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
newrct->xmin = rf->xmin;
newrct->xmax = rf->xmax;
- if (newrct->ymin == newrct->ymax)
+ if (newrct->ymin == newrct->ymax) {
(*count)--;
+ }
rf->ymin = y1;
}
@@ -416,8 +436,9 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
rf->ymax -= (y2 - y1);
}
else {
- if (rf->ymin < y1)
+ if (rf->ymin < y1) {
rf->ymin = y1;
+ }
newrct = stack + *count;
(*count)++;
@@ -426,8 +447,9 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
newrct->xmin = rf->xmin;
newrct->xmax = rf->xmax;
- if (newrct->ymin == newrct->ymax)
+ if (newrct->ymin == newrct->ymax) {
(*count)--;
+ }
rf->ymax = y2;
}
@@ -503,14 +525,18 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
starty = (int)floor(rf->ymin);
endy = (int)floor(rf->ymax);
- if (startx < 0)
+ if (startx < 0) {
startx = 0;
- if (starty < 0)
+ }
+ if (starty < 0) {
starty = 0;
- if (endx >= ibuf->x)
+ }
+ if (endx >= ibuf->x) {
endx = ibuf->x - 1;
- if (endy >= ibuf->y)
+ }
+ if (endy >= ibuf->y) {
endy = ibuf->y - 1;
+ }
if (starty == endy && startx == endx) {
ibuf_get_color(&texres->tr, ibuf, startx, starty);
@@ -525,10 +551,12 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
/* pass */
}
else {
- if (y == starty)
+ if (y == starty) {
muly = 1.0f - (rf->ymin - y);
- if (y == endy)
+ }
+ if (y == endy) {
muly = (rf->ymax - y);
+ }
}
if (startx == endx) {
@@ -545,10 +573,12 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
else {
for (x = startx; x <= endx; x++) {
mulx = muly;
- if (x == startx)
+ if (x == startx) {
mulx *= 1.0f - (rf->xmin - x);
- if (x == endx)
+ }
+ if (x == endx) {
mulx *= (rf->xmax - x);
+ }
ibuf_get_color(col, ibuf, x, y);
@@ -597,7 +627,8 @@ static void boxsample(ImBuf *ibuf,
* If variable 'imaprepeat' has been set, the
* clipped-away parts are sampled as well.
*/
- /* note: actually minx etc isn't in the proper range... this due to filter size and offset vectors for bump */
+ /* note: actually minx etc isn't in the proper range...
+ * this due to filter size and offset vectors for bump */
/* note: talpha must be initialized */
/* note: even when 'imaprepeat' is set, this can only repeat once in any direction.
* the point which min/max is derived from is assumed to be wrapped */
@@ -618,8 +649,9 @@ static void boxsample(ImBuf *ibuf,
CLAMP(rf->xmin, 0.0f, ibuf->x - 1);
CLAMP(rf->xmax, 0.0f, ibuf->x - 1);
}
- else if (imaprepeat)
+ else if (imaprepeat) {
clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x));
+ }
else {
alphaclip = clipx_rctf(rf, 0.0, (float)(ibuf->x));
@@ -633,8 +665,9 @@ static void boxsample(ImBuf *ibuf,
CLAMP(rf->ymin, 0.0f, ibuf->y - 1);
CLAMP(rf->ymax, 0.0f, ibuf->y - 1);
}
- else if (imaprepeat)
+ else if (imaprepeat) {
clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y));
+ }
else {
alphaclip *= clipy_rctf(rf, 0.0, (float)(ibuf->y));
@@ -655,23 +688,27 @@ static void boxsample(ImBuf *ibuf,
texres->tr += opp * texr.tr;
texres->tg += opp * texr.tg;
texres->tb += opp * texr.tb;
- if (texres->talpha)
+ if (texres->talpha) {
texres->ta += opp * texr.ta;
+ }
rf++;
}
if (tot != 0.0f) {
texres->tr /= tot;
texres->tg /= tot;
texres->tb /= tot;
- if (texres->talpha)
+ if (texres->talpha) {
texres->ta /= tot;
+ }
}
}
- else
+ else {
boxsampleclip(ibuf, rf, texres);
+ }
- if (texres->talpha == 0)
+ if (texres->talpha == 0) {
texres->ta = 1.0;
+ }
if (alphaclip != 1.0f) {
/* premul it all */
@@ -682,8 +719,8 @@ static void boxsample(ImBuf *ibuf,
}
}
-/*-----------------------------------------------------------------------------------------------------------------
- * from here, some functions only used for the new filtering */
+/* -------------------------------------------------------------------- */
+/* from here, some functions only used for the new filtering */
/* anisotropic filters, data struct used instead of long line of (possibly unused) func args */
typedef struct afdata_t {
@@ -746,8 +783,9 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
if (ibuf->rect_float) {
const float *fp = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
- if (ibuf->channels == 1)
+ if (ibuf->channels == 1) {
col[0] = col[1] = col[2] = col[3] = *fp;
+ }
else {
col[0] = fp[0];
col[1] = fp[1];
@@ -877,9 +915,12 @@ static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata
float tc[4];
const float hn = n * 0.5f;
const float u = fx + hn * du, v = fy + hn * dv;
- /*const float wt = expf(n*n*D);
- * can use ewa table here too */
+ /* Can use ewa table here too. */
+#if 0
+ const float wt = expf(n * n * D);
+#else
const float wt = EWA_WTS[(int)(n * n * D)];
+#endif
/*const int out =*/ibuf_get_color_clip_bilerp(
tc, ibuf, ibuf->x * u, ibuf->y * v, AFD->intpol, AFD->extflag);
/* TXF alpha: clip |= out;
@@ -942,8 +983,9 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
}
if (ibuf->mipmap[0] == NULL) {
BLI_thread_lock(LOCK_IMAGE);
- if (ibuf->mipmap[0] == NULL)
+ if (ibuf->mipmap[0] == NULL) {
IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
+ }
BLI_thread_unlock(LOCK_IMAGE);
}
/* if no mipmap could be made, fall back on non-mipmap render */
@@ -988,8 +1030,9 @@ static int imagewraposa_aniso(Tex *tex,
retval = texres->nor ? 3 : 1;
/* quick tests */
- if (ibuf == NULL && ima == NULL)
+ if (ibuf == NULL && ima == NULL) {
return retval;
+ }
if (ima) { /* hack for icon render */
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
@@ -999,8 +1042,9 @@ static int imagewraposa_aniso(Tex *tex,
}
if ((ibuf == NULL) || ((ibuf->rect == NULL) && (ibuf->rect_float == NULL))) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
@@ -1040,12 +1084,15 @@ static int imagewraposa_aniso(Tex *tex,
miny = (maxy - miny) * 0.5f;
if (tex->imaflag & TEX_FILTER_MIN) {
- /* make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) */
+ /* Make sure the filtersize is minimal in pixels
+ * (normal, ref map can have miniature pixel dx/dy). */
const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y);
- if (addval > minx)
+ if (addval > minx) {
minx = addval;
- if (addval > miny)
+ }
+ if (addval > miny) {
miny = addval;
+ }
}
else if (tex->filtersize != 1.f) {
minx *= tex->filtersize;
@@ -1060,8 +1107,9 @@ static int imagewraposa_aniso(Tex *tex,
float t;
SWAP(float, minx, miny);
/* must rotate dxt/dyt 90 deg
- * yet another blender problem is that swapping X/Y axes (or any tex proj switches) should do something similar,
- * but it doesn't, it only swaps coords, so filter area will be incorrect in those cases. */
+ * yet another blender problem is that swapping X/Y axes (or any tex proj switches)
+ * should do something similar, but it doesn't, it only swaps coords,
+ * so filter area will be incorrect in those cases. */
t = dxt[0];
dxt[0] = dxt[1];
dxt[1] = -t;
@@ -1077,17 +1125,22 @@ static int imagewraposa_aniso(Tex *tex,
/* repeat and clip */
if (tex->extend == TEX_REPEAT) {
- if ((tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) == (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR))
+ if ((tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) == (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) {
extflag = TXC_EXTD;
- else if (tex->flag & TEX_REPEAT_XMIR)
+ }
+ else if (tex->flag & TEX_REPEAT_XMIR) {
extflag = TXC_XMIR;
- else if (tex->flag & TEX_REPEAT_YMIR)
+ }
+ else if (tex->flag & TEX_REPEAT_YMIR) {
extflag = TXC_YMIR;
- else
+ }
+ else {
extflag = TXC_REPT;
+ }
}
- else if (tex->extend == TEX_EXTEND)
+ else if (tex->extend == TEX_EXTEND) {
extflag = TXC_EXTD;
+ }
if (tex->extend == TEX_CHECKER) {
int xs = (int)floorf(fx), ys = (int)floorf(fy);
@@ -1097,8 +1150,9 @@ static int imagewraposa_aniso(Tex *tex,
fy -= ys;
}
else if ((tex->flag & TEX_CHECKER_ODD) == 0 && (tex->flag & TEX_CHECKER_EVEN) == 0) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
else {
@@ -1118,13 +1172,15 @@ static int imagewraposa_aniso(Tex *tex,
}
else {
if ((tex->flag & TEX_CHECKER_ODD) == 0 && ((xs + ys) & 1) == 0) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
if ((tex->flag & TEX_CHECKER_EVEN) == 0 && (xs + ys) & 1) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
fx -= xs;
@@ -1144,15 +1200,17 @@ static int imagewraposa_aniso(Tex *tex,
if (tex->extend == TEX_CLIPCUBE) {
if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f ||
texvec[2] < -1.f || texvec[2] > 1.f) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
@@ -1178,10 +1236,12 @@ static int imagewraposa_aniso(Tex *tex,
/* brecht: added stupid clamping here, large dx/dy can give very large
* filter sizes which take ages to render, it may be better to do this
* more intelligently later in the code .. probably it's not noticeable */
- if (AFD.dxt[0] * AFD.dxt[0] + AFD.dxt[1] * AFD.dxt[1] > 2.0f * 2.0f)
+ if (AFD.dxt[0] * AFD.dxt[0] + AFD.dxt[1] * AFD.dxt[1] > 2.0f * 2.0f) {
mul_v2_fl(AFD.dxt, 2.0f / len_v2(AFD.dxt));
- if (AFD.dyt[0] * AFD.dyt[0] + AFD.dyt[1] * AFD.dyt[1] > 2.0f * 2.0f)
+ }
+ if (AFD.dyt[0] * AFD.dyt[0] + AFD.dyt[1] * AFD.dyt[1] > 2.0f * 2.0f) {
mul_v2_fl(AFD.dyt, 2.0f / len_v2(AFD.dyt));
+ }
/* choice: */
if (tex->imaflag & TEX_MIPMAP) {
@@ -1210,8 +1270,9 @@ static int imagewraposa_aniso(Tex *tex,
fProbes = 2.f * (a / b) - 1.f;
AFD.iProbes = round_fl_to_int(fProbes);
AFD.iProbes = MIN2(AFD.iProbes, tex->afmax);
- if (AFD.iProbes < fProbes)
+ if (AFD.iProbes < fProbes) {
b = 2.f * a / (float)(AFD.iProbes + 1);
+ }
AFD.majrad = a / ff;
AFD.minrad = b / ff;
AFD.theta = th;
@@ -1219,8 +1280,9 @@ static int imagewraposa_aniso(Tex *tex,
AFD.dvsc = ff / (float)ibuf->y;
}
else { /* EWA & area */
- if (ecc > (float)tex->afmax)
+ if (ecc > (float)tex->afmax) {
b = a / (float)tex->afmax;
+ }
b *= ff;
}
maxd = max_ff(b, 1e-8f);
@@ -1231,8 +1293,9 @@ static int imagewraposa_aniso(Tex *tex,
mipmaps[0] = ibuf;
while (curmap < IMB_MIPMAP_LEVELS) {
mipmaps[curmap + 1] = ibuf->mipmap[curmap];
- if (ibuf->mipmap[curmap])
+ if (ibuf->mipmap[curmap]) {
maxlev++;
+ }
curmap++;
}
@@ -1244,8 +1307,9 @@ static int imagewraposa_aniso(Tex *tex,
else if (levf >= maxlev - 1) {
previbuf = curibuf = mipmaps[maxlev - 1];
levf = 0.f;
- if (tex->texfilter == TXF_FELINE)
+ if (tex->texfilter == TXF_FELINE) {
AFD.iProbes = 1;
+ }
}
else {
const int lev = isnan(levf) ? 0 : (int)levf;
@@ -1317,8 +1381,9 @@ static int imagewraposa_aniso(Tex *tex,
fProbes = 2.f * (a / b) - 1.f;
/* no limit to number of Probes here */
AFD.iProbes = round_fl_to_int(fProbes);
- if (AFD.iProbes < fProbes)
+ if (AFD.iProbes < fProbes) {
b = 2.f * a / (float)(AFD.iProbes + 1);
+ }
AFD.majrad = a / ff;
AFD.minrad = b / ff;
AFD.theta = th;
@@ -1345,12 +1410,15 @@ static int imagewraposa_aniso(Tex *tex,
}
}
- if (tex->imaflag & TEX_CALCALPHA)
+ if (tex->imaflag & TEX_CALCALPHA) {
texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb);
- else
+ }
+ else {
texres->tin = texres->ta;
- if (tex->flag & TEX_NEGALPHA)
+ }
+ if (tex->flag & TEX_NEGALPHA) {
texres->ta = 1.f - texres->ta;
+ }
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */
/* The invert of the red channel is to make
@@ -1365,8 +1433,9 @@ static int imagewraposa_aniso(Tex *tex,
}
/* de-premul, this is being premulled in shade_input_do_shade()
- * TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, so for now commented out
- * also disabled in imagewraposa() to be able to compare results with blender's default texture filtering */
+ * TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode,
+ * so for now commented out also disabled in imagewraposa()
+ * to be able to compare results with blender's default texture filtering */
/* brecht: tried to fix this, see "TXF alpha" comments */
@@ -1378,8 +1447,9 @@ static int imagewraposa_aniso(Tex *tex,
texres->tb *= fx;
}
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
BRICONTRGB;
@@ -1401,14 +1471,15 @@ int imagewraposa(Tex *tex,
float maxd, pixsize, val1, val2, val3;
int curmap, retval, imaprepeat, imapextend;
- /* TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call,
- * make a local copy here so that original vecs remain untouched */
+ /* TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa()
+ * call, make a local copy here so that original vecs remain untouched. */
copy_v2_v2(dxt, DXT);
copy_v2_v2(dyt, DYT);
/* anisotropic filtering */
- if (tex->texfilter != TXF_BOX)
+ if (tex->texfilter != TXF_BOX) {
return imagewraposa_aniso(tex, ima, ibuf, texvec, dxt, dyt, texres, pool, skip_load_image);
+ }
texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f;
@@ -1416,21 +1487,24 @@ int imagewraposa(Tex *tex,
retval = texres->nor ? 3 : 1;
/* quick tests */
- if (ibuf == NULL && ima == NULL)
+ if (ibuf == NULL && ima == NULL) {
return retval;
+ }
if (ima) {
/* hack for icon render */
- if (skip_load_image && !BKE_image_has_loaded_ibuf(ima))
+ if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
return retval;
+ }
ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool);
ima->flag |= IMA_USED_FOR_RENDER;
}
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
@@ -1468,13 +1542,16 @@ int imagewraposa(Tex *tex,
miny = (maxy - miny) / 2.0f;
if (tex->imaflag & TEX_FILTER_MIN) {
- /* make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) */
+ /* Make sure the filtersize is minimal in pixels
+ * (normal, ref map can have miniature pixel dx/dy). */
float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y);
- if (addval > minx)
+ if (addval > minx) {
minx = addval;
- if (addval > miny)
+ }
+ if (addval > miny) {
miny = addval;
+ }
}
else if (tex->filtersize != 1.0f) {
minx *= tex->filtersize;
@@ -1486,17 +1563,22 @@ int imagewraposa(Tex *tex,
dyt[1] *= tex->filtersize;
}
- if (tex->imaflag & TEX_IMAROT)
+ if (tex->imaflag & TEX_IMAROT) {
SWAP(float, minx, miny);
+ }
- if (minx > 0.25f)
+ if (minx > 0.25f) {
minx = 0.25f;
- else if (minx < 0.00001f)
+ }
+ else if (minx < 0.00001f) {
minx = 0.00001f; /* side faces of unit-cube */
- if (miny > 0.25f)
+ }
+ if (miny > 0.25f) {
miny = 0.25f;
- else if (miny < 0.00001f)
+ }
+ else if (miny < 0.00001f) {
miny = 0.00001f;
+ }
/* repeat and clip */
imaprepeat = (tex->extend == TEX_REPEAT);
@@ -1521,8 +1603,9 @@ int imagewraposa(Tex *tex,
fy -= ys;
}
else if ((tex->flag & TEX_CHECKER_ODD) == 0 && (tex->flag & TEX_CHECKER_EVEN) == 0) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
else {
@@ -1539,15 +1622,17 @@ int imagewraposa(Tex *tex,
/* pass */
}
else {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
if ((tex->flag & TEX_CHECKER_EVEN) == 0) {
if ((xs + ys) & 1) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
@@ -1556,26 +1641,34 @@ int imagewraposa(Tex *tex,
}
else {
if (tex->flag & TEX_CHECKER_ODD) {
- if ((xs1 + ys) & 1)
+ if ((xs1 + ys) & 1) {
fx -= xs2;
- else
+ }
+ else {
fx -= xs1;
+ }
- if ((ys1 + xs) & 1)
+ if ((ys1 + xs) & 1) {
fy -= ys2;
- else
+ }
+ else {
fy -= ys1;
+ }
}
if (tex->flag & TEX_CHECKER_EVEN) {
- if ((xs1 + ys) & 1)
+ if ((xs1 + ys) & 1) {
fx -= xs1;
- else
+ }
+ else {
fx -= xs2;
+ }
- if ((ys1 + xs) & 1)
+ if ((ys1 + xs) & 1) {
fy -= ys1;
- else
+ }
+ else {
fy -= ys2;
+ }
}
}
}
@@ -1592,43 +1685,53 @@ int imagewraposa(Tex *tex,
if (tex->extend == TEX_CLIPCUBE) {
if (fx + minx < 0.0f || fy + miny < 0.0f || fx - minx > 1.0f || fy - miny > 1.0f ||
texvec[2] < -1.0f || texvec[2] > 1.0f) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
if (fx + minx < 0.0f || fy + miny < 0.0f || fx - minx > 1.0f || fy - miny > 1.0f) {
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
return retval;
}
}
else {
if (imapextend) {
- if (fx > 1.0f)
+ if (fx > 1.0f) {
fx = 1.0f;
- else if (fx < 0.0f)
+ }
+ else if (fx < 0.0f) {
fx = 0.0f;
+ }
}
else {
- if (fx > 1.0f)
+ if (fx > 1.0f) {
fx -= (int)(fx);
- else if (fx < 0.0f)
+ }
+ else if (fx < 0.0f) {
fx += 1 - (int)(fx);
+ }
}
if (imapextend) {
- if (fy > 1.0f)
+ if (fy > 1.0f) {
fy = 1.0f;
- else if (fy < 0.0f)
+ }
+ else if (fy < 0.0f) {
fy = 0.0f;
+ }
}
else {
- if (fy > 1.0f)
+ if (fy > 1.0f) {
fy -= (int)(fy);
- else if (fy < 0.0f)
+ }
+ else if (fy < 0.0f) {
fy += 1 - (int)(fy);
+ }
}
}
@@ -1640,22 +1743,26 @@ int imagewraposa(Tex *tex,
dx = minx;
dy = miny;
maxd = max_ff(dx, dy);
- if (maxd > 0.5f)
+ if (maxd > 0.5f) {
maxd = 0.5f;
+ }
pixsize = 1.0f / (float)MIN2(ibuf->x, ibuf->y);
bumpscale = pixsize / maxd;
- if (bumpscale > 1.0f)
+ if (bumpscale > 1.0f) {
bumpscale = 1.0f;
- else
+ }
+ else {
bumpscale *= bumpscale;
+ }
curmap = 0;
previbuf = curibuf = ibuf;
while (curmap < IMB_MIPMAP_LEVELS && ibuf->mipmap[curmap]) {
- if (maxd < pixsize)
+ if (maxd < pixsize) {
break;
+ }
previbuf = curibuf;
curibuf = ibuf->mipmap[curmap];
pixsize = 1.0f / (float)MIN2(curibuf->x, curibuf->y);
@@ -1664,16 +1771,18 @@ int imagewraposa(Tex *tex,
if (previbuf != curibuf || (tex->imaflag & TEX_INTERPOL)) {
/* sample at least 1 pixel */
- if (minx < 0.5f / ibuf->x)
+ if (minx < 0.5f / ibuf->x) {
minx = 0.5f / ibuf->x;
- if (miny < 0.5f / ibuf->y)
+ }
+ if (miny < 0.5f / ibuf->y) {
miny = 0.5f / ibuf->y;
+ }
}
if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) {
/* a bit extra filter */
- //minx*= 1.35f;
- //miny*= 1.35f;
+ // minx*= 1.35f;
+ // miny*= 1.35f;
boxsample(
curibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
@@ -1789,10 +1898,12 @@ int imagewraposa(Tex *tex,
const int intpol = tex->imaflag & TEX_INTERPOL;
if (intpol) {
/* sample 1 pixel minimum */
- if (minx < 0.5f / ibuf->x)
+ if (minx < 0.5f / ibuf->x) {
minx = 0.5f / ibuf->x;
- if (miny < 0.5f / ibuf->y)
+ }
+ if (miny < 0.5f / ibuf->y) {
miny = 0.5f / ibuf->y;
+ }
}
if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) {
@@ -1821,8 +1932,9 @@ int imagewraposa(Tex *tex,
texres->nor[0] = (val1 - val2);
texres->nor[1] = (val1 - val3);
}
- else
+ else {
boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
+ }
}
if (tex->imaflag & TEX_CALCALPHA) {
@@ -1832,8 +1944,9 @@ int imagewraposa(Tex *tex,
texres->tin = texres->ta;
}
- if (tex->flag & TEX_NEGALPHA)
+ if (tex->flag & TEX_NEGALPHA) {
texres->ta = 1.0f - texres->ta;
+ }
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) {
/* qdn: normal from color
@@ -1854,8 +1967,9 @@ int imagewraposa(Tex *tex,
mul_v3_fl(&texres->tr, 1.0f / texres->ta);
}
- if (ima)
+ if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
+ }
BRICONTRGB;
@@ -1891,8 +2005,8 @@ void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float resu
AFD.dxt[1] = dx;
AFD.dyt[0] = dy;
AFD.dyt[1] = dy;
- //copy_v2_v2(AFD.dxt, dx);
- //copy_v2_v2(AFD.dyt, dy);
+ // copy_v2_v2(AFD.dxt, dx);
+ // copy_v2_v2(AFD.dyt, dy);
AFD.intpol = 1;
AFD.extflag = TXC_EXTD;
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index e23d839297a..4540e4e2cc2 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -49,12 +49,15 @@
static float filt_quadratic(float x)
{
- if (x < 0.0f)
+ if (x < 0.0f) {
x = -x;
- if (x < 0.5f)
+ }
+ if (x < 0.5f) {
return 0.75f - (x * x);
- if (x < 1.5f)
+ }
+ if (x < 1.5f) {
return 0.50f * (x - 1.5f) * (x - 1.5f);
+ }
return 0.0f;
}
@@ -62,13 +65,16 @@ static float filt_cubic(float x)
{
float x2 = x * x;
- if (x < 0.0f)
+ if (x < 0.0f) {
x = -x;
+ }
- if (x < 1.0f)
+ if (x < 1.0f) {
return 0.5f * x * x2 - x2 + 2.0f / 3.0f;
- if (x < 2.0f)
+ }
+ if (x < 2.0f) {
return (2.0f - x) * (2.0f - x) * (2.0f - x) / 6.0f;
+ }
return 0.0f;
}
@@ -76,12 +82,15 @@ static float filt_catrom(float x)
{
float x2 = x * x;
- if (x < 0.0f)
+ if (x < 0.0f) {
x = -x;
- if (x < 1.0f)
+ }
+ if (x < 1.0f) {
return 1.5f * x2 * x - 2.5f * x2 + 1.0f;
- if (x < 2.0f)
+ }
+ if (x < 2.0f) {
return -0.5f * x2 * x + 2.5f * x2 - 4.0f * x + 2.0f;
+ }
return 0.0f;
}
@@ -96,16 +105,21 @@ static float filt_mitchell(float x) /* Mitchell & Netravali's two-param cubic */
float q2 = (6.0f * b + 30.0f * c) / 6.0f;
float q3 = (-b - 6.0f * c) / 6.0f;
- if (x < -2.0f)
+ if (x < -2.0f) {
return 0.0f;
- if (x < -1.0f)
+ }
+ if (x < -1.0f) {
return (q0 - x * (q1 - x * (q2 - x * q3)));
- if (x < 0.0f)
+ }
+ if (x < 0.0f) {
return (p0 + x * x * (p2 - x * p3));
- if (x < 1.0f)
+ }
+ if (x < 1.0f) {
return (p0 + x * x * (p2 + x * p3));
- if (x < 2.0f)
+ }
+ if (x < 2.0f) {
return (q0 + x * (q1 + x * (q2 + x * q3)));
+ }
return 0.0f;
}
@@ -118,13 +132,15 @@ float RE_filter_value(int type, float x)
switch (type) {
case R_FILTER_BOX:
- if (x > 1.0f)
+ if (x > 1.0f) {
return 0.0f;
+ }
return 1.0f;
case R_FILTER_TENT:
- if (x > 1.0f)
+ if (x > 1.0f) {
return 0.0f;
+ }
return 1.0f - x;
case R_FILTER_GAUSS: {
@@ -278,19 +294,23 @@ void RE_parts_init(Render *re)
/* ensure we cover the entire picture, so last parts go to end */
if (xd < xparts - 1) {
disprect.xmax = disprect.xmin + partx;
- if (disprect.xmax > xmaxb)
+ if (disprect.xmax > xmaxb) {
disprect.xmax = xmaxb;
+ }
}
- else
+ else {
disprect.xmax = xmaxb;
+ }
if (yd < yparts - 1) {
disprect.ymax = disprect.ymin + party;
- if (disprect.ymax > ymaxb)
+ if (disprect.ymax > ymaxb) {
disprect.ymax = ymaxb;
+ }
}
- else
+ else {
disprect.ymax = ymaxb;
+ }
rectx = BLI_rcti_size_x(&disprect);
recty = BLI_rcti_size_y(&disprect);
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c
index 1358b7a9438..237debceb83 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/source/multires_bake.c
@@ -251,8 +251,9 @@ static void rasterize_half(const MBakeRast *bake_rast,
const int h = bake_rast->h;
int y, y0, y1;
- if (y1_in <= 0 || y0_in >= h)
+ if (y1_in <= 0 || y0_in >= h) {
return;
+ }
y0 = y0_in < 0 ? 0 : y0_in;
y1 = y1_in >= h ? h : y1_in;
@@ -263,8 +264,9 @@ static void rasterize_half(const MBakeRast *bake_rast,
float x_l = s_stable != 0 ? (s0_s + (((s1_s - s0_s) * (y - t0_s)) / (t1_s - t0_s))) : s0_s;
float x_r = l_stable != 0 ? (s0_l + (((s1_l - s0_l) * (y - t0_l)) / (t1_l - t0_l))) : s0_l;
- if (is_mid_right != 0)
+ if (is_mid_right != 0) {
SWAP(float, x_l, x_r);
+ }
iXl = (int)ceilf(x_l);
iXr = (int)ceilf(x_r);
@@ -273,8 +275,9 @@ static void rasterize_half(const MBakeRast *bake_rast,
iXl = iXl < 0 ? 0 : iXl;
iXr = iXr >= w ? w : iXr;
- for (x = iXl; x < iXr; x++)
+ for (x = iXl; x < iXr; x++) {
set_rast_triangle(bake_rast, x, y);
+ }
}
}
}
@@ -295,8 +298,9 @@ static void bake_rasterize(const MBakeRast *bake_rast,
int is_mid_right = 0, ylo, yhi, yhi_beg;
/* skip degenerates */
- if ((slo == smi && tlo == tmi) || (slo == shi && tlo == thi) || (smi == shi && tmi == thi))
+ if ((slo == smi && tlo == tmi) || (slo == shi && tlo == thi) || (smi == shi && tmi == thi)) {
return;
+ }
/* sort by T */
if (tlo > tmi && tlo > thi) {
@@ -389,12 +393,14 @@ static void *do_multires_bake_thread(void *data_v)
const short mat_nr = mp->mat_nr;
const MLoopUV *mloopuv = data->mloopuv;
- if (multiresbake_test_break(bkr))
+ if (multiresbake_test_break(bkr)) {
break;
+ }
Image *tri_image = mat_nr < bkr->ob_image.len ? bkr->ob_image.array[mat_nr] : NULL;
- if (tri_image != handle->image)
+ if (tri_image != handle->image) {
continue;
+ }
data->tri_index = tri_index;
@@ -402,8 +408,9 @@ static void *do_multires_bake_thread(void *data_v)
bake_rast, mloopuv[lt->tri[0]].uv, mloopuv[lt->tri[1]].uv, mloopuv[lt->tri[2]].uv);
/* tag image buffer for refresh */
- if (data->ibuf->rect_float)
+ if (data->ibuf->rect_float) {
data->ibuf->userflags |= IB_RECT_INVALID;
+ }
data->ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
@@ -411,13 +418,15 @@ static void *do_multires_bake_thread(void *data_v)
BLI_spin_lock(&handle->queue->spin);
bkr->baked_faces++;
- if (bkr->do_update)
+ if (bkr->do_update) {
*bkr->do_update = true;
+ }
- if (bkr->progress)
+ if (bkr->progress) {
*bkr->progress = ((float)bkr->baked_objects +
(float)bkr->baked_faces / handle->queue->tot_tri) /
bkr->tot_obj;
+ }
BLI_spin_unlock(&handle->queue->spin);
}
@@ -476,18 +485,21 @@ static void do_multires_bake(MultiresBakeRender *bkr,
void *bake_data = NULL;
if (require_tangent) {
- if (CustomData_get_layer_index(&dm->loopData, CD_TANGENT) == -1)
+ if (CustomData_get_layer_index(&dm->loopData, CD_TANGENT) == -1) {
DM_calc_loop_tangents(dm, true, NULL, 0);
+ }
pvtangent = DM_get_loop_data_layer(dm, CD_TANGENT);
}
/* all threads shares the same custom bake data */
- if (initBakeData)
+ if (initBakeData) {
bake_data = initBakeData(bkr, ima);
+ }
- if (tot_thread > 1)
+ if (tot_thread > 1) {
BLI_threadpool_init(&threads, do_multires_bake_thread, tot_thread);
+ }
handles = MEM_callocN(tot_thread * sizeof(MultiresBakeThread), "do_multires_bake handles");
@@ -528,15 +540,18 @@ static void do_multires_bake(MultiresBakeRender *bkr,
init_bake_rast(&handle->bake_rast, ibuf, &handle->data, flush_pixel, bkr->do_update);
- if (tot_thread > 1)
+ if (tot_thread > 1) {
BLI_threadpool_insert(&threads, handle);
+ }
}
/* run threads */
- if (tot_thread > 1)
+ if (tot_thread > 1) {
BLI_threadpool_end(&threads);
- else
+ }
+ else {
do_multires_bake_thread(&handles[0]);
+ }
/* construct bake result */
result->height_min = handles[0].height_min;
@@ -550,8 +565,9 @@ static void do_multires_bake(MultiresBakeRender *bkr,
BLI_spin_end(&queue.spin);
/* finalize baking */
- if (freeBakeData)
+ if (freeBakeData) {
freeBakeData(bake_data);
+ }
MEM_freeN(handles);
@@ -658,11 +674,13 @@ static void get_ccgdm_data(DerivedMesh *lodm,
CLAMP(crn_x, 0.0f, grid_size);
CLAMP(crn_y, 0.0f, grid_size);
- if (n != NULL)
+ if (n != NULL) {
interp_bilinear_grid(&key, grid_data[g_index + S], crn_x, crn_y, 0, n);
+ }
- if (co != NULL)
+ if (co != NULL) {
interp_bilinear_grid(&key, grid_data[g_index + S], crn_x, crn_y, 1, co);
+ }
}
/* mode = 0: interpolate normals,
@@ -727,9 +745,10 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
DerivedMesh *lodm = bkr->lores_dm;
BakeImBufuserData *userdata = ibuf->userdata;
- if (userdata->displacement_buffer == NULL)
+ if (userdata->displacement_buffer == NULL) {
userdata->displacement_buffer = MEM_callocN(sizeof(float) * ibuf->x * ibuf->y,
"MultiresBake heights");
+ }
height_data = MEM_callocN(sizeof(MHeightBakeData), "MultiresBake heightData");
@@ -747,8 +766,9 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
smd.uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
smd.quality = 3;
- if (bkr->simple)
+ if (bkr->simple) {
smd.subdivType = ME_SIMPLE_SUBSURF;
+ }
height_data->ssdm = subsurf_make_derived_from_derived(
bkr->lores_dm, &smd, bkr->scene, NULL, 0);
@@ -767,8 +787,9 @@ static void free_heights_data(void *bake_data)
{
MHeightBakeData *height_data = (MHeightBakeData *)bake_data;
- if (height_data->ssdm)
+ if (height_data->ssdm) {
height_data->ssdm->release(height_data->ssdm);
+ }
MEM_freeN(height_data);
}
@@ -984,8 +1005,10 @@ static unsigned short get_ao_random2(const int i)
return ao_random_table_2[i & (MAX_NUMBER_OF_AO_RAYS - 1)];
}
-static void build_permutation_table(unsigned short permutation[], unsigned short temp_permutation[],
- const int number_of_rays, const int is_first_perm_table)
+static void build_permutation_table(unsigned short permutation[],
+ unsigned short temp_permutation[],
+ const int number_of_rays,
+ const int is_first_perm_table)
{
int i, k;
@@ -1031,11 +1054,13 @@ static void create_ao_raytree(MultiresBakeRender *bkr, MAOBakeData *ao_data)
grid_data = hidm->getGridData(hidm);
hidm->getGridKey(hidm, &key);
- /* face_side = (grid_size << 1) - 1; */ /* UNUSED */
+ /* face_side = (grid_size << 1) - 1; */ /* UNUSED */
num_faces = num_grids * (grid_size - 1) * (grid_size - 1);
- raytree = ao_data->raytree = RE_rayobject_create(bkr->raytrace_structure, num_faces, bkr->octree_resolution);
- face = ao_data->rayfaces = (RayFace *)MEM_callocN(num_faces * sizeof(RayFace), "ObjectRen faces");
+ raytree = ao_data->raytree = RE_rayobject_create(
+ bkr->raytrace_structure, num_faces, bkr->octree_resolution);
+ face = ao_data->rayfaces = (RayFace *)MEM_callocN(num_faces * sizeof(RayFace),
+ "ObjectRen faces");
for (i = 0; i < num_grids; i++) {
int x, y;
@@ -1083,8 +1108,10 @@ static void *init_ao_data(MultiresBakeRender *bkr, Image *UNUSED(ima))
ao_data->permutation_table_2 = MEM_callocN(permutation_size, "multires AO baker perm2");
temp_permutation_table = MEM_callocN(permutation_size, "multires AO baker temp perm");
- build_permutation_table(ao_data->permutation_table_1, temp_permutation_table, bkr->number_of_rays, 1);
- build_permutation_table(ao_data->permutation_table_2, temp_permutation_table, bkr->number_of_rays, 0);
+ build_permutation_table(
+ ao_data->permutation_table_1, temp_permutation_table, bkr->number_of_rays, 1);
+ build_permutation_table(
+ ao_data->permutation_table_2, temp_permutation_table, bkr->number_of_rays, 0);
MEM_freeN(temp_permutation_table);
@@ -1113,17 +1140,23 @@ static void build_coordinate_frame(float axisX[3], float axisY[3], const float a
if (faX <= faY && faX <= faZ) {
const float len = sqrtf(axisZ[1] * axisZ[1] + axisZ[2] * axisZ[2]);
- axisY[0] = 0; axisY[1] = axisZ[2] / len; axisY[2] = -axisZ[1] / len;
+ axisY[0] = 0;
+ axisY[1] = axisZ[2] / len;
+ axisY[2] = -axisZ[1] / len;
cross_v3_v3v3(axisX, axisY, axisZ);
}
else if (faY <= faZ) {
const float len = sqrtf(axisZ[0] * axisZ[0] + axisZ[2] * axisZ[2]);
- axisX[0] = axisZ[2] / len; axisX[1] = 0; axisX[2] = -axisZ[0] / len;
+ axisX[0] = axisZ[2] / len;
+ axisX[1] = 0;
+ axisX[2] = -axisZ[0] / len;
cross_v3_v3v3(axisY, axisZ, axisX);
}
else {
const float len = sqrtf(axisZ[0] * axisZ[0] + axisZ[1] * axisZ[1]);
- axisX[0] = axisZ[1] / len; axisX[1] = -axisZ[0] / len; axisX[2] = 0;
+ axisX[0] = axisZ[1] / len;
+ axisX[1] = -axisZ[0] / len;
+ axisX[2] = 0;
cross_v3_v3v3(axisY, axisZ, axisX);
}
}
@@ -1143,9 +1176,17 @@ static int trace_ao_ray(MAOBakeData *ao_data, float ray_start[3], float ray_dire
return RE_rayobject_raycast(ao_data->raytree, &isect);
}
-static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void *UNUSED(thread_data),
- void *bake_data, ImBuf *ibuf, const int tri_index, const int lvl,
- const float st[2], float UNUSED(tangmat[3][3]), const int x, const int y)
+static void apply_ao_callback(DerivedMesh *lores_dm,
+ DerivedMesh *hires_dm,
+ void *UNUSED(thread_data),
+ void *bake_data,
+ ImBuf *ibuf,
+ const int tri_index,
+ const int lvl,
+ const float st[2],
+ float UNUSED(tangmat[3][3]),
+ const int x,
+ const int y)
{
const MLoopTri *lt = lores_dm->getLoopTriArray(lores_dm) + tri_index;
MPoly *mpoly = lores_dm->getPolyArray(lores_dm) + lt->poly;
@@ -1180,9 +1221,8 @@ static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void
CLAMP(uv[0], 0.0f, 1.0f);
CLAMP(uv[1], 0.0f, 1.0f);
- get_ccgdm_data(lores_dm, hires_dm,
- ao_data->orig_index_mp_to_orig,
- lvl, lt, uv[0], uv[1], pos, nrm);
+ get_ccgdm_data(
+ lores_dm, hires_dm, ao_data->orig_index_mp_to_orig, lvl, lt, uv[0], uv[1], pos, nrm);
/* offset ray origin by user bias along normal */
for (i = 0; i < 3; i++)
@@ -1204,11 +1244,14 @@ static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void
/* use N-Rooks to distribute our N ray samples across
* a multi-dimensional domain (2D)
*/
- const unsigned short I = ao_data->permutation_table_1[(i + perm_offs) % ao_data->number_of_rays];
+ const unsigned short I =
+ ao_data->permutation_table_1[(i + perm_offs) % ao_data->number_of_rays];
const unsigned short J = ao_data->permutation_table_2[i];
- const float JitPh = (get_ao_random2(I + perm_offs) & (MAX_NUMBER_OF_AO_RAYS - 1)) / ((float)MAX_NUMBER_OF_AO_RAYS);
- const float JitTh = (get_ao_random1(J + perm_offs) & (MAX_NUMBER_OF_AO_RAYS - 1)) / ((float)MAX_NUMBER_OF_AO_RAYS);
+ const float JitPh = (get_ao_random2(I + perm_offs) & (MAX_NUMBER_OF_AO_RAYS - 1)) /
+ ((float)MAX_NUMBER_OF_AO_RAYS);
+ const float JitTh = (get_ao_random1(J + perm_offs) & (MAX_NUMBER_OF_AO_RAYS - 1)) /
+ ((float)MAX_NUMBER_OF_AO_RAYS);
const float SiSqPhi = (I + JitPh) / ao_data->number_of_rays;
const float Theta = (float)(2 * M_PI) * ((J + JitTh) / ao_data->number_of_rays);
@@ -1288,10 +1331,12 @@ static void bake_ibuf_normalize_displacement(
if (*current_mask == FILTER_MASK_USED) {
float normalized_displacement;
- if (max_distance > 1e-5f)
+ if (max_distance > 1e-5f) {
normalized_displacement = (*current_displacement + max_distance) / (max_distance * 2);
- else
+ }
+ else {
normalized_displacement = 0.5f;
+ }
if (ibuf->rect_float) {
/* currently baking happens to RGBA only */
@@ -1399,8 +1444,9 @@ static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
BakeImBufuserData *userdata = (BakeImBufuserData *)ibuf->userdata;
- if (ibuf->x <= 0 || ibuf->y <= 0)
+ if (ibuf->x <= 0 || ibuf->y <= 0) {
continue;
+ }
if (use_displacement_buffer) {
bake_ibuf_normalize_displacement(ibuf,
@@ -1414,8 +1460,9 @@ static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
ibuf->userflags |= IB_RECT_INVALID;
+ }
if (ibuf->mipmap[0]) {
ibuf->userflags |= IB_MIPMAP_INVALID;
@@ -1423,8 +1470,9 @@ static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
}
if (ibuf->userdata) {
- if (userdata->displacement_buffer)
+ if (userdata->displacement_buffer) {
MEM_freeN(userdata->displacement_buffer);
+ }
MEM_freeN(userdata->mask_buffer);
MEM_freeN(userdata);
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index b6aa9904747..7d3002ea71d 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -186,10 +186,12 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
mmap_used_memory,
megs_peak_memory);
- if (rs->curfield)
+ if (rs->curfield) {
fprintf(stdout, IFACE_("Field %d "), rs->curfield);
- if (rs->curblur)
+ }
+ if (rs->curblur) {
fprintf(stdout, IFACE_("Blur %d "), rs->curblur);
+ }
BLI_timecode_string_from_time_simple(
info_time_str, sizeof(info_time_str), PIL_check_seconds_timer() - rs->starttime);
@@ -199,7 +201,7 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
fprintf(stdout, "%s", rs->infostr);
}
else {
- if (rs->tothalo)
+ if (rs->tothalo) {
fprintf(stdout,
IFACE_("Sce: %s Ve:%d Fa:%d Ha:%d La:%d"),
rs->scene_name,
@@ -207,19 +209,22 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
rs->totface,
rs->tothalo,
rs->totlamp);
- else
+ }
+ else {
fprintf(stdout,
IFACE_("Sce: %s Ve:%d Fa:%d La:%d"),
rs->scene_name,
rs->totvert,
rs->totface,
rs->totlamp);
+ }
}
/* Flush stdout to be sure python callbacks are printing stuff after blender. */
fflush(stdout);
- /* NOTE: using G_MAIN seems valid here??? Not sure it's actually even used anyway, we could as well pass NULL? */
+ /* NOTE: using G_MAIN seems valid here???
+ * Not sure it's actually even used anyway, we could as well pass NULL? */
BLI_callback_exec(G_MAIN, NULL, BLI_CB_EVT_RENDER_STATS);
fputc('\n', stdout);
@@ -330,9 +335,11 @@ Render *RE_GetRender(const char *name)
Render *re;
/* search for existing renders */
- for (re = RenderGlobal.renderlist.first; re; re = re->next)
- if (STREQLEN(re->name, name, RE_MAXNAME))
+ for (re = RenderGlobal.renderlist.first; re; re = re->next) {
+ if (STREQLEN(re->name, name, RE_MAXNAME)) {
break;
+ }
+ }
return re;
}
@@ -376,15 +383,17 @@ void RE_SwapResult(Render *re, RenderResult **rr)
void RE_ReleaseResult(Render *re)
{
- if (re)
+ if (re) {
BLI_rw_mutex_unlock(&re->resultmutex);
+ }
}
/* displist.c util.... */
Scene *RE_GetScene(Render *re)
{
- if (re)
+ if (re) {
return re->scene;
+ }
return NULL;
}
@@ -485,11 +494,13 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr, const int view_id)
rl = render_get_active_layer(re, re->result);
if (rl) {
- if (rv->rectf == NULL)
+ if (rv->rectf == NULL) {
rr->rectf = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, rv->name);
+ }
- if (rv->rectz == NULL)
+ if (rv->rectz == NULL) {
rr->rectz = RE_RenderLayerGetPass(rl, RE_PASSNAME_Z, rv->name);
+ }
}
rr->layers = re->result->layers;
@@ -505,8 +516,9 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr, const int view_id)
void RE_ReleaseResultImage(Render *re)
{
- if (re)
+ if (re) {
BLI_rw_mutex_unlock(&re->resultmutex);
+ }
}
/* caller is responsible for allocating rect in correct size! */
@@ -606,10 +618,12 @@ void RE_InitRenderCB(Render *re)
re->current_scene_update = current_scene_nothing;
re->progress = float_nothing;
re->test_break = default_break;
- if (G.background)
+ if (G.background) {
re->stats_draw = stats_background;
- else
+ }
+ else {
re->stats_draw = stats_nothing;
+ }
/* clear callback handles */
re->dih = re->dch = re->duh = re->sdh = re->prh = re->tbh = NULL;
}
@@ -617,8 +631,9 @@ void RE_InitRenderCB(Render *re)
/* only call this while you know it will remove the link too */
void RE_FreeRender(Render *re)
{
- if (re->engine)
+ if (re->engine) {
RE_engine_free(re->engine);
+ }
BLI_rw_mutex_end(&re->resultmutex);
BLI_rw_mutex_end(&re->partsmutex);
@@ -685,8 +700,9 @@ void RE_FreePersistentData(void)
for (re = RenderGlobal.renderlist.first; re; re = re->next) {
if (re->engine) {
/* if engine is currently rendering, just tag it to be freed when render is finished */
- if (!(re->engine->flag & RE_ENGINE_RENDERING))
+ if (!(re->engine->flag & RE_ENGINE_RENDERING)) {
RE_engine_free(re->engine);
+ }
re->engine = NULL;
}
@@ -704,8 +720,9 @@ static int check_mode_full_sample(RenderData *rd)
scemode &= ~R_FULL_SAMPLE;
#ifdef WITH_OPENEXR
- if (scemode & R_FULL_SAMPLE)
+ if (scemode & R_FULL_SAMPLE) {
scemode |= R_EXR_TILE_FILE; /* enable automatic */
+ }
#else
/* can't do this without openexr support */
scemode &= ~(R_EXR_TILE_FILE | R_FULL_SAMPLE);
@@ -835,9 +852,11 @@ void RE_InitState(Render *re,
RenderLayer *rl;
bool have_layer = false;
- for (rl = re->result->layers.first; rl; rl = rl->next)
- if (STREQ(rl->name, active_render_layer->name))
+ for (rl = re->result->layers.first; rl; rl = rl->next) {
+ if (STREQ(rl->name, active_render_layer->name)) {
have_layer = true;
+ }
+ }
if (re->result->rectx == re->rectx && re->result->recty == re->recty && have_layer) {
/* keep render result, this avoids flickering black tiles
@@ -1108,7 +1127,6 @@ void *RE_gpu_context_get(Render *re)
#if 0
void RE_AddObject(Render *UNUSED(re), Object *UNUSED(ob))
{
-
}
#endif
@@ -1249,23 +1267,29 @@ static void render_scene(Render *re, Scene *sce, int cfra)
do_render(resc);
}
-/* helper call to detect if this scene needs a render, or if there's a any render layer to render */
+/* helper call to detect if this scene needs a render,
+ * or if there's a any render layer to render. */
static int composite_needs_render(Scene *sce, int this_scene)
{
bNodeTree *ntree = sce->nodetree;
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return 1;
- if (sce->use_nodes == false)
+ }
+ if (sce->use_nodes == false) {
return 1;
- if ((sce->r.scemode & R_DOCOMP) == 0)
+ }
+ if ((sce->r.scemode & R_DOCOMP) == 0) {
return 1;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_R_LAYERS && (node->flag & NODE_MUTED) == 0)
- if (this_scene == 0 || node->id == NULL || node->id == &sce->id)
+ if (node->type == CMP_NODE_R_LAYERS && (node->flag & NODE_MUTED) == 0) {
+ if (this_scene == 0 || node->id == NULL || node->id == &sce->id) {
return 1;
+ }
+ }
}
return 0;
}
@@ -1288,8 +1312,9 @@ static void ntree_render_scenes(Render *re)
int cfra = re->scene->r.cfra;
Scene *restore_scene = re->scene;
- if (re->scene->nodetree == NULL)
+ if (re->scene->nodetree == NULL) {
return;
+ }
/* now foreach render-result node we do a full render */
/* results are stored in a way compositor will find it */
@@ -1355,8 +1380,9 @@ static void add_freestyle(Render *re, int render)
link = (LinkData *)MEM_callocN(sizeof(LinkData), "LinkData to Freestyle render");
BLI_addtail(&re->freestyle_renders, link);
- if ((re->r.scemode & R_SINGLE_LAYER) && view_layer != active_view_layer)
+ if ((re->r.scemode & R_SINGLE_LAYER) && view_layer != active_view_layer) {
continue;
+ }
if (FRS_is_freestyle_enabled(view_layer)) {
r = FRS_do_stroke_rendering(re, view_layer, render);
link->data = (void *)r;
@@ -1446,13 +1472,13 @@ static void do_render_composite(Render *re)
if (ntree) {
ntreeCompositTagRender(re->scene);
- ntreeCompositTagAnimated(ntree);
}
if (ntree && re->scene->use_nodes && re->r.scemode & R_DOCOMP) {
/* checks if there are render-result nodes that need scene */
- if ((re->r.scemode & R_SINGLE_LAYER) == 0)
+ if ((re->r.scemode & R_SINGLE_LAYER) == 0) {
ntree_render_scenes(re);
+ }
if (!re->test_break(re->tbh)) {
ntree->stats_draw = render_composit_stats;
@@ -1527,12 +1553,14 @@ int RE_seq_render_active(Scene *scene, RenderData *rd)
ed = scene->ed;
- if (!(rd->scemode & R_DOSEQ) || !ed || !ed->seqbase.first)
+ if (!(rd->scemode & R_DOSEQ) || !ed || !ed->seqbase.first) {
return 0;
+ }
for (seq = ed->seqbase.first; seq; seq = seq->next) {
- if (seq->type != SEQ_TYPE_SOUND_RAM)
+ if (seq->type != SEQ_TYPE_SOUND_RAM) {
return 1;
+ }
}
return 0;
@@ -1614,8 +1642,9 @@ static void do_render_seq(Render *re)
if (recurs_depth == 0) { /* with nested scenes, only free on toplevel... */
Editing *ed = re->scene->ed;
- if (ed)
+ if (ed) {
BKE_sequencer_free_imbuf(re->scene, &ed->seqbase, true);
+ }
}
IMB_freeImBuf(ibuf_arr[view_id]);
}
@@ -1639,10 +1668,12 @@ static void do_render_seq(Render *re)
re->r.scemode |= R_DOSEQ;
/* set overall progress of sequence rendering */
- if (re->r.efra != re->r.sfra)
+ if (re->r.efra != re->r.sfra) {
re->progress(re->prh, (float)(cfra - re->r.sfra) / (re->r.efra - re->r.sfra));
- else
+ }
+ else {
re->progress(re->prh, 1.0f);
+ }
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
@@ -1662,7 +1693,7 @@ static void do_render_all_options(Render *re)
/* ensure no images are in memory from previous animated sequences */
BKE_image_all_free_anim_ibufs(re->main, re->r.cfra);
- BKE_sequencer_all_free_anim_ibufs(re->main, re->r.cfra);
+ BKE_sequencer_all_free_anim_ibufs(re->scene, re->r.cfra);
/* Update for sequencer and compositing animation.
* TODO: ideally we would create a depsgraph with a copy of the scene
@@ -1670,7 +1701,8 @@ static void do_render_all_options(Render *re)
* work with copy-on-write. */
BKE_animsys_evaluate_all_animation(re->main, NULL, re->scene, (float)cfra);
- /* Update for masks (these do not use animsys but own lighter weight structure to define animation). */
+ /* Update for masks
+ * (these do not use animsys but own lighter weight structure to define animation). */
BKE_mask_evaluate_all_masks(re->main, (float)cfra, true);
if (RE_engine_render(re, 1)) {
@@ -1698,8 +1730,9 @@ static void do_render_all_options(Render *re)
if (re->result != NULL) {
camera = RE_GetCamera(re);
/* sequence rendering should have taken care of that already */
- if (!(render_seq && (re->r.stamp & R_STAMP_STRIPMETA)))
+ if (!(render_seq && (re->r.stamp & R_STAMP_STRIPMETA))) {
BKE_render_result_stamp_info(re->scene, camera, re->result, false);
+ }
/* stamp image info here */
if ((re->r.stamp & R_STAMP_ALL) && (re->r.stamp & R_STAMP_DRAW)) {
@@ -1740,8 +1773,9 @@ static bool check_valid_camera_multiview(Scene *scene, Object *camera, ReportLis
SceneRenderView *srv;
bool active_view = false;
- if (camera == NULL || (scene->r.scemode & R_MULTIVIEW) == 0)
+ if (camera == NULL || (scene->r.scemode & R_MULTIVIEW) == 0) {
return true;
+ }
for (srv = scene->r.views.first; srv; srv = srv->next) {
if (BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
@@ -1777,11 +1811,13 @@ static int check_valid_camera(Scene *scene, Object *camera_override, ReportList
{
const char *err_msg = "No camera found in scene \"%s\"";
- if (camera_override == NULL && scene->camera == NULL)
+ if (camera_override == NULL && scene->camera == NULL) {
scene->camera = BKE_view_layer_camera_find(BKE_view_layer_default_render(scene));
+ }
- if (!check_valid_camera_multiview(scene, scene->camera, reports))
+ if (!check_valid_camera_multiview(scene, scene->camera, reports)) {
return false;
+ }
if (RE_seq_render_active(scene, &scene->r)) {
if (scene->ed) {
@@ -1802,8 +1838,9 @@ static int check_valid_camera(Scene *scene, Object *camera_override, ReportList
}
}
}
- else if (!check_valid_camera_multiview(seq->scene, seq->scene_camera, reports))
+ else if (!check_valid_camera_multiview(seq->scene, seq->scene_camera, reports)) {
return false;
+ }
}
seq = seq->next;
@@ -1969,7 +2006,8 @@ static int render_initialize_from_main(Render *re,
winx = (rd->size * rd->xsch) / 100;
winy = (rd->size * rd->ysch) / 100;
- /* we always render smaller part, inserting it in larger image is compositor bizz, it uses disprect for it */
+ /* We always render smaller part, inserting it in larger image is compositor bizz,
+ * it uses disprect for it. */
if (scene->r.mode & R_BORDER) {
disprect.xmin = rd->border.xmin * winx;
disprect.xmax = rd->border.xmax * winx;
@@ -2013,8 +2051,9 @@ static int render_initialize_from_main(Render *re,
}
RE_InitState(re, NULL, &scene->r, &scene->view_layers, single_layer, winx, winy, &disprect);
- if (!re->ok) /* if an error was printed, abort */
+ if (!re->ok) { /* if an error was printed, abort */
return 0;
+ }
/* initstate makes new result, have to send changed tags around */
ntreeCompositTagRender(re->scene);
@@ -2043,7 +2082,8 @@ void RE_BlenderFrame(Render *re,
{
BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_INIT);
- /* ugly global still... is to prevent preview events and signal subsurfs etc to make full resol */
+ /* Ugly global still...
+ * is to prevent preview events and signal subsurfs etc to make full resol. */
G.is_rendering = true;
scene->r.cfra = frame;
@@ -2098,8 +2138,9 @@ void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, int render
{
re->result_ok = 0;
if (render_initialize_from_main(re, &scene->r, bmain, scene, NULL, NULL, 0, 0)) {
- if (render)
+ if (render) {
do_render_3d(re);
+ }
}
re->result_ok = 1;
}
@@ -2125,8 +2166,9 @@ bool RE_WriteRenderViewsImage(
bool ok = true;
RenderData *rd = &scene->r;
- if (!rr)
+ if (!rr) {
return false;
+ }
bool is_mono = BLI_listbase_count_at_most(&rr->views, 2) < 2;
bool is_exr_rr = ELEM(rd->im_format.imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER) &&
@@ -2159,8 +2201,9 @@ bool RE_WriteRenderViewsImage(
ImageFormatData imf = rd->im_format;
imf.imtype = R_IMF_IMTYPE_JPEG90;
- if (BLI_path_extension_check(name, ".exr"))
+ if (BLI_path_extension_check(name, ".exr")) {
name[strlen(name) - 4] = 0;
+ }
BKE_image_path_ensure_ext_from_imformat(name, &imf);
ImBuf *ibuf = render_result_rect_to_ibuf(rr, rd, view_id);
@@ -2219,8 +2262,9 @@ bool RE_WriteRenderViewsImage(
ImageFormatData imf = rd->im_format;
imf.imtype = R_IMF_IMTYPE_JPEG90;
- if (BLI_path_extension_check(name, ".exr"))
+ if (BLI_path_extension_check(name, ".exr")) {
name[strlen(name) - 4] = 0;
+ }
BKE_image_path_ensure_ext_from_imformat(name, &imf);
ibuf_arr[2]->planes = 24;
@@ -2251,8 +2295,9 @@ bool RE_WriteRenderViewsMovie(ReportList *reports,
bool is_mono;
bool ok = true;
- if (!rr)
+ if (!rr) {
return false;
+ }
is_mono = BLI_listbase_count_at_most(&rr->views, 2) < 2;
@@ -2340,9 +2385,10 @@ static int do_write_image_or_movie(Render *re,
re->reports, &rres, scene, &re->r, mh, re->movie_ctx_arr, totvideos, false);
}
else {
- if (name_override)
+ if (name_override) {
BLI_strncpy(name, name_override, sizeof(name));
- else
+ }
+ else {
BKE_image_path_from_imformat(name,
scene->r.pic,
BKE_main_blendfile_path(bmain),
@@ -2351,6 +2397,7 @@ static int do_write_image_or_movie(Render *re,
(scene->r.scemode & R_EXTENSION) != 0,
true,
NULL);
+ }
/* write images as individual images or stereo */
ok = RE_WriteRenderViewsImage(re->reports, &rres, scene, true, name);
@@ -2367,7 +2414,8 @@ static int do_write_image_or_movie(Render *re,
/* Flush stdout to be sure python callbacks are printing stuff after blender. */
fflush(stdout);
- /* NOTE: using G_MAIN seems valid here??? Not sure it's actually even used anyway, we could as well pass NULL? */
+ /* NOTE: using G_MAIN seems valid here???
+ * Not sure it's actually even used anyway, we could as well pass NULL? */
BLI_callback_exec(G_MAIN, NULL, BLI_CB_EVT_RENDER_STATS);
BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime - render_time);
@@ -2434,8 +2482,9 @@ void RE_BlenderAnim(Render *re,
BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_INIT);
/* do not fully call for each frame, it initializes & pops output window */
- if (!render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1))
+ if (!render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1)) {
return;
+ }
if (is_movie) {
size_t width, height;
@@ -2471,8 +2520,8 @@ void RE_BlenderAnim(Render *re,
}
}
- /* ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol */
- /* is also set by caller renderwin.c */
+ /* Ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol
+ * is also set by caller renderwin.c */
G.is_rendering = true;
re->flag |= R_ANIMATION;
@@ -2527,12 +2576,13 @@ void RE_BlenderAnim(Render *re,
/* Skip this frame, but could update for physics and particles system. */
continue;
}
- else
+ else {
nfra += tfra;
+ }
/* Touch/NoOverwrite options are only valid for image's */
if (is_movie == false) {
- if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH))
+ if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH)) {
BKE_image_path_from_imformat(name,
scene->r.pic,
BKE_main_blendfile_path(bmain),
@@ -2541,6 +2591,7 @@ void RE_BlenderAnim(Render *re,
(scene->r.scemode & R_EXTENSION) != 0,
true,
NULL);
+ }
if (scene->r.mode & R_NO_OVERWRITE) {
if (!is_multiview_name) {
@@ -2556,8 +2607,9 @@ void RE_BlenderAnim(Render *re,
char filepath[FILE_MAX];
for (srv = scene->r.views.first; srv; srv = srv->next) {
- if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv))
+ if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
continue;
+ }
BKE_scene_multiview_filepath_get(srv, name, filepath);
@@ -2586,8 +2638,9 @@ void RE_BlenderAnim(Render *re,
char filepath[FILE_MAX];
for (srv = scene->r.views.first; srv; srv = srv->next) {
- if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv))
+ if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
continue;
+ }
BKE_scene_multiview_filepath_get(srv, name, filepath);
@@ -2609,12 +2662,15 @@ void RE_BlenderAnim(Render *re,
totrendered++;
if (re->test_break(re->tbh) == 0) {
- if (!G.is_break)
- if (!do_write_image_or_movie(re, bmain, scene, mh, totvideos, NULL))
+ if (!G.is_break) {
+ if (!do_write_image_or_movie(re, bmain, scene, mh, totvideos, NULL)) {
G.is_break = true;
+ }
+ }
}
- else
+ else {
G.is_break = true;
+ }
if (G.is_break == true) {
/* remove touched file */
@@ -2631,8 +2687,9 @@ void RE_BlenderAnim(Render *re,
char filepath[FILE_MAX];
for (srv = scene->r.views.first; srv; srv = srv->next) {
- if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv))
+ if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
continue;
+ }
BKE_scene_multiview_filepath_get(srv, name, filepath);
@@ -2661,8 +2718,9 @@ void RE_BlenderAnim(Render *re,
re_movie_free_all(re, mh, totvideos);
}
- if (totskipped && totrendered == 0)
+ if (totskipped && totrendered == 0) {
BKE_report(re->reports, RPT_INFO, "No frames rendered, skipped to not overwrite");
+ }
scene->r.cfra = cfrao;
@@ -2726,13 +2784,15 @@ bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
disprect.ymax = winy;
}
- if (scenode)
+ if (scenode) {
scene = scenode;
+ }
/* get render: it can be called from UI with draw callbacks */
re = RE_GetSceneRender(scene);
- if (re == NULL)
+ if (re == NULL) {
re = RE_NewSceneRender(scene);
+ }
RE_InitState(re, NULL, &scene->r, &scene->view_layers, NULL, winx, winy, &disprect);
re->scene = scene;
@@ -2760,21 +2820,25 @@ void RE_layer_load_from_file(
RenderPass *rpass = NULL;
/* multiview: since the API takes no 'view', we use the first combined pass found */
- for (rpass = layer->passes.first; rpass; rpass = rpass->next)
- if (STREQ(rpass->name, RE_PASSNAME_COMBINED))
+ for (rpass = layer->passes.first; rpass; rpass = rpass->next) {
+ if (STREQ(rpass->name, RE_PASSNAME_COMBINED)) {
break;
+ }
+ }
- if (rpass == NULL)
+ if (rpass == NULL) {
BKE_reportf(reports,
RPT_ERROR,
"%s: no Combined pass found in the render layer '%s'",
__func__,
filename);
+ }
if (ibuf && (ibuf->rect || ibuf->rect_float)) {
if (ibuf->x == layer->rectx && ibuf->y == layer->recty) {
- if (ibuf->rect_float == NULL)
+ if (ibuf->rect_float == NULL) {
IMB_float_from_rect(ibuf);
+ }
memcpy(rpass->rect, ibuf->rect_float, sizeof(float) * 4 * layer->rectx * layer->recty);
}
@@ -2782,8 +2846,9 @@ void RE_layer_load_from_file(
if ((ibuf->x - x >= layer->rectx) && (ibuf->y - y >= layer->recty)) {
ImBuf *ibuf_clip;
- if (ibuf->rect_float == NULL)
+ if (ibuf->rect_float == NULL) {
IMB_float_from_rect(ibuf);
+ }
ibuf_clip = IMB_allocImBuf(layer->rectx, layer->recty, 32, IB_rectfloat);
if (ibuf_clip) {
@@ -2853,10 +2918,12 @@ RenderPass *RE_pass_find_by_name(volatile RenderLayer *rl, const char *name, con
for (rp = rl->passes.last; rp; rp = rp->prev) {
if (STREQ(rp->name, name)) {
- if (viewname == NULL || viewname[0] == '\0')
+ if (viewname == NULL || viewname[0] == '\0') {
break;
- else if (STREQ(rp->view, viewname))
+ }
+ else if (STREQ(rp->view, viewname)) {
break;
+ }
}
}
return rp;
@@ -2866,8 +2933,10 @@ RenderPass *RE_pass_find_by_name(volatile RenderLayer *rl, const char *name, con
RenderPass *RE_pass_find_by_type(volatile RenderLayer *rl, int passtype, const char *viewname)
{
#define CHECK_PASS(NAME) \
- if (passtype == SCE_PASS_##NAME) \
- return RE_pass_find_by_name(rl, RE_PASSNAME_##NAME, viewname);
+ if (passtype == SCE_PASS_##NAME) { \
+ return RE_pass_find_by_name(rl, RE_PASSNAME_##NAME, viewname); \
+ } \
+ ((void)0)
CHECK_PASS(COMBINED);
CHECK_PASS(Z);
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index a38c0d71a79..f9d4d5715d8 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -99,33 +99,39 @@ static void point_data_pointers(PointDensity *pd,
int offset = 0;
if (data_used & POINT_DATA_VEL) {
- if (r_data_velocity)
+ if (r_data_velocity) {
*r_data_velocity = data + offset;
+ }
offset += 3 * totpoint;
}
else {
- if (r_data_velocity)
+ if (r_data_velocity) {
*r_data_velocity = NULL;
+ }
}
if (data_used & POINT_DATA_LIFE) {
- if (r_data_life)
+ if (r_data_life) {
*r_data_life = data + offset;
+ }
offset += totpoint;
}
else {
- if (r_data_life)
+ if (r_data_life) {
*r_data_life = NULL;
+ }
}
if (data_used & POINT_DATA_COLOR) {
- if (r_data_color)
+ if (r_data_color) {
*r_data_color = data + offset;
+ }
offset += 3 * totpoint;
}
else {
- if (r_data_color)
+ if (r_data_color) {
*r_data_color = NULL;
+ }
}
}
@@ -203,12 +209,15 @@ static void pointdensity_cache_psys(
if (psys->part->type == PART_HAIR) {
/* hair particles */
- if (i < psys->totpart && psys->pathcache)
+ if (i < psys->totpart && psys->pathcache) {
cache = psys->pathcache[i];
- else if (i >= psys->totpart && psys->childcache)
+ }
+ else if (i >= psys->totpart && psys->childcache) {
cache = psys->childcache[i - psys->totpart];
- else
+ }
+ else {
continue;
+ }
cache += cache->segments; /* use endpoint */
@@ -220,8 +229,9 @@ static void pointdensity_cache_psys(
/* emitter particles */
state.time = cfra;
- if (!psys_get_particle_state(&sim, i, &state, 0))
+ if (!psys_get_particle_state(&sim, i, &state, 0)) {
continue;
+ }
if (data_used & POINT_DATA_LIFE) {
if (i < psys->totpart) {
@@ -238,8 +248,9 @@ static void pointdensity_cache_psys(
copy_v3_v3(partco, state.co);
- if (pd->psys_cache_space == TEX_PD_OBJECTSPACE)
+ if (pd->psys_cache_space == TEX_PD_OBJECTSPACE) {
mul_m4_v3(ob->imat, partco);
+ }
else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) {
sub_v3_v3(partco, ob->loc);
}
@@ -280,12 +291,14 @@ static void pointdensity_cache_vertex_color(PointDensity *pd,
BLI_assert(data_color);
- if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPCOL))
+ if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPCOL)) {
return;
+ }
CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPCOL, pd->vertex_attribute_name, layername);
mcol = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPCOL, layername);
- if (!mcol)
+ if (!mcol) {
return;
+ }
/* Stores the number of MLoops using the same vertex, so we can normalize colors. */
int *mcorners = MEM_callocN(sizeof(int) * pd->totpoints, "point density corner count");
@@ -309,8 +322,9 @@ static void pointdensity_cache_vertex_color(PointDensity *pd,
* All the corners share the same vertex, ie. occupy the same point in space.
*/
for (i = 0; i < pd->totpoints; i++) {
- if (mcorners[i] > 0)
+ if (mcorners[i] > 0) {
mul_v3_fl(&data_color[i * 3], 1.0f / mcorners[i]);
+ }
}
MEM_freeN(mcorners);
@@ -329,13 +343,16 @@ static void pointdensity_cache_vertex_weight(PointDensity *pd,
BLI_assert(data_color);
mdef = CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT);
- if (!mdef)
+ if (!mdef) {
return;
+ }
mdef_index = defgroup_name_index(ob, pd->vertex_attribute_name);
- if (mdef_index < 0)
+ if (mdef_index < 0) {
mdef_index = ob->actdef - 1;
- if (mdef_index < 0)
+ }
+ if (mdef_index < 0) {
return;
+ }
for (i = 0, dv = mdef; i < totvert; ++i, ++dv, data_color += 3) {
MDeformWeight *dw;
@@ -459,8 +476,9 @@ static void cache_pointdensity(Depsgraph *depsgraph, Scene *scene, PointDensity
}
else if (pd->source == TEX_PD_OBJECT) {
Object *ob = pd->object;
- if (ob && ob->type == OB_MESH)
+ if (ob && ob->type == OB_MESH) {
pointdensity_cache_object(pd, ob);
+ }
}
}
@@ -520,16 +538,20 @@ static float density_falloff(PointDensityRangeData *pdr, int index, float square
density = sqrtf(dist);
break;
case TEX_PD_FALLOFF_PARTICLE_AGE:
- if (pdr->point_data_life)
+ if (pdr->point_data_life) {
density = dist * MIN2(pdr->point_data_life[index], 1.0f);
- else
+ }
+ else {
density = dist;
+ }
break;
case TEX_PD_FALLOFF_PARTICLE_VEL:
- if (pdr->point_data_velocity)
+ if (pdr->point_data_velocity) {
density = dist * len_v3(&pdr->point_data_velocity[index * 3]) * pdr->velscale;
- else
+ }
+ else {
density = dist;
+ }
break;
}
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 0140aa44645..9ca9472e571 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -62,14 +62,17 @@ static void render_result_views_free(RenderResult *res)
RenderView *rv = res->views.first;
BLI_remlink(&res->views, rv);
- if (rv->rect32)
+ if (rv->rect32) {
MEM_freeN(rv->rect32);
+ }
- if (rv->rectz)
+ if (rv->rectz) {
MEM_freeN(rv->rectz);
+ }
- if (rv->rectf)
+ if (rv->rectf) {
MEM_freeN(rv->rectf);
+ }
MEM_freeN(rv);
}
@@ -79,24 +82,30 @@ static void render_result_views_free(RenderResult *res)
void render_result_free(RenderResult *res)
{
- if (res == NULL)
+ if (res == NULL) {
return;
+ }
while (res->layers.first) {
RenderLayer *rl = res->layers.first;
- /* acolrect and scolrect are optionally allocated in shade_tile, only free here since it can be used for drawing */
- if (rl->acolrect)
+ /* acolrect and scolrect are optionally allocated in shade_tile,
+ * only free here since it can be used for drawing. */
+ if (rl->acolrect) {
MEM_freeN(rl->acolrect);
- if (rl->scolrect)
+ }
+ if (rl->scolrect) {
MEM_freeN(rl->scolrect);
- if (rl->display_buffer)
+ }
+ if (rl->display_buffer) {
MEM_freeN(rl->display_buffer);
+ }
while (rl->passes.first) {
RenderPass *rpass = rl->passes.first;
- if (rpass->rect)
+ if (rpass->rect) {
MEM_freeN(rpass->rect);
+ }
BLI_remlink(&rl->passes, rpass);
MEM_freeN(rpass);
}
@@ -106,16 +115,21 @@ void render_result_free(RenderResult *res)
render_result_views_free(res);
- if (res->rect32)
+ if (res->rect32) {
MEM_freeN(res->rect32);
- if (res->rectz)
+ }
+ if (res->rectz) {
MEM_freeN(res->rectz);
- if (res->rectf)
+ }
+ if (res->rectf) {
MEM_freeN(res->rectf);
- if (res->text)
+ }
+ if (res->text) {
MEM_freeN(res->text);
- if (res->error)
+ }
+ if (res->error) {
MEM_freeN(res->error);
+ }
BKE_stamp_data_free(res->stamp_data);
@@ -130,8 +144,9 @@ void render_result_free_list(ListBase *lb, RenderResult *rr)
for (; rr; rr = rrnext) {
rrnext = rr->next;
- if (lb && lb->first)
+ if (lb && lb->first) {
BLI_remlink(lb, rr);
+ }
render_result_free(rr);
}
@@ -144,8 +159,9 @@ void render_result_views_shallowcopy(RenderResult *dst, RenderResult *src)
{
RenderView *rview;
- if (dst == NULL || src == NULL)
+ if (dst == NULL || src == NULL) {
return;
+ }
for (rview = src->views.first; rview; rview = rview->next) {
RenderView *rv;
@@ -163,8 +179,9 @@ void render_result_views_shallowcopy(RenderResult *dst, RenderResult *src)
/* free the views created temporarily */
void render_result_views_shallowdelete(RenderResult *rr)
{
- if (rr == NULL)
+ if (rr == NULL) {
return;
+ }
while (rr->views.first) {
RenderView *rv = rr->views.first;
@@ -247,13 +264,15 @@ static RenderPass *render_layer_add_pass(RenderResult *rr,
if (STREQ(rpass->name, RE_PASSNAME_VECTOR)) {
/* initialize to max speed */
rect = rpass->rect;
- for (x = rectsize - 1; x >= 0; x--)
+ for (x = rectsize - 1; x >= 0; x--) {
rect[x] = PASS_VECTOR_MAX;
+ }
}
else if (STREQ(rpass->name, RE_PASSNAME_Z)) {
rect = rpass->rect;
- for (x = rectsize - 1; x >= 0; x--)
+ for (x = rectsize - 1; x >= 0; x--) {
rect[x] = 10e10;
+ }
}
}
@@ -287,8 +306,9 @@ RenderResult *render_result_new(Render *re,
rectx = BLI_rcti_size_x(partrct);
recty = BLI_rcti_size_y(partrct);
- if (rectx <= 0 || recty <= 0)
+ if (rectx <= 0 || recty <= 0) {
return NULL;
+ }
rr = MEM_callocN(sizeof(RenderResult), "new render result");
rr->rectx = rectx;
@@ -341,12 +361,15 @@ RenderResult *render_result_new(Render *re,
for (rv = rr->views.first; rv; rv = rv->next) {
const char *view = rv->name;
- if (viewname && viewname[0])
- if (!STREQ(view, viewname))
+ if (viewname && viewname[0]) {
+ if (!STREQ(view, viewname)) {
continue;
+ }
+ }
- if (rr->do_exr_tile)
+ if (rr->do_exr_tile) {
IMB_exr_add_view(rl->exrhandle, view);
+ }
#define RENDER_LAYER_ADD_PASS_SAFE(rr, rl, channels, name, viewname, chan_id) \
do { \
@@ -359,54 +382,78 @@ RenderResult *render_result_new(Render *re,
/* a renderlayer should always have a Combined pass*/
render_layer_add_pass(rr, rl, 4, "Combined", view, "RGBA");
- if (view_layer->passflag & SCE_PASS_Z)
+ if (view_layer->passflag & SCE_PASS_Z) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_Z, view, "Z");
- if (view_layer->passflag & SCE_PASS_VECTOR)
+ }
+ if (view_layer->passflag & SCE_PASS_VECTOR) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 4, RE_PASSNAME_VECTOR, view, "XYZW");
- if (view_layer->passflag & SCE_PASS_NORMAL)
+ }
+ if (view_layer->passflag & SCE_PASS_NORMAL) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_NORMAL, view, "XYZ");
- if (view_layer->passflag & SCE_PASS_UV)
+ }
+ if (view_layer->passflag & SCE_PASS_UV) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_UV, view, "UVA");
- if (view_layer->passflag & SCE_PASS_EMIT)
+ }
+ if (view_layer->passflag & SCE_PASS_EMIT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_EMIT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_AO)
+ }
+ if (view_layer->passflag & SCE_PASS_AO) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_AO, view, "RGB");
- if (view_layer->passflag & SCE_PASS_ENVIRONMENT)
+ }
+ if (view_layer->passflag & SCE_PASS_ENVIRONMENT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_ENVIRONMENT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_SHADOW)
+ }
+ if (view_layer->passflag & SCE_PASS_SHADOW) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SHADOW, view, "RGB");
- if (view_layer->passflag & SCE_PASS_INDEXOB)
+ }
+ if (view_layer->passflag & SCE_PASS_INDEXOB) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_INDEXOB, view, "X");
- if (view_layer->passflag & SCE_PASS_INDEXMA)
+ }
+ if (view_layer->passflag & SCE_PASS_INDEXMA) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_INDEXMA, view, "X");
- if (view_layer->passflag & SCE_PASS_MIST)
+ }
+ if (view_layer->passflag & SCE_PASS_MIST) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_MIST, view, "Z");
- if (rl->passflag & SCE_PASS_RAYHITS)
+ }
+ if (rl->passflag & SCE_PASS_RAYHITS) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 4, RE_PASSNAME_RAYHITS, view, "RGB");
- if (view_layer->passflag & SCE_PASS_DIFFUSE_DIRECT)
+ }
+ if (view_layer->passflag & SCE_PASS_DIFFUSE_DIRECT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_DIFFUSE_DIRECT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_DIFFUSE_INDIRECT)
+ }
+ if (view_layer->passflag & SCE_PASS_DIFFUSE_INDIRECT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_DIFFUSE_INDIRECT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_DIFFUSE_COLOR)
+ }
+ if (view_layer->passflag & SCE_PASS_DIFFUSE_COLOR) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_DIFFUSE_COLOR, view, "RGB");
- if (view_layer->passflag & SCE_PASS_GLOSSY_DIRECT)
+ }
+ if (view_layer->passflag & SCE_PASS_GLOSSY_DIRECT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_GLOSSY_DIRECT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_GLOSSY_INDIRECT)
+ }
+ if (view_layer->passflag & SCE_PASS_GLOSSY_INDIRECT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_GLOSSY_INDIRECT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_GLOSSY_COLOR)
+ }
+ if (view_layer->passflag & SCE_PASS_GLOSSY_COLOR) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_GLOSSY_COLOR, view, "RGB");
- if (view_layer->passflag & SCE_PASS_TRANSM_DIRECT)
+ }
+ if (view_layer->passflag & SCE_PASS_TRANSM_DIRECT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_TRANSM_DIRECT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_TRANSM_INDIRECT)
+ }
+ if (view_layer->passflag & SCE_PASS_TRANSM_INDIRECT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_TRANSM_INDIRECT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_TRANSM_COLOR)
+ }
+ if (view_layer->passflag & SCE_PASS_TRANSM_COLOR) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_TRANSM_COLOR, view, "RGB");
- if (view_layer->passflag & SCE_PASS_SUBSURFACE_DIRECT)
+ }
+ if (view_layer->passflag & SCE_PASS_SUBSURFACE_DIRECT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_DIRECT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_SUBSURFACE_INDIRECT)
+ }
+ if (view_layer->passflag & SCE_PASS_SUBSURFACE_INDIRECT) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_INDIRECT, view, "RGB");
- if (view_layer->passflag & SCE_PASS_SUBSURFACE_COLOR)
+ }
+ if (view_layer->passflag & SCE_PASS_SUBSURFACE_COLOR) {
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_COLOR, view, "RGB");
+ }
#undef RENDER_LAYER_ADD_PASS_SAFE
}
}
@@ -430,12 +477,15 @@ RenderResult *render_result_new(Render *re,
for (rv = rr->views.first; rv; rv = rv->next) {
const char *view = rv->name;
- if (viewname && viewname[0])
- if (strcmp(view, viewname) != 0)
+ if (viewname && viewname[0]) {
+ if (strcmp(view, viewname) != 0) {
continue;
+ }
+ }
- if (rr->do_exr_tile)
+ if (rr->do_exr_tile) {
IMB_exr_add_view(rl->exrhandle, view);
+ }
/* a renderlayer should always have a Combined pass */
render_layer_add_pass(rr, rl, 4, RE_PASSNAME_COMBINED, view, "RGBA");
@@ -503,15 +553,18 @@ void render_result_add_pass(RenderResult *rr,
for (rv = rr->views.first; rv; rv = rv->next) {
const char *view = rv->name;
- if (viewname && viewname[0] && !STREQ(view, viewname))
+ if (viewname && viewname[0] && !STREQ(view, viewname)) {
continue;
+ }
/* Ensure that the pass doesn't exist yet. */
for (rp = rl->passes.first; rp; rp = rp->next) {
- if (!STREQ(rp->name, name))
+ if (!STREQ(rp->name, name)) {
continue;
- if (!STREQ(rp->view, view))
+ }
+ if (!STREQ(rp->view, view)) {
continue;
+ }
break;
}
@@ -648,43 +701,54 @@ static int order_render_passes(const void *a, const void *b)
unsigned int passtype_b = passtype_from_name(rpb->name);
/* Render passes with default type always go first. */
- if (passtype_b && !passtype_a)
+ if (passtype_b && !passtype_a) {
return 1;
- if (passtype_a && !passtype_b)
+ }
+ if (passtype_a && !passtype_b) {
return 0;
+ }
if (passtype_a && passtype_b) {
- if (passtype_a > passtype_b)
+ if (passtype_a > passtype_b) {
return 1;
- else if (passtype_a < passtype_b)
+ }
+ else if (passtype_a < passtype_b) {
return 0;
+ }
}
else {
int cmp = strncmp(rpa->name, rpb->name, EXR_PASS_MAXNAME);
- if (cmp > 0)
+ if (cmp > 0) {
return 1;
- if (cmp < 0)
+ }
+ if (cmp < 0) {
return 0;
+ }
}
/* they have the same type */
/* left first */
- if (STREQ(rpa->view, STEREO_LEFT_NAME))
+ if (STREQ(rpa->view, STEREO_LEFT_NAME)) {
return 0;
- else if (STREQ(rpb->view, STEREO_LEFT_NAME))
+ }
+ else if (STREQ(rpb->view, STEREO_LEFT_NAME)) {
return 1;
+ }
/* right second */
- if (STREQ(rpa->view, STEREO_RIGHT_NAME))
+ if (STREQ(rpa->view, STEREO_RIGHT_NAME)) {
return 0;
- else if (STREQ(rpb->view, STEREO_RIGHT_NAME))
+ }
+ else if (STREQ(rpb->view, STEREO_RIGHT_NAME)) {
return 1;
+ }
/* remaining in ascending id order */
return (rpa->view_id < rpb->view_id);
}
-/* from imbuf, if a handle was returned and it's not a singlelayer multiview we convert this to render result */
+/* From imbuf, if a handle was returned and
+ * it's not a singlelayer multiview we convert this to render result. */
RenderResult *render_result_new_from_exr(
void *exrhandle, const char *colorspace, bool predivide, int rectx, int recty)
{
@@ -741,8 +805,9 @@ void render_result_views_new(RenderResult *rr, RenderData *rd)
/* check renderdata for amount of views */
if ((rd->scemode & R_MULTIVIEW)) {
for (srv = rd->views.first; srv; srv = srv->next) {
- if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
+ if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
continue;
+ }
render_result_view_new(rr, srv->name);
}
}
@@ -811,8 +876,9 @@ void render_result_merge(RenderResult *rr, RenderResult *rrpart)
for (rpass = rl->passes.first, rpassp = rlp->passes.first; rpass && rpassp;
rpass = rpass->next) {
/* renderresult have all passes, renderpart only the active view's passes */
- if (strcmp(rpassp->fullname, rpass->fullname) != 0)
+ if (strcmp(rpassp->fullname, rpass->fullname) != 0) {
continue;
+ }
do_merge_tile(rr, rrpart, rpass->rect, rpassp->rect, rpass->channels);
@@ -1011,8 +1077,9 @@ void render_result_single_layer_end(Render *re)
return;
}
- if (!re->pushedresult)
+ if (!re->pushedresult) {
return;
+ }
if (re->pushedresult->rectx == re->result->rectx &&
re->pushedresult->recty == re->result->recty) {
@@ -1240,8 +1307,9 @@ void render_result_exr_file_end(Render *re, RenderEngine *engine)
/* save part into exr file */
void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart, const char *viewname)
{
- for (; rr && rrpart; rr = rr->next, rrpart = rrpart->next)
+ for (; rr && rrpart; rr = rr->next, rrpart = rrpart->next) {
save_render_result_tile(rr, rrpart, viewname);
+ }
}
/* path to temporary exr file */
@@ -1280,17 +1348,20 @@ int render_result_exr_file_read_path(RenderResult *rr,
}
if (rr == NULL || rectx != rr->rectx || recty != rr->recty) {
- if (rr)
+ if (rr) {
printf("error in reading render result: dimensions don't match\n");
- else
+ }
+ else {
printf("error in reading render result: NULL result pointer\n");
+ }
IMB_exr_close(exrhandle);
return 0;
}
for (rl = rr->layers.first; rl; rl = rl->next) {
- if (rl_single && rl_single != rl)
+ if (rl_single && rl_single != rl) {
continue;
+ }
/* passes are allocated in sync */
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
@@ -1436,8 +1507,9 @@ void RE_render_result_rect_from_ibuf(RenderResult *rr,
if (ibuf->rect_float) {
rr->have_combined = true;
- if (!rv->rectf)
+ if (!rv->rectf) {
rv->rectf = MEM_mallocN(4 * sizeof(float) * rr->rectx * rr->recty, "render_seq rectf");
+ }
memcpy(rv->rectf, ibuf->rect_float, 4 * sizeof(float) * rr->rectx * rr->recty);
@@ -1448,8 +1520,9 @@ void RE_render_result_rect_from_ibuf(RenderResult *rr,
else if (ibuf->rect) {
rr->have_combined = true;
- if (!rv->rect32)
+ if (!rv->rect32) {
rv->rect32 = MEM_mallocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
+ }
memcpy(rv->rect32, ibuf->rect, 4 * rr->rectx * rr->recty);
@@ -1462,12 +1535,15 @@ void render_result_rect_fill_zero(RenderResult *rr, const int view_id)
{
RenderView *rv = RE_RenderViewGetById(rr, view_id);
- if (rv->rectf)
+ if (rv->rectf) {
memset(rv->rectf, 0, 4 * sizeof(float) * rr->rectx * rr->recty);
- else if (rv->rect32)
+ }
+ else if (rv->rect32) {
memset(rv->rect32, 0, 4 * rr->rectx * rr->recty);
- else
+ }
+ else {
rv->rect32 = MEM_callocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
+ }
}
void render_result_rect_get_pixels(RenderResult *rr,
@@ -1480,9 +1556,10 @@ void render_result_rect_get_pixels(RenderResult *rr,
{
RenderView *rv = RE_RenderViewGetById(rr, view_id);
- if (rv->rect32)
+ if (rv->rect32) {
memcpy(rect, rv->rect32, sizeof(int) * rr->rectx * rr->recty);
- else if (rv->rectf)
+ }
+ else if (rv->rectf) {
IMB_display_buffer_transform_apply((unsigned char *)rect,
rv->rectf,
rr->rectx,
@@ -1491,9 +1568,11 @@ void render_result_rect_get_pixels(RenderResult *rr,
view_settings,
display_settings,
true);
- else
+ }
+ else {
/* else fill with black */
memset(rect, 0, sizeof(int) * rectx * recty);
+ }
}
/*************************** multiview functions *****************************/
@@ -1502,12 +1581,14 @@ bool RE_HasCombinedLayer(RenderResult *res)
{
RenderView *rv;
- if (res == NULL)
+ if (res == NULL) {
return false;
+ }
rv = res->views.first;
- if (rv == NULL)
+ if (rv == NULL) {
return false;
+ }
return (rv->rect32 || rv->rectf);
}
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 0400ad7ee95..67555b70be2 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -121,17 +121,21 @@ static int blend(Tex *tex, const float texvec[3], TexResult *texres)
}
else if (tex->stype == TEX_QUAD) { /* quad */
texres->tin = (1.0f + x) / 2.0f;
- if (texres->tin < 0.0f)
+ if (texres->tin < 0.0f) {
texres->tin = 0.0f;
- else
+ }
+ else {
texres->tin *= texres->tin;
+ }
}
else if (tex->stype == TEX_EASE) { /* ease */
texres->tin = (1.0f + x) / 2.0f;
- if (texres->tin <= 0.0f)
+ if (texres->tin <= 0.0f) {
texres->tin = 0.0f;
- else if (texres->tin >= 1.0f)
+ }
+ else if (texres->tin >= 1.0f) {
texres->tin = 1.0f;
+ }
else {
t = texres->tin * texres->tin;
texres->tin = (3.0f * t - 2.0f * t * texres->tin);
@@ -145,10 +149,12 @@ static int blend(Tex *tex, const float texvec[3], TexResult *texres)
}
else { /* sphere TEX_SPHERE */
texres->tin = 1.0f - sqrtf(x * x + y * y + texvec[2] * texvec[2]);
- if (texres->tin < 0.0f)
+ if (texres->tin < 0.0f) {
texres->tin = 0.0f;
- if (tex->stype == TEX_HALO)
+ }
+ if (tex->stype == TEX_HALO) {
texres->tin *= texres->tin; /* halo */
+ }
}
BRICONT;
@@ -244,8 +250,9 @@ static float tex_saw(float a)
int n = (int)(a / b);
a -= n * b;
- if (a < 0)
+ if (a < 0) {
a += b;
+ }
return a / b;
}
@@ -264,18 +271,19 @@ static float tex_tri(float a)
static float wood_int(Tex *tex, float x, float y, float z)
{
float wi = 0;
- short wf =
- tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
- short wt =
- tex->stype; /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
+ /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
+ short wf = tex->noisebasis2;
+ /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
+ short wt = tex->stype;
float (*waveform[3])(float); /* create array of pointers to waveform functions */
waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
waveform[1] = tex_saw;
waveform[2] = tex_tri;
- if ((wf > TEX_TRI) || (wf < TEX_SIN))
+ if ((wf > TEX_TRI) || (wf < TEX_SIN)) {
wf = 0; /* check to be sure noisebasis2 is initialized ahead of time */
+ }
if (wt == TEX_BAND) {
wi = waveform[wf]((x + y + z) * 10.0f);
@@ -329,8 +337,9 @@ static float marble_int(Tex *tex, float x, float y, float z)
waveform[1] = tex_saw;
waveform[2] = tex_tri;
- if ((wf > TEX_TRI) || (wf < TEX_SIN))
+ if ((wf > TEX_TRI) || (wf < TEX_SIN)) {
wf = 0; /* check to be sure noisebasis2 isn't initialized ahead of time */
+ }
n = 5.0f * (x + y + z);
@@ -469,8 +478,9 @@ static int stucci(Tex *tex, const float texvec[3], TexResult *texres)
ofs = tex->turbul / 200.0f;
- if (tex->stype)
+ if (tex->stype) {
ofs *= (b2 * b2);
+ }
nor[0] = BLI_gNoise(tex->noisesize,
texvec[0] + ofs,
texvec[1],
@@ -506,11 +516,13 @@ static int stucci(Tex *tex, const float texvec[3], TexResult *texres)
retval |= TEX_NOR;
}
- if (tex->stype == TEX_WALLOUT)
+ if (tex->stype == TEX_WALLOUT) {
texres->tin = 1.0f - texres->tin;
+ }
- if (texres->tin < 0.0f)
+ if (texres->tin < 0.0f) {
texres->tin = 0.0f;
+ }
return retval;
}
@@ -523,10 +535,12 @@ static float mg_mFractalOrfBmTex(Tex *tex, const float texvec[3], TexResult *tex
int rv = TEX_INT;
float (*mgravefunc)(float, float, float, float, float, float, int);
- if (tex->stype == TEX_MFRACTAL)
+ if (tex->stype == TEX_MFRACTAL) {
mgravefunc = mg_MultiFractal;
- else
+ }
+ else {
mgravefunc = mg_fBm;
+ }
texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
texvec[1],
@@ -576,10 +590,12 @@ static float mg_ridgedOrHybridMFTex(Tex *tex, const float texvec[3], TexResult *
int rv = TEX_INT;
float (*mgravefunc)(float, float, float, float, float, float, float, float, int);
- if (tex->stype == TEX_RIDGEDMF)
+ if (tex->stype == TEX_RIDGEDMF) {
mgravefunc = mg_RidgedMultiFractal;
- else
+ }
+ else {
mgravefunc = mg_HybridMultiFractal;
+ }
texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
texvec[1],
@@ -723,7 +739,10 @@ static float mg_distNoiseTex(Tex *tex, const float texvec[3], TexResult *texres)
}
/* ------------------------------------------------------------------------- */
-/* newnoise: Voronoi texture type, probably the slowest, especially with minkovsky, bumpmapping, could be done another way */
+/* newnoise: Voronoi texture type
+ *
+ * probably the slowest, especially with minkovsky, bumpmapping, could be done another way.
+ */
static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
{
@@ -734,8 +753,9 @@ static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
float aw3 = fabsf(tex->vn_w3);
float aw4 = fabsf(tex->vn_w4);
float sc = (aw1 + aw2 + aw3 + aw4);
- if (sc != 0.f)
+ if (sc != 0.f) {
sc = tex->ns_outscale / sc;
+ }
voronoi(texvec[0], texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
texres->tin = sc * fabsf(tex->vn_w1 * da[0] + tex->vn_w2 * da[1] + tex->vn_w3 * da[2] +
@@ -761,12 +781,15 @@ static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
texres->tb += aw4 * ca[2];
if (tex->vn_coltype >= 2) {
float t1 = (da[1] - da[0]) * 10;
- if (t1 > 1)
+ if (t1 > 1) {
t1 = 1;
- if (tex->vn_coltype == 3)
+ }
+ if (tex->vn_coltype == 3) {
t1 *= texres->tin;
- else
+ }
+ else {
t1 *= sc;
+ }
texres->tr *= t1;
texres->tg *= t1;
texres->tb *= t1;
@@ -892,10 +915,12 @@ static void do_2d_mapping(
fx = (texvec[0] + 1.0f) / 2.0f;
fy = (texvec[1] + 1.0f) / 2.0f;
}
- else if (wrap == MTEX_TUBE)
+ else if (wrap == MTEX_TUBE) {
map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
- else if (wrap == MTEX_SPHERE)
+ }
+ else if (wrap == MTEX_SPHERE) {
map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
+ }
else {
cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
}
@@ -905,29 +930,35 @@ static void do_2d_mapping(
if (tex->xrepeat > 1) {
float origf = fx *= tex->xrepeat;
- if (fx > 1.0f)
+ if (fx > 1.0f) {
fx -= (int)(fx);
- else if (fx < 0.0f)
+ }
+ else if (fx < 0.0f) {
fx += 1 - (int)(fx);
+ }
if (tex->flag & TEX_REPEAT_XMIR) {
int orig = (int)floor(origf);
- if (orig & 1)
+ if (orig & 1) {
fx = 1.0f - fx;
+ }
}
}
if (tex->yrepeat > 1) {
float origf = fy *= tex->yrepeat;
- if (fy > 1.0f)
+ if (fy > 1.0f) {
fy -= (int)(fy);
- else if (fy < 0.0f)
+ }
+ else if (fy < 0.0f) {
fy += 1 - (int)(fy);
+ }
if (tex->flag & TEX_REPEAT_YMIR) {
int orig = (int)floor(origf);
- if (orig & 1)
+ if (orig & 1) {
fy = 1.0f - fy;
+ }
}
}
}
@@ -991,10 +1022,12 @@ static void do_2d_mapping(
areaflag = 1;
}
else {
- if (wrap == MTEX_TUBE)
+ if (wrap == MTEX_TUBE) {
map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
- else
+ }
+ else {
map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
+ }
dxt[0] /= 2.0f;
dxt[1] /= 2.0f;
dyt[0] /= 2.0f;
@@ -1046,15 +1079,18 @@ static void do_2d_mapping(
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
if (tex->texfilter == TXF_BOX) {
- if (fx > 1.0f)
+ if (fx > 1.0f) {
fx -= (int)(fx);
- else if (fx < 0.0f)
+ }
+ else if (fx < 0.0f) {
fx += 1 - (int)(fx);
+ }
if (tex->flag & TEX_REPEAT_XMIR) {
int orig = (int)floor(origf);
- if (orig & 1)
+ if (orig & 1) {
fx = 1.0f - fx;
+ }
}
}
@@ -1068,20 +1104,24 @@ static void do_2d_mapping(
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
if (tex->texfilter == TXF_BOX) {
- if (fy > 1.0f)
+ if (fy > 1.0f) {
fy -= (int)(fy);
- else if (fy < 0.0f)
+ }
+ else if (fy < 0.0f) {
fy += 1 - (int)(fy);
+ }
if (tex->flag & TEX_REPEAT_YMIR) {
int orig = (int)floor(origf);
- if (orig & 1)
+ if (orig & 1) {
fy = 1.0f - fy;
+ }
}
}
- if (max < tex->yrepeat)
+ if (max < tex->yrepeat) {
max = tex->yrepeat;
+ }
dxt[1] *= tex->yrepeat;
dyt[1] *= tex->yrepeat;
@@ -1172,11 +1212,13 @@ static int multitex(Tex *tex,
retval = texnoise(tex, texres, thread);
break;
case TEX_IMAGE:
- if (osatex)
+ if (osatex) {
retval = imagewraposa(
tex, tex->ima, NULL, texvec, dxt, dyt, texres, pool, skip_load_image);
- else
+ }
+ else {
retval = imagewrap(tex, tex->ima, NULL, texvec, texres, pool, skip_load_image);
+ }
if (tex->ima) {
BKE_image_tag_time(tex->ima);
}
@@ -1260,8 +1302,9 @@ static int multitex_nodes_intern(Tex *tex,
return 0;
}
- if (mtex)
+ if (mtex) {
which_output = mtex->which_output;
+ }
if (tex->type == TEX_IMAGE) {
int rgbnor;
@@ -1387,8 +1430,10 @@ int multitex_nodes(Tex *tex,
true);
}
-/* Warning, if the texres's values are not declared zero, check the return value to be sure
- * the color values are set before using the r/g/b values, otherwise you may use uninitialized values - Campbell
+/**
+ * \warning if the texres's values are not declared zero,
+ * check the return value to be sure the color values are set before using the r/g/b values,
+ * otherwise you may use uninitialized values - Campbell
*
* Use it for stuff which is out of render pipeline.
*/
@@ -1485,18 +1530,24 @@ void texture_rgb_blend(
fact *= facg;
facm = 1.0f - fact;
- if (out[0] < 0.5f)
+ if (out[0] < 0.5f) {
in[0] = out[0] * (facm + 2.0f * fact * tex[0]);
- else
+ }
+ else {
in[0] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[0])) * (1.0f - out[0]);
- if (out[1] < 0.5f)
+ }
+ if (out[1] < 0.5f) {
in[1] = out[1] * (facm + 2.0f * fact * tex[1]);
- else
+ }
+ else {
in[1] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[1])) * (1.0f - out[1]);
- if (out[2] < 0.5f)
+ }
+ if (out[2] < 0.5f) {
in[2] = out[2] * (facm + 2.0f * fact * tex[2]);
- else
+ }
+ else {
in[2] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[2])) * (1.0f - out[2]);
+ }
break;
case MTEX_SUB:
@@ -1513,12 +1564,15 @@ void texture_rgb_blend(
fact *= facg;
facm = 1.0f - fact;
- if (tex[0] != 0.0f)
+ if (tex[0] != 0.0f) {
in[0] = facm * out[0] + fact * out[0] / tex[0];
- if (tex[1] != 0.0f)
+ }
+ if (tex[1] != 0.0f) {
in[1] = facm * out[1] + fact * out[1] / tex[1];
- if (tex[2] != 0.0f)
+ }
+ if (tex[2] != 0.0f) {
in[2] = facm * out[2] + fact * out[2] / tex[2];
+ }
break;
@@ -1589,8 +1643,9 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
fact *= facg;
facm = 1.0f - fact;
- if (flip)
+ if (flip) {
SWAP(float, fact, facm);
+ }
switch (blendtype) {
case MTEX_BLEND:
@@ -1609,10 +1664,12 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
case MTEX_OVERLAY:
facm = 1.0f - facg;
- if (out < 0.5f)
+ if (out < 0.5f) {
in = out * (facm + 2.0f * fact * tex);
- else
+ }
+ else {
in = 1.0f - (facm + 2.0f * fact * (1.0f - tex)) * (1.0f - out);
+ }
break;
case MTEX_SUB:
@@ -1623,8 +1680,9 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
break;
case MTEX_DIV:
- if (tex != 0.0f)
+ if (tex != 0.0f) {
in = facm * out + fact * out / tex;
+ }
break;
case MTEX_DIFF:
@@ -1637,10 +1695,12 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
case MTEX_LIGHT:
col = fact * tex;
- if (col > out)
+ if (col > out) {
in = col;
- else
+ }
+ else {
in = out;
+ }
break;
case MTEX_SOFT_LIGHT:
@@ -1649,10 +1709,12 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
break;
case MTEX_LIN_LIGHT:
- if (tex > 0.5f)
+ if (tex > 0.5f) {
in = out + fact * (2.0f * (tex - 0.5f));
- else
+ }
+ else {
in = out + fact * (2.0f * tex - 1.0f);
+ }
break;
}
@@ -1679,25 +1741,32 @@ int externtex(const MTex *mtex,
int rgb;
tex = mtex->tex;
- if (tex == NULL)
+ if (tex == NULL) {
return 0;
+ }
texr.nor = NULL;
/* placement */
- if (mtex->projx)
+ if (mtex->projx) {
texvec[0] = mtex->size[0] * (vec[mtex->projx - 1] + mtex->ofs[0]);
- else
+ }
+ else {
texvec[0] = mtex->size[0] * (mtex->ofs[0]);
+ }
- if (mtex->projy)
+ if (mtex->projy) {
texvec[1] = mtex->size[1] * (vec[mtex->projy - 1] + mtex->ofs[1]);
- else
+ }
+ else {
texvec[1] = mtex->size[1] * (mtex->ofs[1]);
+ }
- if (mtex->projz)
+ if (mtex->projz) {
texvec[2] = mtex->size[2] * (vec[mtex->projz - 1] + mtex->ofs[2]);
- else
+ }
+ else {
texvec[2] = mtex->size[2] * (mtex->ofs[2]);
+ }
/* texture */
if (tex->type == TEX_IMAGE) {
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index e8c97661547..d74ab330dc2 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -56,10 +56,12 @@ void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty)
void zbuf_free_span(ZSpan *zspan)
{
if (zspan) {
- if (zspan->span1)
+ if (zspan->span1) {
MEM_freeN(zspan->span1);
- if (zspan->span2)
+ }
+ if (zspan->span2) {
MEM_freeN(zspan->span2);
+ }
zspan->span1 = zspan->span2 = NULL;
}
}
@@ -91,18 +93,22 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
my0 = ceil(minv[1]);
my2 = floor(maxv[1]);
- if (my2 < 0 || my0 >= zspan->recty)
+ if (my2 < 0 || my0 >= zspan->recty) {
return;
+ }
/* clip top */
- if (my2 >= zspan->recty)
+ if (my2 >= zspan->recty) {
my2 = zspan->recty - 1;
+ }
/* clip bottom */
- if (my0 < 0)
+ if (my0 < 0) {
my0 = 0;
+ }
- if (my0 > my2)
+ if (my0 > my2) {
return;
+ }
/* if (my0>my2) should still fill in, that way we get spans that skip nicely */
xx1 = maxv[1] - minv[1];
@@ -136,10 +142,12 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) {
zspan->maxp1 = maxv;
}
- if (my0 < zspan->miny1)
+ if (my0 < zspan->miny1) {
zspan->miny1 = my0;
- if (my2 > zspan->maxy1)
+ }
+ if (my2 > zspan->maxy1) {
zspan->maxy1 = my2;
+ }
}
else {
// printf("right span my0 %d my2 %d\n", my0, my2);
@@ -149,10 +157,12 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) {
zspan->maxp2 = maxv;
}
- if (my0 < zspan->miny2)
+ if (my0 < zspan->miny2) {
zspan->miny2 = my0;
- if (my2 > zspan->maxy2)
+ }
+ if (my2 > zspan->maxy2) {
zspan->maxy2 = my2;
+ }
}
for (y = my2; y >= my0; y--, xs0 += dx0) {
@@ -165,7 +175,8 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
/* Functions */
/*-----------------------------------------------------------*/
-/* scanconvert for strand triangles, calls func for each x, y coordinate and gives UV barycentrics and z */
+/* Scanconvert for strand triangles, calls func for each x, y coordinate
+ * and gives UV barycentrics and z. */
void zspan_scanconvert(ZSpan *zspan,
void *handle,
@@ -188,15 +199,17 @@ void zspan_scanconvert(ZSpan *zspan,
zbuf_add_to_span(zspan, v3, v1);
/* clipped */
- if (zspan->minp2 == NULL || zspan->maxp2 == NULL)
+ if (zspan->minp2 == NULL || zspan->maxp2 == NULL) {
return;
+ }
my0 = max_ii(zspan->miny1, zspan->miny2);
my2 = min_ii(zspan->maxy1, zspan->maxy2);
// printf("my %d %d\n", my0, my2);
- if (my2 < my0)
+ if (my2 < my0) {
return;
+ }
/* ZBUF DX DY, in floats still */
x1 = v1[0] - v2[0];
@@ -211,8 +224,9 @@ void zspan_scanconvert(ZSpan *zspan,
y0 = z1 * x2 - x1 * z2;
z0 = x1 * y2 - y1 * x2;
- if (z0 == 0.0f)
+ if (z0 == 0.0f) {
return;
+ }
xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + 1.0f;
uxd = -(double)x0 / (double)z0;
@@ -240,10 +254,12 @@ void zspan_scanconvert(ZSpan *zspan,
sn2 = floor(max_ff(*span1, *span2));
sn1++;
- if (sn2 >= rectx)
+ if (sn2 >= rectx) {
sn2 = rectx - 1;
- if (sn1 < 0)
+ }
+ if (sn1 < 0) {
sn1 = 0;
+ }
u = (((double)sn1 * uxd) + uy0) - (i * uyd);
v = (((double)sn1 * vxd) + vy0) - (i * vyd);
diff --git a/source/blender/shader_fx/CMakeLists.txt b/source/blender/shader_fx/CMakeLists.txt
index 7d36e8836fd..57c7345076e 100644
--- a/source/blender/shader_fx/CMakeLists.txt
+++ b/source/blender/shader_fx/CMakeLists.txt
@@ -22,17 +22,17 @@
set(INC
.
intern
+ ../blenfont
../blenkernel
../blenlib
- ../blenfont
+ ../bmesh
../depsgraph
../makesdna
../makesrna
- ../bmesh
../render/extern/include
../../../intern/elbeem/extern
- ../../../intern/guardedalloc
../../../intern/eigen
+ ../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index d6107033eb7..7e53c652ab5 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -39,8 +39,8 @@ set(INC
../render/extern/include
../../../intern/clog
../../../intern/ghost
- ../../../intern/guardedalloc
../../../intern/glew-mx
+ ../../../intern/guardedalloc
../../../intern/memutil
)
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index af6f2559cae..f1037dadf85 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -208,12 +208,13 @@ int WM_userdef_event_type_from_keymap_type(int kmitype);
/* handlers */
+typedef bool (*EventHandlerPoll)(const ARegion *ar, const struct wmEvent *event);
struct wmEventHandler_Keymap *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
-/* boundbox, optional subwindow boundbox for offset */
-struct wmEventHandler_Keymap *WM_event_add_keymap_handler_bb(ListBase *handlers,
- wmKeyMap *keymap,
- const rcti *bb,
- const rcti *swinbb);
+struct wmEventHandler_Keymap *WM_event_add_keymap_handler_poll(ListBase *handlers,
+ wmKeyMap *keymap,
+ EventHandlerPoll poll);
+struct wmEventHandler_Keymap *WM_event_add_keymap_handler_v2d_mask(ListBase *handlers,
+ wmKeyMap *keymap);
/* priority not implemented, it adds in begin */
struct wmEventHandler_Keymap *WM_event_add_keymap_handler_priority(ListBase *handlers,
wmKeyMap *keymap,
@@ -635,7 +636,8 @@ enum {
WM_JOB_SUSPEND = (1 << 3),
};
-/* identifying jobs by owner alone is unreliable, this isnt saved, order can change (keep 0 for 'any') */
+/** Identifying jobs by owner alone is unreliable, this isnt saved,
+ * order can change (keep 0 for 'any'). */
enum {
WM_JOB_TYPE_ANY = 0,
WM_JOB_TYPE_COMPOSITE,
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 06e970d8ba1..53488cd1f71 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -149,11 +149,11 @@ void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname);
/* Keymap Editor */
void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C);
-void WM_keymap_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties);
-void WM_keymap_restore_item_to_default(struct bContext *C,
+void WM_keymap_item_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties);
+void WM_keymap_item_restore_to_default(struct bContext *C,
struct wmKeyMap *keymap,
struct wmKeyMapItem *kmi);
-int WM_keymap_map_type_get(struct wmKeyMapItem *kmi);
+int WM_keymap_item_map_type_get(const struct wmKeyMapItem *kmi);
/* Key Event */
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 7eee8da1ecf..154c4837a68 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -427,7 +427,8 @@ typedef struct wmGesture {
int modal_state;
/* For modal operators which may be running idle, waiting for an event to activate the gesture.
- * Typically this is set when the user is click-dragging the gesture (border and circle select for eg). */
+ * Typically this is set when the user is click-dragging the gesture
+ * (border and circle select for eg). */
uint is_active : 1;
/* Previous value of is-active (use to detect first run & edge cases). */
uint is_active_prev : 1;
@@ -457,8 +458,8 @@ typedef struct wmEvent {
int x, y; /* mouse pointer position, screen coord */
int mval[2]; /* region mouse position, name convention pre 2.5 :) */
char utf8_buf[6]; /* from, ghost if utf8 is enabled for the platform,
- * BLI_str_utf8_size() must _always_ be valid, check
- * when assigning s we don't need to check on every access after */
+ * BLI_str_utf8_size() must _always_ be valid, check
+ * when assigning s we don't need to check on every access after */
char ascii; /* from ghost, fallback if utf8 isn't set */
char pad;
@@ -526,7 +527,8 @@ typedef enum { /* motion progress, for modal handlers */
typedef struct wmNDOFMotionData {
/* awfully similar to GHOST_TEventNDOFMotionData... */
/* Each component normally ranges from -1 to +1, but can exceed that.
- * These use blender standard view coordinates, with positive rotations being CCW about the axis. */
+ * These use blender standard view coordinates,
+ * with positive rotations being CCW about the axis. */
float tvec[3]; /* translation */
float rvec[3]; /* rotation: */
/* axis = (rx,ry,rz).normalized */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
index 997afb1dc6c..e2e5096ef99 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c
@@ -462,7 +462,8 @@ bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *gzmap, wmGizmo *gz)
/**
* Special function to run from setup so gizmos start out interactive.
*
- * We could do this when linking them, but this complicates things since the window update code needs to run first.
+ * We could do this when linking them,
+ * but this complicates things since the window update code needs to run first.
*/
void WM_gizmo_modal_set_from_setup(struct wmGizmoMap *gzmap,
struct bContext *C,
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index b37991ec8cd..5aecab122a2 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -188,7 +188,8 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo(const wmGizmoGroup *gzgroup,
}
/**
- * Adds all gizmos of \a gzgroup that can be selected to the head of \a listbase. Added items need freeing!
+ * Adds all gizmos of \a gzgroup that can be selected to the head of \a listbase.
+ * Added items need freeing!
*/
void wm_gizmogroup_intersectable_gizmos_to_list(const wmGizmoGroup *gzgroup, ListBase *listbase)
{
@@ -219,7 +220,8 @@ void WM_gizmogroup_ensure_init(const bContext *C, wmGizmoGroup *gzgroup)
gzgroup->init_flag |= WM_GIZMOGROUP_INIT_SETUP;
}
- /* refresh may be called multiple times, this just ensures its called at least once before we draw. */
+ /* Refresh may be called multiple times,
+ * this just ensures its called at least once before we draw. */
if (UNLIKELY((gzgroup->init_flag & WM_GIZMOGROUP_INIT_REFRESH) == 0)) {
if (gzgroup->type->refresh) {
gzgroup->type->refresh(C, gzgroup);
@@ -237,7 +239,8 @@ bool WM_gizmo_group_type_poll(const bContext *C, const struct wmGizmoGroupType *
return false;
}
}
- /* Check for poll function, if gizmo-group belongs to an operator, also check if the operator is running. */
+ /* Check for poll function, if gizmo-group belongs to an operator,
+ * also check if the operator is running. */
return (!gzgt->poll || gzgt->poll(C, (wmGizmoGroupType *)gzgt));
}
@@ -679,7 +682,8 @@ static wmKeyMap *gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char
*/
wmKeyMap *WM_gizmogroup_keymap_common(const wmGizmoGroupType *gzgt, wmKeyConfig *config)
{
- /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */
+ /* Use area and region id since we might have multiple gizmos
+ * with the same name in different areas/regions. */
wmKeyMap *km = WM_keymap_ensure(
config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid);
@@ -694,7 +698,8 @@ wmKeyMap *WM_gizmogroup_keymap_common(const wmGizmoGroupType *gzgt, wmKeyConfig
*/
wmKeyMap *WM_gizmogroup_keymap_common_select(const wmGizmoGroupType *gzgt, wmKeyConfig *config)
{
- /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */
+ /* Use area and region id since we might have multiple gizmos
+ * with the same name in different areas/regions. */
wmKeyMap *km = WM_keymap_ensure(
config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid);
/* FIXME(campbell) */
@@ -759,7 +764,8 @@ struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(struct wmGizmoMapType *gz
}
/**
- * Use this for registering gizmos on startup. For runtime, use #WM_gizmomaptype_group_link_runtime.
+ * Use this for registering gizmos on startup.
+ * For runtime, use #WM_gizmomaptype_group_link_runtime.
*/
wmGizmoGroupTypeRef *WM_gizmomaptype_group_link(wmGizmoMapType *gzmap_type, const char *idname)
{
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 33c58f8563d..31c5e1fb94c 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -369,8 +369,9 @@ static void gizmomap_prepare_drawing(wmGizmoMap *gzmap,
continue;
}
- /* needs to be initialized on first draw */
- /* XXX weak: Gizmo-group may skip refreshing if it's invisible (map gets untagged nevertheless) */
+ /* Needs to be initialized on first draw. */
+ /* XXX weak: Gizmo-group may skip refreshing if it's invisible
+ * (map gets untagged nevertheless). */
if (gzmap->update_flag[drawstep] & GIZMOMAP_IS_REFRESH_CALLBACK) {
/* force refresh again. */
gzgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH;
@@ -402,8 +403,9 @@ static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBas
return;
}
- /* TODO this will need it own shader probably? don't think it can be handled from that point though. */
- /* const bool use_lighting = (U.gizmo_flag & V3D_GIZMO_SHADED) != 0; */
+ /* TODO(campbell): This will need it own shader probably?
+ * Don't think it can be handled from that point though. */
+ /* const bool use_lighting = (U.gizmo_flag & V3D_GIZMO_SHADED) != 0; */
bool is_depth_prev = false;
@@ -414,7 +416,8 @@ static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBas
bool is_depth = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0;
- /* Weak! since we don't 100% support depth yet (select ignores depth) always show highlighted */
+ /* Weak! since we don't 100% support depth yet (select ignores depth)
+ * always show highlighted. */
if (is_depth && (gz->state & WM_GIZMO_STATE_HIGHLIGHT)) {
is_depth = false;
}
@@ -472,7 +475,8 @@ static void gizmo_draw_select_3D_loop(const bContext *C,
int select_id = 0;
wmGizmo *gz;
- /* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */
+ /* TODO(campbell): this depends on depth buffer being written to,
+ * currently broken for the 3D view. */
bool is_depth_prev = false;
bool is_depth_skip_prev = false;
@@ -806,8 +810,7 @@ static bool wm_gizmomap_select_all_intern(bContext *C, wmGizmoMap *gzmap)
wm_gizmomap_select_array_ensure_len_alloc(gzmap, BLI_ghash_len(hash));
- GHASH_ITER_INDEX(gh_iter, hash, i)
- {
+ GHASH_ITER_INDEX (gh_iter, hash, i) {
wmGizmo *gz_iter = BLI_ghashIterator_getValue(&gh_iter);
WM_gizmo_select_set(gzmap, gz_iter, true);
}
@@ -905,6 +908,7 @@ bool WM_gizmomap_cursor_set(const wmGizmoMap *gzmap, wmWindow *win)
bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz, int part)
{
if ((gz != gzmap->gzmap_context.highlight) || (gz && part != gz->highlight_part)) {
+ const bool init_last_cursor = (gzmap->gzmap_context.highlight == NULL);
if (gzmap->gzmap_context.highlight) {
gzmap->gzmap_context.highlight->state &= ~WM_GIZMO_STATE_HIGHLIGHT;
gzmap->gzmap_context.highlight->highlight_part = -1;
@@ -915,11 +919,15 @@ bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz
if (gz) {
gz->state |= WM_GIZMO_STATE_HIGHLIGHT;
gz->highlight_part = part;
- gzmap->gzmap_context.last_cursor = -1;
+ if (init_last_cursor) {
+ gzmap->gzmap_context.last_cursor = -1;
+ }
if (C && gz->type->cursor_get) {
wmWindow *win = CTX_wm_window(C);
- gzmap->gzmap_context.last_cursor = win->cursor;
+ if (init_last_cursor) {
+ gzmap->gzmap_context.last_cursor = win->cursor;
+ }
WM_cursor_set(win, gz->type->cursor_get(gz));
}
}
@@ -928,6 +936,7 @@ bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz
wmWindow *win = CTX_wm_window(C);
WM_cursor_set(win, gzmap->gzmap_context.last_cursor);
}
+ gzmap->gzmap_context.last_cursor = -1;
}
/* tag the region for redraw */
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 45f56968a32..58cfc350b17 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -386,13 +386,17 @@ void WM_cursor_time(wmWindow *win, int nr)
* I define 2 pretty brain-dead macros so it's obvious what the extra "[]"
* are for */
-#define BEGIN_CURSOR_BLOCK {
-#define END_CURSOR_BLOCK }
+#define BEGIN_CURSOR_BLOCK \
+ { \
+ ((void)0)
+#define END_CURSOR_BLOCK \
+ } \
+ ((void)0)
void wm_init_cursor_data(void)
{
/********************** NW_ARROW Cursor **************************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char nw_sbm[] = {
0x03, 0x00, 0x05, 0x00, 0x09, 0x00, 0x11, 0x00, 0x21, 0x00, 0x41,
0x00, 0x81, 0x00, 0x01, 0x01, 0x01, 0x02, 0xc1, 0x03, 0x49, 0x00,
@@ -426,10 +430,10 @@ void wm_init_cursor_data(void)
};
BlenderCursor[BC_NW_ARROWCURSOR] = &NWArrowCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
///********************** NS_ARROW Cursor *************************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char ns_sbm[] = {
0x40, 0x01, 0x20, 0x02, 0x10, 0x04, 0x08, 0x08, 0x04, 0x10, 0x3c,
0x1e, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x3c, 0x1e,
@@ -464,9 +468,9 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_NS_ARROWCURSOR] = &NSArrowCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** EW_ARROW Cursor *************************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char ew_sbm[] = {
0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x38, 0x1c, 0x2c, 0x34, 0xe6,
0x67, 0x03, 0xc0, 0x01, 0x80, 0x03, 0xc0, 0xe6, 0x67, 0x2c, 0x34,
@@ -500,10 +504,10 @@ void wm_init_cursor_data(void)
};
BlenderCursor[BC_EW_ARROWCURSOR] = &EWArrowCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Wait Cursor *****************************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char wait_sbm[] = {
0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0x84, 0x21, 0xc8, 0x13, 0xd0,
0x0b, 0xa0, 0x04, 0x20, 0x05, 0xa0, 0x04, 0x10, 0x09, 0x88, 0x11,
@@ -561,10 +565,10 @@ void wm_init_cursor_data(void)
};
BlenderCursor[BC_WAITCURSOR] = &WaitCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Cross Cursor ***************************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char cross_sbm[] = {
0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80,
0x01, 0x80, 0x01, 0x7e, 0x7e, 0x7e, 0x7e, 0x80, 0x01, 0x80, 0x01,
@@ -621,10 +625,10 @@ void wm_init_cursor_data(void)
};
BlenderCursor[BC_CROSSCURSOR] = &CrossCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** EditCross Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char editcross_sbm[] = {
0x0e, 0x00, 0x11, 0x00, 0x1d, 0x00, 0x19, 0x03, 0x1d, 0x03, 0x11,
0x03, 0x0e, 0x03, 0x00, 0x03, 0xf8, 0x7c, 0xf8, 0x7c, 0x00, 0x03,
@@ -658,10 +662,10 @@ void wm_init_cursor_data(void)
};
BlenderCursor[BC_EDITCROSSCURSOR] = &EditCrossCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Box Select *************************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char box_sbm[32] = {
0x7f, 0x00, 0x41, 0x00, 0x41, 0x00, 0x41, 0x06, 0x41, 0x06, 0x41,
0x06, 0x7f, 0x06, 0x00, 0x06, 0xe0, 0x79, 0xe0, 0x79, 0x00, 0x06,
@@ -696,9 +700,9 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_BOXSELCURSOR] = &BoxSelCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Knife Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char knife_sbm[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x2c, 0x00, 0x5a, 0x00,
0x34, 0x00, 0x2a, 0x00, 0x17, 0x80, 0x06, 0x40, 0x03, 0xa0, 0x03,
@@ -757,10 +761,10 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_KNIFECURSOR] = &KnifeCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Loop Select Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char vloop_sbm[] = {
0x00, 0x00, 0x7e, 0x00, 0x3e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x66,
@@ -820,10 +824,10 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_VLOOPCURSOR] = &VLoopCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** TextEdit Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char textedit_sbm[] = {
0xe0, 0x03, 0x10, 0x04, 0x60, 0x03, 0x40, 0x01, 0x40, 0x01, 0x40,
0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
@@ -857,10 +861,10 @@ void wm_init_cursor_data(void)
};
BlenderCursor[BC_TEXTEDITCURSOR] = &TextEditCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Paintbrush Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char paintbrush_sbm[] = {
0x00, 0xe0, 0x00, 0x98, 0x00, 0x44, 0x00, 0x42, 0x00, 0x21, 0x80,
@@ -895,10 +899,10 @@ void wm_init_cursor_data(void)
};
BlenderCursor[BC_PAINTBRUSHCURSOR] = &PaintBrushCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Hand Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char hand_sbm[] = {
0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x0d, 0x98, 0x6d, 0x98,
@@ -934,10 +938,10 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_HANDCURSOR] = &HandCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** NSEW Scroll Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char nsewscroll_sbm[] = {
0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03, 0x00, 0x00, 0x00,
@@ -973,10 +977,10 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_NSEW_SCROLLCURSOR] = &NSEWScrollCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** NS Scroll Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char nsscroll_sbm[] = {
0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xc0, 0x03, 0x00, 0x00, 0x00,
@@ -1012,10 +1016,10 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_NS_SCROLLCURSOR] = &NSScrollCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** EW Scroll Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char ewscroll_sbm[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -1051,10 +1055,10 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_EW_SCROLLCURSOR] = &EWScrollCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Eyedropper Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char eyedropper_sbm[] = {
0x00, 0x30, 0x00, 0x48, 0x00, 0x85, 0x80, 0x82, 0x40, 0x40, 0x80,
@@ -1090,10 +1094,10 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_EYEDROPPER_CURSOR] = &EyedropperCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Swap Area Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
static char swap_sbm[] = {
0xc0, 0xff, 0x40, 0x80, 0x40, 0x80, 0x40, 0x9c, 0x40, 0x98, 0x40,
0x94, 0x00, 0x82, 0xfe, 0x80, 0x7e, 0xfd, 0xbe, 0x01, 0xda, 0x01,
@@ -1128,18 +1132,22 @@ void wm_init_cursor_data(void)
BlenderCursor[BC_SWAPAREA_CURSOR] = &SwapCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Horizontal Split Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
- static char hsplit_sbm[] = {0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x88,
- 0x08, 0x8C, 0x18, 0x8E, 0x38, 0x8C, 0x18, 0x88, 0x08, 0x80, 0x00,
- 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00};
+ static char hsplit_sbm[] = {
+ 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x88,
+ 0x08, 0x8C, 0x18, 0x8E, 0x38, 0x8C, 0x18, 0x88, 0x08, 0x80, 0x00,
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
- static char hsplit_smsk[] = {0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xD0, 0x05, 0xD8, 0x0D, 0xDC,
- 0x1D, 0xDE, 0x3D, 0xDF, 0x7D, 0xDE, 0x3D, 0xDC, 0x1D, 0xD8, 0x0D,
- 0xD0, 0x05, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0x00, 0x00};
+ static char hsplit_smsk[] = {
+ 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xD0, 0x05, 0xD8, 0x0D, 0xDC,
+ 0x1D, 0xDE, 0x3D, 0xDF, 0x7D, 0xDE, 0x3D, 0xDC, 0x1D, 0xD8, 0x0D,
+ 0xD0, 0x05, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0x00, 0x00,
+ };
static char hsplit_lbm[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01,
@@ -1163,38 +1171,44 @@ void wm_init_cursor_data(void)
0xC8, 0x03, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0xC0, 0x03, 0x00,
0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00};
- static BCursor HSplitCursor = {/*small*/
- hsplit_sbm,
- hsplit_smsk,
- 16,
- 16,
- 7,
- 7,
- /*big*/
- hsplit_lbm,
- hsplit_lmsk,
- 32,
- 32,
- 15,
- 15,
- /*color*/
- BC_BLACK,
- BC_WHITE};
+ static BCursor HSplitCursor = {
+ /*small*/
+ hsplit_sbm,
+ hsplit_smsk,
+ 16,
+ 16,
+ 7,
+ 7,
+ /*big*/
+ hsplit_lbm,
+ hsplit_lmsk,
+ 32,
+ 32,
+ 15,
+ 15,
+ /*color*/
+ BC_BLACK,
+ BC_WHITE,
+ };
BlenderCursor[BC_H_SPLITCURSOR] = &HSplitCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Vertical Split Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
- static char vsplit_sbm[] = {0x00, 0x00, 0x80, 0x00, 0xC0, 0x01, 0xE0, 0x03, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xFE, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00};
+ static char vsplit_sbm[] = {
+ 0x00, 0x00, 0x80, 0x00, 0xC0, 0x01, 0xE0, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xFE, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
- static char vsplit_smsk[] = {0x80, 0x00, 0xC0, 0x01, 0xE0, 0x03, 0xF0, 0x07, 0xF8, 0x0F, 0x00,
- 0x00, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0x00, 0x00, 0xF8, 0x0F,
- 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00};
+ static char vsplit_smsk[] = {
+ 0x80, 0x00, 0xC0, 0x01, 0xE0, 0x03, 0xF0, 0x07, 0xF8, 0x0F, 0x00,
+ 0x00, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0x00, 0x00, 0xF8, 0x0F,
+ 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00,
+ };
static char vsplit_lbm[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
@@ -1218,38 +1232,44 @@ void wm_init_cursor_data(void)
0xF8, 0x0F, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0xE0, 0x03, 0x00, 0x00, 0xC0, 0x01, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- static BCursor VSplitCursor = {/*small*/
- vsplit_sbm,
- vsplit_smsk,
- 16,
- 16,
- 7,
- 7,
- /*big*/
- vsplit_lbm,
- vsplit_lmsk,
- 32,
- 32,
- 15,
- 15,
- /*color*/
- BC_BLACK,
- BC_WHITE};
+ static BCursor VSplitCursor = {
+ /*small*/
+ vsplit_sbm,
+ vsplit_smsk,
+ 16,
+ 16,
+ 7,
+ 7,
+ /*big*/
+ vsplit_lbm,
+ vsplit_lmsk,
+ 32,
+ 32,
+ 15,
+ 15,
+ /*color*/
+ BC_BLACK,
+ BC_WHITE,
+ };
BlenderCursor[BC_V_SPLITCURSOR] = &VSplitCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** North Arrow Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
- static char narrow_sbm[] = {0x00, 0x00, 0x80, 0x00, 0xC0, 0x01, 0xE0, 0x03, 0xF0, 0x07, 0xF8,
- 0x0F, 0xFC, 0x1F, 0xE0, 0x03, 0xE0, 0x03, 0xE0, 0x03, 0xE0, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ static char narrow_sbm[] = {
+ 0x00, 0x00, 0x80, 0x00, 0xC0, 0x01, 0xE0, 0x03, 0xF0, 0x07, 0xF8,
+ 0x0F, 0xFC, 0x1F, 0xE0, 0x03, 0xE0, 0x03, 0xE0, 0x03, 0xE0, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
- static char narrow_smsk[] = {0x80, 0x00, 0xC0, 0x01, 0xE0, 0x03, 0xF0, 0x07, 0xF8, 0x0F, 0xFC,
- 0x1F, 0xFE, 0x3F, 0xFF, 0x7F, 0xF0, 0x07, 0xF0, 0x07, 0xF0, 0x07,
- 0xF0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ static char narrow_smsk[] = {
+ 0x80, 0x00, 0xC0, 0x01, 0xE0, 0x03, 0xF0, 0x07, 0xF8, 0x0F, 0xFC,
+ 0x1F, 0xFE, 0x3F, 0xFF, 0x7F, 0xF0, 0x07, 0xF0, 0x07, 0xF0, 0x07,
+ 0xF0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
static char narrow_lbm[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xC0, 0x01,
@@ -1273,38 +1293,44 @@ void wm_init_cursor_data(void)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- static BCursor NArrowCursor = {/*small*/
- narrow_sbm,
- narrow_smsk,
- 16,
- 16,
- 7,
- 4,
- /*big*/
- narrow_lbm,
- narrow_lmsk,
- 32,
- 32,
- 15,
- 10,
- /*color*/
- BC_BLACK,
- BC_WHITE};
+ static BCursor NArrowCursor = {
+ /*small*/
+ narrow_sbm,
+ narrow_smsk,
+ 16,
+ 16,
+ 7,
+ 4,
+ /*big*/
+ narrow_lbm,
+ narrow_lmsk,
+ 32,
+ 32,
+ 15,
+ 10,
+ /*color*/
+ BC_BLACK,
+ BC_WHITE,
+ };
BlenderCursor[BC_N_ARROWCURSOR] = &NArrowCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** South Arrow Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
- static char sarrow_sbm[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0,
- 0x03, 0xE0, 0x03, 0xE0, 0x03, 0xE0, 0x03, 0xFC, 0x1F, 0xF8, 0x0F,
- 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00};
+ static char sarrow_sbm[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0,
+ 0x03, 0xE0, 0x03, 0xE0, 0x03, 0xE0, 0x03, 0xFC, 0x1F, 0xF8, 0x0F,
+ 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00,
+ };
- static char sarrow_smsk[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x07, 0xF0,
- 0x07, 0xF0, 0x07, 0xF0, 0x07, 0xFF, 0x7F, 0xFE, 0x3F, 0xFC, 0x1F,
- 0xF8, 0x0F, 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00};
+ static char sarrow_smsk[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x07, 0xF0,
+ 0x07, 0xF0, 0x07, 0xF0, 0x07, 0xFF, 0x7F, 0xFE, 0x3F, 0xFC, 0x1F,
+ 0xF8, 0x0F, 0xF0, 0x07, 0xE0, 0x03, 0xC0, 0x01, 0x80, 0x00,
+ };
static char sarrow_lbm[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -1328,38 +1354,44 @@ void wm_init_cursor_data(void)
0xFC, 0x1F, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0xF0, 0x07, 0x00, 0x00, 0xE0, 0x03, 0x00,
0x00, 0xC0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00};
- static BCursor SArrowCursor = {/*small*/
- sarrow_sbm,
- sarrow_smsk,
- 16,
- 16,
- 7,
- 11,
- /*big*/
- sarrow_lbm,
- sarrow_lmsk,
- 32,
- 32,
- 15,
- 21,
- /*color*/
- BC_BLACK,
- BC_WHITE};
+ static BCursor SArrowCursor = {
+ /*small*/
+ sarrow_sbm,
+ sarrow_smsk,
+ 16,
+ 16,
+ 7,
+ 11,
+ /*big*/
+ sarrow_lbm,
+ sarrow_lmsk,
+ 32,
+ 32,
+ 15,
+ 21,
+ /*color*/
+ BC_BLACK,
+ BC_WHITE,
+ };
BlenderCursor[BC_S_ARROWCURSOR] = &SArrowCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** East Arrow Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
- static char earrow_sbm[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x0E, 0xE0,
- 0x1F, 0xE0, 0x3F, 0xE0, 0x7F, 0xE0, 0x3F, 0xE0, 0x1F, 0x00, 0x0E,
- 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ static char earrow_sbm[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x0E, 0xE0,
+ 0x1F, 0xE0, 0x3F, 0xE0, 0x7F, 0xE0, 0x3F, 0xE0, 0x1F, 0x00, 0x0E,
+ 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
- static char earrow_smsk[] = {0x00, 0x01, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0F, 0xF0, 0x1F, 0xF0,
- 0x3F, 0xF0, 0x7F, 0xF0, 0xFF, 0xF0, 0x7F, 0xF0, 0x3F, 0xF0, 0x1F,
- 0x00, 0x0F, 0x00, 0x07, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00};
+ static char earrow_smsk[] = {
+ 0x00, 0x01, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0F, 0xF0, 0x1F, 0xF0,
+ 0x3F, 0xF0, 0x7F, 0xF0, 0xFF, 0xF0, 0x7F, 0xF0, 0x3F, 0xF0, 0x1F,
+ 0x00, 0x0F, 0x00, 0x07, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00,
+ };
static char earrow_lbm[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
@@ -1383,38 +1415,44 @@ void wm_init_cursor_data(void)
0x00, 0x1F, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00};
- static BCursor EArrowCursor = {/*small*/
- earrow_sbm,
- earrow_smsk,
- 16,
- 16,
- 11,
- 7,
- /*big*/
- earrow_lbm,
- earrow_lmsk,
- 32,
- 32,
- 15,
- 22,
- /*color*/
- BC_BLACK,
- BC_WHITE};
+ static BCursor EArrowCursor = {
+ /*small*/
+ earrow_sbm,
+ earrow_smsk,
+ 16,
+ 16,
+ 11,
+ 7,
+ /*big*/
+ earrow_lbm,
+ earrow_lmsk,
+ 32,
+ 32,
+ 15,
+ 22,
+ /*color*/
+ BC_BLACK,
+ BC_WHITE,
+ };
BlenderCursor[BC_E_ARROWCURSOR] = &EArrowCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** West Arrow Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
- static char warrow_sbm[] = {0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 0x70, 0x00, 0xF8,
- 0x07, 0xFC, 0x07, 0xFE, 0x07, 0xFC, 0x07, 0xF8, 0x07, 0x70, 0x00,
- 0x60, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ static char warrow_sbm[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 0x70, 0x00, 0xF8,
+ 0x07, 0xFC, 0x07, 0xFE, 0x07, 0xFC, 0x07, 0xF8, 0x07, 0x70, 0x00,
+ 0x60, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
- static char warrow_smsk[] = {0x80, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF8, 0x0F, 0xFC,
- 0x0F, 0xFE, 0x0F, 0xFF, 0x0F, 0xFE, 0x0F, 0xFC, 0x0F, 0xF8, 0x0F,
- 0xF0, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0x80, 0x00, 0x00, 0x00};
+ static char warrow_smsk[] = {
+ 0x80, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF8, 0x0F, 0xFC,
+ 0x0F, 0xFE, 0x0F, 0xFF, 0x0F, 0xFE, 0x0F, 0xFC, 0x0F, 0xF8, 0x0F,
+ 0xF0, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0x80, 0x00, 0x00, 0x00,
+ };
static char warrow_lbm[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
@@ -1438,38 +1476,44 @@ void wm_init_cursor_data(void)
0xF8, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- static BCursor WArrowCursor = {/*small*/
- warrow_sbm,
- warrow_smsk,
- 16,
- 16,
- 4,
- 7,
- /*big*/
- warrow_lbm,
- warrow_lmsk,
- 32,
- 32,
- 15,
- 15,
- /*color*/
- BC_BLACK,
- BC_WHITE};
+ static BCursor WArrowCursor = {
+ /*small*/
+ warrow_sbm,
+ warrow_smsk,
+ 16,
+ 16,
+ 4,
+ 7,
+ /*big*/
+ warrow_lbm,
+ warrow_lmsk,
+ 32,
+ 32,
+ 15,
+ 15,
+ /*color*/
+ BC_BLACK,
+ BC_WHITE,
+ };
BlenderCursor[BC_W_ARROWCURSOR] = &WArrowCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Stop Sign Cursor ***********************/
- BEGIN_CURSOR_BLOCK
+ BEGIN_CURSOR_BLOCK;
- static char stop_sbm[] = {0x00, 0x00, 0xE0, 0x07, 0x38, 0x1C, 0x1C, 0x30, 0x3C, 0x20, 0x76,
- 0x60, 0xE2, 0x40, 0xC2, 0x41, 0x82, 0x43, 0x02, 0x47, 0x06, 0x6E,
- 0x04, 0x3C, 0x0C, 0x38, 0x38, 0x1C, 0xE0, 0x07, 0x00, 0x00};
+ static char stop_sbm[] = {
+ 0x00, 0x00, 0xE0, 0x07, 0x38, 0x1C, 0x1C, 0x30, 0x3C, 0x20, 0x76,
+ 0x60, 0xE2, 0x40, 0xC2, 0x41, 0x82, 0x43, 0x02, 0x47, 0x06, 0x6E,
+ 0x04, 0x3C, 0x0C, 0x38, 0x38, 0x1C, 0xE0, 0x07, 0x00, 0x00,
+ };
- static char stop_smsk[] = {0xE0, 0x07, 0xF8, 0x1F, 0xFC, 0x3F, 0x3E, 0x7C, 0x7E, 0x70, 0xFF,
- 0xF0, 0xF7, 0xE1, 0xE7, 0xE3, 0xC7, 0xE7, 0x87, 0xEF, 0x0F, 0xFF,
- 0x0E, 0x7E, 0x3E, 0x7C, 0xFC, 0x3F, 0xF8, 0x1F, 0xE0, 0x07};
+ static char stop_smsk[] = {
+ 0xE0, 0x07, 0xF8, 0x1F, 0xFC, 0x3F, 0x3E, 0x7C, 0x7E, 0x70, 0xFF,
+ 0xF0, 0xF7, 0xE1, 0xE7, 0xE3, 0xC7, 0xE7, 0x87, 0xEF, 0x0F, 0xFF,
+ 0x0E, 0x7E, 0x3E, 0x7C, 0xFC, 0x3F, 0xF8, 0x1F, 0xE0, 0x07,
+ };
static char stop_lbm[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0x00, 0xFE, 0x7F, 0x00, 0x00, 0x0F, 0xF0,
@@ -1493,27 +1537,29 @@ void wm_init_cursor_data(void)
0x03, 0xC0, 0x0F, 0xE0, 0x1F, 0xF8, 0x07, 0xC0, 0xFF, 0xFF, 0x03, 0x80, 0xFF, 0xFF, 0x01,
0x00, 0xFE, 0x7F, 0x00, 0x00, 0xF0, 0x0F, 0x00};
- static BCursor StopCursor = {/*small*/
- stop_sbm,
- stop_smsk,
- 16,
- 16,
- 7,
- 7,
- /*big*/
- stop_lbm,
- stop_lmsk,
- 32,
- 32,
- 15,
- 15,
- /*color*/
- BC_BLACK,
- BC_WHITE};
+ static BCursor StopCursor = {
+ /*small*/
+ stop_sbm,
+ stop_smsk,
+ 16,
+ 16,
+ 7,
+ 7,
+ /*big*/
+ stop_lbm,
+ stop_lmsk,
+ 32,
+ 32,
+ 15,
+ 15,
+ /*color*/
+ BC_BLACK,
+ BC_WHITE,
+ };
BlenderCursor[BC_STOPCURSOR] = &StopCursor;
- END_CURSOR_BLOCK
+ END_CURSOR_BLOCK;
/********************** Put the cursors in the array ***********************/
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index c31f78339a8..13b6260e2b9 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -69,6 +69,7 @@
#include "RNA_access.h"
#include "UI_interface.h"
+#include "UI_view2d.h"
#include "PIL_time.h"
@@ -123,7 +124,8 @@ wmEvent *wm_event_add_ex(wmWindow *win,
BLI_addtail(&win->queue, event);
}
else {
- /* note, strictly speaking this breaks const-correctness, however we're only changing 'next' member */
+ /* Note: strictly speaking this breaks const-correctness,
+ * however we're only changing 'next' member. */
BLI_insertlinkafter(&win->queue, (void *)event_to_add_after, event);
}
return event;
@@ -354,7 +356,8 @@ void wm_event_do_depsgraph(bContext *C)
}
/**
- * Was part of #wm_event_do_notifiers, split out so it can be called once before entering the #WM_main loop.
+ * Was part of #wm_event_do_notifiers,
+ * split out so it can be called once before entering the #WM_main loop.
* This ensures operators don't run before the UI and depsgraph are initialized.
*/
void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
@@ -504,7 +507,12 @@ void wm_event_do_notifiers(bContext *C)
/* XXX context in notifiers? */
CTX_wm_window_set(C, win);
- /* printf("notifier win %d screen %s cat %x\n", win->winid, win->screen->id.name + 2, note->category); */
+# if 0
+ printf("notifier win %d screen %s cat %x\n",
+ win->winid,
+ win->screen->id.name + 2,
+ note->category);
+# endif
ED_screen_do_listen(C, note);
for (ar = screen->regionbase.first; ar; ar = ar->next) {
@@ -633,8 +641,7 @@ static void wm_handler_ui_cancel(bContext *C)
return;
}
- LISTBASE_FOREACH_MUTABLE(wmEventHandler *, handler_base, &ar->handlers)
- {
+ LISTBASE_FOREACH_MUTABLE (wmEventHandler *, handler_base, &ar->handlers) {
if (handler_base->type == WM_HANDLER_TYPE_UI) {
wmEventHandler_UI *handler = (wmEventHandler_UI *)handler_base;
BLI_assert(handler->handle_fn != NULL);
@@ -1031,9 +1038,9 @@ static int wm_operator_exec(bContext *C,
}
}
- /* XXX Disabled the repeat check to address part 2 of #31840.
- * Carefully checked all calls to wm_operator_exec and WM_operator_repeat, don't see any reason
- * why this was needed, but worth to note it in case something turns bad. (mont29) */
+ /* XXX(mont29) Disabled the repeat check to address part 2 of T31840.
+ * Carefully checked all calls to wm_operator_exec and WM_operator_repeat, don't see any reason
+ * why this was needed, but worth to note it in case something turns bad. */
if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED) /* && repeat == 0 */) {
wm_operator_reports(C, op, retval, false);
}
@@ -1362,7 +1369,8 @@ static int wm_operator_invoke(bContext *C,
{
int retval = OPERATOR_PASS_THROUGH;
- /* this is done because complicated setup is done to call this function that is better not duplicated */
+ /* This is done because complicated setup is done to call this function
+ * that is better not duplicated. */
if (poll_only) {
return WM_operator_poll(C, ot);
}
@@ -1422,8 +1430,8 @@ static int wm_operator_invoke(bContext *C,
CLOG_ERROR(WM_LOG_OPERATORS, "invalid operator call '%s'", op->idname);
}
- /* Note, if the report is given as an argument then assume the caller will deal with displaying them
- * currently python only uses this */
+ /* Note, if the report is given as an argument then assume the caller will deal with displaying
+ * them currently Python only uses this. */
if (!(retval & OPERATOR_HANDLED) && (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED))) {
/* only show the report if the report list was not given in the function */
wm_operator_reports(C, op, retval, (reports != NULL));
@@ -1463,7 +1471,7 @@ static int wm_operator_invoke(bContext *C,
/* exception, cont. grab in header is annoying */
if (wrap) {
ARegion *ar = CTX_wm_region(C);
- if (ar && ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_FOOTER)) {
+ if (ar && ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER)) {
wrap = false;
}
}
@@ -1716,7 +1724,9 @@ int WM_operator_call_py(bContext *C,
wm->op_undo_depth--;
}
else {
- CLOG_WARN(WM_LOG_OPERATORS, "\"%s\" operator has no exec function, Python cannot call it", op->type->name);
+ CLOG_WARN(WM_LOG_OPERATORS,
+ "\"%s\" operator has no exec function, Python cannot call it",
+ op->type->name);
}
#endif
@@ -1990,8 +2000,9 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi)
}
}
- /* only keymap entry with keymodifier is checked, means all keys without modifier get handled too. */
- /* that is currently needed to make overlapping events work (when you press A - G fast or so). */
+ /* Only keymap entry with keymodifier is checked,
+ * means all keys without modifier get handled too. */
+ /* That is currently needed to make overlapping events work (when you press A - G fast or so). */
if (kmi->keymodifier) {
if (winevent->keymodifier != kmi->keymodifier) {
return false;
@@ -2192,7 +2203,7 @@ static int wm_handler_operator_call(bContext *C,
wm_event_free_handler(&handler->head);
/* prevent silly errors from operator users */
- //retval &= ~OPERATOR_PASS_THROUGH;
+ // retval &= ~OPERATOR_PASS_THROUGH;
}
}
}
@@ -2272,7 +2283,8 @@ static int wm_handler_operator_call(bContext *C,
return WM_HANDLER_BREAK;
}
-/* fileselect handlers are only in the window queue, so it's safe to switch screens or area types */
+/* Fileselect handlers are only in the window queue,
+ * so it's safe to switch screens or area types. */
static int wm_handler_fileselect_do(bContext *C,
ListBase *handlers,
wmEventHandler_Op *handler,
@@ -2458,38 +2470,6 @@ static int wm_handler_fileselect_call(bContext *C,
return wm_handler_fileselect_do(C, handlers, handler, event->val);
}
-static bool handler_boundbox_test(wmEventHandler *handler, const wmEvent *event)
-{
- if (handler->bbwin) {
- if (handler->bblocal) {
- rcti rect = *handler->bblocal;
- BLI_rcti_translate(&rect, handler->bbwin->xmin, handler->bbwin->ymin);
-
- if (BLI_rcti_isect_pt_v(&rect, &event->x)) {
- return 1;
- }
- else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt_v(&rect, &event->prevx)) {
- return 1;
- }
- else {
- return 0;
- }
- }
- else {
- if (BLI_rcti_isect_pt_v(handler->bbwin, &event->x)) {
- return 1;
- }
- else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt_v(handler->bbwin, &event->prevx)) {
- return 1;
- }
- else {
- return 0;
- }
- }
- }
- return 1;
-}
-
static int wm_action_not_handled(int action)
{
return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL);
@@ -2528,7 +2508,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
if (handler_base->flag & WM_HANDLER_DO_FREE) {
/* pass */
}
- else if (handler_boundbox_test(handler_base, event)) { /* optional boundbox */
+ else if (handler_base->poll == NULL || handler_base->poll(CTX_wm_region(C), event)) {
/* in advance to avoid access to freed event on window close */
always_pass = wm_event_always_pass(event);
@@ -2940,15 +2920,23 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
return action;
}
-static int wm_event_inside_i(wmEvent *event, rcti *rect)
+static bool wm_event_inside_rect(const wmEvent *event, const rcti *rect)
{
if (wm_event_always_pass(event)) {
- return 1;
+ return true;
}
if (BLI_rcti_isect_pt_v(rect, &event->x)) {
- return 1;
+ return true;
}
- return 0;
+ return false;
+}
+
+static bool wm_event_inside_region(const wmEvent *event, const ARegion *ar)
+{
+ if (wm_event_always_pass(event)) {
+ return true;
+ }
+ return ED_region_contains_xy(ar, &event->x);
}
static ScrArea *area_event_inside(bContext *C, const int xy[2])
@@ -3174,7 +3162,8 @@ void wm_event_do_handlers(bContext *C)
CTX_wm_area_set(C, area_event_inside(C, &event->x));
CTX_wm_region_set(C, region_event_inside(C, &event->x));
- /* MVC demands to not draw in event handlers... but we need to leave it for ogl selecting etc */
+ /* MVC demands to not draw in event handlers...
+ * but we need to leave it for ogl selecting etc. */
wm_window_make_drawable(wm, win);
wm_region_mouse_co(C, event);
@@ -3207,7 +3196,8 @@ void wm_event_do_handlers(bContext *C)
/* Note: setting subwin active should be done here, after modal handlers have been done */
if (event->type == MOUSEMOVE) {
- /* state variables in screen, cursors. Also used in wm_draw.c, fails for modal handlers though */
+ /* State variables in screen, cursors.
+ * Also used in wm_draw.c, fails for modal handlers though. */
ED_screen_set_active_region(C, win, &event->x);
/* for regions having custom cursors */
wm_paintcursor_test(C, event);
@@ -3233,12 +3223,13 @@ void wm_event_do_handlers(bContext *C)
ED_area_azones_update(sa, &event->x);
}
- if (wm_event_inside_i(event, &sa->totrct)) {
+ if (wm_event_inside_rect(event, &sa->totrct)) {
CTX_wm_area_set(C, sa);
if ((action & WM_HANDLER_BREAK) == 0) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (wm_event_inside_i(event, &ar->winrct)) {
+ if (wm_event_inside_region(event, ar)) {
+
CTX_wm_region_set(C, ar);
/* call even on non mouse events, since the */
@@ -3274,7 +3265,8 @@ void wm_event_do_handlers(bContext *C)
}
CTX_wm_area_set(C, NULL);
- /* NOTE: do not escape on WM_HANDLER_BREAK, mousemove needs handled for previous area */
+ /* NOTE: do not escape on WM_HANDLER_BREAK,
+ * mousemove needs handled for previous area. */
}
}
@@ -3365,8 +3357,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
UI_popup_handlers_remove_all(C, &win->modalhandlers);
/* only allow 1 file selector open per window */
- LISTBASE_FOREACH_MUTABLE(wmEventHandler *, handler_base, &win->modalhandlers)
- {
+ LISTBASE_FOREACH_MUTABLE (wmEventHandler *, handler_base, &win->modalhandlers) {
if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
if (handler->is_fileselect == false) {
@@ -3464,7 +3455,8 @@ void WM_event_modal_handler_area_replace(wmWindow *win, const ScrArea *old_area,
LISTBASE_FOREACH (wmEventHandler *, handler_base, &win->modalhandlers) {
if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
- /* fileselect handler is quite special... it needs to keep old area stored in handler, so don't change it */
+ /* Fileselect handler is quite special...
+ * it needs to keep old area stored in handler, so don't change it. */
if ((handler->context.area == old_area) && (handler->is_fileselect == false)) {
handler->context.area = new_area;
}
@@ -3483,7 +3475,8 @@ void WM_event_modal_handler_region_replace(wmWindow *win,
LISTBASE_FOREACH (wmEventHandler *, handler_base, &win->modalhandlers) {
if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
- /* fileselect handler is quite special... it needs to keep old region stored in handler, so don't change it */
+ /* Fileselect handler is quite special...
+ * it needs to keep old region stored in handler, so don't change it. */
if ((handler->context.region == old_region) && (handler->is_fileselect == false)) {
handler->context.region = new_region;
handler->context.region_type = new_region ? new_region->regiontype : RGN_TYPE_WINDOW;
@@ -3583,20 +3576,44 @@ wmEventHandler_Keymap *WM_event_add_keymap_handler_priority(ListBase *handlers,
return handler;
}
-wmEventHandler_Keymap *WM_event_add_keymap_handler_bb(ListBase *handlers,
- wmKeyMap *keymap,
- const rcti *bblocal,
- const rcti *bbwin)
+static bool event_or_prev_in_rect(const wmEvent *event, const rcti *rect)
{
- wmEventHandler_Keymap *handler = WM_event_add_keymap_handler(handlers, keymap);
+ if (BLI_rcti_isect_pt(rect, event->x, event->y)) {
+ return true;
+ }
+ else if (event->type == MOUSEMOVE && BLI_rcti_isect_pt(rect, event->prevx, event->prevy)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+static bool handler_region_v2d_mask_test(const ARegion *ar, const wmEvent *event)
+{
+ rcti rect = ar->v2d.mask;
+ BLI_rcti_translate(&rect, ar->winrct.xmin, ar->winrct.ymin);
+ return event_or_prev_in_rect(event, &rect);
+}
- if (handler) {
- handler->head.bblocal = bblocal;
- handler->head.bbwin = bbwin;
+wmEventHandler_Keymap *WM_event_add_keymap_handler_poll(ListBase *handlers,
+ wmKeyMap *keymap,
+ EventHandlerPoll poll)
+{
+ wmEventHandler_Keymap *handler = WM_event_add_keymap_handler(handlers, keymap);
+ if (handler == NULL) {
+ return NULL;
}
+
+ handler->head.poll = poll;
return handler;
}
+wmEventHandler_Keymap *WM_event_add_keymap_handler_v2d_mask(ListBase *handlers, wmKeyMap *keymap)
+{
+ return WM_event_add_keymap_handler_poll(handlers, keymap, handler_region_v2d_mask_test);
+}
+
void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
{
LISTBASE_FOREACH (wmEventHandler *, handler_base, handlers) {
@@ -3683,8 +3700,7 @@ void WM_event_free_ui_handler_all(bContext *C,
wmUIHandlerFunc handle_fn,
wmUIHandlerRemoveFunc remove_fn)
{
- LISTBASE_FOREACH_MUTABLE(wmEventHandler *, handler_base, handlers)
- {
+ LISTBASE_FOREACH_MUTABLE (wmEventHandler *, handler_base, handlers) {
if (handler_base->type == WM_HANDLER_TYPE_UI) {
wmEventHandler_UI *handler = (wmEventHandler_UI *)handler_base;
if ((handler->handle_fn == handle_fn) && (handler->remove_fn == remove_fn)) {
@@ -3721,8 +3737,7 @@ wmEventHandler_Dropbox *WM_event_add_dropbox_handler(ListBase *handlers, ListBas
/* XXX solution works, still better check the real cause (ton) */
void WM_event_remove_area_handler(ListBase *handlers, void *area)
{
- LISTBASE_FOREACH_MUTABLE(wmEventHandler *, handler_base, handlers)
- {
+ LISTBASE_FOREACH_MUTABLE (wmEventHandler *, handler_base, handlers) {
if (handler_base->type == WM_HANDLER_TYPE_UI) {
wmEventHandler_UI *handler = (wmEventHandler_UI *)handler_base;
if (handler->context.area == area) {
@@ -4149,8 +4164,9 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
wmWindow *owin;
wmEventHandler *handler;
- /* let's skip windows having modal handlers now */
- /* potential XXX ugly... I wouldn't have added a modalhandlers list (introduced in rev 23331, ton) */
+ /* Let's skip windows having modal handlers now */
+ /* potential XXX ugly... I wouldn't have added a modalhandlers list
+ * (introduced in rev 23331, ton). */
for (handler = win->modalhandlers.first; handler; handler = handler->next) {
if (ELEM(handler->type, WM_HANDLER_TYPE_UI, WM_HANDLER_TYPE_OP)) {
return NULL;
@@ -4228,11 +4244,15 @@ void wm_event_add_ghostevent(
return;
}
- /* Having both, event and evt, can be highly confusing to work with, but is necessary for
- * our current event system, so let's clear things up a bit:
- * - data added to event only will be handled immediately, but will not be copied to the next event
- * - data added to evt only stays, but is handled with the next event -> execution delay
- * - data added to event and evt stays and is handled immediately
+ /**
+ * Having both, \a event and \a evt, can be highly confusing to work with,
+ * but is necessary for our current event system, so let's clear things up a bit:
+ *
+ * - Data added to event only will be handled immediately,
+ * but will not be copied to the next event.
+ * - Data added to \a evt only stays,
+ * but is handled with the next event -> execution delay.
+ * - Data added to event and \a evt stays and is handled immediately.
*/
wmEvent event, *evt = win->eventstate;
@@ -4344,7 +4364,8 @@ void wm_event_add_ghostevent(
if (win->active == 0) {
int cx, cy;
- /* entering window, update mouse pos. (ghost sends win-activate *after* the mouseclick in window!) */
+ /* Entering window, update mouse pos.
+ * (ghost sends win-activate *after* the mouseclick in window!) */
wm_get_cursor_position(win, &cx, &cy);
event.x = evt->x = cx;
@@ -4503,14 +4524,16 @@ void wm_event_add_ghostevent(
event.keymodifier = 0;
}
- /* this case happens with an external numpad, and also when using 'dead keys' (to compose complex latin
- * characters e.g.), it's not really clear why.
- * Since it's impossible to map a key modifier to an unknown key, it shouldn't harm to clear it. */
+ /* this case happens with an external numpad, and also when using 'dead keys'
+ * (to compose complex latin characters e.g.), it's not really clear why.
+ * Since it's impossible to map a key modifier to an unknown key,
+ * it shouldn't harm to clear it. */
if (event.keymodifier == UNKNOWNKEY) {
evt->keymodifier = event.keymodifier = 0;
}
- /* if test_break set, it catches this. Do not set with modifier presses. XXX Keep global for now? */
+ /* if test_break set, it catches this. Do not set with modifier presses.
+ * XXX Keep global for now? */
if ((event.type == ESCKEY && event.val == KM_PRESS) &&
/* check other modifiers because ms-windows uses these to bring up the task manager */
(event.shift == 0 && event.ctrl == 0 && event.alt == 0)) {
@@ -4771,7 +4794,7 @@ static wmKeyMapItem *wm_kmi_from_event(bContext *C,
if (handler_base->flag & WM_HANDLER_DO_FREE) {
/* pass */
}
- else if (handler_boundbox_test(handler_base, event)) { /* optional boundbox */
+ else if (handler_base->poll == NULL || handler_base->poll(CTX_wm_region(C), event)) {
if (handler_base->type == WM_HANDLER_TYPE_KEYMAP) {
wmEventHandler_Keymap *handler = (wmEventHandler_Keymap *)handler_base;
wmKeyMap *keymap = WM_event_get_keymap_from_handler(wm, handler);
@@ -4924,7 +4947,12 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win)
if (ELEM(sa->spacetype, SPACE_STATUSBAR, SPACE_TOPBAR)) {
return;
}
- if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_FOOTER, RGN_TYPE_TEMPORARY, RGN_TYPE_HUD)) {
+ if (ELEM(ar->regiontype,
+ RGN_TYPE_HEADER,
+ RGN_TYPE_TOOL_HEADER,
+ RGN_TYPE_FOOTER,
+ RGN_TYPE_TEMPORARY,
+ RGN_TYPE_HUD)) {
return;
}
/* Fallback to window. */
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a4e059effb4..6d90d4745a6 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -20,7 +20,8 @@
/** \file
* \ingroup wm
*
- * User level access for blend file read/write, file-history and userprefs (including relevant operators).
+ * User level access for blend file read/write, file-history and user-preferences
+ * (including relevant operators).
*/
/* placed up here because of crappy
@@ -40,7 +41,7 @@
# define _WIN32_IE 0x0400
# endif
/* For SHGetSpecialFolderPath, has to be done before BLI_winstuff
- * because 'near' is disabled through BLI_windstuff */
+ * because 'near' is disabled through BLI_windstuff */
# include <shlobj.h>
# include "BLI_winstuff.h"
#endif
@@ -169,11 +170,13 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
/* reset active window */
CTX_wm_window_set(C, active_win);
- /* XXX Hack! We have to clear context menu here, because removing all modalhandlers above frees the active menu
- * (at least, in the 'startup splash' case), causing use-after-free error in later handling of the button
- * callbacks in UI code (see ui_apply_but_funcs_after()).
- * Tried solving this by always NULL-ing context's menu when setting wm/win/etc., but it broke popups refreshing
- * (see T47632), so for now just handling this specific case here. */
+ /* XXX Hack! We have to clear context menu here, because removing all modalhandlers
+ * above frees the active menu (at least, in the 'startup splash' case),
+ * causing use-after-free error in later handling of the button callbacks in UI code
+ * (see ui_apply_but_funcs_after()).
+ * Tried solving this by always NULL-ing context's menu when setting wm/win/etc.,
+ * but it broke popups refreshing (see T47632),
+ * so for now just handling this specific case here. */
CTX_wm_menu_set(C, NULL);
ED_editors_exit(G_MAIN, true);
@@ -737,12 +740,18 @@ static bool wm_app_template_has_userpref(const char *app_template)
* Called on startup, (context entirely filled with NULLs)
* or called for 'New File' both startup.blend and userpref.blend are checked.
*
- * \param use_factory_settings: Ignore on-disk startup file, use bundled ``datatoc_startup_blend`` instead.
+ * \param use_factory_settings:
+ * Ignore on-disk startup file, use bundled ``datatoc_startup_blend`` instead.
* Used for "Restore Factory Settings".
+ *
* \param use_userdef: Load factory settings as well as startup file.
* Disabled for "File New" we don't want to reload preferences.
- * \param filepath_startup_override: Optional path pointing to an alternative blend file (may be NULL).
- * \param app_template_override: Template to use instead of the template defined in user-preferences.
+ *
+ * \param filepath_startup_override:
+ * Optional path pointing to an alternative blend file (may be NULL).
+ *
+ * \param app_template_override:
+ * Template to use instead of the template defined in user-preferences.
* When not-null, this is written into the user preferences.
*/
void wm_homefile_read(bContext *C,
@@ -762,9 +771,11 @@ void wm_homefile_read(bContext *C,
char filepath_startup[FILE_MAX];
char filepath_userdef[FILE_MAX];
- /* When 'app_template' is set: '{BLENDER_USER_CONFIG}/{app_template}' */
+ /* When 'app_template' is set:
+ * '{BLENDER_USER_CONFIG}/{app_template}' */
char app_template_system[FILE_MAX];
- /* When 'app_template' is set: '{BLENDER_SYSTEM_SCRIPTS}/startup/bl_app_templates_system/{app_template}' */
+ /* When 'app_template' is set:
+ * '{BLENDER_SYSTEM_SCRIPTS}/startup/bl_app_templates_system/{app_template}' */
char app_template_config[FILE_MAX];
/* Indicates whether user preferences were really load from memory.
@@ -779,7 +790,8 @@ void wm_homefile_read(bContext *C,
bool read_userdef_from_memory = false;
eBLOReadSkip skip_flags = use_userdef ? 0 : BLO_READ_SKIP_USERDEF;
- /* True if we load startup.blend from memory or use app-template startup.blend which the user hasn't saved. */
+ /* True if we load startup.blend from memory
+ * or use app-template startup.blend which the user hasn't saved. */
bool is_factory_startup = true;
/* options exclude eachother */
@@ -998,8 +1010,9 @@ void wm_homefile_read(bContext *C,
BLI_strncpy(U.app_template, app_template_override, sizeof(U.app_template));
}
- /* prevent buggy files that had G_FILE_RELATIVE_REMAP written out by mistake. Screws up autosaves otherwise
- * can remove this eventually, only in a 2.53 and older, now its not written */
+ /* Prevent buggy files that had G_FILE_RELATIVE_REMAP written out by mistake.
+ * Screws up autosaves otherwise can remove this eventually,
+ * only in a 2.53 and older, now its not written. */
G.fileflags &= ~G_FILE_RELATIVE_REMAP;
bmain = CTX_data_main(C);
@@ -1014,8 +1027,8 @@ void wm_homefile_read(bContext *C,
wm_window_match_do(C, &wmbase, &bmain->wm, &bmain->wm);
if (use_factory_settings) {
- /* Clear keymaps because the current default keymap may have been initialized from user preferences,
- * which have been reset. */
+ /* Clear keymaps because the current default keymap may have been initialized
+ * from user preferences, which have been reset. */
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
if (wm->defaultconf) {
wm->defaultconf->flag &= ~KEYCONF_INIT_DEFAULT;
@@ -1210,6 +1223,7 @@ static ImBuf *blend_file_thumb(const bContext *C,
if (scene->camera) {
ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene,
+ NULL,
OB_SOLID,
scene->camera,
BLEN_THUMB_SIZE * 2,
@@ -1322,12 +1336,14 @@ static bool wm_file_write(bContext *C, const char *filepath, int fileflags, Repo
}
}
- /* Call pre-save callbacks befores writing preview, that way you can generate custom file thumbnail... */
+ /* Call pre-save callbacks befores writing preview,
+ * that way you can generate custom file thumbnail. */
BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_PRE);
/* blend file thumbnail */
- /* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */
- /* Main now can store a .blend thumbnail, useful for background mode or thumbnail customization. */
+ /* Save before exit_editmode, otherwise derivedmeshes for shared data corrupt T27765. */
+ /* Main now can store a '.blend' thumbnail, useful for background mode
+ * or thumbnail customization. */
main_thumb = thumb = bmain->blen_thumb;
if ((U.flag & USER_SAVE_PREVIEWS) && BLI_thread_is_main()) {
ibuf_thumb = blend_file_thumb(C, CTX_data_scene(C), CTX_wm_screen(C), &thumb);
@@ -1409,10 +1425,10 @@ void wm_autosave_location(char *filepath)
if (G_MAIN && G.relbase_valid) {
const char *basename = BLI_path_basename(BKE_main_blendfile_path_from_global());
int len = strlen(basename) - 6;
- BLI_snprintf(path, sizeof(path), "%.*s (autosave).blend", len, basename);
+ BLI_snprintf(path, sizeof(path), "%.*s_%d_autosave.blend", len, basename, pid);
}
else {
- BLI_snprintf(path, sizeof(path), "%d (autosave).blend", pid);
+ BLI_snprintf(path, sizeof(path), "%d_autosave.blend", pid);
}
#ifdef WIN32
@@ -1831,22 +1847,15 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int wm_homefile_read_invoke(bContext *C,
- wmOperator *UNUSED(op),
- const wmEvent *UNUSED(event))
+static int wm_homefile_read_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- /* Draw menu which includes default startup and application templates. */
- uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("New File"), ICON_FILE_NEW);
- uiLayout *layout = UI_popup_menu_layout(pup);
-
- MenuType *mt = WM_menutype_find("TOPBAR_MT_file_new", false);
- if (mt) {
- UI_menutype_draw(C, mt, layout);
+ wmWindowManager *wm = CTX_wm_manager(C);
+ if (U.uiflag & USER_SAVE_PROMPT && !wm->file_saved) {
+ return WM_operator_confirm_message(C, op, "Changes in current file will be lost. Continue?");
+ }
+ else {
+ return wm_homefile_read_exec(C, op);
}
-
- UI_popup_menu_end(C, pup);
-
- return OPERATOR_INTERFACE;
}
void WM_OT_read_homefile(wmOperatorType *ot)
@@ -2409,8 +2418,9 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *U
save_set_compress(op);
save_set_filepath(C, op);
- /* if we're saving for the first time and prefer relative paths - any existing paths will be absolute,
- * enable the option to remap paths to avoid confusion [#37240] */
+ /* if we're saving for the first time and prefer relative paths -
+ * any existing paths will be absolute,
+ * enable the option to remap paths to avoid confusion T37240. */
if ((G.relbase_valid == false) && (U.flag & USER_RELPATHS)) {
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "relative_remap");
if (!RNA_property_is_set(op->ptr, prop)) {
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 14c032e6ffa..0cb3e5e3088 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -152,7 +152,9 @@ typedef struct WMLinkAppendData {
LinkNodePair items;
int num_libraries;
int num_items;
- int flag; /* Combines eFileSel_Params_Flag from DNA_space_types.h and BLO_LibLinkFlags from BLO_readfile.h */
+ /** Combines #eFileSel_Params_Flag from DNA_space_types.h and
+ * BLO_LibLinkFlags from BLO_readfile.h */
+ int flag;
/* Internal 'private' data */
MemArena *memarena;
@@ -511,10 +513,11 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
/* TODO(sergey): Use proper flag for tagging here. */
/* TODO (dalai): Temporary solution!
- * Ideally we only need to tag the new objects themselves, not the scene. This way we'll avoid flush of
- * collection properties to all objects and limit update to the particular object only.
- * But afraid first we need to change collection evaluation in DEG according to depsgraph manifesto.
- */
+ * Ideally we only need to tag the new objects themselves, not the scene.
+ * This way we'll avoid flush of collection properties
+ * to all objects and limit update to the particular object only.
+ * But afraid first we need to change collection evaluation in DEG
+ * according to depsgraph manifesto. */
DEG_id_tag_update(&scene->id, 0);
/* recreate dependency graph to include new objects */
@@ -662,7 +665,8 @@ static void lib_relocate_do(Main *bmain,
const short idcode = id ? GS(id->name) : 0;
if (!id || !BKE_idcode_is_linkable(idcode)) {
- /* No need to reload non-linkable datatypes, those will get relinked with their 'users ID'. */
+ /* No need to reload non-linkable datatypes,
+ * those will get relinked with their 'users ID'. */
continue;
}
@@ -719,7 +723,8 @@ static void lib_relocate_do(Main *bmain,
BLI_assert(old_id);
if (do_reload) {
- /* Since we asked for placeholders in case of missing IDs, we expect to always get a valid one. */
+ /* Since we asked for placeholders in case of missing IDs,
+ * we expect to always get a valid one. */
BLI_assert(new_id);
}
if (new_id) {
@@ -747,9 +752,10 @@ static void lib_relocate_do(Main *bmain,
}
if (old_id->us > 0 && new_id && old_id->lib == new_id->lib) {
- /* Note that this *should* not happen - but better be safe than sorry in this area, at least until we are
- * 100% sure this cannot ever happen.
- * Also, we can safely assume names were unique so far, so just replacing '.' by '~' should work,
+ /* Note that this *should* not happen - but better be safe than sorry in this area,
+ * at least until we are 100% sure this cannot ever happen.
+ * Also, we can safely assume names were unique so far,
+ * so just replacing '.' by '~' should work,
* but this does not totally rules out the possibility of name collision. */
size_t len = strlen(old_id->name);
size_t dot_pos;
@@ -800,8 +806,8 @@ static void lib_relocate_do(Main *bmain,
}
}
- /* Some datablocks can get reloaded/replaced 'silently' because they are not linkable (shape keys e.g.),
- * so we need another loop here to clear old ones if possible. */
+ /* Some datablocks can get reloaded/replaced 'silently' because they are not linkable
+ * (shape keys e.g.), so we need another loop here to clear old ones if possible. */
lba_idx = set_listbasepointers(bmain, lbarray);
while (lba_idx--) {
ID *id, *id_next;
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index b264f6a570d..b12bb89ea9f 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -165,14 +165,22 @@ int wm_gesture_evaluate(wmGesture *gesture)
#if 0
/* debug */
- if (val == 1) printf("tweak north\n");
- if (val == 2) printf("tweak north-east\n");
- if (val == 3) printf("tweak east\n");
- if (val == 4) printf("tweak south-east\n");
- if (val == 5) printf("tweak south\n");
- if (val == 6) printf("tweak south-west\n");
- if (val == 7) printf("tweak west\n");
- if (val == 8) printf("tweak north-west\n");
+ if (val == 1)
+ printf("tweak north\n");
+ if (val == 2)
+ printf("tweak north-east\n");
+ if (val == 3)
+ printf("tweak east\n");
+ if (val == 4)
+ printf("tweak south-east\n");
+ if (val == 5)
+ printf("tweak south\n");
+ if (val == 6)
+ printf("tweak south-west\n");
+ if (val == 7)
+ printf("tweak west\n");
+ if (val == 8)
+ printf("tweak north-west\n");
#endif
return val;
}
@@ -247,7 +255,8 @@ static void wm_gesture_draw_rect(wmGesture *gt)
immUnbindProgram();
- // wm_gesture_draw_line(gt); // draws a diagonal line in the lined box to test wm_gesture_draw_line
+ /* draws a diagonal line in the lined box to test wm_gesture_draw_line */
+ // wm_gesture_draw_line(gt);
}
static void wm_gesture_draw_circle(wmGesture *gt)
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index 254ced02b26..9161c97374c 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -267,7 +267,8 @@ void WM_gesture_box_cancel(bContext *C, wmOperator *op)
/** \name Circle Gesture
*
* Currently only used for selection or modal paint stuff,
- * calls ``exec`` while hold mouse, exits on release (with no difference between cancel and confirm).
+ * calls #wmOperator.exec while hold mouse, exits on release
+ * (with no difference between cancel and confirm).
*
* \{ */
@@ -286,7 +287,8 @@ int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
gesture->wait_for_input = wait_for_input;
- /* Starting with the mode starts immediately, like having 'wait_for_input' disabled (some tools use this). */
+ /* Starting with the mode starts immediately,
+ * like having 'wait_for_input' disabled (some tools use this). */
if (gesture->wait_for_input == false) {
gesture->is_active = true;
gesture_circle_apply(C, op);
@@ -314,8 +316,9 @@ static void gesture_circle_apply(bContext *C, wmOperator *op)
RNA_int_set(op->ptr, "y", rect->ymin);
RNA_int_set(op->ptr, "radius", rect->xmax);
- /* When 'wait_for_input' is false, use properties to get the selection state.
- * typically tool settings. This is done so executing as a mode can select & de-select, see: T58594. */
+ /* When 'wait_for_input' is false,
+ * use properties to get the selection state (typically tool settings).
+ * This is done so executing as a mode can select & de-select, see: T58594. */
if (gesture->wait_for_input) {
gesture_modal_state_to_operator(op, gesture->modal_state);
}
@@ -449,7 +452,6 @@ void WM_OT_circle_gesture(wmOperatorType *ot)
/* properties */
WM_operator_properties_gesture_circle(ot);
-
}
#endif
@@ -477,7 +479,8 @@ static void gesture_tweak_modal(bContext *C, const wmEvent *event)
wmEvent tevent;
wm_event_init_from_window(window, &tevent);
- /* We want to get coord from start of drag, not from point where it becomes a tweak event, see T40549 */
+ /* We want to get coord from start of drag,
+ * not from point where it becomes a tweak event, see T40549. */
tevent.x = rect->xmin + gesture->winrct.xmin;
tevent.y = rect->ymin + gesture->winrct.ymin;
if (gesture->event_type == LEFTMOUSE) {
@@ -726,8 +729,7 @@ const int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C),
static int gesture_lasso_exec(bContext *C, wmOperator *op)
{
- RNA_BEGIN (op->ptr, itemptr, "path")
- {
+ RNA_BEGIN (op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index ad3cc50ea13..97ba9190351 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -237,7 +237,8 @@ void WM_init(bContext *C, int argc, const char **argv)
BLF_init();
BLT_lang_init();
- /* Must call first before doing any .blend file reading, since versionning code may create new IDs... See T57066. */
+ /* Must call first before doing any '.blend' file reading,
+ * since versionning code may create new IDs... See T57066. */
BLT_lang_set(NULL);
/* Init icons before reading .blend files for preview icons, which can
@@ -408,7 +409,8 @@ static int wm_exit_handler(bContext *C, const wmEvent *event, void *userdata)
}
/**
- * Cause a delayed #WM_exit() call to avoid leaking memory when trying to exit from within operators.
+ * Cause a delayed #WM_exit()
+ * call to avoid leaking memory when trying to exit from within operators.
*/
void wm_exit_schedule_delayed(const bContext *C)
{
@@ -417,7 +419,8 @@ void wm_exit_schedule_delayed(const bContext *C)
wmWindow *win = CTX_wm_window(C);
- /* Use modal UI handler for now. Could add separate WM handlers or so, but probably not worth it. */
+ /* Use modal UI handler for now.
+ * Could add separate WM handlers or so, but probably not worth it. */
WM_event_add_ui_handler(C, &win->modalhandlers, wm_exit_handler, NULL, NULL, 0);
WM_event_add_mousemove(C); /* ensure handler actually gets called */
}
@@ -530,7 +533,8 @@ void WM_exit_ext(bContext *C, const bool do_python)
ED_gpencil_anim_copybuf_free();
ED_gpencil_strokes_copybuf_free();
- /* free gizmo-maps after freeing blender, so no deleted data get accessed during cleaning up of areas */
+ /* free gizmo-maps after freeing blender,
+ * so no deleted data get accessed during cleaning up of areas. */
wm_gizmomaptypes_free();
wm_gizmogrouptype_free();
wm_gizmotype_free();
@@ -562,9 +566,9 @@ void WM_exit_ext(bContext *C, const bool do_python)
/* before BKE_blender_free so py's gc happens while library still exists */
/* needed at least for a rare sigsegv that can happen in pydrivers */
- /* Update for blender 2.5, move after BKE_blender_free because blender now holds references to PyObject's
- * so decref'ing them after python ends causes bad problems every time
- * the pyDriver bug can be fixed if it happens again we can deal with it then */
+ /* Update for blender 2.5, move after BKE_blender_free because Blender now holds references to
+ * PyObject's so decref'ing them after python ends causes bad problems every time
+ * the py-driver bug can be fixed if it happens again we can deal with it then. */
BPY_python_end();
}
#else
@@ -588,8 +592,8 @@ void WM_exit_ext(bContext *C, const bool do_python)
BLI_threadapi_exit();
- /* No need to call this early, rather do it late so that other pieces of Blender using sound may exit cleanly,
- * see also T50676. */
+ /* No need to call this early, rather do it late so that other
+ * pieces of Blender using sound may exit cleanly, see also T50676. */
BKE_sound_exit();
CLG_exit();
@@ -610,7 +614,8 @@ void WM_exit_ext(bContext *C, const bool do_python)
/**
* \brief Main exit function to close Blender ordinarily.
- * \note Use #wm_exit_schedule_delayed() to close Blender from an operator. Might leak memory otherwise.
+ * \note Use #wm_exit_schedule_delayed() to close Blender from an operator.
+ * Might leak memory otherwise.
*/
void WM_exit(bContext *C)
{
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 6ce9dd70574..a63592f7b60 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -71,27 +71,28 @@
struct wmJob {
struct wmJob *next, *prev;
- /* job originating from, keep track of this when deleting windows */
+ /** Job originating from, keep track of this when deleting windows */
wmWindow *win;
- /* should store entire own context, for start, update, free */
+ /** Should store entire own context, for start, update, free */
void *customdata;
- /* to prevent cpu overhead, use this one which only gets called when job really starts, not in thread */
+ /** To prevent cpu overhead,
+ * use this one which only gets called when job really starts, not in thread */
void (*initjob)(void *);
- /* this runs inside thread, and does full job */
+ /** This runs inside thread, and does full job */
void (*startjob)(void *, short *stop, short *do_update, float *progress);
- /* update gets called if thread defines so, and max once per timerstep */
- /* it runs outside thread, blocking blender, no drawing! */
+ /** Update gets called if thread defines so, and max once per timerstep
+ * it runs outside thread, blocking blender, no drawing! */
void (*update)(void *);
- /* free entire customdata, doesn't run in thread */
+ /** Free entire customdata, doesn't run in thread */
void (*free)(void *);
- /* gets called when job is stopped, not in thread */
+ /** Gets called when job is stopped, not in thread */
void (*endjob)(void *);
- /* running jobs each have own timer */
+ /** Running jobs each have own timer */
double timestep;
wmTimer *wt;
- /* the notifier event timers should send */
+ /** The notifier event timers should send */
unsigned int note, endnote;
/* internal */
@@ -100,19 +101,19 @@ struct wmJob {
short suspended, running, ready, do_update, stop, job_type;
float progress;
- /* for display in header, identification */
+ /** For display in header, identification */
char name[128];
- /* once running, we store this separately */
+ /** Once running, we store this separately */
void *run_customdata;
void (*run_free)(void *);
- /* we use BLI_threads api, but per job only 1 thread runs */
+ /** We use BLI_threads api, but per job only 1 thread runs */
ListBase threads;
double start_time;
- /* ticket mutex for main thread locking while some job accesses
+ /** Ticket mutex for main thread locking while some job accesses
* data that the main thread might modify at the same time */
TicketMutex *main_thread_mutex;
};
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 3feae3d7dfc..bae9a5de1e6 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -39,6 +39,8 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLF_api.h"
+
#include "BKE_context.h"
#include "BKE_idprop.h"
#include "BKE_global.h"
@@ -61,8 +63,11 @@ struct wmKeyMapItemFind_Params {
void *user_data;
};
-/******************************* Keymap Item **********************************
- * Item in a keymap, that maps from an event to an operator or modal map item */
+/* -------------------------------------------------------------------- */
+/** \name Keymap Item
+ *
+ * Item in a keymap, that maps from an event to an operator or modal map item.
+ * \{ */
static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi)
{
@@ -104,7 +109,8 @@ static void wm_keymap_item_properties_set(wmKeyMapItem *kmi)
}
/**
- * Similar to #wm_keymap_item_properties_set but checks for the wmOperatorType having changed, see [#38042]
+ * Similar to #wm_keymap_item_properties_set
+ * but checks for the #wmOperatorType having changed, see T38042.
*/
static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
{
@@ -139,7 +145,7 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
}
}
-static void wm_keyconfig_properties_update_ot(ListBase *km_lb)
+static void wm_keymap_item_properties_update_ot_from_list(ListBase *km_lb)
{
wmKeyMap *km;
wmKeyMapItem *kmi;
@@ -178,7 +184,7 @@ static bool wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b)
}
/* properties can be NULL, otherwise the arg passed is used and ownership is given to the kmi */
-void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties)
+void WM_keymap_item_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties)
{
if (LIKELY(kmi->ptr)) {
WM_operator_properties_free(kmi->ptr);
@@ -192,7 +198,7 @@ void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties
wm_keymap_item_properties_set(kmi);
}
-int WM_keymap_map_type_get(wmKeyMapItem *kmi)
+int WM_keymap_item_map_type_get(const wmKeyMapItem *kmi)
{
if (ISTIMER(kmi->type)) {
return KMI_TYPE_TIMER;
@@ -218,8 +224,13 @@ int WM_keymap_map_type_get(wmKeyMapItem *kmi)
return KMI_TYPE_KEYBOARD;
}
-/**************************** Keymap Diff Item *********************************
- * Item in a diff keymap, used for saving diff of keymaps in user preferences */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Keymap Diff Item
+ *
+ * Item in a diff keymap, used for saving diff of keymaps in user preferences.
+ * \{ */
static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi)
{
@@ -248,9 +259,15 @@ static void wm_keymap_diff_item_free(wmKeyMapDiffItem *kmdi)
}
}
-/***************************** Key Configuration ******************************
- * List of keymaps for all editors, modes, ... . There is a builtin default key
- * configuration, a user key configuration, and other preset configurations. */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Key Configuration
+ *
+ * List of keymaps for all editors, modes, etc.
+ * There is a builtin default key configuration,
+ * a user key configuration, and other preset configurations.
+ * \{ */
wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname, bool user_defined)
{
@@ -348,8 +365,13 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
WM_keyconfig_update(wm);
}
-/********************************** Keymap *************************************
- * List of keymap items for one editor, mode, modal operator, ... */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Keymap
+ *
+ * List of keymap items for one editor, mode, modal operator.
+ * \{ */
static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid)
{
@@ -553,11 +575,16 @@ bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
}
}
-/************************** Keymap Diff and Patch ****************************
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Keymap Diff and Patch
+ *
* Rather than saving the entire keymap for user preferences, we only save a
* diff so that changes in the defaults get synced. This system is not perfect
* but works better than overriding the keymap entirely when only few items
- * are changed. */
+ * are changed.
+ * \{ */
static void wm_keymap_addon_add(wmKeyMap *keymap, wmKeyMap *addonmap)
{
@@ -665,16 +692,21 @@ static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km)
/* We seek only for exact copy here! See T42137. */
kmi_add = wm_keymap_find_item_equals(km, kmdi->add_item);
- /* If kmi_add is same as kmi_remove (can happen in some cases, typically when we got kmi_remove
- * from wm_keymap_find_item_equals_result()), no need to add or remove anything, see T45579. */
- /* Note: This typically happens when we apply user-defined keymap diff to a base one that was exported
- * with that customized keymap already. In that case:
- * - wm_keymap_find_item_equals(km, kmdi->remove_item) finds nothing (because actual shortcut of
- * current base does not match kmdi->remove_item any more).
- * - wm_keymap_find_item_equals_result(km, kmdi->remove_item) finds the current kmi from
- * base keymap (because it does exactly the same thing).
- * - wm_keymap_find_item_equals(km, kmdi->add_item) finds the same kmi, since base keymap was
- * exported with that user-defined shortcut already!
+ /** If kmi_add is same as kmi_remove (can happen in some cases,
+ * typically when we got kmi_remove from #wm_keymap_find_item_equals_result()),
+ * no need to add or remove anything, see T45579. */
+
+ /**
+ * \note This typically happens when we apply user-defined keymap diff to a base one that
+ * was exported with that customized keymap already. In that case:
+ *
+ * - wm_keymap_find_item_equals(km, kmdi->remove_item) finds nothing
+ * (because actual shortcut of current base does not match kmdi->remove_item any more).
+ * - wm_keymap_find_item_equals_result(km, kmdi->remove_item) finds the current kmi from
+ * base keymap (because it does exactly the same thing).
+ * - wm_keymap_find_item_equals(km, kmdi->add_item) finds the same kmi,
+ * since base keymap was exported with that user-defined shortcut already!
+ *
* Maybe we should rather keep user-defined keymaps specific to a given base one? */
if (kmi_add != NULL && kmi_add == kmi_remove) {
kmi_remove = NULL;
@@ -818,11 +850,16 @@ static void wm_keymap_diff_update(ListBase *lb,
}
}
-/* ****************** storage in WM ************ */
+/** \} */
-/* name id's are for storing general or multiple keymaps,
- * space/region ids are same as DNA_space_types.h */
-/* gets freed in wm.c */
+/* -------------------------------------------------------------------- */
+/** \name Storage in WM
+ *
+ * Name id's are for storing general or multiple keymaps.
+ *
+ * - Space/region ids are same as DNA_space_types.h
+ * - Gets freed in wm.c
+ * \{ */
wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid)
{
@@ -888,9 +925,14 @@ wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const bContext *C,
return WM_keymap_list_find_spaceid_or_empty(&wm->userconf->keymaps, idname, spaceid, regionid);
}
-/* ****************** modal keymaps ************ */
+/** \} */
-/* modal maps get linked to a running operator, and filter the keys before sending to modal() callback */
+/* -------------------------------------------------------------------- */
+/** \name Modal Keymaps
+ *
+ * Modal key-maps get linked to a running operator,
+ * and filter the keys before sending to #wmOperatorType.modal callback.
+ * \{ */
wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf,
const char *idname,
@@ -1039,10 +1081,98 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km)
}
}
-/* ***************** get string from key events **************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Text from Key Events
+ * \{ */
+
+static const char *key_event_icon_or_text(const int font_id, const char *text, const char *icon)
+{
+ BLI_assert(icon == NULL || (BLI_strlen_utf8(icon) == 1));
+ return (icon && BLF_has_glyph(font_id, BLI_str_utf8_as_unicode(icon))) ? icon : text;
+}
const char *WM_key_event_string(const short type, const bool compact)
{
+ if (compact) {
+ /* String storing a single unicode character or NULL. */
+ const char *icon_glyph = NULL;
+ int font_id = BLF_default();
+ const enum {
+ UNIX,
+ MACOS,
+ MSWIN,
+ } platform =
+
+#if defined(__APPLE__)
+ MACOS
+#elif defined(_WIN32)
+ MSWIN
+#else
+ UNIX
+#endif
+ ;
+
+ switch (type) {
+ case LEFTSHIFTKEY:
+ case RIGHTSHIFTKEY: {
+ if (platform == MACOS) {
+ icon_glyph = "\xe2\x87\xa7";
+ }
+ return key_event_icon_or_text(font_id, IFACE_("Shift"), icon_glyph);
+ }
+ case LEFTCTRLKEY:
+ case RIGHTCTRLKEY:
+ if (platform == MACOS) {
+ return "^";
+ }
+ return IFACE_("Ctrl");
+ case LEFTALTKEY:
+ case RIGHTALTKEY: {
+ if (platform == MACOS) {
+ icon_glyph = "\xe2\x8c\xa5";
+ }
+ return key_event_icon_or_text(font_id, IFACE_("Alt"), icon_glyph);
+ }
+ case OSKEY: {
+ if (platform == MACOS) {
+ return key_event_icon_or_text(font_id, IFACE_("Cmd"), "\xe2\x8c\x98");
+ }
+ else if (platform == MSWIN) {
+ return key_event_icon_or_text(font_id, IFACE_("Win"), "\xe2\x8a\x9e");
+ }
+ return IFACE_("OSkey");
+ } break;
+ case TABKEY: {
+ if (platform == MACOS) {
+ icon_glyph = "\xe2\x86\xb9";
+ }
+ return key_event_icon_or_text(font_id, IFACE_("Tab"), icon_glyph);
+ }
+ case BACKSPACEKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Bksp"), "\xe2\x8c\xab");
+ case ESCKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Esc"), NULL /* "\xe2\x8e\x8b" */);
+ case RETKEY: {
+ if (platform == MACOS) {
+ icon_glyph = "\xe2\x8f\x8e";
+ }
+ return key_event_icon_or_text(font_id, IFACE_("Enter"), icon_glyph);
+ }
+ case SPACEKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Space"), NULL /* "\xe2\x90\xa3" */);
+ case LEFTARROWKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Left"), "\xe2\x86\x90");
+ case UPARROWKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Up"), "\xe2\x86\x91");
+ case RIGHTARROWKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Right"), "\xe2\x86\x92");
+ case DOWNARROWKEY:
+ return key_event_icon_or_text(font_id, IFACE_("Down"), "\xe2\x86\x93");
+ }
+ }
+
const EnumPropertyItem *it;
const int i = RNA_enum_from_value(rna_enum_event_type_items, (int)type);
@@ -1051,7 +1181,8 @@ const char *WM_key_event_string(const short type, const bool compact)
}
it = &rna_enum_event_type_items[i];
- /* We first try enum items' description (abused as shortname here), and fall back to usual name if empty. */
+ /* We first try enum items' description (abused as shortname here),
+ * and fall back to usual name if empty. */
if (compact && it->description[0]) {
/* XXX No context for enum descriptions... In practice shall not be an issue though. */
return IFACE_(it->description);
@@ -1089,22 +1220,22 @@ int WM_keymap_item_raw_to_string(const short shift,
else {
if (shift) {
ADD_SEP;
- p += BLI_strcpy_rlen(p, IFACE_("Shift"));
+ p += BLI_strcpy_rlen(p, WM_key_event_string(LEFTSHIFTKEY, true));
}
if (ctrl) {
ADD_SEP;
- p += BLI_strcpy_rlen(p, IFACE_("Ctrl"));
+ p += BLI_strcpy_rlen(p, WM_key_event_string(LEFTCTRLKEY, true));
}
if (alt) {
ADD_SEP;
- p += BLI_strcpy_rlen(p, IFACE_("Alt"));
+ p += BLI_strcpy_rlen(p, WM_key_event_string(LEFTALTKEY, true));
}
if (oskey) {
ADD_SEP;
- p += BLI_strcpy_rlen(p, IFACE_("Cmd"));
+ p += BLI_strcpy_rlen(p, WM_key_event_string(OSKEY, true));
}
}
@@ -1121,7 +1252,8 @@ int WM_keymap_item_raw_to_string(const short shift,
p += BLI_strcpy_rlen(p, WM_key_event_string(type, compact));
}
- /* We assume size of buf is enough to always store any possible shortcut, but let's add a debug check about it! */
+ /* We assume size of buf is enough to always store any possible shortcut,
+ * but let's add a debug check about it! */
BLI_assert(p - buf < sizeof(buf));
/* We need utf8 here, otherwise we may 'cut' some unicode chars like arrows... */
@@ -1209,6 +1341,8 @@ char *WM_modalkeymap_operator_items_to_string_buf(wmOperatorType *ot,
return ret;
}
+/** \} */
+
static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap,
const char *opname,
IDProperty *properties,
@@ -1409,10 +1543,10 @@ static wmKeyMapItem *wm_keymap_item_find(const bContext *C,
{
wmKeyMapItem *found;
- /* XXX Hack! Macro operators in menu entry have their whole props defined, which is not the case for
- * relevant keymap entries. Could be good to check and harmonize this, but for now always
- * compare non-strict in this case.
- */
+ /* XXX Hack! Macro operators in menu entry have their whole props defined,
+ * which is not the case for relevant keymap entries.
+ * Could be good to check and harmonize this,
+ * but for now always compare non-strict in this case. */
wmOperatorType *ot = WM_operatortype_find(opname, true);
if (ot) {
is_strict = is_strict && ((ot->flag & OPTYPE_MACRO) == 0);
@@ -1438,7 +1572,8 @@ static wmKeyMapItem *wm_keymap_item_find(const bContext *C,
RNA_pointer_create(NULL, ot->srna, properties_temp, &opptr);
if (RNA_property_is_set(&opptr, ot->prop)) {
- /* for operator that has enum menu, unset it so its value does not affect comparison result */
+ /* For operator that has enum menu,
+ * unset it so its value does not affect comparison result. */
RNA_property_unset(&opptr, ot->prop);
found = wm_keymap_item_find_props(
@@ -1538,7 +1673,8 @@ static bool kmi_filter_is_visible_type_mask(const wmKeyMap *km,
}
/**
- * \param include_mask, exclude_mask: Event types to include/exclude when looking up keys (#eEventType_Mask).
+ * \param include_mask, exclude_mask:
+ * Event types to include/exclude when looking up keys (#eEventType_Mask).
*/
wmKeyMapItem *WM_key_event_operator(const bContext *C,
const char *opname,
@@ -1634,10 +1770,15 @@ bool WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
return 1;
}
-/************************* Update Final Configuration *************************
- * On load or other changes, the final user key configuration is rebuilt from
- * the preset, addon and user preferences keymaps. We also test if the final
- * configuration changed and write the changes to the user preferences. */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Update Final Configuration
+ *
+ * On load or other changes, the final user key configuration is rebuilt from the preset,
+ * add-on and user preferences keymaps. We also test if the final configuration changed and write
+ * the changes to the user preferences.
+ * \{ */
/* so operator removal can trigger update */
enum {
@@ -1727,11 +1868,11 @@ void WM_keyconfig_update(wmWindowManager *wm)
int i;
for (i = 0; keymaps_lb[i]; i++) {
- wm_keyconfig_properties_update_ot(keymaps_lb[i]);
+ wm_keymap_item_properties_update_ot_from_list(keymaps_lb[i]);
}
for (kc = wm->keyconfigs.first; kc; kc = kc->next) {
- wm_keyconfig_properties_update_ot(&kc->keymaps);
+ wm_keymap_item_properties_update_ot_from_list(&kc->keymaps);
}
wm_keymap_update_flag &= ~WM_KEYMAP_UPDATE_OPERATORTYPE;
@@ -1807,10 +1948,14 @@ void WM_keyconfig_update(wmWindowManager *wm)
}
}
-/********************************* Event Handling *****************************
- * Handlers have pointers to the keymap in the default configuration. During
- * event handling this function is called to get the keymap from the final
- * configuration. */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Event Handling
+ *
+ * Handlers have pointers to the keymap in the default configuration.
+ * During event handling this function is called to get the keymap from the final configuration.
+ * \{ */
wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
{
@@ -1831,10 +1976,15 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
return keymap;
}
-/******************************* Keymap Editor ********************************
- * In the keymap editor the user key configuration is edited. */
+/** \} */
-void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapItem *kmi)
+/* -------------------------------------------------------------------- */
+/** \name Keymap Editor
+ *
+ * In the keymap editor the user key configuration is edited.
+ * \{ */
+
+void WM_keymap_item_restore_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapItem *kmi)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmKeyMap *defaultmap, *addonmap;
@@ -1861,7 +2011,7 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt
/* restore to original */
if (!STREQ(orig->idname, kmi->idname)) {
BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname));
- WM_keymap_properties_reset(kmi, NULL);
+ WM_keymap_item_properties_reset(kmi, NULL);
}
if (orig->properties) {
@@ -1930,3 +2080,5 @@ const char *WM_bool_as_string(bool test)
{
return test ? IFACE_("ON") : IFACE_("OFF");
}
+
+/** \} */
diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c
index 37a7ed4d751..626e9e88845 100644
--- a/source/blender/windowmanager/intern/wm_keymap_utils.c
+++ b/source/blender/windowmanager/intern/wm_keymap_utils.c
@@ -295,9 +295,6 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
case CTX_MODE_SCULPT:
km = WM_keymap_find_all(C, "Sculpt", 0, 0);
break;
- case CTX_MODE_EDIT_MESH:
- km = WM_keymap_find_all(C, "UV Sculpt", 0, 0);
- break;
default:
break;
}
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 39594a66e4e..ece57f5a63b 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -449,6 +449,13 @@ void WM_operator_properties_mouse_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+ prop = RNA_def_boolean(ot->srna,
+ "deselect_all",
+ false,
+ "Deselect On Nothing",
+ "Deselect all when nothing under the cursor");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/**
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
index 63caf6126cc..3585cffc615 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -236,9 +236,11 @@ void WM_operatortype_props_advanced_begin(wmOperatorType *ot)
}
/**
- * Tags all operator-properties of \ot defined since the first #WM_operatortype_props_advanced_begin
- * call, or the last #WM_operatortype_props_advanced_end call, with #OP_PROP_TAG_ADVANCED.
- * Note that this is called for all operators during registration (see #wm_operatortype_append__end).
+ * Tags all operator-properties of \a ot defined since the first
+ * #WM_operatortype_props_advanced_begin call,
+ * or the last #WM_operatortype_props_advanced_end call, with #OP_PROP_TAG_ADVANCED.
+ *
+ * \note This is called for all operators during registration (see #wm_operatortype_append__end).
* So it does not need to be explicitly called in operator-type definition.
*/
void WM_operatortype_props_advanced_end(wmOperatorType *ot)
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 41cebec7e90..ec803c9bba7 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -214,7 +214,8 @@ bool WM_operator_py_idname_ok_or_report(ReportList *reports,
}
/**
- * Print a string representation of the operator, with the args that it runs so python can run it again.
+ * Print a string representation of the operator,
+ * with the args that it runs so python can run it again.
*
* When calling from an existing wmOperator, better to use simple version:
* `WM_operator_pystring(C, op);`
@@ -353,7 +354,8 @@ static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr
* - see if the pointers ID is in the context.
*/
- /* don't get from the context store since this is normally set only for the UI and not usable elsewhere */
+ /* Don't get from the context store since this is normally
+ * set only for the UI and not usable elsewhere. */
ListBase lb = CTX_data_dir_get_ex(C, false, true, true);
LinkData *link;
@@ -362,16 +364,15 @@ static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr
for (link = lb.first; link; link = link->next) {
const char *identifier = link->data;
- PointerRNA ctx_item_ptr = {{0}}; // CTX_data_pointer_get(C, identifier); // XXX, this isnt working
+ PointerRNA ctx_item_ptr = {
+ {0}}; // CTX_data_pointer_get(C, identifier); // XXX, this isnt working
if (ctx_item_ptr.type == NULL) {
continue;
}
if (ptr->id.data == ctx_item_ptr.id.data) {
- if ((ptr->data == ctx_item_ptr.data) &&
- (ptr->type == ctx_item_ptr.type))
- {
+ if ((ptr->data == ctx_item_ptr.data) && (ptr->type == ctx_item_ptr.type)) {
/* found! */
member_found = identifier;
break;
@@ -778,13 +779,14 @@ struct EnumSearchMenu {
short prv_cols, prv_rows;
};
-/* generic enum search invoke popup */
+/** Generic enum search invoke popup. */
static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg)
{
struct EnumSearchMenu *search_menu = arg;
wmWindow *win = CTX_wm_window(C);
wmOperator *op = search_menu->op;
- /* template_ID uses 4 * widget_unit for width, we use a bit more, some items may have a suffix to show */
+ /* template_ID uses 4 * widget_unit for width,
+ * we use a bit more, some items may have a suffix to show. */
const int width = search_menu->use_previews ? 5 * U.widget_unit * search_menu->prv_cols :
UI_searchbox_size_x();
const int height = search_menu->use_previews ? 5 * U.widget_unit * search_menu->prv_rows :
@@ -801,7 +803,20 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg)
BLI_assert(search_menu->use_previews ||
(search_menu->prv_cols == 0 && search_menu->prv_rows == 0));
#if 0 /* ok, this isn't so easy... */
- uiDefBut(block, UI_BTYPE_LABEL, 0, RNA_struct_ui_name(op->type->srna), 10, 10, UI_searchbox_size_x(), UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefBut(block,
+ UI_BTYPE_LABEL,
+ 0,
+ RNA_struct_ui_name(op->type->srna),
+ 10,
+ 10,
+ UI_searchbox_size_x(),
+ UI_UNIT_Y,
+ NULL,
+ 0.0,
+ 0.0,
+ 0,
+ 0,
+ "");
#endif
but = uiDefSearchButO_ptr(block,
op->type,
@@ -1143,13 +1158,14 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
WM_operator_call_ex(C, data->op, true);
/* let execute handle freeing it */
- //data->free_op = false;
- //data->op = NULL;
+ // data->free_op = false;
+ // data->op = NULL;
/* in this case, wm_operator_ui_popup_cancel wont run */
MEM_freeN(data);
- /* get context data *after* WM_operator_call_ex which might have closed the current file and changed context */
+ /* Get context data *after* WM_operator_call_ex
+ * which might have closed the current file and changed context. */
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
@@ -3331,14 +3347,16 @@ static const EnumPropertyItem preview_id_type_items[] = {
static int previews_clear_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- ListBase *lb[] = {&bmain->objects,
- &bmain->collections,
- &bmain->materials,
- &bmain->worlds,
- &bmain->lights,
- &bmain->textures,
- &bmain->images,
- NULL};
+ ListBase *lb[] = {
+ &bmain->objects,
+ &bmain->collections,
+ &bmain->materials,
+ &bmain->worlds,
+ &bmain->lights,
+ &bmain->textures,
+ &bmain->images,
+ NULL,
+ };
int i;
const int id_filters = RNA_enum_get(op->ptr, "id_type");
@@ -3349,8 +3367,14 @@ static int previews_clear_exec(bContext *C, wmOperator *op)
continue;
}
- // printf("%s: %d, %d, %d -> %d\n", id->name, GS(id->name), BKE_idcode_to_idfilter(GS(id->name)),
- // id_filters, BKE_idcode_to_idfilter(GS(id->name)) & id_filters);
+#if 0
+ printf("%s: %d, %d, %d -> %d\n",
+ id->name,
+ GS(id->name),
+ BKE_idcode_to_idfilter(GS(id->name)),
+ id_filters,
+ BKE_idcode_to_idfilter(GS(id->name)) & id_filters);
+#endif
if (!id || !(BKE_idcode_to_idfilter(GS(id->name)) & id_filters)) {
continue;
@@ -3624,9 +3648,8 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_box");
- WM_modalkeymap_assign(
- keymap,
- "VIEW3D_OT_zoom_border"); /* XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel */
+ /* XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel */
+ WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border");
WM_modalkeymap_assign(keymap, "IMAGE_OT_render_border");
WM_modalkeymap_assign(keymap, "IMAGE_OT_view_zoom_border");
WM_modalkeymap_assign(keymap, "GPENCIL_OT_select_box");
@@ -3722,7 +3745,10 @@ const EnumPropertyItem *RNA_action_itemf(bContext *C,
C, ptr, r_free, C ? (ID *)CTX_data_main(C)->actions.first : NULL, false, NULL, NULL);
}
#if 0 /* UNUSED */
-const EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
+const EnumPropertyItem *RNA_action_local_itemf(bContext *C,
+ PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop),
+ bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, true);
}
@@ -3788,7 +3814,7 @@ const EnumPropertyItem *RNA_scene_without_active_itemf(bContext *C,
ptr,
r_free,
C ? (ID *)CTX_data_main(C)->scenes.first : NULL,
- true,
+ false,
rna_id_enum_filter_single,
scene_active);
}
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 098284de0d1..844316bc925 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -1284,7 +1284,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
GHOST_GetMainDisplayDimensions(g_WS.ghost_system, &maxwinx, &maxwiny);
- //GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
+ // GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
/* initialize OpenGL immediate mode */
g_WS.gpu_context = GPU_context_create();
diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c
index 47f860e7667..874f8516caa 100644
--- a/source/blender/windowmanager/intern/wm_stereo.c
+++ b/source/blender/windowmanager/intern/wm_stereo.c
@@ -165,7 +165,7 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
soffx = 0;
}
}
- else { //RIGHT_LEFT_ID
+ else { // RIGHT_LEFT_ID
if (cross_eyed) {
soffx = 0;
}
@@ -280,7 +280,8 @@ bool WM_stereo3d_enabled(wmWindow *win, bool skip_stereo3d_check)
}
/**
- * If needed, this adjusts \a r_mouse_xy so that drawn cursor and handled mouse position are matching visually.
+ * If needed, adjust \a r_mouse_xy
+ * so that drawn cursor and handled mouse position are matching visually.
*/
void wm_stereo3d_mouse_offset_apply(wmWindow *win, int *r_mouse_xy)
{
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index a867a17f529..f429415bee9 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -169,14 +169,6 @@ void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace, const bToolKey *tke
}
}
-static void toolsystem_ref_link__refresh_image_uv_sculpt(bContext *C, Scene *scene)
-{
- PointerRNA ptr;
- RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &ptr);
- PropertyRNA *prop = RNA_struct_find_property(&ptr, "use_uv_sculpt");
- RNA_property_update(C, &ptr, prop);
-}
-
/**
* \see #toolsystem_ref_link
*/
@@ -244,28 +236,6 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
}
}
}
- else if ((tref->space_type == SPACE_IMAGE) && (tref->mode == SI_MODE_UV)) {
- /* Note that switching uv-sculpt boolean is a hack at the moment.
- * It would be best to make this either an operator or a higher level mode (like mesh-object sculpt mode). */
- const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
- const int i = RNA_enum_from_identifier(items, tref_rt->data_block);
- if (i != -1) {
- const int value = items[i].value;
- wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- if (workspace == WM_window_get_active_workspace(win)) {
- Scene *scene = WM_window_get_active_scene(win);
- ToolSettings *ts = scene->toolsettings;
- ts->uv_sculpt_tool = value;
-
- if (ts->use_uv_sculpt == false) {
- ts->use_uv_sculpt = true;
- toolsystem_ref_link__refresh_image_uv_sculpt(C, scene);
- }
- }
- }
- }
- }
else {
const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
BLI_assert(paint_mode != PAINT_MODE_INVALID);
@@ -279,6 +249,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
for (wmWindow *win = wm->windows.first; win; win = win->next) {
if (workspace == WM_window_get_active_workspace(win)) {
Scene *scene = WM_window_get_active_scene(win);
+ BKE_paint_ensure_from_paintmode(scene, paint_mode);
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
struct Brush *brush = BKE_paint_toolslots_brush_get(paint, slot_index);
if (brush == NULL) {
@@ -299,23 +270,6 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
}
}
}
- else {
- /* XXX, this part is weak, disables uv_sculpt when non uv-tool set. */
- if ((tref->space_type == SPACE_IMAGE) && (tref->mode == SI_MODE_UV)) {
- Main *bmain = CTX_data_main(C);
- wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- if (workspace == WM_window_get_active_workspace(win)) {
- Scene *scene = WM_window_get_active_scene(win);
- ToolSettings *ts = scene->toolsettings;
- if (ts->use_uv_sculpt == true) {
- ts->use_uv_sculpt = false;
- toolsystem_ref_link__refresh_image_uv_sculpt(C, scene);
- }
- }
- }
- }
- }
}
static void toolsystem_refresh_ref(bContext *C, WorkSpace *workspace, bToolRef *tref)
@@ -408,10 +362,6 @@ void WM_toolsystem_ref_set_from_runtime(struct bContext *C,
STRNCPY(tref->idname, idname);
- /* BAD DESIGN WARNING: used for topbar. */
- workspace->tools_space_type = tref->space_type;
- workspace->tools_mode = tref->mode;
-
if (tref->runtime == NULL) {
tref->runtime = MEM_callocN(sizeof(*tref->runtime), __func__);
}
@@ -488,17 +438,6 @@ void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToo
}
}
}
- else if ((tref->space_type == SPACE_IMAGE) && (tref->mode == SI_MODE_UV)) {
- if (ob->mode & OB_MODE_EDIT) {
- const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
- const int i = RNA_enum_from_value(items, ts->uv_sculpt_tool);
- const EnumPropertyItem *item = &items[i];
- if (!STREQ(tref_rt->data_block, item->identifier)) {
- STRNCPY(tref_rt->data_block, item->identifier);
- SNPRINTF(tref->idname, "builtin_brush.%s", item->name);
- }
- }
- }
else {
const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
@@ -602,7 +541,8 @@ bool WM_toolsystem_key_from_context(ViewLayer *view_layer, ScrArea *sa, bToolKey
/**
* Use to update the active tool (shown in the top bar) in the least disruptive way.
*
- * This is a little involved since there may be multiple valid active tools depending on the mode and space type.
+ * This is a little involved since there may be multiple valid active tools
+ * depending on the mode and space type.
*
* Used when undoing since the active mode may have changed.
*/
@@ -614,31 +554,24 @@ void WM_toolsystem_refresh_active(bContext *C)
WorkSpace *workspace = WM_window_get_active_workspace(win);
bScreen *screen = WM_window_get_active_screen(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- int mode_other = 0;
- enum { UNSET = -1, CHANGE = 0, MATCH = 1 } mode_match = UNSET;
/* Could skip loop for modes that don't depend on space type. */
+ int space_type_mask_handled = 0;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
/* Don't change the space type of the active tool, only update it's mode. */
- if (sa->spacetype == workspace->tools_space_type) {
- const int mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype);
- if (workspace->tools_mode == mode) {
- mode_match = MATCH;
- break;
- }
- else if (mode_match == -1) {
- mode_match = CHANGE;
- mode_other = mode;
+ const int space_type_mask = (1 << sa->spacetype);
+ if ((space_type_mask & WM_TOOLSYSTEM_SPACE_MASK) &&
+ ((space_type_mask_handled & space_type_mask) == 0)) {
+ space_type_mask_handled |= space_type_mask;
+ const bToolKey tkey = {
+ .space_type = sa->spacetype,
+ .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
+ };
+ bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
+ if (tref != sa->runtime.tool) {
+ toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
}
}
}
-
- if (mode_match == CHANGE) {
- const bToolKey tkey = {
- .space_type = workspace->tools_space_type,
- .mode = mode_other,
- };
- toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
- }
}
}
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 89696082e7a..e98067d78cc 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -364,6 +364,7 @@ static void wm_block_confirm_quit_cancel(bContext *C, void *arg_block, void *UNU
}
/** Discard the file changes and quit */
+ATTR_NORETURN
static void wm_block_confirm_quit_discard(bContext *C, void *arg_block, void *UNUSED(arg))
{
wmWindow *win = CTX_wm_window(C);
@@ -624,9 +625,9 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
GHOST_SetTitle(win->ghostwin, "Blender");
}
- /* Informs GHOST of unsaved changes, to set window modified visual indicator (MAC OS X)
- * and to give hint of unsaved changes for a user warning mechanism
- * in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */
+ /* Informs GHOST of unsaved changes, to set window modified visual indicator (macOS)
+ * and to give hint of unsaved changes for a user warning mechanism in case of OS
+ * application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end). */
GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8)!wm->file_saved);
}
}
@@ -769,7 +770,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
wm_window_swap_buffers(win);
- //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified);
+ // GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified);
/* standard state vars for window */
GPU_state_init();
@@ -1271,8 +1272,9 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
GHOST_TEventDataPtr data = GHOST_GetEventData(evt);
wmWindow *win;
- /* Ghost now can call this function for life resizes, but it should return if WM didn't initialize yet.
- * Can happen on file read (especially full size window) */
+ /* Ghost now can call this function for life resizes,
+ * but it should return if WM didn't initialize yet.
+ * Can happen on file read (especially full size window). */
if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
return 1;
}
@@ -2197,7 +2199,8 @@ bool WM_window_is_fullscreen(wmWindow *win)
/**
* Some editor data may need to be synced with scene data (3D View camera and layers).
- * This function ensures data is synced for editors in visible workspaces and their visible layouts.
+ * This function ensures data is synced for editors
+ * in visible workspaces and their visible layouts.
*/
void WM_windows_scene_data_sync(const ListBase *win_lb, Scene *scene)
{
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
index 227a21726f4..73758e2d98f 100644
--- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
+++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
@@ -159,8 +159,9 @@ static void wm_msg_rna_update_by_id(struct wmMsgBus *mbus, ID *id_src, ID *id_ds
wm_msg_rna_gset_key_free(key);
}
else {
- /* note that it's not impossible this key exists, however it is very unlikely
- * since a subscriber would need to register in the middle of an undo for eg. so assert for now. */
+ /* Note that it's not impossible this key exists, however it is very unlikely
+ * since a subscriber would need to register in the middle of an undo for eg.
+ * so assert for now. */
BLI_assert(!BLI_gset_haskey(gs, key));
BLI_gset_add(gs, key);
}
diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h
index dcc92396770..b4b0bcf0149 100644
--- a/source/blender/windowmanager/wm_cursors.h
+++ b/source/blender/windowmanager/wm_cursors.h
@@ -42,7 +42,7 @@ enum {
CURSOR_COPY,
};
-//typedef struct BCursor_s BCursor;
+// typedef struct BCursor_s BCursor;
typedef struct BCursor {
char *small_bm;
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index 9a2f8bda041..049e4d44994 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -44,14 +44,15 @@ enum eWM_EventHandlerType {
WM_HANDLER_TYPE_KEYMAP,
};
+typedef bool (*EventHandlerPoll)(const ARegion *ar, const wmEvent *event);
+
typedef struct wmEventHandler {
struct wmEventHandler *next, *prev;
enum eWM_EventHandlerType type;
char flag; /* WM_HANDLER_BLOCKING, ... */
- /** Optional local and windowspace bb. */
- const rcti *bblocal, *bbwin;
+ EventHandlerPoll poll;
} wmEventHandler;
/** Run after the keymap item runs. */
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index cb269dd415a..91c1d76895d 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -308,7 +308,8 @@ enum {
/* NOTE: these values are saved in keymap files, do not change them but just add new ones */
/* Tweak events:
- * Sent as additional event with the mouse coordinates from where the initial click was placed. */
+ * Sent as additional event with the mouse coordinates
+ * from where the initial click was placed. */
/* tweak events for L M R mousebuttons */
EVT_TWEAK_L = 0x5002,
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 877d9c971a3..0f7612abb0c 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -22,18 +22,18 @@ setup_libdirs()
blender_include_dirs(
../../intern/clog
- ../../intern/guardedalloc
../../intern/glew-mx
- ../blender/blenlib
+ ../../intern/guardedalloc
../blender/blenkernel
+ ../blender/blenlib
../blender/blenloader
../blender/depsgraph
../blender/editors/include
- ../blender/makesrna
../blender/imbuf
+ ../blender/makesrna
../blender/render/extern/include
- ../blender/makesdna
../blender/gpu
+ ../blender/makesdna
../blender/windowmanager
)
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 713ebdaadec..b257564519a 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -447,8 +447,8 @@ int main(int argc,
/* TODO - U.pythondir */
#else
printf(
- "\n* WARNING * - Blender compiled without Python!\nthis is not intended for typical "
- "usage\n\n");
+ "\n* WARNING * - Blender compiled without Python!\n"
+ "this is not intended for typical usage\n\n");
#endif
CTX_py_init_set(C, 1);
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index afe9a135c79..e15a1f3e258 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -274,8 +274,7 @@ static bool parse_int_clamp(const char *str,
* that parses a comma separated list of numbers.
*/
static int *parse_int_relative_clamp_n(
- const char *str, int pos, int neg, int min, int max,
- int *r_value_len, const char **r_err_msg)
+ const char *str, int pos, int neg, int min, int max, int *r_value_len, const char **r_err_msg)
{
const char sep = ',';
int len = 1;
@@ -293,19 +292,18 @@ static int *parse_int_relative_clamp_n(
static const char *msg = "incorrect comma use";
*r_err_msg = msg;
goto fail;
-
}
else if (parse_int_relative_clamp(str, str_end, pos, neg, min, max, &values[i], r_err_msg)) {
i++;
}
else {
- goto fail; /* error message already set */
+ goto fail; /* error message already set */
}
- if (str_end) { /* next */
+ if (str_end) { /* next */
str = str_end + 1;
}
- else { /* finished */
+ else { /* finished */
break;
}
}
@@ -635,8 +633,8 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
BLI_argsPrintArgDoc(ba, "--");
- //printf("\n");
- //printf("Experimental Features:\n");
+ // printf("\n");
+ // printf("Experimental Features:\n");
/* Other options _must_ be last (anything not handled will show here) */
printf("\n");
@@ -1946,7 +1944,7 @@ void main_args_setup(bContext *C, bArgs *ba)
# define CB(a) a##_doc, a
# define CB_EX(a, b) a##_doc_##b, a
- //BLI_argsAdd(ba, pass, short_arg, long_arg, doc, cb, C);
+ // BLI_argsAdd(ba, pass, short_arg, long_arg, doc, cb, C);
/* end argument processing after -- */
BLI_argsAdd(ba, -1, "--", NULL, CB(arg_handle_arguments_end), NULL);